types

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2015 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package "types" provides types which represent matrix and iterator of elements.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cursor

type Cursor interface {
	// Read the next element and return "true".
	// If the next element doesn't exist, return "false".
	HasNext() bool

	// Return the current read element.
	Get() (element float64, row, column int)
}

type Index added in v0.1.3

type Index struct {
	// contains filtered or unexported fields
}

func NewIndex added in v0.1.3

func NewIndex(row, column int) *Index

func (*Index) Column added in v0.1.3

func (i *Index) Column() int

func (*Index) MarshalJSON added in v0.1.4

func (i *Index) MarshalJSON() ([]byte, error)

func (*Index) Row added in v0.1.3

func (i *Index) Row() int

func (*Index) UnmarshalJSON added in v0.1.4

func (i *Index) UnmarshalJSON(b []byte) error

type Matrix

type Matrix interface {
	// Serialize the receiver matrix by using the given writer.
	Serialize(wrtier io.Writer) error

	// Return the shape of matrix, which consists of the "rows" and the "columns".
	Shape() (rows, columns int)

	// Return the number of "rows".
	Rows() (rows int)

	// Return the number of "columns".
	Columns() (columns int)

	// Create and return an iterator for all elements.
	All() Cursor

	// Create and return an iterator for non-zero elements.
	NonZeros() Cursor

	// Create and return an iterator for diagonal elements.
	Diagonal() Cursor

	// Get an element of matrix specified with "row" and "column".
	// When "row" or "column" is lower than the number of rows or columns,
	// validates.OUT_OF_RANGE_PANIC will be caused.
	Get(row, column int) (element float64)

	// Update the element of matrix specified with "row" and "column".
	// When "row" or "column" is lower than the number of rows or columns,
	// validates.OUT_OF_RANGE_PANIC will be caused.
	Update(row, column int, element float64) Matrix

	// Check element-wise equality of the receiver matrix and the given matrix.
	// When the shape of the receiver and the argument is different,
	// validates.DIFFERENT_SIZE_PANIC will be caused.
	Equal(n Matrix) bool

	// Add the given matrix to the receiver matrix.
	// When the shape of the receiver and the argument is different,
	// validates.DIFFERENT_SIZE_PANIC will be caused.
	Add(n Matrix) Matrix

	// Subtract the given matrix from the receiver matrix.
	// When the shape of the receiver and the argument is different,
	// validates.DIFFERENT_SIZE_PANIC will be caused.
	Subtract(n Matrix) Matrix

	// Multiply the receiver matrix by the given matrix.
	// When the number of columns of the receiver doesn't equal to
	// the number of rows of the argument,
	// validates.NOT_MULTIPLIABLE_PANIC will be caused.
	Multiply(n Matrix) Matrix

	// Multiply by scalar value.
	Scalar(s float64) Matrix

	// Create the transpose matrix.
	Transpose() Matrix

	// Create a arbitrary view.
	View(row, column, rows, columns int) Matrix

	// Get the base matrix.
	Base() Matrix

	// Create a row view.
	Row(row int) Matrix

	// Create a column view.
	Column(column int) Matrix

	// Find and return the first one of maximum elements.
	Max() (element float64, row, column int)

	// Find and return the first one of minimum elements.
	Min() (element float64, row, column int)
}

type Shape added in v0.1.3

type Shape struct {
	// contains filtered or unexported fields
}

func NewShape added in v0.1.3

func NewShape(rows, columns int) *Shape

func (*Shape) Columns added in v0.1.3

func (s *Shape) Columns() int

func (*Shape) MarshalJSON added in v0.1.4

func (s *Shape) MarshalJSON() ([]byte, error)

func (*Shape) Rows added in v0.1.3

func (s *Shape) Rows() int

func (*Shape) UnmarshalJSON added in v0.1.4

func (s *Shape) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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