mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
34 lines
637 B
C++
34 lines
637 B
C++
|
|
/*
|
||
|
|
* $Id: alias.cc,v 1.1 2004/03/26 07:56:32 opetzold Exp $
|
||
|
|
*
|
||
|
|
* This example shows the solution of the problem with aliasing
|
||
|
|
* mentioned at
|
||
|
|
* http://tvmet.sourceforge.net/notes.html#alias
|
||
|
|
*/
|
||
|
|
|
||
|
|
#include <iostream>
|
||
|
|
#include <algorithm>
|
||
|
|
#include <tvmet/Matrix.h>
|
||
|
|
#include <tvmet/Vector.h>
|
||
|
|
#include <tvmet/util/Incrementor.h>
|
||
|
|
|
||
|
|
using namespace std;
|
||
|
|
|
||
|
|
|
||
|
|
int main()
|
||
|
|
{
|
||
|
|
typedef tvmet::Matrix<double, 3, 3> matrix_type;
|
||
|
|
|
||
|
|
matrix_type M;
|
||
|
|
|
||
|
|
std::generate(M.begin(), M.end(),
|
||
|
|
tvmet::util::Incrementor<matrix_type::value_type>());
|
||
|
|
|
||
|
|
std::cout << "M = " << M << std::endl;
|
||
|
|
|
||
|
|
alias(M) = M * trans(M);
|
||
|
|
|
||
|
|
std::cout << M << std::endl;
|
||
|
|
|
||
|
|
}
|