Граф коммитов

94 Коммитов

Автор SHA1 Сообщение Дата
nobu 202cc8e615 math.c: fix for Bignum argument
* math.c (math_log, math_log2, math_log10): fix for Bignum argument.
  numbits should be add only when right shifted.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43080 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-28 14:25:59 +00:00
nobu e146015272 bignum.c, math.c: RB_BIGNUM_TYPE_P
* bignum.c, math.c (RB_BIGNUM_TYPE_P): predicate macro like
  RB_FLOAT_TYPE_P.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-07 19:04:23 +00:00
nobu c26293dccf bignum.c, math.c: type predicates
* bignum.c, math.c: use type predicate macros instead of TYPE().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-07 19:04:18 +00:00
akr 0e02d92371 * math.c (math_log): Test the sign for bignums.
(math_log2): Ditto.
  (math_log10): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-07 12:34:09 +00:00
akr 08e3cb6959 * math.c (math_log): Support bignums bigger than 2**1024.
(math_log2): Ditto.
  (math_log10): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-07 11:26:52 +00:00
akr bd15d4ca78 * internal.h (numberof): Gathered from various files.
* array.c, math.c, thread_pthread.c, iseq.c, enum.c, string.c, io.c,
  load.c, compile.c, struct.c, eval.c, gc.c, parse.y, process.c,
  error.c, ruby.c: Remove the definitions of numberof.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 10:01:19 +00:00
nobu 021c2102dc math.c: ASCII minus
* math.c: use ASCII minus (-) instead of U+2212.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-02 05:59:40 +00:00
eregon 46cb75db9b * math.c: improve and fix documentation of sin, tan and log
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-20 10:35:26 +00:00
zzak c1f176974c * math.c: RDoc formatting of Math core docs with domains and codomains
Patch by @eLobato [Fixes GH-309]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-19 22:29:26 +00:00
tadf c07d295204 * include/ruby/util.h: removed extra semicolon in definition of
macro.
	* compile.c: ditto.
	* cont.c: ditto.
	* math.c: ditto.
	* node.c: ditto.
	* parse.y: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-21 12:42:11 +00:00
akr 2bb5441808 * complex.c: use "__sun" instead of "__sun__" to detect SunOS.
* math.c: ditto.

* hash.c: ditto.

* atomic.h: ditto.

* ext/io/wait/wait.c: ditto.

[ruby-dev:44693]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33521 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-24 14:57:08 +00:00
nobu 8e6e8e6288 * use RB_TYPE_P which is optimized for constant types, instead of
comparison with TYPE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-29 11:07:45 +00:00
ngoto 700aeee754 * complex.c (f_signbit): fix compile error in gcc4 on Solaris with
CFLAGS="-std=gnu99".  [ruby-dev:44355] fix [Bug #5159]

* math.c: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-05 07:03:21 +00:00
yugui 4270dbe629 Forward-ports r32777 from branches/ruby_1_9_3 to trunk.
--
* complex.c (f_signbit): gcc4 on Solaris DOES have signbit but does
  not have it on header.

* math.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-31 14:17:40 +00:00
drbrain 926301969f * math.c: Attach documentation for Math.
* object.c:  Document NIL, TRUE, FALSE.
	* io.c:  Improve grammar in ARGF comment.  Document STDIN/OUT/ERR.
	  Document ARGF global constant.
	* lib/rake:  Hide deprecated toplevel constants from RDoc (import from
	  rake trunk).
	* lib/thwait.rb:  Document ThWait.
	* lib/mathn.rb:  Hide Math redefinition from RDoc
	* lib/sync.rb:  Add a basic comment for Sync_m, Synchronizer_m, Sync,
	  Synchronizer.
	* parse.y:  Document SCRIPT_LINES__.
	* hash.c:  Document ENV class and global constant.
	* vm.c:  Document TOPLEVEL_BINDING.
	* version.c:  Document RUBY_* constants.
	* ruby.c:  Document DATA and ARGV.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32281 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-29 03:09:34 +00:00
akr e7996eb3cc * internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.

* iseq.h: declare rb_iseq_t dependent internal functions here.

* vm_core.h: declare rb_thread_t dependent internal functions here.

* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
  enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
  iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
  proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
  thread.c, time.c, transcode.c, variable.c, vm.c,
  tool/compile_prelude.rb: don't declare internal functions declared
  in above headers.  include above headers if required.

  Note that rb_thread_mark() was declared as
  void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
  void rb_thread_mark(void *ptr) in vm.c.  Now it is declared as
  the later in internal.h.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 22:43:38 +00:00
usa 0cfe185f39 * math.c (math_atan2): you should know that M_PI is not the feature
of C90.
  fixed build failure caused by r29115.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-27 06:29:47 +00:00
mrkn 9be503f332 * math.c (math_atan2): change the behavior when x and y are zero.
* test/ruby/test_math.rb (test_atan2): add tests for the above
  changes.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29115 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-27 03:51:56 +00:00
marcandre 7729de4d91 * array.c: Documentation: change => in call-seq to ->.
Harmonize "#=>" in examples. [ruby-core:30206]

* bignum.c: ditto

* class.c: ditto

* compar.c: ditto

* cont.c: ditto

* dir.c: ditto

* encoding.c: ditto

* enum.c: ditto

* enumerator.c: ditto

* error.c: ditto

* eval.c: ditto

* file.c: ditto

* gc.c: ditto

* io.c: ditto

* load.c: ditto

* marshal.c: ditto

* math.c: ditto

* numeric.c: ditto

* object.c: ditto

* pack.c: ditto

* proc.c: ditto

* process.c: ditto

* random.c: ditto

* range.c: ditto

* re.c: ditto

* ruby.c: ditto

* signal.c: ditto

* sprintf.c: ditto

* string.c: ditto

* struct.c: ditto

* thread.c: ditto

* time.c: ditto

* transcode.c: ditto

* variable.c: ditto

* vm_eval.c: ditto

* vm_method.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-17 21:07:33 +00:00
marcandre 1dee5e34a3 * error.c: RDoc for subclasses of Exception. [ruby-core:28394]
* cont.c: ditto

* enumerator.c: ditto

* io.c: ditto

* math.c: ditto

* numeric.c: ditto

* proc.c: ditto

* re.c: ditto

* thread.c: ditto

* transcode.c: ditto. Thanks to Run Paint for some of the documentation.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-08 04:50:09 +00:00
marcandre 63324cb36d * math.c: Math::DomainError < StandardException [ruby-core:29855]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27566 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-30 13:46:38 +00:00
muraken 5073155a17 * math.c (rb_eMathDomainError): new exception class for representing mathematical domain error instead of Errno::EDOM.
* math.c (domain_check, infinity_check): removed, no longer needed.
* math.c (math_atan2, math_acos, math_asin, math_acosh, math_atanh, math_log, math_log2, math_log10, math_sqrt, math_gamma, math_lgamma): mathematical domain errors are checked and raised before calling libm's functions.
* test/ruby/test_math.rb: updated for changes of maht.c.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-28 10:08:22 +00:00
mame 54380d99f8 * math.c (math_atanh): raise ERANGE without calling atanh if absolute
value is 1 to achieve platform-independent math.  [ruby-core:28219]

* math.c (math_lgamma): return [Infinity, 1] without calling lgamma_r
  if argument is infinity or -infinity.  [ruby-core:28219]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-18 13:39:11 +00:00
akr fcd2fb4e87 * math.c (math_lgamma): initialize sign because
lgamma(NaN) doesn't set the sign in OpenSolaris.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-06 18:02:59 +00:00
naruse 0fdbdfbbda * math.c (domain_check): ignore errno if y is inf.
r26335 is because NetBSD 5.0's asin and acos returns
  0.0 with errno EDOM. But it breaks Linux whose gamma returns inf
  with errno ERANGE on.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26397 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-01-25 02:51:16 +00:00
nobu 441619b73c * math.c (domain_check): check errno first.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26335 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-01-17 10:24:27 +00:00
akr 4d4ed5640c rdoc update.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-12-27 01:37:23 +00:00
takano32 a1c4d60560 * math.c (math_gamma): fix incorrect comparison expression.
see also [ruby-dev:39709] [Bug #2381]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25836 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-18 03:06:32 +00:00
akr 10b7e0e4ad rdoc update.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-17 13:24:53 +00:00
yugui 6b7e6f08b0 * math.c (math_atanh): reverted r25279.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25287 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-10 11:38:47 +00:00
marcandre 243400fbed * math.c (math_atanh): Fix bug for Math.atanh(+/-1). It now returns +-Infinity. [ruby-core:26028]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25279 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-10 05:56:07 +00:00
akr 78a54607b6 update comment.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-05 00:40:13 +00:00
nobu 3fe5402dfa * math.c (math_gamma): get rid of direct comparison between too
big double and integer, with gcc on x86_64.  [ruby-core:25257]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-02 07:50:16 +00:00
nobu 274fa77e3f * math.c (domain_check): simplified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-02 04:47:39 +00:00
nobu dc697b1905 * math.c (math_gamma): constified fact_table.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-02 04:32:18 +00:00
akr e7ba39350a rdoc update.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-13 10:36:52 +00:00
akr 91892b820e update rdoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-06 09:30:04 +00:00
akr c36aeb5360 * math.c (math_gamma): use a table for positive small integers.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-06 07:51:20 +00:00
matz 0b58675868 * math.c (Need_Float): call rb_to_float() only when it is really
needed.  small performance improvement.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-23 15:51:31 +00:00
nobu 12d2c8ba41 stripped trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-22 14:23:33 +00:00
takano32 c4e79b640b * math.c: SEGV is caused by implicit rb_to_float declaration
test_complexrational.rb: [BUG] at IA-64 architecture


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-28 06:42:09 +00:00
matz 98454a6da8 * object.c (rb_to_float): replaced by to_flo definition from
math.c  [ruby-dev:37668]

* math.c (Need_Float): use rb_to_float().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-31 14:30:50 +00:00
matz 54a722bd42 * math.c (domain_check): should not raise EDOM exception for NaN
value if operand is also NaN.  affects acos, asin, acosh, atanh,
  log, log2, log10, sqrt, gamma, lgamma. [ruby-dev:37357]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-10 18:00:51 +00:00
tadf f019cd5b79 inserted a newline.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-28 15:19:53 +00:00
tadf 2d5a281c98 * math.c (rb_math_{atan2,cos,cosh,hypot,log,sin,sinh,sqrt}): added.
* complex.c: follows the above change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-28 15:10:40 +00:00
tadf bdf81563bf * math.c (math_log): should check argc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-21 12:53:40 +00:00
matz 31b6ea65bb * include/ruby/ruby.h (DBL2NUM): renamed from DOUBLE2NUM.
a patch from Tadashi Saito <shiba at mail2.accsnet.ne.jp>
  in [ruby-dev:36102].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-05 18:24:21 +00:00
naruse 78b5fdd5a8 * math.c (math_atanh): raise EDOM on FreeBSD when atanh(1).
* math.c (math_log): ditto.

* math.c (math_log2): ditto.

* math.c (math_log10): ditto.

* test/ruby/test_math.rb: test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-28 17:42:32 +00:00
akr 2e35696bbe add an example to rdoc of sqrt and cbrt.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-15 02:13:16 +00:00
nobu 075530a685 * suppress warnings with -Wwrite-string.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-31 09:28:20 +00:00