does not include MatrixMaketIterator on win32,

no "using whatever" in global scope in a header file
This commit is contained in:
Gael Guennebaud 2012-03-31 18:01:43 +02:00
parent daaeddd581
commit a060e0b486
2 changed files with 20 additions and 19 deletions

View File

@ -38,9 +38,15 @@ namespace Eigen {
#include "src/SparseExtra/RandomSetter.h"
#include "src/SparseExtra/MarketIO.h"
#include "src/SparseExtra/MatrixMarketIterator.h"
} // namespace Eigen
#if !defined(_WIN32)
#include <dirent.h>
namespace Eigen {
#include "src/SparseExtra/MatrixMarketIterator.h"
}
#endif
#include "../../Eigen/src/Core/util/ReenableStupidWarnings.h"
#endif // EIGEN_SPARSE_EXTRA_MODULE_H

View File

@ -1,4 +1,4 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
@ -25,11 +25,6 @@
#ifndef EIGEN_BROWSE_MATRICES_H
#define EIGEN_BROWSE_MATRICES_H
#include <dirent.h>
#include <unsupported/Eigen/SparseExtra>
using namespace Eigen;
using std::string;
enum {
SPD = 0x100,
NonSymmetric = 0x0
@ -63,7 +58,7 @@ class MatrixMarketIterator
typedef SparseMatrix<Scalar,ColMajor> MatrixType;
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());
if (!m_folder_id){
@ -95,7 +90,7 @@ class MatrixMarketIterator
// Read the matrix
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))
{
m_matIsLoaded = false;
@ -120,7 +115,7 @@ class MatrixMarketIterator
// Get the right hand side
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
m_hasRhs = Fileexists(rhs_file);
if (m_hasRhs)
@ -152,7 +147,7 @@ class MatrixMarketIterator
// Check if a reference solution is provided
if (m_hasrefX) return m_refX;
string lhs_file;
std::string lhs_file;
lhs_file = m_folder + "/" + m_matname + "_x.mtx";
m_hasrefX = Fileexists(lhs_file);
if (m_hasrefX)
@ -163,7 +158,7 @@ class MatrixMarketIterator
return m_refX;
}
inline string& matname() { return m_matname; }
inline std::string& matname() { return m_matname; }
inline int sym() { return m_sym; }
@ -172,7 +167,7 @@ class MatrixMarketIterator
protected:
inline bool Fileexists(string file)
inline bool Fileexists(std::string file)
{
std::ifstream file_id(file.c_str());
if (!file_id.good() )
@ -191,7 +186,7 @@ class MatrixMarketIterator
// Here, we return with the next valid matrix in the folder
while ( (m_curs_id = readdir(m_folder_id)) != NULL) {
m_isvalid = false;
string curfile;
std::string curfile;
curfile = m_folder + "/" + m_curs_id->d_name;
// 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
@ -205,12 +200,12 @@ class MatrixMarketIterator
if(isvector) continue;
// 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);
// Find if the matrix is 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_isvalid = true;
@ -221,15 +216,15 @@ class MatrixMarketIterator
MatrixType m_mat; // Current matrix
VectorType m_rhs; // Current vector
VectorType m_refX; // The reference solution, if exists
string m_matname; // Matrix Name
std::string m_matname; // Matrix Name
bool m_isvalid;
bool m_matIsLoaded; // Determine if the matrix has already been loaded from the file
bool m_hasRhs; // The right hand side exists
bool m_hasrefX; // A reference solution is provided
string m_folder;
std::string m_folder;
DIR * m_folder_id;
struct dirent *m_curs_id;
};
#endif
#endif