MFEM  v4.6.0
Finite element discretization library
matrix.cpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2023, Lawrence Livermore National Security, LLC. Produced
2 // at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3 // LICENSE and NOTICE for details. LLNL-CODE-806117.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability visit https://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the BSD-3 license. We welcome feedback and contributions, see file
10 // CONTRIBUTING.md for details.
11 
12 // Implementation of class matrix
13 
14 #include "matrix.hpp"
15 #include <iostream>
16 #include <iomanip>
17 
18 
19 namespace mfem
20 {
21 
22 void Matrix::Print (std::ostream & os, int width_) const
23 {
24  using namespace std;
25  // output flags = scientific + show sign
26  os << setiosflags(ios::scientific | ios::showpos);
27  for (int i = 0; i < height; i++)
28  {
29  os << "[row " << i << "]\n";
30  for (int j = 0; j < width; j++)
31  {
32  os << Elem(i,j) << " ";
33  if ( !((j+1) % width_) )
34  {
35  os << '\n';
36  }
37  }
38  os << '\n';
39  }
40  os << '\n';
41 }
42 
43 }
STL namespace.
virtual void Print(std::ostream &out=mfem::out, int width_=4) const
Prints matrix to stream out.
Definition: matrix.cpp:22
virtual double & Elem(int i, int j)=0
Returns reference to a_{ij}.
int height
Dimension of the output / number of rows in the matrix.
Definition: operator.hpp:27
int width
Dimension of the input / number of columns in the matrix.
Definition: operator.hpp:28