예제 #1
0
//-----------------------------------------------------------------------------
// TestMatrixCopyConstructor
//-----------------------------------------------------------------------------
bool TestMatrixCopyConstructor()
{
   Matrix A("1,2,3;4,5,6");
   Matrix B( A );

   return ApproxEqual(A,B,TOLERANCE);
}
예제 #2
0
//-----------------------------------------------------------------------------
// TestMatrixConstructorWithScalarFill
//-----------------------------------------------------------------------------
bool TestMatrixConstructorWithScalarFill()
{
   Matrix A(2,3, 1.2);
   Matrix B("1.2,1.2,1.2;1.2,1.2,1.2");

   return ApproxEqual(A,B,TOLERANCE);
}
예제 #3
0
//-----------------------------------------------------------------------------
// TestMatrixDimensionedConstructor
//-----------------------------------------------------------------------------
bool TestMatrixDimensionedConstructor()
{
   Matrix A(2,3);
   Matrix B("0,0,0;0,0,0");

   return ApproxEqual(A,B,TOLERANCE);
}
예제 #4
0
//-----------------------------------------------------------------------------
// TestMatrixConstructorWithStringFill
//-----------------------------------------------------------------------------
bool TestMatrixConstructorWithStringFill()
{
   Matrix A("1,,;4,5,");
   Matrix B("1,0,0;4,5,0");

   return ApproxEqual(A,B,TOLERANCE);
}
예제 #5
0
//-----------------------------------------------------------------------------
// TestMatrixIdentity
//-----------------------------------------------------------------------------
bool TestMatrixIdentity()
{
   Matrix A(3,2,1.0);
   Identity( A, 4 );
   Matrix I("1,0,0,0; 0,1,0,0; 0,0,1,0; 0,0,0,1");

   return ApproxEqual(A,I,TOLERANCE);
}
예제 #6
0
//-----------------------------------------------------------------------------
// TestMatrixScalarAssignment
//-----------------------------------------------------------------------------
bool TestMatrixScalarAssignment()
{
   Matrix A("1,2,3;4,5,6");
   A = 0.0;
   Matrix B("0,0,0;0,0,0");

   return ApproxEqual(A,B,TOLERANCE);
}
예제 #7
0
//-----------------------------------------------------------------------------
// TestMatrixAssignmentOperator
//-----------------------------------------------------------------------------
bool TestMatrixAssignmentOperator()
{
   Matrix A("1,2,3;4,5,6");
   Matrix B("0,1,1,0");
   B = A;

   return ApproxEqual(A,B,TOLERANCE);
}
예제 #8
0
//-----------------------------------------------------------------------------
// TestMatrixDestructiveResize
//-----------------------------------------------------------------------------
bool TestMatrixDestructiveResize()
{
   Matrix A("1,2,3;4,5,6");
   A.Resize(2,2);
   Matrix B("0,0;0,0");

   return ApproxEqual(A,B,TOLERANCE);
}
예제 #9
0
//-----------------------------------------------------------------------------
// TestMatrixConstructorWithArrayFill
//-----------------------------------------------------------------------------
bool TestMatrixConstructorWithArrayFill()
{
   double A_data[] = {1.0,2.0,3.0,4.0,5.0,6.0};
   Matrix A(2,3, A_data);
   Matrix B("1,2,3;4,5,6");

   return ApproxEqual(A,B,TOLERANCE);
}
예제 #10
0
//-----------------------------------------------------------------------------
// TestMatrixRowSum
//-----------------------------------------------------------------------------
bool TestMatrixRowSum()
{
   Matrix A("1,2,3;4,5,6;7,8,9");
   Matrix x;
   RowSum( A, x );
   Matrix row_sum("6;15;24");

   return ApproxEqual(x,row_sum,TOLERANCE);
}
예제 #11
0
//-----------------------------------------------------------------------------
// TestMatrixColumnSum
//-----------------------------------------------------------------------------
bool TestMatrixColumnSum()
{
   Matrix A("1,2,3;4,5,6;7,8,9");
   Matrix x;
   ColumnSum( A, x );
   Matrix col_sum("12,15,18");

   return ApproxEqual(x,col_sum,TOLERANCE);
}
예제 #12
0
//-----------------------------------------------------------------------------
// TestMatrixTranspose
//-----------------------------------------------------------------------------
bool TestMatrixTranspose()
{
   Matrix A("1,2,3;4,5,6;7,8,9");
   Matrix C;
   Transpose( A, C );
   Matrix At("1,4,7; 2,5,8; 3,6,9");

   return ApproxEqual(C,At,TOLERANCE);
}
예제 #13
0
//-----------------------------------------------------------------------------
// TestMatrixAdd_aM
//-----------------------------------------------------------------------------
bool TestMatrixAdd_aM()
{
   Matrix A("1,2,3;4,5,6");
   Matrix B;
   Add_aM(2,A,B);
   Matrix Ap2("3,4,5;6,7,8");

   return ApproxEqual(B,Ap2,TOLERANCE);
}
예제 #14
0
//-----------------------------------------------------------------------------
// TestMatrixMultiply_aM
//-----------------------------------------------------------------------------
bool TestMatrixMultiply_aM()
{
   Matrix A("1,2,3;4,5,6");
   Matrix B;
   Multiply_aM(2,A,B);
   Matrix Ax2("2,4,6;8,10,12");

   return ApproxEqual(B,Ax2,TOLERANCE);
}
예제 #15
0
//-----------------------------------------------------------------------------
// TestMatrixNegative
//-----------------------------------------------------------------------------
bool TestMatrixNegative()
{
   Matrix A("1,2,3;4,5,6;7,8,9");
   Matrix C;
   Negative( A, C );
   Matrix B("-1,-2,-3;-4,-5,-6;-7,-8,-9");

   return ApproxEqual(B,C,TOLERANCE);
}
예제 #16
0
//-----------------------------------------------------------------------------
// TestMatrixMultiply_MtMt
//-----------------------------------------------------------------------------
bool TestMatrixMultiply_MtMt()
{
   Matrix A("1,4;2,5;3,6");
   Matrix B("1,3,5;2,4,6");
   Matrix C;
   Multiply_MtMt(A,B,C);
   Matrix AtxBt("22,28; 49,64");

   return ApproxEqual(C,AtxBt,TOLERANCE);
}
예제 #17
0
//-----------------------------------------------------------------------------
// TestMatrixMultiply_MMt
//-----------------------------------------------------------------------------
bool TestMatrixMultiply_MMt()
{
   Matrix A("1,2,3;4,5,6");
   Matrix B("1,3,5;2,4,6");
   Matrix C;
   Multiply_MMt(A,B,C);
   Matrix AxBt("22,28; 49,64");

   return ApproxEqual(C,AxBt,TOLERANCE);
}
예제 #18
0
//-----------------------------------------------------------------------------
// TestMatrixMultiply_MtM
//-----------------------------------------------------------------------------
bool TestMatrixMultiply_MtM()
{
   Matrix A("1,4;2,5;3,6");
   Matrix B("1,2;3,4;5,6");
   Matrix C;
   Multiply_MtM(A,B,C);
   Matrix AtxB("22,28; 49,64");

   return ApproxEqual(C,AtxB,TOLERANCE);
}
예제 #19
0
//-----------------------------------------------------------------------------
// TestMatrixAdd_MM
//-----------------------------------------------------------------------------
bool TestMatrixAdd_MM()
{
   Matrix A("1,2,3;4,5,6");
   Matrix B("1,0,1;0,0,1");
   Matrix C;
   Add_MM(A,B,C);
   Matrix ApB("2,2,4;4,5,7");

   return ApproxEqual(C,ApB,TOLERANCE);
}
예제 #20
0
//-----------------------------------------------------------------------------
// TestMatrixQuadraticForm_MMM
//-----------------------------------------------------------------------------
bool TestMatrixQuadraticForm_MMM()
{
   Matrix a("1,2,3");
   Matrix B("1,2,3;4,5,6;7,8,9");
   Matrix c("4;5;6");

   double q = QuadraticForm_MMM(a,B,c);

   return ApproxEqual(q,552.0,TOLERANCE);
}
예제 #21
0
//-----------------------------------------------------------------------------
// TestMatrixSubtract_MM
//-----------------------------------------------------------------------------
bool TestMatrixSubtract_MM()
{
   Matrix A("1,2,3;4,5,6");
   Matrix B("1,0,1;0,0,1");
   Matrix C;
   Subtract_MM(A,B,C);
   Matrix AmB("0,2,2;4,5,5");

   return ApproxEqual(C,AmB,TOLERANCE);
}
예제 #22
0
//-----------------------------------------------------------------------------
// TestMatrixAccessToRawStorageWithOffset
//-----------------------------------------------------------------------------
bool TestMatrixAccessToRawStorageWithOffset()
{
   Matrix A("1,2,3;4,5,6");
   Matrix B(2,3);

   for (int i=0; i<2; ++i)
      for (int j=0; j<3; ++j)
         *B.Base(i,j) = *A.Base(i,j);

   return ApproxEqual(A,B,TOLERANCE);
}
예제 #23
0
//-----------------------------------------------------------------------------
// TestMatrixAccess
//-----------------------------------------------------------------------------
bool TestMatrixAccess()
{
   Matrix A(2,3);
   Matrix B("1,2,3;4,5,6");

   for (int i=0; i<2; ++i)
      for (int j=0; j<3; ++j)
         A(i,j) = B(i,j);

   return ApproxEqual(A,B,TOLERANCE);
}
예제 #24
0
//-----------------------------------------------------------------------------
// TestMatrixAccessToRawStorage
//-----------------------------------------------------------------------------
bool TestMatrixAccessToRawStorage()
{
   Matrix A("1,2,3;4,5,6");
   Matrix B(2,3);

   const double* pA = A.Base();
   double* pB = B.Base();

   for (int i=0; i<6; ++i)
      *pB++ = *pA++;

   return ApproxEqual(A,B,TOLERANCE);
}
예제 #25
0
void OnePole::ProcessHighpass(BufferOrVal& buf /*inout*/, sample_t approxEqualThresh) {

	if (buf.IsVal()) {

		sample_t val = buf.GetVal();

		// If filter output memory (z1) is very close to input value, then don't need to process
		bool bSkipProcessing = ApproxEqual(val, sample_t(z1), approxEqualThresh);

		if (bSkipProcessing) {
			z1 = double(val);
			return;
		}

		buf.ConvertValToBuf();
	}

	ProcessBufHighpass_(buf.GetBuf(), buf.GetBuf());
}
예제 #26
0
//-----------------------------------------------------------------------------
// TestMatrixLInfNorm
//-----------------------------------------------------------------------------
bool TestMatrixLInfNorm()
{
   Matrix A("1,2,3;4,5,6;7,8,9");

   return ApproxEqual( LInfNorm(A), 24.0, TOLERANCE);
}
예제 #27
0
//-----------------------------------------------------------------------------
// TestMatrixTrace
//-----------------------------------------------------------------------------
bool TestMatrixTrace()
{
   Matrix A("1,2,3;4,5,6;7,8,9");

   return ApproxEqual( Trace(A), 15.0, TOLERANCE);
}
예제 #28
0
//-----------------------------------------------------------------------------
// TestMatrixMaxAbs
//-----------------------------------------------------------------------------
bool TestMatrixMaxAbs()
{
   Matrix A("-1,2,-3;4,-5,6;-7,8,-9");

   return ApproxEqual( MaxAbs(A), 9.0, TOLERANCE);
}
예제 #29
0
//-----------------------------------------------------------------------------
// TestMatrixFNorm
//-----------------------------------------------------------------------------
bool TestMatrixFNorm()
{
   Matrix A("1,2,3;4,5,6;7,8,9");

   return ApproxEqual( FNorm(A), 16.8819430161341, TOLERANCE);
}