summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-complex
AgeCommit message (Collapse)Author
2022-01-05object.c: Call functions directly from `mrb_ensure_int_type()`; #5622Yukihiro "Matz" Matsumoto
2021-12-31Call functions directly from `mrb_ensure_float_type()`dearblue
ref. commit 7f40b645d2773c8f50c48ae4adf90488e164da55 Currently, the build configurations `MRB_USE_COMPLEX` and `MRB_USE_RATIONAL` are not listed in the documentation. In other words, they are hidden settings. They are defined in `mrbgems/mruby-{complex,rational}/mrbgem.rake`. So this patch assumes that it is safe to refer to these functions in core-gems directly from core functions. However, applications that link with `libmruby_core.a` will have compatibility issues. In fact, `mrbgems/mruby-bin-mrbc` links with `libmruby_core.a`, so I had to prepare a dummy function.
2021-08-21Organize the include of header filesdearblue
- `#include <math.h>` is done in `mruby.h`. Eliminate the need to worry about the `MRB_NO_FLOAT` macro. - Include mruby header files before standard header files. If the standard header file is already placed before `mruby.h`, the standard header file added in the future tends to be placed before `mruby.h`. This change should some reduce the chances of macros that must be defined becoming undefined in C++ or including problematic header files in a particular mruby build configuration.
2021-06-20Added `MRB_OBJ_ALLOC()` macro that does not require a castdearblue
The `MRB_OBJ_ALLOC()` macro function returns a pointer of the type corresponding to the constant literal defined in `enum mrb_vtype`.
2021-06-16Run pre-commit with GitHub ActionsJohn Bampton
Running pre-commit with GitHub Actions now gives us more tests and coverage Remove duplicate GitHub Actions for merge conflicts and trailing whitespace Remove duplicate checks for markdownlint and yamllint from the GitHub Super-Linter Add new custom pre-commit hook running with a shell script to sort alphabetically and uniquify codespell.txt Add new pre-commit hook to check spelling with codespell https://github.com/codespell-project/codespell Fix spelling
2021-05-17Global renaming regarding `integer` and `float`.Yukihiro "Matz" Matsumoto
Consistent number conversion function names: * `mrb_value` to immediate (C) value * `mrb_int()` -> `mrb_as_int()` * `mrb_to_flo()` -> `mrb_as_float()` * `mrb_value` to `mrb_value` (converted) * `mrb_to_int()' * `mrb_Integer()` - removed * `mrb_Float()` -> `mrb_to_float` Consistent function name (avoid `_flo` suffix): * `mrb_div_flo()` -> `mrb_div_float`
2021-04-20Remove unused `#include` in `complex.c` and `rational.c`KOBAYASHI Shuji
2021-04-16feat(CI): add the GitHub Super LinterJohn Bampton
The GitHub Super Linter is a more robust and better supported tool than the current GitHub Actions we are using. Running these checks: ERROR_ON_MISSING_EXEC_BIT: true VALIDATE_BASH: true VALIDATE_BASH_EXEC: true VALIDATE_EDITORCONFIG: true VALIDATE_MARKDOWN: true VALIDATE_SHELL_SHFMT: true VALIDATE_YAML: true https://github.com/marketplace/actions/super-linter https://github.com/github/super-linter Added the GitHub Super Linter badge to the README. Also updated the pre-commit framework and added more documentation on pre-commit. Added one more pre-commit check: check-executables-have-shebangs Added one extra check for merge conflicts to our GitHub Actions. EditorConfig and Markdown linting. Minor grammar and spelling fixes. Update linter.yml
2021-03-28numeric.c: function renaming.Yukihiro "Matz" Matsumoto
- `mrb_num_div_int(mrb,x,y)` -> `mrb_div_int(mrb,x,y)` - `mrb_num_div_flo(mrb,x,y)` -> `mrb_div_flo(x,y)` They are internal function not supposed to be used outside of the core.
2021-03-27Move default `Integer#/` from `rational.c` to `complex.c`.Yukihiro "Matz" Matsumoto
2021-03-26complex.rb: add test for arithmetic operators. [ci skip]Yukihiro "Matz" Matsumoto
Tests for (`Float` or `Integer`) `op` `Complex`. Also added test dependency to `mruby-rational` since `int_div` definition relies on `Rational` when `MRB_USE_RATIONAL` is defined.
2021-03-24complex.c: use `mrb_num_div_flo` to avoid copying function.Yukihiro "Matz" Matsumoto
This change relies that `mrb_num_div_flo` does not use `mrb` inside.
2021-03-24complex.rb: unary plus (`+@`) to return self avoiding copying.Yukihiro "Matz" Matsumoto
2021-03-24complex.c: implement `Complex` addition and subtraction in C.Yukihiro "Matz" Matsumoto
2021-03-24complex.c: override float division to support `Complex`.Yukihiro "Matz" Matsumoto
2021-03-24Use `div_flo` (copy of `mrb_num_div_flo`) for float division.Yukihiro "Matz" Matsumoto
2021-03-24Use `mrb_num_div_flo` for float division.Yukihiro "Matz" Matsumoto
This function handles zero division properly. Also fixed bugs that multiply numbers instead of division.
2021-03-24Fix infinite recursive call bugs in integer division.Yukihiro "Matz" Matsumoto
2021-03-24complex.c: implement `Complex#/` and `#quo` in C.Yukihiro "Matz" Matsumoto
2021-03-24complex.c: implement `Complex#*` in C.Yukihiro "Matz" Matsumoto
2021-03-24rational.rb: avoid 'NaNi` representation.Yukihiro "Matz" Matsumoto
Use `NaN*i` as CRuby does.
2021-03-22Use global defines for `Rational` and `Complex`.Yukihiro "Matz" Matsumoto
2021-03-21complex.c: define `Complex#==` in C.Yukihiro "Matz" Matsumoto
This change also fixes the error caused by `rational.c` that calls `mrb_complex_eq()`, which had been undefined.
2021-03-19complex.c: overhaul complex operators.Yukihiro "Matz" Matsumoto
- define `MRB_TT_COMPLEX` - change object structure (`struct RComplex`) - add memory management for `MRB_TT_COMPLEX` - avoid operator overloading as much as possible - as a result, performance improved a log - should work with and without `Rational` defined
2021-02-26Use `MRB_SYM()` more extensively.Yukihiro "Matz" Matsumoto
2021-02-05Add a few new API for complex access.Yukihiro "Matz" Matsumoto
2021-02-05Refactor method overriding.Yukihiro "Matz" Matsumoto
* Use `class_eval` instead of `instance_eval`. * Reduce `class_eval` calls * define `Numeric#i` * undefine `Complex#i`
2021-02-05Add `Complex#to_c` method.Yukihiro "Matz" Matsumoto
2021-01-26Revert "Minimize the changes in #5277"Yukihiro "Matz" Matsumoto
This reverts commit dc51d89ac22acc60b9bfeed87115863565b74085.
2021-01-22Minimize the changes in #5277Yukihiro "Matz" Matsumoto
Instead of including `mruby/presym.h` everywhere, we provided the fallback `mruby/presym.inc` under `include/mruby` directory, and specify `-I<build-dir>/include` before `-I<top-dir>/include` in `presym.rake`. So even when someone drops `-I<build-dir>/include` in compiler options, it just compiles without failure.
2021-01-11Avoid including `presym.inc` in existing header filesKOBAYASHI Shuji
Addressed an issue where existing programs linking `libmruby.a` could only be built by adding `<build-dir>/include` to compiler's include path.
2020-10-12Silence warnings from implicit integer conversions.Yukihiro "Matz" Matsumoto
Caused from combination of `mrb_int`, `int` and `size_t`..
2020-10-12Integrate `Fixnum` class into `Integer` classdearblue
* The `Fixnum` constant is now an alias for the `Integer` class. * Remove `struct mrb_state::fixnum_class` member. If necessary, use `struct mrb_state::integer_class` instead.
2020-10-12Update tests for integer division.Yukihiro "Matz" Matsumoto
2020-10-12Rename float configuration option names.Yukihiro "Matz" Matsumoto
- `MRB_WITHOUT_FLOAT` => `MRB_NO_FLOAT` - `MRB_USE_FLOAT` => `MRB_USE_FLOAT32` The former is to use `USE_XXX` naming convention. The latter is to make sure `float` is 32bit float and not floating point number in general.
2020-10-12Use functions that take symbols to reduce string litrals in C.Yukihiro "Matz" Matsumoto
2020-06-20Add `mrb_get_arg1()` that retrieves single (and only) argument.Yukihiro "Matz" Matsumoto
`mrb_get_arg1()` raises `ArgumentError` if the method does not receive one argument. And replaces all `mrb_get_args(mrb, "o", &arg)` by the new function.
2020-06-20Symbolify saved alias name to improve performance.Yukihiro "Matz" Matsumoto
2019-12-15Drop dependencies from `mruby-complex` to some gemsKOBAYASHI Shuji
2019-08-09Avoid overflow and underflow in Complex#/Ray Chason
2019-08-08Implement Complex#abs in terms of Math.hypotRay Chason
Math.hypot avoids premature overflow and underflow
2019-08-05Use new specifiers/modifiers of `mrb_vfromat()`KOBAYASHI Shuji
The binary sizes (gems are only `mruby-bin-mruby`) are reduced slightly in my environment than before the introduction of new specifiers/modifiers (5116789a) with this change. ------------+-------------------+-------------------+-------- BINARY | BEFORE (5116789a) | AFTER (This PR) | RATIO ------------+-------------------+-------------------+-------- mruby | 593416 bytes | 593208 bytes | -0.04% libmruby.a | 769048 bytes | 767264 bytes | -0.23% ------------+-------------------+-------------------+-------- BTW, I accidentally changed `tasks/toolchains/visualcpp.rake` at #4613, so I put it back.
2019-07-30Refine message to `skip` in nested `assert`KOBAYASHI Shuji
- I think "Info" is used only to `skip`, so change to "Skip". - Changed the default value of `assert` and specify the argument explicitly at the caller of `assert` because it is unnatural "Assertion failed" is output even though the assertion doesn't fail. == Example: def assert_foo(exp, act) assert do assert_equal exp[0], act[0] assert_equal exp[1], act[1] end end def assert_bar(exp, act) assert do skip end end def assert_baz(exp, act) assert do assert_equal exp, act assert_bar exp, act end end assert 'test#skip_in_nested_assert' do assert_baz 1, 1 end === Before this patch: ?.. Info: test#skip_in_nested_assert (core) - Assertion[1] Info: Assertion failed (core) - Assertion[1-2] Skip: Assertion failed (core) Total: 3 OK: 2 KO: 0 Crash: 0 Warning: 0 Skip: 1 === After this patch: ??? Skip: test#skip_in_nested_assert (core) - Assertion[1] Skip: assert (core) - Assertion[1-2] Skip: assert (core) Total: 3 OK: 0 KO: 0 Crash: 0 Warning: 0 Skip: 3
2019-07-24Call `MRB_SET_INSTANCE_TT` for `Complex` and `Rational`.Yukihiro "Matz" Matsumoto
2019-07-22Check conflicts with `Complex` and `MRB_WITHOUT_FLOAT`; ref #4576Yukihiro "Matz" Matsumoto
The Complex class needs `mrb_float` so that it does not work with `MRB_WITHOUT_FLOAT` anyway.
2019-07-18Avoid making top-level `env` in initialization code; ref #4581Yukihiro "Matz" Matsumoto
2019-07-13Resolve ambiguous argument warning.Yukihiro "Matz" Matsumoto
2019-06-29Use nested `assert`dearblue
2019-06-05Fix not frozen in `Complex` method by `RData`dearblue
Object allocation was separated, and initialization was made common.
2019-06-05Fix memory leak in `Complex` method by `RData`dearblue
If `Data_Wrap_Struct()` raises a `NoMemoryError` exception, it will leak memory if it does `mrb_malloc()` first.