Reference documentation for deal.II version 8.5.1
|
#include <deal.II/lac/vector_view.h>
Public Types | |
typedef types::global_dof_index | size_type |
Public Types inherited from Vector< Number > | |
typedef Number | value_type |
typedef numbers::NumberTraits< Number >::real_type | real_type |
Public Member Functions | |
VectorView (const size_type new_size, Number *ptr) | |
VectorView (const size_type new_size, const Number *ptr) | |
~VectorView () | |
virtual void | reinit (const size_type N, const bool omit_zeroing_entries=false) |
void | reinit (const size_type N, Number *ptr) |
void | reinit (const size_type N, const Number *ptr) |
virtual void | swap (Vector< Number > &v) |
Public Member Functions inherited from Vector< Number > | |
Vector () | |
Vector (const Vector< Number > &v) | |
Vector (Vector< Number > &&v) | |
template<typename OtherNumber > | |
Vector (const Vector< OtherNumber > &v) | |
Vector (const PETScWrappers::Vector &v) | |
Vector (const PETScWrappers::MPI::Vector &v) | |
Vector (const TrilinosWrappers::MPI::Vector &v) | |
Vector (const TrilinosWrappers::Vector &v) | |
Vector (const size_type n) | |
template<typename InputIterator > | |
Vector (const InputIterator first, const InputIterator last) | |
virtual | ~Vector () |
void | compress (::VectorOperation::values operation=::VectorOperation::unknown) const |
template<typename Number2 > | |
void | reinit (const Vector< Number2 > &V, const bool omit_zeroing_entries=false) |
Vector< Number > & | operator= (const Number s) |
Vector< Number > & | operator= (const Vector< Number > &v) |
Vector< Number > & | operator= (Vector< Number > &&v) |
template<typename Number2 > | |
Vector< Number > & | operator= (const Vector< Number2 > &v) |
Vector< Number > & | operator= (const BlockVector< Number > &v) |
Vector< Number > & | operator= (const PETScWrappers::Vector &v) |
Vector< Number > & | operator= (const PETScWrappers::MPI::Vector &v) |
Vector< Number > & | operator= (const TrilinosWrappers::MPI::Vector &v) |
Vector< Number > & | operator= (const TrilinosWrappers::Vector &v) |
template<typename Number2 > | |
bool | operator== (const Vector< Number2 > &v) const |
template<typename Number2 > | |
bool | operator!= (const Vector< Number2 > &v) const |
template<typename Number2 > | |
Number | operator* (const Vector< Number2 > &V) const |
real_type | norm_sqr () const |
Number | mean_value () const |
real_type | l1_norm () const |
real_type | l2_norm () const |
real_type | lp_norm (const real_type p) const |
real_type | linfty_norm () const |
Number | add_and_dot (const Number a, const Vector< Number > &V, const Vector< Number > &W) |
iterator | begin () |
const_iterator | begin () const |
iterator | end () |
const_iterator | end () const |
Number | operator() (const size_type i) const |
Number & | operator() (const size_type i) |
Number | operator[] (const size_type i) const |
Number & | operator[] (const size_type i) |
template<typename OtherNumber > | |
void | extract_subvector_to (const std::vector< size_type > &indices, std::vector< OtherNumber > &values) const |
template<typename ForwardIterator , typename OutputIterator > | |
void | extract_subvector_to (ForwardIterator indices_begin, const ForwardIterator indices_end, OutputIterator values_begin) const |
Vector< Number > & | operator+= (const Vector< Number > &V) |
Vector< Number > & | operator-= (const Vector< Number > &V) |
template<typename OtherNumber > | |
void | add (const std::vector< size_type > &indices, const std::vector< OtherNumber > &values) |
template<typename OtherNumber > | |
void | add (const std::vector< size_type > &indices, const Vector< OtherNumber > &values) |
template<typename OtherNumber > | |
void | add (const size_type n_elements, const size_type *indices, const OtherNumber *values) |
void | add (const Number s) |
void | add (const Vector< Number > &V) 1 |
void | add (const Number a, const Vector< Number > &V, const Number b, const Vector< Number > &W) |
void | add (const Number a, const Vector< Number > &V) |
void | sadd (const Number s, const Vector< Number > &V) |
void | sadd (const Number s, const Number a, const Vector< Number > &V) |
void | sadd (const Number s, const Number a, const Vector< Number > &V, const Number b, const Vector< Number > &W) 1 |
void | sadd (const Number s, const Number a, const Vector< Number > &V, const Number b, const Vector< Number > &W, const Number c, const Vector< Number > &X) 1 |
Vector< Number > & | operator*= (const Number factor) |
Vector< Number > & | operator/= (const Number factor) |
void | scale (const Vector< Number > &scaling_factors) |
template<typename Number2 > | |
void | scale (const Vector< Number2 > &scaling_factors) |
void | equ (const Number a, const Vector< Number > &u) |
template<typename Number2 > | |
void | equ (const Number a, const Vector< Number2 > &u) |
void | equ (const Number a, const Vector< Number > &u, const Number b, const Vector< Number > &v) 1 |
void | equ (const Number a, const Vector< Number > &u, const Number b, const Vector< Number > &v, const Number c, const Vector< Number > &w) 1 |
void | ratio (const Vector< Number > &a, const Vector< Number > &b) 1 |
void | update_ghost_values () const |
void | print (const char *format=0) const 1 |
void | print (std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const |
void | print (LogStream &out, const unsigned int width=6, const bool across=true) const 1 |
void | block_write (std::ostream &out) const |
void | block_read (std::istream &in) |
template<class Archive > | |
void | save (Archive &ar, const unsigned int version) const |
template<class Archive > | |
void | load (Archive &ar, const unsigned int version) |
bool | in_local_range (const size_type global_index) const |
IndexSet | locally_owned_elements () const |
std::size_t | size () const |
bool | all_zero () const |
bool | is_non_negative () const |
std::size_t | memory_consumption () const |
Public Member Functions inherited from Subscriptor | |
Subscriptor () | |
Subscriptor (const Subscriptor &) | |
Subscriptor (Subscriptor &&) | |
virtual | ~Subscriptor () |
Subscriptor & | operator= (const Subscriptor &) |
Subscriptor & | operator= (Subscriptor &&) |
void | subscribe (const char *identifier=0) const |
void | unsubscribe (const char *identifier=0) const |
unsigned int | n_subscriptions () const |
void | list_subscribers () const |
template<class Archive > | |
void | serialize (Archive &ar, const unsigned int version) |
Additional Inherited Members | |
Static Public Member Functions inherited from Subscriptor | |
static ::ExceptionBase & | ExcInUse (int arg1, char *arg2, std::string &arg3) |
static ::ExceptionBase & | ExcNoSubscriber (char *arg1, char *arg2) |
Static Public Attributes inherited from Vector< Number > | |
static const bool | supports_distributed_data = false |
Protected Attributes inherited from Vector< Number > | |
size_type | vec_size |
size_type | max_vec_size |
Number * | val |
std_cxx11::shared_ptr< parallel::internal::TBBPartitioner > | thread_loop_partitioner |
Related Functions inherited from Vector< Number > | |
template<typename Number > | |
void | swap (LinearAlgebra::distributed::Vector< Number > &u, LinearAlgebra::distributed::Vector< Number > &v) |
template<typename Number > | |
void | swap (LinearAlgebra::ReadWriteVector< Number > &u, LinearAlgebra::ReadWriteVector< Number > &v) |
template<typename Number > | |
void | swap (Vector< Number > &u, Vector< Number > &v) |
View of a numerical vector of data. This class provides an interface compatible with the Vector<double> class (from which it is inherited), that allows fast access to locations of memory already allocated with arrays of type Number.
This is in the same style of the vector view in the Trilinos library.
You should consider using the VectorView object ONLY when ALL of the following requirements are met:
Notice that NO CHECKS are performed on the actual memory, and if you try to access illegal areas of memory, your computer will suffer from it. Once again, use this class ONLY if you know exactly what you are doing.
Two constructors are provided. One for read-write access, and one for read only access, and you are allowed to use this class on objects of type const Number*. However you should be aware of the fact that the constness of the array pointed to is ignored, which means that you should only use the const constructor when the actual object you are constructing is itself a constant object. As a corollary, you will be allowed to call even functions of the base class that change data of the array; this being a violation of the C++ type model, you should make sure that this only happens if it is really valid and, in general, if you know what you are doing.
Since this class does not own the memory that you are accessing, you have to make sure that the lifetime of the section of memory you are viewing is longer than this object. No attempt is made to ensure that this is the case.
An example usage of this class is the following:
<float>, <double>, <std::complex<float>>, <std::complex<double>>
; others can be generated in application programs (see the section on Template instantiations in the manual).typedef types::global_dof_index VectorView< Number >::size_type |
Declare type for container size.
Definition at line 138 of file vector_view.h.
VectorView< Number >::VectorView | ( | const size_type | new_size, |
Number * | ptr | ||
) |
Read write constructor. Takes the size of the vector, just like the standard one, but the data is picked starting from the location of the pointer ptr
.
VectorView< Number >::VectorView | ( | const size_type | new_size, |
const Number * | ptr | ||
) |
The constant constructor is the same as above, however you will not be able to access the data for write access.
You should only use this class by constructing it as a const VectorView<double>(size, ptr) object.
Undefined behavior will occur if you construct it as a non const object or attempt to write on it.
VectorView< Number >::~VectorView | ( | ) |
This destructor will only reset the internal sizes and the internal pointers, but it will NOT clear the memory.
|
virtual |
The reinit function of this object has a behavior which is different from the one of the base class. VectorView does not handle memory, and you should not attempt to resize the memory that is pointed to by this object using the reinit function. You can, however, resize the view that you have of the original object. Notice that it is your own responsibility to ensure that the memory you are pointing to is big enough.
Similarly to what happens in the base class, if 'omit_zeroing_entries' is false, then the entire content of the vector is set to 0, otherwise the content of the memory is left unchanged.
Notice that the following snippet of code may not produce what you expect:
In the above case, the Vector<double>::reinit method is called, and a NEW area of memory is reserved, possibly not starting at the same place as before. However, the VectorView<double> object keeps pointing to the same old area. After the two reinits, any call to view_of_long_vector(i), with i>0 might cause an attempt to access invalid areas of memory, or might function properly, depending on whether or not the system was able to allocate some memory consecutively after the original allocation.
In any case, you should not rely on this behavior, and you should only call this reinit function if you really know what you are doing.
Reimplemented from Vector< Number >.
void VectorView< Number >::reinit | ( | const size_type | N, |
Number * | ptr | ||
) |
This reinit function is equivalent to constructing a new object with the given size, starting from the pointer ptr.
void VectorView< Number >::reinit | ( | const size_type | N, |
const Number * | ptr | ||
) |
This reinit function is equivalent to constructing a new object with the given size, starting from the pointer ptr. The same considerations made for the constructor apply here.
|
virtual |
This function is here to prevent memory corruption. It should never be called, and will throw an exception if you try to do so.
Reimplemented from Vector< Number >.