S2kit  1.1
Toolkit for working with functions defined on the sphere
vector_funcs.c
Go to the documentation of this file.
1 
6 #include "vector_funcs.h"
7 
18 void vec_add(double* v1, double* v2, double* result, const int len) {
19  for (int i = 0; i < len; ++i)
20  result[i] = v1[i] + v2[i];
21 }
22 
33 void vec_mul(const double scalar, double* v, double* result, const int len) {
34  for (int i = 0; i < len; ++i)
35  result[i] = scalar * v[i];
36 }
37 
38 /*
39  Returns dot product of `v1` and `v2` in `result`
40 
41  Note: `result` and `v{1,2}` must be vectors of length `len`
42 */
53 void vec_dot(double* v1, double* v2, double* result, const int len) {
54  for (int i = 0; i < len; ++i)
55  result[i] = v1[i] * v2[i];
56 }
vector_funcs.h
vec_dot
void vec_dot(double *v1, double *v2, double *result, const int len)
Performs dot product of v1 and v2.
Definition: vector_funcs.c:53
vec_mul
void vec_mul(const double scalar, double *v, double *result, const int len)
Multiplies the vector v by scalar.
Definition: vector_funcs.c:33
vec_add
void vec_add(double *v1, double *v2, double *result, const int len)
Adds two vectors into a third one.
Definition: vector_funcs.c:18