RealDot.jl

Compute `real(dot(x, y))` efficiently.
Author JuliaMath
Popularity
4 Stars
Updated Last
5 Months Ago
Started In
October 2021

RealDot

Build Status Coverage Coverage Code Style: Blue

This package only contains and exports a single function realdot(x, y). It computes real(LinearAlgebra.dot(x, y)) while avoiding computing the imaginary part of LinearAlgebra.dot(x, y) if possible.

The real dot product is useful when one treats complex numbers as embedded in a real vector space. For example, take two complex arrays x and y. Their real dot product is real(dot(x, y)) == dot(real(x), real(y)) + dot(imag(x), imag(y)). This is the same result one would get by reinterpreting the arrays as real arrays:

xreal = reinterpret(real(eltype(x)), x)
yreal = reinterpret(real(eltype(y)), y)
real(dot(x, y)) == dot(xreal, yreal)

In particular, this function can be useful if you define pullbacks for non-holomorphic functions (see e.g. this discussion in the ChainRulesCore.jl repo). It was implemented initially in ChainRules.jl in this PR as _realconjtimes.

Required Packages

No packages found.