tensor

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: MIT Imports: 9 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OffsetOf added in v0.3.0

func OffsetOf(shape, index Shape) int

OffsetOf calculates offset of index in shape

func SizeOf added in v0.3.0

func SizeOf(shape Shape) int

SizeOf calculates size of shape

Types

type Euler added in v0.1.7

type Euler[T constraints.Float] struct {
	Vector3[T]
	Order EulerRotationOrder // XYZ, XZY, YXZ, YZX, ZXY, ZYX
}

func (*Euler[T]) SetFromRotationMatrix added in v0.1.7

func (euler *Euler[T]) SetFromRotationMatrix(mat Matrix4[T]) *Euler[T]

func (Euler[T]) String added in v0.2.3

func (euler Euler[T]) String() string

type EulerRotationOrder added in v0.2.3

type EulerRotationOrder int8
const (
	EulerRotationOrderXYZ EulerRotationOrder = iota
	EulerRotationOrderXZY
	EulerRotationOrderYXZ
	EulerRotationOrderYZX
	EulerRotationOrderZXY
	EulerRotationOrderZYX
)

func (EulerRotationOrder) String added in v0.2.3

func (order EulerRotationOrder) String() string

type Index added in v0.2.13

type Index int

Index implements a 1-dim shape

func (Index) At added in v0.2.13

func (i Index) At(j int) int

func (Index) Len added in v0.2.13

func (i Index) Len() int

type Indices added in v0.2.13

type Indices []int

Index implements a n-dim shape

func IndexOf added in v0.3.0

func IndexOf(shape Shape, offset int, indices Indices) Indices

IndexOf calculates index of offset in shape and returns indices

func Next added in v0.3.0

func Next(shape Shape, index Indices) Indices

Next retrieves next index

func (Indices) At added in v0.2.13

func (i Indices) At(j int) int

func (Indices) Len added in v0.2.13

func (i Indices) Len() int

type Matrix added in v0.2.13

type Matrix[T constraints.SignedReal] struct {
	// contains filtered or unexported fields
}

Matrix represents a MxN matrix

func IdentityN added in v0.2.13

func IdentityN[T constraints.SignedReal](n int) Matrix[T]

IdentityN creates a NxN identity matrix

func OneMxN added in v0.2.13

func OneMxN[T constraints.SignedReal](m, n int) Matrix[T]

OneMxN creates a MxN matrix which every element is 1

func ZeroMxN added in v0.2.13

func ZeroMxN[T constraints.SignedReal](m, n int) Matrix[T]

ZeroMxN creates a zero MxN matrix

func (Matrix[T]) Add added in v0.2.13

func (mat Matrix[T]) Add(other Matrix[T]) Matrix[T]

func (Matrix[T]) At added in v0.2.13

func (mat Matrix[T]) At(index Shape) T

At implements Tensor At method

func (Matrix[T]) Columns added in v0.2.13

func (mat Matrix[T]) Columns() int

func (Matrix[T]) Determinant added in v0.2.13

func (mat Matrix[T]) Determinant() T

func (Matrix[T]) Div added in v0.2.13

func (mat Matrix[T]) Div(other Matrix[T]) Matrix[T]

func (Matrix[T]) Dot added in v0.2.13

func (mat Matrix[T]) Dot(other Matrix[T]) Matrix[T]

func (Matrix[T]) DotVec added in v0.2.14

func (mat Matrix[T]) DotVec(vec Vector[T]) Vector[T]

func (Matrix[T]) Elements added in v0.2.13

func (mat Matrix[T]) Elements() []T

func (Matrix[T]) Get added in v0.2.13

func (mat Matrix[T]) Get(i, j int) T

func (Matrix[T]) Invert added in v0.2.13

func (mat Matrix[T]) Invert() Matrix[T]

func (Matrix[T]) Mul added in v0.2.13

func (mat Matrix[T]) Mul(other Matrix[T]) Matrix[T]

func (Matrix[T]) Norm added in v0.2.13

func (mat Matrix[T]) Norm() T

func (Matrix[T]) Normalize added in v0.2.13

func (mat Matrix[T]) Normalize() Matrix[T]

func (Matrix[T]) Normp added in v0.2.13

func (mat Matrix[T]) Normp(p T) T

func (Matrix[T]) Rows added in v0.2.13

func (mat Matrix[T]) Rows() int

func (Matrix[T]) Scale added in v0.2.13

func (mat Matrix[T]) Scale(x T) Matrix[T]

func (*Matrix[T]) Set added in v0.2.13

func (mat *Matrix[T]) Set(i, j int, x T)

func (Matrix[T]) Shape added in v0.2.13

func (mat Matrix[T]) Shape() Shape

Shape implements Tensor Shape method

func (Matrix[T]) SquaredLength added in v0.2.13

func (mat Matrix[T]) SquaredLength() T

func (Matrix[T]) String added in v0.2.13

func (mat Matrix[T]) String() string

String converts matrix as a string

func (Matrix[T]) Sub added in v0.2.13

func (mat Matrix[T]) Sub(other Matrix[T]) Matrix[T]

func (Matrix[T]) Sum added in v0.2.13

func (mat Matrix[T]) Sum() T

Sum implements Tensor Sum method

func (Matrix[T]) Transpose added in v0.2.13

func (mat Matrix[T]) Transpose() Matrix[T]

Transpose returns a transposed matrix

type Matrix2 added in v0.2.3

type Matrix2[T constraints.SignedReal] [2 * 2]T

Matrix2 represents a 2x2 matrix

func Identity2 added in v0.2.13

func Identity2[T constraints.SignedReal]() Matrix2[T]

Identity2 creates a 2x2 identity matrix

func One2x2 added in v0.2.3

func One2x2[T constraints.SignedReal]() Matrix2[T]

One2x2 creates a 2x2 matrix which every element is 1

func Zero2x2 added in v0.2.13

func Zero2x2[T constraints.SignedReal]() Matrix2[T]

Zero2x2 creates a zero 2x2 matrix

func (Matrix2[T]) Add added in v0.2.3

func (mat Matrix2[T]) Add(other Matrix2[T]) Matrix2[T]

func (Matrix2[T]) At added in v0.2.13

func (mat Matrix2[T]) At(index Shape) T

At implements Tensor At method

func (Matrix2[T]) Determaint added in v0.2.3

func (mat Matrix2[T]) Determaint() T

func (Matrix2[T]) Div added in v0.2.3

func (mat Matrix2[T]) Div(other Matrix2[T]) Matrix2[T]

func (Matrix2[T]) Dot added in v0.2.3

func (mat Matrix2[T]) Dot(other Matrix2[T]) Matrix2[T]

func (Matrix2[T]) DotVec2 added in v0.2.3

func (mat Matrix2[T]) DotVec2(vec Vector2[T]) Vector2[T]

func (Matrix2[T]) Get added in v0.2.13

func (mat Matrix2[T]) Get(i, j int) T

func (Matrix2[T]) Invert added in v0.2.3

func (mat Matrix2[T]) Invert() Matrix2[T]

func (*Matrix2[T]) MakeIdentity added in v0.2.3

func (mat *Matrix2[T]) MakeIdentity() *Matrix2[T]

func (*Matrix2[T]) MakeRotation added in v0.2.3

func (mat *Matrix2[T]) MakeRotation(theta T) *Matrix2[T]

func (*Matrix2[T]) MakeScale added in v0.2.3

func (mat *Matrix2[T]) MakeScale(vec Vector2[T]) *Matrix2[T]

func (*Matrix2[T]) MakeZero added in v0.2.3

func (mat *Matrix2[T]) MakeZero() *Matrix2[T]

func (Matrix2[T]) Mul added in v0.2.3

func (mat Matrix2[T]) Mul(other Matrix2[T]) Matrix2[T]

func (Matrix2[T]) Norm added in v0.2.13

func (mat Matrix2[T]) Norm() T

func (Matrix2[T]) Normalize added in v0.2.3

func (mat Matrix2[T]) Normalize() Matrix2[T]

func (Matrix2[T]) Normp added in v0.2.13

func (mat Matrix2[T]) Normp(p T) T

func (Matrix2[T]) Scale added in v0.2.13

func (mat Matrix2[T]) Scale(v T) Matrix2[T]

func (*Matrix2[T]) Set added in v0.2.13

func (mat *Matrix2[T]) Set(i, j int, x T)

func (*Matrix2[T]) SetElements added in v0.2.3

func (mat *Matrix2[T]) SetElements(n11, n12, n21, n22 T) *Matrix2[T]

func (Matrix2[T]) Shape added in v0.2.13

func (mat Matrix2[T]) Shape() Shape

Shape implements Tensor Shape method

func (Matrix2[T]) SquaredLength added in v0.2.12

func (mat Matrix2[T]) SquaredLength() T

func (Matrix2[T]) String added in v0.2.3

func (mat Matrix2[T]) String() string

String converts matrix as a string

func (Matrix2[T]) Sub added in v0.2.3

func (mat Matrix2[T]) Sub(other Matrix2[T]) Matrix2[T]

func (Matrix2[T]) Sum added in v0.2.3

func (mat Matrix2[T]) Sum() T

Sum implements Tensor Sum method

func (Matrix2[T]) Transpose added in v0.2.3

func (mat Matrix2[T]) Transpose() Matrix2[T]

type Matrix3 added in v0.1.7

type Matrix3[T constraints.SignedReal] [3 * 3]T

Matrix3 represents a 3x3 matrix

func Identity3 added in v0.2.13

func Identity3[T constraints.SignedReal]() Matrix3[T]

Identity3 creates a 3x3 identity matrix

func One3x3 added in v0.1.7

func One3x3[T constraints.SignedReal]() Matrix3[T]

One4x4 creates a 3x3 matrix which every element is 1

func Zero3x3 added in v0.2.13

func Zero3x3[T constraints.SignedReal]() Matrix3[T]

Zero3x3 creates a zero 3x3 matrix

func (Matrix3[T]) Add added in v0.1.7

func (mat Matrix3[T]) Add(other Matrix3[T]) Matrix3[T]

func (Matrix3[T]) At added in v0.2.13

func (mat Matrix3[T]) At(index Shape) T

At implements Tensor At method

func (Matrix3[T]) Determaint added in v0.1.7

func (mat Matrix3[T]) Determaint() T

func (Matrix3[T]) Div added in v0.1.7

func (mat Matrix3[T]) Div(other Matrix3[T]) Matrix3[T]

func (Matrix3[T]) Dot added in v0.1.7

func (mat Matrix3[T]) Dot(other Matrix3[T]) Matrix3[T]

func (Matrix3[T]) DotVec2 added in v0.1.7

func (mat Matrix3[T]) DotVec2(vec Vector2[T]) Vector3[T]

func (Matrix3[T]) DotVec3 added in v0.1.7

func (mat Matrix3[T]) DotVec3(vec Vector3[T]) Vector3[T]

func (Matrix3[T]) Elements added in v0.2.13

func (mat Matrix3[T]) Elements() []T

func (Matrix3[T]) Get added in v0.2.13

func (mat Matrix3[T]) Get(i, j int) T

func (Matrix3[T]) Invert added in v0.1.7

func (mat Matrix3[T]) Invert() Matrix3[T]

func (*Matrix3[T]) MakeIdentity added in v0.1.7

func (mat *Matrix3[T]) MakeIdentity() *Matrix3[T]

func (*Matrix3[T]) MakeRotationAxis added in v0.1.7

func (mat *Matrix3[T]) MakeRotationAxis(axis Vector3[T], angle T) *Matrix3[T]

Based on http://www.gamedev.net/reference/articles/article1199.asp

func (*Matrix3[T]) MakeRotationX added in v0.1.7

func (mat *Matrix3[T]) MakeRotationX(theta T) *Matrix3[T]

func (*Matrix3[T]) MakeRotationY added in v0.1.7

func (mat *Matrix3[T]) MakeRotationY(theta T) *Matrix3[T]

func (*Matrix3[T]) MakeRotationZ added in v0.1.7

func (mat *Matrix3[T]) MakeRotationZ(theta T) *Matrix3[T]

func (*Matrix3[T]) MakeScale added in v0.1.7

func (mat *Matrix3[T]) MakeScale(vec Vector3[T]) *Matrix3[T]

func (*Matrix3[T]) MakeShear added in v0.1.7

func (mat *Matrix3[T]) MakeShear(xy, xz, yx, yz, zx, zy T) *Matrix3[T]

func (*Matrix3[T]) MakeZero added in v0.1.7

func (mat *Matrix3[T]) MakeZero() *Matrix3[T]

func (Matrix3[T]) Mul added in v0.1.7

func (mat Matrix3[T]) Mul(other Matrix3[T]) Matrix3[T]

func (Matrix3[T]) Norm added in v0.2.13

func (mat Matrix3[T]) Norm() T

func (Matrix3[T]) Normalize added in v0.1.7

func (mat Matrix3[T]) Normalize() Matrix3[T]

func (Matrix3[T]) Normp added in v0.2.13

func (mat Matrix3[T]) Normp(p T) T

func (Matrix3[T]) Scale added in v0.2.13

func (mat Matrix3[T]) Scale(v T) Matrix3[T]

func (*Matrix3[T]) Set added in v0.2.13

func (mat *Matrix3[T]) Set(i, j int, x T)

func (*Matrix3[T]) SetElements added in v0.1.7

func (mat *Matrix3[T]) SetElements(n11, n12, n13, n21, n22, n23, n31, n32, n33 T) *Matrix3[T]

func (Matrix3[T]) Shape added in v0.2.13

func (mat Matrix3[T]) Shape() Shape

Shape implements Tensor Shape method

func (Matrix3[T]) SquaredLength added in v0.2.12

func (mat Matrix3[T]) SquaredLength() T

func (Matrix3[T]) String added in v0.2.3

func (mat Matrix3[T]) String() string

String converts matrix as a string

func (Matrix3[T]) Sub added in v0.1.7

func (mat Matrix3[T]) Sub(other Matrix3[T]) Matrix3[T]

func (Matrix3[T]) Sum added in v0.1.7

func (mat Matrix3[T]) Sum() T

Sum implements Tensor Sum method

func (Matrix3[T]) Transpose added in v0.1.7

func (mat Matrix3[T]) Transpose() Matrix3[T]

type Matrix4 added in v0.1.7

type Matrix4[T constraints.SignedReal] [4 * 4]T

Matrix4 represents a 4x4 matrix

func Identity4 added in v0.2.13

func Identity4[T constraints.SignedReal]() Matrix4[T]

Identity4 creates a 4x4 identity matrix

func One4x4

func One4x4[T constraints.SignedReal]() Matrix4[T]

One4x4 creates a 4x4 matrix which every element is 1

func Zero4x4 added in v0.2.13

func Zero4x4[T constraints.SignedReal]() Matrix4[T]

Zero4x4 creates a zero 4x4 matrix

func (Matrix4[T]) Add added in v0.1.7

func (mat Matrix4[T]) Add(other Matrix4[T]) Matrix4[T]

func (Matrix4[T]) At added in v0.2.13

func (mat Matrix4[T]) At(index Shape) T

At implements Tensor At method

func (*Matrix4[T]) Compose added in v0.1.7

func (mat *Matrix4[T]) Compose(position Vector3[T], quaternion Vector4[T], scale Vector3[T]) *Matrix4[T]

func (Matrix4[T]) Decompose added in v0.1.7

func (mat Matrix4[T]) Decompose() (position Vector3[T], quaternion Vector4[T], scale Vector3[T])

func (Matrix4[T]) Determinant added in v0.1.7

func (mat Matrix4[T]) Determinant() T

func (Matrix4[T]) Div added in v0.1.7

func (mat Matrix4[T]) Div(other Matrix4[T]) Matrix4[T]

func (Matrix4[T]) Dot added in v0.1.7

func (mat Matrix4[T]) Dot(other Matrix4[T]) Matrix4[T]

func (Matrix4[T]) DotVec2 added in v0.1.7

func (mat Matrix4[T]) DotVec2(vec Vector2[T]) Vector3[T]

func (Matrix4[T]) DotVec3 added in v0.1.7

func (mat Matrix4[T]) DotVec3(vec Vector3[T]) Vector3[T]

func (Matrix4[T]) DotVec4 added in v0.1.7

func (mat Matrix4[T]) DotVec4(vec Vector4[T]) Vector4[T]

func (Matrix4[T]) Elements added in v0.2.13

func (mat Matrix4[T]) Elements() []T

func (Matrix4[T]) Get added in v0.2.13

func (mat Matrix4[T]) Get(i, j int) T

func (Matrix4[T]) GetPosition added in v0.1.7

func (mat Matrix4[T]) GetPosition() Vector3[T]

func (Matrix4[T]) Invert added in v0.1.7

func (mat Matrix4[T]) Invert() Matrix4[T]

based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm

func (*Matrix4[T]) MakeFromMatrix3 added in v0.1.7

func (mat *Matrix4[T]) MakeFromMatrix3(m Matrix3[T]) *Matrix4[T]

func (*Matrix4[T]) MakeIdentity added in v0.1.7

func (mat *Matrix4[T]) MakeIdentity() *Matrix4[T]

func (*Matrix4[T]) MakeOrthographic added in v0.1.7

func (mat *Matrix4[T]) MakeOrthographic(left, right, top, bottom, near, far T) *Matrix4[T]

func (*Matrix4[T]) MakePerspective added in v0.1.7

func (mat *Matrix4[T]) MakePerspective(left, right, top, bottom, near, far T) *Matrix4[T]

func (*Matrix4[T]) MakeRotationAxis added in v0.1.7

func (mat *Matrix4[T]) MakeRotationAxis(axis Vector3[T], angle T) *Matrix4[T]

Based on http://www.gamedev.net/reference/articles/article1199.asp

func (*Matrix4[T]) MakeRotationX added in v0.1.7

func (mat *Matrix4[T]) MakeRotationX(theta T) *Matrix4[T]

func (*Matrix4[T]) MakeRotationY added in v0.1.7

func (mat *Matrix4[T]) MakeRotationY(theta T) *Matrix4[T]

func (*Matrix4[T]) MakeRotationZ added in v0.1.7

func (mat *Matrix4[T]) MakeRotationZ(theta T) *Matrix4[T]

func (*Matrix4[T]) MakeScale added in v0.1.7

func (mat *Matrix4[T]) MakeScale(vec Vector3[T]) *Matrix4[T]

func (*Matrix4[T]) MakeShear added in v0.1.7

func (mat *Matrix4[T]) MakeShear(xy, xz, yx, yz, zx, zy T) *Matrix4[T]

func (*Matrix4[T]) MakeTranslation added in v0.1.7

func (mat *Matrix4[T]) MakeTranslation(vec Vector3[T]) *Matrix4[T]

func (*Matrix4[T]) MakeZero added in v0.1.7

func (mat *Matrix4[T]) MakeZero() *Matrix4[T]

func (Matrix4[T]) Mul added in v0.1.7

func (mat Matrix4[T]) Mul(other Matrix4[T]) Matrix4[T]

func (Matrix4[T]) Norm added in v0.2.13

func (mat Matrix4[T]) Norm() T

func (Matrix4[T]) Normalize added in v0.1.7

func (mat Matrix4[T]) Normalize() Matrix4[T]

func (Matrix4[T]) Normp added in v0.2.13

func (mat Matrix4[T]) Normp(p T) T

func (Matrix4[T]) Scale added in v0.2.13

func (mat Matrix4[T]) Scale(v T) Matrix4[T]

func (*Matrix4[T]) Set added in v0.2.13

func (mat *Matrix4[T]) Set(i, j int, x T)

func (*Matrix4[T]) SetElements added in v0.1.7

func (mat *Matrix4[T]) SetElements(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 T) *Matrix4[T]

func (*Matrix4[T]) SetPosition added in v0.1.7

func (mat *Matrix4[T]) SetPosition(pos Vector3[T]) *Matrix4[T]

func (Matrix4[T]) Shape added in v0.2.13

func (mat Matrix4[T]) Shape() Shape

Shape implements Tensor Shape method

func (Matrix4[T]) SquaredLength added in v0.2.12

func (mat Matrix4[T]) SquaredLength() T

func (Matrix4[T]) String added in v0.2.3

func (mat Matrix4[T]) String() string

String converts matrix as a string

func (Matrix4[T]) Sub added in v0.1.7

func (mat Matrix4[T]) Sub(other Matrix4[T]) Matrix4[T]

func (Matrix4[T]) Sum added in v0.1.7

func (mat Matrix4[T]) Sum() T

Sum implements Tensor Sum method

func (Matrix4[T]) Transpose added in v0.1.7

func (mat Matrix4[T]) Transpose() Matrix4[T]

type Shape added in v0.2.13

type Shape = tuple.Tuple[int]

Shape represents shape of tensor

type Tensor added in v0.2.13

type Tensor[T constraints.SignedReal] interface {
	Shape() tuple.Tuple[int]
	At(index tuple.Tuple[int]) T
	Sum() T
}

Tensor represents a tensor

func Create added in v0.2.13

func Create[T constraints.SignedReal](shape Shape) Tensor[T]

Create creates a tensor by shape

func Dot added in v0.2.13

func Dot[T constraints.SignedReal](a, b Tensor[T]) Tensor[T]

Dot computes dot product: a‧b

func Product added in v0.2.13

func Product[T constraints.SignedReal](a, b Tensor[T]) Tensor[T]

Product computes tensor product: a⊗b

func Reshape added in v0.3.0

func Reshape[T constraints.SignedReal](tensor Tensor[T], shape Shape) Tensor[T]

Reshape reshapes the tensor

func Scalar added in v0.2.13

func Scalar[T constraints.SignedReal](x T) Tensor[T]

type Vector added in v0.2.11

type Vector[T constraints.SignedReal] []T

Vector implements n-dim vector

func Linspace added in v0.2.12

func Linspace[T constraints.SignedReal](from, to T, n int) Vector[T]

Linspace creates a vector {x1=from, ..., xn=to}

func Range added in v0.2.12

func Range[T constraints.SignedReal](start, end T) Vector[T]

Range creates a vector [start, end)

func RangeN added in v0.2.12

func RangeN[T constraints.SignedReal](n T) Vector[T]

RangeN creates a vector [0, n)

func Repeat added in v0.2.13

func Repeat[T constraints.SignedReal](x T, n int) Vector[T]

Repeat creates a n-dim vector which has same value x

func Vec added in v0.2.11

func Vec[T constraints.SignedReal](elements ...T) Vector[T]

Vec creates a vector by elements

func (Vector[T]) Add added in v0.2.11

func (vec Vector[T]) Add(other Vector[T]) Vector[T]

func (Vector[T]) At added in v0.2.13

func (vec Vector[T]) At(index Shape) T

At implements Tensor At method

func (Vector[T]) Dim added in v0.2.11

func (vec Vector[T]) Dim() int

func (Vector[T]) Div added in v0.2.11

func (vec Vector[T]) Div(other Vector[T]) Vector[T]

func (Vector[T]) Dot added in v0.2.11

func (vec Vector[T]) Dot(other Vector[T]) T

func (Vector[T]) Elements added in v0.2.13

func (vec Vector[T]) Elements() []T

func (Vector[T]) Get added in v0.2.11

func (vec Vector[T]) Get(i int) T

func (Vector[T]) Mul added in v0.2.11

func (vec Vector[T]) Mul(other Vector[T]) Vector[T]

func (Vector[T]) Norm added in v0.2.11

func (vec Vector[T]) Norm() T

Norm computes 2-norm

func (Vector[T]) Normp added in v0.2.11

func (vec Vector[T]) Normp(p T) T

Normp computes p-norm

func (Vector[T]) Set added in v0.2.11

func (vec Vector[T]) Set(i int, v T)

func (Vector[T]) Shape added in v0.2.13

func (vec Vector[T]) Shape() Shape

Shape implements Tensor Shape method

func (Vector[T]) SquaredLength added in v0.2.11

func (vec Vector[T]) SquaredLength() T

SquaredLength computes ║vec║²

func (Vector[T]) String added in v0.2.13

func (vec Vector[T]) String() string

String converts vector as a string

func (Vector[T]) Sub added in v0.2.11

func (vec Vector[T]) Sub(other Vector[T]) Vector[T]

func (Vector[T]) Sum added in v0.2.11

func (vec Vector[T]) Sum() T

Sum implements Tensor Sum method

type Vector2

type Vector2[T constraints.SignedReal] [2]T

Vector2 implements 2d vector

func Vec2

func Vec2[T constraints.SignedReal](x, y T) Vector2[T]

Vec2 creates a 2d vector by elements

func (Vector2[T]) Add

func (vec Vector2[T]) Add(other Vector2[T]) Vector2[T]

func (Vector2[T]) At added in v0.2.13

func (vec Vector2[T]) At(index Shape) T

At implements Tensor At method

func (*Vector2[T]) Copy added in v0.1.7

func (vec *Vector2[T]) Copy(other Vector2[T])

func (Vector2[T]) Cross added in v0.2.1

func (vec Vector2[T]) Cross(other Vector2[T]) T

func (Vector2[T]) Div

func (vec Vector2[T]) Div(other Vector2[T]) Vector2[T]

func (Vector2[T]) Dot

func (vec Vector2[T]) Dot(other Vector2[T]) T

func (Vector2[T]) Get added in v0.2.11

func (vec Vector2[T]) Get(i int) T

func (Vector2[T]) Mul

func (vec Vector2[T]) Mul(other Vector2[T]) Vector2[T]

func (Vector2[T]) Norm added in v0.2.13

func (vec Vector2[T]) Norm() T

func (Vector2[T]) Normalize

func (vec Vector2[T]) Normalize() Vector2[T]

func (Vector2[T]) Normp added in v0.2.13

func (vec Vector2[T]) Normp(p T) T

Normp computes p-norm

func (Vector2[T]) Scale added in v0.2.13

func (vec Vector2[T]) Scale(k T) Vector2[T]

func (*Vector2[T]) Set added in v0.1.7

func (vec *Vector2[T]) Set(i int, v T)

func (*Vector2[T]) SetElements added in v0.2.11

func (vec *Vector2[T]) SetElements(x, y T)

func (*Vector2[T]) SetX added in v0.1.7

func (vec *Vector2[T]) SetX(x T)

func (*Vector2[T]) SetY added in v0.1.7

func (vec *Vector2[T]) SetY(y T)

func (Vector2[T]) Shape added in v0.2.13

func (vec Vector2[T]) Shape() Shape

Shape implements Tensor Shape method

func (Vector2[T]) SquaredLength added in v0.2.11

func (vec Vector2[T]) SquaredLength() T

func (Vector2[T]) String added in v0.2.3

func (vec Vector2[T]) String() string

String converts vector as a string

func (Vector2[T]) Sub

func (vec Vector2[T]) Sub(other Vector2[T]) Vector2[T]

func (Vector2[T]) Sum

func (vec Vector2[T]) Sum() T

Sum implements Tensor Sum method

func (Vector2[T]) Vec3

func (vec Vector2[T]) Vec3() Vector3[T]

func (Vector2[T]) Vec4

func (vec Vector2[T]) Vec4() Vector4[T]

func (Vector2[T]) X

func (vec Vector2[T]) X() T

func (Vector2[T]) Y

func (vec Vector2[T]) Y() T

type Vector3

type Vector3[T constraints.SignedReal] [3]T

Vector3 implements 3d vector

func Vec3

func Vec3[T constraints.SignedReal](x, y, z T) Vector3[T]

Vec3 creates a 3d vector by elements

func (Vector3[T]) Add

func (vec Vector3[T]) Add(other Vector3[T]) Vector3[T]

func (Vector3[T]) At added in v0.2.13

func (vec Vector3[T]) At(index Shape) T

At implements Tensor At method

func (*Vector3[T]) Copy added in v0.1.7

func (vec *Vector3[T]) Copy(other Vector3[T])

func (Vector3[T]) Cross added in v0.2.1

func (vec Vector3[T]) Cross(other Vector3[T]) Vector3[T]

func (Vector3[T]) Div

func (vec Vector3[T]) Div(other Vector3[T]) Vector3[T]

func (Vector3[T]) Dot

func (vec Vector3[T]) Dot(other Vector3[T]) T

func (Vector3[T]) Get added in v0.2.11

func (vec Vector3[T]) Get(i int) T

func (Vector3[T]) Mul

func (vec Vector3[T]) Mul(other Vector3[T]) Vector3[T]

func (Vector3[T]) Norm added in v0.2.13

func (vec Vector3[T]) Norm() T

func (Vector3[T]) Normalize

func (vec Vector3[T]) Normalize() Vector3[T]

func (Vector3[T]) Normp added in v0.2.13

func (vec Vector3[T]) Normp(p T) T

Normp computes p-norm

func (Vector3[T]) Scale added in v0.2.13

func (vec Vector3[T]) Scale(k T) Vector3[T]

func (*Vector3[T]) Set added in v0.1.7

func (vec *Vector3[T]) Set(i int, v T)

func (*Vector3[T]) SetElements added in v0.2.11

func (vec *Vector3[T]) SetElements(x, y, z T)

func (*Vector3[T]) SetX added in v0.1.7

func (vec *Vector3[T]) SetX(x T)

func (*Vector3[T]) SetY added in v0.1.7

func (vec *Vector3[T]) SetY(y T)

func (*Vector3[T]) SetZ added in v0.1.7

func (vec *Vector3[T]) SetZ(z T)

func (Vector3[T]) Shape added in v0.2.13

func (vec Vector3[T]) Shape() Shape

Shape implements Tensor Shape method

func (Vector3[T]) SquaredLength added in v0.2.11

func (vec Vector3[T]) SquaredLength() T

func (Vector3[T]) String added in v0.2.3

func (vec Vector3[T]) String() string

String converts vector as a string

func (Vector3[T]) Sub

func (vec Vector3[T]) Sub(other Vector3[T]) Vector3[T]

func (Vector3[T]) Sum

func (vec Vector3[T]) Sum() T

Sum implements Tensor Sum method

func (Vector3[T]) Vec2 added in v0.2.13

func (vec Vector3[T]) Vec2() Vector2[T]

func (Vector3[T]) Vec4

func (vec Vector3[T]) Vec4() Vector4[T]

func (Vector3[T]) X

func (vec Vector3[T]) X() T

func (Vector3[T]) Y

func (vec Vector3[T]) Y() T

func (Vector3[T]) Z

func (vec Vector3[T]) Z() T

type Vector4

type Vector4[T constraints.SignedReal] [4]T

Vector4 implements 4d vector

func Vec4

func Vec4[T constraints.SignedReal](x, y, z, w T) Vector4[T]

Vec4 creates a 4d vector by elements

func (Vector4[T]) Add

func (vec Vector4[T]) Add(other Vector4[T]) Vector4[T]

func (Vector4[T]) At added in v0.2.13

func (vec Vector4[T]) At(index Shape) T

At implements Tensor At method

func (*Vector4[T]) Copy added in v0.1.7

func (vec *Vector4[T]) Copy(other Vector4[T])

func (Vector4[T]) Div

func (vec Vector4[T]) Div(other Vector4[T]) Vector4[T]

func (Vector4[T]) Dot

func (vec Vector4[T]) Dot(other Vector4[T]) T

func (Vector4[T]) Get added in v0.2.11

func (vec Vector4[T]) Get(i int) T

func (Vector4[T]) Mul

func (vec Vector4[T]) Mul(other Vector4[T]) Vector4[T]

func (Vector4[T]) Norm added in v0.2.13

func (vec Vector4[T]) Norm() T

func (Vector4[T]) Normalize

func (vec Vector4[T]) Normalize() Vector4[T]

func (Vector4[T]) Normp added in v0.2.13

func (vec Vector4[T]) Normp(p T) T

Normp computes p-norm

func (Vector4[T]) Scale added in v0.2.13

func (vec Vector4[T]) Scale(k T) Vector4[T]

func (*Vector4[T]) Set added in v0.1.7

func (vec *Vector4[T]) Set(i int, v T)

func (*Vector4[T]) SetElements added in v0.2.11

func (vec *Vector4[T]) SetElements(x, y, z, w T)

func (*Vector4[T]) SetW added in v0.1.7

func (vec *Vector4[T]) SetW(w T)

func (*Vector4[T]) SetX added in v0.1.7

func (vec *Vector4[T]) SetX(x T)

func (*Vector4[T]) SetY added in v0.1.7

func (vec *Vector4[T]) SetY(y T)

func (*Vector4[T]) SetZ added in v0.1.7

func (vec *Vector4[T]) SetZ(z T)

func (Vector4[T]) Shape added in v0.2.13

func (vec Vector4[T]) Shape() Shape

Shape implements Tensor Shape method

func (Vector4[T]) SquaredLength added in v0.2.11

func (vec Vector4[T]) SquaredLength() T

func (Vector4[T]) String added in v0.2.3

func (vec Vector4[T]) String() string

String converts vector as a string

func (Vector4[T]) Sub

func (vec Vector4[T]) Sub(other Vector4[T]) Vector4[T]

func (Vector4[T]) Sum

func (vec Vector4[T]) Sum() T

Sum implements Tensor Sum method

func (Vector4[T]) Vec2 added in v0.2.13

func (vec Vector4[T]) Vec2() Vector2[T]

func (Vector4[T]) Vec3

func (vec Vector4[T]) Vec3() Vector3[T]

func (Vector4[T]) W

func (vec Vector4[T]) W() T

func (Vector4[T]) X

func (vec Vector4[T]) X() T

func (Vector4[T]) Y

func (vec Vector4[T]) Y() T

func (Vector4[T]) Z

func (vec Vector4[T]) Z() T

Jump to

Keyboard shortcuts

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