Loading...
Searching...
No Matches
Metrics.hpp
Go to the documentation of this file.
1/*
2 * STRUMPACK -- STRUctured Matrices PACKage, Copyright (c) 2014, The
3 * Regents of the University of California, through Lawrence Berkeley
4 * National Laboratory (subject to receipt of any required approvals
5 * from the U.S. Dept. of Energy). All rights reserved.
6 *
7 * If you have questions about your rights to use or distribute this
8 * software, please contact Berkeley Lab's Technology Transfer
9 * Department at TTD@lbl.gov.
10 *
11 * NOTICE. This software is owned by the U.S. Department of Energy. As
12 * such, the U.S. Government has been granted for itself and others
13 * acting on its behalf a paid-up, nonexclusive, irrevocable,
14 * worldwide license in the Software to reproduce, prepare derivative
15 * works, and perform publicly and display publicly. Beginning five
16 * (5) years after the date permission to assert copyright is obtained
17 * from the U.S. Department of Energy, and subject to any subsequent
18 * five (5) year renewals, the U.S. Government is granted for itself
19 * and others acting on its behalf a paid-up, nonexclusive,
20 * irrevocable, worldwide license in the Software to reproduce,
21 * prepare derivative works, distribute copies to the public, perform
22 * publicly and display publicly, and to permit others to do so.
23 *
24 * Developers: Pieter Ghysels, Francois-Henry Rouet, Xiaoye S. Li.
25 * (Lawrence Berkeley National Lab, Computational Research
26 * Division).
27 *
28 */
32#ifndef STRUMPACK_METRICS_HPP
33#define STRUMPACK_METRICS_HPP
34
35#include <cmath>
36#include "dense/BLASLAPACKWrapper.hpp"
37
38namespace strumpack {
39
50 template<typename scalar_t,
51 typename real_t=typename RealType<scalar_t>::value_type>
53 (std::size_t d, const scalar_t* x, const scalar_t* y) {
54 real_t k(0.);
55 for (std::size_t i=0; i<d; i++) {
56 auto xy = x[i]-y[i];
57 k += xy * xy;
58 }
59 return k;
60 }
61
71 template<typename scalar_t,
72 typename real_t=typename RealType<scalar_t>::value_type>
74 (std::size_t d, const scalar_t* x, const scalar_t* y) {
75 return std::sqrt(Euclidean_distance_squared(d, x, y));
76 }
77
78
88 template<typename scalar_t,
89 typename real_t=typename RealType<scalar_t>::value_type>
91 (std::size_t d, const scalar_t* x, const scalar_t* y) {
92 real_t k(0.);
93 for (std::size_t i=0; i<d; i++)
94 k += std::abs(x[i]-y[i]);
95 return k;
96 }
97
98} // end namespace strumpack
99
100#endif // STRUMPACK_METRICS_HPP
101
Definition StrumpackOptions.hpp:44
real_t Euclidean_distance(std::size_t d, const scalar_t *x, const scalar_t *y)
Definition Metrics.hpp:74
real_t norm1_distance(std::size_t d, const scalar_t *x, const scalar_t *y)
Definition Metrics.hpp:91
real_t Euclidean_distance_squared(std::size_t d, const scalar_t *x, const scalar_t *y)
Definition Metrics.hpp:53