Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F86431821
matrix.hh
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Oct 6, 11:21
Size
776 B
Mime Type
text/x-c++
Expires
Tue, Oct 8, 11:21 (2 d)
Engine
blob
Format
Raw Data
Handle
21419269
Attached To
R12662 PHPC-graded_hw_1
matrix.hh
View Options
#include <string>
#include <vector>
#ifndef __MATRIX_H_
#define __MATRIX_H_
class
Matrix
{
public
:
Matrix
(
int
m
=
0
,
int
n
=
0
)
:
m_m
(
m
),
m_n
(
n
),
m_a
(
m
*
n
)
{}
void
resize
(
int
m
,
int
n
)
{
m_m
=
m
;
m_n
=
n
;
m_a
.
resize
(
m
*
n
);
}
inline
double
&
operator
()(
int
i
,
int
j
)
{
return
m_a
[
i
*
m_n
+
j
];
}
inline
int
m
()
const
{
return
m_m
;
}
inline
int
n
()
const
{
return
m_n
;
}
inline
double
*
data
()
{
return
m_a
.
data
();
}
void
read
(
const
std
::
string
&
filename
);
/* Custom function to get chunks of contiguous rows of data */
std
::
vector
<
double
>
getChunk
(
int
sRow
,
int
fRow
)
const
;
inline
void
setData
(
const
std
::
vector
<
double
>
data
)
{
m_a
=
data
;
}
private
:
int
m_m
{
0
};
int
m_n
{
0
};
std
::
vector
<
double
>
m_a
;
};
#endif
// __MATRIX_H_
Event Timeline
Log In to Comment