|
| 1 | +/* |
| 2 | + * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF ICT, |
| 3 | + * Applied Mathematics, Norway. |
| 4 | + * |
| 5 | + * Contact information: E-mail: [email protected] |
| 6 | + * SINTEF ICT, Department of Applied Mathematics, |
| 7 | + * P.O. Box 124 Blindern, |
| 8 | + * 0314 Oslo, Norway. |
| 9 | + * |
| 10 | + * This file is part of GoTools. |
| 11 | + * |
| 12 | + * GoTools is free software: you can redistribute it and/or modify |
| 13 | + * it under the terms of the GNU Affero General Public License as |
| 14 | + * published by the Free Software Foundation, either version 3 of the |
| 15 | + * License, or (at your option) any later version. |
| 16 | + * |
| 17 | + * GoTools is distributed in the hope that it will be useful, |
| 18 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | + * GNU Affero General Public License for more details. |
| 21 | + * |
| 22 | + * You should have received a copy of the GNU Affero General Public |
| 23 | + * License along with GoTools. If not, see |
| 24 | + * <http://www.gnu.org/licenses/>. |
| 25 | + * |
| 26 | + * In accordance with Section 7(b) of the GNU Affero General Public |
| 27 | + * License, a covered work must retain the producer line in every data |
| 28 | + * file that is created or manipulated using GoTools. |
| 29 | + * |
| 30 | + * Other Usage |
| 31 | + * You can be released from the requirements of the license by purchasing |
| 32 | + * a commercial license. Buying such a license is mandatory as soon as you |
| 33 | + * develop commercial activities involving the GoTools library without |
| 34 | + * disclosing the source code of your own applications. |
| 35 | + * |
| 36 | + * This file may be used in accordance with the terms contained in a |
| 37 | + * written agreement between you and SINTEF ICT. |
| 38 | + */ |
| 39 | + |
| 40 | +#include "GoTools/geometry/GoTools.h" |
| 41 | +#include "GoTools/geometry/FileUtils.h" |
| 42 | +#include "GoTools/lrsplines2D/LogLikelyhood.h" |
| 43 | +#include <iostream> |
| 44 | +#include <fstream> |
| 45 | + |
| 46 | +using std::vector; |
| 47 | +using namespace Go; |
| 48 | + |
| 49 | +int main(int argc, char *argv[]) |
| 50 | +{ |
| 51 | + |
| 52 | + if (argc != 3) |
| 53 | + { |
| 54 | + std::cout << "Parameters: residuals (x,y,z,r), degrees of freedom in T-distribution" << std::endl; |
| 55 | + return 1; |
| 56 | + } |
| 57 | + |
| 58 | + std::ifstream input(argv[1]); |
| 59 | + double Tny = atof(argv[2]); |
| 60 | + |
| 61 | + // Read point cloud with residuals |
| 62 | + vector<double> data; |
| 63 | + vector<double> extent(8); // Limits for points in all coordinates |
| 64 | + int nmb_pts = 0; |
| 65 | + FileUtils::readTxtPointFile(input, 4, data, nmb_pts, extent); |
| 66 | + |
| 67 | + std::cout << "Number of points: " << nmb_pts << std::endl; |
| 68 | + // Extract residuals |
| 69 | + vector<double> residuals(nmb_pts); |
| 70 | + for (size_t ki=0; ki<nmb_pts; ++ki) |
| 71 | + residuals[ki] = data[4*ki+3]; |
| 72 | + std::cout << "Min: " << extent[6] << ", max: " << extent[7] << std::endl; |
| 73 | + |
| 74 | + double loglh2 = 0.0; |
| 75 | + double loglh = LogLikelyhood::compute(residuals, Tny, false, loglh2); |
| 76 | + printf("Loglikelyhood: %7.13f, %7.13f \n",loglh, loglh2); |
| 77 | +} |
0 commit comments