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   
)

◆ TEST() [2/65]

TEST ( MatrixAddition  ,
AddSparseMatrices   
)

◆ TEST() [3/65]

TEST ( MatrixAddition  ,
AddTwoMatrices   
)

◆ TEST() [4/65]

TEST ( MatrixConstruction  ,
EmptyMatrixHasZeroEntries   
)

◆ TEST() [5/65]

TEST ( MatrixConstruction  ,
InitializerListColMismatchThrows   
)

◆ TEST() [6/65]

TEST ( MatrixConstruction  ,
InitializerListConstructor   
)

◆ TEST() [7/65]

TEST ( MatrixConstruction  ,
InitializerListRowMismatchThrows   
)

◆ TEST() [8/65]

TEST ( MatrixConstruction  ,
InitializerListWithZerosNotStored   
)

◆ TEST() [9/65]

TEST ( MatrixConversion  ,
ToColList   
)

◆ TEST() [10/65]

TEST ( MatrixConversion  ,
ToRowList   
)

◆ TEST() [11/65]

TEST ( MatrixCopyMove  ,
CopyAssignment   
)

◆ TEST() [12/65]

TEST ( MatrixCopyMove  ,
CopyConstructor   
)

◆ TEST() [13/65]

TEST ( MatrixCopyMove  ,
CopyPreservesEpsilon   
)

◆ TEST() [14/65]

TEST ( MatrixCopyMove  ,
MoveAssignment   
)

◆ TEST() [15/65]

TEST ( MatrixCopyMove  ,
MoveConstructor   
)

◆ TEST() [16/65]

TEST ( MatrixCopyMove  ,
SelfAssignment   
)

◆ TEST() [17/65]

TEST ( MatrixDomain  ,
GetRowAndColDomain   
)

◆ TEST() [18/65]

TEST ( MatrixDomain  ,
RowAndColDomainList   
)

◆ TEST() [19/65]

TEST ( MatrixEntries  ,
OverwriteEntry   
)

◆ TEST() [20/65]

TEST ( MatrixEntries  ,
SetAndGetEntry   
)

◆ TEST() [21/65]

TEST ( MatrixEntries  ,
SetEntryToZeroRemovesIt   
)

◆ TEST() [22/65]

TEST ( MatrixEntries  ,
SetEntryWithinEpsilonIsZero   
)

◆ TEST() [23/65]

TEST ( MatrixEpsilon  ,
GetAndSetEpsilon   
)

◆ TEST() [24/65]

TEST ( MatrixEpsilon  ,
NegativeEpsilonThrows   
)

◆ TEST() [25/65]

TEST ( MatrixEquality  ,
EqualMatrices   
)

◆ TEST() [26/65]

TEST ( MatrixEquality  ,
EqualWithinEpsilon   
)

◆ TEST() [27/65]

TEST ( MatrixEquality  ,
UnequalMatrices   
)

◆ TEST() [28/65]

TEST ( MatrixExtraction  ,
GetColAsList   
)

◆ TEST() [29/65]

TEST ( MatrixExtraction  ,
GetColVector   
)

◆ TEST() [30/65]

TEST ( MatrixExtraction  ,
GetRowAsList   
)

◆ TEST() [31/65]

TEST ( MatrixExtraction  ,
GetRowVector   
)

◆ TEST() [32/65]

TEST ( MatrixExtraction  ,
InvalidColThrows   
)

◆ TEST() [33/65]

TEST ( MatrixExtraction  ,
InvalidRowThrows   
)

◆ TEST() [34/65]

TEST ( MatrixFactory  ,
CreateByColumns   
)

◆ TEST() [35/65]

TEST ( MatrixFactory  ,
CreateByRows   
)

◆ TEST() [36/65]

TEST ( MatrixGenericDomain  ,
StringDomainMatrix   
)

Definition at line 883 of file al_matrix_test.cc.

References Aleph::blossom_maximum_cardinality_matching(), cols, m, and rows.

◆ TEST() [37/65]

TEST ( MatrixGenericDomain  ,
StringDomainTranspose   
)

Definition at line 907 of file al_matrix_test.cc.

References Aleph::blossom_maximum_cardinality_matching(), cols, m, and rows.

◆ TEST() [38/65]

TEST ( MatrixIdentity  ,
CreateIdentity   
)

◆ TEST() [39/65]

TEST ( MatrixIdentity  ,
IdentityTimesVectorIsVector   
)

◆ TEST() [40/65]

TEST ( MatrixMultDomainIdentity  ,
ChainedMultiplicationWithSharedDomain   
)

Definition at line 1310 of file al_matrix_test.cc.

References Aleph::blossom_maximum_cardinality_matching(), cols, and rows.

◆ TEST() [41/65]

TEST ( MatrixMultDomainIdentity  ,
DifferentDomainsThrows   
)

Definition at line 1297 of file al_matrix_test.cc.

References Aleph::blossom_maximum_cardinality_matching().

◆ TEST() [42/65]

TEST ( MatrixMultDomainIdentity  ,
SameDomainWorks   
)

Definition at line 1280 of file al_matrix_test.cc.

References Aleph::blossom_maximum_cardinality_matching().

◆ TEST() [43/65]

TEST ( MatrixOuterProduct  ,
BasicOuterProduct   
)

◆ TEST() [44/65]

TEST ( MatrixScalar  ,
MultiplyByScalar   
)

◆ TEST() [45/65]

TEST ( MatrixScalar  ,
ScalarTimesMatrix   
)

◆ TEST() [46/65]

TEST ( MatrixSetVector  ,
SetVectorAsCol   
)

◆ TEST() [47/65]

TEST ( MatrixSetVector  ,
SetVectorAsRow   
)

◆ TEST() [48/65]

TEST ( MatrixSharedPtr  ,
ConstructWithSharedPtrDomains   
)

Definition at line 1198 of file al_matrix_test.cc.

References Aleph::blossom_maximum_cardinality_matching(), cols, m, and rows.

◆ TEST() [49/65]

TEST ( MatrixSharedPtr  ,
CopiedMatrixSharesDomain   
)

Definition at line 1228 of file al_matrix_test.cc.

References Aleph::blossom_maximum_cardinality_matching().

◆ TEST() [50/65]

TEST ( MatrixSharedPtr  ,
DomainOutlivesLocalScope   
)

◆ TEST() [51/65]

TEST ( MatrixSharedPtr  ,
MatrixVectorMultWithSharedDomains   
)

Definition at line 1256 of file al_matrix_test.cc.

References Aleph::blossom_maximum_cardinality_matching(), and m.

◆ TEST() [52/65]

TEST ( MatrixSharedPtr  ,
VectorWithSharedPtrDomain   
)

Definition at line 1241 of file al_matrix_test.cc.

References Aleph::blossom_maximum_cardinality_matching().

◆ TEST() [53/65]

TEST ( MatrixString  ,
ToStrDoesNotCrash   
)

◆ TEST() [54/65]

TEST ( MatrixSubtraction  ,
DomainMismatchThrows   
)

◆ TEST() [55/65]

TEST ( MatrixSubtraction  ,
SubtractFromItself   
)

◆ TEST() [56/65]

TEST ( MatrixSubtraction  ,
SubtractInPlace   
)

◆ TEST() [57/65]

TEST ( MatrixSubtraction  ,
SubtractSparseMatrices   
)

◆ TEST() [58/65]

TEST ( MatrixSubtraction  ,
SubtractTwoMatrices   
)

◆ TEST() [59/65]

TEST ( MatrixTranspose  ,
DoubleTransposeIsIdentity   
)

◆ TEST() [60/65]

TEST ( MatrixTranspose  ,
TransposeSwapsRowsAndCols   
)

◆ TEST() [61/65]

TEST ( MatrixVectorMult  ,
DomainMismatchThrows   
)

◆ TEST() [62/65]

TEST ( MatrixVectorMult  ,
DotProductMethod   
)

◆ TEST() [63/65]

TEST ( MatrixVectorMult  ,
MatrixTimesVector   
)

◆ TEST() [64/65]

TEST ( MatrixVectorMult  ,
SparseMultiplication   
)

◆ TEST() [65/65]

TEST ( MatrixVectorMult  ,
VectorTimesMatrix   
)