Vectors


Constant vectors



typedef void * Vec
typedef double * vec
typedef int * ivec
typedef bytebvec
typedef cplxcvec
vec const vec_null
ivec const ivec_null
bvec const bvec_null
cvec const cvec_null

Basic vector allocation, initialization and deletion



vec vec_new_alloc (idx_t length, idx_t length_max)
ivec ivec_new_alloc (idx_t length, idx_t length_max)
bvec bvec_new_alloc (idx_t length, idx_t length_max)
cvec cvec_new_alloc (idx_t length, idx_t length_max)
#define Vec_new_alloc(type_t, N, length_max)   ((type_t *) __Vec_new_alloc(sizeof(type_t), N, length_max ))
Vec __Vec_new (size_t elem_size, idx_t N)
vec vec_new (idx_t length)
ivec ivec_new (idx_t length)
bvec bvec_new (idx_t length)
cvec cvec_new (idx_t length)
#define Vec_new(type_t, N)   ((type_t *) __Vec_new( sizeof(type_t), N ))
void vec_delete (vec v)
void ivec_delete (ivec v)
void bvec_delete (bvec v)
void cvec_delete (cvec v)
#define Vec_delete(v)   free( Vec_header(v).ptr )

Length and max length vector operations



idx_t vec_length (vec v)
idx_t ivec_length (ivec v)
idx_t bvec_length (bvec v)
idx_t cvec_length (cvec v)
#define Vec_length(v)   ( Vec_header(v).length )
idx_t vec_length_max (vec v)
idx_t ivec_length_max (ivec v)
idx_t bvec_length_max (bvec v)
idx_t cvec_length_max (cvec v)
#define Vec_length_max(v)   ( Vec_header(v).length_max )
vec _vec_set_length_max (vec v, idx_t N)
ivec _ivec_set_length_max (ivec v, idx_t N)
bvec _bvec_set_length_max (bvec v, idx_t N)
cvec _cvec_set_length_max (cvec v, idx_t N)
#define Vec_set_length_max(v, N)
#define vec_set_length_max(v, N)   do { v=_vec_set_length_max( v, N ); } while (0)
#define ivec_set_length_max(v, N)   do { v=_ivec_set_length_max( v, N ); } while (0)
#define bvec_set_length_max(v, N)   do { v=_bvec_set_length_max( v, N ); } while (0)
#define cvec_set_length_max(v, N)   do { v=_cvec_set_length_max( v, N ); } while (0)
vec _vec_set_length (vec v, idx_t N)
ivec _ivec_set_length (ivec v, idx_t N)
bvec _bvec_set_length (bvec v, idx_t N)
cvec _cvec_set_length (cvec v, idx_t N)
#define Vec_set_length(v, N)
#define vec_set_length(v, N)   do { v=_vec_set_length( v, N ); } while (0)
#define ivec_set_length(v, N)   do { v=_ivec_set_length( v, N ); } while (0)
#define bvec_set_length(v, N)   do { v=_bvec_set_length( v, N ); } while (0)
#define cvec_set_length(v, N)   do { v=_cvec_set_length( v, N ); } while (0)

Basic vector initialization/modification



vec vec_init (vec v, double *buf, idx_t N)
ivec ivec_init (ivec v, int *buf, idx_t N)
bvec bvec_init (bvec v, byte *buf, idx_t N)
cvec cvec_init (cvec v, cplx *buf, idx_t N)
#define Vec_init(v, buf, N)   memcpy( v, buf, Vec_element_size(v) * (N) );
vec vec_set (vec v, double val)
ivec ivec_set (ivec v, int val)
bvec bvec_set (bvec v, byte val)
cvec cvec_set (cvec v, cplx val)
#define Vec_set(v, val)
vec vec_new_set (double val, idx_t N)
ivec ivec_new_set (int val, idx_t N)
bvec bvec_new_set (byte val, idx_t N)
cvec cvec_new_set (cplx val, idx_t N)
void vec_void (vec)
void ivec_void (ivec)
void bvec_void (bvec)
void cvec_void (cvec)
#define Vec_void(v)
vec vec_new_void ()
ivec ivec_new_void ()
bvec bvec_new_void ()
cvec cvec_new_void ()
#define Vec_new_void(type_t)   Vec_new( type_t, 0 )
void vec_zeros (vec)
void ivec_zeros (ivec)
void bvec_zeros (bvec)
void cvec_zeros (cvec)
vec vec_new_zeros (idx_t N)
ivec ivec_new_zeros (idx_t N)
bvec bvec_new_zeros (idx_t N)
cvec cvec_new_zeros (idx_t N)
void vec_ones (vec)
void ivec_ones (ivec)
void bvec_ones (bvec)
void cvec_ones (cvec)
vec vec_new_ones (idx_t N)
ivec ivec_new_ones (idx_t N)
bvec bvec_new_ones (idx_t N)
cvec cvec_new_ones (idx_t N)
vec vec_set_between (vec v, idx_t i1, idx_t i2, double val)
ivec ivec_set_between (ivec v, idx_t i1, idx_t i2, int val)
bvec bvec_set_between (bvec v, idx_t i1, idx_t i2, byte val)
cvec cvec_set_between (cvec v, idx_t i1, idx_t i2, cplx val)
#define Vec_set_between(v, i1, i2, val)
void vec_set_subvector (vec v, vec s, idx_t idx)
void ivec_set_subvector (ivec v, ivec s, idx_t idx)
void bvec_set_subvector (bvec v, bvec s, idx_t idx)
void cvec_set_subvector (cvec v, cvec s, idx_t idx)
#define Vec_set_subvector(v, s, index)
vec vec_get_subvector (vec v, idx_t i1, idx_t i2)
ivec ivec_get_subvector (ivec v, idx_t i1, idx_t i2)
bvec bvec_get_subvector (bvec v, idx_t i1, idx_t i2)
cvec cvec_get_subvector (cvec v, idx_t i1, idx_t i2)

Comparisons functions



int vec_eq (vec v1, vec v2)
int ivec_eq (ivec v1, ivec v2)
int bvec_eq (bvec v1, bvec v2)
int cvec_eq (cvec v1, cvec v2)
#define Vec_eq(v1, v2)
int vec_geq (vec v1, vec v2)
int ivec_geq (ivec v1, ivec v2)
int bvec_geq (bvec v1, bvec v2)

Copy and Conversions Functions



Vec __Vec_copy (Vec v1, Vec v2)
void vec_copy (vec dest, vec orig)
void ivec_copy (ivec dest, ivec orig)
void bvec_copy (bvec dest, bvec orig)
void cvec_copy (cvec dest, cvec orig)
#define Vec_copy(v1, v2)   __Vec_copy((Vec) v1, (Vec) v2)
Vec Vec_clone (Vec v)
vec vec_clone (vec v)
ivec ivec_clone (ivec v)
bvec bvec_clone (bvec v)
cvec cvec_clone (cvec v)
void vec_copy_from_ivec (vec dest, ivec orig)
void vec_copy_from_bvec (vec dest, bvec orig)
void vec_copy_from_cvec (vec dest, cvec orig)
void ivec_copy_from_vec (ivec dest, vec orig)
void ivec_copy_from_bvec (ivec dest, bvec orig)
void ivec_copy_from_cvec (ivec dest, cvec orig)
void bvec_copy_from_vec (bvec dest, vec orig)
void bvec_copy_from_ivec (bvec dest, ivec orig)
void bvec_copy_from_cvec (bvec dest, cvec orig)
void cvec_copy_from_vec (cvec dest, vec orig)
void cvec_copy_from_ivec (cvec dest, ivec orig)
void cvec_copy_from_bvec (cvec dest, bvec orig)
bvec vec_to_bvec (vec v)
ivec vec_to_ivec (vec v)
cvec vec_to_cvec (vec v)
vec ivec_to_vec (ivec v)
bvec ivec_to_bvec (ivec v)
cvec ivec_to_cvec (ivec v)
ivec bvec_to_ivec (bvec v)
vec bvec_to_vec (bvec v)
cvec bvec_to_cvec (bvec v)
void vec_copy_mem (double *buf, vec v)
void ivec_copy_mem (int *buf, ivec v)
void bvec_copy_mem (byte *buf, bvec v)
void cvec_copy_mem (cplx *buf, cvec v)
void bvec_pack (byte *buf, bvec v)
void bvec_unpack (bvec v, byte *buf)

Ordered set and stack operations



vec vec_del (vec v, idx_t pos)
ivec ivec_del (ivec v, idx_t pos)
bvec bvec_del (bvec v, idx_t pos)
cvec cvec_del (cvec v, idx_t pos)
#define Vec_del(v, pos)
vec _vec_ins (vec v, idx_t pos, double elt)
ivec _ivec_ins (ivec v, idx_t pos, int elt)
bvec _bvec_ins (bvec v, idx_t pos, byte elt)
cvec _cvec_ins (cvec v, idx_t pos, cplx elt)
#define Vec_ins(v, pos, elt)
#define vec_ins(v, pos, elt)   do { v=_vec_ins( v, pos, elt ); } while (0)
#define ivec_ins(v, pos, elt)   do { v=_ivec_ins( v, pos, elt ); } while (0)
#define bvec_ins(v, pos, elt)   do { v=_bvec_ins( v, pos, elt ); } while (0)
#define cvec_ins(v, pos, elt)   do { v=_cvec_ins( v, pos, elt ); } while (0)
vec _vec_push (vec v, double elt)
ivec _ivec_push (ivec v, int elt)
bvec _bvec_push (bvec v, byte elt)
cvec _cvec_push (cvec v, cplx elt)
#define Vec_push(v, elt)   Vec_ins( v, Vec_length(v), elt )
#define vec_push(v, elt)   do { v=_vec_push( v, elt ); } while (0)
#define ivec_push(v, elt)   do { v=_ivec_push( v, elt ); } while (0)
#define bvec_push(v, elt)   do { v=_bvec_push( v, elt ); } while (0)
#define cvec_push(v, elt)   do { v=_cvec_push( v, elt ); } while (0)
vec vec_pop (vec v)
ivec ivec_pop (ivec v)
bvec bvec_pop (bvec v)
cvec cvec_pop (cvec v)
#define Vec_pop(v)   Vec_del( v, Vec_length(v)-1 )
double vec_head (vec v)
int ivec_head (ivec v)
byte bvec_head (bvec v)
cplx cvec_head (const cvec v)
#define Vec_head(v)   ((v)[Vec_length(v)-1])

Safe vector access



double * __vec (vec v, idx_t i)
int * __ivec (ivec v, idx_t i)
byte__bvec (bvec v, idx_t i)
cplx__cvec (cvec v, idx_t i)
#define _vec(v, i)   (*__vec(v, i))
#define _ivec(v, i)   (*__ivec(v, i))
#define _bvec(v, i)   (*__bvec(v, i))
#define _cvec(v, i)   (*__cvec(v, i))

Mean, median, min, max, sum and elementary statistic indicators



double vec_mean (vec v)
double ivec_mean (ivec v)
double vec_mean_robust (vec v)
double vec_median (vec v)
int ivec_median (ivec v)
double vec_sum (vec v)
int ivec_sum (ivec v)
cplx cvec_sum (cvec v)
double vec_sum_robust (vec v)
vec vec_cum_sum (vec v)
ivec ivec_cum_sum (ivec v)
cvec cvec_cum_sum (cvec v)
double vec_sum_between (vec v, idx_t i1, idx_t i2)
int ivec_sum_between (ivec v, idx_t i1, idx_t i2)
cplx cvec_sum_between (cvec v, idx_t i1, idx_t i2)
double vec_sum_sqr (vec v)
double vec_min (vec v)
int ivec_min (ivec v)
double vec_max (vec v)
int ivec_max (ivec v)
idx_t vec_min_index (vec v)
idx_t ivec_min_index (ivec v)
idx_t vec_max_index (vec v)
idx_t ivec_max_index (ivec v)
vec vec_k_min (vec v, int k)
ivec ivec_k_min (ivec v, int k)
vec vec_k_max (vec v, int k)
ivec ivec_k_max (ivec v, int k)
vec vec_k_min_between (vec v, int k, idx_t a, idx_t b)
ivec ivec_k_min_between (ivec v, int k, idx_t a, idx_t b)
vec vec_k_max_between (vec v, int k, idx_t a, idx_t b)
ivec ivec_k_max_between (ivec v, int k, idx_t a, idx_t b)
ivec vec_k_min_index (vec v, int k)
ivec ivec_k_min_index (ivec v, int k)
ivec vec_k_max_index (vec v, int k)
ivec ivec_k_max_index (ivec v, int k)
ivec vec_k_min_index_between (vec v, int k, idx_t a, idx_t b)
ivec ivec_k_min_index_between (ivec v, int k, idx_t a, idx_t b)
ivec vec_k_max_index_between (vec v, int k, idx_t a, idx_t b)
ivec ivec_k_max_index_between (ivec v, int k, idx_t a, idx_t b)
double vec_variance (vec v)
double vec_variance_robust (vec v)
double vec_cov (vec v1, vec v2)
double vec_norm (vec v, double nr)
double ivec_norm (ivec v, int nr)
void vec_normalize (vec v, double nr)
vec vec_new_normalize (vec v, double nr)

Basic arithmetic operations



void vec_neg (vec v)
void ivec_neg (ivec v)
void cvec_neg (cvec v)
void cvec_conj (cvec v)
void cvec_abssqr (cvec v)
void vec_sqr (vec v)
void ivec_sqr (ivec v)
void vec_sqrt (vec v)
void vec_log (vec v)
void vec_log10 (vec v)
void vec_exp (vec v)
void vec_pow (vec v, double a)
vec vec_new_pow (vec v, double a)
void vec_abs (vec v)
void ivec_abs (ivec v)
vec vec_new_abs (vec v)
ivec ivec_new_abs (ivec v)
vec cvec_new_abs (cvec v)

Arithmetic operations with a scalar value



void vec_incr (vec v, double a)
void ivec_incr (ivec v, int a)
void cvec_incr (cvec v, cplx a)
void cvec_incr_real (cvec v, double a)
void vec_decr (vec v, double a)
void ivec_decr (ivec v, int a)
void cvec_decr (cvec v, cplx a)
void cvec_decr_real (cvec v, double a)
void vec_mul_by (vec v, double a)
void ivec_mul_by (ivec v, int a)
void cvec_mul_by (cvec v, cplx a)
void cvec_mul_by_real (cvec v, double a)
void vec_div_by (vec v, double a)
void ivec_div_by (ivec v, int a)
void cvec_div_by (cvec v, cplx a)
void cvec_div_by_real (cvec v, double a)

Component per component operations



void vec_add (vec v1, vec v2)
void ivec_add (ivec v1, ivec v2)
void cvec_add (cvec v1, cvec v2)
vec vec_new_add (vec v1, vec v2)
ivec ivec_new_add (ivec v1, ivec v2)
void vec_sub (vec v1, vec v2)
void ivec_sub (ivec v1, ivec v2)
void cvec_sub (cvec v1, cvec v2)
vec vec_new_sub (vec v1, vec v2)
ivec ivec_new_sub (ivec v1, ivec v2)
void vec_mul (vec v1, vec v2)
void ivec_mul (ivec v1, ivec v2)
void cvec_mul (cvec v1, cvec v2)
vec vec_new_mul (vec v1, vec v2)
ivec ivec_new_mul (ivec v1, ivec v2)
void vec_div (vec v1, vec v2)
void ivec_div (ivec v1, ivec v2)
void cvec_div (cvec v1, cvec v2)
vec vec_new_div (vec v1, vec v2)
ivec ivec_new_div (ivec v1, ivec v2)
double vec_inner_product (vec v1, vec v2)
int ivec_inner_product (ivec v1, ivec v2)
double vecivec_inner_product (vec v1, ivec v2)
int bvecivec_inner_product (bvec v1, ivec v2)
double vec_inner_product_robust (vec v1, vec v2)
void cvec_conj_mul (cvec v1, cvec v2)

Component per component arbitrar function



void vec_apply_function (vec v, it_function_t function, it_args_t args)
vec vec_new_apply_function (vec v, it_function_t function, it_args_t args)
ivec ivec_apply_function (ivec v, it_ifunction_t function, it_args_t args)
ivec ivec_new_apply_function (ivec v, it_ifunction_t function, it_args_t args)
#define ivec_eval(v, f, a)   ivec_apply_function(v, f, a)
#define ivec_new_eval(v, f, a)   ivec_new_apply_function(v, f, a)

Set, sorting and finding functions



void vec_reverse (vec v)
void ivec_reverse (ivec v)
void bvec_reverse (bvec v)
void cvec_reverse (cvec v)
vec vec_new_reverse (vec v)
ivec ivec_new_reverse (ivec v)
bvec bvec_new_reverse (bvec v)
cvec cvec_new_reverse (cvec v)
idx_t vec_count (vec v, double a)
idx_t ivec_count (ivec v, int a)
idx_t bvec_count (bvec v, byte a)
idx_t cvec_count (cvec v, cplx a)
idx_t vec_find_first (vec v, double a)
idx_t ivec_find_first (ivec v, int a)
idx_t bvec_find_first (bvec v, byte a)
idx_t cvec_find_first (cvec v, cplx a)
ivec vec_find (vec v, double a)
ivec ivec_find (ivec v, int a)
ivec bvec_find (bvec v, byte a)
ivec cvec_find (cvec v, cplx a)
idx_t vec_find_sorted (vec v, double a)
idx_t ivec_find_sorted (ivec v, int a)
idx_t bvec_find_sorted (bvec v, byte a)
ivec vec_replace (vec v, double a, double b)
ivec ivec_replace (ivec v, int a, int b)
ivec bvec_replace (bvec v, byte a, byte b)
ivec cvec_replace (cvec v, cplx a, cplx b)
vec vec_new_concat (vec v1, vec v2)
ivec ivec_new_concat (ivec v1, ivec v2)
bvec bvec_new_concat (bvec v1, bvec v2)
cvec cvec_new_concat (cvec v1, cvec v2)
vec vec_new_unique (vec v)
ivec ivec_new_unique (ivec v)
bvec bvec_new_unique (bvec v)
vec vec_new_union (vec v1, vec v2)
ivec ivec_new_union (ivec v1, ivec v2)
bvec bvec_new_union (bvec v1, bvec v2)
vec vec_new_intersection (vec v1, vec v2)
ivec ivec_new_intersection (ivec v1, ivec v2)
bvec bvec_new_intersection (bvec v1, bvec v2)
vec vec_index_by (vec v, ivec idx)
ivec ivec_index_by (ivec v, ivec idx)
bvec bvec_index_by (bvec v, ivec idx)
cvec cvec_index_by (cvec v, ivec idx)
void Vec_sort (Vec v, int(*elem_leq)(const void *, const void *))
void vec_sort (vec v)
void ivec_sort (ivec v)
void bvec_sort (bvec v)
ivec Vec_sort_index (Vec v, int(*elem_leq_idx)(const void *, const void *))
ivec vec_sort_index (vec v)
ivec ivec_sort_index (ivec v)
ivec bvec_sort_index (bvec v)

Special vectors



void vec_range (vec)
void ivec_range (ivec)
void bvec_range (bvec)
void cvec_range (cvec)
vec vec_new_range (idx_t n)
ivec ivec_new_range (idx_t n)
bvec bvec_new_range (idx_t n)
cvec cvec_new_range (idx_t n)
void vec_1N (vec)
void ivec_1N (ivec)
void bvec_1N (bvec)
void cvec_1N (cvec)
vec vec_new_1N (idx_t n)
ivec ivec_new_1N (idx_t n)
bvec bvec_new_1N (idx_t n)
cvec cvec_new_1N (idx_t n)
void vec_arithm (vec, double start, double incr)
void ivec_arithm (ivec, int start, int incr)
void bvec_arithm (bvec, byte start, byte incr)
void cvec_arithm (cvec, cplx start, cplx incr)
vec vec_new_arithm (double start, double incr, idx_t N)
ivec ivec_new_arithm (int start, int incr, idx_t N)
bvec bvec_new_arithm (byte start, byte incr, idx_t N)
cvec cvec_new_arithm (cplx start, cplx incr, idx_t N)
void vec_geom (vec, double start, double r)
void ivec_geom (ivec, int start, int r)
void bvec_geom (bvec, byte start, byte r)
void cvec_geom (cvec, cplx start, cplx r)
vec vec_new_geom (double start, double r, idx_t N)
ivec ivec_new_geom (int start, int r, idx_t N)
bvec bvec_new_geom (byte start, byte r, idx_t N)
cvec cvec_new_geom (cplx start, cplx r, idx_t N)
cvec cvec_new_unit_roots (idx_t N)

Random vectors



void vec_rand (vec v)
vec vec_new_rand (idx_t N)
void vec_randn (vec v)
vec vec_new_randn (idx_t N)
ivec ivec_new_perm (size_t N)

Convolution



vec vec_conv (vec v1, vec v2)
ivec ivec_conv (ivec v1, ivec v2)

Vector <-> sparse vectors conversion



void vec_to_spvec (vec v, ivec *svi_out, vec *sv_out)
void ivec_to_spivec (ivec v, ivec *svi_out, ivec *sv_out)
vec spvec_to_vec (ivec svi, vec sv, int n)
ivec spivec_to_ivec (ivec svi, ivec sv, int n)
double spvec_inner_product (ivec svi1, vec sv1, ivec svi2, vec sv2)
int spivec_inner_product (ivec svi1, ivec sv1, ivec svi2, ivec sv2)

Initialization of a vector or of some of its components



static int double_leq (const void *d1, const void *d2)
static int double_leq_index (const void *d1, const void *d2)
static int int_leq (const void *d1, const void *d2)
static int int_leq_index (const void *d1, const void *d2)
static int byte_leq (const void *d1, const void *d2)
static int byte_leq_index (const void *d1, const void *d2)

Defines

#define VEC_END_PARAM(v, param)   do { if( param == end ) param = Vec_length( v ) - 1; } while(0)
#define vec_eval(v, f, a)   vec_apply_function(v, f, a)
#define vec_new_eval(v, f, a)   vec_new_apply_function(v, f, a)

Detailed Description


Define Documentation

#define _bvec ( v,
 )     (*__bvec(v, i))

Safe access to vector's elements

Definition at line 605 of file vec.h.

#define _cvec ( v,
 )     (*__cvec(v, i))

Safe access to vector's elements

Definition at line 606 of file vec.h.

#define _ivec ( v,
 )     (*__ivec(v, i))

Safe access to vector's elements

Definition at line 604 of file vec.h.

#define _vec ( v,
 )     (*__vec(v, i))

Safe access to vector's elements

Definition at line 603 of file vec.h.

Referenced by main().

#define bvec_ins ( v,
pos,
elt   )     do { v=_bvec_ins( v, pos, elt ); } while (0)

insert an element in a given vector at the specified position

Warning:
the function MAY modify the value of the pointer v The vector max length is increased according to a geometric allocation

Definition at line 553 of file vec.h.

Referenced by _bvec_push().

#define bvec_push ( v,
elt   )     do { v=_bvec_push( v, elt ); } while (0)

Add an element at the end of the vector

Definition at line 569 of file vec.h.

Referenced by bvec_new_intersection(), bvec_new_union(), bvec_new_unique(), it_read_bvec(), main(), and vlc_encode_concat().

#define bvec_set_length ( v,
 )     do { v=_bvec_set_length( v, N ); } while (0)

Modify the length of a vector

Warning:
This function never decreases the max size of the vector (explictly call Vec_set_length_max for that purpose)

Definition at line 241 of file vec.h.

Referenced by it_read_bvec().

#define bvec_set_length_max ( v,
 )     do { v=_bvec_set_length_max( v, N ); } while (0)

Modify the maximum length of a vector

Warning:
the function Vec_set_length_max may change the value of the pointer corresponding to vector v. Consequently, the functions calling this function must be handled with care, especially when vectors are passed as parameters

Definition at line 216 of file vec.h.

#define cvec_ins ( v,
pos,
elt   )     do { v=_cvec_ins( v, pos, elt ); } while (0)

insert an element in a given vector at the specified position

Warning:
the function MAY modify the value of the pointer v The vector max length is increased according to a geometric allocation

Definition at line 554 of file vec.h.

Referenced by _cvec_push().

#define cvec_push ( v,
elt   )     do { v=_cvec_push( v, elt ); } while (0)

Add an element at the end of the vector

Definition at line 570 of file vec.h.

Referenced by fft_init(), and it_read_cvec().

#define cvec_set_length ( v,
 )     do { v=_cvec_set_length( v, N ); } while (0)

Modify the length of a vector

Warning:
This function never decreases the max size of the vector (explictly call Vec_set_length_max for that purpose)

Definition at line 242 of file vec.h.

Referenced by cvec_fft_autocorr(), cvec_fft_conv(), cvec_fft_corr(), it_fdft(), it_fzt(), and it_read_cvec().

#define cvec_set_length_max ( v,
 )     do { v=_cvec_set_length_max( v, N ); } while (0)

Modify the maximum length of a vector

Warning:
the function Vec_set_length_max may change the value of the pointer corresponding to vector v. Consequently, the functions calling this function must be handled with care, especially when vectors are passed as parameters

Definition at line 217 of file vec.h.

#define ivec_eval ( v,
f,
 )     ivec_apply_function(v, f, a)

Apply a function to all vector elements

Definition at line 1035 of file vec.h.

#define ivec_ins ( v,
pos,
elt   )     do { v=_ivec_ins( v, pos, elt ); } while (0)

insert an element in a given vector at the specified position

Warning:
the function MAY modify the value of the pointer v The vector max length is increased according to a geometric allocation

Definition at line 552 of file vec.h.

Referenced by _ivec_push().

#define ivec_new_eval ( v,
f,
 )     ivec_new_apply_function(v, f, a)

Apply a function to all vector elements

Definition at line 1036 of file vec.h.

#define ivec_push ( v,
elt   )     do { v=_ivec_push( v, elt ); } while (0)

#define ivec_set_length ( v,
 )     do { v=_ivec_set_length( v, N ); } while (0)

Modify the length of a vector

Warning:
This function never decreases the max size of the vector (explictly call Vec_set_length_max for that purpose)

Definition at line 240 of file vec.h.

Referenced by it_read_ivec().

#define ivec_set_length_max ( v,
 )     do { v=_ivec_set_length_max( v, N ); } while (0)

Modify the maximum length of a vector

Warning:
the function Vec_set_length_max may change the value of the pointer corresponding to vector v. Consequently, the functions calling this function must be handled with care, especially when vectors are passed as parameters

Definition at line 215 of file vec.h.

#define Vec_copy ( v1,
v2   )     __Vec_copy((Vec) v1, (Vec) v2)

Copy the content of a vector into another vector

Warning:
Note that these functions do NOT allocate memory for the destination vectors. Consequently, the amount of allocated elements vec_length_max(v) must be sufficient. The function returns the number of elements that has really been copied If the vectors have not the same size, the function returns an error

Definition at line 433 of file vec.h.

Referenced by __Mat_copy(), __Mat_new_deinterleave_block(), __Mat_new_interleave_block(), bmat_copy_row(), bvec_clone(), bvec_copy(), cmat_copy_row(), cvec_clone(), cvec_copy(), imat_copy_row(), ivec_clone(), ivec_copy(), mat_copy_row(), vec_clone(), Vec_clone(), and vec_copy().

#define Vec_del ( v,
pos   ) 

Value:

do {                                                \
                               idx_t l = Vec_length(v)-1;                   \
                               idx_t i;                                     \
                               assert(v);                                   \
                               assert((pos) <= l);                          \
                               for( i = (pos) + 1 ; i <= l ; i++ )          \
                                 (v)[ i - 1 ] = (v)[ i ];                   \
                               Vec_length(v)--;                             \
                             } while( 0 )
Delete an element from the vector

Definition at line 510 of file vec.h.

Referenced by bvec_del(), cvec_del(), ivec_del(), and vec_del().

#define VEC_END_PARAM ( v,
param   )     do { if( param == end ) param = Vec_length( v ) - 1; } while(0)

#define Vec_eq ( v1,
v2   ) 

Value:

( Vec_length( v1 ) == Vec_length( v2 ) &&          \
                         !memcmp( v1, v2, Vec_element_size( v1 ) * Vec_length( v1 ) ) )
Return true iff all the vectors v1 and v2 are equal component per component

Definition at line 401 of file vec.h.

Referenced by Mat_eq().

#define vec_eval ( v,
f,
 )     vec_apply_function(v, f, a)

Definition at line 1021 of file vec.h.

#define Vec_head (  )     ((v)[Vec_length(v)-1])

Return the last element of vector

Definition at line 588 of file vec.h.

Referenced by _parser_add_string(), bvec_head(), cvec_head(), ivec_head(), and vec_head().

#define Vec_init ( v,
buf,
 )     memcpy( v, buf, Vec_element_size(v) * (N) );

Initialize the vector from a buffer of the same type

Definition at line 254 of file vec.h.

Referenced by bvec_init(), cvec_init(), ivec_init(), and vec_init().

#define vec_ins ( v,
pos,
elt   )     do { v=_vec_ins( v, pos, elt ); } while (0)

insert an element in a given vector at the specified position

Warning:
the function MAY modify the value of the pointer v The vector max length is increased according to a geometric allocation

Definition at line 551 of file vec.h.

Referenced by _vec_push(), it_rand_memoryless(), and source_memoryless().

#define Vec_ins ( v,
pos,
elt   ) 

Value:

do {                                         \
                               idx_t l = Vec_length(v);                     \
                               idx_t i;                                     \
                               assert(v);                                   \
                               assert((pos) <= l);                          \
                               if( l+1 > Vec_length_max(v) )                \
                                 Vec_set_length_max( v, DYN_ALLOC_RULE( l ));\
                               for( i = l ; i >(pos) ; i-- )                \
                                 (v)[i] = (v)[ i-1 ];                       \
                               (v)[(pos)] = (elt);                          \
                               Vec_length(v)++;                             \
                             } while( 0 )
insert an element in a given vector at the specified position
Warning:
the function MAY modify the value of the pointer v The vector max length is increased according to a geometric allocation

Definition at line 532 of file vec.h.

Referenced by _bvec_ins(), _cvec_ins(), _ivec_ins(), and _vec_ins().

#define Vec_length_max (  )     ( Vec_header(v).length_max )

Return the maximum length of the vector (number of allocated elements)

Definition at line 183 of file vec.h.

Referenced by bvec_length_max(), cvec_length_max(), ivec_length_max(), vec_length_max(), and Vec_sort_index().

#define Vec_new ( type_t,
 )     ((type_t *) __Vec_new( sizeof(type_t), N ))

Allocate a vector

Definition at line 142 of file vec.h.

Referenced by __it_dequantize_mat(), __it_quantize_mat(), bvec_new(), cvec_new(), ivec_new(), parser_init(), pvec_new(), vec_new(), and Vec_sort_index().

#define Vec_new_alloc ( type_t,
N,
length_max   )     ((type_t *) __Vec_new_alloc(sizeof(type_t), N, length_max ))

Vector allocation with explicit allocation of the maximum number of elements

Definition at line 130 of file vec.h.

Referenced by __Mat_new_alloc(), bvec_new_alloc(), cvec_new_alloc(), ivec_new_alloc(), and vec_new_alloc().

#define vec_new_eval ( v,
f,
 )     vec_new_apply_function(v, f, a)

Definition at line 1022 of file vec.h.

Referenced by main().

#define Vec_new_void ( type_t   )     Vec_new( type_t, 0 )

Create a vector of length 0

Definition at line 304 of file vec.h.

#define Vec_pop (  )     Vec_del( v, Vec_length(v)-1 )

Retrieve the last element at the end of the vector (this removes it)

Definition at line 577 of file vec.h.

Referenced by bvec_pop(), cvec_pop(), ivec_pop(), and vec_pop().

#define vec_push ( v,
elt   )     do { v=_vec_push( v, elt ); } while (0)

Add an element at the end of the vector

Definition at line 567 of file vec.h.

Referenced by it_read_fvec(), it_read_vec(), main(), vec_k_max_between(), vec_k_min_between(), vec_new_intersection(), vec_new_union(), and vec_new_unique().

#define Vec_push ( v,
elt   )     Vec_ins( v, Vec_length(v), elt )

Add an element at the end of the vector

Definition at line 560 of file vec.h.

Referenced by _parser_add_params(), and _parser_add_string().

#define Vec_set ( v,
val   ) 

Value:

do {                                              \
                            idx_t i;                                       \
                            assert( v );                                    \
                            for( i = 0 ; i < Vec_length( v ) ; i++ )        \
                              v[ i ] = val; } while( 0 )
Set all the elements of the vector to a given value

Definition at line 266 of file vec.h.

Referenced by bvec_set(), bvec_zeros(), cvec_set(), cvec_zeros(), ivec_set(), ivec_zeros(), vec_set(), and vec_zeros().

#define Vec_set_between ( v,
i1,
i2,
val   ) 

Value:

do {                            \
                            idx_t ve = i2;                                 \
                            idx_t i;                                       \
                            VEC_END_PARAM( v,ve );                          \
                            assert( v );                                    \
                            for( i = i1 ; i <= ve ; i++ )                   \
                              v[ i ] = val; } while( 0 )
Set the elements of a subvector to a given value val

Definition at line 352 of file vec.h.

Referenced by bvec_set_between(), cvec_set_between(), ivec_set_between(), and vec_set_between().

#define vec_set_length ( v,
 )     do { v=_vec_set_length( v, N ); } while (0)

Modify the length of a vector

Warning:
This function never decreases the max size of the vector (explictly call Vec_set_length_max for that purpose)

Definition at line 239 of file vec.h.

Referenced by it_read_fvec(), it_read_vec(), poly_add(), poly_normalize(), and poly_sub().

#define Vec_set_length ( v,
 ) 

Value:

do {                                    \
                                      if( N > Vec_length_max( v ) ) {       \
          Vec_set_length_max( v, N );         \
                                        Vec_length( v ) = (N);              \
                                      } else {                              \
                                      Vec_length( v ) = (N); }              \
                                     } while(0)
Modify the length of a vector
Warning:
This function never decreases the max size of the vector (explictly call Vec_set_length_max for that purpose)

Definition at line 226 of file vec.h.

Referenced by _bvec_set_length(), _cvec_set_length(), _ivec_set_length(), and _vec_set_length().

#define vec_set_length_max ( v,
 )     do { v=_vec_set_length_max( v, N ); } while (0)

Modify the maximum length of a vector

Warning:
the function Vec_set_length_max may change the value of the pointer corresponding to vector v. Consequently, the functions calling this function must be handled with care, especially when vectors are passed as parameters

Definition at line 214 of file vec.h.

#define Vec_set_length_max ( v,
 ) 

Value:

do {                         \
  int L = Vec_length(v);          \
  size_t elem_size = Vec_element_size(v);     \
                \
  assert( N >= Vec_length(v) );         \
  if( N > Vec_length(v) ) {         \
    Vec new_Vec = __Vec_new_realloc(v, elem_size, L, N);  \
    (v) = (v) + ((byte *) new_Vec - (byte *) (v)) / elem_size;  \
  }               \
} while(0)
Modify the maximum length of a vector
Warning:
the function Vec_set_length_max may change the value of the pointer corresponding to vector v. Consequently, the functions calling this function must be handled with care, especially when vectors are passed as parameters

Definition at line 197 of file vec.h.

Referenced by _bvec_set_length_max(), _cvec_set_length_max(), _ivec_set_length_max(), _vec_set_length_max(), and main().

#define Vec_set_subvector ( v,
s,
index   ) 

Value:

do {           \
                            idx_t i;             \
          assert(v);             \
          assert(s);             \
          assert(index + Vec_length(s) <= Vec_length(v)); \
          for(i = 0; i < Vec_length(s); i++)       \
            (v)[(index) + i] = (s)[i]; } while(0)
Modify a given element subset of a vector to another vector

Definition at line 370 of file vec.h.

Referenced by bvec_set_subvector(), cvec_set_subvector(), ivec_set_subvector(), and vec_set_subvector().

#define Vec_void (  ) 

Value:

do {                                                  \
  assert( v );                                                            \
  Vec_length( v ) = 0;                                                    \
} while(0)
Reduce a vector to length 0

Definition at line 290 of file vec.h.

Referenced by bvec_void(), cvec_void(), ivec_void(), and vec_void().


Typedef Documentation

typedef byte* bvec

Definition at line 70 of file vec.h.

typedef cplx* cvec

Definition at line 71 of file vec.h.

typedef int* ivec

Definition at line 69 of file vec.h.

typedef double* vec

Definition at line 68 of file vec.h.

typedef void* Vec

Definition at line 67 of file vec.h.


Function Documentation

byte* __bvec ( bvec  v,
idx_t  i 
)

Safe access to vector's elements

Definition at line 1046 of file vec.c.

References bvec_length(), and VEC_END_PARAM.

cplx* __cvec ( cvec  v,
idx_t  i 
)

Safe access to vector's elements

Definition at line 1055 of file vec.c.

References cvec_length(), and VEC_END_PARAM.

int* __ivec ( ivec  v,
idx_t  i 
)

Safe access to vector's elements

Definition at line 1037 of file vec.c.

References ivec_length(), and VEC_END_PARAM.

double* __vec ( vec  v,
idx_t  i 
)

Safe access to vector's elements

Definition at line 1028 of file vec.c.

References VEC_END_PARAM, and vec_length().

Vec __Vec_copy ( Vec  v1,
Vec  v2 
)

Copy the content of a vector into another vector

Warning:
Note that these functions do NOT allocate memory for the destination vectors. Consequently, the amount of allocated elements vec_length_max(v) must be sufficient. The function returns the number of elements that has really been copied If the vectors have not the same size, the function returns an error

Definition at line 478 of file vec.c.

References Vec_element_size, and Vec_length.

Vec __Vec_new ( size_t  elem_size,
idx_t  N 
)

Allocate a vector

Definition at line 155 of file vec.c.

References __Vec_new_alloc().

Referenced by Vec_clone(), Vec_new_deinterleave_block(), and Vec_new_interleave_block().

bvec _bvec_ins ( bvec  v,
idx_t  pos,
byte  elt 
)

insert an element in a given vector at the specified position

Warning:
the function MAY modify the value of the pointer v The vector max length is increased according to a geometric allocation

Definition at line 931 of file vec.c.

References Vec_ins.

bvec _bvec_push ( bvec  v,
byte  elt 
)

Add an element at the end of the vector

Definition at line 959 of file vec.c.

References bvec_ins, and bvec_length().

bvec _bvec_set_length ( bvec  v,
idx_t  N 
)

Modify the length of a vector

Warning:
This function never decreases the max size of the vector (explictly call Vec_set_length_max for that purpose)

Definition at line 303 of file vec.c.

References Vec_set_length.

bvec _bvec_set_length_max ( bvec  v,
idx_t  N 
)

Modify the maximum length of a vector

Warning:
the function Vec_set_length_max may change the value of the pointer corresponding to vector v. Consequently, the functions calling this function must be handled with care, especially when vectors are passed as parameters

Definition at line 275 of file vec.c.

References Vec_set_length_max.

cvec _cvec_ins ( cvec  v,
idx_t  pos,
cplx  elt 
)

insert an element in a given vector at the specified position

Warning:
the function MAY modify the value of the pointer v The vector max length is increased according to a geometric allocation

Definition at line 938 of file vec.c.

References Vec_ins.

cvec _cvec_push ( cvec  v,
cplx  elt 
)

Add an element at the end of the vector

Definition at line 966 of file vec.c.

References cvec_ins, and cvec_length().

cvec _cvec_set_length ( cvec  v,
idx_t  N 
)

Modify the length of a vector

Warning:
This function never decreases the max size of the vector (explictly call Vec_set_length_max for that purpose)

Definition at line 310 of file vec.c.

References Vec_set_length.

cvec _cvec_set_length_max ( cvec  v,
idx_t  N 
)

Modify the maximum length of a vector

Warning:
the function Vec_set_length_max may change the value of the pointer corresponding to vector v. Consequently, the functions calling this function must be handled with care, especially when vectors are passed as parameters

Definition at line 282 of file vec.c.

References Vec_set_length_max.

ivec _ivec_ins ( ivec  v,
idx_t  pos,
int  elt 
)

insert an element in a given vector at the specified position

Warning:
the function MAY modify the value of the pointer v The vector max length is increased according to a geometric allocation

Definition at line 924 of file vec.c.

References Vec_ins.

ivec _ivec_push ( ivec  v,
int  elt 
)

Add an element at the end of the vector

Definition at line 952 of file vec.c.

References ivec_ins, and ivec_length().

ivec _ivec_set_length ( ivec  v,
idx_t  N 
)

Modify the length of a vector

Warning:
This function never decreases the max size of the vector (explictly call Vec_set_length_max for that purpose)

Definition at line 296 of file vec.c.

References Vec_set_length.

ivec _ivec_set_length_max ( ivec  v,
idx_t  N 
)

Modify the maximum length of a vector

Warning:
the function Vec_set_length_max may change the value of the pointer corresponding to vector v. Consequently, the functions calling this function must be handled with care, especially when vectors are passed as parameters

Definition at line 268 of file vec.c.

References Vec_set_length_max.

vec _vec_ins ( vec  v,
idx_t  pos,
double  elt 
)

insert an element in a given vector at the specified position

Warning:
the function MAY modify the value of the pointer v The vector max length is increased according to a geometric allocation

Definition at line 917 of file vec.c.

References Vec_ins.

vec _vec_push ( vec  v,
double  elt 
)

Add an element at the end of the vector

Definition at line 945 of file vec.c.

References vec_ins, and vec_length().

vec _vec_set_length ( vec  v,
idx_t  N 
)

Modify the length of a vector

Warning:
This function never decreases the max size of the vector (explictly call Vec_set_length_max for that purpose)

Definition at line 289 of file vec.c.

References Vec_set_length.

vec _vec_set_length_max ( vec  v,
idx_t  N 
)

Modify the maximum length of a vector

Warning:
the function Vec_set_length_max may change the value of the pointer corresponding to vector v. Consequently, the functions calling this function must be handled with care, especially when vectors are passed as parameters

Definition at line 261 of file vec.c.

References Vec_set_length_max.

void bvec_1N ( bvec   ) 

Set the vector elements to 1,2, ... n

Definition at line 3846 of file vec.c.

References bvec_length().

void bvec_arithm ( bvec  ,
byte  start,
byte  incr 
)

Set the vector to an arithmetic sequence

Definition at line 3887 of file vec.c.

References bvec_length().

bvec bvec_clone ( bvec  v  ) 

Clone a vector (allocate memory and copy data)

Definition at line 534 of file vec.c.

References bvec_length(), bvec_new(), and Vec_copy.

void bvec_copy ( bvec  dest,
bvec  orig 
)

Copy the content of a vector into another vector

Warning:
Note that these functions do NOT allocate memory for the destination vectors. Consequently, the amount of allocated elements vec_length_max(v) must be sufficient. The function returns the number of elements that has really been copied If the vectors have not the same size, the function returns an error

Definition at line 501 of file vec.c.

References Vec_copy.

void bvec_copy_from_cvec ( bvec  dest,
cvec  orig 
)

Copy with conversion (lengths must match)

Definition at line 628 of file vec.c.

References bvec_length(), creal, and cvec_length().

void bvec_copy_from_ivec ( bvec  dest,
ivec  orig 
)

Copy with conversion (lengths must match)

Definition at line 618 of file vec.c.

References bvec_length(), and ivec_length().

void bvec_copy_from_vec ( bvec  dest,
vec  orig 
)

Copy with conversion (lengths must match)

Definition at line 608 of file vec.c.

References bvec_length(), and vec_length().

void bvec_copy_mem ( byte buf,
bvec  v 
)

Copy the vector into a buffer (which must be a valid allocated pointer)

Definition at line 700 of file vec.c.

References bvec_length().

idx_t bvec_count ( bvec  v,
byte  a 
)

Count the number of elements equal to a given value a

Definition at line 3141 of file vec.c.

References bvec_length().

Referenced by bvec_find(), and bvec_replace().

bvec bvec_del ( bvec  v,
idx_t  pos 
)

Delete an element from the vector

Definition at line 902 of file vec.c.

References Vec_del.

void bvec_delete ( bvec  v  ) 

int bvec_eq ( bvec  v1,
bvec  v2 
)

Return true iff all the vectors v1 and v2 are equal component per component

Definition at line 1102 of file vec.c.

References bvec_length().

Referenced by bmat_eq().

ivec bvec_find ( bvec  v,
byte  a 
)

Return the set of positions where a given value occurs

Definition at line 2950 of file vec.c.

References bvec_count(), bvec_length(), and ivec_new().

idx_t bvec_find_first ( bvec  v,
byte  a 
)

Return the first position where the value a occurs, NULL_INDEX if the research is not successful

Definition at line 2897 of file vec.c.

References bvec_length(), and NULL_INDEX.

idx_t bvec_find_sorted ( bvec  v,
byte  a 
)

Return the set of positions where a given value occurs assuming a sorted set

Definition at line 3033 of file vec.c.

References bvec_length(), and left.

void bvec_geom ( bvec  ,
byte  start,
byte  r 
)

Set the vector to an geometric sequence

Definition at line 3928 of file vec.c.

References bvec_length().

int bvec_geq ( bvec  v1,
bvec  v2 
)

Definition at line 1177 of file vec.c.

References bvec_length().

bvec bvec_get_subvector ( bvec  v,
idx_t  i1,
idx_t  i2 
)

allocate a new vector formed by a subset of a given vector

Definition at line 451 of file vec.c.

References bvec_init(), bvec_new(), and VEC_END_PARAM.

byte bvec_head ( bvec  v  ) 

Return the last element of vector

Definition at line 1012 of file vec.c.

References Vec_head.

bvec bvec_index_by ( bvec  v,
ivec  idx 
)

Return the vector composed of the elements of v indexed by idx

Definition at line 3510 of file vec.c.

References bvec_new(), and ivec_length().

bvec bvec_init ( bvec  v,
byte buf,
idx_t  N 
)

Initialize the vector from a buffer of the same type

Definition at line 333 of file vec.c.

References Vec_init.

Referenced by bmat_get_submatrix(), and bvec_get_subvector().

idx_t bvec_length_max ( bvec  v  ) 

Return the maximum length of the vector (number of allocated elements)

Definition at line 249 of file vec.c.

References Vec_length_max.

bvec bvec_new_1N ( idx_t  n  ) 

The sequence 1, 2.. N

Definition at line 4029 of file vec.c.

References bvec_new().

bvec bvec_new_alloc ( idx_t  length,
idx_t  length_max 
)

Vector allocation with explicit allocation of the maximum number of elements

Definition at line 112 of file vec.c.

References Vec_new_alloc.

Referenced by bvec_new_string(), parser_get_bvec(), parser_get_bvec_verbose(), and vlc_encode_concat().

bvec bvec_new_arithm ( byte  start,
byte  incr,
idx_t  N 
)

New arithmetic sequence

Definition at line 4122 of file vec.c.

References bvec_new().

bvec bvec_new_concat ( bvec  v1,
bvec  v2 
)

Concatenate two vectors

Definition at line 3213 of file vec.c.

References bvec_length(), and bvec_new().

bvec bvec_new_geom ( byte  start,
byte  r,
idx_t  N 
)

Same but a geometric sequence of geometric factor r

Definition at line 4174 of file vec.c.

References bvec_new(), and it_assert.

bvec bvec_new_intersection ( bvec  v1,
bvec  v2 
)

Intersection of two sets represented by the two input vectors

Definition at line 3459 of file vec.c.

References bvec_length(), bvec_new(), bvec_push, ivec_delete(), ivec_length(), and ivec_new_zeros().

bvec bvec_new_ones ( idx_t  N  ) 

New vectors of ones

Definition at line 3777 of file vec.c.

References bvec_new_set().

Referenced by main().

bvec bvec_new_range ( idx_t  n  ) 

New vector 0, 1, ... N-1

Definition at line 4074 of file vec.c.

References bvec_new().

bvec bvec_new_reverse ( bvec  v  ) 

Reverse the vector

Definition at line 2837 of file vec.c.

References bvec_length(), and bvec_new().

bvec bvec_new_set ( byte  val,
idx_t  N 
)

Constant vector

Definition at line 3990 of file vec.c.

References bvec_new(), and bvec_set().

Referenced by bvec_new_ones(), and bvec_new_zeros().

bvec bvec_new_union ( bvec  v1,
bvec  v2 
)

Union of two sets represented by the two input vectors

Definition at line 3373 of file vec.c.

References bvec_length(), bvec_new(), bvec_push, ivec_delete(), ivec_length(), and ivec_new_zeros().

bvec bvec_new_unique ( bvec  v  ) 

Vector created from the input vector by taking one occurences of each possible value of the input vector

Definition at line 3291 of file vec.c.

References bvec_length(), bvec_new(), bvec_push, ivec_delete(), ivec_length(), and ivec_new_zeros().

bvec bvec_new_void (  ) 

Create a vector of length 0

Definition at line 3964 of file vec.c.

References bvec_new().

bvec bvec_new_zeros ( idx_t  N  ) 

Create a vectors of zeros

Definition at line 3730 of file vec.c.

References bvec_new_set().

Referenced by bvec_file_write_bits(), and vlc_huffman().

void bvec_ones ( bvec   ) 

Set all the vector elements to 1

Definition at line 3753 of file vec.c.

References bvec_set().

void bvec_pack ( byte buf,
bvec  v 
)

Pack/unpack all bits of a binary vector together

Definition at line 721 of file vec.c.

References bvec_length().

bvec bvec_pop ( bvec  v  ) 

Retrieve the last element at the end of the vector (this removes it)

Definition at line 986 of file vec.c.

References Vec_pop.

void bvec_range ( bvec   ) 

Set the vector elements to 0,1, ... n-1

Definition at line 3807 of file vec.c.

References bvec_length().

ivec bvec_replace ( bvec  v,
byte  a,
byte  b 
)

Replace a given value by another for all vector components

Definition at line 3094 of file vec.c.

References bvec_count(), bvec_length(), and ivec_new().

void bvec_reverse ( bvec  v  ) 

Reverse the vector

Definition at line 2771 of file vec.c.

References bvec_length().

bvec bvec_set ( bvec  v,
byte  val 
)

Set all the elements of the vector to a given value

Definition at line 359 of file vec.c.

References Vec_set.

Referenced by bvec_new_set(), and bvec_ones().

bvec bvec_set_between ( bvec  v,
idx_t  i1,
idx_t  i2,
byte  val 
)

Set the elements of a subvector to a given value val

Definition at line 387 of file vec.c.

References Vec_set_between.

Referenced by vlc_huffman().

void bvec_set_subvector ( bvec  v,
bvec  s,
idx_t  idx 
)

Modify a given element subset of a vector to another vector

Definition at line 415 of file vec.c.

References VEC_END_PARAM, and Vec_set_subvector.

void bvec_sort ( bvec  v  ) 

Sort the vector by increasing values

Definition at line 3652 of file vec.c.

References byte_leq(), and Vec_sort().

ivec bvec_sort_index ( bvec  v  ) 

Return a vector of index corresponding to increasing values of the input vector

Definition at line 3658 of file vec.c.

References byte_leq_index(), and Vec_sort_index().

cvec bvec_to_cvec ( bvec  v  ) 

Vector type conversion

Definition at line 828 of file vec.c.

References bvec_length(), cimag, creal, and cvec_new().

ivec bvec_to_ivec ( bvec  v  ) 

Vector type conversion

Definition at line 803 of file vec.c.

References bvec_length(), and ivec_new().

vec bvec_to_vec ( bvec  v  ) 

Vector type conversion

Definition at line 816 of file vec.c.

References bvec_length(), and vec_new().

void bvec_unpack ( bvec  v,
byte buf 
)

Pack/unpack all bits of a binary vector together

Definition at line 741 of file vec.c.

References bvec_length().

void bvec_void ( bvec   ) 

Reduce a vector to length 0

Definition at line 3683 of file vec.c.

References Vec_void.

void bvec_zeros ( bvec   ) 

Set all the elements of a vector to 0

Definition at line 3708 of file vec.c.

References Vec_set.

int bvecivec_inner_product ( bvec  v1,
ivec  v2 
)

Inner product of two vectors

Definition at line 1642 of file vec.c.

References bvec_length(), and ivec_length().

static int byte_leq ( const void *  d1,
const void *  d2 
) [static]

Definition at line 3636 of file vec.c.

Referenced by bvec_sort(), and byte_leq_index().

static int byte_leq_index ( const void *  d1,
const void *  d2 
) [static]

Definition at line 3646 of file vec.c.

References byte_leq().

Referenced by bvec_sort_index().

void cvec_1N ( cvec   ) 

Set the vector elements to 1,2, ... n

Definition at line 3855 of file vec.c.

References cvec_length(), _cplx_::i, and _cplx_::r.

void cvec_abssqr ( cvec  v  ) 

elementwise |v_i|^2

Definition at line 1683 of file vec.c.

References cimag, creal, and cvec_length().

Referenced by cvec_fft_autocorr().

void cvec_add ( cvec  v1,
cvec  v2 
)

addition

Definition at line 1460 of file vec.c.

References cadd(), and cvec_length().

void cvec_arithm ( cvec  ,
cplx  start,
cplx  incr 
)

Set the vector to an arithmetic sequence

Definition at line 3897 of file vec.c.

References cadd(), and cvec_length().

cvec cvec_clone ( cvec  v  ) 

Clone a vector (allocate memory and copy data)

Definition at line 541 of file vec.c.

References cvec_length(), cvec_new(), and Vec_copy.

Referenced by cvec_fft_autocorr(), cvec_fft_conv(), cvec_fft_corr(), it_dft(), it_fft(), it_idft(), and it_ifft().

void cvec_conj ( cvec  v  ) 

Complex conjugate

Definition at line 1324 of file vec.c.

References cconj(), and cvec_length().

void cvec_conj_mul ( cvec  v1,
cvec  v2 
)

Hermitian product of two complex vectors

Definition at line 1504 of file vec.c.

References cconj(), cmul(), and cvec_length().

Referenced by cvec_fft_corr().

void cvec_copy ( cvec  dest,
cvec  orig 
)

Copy the content of a vector into another vector

Warning:
Note that these functions do NOT allocate memory for the destination vectors. Consequently, the amount of allocated elements vec_length_max(v) must be sufficient. The function returns the number of elements that has really been copied If the vectors have not the same size, the function returns an error

Definition at line 507 of file vec.c.

References Vec_copy.

void cvec_copy_from_bvec ( cvec  dest,
bvec  orig 
)

Copy with conversion (lengths must match)

Definition at line 663 of file vec.c.

References bvec_length(), cvec_length(), _cplx_::i, and _cplx_::r.

void cvec_copy_from_ivec ( cvec  dest,
ivec  orig 
)

Copy with conversion (lengths must match)

Definition at line 651 of file vec.c.

References cvec_length(), _cplx_::i, ivec_length(), and _cplx_::r.

void cvec_copy_from_vec ( cvec  dest,
vec  orig 
)

Copy with conversion (lengths must match)

Definition at line 639 of file vec.c.

References cvec_length(), _cplx_::i, _cplx_::r, and vec_length().

void cvec_copy_mem ( cplx buf,
cvec  v 
)

Copy the vector into a buffer (which must be a valid allocated pointer)

Definition at line 711 of file vec.c.

References cvec_length().

idx_t cvec_count ( cvec  v,
cplx  a 
)

Count the number of elements equal to a given value a

Definition at line 3165 of file vec.c.

References ceq(), and cvec_length().

Referenced by cvec_find(), and cvec_replace().

cvec cvec_cum_sum ( cvec  v  ) 

cumulative vector sum

Parameters:
v the input vector v
Returns:
a new vector of the cumulative sum of the input vector

Definition at line 2021 of file vec.c.

References cadd(), cvec_length(), and cvec_new().

void cvec_decr ( cvec  v,
cplx  a 
)

substract a specified value to the vector components

Definition at line 1341 of file vec.c.

References csub(), and cvec_length().

void cvec_decr_real ( cvec  v,
double  a 
)

substract a specified real value to the complex components

Definition at line 1291 of file vec.c.

References creal, and cvec_length().

cvec cvec_del ( cvec  v,
idx_t  pos 
)

Delete an element from the vector

Definition at line 909 of file vec.c.

References Vec_del.

void cvec_delete ( cvec  v  ) 

void cvec_div ( cvec  v1,
cvec  v2 
)

Component per component division

Definition at line 1493 of file vec.c.

References cdiv(), and cvec_length().

void cvec_div_by ( cvec  v,
cplx  a 
)

divide the components per a

Definition at line 1359 of file vec.c.

References ceq(), cinv(), cmul(), cplx_0, and cvec_length().

Referenced by cmat_inv().

void cvec_div_by_real ( cvec  v,
double  a 
)

Definition at line 1311 of file vec.c.

References cvec_length(), _cplx_::i, and _cplx_::r.

Referenced by cvec_fft_autocorr(), cvec_fft_conv(), cvec_fft_corr(), it_ifft(), and it_sidft().

int cvec_eq ( cvec  v1,
cvec  v2 
)

Return true iff all the vectors v1 and v2 are equal component per component

Definition at line 1119 of file vec.c.

References ceq(), and cvec_length().

Referenced by cmat_eq().

ivec cvec_find ( cvec  v,
cplx  a 
)

Return the set of positions where a given value occurs

Definition at line 2965 of file vec.c.

References ceq(), cvec_count(), cvec_length(), and ivec_new().

idx_t cvec_find_first ( cvec  v,
cplx  a 
)

Return the first position where the value a occurs, NULL_INDEX if the research is not successful

Definition at line 2908 of file vec.c.

References ceq(), cvec_length(), and NULL_INDEX.

void cvec_geom ( cvec  ,
cplx  start,
cplx  r 
)

Set the vector to an geometric sequence

Definition at line 3938 of file vec.c.

References cmul(), and cvec_length().

cvec cvec_get_subvector ( cvec  v,
idx_t  i1,
idx_t  i2 
)

allocate a new vector formed by a subset of a given vector

Definition at line 462 of file vec.c.

References cvec_init(), cvec_new(), and VEC_END_PARAM.

cplx cvec_head ( const cvec  v  ) 

Return the last element of vector

Definition at line 1018 of file vec.c.

References Vec_head.

void cvec_incr ( cvec  v,
cplx  a 
)

add a to the components

Definition at line 1332 of file vec.c.

References cadd(), and cvec_length().

void cvec_incr_real ( cvec  v,
double  a 
)

add a to the components

Definition at line 1282 of file vec.c.

References creal, and cvec_length().

cvec cvec_index_by ( cvec  v,
ivec  idx 
)

Return the vector composed of the elements of v indexed by idx

Definition at line 3522 of file vec.c.

References cvec_new(), and ivec_length().

cvec cvec_init ( cvec  v,
cplx buf,
idx_t  N 
)

Initialize the vector from a buffer of the same type

Definition at line 339 of file vec.c.

References Vec_init.

Referenced by cvec_get_subvector().

idx_t cvec_length_max ( cvec  v  ) 

Return the maximum length of the vector (number of allocated elements)

Definition at line 255 of file vec.c.

References Vec_length_max.

void cvec_mul ( cvec  v1,
cvec  v2 
)

Component per component multiplication

The result is stored in the vector which is the first parameter

Definition at line 1482 of file vec.c.

References cmul(), and cvec_length().

Referenced by cvec_fft_conv(), it_fdft(), and it_fzt().

void cvec_mul_by ( cvec  v,
cplx  a 
)

multiply the components per a specified value

Definition at line 1350 of file vec.c.

References cmul(), and cvec_length().

void cvec_mul_by_real ( cvec  v,
double  a 
)

multiply the components per a

Definition at line 1300 of file vec.c.

References cvec_length(), _cplx_::i, and _cplx_::r.

Referenced by main().

void cvec_neg ( cvec  v  ) 

Negate the vector

Definition at line 1674 of file vec.c.

References cneg(), and cvec_length().

cvec cvec_new_1N ( idx_t  n  ) 

The sequence 1, 2.. N

Definition at line 4040 of file vec.c.

References cimag, creal, and cvec_new().

vec cvec_new_abs ( cvec  v  ) 

New vector generated with the absolute values of the input vector

Definition at line 1786 of file vec.c.

References cnorm(), cvec_length(), and vec_new().

cvec cvec_new_alloc ( idx_t  length,
idx_t  length_max 
)

Vector allocation with explicit allocation of the maximum number of elements

Definition at line 118 of file vec.c.

References Vec_new_alloc.

Referenced by cvec_new_string(), parser_get_cvec(), and parser_get_cvec_verbose().

cvec cvec_new_arithm ( cplx  start,
cplx  incr,
idx_t  N 
)

New arithmetic sequence

Definition at line 4133 of file vec.c.

References cadd(), and cvec_new().

cvec cvec_new_concat ( cvec  v1,
cvec  v2 
)

Concatenate two vectors

Definition at line 3229 of file vec.c.

References cvec_length(), and cvec_new().

cvec cvec_new_geom ( cplx  start,
cplx  r,
idx_t  N 
)

Same but a geometric sequence of geometric factor r

Definition at line 4186 of file vec.c.

References cmul(), and cvec_new().

cvec cvec_new_ones ( idx_t  N  ) 

New vectors of ones

Definition at line 3783 of file vec.c.

References cplx_1, and cvec_new_set().

cvec cvec_new_range ( idx_t  n  ) 

New vector 0, 1, ... N-1

Definition at line 4084 of file vec.c.

References cimag, creal, and cvec_new().

Referenced by main().

cvec cvec_new_reverse ( cvec  v  ) 

Reverse the vector

Definition at line 2854 of file vec.c.

References cimag, creal, cvec_length(), and cvec_new().

cvec cvec_new_set ( cplx  val,
idx_t  N 
)

Constant vector

Definition at line 3997 of file vec.c.

References cvec_new(), and cvec_set().

Referenced by cvec_new_ones(), and cvec_new_zeros().

cvec cvec_new_unit_roots ( idx_t  N  ) 

generate $e^{2i Pi k / N} = cos(2 k Pi / N) + i sin(2 k Pi / N)$

Definition at line 4200 of file vec.c.

References cimag, creal, cvec_new(), and M_PI.

Referenced by fft_init().

cvec cvec_new_void (  ) 

Create a vector of length 0

Definition at line 3969 of file vec.c.

References cvec_new().

cvec cvec_new_zeros ( idx_t  N  ) 

Create a vectors of zeros

Definition at line 3735 of file vec.c.

References cplx_0, and cvec_new_set().

Referenced by cmat_cvec_mul(), cmat_vec_mul(), it_fdft(), it_fzt(), and mat_h2rs().

void cvec_ones ( cvec   ) 

Set all the vector elements to 1

Definition at line 3759 of file vec.c.

References cplx_1, and cvec_set().

cvec cvec_pop ( cvec  v  ) 

Retrieve the last element at the end of the vector (this removes it)

Definition at line 993 of file vec.c.

References Vec_pop.

void cvec_range ( cvec   ) 

Set the vector elements to 0,1, ... n-1

Definition at line 3816 of file vec.c.

References cvec_length(), _cplx_::i, and _cplx_::r.

ivec cvec_replace ( cvec  v,
cplx  a,
cplx  b 
)

Replace a given value by another for all vector components

Definition at line 3111 of file vec.c.

References ceq(), cvec_count(), cvec_length(), and ivec_new().

void cvec_reverse ( cvec  v  ) 

Reverse the vector

Definition at line 2786 of file vec.c.

References cimag, creal, and cvec_length().

cvec cvec_set ( cvec  v,
cplx  val 
)

Set all the elements of the vector to a given value

Definition at line 366 of file vec.c.

References Vec_set.

Referenced by cvec_new_set(), and cvec_ones().

cvec cvec_set_between ( cvec  v,
idx_t  i1,
idx_t  i2,
cplx  val 
)

Set the elements of a subvector to a given value val

Definition at line 394 of file vec.c.

References Vec_set_between.

void cvec_set_subvector ( cvec  v,
cvec  s,
idx_t  idx 
)

Modify a given element subset of a vector to another vector

Definition at line 422 of file vec.c.

References VEC_END_PARAM, and Vec_set_subvector.

void cvec_sub ( cvec  v1,
cvec  v2 
)

Substraction

Definition at line 1471 of file vec.c.

References csub(), and cvec_length().

cplx cvec_sum ( cvec  v  ) 

vector sum

Definition at line 1974 of file vec.c.

References cadd(), cplx_0, and cvec_length().

Referenced by cmat_row_sum().

cplx cvec_sum_between ( cvec  v,
idx_t  i1,
idx_t  i2 
)

sum of a subset of the vector specified by an index interval

Definition at line 2077 of file vec.c.

References cadd(), cplx_0, and VEC_END_PARAM.

void cvec_void ( cvec   ) 

Reduce a vector to length 0

Definition at line 3689 of file vec.c.

References Vec_void.

void cvec_zeros ( cvec   ) 

Set all the elements of a vector to 0

Definition at line 3714 of file vec.c.

References cplx_0, and Vec_set.

static int double_leq ( const void *  d1,
const void *  d2 
) [static]

Definition at line 3580 of file vec.c.

Referenced by double_leq_index(), and vec_sort().

static int double_leq_index ( const void *  d1,
const void *  d2 
) [static]

Definition at line 3590 of file vec.c.

References double_leq().

Referenced by vec_sort_index().

static int int_leq ( const void *  d1,
const void *  d2 
) [static]

Definition at line 3608 of file vec.c.

Referenced by int_leq_index(), and ivec_sort().

static int int_leq_index ( const void *  d1,
const void *  d2 
) [static]

Definition at line 3618 of file vec.c.

References int_leq().

Referenced by ivec_sort_index().

void ivec_1N ( ivec   ) 

Set the vector elements to 1,2, ... n

Definition at line 3837 of file vec.c.

References ivec_length().

void ivec_abs ( ivec  v  ) 

Apply absolute value

Definition at line 1760 of file vec.c.

References ivec_length().

Referenced by ivec_new_abs().

void ivec_add ( ivec  v1,
ivec  v2 
)

addition

Definition at line 1416 of file vec.c.

References ivec_length().

Referenced by ivec_new_add().

ivec ivec_apply_function ( ivec  v,
it_ifunction_t  function,
it_args_t  args 
)

Apply a function to all vector elements

Definition at line 2714 of file vec.c.

References ivec_length().

Referenced by imat_apply_function(), and imat_new_apply_function().

void ivec_arithm ( ivec  ,
int  start,
int  incr 
)

Set the vector to an arithmetic sequence

Definition at line 3877 of file vec.c.

References ivec_length().

ivec ivec_clone ( ivec  v  ) 

Clone a vector (allocate memory and copy data)

Definition at line 527 of file vec.c.

References ivec_length(), ivec_new(), and Vec_copy.

Referenced by ivec_median(), ivec_new_add(), ivec_new_div(), ivec_new_mul(), ivec_new_sub(), ivec_new_unique(), and vlc_clone().

ivec ivec_conv ( ivec  v1,
ivec  v2 
)

Convolution of two vectors

Definition at line 4232 of file vec.c.

References ivec_length(), and ivec_new_zeros().

void ivec_copy ( ivec  dest,
ivec  orig 
)

Copy the content of a vector into another vector

Warning:
Note that these functions do NOT allocate memory for the destination vectors. Consequently, the amount of allocated elements vec_length_max(v) must be sufficient. The function returns the number of elements that has really been copied If the vectors have not the same size, the function returns an error

Definition at line 495 of file vec.c.

References Vec_copy.

void ivec_copy_from_bvec ( ivec  dest,
bvec  orig 
)

Copy with conversion (lengths must match)

Definition at line 588 of file vec.c.

References bvec_length(), and ivec_length().

void ivec_copy_from_cvec ( ivec  dest,
cvec  orig 
)

Copy with conversion (lengths must match)

Definition at line 598 of file vec.c.

References creal, cvec_length(), and ivec_length().

void ivec_copy_from_vec ( ivec  dest,
vec  orig 
)

Copy with conversion (lengths must match)

Definition at line 578 of file vec.c.

References ivec_length(), and vec_length().

void ivec_copy_mem ( int *  buf,
ivec  v 
)

Copy the vector into a buffer (which must be a valid allocated pointer)

Definition at line 689 of file vec.c.

References ivec_length().

idx_t ivec_count ( ivec  v,
int  a 
)

Count the number of elements equal to a given value a

Definition at line 3153 of file vec.c.

References ivec_length().

Referenced by ivec_find(), and ivec_replace().

ivec ivec_cum_sum ( ivec  v  ) 

cumulative vector sum

Parameters:
v the input vector v
Returns:
a new vector of the cumulative sum of the input vector

Definition at line 2001 of file vec.c.

References INT_MAX, INT_MIN, it_warning(), ivec_length(), ivec_new(), and Vec_length.

void ivec_decr ( ivec  v,
int  a 
)

substract a specified value to the vector components

Definition at line 1253 of file vec.c.

References ivec_length().

Referenced by imat_row_decr(), and test_quantizer().

ivec ivec_del ( ivec  v,
idx_t  pos 
)

Delete an element from the vector

Definition at line 895 of file vec.c.

References Vec_del.

Referenced by main(), vlc_energy_order(), and vlc_hu_tucker().

void ivec_div ( ivec  v1,
ivec  v2 
)

Component per component division

Definition at line 1449 of file vec.c.

References ivec_length().

Referenced by ivec_new_div().

void ivec_div_by ( ivec  v,
int  a 
)

divide the components per a

Definition at line 1271 of file vec.c.

References ivec_length().

Referenced by imat_row_div_by().

int ivec_eq ( ivec  v1,
ivec  v2 
)

Return true iff all the vectors v1 and v2 are equal component per component

Definition at line 1085 of file vec.c.

References ivec_length().

Referenced by imat_eq().

ivec ivec_find ( ivec  v,
int  a 
)

Return the set of positions where a given value occurs

Definition at line 2935 of file vec.c.

References ivec_count(), ivec_length(), and ivec_new().

idx_t ivec_find_first ( ivec  v,
int  a 
)

Return the first position where the value a occurs, NULL_INDEX if the research is not successful

Definition at line 2886 of file vec.c.

References ivec_length(), and NULL_INDEX.

idx_t ivec_find_sorted ( ivec  v,
int  a 
)

Return the set of positions where a given value occurs assuming a sorted set

Definition at line 3008 of file vec.c.

References ivec_length(), and left.

void ivec_geom ( ivec  ,
int  start,
int  r 
)

Set the vector to an geometric sequence

Definition at line 3918 of file vec.c.

References ivec_length().

int ivec_geq ( ivec  v1,
ivec  v2 
)

Definition at line 1156 of file vec.c.

References ivec_length().

ivec ivec_get_subvector ( ivec  v,
idx_t  i1,
idx_t  i2 
)

allocate a new vector formed by a subset of a given vector

Definition at line 440 of file vec.c.

References ivec_init(), ivec_new(), and VEC_END_PARAM.

int ivec_head ( ivec  v  ) 

Return the last element of vector

Definition at line 1006 of file vec.c.

References Vec_head.

void ivec_incr ( ivec  v,
int  a 
)

add a to the components

Definition at line 1244 of file vec.c.

References ivec_length().

Referenced by imat_row_incr().

ivec ivec_index_by ( ivec  v,
ivec  idx 
)

Return the vector composed of the elements of v indexed by idx

Definition at line 3498 of file vec.c.

References ivec_length(), and ivec_new().

Referenced by vlc_quasi_lexicographic().

ivec ivec_init ( ivec  v,
int *  buf,
idx_t  N 
)

Initialize the vector from a buffer of the same type

Definition at line 327 of file vec.c.

References Vec_init.

Referenced by imat_get_submatrix(), ivec_get_subvector(), and ivec_sread().

int ivec_inner_product ( ivec  v1,
ivec  v2 
)

Inner product of two vectors

Definition at line 1614 of file vec.c.

References ivec_length().

ivec ivec_k_max ( ivec  v,
int  k 
)

Search the k greatest elements

Definition at line 2329 of file vec.c.

References ivec_k_max_between(), and ivec_length().

Referenced by main().

ivec ivec_k_max_between ( ivec  v,
int  k,
idx_t  a,
idx_t  b 
)

Search the k greatest elements between two positions

Definition at line 2288 of file vec.c.

References ivec_delete(), ivec_k_max_between(), ivec_length(), ivec_new(), ivec_new_alloc(), ivec_new_void(), and ivec_push.

Referenced by ivec_k_max(), and ivec_k_max_between().

ivec ivec_k_max_index ( ivec  v,
int  k 
)

Search the indexes where the k greatest elements occur

Definition at line 2525 of file vec.c.

References ivec_k_max_index_between(), and ivec_length().

ivec ivec_k_max_index_between ( ivec  v,
int  k,
idx_t  a,
idx_t  b 
)

Search the indexes where the k greatest elements between two positions occur

Definition at line 2483 of file vec.c.

References ivec_delete(), ivec_k_max_index_between(), ivec_length(), ivec_new(), ivec_new_alloc(), ivec_new_void(), and ivec_push.

Referenced by ivec_k_max_index(), ivec_k_max_index_between(), and main().

ivec ivec_k_min ( ivec  v,
int  k 
)

Search the k smallest elements

Todo:
modify the algorithm and use the k-select algorithm

Definition at line 2281 of file vec.c.

References ivec_k_min_between(), and ivec_length().

ivec ivec_k_min_between ( ivec  v,
int  k,
idx_t  a,
idx_t  b 
)

Search the k smallest elements between two positions

Definition at line 2239 of file vec.c.

References ivec_delete(), ivec_k_min_between(), ivec_length(), ivec_new(), ivec_new_alloc(), ivec_new_void(), and ivec_push.

Referenced by ivec_k_min(), and ivec_k_min_between().

ivec ivec_k_min_index ( ivec  v,
int  k 
)

Search the indexes where the k smallest elements occur

Definition at line 2476 of file vec.c.

References ivec_k_min_index_between(), and ivec_length().

ivec ivec_k_min_index_between ( ivec  v,
int  k,
idx_t  a,
idx_t  b 
)

Search the indexes where the k smallest elements between two positions occur

Definition at line 2434 of file vec.c.

References ivec_delete(), ivec_k_min_index_between(), ivec_length(), ivec_new(), ivec_new_alloc(), ivec_new_void(), and ivec_push.

Referenced by ivec_k_min_index(), and ivec_k_min_index_between().

idx_t ivec_length ( ivec  v  ) 

Return the length of the vector

Definition at line 219 of file vec.c.

References Vec_length.

Referenced by __ivec(), _ivec_push(), bcjr_side(), bvec_copy_from_ivec(), bvec_index_by(), bvec_new_intersection(), bvec_new_union(), bvec_new_unique(), bvecivec_inner_product(), convolutional_code_encode_symbolic(), cvec_copy_from_ivec(), cvec_index_by(), histogram(), histogram_cond(), histogram_normalized(), imat_cols_sum(), imat_copy_col(), imat_copy_row(), imat_diag(), imat_ivec_mul(), imat_new_diag(), imat_rows_sum(), imat_set_col(), imat_set_diag(), it_vfprintf(), it_viterbi_decode_symbolic(), ivec_1N(), ivec_abs(), ivec_add(), ivec_apply_function(), ivec_arithm(), ivec_clone(), ivec_conv(), ivec_copy_from_bvec(), ivec_copy_from_cvec(), ivec_copy_from_vec(), ivec_copy_mem(), ivec_count(), ivec_cum_sum(), ivec_decr(), ivec_distance_hamming(), ivec_distance_levenshtein(), ivec_distance_mse(), ivec_distance_norm1(), ivec_distance_sqr(), ivec_div(), ivec_div_by(), ivec_eq(), ivec_find(), ivec_find_first(), ivec_find_sorted(), ivec_fread(), ivec_fwrite(), ivec_geom(), ivec_geq(), ivec_imat_mul(), ivec_incr(), ivec_index_by(), ivec_inner_product(), ivec_k_max(), ivec_k_max_between(), ivec_k_max_index(), ivec_k_max_index_between(), ivec_k_min(), ivec_k_min_between(), ivec_k_min_index(), ivec_k_min_index_between(), ivec_max_index(), ivec_mean(), ivec_median(), ivec_min_index(), ivec_mul(), ivec_mul_by(), ivec_neg(), ivec_new_abs(), ivec_new_apply_function(), ivec_new_concat(), ivec_new_deinterleave_block(), ivec_new_interleave_block(), ivec_new_intersection(), ivec_new_reverse(), ivec_new_union(), ivec_new_unique(), ivec_norm(), ivec_range(), ivec_replace(), ivec_reverse(), ivec_ser(), ivec_sqr(), ivec_sub(), ivec_sum(), ivec_to_bvec(), ivec_to_cvec(), ivec_to_imat(), ivec_to_spivec(), ivec_to_vec(), main(), mat_ivec_mul(), mat_lu(), mat_solve_mat(), mat_solve_vec(), scalar_quantizer_dequantize(), selcol(), spivec_distance_norm1(), spivec_distance_sqr(), spivec_inner_product(), spivec_to_ivec(), spvec_distance_norm1(), spvec_distance_sqr(), spvec_inner_product(), spvec_to_vec(), trellis_coded_quantizer_dequantize(), vec_copy_from_ivec(), vec_index_by(), vec_k_max_index_between(), vec_k_min_index_between(), vecivec_inner_product(), viterbi_side(), vlc_encode_concat(), vlc_energy_order(), vlc_nb_bits_required(), and vlc_read().

idx_t ivec_length_max ( ivec  v  ) 

Return the maximum length of the vector (number of allocated elements)

Definition at line 243 of file vec.c.

References Vec_length_max.

Referenced by main().

int ivec_max ( ivec  v  ) 

Maxinum of a vector

Definition at line 1881 of file vec.c.

References INT_MIN, and Vec_length.

Referenced by test_quantizer().

idx_t ivec_max_index ( ivec  v  ) 

Position where the vector maximum occurs

Definition at line 1906 of file vec.c.

References INT_MIN, ivec_length(), and NULL_INDEX.

double ivec_mean ( ivec  v  ) 

mean of the input vector

Definition at line 1920 of file vec.c.

References ivec_length(), and ivec_sum().

int ivec_median ( ivec  v  ) 

median value of the input vector

Definition at line 2544 of file vec.c.

References it_warning(), ivec_clone(), ivec_delete(), ivec_length(), and ivec_sort().

Referenced by main().

int ivec_min ( ivec  v  ) 

Mininum of a vector

Definition at line 1869 of file vec.c.

References INT_MAX, and Vec_length.

Referenced by test_quantizer().

idx_t ivec_min_index ( ivec  v  ) 

Position where the vector minimum occurs

Definition at line 1892 of file vec.c.

References INT_MAX, ivec_length(), and NULL_INDEX.

void ivec_mul ( ivec  v1,
ivec  v2 
)

Component per component multiplication

The result is stored in the vector which is the first parameter

Definition at line 1438 of file vec.c.

References ivec_length().

Referenced by ivec_new_mul().

void ivec_mul_by ( ivec  v,
int  a 
)

multiply the components per a specified value

Definition at line 1262 of file vec.c.

References ivec_length().

Referenced by imat_row_mul_by().

void ivec_neg ( ivec  v  ) 

Negate the vector

Definition at line 1665 of file vec.c.

References ivec_length().

ivec ivec_new_1N ( idx_t  n  ) 

The sequence 1, 2.. N

Definition at line 4018 of file vec.c.

References ivec_new().

ivec ivec_new_abs ( ivec  v  ) 

New vector generated with the absolute values of the input vector

Definition at line 1778 of file vec.c.

References ivec_abs(), ivec_length(), and ivec_new().

ivec ivec_new_add ( ivec  v1,
ivec  v2 
)

addition stored in a new vector

Definition at line 1547 of file vec.c.

References ivec_add(), and ivec_clone().

ivec ivec_new_apply_function ( ivec  v,
it_ifunction_t  function,
it_args_t  args 
)

Apply a function to all vector elements

Definition at line 2726 of file vec.c.

References ivec_length(), and ivec_new().

ivec ivec_new_arithm ( int  start,
int  incr,
idx_t  N 
)

New arithmetic sequence

Definition at line 4110 of file vec.c.

References ivec_new().

Referenced by ivec_new_perm(), and vlc_hu_tucker().

ivec ivec_new_concat ( ivec  v1,
ivec  v2 
)

Concatenate two vectors

Definition at line 3197 of file vec.c.

References ivec_length(), and ivec_new().

ivec ivec_new_div ( ivec  v1,
ivec  v2 
)

Component per component division

Definition at line 1571 of file vec.c.

References ivec_clone(), and ivec_div().

ivec ivec_new_geom ( int  start,
int  r,
idx_t  N 
)

Same but a geometric sequence of geometric factor r

Definition at line 4161 of file vec.c.

References it_assert, and ivec_new().

Referenced by main().

ivec ivec_new_intersection ( ivec  v1,
ivec  v2 
)

Intersection of two sets represented by the two input vectors

Definition at line 3428 of file vec.c.

References ivec_delete(), ivec_length(), ivec_new_alloc(), ivec_new_unique(), and ivec_push.

Referenced by main().

ivec ivec_new_mul ( ivec  v1,
ivec  v2 
)

Component per component multiplication

Definition at line 1563 of file vec.c.

References ivec_clone(), and ivec_mul().

ivec ivec_new_ones ( idx_t  N  ) 

New vectors of ones

Definition at line 3771 of file vec.c.

References ivec_new_set().

Referenced by main(), and vlc_hu_tucker().

ivec ivec_new_perm ( size_t  N  ) 

Generate a new vector representing a random permutation

Definition at line 4296 of file vec.c.

References it_assert, it_rand(), and ivec_new_arithm().

ivec ivec_new_range ( idx_t  n  ) 

New vector 0, 1, ... N-1

Definition at line 4063 of file vec.c.

References ivec_new().

ivec ivec_new_reverse ( ivec  v  ) 

Reverse the vector

Definition at line 2821 of file vec.c.

References ivec_length(), and ivec_new().

ivec ivec_new_set ( int  val,
idx_t  N 
)

Constant vector

Definition at line 3983 of file vec.c.

References ivec_new(), and ivec_set().

Referenced by ivec_new_ones(), and ivec_new_zeros().

ivec ivec_new_sub ( ivec  v1,
ivec  v2 
)

Substraction

Definition at line 1555 of file vec.c.

References ivec_clone(), and ivec_sub().

ivec ivec_new_union ( ivec  v1,
ivec  v2 
)

Union of two sets represented by the two input vectors

Definition at line 3342 of file vec.c.

References ivec_delete(), ivec_length(), ivec_new_alloc(), ivec_new_unique(), and ivec_push.

Referenced by main().

ivec ivec_new_unique ( ivec  v  ) 

Vector created from the input vector by taking one occurences of each possible value of the input vector

Definition at line 3269 of file vec.c.

References ivec_clone(), ivec_delete(), ivec_length(), ivec_new(), ivec_push, and ivec_sort().

Referenced by ivec_new_intersection(), ivec_new_union(), and main().

ivec ivec_new_void (  ) 

ivec ivec_new_zeros ( idx_t  N  ) 

double ivec_norm ( ivec  v,
int  nr 
)

Norm of the input vector

Definition at line 2675 of file vec.c.

References ivec_length().

void ivec_ones ( ivec   ) 

Set all the vector elements to 1

Definition at line 3747 of file vec.c.

References ivec_set().

ivec ivec_pop ( ivec  v  ) 

Retrieve the last element at the end of the vector (this removes it)

Definition at line 979 of file vec.c.

References Vec_pop.

Referenced by main().

void ivec_range ( ivec   ) 

Set the vector elements to 0,1, ... n-1

Definition at line 3798 of file vec.c.

References ivec_length().

ivec ivec_replace ( ivec  v,
int  a,
int  b 
)

Replace a given value by another for all vector components

Definition at line 3077 of file vec.c.

References ivec_count(), ivec_length(), and ivec_new().

void ivec_reverse ( ivec  v  ) 

Reverse the vector

Definition at line 2756 of file vec.c.

References ivec_length().

Referenced by main().

ivec ivec_set ( ivec  v,
int  val 
)

Set all the elements of the vector to a given value

Definition at line 352 of file vec.c.

References Vec_set.

Referenced by ivec_new_set(), ivec_ones(), main(), vlc_decode_concat_N(), vlc_hu_tucker(), and vlc_new().

ivec ivec_set_between ( ivec  v,
idx_t  i1,
idx_t  i2,
int  val 
)

Set the elements of a subvector to a given value val

Definition at line 380 of file vec.c.

References Vec_set_between.

Referenced by vlc_quasi_lexicographic().

void ivec_set_subvector ( ivec  v,
ivec  s,
idx_t  idx 
)

Modify a given element subset of a vector to another vector

Definition at line 408 of file vec.c.

References VEC_END_PARAM, and Vec_set_subvector.

void ivec_sort ( ivec  v  ) 

Sort the vector by increasing values

Definition at line 3623 of file vec.c.

References int_leq(), and Vec_sort().

Referenced by ivec_median(), ivec_new_unique(), and main().

ivec ivec_sort_index ( ivec  v  ) 

Return a vector of index corresponding to increasing values of the input vector

Definition at line 3629 of file vec.c.

References int_leq_index(), and Vec_sort_index().

void ivec_sqr ( ivec  v  ) 

square the vector component per component

Definition at line 1705 of file vec.c.

References ivec_length().

void ivec_sub ( ivec  v1,
ivec  v2 
)

Substraction

Definition at line 1427 of file vec.c.

References ivec_length().

Referenced by ivec_new_sub().

int ivec_sum ( ivec  v  ) 

vector sum

Definition at line 1958 of file vec.c.

References INT_MAX, INT_MIN, it_warning(), and ivec_length().

Referenced by fpICA(), imat_row_sum(), it_ica(), ivec_mean(), PCAmat(), and selcol().

int ivec_sum_between ( ivec  v,
idx_t  i1,
idx_t  i2 
)

sum of a subset of the vector specified by an index interval

Definition at line 2060 of file vec.c.

References INT_MAX, INT_MIN, it_warning(), and VEC_END_PARAM.

bvec ivec_to_bvec ( ivec  v  ) 

Vector type conversion

Definition at line 775 of file vec.c.

References bvec_new(), and ivec_length().

cvec ivec_to_cvec ( ivec  v  ) 

Vector type conversion

Definition at line 787 of file vec.c.

References cimag, creal, cvec_new(), and ivec_length().

void ivec_to_spivec ( ivec  v,
ivec svi_out,
ivec sv_out 
)

convert a vector into a sparse vector

Definition at line 4349 of file vec.c.

References ivec_length(), and ivec_new().

vec ivec_to_vec ( ivec  v  ) 

Vector type conversion

Definition at line 762 of file vec.c.

References ivec_length(), and vec_new().

void ivec_void ( ivec   ) 

Reduce a vector to length 0

Definition at line 3677 of file vec.c.

References Vec_void.

void ivec_zeros ( ivec   ) 

Set all the elements of a vector to 0

Definition at line 3702 of file vec.c.

References Vec_set.

int spivec_inner_product ( ivec  svi1,
ivec  sv1,
ivec  svi2,
ivec  sv2 
)

Inner product between two sparse vectors

Definition at line 4452 of file vec.c.

References ivec_length().

ivec spivec_to_ivec ( ivec  svi,
ivec  sv,
int  n 
)

convert a sparse vector into a vector

Definition at line 4395 of file vec.c.

References ivec_length(), and ivec_new_zeros().

double spvec_inner_product ( ivec  svi1,
vec  sv1,
ivec  svi2,
vec  sv2 
)

Inner product between two sparse vectors

Definition at line 4419 of file vec.c.

References ivec_length().

vec spvec_to_vec ( ivec  svi,
vec  sv,
int  n 
)

convert a sparse vector into a vector

Definition at line 4372 of file vec.c.

References ivec_length(), vec_length(), and vec_new_zeros().

void vec_1N ( vec   ) 

Set the vector elements to 1,2, ... n

Definition at line 3828 of file vec.c.

References vec_length().

Referenced by main().

void vec_abs ( vec  v  ) 

Apply absolute value

Definition at line 1750 of file vec.c.

References vec_length().

Referenced by fpICA(), and vec_new_abs().

void vec_add ( vec  v1,
vec  v2 
)

addition

Definition at line 1372 of file vec.c.

References vec_length().

Referenced by channel_awgn(), fpICA(), mat_gs(), and vec_new_add().

void vec_apply_function ( vec  v,
it_function_t  function,
it_args_t  args 
)

Apply a function to all vector elements

Definition at line 2689 of file vec.c.

References vec_length().

Referenced by mat_apply_function(), mat_new_apply_function(), viterbi(), and viterbi_side().

void vec_arithm ( vec  ,
double  start,
double  incr 
)

Set the vector to an arithmetic sequence

Definition at line 3867 of file vec.c.

References vec_length().

vec vec_clone ( vec  v  ) 

Vec Vec_clone ( Vec  v  ) 

Clone a vector (allocate memory and copy data)

Definition at line 513 of file vec.c.

References __Vec_new(), Vec_copy, Vec_element_size, and Vec_length.

vec vec_conv ( vec  v1,
vec  v2 
)

Convolution of two vectors

Definition at line 4218 of file vec.c.

References vec_length(), and vec_new_zeros().

Referenced by poly_mul().

void vec_copy ( vec  dest,
vec  orig 
)

Copy the content of a vector into another vector

Warning:
Note that these functions do NOT allocate memory for the destination vectors. Consequently, the amount of allocated elements vec_length_max(v) must be sufficient. The function returns the number of elements that has really been copied If the vectors have not the same size, the function returns an error

Definition at line 489 of file vec.c.

References Vec_copy.

Referenced by __it_wavelet2D_copy(), __wavelet_transform(), bcjr(), bcjr_side(), fpICA(), logviterbi(), main(), viterbi(), and viterbi_side().

void vec_copy_from_bvec ( vec  dest,
bvec  orig 
)

Copy with conversion (lengths must match)

Definition at line 558 of file vec.c.

References bvec_length(), and vec_length().

void vec_copy_from_cvec ( vec  dest,
cvec  orig 
)

Copy with conversion (lengths must match)

Definition at line 568 of file vec.c.

References creal, cvec_length(), and vec_length().

void vec_copy_from_ivec ( vec  dest,
ivec  orig 
)

Copy with conversion (lengths must match)

Definition at line 548 of file vec.c.

References ivec_length(), and vec_length().

void vec_copy_mem ( double *  buf,
vec  v 
)

Copy the vector into a buffer (which must be a valid allocated pointer)

Definition at line 678 of file vec.c.

References vec_length().

idx_t vec_count ( vec  v,
double  a 
)

Count the number of elements equal to a given value a

Definition at line 3129 of file vec.c.

References Vec_length.

Referenced by vec_find(), and vec_replace().

double vec_cov ( vec  v1,
vec  v2 
)

Covariance between two vectors

Definition at line 2627 of file vec.c.

References vec_clone(), vec_delete(), vec_length(), vec_mean(), vec_mul(), vec_new_set(), vec_sub(), and vec_sum().

Referenced by mat_cov().

vec vec_cum_sum ( vec  v  ) 

cumulative vector sum

Parameters:
v the input vector v
Returns:
a new vector of the cumulative sum of the input vector

Definition at line 1985 of file vec.c.

References Vec_length, vec_length(), and vec_new().

Referenced by it_rand_memoryless(), main(), and source_memoryless().

void vec_decr ( vec  v,
double  a 
)

substract a specified value to the vector components

Definition at line 1214 of file vec.c.

References vec_length().

Referenced by mat_row_decr().

vec vec_del ( vec  v,
idx_t  pos 
)

Delete an element from the vector

Definition at line 888 of file vec.c.

References Vec_del.

Referenced by main().

void vec_div ( vec  v1,
vec  v2 
)

Component per component division

Definition at line 1405 of file vec.c.

References vec_length().

Referenced by fpICA(), vec_new_div(), and vlc_energy_order().

void vec_div_by ( vec  v,
double  a 
)

divide the components per a

Definition at line 1232 of file vec.c.

References vec_length().

Referenced by fpICA(), and mat_row_div_by().

int vec_eq ( vec  v1,
vec  v2 
)

Return true iff all the vectors v1 and v2 are equal component per component

Definition at line 1068 of file vec.c.

References vec_length().

Referenced by mat_eq().

void vec_exp ( vec  v  ) 

apply exponential

Definition at line 1741 of file vec.c.

References Vec_length.

Referenced by fpICA().

ivec vec_find ( vec  v,
double  a 
)

Return the set of positions where a given value occurs

Definition at line 2920 of file vec.c.

References ivec_new(), vec_count(), and Vec_length.

idx_t vec_find_first ( vec  v,
double  a 
)

Return the first position where the value a occurs, NULL_INDEX if the research is not successful

Definition at line 2875 of file vec.c.

References NULL_INDEX, and Vec_length.

idx_t vec_find_sorted ( vec  v,
double  a 
)

Return the set of positions where a given value occurs assuming a sorted set

Definition at line 2983 of file vec.c.

References left, and vec_length().

void vec_geom ( vec  ,
double  start,
double  r 
)

Set the vector to an geometric sequence

Definition at line 3908 of file vec.c.

References vec_length().

int vec_geq ( vec  v1,
vec  v2 
)

Definition at line 1136 of file vec.c.

References vec_length().

vec vec_get_subvector ( vec  v,
idx_t  i1,
idx_t  i2 
)

allocate a new vector formed by a subset of a given vector

Definition at line 429 of file vec.c.

References VEC_END_PARAM, vec_init(), and vec_new().

Referenced by it_wavelet_split(), and scalar_quantizer_get_codebook_range().

double vec_head ( vec  v  ) 

Return the last element of vector

Definition at line 1000 of file vec.c.

References Vec_head.

void vec_incr ( vec  v,
double  a 
)

add a to the components

Definition at line 1205 of file vec.c.

References vec_length().

Referenced by mat_row_incr().

vec vec_index_by ( vec  v,
ivec  idx 
)

Return the vector composed of the elements of v indexed by idx

Definition at line 3486 of file vec.c.

References ivec_length(), and vec_new().

Referenced by vlc_energy_order(), and vlc_quasi_lexicographic().

vec vec_init ( vec  v,
double *  buf,
idx_t  N 
)

Initialize the vector from a buffer of the same type

Definition at line 321 of file vec.c.

References Vec_init.

Referenced by mat_get_submatrix(), vec_get_subvector(), and vec_sread().

double vec_inner_product ( vec  v1,
vec  v2 
)

Inner product of two vectors

Definition at line 1580 of file vec.c.

References vec_length().

Referenced by fpICA(), main(), and source_expectation().

double vec_inner_product_robust ( vec  v1,
vec  v2 
)

Robustly computed inner product of two vectors

Definition at line 1593 of file vec.c.

References vec_length().

vec vec_k_max ( vec  v,
int  k 
)

Search the k greatest elements

Definition at line 2232 of file vec.c.

References vec_k_max_between(), and vec_length().

vec vec_k_max_between ( vec  v,
int  k,
idx_t  a,
idx_t  b 
)

Search the k greatest elements between two positions

Definition at line 2191 of file vec.c.

References vec_delete(), vec_k_max_between(), vec_length(), vec_new(), vec_new_alloc(), vec_new_void(), and vec_push.

Referenced by vec_k_max(), and vec_k_max_between().

ivec vec_k_max_index ( vec  v,
int  k 
)

Search the indexes where the k greatest elements occur

Definition at line 2427 of file vec.c.

References vec_k_max_index_between(), and vec_length().

ivec vec_k_max_index_between ( vec  v,
int  k,
idx_t  a,
idx_t  b 
)

Search the indexes where the k greatest elements between two positions occur

Definition at line 2385 of file vec.c.

References ivec_delete(), ivec_length(), ivec_new(), ivec_new_alloc(), ivec_new_void(), ivec_push, and vec_k_max_index_between().

Referenced by vec_k_max_index(), and vec_k_max_index_between().

vec vec_k_min ( vec  v,
int  k 
)

Search the k smallest elements

Todo:
modify the algorithm and use the k-select algorithm

Definition at line 2184 of file vec.c.

References vec_k_min_between(), and vec_length().

vec vec_k_min_between ( vec  v,
int  k,
idx_t  a,
idx_t  b 
)

Search the k smallest elements between two positions

Definition at line 2142 of file vec.c.

References vec_delete(), vec_k_min_between(), vec_length(), vec_new(), vec_new_alloc(), vec_new_void(), and vec_push.

Referenced by vec_k_min(), and vec_k_min_between().

ivec vec_k_min_index ( vec  v,
int  k 
)

Search the indexes where the k smallest elements occur

Definition at line 2378 of file vec.c.

References vec_k_min_index_between(), and vec_length().

ivec vec_k_min_index_between ( vec  v,
int  k,
idx_t  a,
idx_t  b 
)

Search the indexes where the k smallest elements between two positions occur

Definition at line 2336 of file vec.c.

References ivec_delete(), ivec_length(), ivec_new(), ivec_new_alloc(), ivec_new_void(), ivec_push, and vec_k_min_index_between().

Referenced by vec_k_min_index(), and vec_k_min_index_between().

idx_t vec_length ( vec  v  ) 

Length and max length vector operations

Definition at line 213 of file vec.c.

References Vec_length.

Referenced by __vec(), __wavelet_itransform(), __wavelet_pack(), __wavelet_transform(), __wavelet_unpack(), _vec_push(), arithmetic_coder_encode_symbol(), arithmetic_decoder_decode_symbol(), bspk_metrics(), bvec_copy_from_vec(), channel_awgn(), cmat_vec_mul(), cvec_copy_from_vec(), entropy(), fpICA(), fvec_fread(), fvec_fwrite(), imat_vec_mul(), it_instanciate(), it_rand_memoryless(), it_vfprintf(), it_wavelet_merge(), it_wavelet_split(), ivec_copy_from_vec(), main(), mat_cols_sum(), mat_copy_col(), mat_copy_row(), mat_diag(), mat_h2rs(), mat_new_diag(), mat_rank(), mat_rows_sum(), mat_set_col(), mat_set_diag(), mat_solve_vec(), mat_vec_mul(), PCAmat(), poly_add(), poly_is_null(), poly_normalize(), poly_shift(), poly_sub(), scalar_quantizer_quantize(), scalar_quantizer_set_codebook(), scalar_quantizer_set_index_range(), source_expectation(), source_memoryless(), source_pdf_GG(), source_variance(), spvec_distance_norm1(), spvec_distance_sqr(), spvec_to_vec(), trellis_coded_quantizer_quantize(), vec_1N(), vec_abs(), vec_add(), vec_apply_function(), vec_arithm(), vec_clone(), vec_conv(), vec_copy_from_bvec(), vec_copy_from_cvec(), vec_copy_from_ivec(), vec_copy_mem(), vec_cov(), vec_cum_sum(), vec_decr(), vec_distance_hamming(), vec_distance_kullback_leibler(), vec_distance_mse(), vec_distance_norm(), vec_div(), vec_div_by(), vec_eq(), vec_find_sorted(), vec_fread(), vec_fwrite(), vec_geom(), vec_geq(), vec_incr(), vec_inner_product(), vec_inner_product_robust(), vec_is_negative(), vec_k_max(), vec_k_max_between(), vec_k_max_index(), vec_k_min(), vec_k_min_between(), vec_k_min_index(), vec_mat_mul(), vec_max_index(), vec_median(), vec_min_index(), vec_mul(), vec_mul_by(), vec_neg(), vec_new_abs(), vec_new_apply_function(), vec_new_concat(), vec_new_deinterleave_block(), vec_new_interleave_block(), vec_new_intersection(), vec_new_normalize(), vec_new_pow(), vec_new_reverse(), vec_new_union(), vec_new_unique(), vec_norm(), vec_normalize(), vec_rand(), vec_randn(), vec_range(), vec_reverse(), vec_ser(), vec_sqr(), vec_sub(), vec_tanh(), vec_to_bvec(), vec_to_cvec(), vec_to_ivec(), vec_to_mat(), vec_to_spvec(), vecivec_inner_product(), vlc_hu_tucker(), and vlc_nodes_entropy().

idx_t vec_length_max ( vec  v  ) 

Return the maximum length of the vector (number of allocated elements)

Definition at line 237 of file vec.c.

References Vec_length_max.

Referenced by main().

void vec_log ( vec  v  ) 

logarithm of a vector component per component

Definition at line 1723 of file vec.c.

References Vec_length.

void vec_log10 ( vec  v  ) 

logarithm of a vector component per component

Definition at line 1732 of file vec.c.

References Vec_length.

double vec_max ( vec  v  ) 

Maxinum of a vector

Definition at line 2101 of file vec.c.

References Vec_length.

Referenced by main().

idx_t vec_max_index ( vec  v  ) 

Position where the vector maximum occurs

Definition at line 2127 of file vec.c.

References NULL_INDEX, and vec_length().

Referenced by vlc_energy_order().

double vec_mean ( vec  v  ) 

mean of the input vector

Definition at line 2531 of file vec.c.

References Vec_length, and vec_sum().

Referenced by main(), remmean(), and vec_cov().

double vec_mean_robust ( vec  v  ) 

mean of the input vector

Definition at line 2537 of file vec.c.

References Vec_length, and vec_sum_robust().

Referenced by vec_variance_robust().

double vec_median ( vec  v  ) 

median value of the input vector

Definition at line 2567 of file vec.c.

References it_warning(), vec_clone(), vec_delete(), vec_length(), and vec_sort().

double vec_min ( vec  v  ) 

Mininum of a vector

Definition at line 2089 of file vec.c.

References Vec_length.

Referenced by fpICA(), and main().

idx_t vec_min_index ( vec  v  ) 

Position where the vector minimum occurs

Definition at line 2113 of file vec.c.

References NULL_INDEX, and vec_length().

void vec_mul ( vec  v1,
vec  v2 
)

Component per component multiplication

The result is stored in the vector which is the first parameter

Definition at line 1394 of file vec.c.

References vec_length().

Referenced by fpICA(), vec_cov(), and vec_new_mul().

void vec_mul_by ( vec  v,
double  a 
)

multiply the components per a specified value

Definition at line 1223 of file vec.c.

References vec_length().

Referenced by fpICA(), mat_gs(), and mat_row_mul_by().

void vec_neg ( vec  v  ) 

Negate the vector

Definition at line 1656 of file vec.c.

References vec_length().

vec vec_new_1N ( idx_t  n  ) 

The sequence 1, 2.. N

Definition at line 4007 of file vec.c.

References vec_new().

Referenced by main(), and vlc_hu_tucker().

vec vec_new_abs ( vec  v  ) 

New vector generated with the absolute values of the input vector

Definition at line 1770 of file vec.c.

References vec_abs(), vec_length(), and vec_new().

vec vec_new_add ( vec  v1,
vec  v2 
)

addition stored in a new vector

Definition at line 1515 of file vec.c.

References vec_add(), and vec_clone().

vec vec_new_alloc ( idx_t  length,
idx_t  length_max 
)

Vector allocation with explicit allocation of the maximum number of elements

Definition at line 100 of file vec.c.

References Vec_new_alloc.

Referenced by fvec_new_string(), parser_get_vec(), parser_get_vec_verbose(), vec_k_max_between(), vec_k_min_between(), vec_new_intersection(), vec_new_string(), and vec_new_union().

vec vec_new_apply_function ( vec  v,
it_function_t  function,
it_args_t  args 
)

Apply a function to all vector elements

Definition at line 2700 of file vec.c.

References vec_length(), and vec_new().

vec vec_new_arithm ( double  start,
double  incr,
idx_t  N 
)

New arithmetic sequence

Definition at line 4098 of file vec.c.

References vec_new().

Referenced by lloyd_max(), and main().

vec vec_new_concat ( vec  v1,
vec  v2 
)

Concatenate two vectors

Definition at line 3181 of file vec.c.

References vec_length(), and vec_new().

vec vec_new_div ( vec  v1,
vec  v2 
)

Component per component division

Definition at line 1539 of file vec.c.

References vec_clone(), and vec_div().

vec vec_new_geom ( double  start,
double  r,
idx_t  N 
)

Same but a geometric sequence of geometric factor r

Definition at line 4148 of file vec.c.

References it_assert, and vec_new().

Referenced by main().

vec vec_new_intersection ( vec  v1,
vec  v2 
)

Intersection of two sets represented by the two input vectors

Definition at line 3397 of file vec.c.

References vec_delete(), vec_length(), vec_new_alloc(), vec_new_unique(), and vec_push.

vec vec_new_mul ( vec  v1,
vec  v2 
)

Component per component multiplication

Definition at line 1531 of file vec.c.

References vec_clone(), and vec_mul().

vec vec_new_normalize ( vec  v,
double  nr 
)

Return a normalized version of the input vector

Definition at line 1843 of file vec.c.

References vec_length(), vec_new(), vec_new_set(), and vec_sum().

vec vec_new_ones ( idx_t  N  ) 

New vectors of ones

Definition at line 3765 of file vec.c.

References vec_new_set().

Referenced by fpICA(), and main().

vec vec_new_pow ( vec  v,
double  a 
)

new vector: exponential values of the input vector

Definition at line 1830 of file vec.c.

References Vec_length, vec_length(), and vec_new().

Referenced by fpICA().

vec vec_new_rand ( idx_t  N  ) 

Generate a random vector, uniformally drawn in [0,1[

Definition at line 4263 of file vec.c.

References vec_new(), and vec_rand().

vec vec_new_randn ( idx_t  N  ) 

Generate a random vector with normal law

Definition at line 4271 of file vec.c.

References vec_new(), and vec_randn().

vec vec_new_range ( idx_t  n  ) 

New vector 0, 1, ... N-1

Definition at line 4052 of file vec.c.

References vec_new().

vec vec_new_reverse ( vec  v  ) 

Reverse the vector

Definition at line 2805 of file vec.c.

References vec_length(), and vec_new().

vec vec_new_set ( double  val,
idx_t  N 
)

Constant vector

Definition at line 3976 of file vec.c.

References vec_new(), and vec_set().

Referenced by fpICA(), it_instanciate(), vec_cov(), vec_new_normalize(), vec_new_ones(), and vec_new_zeros().

vec vec_new_sub ( vec  v1,
vec  v2 
)

Substraction

Definition at line 1523 of file vec.c.

References vec_clone(), and vec_sub().

vec vec_new_union ( vec  v1,
vec  v2 
)

Union of two sets represented by the two input vectors

Definition at line 3311 of file vec.c.

References vec_delete(), vec_length(), vec_new_alloc(), vec_new_unique(), and vec_push.

vec vec_new_unique ( vec  v  ) 

Vector created from the input vector by taking one occurences of each possible value of the input vector

Definition at line 3247 of file vec.c.

References vec_clone(), vec_delete(), vec_length(), vec_new(), vec_push, and vec_sort().

Referenced by vec_new_intersection(), and vec_new_union().

vec vec_new_void (  ) 

Create a vector of length 0

Definition at line 3952 of file vec.c.

References vec_new().

Referenced by vec_k_max_between(), and vec_k_min_between().

double vec_norm ( vec  v,
double  nr 
)

Norm of the input vector

Definition at line 2661 of file vec.c.

References vec_length().

Referenced by fpICA(), main(), and mat_gs().

void vec_normalize ( vec  v,
double  nr 
)

Normalize the vector for a specified norm, so that $sum(||v||_nr)=1$

Definition at line 1807 of file vec.c.

References vec_length(), and vec_sum().

Referenced by bcjr(), bcjr_side(), markov_marg_pdf(), mat_rows_normalize(), and source_pdf_GG().

void vec_ones ( vec   ) 

Set all the vector elements to 1

Definition at line 3741 of file vec.c.

References vec_set().

Referenced by fpICA().

vec vec_pop ( vec  v  ) 

Retrieve the last element at the end of the vector (this removes it)

Definition at line 972 of file vec.c.

References Vec_pop.

Referenced by main().

void vec_pow ( vec  v,
double  a 
)

set each component c to c^a

Definition at line 1798 of file vec.c.

References Vec_length.

void vec_rand ( vec  v  ) 

Draw the component of a vector to uniformally random variable in [0,1[

Definition at line 4246 of file vec.c.

References it_rand(), and vec_length().

Referenced by vec_new_rand().

void vec_randn ( vec  v  ) 

Generate a random vector, uniformally drawn in [0,1[

Definition at line 4254 of file vec.c.

References it_randn(), and vec_length().

Referenced by fpICA(), and vec_new_randn().

void vec_range ( vec   ) 

Set the vector elements to 0,1, ... n-1

Definition at line 3789 of file vec.c.

References vec_length().

ivec vec_replace ( vec  v,
double  a,
double  b 
)

Replace a given value by another for all vector components

Definition at line 3060 of file vec.c.

References ivec_new(), vec_count(), and Vec_length.

void vec_reverse ( vec  v  ) 

Reverse the vector

Definition at line 2741 of file vec.c.

References vec_length().

Referenced by PCAmat().

vec vec_set ( vec  v,
double  val 
)

Set all the elements of the vector to a given value

Definition at line 345 of file vec.c.

References Vec_set.

Referenced by bcjr_side(), fpICA(), logviterbi(), main(), vec_new_set(), vec_ones(), viterbi(), viterbi_side(), and vlc_hu_tucker().

vec vec_set_between ( vec  v,
idx_t  i1,
idx_t  i2,
double  val 
)

Set the elements of a subvector to a given value val

Definition at line 373 of file vec.c.

References Vec_set_between.

void vec_set_subvector ( vec  v,
vec  s,
idx_t  idx 
)

Modify a given element subset of a vector to another vector

Definition at line 401 of file vec.c.

References VEC_END_PARAM, and Vec_set_subvector.

Referenced by it_wavelet_merge().

void vec_sort ( vec  v  ) 

Sort the vector by increasing values

Definition at line 3595 of file vec.c.

References double_leq(), and Vec_sort().

Referenced by main(), PCAmat(), scalar_quantizer_set_codebook(), vec_median(), and vec_new_unique().

void Vec_sort ( Vec  v,
int(*)(const void *, const void *)  elem_leq 
)

Sort the vector by increasing values

Definition at line 3537 of file vec.c.

References Vec_element_size, and Vec_length.

Referenced by bvec_sort(), ivec_sort(), and vec_sort().

ivec vec_sort_index ( vec  v  ) 

Return a vector of index corresponding to increasing values of the input vector

Definition at line 3601 of file vec.c.

References double_leq_index(), and Vec_sort_index().

Referenced by main(), and vlc_quasi_lexicographic().

ivec Vec_sort_index ( Vec  v,
int(*)(const void *, const void *)  elem_leq_idx 
)

Return a vector of index corresponding to increasing values of the input vector

Definition at line 3543 of file vec.c.

References idx, Vec_element_size, Vec_length, Vec_length_max, and Vec_new.

Referenced by bvec_sort_index(), ivec_sort_index(), and vec_sort_index().

void vec_sqr ( vec  v  ) 

square the vector component per component

Definition at line 1696 of file vec.c.

References vec_length().

void vec_sqrt ( vec  v  ) 

root square of a vector component per component

Definition at line 1714 of file vec.c.

References Vec_length.

Referenced by mat_pow_one_by_two().

void vec_sub ( vec  v1,
vec  v2 
)

Substraction

Definition at line 1383 of file vec.c.

References vec_length().

Referenced by fpICA(), vec_cov(), and vec_new_sub().

double vec_sum ( vec  v  ) 

vector sum

Definition at line 1928 of file vec.c.

References Vec_length.

Referenced by fpICA(), is_valid_pdf(), main(), mat_row_sum(), PCAmat(), vec_cov(), vec_mean(), vec_new_normalize(), and vec_normalize().

double vec_sum_between ( vec  v,
idx_t  i1,
idx_t  i2 
)

sum of a subset of the vector specified by an index interval

Definition at line 2048 of file vec.c.

References VEC_END_PARAM.

double vec_sum_robust ( vec  v  ) 

vector sum

Definition at line 1939 of file vec.c.

References Vec_length.

Referenced by vec_mean_robust().

double vec_sum_sqr ( vec  v  ) 

The sum of the square components of a vector, i.e. the vector energy

Definition at line 2037 of file vec.c.

References Vec_length.

Referenced by fpICA(), and main().

bvec vec_to_bvec ( vec  v  ) 

Vector type conversion

Definition at line 856 of file vec.c.

References bvec_new(), and vec_length().

cvec vec_to_cvec ( vec  v  ) 

Vector type conversion

Definition at line 868 of file vec.c.

References cimag, creal, cvec_new(), and vec_length().

Referenced by it_dft_real(), and main().

ivec vec_to_ivec ( vec  v  ) 

Vector type conversion

Definition at line 843 of file vec.c.

References ivec_new(), and vec_length().

void vec_to_spvec ( vec  v,
ivec svi_out,
vec sv_out 
)

convert a vector into a sparse vector

Definition at line 4325 of file vec.c.

References ivec_new(), vec_length(), and vec_new().

double vec_variance ( vec  v  ) 

Unbiaised variance of the vector (obtained by dividing by N-1)

Definition at line 2590 of file vec.c.

References Vec_length.

Referenced by main(), and test_quantizer().

double vec_variance_robust ( vec  v  ) 

Unbiaised variance of the vector (obtained by dividing by N-1)

Definition at line 2607 of file vec.c.

References Vec_length, and vec_mean_robust().

void vec_void ( vec   ) 

Reduce a vector to length 0

Definition at line 3671 of file vec.c.

References Vec_void.

void vec_zeros ( vec   ) 

Set all the elements of a vector to 0

Definition at line 3696 of file vec.c.

References Vec_set.

Referenced by fpICA(), mat_gs(), and mat_tridiag().

double vecivec_inner_product ( vec  v1,
ivec  v2 
)

Inner product of two vectors

Definition at line 1628 of file vec.c.

References ivec_length(), and vec_length().


Variable Documentation

bvec const bvec_null

Definition at line 66 of file vec.c.

cvec const cvec_null

Definition at line 67 of file vec.c.

ivec const ivec_null

Definition at line 65 of file vec.c.

Referenced by imat_distance_mse().

vec const vec_null

void vector of length 0, i.e. with no element

Warning:
this is a constant vector which is in essence used for comparison. It has to be differentiate from an unallocated vector or from the NULL vector.

Definition at line 64 of file vec.c.

Referenced by _lpoly_ediv(), markov_marg_pdf(), and mat_distance_mse().


Hosted by
Copyright (C) 2005-2006 Hervé Jégou
Vivien Chappelier
Francois Cayre
libit logo courtesy of Jonathan Delhumeau