The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.
Become a Premium Member and unlock a new, free course in leading technologies each month.
vector<boost::thread *> *workerThreads = new vector<boost::thread *>;
workerThreads->clear( );
for( int i=0; i < numberOfCores; i++ )
{
workerThread = new boost::thread( &Anova::monteCarlo, anovas->at( i ) );
workerThreads->push_back( workerThread );
}
for( int i=0; i < numberOfCores; i++ )
workerThreads->at( i )->join( );
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
void LinAlg::pseudoInverse( double* A, double* Apinv, integer rowsA, integer columnsA )
{
// A is m * n
// Apinv is n * m
integer m = rowsA;
integer n = columnsA;
// Singular value decomposition of Matrix A
double *s = new double[min( m, n )];
double *U = new double[m*m];
double *Vt = new double[n*n];
double *Temp = new double[n*m];
svd( A, s, U, Vt, m, n, true );
// Computing the pseudo-inverse of S (which is a diagonal matrix containing the singular values of s): Spinv (is n x m)
double *Spinv = new double[n*m];
int svIndex = 0; // index of vector s
for( int i=0; i < (n*m); i++ )
{
if( i % (n+1) == 0 ) // main diagonal
{
if( fabs( s[svIndex] ) > ZERO_TOLERANCE ) // non-zero values of s are inverted
Spinv[i] = 1.0f / s[svIndex];
else // zero-values of s
Spinv[i] = 0.0f;
svIndex++;
}
else // off main diagonal
Spinv[i] = 0.0f;
}
// Compute Apinv = V * Spinv * U'
multiply( Vt, Spinv, Temp, n, n, n, m, true, false ); // transpose Vt
multiply( Temp, U, Apinv, n, m, m, m, false, true ); // transpose U; Temp is n x m
SAFE_DELETE_ARRAY( s );
SAFE_DELETE_ARRAY( U );
SAFE_DELETE_ARRAY( Vt );
SAFE_DELETE_ARRAY( Spinv );
SAFE_DELETE_ARRAY( Temp );
}
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.