#include <stdlib.h>
#include <stdio.h>
Include dependency graph for vect.h:
Go to the source code of this file.
Compounds | |
struct | Vect_ |
Stores the vector elements in an array and the logical and physical lengths. More... | |
Functions | |
void | init_vect (Vect_ *V, unsigned int L) |
init_vect(V, L): inits *V to contain L items. More... | |
void | resize_vect (Vect_ *V, unsigned int Newsize) |
resize_vect(V, Newsize): changes *V so that its logical length is now Newsize. More... | |
void | copy_vect (const Vect_ *From, Vect_ *To) |
copy_vect(From, To): copies the contents of *From to *To. More... | |
void | free_vect (Vect_ *V) |
free_vect(V): frees up all storage associated with *V. More... | |
int | vect_scalar (Vect_ *V, char Opcode, double Scalar) |
vect_scalar(V, Opcode, Scalar): Performs a simple arithmetic operation in place between the elements of *V and Scalar, depending on Opcode. More... | |
int | vect_inplace (const Vect_ *V, char Opcode, Vect_ *R) |
vect_inplace(V, Opcode, R): Performs binary in-place operations on R and V and puts the result in R. More... | |
int | vect_vect (const Vect_ *V1, char Opcode, const Vect_ *V2, Vect_ *R) |
vect_vect(V1, Opcode, V2, R): Performs binary operations on V1 and V2 and puts the result in R. More... | |
double | scalar_product (const Vect_ *V1, const Vect_ *V2) |
scalar_product(V1, V2): returns the scalar product of V1 and V2. More... | |
int | vect_product (const Vect_ *V1, const Vect_ *V2, Vect_ *P) |
vect_product(V1, V2, P): Calculates the vectorial (cross) product of V1 and V2 and puts the result in P. More... | |
double | vect_len2 (const Vect_ *V) |
vect_len2(V): Returns the squared length of V or 0.0 if it was empty. | |
double | vect_len (const Vect_ *V) |
vect_len(V): returns the length of the vector V, or 0.0 if empty. | |
double | vect_norm (Vect_ *V) |
vect_norm(V): Normalises V to unit length. More... | |
double | vect_norm_eps (Vect_ *V, double Eps) |
vect_norm_eps(V, Eps): Calculates the length of V. More... | |
int | read_vect (FILE *In, Vect_ *V) |
read_vect(In, V): reads a vector from the file In into V. More... | |
void | write_vect (FILE *Out, const Vect_ *V, unsigned int Prec) |
write_vect(Out, V, Prec): writes the vector V to the file Out using scientific notation, with Prec figures after the decimal point. |
Supports safe creation, copy, resize, and some algebraic operations.
Definition in file vect.h.
|
init_vect(V, L): inits *V to contain L items. If L==0, then L=3 is used. This must be the first call on *V before any other operation is done. Referenced by Vect_::Physlen(). |
|
resize_vect(V, Newsize): changes *V so that its logical length is now Newsize. If Newsize==0, then Newsize=3 will be used. If *V was empty, then it will be re-initialised. Does nothing if Newsize==V->Len. Referenced by Vect_::Physlen(). |
|
copy_vect(From, To): copies the contents of *From to *To. *To is resized if necessary. Referenced by Vect_::Physlen(). |
|
free_vect(V): frees up all storage associated with *V. Does not deallocate V itself. Referenced by Vect_::Physlen(). |
|
vect_scalar(V, Opcode, Scalar): Performs a simple arithmetic operation in place between the elements of *V and Scalar, depending on Opcode. Supported operations:- '=': set all elements of *V to Scalar. '+': adds Scalar to all elements of *V. '-': subtracts Scalar from all elements of *V. '*': multiplies all elements of *V by Scalar. '/': divides all elements of *V by Scalar. Warns if Scalar == 0. Prints a warning if the Opcode is different from these listed above. Returns an error code: 0 if div by zero or op not supported, the length otherwise. Referenced by Vect_::Physlen(). |
|
vect_inplace(V, Opcode, R): Performs binary in-place operations on R and V and puts the result in R. Supported operations:- '+': performs R[i]+=V[i], for all i '-': performs R[i]-=V[i], for all i '*': performs R[i]*=V[i], for all i V and R must have the same logical length. If not, a warning is printed and 0 is returned. Return value: the common length on success. Referenced by Vect_::Physlen(). |
|
vect_vect(V1, Opcode, V2, R): Performs binary operations on V1 and V2 and puts the result in R. Supported operations:- '+': performs R[i]=V1[i]+V2[i], for all i '-': performs R[i]=V1[i]-V2[i], for all i '*': performs R[i]=V1[i]*V2[i], for all i V1, V2 and R must have the same logical length. If not, a warning is printed and 0 is returned. Return value: the common length on success. Referenced by Vect_::Physlen(). |
|
scalar_product(V1, V2): returns the scalar product of V1 and V2. Returns 0.0 if either of the vectors is empty or the dimensions don't match. Referenced by Vect_::Physlen(). |
|
vect_product(V1, V2, P): Calculates the vectorial (cross) product of V1 and V2 and puts the result in P. V1 and V2 must be 3-dimensional, if not, then P will be unchanged and 0 is returned. The dimension of P will be set to 3. Returns 1 on success. Referenced by Vect_::Physlen(). |
|
vect_len2(V): Returns the squared length of V or 0.0 if it was empty.
Referenced by Vect_::Physlen(). |
|
vect_len(V): returns the length of the vector V, or 0.0 if empty.
Referenced by Vect_::Physlen(). |
|
vect_norm(V): Normalises V to unit length. Does nothing to null-vectors. Returns the original length. Referenced by Vect_::Physlen(). |
|
vect_norm_eps(V, Eps): Calculates the length of V. If that is smaller than |Eps|, then V is assumed to be a null-vector, its coordinates will be set to 0.0 and 0.0 is returned as its previous length. Otherwise, V is normalised just like in vect_norm(V). Referenced by Vect_::Physlen(). |
|
read_vect(In, V): reads a vector from the file In into V. Returns the number of errors encountered during parsing (0 if OK). If there were errors, V remains unchanged. Referenced by Vect_::Physlen(). |
|
write_vect(Out, V, Prec): writes the vector V to the file Out using scientific notation, with Prec figures after the decimal point.
Referenced by Vect_::Physlen(). |