tesseract++ 0.0.1
N-dimensional tensor library for embedded systems
Loading...
Searching...
No Matches
Namespaces | Functions
trace.h File Reference

Trace of a square matrix — sum of diagonal elements. More...

#include "config.h"
#include "fused/fused_matrix.h"
Include dependency graph for trace.h:

Go to the source code of this file.

Namespaces

namespace  matrix_algorithms
 

Functions

template<typename T , my_size_t N>
matrix_algorithms::trace (const FusedMatrix< T, N, N > &A)
 Compute the trace of a square matrix.
 

Detailed Description

Trace of a square matrix — sum of diagonal elements.

Infallible, O(N). Works for any scalar type (not restricted to floating point).

Note
Future optimization: if a diagonal view is supported (strided view with stride = N+1 into the flat storage), trace becomes a single reduce_sum call on that view, gaining SIMD acceleration for free via the existing reduction kernel.