MFEM  v3.3
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
matrix.cpp
Go to the documentation of this file.
1 // Copyright (c) 2010, Lawrence Livermore National Security, LLC. Produced at
2 // the Lawrence Livermore National Laboratory. LLNL-CODE-443211. All Rights
3 // reserved. See file COPYRIGHT for details.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability see http://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the GNU Lesser General Public License (as published by the Free
10 // Software Foundation) version 2.1 dated February 1999.
11 
12 // Implementation of class matrix
13 
14 #include <iostream>
15 #include <iomanip>
16 
17 #include "matrix.hpp"
18 
19 namespace mfem
20 {
21 
22 void Matrix::Print (std::ostream & out, int width_) const
23 {
24  using namespace std;
25  // output flags = scientific + show sign
26  out << setiosflags(ios::scientific | ios::showpos);
27  for (int i = 0; i < height; i++)
28  {
29  out << "[row " << i << "]\n";
30  for (int j = 0; j < width; j++)
31  {
32  out << Elem(i,j) << " ";
33  if ( !((j+1) % width_) )
34  {
35  out << '\n';
36  }
37  }
38  out << '\n';
39  }
40  out << '\n';
41 }
42 
43 }
virtual void Print(std::ostream &out=std::cout, 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:24
int width
Dimension of the input / number of columns in the matrix.
Definition: operator.hpp:25