comparison src/data.cc @ 9197:3c27a0340a64

Update documentation for section 17.8 (Mathematical Constants) of arith.texi
author Rik <rdrider0-list@yahoo.com>
date Thu, 14 May 2009 16:03:58 -0700
parents 41a0fc5c4600
children 3b9aacf07744
comparison
equal deleted inserted replaced
9196:c229bfb14d8d 9197:3c27a0340a64
3679 3679
3680 */ 3680 */
3681 3681
3682 DEFUN (Inf, args, , 3682 DEFUN (Inf, args, ,
3683 "-*- texinfo -*-\n\ 3683 "-*- texinfo -*-\n\
3684 @deftypefn {Built-in Function} {} Inf (@var{x})\n\ 3684 @deftypefn {Built-in Function} {} Inf\n\
3685 @deftypefnx {Built-in Function} {} Inf (@var{n})\n\
3685 @deftypefnx {Built-in Function} {} Inf (@var{n}, @var{m})\n\ 3686 @deftypefnx {Built-in Function} {} Inf (@var{n}, @var{m})\n\
3686 @deftypefnx {Built-in Function} {} Inf (@var{n}, @var{m}, @var{k}, @dots{})\n\ 3687 @deftypefnx {Built-in Function} {} Inf (@var{n}, @var{m}, @var{k}, @dots{})\n\
3687 @deftypefnx {Built-in Function} {} Inf (@dots{}, @var{class})\n\ 3688 @deftypefnx {Built-in Function} {} Inf (@dots{}, @var{class})\n\
3688 Return a matrix or N-dimensional array whose elements are all Infinity.\n\ 3689 Return a scalar, matrix or N-dimensional array whose elements are all equal\n\
3689 The arguments are handled the same as the arguments for @code{eye}.\n\ 3690 to the IEEE representation for positive infinity.\n\
3690 The optional argument @var{class} may be either @samp{\"single\"} or\n\ 3691 \n\
3691 @samp{\"double\"}. The default is @samp{\"double\"}.\n\ 3692 Infinity is produced when results are too large to be represented using the\n\
3693 the IEEE floating point format for numbers. Two common examples which\n\
3694 produce infinity are division by zero and overflow.\n\
3695 @example\n\
3696 @group\n\
3697 [1/0 e^800]\n\
3698 @result{}\n\
3699 Inf Inf\n\
3700 @end group\n\
3701 @end example\n\
3702 \n\
3703 When called with no arguments, return a scalar with the value @samp{Inf}.\n\
3704 When called with a single argument, return a square matrix with the dimension\n\
3705 specified. When called with more than one scalar argument the first two\n\
3706 arguments are taken as the number of rows and columns and any further\n\
3707 arguments specify additional matrix dimensions.\n\
3708 The optional argument @var{class} specifies the return type and may be\n\
3709 either \"double\" or \"single\".\n\
3692 @end deftypefn") 3710 @end deftypefn")
3693 { 3711 {
3694 return fill_matrix (args, lo_ieee_inf_value (), 3712 return fill_matrix (args, lo_ieee_inf_value (),
3695 lo_ieee_float_inf_value (), "Inf"); 3713 lo_ieee_float_inf_value (), "Inf");
3696 } 3714 }
3716 3734
3717 */ 3735 */
3718 3736
3719 DEFUN (NaN, args, , 3737 DEFUN (NaN, args, ,
3720 "-*- texinfo -*-\n\ 3738 "-*- texinfo -*-\n\
3721 @deftypefn {Built-in Function} {} NaN (@var{x})\n\ 3739 @deftypefn {Built-in Function} {} NaN\n\
3740 @deftypefnx {Built-in Function} {} NaN (@var{n})\n\
3722 @deftypefnx {Built-in Function} {} NaN (@var{n}, @var{m})\n\ 3741 @deftypefnx {Built-in Function} {} NaN (@var{n}, @var{m})\n\
3723 @deftypefnx {Built-in Function} {} NaN (@var{n}, @var{m}, @var{k}, @dots{})\n\ 3742 @deftypefnx {Built-in Function} {} NaN (@var{n}, @var{m}, @var{k}, @dots{})\n\
3724 @deftypefnx {Built-in Function} {} NaN (@dots{}, @var{class})\n\ 3743 @deftypefnx {Built-in Function} {} NaN (@dots{}, @var{class})\n\
3725 Return a matrix or N-dimensional array whose elements are all NaN\n\ 3744 Return a scalar, matrix, or N-dimensional array whose elements are all equal\n\
3726 (Not a Number). The value NaN is the result of an operation like\n\ 3745 to the IEEE symbol NaN (Not a Number).\n\
3727 @iftex\n\ 3746 NaN is the result of operations which do not produce a well defined numerical\n\
3747 result. Common operations which produce a NaN are arithmetic with infinity\n\
3728 @tex\n\ 3748 @tex\n\
3729 $0/0$, or $\\infty - \\infty$,\n\ 3749 ($\\infty - \\infty$), zero divided by zero ($0/0$),\n\
3730 @end tex\n\ 3750 @end tex\n\
3731 @end iftex\n\
3732 @ifnottex\n\ 3751 @ifnottex\n\
3733 0/0, or @samp{Inf - Inf},\n\ 3752 (Inf - Inf), zero divided by zero (0/0),\n\
3734 @end ifnottex\n\ 3753 @end ifnottex\n\
3735 or any operation with a NaN.\n\ 3754 and any operation involving another NaN value (5 + NaN).\n\
3736 \n\ 3755 \n\
3737 Note that NaN always compares not equal to NaN. This behavior is\n\ 3756 Note that NaN always compares not equal to NaN (NaN != NaN). This behavior\n\
3738 specified by the IEEE standard for floating point arithmetic. To\n\ 3757 is specified by the IEEE standard for floating point arithmetic. To\n\
3739 find NaN values, you must use the @code{isnan} function.\n\ 3758 find NaN values, use the @code{isnan} function.\n\
3740 \n\ 3759 \n\
3741 The arguments are handled the same as the arguments for @code{eye}.\n\ 3760 When called with no arguments, return a scalar with the value @samp{NaN}.\n\
3742 The optional argument @var{class} may be either @samp{\"single\"} or\n\ 3761 When called with a single argument, return a square matrix with the dimension\n\
3743 @samp{\"double\"}. The default is @samp{\"double\"}.\n\ 3762 specified. When called with more than one scalar argument the first two\n\
3763 arguments are taken as the number of rows and columns and any further\n\
3764 arguments specify additional matrix dimensions.\n\
3765 The optional argument @var{class} specifies the return type and may be\n\
3766 either \"double\" or \"single\".\n\
3767 @seealso{isnan}\n\
3744 @end deftypefn") 3768 @end deftypefn")
3745 { 3769 {
3746 return fill_matrix (args, lo_ieee_nan_value (), 3770 return fill_matrix (args, lo_ieee_nan_value (),
3747 lo_ieee_float_nan_value (), "NaN"); 3771 lo_ieee_float_nan_value (), "NaN");
3748 } 3772 }
3767 3791
3768 */ 3792 */
3769 3793
3770 DEFUN (e, args, , 3794 DEFUN (e, args, ,
3771 "-*- texinfo -*-\n\ 3795 "-*- texinfo -*-\n\
3772 @deftypefn {Built-in Function} {} e (@var{x})\n\ 3796 @deftypefn {Built-in Function} {} e\n\
3797 @deftypefnx {Built-in Function} {} e (@var{n})\n\
3773 @deftypefnx {Built-in Function} {} e (@var{n}, @var{m})\n\ 3798 @deftypefnx {Built-in Function} {} e (@var{n}, @var{m})\n\
3774 @deftypefnx {Built-in Function} {} e (@var{n}, @var{m}, @var{k}, @dots{})\n\ 3799 @deftypefnx {Built-in Function} {} e (@var{n}, @var{m}, @var{k}, @dots{})\n\
3775 @deftypefnx {Built-in Function} {} e (@dots{}, @var{class})\n\ 3800 @deftypefnx {Built-in Function} {} e (@dots{}, @var{class})\n\
3776 Return a matrix or N-dimensional array whose elements are all equal\n\ 3801 Return a scalar, matrix, or N-dimensional array whose elements are all equal\n\
3777 to the base of natural logarithms. The constant\n\ 3802 to the base of natural logarithms. The constant\n\
3778 @iftex\n\
3779 @tex\n\ 3803 @tex\n\
3780 $e$\n\ 3804 $e$ satisfies the equation $\\log (e) = 1$.\n\
3781 @end tex\n\ 3805 @end tex\n\
3782 @end iftex\n\
3783 @ifnottex\n\ 3806 @ifnottex\n\
3784 @var{e}\n\ 3807 @samp{e} satisfies the equation @code{log} (e) = 1.\n\
3785 @end ifnottex\n\ 3808 @end ifnottex\n\
3786 satisfies the equation\n\ 3809 \n\
3787 @iftex\n\ 3810 When called with no arguments, return a scalar with the value @math{e}. When\n\
3788 @tex\n\ 3811 called with a single argument, return a square matrix with the dimension\n\
3789 $\\log (e) = 1$.\n\ 3812 specified. When called with more than one scalar argument the first two\n\
3790 @end tex\n\ 3813 arguments are taken as the number of rows and columns and any further\n\
3791 @end iftex\n\ 3814 arguments specify additional matrix dimensions.\n\
3792 @ifnottex\n\ 3815 The optional argument @var{class} specifies the return type and may be\n\
3793 @code{log} (@var{e}) = 1.\n\ 3816 either \"double\" or \"single\".\n\
3794 @end ifnottex\n\
3795 @end deftypefn") 3817 @end deftypefn")
3796 { 3818 {
3797 #if defined (M_E) 3819 #if defined (M_E)
3798 double e_val = M_E; 3820 double e_val = M_E;
3799 #else 3821 #else
3803 return fill_matrix (args, e_val, "e"); 3825 return fill_matrix (args, e_val, "e");
3804 } 3826 }
3805 3827
3806 DEFUN (eps, args, , 3828 DEFUN (eps, args, ,
3807 "-*- texinfo -*-\n\ 3829 "-*- texinfo -*-\n\
3808 @deftypefn {Built-in Function} {} eps (@var{x})\n\ 3830 @deftypefn {Built-in Function} {} eps\n\
3831 @deftypefnx {Built-in Function} {} eps (@var{x})\n\
3809 @deftypefnx {Built-in Function} {} eps (@var{n}, @var{m})\n\ 3832 @deftypefnx {Built-in Function} {} eps (@var{n}, @var{m})\n\
3810 @deftypefnx {Built-in Function} {} eps (@var{n}, @var{m}, @var{k}, @dots{})\n\ 3833 @deftypefnx {Built-in Function} {} eps (@var{n}, @var{m}, @var{k}, @dots{})\n\
3811 @deftypefnx {Built-in Function} {} eps (@dots{}, @var{class})\n\ 3834 @deftypefnx {Built-in Function} {} eps (@dots{}, @var{class})\n\
3812 Return a matrix or N-dimensional array whose elements are all eps,\n\ 3835 Return a scalar, matrix or N-dimensional array whose elements are all eps,\n\
3813 the machine precision. More precisely, @code{eps} is the largest\n\ 3836 the machine precision. More precisely, @code{eps} is the relative spacing\n\
3814 relative spacing between any two adjacent numbers in the machine's\n\ 3837 between any two adjacent numbers in the machine's floating point system.\n\
3815 floating point system. This number is obviously system-dependent. On\n\ 3838 This number is obviously system dependent. On machines that support IEEE\n\
3816 machines that support 64-bit IEEE floating point arithmetic, @code{eps}\n\ 3839 floating point arithmetic, @code{eps} is approximately\n\
3817 is approximately\n\ 3840 @tex\n\
3841 $2.2204\\times10^{-16}$ for double precision and $1.1921\\times10^{-7}$\n\
3842 @end tex\n\
3818 @ifnottex\n\ 3843 @ifnottex\n\
3819 2.2204e-16.\n\ 3844 2.2204e-16 for double precision and 1.1921e-07\n\
3820 @end ifnottex\n\ 3845 @end ifnottex\n\
3821 @iftex\n\ 3846 for single precision.\n\
3822 @tex\n\ 3847 \n\
3823 $2.2204\\times10^{-16}$.\n\ 3848 When called with no arguments, return a scalar with the value\n\
3824 @end tex\n\ 3849 @code{eps(1.0)}.\n\
3825 @end iftex\n\ 3850 Given a single argument @var{x}, return the distance between @var{x} and\n\
3826 for double precision and\n\ 3851 the next largest value.\n\
3827 @ifnottex\n\ 3852 When called with more than one argument the first two arguments are taken as\n\
3828 1.1921e-07.\n\ 3853 the number of rows and columns and any further\n\
3829 @end ifnottex\n\ 3854 arguments specify additional matrix dimensions.\n\
3830 @iftex\n\ 3855 The optional argument @var{class} specifies the return type and may be\n\
3831 @tex\n\ 3856 either \"double\" or \"single\".\n\
3832 $1.1921\\times10^{-7}$.\n\
3833 @end tex\n\
3834 @end iftex\n\
3835 for single precision. Given a single argument @var{x}, return the\n\
3836 distance between @var{x} and the next largest value.\n\
3837 @end deftypefn") 3857 @end deftypefn")
3838 { 3858 {
3839 int nargin = args.length (); 3859 int nargin = args.length ();
3840 octave_value retval; 3860 octave_value retval;
3841 3861
3922 */ 3942 */
3923 3943
3924 3944
3925 DEFUN (pi, args, , 3945 DEFUN (pi, args, ,
3926 "-*- texinfo -*-\n\ 3946 "-*- texinfo -*-\n\
3927 @deftypefn {Built-in Function} {} pi (@var{x})\n\ 3947 @deftypefn {Built-in Function} {} pi\n\
3948 @deftypefnx {Built-in Function} {} pi (@var{n})\n\
3928 @deftypefnx {Built-in Function} {} pi (@var{n}, @var{m})\n\ 3949 @deftypefnx {Built-in Function} {} pi (@var{n}, @var{m})\n\
3929 @deftypefnx {Built-in Function} {} pi (@var{n}, @var{m}, @var{k}, @dots{})\n\ 3950 @deftypefnx {Built-in Function} {} pi (@var{n}, @var{m}, @var{k}, @dots{})\n\
3930 @deftypefnx {Built-in Function} {} pi (@dots{}, @var{class})\n\ 3951 @deftypefnx {Built-in Function} {} pi (@dots{}, @var{class})\n\
3931 Return a matrix or N-dimensional array whose elements are all equal\n\ 3952 Return a scalar, matrix, or N-dimensional array whose elements are all equal\n\
3932 to the ratio of the circumference of a circle to its diameter.\n\ 3953 to the ratio of the circumference of a circle to its\n\
3954 @tex\n\
3955 diameter($\\pi$).\n\
3956 @end tex\n\
3957 @ifnottex\n\
3958 diameter.\n\
3959 @end ifnottex\n\
3933 Internally, @code{pi} is computed as @samp{4.0 * atan (1.0)}.\n\ 3960 Internally, @code{pi} is computed as @samp{4.0 * atan (1.0)}.\n\
3961 \n\
3962 When called with no arguments, return a scalar with the value of\n\
3963 @tex\n\
3964 $\\pi$.\n\
3965 @end tex\n\
3966 @ifnottex\n\
3967 pi.\n\
3968 @end ifnottex\n\
3969 When called with a single argument, return a square matrix with the dimension\n\
3970 specified. When called with more than one scalar argument the first two\n\
3971 arguments are taken as the number of rows and columns and any further\n\
3972 arguments specify additional matrix dimensions.\n\
3973 The optional argument @var{class} specifies the return type and may be\n\
3974 either \"double\" or \"single\".\n\
3934 @end deftypefn") 3975 @end deftypefn")
3935 { 3976 {
3936 #if defined (M_PI) 3977 #if defined (M_PI)
3937 double pi_val = M_PI; 3978 double pi_val = M_PI;
3938 #else 3979 #else
3942 return fill_matrix (args, pi_val, "pi"); 3983 return fill_matrix (args, pi_val, "pi");
3943 } 3984 }
3944 3985
3945 DEFUN (realmax, args, , 3986 DEFUN (realmax, args, ,
3946 "-*- texinfo -*-\n\ 3987 "-*- texinfo -*-\n\
3947 @deftypefn {Built-in Function} {} realmax (@var{x})\n\ 3988 @deftypefn {Built-in Function} {} realmax\n\
3989 @deftypefnx {Built-in Function} {} realmax (@var{n})\n\
3948 @deftypefnx {Built-in Function} {} realmax (@var{n}, @var{m})\n\ 3990 @deftypefnx {Built-in Function} {} realmax (@var{n}, @var{m})\n\
3949 @deftypefnx {Built-in Function} {} realmax (@var{n}, @var{m}, @var{k}, @dots{})\n\ 3991 @deftypefnx {Built-in Function} {} realmax (@var{n}, @var{m}, @var{k}, @dots{})\n\
3950 @deftypefnx {Built-in Function} {} realmax (@dots{}, @var{class})\n\ 3992 @deftypefnx {Built-in Function} {} realmax (@dots{}, @var{class})\n\
3951 Return a matrix or N-dimensional array whose elements are all equal\n\ 3993 Return a scalar, matrix or N-dimensional array whose elements are all equal\n\
3952 to the largest floating point number that is representable. The actual\n\ 3994 to the largest floating point number that is representable. The actual\n\
3953 value is system-dependent. On machines that support 64-bit IEEE\n\ 3995 value is system dependent. On machines that support IEEE\n\
3954 floating point arithmetic, @code{realmax} is approximately\n\ 3996 floating point arithmetic, @code{realmax} is approximately\n\
3997 @tex\n\
3998 $1.7977\\times10^{308}$ for double precision and $3.4028\\times10^{38}$\n\
3999 @end tex\n\
3955 @ifnottex\n\ 4000 @ifnottex\n\
3956 1.7977e+308\n\ 4001 1.7977e+308 for double precision and 3.4028e+38\n\
3957 @end ifnottex\n\ 4002 @end ifnottex\n\
3958 @iftex\n\ 4003 for single precision.\n\
3959 @tex\n\ 4004 \n\
3960 $1.7977\\times10^{308}$.\n\ 4005 When called with no arguments, return a scalar with the value\n\
3961 @end tex\n\ 4006 @code{realmax(\"double\")}.\n\
3962 @end iftex\n\ 4007 When called with a single argument, return a square matrix with the dimension\n\
3963 @seealso{realmin}\n\ 4008 specified. When called with more than one scalar argument the first two\n\
4009 arguments are taken as the number of rows and columns and any further\n\
4010 arguments specify additional matrix dimensions.\n\
4011 The optional argument @var{class} specifies the return type and may be\n\
4012 either \"double\" or \"single\".\n\
4013 @seealso{realmin, intmax, bitmax}\n\
3964 @end deftypefn") 4014 @end deftypefn")
3965 { 4015 {
3966 return fill_matrix (args, DBL_MAX, FLT_MAX, "realmax"); 4016 return fill_matrix (args, DBL_MAX, FLT_MAX, "realmax");
3967 } 4017 }
3968 4018
3969 DEFUN (realmin, args, , 4019 DEFUN (realmin, args, ,
3970 "-*- texinfo -*-\n\ 4020 "-*- texinfo -*-\n\
3971 @deftypefn {Built-in Function} {} realmin (@var{x})\n\ 4021 @deftypefn {Built-in Function} {} realmin\n\
4022 @deftypefnx {Built-in Function} {} realmin (@var{n})\n\
3972 @deftypefnx {Built-in Function} {} realmin (@var{n}, @var{m})\n\ 4023 @deftypefnx {Built-in Function} {} realmin (@var{n}, @var{m})\n\
3973 @deftypefnx {Built-in Function} {} realmin (@var{n}, @var{m}, @var{k}, @dots{})\n\ 4024 @deftypefnx {Built-in Function} {} realmin (@var{n}, @var{m}, @var{k}, @dots{})\n\
3974 @deftypefnx {Built-in Function} {} realmin (@dots{}, @var{class})\n\ 4025 @deftypefnx {Built-in Function} {} realmin (@dots{}, @var{class})\n\
3975 Return a matrix or N-dimensional array whose elements are all equal\n\ 4026 Return a scalar, matrix or N-dimensional array whose elements are all equal\n\
3976 to the smallest normalized floating point number that is representable.\n\ 4027 to the smallest normalized floating point number that is representable.\n\
3977 The actual value is system-dependent. On machines that support\n\ 4028 The actual value is system dependent. On machines that support\n\
3978 64-bit IEEE floating point arithmetic, @code{realmin} is approximately\n\ 4029 IEEE floating point arithmetic, @code{realmin} is approximately\n\
4030 @tex\n\
4031 $2.2251\\times10^{-308}$ for double precision and $1.1755\\times10^{-38}$\n\
4032 @end tex\n\
3979 @ifnottex\n\ 4033 @ifnottex\n\
3980 2.2251e-308\n\ 4034 2.2251e-308 for double precision and 1.1755e-38\n\
3981 @end ifnottex\n\ 4035 @end ifnottex\n\
3982 @iftex\n\ 4036 for single precision.\n\
3983 @tex\n\ 4037 \n\
3984 $2.2251\\times10^{-308}$.\n\ 4038 When called with no arguments, return a scalar with the value\n\
3985 @end tex\n\ 4039 @code{realmin(\"double\")}.\n\
3986 @end iftex\n\ 4040 When called with a single argument, return a square matrix with the dimension\n\
3987 @seealso{realmax}\n\ 4041 specified. When called with more than one scalar argument the first two\n\
4042 arguments are taken as the number of rows and columns and any further\n\
4043 arguments specify additional matrix dimensions.\n\
4044 The optional argument @var{class} specifies the return type and may be\n\
4045 either \"double\" or \"single\".\n\
4046 @seealso{realmax, intmin}\n\
3988 @end deftypefn") 4047 @end deftypefn")
3989 { 4048 {
3990 return fill_matrix (args, DBL_MIN, FLT_MIN, "realmin"); 4049 return fill_matrix (args, DBL_MIN, FLT_MIN, "realmin");
3991 } 4050 }
3992 4051
3993 DEFUN (I, args, , 4052 DEFUN (I, args, ,
3994 "-*- texinfo -*-\n\ 4053 "-*- texinfo -*-\n\
3995 @deftypefn {Built-in Function} {} I (@var{x})\n\ 4054 @deftypefn {Built-in Function} {} I\n\
4055 @deftypefnx {Built-in Function} {} I (@var{n})\n\
3996 @deftypefnx {Built-in Function} {} I (@var{n}, @var{m})\n\ 4056 @deftypefnx {Built-in Function} {} I (@var{n}, @var{m})\n\
3997 @deftypefnx {Built-in Function} {} I (@var{n}, @var{m}, @var{k}, @dots{})\n\ 4057 @deftypefnx {Built-in Function} {} I (@var{n}, @var{m}, @var{k}, @dots{})\n\
3998 @deftypefnx {Built-in Function} {} I (@dots{}, @var{class})\n\ 4058 @deftypefnx {Built-in Function} {} I (@dots{}, @var{class})\n\
3999 Return a matrix or N-dimensional array whose elements are all equal\n\ 4059 Return a scalar, matrix, or N-dimensional array whose elements are all equal\n\
4000 to the pure imaginary unit, defined as\n\ 4060 to the pure imaginary unit, defined as\n\
4001 @iftex\n\
4002 @tex\n\ 4061 @tex\n\
4003 $\\sqrt{-1}$.\n\ 4062 $\\sqrt{-1}$.\n\
4004 @end tex\n\ 4063 @end tex\n\
4005 @end iftex\n\
4006 @ifnottex\n\ 4064 @ifnottex\n\
4007 @code{sqrt (-1)}.\n\ 4065 @code{sqrt (-1)}.\n\
4008 @end ifnottex\n\ 4066 @end ifnottex\n\
4009 Since I (also i, J, and j) is a function, you can use the name(s) for\n\ 4067 I, and its equivalents i, J, and j, are functions so any of the names may\n\
4010 other purposes.\n\ 4068 be reused for other purposes (such as i for a counter variable).\n\
4069 \n\
4070 When called with no arguments, return a scalar with the value @math{i}. When\n\
4071 called with a single argument, return a square matrix with the dimension\n\
4072 specified. When called with more than one scalar argument the first two\n\
4073 arguments are taken as the number of rows and columns and any further\n\
4074 arguments specify additional matrix dimensions.\n\
4075 The optional argument @var{class} specifies the return type and may be\n\
4076 either \"double\" or \"single\".\n\
4011 @end deftypefn") 4077 @end deftypefn")
4012 { 4078 {
4013 return fill_matrix (args, Complex (0.0, 1.0), "I"); 4079 return fill_matrix (args, Complex (0.0, 1.0), "I");
4014 } 4080 }
4015 4081