14 void MinEigenSY(
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;
37 void Dcopy(
const int& N,
double* dst,
const double* src)
39 const int incx = 1, incy = 1;
40 dcopy_(&N, src, &incx, dst, &incy);
43 double Ddot(
int n,
double* a,
double* b)
45 const int inca = 1, incb = 1;
46 return ddot_(&n, a, &inca, b, &incb);
50 double Dnorm1(
const int& N,
double* x)
53 return dasum_(&N, x, &incx);
56 double Dnorm2(
const int& N,
double* x)
59 return dnrm2_(&N, x, &incx);
62 void Dscalar(
const int& n,
const double& alpha,
double* x)
66 dscal_(&n, &alpha, x, &incx);
69 void Daxpy(
const int& n,
const double& alpha,
const double* x,
double* y)
72 const int incx = 1, incy = 1;
73 daxpy_(&n, &alpha, x, &incx, y, &incy);
76 void DaABpbC(
const int& m,
const int& n,
const int& k,
const double& alpha,
77 const double* A,
const double* B,
const double& beta,
double* C)
87 const char transa =
'N', transb =
'N';
88 dgemm_(&transa, &transb, &n, &m, &k, &alpha, B, &n, A, &k, &beta, C, &n);
92 void myDABpC(
const int& m,
const int& n,
const int& k,
const double* A,
const double* B,
double* C)
98 for (
int i = 0; i < m; i++) {
99 for (
int j = 0; j < k; j++) {
100 for (
int m = 0; m < n; m++) {
101 C[i * k + j] += A[i * n + m] * B[m * k + j];
107 void myDABpCp(
const int& m,
const int& n,
const int& k,
const double* A,
const double* B,
double* C,
const int* flag,
const int N)
109 for (
int i = 0; i < m; i++) {
110 for (
int j = 0; j < k; j++) {
111 for (
int p = 0; p < 3; p++) {
113 C[i * k + j] += A[i * n + p] * B[p * k + j];
115 for (
int p = 0; p < 2; p++) {
117 for (
int m = 0; m < N; m++) {
118 C[i * k + j] += A[i * n + 3 + p * (N + 1) + m] * B[(3 + p * (N + 1) + m) * k + j];
126 void myDABpCp1(
const int& m,
const int& n,
const int& k,
const double* A,
const double* B,
double* C,
const int* flag,
const int N)
129 for (
int i = 0; i < m; i++) {
130 for (
int j = 0; j < k; j++) {
132 for (
int p = 0; p < 3; p++) {
134 C[i * k + j] += A[i * n + p] * B[s * k + j];
138 for (
int p = 0; p < 2; p++) {
140 for (
int m = 0; m < N; m++) {
141 C[i * k + j] += A[i * n + 3 + p * (N + 1) + m] * B[s * k + j];
150 void myDABpCp2(
const int& m,
const int& n,
const int& k,
const double* A,
const double* B,
double* C,
const int* flag,
const int N)
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 + s] * B[p * 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 + s] * B[(3 + p * (N + 1) + m) * k + j];
173 void DaAxpby(
const int& m,
const int& n,
const double& a,
const double* A,
174 const double* x,
const double& b,
double* y)
178 for (
int i = 0; i < m; i++) {
180 for (
int j = 0; j < n; j++) {
181 y[i] += a * A[i * n + j] * x[j];
186 void LUSolve(
const int& nrhs,
const int& N,
double* A,
double* b,
int* pivot)
190 dgesv_(&N, &nrhs, A, &N, pivot, b, &N, &info);
193 cout <<
"Wrong Input !" << endl;
194 }
else if (info > 0) {
195 cout <<
"Singular Matrix !" << endl;
199 void SYSSolve(
const int& nrhs,
const char* uplo,
const int& N,
double* A,
double* b,
int* pivot,
double* work,
const int& lwork)
203 dsysv_(uplo, &N, &nrhs, A, &N, pivot, b, &N, work, &lwork, &info);
205 cout <<
"Wrong Input !" << endl;
206 }
else if (info > 0) {
207 cout <<
"Singular Matrix !" << endl;
void 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.
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 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.
void MinEigenSY(const int &N, float *A, float *w, float *work, const int &lwork)
Calculate the minimal eigenvalue for sysmetric matrix with mkl lapack.
double Dnorm1(const int &N, double *x)
Computes the L1-norm of a vector.
void Dcopy(const int &N, double *dst, const double *src)
Calculate the minimal eigenvalue for sysmetric 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)
Computes the eigenvalues and, optionally, the leftand /or right eigenvectors for SY matrices.
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.