Skip to content

Commit

Permalink
v1.15.1 SMap Do not use BLAS on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
SoftwareLiteracy committed Oct 27, 2023
1 parent 10ad529 commit c41f7f5
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 12 deletions.
Binary file modified doc/cppEDM.pdf
Binary file not shown.
2 changes: 2 additions & 0 deletions src/API.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ DataFrame< double > PredictNonlinear( std::string pathIn = "./data/",
bool verbose = true,
std::vector<bool> validLib =
std::vector<bool>(),
bool ignoreNan = true,
unsigned nThreads = 4 );

DataFrame< double > PredictNonlinear( DataFrame< double > & dataFrameIn,
Expand All @@ -378,5 +379,6 @@ DataFrame< double > PredictNonlinear( DataFrame< double > & dataFrameIn,
bool verbose = true,
std::vector<bool> validLib =
std::vector<bool>(),
bool ignoreNan = true,
unsigned nThreads = 4 );
#endif
15 changes: 11 additions & 4 deletions src/Eval.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ void SMapThread( EDM_Eval::WorkQueue &workQ,
std::string target,
bool embedded,
bool verbose,
std::vector<bool> validLib );
std::vector<bool> validLib,
bool ignoreNan );

//----------------------------------------------------------------
// EmbedDimension() : Evaluate Simplex rho vs. dimension E
Expand Down Expand Up @@ -497,6 +498,7 @@ DataFrame< double > PredictNonlinear( std::string pathIn,
bool embedded,
bool verbose,
std::vector<bool> validLib,
bool ignoreNan,
unsigned nThreads ) {

// Create DataFrame (constructor loads data)
Expand All @@ -518,6 +520,7 @@ DataFrame< double > PredictNonlinear( std::string pathIn,
embedded,
verbose,
validLib,
ignoreNan,
nThreads );
return Theta_rho;
}
Expand All @@ -542,6 +545,7 @@ DataFrame< double > PredictNonlinear( DataFrame< double > & data,
bool embedded,
bool verbose,
std::vector<bool> validLib,
bool ignoreNan,
unsigned nThreads ) {

std::vector<double> ThetaValues( { 0.01, 0.1, 0.3, 0.5, 0.75, 1,
Expand Down Expand Up @@ -600,7 +604,8 @@ DataFrame< double > PredictNonlinear( DataFrame< double > & data,
target,
embedded,
verbose,
validLib ) );
validLib,
ignoreNan ) );
}

// join threads
Expand Down Expand Up @@ -647,7 +652,8 @@ void SMapThread( EDM_Eval::WorkQueue &workQ,
std::string target,
bool embedded,
bool verbose,
std::vector<bool> validLib )
std::vector<bool> validLib,
bool ignoreNan )
{
std::size_t i =
std::atomic_fetch_add( &EDM_Eval::smap_count_i, std::size_t(1) );
Expand Down Expand Up @@ -679,7 +685,8 @@ void SMapThread( EDM_Eval::WorkQueue &workQ,
embedded,
false, // const_predict
verbose,
validLib );
validLib,
ignoreNan );

DataFrame< double > predictions = S.predictions;
DataFrame< double > coefficients = S.coefficients;
Expand Down
7 changes: 4 additions & 3 deletions src/Parameter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Parameters::Parameters(
validated ( false ),

// Instantiate Version
version( 1, 15, 0, "2023-10-21" )
version( 1, 15, 1, "2023-10-27" )
{
// Constructor code
if ( method != Method::None ) {
Expand Down Expand Up @@ -184,14 +184,15 @@ void Parameters::Validate() {
if ( randomLib ) {
if ( subSamples < 1 ) {
std::string errMsg( "Parameters::Validate(): "
"CCM samples must be > 0.\n" );
"CCM sample must be > 0.\n" );
throw std::runtime_error( errMsg );
}
}

// CCM librarySizes
if ( not libSizes_str.size() ) {
std::string errMsg( "Parameters::Validate(): CCM libSize empty.\n" );
std::string errMsg( "Parameters::Validate(): "
"CCM libSizes empty.\n" );
throw std::runtime_error( errMsg );
}

Expand Down
30 changes: 25 additions & 5 deletions src/SMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,11 @@ void SMapClass::WriteOutput () {
}
}

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// Do not use LAPACK on Windog: use scikit-learn LinearRegression
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#if !defined _WIN32 || defined USING_R

//----------------------------------------------------------------
// Singular Value Decomposition : wrapper for Lapack_SVD()
//----------------------------------------------------------------
Expand All @@ -504,11 +509,11 @@ SVDValues SVD( DataFrame < double > A,

double *b = &( B[0] );

SVDValues SVD_ = Lapack_SVD( A.NRows(), // number of rows
A.NColumns(), // number of columns
a, // A
b, // b
1.E-9 ); // rcond
SVDValues SVD_ = Lapack_SVD( A.NRows(), // number of rows
A.NColumns(), // number of columns
a, // A
b, // b
1.E-9 ); // rcond

#ifdef DEBUG_ALL
std::cout << "SVD------------------------\n";
Expand Down Expand Up @@ -657,3 +662,18 @@ SVDValues Lapack_SVD( int m, // rows in matrix

return SVD_;
}
#else
//-----------------------------------------------------------------
// Singular Value Decomposition : SVD() dummy function: Replaced by
// scikit-learn LinearRegression on Windog. LAPACK is not feasible.
//-----------------------------------------------------------------
SVDValues SVD( DataFrame < double > A,
std::valarray< double > B ) {
if ( A.NRows() == B.size() ) {} // Avoid compiler unused warn
SVDValues SVD_;
return SVD_;
}
#endif
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// Do not use LAPACK on Windog: use scikit-learn LinearRegression
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
5 changes: 5 additions & 0 deletions src/SMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@ using Solver = SVDValues (*) ( DataFrame < double >,
// Prototype declaration of general functions
SVDValues SVD( DataFrame < double > A, std::valarray< double > B );

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// Do not use LAPACK on Windog: use scikit-learn LinearRegression
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#if !defined _WIN32 || defined USING_R
SVDValues Lapack_SVD( int m, // number of rows in matrix
int n, // number of columns in matrix
double *a, // pointer to top-left corner
double *b,
double rcond );
#endif

//----------------------------------------------------------------
// SMap class inherits from EDM class and defines
Expand Down

0 comments on commit c41f7f5

Please sign in to comment.