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
1fa7a827
Commit
1fa7a827
authored
6 years ago
by
Daniel Jankowski
Browse files
Options
Downloads
Patches
Plain Diff
Added: some print functions for the matrix
parent
82009a79
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#4272
passed
6 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
print.go
+40
-0
40 additions, 0 deletions
print.go
print_test.go
+23
-0
23 additions, 0 deletions
print_test.go
with
63 additions
and
0 deletions
print.go
0 → 100644
+
40
−
0
View file @
1fa7a827
// Package gomatrix Is a go package for scientific operations with matrices in F2.
package
gomatrix
import
(
"fmt"
)
// PrettyPrint prints the matrix to stdout
func
(
f
*
F2
)
PrettyPrint
()
{
f
.
printWithSeperators
(
" "
,
"
\n
"
)
}
// PrintLaTex prints the matrix as latex code
func
(
f
*
F2
)
PrintLaTex
()
{
fmt
.
Printf
(
"
\\
begin{bmatrix}
\n
"
)
f
.
printWithSeperators
(
" & "
,
"
\\\n
"
)
fmt
.
Printf
(
"
\\
end{bmatrix}
\n
"
)
}
// PrintCSV prints the matrix as csv
func
(
f
*
F2
)
PrintCSV
()
{
f
.
printWithSeperators
(
", "
,
"
\n
"
)
}
// printWithSeperators prints the matrix with custom seperators
//
// @param string valSep The seperator for the single values
// @param string lineSep The line seperator
func
(
f
*
F2
)
printWithSeperators
(
valSep
,
lineSep
string
)
{
for
_
,
row
:=
range
f
.
Rows
{
for
i
:=
0
;
i
<
f
.
M
;
i
++
{
if
i
==
f
.
M
-
1
{
fmt
.
Printf
(
"%d "
,
row
.
Bit
(
i
))
continue
}
fmt
.
Printf
(
"%d%s"
,
row
.
Bit
(
i
),
valSep
)
}
fmt
.
Print
(
lineSep
)
}
}
This diff is collapsed.
Click to expand it.
print_test.go
0 → 100644
+
23
−
0
View file @
1fa7a827
// Package gomatrix Is a go package for scientific operations with matrices in F2.
package
gomatrix
import
(
"math/big"
"testing"
)
func
TestPrettyPrint
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
matrix
*
F2
}{
{
matrix
:
NewF2
(
3
,
3
)
.
Set
([]
*
big
.
Int
{
big
.
NewInt
(
5
),
big
.
NewInt
(
3
),
big
.
NewInt
(
2
)}),
},
}
for
_
,
test
:=
range
tests
{
test
.
matrix
.
PrettyPrint
()
test
.
matrix
.
PrintLaTex
()
test
.
matrix
.
PrintCSV
()
}
}
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