Comments (7)
It is clear why -single/-double makes a difference in this case,
but...
To be honest, I never really understood the purpose of ma.EPSILON.
And what is it? Say,
doubleprecision EPSILON = 2.2204460492503131e-016;
is it DBL_MIN? Or DBL_TRUE_MIN?
Nevermind. In any case I'd say it should be used with care.
process = (1.0 + ma.EPSILON/2.0) > 1.0 correctly returns 0 when
compiled in -double
OK, lets suppose that "0" is correct in this case. Now consider
import("stdfaust.lib");
process =
(0.0 + ma.EPSILON/2.0) > 0.0,
(0.5 + ma.EPSILON/2.0) > 0.5,
(1.0 + ma.EPSILON/2.0) > 1.0;
compiled in double, it outputs
1, 1, 0
Doesn't look consistent but what can we do? and do we really care?
Oleg.
from faust.
- see: https://en.cppreference.com/w/cpp/types/climits
- as in C:
#include <iostream>
#include <cfloat>
int main() {
bool a = (0.0f + FLT_EPSILON / 2.0f) > 0.f;
bool b = (0.5f + FLT_EPSILON / 2.0f) > 0.5f;
bool c = (1.f + FLT_EPSILON / 2.0f) > 1.f;
std::cout << "a: " << a << std::endl;
std::cout << "b: " << b << std::endl;
std::cout << "c: " << c << std::endl;
bool d = (0.0f + DBL_EPSILON / 2.0f) > 0.f;
bool e = (0.5f + DBL_EPSILON / 2.0f) > 0.5f;
bool f = (1.f + DBL_EPSILON / 2.0f) > 1.f;
std::cout << "d: " << d << std::endl;
std::cout << "e: " << e << std::endl;
std::cout << "f: " << f << std::endl;
return 0;
}
from faust.
from faust.
see: https://en.cppreference.com/w/cpp/types/climits
- as in C:
Ah. Yes, yes, I know. And I too wrote the similar program to verify.
Sorry for confusion. When I said "Doesn't look consistent" I meant "Doesn't look consistent but in fact correct".
My only point was, again, in any case ma.EPSILON should be used with care.
It is not immediately clear that, again,
process = (0.5 + ma.EPSILON/2.0) > 0.5;
and
process = (1.0 + ma.EPSILON/2.0) > 1.0;
do not output the same result.
And I think we do not really care.
But I agree that the fact it depends on -single/-double make the things worse.
from faust.
I think that it is defined as the smallest quantity, let's call it EPS, for
which (1.0 + EPS) > 1.0 returns true.
OK, quite possible, then ma.EPSILON == nextafter(1.0,2.0) - 1.0
And this means that even a more simple example can surprise the user:
import("stdfaust.lib");
process =
(1.0 + ma.EPSILON) > 1.0,
(2.0 + ma.EPSILON) > 2.0;
compiled with -double outputs
output0[i0] = FAUSTFLOAT(1);
output1[i0] = FAUSTFLOAT(0);
Again, this is correct in that this is how the FP math works.
But again, this means that ma.EPSILON should be used with care.
And "the smallest quantity" depends on the usage, while *.lib
blindly use ma.ma.EPSILON assuming it always fits the needs.
from faust.
I guess we want ma.EPSILON
to exactly behave as the FP norm says, in -single
and -double
mode, no more no less (and which is not currently the case).
from faust.
Improved documentation: https://faustlibraries.grame.fr/libs/maths/#maepsilon
from faust.
Related Issues (20)
- Rust's F{32,64}::rem_euclid behaves differently from C/C++ remainder HOT 4
- Rust allocation HOT 2
- Rust backend: mutable reference to mutable static is deprecated HOT 1
- Build error on Fedora 40 HOT 2
- [Android] Custom input/output support HOT 1
- Slow compilation
- faust CLI broken on macOS (Apple Silicon) HOT 3
- int64_t has not been decalred HOT 4
- Cannot use a synth as lv2 instrument HOT 2
- Portable builds HOT 5
- GUI class leaves dangling pointers in fZoneMap when it's moved or copied and destroyed HOT 5
- mesh2faust failing to build on Ubuntu 22.04 (Win 11 WSL) HOT 6
- Interpreter: Bad performance for this instrument HOT 7
- faust2lv2: -gui not working
- Compiler crash when slider name is a keyword. HOT 1
- Mesh2faust error with material density higher than 4019
- (IMPORTANT) need help bypassing an error HOT 2
- Compilation assertion failure using waveform primitive with LLVM HOT 1
- Generated synth LV2 plugin crashes very often on Windows HOT 3
- Rust backend does not support -double. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from faust.