Matrix
First matrix implementation with print_matrix in io
This commit is contained in:
+59
-4
@@ -37,6 +37,7 @@
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
#include <iostream> // for std::cout, std::endl
|
||||
#include <tensor/vector.hpp> // for panic::tensor::vector
|
||||
#include <tensor/matrix.hpp>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
// DEFINE DESCRIPTION
|
||||
@@ -55,13 +56,13 @@ namespace panic {
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
// Function Name : panic::io::print
|
||||
// Function Name : panic::io::print_vector
|
||||
//
|
||||
// Description:
|
||||
// The vector is printed out in square brackets.
|
||||
// Overloaded for panic::uint, panic::int and panic::real
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void print(const panic::tensor::uint_vector& v){
|
||||
void print_vector(const panic::tensor::uint_vector& v){
|
||||
std::cout << "[";
|
||||
for (panic::uint_t i = 0; i < v.size()-1; ++i){
|
||||
std::cout << v[i] << ", ";
|
||||
@@ -69,7 +70,7 @@ void print(const panic::tensor::uint_vector& v){
|
||||
std::cout << v[v.size()-1]<< "]" << std::endl;
|
||||
|
||||
}
|
||||
void print(const panic::tensor::int_vector& v){
|
||||
void print_vector(const panic::tensor::int_vector& v){
|
||||
std::cout << "[";
|
||||
for (panic::uint_t i = 0; i < v.size()-1; ++i){
|
||||
std::cout << v[i] << ", ";
|
||||
@@ -77,7 +78,7 @@ void print(const panic::tensor::int_vector& v){
|
||||
std::cout << v[v.size()-1]<< "]" << std::endl;
|
||||
|
||||
}
|
||||
void print(const panic::tensor::real_vector& v){
|
||||
void print_vector(const panic::tensor::real_vector& v){
|
||||
std::cout << "[";
|
||||
for (panic::uint_t i = 0; i < v.size()-1; ++i){
|
||||
std::cout << v[i] << ", ";
|
||||
@@ -87,5 +88,59 @@ void print(const panic::tensor::real_vector& v){
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
// Function Name : panic::io::print_matrix
|
||||
//
|
||||
// Description:
|
||||
// The matrix is printed out in square brackets.
|
||||
// Overloaded for panic::uint, panic::int and panic::real
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void print_matrix(const panic::tensor::uint_matrix& A){
|
||||
std::cout << "[";
|
||||
for (panic::uint_t i = 0; i < A.rows(); ++i){
|
||||
std::cout << "[";
|
||||
for (panic::uint_t j = 0; j < A.cols(); ++j){
|
||||
std::cout << A(i,j) << ", ";
|
||||
}
|
||||
if (i < A.rows()-1){
|
||||
std::cout << A(A.rows()-1,A.cols()-1) << "]" << std::endl;
|
||||
}else{
|
||||
std::cout << A(A.rows()-1,A.cols()-1) << "]]" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void print_matrix(const panic::tensor::int_matrix& A){
|
||||
std::cout << "[";
|
||||
for (panic::uint_t i = 0; i < A.rows(); ++i){
|
||||
std::cout << "[";
|
||||
for (panic::uint_t j = 0; j < A.cols(); ++j){
|
||||
std::cout << A(i,j) << ", ";
|
||||
}
|
||||
if (i < A.rows()-1){
|
||||
std::cout << A(A.rows()-1,A.cols()-1) << "]" << std::endl;
|
||||
}else{
|
||||
std::cout << A(A.rows()-1,A.cols()-1) << "]]" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void print_matrix(const panic::tensor::real_matrix& A){
|
||||
std::cout << "[";
|
||||
for (panic::uint_t i = 0; i < A.rows(); ++i){
|
||||
std::cout << "[";
|
||||
for (panic::uint_t j = 0; j < A.cols(); ++j){
|
||||
std::cout << A(i,j) << ", ";
|
||||
}
|
||||
if (i < A.rows()-1){
|
||||
std::cout << A(A.rows()-1,A.cols()-1) << "]" << std::endl;
|
||||
}else{
|
||||
std::cout << A(A.rows()-1,A.cols()-1) << "]]" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace io
|
||||
}// namespace panic
|
||||
|
||||
Reference in New Issue
Block a user