File: mymath.h

package info (click to toggle)
python-cmake-build-extension 0.6.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 484 kB
  • sloc: python: 504; cpp: 70; sh: 13; makefile: 5
file content (32 lines) | stat: -rw-r--r-- 907 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef MYMATH_H
#define MYMATH_H

#include <vector>

namespace mymath {

    /**
     * Perform the inner product between two 1D vectors.
     *
     * @param vector1 The first vector.
     * @param vector2 The second vector.
     * @throws If the vectors sizes do not match.
     * @return The double product of the input vectors.
     */
    double dot(const std::vector<double>& vector1,
               const std::vector<double>& vector2);

    /**
     * Normalize a 1D vector.
     *
     * The normalization operation takes the input vector and divides
     * all its element by its norm. The resulting vector is a unit vector,
     * i.e. a vector with length 1.
     *
     * @param input The vector to normalize.
     * @return The unit vector computed by normalizing the input.
     */
    std::vector<double> normalize(const std::vector<double>& data);
} // namespace mymath

#endif // MYMATH_H