mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-08 09:49:03 +08:00
does not include MatrixMaketIterator on win32,
no "using whatever" in global scope in a header file
This commit is contained in:
parent
daaeddd581
commit
a060e0b486
@ -38,9 +38,15 @@ namespace Eigen {
|
|||||||
#include "src/SparseExtra/RandomSetter.h"
|
#include "src/SparseExtra/RandomSetter.h"
|
||||||
|
|
||||||
#include "src/SparseExtra/MarketIO.h"
|
#include "src/SparseExtra/MarketIO.h"
|
||||||
#include "src/SparseExtra/MatrixMarketIterator.h"
|
|
||||||
} // namespace Eigen
|
} // namespace Eigen
|
||||||
|
|
||||||
|
#if !defined(_WIN32)
|
||||||
|
#include <dirent.h>
|
||||||
|
namespace Eigen {
|
||||||
|
#include "src/SparseExtra/MatrixMarketIterator.h"
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../../Eigen/src/Core/util/ReenableStupidWarnings.h"
|
#include "../../Eigen/src/Core/util/ReenableStupidWarnings.h"
|
||||||
|
|
||||||
#endif // EIGEN_SPARSE_EXTRA_MODULE_H
|
#endif // EIGEN_SPARSE_EXTRA_MODULE_H
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
|
|
||||||
// This file is part of Eigen, a lightweight C++ template library
|
// This file is part of Eigen, a lightweight C++ template library
|
||||||
// for linear algebra.
|
// for linear algebra.
|
||||||
//
|
//
|
||||||
@ -25,11 +25,6 @@
|
|||||||
#ifndef EIGEN_BROWSE_MATRICES_H
|
#ifndef EIGEN_BROWSE_MATRICES_H
|
||||||
#define EIGEN_BROWSE_MATRICES_H
|
#define EIGEN_BROWSE_MATRICES_H
|
||||||
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <unsupported/Eigen/SparseExtra>
|
|
||||||
using namespace Eigen;
|
|
||||||
using std::string;
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
SPD = 0x100,
|
SPD = 0x100,
|
||||||
NonSymmetric = 0x0
|
NonSymmetric = 0x0
|
||||||
@ -63,7 +58,7 @@ class MatrixMarketIterator
|
|||||||
typedef SparseMatrix<Scalar,ColMajor> MatrixType;
|
typedef SparseMatrix<Scalar,ColMajor> MatrixType;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MatrixMarketIterator(const string folder):m_sym(0),m_isvalid(false),m_matIsLoaded(false),m_hasRhs(false),m_hasrefX(false),m_folder(folder)
|
MatrixMarketIterator(const std::string folder):m_sym(0),m_isvalid(false),m_matIsLoaded(false),m_hasRhs(false),m_hasrefX(false),m_folder(folder)
|
||||||
{
|
{
|
||||||
m_folder_id = opendir(folder.c_str());
|
m_folder_id = opendir(folder.c_str());
|
||||||
if (!m_folder_id){
|
if (!m_folder_id){
|
||||||
@ -95,7 +90,7 @@ class MatrixMarketIterator
|
|||||||
// Read the matrix
|
// Read the matrix
|
||||||
if (m_matIsLoaded) return m_mat;
|
if (m_matIsLoaded) return m_mat;
|
||||||
|
|
||||||
string matrix_file = m_folder + "/" + m_matname + ".mtx";
|
std::string matrix_file = m_folder + "/" + m_matname + ".mtx";
|
||||||
if ( !loadMarket(m_mat, matrix_file))
|
if ( !loadMarket(m_mat, matrix_file))
|
||||||
{
|
{
|
||||||
m_matIsLoaded = false;
|
m_matIsLoaded = false;
|
||||||
@ -120,7 +115,7 @@ class MatrixMarketIterator
|
|||||||
// Get the right hand side
|
// Get the right hand side
|
||||||
if (m_hasRhs) return m_rhs;
|
if (m_hasRhs) return m_rhs;
|
||||||
|
|
||||||
string rhs_file;
|
std::string rhs_file;
|
||||||
rhs_file = m_folder + "/" + m_matname + "_b.mtx"; // The pattern is matname_b.mtx
|
rhs_file = m_folder + "/" + m_matname + "_b.mtx"; // The pattern is matname_b.mtx
|
||||||
m_hasRhs = Fileexists(rhs_file);
|
m_hasRhs = Fileexists(rhs_file);
|
||||||
if (m_hasRhs)
|
if (m_hasRhs)
|
||||||
@ -152,7 +147,7 @@ class MatrixMarketIterator
|
|||||||
// Check if a reference solution is provided
|
// Check if a reference solution is provided
|
||||||
if (m_hasrefX) return m_refX;
|
if (m_hasrefX) return m_refX;
|
||||||
|
|
||||||
string lhs_file;
|
std::string lhs_file;
|
||||||
lhs_file = m_folder + "/" + m_matname + "_x.mtx";
|
lhs_file = m_folder + "/" + m_matname + "_x.mtx";
|
||||||
m_hasrefX = Fileexists(lhs_file);
|
m_hasrefX = Fileexists(lhs_file);
|
||||||
if (m_hasrefX)
|
if (m_hasrefX)
|
||||||
@ -163,7 +158,7 @@ class MatrixMarketIterator
|
|||||||
return m_refX;
|
return m_refX;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline string& matname() { return m_matname; }
|
inline std::string& matname() { return m_matname; }
|
||||||
|
|
||||||
inline int sym() { return m_sym; }
|
inline int sym() { return m_sym; }
|
||||||
|
|
||||||
@ -172,7 +167,7 @@ class MatrixMarketIterator
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
inline bool Fileexists(string file)
|
inline bool Fileexists(std::string file)
|
||||||
{
|
{
|
||||||
std::ifstream file_id(file.c_str());
|
std::ifstream file_id(file.c_str());
|
||||||
if (!file_id.good() )
|
if (!file_id.good() )
|
||||||
@ -191,7 +186,7 @@ class MatrixMarketIterator
|
|||||||
// Here, we return with the next valid matrix in the folder
|
// Here, we return with the next valid matrix in the folder
|
||||||
while ( (m_curs_id = readdir(m_folder_id)) != NULL) {
|
while ( (m_curs_id = readdir(m_folder_id)) != NULL) {
|
||||||
m_isvalid = false;
|
m_isvalid = false;
|
||||||
string curfile;
|
std::string curfile;
|
||||||
curfile = m_folder + "/" + m_curs_id->d_name;
|
curfile = m_folder + "/" + m_curs_id->d_name;
|
||||||
// Discard if it is a folder
|
// Discard if it is a folder
|
||||||
if (m_curs_id->d_type == DT_DIR) continue; //FIXME This may not be available on non BSD systems
|
if (m_curs_id->d_type == DT_DIR) continue; //FIXME This may not be available on non BSD systems
|
||||||
@ -205,12 +200,12 @@ class MatrixMarketIterator
|
|||||||
if(isvector) continue;
|
if(isvector) continue;
|
||||||
|
|
||||||
// Get the matrix name
|
// Get the matrix name
|
||||||
string filename = m_curs_id->d_name;
|
std::string filename = m_curs_id->d_name;
|
||||||
m_matname = filename.substr(0, filename.length()-4);
|
m_matname = filename.substr(0, filename.length()-4);
|
||||||
|
|
||||||
// Find if the matrix is SPD
|
// Find if the matrix is SPD
|
||||||
size_t found = m_matname.find("SPD");
|
size_t found = m_matname.find("SPD");
|
||||||
if( (found!=string::npos) && (m_sym == Symmetric) )
|
if( (found!=std::string::npos) && (m_sym == Symmetric) )
|
||||||
m_sym = SPD;
|
m_sym = SPD;
|
||||||
|
|
||||||
m_isvalid = true;
|
m_isvalid = true;
|
||||||
@ -221,15 +216,15 @@ class MatrixMarketIterator
|
|||||||
MatrixType m_mat; // Current matrix
|
MatrixType m_mat; // Current matrix
|
||||||
VectorType m_rhs; // Current vector
|
VectorType m_rhs; // Current vector
|
||||||
VectorType m_refX; // The reference solution, if exists
|
VectorType m_refX; // The reference solution, if exists
|
||||||
string m_matname; // Matrix Name
|
std::string m_matname; // Matrix Name
|
||||||
bool m_isvalid;
|
bool m_isvalid;
|
||||||
bool m_matIsLoaded; // Determine if the matrix has already been loaded from the file
|
bool m_matIsLoaded; // Determine if the matrix has already been loaded from the file
|
||||||
bool m_hasRhs; // The right hand side exists
|
bool m_hasRhs; // The right hand side exists
|
||||||
bool m_hasrefX; // A reference solution is provided
|
bool m_hasrefX; // A reference solution is provided
|
||||||
string m_folder;
|
std::string m_folder;
|
||||||
DIR * m_folder_id;
|
DIR * m_folder_id;
|
||||||
struct dirent *m_curs_id;
|
struct dirent *m_curs_id;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user