Пример #1
0
int main(void)
{
    int matrix1[5][5] =
    {
        { 1, 5, 4, 7, 2 },
        { 4, 8, 5, 9, 0 },
        { 2, 7, 6, 5, 3 },
        { 3, 1, 7, 4, 9 },
        { 2, 5, 1, 7, 3 },
    };
    test_matrix("SAMPLE1", 5, matrix1);

    // gen_matrix -i -n matrix2 -r 10 -c 10 -L 10 -H 99
    int matrix2[10][10] =
    {
        { 87, 32, 98, 58, 60, 71, 46, 81, 70, 14, },
        { 22, 92, 15, 98, 51, 26, 94, 67, 46, 56, },
        { 71, 89, 86, 16, 20, 89, 97, 89, 45, 92, },
        { 63, 13, 76, 19, 75, 19, 66, 89, 58, 41, },
        { 82, 68, 75, 26, 58, 20, 89, 87, 65, 66, },
        { 74, 83, 68, 92, 10, 98, 90, 21, 39, 63, },
        { 24, 65, 23, 68, 62, 44, 48, 22, 27, 59, },
        { 26, 27, 71, 71, 51, 31, 43, 69, 92, 10, },
        { 54, 19, 41, 50, 10, 89, 42, 52, 94, 54, },
        { 42, 50, 79, 48, 77, 18, 29, 40, 61, 63, },
    };
    test_matrix("SAMPLE 2", 10, matrix2);

    return 0;
}
Пример #2
0
void
TestSeriesMatcher_run_tests() {
    TestBatch *batch = TestBatch_new(135);
    TestBatch_Plan(batch);
    test_matrix(batch);
    DECREF(batch);
}
Пример #3
0
int main()
{
    std::string input("[[1,2][3][4,5,6]]");
    std::vector<std::vector<double> > results;

    typedef std::string::iterator iter;
    typedef boost::spirit::lex::lexertl::static_actor_lexer<
        boost::spirit::lex::lexertl::token<iter>,
        boost::spirit::lex::lexertl::static_::lexer_matlib
    > lexer_type;

    typedef matlib_tokens<lexer_type> matlib_type;
    matlib_type matrix(results);
    iter first = input.begin();

    try {
        BOOST_TEST(boost::spirit::lex::tokenize(first, input.end(), matrix));
        test_matrix(results);
    }
    catch (std::runtime_error const& e) {
        std::cerr << e.what() << '\n';
        BOOST_TEST(false);
    }
    return boost::report_errors();
}
Пример #4
0
int tst3(int n)
   {int ok;
    PM_matrix *a, *b, *val;

    printf("Test #3\n");

    a = test_matrix(n);
    b = PM_create(a->nrow, a->ncol);
    PM_copy(b, a);

/* find eigenvalues and eigenvectors */
    val = PM_eigensys(a);

    printf("Eigenvalues for A:\n");
    PM_print(val);

    printf("Eigenvectors for A:\n");
    PM_print(a);

/* verify */
    ok = check_matrix(a, b, val);

    PM_destroy(val);
    PM_destroy(a);
    PM_destroy(b);

    return(ok);}
Пример #5
0
int main ( int argc, char **argv ) {

	test_matrix (3);

	return 0;

}
Пример #6
0
int main(int argc, char** args)
{
	CTester c(argc, args);

	test_mesh();
	test_eangles();
	test_matrix();
}
Пример #7
0
int main(int argc, char **argv)
{
    test_str();
    test_vec();
    test_matrix();
    test_stats(); 
    test_list();
}
Пример #8
0
int main()
{
	mom_trace=trace;

	test_matrix();

	return 0;
}
Пример #9
0
void testMatrixOperationsComplex() {
    std::cout << "testing MatrixOperations over std::complex" << std::endl;
    std::complex<double> data[12] = {{1,  -1},
        {2,  -2},
        {3,  -3},
        {4,  -4},
        {5,  -5},
        {6,  -6},
        {7,  -7},
        {8,  -8},
        {9,  -9},
        {10, -10},
        {11, -11},
        {12, -12}
    };
    CDMatrix test_matrix(3, 4, data);
    std::string test_string = "(1,-1) (2,-2) (3,-3) (4,-4) \n(5,-5) (6,-6) (7,-7) (8,-8) \n(9,-9) (10,-10) (11,-11) (12,-12) \n";
    std::string test_cs12 = "(1,-1) (3,-3) (2,-2) (4,-4) \n(5,-5) (7,-7) (6,-6) (8,-8) \n(9,-9) (11,-11) (10,-10) (12,-12) \n";
    std::string test_rs12 = "(1,-1) (3,-3) (2,-2) (4,-4) \n(9,-9) (11,-11) (10,-10) (12,-12) \n(5,-5) (7,-7) (6,-6) (8,-8) \n";
    std::string test_ra013 = "(28,-28) (36,-36) (32,-32) (40,-40) \n(9,-9) (11,-11) (10,-10) (12,-12) \n(5,-5) (7,-7) (6,-6) (8,-8) \n";
    std::string test_ca23m2 = "(28,-28) (36,-36) (-48,48) (40,-40) \n(9,-9) (11,-11) (-14,14) (12,-12) \n(5,-5) (7,-7) (-10,10) (8,-8) \n";
    std::string test_rm22 = "(28,-28) (36,-36) (-48,48) (40,-40) \n(9,-9) (11,-11) (-14,14) (12,-12) \n(10,-10) (14,-14) (-20,20) (16,-16) \n";
    std::string test_cm03 = "(84,-84) (36,-36) (-48,48) (40,-40) \n(27,-27) (11,-11) (-14,14) (12,-12) \n(30,-30) (14,-14) (-20,20) (16,-16) \n";
    std::string test_rg2 = "(84,-84) (36,-36) (-48,48) (40,-40) \n(27,-27) (11,-11) (-14,14) (12,-12) \n(-30,30) (-14,14) (20,-20) (-16,16) \n";
    std::string test_cg2 = "(84,-84) (36,-36) (48,-48) (40,-40) \n(27,-27) (11,-11) (14,-14) (12,-12) \n(-30,30) (-14,14) (-20,20) (-16,16) \n";
    Test tostr(test_string);
    Test tcs12(test_cs12);
    Test trs12(test_rs12);
    Test tra013(test_ra013);
    Test tca23m2(test_ca23m2);
    Test trm22(test_rm22);
    Test tcm03(test_cm03);
    Test trg2(test_rg2);
    Test tcg2(test_cg2);
    std::cout << "tostr:" << tostr.do_(test_matrix.toString()) << std::endl;
    test_matrix.colSwap(1, 2);
    std::cout << "tcs12:" << tcs12.do_(test_matrix.toString()) << std::endl;
    test_matrix.rowSwap(1, 2);
    std::cout << "trs12:" << trs12.do_(test_matrix.toString()) << std::endl;
    test_matrix.rowAdd(0, 1, 3);
    std::cout << "tra013:" << tra013.do_(test_matrix.toString()) << std::endl;
    test_matrix.colAdd(2, 3, -2);
    std::cout << "tca23m2:" << tca23m2.do_(test_matrix.toString()) << std::endl;
    test_matrix.rowMultiply(2, 2);
    std::cout << "trm22:" << trm22.do_(test_matrix.toString()) << std::endl;
    test_matrix.colMultiply(0, 3);
    std::cout << "tcm03:" << tcm03.do_(test_matrix.toString()) << std::endl;
    test_matrix.rowSgnChange(2);
    std::cout << "trg2:" << trg2.do_(test_matrix.toString()) << std::endl;
    test_matrix.colSgnChange(2);
    std::cout << "tcg2:" << tcg2.do_(test_matrix.toString()) << std::endl;
    std::cout << "square:" << (test_matrix.isSquare() == 0) << std::endl;
    std::cout << "cols:" << (test_matrix.getNumOfCols() == 4) << std::endl;
    std::cout << "rows:" << (test_matrix.getNumOfRows() == 3) << std::endl;


}
Пример #10
0
int main()
{
    test_jeu();
    test_util();
    test_matrix();
    
    recap();
    return 0;
}
Пример #11
0
TEST_F (MatrixTest, minsize_RowsCountAndColumnsCountAreEqual_Success)
{
    // Arrange.
    munkres_cpp::Matrix<double> test_matrix (3u, 3u);
    constexpr unsigned int etalon_result {3u};

    // Act.
    const unsigned int test_result = test_matrix.minsize ();

    // Assert.
    EXPECT_EQ (etalon_result, test_result);
}
Пример #12
0
TEST_F (MatrixTest, minsize_ColumnsCountIsMin_Success)
{
    // Arrange.
    munkres_cpp::Matrix<double> test_matrix (2u, 1u);
    constexpr unsigned int etalon_result {1u};

    // Act.
    const unsigned int test_result = test_matrix.minsize ();

    // Assert.
    EXPECT_EQ (etalon_result, test_result);
}
Пример #13
0
Файл: 58.c Проект: dpaneda/code
int main(void) {
  int percent = 100;
  int size=9;

  while (1) {
    float percent = test_matrix(size);
    printf("%f\n", percent);
    if (percent < 0.1)
      break;
    size+=2;
  }

  printf("%d\n", size);
}
Пример #14
0
void testMatrixOperations() {
    std::cout << "testing MatrixOperations over int" << std::endl;
    int data[12] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
    IMatrix test_matrix(3, 4, data);
    std::string test_string = "1 2 3 4 \n5 6 7 8 \n9 10 11 12 \n";
    std::string test_cs12 = "1 3 2 4 \n5 7 6 8 \n9 11 10 12 \n";
    std::string test_rs12 = "1 3 2 4 \n9 11 10 12 \n5 7 6 8 \n";
    std::string test_ra013 = "28 36 32 40 \n9 11 10 12 \n5 7 6 8 \n";
    std::string test_ca23m2 = "28 36 -48 40 \n9 11 -14 12 \n5 7 -10 8 \n";
    std::string test_rm22 = "28 36 -48 40 \n9 11 -14 12 \n10 14 -20 16 \n";
    std::string test_cm03 = "84 36 -48 40 \n27 11 -14 12 \n30 14 -20 16 \n";
    std::string test_rg2 = "84 36 -48 40 \n27 11 -14 12 \n-30 -14 20 -16 \n";
    std::string test_cg2 = "84 36 48 40 \n27 11 14 12 \n-30 -14 -20 -16 \n";
    std::string test_trp = "84 27 -30 \n36 11 -14 \n48 14 -20 \n40 12 -16 \n";
    Test tostr(test_string);
    Test tcs12(test_cs12);
    Test trs12(test_rs12);
    Test tra013(test_ra013);
    Test tca23m2(test_ca23m2);
    Test trm22(test_rm22);
    Test tcm03(test_cm03);
    Test trg2(test_rg2);
    Test tcg2(test_cg2);
    Test ttrp(test_trp);
    std::cout << "tostr:" << tostr.do_(test_matrix.toString()) << std::endl;
    test_matrix.colSwap(1, 2);
    std::cout << "tcs12:" << tcs12.do_(test_matrix.toString()) << std::endl;
    test_matrix.rowSwap(1, 2);
    std::cout << "trs12:" << trs12.do_(test_matrix.toString()) << std::endl;
    test_matrix.rowAdd(0, 1, 3);
    std::cout << "tra013:" << tra013.do_(test_matrix.toString()) << std::endl;
    test_matrix.colAdd(2, 3, -2);
    std::cout << "tca23m2:" << tca23m2.do_(test_matrix.toString()) << std::endl;
    test_matrix.rowMultiply(2, 2);
    std::cout << "trm22:" << trm22.do_(test_matrix.toString()) << std::endl;
    test_matrix.colMultiply(0, 3);
    std::cout << "tcm03:" << tcm03.do_(test_matrix.toString()) << std::endl;
    test_matrix.rowSgnChange(2);
    std::cout << "trg2:" << trg2.do_(test_matrix.toString()) << std::endl;
    test_matrix.colSgnChange(2);
    std::cout << "tcg2:" << tcg2.do_(test_matrix.toString()) << std::endl;
    std::cout << "square:" << (test_matrix.isSquare() == 0) << std::endl;
    std::cout << "cols:" << (test_matrix.getNumOfCols() == 4) << std::endl;
    std::cout << "rows:" << (test_matrix.getNumOfRows() == 3) << std::endl;
    test_matrix.transpose();
    std::cout << "transpose:" << ttrp.do_(test_matrix.toString()) << std::endl;
    std::cout << "cols_trp:" << (test_matrix.getNumOfCols() == 3) << std::endl;
    std::cout << "rows_trp:" << (test_matrix.getNumOfRows() == 4) << std::endl;

}
Пример #15
0
enum piglit_result
piglit_display(void)
{
	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);

	test_matrix();

	test_vector("float", ", 0, 0, 0", glUniform1fvARB);
	test_vector("vec2", ", 0, 0", glUniform2fvARB);
	test_vector("vec3", ", 0", glUniform3fvARB);
	test_vector("vec4", "", glUniform4fvARB);

	return PIGLIT_PASS;
}
Пример #16
0
TEST_F (MatrixTest, operatorSubscript_Success)
{
    // Arrange.
    munkres_cpp::Matrix<double> test_matrix {
        {0.0, 0.1, 0.2},
        {1.0, 1.1, 1.2},
        {2.0, 2.1, 2.2}
    };

    // Act, Assert.
    EXPECT_FLOAT_EQ ( 0.0, test_matrix (0, 0) );
    EXPECT_FLOAT_EQ ( 0.1, test_matrix (0, 1) );
    EXPECT_FLOAT_EQ ( 0.2, test_matrix (0, 2) );
    EXPECT_FLOAT_EQ ( 1.0, test_matrix (1, 0) );
    EXPECT_FLOAT_EQ ( 1.1, test_matrix (1, 1) );
    EXPECT_FLOAT_EQ ( 1.2, test_matrix (1, 2) );
    EXPECT_FLOAT_EQ ( 2.0, test_matrix (2, 0) );
    EXPECT_FLOAT_EQ ( 2.1, test_matrix (2, 1) );
    EXPECT_FLOAT_EQ ( 2.2, test_matrix (2, 2) );
}
Пример #17
0
int TestApp::main()
{
	// Create a console window for text-output if not available
	ConsoleWindow console("Console");

	try
	{

		Console::write_line("ClanLib Test Suite:");
		Console::write_line("-------------------");
#ifdef WIN32
		Console::write_line("Target: WIN32");
#else
		Console::write_line("Target: LINUX");
#endif
		Console::write_line("Directory: API/Core/Math");

		test_bigint();
		test_angle();
		test_quaternion_f();
		test_quaternion_d();
		test_vector2();
		test_vector3();
		test_vector4();
		test_matrix();
		test_line2();
		test_line3();
		test_line_ray2();
		test_line_ray3();
		test_line_segment2();
		test_line_segment3();
		test_triangle();
		test_rect();
	
		Console::write_line("All Tests Complete");
		console.display_close_message();
	}

	catch(Exception error)
	{
		Console::write_line("Exception caught:");
		Console::write_line(error.message);
		console.display_close_message();
		return -1;
	}

	return 0;
}
Пример #18
0
int tst1(int n)
   {int rv;
    PM_matrix *a, *x;

    printf("Test #1\n");

    rv = TRUE;

    a = test_matrix(n);

/* find the eigenvalues */
    x = PM_eigenvalue(a);

    printf("Eigenvalues for A:\n");
    PM_print(x);

    PM_destroy(x);
    PM_destroy(a);

    return(rv);}
Пример #19
0
int tst2(int n)
   {int rv;
    PM_matrix *a, *b;

    printf("Test #2\n");

    a = test_matrix(n);
    b = PM_create(a->nrow, a->ncol);
    PM_copy(b, a);

/* find the right eigenvectors */
    rv = PM_eigenvectors(a);

    if (rv == TRUE)
       {printf("Eigenvectors for A:\n");
	PM_print(a);};

/* verify */
    rv &= check_matrix(a, b, NULL);

    PM_destroy(a);

    return(rv);}
Пример #20
0
void
TestSeriesMatcher_Run_IMP(TestSeriesMatcher *self, TestBatchRunner *runner) {
    TestBatchRunner_Plan(runner, (TestBatch*)self, 135);
    test_matrix(runner);
}
Пример #21
0
int main () {
    test_matrix_vector ();
    test_matrix ();
    return 0;
}
Пример #22
0
const SkMatrix& TestMatrixInvertible(SkRandom* random) { return test_matrix(random, false); }
Пример #23
0
const SkMatrix& TestMatrixPerspective(SkRandom* random) { return test_matrix(random, false, true); }
Пример #24
0
// test the star by solving an all-pairs-shortest path problem (over the tropical semiring)
void MatrixTest::testStar()
{

  /*int n = 6;
  std::vector<FreeSemiring> v;
  for (int i=0; i< n*n; i++){
    v.push_back(Var::GetVarId());
  }
  A = new Matrix<FreeSemiring>(n,v);

  std::cout<< "Astar_start"<< std::endl;
  A->star4();
  std::cout<< "Astar_end"<< std::endl;
  FreeSemiring::one().PrintStats(std::cout);
*/

  // use a fix seed, so tests are deterministic
  std::vector<unsigned int> seeds{42,23,11805,24890};

  /*auto A_star = A->star2();

  std::ofstream dotfile;
  dotfile.open("free-structure.dot");
  FreeSemiring::one().PrintDot(dotfile);
  dotfile.close();
  */

	for (auto &seed : seeds) {
	  srand(seed);

	  // generate random matrix with values [0,10] where 0 is INFTY
	  int size = 100;
	  float density = 0.6; // this is a percentage of how many elements are not INFTY
	  int mod = 10 / density;
	  std::vector<TS> elements;

	  for(unsigned int i = 0; i < size*size; i++)
	  {
		int r = rand() % mod;
	  if(r > 10 || r == 0)
		  elements.push_back(TS(INFTY));
		else
		  elements.push_back(TS(r));
	  }
	  Matrix<TS> test_matrix(size, elements);
	  //std::cout << "testmat:" << std::endl << test_matrix;

	  // calculate the star with the recursive versions and a floyd-warshall implementation
	  // and compare results. All three results should be equal.
	  auto rec_star2 = test_matrix.star();
	  auto rec_star = test_matrix.star3();
	  auto fw_star = test_matrix.star2();
	  /*
	  std::cout << "recursive:" << std::endl << rec_star;
	  std::cout << "recursive2:" << std::endl << rec_star2;
	  std::cout << "floyd-warshall:" << std::endl << fw_star;
	   */
	  CPPUNIT_ASSERT(rec_star2 == fw_star);
	  CPPUNIT_ASSERT(rec_star2 == rec_star);
	}

  Matrix<FS> test_matrix2(2, {FS(0.5), FS(0.5), FS(0), FS(0.5)});
  CPPUNIT_ASSERT(test_matrix2.star() == test_matrix2.star2());
  CPPUNIT_ASSERT(test_matrix2.star() == test_matrix2.star3());

}
Пример #25
0
const SkMatrix& TestMatrix(SkRandom* random) { return test_matrix(random, true); }