forked from skelterjohn/go.matrix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.go
54 lines (48 loc) · 1.51 KB
/
error.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright 2009 The GoMatrix Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package matrix
import "fmt"
const (
//The matrix returned was nil.
errorNilMatrix = iota + 1
//The dimensions of the inputs do not make sense for this operation.
errorDimensionMismatch
//The indices provided are out of bounds.
errorIllegalIndex
//The matrix provided has a singularity.
exceptionSingular
//The matrix provided is not positive semi-definite.
exceptionNotSPD
)
type error_ int
func (e error_) Error() string {
switch e {
case errorNilMatrix:
return "Matrix is nil"
case errorDimensionMismatch:
return "Input dimensions do not match"
case errorIllegalIndex:
return "Index out of bounds"
case exceptionSingular:
return "Matrix is singular"
case exceptionNotSPD:
return "Matrix is not positive semidefinite"
}
return fmt.Sprintf("Unknown error code %d", e)
}
func (e error_) String() string {
return e.Error()
}
var (
//The matrix returned was nil.
ErrorNilMatrix error_ = error_(errorNilMatrix)
//The dimensions of the inputs do not make sense for this operation.
ErrorDimensionMismatch error_ = error_(errorDimensionMismatch)
//The indices provided are out of bounds.
ErrorIllegalIndex error_ = error_(errorIllegalIndex)
//The matrix provided has a singularity.
ExceptionSingular error_ = error_(exceptionSingular)
//The matrix provided is not positive semi-definite.
ExceptionNotSPD error_ = error_(exceptionNotSPD)
)