math

package
v0.0.0-...-af67c94 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2021 License: MIT Imports: 1 Imported by: 0

README

Native vector/matrix/tensor implementation

Calculations are performed inplace as much as possible to reduce allocations and copying.

Most places assume that vector/matrix sizes are correct. Other places panic on wrong sizes. This is intentional since the code is intended for embedded systems like microcontrollers. Therefore always test your code.

Some operations require a destination vector/matrix. The design decision was made to have Vector and Matrix serve as the mutable arguments instead of a pointer to a concrete type, e.g. Matrix3x3.

Most of the code uses math32 package directly, however, in the future this package should be float32 implementation of basic math operations or a proxy to some other embedded math library.

Auto - Generated

The main code is in gen/*.tpl and is autogenerated using parameters from gen/*.json. Generation instruction is in math.go.

Tests were generated once and mostly generic implementagion is tested, however, where more optimized implementation is available, then there will be tests for each such concrete implementation.

Development cycle

Usually the fixes/development/experimentation is done on the generic implementation and/or concrete in some cases, and then the code is moved to the template, generated back and tested.

NOTE: No manually edited code in the generated files should be commited.

Features

  • Vectors
    • Generic vector
    • 2D, 3D, 4D
  • Matrices
    • Generic
      • Inverse
      • SVD
      • Pseudo Inverse (for KI)
    • 2x2, 3x3, 4x4, 3x4, 4x3
      • Inverse
    • Sparse matrix
  • Tensors
  • Helpers

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clamp

func Clamp(a, min, max float32) float32

func Pytag

func Pytag(a, b float32) float32

(a^2+b^2)^(1/2) without Owerflow

func Quad

func Quad(a, b, c, eps float32) (float32, float32)

Quadratic equation solver

func SQR

func SQR(a float32) float32

Types

This section is empty.

Directories

Path Synopsis
pid

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL