/* -*- 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: 2003-08-20 (C) Copyright 2003-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 "vctFixedSizeVectorRefTest.h" #include "vctGenericContainerTest.h" #include "vctGenericVectorTest.h" #include #include #include // this macro creates a vector##number by reference and the // associatied storage based on SIZE and STRIDE##number #define CREATE_STORAGE_AND_REF(number) \ value_type storage##number[SIZE * STRIDE##number]; \ vctFixedSizeVectorRef vector##number; \ vector##number.SetRef(storage##number) template void vctFixedSizeVectorRefTest::TestAssignment(void) { enum {SIZE = 7, STRIDE1 = 3, STRIDE2 = 2}; typedef _elementType value_type; CREATE_STORAGE_AND_REF(1); CREATE_STORAGE_AND_REF(2); vctRandom(vector1, value_type(-10), value_type(10)); vctGenericVectorTest::TestAssignment(vector1, vector2); } void vctFixedSizeVectorRefTest::TestAssignmentDouble(void) { TestAssignment(); } void vctFixedSizeVectorRefTest::TestAssignmentFloat(void) { TestAssignment(); } void vctFixedSizeVectorRefTest::TestAssignmentInt(void) { TestAssignment(); } template void vctFixedSizeVectorRefTest::TestAccessMethods(void) { enum {SIZE = 7, STRIDE1 = 4}; typedef _elementType value_type; CREATE_STORAGE_AND_REF(1); vctRandom(vector1, value_type(-10), value_type(10)); vctFixedSizeConstVectorRef vector2(vector1.Pointer()); vctGenericVectorTest::TestAccessMethods(vector1, vector2); } void vctFixedSizeVectorRefTest::TestAccessMethodsDouble(void) { TestAccessMethods(); } void vctFixedSizeVectorRefTest::TestAccessMethodsFloat(void) { TestAccessMethods(); } void vctFixedSizeVectorRefTest::TestAccessMethodsInt(void) { TestAccessMethods(); } template void vctFixedSizeVectorRefTest::TestSoViOperations(void) { enum {SIZE = 6, STRIDE1 = 2, STRIDE2 = 4}; typedef _elementType value_type; CREATE_STORAGE_AND_REF(1); CREATE_STORAGE_AND_REF(2); vctRandom(vector1, value_type(-10), value_type(10)); vctGenericContainerTest::TestSoCiOperations(vector1, vector2); } void vctFixedSizeVectorRefTest::TestSoViOperationsDouble(void) { TestSoViOperations(); } void vctFixedSizeVectorRefTest::TestSoViOperationsFloat(void) { TestSoViOperations(); } void vctFixedSizeVectorRefTest::TestSoViOperationsInt(void) { TestSoViOperations(); } template void vctFixedSizeVectorRefTest::TestSoViViOperations(void) { enum {SIZE = 5, STRIDE1 = 1, STRIDE2 = 2, STRIDE3 = 3}; typedef _elementType value_type; CREATE_STORAGE_AND_REF(1); CREATE_STORAGE_AND_REF(2); CREATE_STORAGE_AND_REF(3); vctRandom(vector1, value_type(-10), value_type(10)); vctRandom(vector2, value_type(-10), value_type(10)); vctGenericContainerTest::TestSoCiCiOperations(vector1, vector2, vector3); } void vctFixedSizeVectorRefTest::TestSoViViOperationsDouble(void) { TestSoViViOperations(); } void vctFixedSizeVectorRefTest::TestSoViViOperationsFloat(void) { TestSoViViOperations(); } void vctFixedSizeVectorRefTest::TestSoViViOperationsInt(void) { TestSoViViOperations(); } template void vctFixedSizeVectorRefTest::TestVioViOperations(void) { enum {SIZE = 8, STRIDE1 = 3, STRIDE2 = 2, STRIDE3 = 2}; typedef _elementType value_type; CREATE_STORAGE_AND_REF(1); CREATE_STORAGE_AND_REF(2); CREATE_STORAGE_AND_REF(3); vctRandom(vector1, value_type(-10), value_type(10)); vctRandom(vector2, value_type(-10), value_type(10)); RemoveQuasiZero(vector2); vctGenericContainerTest::TestCioCiOperations(vector1, vector2, vector3); } void vctFixedSizeVectorRefTest::TestVioViOperationsDouble(void) { TestVioViOperations(); } void vctFixedSizeVectorRefTest::TestVioViOperationsFloat(void) { TestVioViOperations(); } void vctFixedSizeVectorRefTest::TestVioViOperationsInt(void) { TestVioViOperations(); } template void vctFixedSizeVectorRefTest::TestVoViViOperations(void) { enum {SIZE = 4, STRIDE1 = 4, STRIDE2 = 1, STRIDE3 = 2}; typedef _elementType value_type; CREATE_STORAGE_AND_REF(1); CREATE_STORAGE_AND_REF(2); CREATE_STORAGE_AND_REF(3); vctRandom(vector1, value_type(-10), value_type(10)); vctRandom(vector2, value_type(-10), value_type(10)); RemoveQuasiZero(vector2); vctGenericContainerTest::TestCoCiCiOperations(vector1, vector2, vector3); } void vctFixedSizeVectorRefTest::TestVoViViOperationsDouble(void) { TestVoViViOperations(); } void vctFixedSizeVectorRefTest::TestVoViViOperationsFloat(void) { TestVoViViOperations(); } void vctFixedSizeVectorRefTest::TestVoViViOperationsInt(void) { TestVoViViOperations(); } template void vctFixedSizeVectorRefTest::TestCrossProduct(void) { enum {SIZE = 3, STRIDE1 = 3, STRIDE2 = 1, STRIDE3 = 2}; typedef _elementType value_type; CREATE_STORAGE_AND_REF(1); CREATE_STORAGE_AND_REF(2); CREATE_STORAGE_AND_REF(3); vctRandom(vector1, value_type(-10), value_type(10)); vctRandom(vector2, value_type(-10), value_type(10)); vctGenericVectorTest::TestCrossProduct(vector1, vector2, vector3); } void vctFixedSizeVectorRefTest::TestCrossProductDouble(void) { TestCrossProduct(); } void vctFixedSizeVectorRefTest::TestCrossProductFloat(void) { TestCrossProduct(); } void vctFixedSizeVectorRefTest::TestCrossProductInt(void) { TestCrossProduct(); } template void vctFixedSizeVectorRefTest::TestDotProduct(void) { enum {SIZE = 8, STRIDE1 = 3, STRIDE2 = 1}; typedef _elementType value_type; CREATE_STORAGE_AND_REF(1); CREATE_STORAGE_AND_REF(2); vctRandom(vector1, value_type(-10), value_type(10)); vctRandom(vector2, value_type(-10), value_type(10)); vctGenericVectorTest::TestDotProduct(vector1, vector2); } void vctFixedSizeVectorRefTest::TestDotProductDouble(void) { TestDotProduct(); } void vctFixedSizeVectorRefTest::TestDotProductFloat(void) { TestDotProduct(); } void vctFixedSizeVectorRefTest::TestDotProductInt(void) { TestDotProduct(); } template void vctFixedSizeVectorRefTest::TestVoViOperations(void) { enum {SIZE = 4, STRIDE1 = 1, STRIDE2 = 3}; typedef _elementType value_type; CREATE_STORAGE_AND_REF(1); CREATE_STORAGE_AND_REF(2); vctRandom(vector1, value_type(-10), value_type(10)); vctGenericContainerTest::TestCoCiOperations(vector1, vector2); } void vctFixedSizeVectorRefTest::TestVoViOperationsDouble(void) { TestVoViOperations(); } void vctFixedSizeVectorRefTest::TestVoViOperationsFloat(void) { TestVoViOperations(); } void vctFixedSizeVectorRefTest::TestVoViOperationsInt(void) { TestVoViOperations(); } template void vctFixedSizeVectorRefTest::TestVoViSiOperations(void) { enum {SIZE = 8, STRIDE1 = 3, STRIDE2 = 4}; 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(vector1, value_type(-10), value_type(10)); vctGenericContainerTest::TestCoCiSiOperations(vector1, scalar, vector2); } void vctFixedSizeVectorRefTest::TestVoViSiOperationsDouble(void) { TestVoViSiOperations(); } void vctFixedSizeVectorRefTest::TestVoViSiOperationsFloat(void) { TestVoViSiOperations(); } void vctFixedSizeVectorRefTest::TestVoViSiOperationsInt(void) { TestVoViSiOperations(); } template void vctFixedSizeVectorRefTest::TestVoSiViOperations(void) { enum {SIZE = 10, STRIDE1 = 3, STRIDE2 = 1}; 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(vector1, value_type(-10), value_type(10)); RemoveQuasiZero(vector1); vctGenericContainerTest::TestCoSiCiOperations(scalar, vector1, vector2); } void vctFixedSizeVectorRefTest::TestVoSiViOperationsDouble(void) { TestVoSiViOperations(); } void vctFixedSizeVectorRefTest::TestVoSiViOperationsFloat(void) { TestVoSiViOperations(); } void vctFixedSizeVectorRefTest::TestVoSiViOperationsInt(void) { TestVoSiViOperations(); } template void vctFixedSizeVectorRefTest::TestVioSiOperations(void) { enum {SIZE = 9, STRIDE1 = 1, STRIDE2 = 2}; 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(vector1, value_type(-10), value_type(10)); vctGenericContainerTest::TestCioSiOperations(vector1, scalar, vector2); } void vctFixedSizeVectorRefTest::TestVioSiOperationsDouble(void) { TestVioSiOperations(); } void vctFixedSizeVectorRefTest::TestVioSiOperationsFloat(void) { TestVioSiOperations(); } void vctFixedSizeVectorRefTest::TestVioSiOperationsInt(void) { TestVioSiOperations(); } template void vctFixedSizeVectorRefTest::TestVioOperations(void) { enum {SIZE = 9, STRIDE1 = 2, STRIDE2 = 4}; typedef _elementType value_type; CREATE_STORAGE_AND_REF(1); CREATE_STORAGE_AND_REF(2); vctRandom(vector1, value_type(-10), value_type(10)); vctGenericContainerTest::TestCioOperations(vector1, vector2); } void vctFixedSizeVectorRefTest::TestVioOperationsDouble(void) { TestVioOperations(); } void vctFixedSizeVectorRefTest::TestVioOperationsFloat(void) { TestVioOperations(); } void vctFixedSizeVectorRefTest::TestVioOperationsInt(void) { TestVioOperations(); } template void vctFixedSizeVectorRefTest::TestSoViSiOperations(void) { enum {SIZE = 9, STRIDE1 = 1, STRIDE2 = 2}; 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(vector1, value_type(-10), value_type(10)); vctGenericContainerTest::TestSoCiSiOperations(vector1, scalar, vector2); } void vctFixedSizeVectorRefTest::TestSoViSiOperationsDouble(void) { TestSoViSiOperations(); } void vctFixedSizeVectorRefTest::TestSoViSiOperationsFloat(void) { TestSoViSiOperations(); } void vctFixedSizeVectorRefTest::TestSoViSiOperationsInt(void) { TestSoViSiOperations(); } template void vctFixedSizeVectorRefTest::TestIterators(void) { enum {SIZE = 9, STRIDE1 = 5}; typedef _elementType value_type; CREATE_STORAGE_AND_REF(1); vctRandom(vector1, value_type(-10), value_type(10)); vctGenericContainerTest::TestIterators(vector1); } void vctFixedSizeVectorRefTest::TestIteratorsDouble(void) { TestIterators(); } void vctFixedSizeVectorRefTest::TestIteratorsFloat(void) { TestIterators(); } void vctFixedSizeVectorRefTest::TestIteratorsInt(void) { TestIterators(); } template void vctFixedSizeVectorRefTest::TestSTLFunctions(void) { enum {SIZE = 9, STRIDE1 = 5, STRIDE2 = 1}; typedef _elementType value_type; CREATE_STORAGE_AND_REF(1); CREATE_STORAGE_AND_REF(2); vctRandom(vector1, value_type(-10), value_type(10)); vctGenericContainerTest::TestSTLFunctions(vector1, vector2); } void vctFixedSizeVectorRefTest::TestSTLFunctionsDouble(void) { TestSTLFunctions(); } void vctFixedSizeVectorRefTest::TestSTLFunctionsFloat(void) { TestSTLFunctions(); } void vctFixedSizeVectorRefTest::TestSTLFunctionsInt(void) { TestSTLFunctions(); } template void vctFixedSizeVectorRefTest::TestNormalization(void) { enum {SIZE = 9, STRIDE1 = 5}; typedef _elementType value_type; CREATE_STORAGE_AND_REF(1); vctRandom(vector1, value_type(-10), value_type(10)); vctGenericVectorTest::TestNormalization(vector1); } void vctFixedSizeVectorRefTest::TestNormalizationDouble(void) { TestNormalization(); } void vctFixedSizeVectorRefTest::TestNormalizationFloat(void) { TestNormalization(); } template void vctFixedSizeVectorRefTest::TestRandomTemporaryRef(void) { enum {SIZE = 7, STRIDE1 = 3}; typedef _elementType value_type; CREATE_STORAGE_AND_REF(1); vector1.SetAll(value_type(100)); vctRandom(vctFixedSizeVectorRef(storage1), value_type(-10), value_type(10)); vctGenericContainerTest::TestElementsInRange(vector1, value_type(-10), value_type(10)); } void vctFixedSizeVectorRefTest::TestRandomTemporaryRefDouble(void) { TestRandomTemporaryRef(); } void vctFixedSizeVectorRefTest::TestRandomTemporaryRefFloat(void) { TestRandomTemporaryRef(); } void vctFixedSizeVectorRefTest::TestRandomTemporaryRefInt(void) { TestRandomTemporaryRef(); } CPPUNIT_TEST_SUITE_REGISTRATION(vctFixedSizeVectorRefTest);