This course will introduce you to C++ 11 and teach you about syntax fundamentals.
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( );
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 );
}
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
What does Anova::monteCarlo do? It's possible you have a dead-lock in that method but without seeing it it's hard to say.