コード例 #1
0
TEUCHOS_UNIT_TEST( Rythmos_ConvergenceTestHelpers, trivialData ) {
  LinearRegression<double> lr;
  Array<double> x,y;
  x.push_back(0.0);
  x.push_back(1.0);
  y.push_back(0.0);
  y.push_back(1.0);
  lr.setData(x,y);
  TEST_EQUALITY_CONST( lr.getSlope(), 1.0 );
  TEST_EQUALITY_CONST( lr.getYIntercept(), 0.0 );
}
コード例 #2
0
TEUCHOS_UNIT_TEST( Rythmos_ConvergenceTestHelpers, nonUniqueXData ) {
  LinearRegression<double> lr;
  Array<double> x,y;
  x.push_back(0.0);
  x.push_back(1.0);
  x.push_back(1.0);
  y.push_back(0.0);
  y.push_back(0.5);
  y.push_back(1.5);
  lr.setData(x,y);
  double tol = 1.0e-10;
  TEST_FLOATING_EQUALITY( lr.getSlope(), 1.0, tol );
  TEST_FLOATING_EQUALITY( lr.getYIntercept(), 0.0, tol );
}
コード例 #3
0
TEUCHOS_UNIT_TEST( Rythmos_ConvergenceTestHelpers, CoSineData ) {
  LinearRegression<double> lr;
  Array<double> x,y;
  int N = 11;
  double dt = 0.1;
  for (int i=0 ; i<N ; ++i) {
    double xval = dt*i;
    x.push_back( xval );
    y.push_back( cos(xval) );
  }
  lr.setData(x,y);
  // 1.0e-14 works on rancilio but not on gabriel, exetazo, or s858352
  double tol = 1.0e-13;
  TEST_FLOATING_EQUALITY( lr.getSlope(), -4.653508042678562e-01, tol ); // These came from matlab
  TEST_FLOATING_EQUALITY( lr.getYIntercept(), 1.067025181571952, tol );
}
コード例 #4
0
TEUCHOS_UNIT_TEST( Rythmos_ConvergenceTestHelpers, SineData ) {
  LinearRegression<double> lr;
  Array<double> x,y;
  int N = 11;
  double dt = 0.1;
  for (int i=0 ; i<N ; ++i) {
    double xval = dt*i;
    x.push_back( xval );
    y.push_back( sin(xval) );
  }
  lr.setData(x,y);
  // 1.0e-14 works on rancilio but not on gabriel, exetazo, or s858352
  double tol = 1.0e-13;
  TEST_FLOATING_EQUALITY( lr.getSlope(), 8.518189335013251e-01, tol ); // These came from matlab
  TEST_FLOATING_EQUALITY( lr.getYIntercept(), 2.989789515694744e-02, tol );
}
コード例 #5
0
TEUCHOS_UNIT_TEST( Rythmos_ConvergenceTestHelpers, create ) {
  LinearRegression<double> lr;
  TEST_THROW(lr.getSlope(), std::logic_error);
  TEST_THROW(lr.getYIntercept(), std::logic_error);
}