matrix-vector-number multiplications

void Mul_matmat(double **A, double **B, double **Res) { for (int i = 0; i < N + 1; i++) { for (int j = 0; j < N + 1; j++) { for (int k = 0; k < N + 1; ++k) { Res[i][j] += A[i][k] * B[k][j]; } } } } void Mul_matvec(double **A, double *b, double *res) { for (int i = 0; i < N + 1; i++) { for (int j = 0; j < N + 1; j++) { res[i] += A[i][j] * b[j]; } } } double vTu(double *vec1, double *vec2) { double res = 0; for (int i = 0; i < N + 1; i++) { res += vec1[i] * vec2[i]; } return res; } void vuT(double *vec1, double *vec2, double **res) { for (int i = 0; i < N + 1; i++) { for (int j = 0; j < N + 1; j++) { res[i][j] = vec1[i] * vec2[j]; } } } void Mul_numvec(double *vec, double m) { for (int j = 0; j < N + 1; j++) { vec[j] *= m; } } void Mul_nummat(double **A, double m) { for (int i = 0; i < N + 1; i++) { for (int j = 0; j < N + 1; j++) { A[i][j] *= m; } } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.