util

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2021 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Overview

Copyright © 2021 Brian Longmore branodev@gmail.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckMatSizes added in v1.1.0

func CheckMatSizes(mats ...Matrix) error

CheckMatSizes checks if all mats are the same size.

func IsMultPossible

func IsMultPossible(m1, m2 Matrix) bool

IsMultPossible checks if multiplication between m1 and m2 is possible.

func MatToString added in v1.2.0

func MatToString(mat Matrix) string

MatToString returns mat in its string form.

func PrintMat

func PrintMat(mat Matrix) (n int, err error)

PrintMat prints mat to the command line. Returns the number of bytes written and any write error encountered.

Types

type MatPopConfig added in v1.0.0

type MatPopConfig struct {
	MainMat Matrix
	SecMats []Matrix
	NewRows int
	NewCols int
	Action  func(m Matrix, r, c int, secMs []Matrix) float64
}

type Matrix

type Matrix []Row

func GetMatFromFile

func GetMatFromFile(path string) (Matrix, error)

GetMatFromFile returns a matrix from a matrix file.

func GetMatsFromFiles

func GetMatsFromFiles(paths []string) ([]Matrix, error)

GetMatsFromFiles returns a slice of matrices from their matrix files.

func GetMinor added in v1.6.0

func GetMinor(m Matrix, row, c int) Matrix

GetMinor returns the minor of m according to row at column c.

func InitMat added in v1.0.0

func InitMat(rows, cols int) Matrix

InitMat creates an empty matrix with the passed size. Main purpose is to init matrix that can later be populated with PopulateNewMat.

func MakeIdentityMat added in v1.6.0

func MakeIdentityMat(w int) Matrix

MakeIdentityMat creates an indentity matrix with wid as the number of rows and cols.

func ParseCmdArgs added in v1.3.0

func ParseCmdArgs(cmd *cobra.Command, args []string) ([]Matrix, error)

ParseCmdArgs parses args according to the command raw-input flag.

func PopulateNewMat

func PopulateNewMat(c MatPopConfig) Matrix

PopulateNewMat creates and fills a new matrix according to the action performed on each element of the passed matrices and configurations. Omit NewRows and NewCols fields in c if you want them to be the same as the rows and cols of MainMat.

func StringToMat added in v1.2.0

func StringToMat(ms string) (Matrix, error)

StringToMat parses a string to a matrix.

func StringsToMats added in v1.3.0

func StringsToMats(mats []string) ([]Matrix, error)

StringsToMats parses strings to matrices.

func (Matrix) Cols added in v1.12.0

func (m Matrix) Cols() int

Get the number of columns of m.

func (Matrix) Rows added in v1.12.0

func (m Matrix) Rows() int

Get the number of rows of m.

type Row

type Row []float64

Jump to

Keyboard shortcuts

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