NumCpp
2.1.0
A C++ implementation of the Python Numpy library
identity.hpp
Go to the documentation of this file.
1
#pragma once
30
31
#include "
NumCpp/NdArray.hpp
"
32
33
namespace
nc
34
{
35
//============================================================================
36
// Method Description:
49
template
<
typename
dtype>
50
NdArray<dtype>
identity
(
uint32
inSquareSize)
51
{
52
NdArray<dtype>
returnArray(inSquareSize);
53
returnArray.
zeros
();
54
for
(
uint32
i = 0; i < inSquareSize; ++i)
55
{
56
returnArray(i, i) = dtype{ 1 };
57
}
58
59
return
returnArray;
60
}
61
}
// namespace nc
nc::identity
NdArray< dtype > identity(uint32 inSquareSize)
Definition:
identity.hpp:50
nc::NdArray< dtype >
nc::uint32
std::uint32_t uint32
Definition:
Types.hpp:41
NdArray.hpp
nc::NdArray::zeros
NdArray< dtype > & zeros() noexcept
Definition:
NdArrayCore.hpp:4626
nc
Definition:
Coordinate.hpp:45
include
NumCpp
Functions
identity.hpp
Generated by
1.8.17