A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
18
Task/Identity-matrix/Go/identity-matrix-1.go
Normal file
18
Task/Identity-matrix/Go/identity-matrix-1.go
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println(I(3))
|
||||
}
|
||||
|
||||
func I(n int) [][]float64 {
|
||||
m := make([][]float64, n)
|
||||
a := make([]float64, n*n)
|
||||
for i := 0; i < n; i++ {
|
||||
a[i] = 1
|
||||
m[i] = a[:n]
|
||||
a = a[n:]
|
||||
}
|
||||
return m
|
||||
}
|
||||
18
Task/Identity-matrix/Go/identity-matrix-2.go
Normal file
18
Task/Identity-matrix/Go/identity-matrix-2.go
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
type matrix []float64
|
||||
|
||||
func main() {
|
||||
fmt.Println(I(3))
|
||||
}
|
||||
|
||||
func I(n int) matrix {
|
||||
m := make(matrix, n*n)
|
||||
n++
|
||||
for i := 0; i < len(m); i += n {
|
||||
m[i] = 1
|
||||
}
|
||||
return m
|
||||
}
|
||||
11
Task/Identity-matrix/Go/identity-matrix-3.go
Normal file
11
Task/Identity-matrix/Go/identity-matrix-3.go
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
mat "github.com/skelterjohn/go.matrix"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println(mat.Eye(3))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue