Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make linspace and logspace pure functions #549

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/specs/stdlib_math.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ Experimental

#### Class

Function.
Pure function.

#### Argument(s)

Expand Down Expand Up @@ -224,7 +224,7 @@ Experimental

#### Class

Function.
Pure function.

#### Argument(s)

Expand Down
34 changes: 17 additions & 17 deletions src/stdlib_math.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module stdlib_math
!!([Specification](../page/specs/stdlib_math.html#linspace-create-a-linearly-spaced-rank-one-array))
#:for k1, t1 in RC_KINDS_TYPES
#:set RName = rname("linspace_default", 1, t1, k1)
module function ${RName}$(start, end) result(res)
pure module function ${RName}$(start, end) result(res)
${t1}$, intent(in) :: start
${t1}$, intent(in) :: end

Expand All @@ -57,7 +57,7 @@ module stdlib_math

#:for k1, t1 in RC_KINDS_TYPES
#:set RName = rname("linspace_n", 1, t1, k1)
module function ${RName}$(start, end, n) result(res)
pure module function ${RName}$(start, end, n) result(res)
${t1}$, intent(in) :: start
${t1}$, intent(in) :: end
integer, intent(in) :: n
Expand All @@ -74,7 +74,7 @@ module stdlib_math
#:set RName = rname("linspace_default", 1, t1, k1)
#! The interface for INT_KINDS_TYPES cannot be combined with RC_KINDS_TYPES
#! because the output for integer types is always a real with dp.
module function ${RName}$(start, end) result(res)
pure module function ${RName}$(start, end) result(res)
${t1}$, intent(in) :: start
${t1}$, intent(in) :: end

Expand All @@ -84,7 +84,7 @@ module stdlib_math

#:for k1, t1 in INT_KINDS_TYPES
#:set RName = rname("linspace_n", 1, t1, k1)
module function ${RName}$(start, end, n) result(res)
pure module function ${RName}$(start, end, n) result(res)
${t1}$, intent(in) :: start
${t1}$, intent(in) :: end
integer, intent(in) :: n
Expand All @@ -109,7 +109,7 @@ module stdlib_math
#!=========================================================
#:for k1, t1 in RC_KINDS_TYPES
#:set RName = rname("logspace", 1, t1, k1, "default")
module function ${RName}$(start, end) result(res)
pure module function ${RName}$(start, end) result(res)

${t1}$, intent(in) :: start
${t1}$, intent(in) :: end
Expand All @@ -120,7 +120,7 @@ module stdlib_math
#:endfor
#! Integer support
#:set RName = rname("logspace", 1, "integer(int32)", "int32", "default")
module function ${RName}$(start, end) result(res)
pure module function ${RName}$(start, end) result(res)

integer, intent(in) :: start
integer, intent(in) :: end
Expand All @@ -134,7 +134,7 @@ module stdlib_math
#!=========================================================
#:for k1, t1 in RC_KINDS_TYPES
#:set RName = rname("logspace", 1, t1, k1, "n")
module function ${RName}$(start, end, n) result(res)
pure module function ${RName}$(start, end, n) result(res)
${t1}$, intent(in) :: start
${t1}$, intent(in) :: end
integer, intent(in) :: n
Expand All @@ -144,7 +144,7 @@ module stdlib_math
#:endfor
#! Integer support
#:set RName = rname("logspace", 1, "integer(int32)", "int32", "n")
module function ${RName}$(start, end, n) result(res)
pure module function ${RName}$(start, end, n) result(res)
integer, intent(in) :: start
integer, intent(in) :: end
integer, intent(in) :: n
Expand All @@ -165,7 +165,7 @@ module stdlib_math
! Different combinations of parameter types will lead to different result types.
! Those combinations are indicated in the body of each function.
#:set RName = rname("logspace", 1, t1, k1, "n_rbase")
module function ${RName}$(start, end, n, base) result(res)
pure module function ${RName}$(start, end, n, base) result(res)
${t1}$, intent(in) :: start
${t1}$, intent(in) :: end
integer, intent(in) :: n
Expand All @@ -175,7 +175,7 @@ module stdlib_math
end function ${RName}$

#:set RName = rname("logspace", 1, t1, k1, "n_cbase")
module function ${RName}$(start, end, n, base) result(res)
pure module function ${RName}$(start, end, n, base) result(res)
${t1}$, intent(in) :: start
${t1}$, intent(in) :: end
integer, intent(in) :: n
Expand All @@ -185,7 +185,7 @@ module stdlib_math
end function ${RName}$

#:set RName = rname("logspace", 1, t1, k1, "n_ibase")
module function ${RName}$(start, end, n, base) result(res)
pure module function ${RName}$(start, end, n, base) result(res)
${t1}$, intent(in) :: start
${t1}$, intent(in) :: end
integer, intent(in) :: n
Expand All @@ -202,7 +202,7 @@ module stdlib_math
! Different combinations of parameter types will lead to different result types.
! Those combinations are indicated in the body of each function.
#:set RName = rname("logspace", 1, t1, k1, "n_rbase")
module function ${RName}$(start, end, n, base) result(res)
pure module function ${RName}$(start, end, n, base) result(res)
${t1}$, intent(in) :: start
${t1}$, intent(in) :: end
integer, intent(in) :: n
Expand All @@ -212,7 +212,7 @@ module stdlib_math
end function ${RName}$

#:set RName = rname("logspace", 1, t1, k1, "n_cbase")
module function ${RName}$(start, end, n, base) result(res)
pure module function ${RName}$(start, end, n, base) result(res)
${t1}$, intent(in) :: start
${t1}$, intent(in) :: end
integer, intent(in) :: n
Expand All @@ -222,7 +222,7 @@ module stdlib_math
end function ${RName}$

#:set RName = rname("logspace", 1, t1, k1, "n_ibase")
module function ${RName}$(start, end, n, base) result(res)
pure module function ${RName}$(start, end, n, base) result(res)
${t1}$, intent(in) :: start
${t1}$, intent(in) :: end
integer, intent(in) :: n
Expand All @@ -240,7 +240,7 @@ module stdlib_math
! Those combinations are indicated in the body of each function.
#:for k1 in REAL_KINDS
#:set RName = rname("logspace", 1, "integer(int32)", "int32", "n_r" + str(k1) + "base")
module function ${RName}$(start, end, n, base) result(res)
pure module function ${RName}$(start, end, n, base) result(res)
integer, intent(in) :: start
integer, intent(in) :: end
integer, intent(in) :: n
Expand All @@ -250,7 +250,7 @@ module stdlib_math
end function ${RName}$

#:set RName = rname("logspace", 1, "integer(int32)", "int32", "n_c" + str(k1) + "base")
module function ${RName}$(start, end, n, base) result(res)
pure module function ${RName}$(start, end, n, base) result(res)
integer, intent(in) :: start
integer, intent(in) :: end
integer, intent(in) :: n
Expand All @@ -261,7 +261,7 @@ module stdlib_math
#:endfor

#:set RName = rname("logspace", 1, "integer(int32)", "int32", "n_ibase")
module function ${RName}$(start, end, n, base) result(res)
pure module function ${RName}$(start, end, n, base) result(res)
integer, intent(in) :: start
integer, intent(in) :: end
integer, intent(in) :: n
Expand Down
4 changes: 2 additions & 2 deletions src/stdlib_math_linspace.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ contains

#:for k1, t1 in REAL_KINDS_TYPES
#:set RName = rname("linspace_default", 1, t1, k1)
module function ${RName}$(start, end) result(res)
pure module function ${RName}$(start, end) result(res)
${t1}$, intent(in) :: start
${t1}$, intent(in) :: end

Expand All @@ -20,7 +20,7 @@ contains

#:for k1, t1 in REAL_KINDS_TYPES
#:set RName = rname("linspace_n", 1, t1, k1)
module function ${RName}$(start, end, n) result(res)
pure module function ${RName}$(start, end, n) result(res)
${t1}$, intent(in) :: start
${t1}$, intent(in) :: end
integer, intent(in) :: n
Expand Down