cfixmat operator*(const cfixmat &a, const imat &b) { it_assert_debug(a.cols() == b.rows(), "operator*: wrong sizes"); cfixmat r(a.rows(), b.cols()); CFix tmp; int i, j, k; CFix *tr = r._data(); const CFix *t1; const int *t2 = b._data(); for (i = 0; i < r.cols(); i++) { for (j = 0; j < r.rows(); j++) { tmp = CFix(0); t1 = a._data() + j; for (k = a.cols(); k > 0; k--) { tmp += *(t1) * *(t2++); t1 += a.rows(); } *(tr++) = tmp; t2 -= b.rows(); } t2 += b.rows(); } return r; }
cmat operator+(const imat &a, const cmat &b) { it_assert_debug(a.cols() == b.cols() && a.rows() == b.rows(), "operator+(): sizes does not match"); cmat temp(b); for (int i = 0;i < a.rows();i++) { for (int j = 0;j < a.cols();j++) { temp(i, j) += std::complex<double>(static_cast<double>(a(i, j)), 0.0); } } return temp; }
mat operator+(const imat &a, const mat &b) { it_assert_debug(a.cols() == b.cols() && a.rows() == b.rows(), "operator+(): sizes does not match"); mat temp(b); for (int i = 0;i < a.rows();i++) { for (int j = 0;j < a.cols();j++) { temp(i, j) += (double)a(i, j); } } return temp; }
cfixmat operator+(const cfixmat &a, const imat &b) { it_assert_debug(a.cols() == b.cols() && a.rows() == b.rows(), "operator+(): sizes do not match"); cfixmat temp(a); for (int i = 0; i < a.rows(); i++) { for (int j = 0; j < a.cols(); j++) { temp(i, j) += b(i, j); } } return temp; }