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) {}
104 self_type
operator++(
int) { self_type tmp = *
this; ++(*this);
return tmp; }
106 bool operator==(self_type
const & other) {
return (row_ == other.row_) && (col_ == other.col_); }
107 bool operator!=(self_type
const & other) {
return !(*
this == other); }
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),
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());
226 template<
class NumericT,
typename SizeT,
typename DistanceT>
228 size1_(other.
size1()), size2_(other.
size2()), start1_(0), start2_(0), stride1_(1), stride2_(1),
231 row_major_fixed_(true), row_major_(other.
row_major())
242 template<
class NumericT,
typename SizeT,
typename DistanceT>
252 if (!row_major_fixed_)
266 template<
class NumericT,
typename SizeT,
typename DistanceT>
267 template<
typename LHS,
typename RHS,
typename OP>
272 &&
bool(
"Incompatible matrix sizes!"));
277 internal_size1_ = viennacl::tools::align_to_multiple<size_type>(size1_, dense_padding_size);
278 internal_size2_ = viennacl::tools::align_to_multiple<size_type>(size2_, dense_padding_size);
279 if (!row_major_fixed_)
282 if (size1_ != internal_size1_ || size2_ != internal_size2_)
294 template<
class NumericT,
typename SizeT,
typename DistanceT>
301 internal_size1_ = viennacl::tools::align_to_multiple<size_type>(size1_, dense_padding_size);
302 internal_size2_ = viennacl::tools::align_to_multiple<size_type>(size2_, dense_padding_size);
303 if (!row_major_fixed_)
307 if (
handle() == proxy.lhs().handle() )
311 if ( proxy.lhs().size1() != proxy.lhs().size2() )
312 this->
resize(proxy.lhs().size2(), proxy.lhs().size1());
313 elements_ = temp.handle();
317 if ( proxy.lhs().size1() != proxy.lhs().size2() )
318 this->
resize(proxy.lhs().size2(), proxy.lhs().size1());
324 template<
class NumericT,
typename SizeT,
typename DistanceT>
325 template<
typename LHS,
typename RHS,
typename OP>
330 &&
bool(
"Incompatible matrix sizes!"));
331 assert( (
size1() > 0) &&
bool(
"Vector not yet initialized!") );
332 assert( (
size2() > 0) &&
bool(
"Vector not yet initialized!") );
339 template<
class NumericT,
typename SizeT,
typename DistanceT>
340 template<
typename LHS,
typename RHS,
typename OP>
345 &&
bool(
"Incompatible matrix sizes!"));
346 assert( (
size1() > 0) &&
bool(
"Vector not yet initialized!") );
347 assert( (
size2() > 0) &&
bool(
"Vector not yet initialized!") );
355 template<
class NumericT,
typename SizeT,
typename DistanceT>
358 assert( (m.
size1() == size1_ || size1_ == 0) &&
bool(
"Size mismatch!") );
359 assert( (m.
size2() == size2_ || size2_ == 0) &&
bool(
"Size mismatch!") );
365 internal_size1_ = viennacl::tools::align_to_multiple<size_type>(size1_, dense_padding_size);
366 internal_size2_ = viennacl::tools::align_to_multiple<size_type>(size2_, dense_padding_size);
383 template<
class NumericT,
typename SizeT,
typename DistanceT>
386 assert( (m.
size1() == size1_ || size1_ == 0) &&
bool(
"Size mismatch!") );
387 assert( (m.
size2() == size2_ || size2_ == 0) &&
bool(
"Size mismatch!") );
393 internal_size1_ = viennacl::tools::align_to_multiple<size_type>(size1_, dense_padding_size);
394 internal_size2_ = viennacl::tools::align_to_multiple<size_type>(size2_, dense_padding_size);
408 template<
class NumericT,
typename SizeT,
typename DistanceT>
411 assert( (m.
size1() == size1_ || size1_ == 0) &&
bool(
"Size mismatch!") );
412 assert( (m.
size2() == size2_ || size2_ == 0) &&
bool(
"Size mismatch!") );
418 internal_size1_ = viennacl::tools::align_to_multiple<size_type>(size1_, dense_padding_size);
419 internal_size2_ = viennacl::tools::align_to_multiple<size_type>(size2_, dense_padding_size);
439 template<
class NumericT,
typename SizeT,
typename DistanceT>
449 template<
class NumericT,
typename SizeT,
typename DistanceT>
460 template<
class NumericT,
typename SizeT,
typename DistanceT>
464 *
this, NumericT(1.0), 1,
false,
false,
465 other, NumericT(1.0), 1,
false,
false);
469 template<
class NumericT,
typename SizeT,
typename DistanceT>
473 *
this, NumericT(1.0), 1,
false,
false,
474 other, NumericT(1.0), 1,
false,
true);
479 template<
class NumericT,
typename SizeT,
typename DistanceT>
483 *
this, NumericT(val), 1,
false,
false);
488 template<
class NumericT,
typename SizeT,
typename DistanceT>
492 *
this, NumericT(val), 1,
false,
false);
497 template<
class NumericT,
typename SizeT,
typename DistanceT>
501 *
this, NumericT(val), 1,
false,
false);
506 template<
class NumericT,
typename SizeT,
typename DistanceT>
510 *
this, NumericT(val), 1,
false,
false);
515 template<
class NumericT,
typename SizeT,
typename DistanceT>
519 *
this, NumericT(val), 1,
false,
false);
524 template<
class NumericT,
typename SizeT,
typename DistanceT>
528 *
this, NumericT(val), 1,
false,
false);
535 template<
class NumericT,
typename SizeT,
typename DistanceT>
539 *
this, NumericT(val), 1,
true,
false);
544 template<
class NumericT,
typename SizeT,
typename DistanceT>
548 *
this, NumericT(val), 1,
true,
false);
553 template<
class NumericT,
typename SizeT,
typename DistanceT>
557 *
this, NumericT(val), 1,
true,
false);
562 template<
class NumericT,
typename SizeT,
typename DistanceT>
566 *
this, NumericT(val), 1,
true,
false);
571 template<
class NumericT,
typename SizeT,
typename DistanceT>
575 *
this, NumericT(val), 1,
true,
false);
580 template<
class NumericT,
typename SizeT,
typename DistanceT>
584 *
this, NumericT(val), 1,
true,
false);
590 template<
class NumericT,
typename SizeT,
typename DistanceT>
596 template<
class NumericT,
typename SizeT,
typename DistanceT>
600 template<
class NumericT,
typename SizeT,
typename DistanceT>
603 assert( (rows > 0 && columns > 0) &&
bool(
"Check failed in matrix::resize(): Number of rows and columns must be positive!"));
612 std::vector< NumericT > new_entries( viennacl::tools::align_to_multiple<vcl_size_t>(rows, dense_padding_size)
613 * viennacl::tools::align_to_multiple<vcl_size_t>(columns, dense_padding_size));
624 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))]
627 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))]
635 internal_size1_ = viennacl::tools::align_to_multiple<size_type>(size1_, dense_padding_size);
636 internal_size2_ = viennacl::tools::align_to_multiple<size_type>(size2_, dense_padding_size);
643 internal_size1_ = viennacl::tools::align_to_multiple<size_type>(size1_, dense_padding_size);
644 internal_size2_ = viennacl::tools::align_to_multiple<size_type>(size2_, dense_padding_size);
658 template<
class NumericT,
typename F,
unsigned int AlignmentV>
667 explicit matrix() : base_type(static_cast<bool>(
viennacl::is_row_major<F>::value)) {}
685 : base_type(ptr_to_mem, mem_type,
688 viennacl::is_row_major<F>::value) {}
701 size_type rows, size_type internal_row_count,
702 size_type cols, size_type internal_col_count)
703 : base_type(ptr_to_mem, mem_type,
704 rows, 0, 1, internal_row_count,
705 cols, 0, 1, internal_col_count,
706 true,
viennacl::is_row_major<F>::value) {}
708 #ifdef VIENNACL_WITH_OPENCL
709 explicit matrix(cl_mem mem, size_type rows, size_type columns) : base_type(mem, rows, columns,
viennacl::is_row_major<F>::value) {}
712 template<
typename LHS,
typename RHS,
typename OP>
757 using base_type::operator=;
766 void resize(size_type rows, size_type columns,
bool preserve =
true)
780 template<
class NumericT>
781 std::ostream & operator<<(std::ostream & s, const matrix_base<NumericT> & gpu_matrix)
785 std::vector<NumericT> tmp(gpu_matrix.internal_size());
788 s <<
"[" << gpu_matrix.size1() <<
"," << gpu_matrix.size2() <<
"]";
791 for (size_type i = 0; i < gpu_matrix.size1(); ++i)
794 for (size_type j = 0; j < gpu_matrix.size2(); ++j)
796 if (gpu_matrix.row_major())
797 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())];
799 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())];
801 if (j < gpu_matrix.size2() - 1)
805 if (i < gpu_matrix.size1() - 1)
817 template<
typename LHS,
typename RHS,
typename OP>
818 std::ostream & operator<<(std::ostream & s, const matrix_expression<LHS, RHS, OP> & expr)
828 template<
typename NumericT>
829 matrix_expression< const matrix_base<NumericT>,
const matrix_base<NumericT>, op_trans>
830 trans(
const matrix_base<NumericT> & mat)
836 template<
typename NumericT>
837 vector_expression< const matrix_base<NumericT>,
const int, op_matrix_diag>
838 diag(
const matrix_base<NumericT> & A,
int k = 0)
843 template<
typename NumericT>
844 matrix_expression< const vector_base<NumericT>,
const int, op_vector_diag>
851 template<
typename NumericT,
typename F>
852 vector_expression< const matrix_base<NumericT, F>,
const unsigned int, op_row>
859 template<
typename NumericT,
typename F>
860 vector_expression< const matrix_base<NumericT, F>,
const unsigned int, op_column>
876 template<
typename CPUMatrixT,
typename NumericT,
typename F,
unsigned int AlignmentV>
877 void copy(
const CPUMatrixT & cpu_matrix,
884 if (gpu_matrix.
size1() == 0 || gpu_matrix.
size2() == 0)
886 gpu_matrix.
resize(cpu_matrix.size1(),
887 cpu_matrix.size2(),
false);
890 assert( (gpu_matrix.
size1() == cpu_matrix.size1()) && (gpu_matrix.
size2() == cpu_matrix.size2()) &&
bool(
"Matrix dimensions mismatch.") );
893 for (size_type i = 0; i < gpu_matrix.
size1(); ++i)
895 for (size_type j = 0; j < gpu_matrix.
size2(); ++j)
912 template<
typename NumericT,
typename A1,
typename A2,
typename F,
unsigned int AlignmentV>
913 void copy(
const std::vector< std::vector<NumericT, A1>, A2> & cpu_matrix,
918 if (gpu_matrix.
size1() == 0 || gpu_matrix.
size2() == 0)
920 gpu_matrix.
resize(cpu_matrix.size(),
921 cpu_matrix[0].size(),
925 assert( (gpu_matrix.
size1() == cpu_matrix.size()) &&
bool(
"Matrix dimensions mismatch.") );
928 for (size_type i = 0; i < gpu_matrix.
size1(); ++i)
930 assert( (gpu_matrix.
size2() == cpu_matrix[i].size()) &&
bool(
"Matrix dimensions mismatch.") );
932 for (size_type j = 0; j < gpu_matrix.
size2(); ++j)
952 template<
typename NumericT,
typename F,
unsigned int AlignmentV>
954 NumericT * cpu_matrix_end,
961 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!"));
967 #ifdef VIENNACL_WITH_EIGEN
973 template<
typename F,
unsigned int AlignmentV>
974 void copy(
const Eigen::MatrixXf & cpu_matrix,
975 matrix<float, F, AlignmentV> & gpu_matrix)
977 typedef typename matrix<float, F, AlignmentV>::size_type size_type;
979 if (gpu_matrix.size1() == 0 || gpu_matrix.size2() == 0)
981 gpu_matrix.resize(cpu_matrix.rows(),
987 assert( (gpu_matrix.size1() ==
static_cast<vcl_size_t>(cpu_matrix.rows()))
988 && (gpu_matrix.size2() ==
static_cast<vcl_size_t>(cpu_matrix.cols()))
989 && bool(
"matrix size mismatch")
993 std::vector<float> data(gpu_matrix.internal_size());
994 for (size_type i = 0; i < gpu_matrix.size1(); ++i)
996 for (size_type j = 0; j < gpu_matrix.size2(); ++j)
997 data[F::mem_index(i, j, gpu_matrix.internal_size1(), gpu_matrix.internal_size2())] = cpu_matrix(i,j);
1009 template<
typename F,
unsigned int AlignmentV>
1010 void copy(
const Eigen::MatrixXd & cpu_matrix,
1011 matrix<double, F, AlignmentV> & gpu_matrix)
1013 typedef typename matrix<double, F, AlignmentV>::size_type size_type;
1015 if (gpu_matrix.size1() == 0 || gpu_matrix.size2() == 0)
1017 gpu_matrix.resize(cpu_matrix.rows(),
1023 assert( (gpu_matrix.size1() ==
static_cast<vcl_size_t>(cpu_matrix.rows()))
1024 && (gpu_matrix.size2() ==
static_cast<vcl_size_t>(cpu_matrix.cols()))
1025 && bool(
"matrix size mismatch")
1029 std::vector<double> data(gpu_matrix.internal_size());
1030 for (size_type i = 0; i < gpu_matrix.size1(); ++i)
1032 for (size_type j = 0; j < gpu_matrix.size2(); ++j)
1033 data[F::mem_index(i, j, gpu_matrix.internal_size1(), gpu_matrix.internal_size2())] = cpu_matrix(i,j);
1041 #ifdef VIENNACL_WITH_MTL4
1047 template<
typename NumericT,
typename T,
typename F,
unsigned int AlignmentV>
1048 void copy(
const mtl::dense2D<NumericT, T>& cpu_matrix,
1049 matrix<NumericT, F, AlignmentV> & gpu_matrix)
1051 typedef typename matrix<NumericT, F, AlignmentV>::size_type size_type;
1053 if (gpu_matrix.size1() == 0 || gpu_matrix.size2() == 0)
1055 gpu_matrix.resize(cpu_matrix.num_rows(),
1056 cpu_matrix.num_cols(),
1061 assert( (gpu_matrix.size1() == cpu_matrix.num_rows())
1062 && (gpu_matrix.size2() == cpu_matrix.num_cols())
1063 &&
bool(
"matrix size mismatch")
1067 std::vector<NumericT> data(gpu_matrix.internal_size());
1068 for (size_type i = 0; i < gpu_matrix.size1(); ++i)
1070 for (size_type j = 0; j < gpu_matrix.size2(); ++j)
1071 data[F::mem_index(i, j, gpu_matrix.internal_size1(), gpu_matrix.internal_size2())] = cpu_matrix[i][j];
1090 template<
typename CPUMatrixT,
typename NumericT,
typename F,
unsigned int AlignmentV>
1092 CPUMatrixT & cpu_matrix )
1096 if ( (gpu_matrix.
size1() > 0) && (gpu_matrix.
size2() > 0) )
1100 std::vector<NumericT> temp_buffer(gpu_matrix.
internal_size());
1104 for (size_type i = 0; i < gpu_matrix.
size1(); ++i)
1107 for (size_type j = 0; j < gpu_matrix.
size2(); ++j)
1119 template<
typename NumericT,
typename A1,
typename A2,
typename F,
unsigned int AlignmentV>
1121 std::vector< std::vector<NumericT, A1>, A2> & cpu_matrix)
1125 if ( (gpu_matrix.
size1() > 0) && (gpu_matrix.
size2() > 0) )
1127 assert( (cpu_matrix.size() == gpu_matrix.
size1()) &&
bool(
"Matrix dimensions mismatch: rows"));
1129 std::vector<NumericT> temp_buffer(gpu_matrix.
internal_size());
1133 for (size_type i = 0; i < gpu_matrix.
size1(); ++i)
1135 assert( (cpu_matrix[i].
size() == gpu_matrix.
size2()) &&
bool(
"Matrix dimensions mismatch: columns"));
1137 for (size_type j = 0; j < gpu_matrix.
size2(); ++j)
1151 template<
typename NumericT,
typename F,
unsigned int AlignmentV>
1153 NumericT * cpu_matrix_begin)
1165 template<
typename LHS1,
typename RHS1,
typename OP1,
1166 typename LHS2,
typename RHS2,
typename OP2>
1167 matrix_expression< const matrix_expression<const LHS1, const RHS1, OP1>,
1168 const matrix_expression<const LHS2, const RHS2, OP2>,
1171 matrix_expression<const LHS2, const RHS2, OP2>
const & proxy2)
1175 &&
bool(
"Incompatible matrix sizes!"));
1176 return matrix_expression< const matrix_expression<const LHS1, const RHS1, OP1>,
1177 const matrix_expression<const LHS2, const RHS2, OP2>,
1181 template<
typename LHS1,
typename RHS1,
typename OP1,
1183 matrix_expression< const matrix_expression<const LHS1, const RHS1, OP1>,
1184 const matrix_base<NumericT>,
1187 matrix_base<NumericT>
const & proxy2)
1191 &&
bool(
"Incompatible matrix sizes!"));
1192 return matrix_expression< const matrix_expression<const LHS1, const RHS1, OP1>,
1193 const matrix_base<NumericT>,
1197 template<
typename NumericT,
1198 typename LHS2,
typename RHS2,
typename OP2>
1199 matrix_expression< const matrix_base<NumericT>,
1200 const matrix_expression<const LHS2, const RHS2, OP2>,
1203 matrix_expression<const LHS2, const RHS2, OP2>
const & proxy2)
1207 &&
bool(
"Incompatible matrix sizes!"));
1208 return matrix_expression< const matrix_base<NumericT>,
1209 const matrix_expression<const LHS2, const RHS2, OP2>,
1214 template<
typename NumericT>
1215 matrix_expression< const matrix_base<NumericT>,
const matrix_base<NumericT>, op_add >
1216 operator + (
const matrix_base<NumericT> &
m1,
const matrix_base<NumericT> & m2)
1218 return matrix_expression< const matrix_base<NumericT>,
1219 const matrix_base<NumericT>,
1225 template<
typename LHS1,
typename RHS1,
typename OP1,
1226 typename LHS2,
typename RHS2,
typename OP2>
1227 matrix_expression< const matrix_expression<const LHS1, const RHS1, OP1>,
1228 const matrix_expression<const LHS2, const RHS2, OP2>,
1231 matrix_expression<const LHS2, const RHS2, OP2>
const & proxy2)
1235 &&
bool(
"Incompatible matrix sizes!"));
1236 return matrix_expression< const matrix_expression<const LHS1, const RHS1, OP1>,
1237 const matrix_expression<const LHS2, const RHS2, OP2>,
1241 template<
typename LHS1,
typename RHS1,
typename OP1,
1243 matrix_expression< const matrix_expression<const LHS1, const RHS1, OP1>,
1244 const matrix_base<NumericT>,
1247 matrix_base<NumericT>
const & proxy2)
1251 &&
bool(
"Incompatible matrix sizes!"));
1252 return matrix_expression< const matrix_expression<const LHS1, const RHS1, OP1>,
1253 const matrix_base<NumericT>,
1257 template<
typename NumericT,
1258 typename LHS2,
typename RHS2,
typename OP2>
1259 matrix_expression< const matrix_base<NumericT>,
1260 const matrix_expression<const LHS2, const RHS2, OP2>,
1263 matrix_expression<const LHS2, const RHS2, OP2>
const & proxy2)
1267 &&
bool(
"Incompatible matrix sizes!"));
1268 return matrix_expression< const matrix_base<NumericT>,
1269 const matrix_expression<const LHS2, const RHS2, OP2>,
1274 template<
typename NumericT>
1275 matrix_expression< const matrix_base<NumericT>,
const matrix_base<NumericT>, op_sub >
1276 operator - (
const matrix_base<NumericT> &
m1,
const matrix_base<NumericT> & m2)
1278 return matrix_expression< const matrix_base<NumericT>,
1279 const matrix_base<NumericT>,
1291 template<
typename S1,
typename NumericT>
1293 matrix_expression< const matrix_base<NumericT>,
const S1, op_mult>
1297 return matrix_expression< const matrix_base<NumericT>,
const S1,
op_mult>(
m1, value);
1301 template<
typename NumericT>
1302 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_mult>
1305 return matrix_expression< const matrix_base<NumericT>,
const NumericT,
op_mult>(
m1, NumericT(value));
1309 template<
typename NumericT>
1310 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_mult>
1313 return matrix_expression< const matrix_base<NumericT>,
const NumericT,
op_mult>(
m1, NumericT(value));
1317 template<
typename NumericT>
1318 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_mult>
1321 return matrix_expression< const matrix_base<NumericT>,
const NumericT,
op_mult>(
m1, NumericT(value));
1325 template<
typename NumericT>
1326 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_mult>
1329 return matrix_expression< const matrix_base<NumericT>,
const NumericT,
op_mult>(
m1, NumericT(value));
1333 template<
typename NumericT>
1334 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_mult>
1337 return matrix_expression< const matrix_base<NumericT>,
const NumericT,
op_mult>(
m1, NumericT(value));
1341 template<
typename NumericT>
1342 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_mult>
1345 return matrix_expression< const matrix_base<NumericT>,
const NumericT,
op_mult>(
m1, NumericT(value));
1355 template<
typename LHS,
typename RHS,
typename OP,
typename S1>
1357 matrix_expression< const matrix_expression< LHS, RHS, OP>,
const S1, op_mult> >::type
1361 return matrix_expression< const matrix_expression< LHS, RHS, OP>,
const S1,
op_mult>(proxy, val);
1370 template<
typename S1,
typename LHS,
typename RHS,
typename OP>
1372 matrix_expression< const matrix_expression< LHS, RHS, OP>,
const S1, op_mult> >::type
1376 return matrix_expression< const matrix_expression< LHS, RHS, OP>,
const S1,
op_mult>(proxy, val);
1381 template<
typename NumericT,
typename S1>
1383 matrix_expression< const matrix_base<NumericT>,
const S1, op_mult> >::type
1386 return matrix_expression< const matrix_base<NumericT>,
const S1,
op_mult>(
m1,
s1);
1390 template<
typename NumericT>
1391 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_mult>
1394 return matrix_expression< const matrix_base<NumericT>,
const NumericT,
op_mult>(
m1, NumericT(s1));
1398 template<
typename NumericT>
1399 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_mult>
1402 return matrix_expression< const matrix_base<NumericT>,
const NumericT,
op_mult>(
m1, NumericT(s1));
1406 template<
typename NumericT>
1407 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_mult>
1410 return matrix_expression< const matrix_base<NumericT>,
const NumericT,
op_mult>(
m1, NumericT(s1));
1414 template<
typename NumericT>
1415 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_mult>
1418 return matrix_expression< const matrix_base<NumericT>,
const NumericT,
op_mult>(
m1, NumericT(s1));
1422 template<
typename NumericT>
1423 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_mult>
1426 return matrix_expression< const matrix_base<NumericT>,
const NumericT,
op_mult>(
m1, NumericT(s1));
1430 template<
typename NumericT>
1431 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_mult>
1434 return matrix_expression< const matrix_base<NumericT>,
const NumericT,
op_mult>(
m1, NumericT(s1));
1441 template<
typename NumericT,
typename S1>
1447 m1, gpu_val, 1,
false, is_sign_flip ?
true :
false);
1452 template<
typename NumericT>
1453 matrix_base<NumericT> &
1457 m1, NumericT(gpu_val), 1,
false,
false);
1462 template<
typename NumericT>
1463 matrix_base<NumericT> &
1467 m1, NumericT(gpu_val), 1,
false,
false);
1472 template<
typename NumericT>
1473 matrix_base<NumericT> &
1477 m1, NumericT(gpu_val), 1,
false,
false);
1482 template<
typename NumericT>
1483 matrix_base<NumericT> &
1487 m1, NumericT(gpu_val), 1,
false,
false);
1492 template<
typename NumericT>
1493 matrix_base<NumericT> &
1497 m1, NumericT(gpu_val), 1,
false,
false);
1502 template<
typename NumericT>
1503 matrix_base<NumericT> &
1507 m1, NumericT(gpu_val), 1,
false,
false);
1521 template<
typename LHS,
typename RHS,
typename OP,
typename S1>
1523 matrix_expression< const matrix_expression<const LHS, const RHS, OP>,
const S1, op_div> >::type
1527 return matrix_expression< const matrix_expression<const LHS, const RHS, OP>,
const S1,
op_div>(proxy, val);
1532 template<
typename NumericT,
typename S1>
1534 matrix_expression< const matrix_base<NumericT>,
const S1, op_div> >::type
1537 return matrix_expression< const matrix_base<NumericT>,
const S1,
op_div>(
m1,
s1);
1541 template<
typename NumericT>
1542 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_div>
1545 return matrix_expression< const matrix_base<NumericT>,
const NumericT,
op_div>(
m1, NumericT(s1));
1549 template<
typename NumericT>
1550 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_div>
1553 return matrix_expression< const matrix_base<NumericT>,
const NumericT,
op_div>(
m1, NumericT(s1));
1557 template<
typename NumericT>
1558 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_div>
1561 return matrix_expression< const matrix_base<NumericT>,
const NumericT,
op_div>(
m1, NumericT(s1));
1565 template<
typename NumericT>
1566 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_div>
1569 return matrix_expression< const matrix_base<NumericT>,
const NumericT,
op_div>(
m1, NumericT(s1));
1573 template<
typename NumericT>
1574 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_div>
1577 return matrix_expression< const matrix_base<NumericT>,
const NumericT,
op_div>(
m1, NumericT(s1));
1581 template<
typename NumericT>
1582 matrix_expression< const matrix_base<NumericT>,
const NumericT, op_div>
1585 return matrix_expression< const matrix_base<NumericT>,
const NumericT,
op_div>(
m1, NumericT(s1));
1593 template<
typename NumericT,
typename S1>
1598 m1, gpu_val, 1,
true,
false);
1603 template<
typename NumericT>
1604 matrix_base<NumericT> &
1608 m1, NumericT(gpu_val), 1,
true,
false);
1613 template<
typename NumericT>
1614 matrix_base<NumericT> &
1618 m1, gpu_val, 1,
true,
false);
1623 template<
typename NumericT>
1624 matrix_base<NumericT> &
1628 m1, gpu_val, 1,
true,
false);
1633 template<
typename NumericT>
1634 matrix_base<NumericT> &
1638 m1, gpu_val, 1,
true,
false);
1643 template<
typename NumericT>
1644 matrix_base<NumericT> &
1648 m1, gpu_val, 1,
true,
false);
1653 template<
typename NumericT>
1654 matrix_base<NumericT> &
1658 m1, gpu_val, 1,
true,
false);
1667 template<
typename NumericT,
typename S1>
1676 return viennacl::matrix_expression< const viennacl::matrix_expression< const vector_base<NumericT>,
const vector_base<NumericT>, op_prod>,
1681 template<
typename NumericT,
typename S1>
1683 viennacl::matrix_expression< const viennacl::matrix_expression< const vector_base<NumericT>,
const vector_base<NumericT>, op_prod>,
1690 return viennacl::matrix_expression< const viennacl::matrix_expression< const vector_base<NumericT>,
const vector_base<NumericT>, op_prod>,
1692 op_mult>(proxy, NumericT(val));
1696 template<
typename NumericT,
typename S1>
1698 viennacl::matrix_expression< const viennacl::matrix_expression< const vector_base<NumericT>,
const vector_base<NumericT>, op_prod>,
1705 return viennacl::matrix_expression< const viennacl::matrix_expression< const vector_base<NumericT>,
const vector_base<NumericT>, op_prod>,
1710 template<
typename NumericT,
typename S1>
1712 viennacl::matrix_expression< const viennacl::matrix_expression< const vector_base<NumericT>,
const vector_base<NumericT>, op_prod>,
1719 return viennacl::matrix_expression< const viennacl::matrix_expression< const vector_base<NumericT>,
const vector_base<NumericT>, op_prod>,
1721 op_mult>(proxy, NumericT(val));
1738 template<
typename T>
1739 struct op_executor<matrix_base<T>,
op_assign, matrix_base<T> >
1741 static void apply(matrix_base<T> & lhs, matrix_base<T>
const & rhs)
1748 template<
typename T>
1749 struct op_executor<matrix_base<T>,
op_assign, matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans> >
1751 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>
const & rhs)
1753 matrix_base<T> temp(rhs);
1760 template<
typename T>
1761 struct op_executor<matrix_base<T>, op_inplace_add, matrix_base<T> >
1763 static void apply(matrix_base<T> & lhs, matrix_base<T>
const & rhs)
1765 viennacl::linalg::ambm(lhs, lhs, T(1), 1,
false,
false, rhs, T(1), 1,
false,
false);
1770 template<
typename T>
1771 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans> >
1773 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>
const & rhs)
1775 matrix_base<T> temp(rhs);
1776 viennacl::linalg::ambm(lhs, lhs, T(1), 1,
false,
false, temp, T(1), 1,
false,
false);
1781 template<
typename T>
1782 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_base<T> >
1784 static void apply(matrix_base<T> & lhs, matrix_base<T>
const & rhs)
1786 viennacl::linalg::ambm(lhs, lhs, T(1), 1,
false,
false, rhs, T(1), 1,
false,
true);
1791 template<
typename T>
1792 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans> >
1794 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>
const & rhs)
1796 matrix_base<T> temp(rhs);
1797 viennacl::linalg::ambm(lhs, lhs, T(1), 1,
false,
false, temp, T(1), 1,
false,
true);
1805 template<
typename T,
typename ScalarType>
1806 struct op_executor<matrix_base<T>,
op_assign, matrix_expression<const matrix_base<T>, const
ScalarType, op_mult> >
1808 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>
const & proxy)
1815 template<
typename T,
typename ScalarType>
1816 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression<const matrix_base<T>, const
ScalarType, op_mult> >
1818 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>
const & proxy)
1820 viennacl::linalg::ambm(lhs, lhs, T(1), 1,
false,
false, proxy.lhs(), proxy.rhs(), 1,
false,
false);
1825 template<
typename T,
typename ScalarType>
1826 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression<const matrix_base<T>, const
ScalarType, op_mult> >
1828 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>
const & proxy)
1830 viennacl::linalg::ambm(lhs, lhs, T(1), 1,
false,
false, proxy.lhs(), proxy.rhs(), 1,
false,
true);
1838 template<
typename T,
typename LHS,
typename RHS,
typename OP,
typename ScalarType>
1839 struct op_executor<matrix_base<T>,
op_assign, matrix_expression<const matrix_expression<const LHS, const RHS, OP>, const
ScalarType, op_mult> >
1841 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LHS, const RHS, OP>,
const ScalarType, op_mult>
const & proxy)
1843 if (lhs.row_major())
1845 matrix<T> temp(proxy.lhs());
1846 lhs = temp * proxy.rhs();
1850 matrix<T, column_major> temp(proxy.lhs());
1851 lhs = temp * proxy.rhs();
1857 template<
typename T,
typename LHS,
typename RHS,
typename OP,
typename ScalarType>
1858 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression<const matrix_expression<const LHS, const RHS, OP>, const
ScalarType, op_mult> >
1860 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LHS, const RHS, OP>,
const ScalarType, op_mult>
const & proxy)
1862 if (lhs.row_major())
1864 matrix<T> temp(proxy.lhs());
1865 lhs += temp * proxy.rhs();
1869 matrix<T, column_major> temp(proxy.lhs());
1870 lhs += temp * proxy.rhs();
1876 template<
typename T,
typename LHS,
typename RHS,
typename OP,
typename ScalarType>
1877 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression<const matrix_expression<const LHS, const RHS, OP>, const
ScalarType, op_mult> >
1879 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LHS, const RHS, OP>,
const ScalarType, op_mult>
const & proxy)
1881 if (lhs.row_major())
1883 matrix<T> temp(proxy.lhs());
1884 lhs -= temp * proxy.rhs();
1888 matrix<T, column_major> temp(proxy.lhs());
1889 lhs -= temp * proxy.rhs();
1898 template<
typename T,
typename ScalarType>
1899 struct op_executor<matrix_base<T>,
op_assign, matrix_expression<const matrix_base<T>, const
ScalarType, op_div> >
1901 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>
const & proxy)
1908 template<
typename T,
typename ScalarType>
1909 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression<const matrix_base<T>, const
ScalarType, op_div> >
1911 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>
const & proxy)
1913 viennacl::linalg::ambm(lhs, lhs, T(1), 1,
false,
false, proxy.lhs(), proxy.rhs(), 1,
true,
false);
1918 template<
typename T,
typename ScalarType>
1919 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression<const matrix_base<T>, const
ScalarType, op_div> >
1921 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>
const & proxy)
1923 viennacl::linalg::ambm(lhs, lhs, T(1), 1,
false,
false, proxy.lhs(), proxy.rhs(), 1,
true,
true);
1931 template<
typename T,
typename LHS,
typename RHS,
typename OP,
typename ScalarType>
1932 struct op_executor<matrix_base<T>,
op_assign, matrix_expression<const matrix_expression<const LHS, const RHS, OP>, const
ScalarType, op_div> >
1934 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LHS, const RHS, OP>,
const ScalarType, op_div>
const & proxy)
1936 if (lhs.row_major())
1938 matrix<T> temp(proxy.lhs());
1939 lhs = temp / proxy.rhs();
1943 matrix<T, column_major> temp(proxy.lhs());
1944 lhs = temp / proxy.rhs();
1950 template<
typename T,
typename LHS,
typename RHS,
typename OP,
typename ScalarType>
1951 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression<const matrix_expression<const LHS, const RHS, OP>, const
ScalarType, op_div> >
1953 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LHS, const RHS, OP>,
const ScalarType, op_div>
const & proxy)
1955 if (lhs.row_major())
1957 matrix<T> temp(proxy.lhs());
1958 lhs += temp / proxy.rhs();
1962 matrix<T, column_major> temp(proxy.lhs());
1963 lhs += temp / proxy.rhs();
1969 template<
typename T,
typename LHS,
typename RHS,
typename OP,
typename ScalarType>
1970 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression<const matrix_expression<const LHS, const RHS, OP>, const
ScalarType, op_div> >
1972 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LHS, const RHS, OP>,
const ScalarType, op_div>
const & proxy)
1974 if (lhs.row_major())
1976 matrix<T, row_major> temp(proxy.lhs());
1977 lhs -= temp / proxy.rhs();
1981 matrix<T, column_major> temp(proxy.lhs());
1982 lhs -= temp / proxy.rhs();
1990 template<
typename T,
typename LHS,
typename RHS>
1991 struct op_executor<matrix_base<T>,
op_assign, matrix_expression<const LHS, const RHS, op_add> >
1994 template<
typename LHS1,
typename RHS1>
1995 static void apply(matrix_base<T> & lhs, matrix_expression<const LHS1, const RHS1, op_add>
const & proxy)
1997 bool op_aliasing_lhs =
op_aliasing(lhs, proxy.lhs());
1998 bool op_aliasing_rhs =
op_aliasing(lhs, proxy.rhs());
2000 if (op_aliasing_lhs || op_aliasing_rhs)
2002 matrix_base<T> temp(proxy.lhs());
2003 op_executor<matrix_base<T>, op_inplace_add, RHS>::apply(temp, proxy.rhs());
2008 op_executor<matrix_base<T>,
op_assign, LHS>::apply(lhs, proxy.lhs());
2009 op_executor<matrix_base<T>, op_inplace_add, RHS>::apply(lhs, proxy.rhs());
2014 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_add>
const & proxy)
2017 proxy.lhs(), T(1), 1,
false,
false,
2018 proxy.rhs(), T(1), 1,
false,
false);
2022 template<
typename ScalarType>
2023 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>,
2024 const matrix_base<T>,
2025 op_add>
const & proxy)
2028 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2029 proxy.rhs(), T(1), 1,
false,
false);
2033 template<
typename ScalarType>
2034 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>,
2035 const matrix_base<T>,
2036 op_add>
const & proxy)
2039 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2040 proxy.rhs(), T(1), 1,
false,
false);
2044 template<
typename ScalarType>
2045 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
2046 const matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>,
2047 op_add>
const & proxy)
2050 proxy.lhs(), T(1), 1,
false,
false,
2051 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
false);
2055 template<
typename ScalarType>
2056 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
2057 const matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>,
2058 op_add>
const & proxy)
2061 proxy.lhs(), T(1), 1,
false,
false,
2062 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
false);
2066 template<
typename ScalarType1,
typename ScalarType2>
2067 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_mult>,
2068 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_mult>,
2069 op_add>
const & proxy)
2072 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2073 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
false);
2077 template<
typename ScalarType1,
typename ScalarType2>
2078 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_mult>,
2079 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_div>,
2080 op_add>
const & proxy)
2083 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2084 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
false);
2088 template<
typename ScalarType1,
typename ScalarType2>
2089 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_div>,
2090 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_mult>,
2091 op_add>
const & proxy)
2094 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2095 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
false);
2099 template<
typename ScalarType1,
typename ScalarType2>
2100 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_div>,
2101 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_div>,
2102 op_add>
const & proxy)
2105 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2106 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
false);
2111 template<
typename T,
typename LHS,
typename RHS>
2112 struct op_executor<matrix_base<T>, op_assign, matrix_expression<const LHS, const RHS, op_prod> >
2114 template<
typename SparseMatrixType>
2115 static void apply(matrix_base<T> & lhs, matrix_expression<
const SparseMatrixType,
2122 matrix_base<T> temp(proxy);
2130 template<
typename SparseMatrixType >
2131 static void apply(matrix_base<T> & lhs, matrix_expression<
const SparseMatrixType,
2140 matrix_base<T> temp(proxy);
2150 template<
typename T,
typename LHS,
typename RHS>
2151 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression<const LHS, const RHS, op_add> >
2154 template<
typename LHS1,
typename RHS1>
2155 static void apply(matrix_base<T> & lhs, matrix_expression<const LHS1, const RHS1, op_add>
const & proxy)
2157 bool op_aliasing_lhs =
op_aliasing(lhs, proxy.lhs());
2158 bool op_aliasing_rhs =
op_aliasing(lhs, proxy.rhs());
2160 if (op_aliasing_lhs || op_aliasing_rhs)
2162 matrix_base<T> temp(proxy.lhs());
2163 op_executor<matrix_base<T>, op_inplace_add, RHS>::apply(temp, proxy.rhs());
2168 op_executor<matrix_base<T>, op_inplace_add, LHS>::apply(lhs, proxy.lhs());
2169 op_executor<matrix_base<T>, op_inplace_add, RHS>::apply(lhs, proxy.rhs());
2174 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_add>
const & proxy)
2177 proxy.lhs(), T(1), 1,
false,
false,
2178 proxy.rhs(), T(1), 1,
false,
false);
2182 template<
typename ScalarType>
2183 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>,
2184 const matrix_base<T>,
2185 op_add>
const & proxy)
2188 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2189 proxy.rhs(), T(1), 1,
false,
false);
2193 template<
typename ScalarType>
2194 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>,
2195 const matrix_base<T>,
2196 op_add>
const & proxy)
2199 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2200 proxy.rhs(), T(1), 1,
false,
false);
2204 template<
typename ScalarType>
2205 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
2206 const matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>,
2207 op_add>
const & proxy)
2210 proxy.lhs(), T(1), 1,
false,
false,
2211 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
false);
2215 template<
typename ScalarType>
2216 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
2217 const matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>,
2218 op_add>
const & proxy)
2221 proxy.lhs(), T(1), 1,
false,
false,
2222 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
false);
2226 template<
typename ScalarType1,
typename ScalarType2>
2227 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_mult>,
2228 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_mult>,
2229 op_add>
const & proxy)
2232 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2233 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
false);
2237 template<
typename ScalarType1,
typename ScalarType2>
2238 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_mult>,
2239 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_div>,
2240 op_add>
const & proxy)
2243 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2244 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
false);
2248 template<
typename ScalarType1,
typename ScalarType2>
2249 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_div>,
2250 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_mult>,
2251 op_add>
const & proxy)
2254 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2255 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
false);
2259 template<
typename ScalarType1,
typename ScalarType2>
2260 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_div>,
2261 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_div>,
2262 op_add>
const & proxy)
2265 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2266 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
false);
2273 template<
typename T,
typename LHS,
typename RHS>
2274 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression<const LHS, const RHS, op_add> >
2277 template<
typename LHS1,
typename RHS1>
2278 static void apply(matrix_base<T> & lhs, matrix_expression<const LHS1, const RHS1, op_add>
const & proxy)
2280 bool op_aliasing_lhs =
op_aliasing(lhs, proxy.lhs());
2281 bool op_aliasing_rhs =
op_aliasing(lhs, proxy.rhs());
2283 if (op_aliasing_lhs || op_aliasing_rhs)
2285 matrix_base<T> temp(proxy.lhs());
2286 op_executor<matrix_base<T>, op_inplace_add, RHS>::apply(temp, proxy.rhs());
2291 op_executor<matrix_base<T>, op_inplace_sub, LHS>::apply(lhs, proxy.lhs());
2292 op_executor<matrix_base<T>, op_inplace_sub, RHS>::apply(lhs, proxy.rhs());
2297 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_add>
const & proxy)
2300 proxy.lhs(), T(1), 1,
false,
true,
2301 proxy.rhs(), T(1), 1,
false,
true);
2305 template<
typename ScalarType>
2306 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>,
2307 const matrix_base<T>,
2308 op_add>
const & proxy)
2311 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
true,
2312 proxy.rhs(), T(1), 1,
false,
true);
2316 template<
typename ScalarType>
2317 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>,
2318 const matrix_base<T>,
2319 op_add>
const & proxy)
2322 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
true,
2323 proxy.rhs(), T(1), 1,
false,
true);
2327 template<
typename ScalarType>
2328 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
2329 const matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>,
2330 op_add>
const & proxy)
2333 proxy.lhs(), T(1), 1,
false,
true,
2334 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
true);
2338 template<
typename ScalarType>
2339 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
2340 const matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>,
2341 op_add>
const & proxy)
2344 proxy.lhs(), T(1), 1,
false,
true,
2345 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
true);
2349 template<
typename ScalarType1,
typename ScalarType2>
2350 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_mult>,
2351 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_mult>,
2352 op_add>
const & proxy)
2355 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
true,
2356 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
true);
2360 template<
typename ScalarType1,
typename ScalarType2>
2361 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_mult>,
2362 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_div>,
2363 op_add>
const & proxy)
2366 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
true,
2367 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
true);
2371 template<
typename ScalarType1,
typename ScalarType2>
2372 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_div>,
2373 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_mult>,
2374 op_add>
const & proxy)
2377 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
true,
2378 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
true);
2382 template<
typename ScalarType1,
typename ScalarType2>
2383 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_div>,
2384 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_div>,
2385 op_add>
const & proxy)
2388 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
true,
2389 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
true);
2400 template<
typename T,
typename LHS,
typename RHS>
2401 struct op_executor<matrix_base<T>, op_assign, matrix_expression<const LHS, const RHS, op_sub> >
2404 template<
typename LHS1,
typename RHS1>
2405 static void apply(matrix_base<T> & lhs, matrix_expression<const LHS1, const RHS1, op_sub>
const & proxy)
2407 bool op_aliasing_lhs =
op_aliasing(lhs, proxy.lhs());
2408 bool op_aliasing_rhs =
op_aliasing(lhs, proxy.rhs());
2410 if (op_aliasing_lhs || op_aliasing_rhs)
2412 matrix_base<T> temp(proxy.lhs());
2413 op_executor<matrix_base<T>, op_inplace_sub, RHS>::apply(temp, proxy.rhs());
2418 op_executor<matrix_base<T>, op_assign, LHS>::apply(lhs, proxy.lhs());
2419 op_executor<matrix_base<T>, op_inplace_sub, RHS>::apply(lhs, proxy.rhs());
2424 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_sub>
const & proxy)
2427 proxy.lhs(), T(1), 1,
false,
false,
2428 proxy.rhs(), T(1), 1,
false,
true);
2432 template<
typename ScalarType>
2433 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>,
2434 const matrix_base<T>,
2435 op_sub>
const & proxy)
2438 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2439 proxy.rhs(), T(1), 1,
false,
true);
2443 template<
typename ScalarType>
2444 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>,
2445 const matrix_base<T>,
2446 op_sub>
const & proxy)
2449 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2450 proxy.rhs(), T(1), 1,
false,
true);
2454 template<
typename ScalarType>
2455 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
2456 const matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>,
2457 op_sub>
const & proxy)
2460 proxy.lhs(), T(1), 1,
false,
false,
2461 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
true);
2465 template<
typename ScalarType>
2466 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
2467 const matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>,
2468 op_sub>
const & proxy)
2471 proxy.lhs(), T(1), 1,
false,
false,
2472 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
true);
2476 template<
typename ScalarType1,
typename ScalarType2>
2477 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_mult>,
2478 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_mult>,
2479 op_sub>
const & proxy)
2482 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2483 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
true);
2487 template<
typename ScalarType1,
typename ScalarType2>
2488 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_mult>,
2489 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_div>,
2490 op_sub>
const & proxy)
2493 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2494 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
true);
2498 template<
typename ScalarType1,
typename ScalarType2>
2499 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_div>,
2500 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_mult>,
2501 op_sub>
const & proxy)
2504 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2505 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
true);
2509 template<
typename ScalarType1,
typename ScalarType2>
2510 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_div>,
2511 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_div>,
2512 op_sub>
const & proxy)
2515 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2516 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
true);
2522 template<
typename T,
typename LHS,
typename RHS>
2523 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression<const LHS, const RHS, op_sub> >
2526 template<
typename LHS1,
typename RHS1>
2527 static void apply(matrix_base<T> & lhs, matrix_expression<const LHS1, const RHS1, op_sub>
const & proxy)
2529 bool op_aliasing_lhs =
op_aliasing(lhs, proxy.lhs());
2530 bool op_aliasing_rhs =
op_aliasing(lhs, proxy.rhs());
2532 if (op_aliasing_lhs || op_aliasing_rhs)
2534 matrix_base<T> temp(proxy.lhs());
2535 op_executor<matrix_base<T>, op_inplace_sub, RHS>::apply(temp, proxy.rhs());
2540 op_executor<matrix_base<T>, op_inplace_add, LHS>::apply(lhs, proxy.lhs());
2541 op_executor<matrix_base<T>, op_inplace_sub, RHS>::apply(lhs, proxy.rhs());
2546 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_sub>
const & proxy)
2549 proxy.lhs(), T(1), 1,
false,
false,
2550 proxy.rhs(), T(1), 1,
false,
true);
2554 template<
typename ScalarType>
2555 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>,
2556 const matrix_base<T>,
2557 op_sub>
const & proxy)
2560 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2561 proxy.rhs(), T(1), 1,
false,
true);
2565 template<
typename ScalarType>
2566 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>,
2567 const matrix_base<T>,
2568 op_sub>
const & proxy)
2571 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2572 proxy.rhs(), T(1), 1,
false,
true);
2576 template<
typename ScalarType>
2577 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
2578 const matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>,
2579 op_sub>
const & proxy)
2582 proxy.lhs(), T(1), 1,
false,
false,
2583 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
true);
2587 template<
typename ScalarType>
2588 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
2589 const matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>,
2590 op_sub>
const & proxy)
2593 proxy.lhs(), T(1), 1,
false,
false,
2594 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
true);
2598 template<
typename ScalarType1,
typename ScalarType2>
2599 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_mult>,
2600 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_mult>,
2601 op_sub>
const & proxy)
2604 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2605 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
true);
2609 template<
typename ScalarType1,
typename ScalarType2>
2610 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_mult>,
2611 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_div>,
2612 op_sub>
const & proxy)
2615 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
false,
2616 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
true);
2620 template<
typename ScalarType1,
typename ScalarType2>
2621 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_div>,
2622 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_mult>,
2623 op_sub>
const & proxy)
2626 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2627 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
true);
2631 template<
typename ScalarType1,
typename ScalarType2>
2632 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_div>,
2633 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_div>,
2634 op_sub>
const & proxy)
2637 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
false,
2638 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
true);
2645 template<
typename T,
typename LHS,
typename RHS>
2646 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression<const LHS, const RHS, op_sub> >
2649 template<
typename LHS1,
typename RHS1>
2650 static void apply(matrix_base<T> & lhs, matrix_expression<const LHS1, const RHS1, op_sub>
const & proxy)
2652 bool op_aliasing_lhs =
op_aliasing(lhs, proxy.lhs());
2653 bool op_aliasing_rhs =
op_aliasing(lhs, proxy.rhs());
2655 if (op_aliasing_lhs || op_aliasing_rhs)
2657 matrix_base<T> temp(proxy.lhs());
2658 op_executor<matrix_base<T>, op_inplace_sub, RHS>::apply(temp, proxy.rhs());
2663 op_executor<matrix_base<T>, op_inplace_sub, LHS>::apply(lhs, proxy.lhs());
2664 op_executor<matrix_base<T>, op_inplace_add, RHS>::apply(lhs, proxy.rhs());
2669 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_sub>
const & proxy)
2672 proxy.lhs(), T(1), 1,
false,
true,
2673 proxy.rhs(), T(1), 1,
false,
false);
2677 template<
typename ScalarType>
2678 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>,
2679 const matrix_base<T>,
2680 op_sub>
const & proxy)
2683 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
true,
2684 proxy.rhs(), T(1), 1,
false,
false);
2688 template<
typename ScalarType>
2689 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>,
2690 const matrix_base<T>,
2691 op_sub>
const & proxy)
2694 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
true,
2695 proxy.rhs(), T(1), 1,
false,
false);
2699 template<
typename ScalarType>
2700 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
2701 const matrix_expression<
const matrix_base<T>,
const ScalarType, op_mult>,
2702 op_sub>
const & proxy)
2705 proxy.lhs(), T(1), 1,
false,
true,
2706 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
false);
2710 template<
typename ScalarType>
2711 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
2712 const matrix_expression<
const matrix_base<T>,
const ScalarType, op_div>,
2713 op_sub>
const & proxy)
2716 proxy.lhs(), T(1), 1,
false,
true,
2717 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
false);
2721 template<
typename ScalarType1,
typename ScalarType2>
2722 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_mult>,
2723 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_mult>,
2724 op_sub>
const & proxy)
2727 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
true,
2728 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
false);
2732 template<
typename ScalarType1,
typename ScalarType2>
2733 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_mult>,
2734 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_div>,
2735 op_sub>
const & proxy)
2738 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
false,
true,
2739 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
false);
2743 template<
typename ScalarType1,
typename ScalarType2>
2744 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_div>,
2745 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_mult>,
2746 op_sub>
const & proxy)
2749 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
true,
2750 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
false,
false);
2754 template<
typename ScalarType1,
typename ScalarType2>
2755 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const ScalarType1, op_div>,
2756 const matrix_expression<
const matrix_base<T>,
const ScalarType2, op_div>,
2757 op_sub>
const & proxy)
2760 proxy.lhs().lhs(), proxy.lhs().rhs(), 1,
true,
true,
2761 proxy.rhs().lhs(), proxy.rhs().rhs(), 1,
true,
false);
2768 template<
typename T,
typename LHS>
2769 struct op_executor<matrix_base<T>, op_assign, matrix_expression<const LHS, const int, op_vector_diag> >
2771 static void apply(matrix_base<T> & lhs, matrix_expression<
const vector_base<T>,
const int, op_vector_diag>
const & proxy)
2778 template<
typename T,
typename LHS>
2779 struct op_executor<vector_base<T>, op_assign, vector_expression<const LHS, const int, op_matrix_diag> >
2781 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_base<T>,
const int, op_matrix_diag>
const & proxy)
2787 template<
typename T,
typename LHS>
2788 struct op_executor<vector_base<T>, op_assign, vector_expression<const LHS, const unsigned int, op_row> >
2790 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_base<T>,
const unsigned int, op_row>
const & proxy)
2797 template<
typename T,
typename LHS>
2798 struct op_executor<vector_base<T>, op_assign, vector_expression<const LHS, const unsigned int, op_column> >
2800 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_base<T>,
const unsigned int, op_column>
const & proxy)
2810 template<
typename T,
typename LHS,
typename RHS,
typename OP>
2811 struct op_executor<matrix_base<T>, op_assign, matrix_expression<const LHS, const RHS, op_element_binary<OP> > >
2814 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_element_binary<OP> >
const & proxy)
2820 template<
typename LHS2,
typename RHS2,
typename OP2>
2821 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)
2823 matrix_base<T> temp(proxy.rhs());
2828 template<
typename LHS1,
typename RHS1,
typename OP1>
2829 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)
2831 matrix_base<T> temp(proxy.lhs());
2836 template<
typename LHS1,
typename RHS1,
typename OP1,
2837 typename LHS2,
typename RHS2,
typename OP2>
2838 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LHS1, const RHS1, OP1>,
2839 const matrix_expression<const LHS2, const RHS2, OP2>,
2840 op_element_binary<OP> >
const & proxy)
2842 matrix_base<T> temp1(proxy.lhs());
2843 matrix_base<T> temp2(proxy.rhs());
2849 template<
typename T,
typename LHS,
typename RHS,
typename OP>
2850 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression<const LHS, const RHS, op_element_binary<OP> > >
2853 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_element_binary<OP> >
const & proxy)
2855 matrix_base<T> temp(proxy);
2860 template<
typename LHS2,
typename RHS2,
typename OP2>
2861 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)
2863 matrix_base<T> temp(proxy.rhs());
2870 template<
typename LHS1,
typename RHS1,
typename OP1>
2871 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)
2873 matrix_base<T> temp(proxy.lhs());
2880 template<
typename LHS1,
typename RHS1,
typename OP1,
2881 typename LHS2,
typename RHS2,
typename OP2>
2882 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LHS1, const RHS1, OP1>,
2883 const matrix_expression<const LHS2, const RHS2, OP2>,
2884 op_element_binary<OP> >
const & proxy)
2886 matrix_base<T> temp1(proxy.lhs());
2887 matrix_base<T> temp2(proxy.rhs());
2895 template<
typename T,
typename LHS,
typename RHS,
typename OP>
2896 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression<const LHS, const RHS, op_element_binary<OP> > >
2900 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_element_binary<OP> >
const & proxy)
2902 matrix_base<T> temp(proxy);
2907 template<
typename LHS2,
typename RHS2,
typename OP2>
2908 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)
2910 matrix_base<T> temp(proxy.rhs());
2917 template<
typename LHS1,
typename RHS1,
typename OP1>
2918 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)
2920 matrix_base<T> temp(proxy.lhs());
2927 template<
typename LHS1,
typename RHS1,
typename OP1,
2928 typename LHS2,
typename RHS2,
typename OP2>
2929 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LHS1, const RHS1, OP1>,
2930 const matrix_expression<const LHS2, const RHS2, OP2>,
2931 op_element_binary<OP> >
const & proxy)
2933 matrix_base<T> temp1(proxy.lhs());
2934 matrix_base<T> temp2(proxy.rhs());
2943 template<
typename T,
typename LHS,
typename RHS,
typename OP>
2944 struct op_executor<matrix_base<T>, op_assign, matrix_expression<const LHS, const RHS, op_element_unary<OP> > >
2947 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_element_unary<OP> >
const & proxy)
2953 template<
typename LHS2,
typename RHS2,
typename OP2>
2954 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LHS2, const RHS2, OP2>,
2955 const matrix_expression<const LHS2, const RHS2, OP2>,
2956 op_element_unary<OP> >
const & proxy)
2958 matrix_base<T> temp(proxy.rhs());
2963 template<
typename T,
typename LHS,
typename RHS,
typename OP>
2964 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression<const LHS, const RHS, op_element_unary<OP> > >
2967 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_element_unary<OP> >
const & proxy)
2969 matrix_base<T> temp(proxy);
2974 template<
typename LHS2,
typename RHS2,
typename OP2>
2975 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LHS2, const RHS2, OP2>,
2976 const matrix_expression<const LHS2, const RHS2, OP2>,
2977 op_element_unary<OP> >
const & proxy)
2979 matrix_base<T> temp(proxy.rhs());
2985 template<
typename T,
typename LHS,
typename RHS,
typename OP>
2986 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression<const LHS, const RHS, op_element_unary<OP> > >
2989 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_element_unary<OP> >
const & proxy)
2991 matrix_base<T> temp(proxy);
2996 template<
typename LHS2,
typename RHS2,
typename OP2>
2997 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<const LHS2, const RHS2, OP2>,
2998 const matrix_expression<const LHS2, const RHS2, OP2>,
2999 op_element_unary<OP> >
const & proxy)
3001 matrix_base<T> temp(proxy.rhs());
3012 template<
typename T>
3013 struct op_executor<matrix_base<T>, op_assign, matrix_expression<const matrix_base<T>, const matrix_base<T>, op_mat_mat_prod> >
3015 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_mat_mat_prod>
const & rhs)
3019 matrix_base<T> temp(rhs);
3028 template<
typename T>
3029 struct op_executor<matrix_base<T>, op_assign, matrix_expression<const matrix_base<T>,
3030 const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3033 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
3034 const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3035 op_mat_mat_prod>
const & rhs)
3039 matrix_base<T> temp(rhs);
3048 template<
typename T>
3049 struct op_executor<matrix_base<T>, op_assign, matrix_expression<const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3050 const matrix_base<T>,
3053 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3054 const matrix_base<T>,
3055 op_mat_mat_prod>
const & rhs)
3059 matrix_base<T> temp(rhs);
3068 template<
typename T>
3069 struct op_executor<matrix_base<T>, op_assign, matrix_expression<const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3070 const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3073 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3074 const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3075 op_mat_mat_prod>
const & rhs)
3079 matrix_base<T> temp(rhs);
3089 template<
typename T>
3090 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression<const matrix_base<T>, const matrix_base<T>, op_mat_mat_prod> >
3092 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_mat_mat_prod>
const & rhs)
3096 matrix_base<T> temp(rhs);
3105 template<
typename T>
3106 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression<const matrix_base<T>,
3107 const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3110 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
3111 const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3112 op_mat_mat_prod>
const & rhs)
3116 matrix_base<T> temp(rhs);
3125 template<
typename T>
3126 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression<const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3127 const matrix_base<T>,
3130 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3131 const matrix_base<T>,
3132 op_mat_mat_prod>
const & rhs)
3136 matrix_base<T> temp(rhs);
3145 template<
typename T>
3146 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression<const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3147 const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3150 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3151 const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3152 op_mat_mat_prod>
const & rhs)
3156 matrix_base<T> temp(rhs);
3166 template<
typename T>
3167 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression<const matrix_base<T>, const matrix_base<T>, op_mat_mat_prod> >
3169 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_mat_mat_prod>
const & rhs)
3173 matrix_base<T> temp(rhs);
3182 template<
typename T>
3183 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression<const matrix_base<T>,
3184 const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3187 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_base<T>,
3188 const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3189 op_mat_mat_prod>
const & rhs)
3193 matrix_base<T> temp(rhs);
3202 template<
typename T>
3203 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression<const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3204 const matrix_base<T>,
3207 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3208 const matrix_base<T>,
3209 op_mat_mat_prod>
const & rhs)
3213 matrix_base<T> temp(rhs);
3222 template<
typename T>
3223 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression<const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3224 const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3227 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3228 const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3229 op_mat_mat_prod>
const & rhs)
3233 matrix_base<T> temp(rhs);
3244 template<
typename T>
3245 struct op_executor<vector_base<T>, op_assign, vector_expression<const matrix_base<T>, const vector_base<T>, op_prod> >
3247 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_base<T>,
const vector_base<T>, op_prod>
const & rhs)
3252 vector_base<T> temp(rhs);
3261 template<
typename T>
3262 struct op_executor<vector_base<T>, op_assign, vector_expression<const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3263 const vector_base<T>,
3266 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3267 const vector_base<T>,
3268 op_prod>
const & rhs)
3273 vector_base<T> temp(rhs);
3283 template<
typename T>
3284 struct op_executor<vector_base<T>, op_inplace_add, vector_expression<const matrix_base<T>, const vector_base<T>, op_prod> >
3286 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_base<T>,
const vector_base<T>, op_prod>
const & rhs)
3288 vector_base<T> temp(rhs);
3294 template<
typename T>
3295 struct op_executor<vector_base<T>, op_inplace_add, vector_expression<const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3296 const vector_base<T>,
3299 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3300 const vector_base<T>,
3301 op_prod>
const & rhs)
3303 vector_base<T> temp(rhs);
3310 template<
typename T>
3311 struct op_executor<vector_base<T>, op_inplace_sub, vector_expression<const matrix_base<T>, const vector_base<T>, op_prod> >
3313 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_base<T>,
const vector_base<T>, op_prod>
const & rhs)
3315 vector_base<T> temp(rhs);
3321 template<
typename T>
3322 struct op_executor<vector_base<T>, op_inplace_sub, vector_expression<const matrix_expression<const matrix_base<T>, const matrix_base<T>, op_trans>,
3323 const vector_base<T>,
3326 static void apply(vector_base<T> & lhs, vector_expression<
const matrix_expression<
const matrix_base<T>,
const matrix_base<T>, op_trans>,
3327 const vector_base<T>,
3328 op_prod>
const & rhs)
3330 vector_base<T> temp(rhs);
3340 template<
typename T>
3341 struct op_executor<matrix_base<T>, op_assign, matrix_expression<const vector_base<T>, const vector_base<T>, op_prod> >
3343 static void apply(matrix_base<T> & lhs, matrix_expression<
const vector_base<T>,
const vector_base<T>, op_prod>
const & rhs)
3351 template<
typename T,
typename ScalarType>
3352 struct op_executor<matrix_base<T>, op_assign, matrix_expression< const matrix_expression<const vector_base<T>, const vector_base<T>, op_prod>,
3356 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const vector_base<T>,
const vector_base<T>, op_prod>,
3358 op_mult>
const & rhs)
3366 template<
typename T>
3367 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression<const vector_base<T>, const vector_base<T>, op_prod> >
3369 static void apply(matrix_base<T> & lhs, matrix_expression<
const vector_base<T>,
const vector_base<T>, op_prod>
const & rhs)
3376 template<
typename T,
typename ScalarType>
3377 struct op_executor<matrix_base<T>, op_inplace_add, matrix_expression< const matrix_expression<const vector_base<T>, const vector_base<T>, op_prod>,
3381 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const vector_base<T>,
const vector_base<T>, op_prod>,
3383 op_mult>
const & rhs)
3390 template<
typename T>
3391 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression<const vector_base<T>, const vector_base<T>, op_prod> >
3393 static void apply(matrix_base<T> & lhs, matrix_expression<
const vector_base<T>,
const vector_base<T>, op_prod>
const & rhs)
3400 template<
typename T,
typename ScalarType>
3401 struct op_executor<matrix_base<T>, op_inplace_sub, matrix_expression< const matrix_expression<const vector_base<T>, const vector_base<T>, op_prod>,
3405 static void apply(matrix_base<T> & lhs, matrix_expression<
const matrix_expression<
const vector_base<T>,
const vector_base<T>, op_prod>,
3407 op_mult>
const & rhs)
Simple enable-if variant that uses the SFINAE pattern.
A tag class representing multiplication by a scalar.
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'.
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)
self_type & operator=(const self_type &other)
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.
matrix_iterator(MatrixT &mat, vcl_size_t start_row, vcl_size_t start_col)
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...
matrix(size_type rows, size_type columns, viennacl::context ctx=viennacl::context())
Creates the matrix with the given dimensions.
vcl_size_t size1() const
Returns the size of the result vector.
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.
self_type & operator++(void)
self_type operator++(int)
A tag class representing the (off-)diagonal of a matrix.
base_type::size_type size_type
Represents a generic 'context' similar to an OpenCL context, but is backend-agnostic and thus also su...
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
value_type operator*(void)
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.
matrix(zero_matrix< NumericT > const &m)
Creates the matrix from the supplied zero matrix.
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.)
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.
matrix_base()
The default constructor. Does not allocate any memory.
void matrix_row(const matrix_base< NumericT > &A, unsigned int i, vector_base< NumericT > &v)
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.
void clear()
Resets all entries to zero.
Implementations of operations using sparse matrices.
A tag class representing addition.
Represents a vector consisting of scalars 's' only, i.e. v[i] = s for all i. To be used as an initial...
matrix(const self_type &other)
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.
handle_type & handle()
Returns the OpenCL handle, non-const-version.
matrix(const base_type &other)
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.
vector_expression< const matrix_base< NumericT, F >, const unsigned int, op_row > row(const matrix_base< NumericT, F > &A, unsigned int i)
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.
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.
matrix(matrix_expression< LHS, RHS, OP > const &proxy)
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 &)
matrix(scalar_matrix< NumericT > const &m)
Creates the matrix from the supplied scalar matrix.
void resize(size_type rows, size_type columns, bool preserve=true)
Resizes the matrix. Existing entries can optionally be preserved.
A tag class representing transposed matrices.
Helper implementations that deduce the dimensions of the supplied matrix-valued expressions.
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...
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
MatrixT::value_type value_type
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...
bool operator!=(self_type const &other)
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)
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.
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.
matrix(identity_matrix< NumericT > const &m)
Creates the matrix from the supplied identity matrix.
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...
MatrixT & operator()(void) const
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.
matrix()
The default constructor. Does not allocate any memory.
bool operator==(self_type const &other)
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.
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)