void Init() {
   const int n = baseG.size();
   mapto = vector<pair<int, int> >(n, make_pair(-1, -1));
   mapfrom.clear();
   vector<int> size(n, 0);
   int start = -1;
   for (int i = 0; i < n; i++) {
     if (baseG[i].size() <= 1) {
       start = i;
       break;
     }
   }
   assert(start != -1);
   SizeCheckBfs(start, size);
   Decomposition(start, start, 0, 0, 0, size);
 }
예제 #2
0
void CallFunction(FunctionCall fc)
{
	int function = GetFunction(fc->function);
	
	switch (function)
	{
		case VAR : NewVariable(fc); break;
		case NMX : NewMatrix(fc); break;
		case ADD : Addition(fc); break;
		case SUB : Substraction(fc); break;
		case MUL : Multiplication(fc); break;
		case MSC : Scalar_Mult(fc); break;
		case EXP : Exponentiation(fc); break;
		case TRA : Transpose(fc); break;
		case DET : Determinant(fc); break;
		case DLU : Decomposition(fc); break;
		case SOL : Solve(fc); break;
		case INV : Inversion(fc); break;
		case RNK : Rank(fc); break;
		case DSP : Display(fc); break;
		case NOF : // default
		default :
		{
			if (GetFunction(fc->name)==SPT) SpeedTest(fc);
			else if (IndexVariable(fc->function)!=-1) NewVariable(fc);
			else if (IndexMatrix(fc->function)!=-1) NewMatrix(fc);
			else
			{
				printf("\t%s : Function Not Implemented\n", fc->function);
				fni++;
			}
			break;
		}
	}
	
	if (function!=NOF && function !=VAR) fni = 0;
}
예제 #3
0
// Returns a pointer to solution array.
int* solve-ls(int A[][], int b[], int ) {
	LUP-Decomposition();
	int* result = LUP-SOLVE();
	return result;
}