Skip to content

Compute `real(dot(x, y))` efficiently.

License

Notifications You must be signed in to change notification settings

JuliaMath/RealDot.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Compute `real(dot(x, y))` efficiently.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

 
 
 

Contributors

Languages