DuQuad  v1.0
Quadratic Programming Optimizations
 All Data Structures Files Functions Variables Typedefs Macros
math_functions.h
Go to the documentation of this file.
1 /*
2  * math_functions.h
3  *
4  * Created on: Aug 21, 2014
5  * Author: Sverre
6  */
7 
8 /** \file
9  * Header for the internal math library. Contains basic vector and matrix operations. The library is tried to be as optimized as possible.
10  */
11 
12 #ifndef MATH_FUNCTIONS_H_
13 #define MATH_FUNCTIONS_H_
14 
15 #include "head.h"
16 
17 
18 /** matrix-vector multiplication: res = mtx * v */
19 void mtx_vec_mul(const real_t *mtx, const real_t *v, real_t *res, const uint32_t rows, const uint32_t cols);
20 
21 /** Computes the transpose of the matrix: mtx_t = transpose(mtx) */
22 void mtx_transpose(const real_t * mtx, real_t * mtx_t, const uint32_t rows, const uint32_t cols);
23 
24 /** compare two vectors element by element, and returns the smallest element of the two: res = min(v1,v2) */
25 void vector_min(const real_t *v1, const real_t *v2, real_t *res, const uint32_t length);
26 
27 /** compare two vectors element by element, and returns the largest element of the two: res = max(v1,v2) */
28 void vector_max(const real_t *v1, const real_t *v2, real_t *res, const uint32_t length);
29 
30 /** vector subtract: res = v1 - v2 */
31 void vector_sub(const real_t *v1, const real_t *v2, real_t *res, const uint32_t length);
32 
33 /** vector addition res = v1 + v2 */
34 void vector_add(const real_t *v1, const real_t *v2, real_t *res, const uint32_t length);
35 
36 /** vector multiplication: res = v1 * v2 */
37 real_t vector_mul(const real_t *v1,const real_t *v2, const uint32_t length);
38 
39 /** Vector times a scalar: res = v1 * scalar */
40 void vector_scalar_mul(const real_t *v1, const real_t scalar, real_t *res, const uint32_t length);
41 
42 /** set all elements in vector v to zero */
43 void vector_elements_to_zero(real_t *v, const uint32_t length);// may not be optimal
44 
45 /** returns true if all elements in the two vectors are equal */
46 uint32_t vector_is_equal(const real_t *v1, const real_t *v2, const uint32_t length);
47 
48 /** copy a vector element by element: v2 = v1 */
49 void vector_copy(const real_t *v1, real_t *v2, const uint32_t length);
50 
51 /** project a vector on all positive numbers: v = max(v,0.0) */
52 void vector_max_with_zero(real_t *v, const uint32_t length);
53 
54 /** compute the euclidean norm of the vector v */
55 real_t vector_norm_2(real_t *v, const uint32_t length);
56 
57 /** return the absolute value of the input */
58 real_t abs_2(const real_t a);
59 
60 /** compute the primal objective function */
61 real_t obj(const real_t *z, const real_t *H, const real_t *c, real_t *temp);
62 
63 #endif /* MATH_FUNCTIONS_H_ */
void vector_add(const real_t *v1, const real_t *v2, real_t *res, const uint32_t length)
real_t abs_2(const real_t a)
unsigned int uint32_t
Definition: typedefs.h:19
real_t obj(const real_t *z, const real_t *H, const real_t *c, real_t *temp)
void vector_min(const real_t *v1, const real_t *v2, real_t *res, const uint32_t length)
uint32_t vector_is_equal(const real_t *v1, const real_t *v2, const uint32_t length)
void vector_elements_to_zero(real_t *v, const uint32_t length)
void vector_sub(const real_t *v1, const real_t *v2, real_t *res, const uint32_t length)
void vector_max_with_zero(real_t *v, const uint32_t length)
void mtx_transpose(const real_t *mtx, real_t *mtx_t, const uint32_t rows, const uint32_t cols)
real_t vector_norm_2(real_t *v, const uint32_t length)
void vector_copy(const real_t *v1, real_t *v2, const uint32_t length)
float64_t real_t
Definition: typedefs.h:25
void vector_scalar_mul(const real_t *v1, const real_t scalar, real_t *res, const uint32_t length)
void mtx_vec_mul(const real_t *mtx, const real_t *v, real_t *res, const uint32_t rows, const uint32_t cols)
void vector_max(const real_t *v1, const real_t *v2, real_t *res, const uint32_t length)
real_t vector_mul(const real_t *v1, const real_t *v2, const uint32_t length)