QPALM 1.1.2
Proximal Augmented Lagrangian method for Quadratic Programs
All Data Structures Namespaces Files Functions Variables Typedefs Macros Modules Pages
Functions
lin_alg.c File Reference

Detailed Description

Linear algebra with vectors.

Author
Ben Hermans

Common operations, such as vector products, infinity norm, elementwise add/product/division/max etc. are included in this file.

Definition in file lin_alg.c.

#include "lin_alg.h"
+ Include dependency graph for lin_alg.c:

Go to the source code of this file.

Functions

c_floatvec_copy (const c_float *a, size_t n)
 Copy vector a into output. More...
 
void prea_vec_copy (const c_float *a, c_float *b, size_t n)
 Copy vector a into preallocated vector b. More...
 
void prea_int_vec_copy (const c_int *a, c_int *b, size_t n)
 Copy integer vector a into preallocated vector b. More...
 
void vec_set_scalar (c_float *a, c_float sc, size_t n)
 Fill float vector with a scalar value. More...
 
void vec_set_scalar_int (c_int *a, c_int sc, size_t n)
 Fill int vector with a scalar value. More...
 
void vec_self_mult_scalar (c_float *a, c_float sc, size_t n)
 Mulitply vector with a constant scale factor. More...
 
void vec_mult_scalar (const c_float *a, c_float sc, c_float *b, size_t n)
 Mulitply vector with a constant scale factor and store in a different vector. More...
 
c_float vec_prod (const c_float *a, const c_float *b, size_t n)
 Inner product between two vectors, aTb. More...
 
c_float vec_norm_two (const c_float *a, size_t n)
 2-norm of a vector, a2. More...
 
void vec_ew_prod (const c_float *a, const c_float *b, c_float *c, size_t n)
 Elementwise product, ci=aibi. More...
 
void vec_ew_div (const c_float *a, const c_float *b, c_float *c, size_t n)
 Elementwise division, ci=ai/bi. More...
 
void vec_add_scaled (const c_float *a, const c_float *b, c_float *c, c_float sc, size_t n)
 Scaled addition of one vector to another vector, ci=ai+scbi. More...
 
void vec_mult_add_scaled (c_float *a, const c_float *b, c_float sc1, c_float sc2, size_t n)
 Scaled addition of one vector to another vector, both being scaled, ai=sc1ai+sc2bi. More...
 
c_float vec_norm_inf (const c_float *a, size_t n)
 Infinity norm of a vector, a. More...
 
void vec_ew_recipr (const c_float *a, c_float *b, size_t n)
 Elementwise reciprocal bi=1/ai. More...
 
void vec_ew_max_vec (const c_float *a, const c_float *b, c_float *c, size_t n)
 Elementwise maximum between vectors, ci=max(ai,bi). More...
 
void vec_ew_min_vec (const c_float *a, const c_float *b, c_float *c, size_t n)
 Elementwise minimum between vectors, ci=min(ai,bi). More...
 
void vec_ew_mid_vec (const c_float *a, const c_float *bmin, const c_float *bmax, c_float *c, size_t n)
 Elementwise mid between vectors, ci=max(bmin,i,min(ai,bmax,i)). More...
 
void vec_ew_sqrt (const c_float *a, c_float *b, size_t n)
 Elementwise square root, bi=ai. More...
 

Function Documentation

◆ prea_int_vec_copy()

void prea_int_vec_copy ( const c_int a,
c_int b,
size_t  n 
)

Copy integer vector a into preallocated vector b.

Parameters
aInput vector
bOutput vector
nVector length

Definition at line 32 of file lin_alg.c.

+ Here is the caller graph for this function:

◆ prea_vec_copy()

void prea_vec_copy ( const c_float a,
c_float b,
size_t  n 
)

Copy vector a into preallocated vector b.

Parameters
aInput vector
bOutput vector
nVector length

Definition at line 24 of file lin_alg.c.

+ Here is the caller graph for this function:

◆ vec_add_scaled()

void vec_add_scaled ( const c_float a,
const c_float b,
c_float c,
c_float  sc,
size_t  n 
)

Scaled addition of one vector to another vector, ci=ai+scbi.

Parameters
aInput vector
bInput vector
cOutput vector
scScaling value
nVector length

Definition at line 110 of file lin_alg.c.

+ Here is the caller graph for this function:

◆ vec_copy()

c_float * vec_copy ( const c_float a,
size_t  n 
)

Copy vector a into output.

Warning
This function uses malloc.
Parameters
aVector
nVector length
Returns
Copy of a

Definition at line 11 of file lin_alg.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vec_ew_div()

void vec_ew_div ( const c_float a,
const c_float b,
c_float c,
size_t  n 
)

Elementwise division, ci=ai/bi.

Parameters
aInput vector
bInput vector
cOutput vector
nVector length

Definition at line 101 of file lin_alg.c.

+ Here is the caller graph for this function:

◆ vec_ew_max_vec()

void vec_ew_max_vec ( const c_float a,
const c_float b,
c_float c,
size_t  n 
)

Elementwise maximum between vectors, ci=max(ai,bi).

Parameters
aInput vector
bInput vector
cOutput vector
nVector length

Definition at line 184 of file lin_alg.c.

◆ vec_ew_mid_vec()

void vec_ew_mid_vec ( const c_float a,
const c_float bmin,
const c_float bmax,
c_float c,
size_t  n 
)

Elementwise mid between vectors, ci=max(bmin,i,min(ai,bmax,i)).

Parameters
aInput vector
bminLower bounds
bmaxUpper bounds
cOutput vector
nVector length

Definition at line 200 of file lin_alg.c.

+ Here is the caller graph for this function:

◆ vec_ew_min_vec()

void vec_ew_min_vec ( const c_float a,
const c_float b,
c_float c,
size_t  n 
)

Elementwise minimum between vectors, ci=min(ai,bi).

Parameters
aInput vector
bInput vector
cOutput vector
nVector length

Definition at line 192 of file lin_alg.c.

◆ vec_ew_prod()

void vec_ew_prod ( const c_float a,
const c_float b,
c_float c,
size_t  n 
)

Elementwise product, ci=aibi.

Parameters
aInput vector
bInput vector
cOutput vector
nVector length

Definition at line 92 of file lin_alg.c.

+ Here is the caller graph for this function:

◆ vec_ew_recipr()

void vec_ew_recipr ( const c_float a,
c_float b,
size_t  n 
)

Elementwise reciprocal bi=1/ai.

This function is used in scaling.

Parameters
aInput vector
bOutput vector
nVector length

Definition at line 176 of file lin_alg.c.

+ Here is the caller graph for this function:

◆ vec_ew_sqrt()

void vec_ew_sqrt ( const c_float a,
c_float b,
size_t  n 
)

Elementwise square root, bi=ai.

Parameters
aInput vector
bOutput vector
nVector length

Definition at line 208 of file lin_alg.c.

+ Here is the caller graph for this function:

◆ vec_mult_add_scaled()

void vec_mult_add_scaled ( c_float a,
const c_float b,
c_float  sc1,
c_float  sc2,
size_t  n 
)

Scaled addition of one vector to another vector, both being scaled, ai=sc1ai+sc2bi.

Parameters
aInput and Output vector
bInput vector
sc1Scaling value for a
sc2Scaling value for b
nVector length

Definition at line 118 of file lin_alg.c.

+ Here is the caller graph for this function:

◆ vec_mult_scalar()

void vec_mult_scalar ( const c_float a,
c_float  sc,
c_float b,
size_t  n 
)

Mulitply vector with a constant scale factor and store in a different vector.

Parameters
aInput vector
scValue
bOutput vector
nVector length

Definition at line 64 of file lin_alg.c.

◆ vec_norm_inf()

c_float vec_norm_inf ( const c_float a,
size_t  n 
)

Infinity norm of a vector, a.

Parameters
aVector
nVector length
Returns
Infinity norm of a

Definition at line 126 of file lin_alg.c.

+ Here is the caller graph for this function:

◆ vec_norm_two()

c_float vec_norm_two ( const c_float a,
size_t  n 
)

2-norm of a vector, a2.

Parameters
aVector
nVector length
Returns
2-norm of a

Definition at line 88 of file lin_alg.c.

+ Here is the call graph for this function:

◆ vec_prod()

c_float vec_prod ( const c_float a,
const c_float b,
size_t  n 
)

Inner product between two vectors, aTb.

Parameters
aVector
bVector
nVector length
Returns
Result of the inner product

Definition at line 72 of file lin_alg.c.

+ Here is the caller graph for this function:

◆ vec_self_mult_scalar()

void vec_self_mult_scalar ( c_float a,
c_float  sc,
size_t  n 
)

Mulitply vector with a constant scale factor.

Parameters
aVector
scValue
nVector length

Definition at line 56 of file lin_alg.c.

+ Here is the caller graph for this function:

◆ vec_set_scalar()

void vec_set_scalar ( c_float a,
c_float  sc,
size_t  n 
)

Fill float vector with a scalar value.

Parameters
aVector
scValue
nVector length

Definition at line 40 of file lin_alg.c.

+ Here is the caller graph for this function:

◆ vec_set_scalar_int()

void vec_set_scalar_int ( c_int a,
c_int  sc,
size_t  n 
)

Fill int vector with a scalar value.

Parameters
aVector
scValue
nVector length

Definition at line 48 of file lin_alg.c.

+ Here is the caller graph for this function: