15 Matrix scalar_to_mat(
double);
20 std::vector<std::vector<std::string>>
str_mat;
24 std::vector<std::vector<double>>
get();
25 std::vector<double>
get_row(
int);
26 std::vector<double>
get_col(
int);
33 void view(
int,
int,
int,
int);
56 assert((
"The Matrix should be first converted to double using to_double() method", error));
64 assert((
"The Matrix should be first converted to double using to_double() method", error));
66 bool is_within_range = (
double_mat.size() >= row);
67 if (!is_within_range) {
68 assert((
"The row parameter is out of bounds of the matrix size.", is_within_range));
71 std::vector<double> row_vec;
81 assert((
"The Matrix should be first converted to double using to_double() method", error));
83 bool is_within_range = (
double_mat[0].size() >= col);
84 if (!is_within_range) {
85 assert((
"The col parameter is out of bounds of the matrix size.", is_within_range));
88 std::vector<double> col_vec;
102 for (
int i = 0; i <
str_mat.size(); i++) {
103 for (
int j = 0; j <
str_mat[i].size(); j++)
104 std::cout <<
str_mat[i][j] <<
"\t";
105 std::cout << std::endl;
113 void Matrix::view(
int row_start,
int row_end,
int col_start,
int col_end) {
114 bool is_within_range = (
str_mat.size() >= row_end) && (
str_mat[0].size() >= col_end);
115 if (!is_within_range) {
116 assert((
"The slicing parameters are out of bounds of the matrix size.", is_within_range));
119 for (
int i = row_start; i < row_end; i++) {
120 for (
int j = col_start; j < col_end; j++)
121 std::cout <<
str_mat[i][j] <<
"\t";
122 std::cout << std::endl;
129 for (
int i = 0; i < row; i++) {
130 for (
int j = 0; j <
str_mat[i].size(); j++)
131 std::cout <<
str_mat[i][j] <<
"\t";
132 std::cout << std::endl;
140 for (
int j = 0; j <
str_mat[i].size(); j++)
141 std::cout <<
str_mat[i][j] <<
"\t";
142 std::cout << std::endl;
151 bool is_within_range = (
str_mat.size() >= row_end) && (
str_mat[0].size() >= col_end);
152 if (!is_within_range) {
153 assert((
"The slicing parameters are out of bounds of the matrix size.", is_within_range));
156 std::vector<std::string> row;
157 for (
int i = row_start; i < row_end; i++) {
158 for (
int j = col_start; j < col_end; j++)
175 std::vector<std::string> row;
192 std::vector<double> row;
194 for (
int i = 0; i <
str_mat.size(); i++) {
195 for (
int j = 0; j <
str_mat[i].size(); j++)
196 row.push_back(std::stod(
str_mat[i][j]));
205 std::vector<std::string> row;
208 for (
int j = 0; j <
double_mat[i].size(); j++)
209 row.push_back(std::to_string(
double_mat[i][j]));
221 assert((
"The Matrix objects should be first converted to double using to_double() method",
226 std::vector<std::string> row;
237 mat = vector_to_mat(mat);
239 std::vector<std::string> row;
250 mat = vector_to_mat(mat);
252 std::vector<std::string> row;
263 assert((
"The Matrix objects should be of compatible dimensions",
false));
270 assert((
"The Matrix should be first converted to double using to_double() method", error));
272 Matrix mat_val = scalar_to_mat(val);
275 std::vector<std::string> row;
290 assert((
"The Matrix objects should be first converted to double using to_double() method",
295 std::vector<std::string> row;
306 mat = vector_to_mat(mat);
308 std::vector<std::string> row;
319 mat = vector_to_mat(mat);
321 std::vector<std::string> row;
332 assert((
"The Matrix objects should be of compatible dimensions",
false));
339 assert((
"The Matrix should be first converted to double using to_double() method", error));
341 Matrix mat_val = scalar_to_mat(val);
344 std::vector<std::string> row;
359 assert((
"The Matrix objects should be first converted to double using to_double() method",
364 std::vector<std::string> row;
375 mat = vector_to_mat(mat);
377 std::vector<std::string> row;
388 mat = vector_to_mat(mat);
390 std::vector<std::string> row;
401 assert((
"The Matrix objects should be of compatible dimensions",
false));
408 assert((
"The Matrix should be first converted to double using to_double() method", error));
410 Matrix mat_val = scalar_to_mat(val);
413 std::vector<std::string> row;
428 assert((
"The Matrix objects should be first converted to double using to_double() method",
433 std::vector<std::string> row;
442 row.push_back(std::to_string(val));
450 mat = vector_to_mat(mat);
452 std::vector<std::string> row;
461 row.push_back(std::to_string(val));
469 mat = vector_to_mat(mat);
471 std::vector<std::string> row;
480 row.push_back(std::to_string(val));
488 assert((
"The Matrix objects should be of compatible dimensions",
false));
495 assert((
"The Matrix should be first converted to double using to_double() method", error));
497 Matrix mat_val = scalar_to_mat(val);
500 std::vector<std::string> row;
509 row.push_back(std::to_string(val));
521 assert((
"The Matrix should be first converted to double using to_double() method", error1));
524 assert((
"Index is out of range",
false));
533 assert((
"The Matrix should be first converted to double using to_double() method", error1));
536 std::vector<double> row;
550 Matrix Matrix::scalar_to_mat(
double val) {
552 std::vector<std::string> row(
col_length(), std::to_string(val));
553 std::vector<std::vector<std::string>> mat(
row_length(), row);
561 std::vector<std::string> row;