remove impossible errors
parent
1b1eb861ea
commit
5784cfa7ff
17
matrix.go
17
matrix.go
|
@ -104,10 +104,7 @@ func (m matrix) Multiply(right matrix) (matrix, error) {
|
|||
if len(m[0]) != len(right) {
|
||||
return nil, fmt.Errorf("columns on left (%d) is different than rows on right (%d)", len(m[0]), len(right))
|
||||
}
|
||||
result, err := newMatrix(len(m), len(right[0]))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result, _ := newMatrix(len(m), len(right[0]))
|
||||
for r, row := range result {
|
||||
for c := range row {
|
||||
var value byte
|
||||
|
@ -202,16 +199,10 @@ func (m matrix) Invert() (matrix, error) {
|
|||
}
|
||||
|
||||
size := len(m)
|
||||
work, err := identityMatrix(size)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
work, err = m.Augment(work)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
work, _ := identityMatrix(size)
|
||||
work, _ = m.Augment(work)
|
||||
|
||||
err = work.gaussianElimination()
|
||||
err := work.gaussianElimination()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -120,19 +120,9 @@ func New(dataShards, parityShards int) (Encoder, error) {
|
|||
// This will make the top square be the identity matrix, but
|
||||
// preserve the property that any square subset of rows is
|
||||
// invertible.
|
||||
top, err := vm.SubMatrix(0, 0, dataShards, dataShards)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
top, err = top.Invert()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r.m, err = vm.Multiply(top)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
top, _ := vm.SubMatrix(0, 0, dataShards, dataShards)
|
||||
top, _ = top.Invert()
|
||||
r.m, _ = vm.Multiply(top)
|
||||
|
||||
r.parity = make([][]byte, parityShards)
|
||||
for i := range r.parity {
|
||||
|
|
Loading…
Reference in New Issue