mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-09 21:50:45 +01:00
ReadBinary needs to do case insensitive name comparison (since I changed the default case of perambulator column names)
This commit is contained in:
parent
eb737daeb5
commit
9ff459816f
@ -268,6 +268,25 @@ using Default_Writer = Grid::BinaryWriter;
|
|||||||
static const char * FileExtension = ".dat";
|
static const char * FileExtension = ".dat";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
Case insensitive compare of two strings
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
bool CompareCaseInsensitive( const std::string &s1, const std::string &s2 ) {
|
||||||
|
auto Len = s1.size();
|
||||||
|
bool bSame{ Len == s2.size() };
|
||||||
|
for( int j = 0; bSame && j < Len; j++ ) {
|
||||||
|
wchar_t c1 = s1[j];
|
||||||
|
if( c1 >= 'a' && c1 <= 'z' )
|
||||||
|
c1 -= 'a' - 'A';
|
||||||
|
wchar_t c2 = s2[j];
|
||||||
|
if( c2 >= 'a' && c1 <= 'z' )
|
||||||
|
c2 -= 'a' - 'A';
|
||||||
|
bSame = ( c1 == c2 );
|
||||||
|
}
|
||||||
|
return bSame;
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
NamedTensor object
|
NamedTensor object
|
||||||
This is an Eigen::Tensor of type Scalar_ and rank NumIndices_ (row-major order)
|
This is an Eigen::Tensor of type Scalar_ and rank NumIndices_ (row-major order)
|
||||||
@ -299,7 +318,7 @@ public:
|
|||||||
);
|
);
|
||||||
public:
|
public:
|
||||||
// Named tensors are intended to be a superset of Eigen tensor
|
// Named tensors are intended to be a superset of Eigen tensor
|
||||||
inline operator ET&() const { return tensor; }
|
inline operator ET&() { return tensor; }
|
||||||
template<typename... IndexTypes>
|
template<typename... IndexTypes>
|
||||||
inline const Scalar_& operator()(const std::array<Eigen::Index, NumIndices_> &Indices) const
|
inline const Scalar_& operator()(const std::array<Eigen::Index, NumIndices_> &Indices) const
|
||||||
{ return tensor.operator()(Indices); }
|
{ return tensor.operator()(Indices); }
|
||||||
@ -506,7 +525,7 @@ void NamedTensor<Scalar_, NumIndices_, Endian_Scalar_Size>::ReadBinary(const std
|
|||||||
std::string s( l, '?' );
|
std::string s( l, '?' );
|
||||||
r.read(&s[0], l);
|
r.read(&s[0], l);
|
||||||
// skip forward to matching name
|
// skip forward to matching name
|
||||||
while( IndexNames[d].size() > 0 && s != IndexNames[d] )
|
while( IndexNames[d].size() > 0 && !CompareCaseInsensitive( s, IndexNames[d] ) )
|
||||||
assert(++d < NumIndices && "NamedTensor error: dimension name" );
|
assert(++d < NumIndices && "NamedTensor error: dimension name" );
|
||||||
if( IndexNames[d].size() == 0 )
|
if( IndexNames[d].size() == 0 )
|
||||||
IndexNames[d] = s;
|
IndexNames[d] = s;
|
||||||
@ -588,21 +607,8 @@ void NamedTensor<Scalar_, NumIndices_, Endian_Scalar_Size>::write(const char * f
|
|||||||
template<typename Scalar_, int NumIndices_, uint16_t Endian_Scalar_Size>
|
template<typename Scalar_, int NumIndices_, uint16_t Endian_Scalar_Size>
|
||||||
bool NamedTensor<Scalar_, NumIndices_, Endian_Scalar_Size>::ValidateIndexNames( int iNumNames, const std::string * MatchNames ) const {
|
bool NamedTensor<Scalar_, NumIndices_, Endian_Scalar_Size>::ValidateIndexNames( int iNumNames, const std::string * MatchNames ) const {
|
||||||
bool bSame{ iNumNames == NumIndices_ && IndexNames.size() == NumIndices_ };
|
bool bSame{ iNumNames == NumIndices_ && IndexNames.size() == NumIndices_ };
|
||||||
for( int i = 0; bSame && i < NumIndices_; i++ ) {
|
for( int i = 0; bSame && i < NumIndices_; i++ )
|
||||||
// Case insensitive name compare
|
bSame = CompareCaseInsensitive( MatchNames[i], IndexNames[i] );
|
||||||
const int iMatchLen{ static_cast<int>( MatchNames[i].size() ) };
|
|
||||||
const int iNewLen { static_cast<int>( IndexNames[i].size() ) };
|
|
||||||
bSame = ( iMatchLen == iNewLen );
|
|
||||||
for( int j = 0; bSame && j < iMatchLen; j++ ) {
|
|
||||||
wchar_t c1 = MatchNames[i][j];
|
|
||||||
if( c1 >= 'a' && c1 <= 'z' )
|
|
||||||
c1 -= 'a' - 'A';
|
|
||||||
wchar_t c2 = IndexNames[i][j];
|
|
||||||
if( c2 >= 'a' && c1 <= 'z' )
|
|
||||||
c2 -= 'a' - 'A';
|
|
||||||
bSame = ( c1 == c2 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return bSame;
|
return bSame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,7 +298,7 @@ The easiest way to link to all required libraries is to obtain a list of all lib
|
|||||||
|
|
||||||
and pasting the output ***with `-lGrid -lHadrons ` prepended*** (including the `-l` switches) directly into `OTHER_LDFLAGS`, e.g.:
|
and pasting the output ***with `-lGrid -lHadrons ` prepended*** (including the `-l` switches) directly into `OTHER_LDFLAGS`, e.g.:
|
||||||
|
|
||||||
-lGrid -lHadrons -lmpi -lhdf5_cpp -lz -lcrypto -llime -lfftw3f -lfftw3 -lmpfr -lgmp -lstdc++ -lm -lz -lhdf5
|
-lGrid -lHadrons -lmpi -lhdf5_cpp -lhdf5 -lz -lcrypto -llime -lfftw3f -lfftw3 -lmpfr -lgmp -lm
|
||||||
|
|
||||||
## Make additional configurations
|
## Make additional configurations
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user