func matrixNaN(x *matrix.FloatMatrix) bool { for i := 0; i < x.NumElements(); i++ { if math.IsNaN(x.GetIndex(i)) { return true } } return false }
/* Returns x' * J * y, where J = [1, 0; 0, -I]. */ func jdot(x, y *matrix.FloatMatrix, n, offsetx, offsety int) float64 { if n <= 0 { n = x.NumElements() } a := blas.DotFloat(x, y, &la_.IOpt{"n", n - 1}, &la_.IOpt{"offsetx", offsetx + 1}, &la_.IOpt{"offsety", offsety + 1}) return x.GetIndex(offsetx)*y.GetIndex(offsety) - a }
/* Returns sqrt(x' * J * x) where J = [1, 0; 0, -I], for a vector x in a second order cone. */ func jnrm2(x *matrix.FloatMatrix, n, offset int) float64 { /*DEBUGGED*/ if n <= 0 { n = x.NumElements() } if offset < 0 { offset = 0 } a := blas.Nrm2Float(x, &la_.IOpt{"n", n - 1}, &la_.IOpt{"offset", offset + 1}) fst := x.GetIndex(offset) return math.Sqrt(fst-a) * math.Sqrt(fst+a) }