/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */ /* Author(s): Anton Deguet Created on: 2004-11-17 (C) Copyright 2004-2026 Johns Hopkins University (JHU), All Rights Reserved. --- begin cisst license - do not edit --- This software is provided "as is" under an open source license, with no warranty. The complete license can be found in license.txt and http://www.cisst.org/cisst/license.txt. --- end cisst license --- */ #include "vctFixedSizeMatrixRefTest.h" #include "vctGenericContainerTest.h" #include "vctGenericMatrixTest.h" #include #include #include #include #include // this macro creates a matrix##number by reference and the // associatied storage based on SIZE and STRIDE##number #define CREATE_STORAGE_AND_REF(number) \ typedef vctFixedSizeMatrix StorageType; \ StorageType storage##number; \ typedef vctFixedSizeMatrixRef MatrixType; \ MatrixType matrix##number; \ matrix##number.SetRef(storage##number.Pointer()) template void vctFixedSizeMatrixRefTest::TestAssignment(void) { typedef _elementType value_type; CREATE_STORAGE_AND_REF(1); CREATE_STORAGE_AND_REF(2); vctRandom(matrix1, value_type(-10), value_type(10)); vctGenericMatrixTest::TestAssignment(matrix1, matrix2); } void vctFixedSizeMatrixRefTest::TestAssignmentDouble(void) { TestAssignment(); } void vctFixedSizeMatrixRefTest::TestAssignmentFloat(void) { TestAssignment(); } void vctFixedSizeMatrixRefTest::TestAssignmentInt(void) { TestAssignment(); } template void vctFixedSizeMatrixRefTest::TestAccessMethods(void) { typedef _elementType value_type; CREATE_STORAGE_AND_REF(1); vctRandom(matrix1, value_type(-10), value_type(10)); typename MatrixType::ConstRefType matrix2(matrix1.Pointer()); vctGenericMatrixTest::TestAccessMethods(matrix1, matrix2); } void vctFixedSizeMatrixRefTest::TestAccessMethodsDouble(void) { TestAccessMethods(); } void vctFixedSizeMatrixRefTest::TestAccessMethodsFloat(void) { TestAccessMethods(); } void vctFixedSizeMatrixRefTest::TestAccessMethodsInt(void) { TestAccessMethods(); } template void vctFixedSizeMatrixRefTest::TestSoMiOperations(void) { typedef _elementType value_type; CREATE_STORAGE_AND_REF(1); CREATE_STORAGE_AND_REF(2); vctRandom(matrix1, value_type(-10), value_type(10)); vctGenericContainerTest::TestSoCiOperations(matrix1, matrix2); } void vctFixedSizeMatrixRefTest::TestSoMiOperationsDouble(void) { TestSoMiOperations(); } void vctFixedSizeMatrixRefTest::TestSoMiOperationsFloat(void) { TestSoMiOperations(); } void vctFixedSizeMatrixRefTest::TestSoMiOperationsInt(void) { TestSoMiOperations(); } template void vctFixedSizeMatrixRefTest::TestSoMiMiOperations(void) { typedef _elementType value_type; CREATE_STORAGE_AND_REF(1); CREATE_STORAGE_AND_REF(2); CREATE_STORAGE_AND_REF(3); vctRandom(matrix1, value_type(-10), value_type(10)); vctRandom(matrix2, value_type(-10), value_type(10)); vctGenericContainerTest::TestSoCiCiOperations(matrix1, matrix2, matrix3); } void vctFixedSizeMatrixRefTest::TestSoMiMiOperationsDouble(void) { TestSoMiMiOperations(); } void vctFixedSizeMatrixRefTest::TestSoMiMiOperationsFloat(void) { TestSoMiMiOperations(); } void vctFixedSizeMatrixRefTest::TestSoMiMiOperationsInt(void) { TestSoMiMiOperations(); } template void vctFixedSizeMatrixRefTest::TestMioMiOperations(void) { typedef _elementType value_type; CREATE_STORAGE_AND_REF(1); CREATE_STORAGE_AND_REF(2); CREATE_STORAGE_AND_REF(3); vctRandom(matrix1, value_type(-10), value_type(10)); vctRandom(matrix2, value_type(-10), value_type(10)); RemoveQuasiZero(matrix2); vctGenericContainerTest::TestCioCiOperations(matrix1, matrix2, matrix3); } void vctFixedSizeMatrixRefTest::TestMioMiOperationsDouble(void) { TestMioMiOperations(); } void vctFixedSizeMatrixRefTest::TestMioMiOperationsFloat(void) { TestMioMiOperations(); } void vctFixedSizeMatrixRefTest::TestMioMiOperationsInt(void) { TestMioMiOperations(); } template void vctFixedSizeMatrixRefTest::TestMoMiMiOperations(void) { typedef _elementType value_type; CREATE_STORAGE_AND_REF(1); CREATE_STORAGE_AND_REF(2); CREATE_STORAGE_AND_REF(3); vctRandom(matrix1, value_type(-10), value_type(10)); vctRandom(matrix2, value_type(-10), value_type(10)); RemoveQuasiZero(matrix2); vctGenericContainerTest::TestCoCiCiOperations(matrix1, matrix2, matrix3); } void vctFixedSizeMatrixRefTest::TestMoMiMiOperationsDouble(void) { TestMoMiMiOperations(); } void vctFixedSizeMatrixRefTest::TestMoMiMiOperationsFloat(void) { TestMoMiMiOperations(); } void vctFixedSizeMatrixRefTest::TestMoMiMiOperationsInt(void) { TestMoMiMiOperations(); } template void vctFixedSizeMatrixRefTest::TestProductOperations(void) { // result size enum {ROWS = 4, COLS = 5, COMSIZE = 7}; typedef _elementType value_type; vctFixedSizeMatrix matrix1; vctFixedSizeMatrix matrix2; vctFixedSizeMatrix matrix3; vctFixedSizeVector vector1; vctFixedSizeVector vector2; vctRandom(matrix1, value_type(-10), value_type(10)); vctRandom(matrix2, value_type(-10), value_type(10)); vctRandom(vector1, value_type(-10), value_type(10)); vctGenericMatrixTest::TestMatrixMatrixProductOperations(matrix1, matrix2, matrix3); vctGenericMatrixTest::TestMatrixVectorProductOperations(matrix1, vector1, vector2); vctRandom(vector2, value_type(-10), value_type(10)); vctGenericMatrixTest::TestVectorMatrixProductOperations(matrix1, vector2, vector1); } void vctFixedSizeMatrixRefTest::TestProductOperationsDouble(void) { TestProductOperations(); } void vctFixedSizeMatrixRefTest::TestProductOperationsFloat(void) { TestProductOperations(); } void vctFixedSizeMatrixRefTest::TestProductOperationsInt(void) { TestProductOperations(); } template void vctFixedSizeMatrixRefTest::TestMoMiOperations(void) { typedef _elementType value_type; CREATE_STORAGE_AND_REF(1); CREATE_STORAGE_AND_REF(2); vctRandom(matrix1, value_type(-10), value_type(10)); vctGenericContainerTest::TestCoCiOperations(matrix1, matrix2); } void vctFixedSizeMatrixRefTest::TestMoMiOperationsDouble(void) { TestMoMiOperations(); } void vctFixedSizeMatrixRefTest::TestMoMiOperationsFloat(void) { TestMoMiOperations(); } void vctFixedSizeMatrixRefTest::TestMoMiOperationsInt(void) { TestMoMiOperations(); } template void vctFixedSizeMatrixRefTest::TestMoMiSiOperations(void) { typedef _elementType value_type; value_type scalar; cmnRandomSequence & randomSequence = cmnRandomSequence::GetInstance(); randomSequence.ExtractRandomValue(value_type(-5), value_type(5), scalar); CREATE_STORAGE_AND_REF(1); CREATE_STORAGE_AND_REF(2); if ((scalar < value_type(1)) && (scalar > -value_type(1))) { scalar = value_type(3); } vctRandom(matrix1, value_type(-10), value_type(10)); vctGenericContainerTest::TestCoCiSiOperations(matrix1, scalar, matrix2); } void vctFixedSizeMatrixRefTest::TestMoMiSiOperationsDouble(void) { TestMoMiSiOperations(); } void vctFixedSizeMatrixRefTest::TestMoMiSiOperationsFloat(void) { TestMoMiSiOperations(); } void vctFixedSizeMatrixRefTest::TestMoMiSiOperationsInt(void) { TestMoMiSiOperations(); } template void vctFixedSizeMatrixRefTest::TestMoSiMiOperations(void) { typedef _elementType value_type; value_type scalar; CREATE_STORAGE_AND_REF(1); CREATE_STORAGE_AND_REF(2); cmnRandomSequence & randomSequence = cmnRandomSequence::GetInstance(); randomSequence.ExtractRandomValue(value_type(-5), value_type(5), scalar); vctRandom(matrix1, value_type(-10), value_type(10)); RemoveQuasiZero(matrix1); vctGenericContainerTest::TestCoSiCiOperations(scalar, matrix1, matrix2); } void vctFixedSizeMatrixRefTest::TestMoSiMiOperationsDouble(void) { TestMoSiMiOperations(); } void vctFixedSizeMatrixRefTest::TestMoSiMiOperationsFloat(void) { TestMoSiMiOperations(); } void vctFixedSizeMatrixRefTest::TestMoSiMiOperationsInt(void) { TestMoSiMiOperations(); } template void vctFixedSizeMatrixRefTest::TestMioSiOperations(void) { typedef _elementType value_type; CREATE_STORAGE_AND_REF(1); CREATE_STORAGE_AND_REF(2); value_type scalar; cmnRandomSequence & randomSequence = cmnRandomSequence::GetInstance(); randomSequence.ExtractRandomValue(value_type(-5), value_type(5), scalar); if ((scalar < value_type(1)) && (scalar > -value_type(1))) { scalar = value_type(3); } vctRandom(matrix1, value_type(-10), value_type(10)); vctGenericContainerTest::TestCioSiOperations(matrix1, scalar, matrix2); } void vctFixedSizeMatrixRefTest::TestMioSiOperationsDouble(void) { TestMioSiOperations(); } void vctFixedSizeMatrixRefTest::TestMioSiOperationsFloat(void) { TestMioSiOperations(); } void vctFixedSizeMatrixRefTest::TestMioSiOperationsInt(void) { TestMioSiOperations(); } template void vctFixedSizeMatrixRefTest::TestMioOperations(void) { typedef _elementType value_type; CREATE_STORAGE_AND_REF(1); CREATE_STORAGE_AND_REF(2); vctRandom(matrix1, value_type(-10), value_type(10)); vctGenericContainerTest::TestCioOperations(matrix1, matrix2); } void vctFixedSizeMatrixRefTest::TestMioOperationsDouble(void) { TestMioOperations(); } void vctFixedSizeMatrixRefTest::TestMioOperationsFloat(void) { TestMioOperations(); } void vctFixedSizeMatrixRefTest::TestMioOperationsInt(void) { TestMioOperations(); } template void vctFixedSizeMatrixRefTest::TestSoMiSiOperations(void) { typedef _elementType value_type; CREATE_STORAGE_AND_REF(1); CREATE_STORAGE_AND_REF(2); value_type scalar; cmnRandomSequence & randomSequence = cmnRandomSequence::GetInstance(); randomSequence.ExtractRandomValue(value_type(-5), value_type(5), scalar); vctRandom(matrix1, value_type(-10), value_type(10)); vctGenericContainerTest::TestSoCiSiOperations(matrix1, scalar, matrix2); } void vctFixedSizeMatrixRefTest::TestSoMiSiOperationsDouble(void) { TestSoMiSiOperations(); } void vctFixedSizeMatrixRefTest::TestSoMiSiOperationsFloat(void) { TestSoMiSiOperations(); } void vctFixedSizeMatrixRefTest::TestSoMiSiOperationsInt(void) { TestSoMiSiOperations(); } template void vctFixedSizeMatrixRefTest::TestIterators(void) { typedef _elementType value_type; CREATE_STORAGE_AND_REF(1); vctRandom(matrix1, value_type(-10), value_type(10)); vctGenericContainerTest::TestIterators(matrix1); } void vctFixedSizeMatrixRefTest::TestIteratorsDouble(void) { TestIterators(); } void vctFixedSizeMatrixRefTest::TestIteratorsFloat(void) { TestIterators(); } void vctFixedSizeMatrixRefTest::TestIteratorsInt(void) { TestIterators(); } template void vctFixedSizeMatrixRefTest::TestSTLFunctions(void) { typedef _elementType value_type; CREATE_STORAGE_AND_REF(1); CREATE_STORAGE_AND_REF(2); vctRandom(matrix1, value_type(-10), value_type(10)); vctGenericContainerTest::TestSTLFunctions(matrix1, matrix2); } void vctFixedSizeMatrixRefTest::TestSTLFunctionsDouble(void) { TestSTLFunctions(); } void vctFixedSizeMatrixRefTest::TestSTLFunctionsFloat(void) { TestSTLFunctions(); } void vctFixedSizeMatrixRefTest::TestSTLFunctionsInt(void) { TestSTLFunctions(); } template void vctFixedSizeMatrixRefTest::TestRandomTemporaryRef(void) { typedef _elementType value_type; CREATE_STORAGE_AND_REF(1); matrix1.SetAll(value_type(100)); vctRandom(MatrixType(storage1.Pointer()), value_type(-10), value_type(10)); vctGenericContainerTest::TestElementsInRange(matrix1, value_type(-10), value_type(10)); } void vctFixedSizeMatrixRefTest::TestRandomTemporaryRefDouble(void) { TestRandomTemporaryRef(); } void vctFixedSizeMatrixRefTest::TestRandomTemporaryRefFloat(void) { TestRandomTemporaryRef(); } void vctFixedSizeMatrixRefTest::TestRandomTemporaryRefInt(void) { TestRandomTemporaryRef(); } CPPUNIT_TEST_SUITE_REGISTRATION(vctFixedSizeMatrixRefTest);