@Override
	public DoubleMatrix1D[] solve() throws Exception {

		DoubleMatrix1D v = null;// dim equals cols of A
		DoubleMatrix1D w = null;// dim equals rank of A
		
		if (log.isDebugEnabled()) {
			log.debug("H: " + ArrayUtils.toString(H.toArray()));
			log.debug("g: " + ArrayUtils.toString(g.toArray()));
			if (A != null) {
				log.debug("A: " + ArrayUtils.toString(A.toArray()));
			}
			if (h != null) {
				log.debug("h: " + ArrayUtils.toString(h.toArray()));
			}
		}
		
		//compose the full KKT matrix
		DoubleMatrix2D KKT = null;
		DoubleMatrix1D b = null;
		final DoubleMatrix2D HFull = ColtUtils.fillSubdiagonalSymmetricMatrix((SparseDoubleMatrix2D)this.H);
		
		if (this.A != null) {
			if(h!=null){
				//H.v + [A]T.w = -g
				//A.v = -h
				DoubleMatrix2D[][] parts = {
						{ HFull, this.AT },
						{ this.A, null } };
				if(HFull instanceof SparseDoubleMatrix2D && A instanceof SparseDoubleMatrix2D){
					KKT = DoubleFactory2D.sparse.compose(parts);
				}else{
					KKT = DoubleFactory2D.dense.compose(parts);
				}
				
				b = F1.append(g, h).assign(Mult.mult(-1));
			}else{
				//H.v + [A]T.w = -g
				DoubleMatrix2D[][] parts = {{ HFull, this.AT }};
				if(HFull instanceof SparseDoubleMatrix2D && A instanceof SparseDoubleMatrix2D){
					KKT = DoubleFactory2D.sparse.compose(parts);
				}else{
					KKT = DoubleFactory2D.dense.compose(parts);
				}
				b = ColtUtils.scalarMult(g, -1);
			}
		}else{
			KKT = HFull;
			b = ColtUtils.scalarMult(g, -1);
		}
		
		//factorization
		//LDLTPermutedFactorization KKTFact = new LDLTPermutedFactorization(KKT, new RequestFilter());
		QRSparseFactorization KKTFact = new QRSparseFactorization((SparseDoubleMatrix2D)KKT, new Matrix1NornRescaler());
		try{
			KKTFact.factorize();
		}catch(Exception e){
			log.error("singular KKT system");
			throw new Exception("singular KKT system");
		}
		
		DoubleMatrix1D x = KKTFact.solve(b);
		v = x.viewPart(0, H.rows());
		w = x.viewPart(H.rows()-1, x.size()-H.rows());

		// solution checking
		if (this.checkKKTSolutionAccuracy && !this.checkKKTSolutionAccuracy(v, w)) {
			log.error("KKT solution failed");
			throw new Exception("KKT solution failed");
		}

		DoubleMatrix1D[] ret = new DoubleMatrix1D[2];
		ret[0] = v;// dim equals cols of A
		ret[1] = w;
		return ret;
	}
@ Override public DoubleMatrix1D [ ] solve ( ) throws Exception { DoubleMatrix1D v = null ; DoubleMatrix1D w = null ; if ( log . isDebugEnabled ( ) ) { log . debug ( "H: " + ArrayUtils . toString ( H . toArray ( ) ) ) ; log . debug ( "g: " + ArrayUtils . toString ( g . toArray ( ) ) ) ; if ( A != null ) { log . debug ( "A: " + ArrayUtils . toString ( A . toArray ( ) ) ) ; } if ( h != null ) { log . debug ( "h: " + ArrayUtils . toString ( h . toArray ( ) ) ) ; } } DoubleMatrix2D KKT = null ; DoubleMatrix1D b = null ; final DoubleMatrix2D HFull = ColtUtils . fillSubdiagonalSymmetricMatrix ( ( SparseDoubleMatrix2D ) this . H ) ; if ( this . A != null ) { if ( h != null ) { DoubleMatrix2D [ ] [ ] parts = { { HFull , this . AT } , { this . A , null } } ; if ( HFull instanceof SparseDoubleMatrix2D && A instanceof SparseDoubleMatrix2D ) { KKT = DoubleFactory2D . sparse . compose ( parts ) ; } else { KKT = DoubleFactory2D . dense . compose ( parts ) ; } b = F1 . append ( g , h ) . assign ( Mult . mult ( - 1 ) ) ; } else { DoubleMatrix2D [ ] [ ] parts = { { HFull , this . AT } } ; if ( HFull instanceof SparseDoubleMatrix2D && A instanceof SparseDoubleMatrix2D ) { KKT = DoubleFactory2D . sparse . compose ( parts ) ; } else { KKT = DoubleFactory2D . dense . compose ( parts ) ; } b = ColtUtils . scalarMult ( g , - 1 ) ; } } else { KKT = HFull ; b = ColtUtils . scalarMult ( g , - 1 ) ; } QRSparseFactorization KKTFact = new QRSparseFactorization ( ( SparseDoubleMatrix2D ) KKT , new Matrix1NornRescaler ( ) ) ; try { KKTFact . factorize ( ) ; } catch ( Exception e ) { log . error ( "singular KKT system" ) ; throw new Exception ( "singular KKT system" ) ; } DoubleMatrix1D x = KKTFact . solve ( b ) ; v = x . viewPart ( 0 , H . rows ( ) ) ; w = x . viewPart ( H . rows ( ) - 1 , x . size ( ) - H . rows ( ) ) ; if ( this . checkKKTSolutionAccuracy && ! this . checkKKTSolutionAccuracy ( v , w ) ) { log . error ( "KKT solution failed" ) ; throw new Exception ( "KKT solution failed" ) ; } DoubleMatrix1D [ ] ret = new DoubleMatrix1D [ 2 ] ; ret [ 0 ] = v ; ret [ 1 ] = w ; return ret ; }
Returns the two vectors v and w.