mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
merge with default Eigen
This commit is contained in:
@@ -6,4 +6,4 @@ int main()
|
||||
{
|
||||
Array4d v(0.5,10,0,-1);
|
||||
std::cout << v.lgamma() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,5 +11,5 @@ int main()
|
||||
VectorXf b = VectorXf::Random(3);
|
||||
cout << "Here is the right hand side b:\n" << b << endl;
|
||||
cout << "The least-squares solution is:\n"
|
||||
<< A.jacobiSvd(ComputeThinU | ComputeThinV).solve(b) << endl;
|
||||
<< A.bdcSvd(ComputeThinU | ComputeThinV).solve(b) << endl;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ int main()
|
||||
MatrixXi m(size,size+1); // a (size)x(size+1)-matrix of int's
|
||||
for (int j=0; j<m.cols(); ++j) // loop over columns
|
||||
for (int i=0; i<m.rows(); ++i) // loop over rows
|
||||
m(i,j) = i+j*m.rows(); // to access matrix coefficients,
|
||||
m(i,j) = i+j*size; // to access matrix coefficients,
|
||||
// use operator()(int,int)
|
||||
std::cout << m << "\n\n";
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ namespace internal {
|
||||
// This method should implement "dst += alpha * lhs * rhs" inplace,
|
||||
// however, for iterative solvers, alpha is always equal to 1, so let's not bother about it.
|
||||
assert(alpha==Scalar(1) && "scaling is not implemented");
|
||||
EIGEN_ONLY_USED_FOR_DEBUG(alpha);
|
||||
|
||||
// Here we could simply call dst.noalias() += lhs.my_matrix() * rhs,
|
||||
// but let's do something fancier (and less efficient):
|
||||
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
// [function]
|
||||
template <class ArgType, class RowIndexType, class ColIndexType>
|
||||
CwiseNullaryOp<indexing_functor<ArgType,RowIndexType,ColIndexType>, typename indexing_functor<ArgType,RowIndexType,ColIndexType>::MatrixType>
|
||||
indexing(const Eigen::MatrixBase<ArgType>& arg, const RowIndexType& row_indices, const ColIndexType& col_indices)
|
||||
mat_indexing(const Eigen::MatrixBase<ArgType>& arg, const RowIndexType& row_indices, const ColIndexType& col_indices)
|
||||
{
|
||||
typedef indexing_functor<ArgType,RowIndexType,ColIndexType> Func;
|
||||
typedef typename Func::MatrixType MatrixType;
|
||||
@@ -45,7 +45,7 @@ int main()
|
||||
Eigen::MatrixXi A = Eigen::MatrixXi::Random(4,4);
|
||||
Array3i ri(1,2,1);
|
||||
ArrayXi ci(6); ci << 3,2,1,0,0,2;
|
||||
Eigen::MatrixXi B = indexing(A, ri, ci);
|
||||
Eigen::MatrixXi B = mat_indexing(A, ri, ci);
|
||||
std::cout << "A =" << std::endl;
|
||||
std::cout << A << std::endl << std::endl;
|
||||
std::cout << "A([" << ri.transpose() << "], [" << ci.transpose() << "]) =" << std::endl;
|
||||
@@ -53,11 +53,11 @@ int main()
|
||||
std::cout << "[main1]\n";
|
||||
|
||||
std::cout << "[main2]\n";
|
||||
B = indexing(A, ri+1, ci);
|
||||
B = mat_indexing(A, ri+1, ci);
|
||||
std::cout << "A(ri+1,ci) =" << std::endl;
|
||||
std::cout << B << std::endl << std::endl;
|
||||
#if __cplusplus >= 201103L
|
||||
B = indexing(A, ArrayXi::LinSpaced(13,0,12).unaryExpr([](int x){return x%4;}), ArrayXi::LinSpaced(4,0,3));
|
||||
B = mat_indexing(A, ArrayXi::LinSpaced(13,0,12).unaryExpr([](int x){return x%4;}), ArrayXi::LinSpaced(4,0,3));
|
||||
std::cout << "A(ArrayXi::LinSpaced(13,0,12).unaryExpr([](int x){return x%4;}), ArrayXi::LinSpaced(4,0,3)) =" << std::endl;
|
||||
std::cout << B << std::endl << std::endl;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user