<Source Index | <PPA-L top page

ppa_l.cpp


//////////////////////////////////////////////////
//
//                      PPA-L
//  point process analysis system: L function calculator
//
//
//      Copyright  October 2001 by TAKENAKA, A.

#include <iostream>

#include "plotarea.h"

void showUsage(void);  //  prototype declaration.

/////////////////////////////////////////////////
//
//

int main (int argc, char** argv)
{
    double r_unit, r_upto;
    const char* file1;
    const char* file2;
    bool rvl;

    if (argc < 4 || 5 < argc) {
        showUsage();
        return -1;
    }

    r_unit = atof(argv[1]);
    r_upto = atof(argv[2]);
    file1 = argv[3];
    file2 = argv[4];  //  if argc = 4, argv[4] is NULL.

    PlotArea plot;

    rvl = plot.loadPoints(file1, file2);
    if (!rvl) {
        return -1;  //  failed to load points.
    }

    rvl = plot.calc_L(r_unit, r_upto);
    if (!rvl) {
        return -1;  //  failed to calculate L.
    }

    const r_X_Array& results = plot.getResults();

    for (int i = 0; i < (int) results.size(); ++i) {
        std::cout << double (results[i].first)
                  << "\t"
                  << double (results[i].second)
                  << std::endl;
    }

    return 0;
}

//////////////////////////////////////

void showUsage(void)
{
    std::cout << "PPA-L ver 0.1  2001 by TAKENAKA A." << std::endl;
    std::cout << "USAGE: ppa-l r_unit r_upto file1 [file2]" << std::endl;
    std::cout << "  r_unit is the increment of the distance, r." << std::endl;
    std::cout << "  r_upto is the max r to calculate L value." << std::endl;
    std::cout << "  Feed one file to calculate L for given point pattern." << std::endl;
    std::cout << "  Feed two files to calculate L for bivariate point pattern." << std::endl;

}