1 #include "../../../../include/monolish_blas.hpp"
2 #include "../../../internal/monolish_internal.hpp"
9 void matadd_core(
const matrix::LinearOperator<F> &A,
10 const matrix::LinearOperator<F> &B,
11 matrix::LinearOperator<F> &C) {
19 assert(A.get_matvec_init_flag() == B.get_matvec_init_flag());
20 assert(A.get_rmatvec_init_flag() == B.get_rmatvec_init_flag());
22 if (A.get_matvec_init_flag()) {
23 C.set_matvec([&](
const vector<F> &VEC) {
24 vector<F> vec(A.get_row(), 0.0), vec_tmp(A.get_row(), 0.0);
25 if (A.get_device_mem_stat()) {
31 if (A.get_device_mem_stat()) {
38 if (A.get_rmatvec_init_flag()) {
39 C.set_rmatvec([&](
const vector<F> &VEC) {
40 vector<F> vec(A.get_col(), 0.0), vec_tmp(A.get_col(), 0.0);
41 if (A.get_device_mem_stat()) {
47 if (A.get_device_mem_stat()) {
58 void matsub_core(
const matrix::LinearOperator<F> &A,
59 const matrix::LinearOperator<F> &B,
60 matrix::LinearOperator<F> &C) {
68 assert(A.get_matvec_init_flag() == B.get_matvec_init_flag());
69 assert(A.get_rmatvec_init_flag() == B.get_rmatvec_init_flag());
71 if (A.get_matvec_init_flag()) {
72 C.set_matvec([&](
const vector<F> &VEC) {
73 vector<F> vec(A.get_row(), 0.0), vec_tmp(A.get_row(), 0.0);
74 if (A.get_device_mem_stat()) {
80 if (A.get_device_mem_stat()) {
87 if (A.get_rmatvec_init_flag()) {
88 C.set_rmatvec([&](
const vector<F> &VEC) {
89 vector<F> vec(A.get_col(), 0.0), vec_tmp(A.get_col(), 0.0);
90 if (A.get_device_mem_stat()) {
96 if (A.get_device_mem_stat()) {
111 matadd_core(A, B, C);
116 matsub_core(A, B, C);
121 matadd_core(A, B, C);
126 matsub_core(A, B, C);