Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
gomatrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Daniel Jankowski
gomatrix
Commits
a3a7aedd
Commit
a3a7aedd
authored
6 years ago
by
Daniel Jankowski
Browse files
Options
Downloads
Patches
Plain Diff
Added: gaussian elimination
parent
0795fc6d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#4255
passed
6 years ago
Stage: test
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
algebra.go
+1
-0
1 addition, 0 deletions
algebra.go
gaussian.go
+32
-0
32 additions, 0 deletions
gaussian.go
gaussian_test.go
+28
-0
28 additions, 0 deletions
gaussian_test.go
matrix.go
+1
-0
1 addition, 0 deletions
matrix.go
with
62 additions
and
0 deletions
algebra.go
+
1
−
0
View file @
a3a7aedd
// Package gomatrix Is a go package for scientific operations with matrices in F2.
package
gomatrix
import
(
...
...
This diff is collapsed.
Click to expand it.
gaussian.go
0 → 100644
+
32
−
0
View file @
a3a7aedd
// Package gomatrix Is a go package for scientific operations with matrices in F2.
package
gomatrix
// GaussianElimination converts the matrix to an echelon form
//
// This function applies the gaussian elemination to the matrix in order to
// create an echelon form.
func
(
f
*
F2
)
GaussianElimination
()
{
// iterate through all possible pivot bits
for
pivotBit
:=
0
;
pivotBit
<
f
.
M
;
pivotBit
++
{
// iterate through the rows
for
rowCounter
:=
0
;
rowCounter
<
f
.
N
;
rowCounter
++
{
// if the pivotbit of this row is 0...
if
f
.
Rows
[
rowCounter
]
.
Bit
(
pivotBit
)
==
uint
(
0
)
{
// ...check the next row
continue
}
// if the row with a valid pivot bit is not the first row...
if
pivotBit
!=
rowCounter
{
// ...swap it with first one
f
.
SwapRows
(
pivotBit
,
rowCounter
)
}
// iterate through all other rows except the first one
for
rr
:=
pivotBit
+
1
;
rr
<
f
.
N
;
rr
++
{
// substract the 1 from all other rows with the pivotBit
f
.
Rows
[
rr
]
.
Xor
(
f
.
Rows
[
rr
],
f
.
Rows
[
pivotBit
])
}
}
}
}
This diff is collapsed.
Click to expand it.
gaussian_test.go
0 → 100644
+
28
−
0
View file @
a3a7aedd
// Package gomatrix Is a go package for scientific operations with matrices in F2.
package
gomatrix
import
(
"math/big"
"testing"
"github.com/stretchr/testify/assert"
)
func
TestGaussianElimination
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
description
string
matrixA
*
F2
expectedMatrix
*
F2
}{
{
matrixA
:
NewF2
(
2
,
2
)
.
Set
([]
*
big
.
Int
{
big
.
NewInt
(
2
),
big
.
NewInt
(
1
)}),
expectedMatrix
:
NewF2
(
2
,
2
)
.
Set
([]
*
big
.
Int
{
big
.
NewInt
(
1
),
big
.
NewInt
(
3
)}),
},
}
for
_
,
test
:=
range
tests
{
test
.
matrixA
.
GaussianElimination
()
assert
.
True
(
t
,
test
.
matrixA
.
IsEqual
(
test
.
expectedMatrix
))
}
}
This diff is collapsed.
Click to expand it.
matrix.go
+
1
−
0
View file @
a3a7aedd
// Package gomatrix Is a go package for scientific operations with matrices in F2.
package
gomatrix
import
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment