예제 #1
0
func main() {
	// matrix string in row order presentation
	sA :=
		"[-7.44e-01  1.11e-01  1.29e+00  2.62e+00 -1.82e+00]" +
			"[ 4.59e-01  7.06e-01  3.16e-01 -1.06e-01  7.80e-01]" +
			"[-2.95e-02 -2.22e-01 -2.07e-01 -9.11e-01 -3.92e-01]" +
			"[-7.75e-01  1.03e-01 -1.22e+00 -5.74e-01 -3.32e-01]" +
			"[-1.80e+00  1.24e+00 -2.61e+00 -9.31e-01 -6.38e-01]"

	sb :=
		"[ 8.38e-01]" +
			"[ 9.92e-01]" +
			"[ 9.56e-01]" +
			"[ 6.14e-01]" +
			"[ 6.56e-01]" +
			"[ 3.57e-01]" +
			"[ 6.36e-01]" +
			"[ 5.08e-01]" +
			"[ 8.81e-03]" +
			"[ 7.08e-02]"

	b, _ := matrix.FloatParsePy(sb)
	Al, _ := matrix.FloatParsePy(sA)
	Au := Al.Copy().Neg()
	A := matrix.FloatZeros(2*Al.Rows(), Al.Cols())
	A.SetSubMatrix(0, 0, Al)
	A.SetSubMatrix(Al.Rows(), 0, Au)

	//fmt.Printf("A (%d,%d):\n%v\n", A.Rows(), A.Cols(), A)
	//fmt.Printf("b (%d,%d):\n%v\n", b.Rows(), b.Cols(), b)
	x, nt := Acent(A, b, 10)
	fmt.Printf("nt:\n%v\n", nt)
	fmt.Printf("x :\n%v\n", x)
}
예제 #2
0
func TestComputeScaling() {
	dims := makeDims()
	sS :=
		"[ 3.57e+01]" +
			"[ 3.61e+01]" +
			"[ 2.29e+01]" +
			"[ 1.58e+01]" +
			"[-1.50e+01]" +
			"[ 1.22e+00]" +
			"[ 4.39e+01]" +
			"[ 2.99e-01]" +
			"[ 3.71e-01]" +
			"[-8.84e-01]" +
			"[ 1.07e+02]" +
			"[-2.80e+01]" +
			"[-2.24e+01]" +
			"[ 3.00e+01]" +
			"[ 1.22e+02]" +
			"[ 2.26e+01]" +
			"[ 1.90e+01]" +
			"[-2.30e+01]" +
			"[ 4.57e+01]"

	zS :=
		"[ 1.28e+00]" +
			"[ 1.21e+00]" +
			"[ 1.23e+00]" +
			"[ 1.00e-02]" +
			"[ 7.99e-03]" +
			"[ 9.00e-02]" +
			"[ 1.16e+00]" +
			"[-6.30e-03]" +
			"[-4.97e-04]" +
			"[-5.57e-03]" +
			"[ 1.26e+00]" +
			"[ 8.42e-03]" +
			"[-3.01e-02]" +
			"[ 0.00e+00]" +
			"[ 1.13e+00]" +
			"[-8.81e-02]" +
			"[ 0.00e+00]" +
			"[ 0.00e+00]" +
			"[ 1.06e+00]"

	s, _ := matrix.FloatParsePy(sS)
	z, _ := matrix.FloatParsePy(zS)
	lmbda := matrix.FloatZeros(14, 1)
	W, err := cvx.ComputeScaling(s, z, lmbda, dims, 0)
	fmt.Printf("lmbda=\n%v\n", lmbda)
	W.Print()
	if W == nil || err == nil {
	}
}
예제 #3
0
func TestJnrm2() {
	s, _ := matrix.FloatParsePy(sS)
	aa := cvx.Jnrm2(s, 4, 2)
	fmt.Printf("aa = %v\n", aa)
}
예제 #4
0
func TestSinv2() {
	dims := makeDims()
	sS2 :=
		"[ 4.58e+01]" +
			"[ 4.35e+01]" +
			"[ 2.83e+01]" +
			"[ 1.97e+01]" +
			"[-1.84e+01]" +
			"[ 2.69e+00]" +
			"[ 5.09e+01]" +
			"[ 7.07e-02]" +
			"[ 4.09e-01]" +
			"[-1.27e+00]" +
			"[ 1.75e+02]" +
			"[ 0.00e+00]" +
			"[ 0.00e+00]" +
			"[ 0.00e+00]" +
			"[ 1.04e+02]" +
			"[ 0.00e+00]" +
			"[ 0.00e+00]" +
			"[ 0.00e+00]" +
			"[ 3.89e+01]"
	lmbdaS2 :=
		"[ 6.77e+00]" +
			"[ 6.59e+00]" +
			"[ 4.27e+00]" +
			"[ 2.30e+00]" +
			"[-2.16e+00]" +
			"[ 3.15e-01]" +
			"[ 7.14e+00]" +
			"[ 4.95e-03]" +
			"[ 2.86e-02]" +
			"[-8.90e-02]" +
			"[ 1.32e+01]" +
			"[ 1.02e+01]" +
			"[ 6.24e+00]" +
			"[ 1.00e+00]"

	sinv_res :=
		"[-6.77e+00]" +
			"[-6.59e+00]" +
			"[-4.27e+00]" +
			"[-2.30e+00]" +
			"[ 2.16e+00]" +
			"[-3.15e-01]" +
			"[-7.14e+00]" +
			"[-4.95e-03]" +
			"[-2.86e-02]" +
			"[ 8.90e-02]" +
			"[-1.32e+01]" +
			"[-0.00e+00]" +
			"[-0.00e+00]" +
			"[-0.00e+00]" +
			"[-1.02e+01]" +
			"[-0.00e+00]" +
			"[-0.00e+00]" +
			"[-0.00e+00]" +
			"[-6.24e+00]"

	s, _ := matrix.FloatParsePy(sS2)
	lmbda, _ := matrix.FloatParsePy(lmbdaS2)
	cvx.Sinv(s, lmbda, dims, 0)
	blas.ScalFloat(s, -1.0)
	res_s, _ := matrix.FloatParsePy(sinv_res)
	fmt.Printf("res=\n%v\n", s)
	fmt.Printf("OK=%v\n", s.Equal(res_s))
}