Class AmiVector

Class Documentation

class AmiVector

AmiVector class provides a generic interface to the NVector_Serial struct

Public Functions

AmiVector() = default

Default constructor.

inline explicit AmiVector(long int const length)

empty constructor

Creates an std::vector<realtype> and attaches the data pointer to a newly created N_Vector_Serial. Using N_VMake_Serial ensures that the N_Vector module does not try to deallocate the data vector when calling N_VDestroy_Serial

Parameters:

length – number of elements in vector

inline explicit AmiVector(std::vector<realtype> rvec)

constructor from std::vector,

Moves data from std::vector and constructs an nvec that points to the data

Parameters:

rvec – vector from which the data will be moved

inline explicit AmiVector(gsl::span<realtype const> rvec)

constructor from gsl::span,

Copy data from gsl::span and constructs a vector

Parameters:

rvec – vector from which the data will be copied

inline AmiVector(AmiVector const &vold)

copy constructor

Parameters:

vold – vector from which the data will be copied

inline AmiVector(AmiVector &&other) noexcept

move constructor

Parameters:

other – vector from which the data will be moved

~AmiVector()

destructor

AmiVector &operator=(AmiVector const &other)

copy assignment operator

Parameters:

other – right hand side

Returns:

left hand side

inline AmiVector &operator*=(AmiVector const &multiplier)

operator *= (element-wise multiplication)

Parameters:

multiplier – multiplier

Returns:

result

inline AmiVector &operator/=(AmiVector const &divisor)

operator /= (element-wise division)

Parameters:

divisor – divisor

Returns:

result

inline auto begin()

Returns an iterator that points to the first element of the vector.

Returns:

iterator that points to the first element

inline auto end()

Returns an iterator that points to one element after the last element of the vector.

Returns:

iterator that points to one element after the last element

realtype *data()

data accessor

Returns:

pointer to data array

realtype const *data() const

const data accessor

Returns:

const pointer to data array

N_Vector getNVector()

N_Vector accessor.

Returns:

N_Vector

const_N_Vector getNVector() const

N_Vector accessor.

Returns:

N_Vector

std::vector<realtype> const &getVector() const

Vector accessor.

Returns:

Vector

int getLength() const

returns the length of the vector

Returns:

length

void zero()

fills vector with zero values

void minus()

changes the sign of data elements

void set(realtype val)

sets all data elements to a specific value

Parameters:

val – value for data elements

realtype &operator[](int pos)

accessor to data elements of the vector

Parameters:

pos – index of element

Returns:

element

realtype &at(int pos)

accessor to data elements of the vector

Parameters:

pos – index of element

Returns:

element

realtype const &at(int pos) const

accessor to data elements of the vector

Parameters:

pos – index of element

Returns:

element

void copy(AmiVector const &other)

copies data from another AmiVector

Parameters:

other – data source

inline void abs()

Take absolute value (in-place)

Friends

template<class Archive>
friend void serialize(Archive &ar, AmiVector &s, unsigned int version)

Serialize AmiVector (see boost::serialization::serialize)

Parameters:
  • ar – Archive to serialize to

  • s – Data to serialize

  • version – Version number