MFEM v4.7.0 Finite element discretization library
Searching...
No Matches
symmat.cpp
Go to the documentation of this file.
1// Copyright (c) 2010-2024, Lawrence Livermore National Security, LLC. Produced
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
13// Implementation of data type DenseSymmetricMatrix
14
15#include "symmat.hpp"
16
17namespace mfem
18{
19
21
23{
24 MFEM_ASSERT(s >= 0, "invalid DenseSymmetricMatrix size: " << s);
25 if (s > 0)
26 {
27 data.New((s*(s+1))/2);
28 *this = 0.0; // init with zeroes
29 }
30}
31
33{
34 MFEM_ASSERT(s >= 0,
35 "invalid DenseSymmetricMatrix size: " << s);
36 if (Height() == s)
37 {
38 return;
39 }
40 height = s;
41 width = s;
42 const int s2 = (s*(s+1))/2;
43 if (s2 > data.Capacity())
44 {
45 data.Delete();
46 data.New(s2);
47 *this = 0.0; // init with zeroes
48 }
49}
50
52{
53 const int s = (Height()*(Height()+1))/2;
54 for (int i = 0; i < s; i++)
55 {
56 data[i] = c;
57 }
58 return *this;
59}
60
62{
63 return (*this)(i,j);
64}
65
66const real_t &DenseSymmetricMatrix::Elem(int i, int j) const
67{
68 return (*this)(i,j);
69}
70
72{
73 int s = GetStoredSize();
74 for (int i = 0; i < s; i++)
75 {
76 data[i] *= c;
77 }
78 return *this;
79}
80
82{
83 mfem_error("DenseSymmetricMatrix::Mult() not implemented!");
84}
85
87{
88 mfem_error("DenseSymmetricMatrix::Inverse() not implemented!");
89 return nullptr;
90}
91
92void DenseSymmetricMatrix::Print (std::ostream & os, int width_) const
93{
94 mfem_error("DenseSymmetricMatrix::Print() not implemented!");
95}
96
98{
99 data.Delete();
100}
101
102}
virtual void Mult(const Vector &x, Vector &y) const
Matrix vector multiplication.
Definition symmat.cpp:81
virtual real_t & Elem(int i, int j)
Returns reference to a_{ij}.
Definition symmat.cpp:61
void SetSize(int s)
Change the size of the DenseSymmetricMatrix to s x s.
Definition symmat.cpp:32
virtual MatrixInverse * Inverse() const
Returns a pointer to (an approximation) of the matrix inverse.
Definition symmat.cpp:86
DenseSymmetricMatrix & operator*=(real_t c)
Definition symmat.cpp:71
int GetStoredSize() const
Return the number of stored nonzeros in the matrix.
Definition symmat.hpp:73
virtual ~DenseSymmetricMatrix()
Destroys the symmetric matrix.
Definition symmat.cpp:97
DenseSymmetricMatrix & operator=(real_t c)
Sets the matrix elements equal to constant c.
Definition symmat.cpp:51
virtual void Print(std::ostream &out=mfem::out, int width_=4) const
Prints matrix to stream out.
Definition symmat.cpp:92
Abstract data type for matrix inverse.
Definition matrix.hpp:63
Abstract data type matrix.
Definition matrix.hpp:28
int Capacity() const
Return the size of the allocated memory.
void Delete()
Delete the owned pointers and reset the Memory object.
void New(int size)
Allocate host memory for size entries with the current host memory type returned by MemoryManager::Ge...
int width
Dimension of the input / number of columns in the matrix.
Definition operator.hpp:28
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
Definition operator.hpp:66
int height
Dimension of the output / number of rows in the matrix.
Definition operator.hpp:27
Vector data type.
Definition vector.hpp:80
void mfem_error(const char *msg)
Definition error.cpp:154
float real_t
Definition config.hpp:43
RefCoord s[3]