array

package module
v0.0.0-...-c5d7e21 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2020 License: MIT Imports: 13 Imported by: 0

README

There is some useful code here, but this repo is still work in progress

Contents

  1. Summary
  2. Introduction
  3. Quickstart
    1. Constructing arrays

Summary

array implements multi-dimensional numeric arrays.

As of 2020-09-06:

  • array is a package that implements a common data structure; it is not a package for linear algebra.
  • The implementation is in pure Go (cgo is not used).
  • Arrays with complex elements are not supported.
  • Arrays of stringss are not supported.

Introduction

For each built-in numeric type,1 there is a corresponding array type. The name of the array type is the same as the name of the type of its elements, but with the first letter capitalised. For example, the type of an array of float64 is Float64 and the type of an array of uint8 is Uint8.

All definitions of array types follow the same pattern:

type Type struct {
	Metadata
	Data []type
}

For example, the definition of Float64 is

type Float64 struct {
	Metadata
	Data []float64
}

Metadata is a type used for the bookkeeping that makes it possible to treat a slice as an array. That is, Metadata is the bridge between the mental model of a multi-dimensional array and the actual storage of data in contiguous memory.

From the definition of the array types it becomes evident that, since the underlying storage of an array is a slice, arrays are "homogeneous containers"; that is, an array cannot contain elements of different types.

Footnotes

1 int8, uint8, int16, uint16, int32, uint32, int64, uint64, int, uint, uintptr, float32, float64

Quickstart

The code shown in this section can found in cmd/quickstart.

Constructing arrays

Make a 7x5 array of float64:

A, _ := array.Factory().Dims(7, 5).Float64()

Print the array:

fmt.Printf("%v\n", A)

Output:

(0,0):       0.0000	      0.0000	      0.0000	      0.0000	      0.0000	
(1,0):       0.0000	      0.0000	      0.0000	      0.0000	      0.0000	
(2,0):       0.0000	      0.0000	      0.0000	      0.0000	      0.0000	
(3,0):       0.0000	      0.0000	      0.0000	      0.0000	      0.0000	
(4,0):       0.0000	      0.0000	      0.0000	      0.0000	      0.0000	
(5,0):       0.0000	      0.0000	      0.0000	      0.0000	      0.0000	
(6,0):       0.0000	      0.0000	      0.0000	      0.0000	      0.0000

Documentation

Overview

Package array implements multi-dimensional numerical arrays and convenient methods to work with them.

File Summaries

Short summaries for some of the main files of the package.

`array\cat.go`: a Go source file generated from the text template `array\templates\cat.go`. It implements concrete array types and their methods.

`array\cmd\codegen\codegen`: the Go script the parses the code templates in `array\templates`

`array\cmd\codegen\config.json`: the settings used by `array\cmd\codegen\codegen` to parse the code templates in `array\templates`

`array\cmd\codegen\configLoader.go`: part of the `codegen` package; implements a function for loading `array\cmd\codegen\config.json`

`array\cmd\codegen\main.go`: implements the `main` function of the package `codegen`

`array\templates\gslice.go`: a text template processed by `array\cmd\codegen\codegen` to generate the Go file `array\gslice.go`.

`array\templates\cat.go`: a text template processed by `array\cmd\codegen\codegen` to generate the Go file `array\cat.go`.

File name key

Explanation of some file names to partially alleviate the mental burden of remembering what each file contains.

`cat.go`: (c)oncrete (a)rray (t)ypes

`gslice.go`: (g)eneric slice

Index

Constants

This section is empty.

Variables

View Source
var ErrPrefix string = "[error:ArrPkgError]"

ErrPrefix is the prefix added to error messages.

View Source
var PrintVerbBools string = "%v"

PrintVerbBools is for bools

View Source
var PrintVerbFloats string = "%12.4f"

PrintVerbFloats is for floats

View Source
var PrintVerbInts string = "%-10d"

PrintVerbInts is for ints

View Source
var PrintVerbStrings string = "%s"

PrintVerbStrings is for strings

Functions

func CummProdInt

func CummProdInt(v []int, k ...int) int

CummProdInt returns the cummulative product of a slice []int, starting the calculation at position k. If `k` is not supplied, then the calculation starts at v[0]. The argument k is variadic so that it's optional; we don't need more than one value, but we want to have at most one value.

func DotProdInt

func DotProdInt(u, v []int) (dotProd int)

DotProdInt returns the inner product of two []int].

func EndsIn1Int

func EndsIn1Int(x []int) bool

EndsIn1Int checks whether the input slice `x` ends in at least 3 consecutive 1s (ones).

func Index

func Index(micf []int, indices ...int) int

Index returns the linear index (into an array) that corresponds to the multi-index `indices` passed as input. The conversion requires the multi-index conversion factors as additional input.

func Indices

func Indices(dims []int, index int) []int

Indices returns the multi-index (into an array) that corresponds to the linear index `index` passed as input. The conversion requires the dimensions of the array as additional input.

func Indices2Str

func Indices2Str(indices []int, bracketType string, separator string) (result string)

Indices2Str converts a slice of type []int to a customised string representation. Example input arguments: indices: []int{1, 2, 3} bracketType: "()" or "[]" separator: ","

func MultiIndexConversionFactors

func MultiIndexConversionFactors(dims []int, ndims int) (micf []int)

MultiIndexConversionFactors returns a slice `micf` of integers such that the inner product <micf,(i_1, i_2,..., i_p)>, where (i_1, i_2,..., i_p) is a multi-index with p == len(A.dims), satisfies A[<micf,(i_1, i_2,..., i_p)>] == A[i_1, i_2,..., i_p]. In other words, the result is used to convert multi-indices to linear indices for arrays.

func NumelsFromDims

func NumelsFromDims(dims []int) int

NumelsFromDims returns the total numbers of elements contained in an `Array` whose dimensions are described by `dims`.

func RangeStr2Arr

func RangeStr2Arr(s string, dim int) ([3]int, error)

RangeStr2Arr converts a string representation of 1-dimensional slice to a usable numeric representation. s: string representation of a `Range` (e.g., [0:3:2])

Types

type ArrPkgError

type ArrPkgError struct {
	When      time.Time
	Where     string
	What      string
	TraceBack []error
}

ArrPkgError encodes information related to errors that occur inside the package `array`.

func MakeError

func MakeError(where, what string, errors ...error) ArrPkgError

MakeError makes an error specific to the `array` package.

func (ArrPkgError) Error

func (e ArrPkgError) Error() string

type ArrayFactory

type ArrayFactory struct {
	// fillVal: Value used to fill the newly constructed array; f(ill)val(ue)
	// fillVal interface{}
	Metadata
}

ArrayFactory is to be thought of as a struct that contains the settings or blueprint needed to construct a new array. Together with its methods, it is the factory that makes new arrays.

Note: Normally, `ArrayFactory` instances will not be used directly. Their main use is in the "builder pattern"; the latter is used because there is no "constructor overloading" available in Go.

func Factory

func Factory() *ArrayFactory

Factory returns an array factory on which `Make` can be called to construct an instance of the core `Array` type. The `Make<ElementType>` methods are implemented in `concrete.go`

func (*ArrayFactory) Dims

func (af *ArrayFactory) Dims(dims ...int) *ArrayFactory

Dims sets the value of `dims` (in the array factory) representing the dimensions of the newly constructed array

func (*ArrayFactory) Float32

func (af *ArrayFactory) Float32() (*Float32, error)

Float32 makes a new array with element type `float32`.

func (*ArrayFactory) Float64

func (af *ArrayFactory) Float64() (*Float64, error)

Float64 makes a new array with element type `float64`.

func (*ArrayFactory) Int

func (af *ArrayFactory) Int() (*Int, error)

Int makes a new array with element type `int`.

func (*ArrayFactory) Int16

func (af *ArrayFactory) Int16() (*Int16, error)

Int16 makes a new array with element type `int16`.

func (*ArrayFactory) Int32

func (af *ArrayFactory) Int32() (*Int32, error)

Int32 makes a new array with element type `int32`.

func (*ArrayFactory) Int64

func (af *ArrayFactory) Int64() (*Int64, error)

Int64 makes a new array with element type `int64`.

func (*ArrayFactory) Int8

func (af *ArrayFactory) Int8() (*Int8, error)

Int8 makes a new array with element type `int8`.

func (*ArrayFactory) SetMetadata

func (af *ArrayFactory) SetMetadata() (*ArrayFactory, error)

SetMetadata completes the initialisation of `Metadata` inside the receiver `af`. SetMetadata checks that `af.Dims` has meaningful values and calculates `numels` and `micf`. The meta-data include all the information to define the array, except for the elements of the array themselves.

func (*ArrayFactory) Uint

func (af *ArrayFactory) Uint() (*Uint, error)

Uint makes a new array with element type `uint`.

func (*ArrayFactory) Uint16

func (af *ArrayFactory) Uint16() (*Uint16, error)

Uint16 makes a new array with element type `uint16`.

func (*ArrayFactory) Uint32

func (af *ArrayFactory) Uint32() (*Uint32, error)

Uint32 makes a new array with element type `uint32`.

func (*ArrayFactory) Uint64

func (af *ArrayFactory) Uint64() (*Uint64, error)

Uint64 makes a new array with element type `uint64`.

func (*ArrayFactory) Uint8

func (af *ArrayFactory) Uint8() (*Uint8, error)

Uint8 makes a new array with element type `uint8`.

func (*ArrayFactory) Uintptr

func (af *ArrayFactory) Uintptr() (*Uintptr, error)

Uintptr makes a new array with element type `uintptr`.

type Counter

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

Counter keeps track, in `digits`, of a counter/multi-index.

func (*Counter) Init

func (c *Counter) Init(dims, micf []int)

Init initialises a counter using a pointer to an array.

func (*Counter) Next

func (c *Counter) Next() []int

Next returns the next value of the counter.

func (*Counter) Previous

func (c *Counter) Previous() []int

Previous returns the previous value of the counter.

func (*Counter) Set

func (c *Counter) Set(k int)

Set sets the value of a counter using a linear index.

type Float32

type Float32 struct {
	Metadata
	Data []float32
}

Float32 is a concrete array type whose elements are of type `float32`. Float32 is defined by composition of `Metadata` and the slice `Data`.

func (*Float32) At

func (A *Float32) At(indices ...int) *float32

At returns a pointer to the k-th linearly indexed element of an `Array`. It is the most primitive way to access elements, without checking bounds or returning errors.

func (*Float32) Dir

func (A *Float32) Dir(out io.Writer)

Dir prints the attributes of an array. The name is inspired by pythons `dir`.

func (*Float32) Fill

func (A *Float32) Fill(val float32, numGoRout ...int)

Fill sets the value of every element of A equal to `val`. In cases where concurrency can be beneficial for speed, `Fill` should be faster than `FillSeq`. For really small arrays, not only `Fill` will not be faster than `FillSeq`, but actually slower; because for tiny arrays the overhead of concurrency (although minimal in Go) dominates the computation.

func (*Float32) FillSeq

func (A *Float32) FillSeq(val float32)

FillSeq sets the value of every element of A equal to `val`. This is a sequential implementation, hence the name. There will be a parallel one too.

func (*Float32) FromCSV

func (A *Float32) FromCSV(in io.Reader) (int, []int, []error, error)

FromCSV reads from a .csv source into an array.

  • Input -- in: a reader from which the csv-formated data can be read.
  • Output -- int: number of element read from the input -- []int: indices for which the parsing of an element failed (when reading csv data into an array, each field in the csv is a string that has be parsed into a numerical type; this is the parsing referref to). -- []error: parsing errors that occur during file reading -- error: nil if no errors occured, something hopefully informative otherwise.

func (*Float32) FromCSVFile

func (A *Float32) FromCSVFile(fpin string) (int, []int, []error, error)

FromCSVFile reads from a .csv source into an array. `FromCSVFile` is a wrapper around `FromCSV`; regarding the return values, see the documentation for the latter method. The input is the path to the .csv file to be read into the array `A`.

func (*Float32) Get

func (A *Float32) Get(indices ...int) float32

Get returns the value of a single element of an `Array`. Note that `A.Data[k]` can also be accessed directly.

func (*Float32) Map

func (A *Float32) Map(f func(float32) float32, numGoRout ...int)

Map applies the function `f` to every element of the array `A`.

func (*Float32) MapIndex

func (A *Float32) MapIndex(f func(int) float32, numGoRout ...int)

MapIndex applies the function `f` to the linear index of each element of the array `A`.

func (*Float32) MapIndexSeq

func (A *Float32) MapIndexSeq(f func(int) float32)

MapIndexSeq applies the function `f` to the linear index of each element of the array `A`.

func (*Float32) MapIndexVal

func (A *Float32) MapIndexVal(f func(int, float32) float32, numGoRout ...int)

MapIndexVal applies the function `f` to all pairs (x, y), where y := linear index of y in `A`. In other words, MapIndexVal is a map function that takes two arguments: the array element and its index.

func (*Float32) MapIndexValSeq

func (A *Float32) MapIndexValSeq(f func(int, float32) float32)

MapIndexValSeq applies the function `f` to all pairs (x, y), where y := linear index of y in `A`. In other words, MapIndexValSeq is a map function that takes two arguments: the array element and its index.

func (*Float32) MapSeq

func (A *Float32) MapSeq(f func(float32) float32)

MapSeq applies the function `f` to each element of the array `A`.

func (*Float32) Set

func (A *Float32) Set(val float32, indices ...int)

Set sets the value of a single element of an `Array`. Note that `A.Data[k]` can also be accessed directly.

func (*Float32) Slice

func (A *Float32) Slice(s string) (Slice, error)

Slice takes as input a string representation `s` of an array slice and returns a `Slice` (which is of type []Range which is the same as [][3]int) that represents the same information as the input string `s` but in numeric data structure conducive for computation. For example, if s == "[0:5:2]", then we are asking the function `Slice` to construct a `Slice` that starts at 0, stops at 4, and advances with step 2. The result, in this case, will be the `Slice` { {0, 5, 2} }. One advantage of using the function Slice over "manually" instantiating `Slice`s is the the former is slightly user-friendlier.The string representation allows for the usual liberal specification of a slice where some information can be ommitted. This is possible by accessing the metadata in the receiver of the method.

func (*Float32) String

func (A *Float32) String() string

String prints an Float32

func (*Float32) ToCSV

func (A *Float32) ToCSV(out io.Writer, printVerb ...string) error

ToCSV saves an array to a .csv file. It also saves a .json file with the same name containing the array metadata. out: io.Writer to write to.

func (*Float32) ToCSVFile

func (A *Float32) ToCSVFile(fpout string, printVerb ...string) error

ToCSV saves an array to a .csv file. It also saves a .json file with the same name containing the array metadata. fpout: the path of the output file

func (*Float32) View

func (A *Float32) View(slice Slice) (*ViewFloat32, error)

View returns a view into the array A.

type Float64

type Float64 struct {
	Metadata
	Data []float64
}

Float64 is a concrete array type whose elements are of type `float64`. Float64 is defined by composition of `Metadata` and the slice `Data`.

func (*Float64) At

func (A *Float64) At(indices ...int) *float64

At returns a pointer to the k-th linearly indexed element of an `Array`. It is the most primitive way to access elements, without checking bounds or returning errors.

func (*Float64) Dir

func (A *Float64) Dir(out io.Writer)

Dir prints the attributes of an array. The name is inspired by pythons `dir`.

func (*Float64) Fill

func (A *Float64) Fill(val float64, numGoRout ...int)

Fill sets the value of every element of A equal to `val`. In cases where concurrency can be beneficial for speed, `Fill` should be faster than `FillSeq`. For really small arrays, not only `Fill` will not be faster than `FillSeq`, but actually slower; because for tiny arrays the overhead of concurrency (although minimal in Go) dominates the computation.

func (*Float64) FillSeq

func (A *Float64) FillSeq(val float64)

FillSeq sets the value of every element of A equal to `val`. This is a sequential implementation, hence the name. There will be a parallel one too.

func (*Float64) FromCSV

func (A *Float64) FromCSV(in io.Reader) (int, []int, []error, error)

FromCSV reads from a .csv source into an array.

  • Input -- in: a reader from which the csv-formated data can be read.
  • Output -- int: number of element read from the input -- []int: indices for which the parsing of an element failed (when reading csv data into an array, each field in the csv is a string that has be parsed into a numerical type; this is the parsing referref to). -- []error: parsing errors that occur during file reading -- error: nil if no errors occured, something hopefully informative otherwise.

func (*Float64) FromCSVFile

func (A *Float64) FromCSVFile(fpin string) (int, []int, []error, error)

FromCSVFile reads from a .csv source into an array. `FromCSVFile` is a wrapper around `FromCSV`; regarding the return values, see the documentation for the latter method. The input is the path to the .csv file to be read into the array `A`.

func (*Float64) Get

func (A *Float64) Get(indices ...int) float64

Get returns the value of a single element of an `Array`. Note that `A.Data[k]` can also be accessed directly.

func (*Float64) Map

func (A *Float64) Map(f func(float64) float64, numGoRout ...int)

Map applies the function `f` to every element of the array `A`.

func (*Float64) MapIndex

func (A *Float64) MapIndex(f func(int) float64, numGoRout ...int)

MapIndex applies the function `f` to the linear index of each element of the array `A`.

func (*Float64) MapIndexSeq

func (A *Float64) MapIndexSeq(f func(int) float64)

MapIndexSeq applies the function `f` to the linear index of each element of the array `A`.

func (*Float64) MapIndexVal

func (A *Float64) MapIndexVal(f func(int, float64) float64, numGoRout ...int)

MapIndexVal applies the function `f` to all pairs (x, y), where y := linear index of y in `A`. In other words, MapIndexVal is a map function that takes two arguments: the array element and its index.

func (*Float64) MapIndexValSeq

func (A *Float64) MapIndexValSeq(f func(int, float64) float64)

MapIndexValSeq applies the function `f` to all pairs (x, y), where y := linear index of y in `A`. In other words, MapIndexValSeq is a map function that takes two arguments: the array element and its index.

func (*Float64) MapSeq

func (A *Float64) MapSeq(f func(float64) float64)

MapSeq applies the function `f` to each element of the array `A`.

func (*Float64) Set

func (A *Float64) Set(val float64, indices ...int)

Set sets the value of a single element of an `Array`. Note that `A.Data[k]` can also be accessed directly.

func (*Float64) Slice

func (A *Float64) Slice(s string) (Slice, error)

Slice takes as input a string representation `s` of an array slice and returns a `Slice` (which is of type []Range which is the same as [][3]int) that represents the same information as the input string `s` but in numeric data structure conducive for computation. For example, if s == "[0:5:2]", then we are asking the function `Slice` to construct a `Slice` that starts at 0, stops at 4, and advances with step 2. The result, in this case, will be the `Slice` { {0, 5, 2} }. One advantage of using the function Slice over "manually" instantiating `Slice`s is the the former is slightly user-friendlier.The string representation allows for the usual liberal specification of a slice where some information can be ommitted. This is possible by accessing the metadata in the receiver of the method.

func (*Float64) String

func (A *Float64) String() string

String prints an Float64

func (*Float64) ToCSV

func (A *Float64) ToCSV(out io.Writer, printVerb ...string) error

ToCSV saves an array to a .csv file. It also saves a .json file with the same name containing the array metadata. out: io.Writer to write to.

func (*Float64) ToCSVFile

func (A *Float64) ToCSVFile(fpout string, printVerb ...string) error

ToCSV saves an array to a .csv file. It also saves a .json file with the same name containing the array metadata. fpout: the path of the output file

func (*Float64) View

func (A *Float64) View(slice Slice) (*ViewFloat64, error)

View returns a view into the array A.

type Int

type Int struct {
	Metadata
	Data []int
}

Int is a concrete array type whose elements are of type `int`. Int is defined by composition of `Metadata` and the slice `Data`.

func (*Int) At

func (A *Int) At(indices ...int) *int

At returns a pointer to the k-th linearly indexed element of an `Array`. It is the most primitive way to access elements, without checking bounds or returning errors.

func (*Int) Dir

func (A *Int) Dir(out io.Writer)

Dir prints the attributes of an array. The name is inspired by pythons `dir`.

func (*Int) Fill

func (A *Int) Fill(val int, numGoRout ...int)

Fill sets the value of every element of A equal to `val`. In cases where concurrency can be beneficial for speed, `Fill` should be faster than `FillSeq`. For really small arrays, not only `Fill` will not be faster than `FillSeq`, but actually slower; because for tiny arrays the overhead of concurrency (although minimal in Go) dominates the computation.

func (*Int) FillSeq

func (A *Int) FillSeq(val int)

FillSeq sets the value of every element of A equal to `val`. This is a sequential implementation, hence the name. There will be a parallel one too.

func (*Int) FromCSV

func (A *Int) FromCSV(in io.Reader) (int, []int, []error, error)

FromCSV reads from a .csv source into an array.

  • Input -- in: a reader from which the csv-formated data can be read.
  • Output -- int: number of element read from the input -- []int: indices for which the parsing of an element failed (when reading csv data into an array, each field in the csv is a string that has be parsed into a numerical type; this is the parsing referref to). -- []error: parsing errors that occur during file reading -- error: nil if no errors occured, something hopefully informative otherwise.

func (*Int) FromCSVFile

func (A *Int) FromCSVFile(fpin string) (int, []int, []error, error)

FromCSVFile reads from a .csv source into an array. `FromCSVFile` is a wrapper around `FromCSV`; regarding the return values, see the documentation for the latter method. The input is the path to the .csv file to be read into the array `A`.

func (*Int) Get

func (A *Int) Get(indices ...int) int

Get returns the value of a single element of an `Array`. Note that `A.Data[k]` can also be accessed directly.

func (*Int) Map

func (A *Int) Map(f func(int) int, numGoRout ...int)

Map applies the function `f` to every element of the array `A`.

func (*Int) MapIndex

func (A *Int) MapIndex(f func(int) int, numGoRout ...int)

MapIndex applies the function `f` to the linear index of each element of the array `A`.

func (*Int) MapIndexSeq

func (A *Int) MapIndexSeq(f func(int) int)

MapIndexSeq applies the function `f` to the linear index of each element of the array `A`.

func (*Int) MapIndexVal

func (A *Int) MapIndexVal(f func(int, int) int, numGoRout ...int)

MapIndexVal applies the function `f` to all pairs (x, y), where y := linear index of y in `A`. In other words, MapIndexVal is a map function that takes two arguments: the array element and its index.

func (*Int) MapIndexValSeq

func (A *Int) MapIndexValSeq(f func(int, int) int)

MapIndexValSeq applies the function `f` to all pairs (x, y), where y := linear index of y in `A`. In other words, MapIndexValSeq is a map function that takes two arguments: the array element and its index.

func (*Int) MapSeq

func (A *Int) MapSeq(f func(int) int)

MapSeq applies the function `f` to each element of the array `A`.

func (*Int) Set

func (A *Int) Set(val int, indices ...int)

Set sets the value of a single element of an `Array`. Note that `A.Data[k]` can also be accessed directly.

func (*Int) Slice

func (A *Int) Slice(s string) (Slice, error)

Slice takes as input a string representation `s` of an array slice and returns a `Slice` (which is of type []Range which is the same as [][3]int) that represents the same information as the input string `s` but in numeric data structure conducive for computation. For example, if s == "[0:5:2]", then we are asking the function `Slice` to construct a `Slice` that starts at 0, stops at 4, and advances with step 2. The result, in this case, will be the `Slice` { {0, 5, 2} }. One advantage of using the function Slice over "manually" instantiating `Slice`s is the the former is slightly user-friendlier.The string representation allows for the usual liberal specification of a slice where some information can be ommitted. This is possible by accessing the metadata in the receiver of the method.

func (*Int) String

func (A *Int) String() string

String prints an Int

func (*Int) ToCSV

func (A *Int) ToCSV(out io.Writer, printVerb ...string) error

ToCSV saves an array to a .csv file. It also saves a .json file with the same name containing the array metadata. out: io.Writer to write to.

func (*Int) ToCSVFile

func (A *Int) ToCSVFile(fpout string, printVerb ...string) error

ToCSV saves an array to a .csv file. It also saves a .json file with the same name containing the array metadata. fpout: the path of the output file

func (*Int) View

func (A *Int) View(slice Slice) (*ViewInt, error)

View returns a view into the array A.

type Int16

type Int16 struct {
	Metadata
	Data []int16
}

Int16 is a concrete array type whose elements are of type `int16`. Int16 is defined by composition of `Metadata` and the slice `Data`.

func (*Int16) At

func (A *Int16) At(indices ...int) *int16

At returns a pointer to the k-th linearly indexed element of an `Array`. It is the most primitive way to access elements, without checking bounds or returning errors.

func (*Int16) Dir

func (A *Int16) Dir(out io.Writer)

Dir prints the attributes of an array. The name is inspired by pythons `dir`.

func (*Int16) Fill

func (A *Int16) Fill(val int16, numGoRout ...int)

Fill sets the value of every element of A equal to `val`. In cases where concurrency can be beneficial for speed, `Fill` should be faster than `FillSeq`. For really small arrays, not only `Fill` will not be faster than `FillSeq`, but actually slower; because for tiny arrays the overhead of concurrency (although minimal in Go) dominates the computation.

func (*Int16) FillSeq

func (A *Int16) FillSeq(val int16)

FillSeq sets the value of every element of A equal to `val`. This is a sequential implementation, hence the name. There will be a parallel one too.

func (*Int16) FromCSV

func (A *Int16) FromCSV(in io.Reader) (int, []int, []error, error)

FromCSV reads from a .csv source into an array.

  • Input -- in: a reader from which the csv-formated data can be read.
  • Output -- int: number of element read from the input -- []int: indices for which the parsing of an element failed (when reading csv data into an array, each field in the csv is a string that has be parsed into a numerical type; this is the parsing referref to). -- []error: parsing errors that occur during file reading -- error: nil if no errors occured, something hopefully informative otherwise.

func (*Int16) FromCSVFile

func (A *Int16) FromCSVFile(fpin string) (int, []int, []error, error)

FromCSVFile reads from a .csv source into an array. `FromCSVFile` is a wrapper around `FromCSV`; regarding the return values, see the documentation for the latter method. The input is the path to the .csv file to be read into the array `A`.

func (*Int16) Get

func (A *Int16) Get(indices ...int) int16

Get returns the value of a single element of an `Array`. Note that `A.Data[k]` can also be accessed directly.

func (*Int16) Map

func (A *Int16) Map(f func(int16) int16, numGoRout ...int)

Map applies the function `f` to every element of the array `A`.

func (*Int16) MapIndex

func (A *Int16) MapIndex(f func(int) int16, numGoRout ...int)

MapIndex applies the function `f` to the linear index of each element of the array `A`.

func (*Int16) MapIndexSeq

func (A *Int16) MapIndexSeq(f func(int) int16)

MapIndexSeq applies the function `f` to the linear index of each element of the array `A`.

func (*Int16) MapIndexVal

func (A *Int16) MapIndexVal(f func(int, int16) int16, numGoRout ...int)

MapIndexVal applies the function `f` to all pairs (x, y), where y := linear index of y in `A`. In other words, MapIndexVal is a map function that takes two arguments: the array element and its index.

func (*Int16) MapIndexValSeq

func (A *Int16) MapIndexValSeq(f func(int, int16) int16)

MapIndexValSeq applies the function `f` to all pairs (x, y), where y := linear index of y in `A`. In other words, MapIndexValSeq is a map function that takes two arguments: the array element and its index.

func (*Int16) MapSeq

func (A *Int16) MapSeq(f func(int16) int16)

MapSeq applies the function `f` to each element of the array `A`.

func (*Int16) Set

func (A *Int16) Set(val int16, indices ...int)

Set sets the value of a single element of an `Array`. Note that `A.Data[k]` can also be accessed directly.

func (*Int16) Slice

func (A *Int16) Slice(s string) (Slice, error)

Slice takes as input a string representation `s` of an array slice and returns a `Slice` (which is of type []Range which is the same as [][3]int) that represents the same information as the input string `s` but in numeric data structure conducive for computation. For example, if s == "[0:5:2]", then we are asking the function `Slice` to construct a `Slice` that starts at 0, stops at 4, and advances with step 2. The result, in this case, will be the `Slice` { {0, 5, 2} }. One advantage of using the function Slice over "manually" instantiating `Slice`s is the the former is slightly user-friendlier.The string representation allows for the usual liberal specification of a slice where some information can be ommitted. This is possible by accessing the metadata in the receiver of the method.

func (*Int16) String

func (A *Int16) String() string

String prints an Int16

func (*Int16) ToCSV

func (A *Int16) ToCSV(out io.Writer, printVerb ...string) error

ToCSV saves an array to a .csv file. It also saves a .json file with the same name containing the array metadata. out: io.Writer to write to.

func (*Int16) ToCSVFile

func (A *Int16) ToCSVFile(fpout string, printVerb ...string) error

ToCSV saves an array to a .csv file. It also saves a .json file with the same name containing the array metadata. fpout: the path of the output file

func (*Int16) View

func (A *Int16) View(slice Slice) (*ViewInt16, error)

View returns a view into the array A.

type Int32

type Int32 struct {
	Metadata
	Data []int32
}

Int32 is a concrete array type whose elements are of type `int32`. Int32 is defined by composition of `Metadata` and the slice `Data`.

func (*Int32) At

func (A *Int32) At(indices ...int) *int32

At returns a pointer to the k-th linearly indexed element of an `Array`. It is the most primitive way to access elements, without checking bounds or returning errors.

func (*Int32) Dir

func (A *Int32) Dir(out io.Writer)

Dir prints the attributes of an array. The name is inspired by pythons `dir`.

func (*Int32) Fill

func (A *Int32) Fill(val int32, numGoRout ...int)

Fill sets the value of every element of A equal to `val`. In cases where concurrency can be beneficial for speed, `Fill` should be faster than `FillSeq`. For really small arrays, not only `Fill` will not be faster than `FillSeq`, but actually slower; because for tiny arrays the overhead of concurrency (although minimal in Go) dominates the computation.

func (*Int32) FillSeq

func (A *Int32) FillSeq(val int32)

FillSeq sets the value of every element of A equal to `val`. This is a sequential implementation, hence the name. There will be a parallel one too.

func (*Int32) FromCSV

func (A *Int32) FromCSV(in io.Reader) (int, []int, []error, error)

FromCSV reads from a .csv source into an array.

  • Input -- in: a reader from which the csv-formated data can be read.
  • Output -- int: number of element read from the input -- []int: indices for which the parsing of an element failed (when reading csv data into an array, each field in the csv is a string that has be parsed into a numerical type; this is the parsing referref to). -- []error: parsing errors that occur during file reading -- error: nil if no errors occured, something hopefully informative otherwise.

func (*Int32) FromCSVFile

func (A *Int32) FromCSVFile(fpin string) (int, []int, []error, error)

FromCSVFile reads from a .csv source into an array. `FromCSVFile` is a wrapper around `FromCSV`; regarding the return values, see the documentation for the latter method. The input is the path to the .csv file to be read into the array `A`.

func (*Int32) Get

func (A *Int32) Get(indices ...int) int32

Get returns the value of a single element of an `Array`. Note that `A.Data[k]` can also be accessed directly.

func (*Int32) Map

func (A *Int32) Map(f func(int32) int32, numGoRout ...int)

Map applies the function `f` to every element of the array `A`.

func (*Int32) MapIndex

func (A *Int32) MapIndex(f func(int) int32, numGoRout ...int)

MapIndex applies the function `f` to the linear index of each element of the array `A`.

func (*Int32) MapIndexSeq

func (A *Int32) MapIndexSeq(f func(int) int32)

MapIndexSeq applies the function `f` to the linear index of each element of the array `A`.

func (*Int32) MapIndexVal

func (A *Int32) MapIndexVal(f func(int, int32) int32, numGoRout ...int)

MapIndexVal applies the function `f` to all pairs (x, y), where y := linear index of y in `A`. In other words, MapIndexVal is a map function that takes two arguments: the array element and its index.

func (*Int32) MapIndexValSeq

func (A *Int32) MapIndexValSeq(f func(int, int32) int32)

MapIndexValSeq applies the function `f` to all pairs (x, y), where y := linear index of y in `A`. In other words, MapIndexValSeq is a map function that takes two arguments: the array element and its index.

func (*Int32) MapSeq

func (A *Int32) MapSeq(f func(int32) int32)

MapSeq applies the function `f` to each element of the array `A`.

func (*Int32) Set

func (A *Int32) Set(val int32, indices ...int)

Set sets the value of a single element of an `Array`. Note that `A.Data[k]` can also be accessed directly.

func (*Int32) Slice

func (A *Int32) Slice(s string) (Slice, error)

Slice takes as input a string representation `s` of an array slice and returns a `Slice` (which is of type []Range which is the same as [][3]int) that represents the same information as the input string `s` but in numeric data structure conducive for computation. For example, if s == "[0:5:2]", then we are asking the function `Slice` to construct a `Slice` that starts at 0, stops at 4, and advances with step 2. The result, in this case, will be the `Slice` { {0, 5, 2} }. One advantage of using the function Slice over "manually" instantiating `Slice`s is the the former is slightly user-friendlier.The string representation allows for the usual liberal specification of a slice where some information can be ommitted. This is possible by accessing the metadata in the receiver of the method.

func (*Int32) String

func (A *Int32) String() string

String prints an Int32

func (*Int32) ToCSV

func (A *Int32) ToCSV(out io.Writer, printVerb ...string) error

ToCSV saves an array to a .csv file. It also saves a .json file with the same name containing the array metadata. out: io.Writer to write to.

func (*Int32) ToCSVFile

func (A *Int32) ToCSVFile(fpout string, printVerb ...string) error

ToCSV saves an array to a .csv file. It also saves a .json file with the same name containing the array metadata. fpout: the path of the output file

func (*Int32) View

func (A *Int32) View(slice Slice) (*ViewInt32, error)

View returns a view into the array A.

type Int64

type Int64 struct {
	Metadata
	Data []int64
}

Int64 is a concrete array type whose elements are of type `int64`. Int64 is defined by composition of `Metadata` and the slice `Data`.

func (*Int64) At

func (A *Int64) At(indices ...int) *int64

At returns a pointer to the k-th linearly indexed element of an `Array`. It is the most primitive way to access elements, without checking bounds or returning errors.

func (*Int64) Dir

func (A *Int64) Dir(out io.Writer)

Dir prints the attributes of an array. The name is inspired by pythons `dir`.

func (*Int64) Fill

func (A *Int64) Fill(val int64, numGoRout ...int)

Fill sets the value of every element of A equal to `val`. In cases where concurrency can be beneficial for speed, `Fill` should be faster than `FillSeq`. For really small arrays, not only `Fill` will not be faster than `FillSeq`, but actually slower; because for tiny arrays the overhead of concurrency (although minimal in Go) dominates the computation.

func (*Int64) FillSeq

func (A *Int64) FillSeq(val int64)

FillSeq sets the value of every element of A equal to `val`. This is a sequential implementation, hence the name. There will be a parallel one too.

func (*Int64) FromCSV

func (A *Int64) FromCSV(in io.Reader) (int, []int, []error, error)

FromCSV reads from a .csv source into an array.

  • Input -- in: a reader from which the csv-formated data can be read.
  • Output -- int: number of element read from the input -- []int: indices for which the parsing of an element failed (when reading csv data into an array, each field in the csv is a string that has be parsed into a numerical type; this is the parsing referref to). -- []error: parsing errors that occur during file reading -- error: nil if no errors occured, something hopefully informative otherwise.

func (*Int64) FromCSVFile

func (A *Int64) FromCSVFile(fpin string) (int, []int, []error, error)

FromCSVFile reads from a .csv source into an array. `FromCSVFile` is a wrapper around `FromCSV`; regarding the return values, see the documentation for the latter method. The input is the path to the .csv file to be read into the array `A`.

func (*Int64) Get

func (A *Int64) Get(indices ...int) int64

Get returns the value of a single element of an `Array`. Note that `A.Data[k]` can also be accessed directly.

func (*Int64) Map

func (A *Int64) Map(f func(int64) int64, numGoRout ...int)

Map applies the function `f` to every element of the array `A`.

func (*Int64) MapIndex

func (A *Int64) MapIndex(f func(int) int64, numGoRout ...int)

MapIndex applies the function `f` to the linear index of each element of the array `A`.

func (*Int64) MapIndexSeq

func (A *Int64) MapIndexSeq(f func(int) int64)

MapIndexSeq applies the function `f` to the linear index of each element of the array `A`.

func (*Int64) MapIndexVal

func (A *Int64) MapIndexVal(f func(int, int64) int64, numGoRout ...int)

MapIndexVal applies the function `f` to all pairs (x, y), where y := linear index of y in `A`. In other words, MapIndexVal is a map function that takes two arguments: the array element and its index.

func (*Int64) MapIndexValSeq

func (A *Int64) MapIndexValSeq(f func(int, int64) int64)

MapIndexValSeq applies the function `f` to all pairs (x, y), where y := linear index of y in `A`. In other words, MapIndexValSeq is a map function that takes two arguments: the array element and its index.

func (*Int64) MapSeq

func (A *Int64) MapSeq(f func(int64) int64)

MapSeq applies the function `f` to each element of the array `A`.

func (*Int64) Set

func (A *Int64) Set(val int64, indices ...int)

Set sets the value of a single element of an `Array`. Note that `A.Data[k]` can also be accessed directly.

func (*Int64) Slice

func (A *Int64) Slice(s string) (Slice, error)

Slice takes as input a string representation `s` of an array slice and returns a `Slice` (which is of type []Range which is the same as [][3]int) that represents the same information as the input string `s` but in numeric data structure conducive for computation. For example, if s == "[0:5:2]", then we are asking the function `Slice` to construct a `Slice` that starts at 0, stops at 4, and advances with step 2. The result, in this case, will be the `Slice` { {0, 5, 2} }. One advantage of using the function Slice over "manually" instantiating `Slice`s is the the former is slightly user-friendlier.The string representation allows for the usual liberal specification of a slice where some information can be ommitted. This is possible by accessing the metadata in the receiver of the method.

func (*Int64) String

func (A *Int64) String() string

String prints an Int64

func (*Int64) ToCSV

func (A *Int64) ToCSV(out io.Writer, printVerb ...string) error

ToCSV saves an array to a .csv file. It also saves a .json file with the same name containing the array metadata. out: io.Writer to write to.

func (*Int64) ToCSVFile

func (A *Int64) ToCSVFile(fpout string, printVerb ...string) error

ToCSV saves an array to a .csv file. It also saves a .json file with the same name containing the array metadata. fpout: the path of the output file

func (*Int64) View

func (A *Int64) View(slice Slice) (*ViewInt64, error)

View returns a view into the array A.

type Int8

type Int8 struct {
	Metadata
	Data []int8
}

Int8 is a concrete array type whose elements are of type `int8`. Int8 is defined by composition of `Metadata` and the slice `Data`.

func (*Int8) At

func (A *Int8) At(indices ...int) *int8

At returns a pointer to the k-th linearly indexed element of an `Array`. It is the most primitive way to access elements, without checking bounds or returning errors.

func (*Int8) Dir

func (A *Int8) Dir(out io.Writer)

Dir prints the attributes of an array. The name is inspired by pythons `dir`.

func (*Int8) Fill

func (A *Int8) Fill(val int8, numGoRout ...int)

Fill sets the value of every element of A equal to `val`. In cases where concurrency can be beneficial for speed, `Fill` should be faster than `FillSeq`. For really small arrays, not only `Fill` will not be faster than `FillSeq`, but actually slower; because for tiny arrays the overhead of concurrency (although minimal in Go) dominates the computation.

func (*Int8) FillSeq

func (A *Int8) FillSeq(val int8)

FillSeq sets the value of every element of A equal to `val`. This is a sequential implementation, hence the name. There will be a parallel one too.

func (*Int8) FromCSV

func (A *Int8) FromCSV(in io.Reader) (int, []int, []error, error)

FromCSV reads from a .csv source into an array.

  • Input -- in: a reader from which the csv-formated data can be read.
  • Output -- int: number of element read from the input -- []int: indices for which the parsing of an element failed (when reading csv data into an array, each field in the csv is a string that has be parsed into a numerical type; this is the parsing referref to). -- []error: parsing errors that occur during file reading -- error: nil if no errors occured, something hopefully informative otherwise.

func (*Int8) FromCSVFile

func (A *Int8) FromCSVFile(fpin string) (int, []int, []error, error)

FromCSVFile reads from a .csv source into an array. `FromCSVFile` is a wrapper around `FromCSV`; regarding the return values, see the documentation for the latter method. The input is the path to the .csv file to be read into the array `A`.

func (*Int8) Get

func (A *Int8) Get(indices ...int) int8

Get returns the value of a single element of an `Array`. Note that `A.Data[k]` can also be accessed directly.

func (*Int8) Map

func (A *Int8) Map(f func(int8) int8, numGoRout ...int)

Map applies the function `f` to every element of the array `A`.

func (*Int8) MapIndex

func (A *Int8) MapIndex(f func(int) int8, numGoRout ...int)

MapIndex applies the function `f` to the linear index of each element of the array `A`.

func (*Int8) MapIndexSeq

func (A *Int8) MapIndexSeq(f func(int) int8)

MapIndexSeq applies the function `f` to the linear index of each element of the array `A`.

func (*Int8) MapIndexVal

func (A *Int8) MapIndexVal(f func(int, int8) int8, numGoRout ...int)

MapIndexVal applies the function `f` to all pairs (x, y), where y := linear index of y in `A`. In other words, MapIndexVal is a map function that takes two arguments: the array element and its index.

func (*Int8) MapIndexValSeq

func (A *Int8) MapIndexValSeq(f func(int, int8) int8)

MapIndexValSeq applies the function `f` to all pairs (x, y), where y := linear index of y in `A`. In other words, MapIndexValSeq is a map function that takes two arguments: the array element and its index.

func (*Int8) MapSeq

func (A *Int8) MapSeq(f func(int8) int8)

MapSeq applies the function `f` to each element of the array `A`.

func (*Int8) Set

func (A *Int8) Set(val int8, indices ...int)

Set sets the value of a single element of an `Array`. Note that `A.Data[k]` can also be accessed directly.

func (*Int8) Slice

func (A *Int8) Slice(s string) (Slice, error)

Slice takes as input a string representation `s` of an array slice and returns a `Slice` (which is of type []Range which is the same as [][3]int) that represents the same information as the input string `s` but in numeric data structure conducive for computation. For example, if s == "[0:5:2]", then we are asking the function `Slice` to construct a `Slice` that starts at 0, stops at 4, and advances with step 2. The result, in this case, will be the `Slice` { {0, 5, 2} }. One advantage of using the function Slice over "manually" instantiating `Slice`s is the the former is slightly user-friendlier.The string representation allows for the usual liberal specification of a slice where some information can be ommitted. This is possible by accessing the metadata in the receiver of the method.

func (*Int8) String

func (A *Int8) String() string

String prints an Int8

func (*Int8) ToCSV

func (A *Int8) ToCSV(out io.Writer, printVerb ...string) error

ToCSV saves an array to a .csv file. It also saves a .json file with the same name containing the array metadata. out: io.Writer to write to.

func (*Int8) ToCSVFile

func (A *Int8) ToCSVFile(fpout string, printVerb ...string) error

ToCSV saves an array to a .csv file. It also saves a .json file with the same name containing the array metadata. fpout: the path of the output file

func (*Int8) View

func (A *Int8) View(slice Slice) (*ViewInt8, error)

View returns a view into the array A.

type Metadata

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

Metadata contains information that must accompany an array, but not the actual data stored in the array. Each concrete array type (in `cat.go`) has a `Metadata` member.

func (*Metadata) Dims

func (A *Metadata) Dims() []int

Dims returns the dimensions of an array.

func (*Metadata) Micf

func (A *Metadata) Micf() []int

Micf returns the multi-index conversion factors of an array.

func (*Metadata) Ndims

func (A *Metadata) Ndims() int

Ndims returns the number of dimensions of an array.

func (*Metadata) Numels

func (A *Metadata) Numels() int

Numels returns the number of elements of an array.

type Range

type Range [3]int

Range represents a range of integers with a stride/step in the form [start, stop, step].

func MakeRange

func MakeRange(start, stop, step int) (Range, error)

MakeRange constructs a `Range` object from 3 integers that represent the start, stop, and step of a range. Of course, since a `Range` is simply an array of type [3]int, it can be constructed directly (e.g., range := Range{1, 2, 1}); however, not every combination of values for start, stop, and step is logically valid and the function `MakeRange` checks the validity of the inputs. "Logically valid" has a meaning in a given context of rules and definitions. The latter are implicit in `MakeRange`'s logic. For example, `start` is not allowed to be larger than `stop`, but, alternatively, `start > stop` could have been allowed to signify an empty range.

func (*Range) Get

func (r *Range) Get(k int) int

Get returns the k-th element of a range.

func (*Range) Numels

func (r *Range) Numels() (int, error)

Numels returns the number of elements in a Range. A range with zero step is considered ill-formed, however `Numels` will still attempt to calculate the number of elements in the range and return an error with the result.

func (*Range) Start

func (r *Range) Start() int

Start returns the start/beginning of the range.

func (*Range) Step

func (r *Range) Step() int

Step returns the step/stride of the range.

func (*Range) Stop

func (r *Range) Stop() int

Stop returns the stop/end of the range.

type Slice

type Slice []Range

Slice is an array slice used for, well, array slicing.

func MakeSlice

func MakeSlice(s string, dims []int) (Slice, error)

MakeSlice creates a slice that can be used to slice an array. The input is a string representation of the slice to be created. To keep the code simple for now, an "optimistic" approach is taken where the return value is completely constructed and only then validated. Obviously, the construction of the results could terminate early if checking for logical conrrectness is interleaved with the construction steps. `MakeSlice` takes the output of `MakeSliceCore` and checks the indices against the dimensions of the array. No negative indices allowed.

func MakeSliceClip

func MakeSliceClip(s string, dims []int) (Slice, error)

MakeSliceClip takes the result of `MakeSliceCore` and truncates the indices that exceed the dimensions of the array.

func MakeSliceCore

func MakeSliceCore(slice string, dims []int) (Slice, error)

MakeSliceCore constructs a `Slice` without checking the results against array dimensions or doing any other post-processing.

func MakeSliceWrap

func MakeSliceWrap(s string, dims []int) (Slice, error)

MakeSliceWrap takes the result of `MakeSliceCore` and wraps around indices that exceed the dimensions of the array.

func (*Slice) Start

func (s *Slice) Start() []int

Start returns the starting index of each sub-slice in the slice `s`

func (*Slice) Step

func (s *Slice) Step() []int

Step returns the step size of each sub-slice in the slice `s`

func (*Slice) Stop

func (s *Slice) Stop() []int

Stop returns the last index of each sub-slice in the slice `s`

type Uint

type Uint struct {
	Metadata
	Data []uint
}

Uint is a concrete array type whose elements are of type `uint`. Uint is defined by composition of `Metadata` and the slice `Data`.

func (*Uint) At

func (A *Uint) At(indices ...int) *uint

At returns a pointer to the k-th linearly indexed element of an `Array`. It is the most primitive way to access elements, without checking bounds or returning errors.

func (*Uint) Dir

func (A *Uint) Dir(out io.Writer)

Dir prints the attributes of an array. The name is inspired by pythons `dir`.

func (*Uint) Fill

func (A *Uint) Fill(val uint, numGoRout ...int)

Fill sets the value of every element of A equal to `val`. In cases where concurrency can be beneficial for speed, `Fill` should be faster than `FillSeq`. For really small arrays, not only `Fill` will not be faster than `FillSeq`, but actually slower; because for tiny arrays the overhead of concurrency (although minimal in Go) dominates the computation.

func (*Uint) FillSeq

func (A *Uint) FillSeq(val uint)

FillSeq sets the value of every element of A equal to `val`. This is a sequential implementation, hence the name. There will be a parallel one too.

func (*Uint) FromCSV

func (A *Uint) FromCSV(in io.Reader) (int, []int, []error, error)

FromCSV reads from a .csv source into an array.

  • Input -- in: a reader from which the csv-formated data can be read.
  • Output -- int: number of element read from the input -- []int: indices for which the parsing of an element failed (when reading csv data into an array, each field in the csv is a string that has be parsed into a numerical type; this is the parsing referref to). -- []error: parsing errors that occur during file reading -- error: nil if no errors occured, something hopefully informative otherwise.

func (*Uint) FromCSVFile

func (A *Uint) FromCSVFile(fpin string) (int, []int, []error, error)

FromCSVFile reads from a .csv source into an array. `FromCSVFile` is a wrapper around `FromCSV`; regarding the return values, see the documentation for the latter method. The input is the path to the .csv file to be read into the array `A`.

func (*Uint) Get

func (A *Uint) Get(indices ...int) uint

Get returns the value of a single element of an `Array`. Note that `A.Data[k]` can also be accessed directly.

func (*Uint) Map

func (A *Uint) Map(f func(uint) uint, numGoRout ...int)

Map applies the function `f` to every element of the array `A`.

func (*Uint) MapIndex

func (A *Uint) MapIndex(f func(int) uint, numGoRout ...int)

MapIndex applies the function `f` to the linear index of each element of the array `A`.

func (*Uint) MapIndexSeq

func (A *Uint) MapIndexSeq(f func(int) uint)

MapIndexSeq applies the function `f` to the linear index of each element of the array `A`.

func (*Uint) MapIndexVal

func (A *Uint) MapIndexVal(f func(int, uint) uint, numGoRout ...int)

MapIndexVal applies the function `f` to all pairs (x, y), where y := linear index of y in `A`. In other words, MapIndexVal is a map function that takes two arguments: the array element and its index.

func (*Uint) MapIndexValSeq

func (A *Uint) MapIndexValSeq(f func(int, uint) uint)

MapIndexValSeq applies the function `f` to all pairs (x, y), where y := linear index of y in `A`. In other words, MapIndexValSeq is a map function that takes two arguments: the array element and its index.

func (*Uint) MapSeq

func (A *Uint) MapSeq(f func(uint) uint)

MapSeq applies the function `f` to each element of the array `A`.

func (*Uint) Set

func (A *Uint) Set(val uint, indices ...int)

Set sets the value of a single element of an `Array`. Note that `A.Data[k]` can also be accessed directly.

func (*Uint) Slice

func (A *Uint) Slice(s string) (Slice, error)

Slice takes as input a string representation `s` of an array slice and returns a `Slice` (which is of type []Range which is the same as [][3]int) that represents the same information as the input string `s` but in numeric data structure conducive for computation. For example, if s == "[0:5:2]", then we are asking the function `Slice` to construct a `Slice` that starts at 0, stops at 4, and advances with step 2. The result, in this case, will be the `Slice` { {0, 5, 2} }. One advantage of using the function Slice over "manually" instantiating `Slice`s is the the former is slightly user-friendlier.The string representation allows for the usual liberal specification of a slice where some information can be ommitted. This is possible by accessing the metadata in the receiver of the method.

func (*Uint) String

func (A *Uint) String() string

String prints an Uint

func (*Uint) ToCSV

func (A *Uint) ToCSV(out io.Writer, printVerb ...string) error

ToCSV saves an array to a .csv file. It also saves a .json file with the same name containing the array metadata. out: io.Writer to write to.

func (*Uint) ToCSVFile

func (A *Uint) ToCSVFile(fpout string, printVerb ...string) error

ToCSV saves an array to a .csv file. It also saves a .json file with the same name containing the array metadata. fpout: the path of the output file

func (*Uint) View

func (A *Uint) View(slice Slice) (*ViewUint, error)

View returns a view into the array A.

type Uint16

type Uint16 struct {
	Metadata
	Data []uint16
}

Uint16 is a concrete array type whose elements are of type `uint16`. Uint16 is defined by composition of `Metadata` and the slice `Data`.

func (*Uint16) At

func (A *Uint16) At(indices ...int) *uint16

At returns a pointer to the k-th linearly indexed element of an `Array`. It is the most primitive way to access elements, without checking bounds or returning errors.

func (*Uint16) Dir

func (A *Uint16) Dir(out io.Writer)

Dir prints the attributes of an array. The name is inspired by pythons `dir`.

func (*Uint16) Fill

func (A *Uint16) Fill(val uint16, numGoRout ...int)

Fill sets the value of every element of A equal to `val`. In cases where concurrency can be beneficial for speed, `Fill` should be faster than `FillSeq`. For really small arrays, not only `Fill` will not be faster than `FillSeq`, but actually slower; because for tiny arrays the overhead of concurrency (although minimal in Go) dominates the computation.

func (*Uint16) FillSeq

func (A *Uint16) FillSeq(val uint16)

FillSeq sets the value of every element of A equal to `val`. This is a sequential implementation, hence the name. There will be a parallel one too.

func (*Uint16) FromCSV

func (A *Uint16) FromCSV(in io.Reader) (int, []int, []error, error)

FromCSV reads from a .csv source into an array.

  • Input -- in: a reader from which the csv-formated data can be read.
  • Output -- int: number of element read from the input -- []int: indices for which the parsing of an element failed (when reading csv data into an array, each field in the csv is a string that has be parsed into a numerical type; this is the parsing referref to). -- []error: parsing errors that occur during file reading -- error: nil if no errors occured, something hopefully informative otherwise.

func (*Uint16) FromCSVFile

func (A *Uint16) FromCSVFile(fpin string) (int, []int, []error, error)

FromCSVFile reads from a .csv source into an array. `FromCSVFile` is a wrapper around `FromCSV`; regarding the return values, see the documentation for the latter method. The input is the path to the .csv file to be read into the array `A`.

func (*Uint16) Get

func (A *Uint16) Get(indices ...int) uint16

Get returns the value of a single element of an `Array`. Note that `A.Data[k]` can also be accessed directly.

func (*Uint16) Map

func (A *Uint16) Map(f func(uint16) uint16, numGoRout ...int)

Map applies the function `f` to every element of the array `A`.

func (*Uint16) MapIndex

func (A *Uint16) MapIndex(f func(int) uint16, numGoRout ...int)

MapIndex applies the function `f` to the linear index of each element of the array `A`.

func (*Uint16) MapIndexSeq

func (A *Uint16) MapIndexSeq(f func(int) uint16)

MapIndexSeq applies the function `f` to the linear index of each element of the array `A`.

func (*Uint16) MapIndexVal

func (A *Uint16) MapIndexVal(f func(int, uint16) uint16, numGoRout ...int)

MapIndexVal applies the function `f` to all pairs (x, y), where y := linear index of y in `A`. In other words, MapIndexVal is a map function that takes two arguments: the array element and its index.

func (*Uint16) MapIndexValSeq

func (A *Uint16) MapIndexValSeq(f func(int, uint16) uint16)

MapIndexValSeq applies the function `f` to all pairs (x, y), where y := linear index of y in `A`. In other words, MapIndexValSeq is a map function that takes two arguments: the array element and its index.

func (*Uint16) MapSeq

func (A *Uint16) MapSeq(f func(uint16) uint16)

MapSeq applies the function `f` to each element of the array `A`.

func (*Uint16) Set

func (A *Uint16) Set(val uint16, indices ...int)

Set sets the value of a single element of an `Array`. Note that `A.Data[k]` can also be accessed directly.

func (*Uint16) Slice

func (A *Uint16) Slice(s string) (Slice, error)

Slice takes as input a string representation `s` of an array slice and returns a `Slice` (which is of type []Range which is the same as [][3]int) that represents the same information as the input string `s` but in numeric data structure conducive for computation. For example, if s == "[0:5:2]", then we are asking the function `Slice` to construct a `Slice` that starts at 0, stops at 4, and advances with step 2. The result, in this case, will be the `Slice` { {0, 5, 2} }. One advantage of using the function Slice over "manually" instantiating `Slice`s is the the former is slightly user-friendlier.The string representation allows for the usual liberal specification of a slice where some information can be ommitted. This is possible by accessing the metadata in the receiver of the method.

func (*Uint16) String

func (A *Uint16) String() string

String prints an Uint16

func (*Uint16) ToCSV

func (A *Uint16) ToCSV(out io.Writer, printVerb ...string) error

ToCSV saves an array to a .csv file. It also saves a .json file with the same name containing the array metadata. out: io.Writer to write to.

func (*Uint16) ToCSVFile

func (A *Uint16) ToCSVFile(fpout string, printVerb ...string) error

ToCSV saves an array to a .csv file. It also saves a .json file with the same name containing the array metadata. fpout: the path of the output file

func (*Uint16) View

func (A *Uint16) View(slice Slice) (*ViewUint16, error)

View returns a view into the array A.

type Uint32

type Uint32 struct {
	Metadata
	Data []uint32
}

Uint32 is a concrete array type whose elements are of type `uint32`. Uint32 is defined by composition of `Metadata` and the slice `Data`.

func (*Uint32) At

func (A *Uint32) At(indices ...int) *uint32

At returns a pointer to the k-th linearly indexed element of an `Array`. It is the most primitive way to access elements, without checking bounds or returning errors.

func (*Uint32) Dir

func (A *Uint32) Dir(out io.Writer)

Dir prints the attributes of an array. The name is inspired by pythons `dir`.

func (*Uint32) Fill

func (A *Uint32) Fill(val uint32, numGoRout ...int)

Fill sets the value of every element of A equal to `val`. In cases where concurrency can be beneficial for speed, `Fill` should be faster than `FillSeq`. For really small arrays, not only `Fill` will not be faster than `FillSeq`, but actually slower; because for tiny arrays the overhead of concurrency (although minimal in Go) dominates the computation.

func (*Uint32) FillSeq

func (A *Uint32) FillSeq(val uint32)

FillSeq sets the value of every element of A equal to `val`. This is a sequential implementation, hence the name. There will be a parallel one too.

func (*Uint32) FromCSV

func (A *Uint32) FromCSV(in io.Reader) (int, []int, []error, error)

FromCSV reads from a .csv source into an array.

  • Input -- in: a reader from which the csv-formated data can be read.
  • Output -- int: number of element read from the input -- []int: indices for which the parsing of an element failed (when reading csv data into an array, each field in the csv is a string that has be parsed into a numerical type; this is the parsing referref to). -- []error: parsing errors that occur during file reading -- error: nil if no errors occured, something hopefully informative otherwise.

func (*Uint32) FromCSVFile

func (A *Uint32) FromCSVFile(fpin string) (int, []int, []error, error)

FromCSVFile reads from a .csv source into an array. `FromCSVFile` is a wrapper around `FromCSV`; regarding the return values, see the documentation for the latter method. The input is the path to the .csv file to be read into the array `A`.

func (*Uint32) Get

func (A *Uint32) Get(indices ...int) uint32

Get returns the value of a single element of an `Array`. Note that `A.Data[k]` can also be accessed directly.

func (*Uint32) Map

func (A *Uint32) Map(f func(uint32) uint32, numGoRout ...int)

Map applies the function `f` to every element of the array `A`.

func (*Uint32) MapIndex

func (A *Uint32) MapIndex(f func(int) uint32, numGoRout ...int)

MapIndex applies the function `f` to the linear index of each element of the array `A`.

func (*Uint32) MapIndexSeq

func (A *Uint32) MapIndexSeq(f func(int) uint32)

MapIndexSeq applies the function `f` to the linear index of each element of the array `A`.

func (*Uint32) MapIndexVal

func (A *Uint32) MapIndexVal(f func(int, uint32) uint32, numGoRout ...int)

MapIndexVal applies the function `f` to all pairs (x, y), where y := linear index of y in `A`. In other words, MapIndexVal is a map function that takes two arguments: the array element and its index.

func (*Uint32) MapIndexValSeq

func (A *Uint32) MapIndexValSeq(f func(int, uint32) uint32)

MapIndexValSeq applies the function `f` to all pairs (x, y), where y := linear index of y in `A`. In other words, MapIndexValSeq is a map function that takes two arguments: the array element and its index.

func (*Uint32) MapSeq

func (A *Uint32) MapSeq(f func(uint32) uint32)

MapSeq applies the function `f` to each element of the array `A`.

func (*Uint32) Set

func (A *Uint32) Set(val uint32, indices ...int)

Set sets the value of a single element of an `Array`. Note that `A.Data[k]` can also be accessed directly.

func (*Uint32) Slice

func (A *Uint32) Slice(s string) (Slice, error)

Slice takes as input a string representation `s` of an array slice and returns a `Slice` (which is of type []Range which is the same as [][3]int) that represents the same information as the input string `s` but in numeric data structure conducive for computation. For example, if s == "[0:5:2]", then we are asking the function `Slice` to construct a `Slice` that starts at 0, stops at 4, and advances with step 2. The result, in this case, will be the `Slice` { {0, 5, 2} }. One advantage of using the function Slice over "manually" instantiating `Slice`s is the the former is slightly user-friendlier.The string representation allows for the usual liberal specification of a slice where some information can be ommitted. This is possible by accessing the metadata in the receiver of the method.

func (*Uint32) String

func (A *Uint32) String() string

String prints an Uint32

func (*Uint32) ToCSV

func (A *Uint32) ToCSV(out io.Writer, printVerb ...string) error

ToCSV saves an array to a .csv file. It also saves a .json file with the same name containing the array metadata. out: io.Writer to write to.

func (*Uint32) ToCSVFile

func (A *Uint32) ToCSVFile(fpout string, printVerb ...string) error

ToCSV saves an array to a .csv file. It also saves a .json file with the same name containing the array metadata. fpout: the path of the output file

func (*Uint32) View

func (A *Uint32) View(slice Slice) (*ViewUint32, error)

View returns a view into the array A.

type Uint64

type Uint64 struct {
	Metadata
	Data []uint64
}

Uint64 is a concrete array type whose elements are of type `uint64`. Uint64 is defined by composition of `Metadata` and the slice `Data`.

func (*Uint64) At

func (A *Uint64) At(indices ...int) *uint64

At returns a pointer to the k-th linearly indexed element of an `Array`. It is the most primitive way to access elements, without checking bounds or returning errors.

func (*Uint64) Dir

func (A *Uint64) Dir(out io.Writer)

Dir prints the attributes of an array. The name is inspired by pythons `dir`.

func (*Uint64) Fill

func (A *Uint64) Fill(val uint64, numGoRout ...int)

Fill sets the value of every element of A equal to `val`. In cases where concurrency can be beneficial for speed, `Fill` should be faster than `FillSeq`. For really small arrays, not only `Fill` will not be faster than `FillSeq`, but actually slower; because for tiny arrays the overhead of concurrency (although minimal in Go) dominates the computation.

func (*Uint64) FillSeq

func (A *Uint64) FillSeq(val uint64)

FillSeq sets the value of every element of A equal to `val`. This is a sequential implementation, hence the name. There will be a parallel one too.

func (*Uint64) FromCSV

func (A *Uint64) FromCSV(in io.Reader) (int, []int, []error, error)

FromCSV reads from a .csv source into an array.

  • Input -- in: a reader from which the csv-formated data can be read.
  • Output -- int: number of element read from the input -- []int: indices for which the parsing of an element failed (when reading csv data into an array, each field in the csv is a string that has be parsed into a numerical type; this is the parsing referref to). -- []error: parsing errors that occur during file reading -- error: nil if no errors occured, something hopefully informative otherwise.

func (*Uint64) FromCSVFile

func (A *Uint64) FromCSVFile(fpin string) (int, []int, []error, error)

FromCSVFile reads from a .csv source into an array. `FromCSVFile` is a wrapper around `FromCSV`; regarding the return values, see the documentation for the latter method. The input is the path to the .csv file to be read into the array `A`.

func (*Uint64) Get

func (A *Uint64) Get(indices ...int) uint64

Get returns the value of a single element of an `Array`. Note that `A.Data[k]` can also be accessed directly.

func (*Uint64) Map

func (A *Uint64) Map(f func(uint64) uint64, numGoRout ...int)

Map applies the function `f` to every element of the array `A`.

func (*Uint64) MapIndex

func (A *Uint64) MapIndex(f func(int) uint64, numGoRout ...int)

MapIndex applies the function `f` to the linear index of each element of the array `A`.

func (*Uint64) MapIndexSeq

func (A *Uint64) MapIndexSeq(f func(int) uint64)

MapIndexSeq applies the function `f` to the linear index of each element of the array `A`.

func (*Uint64) MapIndexVal

func (A *Uint64) MapIndexVal(f func(int, uint64) uint64, numGoRout ...int)

MapIndexVal applies the function `f` to all pairs (x, y), where y := linear index of y in `A`. In other words, MapIndexVal is a map function that takes two arguments: the array element and its index.

func (*Uint64) MapIndexValSeq

func (A *Uint64) MapIndexValSeq(f func(int, uint64) uint64)

MapIndexValSeq applies the function `f` to all pairs (x, y), where y := linear index of y in `A`. In other words, MapIndexValSeq is a map function that takes two arguments: the array element and its index.

func (*Uint64) MapSeq

func (A *Uint64) MapSeq(f func(uint64) uint64)

MapSeq applies the function `f` to each element of the array `A`.

func (*Uint64) Set

func (A *Uint64) Set(val uint64, indices ...int)

Set sets the value of a single element of an `Array`. Note that `A.Data[k]` can also be accessed directly.

func (*Uint64) Slice

func (A *Uint64) Slice(s string) (Slice, error)

Slice takes as input a string representation `s` of an array slice and returns a `Slice` (which is of type []Range which is the same as [][3]int) that represents the same information as the input string `s` but in numeric data structure conducive for computation. For example, if s == "[0:5:2]", then we are asking the function `Slice` to construct a `Slice` that starts at 0, stops at 4, and advances with step 2. The result, in this case, will be the `Slice` { {0, 5, 2} }. One advantage of using the function Slice over "manually" instantiating `Slice`s is the the former is slightly user-friendlier.The string representation allows for the usual liberal specification of a slice where some information can be ommitted. This is possible by accessing the metadata in the receiver of the method.

func (*Uint64) String

func (A *Uint64) String() string

String prints an Uint64

func (*Uint64) ToCSV

func (A *Uint64) ToCSV(out io.Writer, printVerb ...string) error

ToCSV saves an array to a .csv file. It also saves a .json file with the same name containing the array metadata. out: io.Writer to write to.

func (*Uint64) ToCSVFile

func (A *Uint64) ToCSVFile(fpout string, printVerb ...string) error

ToCSV saves an array to a .csv file. It also saves a .json file with the same name containing the array metadata. fpout: the path of the output file

func (*Uint64) View

func (A *Uint64) View(slice Slice) (*ViewUint64, error)

View returns a view into the array A.

type Uint8

type Uint8 struct {
	Metadata
	Data []uint8
}

Uint8 is a concrete array type whose elements are of type `uint8`. Uint8 is defined by composition of `Metadata` and the slice `Data`.

func (*Uint8) At

func (A *Uint8) At(indices ...int) *uint8

At returns a pointer to the k-th linearly indexed element of an `Array`. It is the most primitive way to access elements, without checking bounds or returning errors.

func (*Uint8) Dir

func (A *Uint8) Dir(out io.Writer)

Dir prints the attributes of an array. The name is inspired by pythons `dir`.

func (*Uint8) Fill

func (A *Uint8) Fill(val uint8, numGoRout ...int)

Fill sets the value of every element of A equal to `val`. In cases where concurrency can be beneficial for speed, `Fill` should be faster than `FillSeq`. For really small arrays, not only `Fill` will not be faster than `FillSeq`, but actually slower; because for tiny arrays the overhead of concurrency (although minimal in Go) dominates the computation.

func (*Uint8) FillSeq

func (A *Uint8) FillSeq(val uint8)

FillSeq sets the value of every element of A equal to `val`. This is a sequential implementation, hence the name. There will be a parallel one too.

func (*Uint8) FromCSV

func (A *Uint8) FromCSV(in io.Reader) (int, []int, []error, error)

FromCSV reads from a .csv source into an array.

  • Input -- in: a reader from which the csv-formated data can be read.
  • Output -- int: number of element read from the input -- []int: indices for which the parsing of an element failed (when reading csv data into an array, each field in the csv is a string that has be parsed into a numerical type; this is the parsing referref to). -- []error: parsing errors that occur during file reading -- error: nil if no errors occured, something hopefully informative otherwise.

func (*Uint8) FromCSVFile

func (A *Uint8) FromCSVFile(fpin string) (int, []int, []error, error)

FromCSVFile reads from a .csv source into an array. `FromCSVFile` is a wrapper around `FromCSV`; regarding the return values, see the documentation for the latter method. The input is the path to the .csv file to be read into the array `A`.

func (*Uint8) Get

func (A *Uint8) Get(indices ...int) uint8

Get returns the value of a single element of an `Array`. Note that `A.Data[k]` can also be accessed directly.

func (*Uint8) Map

func (A *Uint8) Map(f func(uint8) uint8, numGoRout ...int)

Map applies the function `f` to every element of the array `A`.

func (*Uint8) MapIndex

func (A *Uint8) MapIndex(f func(int) uint8, numGoRout ...int)

MapIndex applies the function `f` to the linear index of each element of the array `A`.

func (*Uint8) MapIndexSeq

func (A *Uint8) MapIndexSeq(f func(int) uint8)

MapIndexSeq applies the function `f` to the linear index of each element of the array `A`.

func (*Uint8) MapIndexVal

func (A *Uint8) MapIndexVal(f func(int, uint8) uint8, numGoRout ...int)

MapIndexVal applies the function `f` to all pairs (x, y), where y := linear index of y in `A`. In other words, MapIndexVal is a map function that takes two arguments: the array element and its index.

func (*Uint8) MapIndexValSeq

func (A *Uint8) MapIndexValSeq(f func(int, uint8) uint8)

MapIndexValSeq applies the function `f` to all pairs (x, y), where y := linear index of y in `A`. In other words, MapIndexValSeq is a map function that takes two arguments: the array element and its index.

func (*Uint8) MapSeq

func (A *Uint8) MapSeq(f func(uint8) uint8)

MapSeq applies the function `f` to each element of the array `A`.

func (*Uint8) Set

func (A *Uint8) Set(val uint8, indices ...int)

Set sets the value of a single element of an `Array`. Note that `A.Data[k]` can also be accessed directly.

func (*Uint8) Slice

func (A *Uint8) Slice(s string) (Slice, error)

Slice takes as input a string representation `s` of an array slice and returns a `Slice` (which is of type []Range which is the same as [][3]int) that represents the same information as the input string `s` but in numeric data structure conducive for computation. For example, if s == "[0:5:2]", then we are asking the function `Slice` to construct a `Slice` that starts at 0, stops at 4, and advances with step 2. The result, in this case, will be the `Slice` { {0, 5, 2} }. One advantage of using the function Slice over "manually" instantiating `Slice`s is the the former is slightly user-friendlier.The string representation allows for the usual liberal specification of a slice where some information can be ommitted. This is possible by accessing the metadata in the receiver of the method.

func (*Uint8) String

func (A *Uint8) String() string

String prints an Uint8

func (*Uint8) ToCSV

func (A *Uint8) ToCSV(out io.Writer, printVerb ...string) error

ToCSV saves an array to a .csv file. It also saves a .json file with the same name containing the array metadata. out: io.Writer to write to.

func (*Uint8) ToCSVFile

func (A *Uint8) ToCSVFile(fpout string, printVerb ...string) error

ToCSV saves an array to a .csv file. It also saves a .json file with the same name containing the array metadata. fpout: the path of the output file

func (*Uint8) View

func (A *Uint8) View(slice Slice) (*ViewUint8, error)

View returns a view into the array A.

type Uintptr

type Uintptr struct {
	Metadata
	Data []uintptr
}

Uintptr is a concrete array type whose elements are of type `uintptr`. Uintptr is defined by composition of `Metadata` and the slice `Data`.

func (*Uintptr) At

func (A *Uintptr) At(indices ...int) *uintptr

At returns a pointer to the k-th linearly indexed element of an `Array`. It is the most primitive way to access elements, without checking bounds or returning errors.

func (*Uintptr) Dir

func (A *Uintptr) Dir(out io.Writer)

Dir prints the attributes of an array. The name is inspired by pythons `dir`.

func (*Uintptr) Fill

func (A *Uintptr) Fill(val uintptr, numGoRout ...int)

Fill sets the value of every element of A equal to `val`. In cases where concurrency can be beneficial for speed, `Fill` should be faster than `FillSeq`. For really small arrays, not only `Fill` will not be faster than `FillSeq`, but actually slower; because for tiny arrays the overhead of concurrency (although minimal in Go) dominates the computation.

func (*Uintptr) FillSeq

func (A *Uintptr) FillSeq(val uintptr)

FillSeq sets the value of every element of A equal to `val`. This is a sequential implementation, hence the name. There will be a parallel one too.

func (*Uintptr) FromCSV

func (A *Uintptr) FromCSV(in io.Reader) (int, []int, []error, error)

FromCSV reads from a .csv source into an array.

  • Input -- in: a reader from which the csv-formated data can be read.
  • Output -- int: number of element read from the input -- []int: indices for which the parsing of an element failed (when reading csv data into an array, each field in the csv is a string that has be parsed into a numerical type; this is the parsing referref to). -- []error: parsing errors that occur during file reading -- error: nil if no errors occured, something hopefully informative otherwise.

func (*Uintptr) FromCSVFile

func (A *Uintptr) FromCSVFile(fpin string) (int, []int, []error, error)

FromCSVFile reads from a .csv source into an array. `FromCSVFile` is a wrapper around `FromCSV`; regarding the return values, see the documentation for the latter method. The input is the path to the .csv file to be read into the array `A`.

func (*Uintptr) Get

func (A *Uintptr) Get(indices ...int) uintptr

Get returns the value of a single element of an `Array`. Note that `A.Data[k]` can also be accessed directly.

func (*Uintptr) Map

func (A *Uintptr) Map(f func(uintptr) uintptr, numGoRout ...int)

Map applies the function `f` to every element of the array `A`.

func (*Uintptr) MapIndex

func (A *Uintptr) MapIndex(f func(int) uintptr, numGoRout ...int)

MapIndex applies the function `f` to the linear index of each element of the array `A`.

func (*Uintptr) MapIndexSeq

func (A *Uintptr) MapIndexSeq(f func(int) uintptr)

MapIndexSeq applies the function `f` to the linear index of each element of the array `A`.

func (*Uintptr) MapIndexVal

func (A *Uintptr) MapIndexVal(f func(int, uintptr) uintptr, numGoRout ...int)

MapIndexVal applies the function `f` to all pairs (x, y), where y := linear index of y in `A`. In other words, MapIndexVal is a map function that takes two arguments: the array element and its index.

func (*Uintptr) MapIndexValSeq

func (A *Uintptr) MapIndexValSeq(f func(int, uintptr) uintptr)

MapIndexValSeq applies the function `f` to all pairs (x, y), where y := linear index of y in `A`. In other words, MapIndexValSeq is a map function that takes two arguments: the array element and its index.

func (*Uintptr) MapSeq

func (A *Uintptr) MapSeq(f func(uintptr) uintptr)

MapSeq applies the function `f` to each element of the array `A`.

func (*Uintptr) Set

func (A *Uintptr) Set(val uintptr, indices ...int)

Set sets the value of a single element of an `Array`. Note that `A.Data[k]` can also be accessed directly.

func (*Uintptr) Slice

func (A *Uintptr) Slice(s string) (Slice, error)

Slice takes as input a string representation `s` of an array slice and returns a `Slice` (which is of type []Range which is the same as [][3]int) that represents the same information as the input string `s` but in numeric data structure conducive for computation. For example, if s == "[0:5:2]", then we are asking the function `Slice` to construct a `Slice` that starts at 0, stops at 4, and advances with step 2. The result, in this case, will be the `Slice` { {0, 5, 2} }. One advantage of using the function Slice over "manually" instantiating `Slice`s is the the former is slightly user-friendlier.The string representation allows for the usual liberal specification of a slice where some information can be ommitted. This is possible by accessing the metadata in the receiver of the method.

func (*Uintptr) String

func (A *Uintptr) String() string

String prints an Uintptr

func (*Uintptr) ToCSV

func (A *Uintptr) ToCSV(out io.Writer, printVerb ...string) error

ToCSV saves an array to a .csv file. It also saves a .json file with the same name containing the array metadata. out: io.Writer to write to.

func (*Uintptr) ToCSVFile

func (A *Uintptr) ToCSVFile(fpout string, printVerb ...string) error

ToCSV saves an array to a .csv file. It also saves a .json file with the same name containing the array metadata. fpout: the path of the output file

func (*Uintptr) View

func (A *Uintptr) View(slice Slice) (*ViewUintptr, error)

View returns a view into the array A.

type ViewFloat32

type ViewFloat32 struct {
	Array *Float32
	S     Slice
	Metadata
	Err error
}

View is a view into an array.

func (*ViewFloat32) At

func (v *ViewFloat32) At(indices ...int) *float32

At returns the address of a single element of a `View` of an array.

func (*ViewFloat32) Dir

func (v *ViewFloat32) Dir() string

func (*ViewFloat32) Get

func (v *ViewFloat32) Get(indices ...int) float32

Get returns the value of a single element of a `View` of an array.

func (*ViewFloat32) Iterator

func (v *ViewFloat32) Iterator(done <-chan struct{}) <-chan *float32
--------------------------------------------------------------------------------

-- Iterator over a view

--------------------------------------------------------------------------------

Iterator returns an iterator over the view of an array

func (*ViewFloat32) Set

func (v *ViewFloat32) Set(val float32, indices ...int)

Set sets the value of a single element of a `View` of an array.

func (*ViewFloat32) String

func (A *ViewFloat32) String() string
--------------------------------------------------------------------------------

-- `String`

--------------------------------------------------------------------------------

String prints an Float32

type ViewFloat64

type ViewFloat64 struct {
	Array *Float64
	S     Slice
	Metadata
	Err error
}

View is a view into an array.

func (*ViewFloat64) At

func (v *ViewFloat64) At(indices ...int) *float64

At returns the address of a single element of a `View` of an array.

func (*ViewFloat64) Dir

func (v *ViewFloat64) Dir() string

func (*ViewFloat64) Get

func (v *ViewFloat64) Get(indices ...int) float64

Get returns the value of a single element of a `View` of an array.

func (*ViewFloat64) Iterator

func (v *ViewFloat64) Iterator(done <-chan struct{}) <-chan *float64
--------------------------------------------------------------------------------

-- Iterator over a view

--------------------------------------------------------------------------------

Iterator returns an iterator over the view of an array

func (*ViewFloat64) Set

func (v *ViewFloat64) Set(val float64, indices ...int)

Set sets the value of a single element of a `View` of an array.

func (*ViewFloat64) String

func (A *ViewFloat64) String() string
--------------------------------------------------------------------------------

-- `String`

--------------------------------------------------------------------------------

String prints an Float64

type ViewInt

type ViewInt struct {
	Array *Int
	S     Slice
	Metadata
	Err error
}

View is a view into an array.

func (*ViewInt) At

func (v *ViewInt) At(indices ...int) *int

At returns the address of a single element of a `View` of an array.

func (*ViewInt) Dir

func (v *ViewInt) Dir() string

func (*ViewInt) Get

func (v *ViewInt) Get(indices ...int) int

Get returns the value of a single element of a `View` of an array.

func (*ViewInt) Iterator

func (v *ViewInt) Iterator(done <-chan struct{}) <-chan *int
--------------------------------------------------------------------------------

-- Iterator over a view

--------------------------------------------------------------------------------

Iterator returns an iterator over the view of an array

func (*ViewInt) Set

func (v *ViewInt) Set(val int, indices ...int)

Set sets the value of a single element of a `View` of an array.

func (*ViewInt) String

func (A *ViewInt) String() string
--------------------------------------------------------------------------------

-- `String`

--------------------------------------------------------------------------------

String prints an Int

type ViewInt16

type ViewInt16 struct {
	Array *Int16
	S     Slice
	Metadata
	Err error
}

View is a view into an array.

func (*ViewInt16) At

func (v *ViewInt16) At(indices ...int) *int16

At returns the address of a single element of a `View` of an array.

func (*ViewInt16) Dir

func (v *ViewInt16) Dir() string

func (*ViewInt16) Get

func (v *ViewInt16) Get(indices ...int) int16

Get returns the value of a single element of a `View` of an array.

func (*ViewInt16) Iterator

func (v *ViewInt16) Iterator(done <-chan struct{}) <-chan *int16
--------------------------------------------------------------------------------

-- Iterator over a view

--------------------------------------------------------------------------------

Iterator returns an iterator over the view of an array

func (*ViewInt16) Set

func (v *ViewInt16) Set(val int16, indices ...int)

Set sets the value of a single element of a `View` of an array.

func (*ViewInt16) String

func (A *ViewInt16) String() string
--------------------------------------------------------------------------------

-- `String`

--------------------------------------------------------------------------------

String prints an Int16

type ViewInt32

type ViewInt32 struct {
	Array *Int32
	S     Slice
	Metadata
	Err error
}

View is a view into an array.

func (*ViewInt32) At

func (v *ViewInt32) At(indices ...int) *int32

At returns the address of a single element of a `View` of an array.

func (*ViewInt32) Dir

func (v *ViewInt32) Dir() string

func (*ViewInt32) Get

func (v *ViewInt32) Get(indices ...int) int32

Get returns the value of a single element of a `View` of an array.

func (*ViewInt32) Iterator

func (v *ViewInt32) Iterator(done <-chan struct{}) <-chan *int32
--------------------------------------------------------------------------------

-- Iterator over a view

--------------------------------------------------------------------------------

Iterator returns an iterator over the view of an array

func (*ViewInt32) Set

func (v *ViewInt32) Set(val int32, indices ...int)

Set sets the value of a single element of a `View` of an array.

func (*ViewInt32) String

func (A *ViewInt32) String() string
--------------------------------------------------------------------------------

-- `String`

--------------------------------------------------------------------------------

String prints an Int32

type ViewInt64

type ViewInt64 struct {
	Array *Int64
	S     Slice
	Metadata
	Err error
}

View is a view into an array.

func (*ViewInt64) At

func (v *ViewInt64) At(indices ...int) *int64

At returns the address of a single element of a `View` of an array.

func (*ViewInt64) Dir

func (v *ViewInt64) Dir() string

func (*ViewInt64) Get

func (v *ViewInt64) Get(indices ...int) int64

Get returns the value of a single element of a `View` of an array.

func (*ViewInt64) Iterator

func (v *ViewInt64) Iterator(done <-chan struct{}) <-chan *int64
--------------------------------------------------------------------------------

-- Iterator over a view

--------------------------------------------------------------------------------

Iterator returns an iterator over the view of an array

func (*ViewInt64) Set

func (v *ViewInt64) Set(val int64, indices ...int)

Set sets the value of a single element of a `View` of an array.

func (*ViewInt64) String

func (A *ViewInt64) String() string
--------------------------------------------------------------------------------

-- `String`

--------------------------------------------------------------------------------

String prints an Int64

type ViewInt8

type ViewInt8 struct {
	Array *Int8
	S     Slice
	Metadata
	Err error
}

View is a view into an array.

func (*ViewInt8) At

func (v *ViewInt8) At(indices ...int) *int8

At returns the address of a single element of a `View` of an array.

func (*ViewInt8) Dir

func (v *ViewInt8) Dir() string

func (*ViewInt8) Get

func (v *ViewInt8) Get(indices ...int) int8

Get returns the value of a single element of a `View` of an array.

func (*ViewInt8) Iterator

func (v *ViewInt8) Iterator(done <-chan struct{}) <-chan *int8
--------------------------------------------------------------------------------

-- Iterator over a view

--------------------------------------------------------------------------------

Iterator returns an iterator over the view of an array

func (*ViewInt8) Set

func (v *ViewInt8) Set(val int8, indices ...int)

Set sets the value of a single element of a `View` of an array.

func (*ViewInt8) String

func (A *ViewInt8) String() string
--------------------------------------------------------------------------------

-- `String`

--------------------------------------------------------------------------------

String prints an Int8

type ViewUint

type ViewUint struct {
	Array *Uint
	S     Slice
	Metadata
	Err error
}

View is a view into an array.

func (*ViewUint) At

func (v *ViewUint) At(indices ...int) *uint

At returns the address of a single element of a `View` of an array.

func (*ViewUint) Dir

func (v *ViewUint) Dir() string

func (*ViewUint) Get

func (v *ViewUint) Get(indices ...int) uint

Get returns the value of a single element of a `View` of an array.

func (*ViewUint) Iterator

func (v *ViewUint) Iterator(done <-chan struct{}) <-chan *uint
--------------------------------------------------------------------------------

-- Iterator over a view

--------------------------------------------------------------------------------

Iterator returns an iterator over the view of an array

func (*ViewUint) Set

func (v *ViewUint) Set(val uint, indices ...int)

Set sets the value of a single element of a `View` of an array.

func (*ViewUint) String

func (A *ViewUint) String() string
--------------------------------------------------------------------------------

-- `String`

--------------------------------------------------------------------------------

String prints an Uint

type ViewUint16

type ViewUint16 struct {
	Array *Uint16
	S     Slice
	Metadata
	Err error
}

View is a view into an array.

func (*ViewUint16) At

func (v *ViewUint16) At(indices ...int) *uint16

At returns the address of a single element of a `View` of an array.

func (*ViewUint16) Dir

func (v *ViewUint16) Dir() string

func (*ViewUint16) Get

func (v *ViewUint16) Get(indices ...int) uint16

Get returns the value of a single element of a `View` of an array.

func (*ViewUint16) Iterator

func (v *ViewUint16) Iterator(done <-chan struct{}) <-chan *uint16
--------------------------------------------------------------------------------

-- Iterator over a view

--------------------------------------------------------------------------------

Iterator returns an iterator over the view of an array

func (*ViewUint16) Set

func (v *ViewUint16) Set(val uint16, indices ...int)

Set sets the value of a single element of a `View` of an array.

func (*ViewUint16) String

func (A *ViewUint16) String() string
--------------------------------------------------------------------------------

-- `String`

--------------------------------------------------------------------------------

String prints an Uint16

type ViewUint32

type ViewUint32 struct {
	Array *Uint32
	S     Slice
	Metadata
	Err error
}

View is a view into an array.

func (*ViewUint32) At

func (v *ViewUint32) At(indices ...int) *uint32

At returns the address of a single element of a `View` of an array.

func (*ViewUint32) Dir

func (v *ViewUint32) Dir() string

func (*ViewUint32) Get

func (v *ViewUint32) Get(indices ...int) uint32

Get returns the value of a single element of a `View` of an array.

func (*ViewUint32) Iterator

func (v *ViewUint32) Iterator(done <-chan struct{}) <-chan *uint32
--------------------------------------------------------------------------------

-- Iterator over a view

--------------------------------------------------------------------------------

Iterator returns an iterator over the view of an array

func (*ViewUint32) Set

func (v *ViewUint32) Set(val uint32, indices ...int)

Set sets the value of a single element of a `View` of an array.

func (*ViewUint32) String

func (A *ViewUint32) String() string
--------------------------------------------------------------------------------

-- `String`

--------------------------------------------------------------------------------

String prints an Uint32

type ViewUint64

type ViewUint64 struct {
	Array *Uint64
	S     Slice
	Metadata
	Err error
}

View is a view into an array.

func (*ViewUint64) At

func (v *ViewUint64) At(indices ...int) *uint64

At returns the address of a single element of a `View` of an array.

func (*ViewUint64) Dir

func (v *ViewUint64) Dir() string

func (*ViewUint64) Get

func (v *ViewUint64) Get(indices ...int) uint64

Get returns the value of a single element of a `View` of an array.

func (*ViewUint64) Iterator

func (v *ViewUint64) Iterator(done <-chan struct{}) <-chan *uint64
--------------------------------------------------------------------------------

-- Iterator over a view

--------------------------------------------------------------------------------

Iterator returns an iterator over the view of an array

func (*ViewUint64) Set

func (v *ViewUint64) Set(val uint64, indices ...int)

Set sets the value of a single element of a `View` of an array.

func (*ViewUint64) String

func (A *ViewUint64) String() string
--------------------------------------------------------------------------------

-- `String`

--------------------------------------------------------------------------------

String prints an Uint64

type ViewUint8

type ViewUint8 struct {
	Array *Uint8
	S     Slice
	Metadata
	Err error
}

View is a view into an array.

func (*ViewUint8) At

func (v *ViewUint8) At(indices ...int) *uint8

At returns the address of a single element of a `View` of an array.

func (*ViewUint8) Dir

func (v *ViewUint8) Dir() string

func (*ViewUint8) Get

func (v *ViewUint8) Get(indices ...int) uint8

Get returns the value of a single element of a `View` of an array.

func (*ViewUint8) Iterator

func (v *ViewUint8) Iterator(done <-chan struct{}) <-chan *uint8
--------------------------------------------------------------------------------

-- Iterator over a view

--------------------------------------------------------------------------------

Iterator returns an iterator over the view of an array

func (*ViewUint8) Set

func (v *ViewUint8) Set(val uint8, indices ...int)

Set sets the value of a single element of a `View` of an array.

func (*ViewUint8) String

func (A *ViewUint8) String() string
--------------------------------------------------------------------------------

-- `String`

--------------------------------------------------------------------------------

String prints an Uint8

type ViewUintptr

type ViewUintptr struct {
	Array *Uintptr
	S     Slice
	Metadata
	Err error
}

View is a view into an array.

func (*ViewUintptr) At

func (v *ViewUintptr) At(indices ...int) *uintptr

At returns the address of a single element of a `View` of an array.

func (*ViewUintptr) Dir

func (v *ViewUintptr) Dir() string

func (*ViewUintptr) Get

func (v *ViewUintptr) Get(indices ...int) uintptr

Get returns the value of a single element of a `View` of an array.

func (*ViewUintptr) Iterator

func (v *ViewUintptr) Iterator(done <-chan struct{}) <-chan *uintptr
--------------------------------------------------------------------------------

-- Iterator over a view

--------------------------------------------------------------------------------

Iterator returns an iterator over the view of an array

func (*ViewUintptr) Set

func (v *ViewUintptr) Set(val uintptr, indices ...int)

Set sets the value of a single element of a `View` of an array.

func (*ViewUintptr) String

func (A *ViewUintptr) String() string
--------------------------------------------------------------------------------

-- `String`

--------------------------------------------------------------------------------

String prints an Uintptr

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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