POV-Ray : Newsgroups : povray.text.scene-files : [Minimum Volume] Bounding Ellipsoid via SVD : Re: [Minimum Volume] Bounding Ellipsoid via SVD Server Time
20 Apr 2024 05:55:40 EDT (-0400)
  Re: [Minimum Volume] Bounding Ellipsoid via SVD  
From: Bald Eagle
Date: 17 Nov 2019 21:15:01
Message: <web.5dd1fe9ff7b9a3af4eec112d0@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:

> please post a data file.

done.

>  when you say "400", are you trying to run a 400x400
> matrix?  not sure but you *might* hit the limits -- the code's recursive, no?

400 x 3 matrix.   A "vector" data type that uses 400 povray vectors split up
into x, y, and z values.

So I just figured I'd read in the 400 first, size my array according to that,
and then just pipe the whole file into the compiled SVD processor.

Right now I just wanted to see if that worked, so I'm just gonna import the
data, and then print it back out to show that that part works, then copy that
working code into the SVD .cpp file.

This is mid-hack, so it's uglier than usual    ;)


#include <vector>
#include <iostream>
#include <iomanip>
#include <ctime>
#include <algorithm>


#include <boost/multiprecision/cpp_bin_float.hpp>
#include <boost/math/special_functions/gamma.hpp>

using namespace boost::multiprecision;

typedef number<backends::cpp_bin_float<4096, backends::digit_base_2, void,
boost::int16_t, -16382, 16383>, et_off>  cpp_bin_float_4096;

using namespace std;



std::vector<std::vector<cpp_bin_float_4096> > matrix_i;

template<typename Arg = cpp_bin_float_4096>
void print_matrix(std::vector<std::vector<cpp_bin_float_4096> > matrix)
{
    std::cout << "Printing matrix . . . \n\n";
 for (std::size_t row = 0; row < matrix.size(); row++)
 {
  for (std::size_t col = 0; col < matrix[row].size(); col++)
   std::cout << std::setprecision(1) << std::fixed << matrix[row][col] << " ";
std::cout << "\n";
 }

 //std::cout << "\n";
}

template<typename Arg = cpp_bin_float_4096>
void generate_matrix(std::vector<std::vector<cpp_bin_float_4096> >& \
 matrix, std::size_t rows, std::size_t cols)

{
    std::cin >> rows;
 std::srand((unsigned int)std::time(nullptr)); matrix.resize(rows);
 for (std::size_t row = 0; row < matrix.size(); row++)
 {
  matrix[row].resize(3);
  for (std::size_t col = 0; col < 3; col++)
   //std::cin >> ignore(100, '\n') >> matrix[rows][cols];
            std::cin >> matrix[rows][cols];
 }
    std::cout << "Data imported. \n\n";
}




int main(int argc, char* argv[])
{
 std::size_t matrix_size = 0;
 std::vector<std::vector<cpp_bin_float_4096> > u, v;
 std::vector<std::vector<cpp_bin_float_4096> > matrix, s;
 std::cout << "Importing data into matrix . . . \n\n";


  generate_matrix(matrix, matrix_size, matrix_size);

  std::cout << "\nA = \n"; print_matrix(matrix);

  //svd(matrix, s, u, v);

  //std::cout << "\nS = \n"; print_matrix(s);
  //std::cout << "\nU = \n"; print_matrix(u);
  //std::cout << "\nV = \n"; print_matrix(v);

 std::cin.get();
 //std::cin.get();

 return 0;
}


Post a reply to this message


Attachments:
Download 'vectors.dat.txt' (12 KB)

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.