DGtal 2.1.0
Loading...
Searching...
No Matches
IntegerMatrixFunctions.h
1
17#pragma once
18
32#if defined(IntegerMatrixFunctions_RECURSES)
33#error Recursive header files inclusion detected in IntegerMatrixFunctions.h
34#else // defined(IntegerMatrixFunctions_RECURSES)
36#define IntegerMatrixFunctions_RECURSES
37
38#if !defined IntegerMatrixFunctions_h
40#define IntegerMatrixFunctions_h
41
43// Inclusions
44#include <iostream>
45#include "DGtal/base/Common.h"
46#include "DGtal/kernel/ArithmeticConversionTraits.h"
47#include "DGtal/arithmetic/IntegerComputer.h"
48#include "DGtal/math/linalg/SimpleMatrix.h"
50
51namespace DGtal
52{
53
54 namespace functions {
55
60 template <typename TComponent>
61 void
62 negate( std::vector<TComponent> &V );
63
72 template <typename TComponent>
73 bool
74 equals( const std::vector<TComponent> &a, const std::vector<TComponent> &b );
75
86 template <typename T, typename U >
88 dotProduct( const std::vector<T>& a, const std::vector<U>& b );
89
97 double
98 dotProduct( const std::vector<BigInteger>& a, const std::vector<double>& b );
99
107 double
108 dotProduct( const std::vector<double>& a, const std::vector<BigInteger>& b );
109
119 template <typename T, typename U >
120 std::vector< typename DGtal::ArithmeticConversionTraits<T,U>::type >
121 crossProduct( const std::vector<T>& a, const std::vector<U>& b );
122
136 template <typename T, typename U, typename Op2 >
137 std::vector< typename DGtal::ArithmeticConversionTraits<T,U>::type >
138 apply( const std::vector<T>& a, const std::vector<U>& b,
139 Op2 op2 );
140
150 template <typename T>
151 T
152 squaredNormL2( const std::vector<T>& a );
153
161 template <typename T>
162 T
163 normL1( const std::vector<T>& a );
164
172 template <typename T>
173 T
174 normLoo( const std::vector<T>& a );
175
184 template <typename TOutput, typename T>
185 void
186 getSquaredNormL2( TOutput& n, const std::vector<T>& a );
187
214 template <typename TOutput,
216 typename TEuclideanRing,
217 typename TContainer>
218 void
219 getSquaredNormL2( TOutput& n,
221
238 template <typename TComponent, DGtal::Dimension TN,
239 typename TInternalNumber>
240 void
241 getDeterminantBareiss( TInternalNumber& result,
242 const SimpleMatrix<TComponent, TN, TN>& matrix );
243
259 template <typename TComponent, typename TInternalNumber>
260 void
261 getDeterminantBareiss( TInternalNumber& result,
262 const std::vector< std::vector< TComponent > >& matrix );
263
274 template <typename TComponent>
275 std::vector< std::vector< TComponent > >
276 matrixAsVectorVector( std::size_t m, std::size_t n,
277 const std::vector< TComponent >& c );
278
289 template <typename TComponent, DGtal::Dimension TM, DGtal::Dimension TN>
290 std::vector< std::vector< TComponent > >
292
323 template <typename TComponent, typename TDouble = long double >
324 std::vector< std::vector< TComponent > >
325 computeLLLBasis( const std::vector< std::vector< TComponent > >& B,
326 TDouble delta = 0.75 );
327
358 template <typename TComponent, typename TDouble = long double >
359 void
360 reduceBasisWithLLL( std::vector< std::vector< TComponent > >& B,
361 TDouble delta = 0.75 );
362
371 template <typename TComponent>
372 TComponent
373 makePrimitive( std::vector< TComponent >& N );
374
384 template <typename TComponent>
385 TComponent
386 extendedGcd( TComponent& x, TComponent& y, TComponent a,TComponent b );
387
399 template <typename TComponent>
400 TComponent
401 extendedGcd( std::vector<TComponent> &C, const std::vector<TComponent> &A );
402
403
423 template <typename TComponent>
424 std::vector< std::vector< TComponent > >
425 computeOrthogonalLattice( std::vector< TComponent > N );
426
436 template <typename TComponent>
437 bool
438 shortenVectors( std::vector< TComponent >& u,
439 std::vector< TComponent >& v );
440
452 template <typename TComponent>
453 std::size_t
454 shortenBasis( std::vector< std::vector< TComponent > >& B );
455
456 } // namespace functions
457
458} // namespace DGtal
459
460
462// Includes inline functions.
463#include "DGtal/math/linalg/IntegerMatrixFunctions.ih"
464
465// //
467
468#endif // !defined IntegerMatrixFunctions_h
469
470#undef IntegerMatrixFunctions_RECURSES
471#endif // else defined(IntegerMatrixFunctions_RECURSES)
Aim: Implements basic operations that will be used in Point and Vector classes.
Aim: implements basic MxN Matrix services (M,N>=1).
std::vector< std::vector< TComponent > > matrixAsVectorVector(std::size_t m, std::size_t n, const std::vector< TComponent > &c)
bool shortenVectors(std::vector< TComponent > &u, std::vector< TComponent > &v)
std::vector< typename DGtal::ArithmeticConversionTraits< T, U >::type > apply(const std::vector< T > &a, const std::vector< U > &b, Op2 op2)
void getSquaredNormL2(TOutput &n, const std::vector< T > &a)
void reduceBasisWithLLL(std::vector< std::vector< TComponent > > &B, TDouble delta=0.75)
T normLoo(const std::vector< T > &a)
std::size_t shortenBasis(std::vector< std::vector< TComponent > > &B)
T squaredNormL2(const std::vector< T > &a)
bool equals(const std::vector< TComponent > &a, const std::vector< TComponent > &b)
std::vector< typename DGtal::ArithmeticConversionTraits< T, U >::type > crossProduct(const std::vector< T > &a, const std::vector< U > &b)
DGtal::ArithmeticConversionTraits< T, U >::type dotProduct(const std::vector< T > &a, const std::vector< U > &b)
std::vector< std::vector< TComponent > > computeLLLBasis(const std::vector< std::vector< TComponent > > &B, TDouble delta=0.75)
TComponent makePrimitive(std::vector< TComponent > &N)
std::vector< std::vector< TComponent > > computeOrthogonalLattice(std::vector< TComponent > N)
void negate(std::vector< TComponent > &V)
void getDeterminantBareiss(TInternalNumber &result, const SimpleMatrix< TComponent, TN, TN > &matrix)
TComponent extendedGcd(TComponent &x, TComponent &y, TComponent a, TComponent b)
T normL1(const std::vector< T > &a)
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::uint32_t Dimension
Definition Common.h:119
Aim: Trait class to get result type of arithmetic binary operators between two given types.