dla.h (2014-04-30 15:38:09 -0400, (build fd32605))
Go to the documentation of this file.
1 //-----------------------------------------------------------------------//
2 // Copyright (c) AccelerEyes LLC. All rights reserved. //
3 // See http://www.accelereyes.com/eula for details. //
4 // This software is distributed WITHOUT ANY WARRANTY; without even //
5 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
6 // PURPOSE. See the above copyright notices for more information. //
7 //-----------------------------------------------------------------------//
8 #pragma once
9 
10 #include "defines.h"
11 namespace af {
12 
13 class array;
14 
17 
27 AFAPI array lu(const array& in);
28 
46 AFAPI void lu(array& lower, array& upper, const array& in);
47 
157 AFAPI void lu(array& lower, array& upper, array& pivot, const array& in);
158 
173 AFAPI array qr(const array& in);
174 
192 AFAPI void qr(array& q, array& r, const array& in);
193 
205 AFAPI void qr(array& q, array& r, array& tau, const array& in);
206 
233 AFAPI array cholesky(const array& X, bool is_upper=true);
234 
251 AFAPI array cholesky(unsigned& info, const array& X, bool is_upper=true);
252 
253 
264 AFAPI array hessenberg(const array& in);
265 
278 AFAPI void hessenberg(array& h, array& q, const array& in);
279 
290 AFAPI array eigen(const array& in, bool is_diag=false);
291 
357 AFAPI void eigen(array& values, array& vectors, const array& in);
358 
381 AFAPI array svd(const array& in, bool is_diag=false);
382 
402 AFAPI void svd(array& s, array& u, array& v, const array& in);
403 
404 // factor_mat
406 
407 
408 
409 
412 
457 AFAPI array inverse(const array& in);
458 
478 AFAPI array matpow(const array& base, double exponent);
479 
491 AFAPI unsigned rank(const array& in, double tolerance=1e-5);
492 
502 template<typename T> T det(const array& in);
503 
504 // matops_mat
506 
507 
508 
511 typedef enum {
523 } af_solve_t;
524 
572 AFAPI array solve(const array& A, const array& b, af_solve_t options=af_solve_none);
573 
574 // linsolve_mat
576 } // namespace af
577 
578 
579 #ifdef __cplusplus
580 extern "C" {
581 #endif
582 
601 AFAPI afError af_lu_S(int *d_piv, float *d_U,
603  float *d_L,
604  unsigned m, unsigned n, unsigned batch);
606 AFAPI afError af_lu_C(int *d_piv, cfloat *d_U,
607  cfloat *d_L,
608  unsigned m, unsigned n, unsigned batch);
610 AFAPI afError af_lu_D(int *d_piv, double *d_U,
611  double *d_L,
612  unsigned m, unsigned n, unsigned batch);
614 AFAPI afError af_lu_Z(int *d_piv, cdouble *d_U,
615  cdouble *d_L,
616  unsigned m, unsigned n, unsigned batch);
619 
640 AFAPI afError af_qr_S(float *d_tau, float *d_R,
643  float *d_Q,
644  unsigned m, unsigned n, unsigned k,
645  unsigned batch);
647 AFAPI afError af_qr_C(cfloat *d_tau, cfloat *d_R,
648  cfloat *d_Q,
649  unsigned m, unsigned n, unsigned k,
650  unsigned batch);
652 AFAPI afError af_qr_D(double *d_tau, double *d_R,
653  double *d_Q,
654  unsigned m, unsigned n, unsigned k,
655  unsigned batch);
657 AFAPI afError af_qr_Z(cdouble *d_tau, cdouble *d_R,
658  cdouble *d_Q,
659  unsigned m, unsigned n, unsigned k,
660  unsigned batch);
663 
681 AFAPI afError af_cholesky_S(float *d_R, unsigned *info,
683  unsigned n, const float *d_A,
684  bool is_upper, unsigned batch);
686 AFAPI afError af_cholesky_C(cfloat *d_R, unsigned *info,
687  unsigned n, const cfloat *d_A,
688  bool is_upper, unsigned batch);
690 AFAPI afError af_cholesky_D(double *d_R, unsigned *info,
691  unsigned n, const double *d_A,
692  bool is_upper, unsigned batch);
694 AFAPI afError af_cholesky_Z(cdouble *d_R, unsigned *info,
695  unsigned n, const cdouble *d_A,
696  bool is_upper, unsigned batch);
699 
712 AFAPI afError af_hessenberg_S(float *d_H, float *d_Q,
715  unsigned n, const float *d_A,
716  unsigned batch);
720  unsigned n, const cfloat *d_A,
721  unsigned batch);
724 AFAPI afError af_hessenberg_D(double *d_H, double *d_Q,
725  unsigned n, const double *d_A,
726  unsigned batch);
730  unsigned n, const cdouble *d_A,
731  unsigned batch);
734 
769 AFAPI afError af_eigen_S(void **d_Val, void **d_Vec, bool *is_imag,
772  unsigned n, const float *d_A,
773  bool is_diag, unsigned batch);
776 AFAPI afError af_eigen_D(void **d_Val, void **d_Vec, bool *is_imag,
777  unsigned n, const double *d_A,
778  bool is_diag, unsigned batch);
781 AFAPI afError af_eigen_C(void **d_Val, cfloat *d_Vec, bool *is_imag,
782  unsigned n, const cfloat *d_A,
783  bool is_diag, unsigned batch);
786 AFAPI afError af_eigen_Z(void **d_Val, cdouble *d_Vec, bool *is_imag,
787  unsigned n, const cdouble *d_A,
788  bool is_diag, unsigned batch);
791 
815 AFAPI afError af_svd_S(float *d_S, float *d_U, float *d_V,
818  char jobU, char jobV,
819  unsigned m, unsigned n, const float *d_A,
820  unsigned m_, unsigned n_,
821  bool is_diag, unsigned batch);
824 AFAPI afError af_svd_C(float *d_S,
825  cfloat *d_U, cfloat *d_V,
826  char jobU, char jobV,
827  unsigned m, unsigned n,
828  const cfloat *d_A,
829  unsigned m_, unsigned n_,
830  bool is_diag, unsigned batch);
833 AFAPI afError af_svd_D(double *d_S, double *d_U, double *d_V,
834  char jobU, char jobV,
835  unsigned m, unsigned n, const double *d_A,
836  unsigned m_, unsigned n_,
837  bool is_diag, unsigned batch);
840 AFAPI afError af_svd_Z(double *d_S,
841  cdouble *d_U, cdouble *d_V,
842  char jobU, char jobV,
843  unsigned m, unsigned n,
844  const cdouble *d_A,
845  unsigned m_, unsigned n_,
846  bool is_diag, unsigned batch);
849 
864 AFAPI afError af_inverse_S(float *out, unsigned n,
866  float *d_in, unsigned batch);
868 AFAPI afError af_inverse_C(cfloat *out, unsigned n,
869  cfloat *d_in, unsigned batch);
871 AFAPI afError af_inverse_D(double *out, unsigned n,
872  double *d_in, unsigned batch);
874 AFAPI afError af_inverse_Z(cdouble *out, unsigned n,
875  cdouble *d_in, unsigned batch);
878 
891 AFAPI afError af_det_S(float *res,
893  unsigned n, float *d_X,
894  bool inplace, unsigned batch);
897  unsigned n, cfloat *d_X,
898  bool inplace, unsigned batch);
900 AFAPI afError af_det_D(double *res,
901  unsigned n, double *d_X,
902  bool inplace, unsigned batch);
905  unsigned n, cdouble *d_X,
906  bool inplace, unsigned batch);
909 
925 AFAPI afError af_matrixPower_S(void **d_out,
928  unsigned n, const float *d_in,
929  float power, unsigned batch, bool *is_cplx);
931 AFAPI afError af_matrixPower_C(void **d_out,
932  unsigned n, const cfloat *d_in,
933  float power, unsigned batch, bool *is_cplx);
935 AFAPI afError af_matrixPower_D(void **d_out,
936  unsigned n, const double *d_in,
937  double power, unsigned batch, bool *is_cplx);
939 AFAPI afError af_matrixPower_Z(void **d_out,
940  unsigned n, const cdouble *d_in,
941  double power, unsigned batch, bool *is_cplx);
944 
972 AFAPI afError af_linearSolve_SS(float *d_X,
974  unsigned m, unsigned n,
975  const float *d_A, unsigned batch_A,
976  unsigned k,
977  const float *d_B, unsigned batch_B,
978  unsigned opts);
981  unsigned m, unsigned n,
982  const cfloat *d_A,
983  unsigned batch_A,
984  unsigned k,
985  const cfloat *d_B,
986  unsigned batch_B,
987  unsigned opts);
989 AFAPI afError af_linearSolve_DD(double *d_X,
990  unsigned m, unsigned n,
991  const double *d_A, unsigned batch_A,
992  unsigned k,
993  const double *d_B, unsigned batch_B,
994  unsigned opts);
997  unsigned m, unsigned n,
998  const cdouble *d_A,
999  unsigned batch_A,
1000  unsigned k,
1001  const cdouble *d_B,
1002  unsigned batch_B,
1003  unsigned opts);
1006 
1020 AFAPI afError af_piv_final_I(int *d_out,
1021  unsigned m, unsigned k, const int *d_piv,
1022  unsigned batch);
1023 AFAPI afError af_piv_final_U(unsigned *d_out,
1024  unsigned m, unsigned k, const int *d_piv,
1025  unsigned batch);
1026 AFAPI afError af_piv_final_S(float *d_out,
1027  unsigned m, unsigned k, const int *d_piv,
1028  unsigned batch);
1029 AFAPI afError af_piv_final_D(double *d_out,
1030  unsigned m, unsigned k, const int *d_piv,
1031  unsigned batch);
1034 #ifdef __cplusplus
1035 }
1036 #endif
void info(bool isdebug=false)
Print diagnostic information on driver, runtime, memory, and devices.
array inverse(const array &in)
Matrix inversion.
afError af_matrixPower_S(void **d_out, unsigned n, const float *d_in, float power, unsigned batch, bool *is_cplx)
Matrix power for single precision matrix.
Use Gaussian elimination (fast, cannot be combined with other options)
Definition: dla.h:515
afError af_inverse_C(cfloat *out, unsigned n, cfloat *d_in, unsigned batch)
Inversion of single precision complex matrix. DLA license required.
afError af_lu_C(int *d_piv, cfloat *d_U, cfloat *d_L, unsigned m, unsigned n, unsigned batch)
lu Decomposition on single precision, complex data. DLA license required.
afError af_hessenberg_D(double *d_H, double *d_Q, unsigned n, const double *d_A, unsigned batch)
Find the hessenberg matrix on double precision data.
Solve A.H() (conjugate transpose)
Definition: dla.h:517
Definition: dla.h:522
afError af_svd_S(float *d_S, float *d_U, float *d_V, char jobU, char jobV, unsigned m, unsigned n, const float *d_A, unsigned m_, unsigned n_, bool is_diag, unsigned batch)
Singular value decomposition on single precision input DLA license not required.
Solve lowertri(A) (lower triangular system)
Definition: dla.h:520
afError af_cholesky_Z(cdouble *d_R, unsigned *info, unsigned n, const cdouble *d_A, bool is_upper, unsigned batch)
Cholesky decomposition, double precision, complex data. DLA license required.
af_solve_t
Definition: dla.h:511
afError af_linearSolve_ZZ(cdouble *d_X, unsigned m, unsigned n, const cdouble *d_A, unsigned batch_A, unsigned k, const cdouble *d_B, unsigned batch_B, unsigned opts)
Solve a double precision complex system. DLA not required for opts = 3.
afError af_lu_S(int *d_piv, float *d_U, float *d_L, unsigned m, unsigned n, unsigned batch)
lu Decomposition on single precision data. No DLA license required.
afError af_piv_final_D(double *d_out, unsigned m, unsigned k, const int *d_piv, unsigned batch)
afError af_matrixPower_C(void **d_out, unsigned n, const cfloat *d_in, float power, unsigned batch, bool *is_cplx)
Matrix power for single precision, complex matrix. DLA license required.
Definition: dla.h:521
afError af_svd_C(float *d_S, cfloat *d_U, cfloat *d_V, char jobU, char jobV, unsigned m, unsigned n, const cfloat *d_A, unsigned m_, unsigned n_, bool is_diag, unsigned batch)
Singular value decomposition on single precision complex input DLA license required.
afError af_eigen_D(void **d_Val, void **d_Vec, bool *is_imag, unsigned n, const double *d_A, bool is_diag, unsigned batch)
Eigen value decomposition of single precision complex input.
afError af_piv_final_S(float *d_out, unsigned m, unsigned k, const int *d_piv, unsigned batch)
array upper(const array &input, int diagonal=0)
Extract upper triangular matrix.
afError af_hessenberg_S(float *d_H, float *d_Q, unsigned n, const float *d_A, unsigned batch)
Find the hessenberg matrix on single precision data.
afError af_inverse_S(float *out, unsigned n, float *d_in, unsigned batch)
Inversion of single precision matrix. DLA license required.
afError af_eigen_C(void **d_Val, cfloat *d_Vec, bool *is_imag, unsigned n, const cfloat *d_A, bool is_diag, unsigned batch)
Eigen value decomposition of double precision input.
afError
Definition: defines.h:10
afError af_hessenberg_C(cfloat *d_H, cfloat *d_Q, unsigned n, const cfloat *d_A, unsigned batch)
Find the hessenberg matrix on single precision complex data.
cuDoubleComplex cdouble
Definition: defines.h:109
afError af_linearSolve_DD(double *d_X, unsigned m, unsigned n, const double *d_A, unsigned batch_A, unsigned k, const double *d_B, unsigned batch_B, unsigned opts)
Solve a double precision system. DLA not required for opts = 3.
afError af_eigen_Z(void **d_Val, cdouble *d_Vec, bool *is_imag, unsigned n, const cdouble *d_A, bool is_diag, unsigned batch)
Eigen value decomposition of double precision complex input.
afError af_inverse_Z(cdouble *out, unsigned n, cdouble *d_in, unsigned batch)
Inversion of double precision complex matrix. DLA license required.
array cholesky(const array &X, bool is_upper=true)
Cholesky decomposition (&quot;Y^T * Y == X&quot;).
afError af_matrixPower_Z(void **d_out, unsigned n, const cdouble *d_in, double power, unsigned batch, bool *is_cplx)
Matrix power for double precision, complex matrix. DLA license required.
afError af_qr_C(cfloat *d_tau, cfloat *d_R, cfloat *d_Q, unsigned m, unsigned n, unsigned k, unsigned batch)
qr decomposition on single precision, complex data. DLA license required.
array lower(const array &input, int diagonal=0)
Extract lower triangular matrix.
afError af_lu_D(int *d_piv, double *d_U, double *d_L, unsigned m, unsigned n, unsigned batch)
lu Decomposition on double precision data. DLA license required.
afError af_piv_final_I(int *d_out, unsigned m, unsigned k, const int *d_piv, unsigned batch)
afError af_matrixPower_D(void **d_out, unsigned n, const double *d_in, double power, unsigned batch, bool *is_cplx)
Matrix power for double precision matrix. DLA license required.
array eigen(const array &in, bool is_diag=false)
Compute eigenvalues.
Default.
Definition: dla.h:512
afError af_lu_Z(int *d_piv, cdouble *d_U, cdouble *d_L, unsigned m, unsigned n, unsigned batch)
lu Decomposition on double precision, complex data. DLA license required.
afError af_cholesky_C(cfloat *d_R, unsigned *info, unsigned n, const cfloat *d_A, bool is_upper, unsigned batch)
Cholesky decomposition, single precision complex data. DLA license required.
T det(const array &in)
Matrix determinant.
afError af_svd_D(double *d_S, double *d_U, double *d_V, char jobU, char jobV, unsigned m, unsigned n, const double *d_A, unsigned m_, unsigned n_, bool is_diag, unsigned batch)
Singular value decomposition on double precision input DLA license not required.
#define AFAPI
Definition: defines.h:45
afError af_det_Z(cdouble *res, unsigned n, cdouble *d_X, bool inplace, unsigned batch)
Determinant of double precision complex matrix. DLA license required.
afError af_qr_D(double *d_tau, double *d_R, double *d_Q, unsigned m, unsigned n, unsigned k, unsigned batch)
qr decomposition on double precision data. DLA license required.
A is not positive definite.
Definition: dla.h:514
array hessenberg(const array &in)
Hessenberg matrix form.
A is positive definite.
Definition: dla.h:513
array matpow(const array &base, double exponent)
Matrix power.
Solve A.T() (non-conjugate transpose)
Definition: dla.h:518
afError af_svd_Z(double *d_S, cdouble *d_U, cdouble *d_V, char jobU, char jobV, unsigned m, unsigned n, const cdouble *d_A, unsigned m_, unsigned n_, bool is_diag, unsigned batch)
Singular value decomposition on double precision complex input DLA license not required.
Solve uppertri(A) (upper triangular system)
Definition: dla.h:519
afError af_cholesky_S(float *d_R, unsigned *info, unsigned n, const float *d_A, bool is_upper, unsigned batch)
Cholesky decomposition, single precision data. No DLA license required.
array qr(const array &in)
QR factorization (packed).
array svd(const array &in, bool is_diag=false)
Singular values.
afError af_hessenberg_Z(cdouble *d_H, cdouble *d_Q, unsigned n, const cdouble *d_A, unsigned batch)
Find the hessenberg matrix on double precision complex data.
afError af_det_S(float *res, unsigned n, float *d_X, bool inplace, unsigned batch)
Determinant of single precision matrix. DLA license not required.
afError af_piv_final_U(unsigned *d_out, unsigned m, unsigned k, const int *d_piv, unsigned batch)
afError af_qr_Z(cdouble *d_tau, cdouble *d_R, cdouble *d_Q, unsigned m, unsigned n, unsigned k, unsigned batch)
qr decomposition on double precision, complex data. DLA license required.
afError af_qr_S(float *d_tau, float *d_R, float *d_Q, unsigned m, unsigned n, unsigned k, unsigned batch)
qr decomposition on single precision data.
unsigned rank(const array &in, double tolerance=1e-5)
Rank of matrix.
cuFloatComplex cfloat
Definition: defines.h:108
Use pseudo inverse (fast, cannot be combined with other options)
Definition: dla.h:516
array lu(const array &in)
LU factorization (packed).
array solve(const array &A, const array &b, af_solve_t options=af_solve_none)
Solve linear system.
afError af_linearSolve_SS(float *d_X, unsigned m, unsigned n, const float *d_A, unsigned batch_A, unsigned k, const float *d_B, unsigned batch_B, unsigned opts)
Solve a single precision system. DLA not required for opts = 0, 3.
afError af_det_D(double *res, unsigned n, double *d_X, bool inplace, unsigned batch)
Determinant of double precision matrix. DLA license required.
afError af_eigen_S(void **d_Val, void **d_Vec, bool *is_imag, unsigned n, const float *d_A, bool is_diag, unsigned batch)
Eigen value decomposition of single precision input.
afError af_inverse_D(double *out, unsigned n, double *d_in, unsigned batch)
Inversion of double precision matrix. DLA license required.
afError af_cholesky_D(double *d_R, unsigned *info, unsigned n, const double *d_A, bool is_upper, unsigned batch)
Cholesky decomposition, double precision data. DLA license required.
afError af_det_C(cfloat *res, unsigned n, cfloat *d_X, bool inplace, unsigned batch)
Determinant of single precision complex matrix. DLA license required.
afError af_linearSolve_CC(cfloat *d_X, unsigned m, unsigned n, const cfloat *d_A, unsigned batch_A, unsigned k, const cfloat *d_B, unsigned batch_B, unsigned opts)
Solve a single precision complex system. DLA not required for opts = 3.