Next: Matrix operations Up: Vector operations Previous: Vector operations   Contents

## Main functions in vector.c

int First_Non_Zero
:(Value *p, unsigned length) return the smallest component index in 'p' whose value is non-zero.

Vector * Vector_Alloc
(unsigned length): allocate memory space for a vector.

void Vector_Free
(Vector *vector): free the memory space occupied by Vector.

void Vector_Print
(FILE *Dst, char *Format, Vector *vector): print the contents of a Vector.

Vector * Vector_Read
(): read the contents of a Vector.

void Vector_Set
(Value *p, int n ,unsigned length): assign 'n' to each component of Vector 'p'.

void Vector_Exchange
: exchange the components of the vectors 'p1' and 'p2'.

void Vector_Copy
(Value *p1, Value *p2, unsigned length): copy vector 'p1' to vector 'p2'.

Vector_Add
(Value *p1, Value *p2, unsigned length): add two vectors 'p1' and 'p2' and store the result in 'p3'.

void Vector_Sub
(Value *p1, Value *p2, Value *p3, unsigned length): subtract two vectors 'p1' and 'p2' and store the result in 'p3'.

void Vector_Or
(Value *p1, Value *p2, Value *p3, unsigned length): compute bit-wise OR of vectors 'p1' and 'p2' and store it in 'p3'.

void Vector_Scale
(Value *p1, Value *p2, Value lambda, unsigned length): scale vector 'p1' by factor 'lambda' and store it in 'p2'.

void Vector_AntiScale
(Value *p1, Value *p2, Value lambda, unsigned length): antiscale vector 'p1' by 'lambda' and store it in 'p2'.

Value * Inner_Product
(Value *p1, Value *p2, unsigned length): return the inner product of two vectors 'p1' and 'p2'.

Value * Vector_Max
(Value *p, unsigned length): return the maximum of the components of 'p'.

Value * Vector_Min
(Value *p, unsigned length): return the minimum of the components of Vector 'p'.

void Vector_Combine
(Value *p1, Value *p2, Value *p3, Value lambda, Value mu, unsigned length): return the linear combination of two vectors.

int Vector_Equal
(Value *Vec1, Value *Vec2, unsigned n): return 1 if 'Vec1' equals 'Vec2', otherwise return 0.

Value * Vector_Min_Not_Zero
(Value *p, unsigned length, int *index): return the component of 'p' with minimum non-zero absolute value.

Value * Vector_Gcd
(Value *p, unsigned length): return the GCD of components of Vector 'p'.

void Vector_Map
(Value *p1, Value *p2, Value *p3, unsigned length, Value *(*f)()): given vectors 'p1' and 'p2', and a pointer to a function returning 'Value' type, compute p3[i] = f(p1[i],p2[i]).

void Vector_Normalize
(Value *p, unsigned length): reduce a vector by dividing it by its GCD.

void Vector_Normalize_Positive
(Value *p, int length,int pos): reduce a vector to a positive vector by dividing it by its GCD.

Value * Vector_Reduce
(Value *p,unsigned length,Value *(*f)()) : reduce 'p' by operating binary function on its components successively.

void Vector_Sort
(Value *vector, unsigned n): sort the components of a vector 'vector' using heap sort.

Next: Matrix operations Up: Vector operations Previous: Vector operations   Contents
Sorin Olaru 2002-04-24