G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsPointGrid.h
Go to the documentation of this file.
1 
14 #pragma once
15 
16 #include <gsCore/gsLinearAlgebra.h>
18 
19 namespace gismo {
20 
21 
22 /* **************** Utility functions **************** */
23 
24 template<typename T> // gsMatrix<T> ab
25 gsVector<unsigned> uniformSampleCount (const gsVector<T>& lower,
26  const gsVector<T>& upper,
27  int numPoints = 1000);
28 
29 template<typename T>
30 void uniformIntervals(const gsVector<T>& lower, const gsVector<T>& upper,
31  std::vector< std::vector<T> >& intervals, int numIntervals = 1000);
32 
33 
34 /* **************** Uniform grids described by limits/corners **************** */
35 
36 
52 template<class T> // gsMatrix<T> ab
53 gsMatrix<T> gsPointGrid( gsVector<T> const & a, gsVector<T> const & b,
54  gsVector<unsigned> const & np );
55 
56 // Specialization of the arguments for the 1D case
57 template<class T> inline
58 gsMatrix<T> gsPointGrid( T const & t1, T const & t2, unsigned const & n = 100)
59 {
60  gsMatrix<T,1,2> ab(1,2); ab << t1, t2;
61  gsGridIterator<T,CUBE,1> pt(ab,n);
62  gsMatrix<T> rvo(ab.rows(), pt.numPoints() );
63  for(index_t c = 0; pt; ++pt, ++c)
64  rvo.col(c) = *pt;
65  return rvo;
66 }
67 
72 template<typename T> // todo: remove, replace by next one
73 gsMatrix<T>uniformPointGrid(const gsVector<T>& lower, // note: structure lost
74  const gsVector<T>& upper,
75  int numPoints = 1000);
76 
83 template<class T> inline
84 gsMatrix<T> gsPointGrid(gsMatrix<T> const & ab, int numPoints)
85 { // Note: structure lost
86  gsGridIterator<T,CUBE> pt(ab,numPoints);
87  gsMatrix<T> rvo(ab.rows(), pt.numPoints() );
88  for(index_t c = 0; pt; ++pt, ++c)
89  rvo.col(c) = *pt;
90  return rvo;
91 }
92 
93 
94 /* **************** Cartesian grids **************** */
95 
96 
99 template<class T, class CwiseContainer> inline
100 void gsPointGrid(CwiseContainer const & cwise, gsMatrix<T>& res)
101 {
102  gsGridIterator<T,CWISE> pt(cwise);
103  res.resize(cwise.size(), pt.numPoints() );
104  for(index_t c = 0; pt; ++pt, ++c)
105  res.col(c) = *pt;
106 }
107 
109 template<class T, class CwiseContainer> inline
110 gsMatrix<T> gsPointGrid(CwiseContainer const & cwise)
111 {
112  gsMatrix<T> rvo;
113  gsPointGrid(cwise, rvo);
114  return rvo;
115 }
116 
117 
118 } // namespace gismo
119 
120 
121 #ifndef GISMO_BUILD_LIB
122 #include GISMO_HPP_HEADER(gsPointGrid.hpp)
123 #endif
#define index_t
Definition: gsConfig.h:32
gsMatrix< T > uniformPointGrid(const gsVector< T > &lower, const gsVector< T > &upper, int numPoints=1000)
Definition: gsPointGrid.hpp:94
gsMatrix< T > gsPointGrid(gsVector< T > const &a, gsVector< T > const &b, gsVector< unsigned > const &np)
Construct a Cartesian grid of uniform points in a hypercube, using np[i] points in direction i...
Definition: gsPointGrid.hpp:82
This is the main header file that collects wrappers of Eigen for linear algebra.
Provides iteration over integer or numeric points in a (hyper-)cube.