void testMatrixType(const MatrixType& m) { // Matrices with clustered eigenvalue lead to different code paths // in MatrixFunction.h and are thus useful for testing. typedef typename MatrixType::Index Index; const Index size = m.rows(); for (int i = 0; i < g_repeat; i++) { testMatrix(MatrixType::Random(size, size).eval()); testMatrix(randomMatrixWithRealEivals<MatrixType>(size)); testMatrix(randomMatrixWithImagEivals<MatrixType>::run(size)); } }
void startTest() { TCHAR logFileName[1024]; getLogFilename(logFileName); testLogFile = _tfopen(logFileName, _T("w")); if (!testLogFile) return; int pointTestErr = testPoint(); logHLine(); int vectorTestErr = testVector(); logHLine(); int lineTestErr = testLine(); logHLine(); int planeTestErr = testPlane(); logHLine(); int triangleTestErr = testTriangle(); logHLine(); int basisTestErr = testBasis(); logHLine(); int matrixTestErr = testMatrix(); fclose(testLogFile); testLogFile = NULL; }
int main(int argc, char **argv) { testMatrixCstyle(); testMatrix(); return 0; }
void IsotropicElasticityTensorTest::calcLambdaMu() { IsotropicElasticityTensor is; is.setLambda( 2.57 ); is.setMu( 1.23 ); is.calculate(0); //Moose::out << "LambdaMu\n"; //is.print(); CPPUNIT_ASSERT( testMatrix( _lambdaMu, is ) ); //verify that setShearModulus is the same as setMu IsotropicElasticityTensor is2; is2.setLambda( 2.57 ); is2.setShearModulus( 1.23 ); is2.calculate(0); CPPUNIT_ASSERT( testMatrix( _lambdaMu, is2 ) ); }
void IsotropicElasticityTensorTest::calcLamdaK() { IsotropicElasticityTensor is; is.setLambda( 1.23 ); is.setBulkModulus( 2.57 ); is.calculate(0); //Moose::out << "LambdaK\n"; //is.print(); CPPUNIT_ASSERT( testMatrix( _lambdaK, is ) ); }
void IsotropicElasticityTensorTest::calcLambdaNu() { IsotropicElasticityTensor is; is.setLambda( 2.57 ); is.setPoissonsRatio( 1.23 ); is.calculate(0); //Moose::out << "LambdaNu\n"; //is.print(); CPPUNIT_ASSERT( testMatrix( _lambdaNu, is ) ); }
void IsotropicElasticityTensorTest::calcEK() { IsotropicElasticityTensor is; is.setYoungsModulus( 1.23 ); is.setBulkModulus( 2.57 ); is.calculate(0); //Moose::out << "EK\n"; //is.print(); CPPUNIT_ASSERT( testMatrix( _eK, is ) ); }
void IsotropicElasticityTensorTest::calcENu() { IsotropicElasticityTensor is; is.setYoungsModulus( 2.57 ); is.setPoissonsRatio( 1.23 ); is.calculate(0); //Moose::out << "ENu\n"; //is.print(); CPPUNIT_ASSERT( testMatrix( _eNu, is ) ); }
void IsotropicElasticityTensorTest::calcNuK() { IsotropicElasticityTensor is; is.setPoissonsRatio( 1.23 ); is.setBulkModulus( 2.57 ); is.calculate(0); //Moose::out << "NuK\n"; //is.print(); CPPUNIT_ASSERT( testMatrix( _nuK, is ) ); }
void IsotropicElasticityTensorTest::calcMuE() { IsotropicElasticityTensor is; is.setMu( 1.23 ); is.setYoungsModulus( 2.57 ); is.calculate(0); //Moose::out << "MuE\n"; //is.print(); CPPUNIT_ASSERT( testMatrix( _muE, is ) ); }
bool LibTest::TestMatrix4Operators() const { mat::Matrix4 testMatrix = { { 0 } }; if ( testMatrix( 0, 0 ) == 0 ) { // yay } //double x = testMatrix( -1, 5 ); return true; }
int main(int argc, char** argv) { if (argc != 6) { printf("Arguments should be: imageWidth imageHeight featureWidth featureHeight maxDisplacement\n"); return 1; } int imgW = atoi(argv[1]); int imgH = atoi(argv[2]); int fW = atoi(argv[3]); int fH = atoi(argv[4]); int md = atoi(argv[5]); printf("Testing %ix%i image, %ix%i feature, %i maximum diplacement...\n", imgW, imgH, fW, fH, md); if (!testMatrix(imgW, imgH, fW, fH, md)) { printf("optimized does not match naive.\n"); } else { printf("passes.\n"); } return 0; }
void peano::applications::poisson::multigrid::mappings::SpacetreeGrid2SetupExperiment::createInnerVertex( peano::applications::poisson::multigrid::SpacetreeGridVertex& fineGridVertex, const tarch::la::Vector<DIMENSIONS,double>& fineGridX, const tarch::la::Vector<DIMENSIONS,double>& fineGridH, peano::applications::poisson::multigrid::SpacetreeGridVertex const * const coarseGridVertices, const peano::kernel::gridinterface::VertexEnumerator& coarseGridVerticesEnumerator, const peano::applications::poisson::multigrid::SpacetreeGridCell& coarseGridCell, const tarch::la::Vector<DIMENSIONS,int>& fineGridPositionOfVertex ) { logTraceInWith6Arguments( "createInnerVertex(...)", fineGridVertex, fineGridX, fineGridH, coarseGridVerticesEnumerator.toString(), coarseGridCell, fineGridPositionOfVertex ); // if (tarch::la::volume(fineGridH) > _refinementThreshold) { // fineGridVertex.refine(); // } if (coarseGridVerticesEnumerator.getLevel() < 3) { fineGridVertex.refine(); } peano::toolbox::stencil::Stencil stencil; #ifdef Dim2 //if(fineGridVertex.getLevel() == 4){ stencil = // kappa_x * peano::toolbox::stencil::StencilFactory::stencilProduct( peano::toolbox::stencil::StencilFactory::get1DLaplaceStencil(fineGridH(0)), peano::toolbox::stencil::StencilFactory::get1DMassStencil(fineGridH(1)) ) + // kappa-y * peano::toolbox::stencil::StencilFactory::stencilProduct( peano::toolbox::stencil::StencilFactory::get1DMassStencil(fineGridH(0)), peano::toolbox::stencil::StencilFactory::get1DLaplaceStencil(fineGridH(1)) ); assertionNumericalEquals(stencil(0), -1.0/3.0); assertionNumericalEquals(stencil(1), -1.0/3.0); assertionNumericalEquals(stencil(2), -1.0/3.0); assertionNumericalEquals(stencil(3), -1.0/3.0); assertionNumericalEquals(stencil(4), 8.0/3.0); assertionNumericalEquals(stencil(5), -1.0/3.0); assertionNumericalEquals(stencil(6), -1.0/3.0); assertionNumericalEquals(stencil(7), -1.0/3.0); assertionNumericalEquals(stencil(8), -1.0/3.0); #if defined(Asserts) peano::toolbox::stencil::ElementMatrix elementMatrix; peano::toolbox::stencil::ElementWiseAssemblyMatrix testMatrix = elementMatrix.getElementWiseAssemblyMatrix( stencil ); assertionNumericalEquals(testMatrix(0,0), 2.0/3.0); assertionNumericalEquals(testMatrix(0,1), -0.5/3.0); assertionNumericalEquals(testMatrix(0,2), -0.5/3.0); assertionNumericalEquals(testMatrix(0,3), -1.0/3.0); assertionNumericalEquals(testMatrix(1,0), -0.5/3.0); assertionNumericalEquals(testMatrix(1,1), 2.0/3.0); assertionNumericalEquals(testMatrix(1,2), -1.0/3.0); assertionNumericalEquals(testMatrix(1,3), -0.5/3.0); assertionNumericalEquals(testMatrix(2,0), -0.5/3.0); assertionNumericalEquals(testMatrix(2,1), -1.0/3.0); assertionNumericalEquals(testMatrix(2,2), 2.0/3.0); assertionNumericalEquals(testMatrix(2,3), -0.5/3.0); assertionNumericalEquals(testMatrix(3,0), -1.0/3.0); assertionNumericalEquals(testMatrix(3,1), -0.5/3.0); assertionNumericalEquals(testMatrix(3,2), -0.5/3.0); assertionNumericalEquals(testMatrix(3,3), 2.0/3.0); //logDebug( "createInnerVertex(...)", testMatrix ); #endif // tarch::la::assignList(stencil) = -1.0/3.0, -1.0/3.0, -1.0/3.0, -1.0/3.0, 8.0/3.0, -1.0/3.0, -1.0/3.0, -1.0/3.0, -1.0/3.0; //} //else{ // tarch::la::assignList(stencil) = 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0; //} fineGridVertex.setStencil(stencil); // double squaredDistanceFromCenter = 0.0; // for (int d=0; d<DIMENSIONS; d++) { // squaredDistanceFromCenter += (0.5 - fineGridX(d)) * (0.5 - fineGridX(d)); // } // if (squaredDistanceFromCenter<0.24*0.24) { // stencil *= 4.2; // } peano::toolbox::stencil::ProlongationMatrix prolongation; tarch::la::assignList(prolongation) = 1.0/9.0, 2.0/9.0, 3.0/9.0, 2.0/9.0, 1.0/9.0, 2.0/9.0, 4.0/9.0, 6.0/9.0, 4.0/9.0, 2.0/9.0, 3.0/9.0, 6.0/9.0, 9.0/9.0, 6.0/9.0, 3.0/9.0, 2.0/9.0, 4.0/9.0, 6.0/9.0, 4.0/9.0, 2.0/9.0, 1.0/9.0, 2.0/9.0, 3.0/9.0, 2.0/9.0, 1.0/9.0; fineGridVertex.setP(prolongation); peano::toolbox::stencil::RestrictionMatrix restriction; tarch::la::assignList(restriction) = 1.0/9.0, 2.0/9.0, 3.0/9.0, 2.0/9.0, 1.0/9.0, 2.0/9.0, 4.0/9.0, 6.0/9.0, 4.0/9.0, 2.0/9.0, 3.0/9.0, 6.0/9.0, 9.0/9.0, 6.0/9.0, 3.0/9.0, 2.0/9.0, 4.0/9.0, 6.0/9.0, 4.0/9.0, 2.0/9.0, 1.0/9.0, 2.0/9.0, 3.0/9.0, 2.0/9.0, 1.0/9.0; fineGridVertex.setR(restriction); fineGridVertex.setRhs(1.0, fineGridH); #else assertionMsg( false, "not implemented yet" ); #endif logTraceOutWith1Argument( "createInnerVertex(...)", fineGridVertex ); }
bool fEnablePdfTesting; }; /////////////////////////////////////////////////////////////////////////////// // Constants used by test steps const SkRect kTestRect = SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(0), SkIntToScalar(2), SkIntToScalar(1)); static SkMatrix testMatrix() { SkMatrix matrix; matrix.reset(); matrix.setScale(SkIntToScalar(2), SkIntToScalar(3)); return matrix; } const SkMatrix kTestMatrix = testMatrix(); static SkPath testPath() { SkPath path; path.addRect(SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(0), SkIntToScalar(2), SkIntToScalar(1))); return path; } const SkPath kTestPath = testPath(); static SkRegion testRegion() { SkRegion region; SkIRect rect = SkIRect::MakeXYWH(0, 0, 2, 1); region.setRect(rect); return region; } const SkIRect kTestIRect = SkIRect::MakeXYWH(0, 0, 2, 1); const SkRegion kTestRegion = testRegion();
int main(int, char**) { testVector(); testMatrix(); testCrsMatrix(); }