// MatrixMultiSimple is an operation that will multiple two matrices of any size together
func MatrixMultiSimple(matrixA ct.Matrix, matrixB ct.Matrix) (ct.Matrix, error) {
	if matrixA.GetNumCols() != matrixB.GetNumRows() {
		return nil, errors.New("Length of columns of matrix A not equal to length of rows of matrix B")
	}

	if matrixA.IsIdentity() {
		return matrixB, nil
	}

	if matrixB.IsIdentity() {
		return matrixA, nil
	}

	var sum float64

	matrixAB := ct.MakeMatrix(matrixA.GetNumRows(), matrixB.GetNumCols())

	for i := 0; i < matrixA.GetNumRows(); i++ {
		for j := 0; j < matrixB.GetNumCols(); j++ {
			sum = 0.0
			for k := 0; k < matrixA.GetNumCols(); k++ {
				sum += matrixA.Get(i, k) * matrixB.Get(k, j)
			}
			matrixAB.Set(i, j, sum)
		}
	}

	return matrixAB, nil
}
// MatrixAddition is an operation that will add two matrices together
func MatrixAddition(matrixA ct.Matrix, matrixB ct.Matrix) (ct.Matrix, error) {
	if matrixA.GetNumCols() != matrixB.GetNumCols() && matrixA.GetNumRows() != matrixB.GetNumRows() {
		return nil, errors.New("Matrices do not have equivalent dimensions")
	}

	matrixAB := ct.MakeMatrix(matrixA.GetNumRows(), matrixB.GetNumCols())

	for i := 0; i < matrixA.GetNumRows(); i++ {
		for j := 0; j < matrixA.GetNumCols(); j++ {
			matrixAB.Set(i, j, matrixA.Get(i, j)+matrixB.Get(i, j))
		}
	}

	return matrixAB, nil
}
// OuterProduct returns the outer product for real Vectors
func OuterProduct(vectorA ct.Vector, vectorB ct.Vector) (ct.Matrix, error) {
	if vectorA.Type() != ct.ColVector || vectorB.Typ() != ct.RowVector {
		return nil, errors.New("One or both vector types are not consistent with the vector inner product")
	}

	matrix := ct.MakeMatrix(vectorA.Dim(), vectorB.Dim())

	for i := 0; i < vectorA.Dim(); i++ {
		for j := 0; j < vectorB.Dim(); j++ {
			matrix.Set(i, j, vectorA.Get(i)*vectorB.Get(j))
		}
	}

	return matrix, nil
}