/* $Id: mvol.cpp,v 1.4 2004/11/12 04:37:15 fujiwara Exp $ */ /* * ## origianl ################################################# MixedVol: Polynomial system mixed volume calculation program. * Version 1.0 Copyright (C) 2003 Tangan Gao, T. Y. Li, Xing Li, and Mengnien Wu. * ############################################################### */ #include #include #include #include #include #include "GetOption/getopt.h" #include "PolyReader/PolynomialSystemReader.h" #include "PolyReader/PolynomialException.h" #include "PreProcess/Pre4MV.h" #include "MixedVol/MixedVol.h" extern int debug_print; extern "C" int mvol(int nVar,int *Spt1stIdx,int **Spt) { int i, j=0, k; int nPts = 0; int nSpt; nPts = Spt1stIdx[nVar]; for (i=nVar-1; i>=0; i--){ Spt1stIdx[i] = Spt1stIdx[i+1] - Spt1stIdx[i]; } // Quick return if 1-variable system or less than two terms k = -1; for (i=0; i= 0 ){ if( debug_print >= 2 ){ cout << "The " << k+1 << "-th support has less than 2 points" << endl; } return 0; // end of the case: too few terms } if ( nVar == 1 ){ int kmin, kmax; kmin = INT_MAX/2; kmax = -INT_MAX/2; for (i=0; i= 2 ){ cout << "A 1-dimensional support, its mixed volume is " << kmax-kmin << endl; } return (kmax-kmin); // end of the case: 1-variable } for (i=0; i 1 || k > 1 ){ j = -1; break; } } if ( j != -1 ){ if( debug_print >= 2 ){ cout << "A linear support, its mixed volume <= 1" << endl; } return 1; } // end of quick return // To preprocess the support int* SptType = new int [nVar]; int* SptVtx1stIdx = new int [nVar+1]; int** SptVtx = new int* [nPts]; SptVtx[0] = new int [nVar*nPts]; for (i=1; i= 2 ){ cout << "The mixed volume is " << MVol << endl; } // Clean the memory while( ! MCells.IsEmpty() ) MCells.Pop(); delete [] SptType; delete [] SptVtx1stIdx; delete [] SptVtx[0]; delete [] SptVtx; delete [] NuIdx2OldIdx; delete [] lft; return MVol; }