MFEM  v3.2
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
operator.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 #include <iostream>
13 #include <iomanip>
14 
15 #include "vector.hpp"
16 #include "operator.hpp"
17 
18 namespace mfem
19 {
20 
21 void Operator::PrintMatlab (std::ostream & out, int n, int m) const
22 {
23  using namespace std;
24  if (n == 0) { n = width; }
25  if (m == 0) { m = height; }
26 
27  Vector x(n), y(m);
28  x = 0.0;
29 
30  int i, j;
31  out << setiosflags(ios::scientific | ios::showpos);
32  for (i = 0; i < n; i++)
33  {
34  if (i != 0)
35  {
36  x(i-1) = 0.0;
37  }
38  x(i) = 1.0;
39  Mult(x,y);
40  for (j = 0; j < m; j++)
41  if (y(j))
42  {
43  out << j+1 << " " << i+1 << " " << y(j) << '\n';
44  }
45  }
46 }
47 
48 }
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application.
void PrintMatlab(std::ostream &out, int n=0, int m=0) const
Prints operator with input size n and output size m in matlab format.
Definition: operator.cpp:21
Vector data type.
Definition: vector.hpp:33