mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
convert ASCII TABs to ASCII SPACEs
Converted all ASCII tabs to ASCII spaces using a 8 character tab stop, for all files, except for all Makefiles (plus rpm.mk). The `git diff -w` reports no changes.
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
*
|
||||
* Calc 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
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
* Public License for more details.
|
||||
*
|
||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
@@ -17,10 +17,10 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Under source code control: 1991/09/30 11:18:41
|
||||
* File existed as early as: 1991
|
||||
* Under source code control: 1991/09/30 11:18:41
|
||||
* File existed as early as: 1991
|
||||
*
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -30,16 +30,16 @@
|
||||
*
|
||||
* The non-builtin code used the following symbolic formula to calculate B(n):
|
||||
*
|
||||
* (b+1)^(n+1) - b^(n+1) = 0
|
||||
* (b+1)^(n+1) - b^(n+1) = 0
|
||||
*
|
||||
* where b is a dummy value, and each power b^i gets replaced by B(i).
|
||||
* For example, for n = 3:
|
||||
*
|
||||
* (b+1)^4 - b^4 = 0
|
||||
* b^4 + 4*b^3 + 6*b^2 + 4*b + 1 - b^4 = 0
|
||||
* 4*b^3 + 6*b^2 + 4*b + 1 = 0
|
||||
* 4*B(3) + 6*B(2) + 4*B(1) + 1 = 0
|
||||
* B(3) = -(6*B(2) + 4*B(1) + 1) / 4
|
||||
* (b+1)^4 - b^4 = 0
|
||||
* b^4 + 4*b^3 + 6*b^2 + 4*b + 1 - b^4 = 0
|
||||
* 4*b^3 + 6*b^2 + 4*b + 1 = 0
|
||||
* 4*B(3) + 6*B(2) + 4*B(1) + 1 = 0
|
||||
* B(3) = -(6*B(2) + 4*B(1) + 1) / 4
|
||||
*
|
||||
* The combinatorial factors in the expansion of the above formula are
|
||||
* calculated interactively, and we use the fact that B(2i+1) = 0 if i > 0.
|
||||
@@ -56,38 +56,38 @@ static mat Bn[1001];
|
||||
define B(n)
|
||||
{
|
||||
/*
|
||||
local nn, np1, i, sum, mulval, divval, combval;
|
||||
local nn, np1, i, sum, mulval, divval, combval;
|
||||
|
||||
if (!isint(n) || (n < 0))
|
||||
quit "Non-negative integer required for Bernoulli";
|
||||
if (!isint(n) || (n < 0))
|
||||
quit "Non-negative integer required for Bernoulli";
|
||||
|
||||
if (n == 0)
|
||||
return 1;
|
||||
if (n == 1)
|
||||
return -1/2;
|
||||
if (isodd(n))
|
||||
return 0;
|
||||
if (n > 1000)
|
||||
quit "Very large Bernoulli";
|
||||
if (n == 0)
|
||||
return 1;
|
||||
if (n == 1)
|
||||
return -1/2;
|
||||
if (isodd(n))
|
||||
return 0;
|
||||
if (n > 1000)
|
||||
quit "Very large Bernoulli";
|
||||
|
||||
if (n <= Bnmax)
|
||||
return Bn[n];
|
||||
if (n <= Bnmax)
|
||||
return Bn[n];
|
||||
|
||||
for (nn = Bnmax + 2; nn <= n; nn+=2) {
|
||||
np1 = nn + 1;
|
||||
mulval = np1;
|
||||
divval = 1;
|
||||
combval = 1;
|
||||
sum = 1 - np1 / 2;
|
||||
for (i = 2; i < np1; i+=2) {
|
||||
combval = combval * mulval-- / divval++;
|
||||
combval = combval * mulval-- / divval++;
|
||||
sum += combval * Bn[i];
|
||||
}
|
||||
Bn[nn] = -sum / np1;
|
||||
}
|
||||
Bnmax = n;
|
||||
return Bn[n];
|
||||
for (nn = Bnmax + 2; nn <= n; nn+=2) {
|
||||
np1 = nn + 1;
|
||||
mulval = np1;
|
||||
divval = 1;
|
||||
combval = 1;
|
||||
sum = 1 - np1 / 2;
|
||||
for (i = 2; i < np1; i+=2) {
|
||||
combval = combval * mulval-- / divval++;
|
||||
combval = combval * mulval-- / divval++;
|
||||
sum += combval * Bn[i];
|
||||
}
|
||||
Bn[nn] = -sum / np1;
|
||||
}
|
||||
Bnmax = n;
|
||||
return Bn[n];
|
||||
*/
|
||||
return bernoulli(n);
|
||||
return bernoulli(n);
|
||||
}
|
||||
|
Reference in New Issue
Block a user