1 #ifndef VIENNACL_MATRIX_HPP_
2 #define VIENNACL_MATRIX_HPP_
43 template<
typename SCALARTYPE>
44 class implicit_matrix_base
76 template <
typename SCALARTYPE>
100 template <
typename SCALARTYPE>
124 template <
typename SCALARTYPE>
161 template <
typename LHS,
typename RHS,
typename OP>
162 class matrix_expression
164 typedef typename viennacl::result_of::reference_if_nonscalar<LHS>::type lhs_reference_type;
165 typedef typename viennacl::result_of::reference_if_nonscalar<RHS>::type rhs_reference_type;
174 LHS &
lhs()
const {
return lhs_; }
177 RHS &
rhs()
const {
return rhs_; }
185 lhs_reference_type lhs_;
187 rhs_reference_type rhs_;
199 template <
typename ROWCOL,
typename MATRIXTYPE>
208 vcl_size_t start_col) : mat_(mat), row_(start_row), col_(start_col) {}
235 template <
class SCALARTYPE,
typename F,
typename SizeType ,
typename DistanceType >
238 typedef matrix_base<SCALARTYPE, F, SizeType, DistanceType> self_type;
255 explicit matrix_base() : size1_(0), size2_(0), start1_(0), start2_(0), stride1_(1), stride2_(1), internal_size1_(0), internal_size2_(0) {}
264 : size1_(rows), size2_(columns), start1_(0), start2_(0), stride1_(1), stride2_(1),
268 if (rows > 0 && columns > 0)
280 : size1_(mat_size1), size2_(mat_size2),
281 start1_(mat_start1), start2_(mat_start2),
282 stride1_(mat_stride1), stride2_(mat_stride2),
283 internal_size1_(mat_internal_size1), internal_size2_(mat_internal_size2),
286 template <
typename LHS,
typename RHS,
typename OP>
288 size1_(viennacl::traits::
size1(proxy)), size2_(viennacl::traits::
size2(proxy)), start1_(0), start2_(0), stride1_(1), stride2_(1),
305 : size1_(mat_size1), size2_(mat_size2),
306 start1_(mat_start1), start2_(mat_start2),
307 stride1_(mat_stride1), stride2_(mat_stride2),
308 internal_size1_(mat_internal_size1), internal_size2_(mat_internal_size2)
312 #ifdef VIENNACL_WITH_CUDA
314 elements_.cuda_handle().reset(reinterpret_cast<char*>(ptr_to_mem));
315 elements_.cuda_handle().inc();
330 #ifdef VIENNACL_WITH_OPENCL
332 : size1_(rows), size2_(columns),
333 start1_(0), start2_(0),
334 stride1_(1), stride2_(1),
335 internal_size1_(rows), internal_size2_(columns)
338 elements_.opencl_handle() = mem;
339 elements_.opencl_handle().inc();
340 elements_.opencl_handle().context(ctx.opencl_context());
347 : size1_(mat_size1), size2_(mat_size2),
348 start1_(mat_start1), start2_(mat_start2),
349 stride1_(mat_stride1), stride2_(mat_stride2),
350 internal_size1_(mat_internal_size1), internal_size2_(mat_internal_size2)
353 elements_.opencl_handle() = mem;
354 elements_.opencl_handle().inc();
355 elements_.opencl_handle().context(ctx.opencl_context());
392 template <
typename LHS,
typename RHS,
typename OP>
397 &&
bool(
"Incompatible matrix sizes!"));
403 internal_size1_ = viennacl::tools::align_to_multiple<size_type>(size1_,
alignment);
404 internal_size2_ = viennacl::tools::align_to_multiple<size_type>(size2_,
alignment);
406 if (size1_ != internal_size1_ || size2_ != internal_size2_)
422 assert( (
handle() != proxy.lhs().handle()) &&
bool(
"Self-assignment of matrix transpose not implemented"));
423 assert( ( (proxy.lhs().size1() ==
size2()) || (
size2() == 0) ) && bool(
"Matrix dimensions do not match!"));
424 assert( ( (proxy.lhs().size2() ==
size1()) || (
size1() == 0) ) && bool(
"Matrix dimensions do not match!"));
430 internal_size1_ = viennacl::tools::align_to_multiple<size_type>(size1_,
alignment);
431 internal_size2_ = viennacl::tools::align_to_multiple<size_type>(size2_,
alignment);
434 std::vector<SCALARTYPE> temp(proxy.lhs().internal_size());
441 for (
vcl_size_t i=0; i<proxy.lhs().size1(); ++i)
442 for (
vcl_size_t j=0; j<proxy.lhs().size2(); ++j)
446 = temp[F::mem_index(proxy.lhs().start1() + proxy.lhs().stride1() * i,
447 proxy.lhs().start2() + proxy.lhs().stride2() * j,
448 proxy.lhs().internal_size1(), proxy.lhs().internal_size2())];
456 template <
typename LHS,
typename RHS,
typename OP>
461 &&
bool(
"Incompatible matrix sizes!"));
462 assert( (
size1() > 0) &&
bool(
"Vector not yet initialized!") );
463 assert( (
size2() > 0) &&
bool(
"Vector not yet initialized!") );
470 template <
typename LHS,
typename RHS,
typename OP>
475 &&
bool(
"Incompatible matrix sizes!"));
476 assert( (
size1() > 0) &&
bool(
"Vector not yet initialized!") );
477 assert( (
size2() > 0) &&
bool(
"Vector not yet initialized!") );
487 assert( (m.
size1() == size1_ || size1_ == 0) &&
bool(
"Size mismatch!") );
488 assert( (m.
size2() == size2_ || size2_ == 0) &&
bool(
"Size mismatch!") );
494 internal_size1_ = viennacl::tools::align_to_multiple<size_type>(size1_,
alignment);
495 internal_size2_ = viennacl::tools::align_to_multiple<size_type>(size2_,
alignment);
514 assert( (m.size1() == size1_ || size1_ == 0) &&
bool(
"Size mismatch!") );
515 assert( (m.size2() == size2_ || size2_ == 0) &&
bool(
"Size mismatch!") );
521 internal_size1_ = viennacl::tools::align_to_multiple<size_type>(size1_,
alignment);
522 internal_size2_ = viennacl::tools::align_to_multiple<size_type>(size2_,
alignment);
538 assert( (m.size1() == size1_ || size1_ == 0) &&
bool(
"Size mismatch!") );
539 assert( (m.size2() == size2_ || size2_ == 0) &&
bool(
"Size mismatch!") );
545 internal_size1_ = viennacl::tools::align_to_multiple<size_type>(size1_,
alignment);
546 internal_size2_ = viennacl::tools::align_to_multiple<size_type>(size2_,
alignment);
584 *
this, SCALARTYPE(1.0), 1,
false,
false,
585 other, SCALARTYPE(1.0), 1,
false,
false);
592 *
this, SCALARTYPE(1.0), 1,
false,
false,
593 other, SCALARTYPE(1.0), 1,
false,
true);
603 *
this, val, 1,
false,
false);
613 *
this, val, 1,
true,
false);
673 viennacl::backend::switch_memory_context<SCALARTYPE>(elements_, new_ctx);
686 assert( (rows > 0 && columns > 0) &&
bool(
"Check failed in matrix::resize(): Number of rows and columns must be positive!"));
695 std::vector< SCALARTYPE > new_entries( viennacl::tools::align_to_multiple<vcl_size_t>(rows,
alignment)
696 * viennacl::tools::align_to_multiple<vcl_size_t>(columns,
alignment));
706 new_entries[F::mem_index(i, j, viennacl::tools::align_to_multiple<vcl_size_t>(rows,
alignment), viennacl::tools::align_to_multiple<vcl_size_t>(columns,
alignment))]
714 internal_size1_ = viennacl::tools::align_to_multiple<size_type>(size1_,
alignment);
715 internal_size2_ = viennacl::tools::align_to_multiple<size_type>(size2_,
alignment);
722 internal_size1_ = viennacl::tools::align_to_multiple<size_type>(size1_,
alignment);
723 internal_size2_ = viennacl::tools::align_to_multiple<size_type>(size2_,
alignment);
750 template <
class SCALARTYPE,
typename F,
unsigned int ALIGNMENT>
751 class matrix :
public matrix_base<SCALARTYPE, F>
753 typedef matrix<SCALARTYPE, F, ALIGNMENT> self_type;
754 typedef matrix_base<SCALARTYPE, F> base_type;
769 #ifdef VIENNACL_WITH_OPENCL
773 template <
typename LHS,
typename RHS,
typename OP>
818 using base_type::operator=;
841 template<
class SCALARTYPE,
typename F>
842 std::ostream & operator<<(std::ostream & s, const matrix_base<SCALARTYPE, F> & gpu_matrix)
846 std::vector<SCALARTYPE> tmp(gpu_matrix.internal_size());
849 s <<
"[" << gpu_matrix.size1() <<
"," << gpu_matrix.size2() <<
"]";
852 for (size_type i = 0; i < gpu_matrix.size1(); ++i)
855 for (size_type j = 0; j < gpu_matrix.size2(); ++j)
857 s << tmp[F::mem_index(i * gpu_matrix.stride1() + gpu_matrix.start1(), j * gpu_matrix.stride2() + gpu_matrix.start2(), gpu_matrix.internal_size1(), gpu_matrix.internal_size2())];
858 if (j < gpu_matrix.size2() - 1)
862 if (i < gpu_matrix.size1() - 1)
874 template<
typename LHS,
typename RHS,
typename OP>
875 std::ostream & operator<<(std::ostream & s, const matrix_expression<LHS, RHS, OP> & expr)
885 template<
typename NumericT,
typename F>
886 matrix_expression< const matrix_base<NumericT, F>,
const matrix_base<NumericT, F>, op_trans>
893 template<
typename NumericT,
typename F>
894 vector_expression< const matrix_base<NumericT, F>,
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 CPU_MATRIX,
typename SCALARTYPE,
typename F,
unsigned int ALIGNMENT>
934 void copy(
const CPU_MATRIX & 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.") );
949 std::vector<SCALARTYPE> data(gpu_matrix.internal_size());
950 for (size_type i = 0; i < gpu_matrix.size1(); ++i)
952 for (size_type j = 0; j < gpu_matrix.size2(); ++j)
953 data[F::mem_index(i, j, gpu_matrix.internal_size1(), gpu_matrix.internal_size2())] = cpu_matrix(i,j);
969 template <
typename SCALARTYPE,
typename A1,
typename A2,
typename F,
unsigned int ALIGNMENT>
970 void copy(
const std::vector< std::vector<SCALARTYPE, 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.") );
984 std::vector<SCALARTYPE> data(gpu_matrix.internal_size());
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)
990 data[F::mem_index(i, j, gpu_matrix.internal_size1(), gpu_matrix.internal_size2())] = cpu_matrix[i][j];
1007 template <
typename SCALARTYPE,
typename F,
unsigned int ALIGNMENT>
1009 SCALARTYPE * cpu_matrix_end,
1019 #ifdef VIENNACL_WITH_EIGEN
1025 template <
typename F,
unsigned int ALIGNMENT>
1026 void copy(
const Eigen::MatrixXf & cpu_matrix,
1027 matrix<float, F, ALIGNMENT> & gpu_matrix)
1029 typedef typename matrix<float, F, ALIGNMENT>::size_type size_type;
1031 if (gpu_matrix.size1() == 0 || gpu_matrix.size2() == 0)
1033 gpu_matrix.resize(cpu_matrix.rows(),
1039 assert( (gpu_matrix.size1() ==
static_cast<vcl_size_t>(cpu_matrix.rows()))
1040 && (gpu_matrix.size2() ==
static_cast<vcl_size_t>(cpu_matrix.cols()))
1041 && bool(
"matrix size mismatch")
1045 std::vector<float> data(gpu_matrix.internal_size());
1046 for (size_type i = 0; i < gpu_matrix.size1(); ++i)
1048 for (size_type j = 0; j < gpu_matrix.size2(); ++j)
1049 data[F::mem_index(i, j, gpu_matrix.internal_size1(), gpu_matrix.internal_size2())] = cpu_matrix(i,j);
1061 template <
typename F,
unsigned int ALIGNMENT>
1062 void copy(
const Eigen::MatrixXd & cpu_matrix,
1063 matrix<double, F, ALIGNMENT> & gpu_matrix)
1065 typedef typename matrix<double, F, ALIGNMENT>::size_type size_type;
1067 if (gpu_matrix.size1() == 0 || gpu_matrix.size2() == 0)
1069 gpu_matrix.resize(cpu_matrix.rows(),
1075 assert( (gpu_matrix.size1() ==
static_cast<vcl_size_t>(cpu_matrix.rows()))
1076 && (gpu_matrix.size2() ==
static_cast<vcl_size_t>(cpu_matrix.cols()))
1077 && bool(
"matrix size mismatch")
1081 std::vector<double> data(gpu_matrix.internal_size());
1082 for (size_type i = 0; i < gpu_matrix.size1(); ++i)
1084 for (size_type j = 0; j < gpu_matrix.size2(); ++j)
1085 data[F::mem_index(i, j, gpu_matrix.internal_size1(), gpu_matrix.internal_size2())] = cpu_matrix(i,j);
1093 #ifdef VIENNACL_WITH_MTL4
1099 template <
typename SCALARTYPE,
typename T,
typename F,
unsigned int ALIGNMENT>
1100 void copy(
const mtl::dense2D<SCALARTYPE, T>& cpu_matrix,
1101 matrix<SCALARTYPE, F, ALIGNMENT> & gpu_matrix)
1103 typedef typename matrix<SCALARTYPE, F, ALIGNMENT>::size_type size_type;
1105 if (gpu_matrix.size1() == 0 || gpu_matrix.size2() == 0)
1107 gpu_matrix.resize(cpu_matrix.num_rows(),
1108 cpu_matrix.num_cols(),
1113 assert( (gpu_matrix.size1() == cpu_matrix.num_rows())
1114 && (gpu_matrix.size2() == cpu_matrix.num_cols())
1115 &&
bool(
"matrix size mismatch")
1119 std::vector<SCALARTYPE> data(gpu_matrix.internal_size());
1120 for (size_type i = 0; i < gpu_matrix.size1(); ++i)
1122 for (size_type j = 0; j < gpu_matrix.size2(); ++j)
1123 data[F::mem_index(i, j, gpu_matrix.internal_size1(), gpu_matrix.internal_size2())] = cpu_matrix[i][j];
1142 template <
typename CPU_MATRIX,
typename SCALARTYPE,
typename F,
unsigned int ALIGNMENT>
1144 CPU_MATRIX & cpu_matrix )
1148 if ( (gpu_matrix.size1() > 0) && (gpu_matrix.size2() > 0) )
1150 assert(
viennacl::traits::size1(cpu_matrix) == gpu_matrix.size1() && bool(
"Matrix dimensions mismatch: rows"));
1152 std::vector<SCALARTYPE> temp_buffer(gpu_matrix.internal_size());
1156 for (size_type i = 0; i < gpu_matrix.size1(); ++i)
1158 assert(
viennacl::traits::size2(cpu_matrix) == gpu_matrix.size2() && bool(
"Matrix dimensions mismatch: columns"));
1159 for (size_type j = 0; j < gpu_matrix.size2(); ++j)
1160 cpu_matrix(i,j) = temp_buffer[F::mem_index(i, j, gpu_matrix.internal_size1(), gpu_matrix.internal_size2())];
1171 template <
typename SCALARTYPE,
typename A1,
typename A2,
typename F,
unsigned int ALIGNMENT>
1173 std::vector< std::vector<SCALARTYPE, A1>, A2> & cpu_matrix)
1177 if ( (gpu_matrix.size1() > 0) && (gpu_matrix.size2() > 0) )
1179 assert( (cpu_matrix.size() == gpu_matrix.size1()) &&
bool(
"Matrix dimensions mismatch: rows"));
1181 std::vector<SCALARTYPE> temp_buffer(gpu_matrix.internal_size());
1185 for (size_type i = 0; i < gpu_matrix.size1(); ++i)
1187 assert( (cpu_matrix[i].
size() == gpu_matrix.size2()) &&
bool(
"Matrix dimensions mismatch: columns"));
1189 for (size_type j = 0; j < gpu_matrix.size2(); ++j)
1190 cpu_matrix[i][j] = temp_buffer[F::mem_index(i, j, gpu_matrix.internal_size1(), gpu_matrix.internal_size2())];
1201 template <
typename SCALARTYPE,
typename F,
unsigned int ALIGNMENT>
1203 SCALARTYPE * cpu_matrix_begin)
1215 template <
typename LHS1,
typename RHS1,
typename OP1,
1216 typename LHS2,
typename RHS2,
typename OP2>
1217 matrix_expression< const matrix_expression<const LHS1, const RHS1, OP1>,
1218 const matrix_expression<const LHS2, const RHS2, OP2>,
1225 &&
bool(
"Incompatible matrix sizes!"));
1231 template <
typename LHS1,
typename RHS1,
typename OP1,
1232 typename NumericT,
typename F>
1233 matrix_expression< const matrix_expression<const LHS1, const RHS1, OP1>,
1234 const matrix_base<NumericT, F>,
1241 &&
bool(
"Incompatible matrix sizes!"));
1247 template <
typename NumericT,
typename F,
1248 typename LHS2,
typename RHS2,
typename OP2>
1249 matrix_expression< const matrix_base<NumericT, F>,
1250 const matrix_expression<const LHS2, const RHS2, OP2>,
1257 &&
bool(
"Incompatible matrix sizes!"));
1264 template <
typename NumericT,
typename F>
1265 matrix_expression< const matrix_base<NumericT, F>,
const matrix_base<NumericT, F>, op_add >
1275 template <
typename LHS1,
typename RHS1,
typename OP1,
1276 typename LHS2,
typename RHS2,
typename OP2>
1277 matrix_expression< const matrix_expression<const LHS1, const RHS1, OP1>,
1278 const matrix_expression<const LHS2, const RHS2, OP2>,
1285 &&
bool(
"Incompatible matrix sizes!"));
1291 template <
typename LHS1,
typename RHS1,
typename OP1,
1292 typename NumericT,
typename F>
1293 matrix_expression< const matrix_expression<const LHS1, const RHS1, OP1>,
1294 const matrix_base<NumericT, F>,
1301 &&
bool(
"Incompatible matrix sizes!"));
1307 template <
typename NumericT,
typename F,
1308 typename LHS2,
typename RHS2,
typename OP2>
1309 matrix_expression< const matrix_base<NumericT, F>,
1310 const matrix_expression<const LHS2, const RHS2, OP2>,
1317 &&
bool(
"Incompatible matrix sizes!"));
1324 template <
typename NumericT,
typename F>
1325 matrix_expression< const matrix_base<NumericT, F>,
const matrix_base<NumericT, F>, op_sub >
1341 template <
typename S1,
typename NumericT,
typename F>
1343 matrix_expression< const matrix_base<NumericT, F>,
const S1, op_mult>
1356 template <
typename LHS,
typename RHS,
typename OP,
typename S1>
1358 matrix_expression< const matrix_expression< LHS, RHS, OP>,
const S1, op_mult> >::type
1371 template <
typename S1,
typename LHS,
typename RHS,
typename OP>
1373 matrix_expression< const matrix_expression< LHS, RHS, OP>,
const S1, op_mult> >::type
1382 template <
typename NumericT,
typename F,
typename S1>
1384 matrix_expression< const matrix_base<NumericT, F>,
const S1, op_mult> >::type
1395 template <
typename NumericT,
typename F,
typename S1>
1397 matrix_base<NumericT, F> &
1416 template <
typename LHS,
typename RHS,
typename OP,
typename S1>
1418 matrix_expression< const matrix_expression<const LHS, const RHS, OP>,
const S1, op_div> >::type
1428 template <
typename NumericT,
typename F,
typename S1>
1430 matrix_expression< const matrix_base<NumericT, F>,
const S1, op_div> >::type
1441 template <
typename NumericT,
typename F,
typename S1>
1443 matrix_base<NumericT, F> &
1458 template <
typename NumericT,
typename S1>
1472 template <
typename NumericT,
typename S1>
1483 op_mult>(proxy, NumericT(val));
1487 template <
typename NumericT,
typename S1>
1501 template<
typename NumericT,
typename S1>
1512 op_mult>(proxy, NumericT(val));
1529 template <
typename T,
typename F>
1530 struct op_executor<matrix_base<T, F>, op_assign, matrix_base<T, F> >
1532 static void apply(matrix_base<T, F> & lhs, matrix_base<T, F>
const & rhs)
1539 template <
typename T,
typename F>
1540 struct op_executor<matrix_base<T, F>, op_inplace_add, matrix_base<T, F> >
1542 static void apply(matrix_base<T, F> & lhs, matrix_base<T, F>
const & rhs)
1544 viennacl::linalg::ambm(lhs, lhs, T(1), 1,
false,
false, rhs, T(1), 1,
false,
false);
1549 template <
typename T,
typename F>
1550 struct op_executor<matrix_base<T, F>, op_inplace_sub, matrix_base<T, F> >
1552 static void apply(matrix_base<T, F> & lhs, matrix_base<T, F>
const & rhs)
1554 viennacl::linalg::ambm(lhs, lhs, T(1), 1,
false,
false, rhs, T(1), 1,
false,
true);
1562 template <
typename T,
typename F,
typename ScalarType>
1563 struct op_executor<matrix_base<T, F>, op_assign, matrix_expression<const matrix_base<T, F>, const ScalarType, op_mult> >
1565 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_mult>
const & proxy)
1572 template <
typename T,
typename F,
typename ScalarType>
1573 struct op_executor<matrix_base<T, F>, op_inplace_add, matrix_expression<const matrix_base<T, F>, const ScalarType, op_mult> >
1575 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_mult>
const & proxy)
1577 viennacl::linalg::ambm(lhs, lhs, T(1), 1,
false,
false, proxy.lhs(), proxy.rhs(), 1,
false,
false);
1582 template <
typename T,
typename F,
typename ScalarType>
1583 struct op_executor<matrix_base<T, F>, op_inplace_sub, matrix_expression<const matrix_base<T, F>, const ScalarType, op_mult> >
1585 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_mult>
const & proxy)
1587 viennacl::linalg::ambm(lhs, lhs, T(1), 1,
false,
false, proxy.lhs(), proxy.rhs(), 1,
false,
true);
1595 template <
typename T,
typename F,
typename LHS,
typename RHS,
typename OP,
typename ScalarType>
1596 struct op_executor<matrix_base<T, F>, op_assign, matrix_expression<const matrix_expression<const LHS, const RHS, OP>, const ScalarType, op_mult> >
1598 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<const LHS, const RHS, OP>,
const ScalarType, op_mult>
const & proxy)
1600 matrix<T, F> temp(proxy.lhs());
1601 lhs = temp * proxy.rhs();
1606 template <
typename T,
typename F,
typename LHS,
typename RHS,
typename OP,
typename ScalarType>
1607 struct op_executor<matrix_base<T, F>, op_inplace_add, matrix_expression<const matrix_expression<const LHS, const RHS, OP>, const ScalarType, op_mult> >
1609 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<const LHS, const RHS, OP>,
const ScalarType, op_mult>
const & proxy)
1611 matrix<T, F> temp(proxy.lhs());
1612 lhs += temp * proxy.rhs();
1617 template <
typename T,
typename F,
typename LHS,
typename RHS,
typename OP,
typename ScalarType>
1618 struct op_executor<matrix_base<T, F>, op_inplace_sub, matrix_expression<const matrix_expression<const LHS, const RHS, OP>, const ScalarType, op_mult> >
1620 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<const LHS, const RHS, OP>,
const ScalarType, op_mult>
const & proxy)
1622 matrix<T, F> temp(proxy.lhs());
1623 lhs -= temp * proxy.rhs();
1631 template <
typename T,
typename F,
typename ScalarType>
1632 struct op_executor<matrix_base<T, F>, op_assign, matrix_expression<const matrix_base<T, F>, const ScalarType, op_div> >
1634 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_div>
const & proxy)
1641 template <
typename T,
typename F,
typename ScalarType>
1642 struct op_executor<matrix_base<T, F>, op_inplace_add, matrix_expression<const matrix_base<T, F>, const ScalarType, op_div> >
1644 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_div>
const & proxy)
1646 viennacl::linalg::ambm(lhs, lhs, T(1), 1,
false,
false, proxy.lhs(), proxy.rhs(), 1,
true,
false);
1651 template <
typename T,
typename F,
typename ScalarType>
1652 struct op_executor<matrix_base<T, F>, op_inplace_sub, matrix_expression<const matrix_base<T, F>, const ScalarType, op_div> >
1654 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_div>
const & proxy)
1656 viennacl::linalg::ambm(lhs, lhs, T(1), 1,
false,
false, proxy.lhs(), proxy.rhs(), 1,
true,
true);
1664 template <
typename T,
typename F,
typename LHS,
typename RHS,
typename OP,
typename ScalarType>
1665 struct op_executor<matrix_base<T, F>, op_assign, matrix_expression<const matrix_expression<const LHS, const RHS, OP>, const ScalarType, op_div> >
1667 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<const LHS, const RHS, OP>,
const ScalarType, op_div>
const & proxy)
1669 matrix<T, F> temp(proxy.lhs());
1670 lhs = temp / proxy.rhs();
1675 template <
typename T,
typename F,
typename LHS,
typename RHS,
typename OP,
typename ScalarType>
1676 struct op_executor<matrix_base<T, F>, op_inplace_add, matrix_expression<const matrix_expression<const LHS, const RHS, OP>, const ScalarType, op_div> >
1678 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<const LHS, const RHS, OP>,
const ScalarType, op_div>
const & proxy)
1680 matrix<T, F> temp(proxy.lhs());
1681 lhs += temp / proxy.rhs();
1686 template <
typename T,
typename F,
typename LHS,
typename RHS,
typename OP,
typename ScalarType>
1687 struct op_executor<matrix_base<T, F>, op_inplace_sub, matrix_expression<const matrix_expression<const LHS, const RHS, OP>, const ScalarType, op_div> >
1689 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<const LHS, const RHS, OP>,
const ScalarType, op_div>
const & proxy)
1691 matrix<T, F> temp(proxy.lhs());
1692 lhs -= temp / proxy.rhs();
1699 template <
typename T,
typename F,
typename LHS,
typename RHS>
1700 struct op_executor<matrix_base<T, F>, op_assign, matrix_expression<const LHS, const RHS, op_add> >
1703 template <
typename LHS1,
typename RHS1>
1704 static void apply(matrix_base<T, F> & lhs, matrix_expression<const LHS1, const RHS1, op_add>
const & proxy)
1706 bool op_aliasing_lhs =
op_aliasing(lhs, proxy.lhs());
1707 bool op_aliasing_rhs =
op_aliasing(lhs, proxy.rhs());
1709 if (op_aliasing_lhs || op_aliasing_rhs)
1711 matrix_base<T, F> temp(proxy.lhs());
1712 op_executor<matrix_base<T, F>, op_inplace_add, RHS>::apply(temp, proxy.rhs());
1717 op_executor<matrix_base<T, F>, op_assign, LHS>::apply(lhs, proxy.lhs());
1718 op_executor<matrix_base<T, F>, op_inplace_add, RHS>::apply(lhs, proxy.rhs());
1723 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
const matrix_base<T, F>, op_add>
const & proxy)
1726 proxy.lhs(), T(1), 1,
false,
false,
1727 proxy.rhs(), T(1), 1,
false,
false);
1731 template <
typename ScalarType>
1732 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_mult>,
1733 const matrix_base<T, F>,
1734 op_add>
const & proxy)
1737 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
1738 proxy.rhs(), T(1), 1,
false,
false);
1742 template <
typename ScalarType>
1743 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_div>,
1744 const matrix_base<T, F>,
1745 op_add>
const & proxy)
1748 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
1749 proxy.rhs(), T(1), 1,
false,
false);
1753 template <
typename ScalarType>
1754 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
1755 const matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_mult>,
1756 op_add>
const & proxy)
1759 proxy.lhs(), T(1), 1,
false,
false,
1760 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
false);
1764 template <
typename ScalarType>
1765 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
1766 const matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_div>,
1767 op_add>
const & proxy)
1770 proxy.lhs(), T(1), 1,
false,
false,
1771 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
false);
1775 template <
typename ScalarType1,
typename ScalarType2>
1776 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType1, op_mult>,
1777 const matrix_expression<
const matrix_base<T, F>,
const ScalarType2, op_mult>,
1778 op_add>
const & proxy)
1781 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
1782 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
false);
1786 template <
typename ScalarType1,
typename ScalarType2>
1787 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType1, op_mult>,
1788 const matrix_expression<
const matrix_base<T, F>,
const ScalarType2, op_div>,
1789 op_add>
const & proxy)
1792 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
1793 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
false);
1797 template <
typename ScalarType1,
typename ScalarType2>
1798 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType1, op_div>,
1799 const matrix_expression<
const matrix_base<T, F>,
const ScalarType2, op_mult>,
1800 op_add>
const & proxy)
1803 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
1804 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
false);
1808 template <
typename ScalarType1,
typename ScalarType2>
1809 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType1, op_div>,
1810 const matrix_expression<
const matrix_base<T, F>,
const ScalarType2, op_div>,
1811 op_add>
const & proxy)
1814 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
1815 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
false);
1820 template <
typename T,
typename F1,
typename LHS,
typename RHS>
1821 struct op_executor<matrix_base<T, F1>, op_assign, matrix_expression<const LHS, const RHS, op_prod> >
1823 template <
typename SparseMatrixType,
typename F2 >
1824 static void apply(matrix_base<T, F1> & lhs, matrix_expression<
const SparseMatrixType,
1832 template <
typename SparseMatrixType,
typename F2 >
1833 static void apply(matrix_base<T, F1> & lhs, matrix_expression<
const SparseMatrixType,
1845 template <
typename T,
typename F,
typename LHS,
typename RHS>
1846 struct op_executor<matrix_base<T, F>, op_inplace_add, matrix_expression<const LHS, const RHS, op_add> >
1849 template <
typename LHS1,
typename RHS1>
1850 static void apply(matrix_base<T, F> & lhs, matrix_expression<const LHS1, const RHS1, op_add>
const & proxy)
1852 bool op_aliasing_lhs =
op_aliasing(lhs, proxy.lhs());
1853 bool op_aliasing_rhs =
op_aliasing(lhs, proxy.rhs());
1855 if (op_aliasing_lhs || op_aliasing_rhs)
1857 matrix_base<T, F> temp(proxy.lhs());
1858 op_executor<matrix_base<T, F>, op_inplace_add, RHS>::apply(temp, proxy.rhs());
1863 op_executor<matrix_base<T, F>, op_inplace_add, LHS>::apply(lhs, proxy.lhs());
1864 op_executor<matrix_base<T, F>, op_inplace_add, RHS>::apply(lhs, proxy.rhs());
1869 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
const matrix_base<T, F>, op_add>
const & proxy)
1872 proxy.lhs(), T(1), 1,
false,
false,
1873 proxy.rhs(), T(1), 1,
false,
false);
1877 template <
typename ScalarType>
1878 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_mult>,
1879 const matrix_base<T, F>,
1880 op_add>
const & proxy)
1883 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
1884 proxy.rhs(), T(1), 1,
false,
false);
1888 template <
typename ScalarType>
1889 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_div>,
1890 const matrix_base<T, F>,
1891 op_add>
const & proxy)
1894 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
1895 proxy.rhs(), T(1), 1,
false,
false);
1899 template <
typename ScalarType>
1900 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
1901 const matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_mult>,
1902 op_add>
const & proxy)
1905 proxy.lhs(), T(1), 1,
false,
false,
1906 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
false);
1910 template <
typename ScalarType>
1911 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
1912 const matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_div>,
1913 op_add>
const & proxy)
1916 proxy.lhs(), T(1), 1,
false,
false,
1917 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
false);
1921 template <
typename ScalarType1,
typename ScalarType2>
1922 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType1, op_mult>,
1923 const matrix_expression<
const matrix_base<T, F>,
const ScalarType2, op_mult>,
1924 op_add>
const & proxy)
1927 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
1928 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
false);
1932 template <
typename ScalarType1,
typename ScalarType2>
1933 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType1, op_mult>,
1934 const matrix_expression<
const matrix_base<T, F>,
const ScalarType2, op_div>,
1935 op_add>
const & proxy)
1938 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
1939 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
false);
1943 template <
typename ScalarType1,
typename ScalarType2>
1944 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType1, op_div>,
1945 const matrix_expression<
const matrix_base<T, F>,
const ScalarType2, op_mult>,
1946 op_add>
const & proxy)
1949 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
1950 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
false);
1954 template <
typename ScalarType1,
typename ScalarType2>
1955 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType1, op_div>,
1956 const matrix_expression<
const matrix_base<T, F>,
const ScalarType2, op_div>,
1957 op_add>
const & proxy)
1960 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
1961 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
false);
1968 template <
typename T,
typename F,
typename LHS,
typename RHS>
1969 struct op_executor<matrix_base<T, F>, op_inplace_sub, matrix_expression<const LHS, const RHS, op_add> >
1972 template <
typename LHS1,
typename RHS1>
1973 static void apply(matrix_base<T, F> & lhs, matrix_expression<const LHS1, const RHS1, op_add>
const & proxy)
1975 bool op_aliasing_lhs =
op_aliasing(lhs, proxy.lhs());
1976 bool op_aliasing_rhs =
op_aliasing(lhs, proxy.rhs());
1978 if (op_aliasing_lhs || op_aliasing_rhs)
1980 matrix_base<T, F> temp(proxy.lhs());
1981 op_executor<matrix_base<T, F>, op_inplace_add, RHS>::apply(temp, proxy.rhs());
1986 op_executor<matrix_base<T, F>, op_inplace_sub, LHS>::apply(lhs, proxy.lhs());
1987 op_executor<matrix_base<T, F>, op_inplace_sub, RHS>::apply(lhs, proxy.rhs());
1992 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
const matrix_base<T, F>, op_add>
const & proxy)
1995 proxy.lhs(), T(1), 1,
false,
true,
1996 proxy.rhs(), T(1), 1,
false,
true);
2000 template <
typename ScalarType>
2001 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_mult>,
2002 const matrix_base<T, F>,
2003 op_add>
const & proxy)
2006 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
true,
2007 proxy.rhs(), T(1), 1,
false,
true);
2011 template <
typename ScalarType>
2012 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_div>,
2013 const matrix_base<T, F>,
2014 op_add>
const & proxy)
2017 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
true,
2018 proxy.rhs(), T(1), 1,
false,
true);
2022 template <
typename ScalarType>
2023 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
2024 const matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_mult>,
2025 op_add>
const & proxy)
2028 proxy.lhs(), T(1), 1,
false,
true,
2029 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
true);
2033 template <
typename ScalarType>
2034 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
2035 const matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_div>,
2036 op_add>
const & proxy)
2039 proxy.lhs(), T(1), 1,
false,
true,
2040 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
true);
2044 template <
typename ScalarType1,
typename ScalarType2>
2045 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType1, op_mult>,
2046 const matrix_expression<
const matrix_base<T, F>,
const ScalarType2, op_mult>,
2047 op_add>
const & proxy)
2050 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
true,
2051 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
true);
2055 template <
typename ScalarType1,
typename ScalarType2>
2056 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType1, op_mult>,
2057 const matrix_expression<
const matrix_base<T, F>,
const ScalarType2, op_div>,
2058 op_add>
const & proxy)
2061 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
true,
2062 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
true);
2066 template <
typename ScalarType1,
typename ScalarType2>
2067 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType1, op_div>,
2068 const matrix_expression<
const matrix_base<T, F>,
const ScalarType2, op_mult>,
2069 op_add>
const & proxy)
2072 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
true,
2073 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
true);
2077 template <
typename ScalarType1,
typename ScalarType2>
2078 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType1, op_div>,
2079 const matrix_expression<
const matrix_base<T, F>,
const ScalarType2, op_div>,
2080 op_add>
const & proxy)
2083 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
true,
2084 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
true);
2095 template <
typename T,
typename F,
typename LHS,
typename RHS>
2096 struct op_executor<matrix_base<T, F>, op_assign, matrix_expression<const LHS, const RHS, op_sub> >
2099 template <
typename LHS1,
typename RHS1>
2100 static void apply(matrix_base<T, F> & lhs, matrix_expression<const LHS1, const RHS1, op_sub>
const & proxy)
2102 bool op_aliasing_lhs =
op_aliasing(lhs, proxy.lhs());
2103 bool op_aliasing_rhs =
op_aliasing(lhs, proxy.rhs());
2105 if (op_aliasing_lhs || op_aliasing_rhs)
2107 matrix_base<T, F> temp(proxy.lhs());
2108 op_executor<matrix_base<T, F>, op_inplace_sub, RHS>::apply(temp, proxy.rhs());
2113 op_executor<matrix_base<T, F>, op_assign, LHS>::apply(lhs, proxy.lhs());
2114 op_executor<matrix_base<T, F>, op_inplace_sub, RHS>::apply(lhs, proxy.rhs());
2119 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
const matrix_base<T, F>, op_sub>
const & proxy)
2122 proxy.lhs(), T(1), 1,
false,
false,
2123 proxy.rhs(), T(1), 1,
false,
true);
2127 template <
typename ScalarType>
2128 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_mult>,
2129 const matrix_base<T, F>,
2130 op_sub>
const & proxy)
2133 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2134 proxy.rhs(), T(1), 1,
false,
true);
2138 template <
typename ScalarType>
2139 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_div>,
2140 const matrix_base<T, F>,
2141 op_sub>
const & proxy)
2144 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2145 proxy.rhs(), T(1), 1,
false,
true);
2149 template <
typename ScalarType>
2150 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
2151 const matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_mult>,
2152 op_sub>
const & proxy)
2155 proxy.lhs(), T(1), 1,
false,
false,
2156 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
true);
2160 template <
typename ScalarType>
2161 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
2162 const matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_div>,
2163 op_sub>
const & proxy)
2166 proxy.lhs(), T(1), 1,
false,
false,
2167 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
true);
2171 template <
typename ScalarType1,
typename ScalarType2>
2172 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType1, op_mult>,
2173 const matrix_expression<
const matrix_base<T, F>,
const ScalarType2, op_mult>,
2174 op_sub>
const & proxy)
2177 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2178 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
true);
2182 template <
typename ScalarType1,
typename ScalarType2>
2183 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType1, op_mult>,
2184 const matrix_expression<
const matrix_base<T, F>,
const ScalarType2, op_div>,
2185 op_sub>
const & proxy)
2188 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2189 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
true);
2193 template <
typename ScalarType1,
typename ScalarType2>
2194 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType1, op_div>,
2195 const matrix_expression<
const matrix_base<T, F>,
const ScalarType2, op_mult>,
2196 op_sub>
const & proxy)
2199 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2200 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
true);
2204 template <
typename ScalarType1,
typename ScalarType2>
2205 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType1, op_div>,
2206 const matrix_expression<
const matrix_base<T, F>,
const ScalarType2, op_div>,
2207 op_sub>
const & proxy)
2210 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2211 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
true);
2217 template <
typename T,
typename F,
typename LHS,
typename RHS>
2218 struct op_executor<matrix_base<T, F>, op_inplace_add, matrix_expression<const LHS, const RHS, op_sub> >
2221 template <
typename LHS1,
typename RHS1>
2222 static void apply(matrix_base<T, F> & lhs, matrix_expression<const LHS1, const RHS1, op_sub>
const & proxy)
2224 bool op_aliasing_lhs =
op_aliasing(lhs, proxy.lhs());
2225 bool op_aliasing_rhs =
op_aliasing(lhs, proxy.rhs());
2227 if (op_aliasing_lhs || op_aliasing_rhs)
2229 matrix_base<T, F> temp(proxy.lhs());
2230 op_executor<matrix_base<T, F>, op_inplace_sub, RHS>::apply(temp, proxy.rhs());
2235 op_executor<matrix_base<T, F>, op_inplace_add, LHS>::apply(lhs, proxy.lhs());
2236 op_executor<matrix_base<T, F>, op_inplace_sub, RHS>::apply(lhs, proxy.rhs());
2241 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
const matrix_base<T, F>, op_sub>
const & proxy)
2244 proxy.lhs(), T(1), 1,
false,
false,
2245 proxy.rhs(), T(1), 1,
false,
true);
2249 template <
typename ScalarType>
2250 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_mult>,
2251 const matrix_base<T, F>,
2252 op_sub>
const & proxy)
2255 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2256 proxy.rhs(), T(1), 1,
false,
true);
2260 template <
typename ScalarType>
2261 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_div>,
2262 const matrix_base<T, F>,
2263 op_sub>
const & proxy)
2266 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2267 proxy.rhs(), T(1), 1,
false,
true);
2271 template <
typename ScalarType>
2272 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
2273 const matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_mult>,
2274 op_sub>
const & proxy)
2277 proxy.lhs(), T(1), 1,
false,
false,
2278 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
true);
2282 template <
typename ScalarType>
2283 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
2284 const matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_div>,
2285 op_sub>
const & proxy)
2288 proxy.lhs(), T(1), 1,
false,
false,
2289 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
true);
2293 template <
typename ScalarType1,
typename ScalarType2>
2294 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType1, op_mult>,
2295 const matrix_expression<
const matrix_base<T, F>,
const ScalarType2, op_mult>,
2296 op_sub>
const & proxy)
2299 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2300 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
true);
2304 template <
typename ScalarType1,
typename ScalarType2>
2305 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType1, op_mult>,
2306 const matrix_expression<
const matrix_base<T, F>,
const ScalarType2, op_div>,
2307 op_sub>
const & proxy)
2310 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2311 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
true);
2315 template <
typename ScalarType1,
typename ScalarType2>
2316 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType1, op_div>,
2317 const matrix_expression<
const matrix_base<T, F>,
const ScalarType2, op_mult>,
2318 op_sub>
const & proxy)
2321 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2322 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
true);
2326 template <
typename ScalarType1,
typename ScalarType2>
2327 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType1, op_div>,
2328 const matrix_expression<
const matrix_base<T, F>,
const ScalarType2, op_div>,
2329 op_sub>
const & proxy)
2332 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2333 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
true);
2340 template <
typename T,
typename F,
typename LHS,
typename RHS>
2341 struct op_executor<matrix_base<T, F>, op_inplace_sub, matrix_expression<const LHS, const RHS, op_sub> >
2344 template <
typename LHS1,
typename RHS1>
2345 static void apply(matrix_base<T, F> & lhs, matrix_expression<const LHS1, const RHS1, op_sub>
const & proxy)
2347 bool op_aliasing_lhs =
op_aliasing(lhs, proxy.lhs());
2348 bool op_aliasing_rhs =
op_aliasing(lhs, proxy.rhs());
2350 if (op_aliasing_lhs || op_aliasing_rhs)
2352 matrix_base<T, F> temp(proxy.lhs());
2353 op_executor<matrix_base<T, F>, op_inplace_sub, RHS>::apply(temp, proxy.rhs());
2358 op_executor<matrix_base<T, F>, op_inplace_sub, LHS>::apply(lhs, proxy.lhs());
2359 op_executor<matrix_base<T, F>, op_inplace_add, RHS>::apply(lhs, proxy.rhs());
2364 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
const matrix_base<T, F>, op_sub>
const & proxy)
2367 proxy.lhs(), T(1), 1,
false,
true,
2368 proxy.rhs(), T(1), 1,
false,
false);
2372 template <
typename ScalarType>
2373 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_mult>,
2374 const matrix_base<T, F>,
2375 op_sub>
const & proxy)
2378 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
true,
2379 proxy.rhs(), T(1), 1,
false,
false);
2383 template <
typename ScalarType>
2384 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_div>,
2385 const matrix_base<T, F>,
2386 op_sub>
const & proxy)
2389 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
true,
2390 proxy.rhs(), T(1), 1,
false,
false);
2394 template <
typename ScalarType>
2395 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
2396 const matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_mult>,
2397 op_sub>
const & proxy)
2400 proxy.lhs(), T(1), 1,
false,
true,
2401 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
false);
2405 template <
typename ScalarType>
2406 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
2407 const matrix_expression<
const matrix_base<T, F>,
const ScalarType, op_div>,
2408 op_sub>
const & proxy)
2411 proxy.lhs(), T(1), 1,
false,
true,
2412 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
false);
2416 template <
typename ScalarType1,
typename ScalarType2>
2417 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType1, op_mult>,
2418 const matrix_expression<
const matrix_base<T, F>,
const ScalarType2, op_mult>,
2419 op_sub>
const & proxy)
2422 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
true,
2423 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
false);
2427 template <
typename ScalarType1,
typename ScalarType2>
2428 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType1, op_mult>,
2429 const matrix_expression<
const matrix_base<T, F>,
const ScalarType2, op_div>,
2430 op_sub>
const & proxy)
2433 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
true,
2434 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
false);
2438 template <
typename ScalarType1,
typename ScalarType2>
2439 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType1, op_div>,
2440 const matrix_expression<
const matrix_base<T, F>,
const ScalarType2, op_mult>,
2441 op_sub>
const & proxy)
2444 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
true,
2445 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
false);
2449 template <
typename ScalarType1,
typename ScalarType2>
2450 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F>,
const ScalarType1, op_div>,
2451 const matrix_expression<
const matrix_base<T, F>,
const ScalarType2, op_div>,
2452 op_sub>
const & proxy)
2455 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
true,
2456 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
false);
2463 template <
typename T,
typename F,
typename LHS>
2464 struct op_executor<matrix_base<T, F>, op_assign, matrix_expression<const LHS, const int, op_vector_diag> >
2466 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const vector_base<T>,
const int, op_vector_diag>
const & proxy)
2473 template <
typename T,
typename LHS>
2474 struct op_executor<vector_base<T>, op_assign, vector_expression<const LHS, const int, op_matrix_diag> >
2476 template <
typename F>
2477 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_base<T, F>,
const int, op_matrix_diag>
const & proxy)
2483 template <
typename T,
typename LHS>
2484 struct op_executor<vector_base<T>, op_assign, vector_expression<const LHS, const unsigned int, op_row> >
2486 template <
typename F>
2487 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_base<T, F>,
const unsigned int, op_row>
const & proxy)
2494 template <
typename T,
typename LHS>
2495 struct op_executor<vector_base<T>, op_assign, vector_expression<const LHS, const unsigned int, op_column> >
2497 template <
typename F>
2498 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_base<T, F>,
const unsigned int, op_column>
const & proxy)
2508 template <
typename T,
typename F,
typename LHS,
typename RHS,
typename OP>
2509 struct op_executor<matrix_base<T, F>, op_assign, matrix_expression<const LHS, const RHS, op_element_binary<OP> > >
2512 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
const matrix_base<T, F>, op_element_binary<OP> >
const & proxy)
2518 template <
typename LHS2,
typename RHS2,
typename OP2>
2519 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
const matrix_expression<const LHS2, const RHS2, OP2>, op_element_binary<OP> >
const & proxy)
2521 matrix<T, F> temp(proxy.rhs());
2526 template <
typename LHS1,
typename RHS1,
typename OP1>
2527 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<const LHS1, const RHS1, OP1>,
const matrix_base<T, F>, op_element_binary<OP> >
const & proxy)
2529 matrix<T, F> temp(proxy.lhs());
2534 template <
typename LHS1,
typename RHS1,
typename OP1,
2535 typename LHS2,
typename RHS2,
typename OP2>
2536 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<const LHS1, const RHS1, OP1>,
2537 const matrix_expression<const LHS2, const RHS2, OP2>,
2538 op_element_binary<OP> >
const & proxy)
2540 matrix<T, F> temp1(proxy.lhs());
2541 matrix<T, F> temp2(proxy.rhs());
2547 template <
typename T,
typename F,
typename LHS,
typename RHS,
typename OP>
2548 struct op_executor<matrix_base<T, F>, op_inplace_add, matrix_expression<const LHS, const RHS, op_element_binary<OP> > >
2551 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
const matrix_base<T, F>, op_element_binary<OP> >
const & proxy)
2558 template <
typename LHS2,
typename RHS2,
typename OP2>
2559 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
const matrix_expression<const LHS2, const RHS2, OP2>, op_element_binary<OP> >
const & proxy)
2561 matrix<T, F> temp(proxy.rhs());
2562 matrix<T, F> temp2(temp.size1(), temp.size2());
2568 template <
typename LHS1,
typename RHS1,
typename OP1>
2569 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<const LHS1, const RHS1, OP1>,
const matrix_base<T, F>, op_element_binary<OP> >
const & proxy)
2571 matrix<T, F> temp(proxy.lhs());
2572 matrix<T, F> temp2(temp.size1(), temp.size2());
2578 template <
typename LHS1,
typename RHS1,
typename OP1,
2579 typename LHS2,
typename RHS2,
typename OP2>
2580 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<const LHS1, const RHS1, OP1>,
2581 const matrix_expression<const LHS2, const RHS2, OP2>,
2582 op_element_binary<OP> >
const & proxy)
2584 matrix<T, F> temp1(proxy.lhs());
2585 matrix<T, F> temp2(proxy.rhs());
2586 matrix<T, F> temp3(temp1.size1(), temp1.size2());
2593 template <
typename T,
typename F,
typename LHS,
typename RHS,
typename OP>
2594 struct op_executor<matrix_base<T, F>, op_inplace_sub, matrix_expression<const LHS, const RHS, op_element_binary<OP> > >
2598 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
const matrix_base<T, F>, op_element_binary<OP> >
const & proxy)
2605 template <
typename LHS2,
typename RHS2,
typename OP2>
2606 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
const matrix_expression<const LHS2, const RHS2, OP2>, op_element_binary<OP> >
const & proxy)
2608 matrix<T, F> temp(proxy.rhs());
2609 matrix<T, F> temp2(temp.size1(), temp.size2());
2615 template <
typename LHS1,
typename RHS1,
typename OP1>
2616 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<const LHS1, const RHS1, OP1>,
const matrix_base<T, F>, op_element_binary<OP> >
const & proxy)
2618 matrix<T, F> temp(proxy.lhs());
2619 matrix<T, F> temp2(temp.size1(), temp.size2());
2625 template <
typename LHS1,
typename RHS1,
typename OP1,
2626 typename LHS2,
typename RHS2,
typename OP2>
2627 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<const LHS1, const RHS1, OP1>,
2628 const matrix_expression<const LHS2, const RHS2, OP2>,
2629 op_element_binary<OP> >
const & proxy)
2631 matrix<T, F> temp1(proxy.lhs());
2632 matrix<T, F> temp2(proxy.rhs());
2633 matrix<T, F> temp3(temp1.size1(), temp1.size2());
2641 template <
typename T,
typename F,
typename LHS,
typename RHS,
typename OP>
2642 struct op_executor<matrix_base<T, F>, op_assign, matrix_expression<const LHS, const RHS, op_element_unary<OP> > >
2645 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
const matrix_base<T, F>, op_element_unary<OP> >
const & proxy)
2651 template <
typename LHS2,
typename RHS2,
typename OP2>
2652 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<const LHS2, const RHS2, OP2>,
2653 const matrix_expression<const LHS2, const RHS2, OP2>,
2654 op_element_unary<OP> >
const & proxy)
2656 matrix<T, F> temp(proxy.rhs());
2661 template <
typename T,
typename F,
typename LHS,
typename RHS,
typename OP>
2662 struct op_executor<matrix_base<T, F>, op_inplace_add, matrix_expression<const LHS, const RHS, op_element_unary<OP> > >
2665 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
const matrix_base<T, F>, op_element_unary<OP> >
const & proxy)
2667 matrix<T, F> temp(proxy);
2672 template <
typename LHS2,
typename RHS2,
typename OP2>
2673 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<const LHS2, const RHS2, OP2>,
2674 const matrix_expression<const LHS2, const RHS2, OP2>,
2675 op_element_unary<OP> >
const & proxy)
2677 matrix<T, F> temp(proxy.rhs());
2683 template <
typename T,
typename F,
typename LHS,
typename RHS,
typename OP>
2684 struct op_executor<matrix_base<T, F>, op_inplace_sub, matrix_expression<const LHS, const RHS, op_element_unary<OP> > >
2687 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F>,
const matrix_base<T, F>, op_element_unary<OP> >
const & proxy)
2689 matrix<T, F> temp(proxy);
2694 template <
typename LHS2,
typename RHS2,
typename OP2>
2695 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<const LHS2, const RHS2, OP2>,
2696 const matrix_expression<const LHS2, const RHS2, OP2>,
2697 op_element_unary<OP> >
const & proxy)
2699 matrix<T, F> temp(proxy.rhs());
2710 template <
typename T,
typename F,
typename F1,
typename F2>
2711 struct op_executor<matrix_base<T, F>, op_assign, matrix_expression<const matrix_base<T, F1>, const matrix_base<T, F2>, op_mat_mat_prod> >
2713 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F1>,
const matrix_base<T, F2>, op_mat_mat_prod>
const & rhs)
2720 template <
typename T,
typename F,
typename F1,
typename F2>
2721 struct op_executor<matrix_base<T, F>, op_assign, matrix_expression<const matrix_base<T, F1>,
2722 const matrix_expression<const matrix_base<T, F2>, const matrix_base<T, F2>, op_trans>,
2725 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F1>,
2726 const matrix_expression<
const matrix_base<T, F2>,
const matrix_base<T, F2>, op_trans>,
2727 op_mat_mat_prod>
const & rhs)
2734 template <
typename T,
typename F,
typename F1,
typename F2>
2735 struct op_executor<matrix_base<T, F>, op_assign, matrix_expression<const matrix_expression<const matrix_base<T, F1>, const matrix_base<T, F1>, op_trans>,
2736 const matrix_base<T, F2>,
2739 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F1>,
const matrix_base<T, F1>, op_trans>,
2740 const matrix_base<T, F2>,
2741 op_mat_mat_prod>
const & rhs)
2748 template <
typename T,
typename F,
typename F1,
typename F2>
2749 struct op_executor<matrix_base<T, F>, op_assign, matrix_expression<const matrix_expression<const matrix_base<T, F1>, const matrix_base<T, F1>, op_trans>,
2750 const matrix_expression<const matrix_base<T, F2>, const matrix_base<T, F2>, op_trans>,
2753 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F1>,
const matrix_base<T, F1>, op_trans>,
2754 const matrix_expression<
const matrix_base<T, F2>,
const matrix_base<T, F2>, op_trans>,
2755 op_mat_mat_prod>
const & rhs)
2763 template <
typename T,
typename F,
typename F1,
typename F2>
2764 struct op_executor<matrix_base<T, F>, op_inplace_add, matrix_expression<const matrix_base<T, F1>, const matrix_base<T, F2>, op_mat_mat_prod> >
2766 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F1>,
const matrix_base<T, F2>, op_mat_mat_prod>
const & rhs)
2773 template <
typename T,
typename F,
typename F1,
typename F2>
2774 struct op_executor<matrix_base<T, F>, op_inplace_add, matrix_expression<const matrix_base<T, F1>,
2775 const matrix_expression<const matrix_base<T, F2>, const matrix_base<T, F2>, op_trans>,
2778 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F1>,
2779 const matrix_expression<
const matrix_base<T, F2>,
const matrix_base<T, F2>, op_trans>,
2780 op_mat_mat_prod>
const & rhs)
2787 template <
typename T,
typename F,
typename F1,
typename F2>
2788 struct op_executor<matrix_base<T, F>, op_inplace_add, matrix_expression<const matrix_expression<const matrix_base<T, F1>, const matrix_base<T, F1>, op_trans>,
2789 const matrix_base<T, F2>,
2792 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F1>,
const matrix_base<T, F1>, op_trans>,
2793 const matrix_base<T, F2>,
2794 op_mat_mat_prod>
const & rhs)
2801 template <
typename T,
typename F,
typename F1,
typename F2>
2802 struct op_executor<matrix_base<T, F>, op_inplace_add, matrix_expression<const matrix_expression<const matrix_base<T, F1>, const matrix_base<T, F1>, op_trans>,
2803 const matrix_expression<const matrix_base<T, F2>, const matrix_base<T, F2>, op_trans>,
2806 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F1>,
const matrix_base<T, F1>, op_trans>,
2807 const matrix_expression<
const matrix_base<T, F2>,
const matrix_base<T, F2>, op_trans>,
2808 op_mat_mat_prod>
const & rhs)
2816 template <
typename T,
typename F,
typename F1,
typename F2>
2817 struct op_executor<matrix_base<T, F>, op_inplace_sub, matrix_expression<const matrix_base<T, F1>, const matrix_base<T, F2>, op_mat_mat_prod> >
2819 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F1>,
const matrix_base<T, F2>, op_mat_mat_prod>
const & rhs)
2826 template <
typename T,
typename F,
typename F1,
typename F2>
2827 struct op_executor<matrix_base<T, F>, op_inplace_sub, matrix_expression<const matrix_base<T, F1>,
2828 const matrix_expression<const matrix_base<T, F2>, const matrix_base<T, F2>, op_trans>,
2831 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_base<T, F1>,
2832 const matrix_expression<
const matrix_base<T, F2>,
const matrix_base<T, F2>, op_trans>,
2833 op_mat_mat_prod>
const & rhs)
2840 template <
typename T,
typename F,
typename F1,
typename F2>
2841 struct op_executor<matrix_base<T, F>, op_inplace_sub, matrix_expression<const matrix_expression<const matrix_base<T, F1>, const matrix_base<T, F1>, op_trans>,
2842 const matrix_base<T, F2>,
2845 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F1>,
const matrix_base<T, F1>, op_trans>,
2846 const matrix_base<T, F2>,
2847 op_mat_mat_prod>
const & rhs)
2854 template <
typename T,
typename F,
typename F1,
typename F2>
2855 struct op_executor<matrix_base<T, F>, op_inplace_sub, matrix_expression<const matrix_expression<const matrix_base<T, F1>, const matrix_base<T, F1>, op_trans>,
2856 const matrix_expression<const matrix_base<T, F2>, const matrix_base<T, F2>, op_trans>,
2859 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T, F1>,
const matrix_base<T, F1>, op_trans>,
2860 const matrix_expression<
const matrix_base<T, F2>,
const matrix_base<T, F2>, op_trans>,
2861 op_mat_mat_prod>
const & rhs)
2870 template <
typename T,
typename F>
2871 struct op_executor<vector_base<T>, op_assign, vector_expression<const matrix_base<T, F>, const vector_base<T>, op_prod> >
2873 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_base<T, F>,
const vector_base<T>, op_prod>
const & rhs)
2878 vector_base<T> temp(rhs);
2887 template <
typename T,
typename F>
2888 struct op_executor<vector_base<T>, op_assign, vector_expression<const matrix_expression<const matrix_base<T, F>, const matrix_base<T, F>, op_trans>,
2889 const vector_base<T>,
2892 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_expression<
const matrix_base<T, F>,
const matrix_base<T, F>, op_trans>,
2893 const vector_base<T>,
2894 op_prod>
const & rhs)
2899 vector_base<T> temp(rhs);
2909 template <
typename T,
typename F>
2910 struct op_executor<vector_base<T>, op_inplace_add, vector_expression<const matrix_base<T, F>, const vector_base<T>, op_prod> >
2912 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_base<T, F>,
const vector_base<T>, op_prod>
const & rhs)
2914 vector_base<T> temp(rhs);
2920 template <
typename T,
typename F>
2921 struct op_executor<vector_base<T>, op_inplace_add, vector_expression<const matrix_expression<const matrix_base<T, F>, const matrix_base<T, F>, op_trans>,
2922 const vector_base<T>,
2925 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_expression<
const matrix_base<T, F>,
const matrix_base<T, F>, op_trans>,
2926 const vector_base<T>,
2927 op_prod>
const & rhs)
2929 vector_base<T> temp(rhs);
2936 template <
typename T,
typename F>
2937 struct op_executor<vector_base<T>, op_inplace_sub, vector_expression<const matrix_base<T, F>, const vector_base<T>, op_prod> >
2939 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_base<T, F>,
const vector_base<T>, op_prod>
const & rhs)
2941 vector_base<T> temp(rhs);
2947 template <
typename T,
typename F>
2948 struct op_executor<vector_base<T>, op_inplace_sub, vector_expression<const matrix_expression<const matrix_base<T, F>, const matrix_base<T, F>, op_trans>,
2949 const vector_base<T>,
2952 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_expression<
const matrix_base<T, F>,
const matrix_base<T, F>, op_trans>,
2953 const vector_base<T>,
2954 op_prod>
const & rhs)
2956 vector_base<T> temp(rhs);
2966 template <
typename T,
typename F>
2967 struct op_executor<matrix_base<T, F>, op_assign, matrix_expression<const vector_base<T>, const vector_base<T>, op_prod> >
2969 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const vector_base<T>,
const vector_base<T>, op_prod>
const & rhs)
2977 template <
typename T,
typename F,
typename ScalarType>
2978 struct op_executor<matrix_base<T, F>, op_assign, matrix_expression< const matrix_expression<const vector_base<T>, const vector_base<T>, op_prod>,
2982 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const vector_base<T>,
const vector_base<T>, op_prod>,
2984 op_mult>
const & rhs)
2992 template <
typename T,
typename F>
2993 struct op_executor<matrix_base<T, F>, op_inplace_add, matrix_expression<const vector_base<T>, const vector_base<T>, op_prod> >
2995 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const vector_base<T>,
const vector_base<T>, op_prod>
const & rhs)
3002 template <
typename T,
typename F,
typename ScalarType>
3003 struct op_executor<matrix_base<T, F>, op_inplace_add, matrix_expression< const matrix_expression<const vector_base<T>, const vector_base<T>, op_prod>,
3007 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const vector_base<T>,
const vector_base<T>, op_prod>,
3009 op_mult>
const & rhs)
3016 template <
typename T,
typename F>
3017 struct op_executor<matrix_base<T, F>, op_inplace_sub, matrix_expression<const vector_base<T>, const vector_base<T>, op_prod> >
3019 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const vector_base<T>,
const vector_base<T>, op_prod>
const & rhs)
3026 template <
typename T,
typename F,
typename ScalarType>
3027 struct op_executor<matrix_base<T, F>, op_inplace_sub, matrix_expression< const matrix_expression<const vector_base<T>, const vector_base<T>, op_prod>,
3031 static void apply(matrix_base<T, F> & lhs, matrix_expression<
const matrix_expression<
const vector_base<T>,
const vector_base<T>, op_prod>,
3033 op_mult>
const & rhs)
Simple enable-if variant that uses the SFINAE pattern.
Definition: enable_if.hpp:29
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.
Definition: matrix.hpp:1419
const_reference operator()(size_type, size_type) const
Definition: matrix.hpp:135
size_type size1_
Definition: matrix.hpp:66
matrix_iterator< row_iteration, self_type > iterator1
Definition: matrix.hpp:241
void ambm_m(matrix_base< NumericT, F > &mat1, matrix_base< NumericT, F > const &mat2, ScalarType1 const &alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha, matrix_base< NumericT, F > const &mat3, ScalarType2 const &beta, vcl_size_t len_beta, bool reciprocal_beta, bool flip_sign_beta)
Definition: matrix_operations.hpp:118
A tag class representing multiplication by a scalar.
Definition: forwards.h:74
size_type size1() const
Definition: matrix.hpp:53
size_type size1() const
Returns the number of rows.
Definition: matrix.hpp:625
std::size_t vcl_size_t
Definition: forwards.h:58
Definition: forwards.h:498
vcl_size_t index1()
Definition: matrix.hpp:217
self_type & operator=(const self_type &other)
Definition: matrix.hpp:361
This class represents a single scalar value on the GPU and behaves mostly like a built-in scalar type...
Definition: forwards.h:172
void clear()
Resets all entries to zero.
Definition: matrix.hpp:640
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.
Definition: sparse_matrix_operations.hpp:330
ram_handle_type & ram_handle()
Returns the handle to a buffer in CPU RAM. NULL is returned if no such buffer has been allocated...
Definition: mem_handle.hpp:72
vcl_size_t index2()
Definition: matrix.hpp:218
Worker class for decomposing expression templates.
Definition: op_executor.hpp:79
A proxy class for a single element of a vector or matrix. This proxy should not be noticed by end-use...
Definition: entry_proxy.hpp:178
Implementations of dense matrix related operations including matrix-vector products.
matrix_expression< const self_type, const SCALARTYPE, op_mult > operator-() const
Sign flip for the matrix. Emulated to be equivalent to -1.0 * matrix.
Definition: matrix.hpp:619
bool diag() const
Definition: matrix.hpp:58
const_reference operator()(size_type i, size_type j) const
Definition: matrix.hpp:87
bool diag_
Definition: matrix.hpp:69
Helper struct for checking whether a type represents a sign flip on a viennacl::scalar<> ...
Definition: forwards.h:377
const_reference operator()(size_type i, size_type j) const
Definition: matrix.hpp:60
vcl_size_t size_type
Definition: matrix.hpp:128
void matrix_diag_to_vector(const matrix_base< NumericT, F > &A, int k, vector_base< NumericT > &v)
Dispatcher interface for v = diag(A, k)
Definition: matrix_operations.hpp:231
A tag class representing the extraction of a matrix column to a vector.
Definition: forwards.h:147
implicit_matrix_base(size_type size1, size_type size2, std::pair< SCALARTYPE, bool > value, bool diag)
Definition: matrix.hpp:48
void set_handle(viennacl::backend::mem_handle const &h)
Definition: matrix.hpp:666
vcl_size_t size1(MatrixType const &mat)
Generic routine for obtaining the number of rows of a matrix (ViennaCL, uBLAS, etc.)
Definition: size.hpp:216
void am(matrix_base< NumericT, F > &mat1, matrix_base< NumericT, F > const &mat2, ScalarType1 const &alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha)
Definition: matrix_operations.hpp:55
const_reference operator()(size_type, size_type) const
Definition: matrix.hpp:111
A tag class representing a matrix given by a vector placed on a certain (off-)diagonal.
Definition: forwards.h:141
void ambm(matrix_base< NumericT, F > &mat1, matrix_base< NumericT, F > const &mat2, ScalarType1 const &alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha, matrix_base< NumericT, F > const &mat3, ScalarType2 const &beta, vcl_size_t len_beta, bool reciprocal_beta, bool flip_sign_beta)
Definition: matrix_operations.hpp:83
std::pair< SCALARTYPE, bool > value_
Definition: matrix.hpp:68
A tag class representing subtraction.
Definition: forwards.h:72
size_type internal_size1() const
Returns the internal number of rows. Usually required for launching OpenCL kernels only...
Definition: matrix.hpp:647
vcl_size_t size_type
Definition: matrix.hpp:104
A dense matrix class.
Definition: forwards.h:290
A tag indicating iteration along increasing row index of a matrix.
Definition: matrix.hpp:192
Expression template class for representing a tree of expressions which ultimately result in a matrix...
Definition: forwards.h:283
viennacl::context context() const
Definition: matrix.hpp:89
SCALARTYPE const & const_reference
Definition: matrix.hpp:50
size_type stride2() const
Returns the number of columns.
Definition: matrix.hpp:637
This file provides the forward declarations for the main types used within ViennaCL.
SCALARTYPE const & const_reference
Definition: matrix.hpp:81
A dense matrix class.
Definition: forwards.h:293
A tag class representing division.
Definition: forwards.h:80
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.
Definition: memory.hpp:261
void matrix_row(const matrix_base< NumericT, F > &A, unsigned int i, vector_base< NumericT > &v)
Definition: matrix_operations.hpp:256
bool is_value_static() const
Definition: matrix.hpp:57
Represents a vector consisting of 1 at a given index and zeros otherwise. To be used as an initialize...
Definition: forwards.h:299
matrix(identity_matrix< SCALARTYPE > const &m)
Creates the matrix from the supplied identity matrix.
Definition: matrix.hpp:777
size_type size2() const
Definition: matrix.hpp:54
An expression template class that represents a binary operation that yields a vector.
Definition: forwards.h:181
void matrix_assign(matrix_base< NumericT, F > &mat, NumericT s, bool clear=false)
Definition: matrix_operations.hpp:152
viennacl::enable_if< viennacl::is_scalar< S1 >::value, matrix_base< NumericT, F > & >::type operator/=(matrix_base< NumericT, F > &m1, S1 const &gpu_val)
Scales a matrix by a GPU scalar value.
Definition: matrix.hpp:1445
result_of::size_type< MatrixType >::type size2(MatrixType const &mat)
Generic routine for obtaining the number of columns of a matrix (ViennaCL, uBLAS, etc...
Definition: size.hpp:245
size_type size2() const
Returns the number of columns.
Definition: matrix.hpp:627
entry_proxy< SCALARTYPE > operator()(size_type row_index, size_type col_index)
Read-write access to a single element of the matrix/matrix_range/matrix_slice.
Definition: matrix.hpp:566
vcl_size_t size_type
Definition: matrix.hpp:80
Definition: forwards.h:481
matrix_expression(LHS &lhs, RHS &rhs)
Definition: matrix.hpp:170
matrix(matrix_expression< LHS, RHS, OP > const &proxy)
Definition: matrix.hpp:774
memory_types
Definition: forwards.h:476
value_type operator*(void)
Definition: matrix.hpp:210
bool operator==(self_type const &other)
Definition: matrix.hpp:214
matrix_base(SCALARTYPE *ptr_to_mem, viennacl::memory_types mem_type, size_type mat_size1, size_type mat_start1, difference_type mat_stride1, size_type mat_internal_size1, size_type mat_size2, size_type mat_start2, difference_type mat_stride2, size_type mat_internal_size2)
Definition: matrix.hpp:302
self_type & operator=(const matrix_expression< const self_type, const self_type, op_trans > &proxy)
Definition: matrix.hpp:418
MATRIXTYPE::value_type value_type
Definition: matrix.hpp:204
vcl_size_t size_type
Definition: matrix.hpp:47
void resize(size_type rows, size_type columns, bool preserve=true)
Resizes the matrix. Existing entries can be preserved, but.
Definition: matrix.hpp:684
A tag class representing the (off-)diagonal of a matrix.
Definition: forwards.h:138
Represents a generic 'context' similar to an OpenCL context, but is backend-agnostic and thus also su...
Definition: context.hpp:39
memory_types get_active_handle_id() const
Returns an ID for the currently active memory buffer. Other memory buffers might contain old or no da...
Definition: mem_handle.hpp:91
SCALARTYPE value() const
Definition: matrix.hpp:56
matrix(size_type rows, size_type columns, viennacl::context ctx=viennacl::context())
Creates the matrix with the given dimensions.
Definition: matrix.hpp:767
SCALARTYPE cpu_value_type
Definition: matrix.hpp:51
viennacl::enable_if< viennacl::is_any_scalar< S1 >::value, matrix_expression< const matrix_base< NumericT, F >, const S1, op_mult > >::type operator*(S1 const &value, matrix_base< NumericT, F > const &m1)
Operator overload for the expression alpha * m1, where alpha is a host scalar (float or double) and m...
Definition: matrix.hpp:1345
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.)
Definition: size.hpp:144
Definition: forwards.h:480
size_type stride1() const
Returns the number of rows.
Definition: matrix.hpp:635
void scaled_rank_1_update(matrix_base< NumericT, F > &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...
Definition: matrix_operations.hpp:748
size_type size2_
Definition: matrix.hpp:67
matrix(const self_type &other)
Definition: matrix.hpp:804
size_type internal_size() const
Returns the total amount of allocated memory in multiples of sizeof(SCALARTYPE)
Definition: matrix.hpp:651
size_type start1() const
Returns the number of rows.
Definition: matrix.hpp:630
vcl_size_t size_type
Definition: matrix.hpp:168
matrix(const base_type &other)
Definition: matrix.hpp:797
size_type start2() const
Returns the number of columns.
Definition: matrix.hpp:632
bool operator!=(self_type const &other)
Definition: matrix.hpp:215
SCALARTYPE cpu_value_type
Definition: matrix.hpp:244
F::orientation_category orientation_category
Definition: matrix.hpp:249
self_type & operator++(void)
Definition: matrix.hpp:211
Implementations of operations using sparse matrices.
scalar< SCALARTYPE > value_type
Definition: matrix.hpp:243
static const size_type alignment
Definition: matrix.hpp:251
DistanceType difference_type
Definition: matrix.hpp:246
matrix_iterator(MATRIXTYPE &mat, vcl_size_t start_row, vcl_size_t start_col)
Definition: matrix.hpp:206
A tag class representing addition.
Definition: forwards.h:70
SCALARTYPE const & const_reference
Definition: matrix.hpp:105
F orientation_functor
Definition: matrix.hpp:248
void copy(std::vector< SCALARTYPE > &cpu_vec, circulant_matrix< SCALARTYPE, ALIGNMENT > &gpu_mat)
Copies a circulant matrix from the std::vector to the OpenCL device (either GPU or multi-core CPU) ...
Definition: circulant_matrix.hpp:150
Represents a vector consisting of scalars 's' only, i.e. v[i] = s for all i. To be used as an initial...
Definition: forwards.h:305
Common base class for dense vectors, vector ranges, and vector slices.
Definition: forwards.h:205
matrix(zero_matrix< SCALARTYPE > const &m)
Creates the matrix from the supplied zero matrix.
Definition: matrix.hpp:784
vcl_size_t size1() const
Returns the size of the result vector.
Definition: matrix.hpp:180
SizeType size_type
Definition: matrix.hpp:245
vcl_size_t size2() const
Definition: matrix.hpp:181
void element_op(matrix_base< T, F > &A, matrix_expression< const matrix_base< T, F >, const matrix_base< T, F >, OP > const &proxy)
Implementation of the element-wise operation A = B .* C and A = B ./ C for matrices (using MATLAB syn...
Definition: matrix_operations.hpp:598
viennacl::memory_types active_handle_id(T const &obj)
Returns an ID for the currently active memory domain of an object.
Definition: handle.hpp:201
Represents a vector consisting of zeros only. To be used as an initializer for viennacl::vector, vector_range, or vector_slize only.
Definition: forwards.h:302
matrix_base()
The default constructor. Does not allocate any memory.
Definition: matrix.hpp:255
self_type & operator+=(const matrix_expression< const LHS, const RHS, OP > &proxy)
Definition: matrix.hpp:457
matrix_base(size_type rows, size_type columns, viennacl::context ctx=viennacl::context())
Creates the matrix with the given dimensions.
Definition: matrix.hpp:263
viennacl::backend::mem_handle handle_type
Definition: matrix.hpp:247
size_type size2() const
Definition: matrix.hpp:134
size_type size2() const
Definition: matrix.hpp:86
viennacl::vector< NumericT > operator-(const vector_base< NumericT > &v1, const vector_expression< const matrix_base< NumericT, F >, const vector_base< NumericT >, op_prod > &proxy)
Implementation of the operation 'result = v1 - A * v2', where A is a matrix.
Definition: matrix_operations.hpp:858
vector_expression< const matrix_base< NumericT, F >, const unsigned int, op_row > row(const matrix_base< NumericT, F > &A, unsigned int i)
Definition: matrix.hpp:910
viennacl::memory_types memory_domain() const
Definition: matrix.hpp:659
const_entry_proxy< SCALARTYPE > operator()(size_type row_index, size_type col_index) const
Read access to a single element of the matrix/matrix_range/matrix_slice.
Definition: matrix.hpp:573
vector_expression< const matrix_base< NumericT, F >, const int, op_matrix_diag > diag(const matrix_base< NumericT, F > &A, int k=0)
Definition: matrix.hpp:895
A tag class representing matrix-vector products and element-wise multiplications. ...
Definition: forwards.h:76
vcl_size_t raw_size() const
Returns the number of bytes of the currently active buffer.
Definition: mem_handle.hpp:203
viennacl::context context(T const &t)
Returns an ID for the currently active memory domain of an object.
Definition: context.hpp:41
void matrix_column(const matrix_base< NumericT, F > &A, unsigned int j, vector_base< NumericT > &v)
Definition: matrix_operations.hpp:281
RHS & rhs() const
Get right hand side operand.
Definition: matrix.hpp:177
uBLAS-like iterator class for iterating over the entries of a dense matrix.
Definition: matrix.hpp:200
The vector type with operator-overloads and proxy classes is defined here. Linear algebra operations ...
zero_matrix(size_type s1, size_type s2, viennacl::context ctx=viennacl::context())
Definition: matrix.hpp:107
self_type & operator*=(SCALARTYPE val)
Scales a matrix by a CPU scalar value.
Definition: matrix.hpp:599
viennacl::enable_if< viennacl::is_scalar< S1 >::value, matrix_base< NumericT, F > & >::type operator*=(matrix_base< NumericT, F > &m1, S1 const &gpu_val)
Scales a matrix by a GPU scalar value.
Definition: matrix.hpp:1399
Definition: forwards.h:479
void matrix_diag_from_vector(const vector_base< NumericT > &v, int k, matrix_base< NumericT, F > &A)
Dispatcher interface for A = diag(v, k)
Definition: matrix_operations.hpp:205
self_type & operator/=(SCALARTYPE val)
Scales this matrix by a CPU scalar value.
Definition: matrix.hpp:609
matrix_base(matrix_expression< const LHS, const RHS, OP > const &proxy)
Definition: matrix.hpp:287
handle_type & handle()
Returns the OpenCL handle, non-const-version.
Definition: matrix.hpp:654
Main abstraction class for multiple memory domains. Represents a buffer in either main RAM...
Definition: mem_handle.hpp:62
size_type size1() const
Definition: matrix.hpp:109
A tag class representing transposed matrices.
Definition: forwards.h:165
Helper implementations that deduce the dimensions of the supplied matrix-valued expressions.
void resize(size_type rows, size_type columns, bool preserve=true)
Resizes the matrix. Existing entries can optionally be preserved.
Definition: matrix.hpp:827
viennacl::context context() const
Definition: matrix.hpp:113
identity_matrix(size_type s, viennacl::context ctx=viennacl::context())
Definition: matrix.hpp:83
matrix_base(viennacl::backend::mem_handle &h, size_type mat_size1, size_type mat_start1, difference_type mat_stride1, size_type mat_internal_size1, size_type mat_size2, size_type mat_start2, difference_type mat_stride2, size_type mat_internal_size2)
Constructor for creating a matrix_range or matrix_stride from some other matrix/matrix_range/matrix_s...
Definition: matrix.hpp:277
void prod_impl(const matrix_base< NumericT, F > &mat, const vector_base< NumericT > &vec, vector_base< NumericT > &result)
Carries out matrix-vector multiplication.
Definition: matrix_operations.hpp:350
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...
Definition: memory.hpp:87
MATRIXTYPE & operator()(void) const
Definition: matrix.hpp:220
self_type & operator=(const matrix_expression< const LHS, const RHS, OP > &proxy)
Creates the matrix from the supplied random matrix.
Definition: matrix.hpp:393
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...
Definition: mem_handle.hpp:94
vector_expression< const matrix_base< NumericT, F >, const unsigned int, op_column > column(const matrix_base< NumericT, F > &A, unsigned int j)
Definition: matrix.hpp:918
Extracts the underlying OpenCL handle from a vector, a matrix, an expression etc. ...
LHS & lhs() const
Get left hand side operand.
Definition: matrix.hpp:174
A tag class representing the extraction of a matrix row to a vector.
Definition: forwards.h:144
viennacl::context context() const
Definition: matrix.hpp:137
const handle_type & handle() const
Returns the OpenCL handle, const-version.
Definition: matrix.hpp:656
self_type & operator-=(const matrix_expression< const LHS, const RHS, OP > &proxy)
Definition: matrix.hpp:471
A proxy class for a single element of a vector or matrix. This proxy should not be noticed by end-use...
Definition: forwards.h:178
SCALARTYPE const & const_reference
Definition: matrix.hpp:129
scalar_matrix(size_type s1, size_type s2, const_reference val, viennacl::context ctx=viennacl::context())
Definition: matrix.hpp:131
matrix()
The default constructor. Does not allocate any memory.
Definition: matrix.hpp:759
void switch_memory_context(viennacl::context new_ctx)
Definition: matrix.hpp:671
bool op_aliasing(vector_base< T > const &, B const &)
Definition: op_executor.hpp:35
Implementation of the ViennaCL scalar class.
size_type size1() const
Definition: matrix.hpp:133
self_type operator++(int)
Definition: matrix.hpp:212
void fast_copy(const const_vector_iterator< SCALARTYPE, ALIGNMENT > &gpu_begin, const const_vector_iterator< SCALARTYPE, ALIGNMENT > &gpu_end, CPU_ITERATOR cpu_begin)
STL-like transfer of a GPU vector to the CPU. The cpu type is assumed to reside in a linear piece of ...
Definition: vector.hpp:1284
viennacl::vector< NumericT > operator+(const vector_base< NumericT > &v1, const vector_expression< const matrix_base< NumericT, F >, const vector_base< NumericT >, op_prod > &proxy)
Implementation of the operation 'result = v1 + A * v2', where A is a matrix.
Definition: matrix_operations.hpp:840
A collection of compile time type deductions.
void matrix_diagonal_assign(matrix_base< NumericT, F > &mat, NumericT s)
Definition: matrix_operations.hpp:178
matrix(scalar_matrix< SCALARTYPE > const &m)
Creates the matrix from the supplied scalar matrix.
Definition: matrix.hpp:791
size_type internal_size2() const
Returns the internal number of columns. Usually required for launching OpenCL kernels only...
Definition: matrix.hpp:649
A tag indicating iteration along increasing columns index of a matrix.
Definition: matrix.hpp:195
Simple enable-if variant that uses the SFINAE pattern.
base_type::size_type size_type
Definition: matrix.hpp:756
size_type size2() const
Definition: matrix.hpp:110
size_type size1() const
Definition: matrix.hpp:85
matrix_iterator< col_iteration, self_type > iterator2
Definition: matrix.hpp:242