kornia/kornia-rs

[Feature]: Add f64 support to SVD3 in kornia-algebra

Open

#808 opened on Mar 13, 2026

View on GitHub
 (3 comments) (0 reactions) (0 assignees)Rust (188 forks)auto 404
enhancementhelp wantedtriage

Repository metrics

Stars
 (675 stars)
PR merge metrics
 (PR metrics pending)

Description

🚀 Feature Description

Currently, the svd3 implementation in kornia-algebra operates only on f32 tensors. Many computer vision and numerical workflows benefit from higher precision, especially in geometric estimation, optimization routines, and 3D transformations.

Adding f64 support would enable users who require higher numerical precision to use the same SVD functionality without converting data or implementing their own double-precision version.

This feature would extend the current functionality while remaining fully backward compatible.

📂 Feature Category

Rust Core Library

💡 Motivation

In computer vision pipelines, f64 precision is often required for:

  • geometric estimation (pose estimation, bundle adjustment)
  • optimization routines
  • 3D reconstruction
  • numerical stability in iterative algorithms

Currently, users must either:

  • downcast their data to f32, or
  • implement their own SVD for f64.

Providing a native f64 implementation would make kornia-algebra more flexible for scientific and high-precision workflows.

💭 Proposed Solution

Extend the current SVD3 implementation to support f64.

This can be done by:

  1. Replicating the existing f32 implementation.
  2. Replacing the scalar type with f64.
  3. Ensuring the same API structure is preserved.

Example conceptual API:

svd3_f32(...)
svd3_f64(...)

or if generics are preferred:

svd3<T: Float>(...)

The initial implementation could simply mirror the f32 version to keep the change minimal and safe.

📚 Library Reference

Similar functionality exists in:

  • nalgebra – supports both f32 and f64 linear algebra operations
  • OpenCV – SVD routines support double precision
  • Standard numerical linear algebra implementations typically support both float precisions

These libraries demonstrate that supporting both scalar types is standard practice in numerical APIs.

🔄 Alternatives Considered

  • Converting f64 tensors to f32 before calling SVD → loses precision

  • Using external linear algebra libraries → adds unnecessary dependency overhead

Providing native support inside kornia-algebra keeps the ecosystem self-contained.

🎯 Use Cases

Examples where f64 SVD3 would be beneficial:

  • 3D pose estimation
  • homography estimation
  • bundle adjustment pipelines
  • structure-from-motion
  • numerical experimentation and research

📝 Additional Context

The change would be purely additive and should not introduce breaking changes.

The existing f32 implementation can remain unchanged while the f64 variant is added alongside it.

🤝 Contribution Intent

  • I plan to submit a PR to implement this feature
  • I'm requesting this feature but not planning to implement it

Contributor guide