1 #ifndef VIENNACL_MATRIX_HPP_
2 #define VIENNACL_MATRIX_HPP_
53 template<
typename LHS,
typename RHS,
typename OP>
54 class matrix_expression
56 typedef typename viennacl::result_of::reference_if_nonscalar<LHS>::type lhs_reference_type;
57 typedef typename viennacl::result_of::reference_if_nonscalar<RHS>::type rhs_reference_type;
66 LHS &
lhs()
const {
return lhs_; }
69 RHS &
rhs()
const {
return rhs_; }
77 lhs_reference_type lhs_;
79 rhs_reference_type rhs_;
91 template<
typename ROWCOL,
typename MatrixT>
100 vcl_size_t start_col) : mat_(mat), row_(start_row), col_(start_col) {}
126 template<
class NumericT,
typename SizeT,
typename DistanceT>
128 : size1_(rows), size2_(columns), start1_(0), start2_(0), stride1_(1), stride2_(1),
131 row_major_fixed_(true), row_major_(is_row_major)
133 if (rows > 0 && columns > 0)
142 template<
class NumericT,
typename SizeT,
typename DistanceT>
143 template<
typename LHS,
typename RHS,
typename OP>
145 size1_(viennacl::traits::
size1(proxy)), size2_(viennacl::traits::
size2(proxy)), start1_(0), start2_(0), stride1_(1), stride2_(1),
148 row_major_fixed_(true), row_major_(viennacl::traits::
row_major(proxy))
160 template<
class NumericT,
typename SizeT,
typename DistanceT>
165 : size1_(mat_size1), size2_(mat_size2),
166 start1_(mat_start1), start2_(mat_start2),
167 stride1_(mat_stride1), stride2_(mat_stride2),
168 internal_size1_(mat_internal_size1), internal_size2_(mat_internal_size2),
169 row_major_fixed_(true), row_major_(is_row_major)
173 #ifdef VIENNACL_WITH_CUDA
175 elements_.cuda_handle().reset(reinterpret_cast<char*>(ptr_to_mem));
176 elements_.cuda_handle().inc();
191 #ifdef VIENNACL_WITH_OPENCL
192 template<
class NumericT,
typename SizeT,
typename DistanceT>
194 : size1_(rows), size2_(columns),
195 start1_(0), start2_(0),
196 stride1_(1), stride2_(1),
197 internal_size1_(rows), internal_size2_(columns),
198 row_major_fixed_(true), row_major_(is_row_major)
201 elements_.opencl_handle() = mem;
202 elements_.opencl_handle().inc();
203 elements_.opencl_handle().context(ctx.opencl_context());
207 template<
class NumericT,
typename SizeT,
typename DistanceT>
209 size_type mat_size1, size_type mat_start1, size_type mat_stride1, size_type mat_internal_size1,
210 size_type mat_size2, size_type mat_start2, size_type mat_stride2, size_type mat_internal_size2,
212 : size1_(mat_size1), size2_(mat_size2),
213 start1_(mat_start1), start2_(mat_start2),
214 stride1_(mat_stride1), stride2_(mat_stride2),
215 internal_size1_(mat_internal_size1), internal_size2_(mat_internal_size2),
216 row_major_fixed_(true), row_major_(is_row_major)
219 elements_.opencl_handle() = mem;
220 elements_.opencl_handle().inc();
221 elements_.opencl_handle().context(ctx.opencl_context());
227 template<
class NumericT,
typename SizeT,
typename DistanceT>
229 size1_(other.
size1()), size2_(other.
size2()), start1_(0), start2_(0), stride1_(1), stride2_(1),
232 row_major_fixed_(true), row_major_(other.
row_major())
244 template<
typename NumericT,
typename SizeT,
typename DistanceT>
245 template<
typename OtherNumericT>
247 size1_(other.
size1()), size2_(other.
size2()), start1_(0), start2_(0), stride1_(1), stride2_(1),
250 row_major_fixed_(true), row_major_(other.
row_major())
261 template<
class NumericT,
typename SizeT,
typename DistanceT>
271 if (!row_major_fixed_)
282 template<
class NumericT,
typename SizeT,
typename DistanceT>
283 template<
typename OtherNumericT>
290 if (!row_major_fixed_)
303 template<
class NumericT,
typename SizeT,
typename DistanceT>
304 template<
typename LHS,
typename RHS,
typename OP>
309 &&
bool(
"Incompatible matrix sizes!"));
314 internal_size1_ = viennacl::tools::align_to_multiple<size_type>(size1_, dense_padding_size);
315 internal_size2_ = viennacl::tools::align_to_multiple<size_type>(size2_, dense_padding_size);
316 if (!row_major_fixed_)
319 if (size1_ != internal_size1_ || size2_ != internal_size2_)
331 template<
class NumericT,
typename SizeT,
typename DistanceT>
338 internal_size1_ = viennacl::tools::align_to_multiple<size_type>(size1_, dense_padding_size);
339 internal_size2_ = viennacl::tools::align_to_multiple<size_type>(size2_, dense_padding_size);
340 if (!row_major_fixed_)
344 if (
handle() == proxy.lhs().handle() )
348 if ( proxy.lhs().size1() != proxy.lhs().size2() )
349 this->
resize(proxy.lhs().size2(), proxy.lhs().size1());
350 elements_ = temp.handle();
354 if ( proxy.lhs().size1() != proxy.lhs().size2() )
355 this->
resize(proxy.lhs().size2(), proxy.lhs().size1(),
false);
361 template<
class NumericT,
typename SizeT,
typename DistanceT>
362 template<
typename LHS,
typename RHS,
typename OP>
367 &&
bool(
"Incompatible matrix sizes!"));
368 assert( (
size1() > 0) &&
bool(
"Vector not yet initialized!") );
369 assert( (
size2() > 0) &&
bool(
"Vector not yet initialized!") );
376 template<
class NumericT,
typename SizeT,
typename DistanceT>
377 template<
typename LHS,
typename RHS,
typename OP>
382 &&
bool(
"Incompatible matrix sizes!"));
383 assert( (
size1() > 0) &&
bool(
"Vector not yet initialized!") );
384 assert( (
size2() > 0) &&
bool(
"Vector not yet initialized!") );
392 template<
class NumericT,
typename SizeT,
typename DistanceT>
395 assert( (m.
size1() == size1_ || size1_ == 0) &&
bool(
"Size mismatch!") );
396 assert( (m.
size2() == size2_ || size2_ == 0) &&
bool(
"Size mismatch!") );
402 internal_size1_ = viennacl::tools::align_to_multiple<size_type>(size1_, dense_padding_size);
403 internal_size2_ = viennacl::tools::align_to_multiple<size_type>(size2_, dense_padding_size);
420 template<
class NumericT,
typename SizeT,
typename DistanceT>
423 assert( (m.
size1() == size1_ || size1_ == 0) &&
bool(
"Size mismatch!") );
424 assert( (m.
size2() == size2_ || size2_ == 0) &&
bool(
"Size mismatch!") );
430 internal_size1_ = viennacl::tools::align_to_multiple<size_type>(size1_, dense_padding_size);
431 internal_size2_ = viennacl::tools::align_to_multiple<size_type>(size2_, dense_padding_size);
445 template<
class NumericT,
typename SizeT,
typename DistanceT>
448 assert( (m.
size1() == size1_ || size1_ == 0) &&
bool(
"Size mismatch!") );
449 assert( (m.
size2() == size2_ || size2_ == 0) &&
bool(
"Size mismatch!") );
455 internal_size1_ = viennacl::tools::align_to_multiple<size_type>(size1_, dense_padding_size);
456 internal_size2_ = viennacl::tools::align_to_multiple<size_type>(size2_, dense_padding_size);
476 template<
class NumericT,
typename SizeT,
typename DistanceT>
486 template<
class NumericT,
typename SizeT,
typename DistanceT>
497 template<
class NumericT,
typename SizeT,
typename DistanceT>
501 *
this,
NumericT(1.0), 1,
false,
false,
502 other,
NumericT(1.0), 1,
false,
false);
506 template<
class NumericT,
typename SizeT,
typename DistanceT>
510 *
this,
NumericT(1.0), 1,
false,
false,
511 other,
NumericT(1.0), 1,
false,
true);
516 template<
class NumericT,
typename SizeT,
typename DistanceT>
520 *
this,
NumericT(val), 1,
false,
false);
525 template<
class NumericT,
typename SizeT,
typename DistanceT>
529 *
this,
NumericT(val), 1,
false,
false);
534 template<
class NumericT,
typename SizeT,
typename DistanceT>
538 *
this,
NumericT(val), 1,
false,
false);
543 template<
class NumericT,
typename SizeT,
typename DistanceT>
547 *
this,
NumericT(val), 1,
false,
false);
552 template<
class NumericT,
typename SizeT,
typename DistanceT>
556 *
this,
NumericT(val), 1,
false,
false);
561 template<
class NumericT,
typename SizeT,
typename DistanceT>
565 *
this,
NumericT(val), 1,
false,
false);
572 template<
class NumericT,
typename SizeT,
typename DistanceT>
576 *
this,
NumericT(val), 1,
true,
false);
581 template<
class NumericT,
typename SizeT,
typename DistanceT>
585 *
this,
NumericT(val), 1,
true,
false);
590 template<
class NumericT,
typename SizeT,
typename DistanceT>
594 *
this,
NumericT(val), 1,
true,
false);
599 template<
class NumericT,
typename SizeT,
typename DistanceT>
603 *
this,
NumericT(val), 1,
true,
false);
608 template<
class NumericT,
typename SizeT,
typename DistanceT>
612 *
this,
NumericT(val), 1,
true,
false);
617 template<
class NumericT,
typename SizeT,
typename DistanceT>
621 *
this,
NumericT(val), 1,
true,
false);
627 template<
class NumericT,
typename SizeT,
typename DistanceT>
633 template<
class NumericT,
typename SizeT,
typename DistanceT>
637 template<
class NumericT,
typename SizeT,
typename DistanceT>
640 assert( (rows > 0 && columns > 0) &&
bool(
"Check failed in matrix::resize(): Number of rows and columns must be positive!"));
649 std::vector< NumericT > new_entries( viennacl::tools::align_to_multiple<vcl_size_t>(rows, dense_padding_size)
650 * viennacl::tools::align_to_multiple<vcl_size_t>(columns, dense_padding_size));
661 new_entries[
row_major::mem_index(i, j, viennacl::tools::align_to_multiple<vcl_size_t>(rows, dense_padding_size), viennacl::tools::align_to_multiple<vcl_size_t>(columns, dense_padding_size))]
664 new_entries[
column_major::mem_index(i, j, viennacl::tools::align_to_multiple<vcl_size_t>(rows, dense_padding_size), viennacl::tools::align_to_multiple<vcl_size_t>(columns, dense_padding_size))]
672 internal_size1_ = viennacl::tools::align_to_multiple<size_type>(size1_, dense_padding_size);
673 internal_size2_ = viennacl::tools::align_to_multiple<size_type>(size2_, dense_padding_size);
680 internal_size1_ = viennacl::tools::align_to_multiple<size_type>(size1_, dense_padding_size);
681 internal_size2_ = viennacl::tools::align_to_multiple<size_type>(size2_, dense_padding_size);
695 template<
class NumericT,
typename F,
unsigned int AlignmentV>
725 viennacl::is_row_major<F>::value) {}
741 rows, 0, 1, internal_row_count,
742 cols, 0, 1, internal_col_count,
743 true, viennacl::is_row_major<F>::value) {}
745 #ifdef VIENNACL_WITH_OPENCL
746 explicit matrix(cl_mem mem,
size_type rows,
size_type columns) : base_type(mem, rows, columns, viennacl::is_row_major<F>::value) {}
749 template<
typename LHS,
typename RHS,
typename OP>
794 using base_type::operator=;
797 template<
typename OtherNumericT,
typename F2>
800 template<
typename OtherNumericT,
typename F2>
803 template<
typename OtherNumericT,
typename F2>
827 template<
class NumericT>
828 std::ostream & operator<<(std::ostream & s, const matrix_base<NumericT> & gpu_matrix)
832 std::vector<NumericT> tmp(gpu_matrix.internal_size());
835 s <<
"[" << gpu_matrix.size1() <<
"," << gpu_matrix.size2() <<
"]";
838 for (size_type i = 0; i < gpu_matrix.size1(); ++i)
841 for (size_type j = 0; j < gpu_matrix.size2(); ++j)
843 if (gpu_matrix.row_major())
844 s << tmp[
row_major::mem_index(i * gpu_matrix.stride1() + gpu_matrix.start1(), j * gpu_matrix.stride2() + gpu_matrix.start2(), gpu_matrix.internal_size1(), gpu_matrix.internal_size2())];
846 s << tmp[
column_major::mem_index(i * gpu_matrix.stride1() + gpu_matrix.start1(), j * gpu_matrix.stride2() + gpu_matrix.start2(), gpu_matrix.internal_size1(), gpu_matrix.internal_size2())];
848 if (j < gpu_matrix.size2() - 1)
852 if (i < gpu_matrix.size1() - 1)
864 template<
typename LHS,
typename RHS,
typename OP>
865 std::ostream & operator<<(std::ostream & s, const matrix_expression<LHS, RHS, OP> & expr)
875 template<
typename NumericT>
876 matrix_expression< const matrix_base<NumericT>,
const matrix_base<NumericT>, op_trans>
883 template<
typename LhsT,
typename RhsT,
typename OpT>
884 matrix_expression< const matrix_expression<const LhsT, const RhsT, OpT>,
const matrix_expression<const LhsT, const RhsT, OpT>, op_trans>
893 template<
typename NumericT>
894 vector_expression< const matrix_base<NumericT>,
const int, op_matrix_diag>
900 template<
typename NumericT>
901 matrix_expression< const vector_base<NumericT>,
const int, op_vector_diag>
908 template<
typename NumericT,
typename F>
909 vector_expression< const matrix_base<NumericT, F>,
const unsigned int, op_row>
916 template<
typename NumericT,
typename F>
917 vector_expression< const matrix_base<NumericT, F>,
const unsigned int, op_column>
933 template<
typename CPUMatrixT,
typename NumericT,
typename F,
unsigned int AlignmentV>
934 void copy(
const CPUMatrixT & cpu_matrix,
941 if (gpu_matrix.
size1() == 0 || gpu_matrix.
size2() == 0)
943 gpu_matrix.
resize(cpu_matrix.size1(),
944 cpu_matrix.size2(),
false);
947 assert( (gpu_matrix.
size1() == cpu_matrix.size1()) && (gpu_matrix.
size2() == cpu_matrix.size2()) &&
bool(
"Matrix dimensions mismatch.") );
950 for (size_type i = 0; i < gpu_matrix.
size1(); ++i)
952 for (size_type j = 0; j < gpu_matrix.
size2(); ++j)
969 template<
typename NumericT,
typename A1,
typename A2,
typename F,
unsigned int AlignmentV>
970 void copy(
const std::vector< std::vector<NumericT, A1>, A2> & cpu_matrix,
975 if (gpu_matrix.
size1() == 0 || gpu_matrix.
size2() == 0)
977 gpu_matrix.
resize(cpu_matrix.size(),
978 cpu_matrix[0].size(),
982 assert( (gpu_matrix.
size1() == cpu_matrix.size()) &&
bool(
"Matrix dimensions mismatch.") );
985 for (size_type i = 0; i < gpu_matrix.
size1(); ++i)
987 assert( (gpu_matrix.
size2() == cpu_matrix[i].size()) &&
bool(
"Matrix dimensions mismatch.") );
989 for (size_type j = 0; j < gpu_matrix.
size2(); ++j)
1009 template<
typename NumericT,
typename F,
unsigned int AlignmentV>
1018 assert( (gpu_matrix.
internal_size() >=
static_cast<vcl_size_t>(cpu_matrix_end - cpu_matrix_begin)) && bool(
"fast_copy(): Matrix not large enough to fit data!"));
1023 #ifdef VIENNACL_WITH_ARMADILLO
1029 template<
typename NumericT,
typename F,
unsigned int AlignmentV>
1030 void copy(arma::Mat<NumericT>
const & arma_matrix,
1035 if (vcl_matrix.
size1() == 0 || vcl_matrix.
size2() == 0)
1037 vcl_matrix.
resize(arma_matrix.n_rows,
1043 assert( (vcl_matrix.
size1() ==
static_cast<vcl_size_t>(arma_matrix.n_rows))
1044 && (vcl_matrix.
size2() ==
static_cast<vcl_size_t>(arma_matrix.n_cols))
1045 && bool(
"matrix size mismatch")
1051 for (size_type j = 0; j < vcl_matrix.
size2(); ++j)
1052 for (size_type i = 0; i < vcl_matrix.
size1(); ++i)
1060 #ifdef VIENNACL_WITH_EIGEN
1063 template<
typename EigenMatrixTypeT,
typename NumericT,
typename F,
unsigned int AlignmentV>
1064 void copy_from_eigen_matrix(EigenMatrixTypeT
const & cpu_matrix,
1069 if (gpu_matrix.
size1() == 0 || gpu_matrix.
size2() == 0)
1071 gpu_matrix.
resize(cpu_matrix.rows(),
1077 assert( (gpu_matrix.
size1() ==
static_cast<vcl_size_t>(cpu_matrix.rows()))
1079 && bool(
"matrix size mismatch")
1084 for (size_type i = 0; i < gpu_matrix.
size1(); ++i)
1086 for (size_type j = 0; j < gpu_matrix.
size2(); ++j)
1100 template<
typename NumericT,
int EigenOptions,
typename F,
unsigned int AlignmentV>
1101 void copy(Eigen::Matrix<NumericT, Eigen::Dynamic, Eigen::Dynamic, EigenOptions>
const & cpu_matrix,
1104 detail::copy_from_eigen_matrix(cpu_matrix, vcl_matrix);
1112 template<
typename NumericT,
int EigenOptions,
int EigenMatTypeV,
typename EigenStr
ideT,
typename F,
unsigned int AlignmentV>
1113 void copy(Eigen::Map<Eigen::Matrix<NumericT, Eigen::Dynamic, Eigen::Dynamic, EigenOptions>, EigenMatTypeV, EigenStrideT>
const & cpu_matrix,
1116 detail::copy_from_eigen_matrix(cpu_matrix, vcl_matrix);
1120 #ifdef VIENNACL_WITH_MTL4
1126 template<
typename NumericT,
typename T,
typename F,
unsigned int AlignmentV>
1127 void copy(
const mtl::dense2D<NumericT, T>& cpu_matrix,
1128 matrix<NumericT, F, AlignmentV> & gpu_matrix)
1130 typedef typename matrix<NumericT, F, AlignmentV>::size_type size_type;
1132 if (gpu_matrix.size1() == 0 || gpu_matrix.size2() == 0)
1134 gpu_matrix.resize(cpu_matrix.num_rows(),
1135 cpu_matrix.num_cols(),
1140 assert( (gpu_matrix.size1() == cpu_matrix.num_rows())
1141 && (gpu_matrix.size2() == cpu_matrix.num_cols())
1142 &&
bool(
"matrix size mismatch")
1146 std::vector<NumericT> data(gpu_matrix.internal_size());
1147 for (size_type i = 0; i < gpu_matrix.size1(); ++i)
1149 for (size_type j = 0; j < gpu_matrix.size2(); ++j)
1150 data[F::mem_index(i, j, gpu_matrix.internal_size1(), gpu_matrix.internal_size2())] = cpu_matrix[i][j];
1169 template<
typename CPUMatrixT,
typename NumericT,
typename F,
unsigned int AlignmentV>
1171 CPUMatrixT & cpu_matrix )
1175 if ( (gpu_matrix.
size1() > 0) && (gpu_matrix.
size2() > 0) )
1179 std::vector<NumericT> temp_buffer(gpu_matrix.
internal_size());
1183 for (size_type i = 0; i < gpu_matrix.
size1(); ++i)
1186 for (size_type j = 0; j < gpu_matrix.
size2(); ++j)
1198 template<
typename NumericT,
typename A1,
typename A2,
typename F,
unsigned int AlignmentV>
1200 std::vector< std::vector<NumericT, A1>, A2> & cpu_matrix)
1204 if ( (gpu_matrix.
size1() > 0) && (gpu_matrix.
size2() > 0) )
1206 assert( (cpu_matrix.size() == gpu_matrix.
size1()) &&
bool(
"Matrix dimensions mismatch: rows"));
1208 std::vector<NumericT> temp_buffer(gpu_matrix.
internal_size());
1212 for (size_type i = 0; i < gpu_matrix.
size1(); ++i)
1214 assert( (cpu_matrix[i].
size() == gpu_matrix.
size2()) &&
bool(
"Matrix dimensions mismatch: columns"));
1216 for (size_type j = 0; j < gpu_matrix.
size2(); ++j)
1230 template<
typename NumericT,
typename F,
unsigned int AlignmentV>
1244 template<
typename LHS1,
typename RHS1,
typename OP1,
1245 typename LHS2,
typename RHS2,
typename OP2>
1246 matrix_expression< const matrix_expression<const LHS1, const RHS1, OP1>,
1247 const matrix_expression<const LHS2, const RHS2, OP2>,
1254 &&
bool(
"Incompatible matrix sizes!"));
1260 template<
typename LHS1,
typename RHS1,
typename OP1,
1262 matrix_expression< const matrix_expression<const LHS1, const RHS1, OP1>,
1263 const matrix_base<NumericT>,
1270 &&
bool(
"Incompatible matrix sizes!"));
1277 typename LHS2,
typename RHS2,
typename OP2>
1278 matrix_expression< const matrix_base<NumericT>,
1279 const matrix_expression<const LHS2, const RHS2, OP2>,
1286 &&
bool(
"Incompatible matrix sizes!"));
1293 template<
typename NumericT>
1294 matrix_expression< const matrix_base<NumericT>,
const matrix_base<NumericT>, op_add >
1304 template<
typename LHS1,
typename RHS1,
typename OP1,
1305 typename LHS2,
typename RHS2,
typename OP2>
1306 matrix_expression< const matrix_expression<const LHS1, const RHS1, OP1>,
1307 const matrix_expression<const LHS2, const RHS2, OP2>,
1314 &&
bool(
"Incompatible matrix sizes!"));
1320 template<
typename LHS1,
typename RHS1,
typename OP1,
1322 matrix_expression< const matrix_expression<const LHS1, const RHS1, OP1>,
1323 const matrix_base<NumericT>,
1330 &&
bool(
"Incompatible matrix sizes!"));
1337 typename LHS2,
typename RHS2,
typename OP2>
1338 matrix_expression< const matrix_base<NumericT>,
1339 const matrix_expression<const LHS2, const RHS2, OP2>,
1346 &&
bool(
"Incompatible matrix sizes!"));
1353 template<
typename NumericT>
1354 matrix_expression< const matrix_base<NumericT>,
const matrix_base<NumericT>, op_sub >
1370 template<
typename S1,
typename NumericT>
1372 matrix_expression< const matrix_base<NumericT>,
const S1, op_mult>
1380 template<
typename NumericT>
1381 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_mult>
1388 template<
typename NumericT>
1389 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_mult>
1396 template<
typename NumericT>
1397 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_mult>
1404 template<
typename NumericT>
1405 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_mult>
1412 template<
typename NumericT>
1413 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_mult>
1420 template<
typename NumericT>
1421 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_mult>
1434 template<
typename LHS,
typename RHS,
typename OP,
typename S1>
1436 matrix_expression< const matrix_expression< LHS, RHS, OP>,
const S1, op_mult> >::type
1449 template<
typename S1,
typename LHS,
typename RHS,
typename OP>
1451 matrix_expression< const matrix_expression< LHS, RHS, OP>,
const S1, op_mult> >::type
1460 template<
typename NumericT,
typename S1>
1462 matrix_expression< const matrix_base<NumericT>,
const S1, op_mult> >::type
1469 template<
typename NumericT>
1470 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_mult>
1477 template<
typename NumericT>
1478 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_mult>
1485 template<
typename NumericT>
1486 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_mult>
1493 template<
typename NumericT>
1494 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_mult>
1501 template<
typename NumericT>
1502 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_mult>
1509 template<
typename NumericT>
1510 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_mult>
1520 template<
typename NumericT,
typename S1>
1526 m1, gpu_val, 1,
false, is_sign_flip ?
true :
false);
1531 template<
typename NumericT>
1532 matrix_base<NumericT> &
1536 m1,
NumericT(gpu_val), 1,
false,
false);
1541 template<
typename NumericT>
1542 matrix_base<NumericT> &
1546 m1,
NumericT(gpu_val), 1,
false,
false);
1551 template<
typename NumericT>
1552 matrix_base<NumericT> &
1556 m1,
NumericT(gpu_val), 1,
false,
false);
1561 template<
typename NumericT>
1562 matrix_base<NumericT> &
1566 m1,
NumericT(gpu_val), 1,
false,
false);
1571 template<
typename NumericT>
1572 matrix_base<NumericT> &
1576 m1,
NumericT(gpu_val), 1,
false,
false);
1581 template<
typename NumericT>
1582 matrix_base<NumericT> &
1586 m1,
NumericT(gpu_val), 1,
false,
false);
1600 template<
typename LHS,
typename RHS,
typename OP,
typename S1>
1602 matrix_expression< const matrix_expression<const LHS, const RHS, OP>,
const S1, op_div> >::type
1611 template<
typename NumericT,
typename S1>
1613 matrix_expression< const matrix_base<NumericT>,
const S1, op_div> >::type
1620 template<
typename NumericT>
1621 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_div>
1628 template<
typename NumericT>
1629 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_div>
1636 template<
typename NumericT>
1637 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_div>
1644 template<
typename NumericT>
1645 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_div>
1652 template<
typename NumericT>
1653 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_div>
1660 template<
typename NumericT>
1661 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_div>
1672 template<
typename NumericT,
typename S1>
1677 m1, gpu_val, 1,
true,
false);
1682 template<
typename NumericT>
1683 matrix_base<NumericT> &
1687 m1,
NumericT(gpu_val), 1,
true,
false);
1692 template<
typename NumericT>
1693 matrix_base<NumericT> &
1697 m1, gpu_val, 1,
true,
false);
1702 template<
typename NumericT>
1703 matrix_base<NumericT> &
1707 m1, gpu_val, 1,
true,
false);
1712 template<
typename NumericT>
1713 matrix_base<NumericT> &
1717 m1, gpu_val, 1,
true,
false);
1722 template<
typename NumericT>
1723 matrix_base<NumericT> &
1727 m1, gpu_val, 1,
true,
false);
1732 template<
typename NumericT>
1733 matrix_base<NumericT> &
1737 m1, gpu_val, 1,
true,
false);
1746 template<
typename NumericT,
typename S1>
1760 template<
typename NumericT,
typename S1>
1775 template<
typename NumericT,
typename S1>
1789 template<
typename NumericT,
typename S1>
1817 template<
typename T>
1818 struct op_executor<matrix_base<T>,
op_assign, matrix_base<T> >
1820 static void apply(matrix_base<T> & lhs, matrix_base<T>
const & rhs)
1827 template<
typename T>
1828 struct op_executor<matrix_base<T>,
op_assign, matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans> >
1830 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>
const & rhs)
1832 matrix_base<T> temp(rhs);
1838 template<
typename T,
typename LhsT,
typename RhsT,
typename OpT>
1839 struct op_executor<matrix_base<T>,
op_assign, matrix_expression<const matrix_expression<const LhsT, const RhsT, OpT>, const matrix_expression<const LhsT, const RhsT, OpT>, op_trans> >
1841 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LhsT, const RhsT, OpT>,
1842 const matrix_expression<const LhsT, const RhsT, OpT>,
1843 op_trans>
const & rhs)
1845 matrix_base<T> temp1(rhs.rhs());
1853 template<
typename T>
1854 struct op_executor<matrix_base<T>, op_inplace_add, matrix_base<T> >
1856 static void apply(matrix_base<T> & lhs, matrix_base<T>
const & rhs)
1858 viennacl::linalg::ambm(lhs, lhs, T(1), 1,
false,
false, rhs, T(1), 1,
false,
false);
1863 template<
typename T>
1864 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans> >
1866 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>
const & rhs)
1868 matrix_base<T> temp(rhs);
1869 viennacl::linalg::ambm(lhs, lhs, T(1), 1,
false,
false, temp, T(1), 1,
false,
false);
1874 template<
typename T,
typename LhsT,
typename RhsT,
typename OpT>
1875 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression<const matrix_expression<const LhsT, const RhsT, OpT>, const matrix_expression<const LhsT, const RhsT, OpT>, op_trans> >
1877 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LhsT, const RhsT, OpT>,
1878 const matrix_expression<const LhsT, const RhsT, OpT>,
1879 op_trans>
const & rhs)
1881 matrix_base<T> temp1(rhs.rhs());
1883 viennacl::linalg::ambm(lhs, lhs, T(1), 1,
false,
false, temp2, T(1), 1,
false,
false);
1888 template<
typename T>
1889 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_base<T> >
1891 static void apply(matrix_base<T> & lhs, matrix_base<T>
const & rhs)
1893 viennacl::linalg::ambm(lhs, lhs, T(1), 1,
false,
false, rhs, T(1), 1,
false,
true);
1898 template<
typename T>
1899 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans> >
1901 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>
const & rhs)
1903 matrix_base<T> temp(rhs);
1904 viennacl::linalg::ambm(lhs, lhs, T(1), 1,
false,
false, temp, T(1), 1,
false,
true);
1909 template<
typename T,
typename LhsT,
typename RhsT,
typename OpT>
1910 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression<const matrix_expression<const LhsT, const RhsT, OpT>, const matrix_expression<const LhsT, const RhsT, OpT>, op_trans> >
1912 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LhsT, const RhsT, OpT>,
1913 const matrix_expression<const LhsT, const RhsT, OpT>,
1914 op_trans>
const & rhs)
1916 matrix_base<T> temp1(rhs.rhs());
1918 viennacl::linalg::ambm(lhs, lhs, T(1), 1,
false,
false, temp2, T(1), 1,
false,
true);
1926 template<
typename T,
typename ScalarType>
1927 struct op_executor<matrix_base<T>,
op_assign, matrix_expression<const matrix_base<T>, const
ScalarType, op_mult> >
1929 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>
const & proxy)
1936 template<
typename T,
typename ScalarType>
1937 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression<const matrix_base<T>, const
ScalarType, op_mult> >
1939 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>
const & proxy)
1941 viennacl::linalg::ambm(lhs, lhs, T(1), 1,
false,
false, proxy.lhs(), proxy.rhs(), 1,
false,
false);
1946 template<
typename T,
typename ScalarType>
1947 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression<const matrix_base<T>, const
ScalarType, op_mult> >
1949 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>
const & proxy)
1951 viennacl::linalg::ambm(lhs, lhs, T(1), 1,
false,
false, proxy.lhs(), proxy.rhs(), 1,
false,
true);
1959 template<
typename T,
typename LHS,
typename RHS,
typename OP,
typename ScalarType>
1960 struct op_executor<matrix_base<T>,
op_assign, matrix_expression<const matrix_expression<const LHS, const RHS, OP>, const
ScalarType, op_mult> >
1962 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LHS, const RHS, OP>,
const ScalarType, op_mult>
const & proxy)
1964 if (lhs.row_major())
1966 matrix<T> temp(proxy.lhs());
1967 lhs = temp * proxy.rhs();
1971 matrix<T, column_major> temp(proxy.lhs());
1972 lhs = temp * proxy.rhs();
1978 template<
typename T,
typename LHS,
typename RHS,
typename OP,
typename ScalarType>
1979 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression<const matrix_expression<const LHS, const RHS, OP>, const
ScalarType, op_mult> >
1981 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LHS, const RHS, OP>,
const ScalarType, op_mult>
const & proxy)
1983 if (lhs.row_major())
1985 matrix<T> temp(proxy.lhs());
1986 lhs += temp * proxy.rhs();
1990 matrix<T, column_major> temp(proxy.lhs());
1991 lhs += temp * proxy.rhs();
1997 template<
typename T,
typename LHS,
typename RHS,
typename OP,
typename ScalarType>
1998 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression<const matrix_expression<const LHS, const RHS, OP>, const
ScalarType, op_mult> >
2000 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LHS, const RHS, OP>,
const ScalarType, op_mult>
const & proxy)
2002 if (lhs.row_major())
2004 matrix<T> temp(proxy.lhs());
2005 lhs -= temp * proxy.rhs();
2009 matrix<T, column_major> temp(proxy.lhs());
2010 lhs -= temp * proxy.rhs();
2019 template<
typename T,
typename ScalarType>
2020 struct op_executor<matrix_base<T>,
op_assign, matrix_expression<const matrix_base<T>, const
ScalarType, op_div> >
2022 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>
const & proxy)
2029 template<
typename T,
typename ScalarType>
2030 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression<const matrix_base<T>, const
ScalarType, op_div> >
2032 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>
const & proxy)
2034 viennacl::linalg::ambm(lhs, lhs, T(1), 1,
false,
false, proxy.lhs(), proxy.rhs(), 1,
true,
false);
2039 template<
typename T,
typename ScalarType>
2040 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression<const matrix_base<T>, const
ScalarType, op_div> >
2042 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>
const & proxy)
2044 viennacl::linalg::ambm(lhs, lhs, T(1), 1,
false,
false, proxy.lhs(), proxy.rhs(), 1,
true,
true);
2052 template<
typename T,
typename LHS,
typename RHS,
typename OP,
typename ScalarType>
2053 struct op_executor<matrix_base<T>,
op_assign, matrix_expression<const matrix_expression<const LHS, const RHS, OP>, const
ScalarType, op_div> >
2055 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LHS, const RHS, OP>,
const ScalarType, op_div>
const & proxy)
2057 if (lhs.row_major())
2059 matrix<T> temp(proxy.lhs());
2060 lhs = temp / proxy.rhs();
2064 matrix<T, column_major> temp(proxy.lhs());
2065 lhs = temp / proxy.rhs();
2071 template<
typename T,
typename LHS,
typename RHS,
typename OP,
typename ScalarType>
2072 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression<const matrix_expression<const LHS, const RHS, OP>, const
ScalarType, op_div> >
2074 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LHS, const RHS, OP>,
const ScalarType, op_div>
const & proxy)
2076 if (lhs.row_major())
2078 matrix<T> temp(proxy.lhs());
2079 lhs += temp / proxy.rhs();
2083 matrix<T, column_major> temp(proxy.lhs());
2084 lhs += temp / proxy.rhs();
2090 template<
typename T,
typename LHS,
typename RHS,
typename OP,
typename ScalarType>
2091 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression<const matrix_expression<const LHS, const RHS, OP>, const
ScalarType, op_div> >
2093 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LHS, const RHS, OP>,
const ScalarType, op_div>
const & proxy)
2095 if (lhs.row_major())
2097 matrix<T, row_major> temp(proxy.lhs());
2098 lhs -= temp / proxy.rhs();
2102 matrix<T, column_major> temp(proxy.lhs());
2103 lhs -= temp / proxy.rhs();
2111 template<
typename T,
typename LHS,
typename RHS>
2112 struct op_executor<matrix_base<T>,
op_assign, matrix_expression<const LHS, const RHS, op_add> >
2115 template<
typename LHS1,
typename RHS1>
2116 static void apply(matrix_base<T> & lhs, matrix_expression<const LHS1, const RHS1, op_add>
const & proxy)
2118 bool op_aliasing_lhs =
op_aliasing(lhs, proxy.lhs());
2119 bool op_aliasing_rhs =
op_aliasing(lhs, proxy.rhs());
2121 if (op_aliasing_lhs || op_aliasing_rhs)
2123 matrix_base<T> temp(proxy.lhs());
2124 op_executor<matrix_base<T>, op_inplace_add, RHS>::apply(temp, proxy.rhs());
2129 op_executor<matrix_base<T>,
op_assign, LHS>::apply(lhs, proxy.lhs());
2130 op_executor<matrix_base<T>, op_inplace_add, RHS>::apply(lhs, proxy.rhs());
2135 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_add>
const & proxy)
2138 proxy.lhs(), T(1), 1,
false,
false,
2139 proxy.rhs(), T(1), 1,
false,
false);
2143 template<
typename ScalarType>
2144 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>,
2145 const matrix_base<T>,
2146 op_add>
const & proxy)
2149 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2150 proxy.rhs(), T(1), 1,
false,
false);
2154 template<
typename ScalarType>
2155 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>,
2156 const matrix_base<T>,
2157 op_add>
const & proxy)
2160 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2161 proxy.rhs(), T(1), 1,
false,
false);
2165 template<
typename ScalarType>
2166 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
2167 const matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>,
2168 op_add>
const & proxy)
2171 proxy.lhs(), T(1), 1,
false,
false,
2172 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
false);
2176 template<
typename ScalarType>
2177 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
2178 const matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>,
2179 op_add>
const & proxy)
2182 proxy.lhs(), T(1), 1,
false,
false,
2183 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
false);
2187 template<
typename ScalarType1,
typename ScalarType2>
2188 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_mult>,
2189 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_mult>,
2190 op_add>
const & proxy)
2193 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2194 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
false);
2198 template<
typename ScalarType1,
typename ScalarType2>
2199 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_mult>,
2200 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_div>,
2201 op_add>
const & proxy)
2204 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2205 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
false);
2209 template<
typename ScalarType1,
typename ScalarType2>
2210 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_div>,
2211 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_mult>,
2212 op_add>
const & proxy)
2215 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2216 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
false);
2220 template<
typename ScalarType1,
typename ScalarType2>
2221 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_div>,
2222 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_div>,
2223 op_add>
const & proxy)
2226 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2227 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
false);
2232 template<
typename T,
typename LHS,
typename RHS>
2233 struct op_executor<matrix_base<T>, op_assign, matrix_expression<const LHS, const RHS, op_prod> >
2235 template<
typename SparseMatrixType>
2236 static void apply(matrix_base<T> & lhs, matrix_expression<
const SparseMatrixType,
2243 matrix_base<T> temp(proxy);
2251 template<
typename SparseMatrixType >
2252 static void apply(matrix_base<T> & lhs, matrix_expression<
const SparseMatrixType,
2261 matrix_base<T> temp(proxy);
2271 template<
typename T,
typename LHS,
typename RHS>
2272 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression<const LHS, const RHS, op_add> >
2275 template<
typename LHS1,
typename RHS1>
2276 static void apply(matrix_base<T> & lhs, matrix_expression<const LHS1, const RHS1, op_add>
const & proxy)
2278 bool op_aliasing_lhs =
op_aliasing(lhs, proxy.lhs());
2279 bool op_aliasing_rhs =
op_aliasing(lhs, proxy.rhs());
2281 if (op_aliasing_lhs || op_aliasing_rhs)
2283 matrix_base<T> temp(proxy.lhs());
2284 op_executor<matrix_base<T>, op_inplace_add, RHS>::apply(temp, proxy.rhs());
2289 op_executor<matrix_base<T>, op_inplace_add, LHS>::apply(lhs, proxy.lhs());
2290 op_executor<matrix_base<T>, op_inplace_add, RHS>::apply(lhs, proxy.rhs());
2295 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_add>
const & proxy)
2298 proxy.lhs(), T(1), 1,
false,
false,
2299 proxy.rhs(), T(1), 1,
false,
false);
2303 template<
typename ScalarType>
2304 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>,
2305 const matrix_base<T>,
2306 op_add>
const & proxy)
2309 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2310 proxy.rhs(), T(1), 1,
false,
false);
2314 template<
typename ScalarType>
2315 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>,
2316 const matrix_base<T>,
2317 op_add>
const & proxy)
2320 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2321 proxy.rhs(), T(1), 1,
false,
false);
2325 template<
typename ScalarType>
2326 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
2327 const matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>,
2328 op_add>
const & proxy)
2331 proxy.lhs(), T(1), 1,
false,
false,
2332 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
false);
2336 template<
typename ScalarType>
2337 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
2338 const matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>,
2339 op_add>
const & proxy)
2342 proxy.lhs(), T(1), 1,
false,
false,
2343 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
false);
2347 template<
typename ScalarType1,
typename ScalarType2>
2348 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_mult>,
2349 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_mult>,
2350 op_add>
const & proxy)
2353 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2354 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
false);
2358 template<
typename ScalarType1,
typename ScalarType2>
2359 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_mult>,
2360 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_div>,
2361 op_add>
const & proxy)
2364 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2365 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
false);
2369 template<
typename ScalarType1,
typename ScalarType2>
2370 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_div>,
2371 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_mult>,
2372 op_add>
const & proxy)
2375 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2376 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
false);
2380 template<
typename ScalarType1,
typename ScalarType2>
2381 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_div>,
2382 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_div>,
2383 op_add>
const & proxy)
2386 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2387 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
false);
2394 template<
typename T,
typename LHS,
typename RHS>
2395 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression<const LHS, const RHS, op_add> >
2398 template<
typename LHS1,
typename RHS1>
2399 static void apply(matrix_base<T> & lhs, matrix_expression<const LHS1, const RHS1, op_add>
const & proxy)
2401 bool op_aliasing_lhs =
op_aliasing(lhs, proxy.lhs());
2402 bool op_aliasing_rhs =
op_aliasing(lhs, proxy.rhs());
2404 if (op_aliasing_lhs || op_aliasing_rhs)
2406 matrix_base<T> temp(proxy.lhs());
2407 op_executor<matrix_base<T>, op_inplace_add, RHS>::apply(temp, proxy.rhs());
2412 op_executor<matrix_base<T>, op_inplace_sub, LHS>::apply(lhs, proxy.lhs());
2413 op_executor<matrix_base<T>, op_inplace_sub, RHS>::apply(lhs, proxy.rhs());
2418 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_add>
const & proxy)
2421 proxy.lhs(), T(1), 1,
false,
true,
2422 proxy.rhs(), T(1), 1,
false,
true);
2426 template<
typename ScalarType>
2427 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>,
2428 const matrix_base<T>,
2429 op_add>
const & proxy)
2432 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
true,
2433 proxy.rhs(), T(1), 1,
false,
true);
2437 template<
typename ScalarType>
2438 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>,
2439 const matrix_base<T>,
2440 op_add>
const & proxy)
2443 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
true,
2444 proxy.rhs(), T(1), 1,
false,
true);
2448 template<
typename ScalarType>
2449 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
2450 const matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>,
2451 op_add>
const & proxy)
2454 proxy.lhs(), T(1), 1,
false,
true,
2455 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
true);
2459 template<
typename ScalarType>
2460 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
2461 const matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>,
2462 op_add>
const & proxy)
2465 proxy.lhs(), T(1), 1,
false,
true,
2466 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
true);
2470 template<
typename ScalarType1,
typename ScalarType2>
2471 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_mult>,
2472 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_mult>,
2473 op_add>
const & proxy)
2476 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
true,
2477 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
true);
2481 template<
typename ScalarType1,
typename ScalarType2>
2482 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_mult>,
2483 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_div>,
2484 op_add>
const & proxy)
2487 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
true,
2488 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
true);
2492 template<
typename ScalarType1,
typename ScalarType2>
2493 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_div>,
2494 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_mult>,
2495 op_add>
const & proxy)
2498 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
true,
2499 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
true);
2503 template<
typename ScalarType1,
typename ScalarType2>
2504 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_div>,
2505 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_div>,
2506 op_add>
const & proxy)
2509 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
true,
2510 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
true);
2521 template<
typename T,
typename LHS,
typename RHS>
2522 struct op_executor<matrix_base<T>, op_assign, matrix_expression<const LHS, const RHS, op_sub> >
2525 template<
typename LHS1,
typename RHS1>
2526 static void apply(matrix_base<T> & lhs, matrix_expression<const LHS1, const RHS1, op_sub>
const & proxy)
2528 bool op_aliasing_lhs =
op_aliasing(lhs, proxy.lhs());
2529 bool op_aliasing_rhs =
op_aliasing(lhs, proxy.rhs());
2531 if (op_aliasing_lhs || op_aliasing_rhs)
2533 matrix_base<T> temp(proxy.lhs());
2534 op_executor<matrix_base<T>, op_inplace_sub, RHS>::apply(temp, proxy.rhs());
2539 op_executor<matrix_base<T>, op_assign, LHS>::apply(lhs, proxy.lhs());
2540 op_executor<matrix_base<T>, op_inplace_sub, RHS>::apply(lhs, proxy.rhs());
2545 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_sub>
const & proxy)
2548 proxy.lhs(), T(1), 1,
false,
false,
2549 proxy.rhs(), T(1), 1,
false,
true);
2553 template<
typename ScalarType>
2554 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>,
2555 const matrix_base<T>,
2556 op_sub>
const & proxy)
2559 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2560 proxy.rhs(), T(1), 1,
false,
true);
2564 template<
typename ScalarType>
2565 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>,
2566 const matrix_base<T>,
2567 op_sub>
const & proxy)
2570 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2571 proxy.rhs(), T(1), 1,
false,
true);
2575 template<
typename ScalarType>
2576 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
2577 const matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>,
2578 op_sub>
const & proxy)
2581 proxy.lhs(), T(1), 1,
false,
false,
2582 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
true);
2586 template<
typename ScalarType>
2587 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
2588 const matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>,
2589 op_sub>
const & proxy)
2592 proxy.lhs(), T(1), 1,
false,
false,
2593 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
true);
2597 template<
typename ScalarType1,
typename ScalarType2>
2598 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_mult>,
2599 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_mult>,
2600 op_sub>
const & proxy)
2603 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2604 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
true);
2608 template<
typename ScalarType1,
typename ScalarType2>
2609 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_mult>,
2610 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_div>,
2611 op_sub>
const & proxy)
2614 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2615 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
true);
2619 template<
typename ScalarType1,
typename ScalarType2>
2620 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_div>,
2621 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_mult>,
2622 op_sub>
const & proxy)
2625 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2626 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
true);
2630 template<
typename ScalarType1,
typename ScalarType2>
2631 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_div>,
2632 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_div>,
2633 op_sub>
const & proxy)
2636 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2637 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
true);
2643 template<
typename T,
typename LHS,
typename RHS>
2644 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression<const LHS, const RHS, op_sub> >
2647 template<
typename LHS1,
typename RHS1>
2648 static void apply(matrix_base<T> & lhs, matrix_expression<const LHS1, const RHS1, op_sub>
const & proxy)
2650 bool op_aliasing_lhs =
op_aliasing(lhs, proxy.lhs());
2651 bool op_aliasing_rhs =
op_aliasing(lhs, proxy.rhs());
2653 if (op_aliasing_lhs || op_aliasing_rhs)
2655 matrix_base<T> temp(proxy.lhs());
2656 op_executor<matrix_base<T>, op_inplace_sub, RHS>::apply(temp, proxy.rhs());
2661 op_executor<matrix_base<T>, op_inplace_add, LHS>::apply(lhs, proxy.lhs());
2662 op_executor<matrix_base<T>, op_inplace_sub, RHS>::apply(lhs, proxy.rhs());
2667 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_sub>
const & proxy)
2670 proxy.lhs(), T(1), 1,
false,
false,
2671 proxy.rhs(), T(1), 1,
false,
true);
2675 template<
typename ScalarType>
2676 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>,
2677 const matrix_base<T>,
2678 op_sub>
const & proxy)
2681 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2682 proxy.rhs(), T(1), 1,
false,
true);
2686 template<
typename ScalarType>
2687 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>,
2688 const matrix_base<T>,
2689 op_sub>
const & proxy)
2692 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2693 proxy.rhs(), T(1), 1,
false,
true);
2697 template<
typename ScalarType>
2698 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
2699 const matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>,
2700 op_sub>
const & proxy)
2703 proxy.lhs(), T(1), 1,
false,
false,
2704 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
true);
2708 template<
typename ScalarType>
2709 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
2710 const matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>,
2711 op_sub>
const & proxy)
2714 proxy.lhs(), T(1), 1,
false,
false,
2715 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
true);
2719 template<
typename ScalarType1,
typename ScalarType2>
2720 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_mult>,
2721 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_mult>,
2722 op_sub>
const & proxy)
2725 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2726 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
true);
2730 template<
typename ScalarType1,
typename ScalarType2>
2731 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_mult>,
2732 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_div>,
2733 op_sub>
const & proxy)
2736 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2737 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
true);
2741 template<
typename ScalarType1,
typename ScalarType2>
2742 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_div>,
2743 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_mult>,
2744 op_sub>
const & proxy)
2747 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2748 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
true);
2752 template<
typename ScalarType1,
typename ScalarType2>
2753 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_div>,
2754 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_div>,
2755 op_sub>
const & proxy)
2758 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2759 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
true);
2766 template<
typename T,
typename LHS,
typename RHS>
2767 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression<const LHS, const RHS, op_sub> >
2770 template<
typename LHS1,
typename RHS1>
2771 static void apply(matrix_base<T> & lhs, matrix_expression<const LHS1, const RHS1, op_sub>
const & proxy)
2773 bool op_aliasing_lhs =
op_aliasing(lhs, proxy.lhs());
2774 bool op_aliasing_rhs =
op_aliasing(lhs, proxy.rhs());
2776 if (op_aliasing_lhs || op_aliasing_rhs)
2778 matrix_base<T> temp(proxy.lhs());
2779 op_executor<matrix_base<T>, op_inplace_sub, RHS>::apply(temp, proxy.rhs());
2784 op_executor<matrix_base<T>, op_inplace_sub, LHS>::apply(lhs, proxy.lhs());
2785 op_executor<matrix_base<T>, op_inplace_add, RHS>::apply(lhs, proxy.rhs());
2790 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_sub>
const & proxy)
2793 proxy.lhs(), T(1), 1,
false,
true,
2794 proxy.rhs(), T(1), 1,
false,
false);
2798 template<
typename ScalarType>
2799 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>,
2800 const matrix_base<T>,
2801 op_sub>
const & proxy)
2804 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
true,
2805 proxy.rhs(), T(1), 1,
false,
false);
2809 template<
typename ScalarType>
2810 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>,
2811 const matrix_base<T>,
2812 op_sub>
const & proxy)
2815 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
true,
2816 proxy.rhs(), T(1), 1,
false,
false);
2820 template<
typename ScalarType>
2821 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
2822 const matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>,
2823 op_sub>
const & proxy)
2826 proxy.lhs(), T(1), 1,
false,
true,
2827 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
false);
2831 template<
typename ScalarType>
2832 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
2833 const matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>,
2834 op_sub>
const & proxy)
2837 proxy.lhs(), T(1), 1,
false,
true,
2838 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
false);
2842 template<
typename ScalarType1,
typename ScalarType2>
2843 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_mult>,
2844 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_mult>,
2845 op_sub>
const & proxy)
2848 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
true,
2849 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
false);
2853 template<
typename ScalarType1,
typename ScalarType2>
2854 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_mult>,
2855 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_div>,
2856 op_sub>
const & proxy)
2859 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
true,
2860 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
false);
2864 template<
typename ScalarType1,
typename ScalarType2>
2865 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_div>,
2866 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_mult>,
2867 op_sub>
const & proxy)
2870 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
true,
2871 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
false);
2875 template<
typename ScalarType1,
typename ScalarType2>
2876 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_div>,
2877 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_div>,
2878 op_sub>
const & proxy)
2881 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
true,
2882 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
false);
2889 template<
typename T,
typename LHS>
2890 struct op_executor<matrix_base<T>, op_assign, matrix_expression<const LHS, const int, op_vector_diag> >
2892 static void apply(matrix_base<T> & lhs, matrix_expression<
const vector_base<T>,
const int, op_vector_diag>
const & proxy)
2899 template<
typename T,
typename LHS>
2900 struct op_executor<vector_base<T>, op_assign, vector_expression<const LHS, const int, op_matrix_diag> >
2902 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_base<T>,
const int, op_matrix_diag>
const & proxy)
2908 template<
typename T,
typename LHS>
2909 struct op_executor<vector_base<T>, op_assign, vector_expression<const LHS, const unsigned int, op_row> >
2911 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_base<T>,
const unsigned int, op_row>
const & proxy)
2918 template<
typename T,
typename LHS>
2919 struct op_executor<vector_base<T>, op_assign, vector_expression<const LHS, const unsigned int, op_column> >
2921 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_base<T>,
const unsigned int, op_column>
const & proxy)
2929 template<
typename T>
2930 struct op_executor<vector_base<T>, op_assign, vector_expression<const matrix_base<T>, const matrix_base<T>, op_row_sum> >
2932 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_base<T>,
const matrix_base<T>, op_row_sum>
const & proxy)
2938 template<
typename T,
typename LHS,
typename RHS,
typename OP>
2939 struct op_executor<vector_base<T>, op_assign, vector_expression<const matrix_expression<LHS, RHS, OP>, const matrix_expression<LHS, RHS, OP>, op_row_sum> >
2941 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_expression<LHS, RHS, OP>,
const matrix_expression<LHS, RHS, OP>, op_row_sum>
const & proxy)
2943 matrix_base<T> tmp(proxy.lhs());
2948 template<
typename T>
2949 struct op_executor<vector_base<T>, op_assign, vector_expression<const matrix_base<T>, const matrix_base<T>, op_col_sum> >
2951 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_base<T>,
const matrix_base<T>, op_col_sum>
const & proxy)
2958 template<
typename T,
typename LHS,
typename RHS,
typename OP>
2959 struct op_executor<vector_base<T>, op_assign, vector_expression<const matrix_expression<LHS, RHS, OP>, const matrix_expression<LHS, RHS, OP>, op_col_sum> >
2961 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_expression<LHS, RHS, OP>,
const matrix_expression<LHS, RHS, OP>, op_col_sum>
const & proxy)
2963 matrix_base<T> tmp(proxy.lhs());
2971 template<
typename T,
typename LHS,
typename RHS,
typename OP>
2972 struct op_executor<matrix_base<T>, op_assign, matrix_expression<const LHS, const RHS, op_element_binary<OP> > >
2975 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_element_binary<OP> >
const & proxy)
2981 template<
typename LHS2,
typename RHS2,
typename OP2>
2982 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_expression<const LHS2, const RHS2, OP2>, op_element_binary<OP> >
const & proxy)
2984 matrix_base<T> temp(proxy.rhs());
2989 template<
typename LHS1,
typename RHS1,
typename OP1>
2990 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LHS1, const RHS1, OP1>,
const matrix_base<T>, op_element_binary<OP> >
const & proxy)
2992 matrix_base<T> temp(proxy.lhs());
2997 template<
typename LHS1,
typename RHS1,
typename OP1,
2998 typename LHS2,
typename RHS2,
typename OP2>
2999 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LHS1, const RHS1, OP1>,
3000 const matrix_expression<const LHS2, const RHS2, OP2>,
3001 op_element_binary<OP> >
const & proxy)
3003 matrix_base<T> temp1(proxy.lhs());
3004 matrix_base<T> temp2(proxy.rhs());
3010 template<
typename T,
typename LHS,
typename RHS,
typename OP>
3011 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression<const LHS, const RHS, op_element_binary<OP> > >
3014 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_element_binary<OP> >
const & proxy)
3016 matrix_base<T> temp(proxy);
3021 template<
typename LHS2,
typename RHS2,
typename OP2>
3022 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_expression<const LHS2, const RHS2, OP2>, op_element_binary<OP> >
const & proxy)
3024 matrix_base<T> temp(proxy.rhs());
3031 template<
typename LHS1,
typename RHS1,
typename OP1>
3032 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LHS1, const RHS1, OP1>,
const matrix_base<T>, op_element_binary<OP> >
const & proxy)
3034 matrix_base<T> temp(proxy.lhs());
3041 template<
typename LHS1,
typename RHS1,
typename OP1,
3042 typename LHS2,
typename RHS2,
typename OP2>
3043 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LHS1, const RHS1, OP1>,
3044 const matrix_expression<const LHS2, const RHS2, OP2>,
3045 op_element_binary<OP> >
const & proxy)
3047 matrix_base<T> temp1(proxy.lhs());
3048 matrix_base<T> temp2(proxy.rhs());
3056 template<
typename T,
typename LHS,
typename RHS,
typename OP>
3057 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression<const LHS, const RHS, op_element_binary<OP> > >
3061 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_element_binary<OP> >
const & proxy)
3063 matrix_base<T> temp(proxy);
3068 template<
typename LHS2,
typename RHS2,
typename OP2>
3069 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_expression<const LHS2, const RHS2, OP2>, op_element_binary<OP> >
const & proxy)
3071 matrix_base<T> temp(proxy.rhs());
3078 template<
typename LHS1,
typename RHS1,
typename OP1>
3079 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LHS1, const RHS1, OP1>,
const matrix_base<T>, op_element_binary<OP> >
const & proxy)
3081 matrix_base<T> temp(proxy.lhs());
3088 template<
typename LHS1,
typename RHS1,
typename OP1,
3089 typename LHS2,
typename RHS2,
typename OP2>
3090 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LHS1, const RHS1, OP1>,
3091 const matrix_expression<const LHS2, const RHS2, OP2>,
3092 op_element_binary<OP> >
const & proxy)
3094 matrix_base<T> temp1(proxy.lhs());
3095 matrix_base<T> temp2(proxy.rhs());
3104 template<
typename T,
typename LHS,
typename RHS,
typename OP>
3105 struct op_executor<matrix_base<T>, op_assign, matrix_expression<const LHS, const RHS, op_element_unary<OP> > >
3108 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_element_unary<OP> >
const & proxy)
3114 template<
typename LHS2,
typename RHS2,
typename OP2>
3115 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LHS2, const RHS2, OP2>,
3116 const matrix_expression<const LHS2, const RHS2, OP2>,
3117 op_element_unary<OP> >
const & proxy)
3119 matrix_base<T> temp(proxy.rhs());
3124 template<
typename T,
typename LHS,
typename RHS,
typename OP>
3125 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression<const LHS, const RHS, op_element_unary<OP> > >
3128 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_element_unary<OP> >
const & proxy)
3130 matrix_base<T> temp(proxy);
3135 template<
typename LHS2,
typename RHS2,
typename OP2>
3136 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LHS2, const RHS2, OP2>,
3137 const matrix_expression<const LHS2, const RHS2, OP2>,
3138 op_element_unary<OP> >
const & proxy)
3140 matrix_base<T> temp(proxy.rhs());
3146 template<
typename T,
typename LHS,
typename RHS,
typename OP>
3147 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression<const LHS, const RHS, op_element_unary<OP> > >
3150 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_element_unary<OP> >
const & proxy)
3152 matrix_base<T> temp(proxy);
3157 template<
typename LHS2,
typename RHS2,
typename OP2>
3158 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LHS2, const RHS2, OP2>,
3159 const matrix_expression<const LHS2, const RHS2, OP2>,
3160 op_element_unary<OP> >
const & proxy)
3162 matrix_base<T> temp(proxy.rhs());
3173 template<
typename T>
3174 struct op_executor<matrix_base<T>, op_assign, matrix_expression<const matrix_base<T>, const matrix_base<T>, op_mat_mat_prod> >
3176 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_mat_mat_prod>
const & rhs)
3180 matrix_base<T> temp(rhs);
3189 template<
typename T>
3190 struct op_executor<matrix_base<T>, op_assign, matrix_expression<const matrix_base<T>,
3191 const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3194 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
3195 const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3196 op_mat_mat_prod>
const & rhs)
3200 matrix_base<T> temp(rhs);
3209 template<
typename T,
typename LhsT,
typename RhsT,
typename OpT>
3210 struct op_executor<matrix_base<T>,
3212 matrix_expression<const matrix_base<T>,
3213 const matrix_expression<const LhsT, const RhsT, OpT>,
3217 static void apply(matrix_base<T> & lhs,
3218 matrix_expression<
const matrix_base<T>,
3219 const matrix_expression<const LhsT, const RhsT, OpT>,
3220 op_mat_mat_prod>
const & rhs)
3222 matrix_base<T> temp(rhs.rhs());
3230 template<
typename T>
3231 struct op_executor<matrix_base<T>, op_assign, matrix_expression<const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3232 const matrix_base<T>,
3235 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3236 const matrix_base<T>,
3237 op_mat_mat_prod>
const & rhs)
3241 matrix_base<T> temp(rhs);
3250 template<
typename T,
typename LhsT,
typename RhsT,
typename OpT>
3251 struct op_executor<matrix_base<T>,
3253 matrix_expression<const matrix_expression<const LhsT, const RhsT, OpT>,
3254 const matrix_base<T>,
3258 static void apply(matrix_base<T> & lhs,
3259 matrix_expression<
const matrix_expression<const LhsT, const RhsT, OpT>,
3260 const matrix_base<T>,
3261 op_mat_mat_prod>
const & rhs)
3263 matrix_base<T> temp(rhs.lhs());
3270 template<
typename T>
3271 struct op_executor<matrix_base<T>, op_assign, matrix_expression<const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3272 const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3275 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3276 const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3277 op_mat_mat_prod>
const & rhs)
3281 matrix_base<T> temp(rhs);
3290 template<
typename T,
3291 typename LhsT1,
typename RhsT1,
typename OpT1,
3292 typename LhsT2,
typename RhsT2,
typename OpT2>
3293 struct op_executor<matrix_base<T>,
3295 matrix_expression<const matrix_expression<const LhsT1, const RhsT1, OpT1>,
3296 const matrix_expression<const LhsT2, const RhsT2, OpT2>,
3300 static void apply(matrix_base<T> & lhs,
3301 matrix_expression<
const matrix_expression<const LhsT1, const RhsT1, OpT1>,
3302 const matrix_expression<const LhsT2, const RhsT2, OpT2>,
3303 op_mat_mat_prod>
const & rhs)
3305 matrix_base<T> temp1(rhs.lhs());
3306 matrix_base<T> temp2(rhs.rhs());
3315 template<
typename T>
3316 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression<const matrix_base<T>, const matrix_base<T>, op_mat_mat_prod> >
3318 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_mat_mat_prod>
const & rhs)
3322 matrix_base<T> temp(rhs);
3331 template<
typename T>
3332 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression<const matrix_base<T>,
3333 const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3336 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
3337 const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3338 op_mat_mat_prod>
const & rhs)
3342 matrix_base<T> temp(rhs);
3351 template<
typename T,
typename LhsT,
typename RhsT,
typename OpT>
3352 struct op_executor<matrix_base<T>,
3354 matrix_expression<const matrix_base<T>,
3355 const matrix_expression<const LhsT, const RhsT, OpT>,
3359 static void apply(matrix_base<T> & lhs,
3360 matrix_expression<
const matrix_base<T>,
3361 const matrix_expression<const LhsT, const RhsT, OpT>,
3362 op_mat_mat_prod>
const & rhs)
3364 matrix_base<T> temp(rhs.rhs());
3371 template<
typename T>
3372 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression<const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3373 const matrix_base<T>,
3376 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3377 const matrix_base<T>,
3378 op_mat_mat_prod>
const & rhs)
3382 matrix_base<T> temp(rhs);
3391 template<
typename T,
typename LhsT,
typename RhsT,
typename OpT>
3392 struct op_executor<matrix_base<T>,
3394 matrix_expression<const matrix_expression<const LhsT, const RhsT, OpT>,
3395 const matrix_base<T>,
3399 static void apply(matrix_base<T> & lhs,
3400 matrix_expression<
const matrix_expression<const LhsT, const RhsT, OpT>,
3401 const matrix_base<T>,
3402 op_mat_mat_prod>
const & rhs)
3404 matrix_base<T> temp(rhs.lhs());
3411 template<
typename T>
3412 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression<const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3413 const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3416 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3417 const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3418 op_mat_mat_prod>
const & rhs)
3422 matrix_base<T> temp(rhs);
3432 template<
typename T,
3433 typename LhsT1,
typename RhsT1,
typename OpT1,
3434 typename LhsT2,
typename RhsT2,
typename OpT2>
3435 struct op_executor<matrix_base<T>,
3437 matrix_expression<const matrix_expression<const LhsT1, const RhsT1, OpT1>,
3438 const matrix_expression<const LhsT2, const RhsT2, OpT2>,
3442 static void apply(matrix_base<T> & lhs,
3443 matrix_expression<
const matrix_expression<const LhsT1, const RhsT1, OpT1>,
3444 const matrix_expression<const LhsT2, const RhsT2, OpT2>,
3445 op_mat_mat_prod>
const & rhs)
3447 matrix_base<T> temp1(rhs.lhs());
3448 matrix_base<T> temp2(rhs.rhs());
3456 template<
typename T>
3457 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression<const matrix_base<T>, const matrix_base<T>, op_mat_mat_prod> >
3459 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_mat_mat_prod>
const & rhs)
3463 matrix_base<T> temp(rhs);
3472 template<
typename T>
3473 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression<const matrix_base<T>,
3474 const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3477 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
3478 const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3479 op_mat_mat_prod>
const & rhs)
3483 matrix_base<T> temp(rhs);
3492 template<
typename T,
typename LhsT,
typename RhsT,
typename OpT>
3493 struct op_executor<matrix_base<T>,
3495 matrix_expression<const matrix_base<T>,
3496 const matrix_expression<const LhsT, const RhsT, OpT>,
3500 static void apply(matrix_base<T> & lhs,
3501 matrix_expression<
const matrix_base<T>,
3502 const matrix_expression<const LhsT, const RhsT, OpT>,
3503 op_mat_mat_prod>
const & rhs)
3505 matrix_base<T> temp(rhs.rhs());
3512 template<
typename T>
3513 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression<const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3514 const matrix_base<T>,
3517 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3518 const matrix_base<T>,
3519 op_mat_mat_prod>
const & rhs)
3523 matrix_base<T> temp(rhs);
3532 template<
typename T,
typename LhsT,
typename RhsT,
typename OpT>
3533 struct op_executor<matrix_base<T>,
3535 matrix_expression<const matrix_expression<const LhsT, const RhsT, OpT>,
3536 const matrix_base<T>,
3540 static void apply(matrix_base<T> & lhs,
3541 matrix_expression<
const matrix_expression<const LhsT, const RhsT, OpT>,
3542 const matrix_base<T>,
3543 op_mat_mat_prod>
const & rhs)
3545 matrix_base<T> temp(rhs.lhs());
3552 template<
typename T>
3553 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression<const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3554 const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3557 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3558 const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3559 op_mat_mat_prod>
const & rhs)
3563 matrix_base<T> temp(rhs);
3572 template<
typename T,
3573 typename LhsT1,
typename RhsT1,
typename OpT1,
3574 typename LhsT2,
typename RhsT2,
typename OpT2>
3575 struct op_executor<matrix_base<T>,
3577 matrix_expression<const matrix_expression<const LhsT1, const RhsT1, OpT1>,
3578 const matrix_expression<const LhsT2, const RhsT2, OpT2>,
3582 static void apply(matrix_base<T> & lhs,
3583 matrix_expression<
const matrix_expression<const LhsT1, const RhsT1, OpT1>,
3584 const matrix_expression<const LhsT2, const RhsT2, OpT2>,
3585 op_mat_mat_prod>
const & rhs)
3587 matrix_base<T> temp1(rhs.lhs());
3588 matrix_base<T> temp2(rhs.rhs());
3596 template<
typename T>
3597 struct op_executor<vector_base<T>, op_assign, vector_expression<const matrix_base<T>, const vector_base<T>, op_prod> >
3599 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_base<T>,
const vector_base<T>, op_prod>
const & rhs)
3604 vector_base<T> temp(rhs);
3613 template<
typename T>
3614 struct op_executor<vector_base<T>, op_assign, vector_expression<const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3615 const vector_base<T>,
3618 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3619 const vector_base<T>,
3620 op_prod>
const & rhs)
3625 vector_base<T> temp(rhs);
3634 template<
typename T,
typename LhsT,
typename RhsT,
typename OpT>
3635 struct op_executor<vector_base<T>,
3637 vector_expression<const matrix_expression<const LhsT, const RhsT, OpT>,
3638 const vector_base<T>,
3642 static void apply(vector_base<T> & lhs,
3643 vector_expression<
const matrix_expression<const LhsT, const RhsT, OpT>,
3644 const vector_base<T>,
3645 op_prod>
const & rhs)
3647 matrix_base<T> temp(rhs.lhs());
3653 template<
typename T,
typename LhsT,
typename RhsT,
typename OpT>
3654 struct op_executor<vector_base<T>,
3656 vector_expression<const matrix_base<T>,
3657 const vector_expression<const LhsT, const RhsT, OpT>,
3661 static void apply(vector_base<T> & lhs,
3662 vector_expression<
const matrix_base<T>,
3663 const vector_expression<const LhsT, const RhsT, OpT>,
3664 op_prod>
const & rhs)
3666 vector_base<T> x(rhs.rhs());
3672 template<
typename T,
3673 typename LhsT1,
typename RhsT1,
typename OpT1,
3674 typename LhsT2,
typename RhsT2,
typename OpT2>
3675 struct op_executor<vector_base<T>,
3677 vector_expression<const matrix_expression<const LhsT1, const RhsT1, OpT1>,
3678 const vector_expression<const LhsT2, const RhsT2, OpT2>,
3682 static void apply(vector_base<T> & lhs,
3683 vector_expression<
const matrix_expression<const LhsT1, const RhsT1, OpT1>,
3684 const vector_expression<const LhsT2, const RhsT2, OpT2>,
3685 op_prod>
const & rhs)
3687 matrix_base<T> A(rhs.lhs());
3688 vector_base<T> x(rhs.rhs());
3696 template<
typename T>
3697 struct op_executor<vector_base<T>, op_inplace_add, vector_expression<const matrix_base<T>, const vector_base<T>, op_prod> >
3699 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_base<T>,
const vector_base<T>, op_prod>
const & rhs)
3701 vector_base<T> temp(rhs);
3707 template<
typename T>
3708 struct op_executor<vector_base<T>, op_inplace_add, vector_expression<const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3709 const vector_base<T>,
3712 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3713 const vector_base<T>,
3714 op_prod>
const & rhs)
3716 vector_base<T> temp(rhs);
3722 template<
typename T,
typename LhsT,
typename RhsT,
typename OpT>
3723 struct op_executor<vector_base<T>,
3725 vector_expression<const matrix_expression<const LhsT, const RhsT, OpT>,
3726 const vector_base<T>,
3730 static void apply(vector_base<T> & lhs,
3731 vector_expression<
const matrix_expression<const LhsT, const RhsT, OpT>,
3732 const vector_base<T>,
3733 op_prod>
const & rhs)
3735 matrix_base<T> A(rhs.lhs());
3736 vector_base<T> y(lhs);
3743 template<
typename T,
typename LhsT,
typename RhsT,
typename OpT>
3744 struct op_executor<vector_base<T>,
3746 vector_expression<const matrix_base<T>,
3747 const vector_expression<const LhsT, const RhsT, OpT>,
3751 static void apply(vector_base<T> & lhs,
3752 vector_expression<
const matrix_base<T>,
3753 const vector_expression<const LhsT, const RhsT, OpT>,
3754 op_prod>
const & rhs)
3756 vector_base<T> x(rhs.rhs());
3757 vector_base<T> y(lhs);
3764 template<
typename T,
3765 typename LhsT1,
typename RhsT1,
typename OpT1,
3766 typename LhsT2,
typename RhsT2,
typename OpT2>
3767 struct op_executor<vector_base<T>,
3769 vector_expression<const matrix_expression<const LhsT1, const RhsT1, OpT1>,
3770 const vector_expression<const LhsT2, const RhsT2, OpT2>,
3774 static void apply(vector_base<T> & lhs,
3775 vector_expression<
const matrix_expression<const LhsT1, const RhsT1, OpT1>,
3776 const vector_expression<const LhsT2, const RhsT2, OpT2>,
3777 op_prod>
const & rhs)
3779 matrix_base<T> A(rhs.lhs());
3780 vector_base<T> x(rhs.rhs());
3781 vector_base<T> y(lhs);
3790 template<
typename T>
3791 struct op_executor<vector_base<T>, op_inplace_sub, vector_expression<const matrix_base<T>, const vector_base<T>, op_prod> >
3793 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_base<T>,
const vector_base<T>, op_prod>
const & rhs)
3795 vector_base<T> temp(rhs);
3801 template<
typename T>
3802 struct op_executor<vector_base<T>, op_inplace_sub, vector_expression<const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3803 const vector_base<T>,
3806 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3807 const vector_base<T>,
3808 op_prod>
const & rhs)
3810 vector_base<T> temp(rhs);
3816 template<
typename T,
typename LhsT,
typename RhsT,
typename OpT>
3817 struct op_executor<vector_base<T>,
3819 vector_expression<const matrix_expression<const LhsT, const RhsT, OpT>,
3820 const vector_base<T>,
3824 static void apply(vector_base<T> & lhs,
3825 vector_expression<
const matrix_expression<const LhsT, const RhsT, OpT>,
3826 const vector_base<T>,
3827 op_prod>
const & rhs)
3829 matrix_base<T> A(rhs.lhs());
3830 vector_base<T> y(lhs);
3837 template<
typename T,
typename LhsT,
typename RhsT,
typename OpT>
3838 struct op_executor<vector_base<T>,
3840 vector_expression<const matrix_base<T>,
3841 const vector_expression<const LhsT, const RhsT, OpT>,
3845 static void apply(vector_base<T> & lhs,
3846 vector_expression<
const matrix_base<T>,
3847 const vector_expression<const LhsT, const RhsT, OpT>,
3848 op_prod>
const & rhs)
3850 vector_base<T> x(rhs.rhs());
3851 vector_base<T> y(lhs);
3858 template<
typename T,
3859 typename LhsT1,
typename RhsT1,
typename OpT1,
3860 typename LhsT2,
typename RhsT2,
typename OpT2>
3861 struct op_executor<vector_base<T>,
3863 vector_expression<const matrix_expression<const LhsT1, const RhsT1, OpT1>,
3864 const vector_expression<const LhsT2, const RhsT2, OpT2>,
3868 static void apply(vector_base<T> & lhs,
3869 vector_expression<
const matrix_expression<const LhsT1, const RhsT1, OpT1>,
3870 const vector_expression<const LhsT2, const RhsT2, OpT2>,
3871 op_prod>
const & rhs)
3873 matrix_base<T> A(rhs.lhs());
3874 vector_base<T> x(rhs.rhs());
3875 vector_base<T> y(lhs);
3886 template<
typename T>
3887 struct op_executor<matrix_base<T>, op_assign, matrix_expression<const vector_base<T>, const vector_base<T>, op_prod> >
3889 static void apply(matrix_base<T> & lhs, matrix_expression<
const vector_base<T>,
const vector_base<T>, op_prod>
const & rhs)
3897 template<
typename T,
typename ScalarType>
3898 struct op_executor<matrix_base<T>, op_assign, matrix_expression< const matrix_expression<const vector_base<T>, const vector_base<T>, op_prod>,
3902 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const vector_base<T>,
const vector_base<T>, op_prod>,
3904 op_mult>
const & rhs)
3912 template<
typename T>
3913 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression<const vector_base<T>, const vector_base<T>, op_prod> >
3915 static void apply(matrix_base<T> & lhs, matrix_expression<
const vector_base<T>,
const vector_base<T>, op_prod>
const & rhs)
3922 template<
typename T,
typename ScalarType>
3923 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression< const matrix_expression<const vector_base<T>, const vector_base<T>, op_prod>,
3927 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const vector_base<T>,
const vector_base<T>, op_prod>,
3929 op_mult>
const & rhs)
3936 template<
typename T>
3937 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression<const vector_base<T>, const vector_base<T>, op_prod> >
3939 static void apply(matrix_base<T> & lhs, matrix_expression<
const vector_base<T>,
const vector_base<T>, op_prod>
const & rhs)
3946 template<
typename T,
typename ScalarType>
3947 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression< const matrix_expression<const vector_base<T>, const vector_base<T>, op_prod>,
3951 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const vector_base<T>,
const vector_base<T>, op_prod>,
3953 op_mult>
const & rhs)
void row_sum_impl(const matrix_base< NumericT > &A, vector_base< NumericT > &result)
Simple enable-if variant that uses the SFINAE pattern.
bool operator==(self_type const &other)
A tag class representing multiplication by a scalar.
matrix(NumericT *ptr_to_mem, viennacl::memory_types mem_type, size_type rows, size_type cols)
Wraps a CUDA or host buffer provided by the user.
Helper class implementing an array on the host. Default case: No conversion necessary.
void matrix_diag_to_vector(const matrix_base< NumericT > &A, int k, vector_base< NumericT > &v)
Dispatcher interface for v = diag(A, k)
static vcl_size_t mem_index(vcl_size_t i, vcl_size_t j, vcl_size_t, vcl_size_t num_cols)
Returns the memory offset for entry (i,j) of a dense matrix.
void memory_write(mem_handle &dst_buffer, vcl_size_t dst_offset, vcl_size_t bytes_to_write, const void *ptr, bool async=false)
Writes data from main RAM identified by 'ptr' to the buffer identified by 'dst_buffer'.
base_type & operator=(viennacl::matrix< OtherNumericT, F2 > const &B)
viennacl::enable_if< viennacl::is_any_sparse_matrix< M1 >::value, matrix_expression< const M1, const M1, op_trans > >::type trans(const M1 &mat)
Returns an expression template class representing a transposed matrix.
Worker class for decomposing expression templates.
A proxy class for a single element of a vector or matrix. This proxy should not be noticed by end-use...
Implementations of dense matrix related operations including matrix-vector products.
size_type internal_size() const
Returns the total amount of allocated memory in multiples of sizeof(NumericT)
Class for representing strided submatrices of a bigger matrix A.
self_type & operator=(const self_type &other)
matrix(zero_matrix< NumericT > const &m)
Creates the matrix from the supplied zero matrix.
Helper class for checking whether a matrix has a row-major layout.
Helper struct for checking whether a type represents a sign flip on a viennacl::scalar<> ...
void matrix_assign(matrix_base< NumericT > &mat, NumericT s, bool clear=false)
matrix_expression< const self_type, const NumericT, op_mult > operator-() const
Sign flip for the matrix. Emulated to be equivalent to -1.0 * matrix.
A tag class representing the extraction of a matrix column to a vector.
vcl_size_t internal_size1(matrix_base< NumericT > const &mat)
Helper routine for obtaining the internal number of entries per row of a ViennaCL matrix...
vcl_size_t size1(MatrixType const &mat)
Generic routine for obtaining the number of rows of a matrix (ViennaCL, uBLAS, etc.)
A tag class representing a matrix given by a vector placed on a certain (off-)diagonal.
A tag class representing subtraction.
void am(matrix_base< NumericT > &mat1, matrix_base< NumericT > const &mat2, ScalarType1 const &alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha)
viennacl::context context() const
vcl_size_t internal_size2(matrix_base< NumericT > const &mat)
Helper routine for obtaining the internal number of entries per column of a ViennaCL matrix...
A tag indicating iteration along increasing row index of a matrix.
Expression template class for representing a tree of expressions which ultimately result in a matrix...
void ambm(matrix_base< NumericT > &mat1, matrix_base< NumericT > const &mat2, ScalarType1 const &alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha, matrix_base< NumericT > const &mat3, ScalarType2 const &beta, vcl_size_t len_beta, bool reciprocal_beta, bool flip_sign_beta)
void clear(VectorType &vec)
Generic routine for setting all entries of a vector to zero. This is the version for non-ViennaCL obj...
This file provides the forward declarations for the main types used within ViennaCL.
A tag class representing division.
void memory_read(mem_handle const &src_buffer, vcl_size_t src_offset, vcl_size_t bytes_to_read, void *ptr, bool async=false)
Reads data from a buffer back to main RAM.
entry_proxy< NumericT > operator()(size_type row_index, size_type col_index)
Read-write access to a single element of the matrix/matrix_range/matrix_slice.
Represents a vector consisting of 1 at a given index and zeros otherwise. To be used as an initialize...
viennacl::enable_if< viennacl::is_scalar< S1 >::value, matrix_base< NumericT > & >::type operator/=(matrix_base< NumericT > &m1, S1 const &gpu_val)
Scales a matrix by a GPU scalar value.
viennacl::enable_if< viennacl::is_any_scalar< S1 >::value, matrix_expression< const matrix_base< NumericT >, const S1, op_mult >>::type operator*(S1 const &value, matrix_base< NumericT > const &m1)
Operator overload for the expression alpha * m1, where alpha is a host scalar (float or double) and m...
viennacl::scalar< float > s1
vcl_size_t internal_size(vector_base< NumericT > const &vec)
Helper routine for obtaining the buffer length of a ViennaCL vector.
An expression template class that represents a binary operation that yields a vector.
void element_op(matrix_base< T > &A, matrix_expression< const matrix_base< T >, const matrix_base< T >, OP > const &proxy)
Implementation of the element-wise operation A = B .* C and A = B ./ C for matrices (using MATLAB syn...
Forward declaration of dense matrix classes.
bool op_aliasing(vector_base< NumericT > const &, B const &)
result_of::size_type< MatrixType >::type size2(MatrixType const &mat)
Generic routine for obtaining the number of columns of a matrix (ViennaCL, uBLAS, etc...
bool operator!=(self_type const &other)
matrix(scalar_matrix< NumericT > const &m)
Creates the matrix from the supplied scalar matrix.
vcl_size_t size1() const
Returns the size of the result vector.
self_type operator++(int)
viennacl::vector< NumericT > operator-(const vector_base< NumericT > &v1, const vector_expression< const matrix_base< NumericT >, const vector_base< NumericT >, op_prod > &proxy)
Implementation of the operation 'result = v1 - A * v2', where A is a matrix.
A tag class representing the (off-)diagonal of a matrix.
Represents a generic 'context' similar to an OpenCL context, but is backend-agnostic and thus also su...
void resize(size_type rows, size_type columns, bool preserve=true)
Resizes the matrix. Existing entries can optionally be preserved.
viennacl::enable_if< viennacl::is_scalar< S1 >::value, matrix_base< NumericT > & >::type operator*=(matrix_base< NumericT > &m1, S1 const &gpu_val)
Scales a matrix by a GPU scalar value.
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.)
matrix_base()
The default constructor. Does not allocate any memory.
void convert(matrix_base< DestNumericT > &dest, matrix_base< SrcNumericT > const &src)
void matrix_row(const matrix_base< NumericT > &A, unsigned int i, vector_base< NumericT > &v)
matrix(matrix_expression< LHS, RHS, OP > const &proxy)
void resize(MatrixType &matrix, vcl_size_t rows, vcl_size_t cols)
Generic resize routine for resizing a matrix (ViennaCL, uBLAS, etc.) to a new size/dimension.
MatrixT::value_type value_type
void clear()
Resets all entries to zero.
MatrixT & operator()(void) const
Implementations of operations using sparse matrices.
A tag class representing addition.
matrix(const self_type &other)
Represents a vector consisting of scalars 's' only, i.e. v[i] = s for all i. To be used as an initial...
matrix_expression(LHS &lhs, RHS &rhs)
void scaled_rank_1_update(matrix_base< NumericT > &mat1, S1 const &alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha, const vector_base< NumericT > &vec1, const vector_base< NumericT > &vec2)
The implementation of the operation mat += alpha * vec1 * vec2^T, i.e. a scaled rank 1 update...
viennacl::enable_if< viennacl::is_any_scalar< S1 >::value, matrix_expression< const matrix_expression< const LHS, const RHS, OP >, const S1, op_div > >::type operator/(matrix_expression< const LHS, const RHS, OP > const &proxy, S1 const &val)
Operator overload for the division of a matrix expression by a scalar from the right, e.g. (beta * m1) / alpha. Here, beta * m1 is wrapped into a matrix_expression and then divided by alpha.
Determines whether a given expression has a row-major matrix layout.
size_type size2() const
Returns the number of columns.
matrix()
The default constructor. Does not allocate any memory.
handle_type & handle()
Returns the OpenCL handle, non-const-version.
matrix(identity_matrix< NumericT > const &m)
Creates the matrix from the supplied identity matrix.
void trans(const matrix_expression< const matrix_base< NumericT, SizeT, DistanceT >, const matrix_base< NumericT, SizeT, DistanceT >, op_trans > &proxy, matrix_base< NumericT > &temp_trans)
vector_expression< const matrix_base< NumericT >, const int, op_matrix_diag > diag(const matrix_base< NumericT > &A, int k=0)
viennacl::memory_types active_handle_id(T const &obj)
Returns an ID for the currently active memory domain of an object.
Represents a vector consisting of zeros only. To be used as an initializer for viennacl::vector, vector_range, or vector_slize only.
void matrix_column(const matrix_base< NumericT > &A, unsigned int j, vector_base< NumericT > &v)
size_type size1() const
Returns the number of rows.
base_type & operator=(viennacl::matrix_slice< viennacl::matrix< OtherNumericT, F2 > > const &B)
vector_expression< const matrix_base< NumericT, F >, const unsigned int, op_row > row(const matrix_base< NumericT, F > &A, unsigned int i)
base_type::size_type size_type
matrix(const base_type &other)
base_type & operator=(viennacl::matrix_range< viennacl::matrix< OtherNumericT, F2 > > const &B)
RHS & rhs() const
Get right hand side operand.
viennacl::vector< NumericT > operator+(const vector_base< NumericT > &v1, const vector_expression< const matrix_base< NumericT >, const vector_base< NumericT >, op_prod > &proxy)
Implementation of the operation 'result = v1 + A * v2', where A is a matrix.
matrix_iterator(MatrixT &mat, vcl_size_t start_row, vcl_size_t start_col)
void switch_active_handle_id(memory_types new_id)
Switches the currently active handle. If no support for that backend is provided, an exception is thr...
A tag class representing matrix-vector products and element-wise multiplications. ...
viennacl::context context(T const &t)
Returns an ID for the currently active memory domain of an object.
void copy(std::vector< NumericT > &cpu_vec, circulant_matrix< NumericT, AlignmentV > &gpu_mat)
Copies a circulant matrix from the std::vector to the OpenCL device (either GPU or multi-core CPU) ...
bool row_major(T const &)
void set(vcl_size_t index, U value)
value_type operator*(void)
A tag class representing transposed matrices.
Helper implementations that deduce the dimensions of the supplied matrix-valued expressions.
matrix(NumericT *ptr_to_mem, viennacl::memory_types mem_type, size_type rows, size_type internal_row_count, size_type cols, size_type internal_col_count)
Wraps a CUDA or host buffer provided by the user including padding of rows and columns.
vcl_size_t raw_size() const
Returns the number of bytes of the currently active buffer.
size_type internal_size2() const
Returns the internal number of columns. Usually required for launching OpenCL kernels only...
Class for representing non-strided submatrices of a bigger matrix A.
self_type & operator*=(char val)
Scales the matrix by a char (8-bit integer)
void memory_create(mem_handle &handle, vcl_size_t size_in_bytes, viennacl::context const &ctx, const void *host_ptr=NULL)
Creates an array of the specified size. If the second argument is provided, the buffer is initialized...
viennacl::matrix< float > m1
void matrix_diagonal_assign(matrix_base< NumericT > &mat, NumericT s)
size_type internal_size1() const
Returns the internal number of rows. Usually required for launching OpenCL kernels only...
matrix(size_type rows, size_type columns, viennacl::context ctx=viennacl::context())
Creates the matrix with the given dimensions.
static vcl_size_t mem_index(vcl_size_t i, vcl_size_t j, vcl_size_t num_rows, vcl_size_t)
Returns the memory offset for entry (i,j) of a dense matrix.
vector_expression< const matrix_base< NumericT, F >, const unsigned int, op_column > column(const matrix_base< NumericT, F > &A, unsigned int j)
Extracts the underlying OpenCL handle from a vector, a matrix, an expression etc. ...
self_type & operator+=(const matrix_expression< const LHS, const RHS, OP > &proxy)
self_type & operator/=(char val)
Scales the matrix by a char (8-bit integer)
void prod_impl(const matrix_base< NumericT > &mat, const vector_base< NumericT > &vec, vector_base< NumericT > &result)
Carries out matrix-vector multiplication.
void resize(size_type rows, size_type columns, bool preserve=true)
viennacl::backend::mem_handle & handle(T &obj)
Returns the generic memory handle of an object. Non-const version.
void matrix_diag_from_vector(const vector_base< NumericT > &v, int k, matrix_base< NumericT > &A)
Dispatcher interface for A = diag(v, k)
LHS & lhs() const
Get left hand side operand.
A tag class representing the extraction of a matrix row to a vector.
A proxy class for a single element of a vector or matrix. This proxy should not be noticed by end-use...
void ambm_m(matrix_base< NumericT > &mat1, matrix_base< NumericT > const &mat2, ScalarType1 const &alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha, matrix_base< NumericT > const &mat3, ScalarType2 const &beta, vcl_size_t len_beta, bool reciprocal_beta, bool flip_sign_beta)
Implementation of the ViennaCL scalar class.
A collection of compile time type deductions.
A tag for row-major storage of a dense matrix.
self_type & operator++(void)
ram_handle_type & ram_handle()
Returns the handle to a buffer in CPU RAM. NULL is returned if no such buffer has been allocated...
A tag indicating iteration along increasing columns index of a matrix.
Simple enable-if variant that uses the SFINAE pattern.
void column_sum_impl(const matrix_base< NumericT > &A, vector_base< NumericT > &result)
self_type & operator-=(const matrix_expression< const LHS, const RHS, OP > &proxy)
void fast_copy(const const_vector_iterator< SCALARTYPE, ALIGNMENT > &gpu_begin, const const_vector_iterator< SCALARTYPE, ALIGNMENT > &gpu_end, CPU_ITERATOR cpu_begin)