https://github.com/fibo/m2c
go for 2x2 complex matrices
https://github.com/fibo/m2c
complex-numbers matrix-calculations
Last synced: 11 months ago
JSON representation
go for 2x2 complex matrices
- Host: GitHub
- URL: https://github.com/fibo/m2c
- Owner: fibo
- License: mit
- Created: 2017-06-02T21:23:22.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2024-09-24T15:45:35.000Z (over 1 year ago)
- Last Synced: 2025-01-02T21:44:30.553Z (about 1 year ago)
- Topics: complex-numbers, matrix-calculations
- Language: Go
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# m2c
> go for 2x2 complex matrices
[](https://pkg.go.dev/github.com/fibo/m2c)
## Description
Complex matrices 2x2 (a.k.a. **m2c**) are a wonderful land to explore.
They are matrices of the form
```
| a b |
| c d |
```
Where a, b, c, d are complex numbers. I found Golang as the perfect
language to implement them since it has `complex128` data type, yeah!
## Examples
First of all import `m2c`.
```go
import "github.com/fibo/m2c"
```
Create an identity matrix
```go
var id = m2c.Matrix{1, 0, 0, 1}
fmt.Println(id) // {(1+0i) (0+0i) (0+0i) (1+0i)}
```
Multiply two matrices.
```go
var a = m2c.Matrix{1, 0, 0, 1}
var b = m2c.Matrix{1, 1 + 1i, 0, 1 - 1i}
var c = m2c.Mul(a, b)
fmt.Println(c) // {(1+0i) (1+1i) (1+1i) (1-1i)}
```
Invert a matrix.
```go
var d = m2c.Matrix{2i, 0, 0, 1}
var invD, err = m2c.Inv(d)
if err != nil {
log.Fatal(err)
}
fmt.Println(invD) // {(0-0.5i) (-0+0i) (-0+0i) (1+0i)}
```
## License
[MIT](https://fibo.github.io/mit-license/)