MFEM v4.9.0
Finite element discretization library
Loading...
Searching...
No Matches
symmat.cpp
Go to the documentation of this file.
1// Copyright (c) 2010-2025, 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
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.SetSize((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 data.SetSize((s*(s+1))/2);
43 *this = 0.0; // init with zeroes
44}
45
47{
48 const int s = (Height()*(Height()+1))/2;
49 for (int i = 0; i < s; i++)
50 {
51 data[i] = c;
52 }
53 return *this;
54}
55
57{
58 return (*this)(i,j);
59}
60
61const real_t &DenseSymmetricMatrix::Elem(int i, int j) const
62{
63 return (*this)(i,j);
64}
65
67{
68 int s = GetStoredSize();
69 for (int i = 0; i < s; i++)
70 {
71 data[i] *= c;
72 }
73 return *this;
74}
75
77{
78 mfem_error("DenseSymmetricMatrix::Mult() not implemented!");
79}
80
82{
83 mfem_error("DenseSymmetricMatrix::Inverse() not implemented!");
84 return nullptr;
85}
86
87}
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
Definition array.hpp:840
void SetSize(int s)
Change the size of the DenseSymmetricMatrix to s x s.
Definition symmat.cpp:32
DenseSymmetricMatrix & operator*=(real_t c)
Definition symmat.cpp:66
int GetStoredSize() const
Return the number of stored nonzeros in the matrix.
Definition symmat.hpp:79
MatrixInverse * Inverse() const override
Returns a pointer to (an approximation) of the matrix inverse.
Definition symmat.cpp:81
void Mult(const Vector &x, Vector &y) const override
Matrix vector multiplication.
Definition symmat.cpp:76
DenseSymmetricMatrix & operator=(real_t c)
Sets the matrix elements equal to constant c.
Definition symmat.cpp:46
real_t & Elem(int i, int j) override
Returns reference to a_{ij}.
Definition symmat.cpp:56
Abstract data type for matrix inverse.
Definition matrix.hpp:63
Abstract data type matrix.
Definition matrix.hpp:28
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:82
void mfem_error(const char *msg)
Definition error.cpp:154
float real_t
Definition config.hpp:46