The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.
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 );
}
If you are experiencing a similar issue, please ask a related question
Title | # Comments | Views | Activity |
---|---|---|---|
Web Form VB.Net import CSV | 4 | 39 | |
SSRS troubles | 4 | 52 | |
ASP.NET MVC | 2 | 33 | |
VB.NET 2008 - SQL Timeout | 9 | 26 |
Join the community of 500,000 technology professionals and ask your questions.