Next: , Previous: Exchanging elements, Up: Vectors


8.3.8 Vector operations

— Function: int gsl_vector_add (gsl_vector * a, const gsl_vector * b)

This function adds the elements of vector b to the elements of vector a. The result a_i \leftarrow a_i + b_i is stored in a and b remains unchanged. The two vectors must have the same length.

— Function: int gsl_vector_sub (gsl_vector * a, const gsl_vector * b)

This function subtracts the elements of vector b from the elements of vector a. The result a_i \leftarrow a_i - b_i is stored in a and b remains unchanged. The two vectors must have the same length.

— Function: int gsl_vector_mul (gsl_vector * a, const gsl_vector * b)

This function multiplies the elements of vector a by the elements of vector b. The result a_i \leftarrow a_i * b_i is stored in a and b remains unchanged. The two vectors must have the same length.

— Function: int gsl_vector_div (gsl_vector * a, const gsl_vector * b)

This function divides the elements of vector a by the elements of vector b. The result a_i \leftarrow a_i / b_i is stored in a and b remains unchanged. The two vectors must have the same length.

— Function: int gsl_vector_scale (gsl_vector * a, const double x)

This function multiplies the elements of vector a by the constant factor x. The result a_i \leftarrow x a_i is stored in a.

— Function: int gsl_vector_add_constant (gsl_vector * a, const double x)

This function adds the constant value x to the elements of the vector a. The result a_i \leftarrow a_i + x is stored in a.