Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jalvesz committed Jan 12, 2025
1 parent 14be974 commit aaa68bc
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 6 deletions.
52 changes: 50 additions & 2 deletions src/stdlib_intrinsics.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,27 @@
#:set RC_KINDS_TYPES = R_KINDS_TYPES + C_KINDS_TYPES
#:set RANKS = range(2, MAXRANK + 1)

! This module is based on https://github.com/jalvesz/fast_math
module stdlib_intrinsics
!!Replacement for certain Fortran intrinsic functions offering either faster and/or more accurate implementations.
!! ([Specification](../page/specs/stdlib_intrinsics.html))
use stdlib_kinds
implicit none
private

interface stdlib_sum
interface stdlib_sum
!! version: experimental
!!
!!### Summary
!! Sum elements of rank N arrays.
!! ([Specification](../page/specs/stdlib_intrinsics.html#stdlib_sum))
!!
!!### Description
!!
!! This interface provides standard conforming call for sum of elements of any rank.
!! The 1-D base implementation follows a chunked approach for optimizing performance and increasing accuracy.
!! The `N-D` interfaces calls upon the `(N-1)-D` implementation.
!! Supported data types include `real` and `complex`.
!!
#:for rk, rt, rs in RC_KINDS_TYPES
pure module function stdlib_sum_1d_${rs}$(a) result(s)
${rt}$, intent(in) :: a(:)
Expand Down Expand Up @@ -41,6 +53,18 @@ module stdlib_intrinsics
public :: stdlib_sum

interface stdlib_sum_kahan
!! version: experimental
!!
!!### Summary
!! Sum elements of rank 1 arrays.
!! ([Specification](../page/specs/stdlib_intrinsics.html#stdlib_sum_kahan))
!!
!!### Description
!!
!! This interface provides standard conforming call for sum of elements of rank 1.
!! The 1-D base implementation follows a chunked approach combined with a kahan kernel for optimizing performance and increasing accuracy.
!! Supported data types include `real` and `complex`.
!!
#:for rk, rt, rs in RC_KINDS_TYPES
pure module function stdlib_sum_kahan_1d_${rs}$(a) result(s)
${rt}$, intent(in) :: a(:)
Expand All @@ -56,6 +80,18 @@ module stdlib_intrinsics
public :: stdlib_sum_kahan

interface stdlib_dot_product
!! version: experimental
!!
!!### Summary
!! dot_product of rank 1 arrays.
!! ([Specification](../page/specs/stdlib_intrinsics.html#stdlib_dot_product))
!!
!!### Description
!!
!! compute the dot_product of rank 1 arrays.
!! The 1-D base implementation follows a chunked approach for optimizing performance and increasing accuracy.
!! Supported data types include `real` and `complex`.
!!
#:for rk, rt, rs in RC_KINDS_TYPES
pure module function stdlib_dot_product_${rs}$(a,b) result(p)
${rt}$, intent(in) :: a(:)
Expand All @@ -67,6 +103,18 @@ module stdlib_intrinsics
public :: stdlib_dot_product

interface stdlib_dot_product_kahan
!! version: experimental
!!
!!### Summary
!! dot_product of rank 1 arrays.
!! ([Specification](../page/specs/stdlib_intrinsics.html#stdlib_dot_product_kahan))
!!
!!### Description
!!
!! compute the dot_product of rank 1 arrays.
!! The implementation follows a chunked approach combined with a kahan kernel for optimizing performance and increasing accuracy.
!! Supported data types include `real` and `complex`.
!!
#:for rk, rt, rs in RC_KINDS_TYPES
pure module function stdlib_dot_product_kahan_${rs}$(a,b) result(p)
${rt}$, intent(in) :: a(:)
Expand Down
3 changes: 1 addition & 2 deletions src/stdlib_intrinsics_dot_product.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ ${expression}$
#:endif
#:enddef

! This module is based on https://github.com/jalvesz/fast_math
submodule(stdlib_intrinsics) stdlib_intrinsics_dot_product
!!Replacement for certain Fortran intrinsic functions offering either faster and/or more accurate implementations.
!! ([Specification](../page/specs/stdlib_intrinsics.html))
Expand All @@ -22,7 +21,7 @@ submodule(stdlib_intrinsics) stdlib_intrinsics_dot_product
integer, parameter :: chunk = 64

contains

! This implementation is based on https://github.com/jalvesz/fast_math
#:for k1, t1, s1 in RC_KINDS_TYPES
pure module function stdlib_dot_product_${s1}$(a,b) result(p)
${t1}$, intent(in) :: a(:)
Expand Down
3 changes: 1 addition & 2 deletions src/stdlib_intrinsics_sum.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
#:set RC_KINDS_TYPES = R_KINDS_TYPES + C_KINDS_TYPES
#:set RANKS = range(2, MAXRANK + 1)

! This module is based on https://github.com/jalvesz/fast_math
submodule(stdlib_intrinsics) stdlib_intrinsics_sum
!!Replacement for certain Fortran intrinsic functions offering either faster and/or more accurate implementations.
!! ([Specification](../page/specs/stdlib_intrinsics.html))
use stdlib_kinds
use stdlib_constants
Expand All @@ -17,6 +15,7 @@ submodule(stdlib_intrinsics) stdlib_intrinsics_sum
contains

!================= 1D Base implementations ============
! This implementation is based on https://github.com/jalvesz/fast_math
#:for rk, rt, rs in RC_KINDS_TYPES
pure module function stdlib_sum_1d_${rs}$(a) result(s)
${rt}$, intent(in) :: a(:)
Expand Down

0 comments on commit aaa68bc

Please sign in to comment.