Example #1
0
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
  /* inputs */
  float *img,step,res,hiThresh,loThresh;
  int nx,ny;

  /* output */
  double *pStat,dummyStatus;
  /*mxArray *es;   Structure of edge-line arrays */

  /* Local */
  EdgeLines el;

  if (nlhs>1)
    { /* enable status return */
      plhs[1] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
      pStat = (double *)mxGetPr(plhs[1]);
    }
  else pStat = &dummyStatus;

  img = parseInputs(nrhs,prhs,&nx,&ny,&step,&res,&hiThresh,&loThresh);

  if (img)
    {
      el = subCannyEdge(img,nx,ny,step,res,hiThresh,loThresh);
      plhs[0] = unpackEdgeLines(&el);
      freeEdgeLines(&el);
    }
  else
    { plhs[0] = NULL; }
}
Example #2
0
UnitInfo::UnitInfo (const char* nameToUse, 
                    const char* detailToUse, ...) throw()
:   name (nameToUse),
    detail (detailToUse)
{
    va_list args;
    va_start(args, detailToUse);
    parseOutputs (args);
    parseInputs (args);
    va_end(args); 
}
int main(int iArgCnt, char* sArrArgs[])
{
	int iIterationNo = 0;
	double dNormOfResult = 0;
	double dTime0 = 0, dTime1 = 0, dTimeDiff = 0, dMinTimeDiff = DBL_MAX, dMaxTimeDiff = 0;

	parseInputs(iArgCnt, sArrArgs);

	MPI_Init(&iArgCnt, &sArrArgs);
	MPI_Comm_size(MPI_COMM_WORLD, &GiProcessCnt);
	MPI_Comm_rank(MPI_COMM_WORLD, &GiProcessRank);

	initData();

	for(iIterationNo = 0; iIterationNo < GiIterationCnt; iIterationNo++)
	{
		MPI_Barrier(MPI_COMM_WORLD);
		dTime0 = MPI_Wtime();

		cblas_dgemv(CblasRowMajor, CblasNoTrans, GiRowCntForOneProc, GiVectorLength, 1.0, GdArrSubMatrix, GiVectorLength, GdArrVector, 1, 0.0, GdArrSubResult, 1);

		MPI_Barrier(MPI_COMM_WORLD);
		MPI_Gather(GdArrSubResult, GiRowCntForOneProc, MPI_DOUBLE, GdArrTotalResult, GiRowCntForOneProc, MPI_DOUBLE, 0, MPI_COMM_WORLD);

		dTime1 = MPI_Wtime();
		dTimeDiff = (dTime1 - dTime0);

		if(dTimeDiff > dMaxTimeDiff)
			dMaxTimeDiff = dTimeDiff;
		if(dTimeDiff < dMinTimeDiff)
			dMinTimeDiff = dTimeDiff;
	}

	if(GiProcessRank == 0)
	{
		dNormOfResult = cblas_dnrm2(GiVectorLength, GdArrTotalResult, 1);
		printf("Result=%f\nMin Time=%f uSec\nMax Time=%f uSec\n", dNormOfResult, (1.e6 * dMinTimeDiff), (1.e6 * dMaxTimeDiff));
	}

	MPI_Finalize();

	return 0;
}
Example #4
0
int main(int argc, char *argv[]){
	int c = -1; // getopt options
	static char usageInfo[] = "[-i input_file] [-o output_file] [-d debug_log_file]\n"; // Prompt on invalid input
	std::string inputFile, outputFile, debugFile;
	std::ofstream outFile, debFile;

if (debug){
	*outputSS<<"Parsing options if they exist."<<std::endl;
}

	// Added:in front of arguement list to suppress errors and use custom error code
	while ((c = getopt(argc, argv, ":i:o:d:")) != -1){ 
		switch (c){
			case 'i':
				inputFile = optarg;
				break;
			case 'o':
				outputFile = optarg;
				break;
			case 'd':
				debugFile = optarg;
				debug = true;
				break;
			case ':':
				switch (optopt){
					case 'i':
						if (inputFile.empty()){
							std::cout<<"Please specify the network topology input file:\n";
							getline(std::cin, inputFile);
						}
						break;
					case 'o':
						if (outputFile.empty()){
							std::cout<<"Please specify the output file:\n";
							getline(std::cin, outputFile);
						}
						break;
					case 'd':
						std::cout<<"No debug file specified. Defaulting to cout."<<std::endl;
						break;
				}
				break;
			case '?':
				*errorSS<<"Error Invalid option:"<<c<<std::endl;
				return -1;
				break;
			default:
				*errorSS<<"Usage:"<<argv[0]<<" "<<usageInfo<<std::endl;
		}
	}
	if (inputFile.empty()){
		std::cout<<"Please specify the network topology input file:\n";
		getline(std::cin, inputFile);
	}
	if (outputFile.empty()){
		std::cout<<"Please specify the output file:\n";
		getline(std::cin, outputFile);
	}
	outFile.open(outputFile.c_str());
	if (outFile.fail()){
		std::cerr<<"Failed to open output file "<<outputFile<<". Are you sure you want to use cout? (y/N)"<<std::endl;
		getline(std::cin, outputFile);
		if (outputFile  != "y"){
			return -1;
		}
	} else {
		outputSS = &outFile;
	}

if (debug){
	debFile.open(debugFile.c_str());
	if (debFile.fail()){
		std::cerr<<"Failed to open debug file "<<debugFile<<". Are you sure you want to use cout? (y/N)"<<std::endl;
		getline(std::cin, debugFile);
	} else {
		debugSS = &debFile;
	}
}

if (debug){
	// Start Debug Logging
	*debugSS<<"Category,SimulationTime,Descriptions,Key,Value,Pairs"<<std::endl;
}

	// Create Network Simulator object 
	net *Network = new net();

if (debug){
	std::cout<<"Created Network Simulator object."<<std::endl;
}
	
	// Load JSON Input File
	parseInputs(*Network, inputFile);

if (debug){
	std::cout<<"Loaded Network Topology."<<std::endl<<std::endl;
}

	Network->run();

	return 0;
}
int main(int argc, char **argv)
{
    /*
     * Parse options.
     */
    for (int i = 1; i < argc; i++)
    {
        const char *psz = argv[i];
        if (*psz == '-')
        {
            if (!strcmp(psz, "--output") || !strcmp(psz, "-o"))
            {
                if (++i >= argc)
                {
                    fprintf(stderr, "syntax error: File name expected after '%s'.\n", psz);
                    return RTEXITCODE_SYNTAX;
                }
                g_pszOutput = argv[i];
            }
            else if (!strcmp(psz, "--library") || !strcmp(psz, "-l"))
            {
                if (++i >= argc)
                {
                    fprintf(stderr, "syntax error: Library name expected after '%s'.\n", psz);
                    return RTEXITCODE_SYNTAX;
                }
                g_pszLibrary = argv[i];
            }
            else if (!strcmp(psz, "--explicit-load-function"))
                g_fWithExplictLoadFunction = true;
            else if (!strcmp(psz, "--no-explicit-load-function"))
                g_fWithExplictLoadFunction = false;
            /** @todo Support different load methods so this can be used on system libs and
             *        such if we like. */
            else if (   !strcmp(psz, "--help")
                        || !strcmp(psz, "-help")
                        || !strcmp(psz, "-h")
                        || !strcmp(psz, "-?") )
                return usage(argv[0]);
            else if (   !strcmp(psz, "--version")
                        || !strcmp(psz, "-V"))
            {
                printf("$Revision: 98271 $\n");
                return RTEXITCODE_SUCCESS;
            }
            else
            {
                fprintf(stderr, "syntax error: Unknown option '%s'.\n", psz);
                return RTEXITCODE_SYNTAX;
            }
        }
        else
        {
            if (g_cInputs >= RT_ELEMENTS(g_apszInputs))
            {
                fprintf(stderr, "syntax error: Too many input files, max is %d.\n", (int)RT_ELEMENTS(g_apszInputs));
                return RTEXITCODE_SYNTAX;
            }
            g_apszInputs[g_cInputs++] = argv[i];
        }
    }
    if (g_cInputs == 0)
    {
        fprintf(stderr, "syntax error: No input file specified.\n");
        return RTEXITCODE_SYNTAX;
    }
    if (!g_pszOutput)
    {
        fprintf(stderr, "syntax error: No output file specified.\n");
        return RTEXITCODE_SYNTAX;
    }
    if (!g_pszLibrary)
    {
        fprintf(stderr, "syntax error: No library name specified.\n");
        return RTEXITCODE_SYNTAX;
    }

    /*
     * Do the job.
     */
    RTEXITCODE rcExit = parseInputs();
    if (rcExit == RTEXITCODE_SUCCESS)
        rcExit = generateOutput();
    return rcExit;
}
Example #6
0
void RobustBundleRTS::run(int nPtsCon, int nCamsCon, int maxIter,
		int nInnerMaxIter) {
	parseInputs(mapAndVecFeatPts);
	bundleAdjustRobust(nCamsCon, Ks, Rs, Ts, nPtsCon, pt3Ds, meas2Ds, m_maxErr,
			maxIter, nInnerMaxIter);
}
Example #7
0
int main(int iArgCnt, char* sArrArgs[])
{
   int iIterationNo = 0;
   int iArrayIndex = 0;
   double dSubResult = 0, dTotalResult = 0;
   double dTime0 = 0, dTime1 = 0, dTimeDiff = 0, dMinTimeDiff = 1000, dMaxTimeDiff = 0;
   MPI_Status statusX, statusY;

   parseInputs(iArgCnt, sArrArgs);

   MPI_Init(&iArgCnt, &sArrArgs);
   MPI_Comm_size(MPI_COMM_WORLD, &GiProcessCnt);
   MPI_Comm_rank(MPI_COMM_WORLD, &GiProcessRank);

   initArrays();

   for(iIterationNo = 0; iIterationNo < GiIterationCnt; iIterationNo++)
   {
      dSubResult = 0;

      MPI_Barrier(MPI_COMM_WORLD);
      dTime0 = MPI_Wtime();
      if(GiProcessCnt > 1)
      {
         if(GiProcessRank == 0)
         {
            for(iArrayIndex = 1; iArrayIndex < GiProcessCnt; iArrayIndex++)
            {
               MPI_Send((GdArrX + (GiSubVectorLength * iArrayIndex)), GiSubVectorLength, MPI_DOUBLE, iArrayIndex, 0, MPI_COMM_WORLD);
               MPI_Send((GdArrY + (GiSubVectorLength * iArrayIndex)), GiSubVectorLength, MPI_DOUBLE, iArrayIndex, 0, MPI_COMM_WORLD);

               /*printf("Process0: Subarrays are sent to Process%d!\n", iArrayIndex);*/
            }

            for(iArrayIndex = 0; iArrayIndex < GiSubVectorLength; iArrayIndex++)
            {
               dSubResult += (GdArrX[iArrayIndex] * GdArrY[iArrayIndex]);
            }
            /*printf("Process0: I did my job and I will be waiting for the subresults!\n");*/
         }
         else
         {
            MPI_Recv(GdArrSubX, GiSubVectorLength, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, &statusX);
            MPI_Recv(GdArrSubY, GiSubVectorLength, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, &statusY);

            for(iArrayIndex = 0; iArrayIndex < GiSubVectorLength; iArrayIndex++)
            {
               dSubResult += (GdArrSubX[iArrayIndex] * GdArrSubY[iArrayIndex]);
            }

            /*printf("Process%d: I did my job and I will be sending my result to Process0!\n", GiProcessRank);*/
         }
      }
      else
      {
         for(iArrayIndex = 0; iArrayIndex < GiVectorLength; iArrayIndex++)
         {
            dSubResult += (GdArrX[iArrayIndex] * GdArrY[iArrayIndex]);
         }
      }

      MPI_Barrier(MPI_COMM_WORLD);
      MPI_Reduce(&dSubResult, &dTotalResult, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD);

      dTime1 = MPI_Wtime();
      dTimeDiff = (dTime1 - dTime0);

      if(dTimeDiff > dMaxTimeDiff)
         dMaxTimeDiff = dTimeDiff;
      if(dTimeDiff < dMinTimeDiff)
         dMinTimeDiff = dTimeDiff;
   }

   if(GiProcessRank == 0)
      printf("Result=%f\nMin Time=%f uSec\nMax Time=%f uSec\n", dTotalResult, (1.e6 * dMinTimeDiff), (1.e6 * dMaxTimeDiff));
   
   MPI_Finalize();

   return 0;
}