14#include "arcane/utils/Array.h"
15#include "arcane/utils/String.h"
16#include "arcane/utils/FatalErrorException.h"
18#include "arcane/core/matvec/Vector.h"
25namespace Arcane::MatVec
41 : m_values(size, init_value)
44 m_values.fill(init_value);
55 VectorImpl(
const VectorImpl& rhs)
56 : m_values(rhs.m_values)
63 void operator=(
const VectorImpl& rhs);
67 Integer size()
const {
return m_values.size(); }
70 void dump(std::ostream& o)
const
73 o <<
"(Vector ptr=" <<
this <<
" size=" << size <<
")\n";
74 for (
Integer i = 0; i < size; ++i)
75 o <<
"[" << i <<
"]=" << m_values[i] <<
'\n';
80 return new VectorImpl(m_values);
82 void copy(
const VectorImpl& rhs)
84 m_values.copy(rhs.m_values);
95 void removeReference()
98 if (m_nb_reference == 0)
155 m_impl->removeReference();
166 m_impl->removeReference();
209dump(std::ostream& o)
const
222 for (
Integer i = 0; i < size; ++i) {
223 Real v2 = math::abs(m_values[i]);
245 std::ifstream ifile(file_name.
localstr());
247 ARCANE_FATAL(
"Can not read Hypre vector file='{0}'", file_name);
250 ifile >> std::ws >> xmin >> std::ws >> xmax;
251 Integer nb = (xmax - xmin) + 1;
254 for (
Integer i = 0; i < nb; ++i) {
257 ifile >> std::ws >> column_id >> std::ws >> v;
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
Integer size() const
Number of elements in the vector.
void dump(std::ostream &o) const
Prints the vector values.
static Vector readHypre(const String &file_name)
Initializes a vector using a Hypre format file.
const Vector & operator=(const Vector &rhs)
Changes the vector reference.
Integer size() const
Number of elements in the vector.
~Vector()
Destroys the reference.
VectorImpl * m_impl
Internal representation of the group.
RealArrayView values()
Vector values.
Vector()
Creates an empty vector.
void copy(const Vector &rhs)
Copies the elements of rhs into this vector.
Unicode character string.
const char * localstr() const
Returns the conversion of the instance into UTF-8 encoding.
1D data vector with value semantics (STL style).
Int32 Integer
Type representing an integer.
double Real
Type representing a real number.
ArrayView< Real > RealArrayView
C equivalent of a 1D array of reals.
ConstArrayView< Real > RealConstArrayView
C equivalent of a 1D array of reals.