matrix

package
v0.0.0-...-a4a72b7 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

filename: strassenmatrixmultiply.go description: Implements matrix multiplication using the Strassen algorithm. details: This program takes two matrices as input and performs matrix multiplication using the Strassen algorithm, which is an optimized divide-and-conquer approach. It allows for efficient multiplication of large matrices. author(s): Mohit Raghav(https://github.com/mohit07raghav19) See strassenmatrixmultiply_test.go for test cases

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValid

func IsValid[T constraints.Integer](elements [][]T) bool

IsValid checks if the input matrix has consistent row lengths.

Types

type Matrix

type Matrix[T constraints.Integer] struct {
	// contains filtered or unexported fields
}

func New

func New[T constraints.Integer](rows, columns int, initial T) Matrix[T]

NewMatrix creates a new Matrix based on the provided arguments.

func NewFromElements

func NewFromElements[T constraints.Integer](elements [][]T) (Matrix[T], error)

NewFromElements creates a new Matrix from the given elements.

func (Matrix[T]) Add

func (m1 Matrix[T]) Add(m2 Matrix[T]) (Matrix[T], error)

Add adds two matrices.

func (Matrix[T]) CheckEqual

func (m1 Matrix[T]) CheckEqual(m2 Matrix[T]) bool

CheckEqual checks if the current matrix is equal to another matrix (m2). Two matrices are considered equal if they have the same dimensions and all their elements are equal.

func (Matrix[T]) Columns

func (m Matrix[T]) Columns() int

func (Matrix[T]) Copy

func (m Matrix[T]) Copy() (Matrix[T], error)

func (Matrix[T]) Get

func (m Matrix[T]) Get(row, col int) (T, error)

func (Matrix[T]) MatchDimensions

func (m Matrix[T]) MatchDimensions(m1 Matrix[T]) bool

MatchDimensions checks if two matrices have the same dimensions.

func (Matrix[T]) Multiply

func (m1 Matrix[T]) Multiply(m2 Matrix[T]) (Matrix[T], error)

Multiply multiplies the current matrix (m1) with another matrix (m2) and returns the result as a new matrix.

func (Matrix[T]) Rows

func (m Matrix[T]) Rows() int

func (Matrix[T]) Set

func (m Matrix[T]) Set(row, col int, val T) error

func (Matrix[T]) StrassenMatrixMultiply

func (A Matrix[T]) StrassenMatrixMultiply(B Matrix[T]) (Matrix[T], error)

Perform matrix multiplication using Strassen's algorithm

func (Matrix[T]) String

func (m Matrix[T]) String() string

String implements the fmt.Stringer interface for Matrix.

func (Matrix[T]) SubMatrix

func (m Matrix[T]) SubMatrix(rowStart, colStart, numRows, numCols int) (Matrix[T], error)

SubMatrix extracts a submatrix from the current matrix.

func (Matrix[T]) Subtract

func (m1 Matrix[T]) Subtract(m2 Matrix[T]) (Matrix[T], error)

Subtract subtracts two matrices.

Jump to

Keyboard shortcuts

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