Diffstat (limited to 'noncore/apps/opie-sheet/sheet.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-sheet/sheet.cpp | 122 |
1 files changed, 85 insertions, 37 deletions
diff --git a/noncore/apps/opie-sheet/sheet.cpp b/noncore/apps/opie-sheet/sheet.cpp index 88847da..477c982 100644 --- a/noncore/apps/opie-sheet/sheet.cpp +++ b/noncore/apps/opie-sheet/sheet.cpp | |||
@@ -1,10 +1,29 @@ | |||
1 | /*************************************************************************** | 1 | /* |
2 | * * | 2 | =. This file is part of the Opie Project |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> |
4 | * it under the terms of the GNU General Public License as published by * | 4 | .>+-= |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | _;:, .> :=|. This program is free software; you can |
6 | * (at your option) any later version. * | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | * * | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | ***************************************************************************/ | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This program is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
9 | 28 | ||
10 | /* | 29 | /* |
@@ -15,5 +34,8 @@ | |||
15 | #include "sheet.h" | 34 | #include "sheet.h" |
16 | 35 | ||
36 | /* QT */ | ||
17 | #include <qmessagebox.h> | 37 | #include <qmessagebox.h> |
38 | |||
39 | /* STD */ | ||
18 | #include <math.h> | 40 | #include <math.h> |
19 | #include <stdlib.h> | 41 | #include <stdlib.h> |
@@ -49,6 +71,5 @@ Sheet::Sheet(int numRows, int numCols, QWidget *parent) | |||
49 | 71 | ||
50 | Sheet::~Sheet() | 72 | Sheet::~Sheet() |
51 | { | 73 | {} |
52 | } | ||
53 | 74 | ||
54 | typeCellData *Sheet::findCellData(int row, int col) | 75 | typeCellData *Sheet::findCellData(int row, int col) |
@@ -68,5 +89,6 @@ void Sheet::slotCellSelected(int row, int col) | |||
68 | { | 89 | { |
69 | emit currentDataChanged(cellData->data); | 90 | emit currentDataChanged(cellData->data); |
70 | }else | 91 | } |
92 | else | ||
71 | emit currentDataChanged(""); | 93 | emit currentDataChanged(""); |
72 | } | 94 | } |
@@ -229,5 +251,6 @@ double Sheet::BesselI0(double x) | |||
229 | y*=y; | 251 | y*=y; |
230 | ans=1.0+y*(3.5156229+y*(3.0899424+y*(1.2067492 +y*(0.2659732+y*(0.360768e-1+y*0.45813e-2))))); | 252 | ans=1.0+y*(3.5156229+y*(3.0899424+y*(1.2067492 +y*(0.2659732+y*(0.360768e-1+y*0.45813e-2))))); |
231 | }else | 253 | } |
254 | else | ||
232 | { | 255 | { |
233 | y=3.75/ax; | 256 | y=3.75/ax; |
@@ -246,5 +269,6 @@ double Sheet::BesselI1(double x) | |||
246 | y*=y; | 269 | y*=y; |
247 | ans=ax*(0.5+y*(0.87890594+y*(0.51498869+y*(0.15084934 +y*(0.2658733e-1+y*(0.301532e-2+y*0.32411e-3)))))); | 270 | ans=ax*(0.5+y*(0.87890594+y*(0.51498869+y*(0.15084934 +y*(0.2658733e-1+y*(0.301532e-2+y*0.32411e-3)))))); |
248 | } else | 271 | } |
272 | else | ||
249 | { | 273 | { |
250 | y=3.75/ax; | 274 | y=3.75/ax; |
@@ -293,5 +317,6 @@ double Sheet::BesselK0(double x) | |||
293 | y=x*x/4.0; | 317 | y=x*x/4.0; |
294 | ans=(-log(x/2.0)*BesselI0(x))+(-0.57721566+y*(0.42278420 +y*(0.23069756+y*(0.3488590e-1+y*(0.262698e-2 +y*(0.10750e-3+y*0.74e-5)))))); | 318 | ans=(-log(x/2.0)*BesselI0(x))+(-0.57721566+y*(0.42278420 +y*(0.23069756+y*(0.3488590e-1+y*(0.262698e-2 +y*(0.10750e-3+y*0.74e-5)))))); |
295 | } else | 319 | } |
320 | else | ||
296 | { | 321 | { |
297 | y=2.0/x; | 322 | y=2.0/x; |
@@ -308,5 +333,6 @@ double Sheet::BesselK1(double x) | |||
308 | y=x*x/4.0; | 333 | y=x*x/4.0; |
309 | ans=(log(x/2.0)*BesselI1(x))+(1.0/x)*(1.0+y*(0.15443144 +y*(-0.67278579+y*(-0.18156897+y*(-0.1919402e-1 +y*(-0.110404e-2+y*(-0.4686e-4))))))); | 334 | ans=(log(x/2.0)*BesselI1(x))+(1.0/x)*(1.0+y*(0.15443144 +y*(-0.67278579+y*(-0.18156897+y*(-0.1919402e-1 +y*(-0.110404e-2+y*(-0.4686e-4))))))); |
310 | } else | 335 | } |
336 | else | ||
311 | { | 337 | { |
312 | y=2.0/x; | 338 | y=2.0/x; |
@@ -343,5 +369,6 @@ double Sheet::BesselJ0(double x) | |||
343 | ans2=57568490411.0+y*(1029532985.0+y*(9494680.718 +y*(59272.64853+y*(267.8532712+y*1.0)))); | 369 | ans2=57568490411.0+y*(1029532985.0+y*(9494680.718 +y*(59272.64853+y*(267.8532712+y*1.0)))); |
344 | ans=ans1/ans2; | 370 | ans=ans1/ans2; |
345 | } else | 371 | } |
372 | else | ||
346 | { | 373 | { |
347 | z=8.0/ax; | 374 | z=8.0/ax; |
@@ -365,5 +392,6 @@ double Sheet::BesselY0(double x) | |||
365 | ans2=40076544269.0+y*(745249964.8+y*(7189466.438 +y*(47447.26470+y*(226.1030244+y*1.0)))); | 392 | ans2=40076544269.0+y*(745249964.8+y*(7189466.438 +y*(47447.26470+y*(226.1030244+y*1.0)))); |
366 | ans=(ans1/ans2)+0.636619772*BesselJ0(x)*log(x); | 393 | ans=(ans1/ans2)+0.636619772*BesselJ0(x)*log(x); |
367 | } else | 394 | } |
395 | else | ||
368 | { | 396 | { |
369 | z=8.0/x; | 397 | z=8.0/x; |
@@ -387,5 +415,6 @@ double Sheet::BesselJ1(double x) | |||
387 | ans2=144725228442.0+y*(2300535178.0+y*(18583304.74 +y*(99447.43394+y*(376.9991397+y*1.0)))); | 415 | ans2=144725228442.0+y*(2300535178.0+y*(18583304.74 +y*(99447.43394+y*(376.9991397+y*1.0)))); |
388 | ans=ans1/ans2; | 416 | ans=ans1/ans2; |
389 | } else | 417 | } |
418 | else | ||
390 | { | 419 | { |
391 | z=8.0/ax; y=z*z; xx=ax-2.356194491; | 420 | z=8.0/ax; y=z*z; xx=ax-2.356194491; |
@@ -408,5 +437,6 @@ double Sheet::BesselY1(double x) | |||
408 | ans2=0.2499580570e14+y*(0.4244419664e12 +y*(0.3733650367e10+y*(0.2245904002e8 +y*(0.1020426050e6+y*(0.3549632885e3+y))))); | 437 | ans2=0.2499580570e14+y*(0.4244419664e12 +y*(0.3733650367e10+y*(0.2245904002e8 +y*(0.1020426050e6+y*(0.3549632885e3+y))))); |
409 | ans=(ans1/ans2)+0.636619772*(BesselJ1(x)*log(x)-1.0/x); | 438 | ans=(ans1/ans2)+0.636619772*(BesselJ1(x)*log(x)-1.0/x); |
410 | } else | 439 | } |
440 | else | ||
411 | { | 441 | { |
412 | z=8.0/x; | 442 | z=8.0/x; |
@@ -459,5 +489,6 @@ double Sheet::BesselJ(int n, double x) | |||
459 | } | 489 | } |
460 | ans=bj; | 490 | ans=bj; |
461 | } else | 491 | } |
492 | else | ||
462 | { | 493 | { |
463 | tox=2.0/ax; | 494 | tox=2.0/ax; |
@@ -519,5 +550,6 @@ double Sheet::GammaP(double a, double x) | |||
519 | GammaSeries(&gamser,a,x,&gln); | 550 | GammaSeries(&gamser,a,x,&gln); |
520 | return gamser; | 551 | return gamser; |
521 | }else | 552 | } |
553 | else | ||
522 | { | 554 | { |
523 | GammaContinuedFraction(&gammcf,a,x,&gln); | 555 | GammaContinuedFraction(&gammcf,a,x,&gln); |
@@ -545,5 +577,6 @@ void Sheet::GammaSeries(double *gamser, double a, double x, double *gln) | |||
545 | *gamser=0.0; | 577 | *gamser=0.0; |
546 | return; | 578 | return; |
547 | } else | 579 | } |
580 | else | ||
548 | { | 581 | { |
549 | ap=a; | 582 | ap=a; |
@@ -559,5 +592,6 @@ void Sheet::GammaSeries(double *gamser, double a, double x, double *gln) | |||
559 | return; | 592 | return; |
560 | } | 593 | } |
561 | } return; | 594 | } |
595 | return; | ||
562 | return; | 596 | return; |
563 | } | 597 | } |
@@ -663,5 +697,6 @@ double Sheet::functionSum(const QString ¶m1, const QString ¶m2) | |||
663 | } | 697 | } |
664 | return result; | 698 | return result; |
665 | }else | 699 | } |
700 | else | ||
666 | { | 701 | { |
667 | double d1=0,d2=0; | 702 | double d1=0,d2=0; |
@@ -790,5 +825,6 @@ double Sheet::functionSumSQ(const QString ¶m1, const QString ¶m2) | |||
790 | } | 825 | } |
791 | return result; | 826 | return result; |
792 | }else | 827 | } |
828 | else | ||
793 | { | 829 | { |
794 | double d1=0,d2=0; | 830 | double d1=0,d2=0; |
@@ -820,5 +856,6 @@ double Sheet::functionMin(const QString ¶m1, const QString ¶m2) | |||
820 | } | 856 | } |
821 | return min; | 857 | return min; |
822 | }else | 858 | } |
859 | else | ||
823 | { | 860 | { |
824 | double d1=0,d2=0; | 861 | double d1=0,d2=0; |
@@ -848,5 +885,6 @@ double Sheet::functionMax(const QString ¶m1, const QString ¶m2) | |||
848 | }; | 885 | }; |
849 | return max; | 886 | return max; |
850 | }else | 887 | } |
888 | else | ||
851 | { | 889 | { |
852 | double d1=0,d2=0; | 890 | double d1=0,d2=0; |
@@ -878,5 +916,6 @@ double Sheet::functionCount(const QString ¶m1, const QString ¶m2) | |||
878 | }; | 916 | }; |
879 | return divider; | 917 | return divider; |
880 | }else | 918 | } |
919 | else | ||
881 | { | 920 | { |
882 | double d1=0,d2=0;int ii=0; | 921 | double d1=0,d2=0;int ii=0; |
@@ -993,10 +1032,12 @@ QString Sheet::calculateFunction(const QString &func, const QString ¶meters, | |||
993 | { | 1032 | { |
994 | if(text(row,col).length()==0) val1=1; else val1=0; | 1033 | if(text(row,col).length()==0) val1=1; else val1=0; |
995 | }else | 1034 | } |
1035 | else | ||
996 | { | 1036 | { |
997 | if(findRowColumn(calculateVariable(getParameter(parameters, 0)), &row,&col, FALSE)) | 1037 | if(findRowColumn(calculateVariable(getParameter(parameters, 0)), &row,&col, FALSE)) |
998 | { | 1038 | { |
999 | if(text(row,col).length()==0) val1=1; else val1=0; | 1039 | if(text(row,col).length()==0) val1=1; else val1=0; |
1000 | }else | 1040 | } |
1041 | else | ||
1001 | { | 1042 | { |
1002 | val1=0; | 1043 | val1=0; |
@@ -1013,5 +1054,6 @@ QString Sheet::calculateFunction(const QString &func, const QString ¶meters, | |||
1013 | val1=text(row,col).toDouble(&ok); | 1054 | val1=text(row,col).toDouble(&ok); |
1014 | if(ok) val1=1; else val1=0; | 1055 | if(ok) val1=1; else val1=0; |
1015 | }else | 1056 | } |
1057 | else | ||
1016 | { | 1058 | { |
1017 | if(findRowColumn(calculateVariable(getParameter(parameters, 0, TRUE, function)), &row,&col, FALSE)) | 1059 | if(findRowColumn(calculateVariable(getParameter(parameters, 0, TRUE, function)), &row,&col, FALSE)) |
@@ -1019,5 +1061,6 @@ QString Sheet::calculateFunction(const QString &func, const QString ¶meters, | |||
1019 | val1=text(row,col).toDouble(&ok); | 1061 | val1=text(row,col).toDouble(&ok); |
1020 | if(ok) val1=1; else val1=0; | 1062 | if(ok) val1=1; else val1=0; |
1021 | }else | 1063 | } |
1064 | else | ||
1022 | { | 1065 | { |
1023 | val1=0; | 1066 | val1=0; |
@@ -1390,5 +1433,6 @@ QString Sheet::calculateFunction(const QString &func, const QString ¶meters, | |||
1390 | s1=calculateVariable(getParameter(parameters, 1, TRUE, function)); | 1433 | s1=calculateVariable(getParameter(parameters, 1, TRUE, function)); |
1391 | return QString(s1); | 1434 | return QString(s1); |
1392 | }else | 1435 | } |
1436 | else | ||
1393 | { | 1437 | { |
1394 | s1=calculateVariable(getParameter(parameters, 2, TRUE, function)); | 1438 | s1=calculateVariable(getParameter(parameters, 2, TRUE, function)); |
@@ -1553,5 +1597,6 @@ QString Sheet::calculateFunction(const QString &func, const QString ¶meters, | |||
1553 | { | 1597 | { |
1554 | return QString::number(GammaQ(floor(val1)+1, val2)); | 1598 | return QString::number(GammaQ(floor(val1)+1, val2)); |
1555 | }else | 1599 | } |
1600 | else | ||
1556 | { | 1601 | { |
1557 | return QString::number(exp(-val2)*pow(val2,val1)/exp(GammaLn(val1+1.0))); | 1602 | return QString::number(exp(-val2)*pow(val2,val1)/exp(GammaLn(val1+1.0))); |
@@ -1567,5 +1612,6 @@ QString Sheet::calculateFunction(const QString &func, const QString ¶meters, | |||
1567 | { | 1612 | { |
1568 | return QString::number(GammaP(val2/2.0,val1*val1/2.0)); | 1613 | return QString::number(GammaP(val2/2.0,val1*val1/2.0)); |
1569 | } else | 1614 | } |
1615 | else | ||
1570 | { | 1616 | { |
1571 | return QString::number( | 1617 | return QString::number( |
@@ -1583,5 +1629,6 @@ QString Sheet::calculateFunction(const QString &func, const QString ¶meters, | |||
1583 | { | 1629 | { |
1584 | return QString::number(GammaP(val2/2.0,val1/2.0)); | 1630 | return QString::number(GammaP(val2/2.0,val1/2.0)); |
1585 | } else | 1631 | } |
1632 | else | ||
1586 | { | 1633 | { |
1587 | return QString::number( | 1634 | return QString::number( |
@@ -2386,5 +2433,6 @@ void Expression::GetNext() | |||
2386 | }//while | 2433 | }//while |
2387 | }//else if | 2434 | }//else if |
2388 | };//end function | 2435 | } |
2436 | ;//end function | ||
2389 | 2437 | ||
2390 | 2438 | ||