14 void CalEigenSY(
const int& N,
float* A,
float* w,
float* work,
const int& lwork)
22 ssyevd_(&Nonly, &uplo, &N, A, &N, w, work, &lwork, iwork, &liwork, &info);
24 cout <<
"failed to compute eigenvalues!" << endl;
36 void Dcopy(
const int& N,
double* dst,
const double* src)
38 const int incx = 1, incy = 1;
39 dcopy_(&N, src, &incx, dst, &incy);
42 double Ddot(
int n,
double* a,
double* b)
44 const int inca = 1, incb = 1;
45 return ddot_(&n, a, &inca, b, &incb);
49 double Dnorm1(
const int& N,
double* x)
52 return dasum_(&N, x, &incx);
55 double Dnorm2(
const int& N,
double* x)
58 return dnrm2_(&N, x, &incx);
61 void Dscalar(
const int& n,
const double& alpha,
double* x)
65 dscal_(&n, &alpha, x, &incx);
68 void Daxpy(
const int& n,
const double& alpha,
const double* x,
double* y)
71 const int incx = 1, incy = 1;
72 daxpy_(&n, &alpha, x, &incx, y, &incy);
92 const char transa =
'N', transb =
'N';
93 dgemm_(&transa, &transb, &n, &m, &k, &alpha, B, &n, A, &k, &beta, C, &n);
96 void myDABpC(
const int& m,
107 for (
int i = 0; i < m; i++) {
108 for (
int j = 0; j < k; j++) {
109 for (
int m = 0; m < n; m++) {
110 C[i * k + j] += A[i * n + m] * B[m * k + j];
116 void myDABpCp(
const int& m,
125 for (
int i = 0; i < m; i++) {
126 for (
int j = 0; j < k; j++) {
127 for (
int p = 0; p < 3; p++) {
128 if (flag[p] != 0) C[i * k + j] += A[i * n + p] * B[p * k + j];
130 for (
int p = 0; p < 2; p++) {
132 for (
int m = 0; m < N; m++) {
133 C[i * k + j] += A[i * n + 3 + p * (N + 1) + m] *
134 B[(3 + p * (N + 1) + m) * k + j];
142 void myDABpCp1(
const int& m,
152 for (
int i = 0; i < m; i++) {
153 for (
int j = 0; j < k; j++) {
155 for (
int p = 0; p < 3; p++) {
157 C[i * k + j] += A[i * n + p] * B[s * k + j];
161 for (
int p = 0; p < 2; p++) {
163 for (
int m = 0; m < N; m++) {
164 C[i * k + j] += A[i * n + 3 + p * (N + 1) + m] * B[s * k + j];
173 void myDABpCp2(
const int& m,
182 for (
int i = 0; i < m; i++) {
183 for (
int j = 0; j < k; j++) {
185 for (
int p = 0; p < 3; p++) {
187 C[i * k + j] += A[i * n + s] * B[p * k + j];
191 for (
int p = 0; p < 2; p++) {
193 for (
int m = 0; m < N; m++) {
194 C[i * k + j] += A[i * n + s] * B[(3 + p * (N + 1) + m) * k + j];
213 for (
int i = 0; i < m; i++) {
215 for (
int j = 0; j < n; j++) {
216 y[i] += a * A[i * n + j] * x[j];
221 void LUSolve(
const int& nrhs,
const int& N,
double* A,
double* b,
int* pivot)
225 dgesv_(&N, &nrhs, A, &N, pivot, b, &N, &info);
228 cout <<
"Wrong Input !" << endl;
229 }
else if (info > 0) {
230 cout <<
"Singular Matrix !" << endl;
245 dsysv_(uplo, &N, &nrhs, A, &N, pivot, b, &N, work, &lwork, &info);
247 cout <<
"Wrong Input !" << endl;
248 }
else if (info > 0) {
249 cout <<
"Singular Matrix !" << endl;
double Ddot(int n, double *a, double *b)
Dot product of two double vectors stored as pointers.
void DaABpbC(const int &m, const int &n, const int &k, const double &alpha, const double *A, const double *B, const double &beta, double *C)
Computes C' = alpha B'A' + beta C', all matrices are column-major.
void Dscalar(const int &n, const double &alpha, double *x)
Scales a vector by a constant.
void CalEigenSY(const int &N, float *A, float *w, float *work, const int &lwork)
Calculate the minimal eigenvalue for symmetric matrix with mkl lapack.
void DaAxpby(const int &m, const int &n, const double &a, const double *A, const double *x, const double &b, double *y)
Computes y = a A x + b y.
void LUSolve(const int &nrhs, const int &N, double *A, double *b, int *pivot)
Calls dgesv to solve the linear system for general matrices.
void Daxpy(const int &n, const double &alpha, const double *x, double *y)
Constant times a vector plus a vector.
double Dnorm1(const int &N, double *x)
Computes the L1-norm of a vector.
int SYSSolve(const int &nrhs, const char *uplo, const int &N, double *A, double *b, int *pivot, double *work, const int &lwork)
Calls dsysy to solve the linear system for symm matrices.
void Dcopy(const int &N, double *dst, const double *src)
Calculate the minimal eigenvalue for symmetric matrix with mkl lapack.
double Dnorm2(const int &N, double *x)
Computes the L2-norm of a vector.
Operations about small dense mat.
double dasum_(const int *n, double *x, const int *incx)
Computes the sum of the absolute values of a vector.
int dsysv_(const char *uplo, const int *n, const int *nrhs, double *A, const int *lda, int *ipiv, double *b, const int *ldb, double *work, const int *lwork, int *info)
Computes the solution to system of linear equations A * X = B for symm matrices.
int dgesv_(const int *n, const int *nrhs, double *A, const int *lda, int *ipiv, double *b, const int *ldb, int *info)
Computes the solution to system of linear equations A * X = B for general matrices.
int ssyevd_(char *jobz, char *uplo, const int *n, float *A, const int *lda, float *w, float *work, const int *lwork, int *iwork, const int *liwork, int *info)
int daxpy_(const int *n, const double *alpha, const double *x, const int *incx, double *y, const int *incy)
Constant times a vector plus a vector.
int dcopy_(const int *n, const double *src, const int *incx, double *dst, const int *incy)
Copies a vector, src, to a vector, dst.
int dgemm_(const char *transa, const char *transb, const int *m, const int *n, const int *k, const double *alpha, const double *A, const int *lda, const double *B, const int *ldb, const double *beta, double *C, const int *ldc)
Performs matrix-matrix operations C : = alpha * op(A) * op(B) + beta * C.
double dnrm2_(const int *n, double *x, const int *incx)
Computes the Euclidean norm of a vector.
void dscal_(const int *n, const double *alpha, double *x, const int *incx)
Scales a vector by a constant.
double ddot_(const int *n, double *a, const int *inca, double *b, const int *incb)
Forms the dot product of two vectors.