ProteoWizard
Public Member Functions | Protected Member Functions | List of all members
MatrixIOTest Class Reference

Public Member Functions

void Run ()
 

Protected Member Functions

virtual void SetUp ()
 
void TearDown ()
 
void SingleReadWrite ()
 
void MultiReadWrite ()
 

Detailed Description

Definition at line 29 of file MatrixIOTest.cpp.

Member Function Documentation

◆ Run()

void MatrixIOTest::Run ( )
inline

Definition at line 31 of file MatrixIOTest.cpp.

32 {
33 SetUp();
36 TearDown();
37 }
virtual void SetUp()
void MultiReadWrite()
void SingleReadWrite()

References MultiReadWrite(), SetUp(), SingleReadWrite(), and TearDown().

Referenced by main().

◆ SetUp()

virtual void MatrixIOTest::SetUp ( )
inlineprotectedvirtual

Definition at line 41 of file MatrixIOTest.cpp.

42 {
43 }

Referenced by Run().

◆ TearDown()

void MatrixIOTest::TearDown ( )
inlineprotected

Definition at line 45 of file MatrixIOTest.cpp.

46 {
47 remove("TestMatrixIOTemp.log");
48 }

Referenced by Run().

◆ SingleReadWrite()

void MatrixIOTest::SingleReadWrite ( )
inlineprotected

Definition at line 50 of file MatrixIOTest.cpp.

51 {
52 std::string testFilename = "TestMatrixIOTemp.log";
53 DemuxTypes::MatrixPtr matrix = boost::make_shared<DemuxTypes::MatrixType>(3, 3);
54 *matrix << 1, 2, 3,
55 4, 5, 6,
56 7, 8, 9;
58
59 DemuxTypes::MatrixPtr matrixIn = boost::make_shared<DemuxTypes::MatrixType>(1, 1);
61
62 unit_assert(matrixIn->isApprox(*matrix));
63 }
void testFilename()
static void ReadBinary(std::ifstream &in, boost::shared_ptr< DemuxTypes::MatrixType > matrix)
Convenience function for reading a single matrix from a file.
static void WriteBinary(std::ofstream &out, boost::shared_ptr< DemuxTypes::MatrixType > matrix)
Writes a matrix to filestream including header information about the number of rows and columns....
boost::shared_ptr< MatrixType > MatrixPtr
#define unit_assert(x)
Definition unit.hpp:85

References pwiz::analysis::MatrixIO::ReadBinary(), testFilename(), unit_assert, and pwiz::analysis::MatrixIO::WriteBinary().

Referenced by Run().

◆ MultiReadWrite()

void MatrixIOTest::MultiReadWrite ( )
inlineprotected

Definition at line 65 of file MatrixIOTest.cpp.

66 {
67 std::string testFilename = "TestMatrixIOTemp.log";
68
69 boost::filesystem::path full_path(boost::filesystem::current_path());
70
71 DemuxTypes::MatrixPtr A = boost::make_shared<DemuxTypes::MatrixType>(3, 4);
72 DemuxTypes::MatrixPtr B = boost::make_shared<DemuxTypes::MatrixType>(4, 3);
73 DemuxTypes::MatrixPtr C = boost::make_shared<DemuxTypes::MatrixType>(3, 3);
74 *A << -14.834628974133, -15.729764770592, 56.292839002858, 30.766363712773,
75 79.595747995303, -8.356622426449, 20.840197237638, 83.801095382748,
76 87.889866880787, 13.75327399942, 86.730656404499, -0.46420627108677;
77
78 *B << 23.588885367543, 49.667231605868, -86.700220187964,
79 51.392601274063, -77.511392742378, 23.389497301117,
80 -78.475202879706, -62.60684915327, -42.39206607192,
81 59.595164405161, 2.1025961854091, 65.787705013259;
82
83 *C = *A * *B;
84
85 std::ofstream out;
87 unit_assert(out.is_open());
91 out.flush();
92 out.close();
93
94 DemuxTypes::MatrixPtr AIn = boost::make_shared<DemuxTypes::MatrixType>(1, 1);
95 DemuxTypes::MatrixPtr BIn = boost::make_shared<DemuxTypes::MatrixType>(1, 1);
96 DemuxTypes::MatrixPtr CIn = boost::make_shared<DemuxTypes::MatrixType>(1, 1);
97
98 std::ifstream in;
100 unit_assert(in.is_open());
101 MatrixIO::ReadBinary(in, AIn);
102 MatrixIO::ReadBinary(in, BIn);
103 MatrixIO::ReadBinary(in, CIn);
104 in.close();
105
106 unit_assert(AIn->isApprox(*A));
107 unit_assert(BIn->isApprox(*B));
108 unit_assert(CIn->isApprox(*C));
109 }
B
Definition Chemistry.hpp:81
C
Definition Chemistry.hpp:80
#define A
static void GetWriteStream(std::ofstream &out, const std::string &filename)
Factory method for generating output streams with fixed properties set for writing matrices.
static void GetReadStream(std::ifstream &in, const std::string &filename)
Factory method for generating input streams with fixed properties set for reading matrices.

References A, B, C, pwiz::analysis::MatrixIO::GetReadStream(), pwiz::analysis::MatrixIO::GetWriteStream(), pwiz::analysis::MatrixIO::ReadBinary(), testFilename(), unit_assert, and pwiz::analysis::MatrixIO::WriteBinary().

Referenced by Run().


The documentation for this class was generated from the following file: