57 #include <Eigen/SparseCore>
58 #include <Eigen/Eigen>
67 #include <QStringList>
85 using namespace Eigen;
127 static VectorXd* combine_xyz(
const VectorXd& vec);
143 static double getConditionNumber(
const MatrixXd& A, VectorXd &s);
153 static double getConditionSlope(
const MatrixXd& A, VectorXd &s);
164 static void get_whitener(MatrixXd& A,
bool pca, QString ch_type, VectorXd& eig, MatrixXd& eigvec);
177 static VectorXi intersect(
const VectorXi &v1,
const VectorXi &v2, VectorXi &idx_sel);
188 static bool issparse(VectorXd &v);
201 static MatrixXd legendre(qint32 n,
const VectorXd &X, QString normalize = QString(
"unnorm"));
220 static SparseMatrix<double>* make_block_diag(
const MatrixXd &A, qint32 n);
229 static int nchoose2(
int n);
242 static qint32 rank(
const MatrixXd& A,
double tol = 1e-8);
262 static MatrixXd rescale(
const MatrixXd &data,
const RowVectorXf ×, QPair<QVariant,QVariant> baseline, QString mode);
274 static VectorXi sort(Matrix<T, Dynamic, 1> &v,
bool desc =
true);
288 static VectorXi sort(Matrix<T, Dynamic, 1> &v_prime, Matrix<T, Dynamic, Dynamic> &mat,
bool desc =
true);
300 static std::vector<Triplet<T> > sortrows(
const std::vector<Triplet<T> > &A, qint32 column = 0);
312 static inline bool compareIdxValuePairBiggerThan(
const std::pair<int,T>& lhs,
const std::pair<int,T>& rhs);
324 static inline bool compareIdxValuePairSmallerThan(
const std::pair<int,T>& lhs,
const std::pair<int,T>& rhs);
336 static inline bool compareTripletFirstEntry(
const Triplet<T>& lhs,
const Triplet<T> & rhs);
348 static inline bool compareTripletSecondEntry(
const Triplet<T>& lhs,
const Triplet<T> & rhs);
359 static inline double log2(
const T d);
367 template<
typename T>
370 std::vector< std::pair<int,T> > t_vecIdxValue;
371 VectorXi idx(v.size());
376 for(qint32 i = 0; i < v.size(); ++i)
377 t_vecIdxValue.push_back(std::pair<int,T>(i, v[i]));
381 std::sort(t_vecIdxValue.begin(), t_vecIdxValue.end(), MNEMath::compareIdxValuePairBiggerThan<T>);
383 std::sort(t_vecIdxValue.begin(), t_vecIdxValue.end(), MNEMath::compareIdxValuePairSmallerThan<T>);
386 for(qint32 i = 0; i < v.size(); ++i)
388 idx[i] = t_vecIdxValue[i].first;
389 v[i] = t_vecIdxValue[i].second;
400 VectorXi
MNEMath::sort(Matrix<T, Dynamic, 1> &v_prime, Matrix<T, Dynamic, Dynamic> &mat,
bool desc)
402 VectorXi idx = MNEMath::sort<T>(v_prime, desc);
404 if(v_prime.size() > 0)
407 Matrix<T, Dynamic, Dynamic> newMat(mat.rows(), mat.cols());
408 for(qint32 i = 0; i < idx.size(); ++i)
409 newMat.col(i) = mat.col(idx[i]);
422 std::vector<Triplet<T> > p_ASorted;
424 for(quint32 i = 0; i < A.size(); ++i)
425 p_ASorted.push_back(A[i]);
428 std::sort(p_ASorted.begin(), p_ASorted.end(), MNEMath::compareTripletFirstEntry<T>);
430 std::sort(p_ASorted.begin(), p_ASorted.end(), MNEMath::compareTripletSecondEntry<T>);
441 return lhs.second > rhs.second;
450 return lhs.second < rhs.second;
459 return lhs.row() < rhs.row();
468 return lhs.col() < rhs.col();
477 return log(d)/log(2);
static bool compareTripletSecondEntry(const Triplet< T > &lhs, const Triplet< T > &rhs)
#define UTILSSHARED_EXPORT
static bool compareIdxValuePairBiggerThan(const std::pair< int, T > &lhs, const std::pair< int, T > &rhs)
utils library export/import macros.
static VectorXi sort(Matrix< T, Dynamic, 1 > &v, bool desc=true)
static bool compareTripletFirstEntry(const Triplet< T > &lhs, const Triplet< T > &rhs)
static std::vector< Triplet< T > > sortrows(const std::vector< Triplet< T > > &A, qint32 column=0)
static bool compareIdxValuePairSmallerThan(const std::pair< int, T > &lhs, const std::pair< int, T > &rhs)
std::pair< int, int > IdxIntValue
static double log2(const T d)