Esempio n. 1
0
func NewMatrix(row, col int) Matrix {
	m := make([]vector.Vector, col)
	for i, _ := range m {
		m[i] = vector.NewVector(row)
	}
	return m
}
Esempio n. 2
0
// return row 'row' in matrix, row starts from 1,
// NOTE: the returned vector is a new vector, not a reference to the vector in matrix
func (m Matrix) Row(row int) vector.Vector {
	if row > 0 && row <= m.Rows() {
		v := vector.NewVector(m.Cols())
		for i := 1; i <= m.Cols(); i++ {
			v.Set(i, m.Column(i).Get(row))
		}
		return v
	}

	return nil
}
Esempio n. 3
0
func TestNewMatrix(t *testing.T) {
	m := NewMatrix(3, 3)
	m.Init(vector.NewVector(3, 1, 2, 3), vector.NewVector(3, 4, 5, 6), vector.NewVector(3, 7, 8, 9))
	t.Log(m)
}
Esempio n. 4
0
func init() {
	m1.Init(vector.NewVector(3, 1, 2, 3), vector.NewVector(3, 4, 5, 6), vector.NewVector(3, 7, 8, 9))
	m2.Init(vector.NewVector(3, 7, 8, 9), vector.NewVector(3, 4, 5, 6), vector.NewVector(3, 1, 2, 3))
}
Esempio n. 5
0
func NewVector4(x, y, z, w float64) *Vector4 {
	return &Vector4{vector.NewVector(4, x, y, z, w)}
}
Esempio n. 6
0
func NewVector3(x, y, z float64) *Vector3 {
	return &Vector3{vector.NewVector(3, x, y, z)}
}