Changeset b6887ed in tol
- Timestamp:
- Nov 16, 2009, 6:27:51 PM (17 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- dc4fc4b
- Parents:
- ff8c23b
- File:
-
- 1 edited
-
tol/btol/set_type/setgra.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol/btol/set_type/setgra.cpp
rff8c23b rb6887ed 743 743 I2("(Real a, Real b, Real p)", 744 744 "(Real desde, Real hasta, Real distancia)"), 745 I2("Returns the set of the real\n\n" 746 747 " n, n + p , n + 2*p, ...\n\n" 748 749 "smaller or just as m." 750 745 I2("Returns the set of real numbers \n" 746 " \n" 747 " a+k*p with k = 0,1,2,3,... \n" 748 " \n" 749 "in the interval [a,b] if p>0 or [b,a] if p<0 \n" 750 " \n" 751 "If p==0 shows an error and returns the empty file. \n" 752 "If p>0 and a>b returns the empty file without showing any error. \n" 753 "If p<0 and a<b returns the empty file without showing any error." 751 754 , 752 753 "Devuelve el conjunto de los reales que van del número " 754 "a al número b separados entre sí por la distancia p."), 755 "Devuelve el conjunto de los reales " 756 " \n" 757 " a+k*p con k = 0,1,2,3,... \n" 758 " \n" 759 "en el intervalo [a,b] si p>0 ó [b,a] si p<0 \n" 760 " \n" 761 "Si p==0 muestra un error y devuelve el conjunto vacío \n" 762 "Si p>0 y a>b devuelve el conjunto vacío sin mostrar error alguno. \n" 763 "Si p<0 y a<b devuelve el conjunto vacío sin mostrar error alguno."), 755 764 BOperClassify::SetAlgebra_); 756 765 … … 759 768 //-------------------------------------------------------------------- 760 769 { 761 BList* result = NIL; 762 BList* aux = NIL; 763 764 BDat fromDat = Dat(Arg(1)); 765 BDat untilDat = Dat(Arg(2)); 766 BDat stepDat = Dat(Arg(3)); 767 768 if (!fromDat.IsKnown() || !untilDat.IsKnown() || !stepDat.IsKnown()) { 769 Warning(I2("Some of the Range's arguments are unknown", 770 "Alguno de los argumentos de Range son desconocidos")); 771 return; 772 } 773 774 double from = fromDat.Value(); 775 double until = untilDat.Value(); 776 double step = stepDat.Value(); 777 int i; 778 779 if (step == 0.0) { /* warning!!! : this is a bad comparison */ 780 return; 781 } 782 783 double spans = (until-from)/step; 784 int n = abs(int(round((until-from)/step))); 785 if (until > from) 786 step = fabs(step); 787 else 788 step = -fabs(step); 789 790 BDat x = from + step*n; 791 if(x>untilDat) { n--; } 792 for(i = 0; i<=n; i++) 793 { 794 x = from + step*i; 795 LstFastAppend(result, aux, new BContensDat("",x)); 796 } 797 #if 0 798 /* last item could not belong because of rounding error */ 799 double item = from + step * i; 800 /* warning!!! : this is a bad comparison */ 801 if ((step>0 && item <= until) || (step<0 && item >= until)) { 802 LstFastAppend(result, aux, new BContensDat("",item)); 803 } 804 #endif 805 contens_.RobElement(result); 770 BList* result = NIL; 771 BList* aux = NIL; 772 773 BDat fromDat = Dat(Arg(1)); 774 BDat untilDat = Dat(Arg(2)); 775 BDat stepDat = Dat(Arg(3)); 776 777 if (!fromDat.IsKnown() || !untilDat.IsKnown() || !stepDat.IsKnown()) { 778 Warning(I2("Some of the Range's arguments are unknown", 779 "Alguno de los argumentos de Range son desconocidos")); 780 return; 781 } 782 double from = fromDat.Value(); 783 double until = untilDat.Value(); 784 double step = stepDat.Value(); 785 int k; 786 double x; 787 if (step == 0.0) { /* warning!!! : this is a bad comparison */ 788 Warning(I2("Argument 'p' of function Range cannot be zero", 789 "El argumento 'p' de la función Range no peude ser cero.")); 790 return; 791 } 792 for(k=0;;k++) 793 { 794 x = from + step*k; 795 if((step>0)?(x>until):(x<until)) { break; } 796 LstFastAppend(result, aux, new BContensDat("",x)); 797 } 798 contens_.RobElement(result); 806 799 } 807 800
Note: See TracChangeset
for help on using the changeset viewer.
