(* ::Package:: *)

(************************************************************************)
(* This file was generated automatically by the Mathematica front end.  *)
(* It contains Initialization cells from a Notebook file, which         *)
(* typically will have the same name as this file except ending in      *)
(* ".nb" instead of ".m".                                               *)
(*                                                                      *)
(* This file is intended to be loaded into the Mathematica kernel using *)
(* the package loading commands Get or Needs.  Doing so is equivalent   *)
(* to using the Evaluate Initialization Cells menu command in the front *)
(* end.                                                                 *)
(*                                                                      *)
(* DO NOT EDIT THIS FILE.  This entire file is regenerated              *)
(* automatically each time the parent Notebook file is saved in the     *)
(* Mathematica front end.  Any changes you make to this file will be    *)
(* overwritten.                                                         *)
(************************************************************************)



Clear[RandomSym, RandomVec, RandomMat]
RandomSym[n_, Distribution_:UniformDistribution[{1,2}]]:=Module[
{Q,dia},
Dia=SparseArray[Band[{1,1}]:>RandomReal[Distribution],{n,n}];
Q=QRDecomposition[RandomReal[{-1,1},{n,n}]][[1]];
Q.Dia.Transpose[Q]
]
RandomVec[n_,Distribution_:UniformDistribution[{-1,1}]]:= RandomReal[Distribution,n]
RandomMat[{m_,n_},Distribution_:UniformDistribution[{-1,1}]]:= RandomReal[Distribution,{m,n}]


KKTSolve[{G_,c_},{A_,b_}]:= Module[
{KKTMat,KKTRHS,x\[Lambda]Star,n=Length[c]},
KKTMat=ArrayFlatten[{{G, -Transpose[A]},{A,0}}];
KKTRHS=Join[-c, b];
x\[Lambda]Star=LinearSolve[KKTMat, KKTRHS];
{Take[x\[Lambda]Star,n],Drop[x\[Lambda]Star,n]}
]



