Skip to content

Commit

Permalink
linecircle included in minus, not building yet
Browse files Browse the repository at this point in the history
  • Loading branch information
rfabbri committed Jun 16, 2024
1 parent 8580711 commit fa482f8
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 31 deletions.
15 changes: 15 additions & 0 deletions minus/linecircle-default.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef linecircle_default_h_
#define linecircle_default_h_
// Include this last of all in user app

#include "minus.h"
#include "linecircle-default-data.h" // default start system etc

// Convenience types to use Minus and the linecircle problem
typedef MiNuS::minus_core<MiNuS::linecircle> M;
typedef MiNuS::minus_io<MiNuS::linecircle> io;
typedef MiNuS::minus_io_14a<MiNuS::linecircle> io14;
typedef MiNuS::minus_data<MiNuS::linecircle, double> data;
extern template struct MiNuS::minus_data<MiNuS::linecircle, double>;

#endif // linecircle_default_h_
6 changes: 3 additions & 3 deletions minus/linecircle2a-HxH.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// (Ask Tim for the way to use cCode so that the input orders are like this.
template <typename F>
inline __attribute__((always_inline)) void
eval<linecircle, F>::
eval<linecircle2a, F>::
HxH(const C<F>* __restrict ux /*x and t*/, const C<F> * __restrict uparams, C<F>* __restrict uy /*HxH*/)
{
const C<F> *params = reinterpret_cast<C<F> *> (__builtin_assume_aligned(uparams,64));
Expand Down Expand Up @@ -84,7 +84,7 @@ HxH(const C<F>* __restrict ux /*x and t*/, const C<F> * __restrict uparams, C<F>
// (Ask Tim for the way to use cCode so that the input orders are like this.
template <typename F>
inline __attribute__((always_inline)) void
eval<linecircle, F>::
eval<linecircle2a, F>::
HxH_constants(const C<F>* __restrict ux /*x and t*/, const C<F> * __restrict uparams, C<F>* __restrict uy /*HxH*/)
{
}
Expand All @@ -98,7 +98,7 @@ HxH_constants(const C<F>* __restrict ux /*x and t*/, const C<F> * __restrict upa
// (Ask Tim for the way to use cCode so that the input orders are like this.
template <typename F>
inline __attribute__((always_inline)) void
eval<linecircle, F>::
eval<linecircle2a, F>::
HxH_constants_all_sols(const C<F>* __restrict ux /*x and t*/, const C<F> * __restrict uparams, C<F>* __restrict uy /*HxH*/)
{
}
2 changes: 1 addition & 1 deletion minus/linecircle2a-Hxt.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//
template <typename F>
inline __attribute__((always_inline)) void
eval<linecircle, F>::
eval<linecircle2a, F>::
HxH(const C<F>* __restrict ux /*x and t*/, const C<F> * __restrict uparams, C<F>* __restrict uy /*HxH*/)
{
const C<F> *params = reinterpret_cast<C<F> *> (__builtin_assume_aligned(uparams,64));
Expand Down
8 changes: 4 additions & 4 deletions minus/linecircle2a-default-data.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
namespace MiNuS {

template <typename F>
struct minus_data<linecircle,F> {
typedef minus_core<linecircle> M;
typedef minus_io<linecircle> io;
typedef minus_io_14a<linecircle> io14;
struct minus_data<linecircle2a,F> {
typedef minus_core<linecircle2a> M;
typedef minus_io<linecircle2a> io;
typedef minus_io_14a<linecircle2a> io14;
typedef std::complex<F> complex;
static const complex start_sols_[M::nve*M::nsols];
alignas (64) static complex params_start_target_[2*M::f::nparams];
Expand Down
12 changes: 6 additions & 6 deletions minus/linecircle2a-default-data.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@


#include "minus.h"
#include "linecircle-default-data.h"
#include "linecircle2a-default-data.h"

namespace MiNuS {

// You can reinterpret as 2D matrix in C as start_sols_[M::nsols][M::nve]
template <typename F>
alignas(64) const std::complex<F> minus_data<linecircle,F>::
alignas(64) const std::complex<F> minus_data<linecircle2a,F>::
start_sols_[M::nve*M::nsols] = {
// solution 0
{-.17713365790154765e1, .18062520635371109e1}, // x
Expand All @@ -51,7 +51,7 @@ start_sols_[M::nve*M::nsols] = {
// to store target system params
// the latter M::nparams are trash
template <typename F>
alignas(64) std::complex<F> minus_data<linecircle,F>::
alignas(64) std::complex<F> minus_data<linecircle2a,F>::
params_start_target_[2*M::f::nparams] = {
{-.54232002300332649, .84017200182443086},
{-.50519558694885758, -.86300487769618039},
Expand All @@ -73,7 +73,7 @@ params_start_target_[2*M::f::nparams] = {
// In tutorial/start-linecirc.m2 example
//
template <typename F>
alignas(64) std::complex<F> minus_data<linecircle,F>::
alignas(64) std::complex<F> minus_data<linecircle2a,F>::
default_params_start_target_gammified_[2*M::f::nparams] = {
{-.54232002300332649, .84017200182443086},
{-.50519558694885758, -.86300487769618039},
Expand All @@ -83,14 +83,14 @@ default_params_start_target_gammified_[2*M::f::nparams] = {
{-.15952718229455548, .98719353629830842}
};
template <typename F>
const std::complex<F> * minus_data<linecircle,F>::
const std::complex<F> * minus_data<linecircle2a,F>::
params_= default_params_start_target_gammified_;

// Input point correspondences for testing could be hardcoded here
// see p_ and p_correct in chicago-default-data.hxx

template <typename F>
C<F> minus_data<linecircle,F>::
C<F> minus_data<linecircle2a,F>::
solutions_gt_[M::nve] = {
{-.83999999999999997, -.38032880511473233},
{30000000000000006e-1, -.11409864153441969}
Expand Down
2 changes: 1 addition & 1 deletion minus/linecircle2a-default.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Include this last of all in user app

#include "minus.h"
#include "linecircle-default-data.h" // default start system etc
#include "linecircle2a-default-data.h" // default start system etc

// Convenience types to use Minus and the linecircle problem
typedef MiNuS::minus_core<MiNuS::linecircle> M;
Expand Down
6 changes: 3 additions & 3 deletions minus/linecircle2a-io.hxx → minus/linecircle2a-io.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
namespace MiNuS {

template <typename F>
struct minus_io<linecircle, F> : public minus_io_14a<linecircle, F> {
struct minus_io<linecircle2a, F> : public minus_io_14a<linecircle2a, F> {
// template specialization defined in problem-internals.h
typedef problem_parameters<linecircle> pp;
typedef minus_core<linecircle, F> M;
typedef problem_parameters<linecircle2a> pp;
typedef minus_core<linecircle2a, F> M;
typedef minus_io_common<F> io;
// shortcuts to the problem parameters
static constexpr unsigned nviews = pp::nviews;
Expand Down
5 changes: 5 additions & 0 deletions minus/linecircle2a-lsolve-pro.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ lsolve(
Map<Matrix<C<F>, minus_core<P,F>::f::nve, minus_core<P,F>::f::nve +1>,Aligned> & __restrict m,
C<F> __restrict *ux)
{
std::cerr << "not implemented" << std::endl;
abort();
/* Example of specialized and optimized Eigen LU solver:
*
C<F> * const x= reinterpret_cast<C<F> *> (__builtin_assume_aligned(ux,64));
//asm("#------ Lsolve begin"); // there is too many vmovsd moving data. It is sub-vectorized, using only xmm no y or zmm
typedef minus_core<P, F> M;
Expand Down Expand Up @@ -63,4 +67,5 @@ lsolve(
x[2] -= (m(2,3)*x[3]+m(2,4)*x[4]+m(2,5)*x[5]+m(2,6)*x[6]+m(2,7)*x[7]+m(2,8)*x[8]+m(2,9)*x[9]+m(2,10)*x[10]+m(2,11)*x[11]+m(2,12)*x[12]+m(2,13)*x[13]); x[2] /= m(2,2);
x[1] -= (m(1,2)*x[2]+m(1,3)*x[3]+m(1,4)*x[4]+m(1,5)*x[5]+m(1,6)*x[6]+m(1,7)*x[7]+m(1,8)*x[8]+m(1,9)*x[9]+m(1,10)*x[10]+m(1,11)*x[11]+m(1,12)*x[12]+m(1,13)*x[13]); x[1] /= m(1,1);
x[0] -= (m(0,1)*x[1]+m(0,2)*x[2]+m(0,3)*x[3]+m(0,4)*x[4]+m(0,5)*x[5]+m(0,6)*x[6]+m(0,7)*x[7]+m(0,8)*x[8]+m(0,9)*x[9]+m(0,10)*x[10]+m(0,11)*x[11]+m(0,12)*x[12]+m(0,13)*x[13]); x[0] /= m(0,0);
*/
}
4 changes: 2 additions & 2 deletions minus/linecircle2a.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define linecircle_h_

template <>
struct formulation_parameters<linecircle> {
struct formulation_parameters<linecircle2a> {
static constexpr unsigned nsols = 2; // number of solutions
static constexpr unsigned nve = 2; // size of the system (Number of Variables or Equations)
// this formulation: two quaternions and
Expand All @@ -12,7 +12,7 @@ struct formulation_parameters<linecircle> {

// setup problem (data) parameters and attributes
template <>
struct problem_parameters<linecircle> {
struct problem_parameters<linecircle2a> {
// static constexpr unsigned nviews = 3;
// static constexpr unsigned npoints = 3;
};
Expand Down
22 changes: 11 additions & 11 deletions minus/linecircle2a.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
namespace MiNuS {

template <typename F>
struct eval<linecircle, F> {
struct eval<linecircle2a, F> {
static void inline __attribute__((always_inline)) Hxt(const C<F> * __restrict x /*x, t*/, const C<F> * __restrict params, C<F> * __restrict y /*Hxt*/);
static void inline __attribute__((always_inline)) HxH(const C<F> * __restrict x /*x and t*/, const C<F> * __restrict params, C<F> * __restrict y /*HxH*/);
static void inline __attribute__((always_inline)) Hxt_constants(const C<F> * __restrict x /*x, t*/, const C<F> * __restrict params, C<F> * __restrict y /*Hxt*/);
static void inline __attribute__((always_inline)) HxH_constants(const C<F> * __restrict x /*x, t*/, const C<F> * __restrict params, C<F> * __restrict y /*HxH*/);
static void inline __attribute__((always_inline)) HxH_constants_all_sols(const C<F> * __restrict x /*x, t*/, const C<F> * __restrict params, C<F> * __restrict y /*HxH*/);
};

#include "linecircle-Hxt.hxx"
#include "linecircle-HxH.hxx"
#include "linecircle2a-Hxt.hxx"
#include "linecircle2a-HxH.hxx"

// Problem and Formulation Paramers --------------------------------------------

} // namespace minus

#include "linecircle-io.h"
#include "linecircle2a-io.h"

namespace MiNuS {

Expand Down Expand Up @@ -61,7 +61,7 @@ namespace MiNuS {
//
template <typename F>
inline void
minus_io<linecircle, F>::
minus_io<linecircle2a, F>::
gammify(C<F> * __restrict params /*[ chicago: M::nparams]*/)
{
// Noob ----------------------------------------------------------------------
Expand All @@ -75,7 +75,7 @@ gammify(C<F> * __restrict params /*[ chicago: M::nparams]*/)
// gammified.
template <typename F>
inline void
minus_io<linecircle, F>::
minus_io<linecircle2a, F>::
get_params_start_target(
F plines[/*15 for chicago*/][io::ncoords2d_h],
C<F> * __restrict params/*[static 2*M::nparams]*/,
Expand All @@ -94,7 +94,7 @@ get_params_start_target(
// Highlevel solver interface - Class minus ------------------------------------

#include <thread>
#include "linecircle-default-data.h"
#include "linecircle2a-default-data.h"

namespace MiNuS {

Expand All @@ -117,15 +117,15 @@ namespace MiNuS {
//
template <typename F>
inline bool
minus<linecircle, F>::solve(
const C<F> params_final, // p1 in linecircle-end.m2
minus<linecircle2a, F>::solve(
const C<F> params_final, // p1 in linecircle2a-end.m2
F solutions[M::nsols], // first camera is always [I | 0]
unsigned id_sols[M::nsols],
unsigned *nsols_final,
unsigned nthreads
)
{
typedef minus_data<linecircle,F> data;
typedef minus_data<linecircle2a,F> data;
alignas(64) C<F> params[2*M::f::nparams];
memcpy(params, data::params_start_target_, M::f::nparams*sizeof(C<F>));

Expand Down Expand Up @@ -164,7 +164,7 @@ minus<linecircle, F>::solve(
//
template <typename F>
inline bool
minus_io<linecircle, F>::
minus_io<linecircle2a, F>::
has_valid_solutions(const typename M::solution solutions[M::nsols])
{
typedef minus_array<M::nve,F> v;
Expand Down

0 comments on commit fa482f8

Please sign in to comment.