Commit b1ef9db2 authored by Olivier Stasse's avatar Olivier Stasse
Browse files

Detect Xenial and compile accordingly.

parent a84c557b
Subproject commit fa2738146fa19d8bbbb1d8c8a97a2b4809ce81af
Subproject commit 8474524906099169b05f5c2d0523519d8e383df1
#ifndef __SOTH_SUB_MATRIX_H__
#define __SOTH_SUB_MATRIX_H__
#if EIGEN_VERSION_AT_LEAST(3,2,92)
#define XENIAL_DETECTED 1
#endif
/*DEBUG*/#include <iostream>
......@@ -29,12 +32,21 @@ namespace Eigen
struct traits<SubMatrix<MatrixType, PermutationType, IsSub> >
: traits<MatrixType>
{
#ifndef XENIAL_DETECTED
typedef typename nested<MatrixType>::type MatrixTypeNested;
typedef typename remove_reference<MatrixTypeNested>::type _MatrixTypeNested;
#endif
typedef typename MatrixType::StorageKind StorageKind;
enum {
RowsAtCompileTime = (PermutationType==ColPermutation) ? (MatrixType::RowsAtCompileTime) : Dynamic,
ColsAtCompileTime = (PermutationType==RowPermutation) ? (MatrixType::ColsAtCompileTime) : Dynamic,
MaxRowsAtCompileTime = (IsSub ? MatrixType::MaxRowsAtCompileTime : Dynamic),
MaxColsAtCompileTime = (IsSub ? MatrixType::MaxColsAtCompileTime : Dynamic),
#ifndef XENIAL_DETECTED
Flags = (_MatrixTypeNested::Flags & HereditaryBits) | ei_compute_lvalue_bit<_MatrixTypeNested>::ret,
CoeffReadCost = _MatrixTypeNested::CoeffReadCost //Todo : check that
};
#else
VectorAtCompileTime = (RowsAtCompileTime == 1) || (ColsAtCompileTime == 1),
Flags = (
(MatrixType::Flags & HereditaryBits) | ei_compute_lvalue_bit<MatrixType>::ret
......@@ -85,7 +97,7 @@ namespace Eigen
// evaluator<MatrixTypeNestedCleaned> m_argImpl;
const XprType& m_argImpl;
#endif
};
}
......@@ -683,7 +695,11 @@ namespace Eigen
struct traits< StackMatrix<MatrixType1,MatrixType2> >
: traits<MatrixType1>
{
#ifndef XENIAL_DETECTED
typedef typename nested<MatrixType1>::type MatrixTypeNested;
#else
typedef typename MatrixType1::Nested MatrixTypeNested;
#endif
typedef typename remove_reference<MatrixTypeNested>::type _MatrixTypeNested;
typedef typename MatrixType1::StorageKind StorageKind;
enum {
......@@ -692,7 +708,11 @@ namespace Eigen
MaxRowsAtCompileTime = MatrixType1::MaxRowsAtCompileTime,
MaxColsAtCompileTime = MatrixType1::MaxColsAtCompileTime,
Flags = (_MatrixTypeNested::Flags & HereditaryBits) | ei_compute_lvalue_bit<_MatrixTypeNested>::ret,
#ifndef XENIAL_DETECTED
CoeffReadCost = _MatrixTypeNested::CoeffReadCost //Todo : check that
#else
CoeffReadCost = evaluator<_MatrixTypeNested>::CoeffReadCost //Todo : check that
#endif
};
};
}
......@@ -746,11 +766,16 @@ namespace Eigen
if( index<r1 ) return m1(index); else return m2(index-r1);
}
#ifndef XENIAL_DETECTED
protected:
#endif
Base1& m1;
Base2& m2;
};
#ifdef XENIAL_DETECTED
namespace internal
{
template<typename MatrixType1,typename MatrixType2>
......@@ -801,7 +826,7 @@ namespace Eigen
Base2& m2;
};
}
#endif
} // namespace soth
#endif // __SOTH_SUB_MATRIX_H__
......
......@@ -129,7 +129,11 @@ namespace soth
MatrixXd::ColsBlockXpr matrixVr() { return V.leftCols(rank); }
MatrixXd::ColsBlockXpr matrixUo() { return U.rightCols(NR-rank); }
MatrixXd::ColsBlockXpr matrixVo() { return V.rightCols(NC-rank); }
#ifndef XENIAL_DETECTED
TriangularView<Block<MatrixXd>,Lower> matrixL() { return L.topRows(rank); }
#else
TriangularView<Block<MatrixXd>,Lower> matrixL() { return L.topRows(rank).triangularView<Lower>(); }
#endif
/* Solve min||Ax-b|| for a matrix A whose rank is given. */
VectorXd solve( const VectorXd& b , bool inY=false)
......
......@@ -11,6 +11,10 @@
#include "soth/Random.hpp"
#include <fstream>
#if EIGEN_VERSION_AT_LEAST(3,2,92)
#define XENIAL_DETECTED 1
#endif
#ifdef WIN32
inline double round( double d )
{ return floor( d + 0.5 ); }
......@@ -499,9 +503,13 @@ namespace soth
sotDEBUG(15) << "Mi: "<< rowDistrib.sum() << " " <<(MATLAB)rowDistrib << std::endl;
sotDEBUG(15) << "Ri: "<< rankDistrib.sum() << " " << (MATLAB)rankDistrib << std::endl;
#ifndef XENIAL_DETECTED
rankDistrib = rankDistrib.unaryExpr(&round);
rowDistrib = rowDistrib.unaryExpr(&round);
#else
rankDistrib = rankDistrib.unaryExpr(std::ptr_fun<double,double>(round));
rowDistrib = rowDistrib.unaryExpr(std::ptr_fun<double,double>(round));
#endif
VectorXd selfdefDistrib(nbStage); soth::MatrixRnd::randomize( selfdefDistrib,0,1 );
double vsd = selfdefDistrib.cwiseProduct(rowDistrib-rankDistrib).sum();
sotDEBUG(20) << "vsd = " << vsd << " / " << TOTALSELFDEF << std::endl;
......@@ -520,8 +528,11 @@ namespace soth
sotDEBUG(25) << selfdefDistrib.sum() << " " << (MATLAB)selfdefDistrib << std::endl;
sotDEBUG(15) << "Si: "<< selfdefDistrib.sum() << " " << (MATLAB)selfdefDistrib << std::endl;
#ifndef XENIAL_DETECTED
selfdefDistrib = selfdefDistrib.unaryExpr(&round);
#else
selfdefDistrib = selfdefDistrib.unaryExpr(std::ptr_fun<double,double>(round));
#endif
sotDEBUG(5) << "Mi: "<< rowDistrib.sum() << " " <<(MATLAB)rowDistrib << std::endl;
sotDEBUG(5) << "Ri: "<< rankDistrib.sum() << " " << (MATLAB)rankDistrib << std::endl;
sotDEBUG(5) << "Si: "<< selfdefDistrib.sum() << " " << (MATLAB)selfdefDistrib << std::endl;
......
......@@ -281,10 +281,18 @@ void testStack()
/* --- */
typedef SubMatrix<MatrixXi,RowPermutation> SubMatrixXi;
#ifndef XENIAL_DETECTED
Matrix<SubMatrixXi::Index,Dynamic,1> row1(3); row1 << 2,3,0;
#else
Matrix<MatrixXi::Index,Dynamic,1> row1(3); row1 << 2,3,0;
#endif
SubMatrixXi m1i( m1,row1 );
std::cout << "m1i = " << m1i << std::endl;
#ifndef XENIAL_DETECTED
Matrix<SubMatrixXi::Index,Dynamic,1> row2(1); row2 << 0;
#else
Matrix<MatrixXi::Index,Dynamic,1> row2(1); row2 << 0;
#endif
SubMatrixXi m2i( m2,row2 );
std::cout << "m2i = " << m2i << std::endl;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment