mtrix

command module
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: 1 Imported by: 0

README

🔮 mtrix

A simple command line matrix calculator.


🧪 Setup

Download and compile from sources:

go get github.com/branogarbo/mtrix

Install just the binary with Go:

go install github.com/branogarbo/mtrix@latest

Or get the pre-compiled binaries for your platform on the releases page

🧙‍♂️ CLI Usage

mtrix

A simple command line matrix calculator.

Usage:
  mtrix [command]

Available Commands:
  add         Get the sum of matrices
  completion  generate the autocompletion script for the specified shell
  det         Compute the determinant of a matrix
  help        Help about any command
  inv         Get the inverse of a matrix
  mult        Multiply two matrices together
  pow         Raise a matrix to the nth power
  smult       Multiply a matrix by a scalar
  sub         Get the difference of two matrices
  trans       Get the transpose of a matrix

Flags:
  -h, --help        help for mtrix
  -r, --raw-input   whether or not the command takes matrices as strings
  -v, --version     version for mtrix

Use "mtrix [command] --help" for more information about a command.

🌌 Package Usage

Get the packages you need for your project:

go get github.com/branogarbo/mtrix/addition
go get github.com/branogarbo/mtrix/multiply
go get github.com/branogarbo/mtrix/util
...
Examples:

Adding two matrices and printing the result:

package main

import (
	"log"

	add "github.com/branogarbo/mtrix/addition"
	u "github.com/branogarbo/mtrix/util"
)

func main() {
	mat1 := u.Matrix{
		{1, -4, 9},
		{2.7, 3, 7},
		{0, -3.3, 8},
	}

	mat2 := u.Matrix{
		{1, 1, 1},
		{1, 1, 1},
		{1, 1, 1},
	}

	resultMat, err := add.MatAdd(mat1, mat2)
	if err != nil {
		log.Fatal(err)
	}

	u.PrintMat(resultMat)
}

Multiplying two matrices together and printing the result:

package main

import (
	"log"

	mult "github.com/branogarbo/mtrix/multiply"
	u "github.com/branogarbo/mtrix/util"
)

func main() {
	mat1 := u.Matrix{
		{1, -4},
		{2.7, 3},
		{0, -3.3},
	}

	mat2 := u.Matrix{
		{1, 0},
		{0, 1},
	}

	resultMat, err := mult.MatMult(mat1, mat2)
	if err != nil {
		log.Fatal(err)
	}

	u.PrintMat(resultMat)
}

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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