reconciliation_lib 0.1
Library for data reconciliation algorithms
Loading...
Searching...
No Matches
dvrlib::vector Class Reference

RAII wrapper around a heap-allocated gsl_vector. More...

#include <gsl_wrapper.h>

Public Member Functions

 vector (int n)
 Allocate an uninitialised vector of length n.
 
 vector (int n, double x)
 Allocate a vector of length n with all elements set to x.
 
 vector (int n, const double *x)
 Allocate a vector of length n and copy values from the array x.
 
 vector (const vector &src)
 Copy constructor.
 
 ~vector ()
 Destructor — frees the underlying GSL allocation.
 
gsl_vectorgsl_internal ()
 Return a pointer to the underlying gsl_vector (mutable).
 
const gsl_vectorgsl_internal () const
 Return a pointer to the underlying gsl_vector (read-only).
 
int size () const
 Return the number of elements.
 
void set (int i, double val)
 Set element i to val.
 
double get (int i) const
 Return element i.
 
double operator[] (int i) const
 Return element i (read-only subscript).
 
vectoroperator= (const vector &src)
 Copy-assign from another vector.
 
vectoroperator= (const vector_view &src)
 Copy-assign from a view.
 
vectoroperator+= (const vector &src)
 
vector operator+ (const vector &src) const
 
vectoroperator-= (const vector &src)
 
vector operator- (const vector &src) const
 
vector operator- () const
 Unary negation — returns -(*this).
 
vectoroperator*= (double d)
 Scale all elements by d in place.
 
vector operator* (double d) const
 Return a copy scaled by d.
 
double norm1 () const
 Return the L1 norm (sum of absolute values).
 
double norm2 () const
 Return the L2 (Euclidean) norm.
 
vector_view subvector (int k, int n)
 Return a view of n elements starting at index k.
 
const vector_view subvector (int k, int n) const
 Return a view of n elements starting at index k.
 

Private Attributes

gsl_vectorv
 

Friends

class matrix
 

Detailed Description

RAII wrapper around a heap-allocated gsl_vector.

Owns the underlying GSL allocation and frees it on destruction. Arithmetic operators follow GSL semantics (element-wise).

Constructor & Destructor Documentation

◆ vector() [1/4]

dvrlib::vector::vector ( int  n)

Allocate an uninitialised vector of length n.

◆ vector() [2/4]

dvrlib::vector::vector ( int  n,
double  x 
)

Allocate a vector of length n with all elements set to x.

◆ vector() [3/4]

dvrlib::vector::vector ( int  n,
const double x 
)

Allocate a vector of length n and copy values from the array x.

◆ vector() [4/4]

dvrlib::vector::vector ( const vector src)

Copy constructor.

◆ ~vector()

dvrlib::vector::~vector ( )

Destructor — frees the underlying GSL allocation.

Member Function Documentation

◆ get()

double dvrlib::vector::get ( int  i) const

Return element i.

◆ gsl_internal() [1/2]

gsl_vector * dvrlib::vector::gsl_internal ( )

Return a pointer to the underlying gsl_vector (mutable).

◆ gsl_internal() [2/2]

const gsl_vector * dvrlib::vector::gsl_internal ( ) const

Return a pointer to the underlying gsl_vector (read-only).

◆ norm1()

double dvrlib::vector::norm1 ( ) const

Return the L1 norm (sum of absolute values).

◆ norm2()

double dvrlib::vector::norm2 ( ) const

Return the L2 (Euclidean) norm.

◆ operator*()

Return a copy scaled by d.

◆ operator*=()

Scale all elements by d in place.

◆ operator+()

◆ operator+=()

◆ operator-() [1/2]

Unary negation — returns -(*this).

◆ operator-() [2/2]

◆ operator-=()

◆ operator=() [1/2]

Copy-assign from another vector.

◆ operator=() [2/2]

Copy-assign from a view.

◆ operator[]()

Return element i (read-only subscript).

◆ set()

void dvrlib::vector::set ( int  i,
double  val 
)

Set element i to val.

◆ size()

int dvrlib::vector::size ( ) const

Return the number of elements.

◆ subvector() [1/2]

vector_view dvrlib::vector::subvector ( int  k,
int  n 
)

Return a view of n elements starting at index k.

Parameters
[in]kStart index (0-based).
[in]nNumber of elements in the sub-vector.

◆ subvector() [2/2]

const vector_view dvrlib::vector::subvector ( int  k,
int  n 
) const

Return a view of n elements starting at index k.

Parameters
[in]kStart index (0-based).
[in]nNumber of elements in the sub-vector.

Friends And Related Symbol Documentation

◆ matrix

Member Data Documentation

◆ v

gsl_vector* dvrlib::vector::v
private

The documentation for this class was generated from the following files: