NumCpp  2.14.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
corrcoef.hpp
Go to the documentation of this file.
1
28#pragma once
29
34#include "NumCpp/NdArray.hpp"
35
36namespace nc
37{
38 //============================================================================
39 // Method Description:
49 template<typename dtype>
51 {
53
54 const auto covariance = cov(x);
56 for (decltype(covariance.numRows()) i = 0; i < covariance.numRows(); ++i)
57 {
58 for (decltype(covariance.numCols()) j = 0; j < covariance.numCols(); ++j)
59 {
60 normalizedCovariance(i, j) = covariance(i, j) / sqrt(covariance(i, i) * covariance(j, j));
61 }
62 }
63
65 }
66} // namespace nc
#define STATIC_ASSERT_ARITHMETIC_OR_COMPLEX(dtype)
Definition StaticAsserts.hpp:56
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:139
Definition Cartesian.hpp:40
NdArray< double > cov(const NdArray< dtype > &x, Bias bias=Bias::NO)
Definition cov.hpp:53
NdArray< dtype > empty_like(const NdArray< dtype > &inArray)
Definition empty_like.hpp:44
NdArray< dtype > arange(dtype inStart, dtype inStop, dtype inStep=1)
Definition arange.hpp:59
auto sqrt(dtype inValue) noexcept
Definition sqrt.hpp:48
NdArray< double > corrcoef(const NdArray< dtype > &x)
Definition corrcoef.hpp:50