Permalink
Browse files

add iamax, asum, nrm2

  • Loading branch information...
9il committed Mar 19, 2017
1 parent e858d33 commit 55032e1e32c0faa0da3a5fc54e9c9a1e1cebf0c8
Showing with 576 additions and 23 deletions.
  1. +3 −3 README.md
  2. +15 −0 include/glas/fortran.h
  3. +27 −0 include/glas/ndslice.h
  4. +54 −0 source/glas/fortran.d
  5. +230 −14 source/glas/internal/l1.d
  6. +98 −1 source/glas/internal/l1_.d
  7. +16 −0 source/glas/internal/utility.d
  8. +128 −0 source/glas/ndslice.d
  9. +5 −5 test.sh
View
@@ -167,9 +167,9 @@ The hardest part (GEMM) is already implemented.
- [x] COPY - copy x into y
- [x] AXPY - `y = a*x + y`. Note: requires addition optimization for complex numbers.
- [ ] DOT - dot product
- [ ] NRM2 - Euclidean norm
- [ ] ASUM - sum of absolute values
- [ ] IAMAX - index of max abs value
- [x] NRM2 - Euclidean norm
- [x] ASUM - sum of absolute values
- [x] IAMAX - index of max abs value
## Porting to a new target
View
@@ -24,6 +24,21 @@ int daxpy_(const FortranInt *n, const double *a, const double *x, const FortranI
int caxpy_(const FortranInt *n, const float _Complex *a, const float _Complex *x, const FortranInt *incx, float _Complex *y, const FortranInt *incy);
int zaxpy_(const FortranInt *n, const double _Complex *a, const double _Complex *x, const FortranInt *incx, double _Complex *y, const FortranInt *incy);
float snrm2_(const FortranInt *n, const float *x, const FortranInt *incx);
double dnrm2_(const FortranInt *n, const double *x, const FortranInt *incx);
float scnrm2_(const FortranInt *n, const float _Complex *x, const FortranInt *incx);
double dznrm2_(const FortranInt *n, const double _Complex *x, const FortranInt *incx);
float sasum_(const FortranInt *n, const float *x, const FortranInt *incx);
double dasum_(const FortranInt *n, const double *x, const FortranInt *incx);
float scasum_(const FortranInt *n, const float _Complex *x, const FortranInt *incx);
double dzasum_(const FortranInt *n, const double _Complex *x, const FortranInt *incx);
FortranInt isamax_(const FortranInt *n, const float *x, const FortranInt *incx);
FortranInt idamax_(const FortranInt *n, const double *x, const FortranInt *incx);
FortranInt icamax_(const FortranInt *n, const float _Complex *x, const FortranInt *incx);
FortranInt izamax_(const FortranInt *n, const double _Complex *x, const FortranInt *incx);
int sscal_(const FortranInt *n, const float *a, float *x, const FortranInt *incx);
int dscal_(const FortranInt *n, const double *a, double *x, const FortranInt *incx);
int csscal_(const FortranInt *n, const float *a, float _Complex *x, const FortranInt *incx);
View
@@ -86,6 +86,33 @@ void _glas_daxpy(double a, size_t n, size_t incx, double* x, size_t incy, double
void _glas_caxpy(float _Complex a, size_t n, size_t incx, float _Complex* x, size_t incy, float _Complex* y);
void _glas_zaxpy(float _Complex a, size_t n, size_t incx, double _Complex* x, size_t incy, double _Complex* y);
float glas_snrm2(struct glas_ConstVector xsl);
double glas_dnrm2(struct glas_ConstVector xsl);
float glas_scnrm2(struct glas_ConstVector xsl);
double glas_dznrm2(struct glas_ConstVector xsl);
float _glas_snrm2(size_t n, size_t incx, const float* x);
double _glas_dnrm2(size_t n, size_t incx, const double* x);
float _glas_scnrm2(size_t n, size_t incx, const float _Complex* x);
double _glas_dznrm2(size_t n, size_t incx, const double _Complex* x);
float glas_sasum(struct glas_ConstVector xsl);
double glas_dasum(struct glas_ConstVector xsl);
float glas_scasum(struct glas_ConstVector xsl);
double glas_dzasum(struct glas_ConstVector xsl);
float _glas_sasum(size_t n, size_t incx, const float* x);
double _glas_dasum(size_t n, size_t incx, const double* x);
float _glas_scasum(size_t n, size_t incx, const float _Complex* x);
double _glas_dzasum(size_t n, size_t incx, const double _Complex* x);
ptrdiff_t glas_isamax(struct glas_ConstVector xsl);
ptrdiff_t glas_idamax(struct glas_ConstVector xsl);
ptrdiff_t glas_icamax(struct glas_ConstVector xsl);
ptrdiff_t glas_izamax(struct glas_ConstVector xsl);
ptrdiff_t _glas_isamax(size_t n, size_t incx, const float* x);
ptrdiff_t _glas_idamax(size_t n, size_t incx, const double* x);
ptrdiff_t _glas_icamax(size_t n, size_t incx, const float _Complex* x);
ptrdiff_t _glas_izamax(size_t n, size_t incx, const double _Complex* x);
void glas_sscal(float a, struct glas_MutVector xsl);
void glas_dscal(double a, struct glas_MutVector xsl);
void glas_csscal(float a, struct glas_MutVector xsl);
View
@@ -145,6 +145,60 @@ alias axpy_ = daxpy_;
alias axpy_ = caxpy_;
alias axpy_ = zaxpy_;
/++
Returns the euclidean norm of a vector via the function.
Unified_alias: `nrm2_`
+/
int snrm2_(ref const FortranInt n, const(float)* x, ref const FortranInt incx);
/// ditto
int dnrm2_(ref const FortranInt n, const(double)* x, ref const FortranInt incx);
/// ditto
int scnrm2_(ref const FortranInt n, const(cfloat)* x, ref const FortranInt incx);
/// ditto
int dznrm2_(ref const FortranInt n, const(cdouble)* x, ref const FortranInt incx);
alias nrm2_ = snrm2_;
alias nrm2_ = dnrm2_;
alias nrm2_ = scnrm2_;
alias nrm2_ = dznrm2_;
/++
Takes the sum of the absolute values.
Unified_alias: `asum_`
+/
int sasum_(ref const FortranInt n, const(float)* x, ref const FortranInt incx);
/// ditto
int dasum_(ref const FortranInt n, const(double)* x, ref const FortranInt incx);
/// ditto
int scasum_(ref const FortranInt n, const(cfloat)* x, ref const FortranInt incx);
/// ditto
int dzasum_(ref const FortranInt n, const(cdouble)* x, ref const FortranInt incx);
alias asum_ = sasum_;
alias asum_ = dasum_;
alias asum_ = scasum_;
alias asum_ = dzasum_;
/++
Finds the index of the first element having maximum `|Re(.)| + |Im(.)|`.
Unified_alias: `iamax_`
+/
int isamax_(ref const FortranInt n, const(float)* x, ref const FortranInt incx);
/// ditto
int idamax_(ref const FortranInt n, const(double)* x, ref const FortranInt incx);
/// ditto
int icamax_(ref const FortranInt n, const(cfloat)* x, ref const FortranInt incx);
/// ditto
int izamax_(ref const FortranInt n, const(cdouble)* x, ref const FortranInt incx);
alias iamax_ = isamax_;
alias iamax_ = idamax_;
alias iamax_ = icamax_;
alias iamax_ = izamax_;
/++
`scal_` scales a vector by a constant.
Oops, something went wrong.

0 comments on commit 55032e1

Please sign in to comment.