Hi Carnë,
I also reacted so late, sorry for that! Hope this header is fine!
One more thing is if the code which was written by Alexander -in one of the
previous message, the code is also attached in `big_factorial.m` file-, his code
calculates the factorial in an arbitrary precision way.
If Alexander's code shall be included in one of the package (eg. specfun) my
header should mention it in the `see also` section. I did not included it,
because I've no information about big_factorial.m file will be included in
Octave or not.
In case of including, it makes sense in order to make connection between
different kinds of factorial calculators.
Cheers,
Akos
Carnë Draug wrote:
On 26 December 2011 11:00, Akos Marton<makos...@gmail.com> wrote:
Hi Folks,
I was looking directly for some large factorial calculator in Octave and did
not find any, hence took a while to find a solution. It could also be my
fault, but for users not initiated in it must be beneficial to have a direct
solution which is documented somewhere. Matlab does not have such a function
`lfactorial`, but R does. Here is another one and Octave would own it too.
After looking at Octave's `factorial.m` that was straightforward to
implement. Someone probably can find a place (e.g. in specfun pkg in
Octave-Forge) for this feature.
Source is attached to spread it around...
I excluded rounding, because it approximates on natural log scale. So it
would return float or double in case of typed usage.
Could you appreciate it, I would finish it up by documenting and complete
the whole source with the administration parts of it.
Cheers,
mAkos
Hi Akos
sorry for the very very late reply. Your function does not have a
license header and as such can't be added to the specfun package.
Could you please do that? Something like this
http://octave.svn.sourceforge.net/viewvc/octave/trunk/octave-forge/main/signal/inst/impinvar.m?revision=9536&content-type=text%2Fplain
would be perfect.
Thanks,
Carnë
## Copyright (C) 2012 Akos Marton <makos...@gmail.com>
##
## This file is part of Octave.
##
## Octave is free software; you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or (at
## your option) any later version.
##
## Octave 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
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Octave; see the file COPYING. If not, see
## <http://www.gnu.org/licenses/>.
## -*- texinfo -*-
## @deftypefn {Function File} {} lfactorial (@var{n})
## Return the factorial of @var{n} where @var{n} is a positive integer.
## Return value approximated on natural logarithmic scale in order to
## calculate the factorial of large numbers. For
## vector or matrix arguments, return the lfactorial of each element in the
## array. For non-integers see the generalized factorial function
## @code{lgamma}.
## @seealso{lgamma}
## @end deftypefn
function ans = lfactorial (n)
if (nargin != 1)
print_usage ();
elseif (any (n(:) < 0 | n(:) != round (n(:))))
error ("factorial: N must all be nonnegative integers");
endif
ans = lgamma (n+1);
endfunction
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev