[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getfem-commits] r4959 - in /trunk/getfem/src: ./ getfem/
From: |
Yves . Renard |
Subject: |
[Getfem-commits] r4959 - in /trunk/getfem/src: ./ getfem/ |
Date: |
Mon, 20 Apr 2015 06:45:07 -0000 |
Author: renard
Date: Mon Apr 20 08:45:05 2015
New Revision: 4959
URL: http://svn.gna.org/viewcvs/getfem?rev=4959&view=rev
Log:
integrating bgeot_imbricated_box.h and bgeot_imbricated_box.cc into
bgeot_poly_composite.h and bgeot_poly_composite.cc
Removed:
trunk/getfem/src/bgeot_imbricated_box.cc
trunk/getfem/src/getfem/bgeot_imbricated_box.h
Modified:
trunk/getfem/src/Makefile.am
trunk/getfem/src/bgeot_poly_composite.cc
trunk/getfem/src/getfem/bgeot_poly_composite.h
trunk/getfem/src/getfem/getfem_config.h
Modified: trunk/getfem/src/Makefile.am
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/Makefile.am?rev=4959&r1=4958&r2=4959&view=diff
==============================================================================
--- trunk/getfem/src/Makefile.am (original)
+++ trunk/getfem/src/Makefile.am Mon Apr 20 08:45:05 2015
@@ -68,7 +68,6 @@
getfem/dal_tas.h \
getfem/dal_tree_sorted.h \
getfem/bgeot_config.h \
- getfem/bgeot_imbricated_box.h \
getfem/bgeot_permutations.h \
getfem/bgeot_convex_structure.h \
getfem/bgeot_convex.h \
@@ -160,7 +159,6 @@
bgeot_convex_ref.cc \
bgeot_geometric_trans.cc \
bgeot_geotrans_inv.cc \
- bgeot_imbricated_box.cc \
bgeot_kdtree.cc \
bgeot_mesh_structure.cc \
bgeot_rtree.cc \
Removed: trunk/getfem/src/bgeot_imbricated_box.cc
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/bgeot_imbricated_box.cc?rev=4958&view=auto
==============================================================================
--- trunk/getfem/src/bgeot_imbricated_box.cc (original)
+++ trunk/getfem/src/bgeot_imbricated_box.cc (removed)
@@ -1,231 +0,0 @@
-/*===========================================================================
-
- Copyright (C) 2005-2012 Yves Renard
-
- This file is a part of GETFEM++
-
- Getfem++ is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version along with the GCC Runtime Library
- Exception either version 3.1 or (at your option) any later version.
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- License and GCC Runtime Library Exception for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
-
-===========================================================================*/
-
-#include "getfem/bgeot_imbricated_box.h"
-
-namespace bgeot {
-#if 0
-#define PBASE2 4
- static double frexpb2(double a, int& e) {
- double x = frexp(a,&e);
- if (PBASE2 != 1) {
- int n = e; e /= PBASE2;
- x *= (1<<(n - e*PBASE2));
- }
- return x;
- }
- int imbricated_box_less::operator()(const base_node &A,
- const base_node &B) const
- {
- base_vector x1(A.size()), x2(A.size());
- std::vector<int> e1(A.size()), e2(A.size());
- int emax = -1000, emax2;
- base_node::const_iterator a=A.begin(), b=B.begin();
- for (size_type i=0; i < A.size(); ++i) {
- x1[i] = frexpb2(a[i], e1[i]); x2[i] = frexpb2(b[i], e2[i]);
- emax = std::max(emax, e1[i]);
- emax = std::max(emax, e2[i]);
- }
- emax2 = emax;
- for (size_type i=0; i < A.size(); ++i) {
- if (x1[i] < 0 || x2[i] < 0) {
- x1[i] = frexpb2(a[i]+exp2(emax2), e1[i]); x2[i] =
frexpb2(b[i]+exp2(emax2), e2[i]);
- //assert(x1[i]>=0); assert(x2[i]>=0);
- emax = std::max(emax, e1[i]);
- emax = std::max(emax, e2[i]);
- }
- }
- bool finished;
- do {
- finished = true;
- for (size_type i=0; i < A.size(); ++i) {
- int d1,d2;
- if (e1[i] != emax && e2[i] != emax) continue;
- if (e1[i] == emax) { x1[i] *= PBASE2; d1 = (int)x1[i]; x1[i] -= d1;
e1[i]--; } else d1 = 0;
- if (e2[i] == emax) { x2[i] *= PBASE2; d2 = (int)x2[i]; x2[i] -= d2;
e2[i]--; } else d2 = 0;
- if (d1 != d2) { return (d1 < d2) ? -1 : +1; }
- finished = finished && !(e1[i] != e2[i] || x1[i] != x2[i]);
- }
- emax--;
- } while (!finished);
- return 0;
- }
-#else
- int imbricated_box_less::operator()(const base_node &x,
- const base_node &y) const
- {
- size_type s = x.size();
- scalar_type c1 = c_max, c2 = c_max * scalar_type(base);
- GMM_ASSERT2(y.size() == s, "dimension error");
-
- base_node::const_iterator itx=x.begin(), itex=x.end(), ity=y.begin();
- int ret = 0;
- for (; itx != itex; ++itx, ++ity) {
- long a = long(sfloor((*itx) * c1)), b = long(sfloor((*ity) * c1));
- if ((gmm::abs(a) > scalar_type(base))
- || (gmm::abs(b) > scalar_type(base))) {
- exp_max++; c_max /= scalar_type(base);
- return (*this)(x,y);
- }
- if (ret == 0) { if (a < b) ret = -1; else if (a > b) ret = 1; }
- }
- if (ret) return ret;
-
- for (int e = exp_max; e >= exp_min; --e, c1 *= scalar_type(base),
- c2 *= scalar_type(base)) {
- itx = x.begin(), itex = x.end(), ity = y.begin();
- for (; itx != itex; ++itx, ++ity) {
- int a = int(sfloor(((*itx) * c2) - sfloor((*itx) * c1)
- * scalar_type(base)));
- int b = int(sfloor(((*ity) * c2) - sfloor((*ity) * c1)
- * scalar_type(base)));
- if (a < b) return -1; else if (a > b) return 1;
- }
- }
- return 0;
- }
-#endif
-
-#if 0 // disable all the rest of the file
-
-#if 1
- size_type geotrans_inv::points_in_box(dal::dynamic_array<size_type> &pt,
- const base_node &min,
- const base_node &max) const {
- TAB_TYPE::const_sorted_iterator it, ite;
- size_type nb = 0;
-
- it = ptab.sorted_ge(min); ite = ptab.sorted_ge(max);
- base_node::const_iterator itl, itmin, itmax, itmine = min.end();
- for(; it != ite; ++it) {
- bool isin = true;
- itl = (*it).begin(); itmin = min.begin(); itmax = max.begin();
- for (; itmin != itmine; ++itmin, ++itmax, ++itl)
- if (*itl < *itmin || *itl > *itmax) { isin = false; break; }
- if (isin) pt[nb++] = it.index();
- }
- return nb;
- }
-#elif 0
- size_type geotrans_inv::points_in_box(dal::dynamic_array<size_type> &pt,
- const base_node &min,
- const base_node &max) const {
- /* The following is a version with a partition, avoiding default */
- /* of the simple search, but which is slower .. in the mean. */
- size_type s = min.size(), i, nbib = 0;
- base_node c(s),boxmin(s),boxmax(s),cbox(s), iboxmin(s), iboxmax(s);
- TAB_TYPE::const_sorted_iterator it, ite;
- scalar_type logbase = log(double(base()));
- cout.precision(25);
- cout << "initial box : " << min << " :: " << max << endl;
-
- for (i = 0; i < s; ++i)
- {
- c[i] = pow(base(),
- rint(log(std::max(EPS, max[i] - min[i]))/logbase));
- boxmin[i] = floor(min[i] / c[i]) * c[i];
- boxmax[i] = ceil(max[i] / c[i]) * c[i];
- }
- cout << "max box : " << boxmin << " :: " << boxmax << endl;
- cout << "steps : " << c << endl;
-
- cbox = boxmin;
- while(cbox[s-1] < boxmax[s-1]-EPS)
- {
- /* intersection */
- for (i = 0; i < s; ++i)
- {
- if (cbox[i] > max[i] || cbox[i]+c[i] < min[i]) goto aurevoir;
- iboxmin[i]=std::max(cbox[i], min[i])+EPS;
- iboxmax[i]=std::max(std::min(cbox[i]+c[i], max[i]), iboxmin[i])-EPS;
- }
- cout << "intersection : " << iboxmin << " : " << iboxmax << endl;
- /* recherche des points entre iboxmin et iboxmax */
- it = ptab.sorted_ge(iboxmin);
- ite = ptab.sorted_ge(iboxmax);
- cout << "ite-it=" << std::distance(it,ite) << "\n";
- cout << "pt " << ptab[0] << " < " << iboxmin << "? : " <<
ptab.comparator()(ptab[0], iboxmin) << "\n";
- cout << "pt " << ptab[0] << " < " << iboxmax << "? : " <<
ptab.comparator()(ptab[0], iboxmax) << "\n";
- for(; it != ite; ++it)
- {
- bool isin = true;
- for (i = 0; i < s; ++i)
- if ((*it)[i] < min[i] || (*it)[i] > max[i])
- { isin = false; break; }
- if (isin) pt[nbib++] = it.index();
- }
- cout << "nbib = " << nbib << "\n";
- aurevoir:
- /* incrementation */
- i = 0; cbox[0] += c[0];
- while((cbox[i] >= boxmax[i]-EPS) && (i < s-1))
- { cbox[i] = boxmin[i]; ++i; cbox[i] += c[i]; }
- }
- return nbib;
- }
-#else
- size_type geotrans_inv::points_in_box(dal::dynamic_array<size_type> &pt,
- const base_node &Pmin,
- const base_node &Pmax) const {
- size_type N = Pmin.size(), nbib=0;
- int boxsz = -1000;
- base_node boxmin(N), boxmax(N);
- TAB_TYPE::const_sorted_iterator it, ite;
-
- base_node::const_iterator min=Pmin.begin(), max=Pmax.begin();
- for (size_type i=0; i < N; ++i) {
- int j; frexp(max[i]-min[i], &j);
- boxsz = std::max(boxsz,j);
- }
- for (size_type i=0; i < N; ++i) {
- scalar_type e = exp2(boxsz*2);
- boxmin[i] = floor(min[i]/e)*e;
- boxmax[i] = ceil(max[i]/e)*e - 1e-10;
- }
- cout.precision(20);
- cout << "points_in_box(" << Pmin << ", " << Pmax << "): boxsz=2^" << boxsz
<< "=" << exp2(boxsz) << ", boxmin=" << boxmin << ", boxmax=" << boxmax << "\n";
- it = ptab.sorted_ge(boxmin);
- ite = ptab.sorted_ge(boxmax);
- cout << "ite-it=" << std::distance(it,ite) << "\n";
- /*cout << "pt " << ptab[0] << " < " << iboxmin << "? : " <<
ptab.comparator()(ptab[0], iboxmin) << "\n";
- cout << "pt " << ptab[0] << " < " << iboxmax << "? : " <<
ptab.comparator()(ptab[0], iboxmax) << "\n";*/
- for(; it != ite; ++it) {
- bool ge_boxmin = true, le_boxmax = true;
- for (size_type i = 0; i < N; ++i) {
- if ((*it)[i]<boxmin[i]) ge_boxmin = false;
- if ((*it)[i]>boxmax[i]) le_boxmax = false;
- }
- cout << "test point " << *it << ", ge_boxmin=" << ge_boxmin << ",
le_boxmax=" << le_boxmax << "\n";
- assert(ge_boxmin && le_boxmax);
- bool isin = true;
- for (size_type i = 0; i < N; ++i) {
- if ((*it)[i] < min[i] || (*it)[i] > max[i]) {
- isin = false; break;
- }
- }
- if (isin) pt[nbib++] = it.index();
- }
- cout << "nbib = " << nbib << "\n";
- return nbib;
- }
-#endif
-#endif
-}
Modified: trunk/getfem/src/bgeot_poly_composite.cc
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/bgeot_poly_composite.cc?rev=4959&r1=4958&r2=4959&view=diff
==============================================================================
--- trunk/getfem/src/bgeot_poly_composite.cc (original)
+++ trunk/getfem/src/bgeot_poly_composite.cc Mon Apr 20 08:45:05 2015
@@ -24,6 +24,43 @@
#include "getfem/bgeot_poly_composite.h"
namespace bgeot {
+
+ inline scalar_type sfloor(scalar_type x)
+ { return (x >= 0) ? floor(x) : -floor(-x); }
+
+
+ int imbricated_box_less::operator()(const base_node &x,
+ const base_node &y) const {
+ size_type s = x.size();
+ scalar_type c1 = c_max, c2 = c_max * scalar_type(base);
+ GMM_ASSERT2(y.size() == s, "dimension error");
+
+ base_node::const_iterator itx=x.begin(), itex=x.end(), ity=y.begin();
+ int ret = 0;
+ for (; itx != itex; ++itx, ++ity) {
+ long a = long(sfloor((*itx) * c1)), b = long(sfloor((*ity) * c1));
+ if ((gmm::abs(a) > scalar_type(base))
+ || (gmm::abs(b) > scalar_type(base))) {
+ exp_max++; c_max /= scalar_type(base);
+ return (*this)(x,y);
+ }
+ if (ret == 0) { if (a < b) ret = -1; else if (a > b) ret = 1; }
+ }
+ if (ret) return ret;
+
+ for (int e = exp_max; e >= exp_min; --e, c1 *= scalar_type(base),
+ c2 *= scalar_type(base)) {
+ itx = x.begin(), itex = x.end(), ity = y.begin();
+ for (; itx != itex; ++itx, ++ity) {
+ int a = int(sfloor(((*itx) * c2) - sfloor((*itx) * c1)
+ * scalar_type(base)));
+ int b = int(sfloor(((*ity) * c2) - sfloor((*ity) * c1)
+ * scalar_type(base)));
+ if (a < b) return -1; else if (a > b) return 1;
+ }
+ }
+ return 0;
+ }
mesh_precomposite::mesh_precomposite(const basic_mesh &m) {
msh = &m;
Removed: trunk/getfem/src/getfem/bgeot_imbricated_box.h
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/bgeot_imbricated_box.h?rev=4958&view=auto
==============================================================================
--- trunk/getfem/src/getfem/bgeot_imbricated_box.h (original)
+++ trunk/getfem/src/getfem/bgeot_imbricated_box.h (removed)
@@ -1,63 +0,0 @@
-/* -*- c++ -*- (enables emacs c++ mode) */
-/*===========================================================================
-
- Copyright (C) 2005-2012 Yves Renard
-
- This file is a part of GETFEM++
-
- Getfem++ is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version along with the GCC Runtime Library
- Exception either version 3.1 or (at your option) any later version.
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- License and GCC Runtime Library Exception for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
-
- As a special exception, you may use this file as it is a part of a free
- software library without restriction. Specifically, if other files
- instantiate templates or use macros or inline functions from this file,
- or you compile this file and link it with other files to produce an
- executable, this file does not by itself cause the resulting executable
- to be covered by the GNU Lesser General Public License. This exception
- does not however invalidate any other reasons why the executable file
- might be covered by the GNU Lesser General Public License.
-
-===========================================================================*/
-
-/address@hidden bgeot_imbricated_box.h
- @author Yves Renard <address@hidden>
- @date January 26, 1999.
- @brief A comparison function for bgeot::base_node
-*/
-#ifndef BGEOT_IMBRICATED_BOX
-#define BGEOT_IMBRICATED_BOX
-
-#include "bgeot_vector.h"
-
-namespace bgeot {
- inline scalar_type sfloor(scalar_type x)
- { return (x >= 0) ? floor(x) : -floor(-x); }
-
- /// A comparison function for bgeot::base_node
- struct imbricated_box_less
- : public std::binary_function<base_node, base_node, int>
- {
- mutable int exp_max, exp_min;
- mutable scalar_type c_max;
- unsigned base;
-
- /// comparaison function
- int operator()(const base_node &x, const base_node &y) const;
-
- imbricated_box_less(unsigned ba = 10, int emi = -15, int ema = -2) {
- base = ba; exp_max = ema; exp_min = emi;
- c_max = pow(double(base), double(-exp_max));
- }
- };
-}
-#endif
Modified: trunk/getfem/src/getfem/bgeot_poly_composite.h
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/bgeot_poly_composite.h?rev=4959&r1=4958&r2=4959&view=diff
==============================================================================
--- trunk/getfem/src/getfem/bgeot_poly_composite.h (original)
+++ trunk/getfem/src/getfem/bgeot_poly_composite.h Mon Apr 20 08:45:05 2015
@@ -42,7 +42,6 @@
#define BGEOT_POLY_COMPOSITE_H__
#include "bgeot_poly.h"
-#include "bgeot_imbricated_box.h"
#include "bgeot_mesh.h"
// TODO : Use of rtree instead of dal::dynamic_tree_sorted<base_node,
@@ -50,6 +49,25 @@
namespace bgeot {
+
+ /// A comparison function for bgeot::base_node
+ struct imbricated_box_less
+ : public std::binary_function<base_node, base_node, int>
+ {
+ mutable int exp_max, exp_min;
+ mutable scalar_type c_max;
+ unsigned base;
+
+ /// comparaison function
+ int operator()(const base_node &x, const base_node &y) const;
+
+ imbricated_box_less(unsigned ba = 10, int emi = -15, int ema = -2) {
+ base = ba; exp_max = ema; exp_min = emi;
+ c_max = pow(double(base), double(-exp_max));
+ }
+ };
+
+
struct mesh_precomposite {
Modified: trunk/getfem/src/getfem/getfem_config.h
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/getfem_config.h?rev=4959&r1=4958&r2=4959&view=diff
==============================================================================
--- trunk/getfem/src/getfem/getfem_config.h (original)
+++ trunk/getfem/src/getfem/getfem_config.h Mon Apr 20 08:45:05 2015
@@ -366,9 +366,9 @@
#else
template <typename T> inline T MPI_SUM_SCALAR(T a) { return a; }
template <typename VECT> inline void MPI_SUM_VECTOR(const VECT &) {}
- template <typename VECT> inline void MPI_MAX_VECTOR(const VECT &VV) {}
+ template <typename VECT> inline void MPI_MAX_VECTOR(const VECT &) {}
template <typename T> void MPI_BCAST0_SCALAR(T &a) {}
- template <typename VECT> inline void MPI_BCAST0_VECTOR(const VECT &VV) {}
+ template <typename VECT> inline void MPI_BCAST0_VECTOR(const VECT &) {}
template <typename MAT> inline void MPI_SUM_SPARSE_MATRIX(const MAT &) {}
template <typename VECT1, typename VECT2>
inline void MPI_SUM_VECTOR(const VECT1 &V, const VECT2 &WW)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Getfem-commits] r4959 - in /trunk/getfem/src: ./ getfem/,
Yves . Renard <=