Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
al_matrix_test.cc File Reference

Exhaustive tests for al-matrix.H (sparse matrix with generic domains) More...

#include <gtest/gtest.h>
#include <cmath>
#include <string>
#include <vector>
#include <al-domain.H>
#include <al-vector.H>
#include <al-matrix.H>
Include dependency graph for al_matrix_test.cc:

Go to the source code of this file.

Functions

 TEST (MatrixConstruction, EmptyMatrixHasZeroEntries)
 
 TEST (MatrixConstruction, InitializerListConstructor)
 
 TEST (MatrixConstruction, InitializerListWithZerosNotStored)
 
 TEST (MatrixConstruction, InitializerListRowMismatchThrows)
 
 TEST (MatrixConstruction, InitializerListColMismatchThrows)
 
 TEST (MatrixEntries, SetAndGetEntry)
 
 TEST (MatrixEntries, SetEntryToZeroRemovesIt)
 
 TEST (MatrixEntries, SetEntryWithinEpsilonIsZero)
 
 TEST (MatrixEntries, OverwriteEntry)
 
 TEST (MatrixEpsilon, GetAndSetEpsilon)
 
 TEST (MatrixEpsilon, NegativeEpsilonThrows)
 
 TEST (MatrixTranspose, TransposeSwapsRowsAndCols)
 
 TEST (MatrixTranspose, DoubleTransposeIsIdentity)
 
 TEST (MatrixExtraction, GetRowAsList)
 
 TEST (MatrixExtraction, GetColAsList)
 
 TEST (MatrixExtraction, GetRowVector)
 
 TEST (MatrixExtraction, GetColVector)
 
 TEST (MatrixExtraction, InvalidRowThrows)
 
 TEST (MatrixExtraction, InvalidColThrows)
 
 TEST (MatrixVectorMult, MatrixTimesVector)
 
 TEST (MatrixVectorMult, VectorTimesMatrix)
 
 TEST (MatrixVectorMult, SparseMultiplication)
 
 TEST (MatrixVectorMult, DotProductMethod)
 
 TEST (MatrixVectorMult, DomainMismatchThrows)
 
 TEST (MatrixAddition, AddTwoMatrices)
 
 TEST (MatrixAddition, AddInPlace)
 
 TEST (MatrixAddition, AddSparseMatrices)
 
 TEST (MatrixScalar, MultiplyByScalar)
 
 TEST (MatrixScalar, ScalarTimesMatrix)
 
 TEST (MatrixIdentity, CreateIdentity)
 
 TEST (MatrixIdentity, IdentityTimesVectorIsVector)
 
 TEST (MatrixEquality, EqualMatrices)
 
 TEST (MatrixEquality, UnequalMatrices)
 
 TEST (MatrixEquality, EqualWithinEpsilon)
 
 TEST (MatrixFactory, CreateByRows)
 
 TEST (MatrixFactory, CreateByColumns)
 
 TEST (MatrixConversion, ToRowList)
 
 TEST (MatrixConversion, ToColList)
 
 TEST (MatrixSetVector, SetVectorAsRow)
 
 TEST (MatrixSetVector, SetVectorAsCol)
 
 TEST (MatrixOuterProduct, BasicOuterProduct)
 
 TEST (MatrixGenericDomain, StringDomainMatrix)
 
 TEST (MatrixGenericDomain, StringDomainTranspose)
 
 TEST (MatrixString, ToStrDoesNotCrash)
 
 TEST (MatrixDomain, GetRowAndColDomain)
 
 TEST (MatrixDomain, RowAndColDomainList)
 
 TEST (MatrixSubtraction, SubtractTwoMatrices)
 
 TEST (MatrixSubtraction, SubtractInPlace)
 
 TEST (MatrixSubtraction, SubtractSparseMatrices)
 
 TEST (MatrixSubtraction, SubtractFromItself)
 
 TEST (MatrixSubtraction, DomainMismatchThrows)
 
 TEST (MatrixCopyMove, CopyConstructor)
 
 TEST (MatrixCopyMove, CopyAssignment)
 
 TEST (MatrixCopyMove, SelfAssignment)
 
 TEST (MatrixCopyMove, MoveConstructor)
 
 TEST (MatrixCopyMove, MoveAssignment)
 
 TEST (MatrixCopyMove, CopyPreservesEpsilon)
 
 TEST (MatrixSharedPtr, ConstructWithSharedPtrDomains)
 
 TEST (MatrixSharedPtr, DomainOutlivesLocalScope)
 
 TEST (MatrixSharedPtr, CopiedMatrixSharesDomain)
 
 TEST (MatrixSharedPtr, VectorWithSharedPtrDomain)
 
 TEST (MatrixSharedPtr, MatrixVectorMultWithSharedDomains)
 
 TEST (MatrixMultDomainIdentity, SameDomainWorks)
 
 TEST (MatrixMultDomainIdentity, DifferentDomainsThrows)
 
 TEST (MatrixMultDomainIdentity, ChainedMultiplicationWithSharedDomain)
 

Detailed Description

Exhaustive tests for al-matrix.H (sparse matrix with generic domains)

Tests cover:

  • Construction (empty, initializer list, DynList)
  • Entry access and modification (get_entry, set_entry)
  • Sparse storage semantics (zero entries not stored)
  • Transpose
  • Row/column extraction (as list and as vector)
  • Matrix-vector and vector-matrix multiplication
  • Matrix addition and scalar multiplication
  • Identity matrix
  • Equality comparison
  • Static factory methods (create_by_rows, create_by_columns)
  • Outer product

Definition in file al_matrix_test.cc.

Function Documentation

◆ TEST() [1/65]

TEST ( MatrixAddition  ,
AddInPlace   
)

Definition at line 523 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [2/65]

TEST ( MatrixAddition  ,
AddSparseMatrices   
)

Definition at line 545 of file al_matrix_test.cc.

References Aleph::maps(), and Aleph::sum().

◆ TEST() [3/65]

TEST ( MatrixAddition  ,
AddTwoMatrices   
)

Definition at line 501 of file al_matrix_test.cc.

References Aleph::maps(), and Aleph::sum().

◆ TEST() [4/65]

TEST ( MatrixConstruction  ,
EmptyMatrixHasZeroEntries   
)

Definition at line 100 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [5/65]

TEST ( MatrixConstruction  ,
InitializerListColMismatchThrows   
)

Definition at line 161 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [6/65]

TEST ( MatrixConstruction  ,
InitializerListConstructor   
)

Definition at line 113 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [7/65]

TEST ( MatrixConstruction  ,
InitializerListRowMismatchThrows   
)

Definition at line 148 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [8/65]

TEST ( MatrixConstruction  ,
InitializerListWithZerosNotStored   
)

Definition at line 131 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [9/65]

TEST ( MatrixConversion  ,
ToColList   
)

◆ TEST() [10/65]

TEST ( MatrixConversion  ,
ToRowList   
)

◆ TEST() [11/65]

TEST ( MatrixCopyMove  ,
CopyAssignment   
)

Definition at line 1109 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [12/65]

TEST ( MatrixCopyMove  ,
CopyConstructor   
)

Definition at line 1089 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [13/65]

TEST ( MatrixCopyMove  ,
CopyPreservesEpsilon   
)

Definition at line 1181 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [14/65]

TEST ( MatrixCopyMove  ,
MoveAssignment   
)

Definition at line 1163 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [15/65]

TEST ( MatrixCopyMove  ,
MoveConstructor   
)

Definition at line 1146 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [16/65]

TEST ( MatrixCopyMove  ,
SelfAssignment   
)

Definition at line 1129 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [17/65]

TEST ( MatrixDomain  ,
GetRowAndColDomain   
)

Definition at line 952 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [18/65]

TEST ( MatrixDomain  ,
RowAndColDomainList   
)

◆ TEST() [19/65]

TEST ( MatrixEntries  ,
OverwriteEntry   
)

Definition at line 216 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [20/65]

TEST ( MatrixEntries  ,
SetAndGetEntry   
)

Definition at line 179 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [21/65]

TEST ( MatrixEntries  ,
SetEntryToZeroRemovesIt   
)

Definition at line 193 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [22/65]

TEST ( MatrixEntries  ,
SetEntryWithinEpsilonIsZero   
)

Definition at line 206 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [23/65]

TEST ( MatrixEpsilon  ,
GetAndSetEpsilon   
)

Definition at line 231 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [24/65]

TEST ( MatrixEpsilon  ,
NegativeEpsilonThrows   
)

Definition at line 243 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [25/65]

TEST ( MatrixEquality  ,
EqualMatrices   
)

Definition at line 641 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [26/65]

TEST ( MatrixEquality  ,
EqualWithinEpsilon   
)

Definition at line 677 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [27/65]

TEST ( MatrixEquality  ,
UnequalMatrices   
)

Definition at line 659 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [28/65]

TEST ( MatrixExtraction  ,
GetColAsList   
)

◆ TEST() [29/65]

TEST ( MatrixExtraction  ,
GetColVector   
)

Definition at line 352 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [30/65]

TEST ( MatrixExtraction  ,
GetRowAsList   
)

◆ TEST() [31/65]

TEST ( MatrixExtraction  ,
GetRowVector   
)

Definition at line 335 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [32/65]

TEST ( MatrixExtraction  ,
InvalidColThrows   
)

Definition at line 378 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [33/65]

TEST ( MatrixExtraction  ,
InvalidRowThrows   
)

Definition at line 368 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [34/65]

TEST ( MatrixFactory  ,
CreateByColumns   
)

Definition at line 723 of file al_matrix_test.cc.

References Aleph::DynList< T >::append(), and Aleph::maps().

◆ TEST() [35/65]

TEST ( MatrixFactory  ,
CreateByRows   
)

Definition at line 694 of file al_matrix_test.cc.

References Aleph::DynList< T >::append(), and Aleph::maps().

◆ TEST() [36/65]

TEST ( MatrixGenericDomain  ,
StringDomainMatrix   
)

Definition at line 883 of file al_matrix_test.cc.

References Aleph::DynList< T >::insert(), and Aleph::maps().

◆ TEST() [37/65]

TEST ( MatrixGenericDomain  ,
StringDomainTranspose   
)

Definition at line 907 of file al_matrix_test.cc.

References Aleph::DynList< T >::insert(), and Aleph::maps().

◆ TEST() [38/65]

TEST ( MatrixIdentity  ,
CreateIdentity   
)

Definition at line 607 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [39/65]

TEST ( MatrixIdentity  ,
IdentityTimesVectorIsVector   
)

Definition at line 619 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [40/65]

TEST ( MatrixMultDomainIdentity  ,
ChainedMultiplicationWithSharedDomain   
)

Definition at line 1310 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [41/65]

TEST ( MatrixMultDomainIdentity  ,
DifferentDomainsThrows   
)

Definition at line 1297 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [42/65]

TEST ( MatrixMultDomainIdentity  ,
SameDomainWorks   
)

Definition at line 1280 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [43/65]

TEST ( MatrixOuterProduct  ,
BasicOuterProduct   
)

Definition at line 851 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [44/65]

TEST ( MatrixScalar  ,
MultiplyByScalar   
)

Definition at line 569 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [45/65]

TEST ( MatrixScalar  ,
ScalarTimesMatrix   
)

Definition at line 586 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [46/65]

TEST ( MatrixSetVector  ,
SetVectorAsCol   
)

Definition at line 826 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [47/65]

TEST ( MatrixSetVector  ,
SetVectorAsRow   
)

Definition at line 805 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [48/65]

TEST ( MatrixSharedPtr  ,
ConstructWithSharedPtrDomains   
)

Definition at line 1198 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [49/65]

TEST ( MatrixSharedPtr  ,
CopiedMatrixSharesDomain   
)

Definition at line 1228 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [50/65]

TEST ( MatrixSharedPtr  ,
DomainOutlivesLocalScope   
)

Definition at line 1216 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [51/65]

TEST ( MatrixSharedPtr  ,
MatrixVectorMultWithSharedDomains   
)

Definition at line 1256 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [52/65]

TEST ( MatrixSharedPtr  ,
VectorWithSharedPtrDomain   
)

Definition at line 1241 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [53/65]

TEST ( MatrixString  ,
ToStrDoesNotCrash   
)

Definition at line 935 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [54/65]

TEST ( MatrixSubtraction  ,
DomainMismatchThrows   
)

Definition at line 1073 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [55/65]

TEST ( MatrixSubtraction  ,
SubtractFromItself   
)

Definition at line 1056 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [56/65]

TEST ( MatrixSubtraction  ,
SubtractInPlace   
)

Definition at line 1014 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [57/65]

TEST ( MatrixSubtraction  ,
SubtractSparseMatrices   
)

Definition at line 1036 of file al_matrix_test.cc.

References Aleph::diff(), and Aleph::maps().

◆ TEST() [58/65]

TEST ( MatrixSubtraction  ,
SubtractTwoMatrices   
)

Definition at line 992 of file al_matrix_test.cc.

References Aleph::diff(), and Aleph::maps().

◆ TEST() [59/65]

TEST ( MatrixTranspose  ,
DoubleTransposeIsIdentity   
)

Definition at line 277 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [60/65]

TEST ( MatrixTranspose  ,
TransposeSwapsRowsAndCols   
)

Definition at line 256 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [61/65]

TEST ( MatrixVectorMult  ,
DomainMismatchThrows   
)

Definition at line 486 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [62/65]

TEST ( MatrixVectorMult  ,
DotProductMethod   
)

Definition at line 466 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [63/65]

TEST ( MatrixVectorMult  ,
MatrixTimesVector   
)

Definition at line 392 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [64/65]

TEST ( MatrixVectorMult  ,
SparseMultiplication   
)

Definition at line 444 of file al_matrix_test.cc.

References Aleph::maps().

◆ TEST() [65/65]

TEST ( MatrixVectorMult  ,
VectorTimesMatrix   
)

Definition at line 418 of file al_matrix_test.cc.

References Aleph::maps().