PolyDiM
C++ library for POLYtopal DIscretization Methods
Loading...
Searching...
No Matches
ISparseArray.hpp
Go to the documentation of this file.
1// _LICENSE_HEADER_
2//
3// Copyright (C) 2019 - 2025.
4// Terms register on the GPL-3.0 license.
5//
6// This file can be redistributed and/or modified under the license terms.
7//
8// See top level LICENSE file for more details.
9//
10// This file can be used citing references in CITATION.cff file.
11
12#ifndef __ISPARSEArray_HPP
13#define __ISPARSEArray_HPP
14
15#include "Eigen/Eigen"
16#include <ostream>
17#include <vector>
18
19namespace Gedim
20{
21class IArray;
22
25{
26 public:
28 {
29 None = 0,
30 Lower = 1,
31 Upper = 2,
32 Symmetric = 3,
33 Diagonal = 4
34 };
35
37 {
38 SVDLapack = 0,
39 CondestLapack = 1,
41 };
42
43 public:
44 virtual ~ISparseArray()
45 {
46 }
47
52 virtual void SetSize(const unsigned int &numRows,
53 const unsigned int &numCols,
55
57 virtual SparseArrayTypes Type() const = 0;
58
61 virtual void Create() = 0;
62 virtual void Destroy() = 0;
64 virtual void Flush() = 0;
65
67 virtual void Reset() = 0;
69 virtual void Triplet(const unsigned int &i, const unsigned int &j, const double &val) = 0;
72 virtual void Triplets(const std::vector<unsigned int> &i, const std::vector<unsigned int> &j, const std::vector<double> &val) = 0;
73
75 virtual double Norm() const = 0;
76
78 virtual std::ostream &Print(std::ostream &output) const = 0;
79
83 virtual void ToBinaryFile(const std::string &filePath, const bool &append = false) const = 0;
84
88
90 virtual unsigned int NonZeros() const = 0;
91
92 virtual ISparseArray &operator+=(const ISparseArray &A) = 0;
93 virtual ISparseArray &operator-=(const ISparseArray &A) = 0;
94 virtual ISparseArray &operator*=(const double &c) = 0;
95 virtual ISparseArray &operator/=(const double &c) = 0;
96
101 inline friend std::ostream &operator<<(std::ostream &output, const ISparseArray &b)
102 {
103 return b.Print(output);
104 }
106};
107} // namespace Gedim
108
109#endif // __ISPARSEArray_HPP
Eigen column vector.
Definition Eigen_Array.hpp:23
Interface used for sparse Array of double.
Definition ISparseArray.hpp:25
virtual ISparseArray & operator+=(const ISparseArray &A)=0
virtual void Destroy()=0
virtual ISparseArray & operator/=(const double &c)=0
virtual void Reset()=0
Put zero-values in the Matrix.
virtual void Flush()=0
Intermediate flush of the Matrix during creation.
virtual ~ISparseArray()
Definition ISparseArray.hpp:44
virtual void Create()=0
Matrix Allocation is implemented in child classes.
virtual void Triplets(const std::vector< unsigned int > &i, const std::vector< unsigned int > &j, const std::vector< double > &val)=0
Given the row indices i and the column indices j the values val are put into the Matrix in ADD or INS...
virtual ISparseArray & operator*=(const double &c)=0
virtual unsigned int NonZeros() const =0
virtual ISparseArray & operator-=(const ISparseArray &A)=0
SparseArrayTypes
Definition ISparseArray.hpp:28
virtual double Cond(const ISparseArray::ConditionNumberAlgorithm &algorithm=ISparseArray::ConditionNumberAlgorithm::SVDLapack) const =0
ConditionNumberAlgorithm
Definition ISparseArray.hpp:37
virtual void SetSize(const unsigned int &numRows, const unsigned int &numCols, const SparseArrayTypes &type=SparseArrayTypes::None)=0
Resize the Matrix.
virtual std::ostream & Print(std::ostream &output) const =0
Print the array.
virtual SparseArrayTypes Type() const =0
virtual void Triplet(const unsigned int &i, const unsigned int &j, const double &val)=0
Given the row index i and the column index j the value val is put into the Matrix in ADD or INSERT mo...
virtual double Norm() const =0
virtual void ToBinaryFile(const std::string &filePath, const bool &append=false) const =0
Write sparse array to binary file.
friend std::ostream & operator<<(std::ostream &output, const ISparseArray &b)
operator <<
Definition ISparseArray.hpp:101
Definition Eigen_Array.cpp:22