package module
Version: v0.0.0-...-fbe61e3 Latest Latest

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

Go to latest
Published: Jun 13, 2020 License: GPL-3.0 Imports: 11 Imported by: 0



numpy implementation in golang


Strictly for learning purposes


  • Benchmarks
  • API consistency with numpy
  • Lot of vector operations


  • Code is not optimized




View Source
const OneBigNumber = 1000000


This section is empty.


func IsDotOperationAllowed

func IsDotOperationAllowed(a, b NDArray, boardcasting ...bool) bool

The size of the result array created by broadcast operations is the maximum size along each dimension from the input arrays.

func ParseDim

func ParseDim(sDims string, shape *domain.IVector) *domain.Dimensions

func Split

func Split(a NDArray, index int, axis (NDArray, NDArray)


type DataSet

type DataSet struct {
	Data         NDArray
	Target       NDArray
	TargetNames  []string
	FeatureNames []string
	DatasetPath  string
	Description  string

func LoadData

func LoadData(datasetName string) DataSet

TODO: Add tests

func LoadDataFromFile

func LoadDataFromFile(path string, featureNames []string) DataSet

TODO: Add tests

type NDArray

type NDArray struct {
	Elements domain.Vector
	Shape    domain.IVector
	Strides  domain.IVector
	DType    string
	Dims     int
	Size     int

func Add

func Add(nd NDArray, factor float64) NDArray

func Addition

func Addition(a, b NDArray) NDArray

func Amax

func Amax(a NDArray, axis NDArray

return maximum along given axis

func Amin

func Amin(a NDArray, axis NDArray

func Arange

func Arange(size NDArray

func Argmax

func Argmax(a NDArray, axis NDArray

func Argmin

func Argmin(a NDArray, axis NDArray

func ArrayMultiply

func ArrayMultiply(a, b NDArray) NDArray

TODO: Implement this

func Clip

func Clip(a NDArray, min, max float64) NDArray

Clip (limit) the values in an array.

func Concatenate

func Concatenate(a, b NDArray, axis NDArray

func Diag

func Diag(nd NDArray, k NDArray

func DimensionReductionV2

func DimensionReductionV2(lambda func(v domain.Vector) float64, a NDArray, axis int) NDArray

func Div

func Div(nd NDArray, factor float64) NDArray

func Division

func Division(a, b NDArray) NDArray

func Dot

func Dot(x, y NDArray, lambda func(float64, float64) float64) NDArray


func Equal

func Equal(nd NDArray, factor float64) NDArray

func Equals

func Equals(a NDArray, b NDArray) NDArray

TODO: Add test cases

func Exp

func Exp(nd NDArray) NDArray

func FilterRows

func FilterRows(a NDArray, lambda func(row *domain.Vector) bool) NDArray

func ForEachElement

func ForEachElement(nd NDArray, lambda func(v float64) float64) NDArray

EACH ELEMENT - lambda functions

func Log

func Log(nd NDArray) NDArray

func Log2

func Log2(nd NDArray) NDArray

func MaxNDArray

func MaxNDArray(dtype string, shape []int) NDArray

func Mult

func Mult(nd NDArray, factor float64) NDArray

func Multiply

func Multiply(a, b NDArray) NDArray

func NewNDArray

func NewNDArray(dtype string, shape []int, noinit ...bool) NDArray

func Ones

func Ones(dtype string, shape NDArray

func Pow

func Pow(nd NDArray, factor float64) NDArray

func Rand

func Rand(dtype string, shape NDArray

func Shuffle

func Shuffle(nd NDArray) NDArray

This function only shuffles the array along the first axis of a multi-dimensional array.

func Sub

func Sub(nd NDArray, factor float64) NDArray

func Subtract

func Subtract(a, b NDArray) NDArray

func Sum

func Sum(a NDArray, axis NDArray

func Transpose

func Transpose(nd NDArray) NDArray

func Unique

func Unique(a NDArray, axis NDArray

TODO: Verify this multi dimension array

func Zeros

func Zeros(dtype string, shape NDArray

func (*NDArray) CopyLike

func (nd *NDArray) CopyLike() NDArray

func (*NDArray) Get

func (nd *NDArray) Get(dims *domain.Dimensions) (NDArray, error)

func (*NDArray) GetIndexed

func (nd *NDArray) GetIndexed(indexes NDArray) NDArray

TODO: implement this

func (*NDArray) Len

func (nd *NDArray) Len() int

func (*NDArray) Mean

func (nd *NDArray) Mean(axis NDArray

TODO: Write test cases

func (*NDArray) Reshape

func (nd *NDArray) Reshape(shape *domain.IVector) bool

TODO: Verify correctness

func (*NDArray) Set

func (nd *NDArray) Set(dims *domain.Dimensions, value float64) error

type NDIndex

type NDIndex struct {
	// contains filtered or unexported fields

func NewNDIndex

func NewNDIndex(shape []int) *NDIndex

func (*NDIndex) IncrementIndex

func (ndIndex *NDIndex) IncrementIndex() bool

func (*NDIndex) Next

func (ndIndex *NDIndex) Next() *domain.IVector

This returns new object So that application can use the newly created object

func (*NDIndex) Reset

func (ndIndex *NDIndex) Reset()


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL