Scythe-1.0.3
template<typename T_type = double, matrix_order ORDER = Col, matrix_style STYLE = Concrete>
template<typename ITERATOR , matrix_order O, matrix_style S>
Matrix& scythe::Matrix< T_type, ORDER, STYLE >::operator= ( ListInitializer< T_type, ITERATOR, O, S >  li) [inline]

A special assignment operator.

This assignment operator provides the necessary glue to allow chained assignments of matrices where the last assignment is achieved through list initialization. This allows users to write code like

 Matrix<> A, B, C;
 Matrix<> D(4, 4, false);
 A = B = C = (D = 1, 2, 3, 4);

where the assignment in the parentheses technically returns a ListInitializer object, not a Matrix object. The details of this mechanism are not important for the average user and the distinction can safely be ignored.

Note:
The parentheses in the code above are necessary because of the precedence of the assignment operator.
See also:
operator=(const Matrix&)
operator=(const Matrix<T_type, O, S>&)
operator=(T_type x)

Example:

#include <scythestat/matrix.h>
using namespace scythe;

/* This example shows how to use the various overloaded versions of
 * the Matrix class assignment operator.
 */

int main ()
{
  // Construct a few uninitialized matrices
  Matrix<> A(3, 3, false);
  Matrix<> B(3, 3, false);
  Matrix<> C(5, 5, false);

  // Use operator= (T_type) to fill A with values.
  A = 1, 0, 1, 0, 1, 0, 1, 0, 1;

  // Now, use it in a slightly different way to fill B
  B = 1, 0;

  // Prints true (1)
  std::cout << A.equals(B) << "\n";

  // Concrete matrices resize and disengage their underlying data
  // block when assigned to.
  Matrix<double,Col,View> CC(C);
  C = A; // uses operator=(const Matrix&)

  // Prints true false (10)
  std::cout << A.equals(C) << CC.equals(C) << "\n";

  // When you assign to a view, it copies the elements into its
  // current viewing area.
  Matrix<double,Row,View> AA (A);
  C = 1, 2, 3;
  AA = C; // uses operator=(const Matrix<T_type, O, S>&)

  // Prints true (1)
  std::cout << A.equals(C) << "\n";

  // Now, let's do a submatrix assignment.  This invokes the
  // assignment operator on a view in an indirect fashion.
  A(1,1,2,2) = Matrix<>(2, 2, true, 4); // uses operator=(const Matrix<T_type, O, S>&)

  // This is another indirect view assignment, this time using an
  // initialization list.
  A(0, 0, 1, 1) = 1, 0; // uses operator=(T_type)

  /* Prints:
   * 1.000000 1.000000 1.000000
   * 0.000000 0.000000 4.000000
   * 3.000000 4.000000 4.000000
   */
  std::cout << A << "\n";

  // This code will only work when the compiler flag
  // SCYTHE_VIEW_ASSIGNMENT_RECYCLE is set.  Otherwise it will raise
  // an exception.
  CC = AA; // uses operator=(const Matrix<T_type, O, S>&)

  /* Prints:
   * 1.000000 4.000000 0.000000 1.000000 3.000000
   * 0.000000 1.000000 3.000000 4.000000 1.000000
   * 3.000000 4.000000 1.000000 4.000000 0.000000
   * 1.000000 4.000000 0.000000 1.000000 4.000000
   * 0.000000 1.000000 4.000000 0.000000 1.000000
   */
  std::cout << CC << "\n";

  /* Here's another example of SCYTHE_VIEW_ASSIGNMENT_RECYCLE only
   * code, but it also illustrates chained assignments.  The way the
   * concretes and views interact here is somewhat subtle.
   *
   * The parentheses here are required if you want the list to be
   * processed before the assignments in the chain, because the
   * assignment operator has precedence over the comma operator.
   *
   * We're using operator=(T_type), 
   * operator=(const Matrix<T_type, O, S>&), and 
   * operator=ListInitializer<T_type, ITERATOR, O, S> li here.
   */
  C = AA = B = (CC = 1, 2);

  // Prints "9 25, 9 25"
  std::cout << C.size() << " " << B.size() << ", "
            << AA.size() << " " << CC.size() << "\n";

  return 0;
}