00001
00014 #ifndef IXAXPY_HPP_
00015 #define IXAXPY_HPP_
00016
00017 #include "jmath/jblas.hpp"
00018 #include "jmath/indirectArray.hpp"
00019
00020 namespace jafar {
00021 namespace jmath {
00022 namespace ublasExtra {
00023
00024 using namespace std;
00025 using namespace jblas;
00026 using namespace boost::numeric::ublas;
00027
00028
00030
00032 template<class bubMatrix>
00033 void ixaxpy_offdiag_subprod(sym_mat & S, const ind_array & ia_invariant, const bubMatrix & J_oi,
00034 const ind_array & ia_in, const ind_array & ia_out)
00035 {
00036 project(S, ia_out, ia_invariant) = prod(J_oi, project(S, ia_in, ia_invariant));
00037 }
00038
00039 template<class bubMatrix, class bubMatrixY>
00040 void ixaxpy_diag_subprod(sym_mat & S, const bubMatrix & J, const ind_array & ia_in, const ind_array & ia_out,
00041 const bubMatrixY Y)
00042 {
00043 matrix<double> JSii = prod(J, project(S, ia_in, ia_in));
00044 ublas::noalias(project(S, ia_out, ia_out)) = prod<sym_mat> (JSii, trans(J));
00045 project(S, ia_out, ia_out) += Y;
00046 }
00047
00048 template<class bubMatrix>
00049 void ixaxpy_diag_subprod(sym_mat & S, const bubMatrix & J, const ind_array & ia_in, const ind_array & ia_out)
00050 {
00051 matrix<double> JSii = prod(J, project(S, ia_in, ia_in));
00052 ublas::noalias(project(S, ia_out, ia_out)) = prod<sym_mat> (JSii, trans(J));
00053 }
00054
00055
00100 template<class bubMatrixJ, class bubMatrixY>
00101 void ixaxpy_prod(sym_mat & X, const ind_array & ia_invariant, const bubMatrixJ & A_oi, const ind_array & ia_in,
00102 const ind_array & ia_out, const bubMatrixY Y_oo)
00103 {
00104 ixaxpy_offdiag_subprod(X, ia_invariant, A_oi, ia_in, ia_out);
00105 ixaxpy_diag_subprod(X, A_oi, ia_in, ia_out, Y_oo);
00106 }
00107
00114 template<class bubMatrixJ>
00115 void ixaxpy_prod(sym_mat & X, const ind_array & ia_invariant, const bubMatrixJ & A_oi, const ind_array & ia_in,
00116 const ind_array & ia_out)
00117 {
00118 ixaxpy_offdiag_subprod(X, ia_invariant, A_oi, ia_in, ia_out);
00119 ixaxpy_diag_subprod(X, A_oi, ia_in, ia_out);
00120 }
00121
00122 }
00123 }
00124 }
00125
00126 #endif