Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please solve your signed unsigned mismatche warnings #263

Open
elanhickler opened this issue Nov 30, 2018 · 12 comments
Open

Please solve your signed unsigned mismatche warnings #263

elanhickler opened this issue Nov 30, 2018 · 12 comments

Comments

@elanhickler
Copy link
Contributor

elanhickler commented Nov 30, 2018

you have a lot of signed unsigned mismatch warnings

// wrong
for (int i = 0; i < vector.size(); ++i)
// ok
for (int i = 0; i < (int)vector.size(); ++i)
// good
for (unsigned i = 0; i < vector.size(); ++i)
// best
for (const auto & obj : vector)
@RobinSchmidt
Copy link
Owner

RobinSchmidt commented Dec 1, 2018

i actually tend to use this idiom:
for(size_t i = 0; i < v.size(); i++)
how many of these warnings do you get and where? because i get none of them when building ToolChain (in debug mode, medium warning level - edit: Level3, to be exact).

i'm actually a bit unhappy with my decision long ago to write all my low-level array functions using int instead of unsigned int (which is the same as size_t, i think) and was already thinking about changing that. ...but that would have ripples throughout the whole library - for example, for finding an element, i use the convention of returning -1 when the element was not found - switching to unsigned would map that the max-value (i think), but std::vector functions use the convention of returning size() - so one would have to be careful to look at all the code that uses such a "find" function and compares the return value against -1 (and that's just one example). ...although, i guess, it may just work

@elanhickler
Copy link
Contributor Author

To get warnings you need to re-compile the code, so you need to change something deep in your library, maybe add a comment or add a character somewhere and then save and then remove then save, it will recompile.

@RobinSchmidt
Copy link
Owner

RobinSchmidt commented Dec 1, 2018

actually, i did a clean rebuild. do you really get them with toolchain or in another project? and/or maybe you are using VS 2017 (while i still use 2015) and 2017 is more strict?

@elanhickler
Copy link
Contributor Author

elanhickler commented Dec 1, 2018

or simply try deleting all the build files.

@elanhickler
Copy link
Contributor Author

Before we can continue with this, I need you to upgrade your library's JUCE to latest. Are you working on it? Also, get on FFT stuff. What are you working on these days?

Have you gotten "any number inputs and outputs" on Liberty yet? I'll have to try Liberty again and give you and update on what is stopping me from using it for prototyping plugins. Mostly it will be convenience issues and maybe a few bugs.

@RobinSchmidt
Copy link
Owner

RobinSchmidt commented Dec 2, 2018

ok - i'll do the update next week and also the fft stuff. i've been learning sage recently. it's really amazing. a big new gun to shoot at math problems. i also had to care a bit for my dad who had some emergency health issue and is now in a nursing home. the any-number of I/O thing - i think - would make sense only if ToolChain itself could have a dynamic number of outputs. i have to check the juce doc, if that's possible and if so, how. i have now implemented multiple inputs for my formula module (it passes some unit tests - but still needs real-world testing). the next step will be multiple outputs - then we have a very flexible module. i also have an idea how to include memory variables - if that works out the way i hope, we can even build filters with the formula module

@elanhickler
Copy link
Contributor Author

elanhickler commented Dec 2, 2018

Sorry to hear about your dad.

What kind of problems will your new math theories help with?

@RobinSchmidt
Copy link
Owner

RobinSchmidt commented Dec 2, 2018

for example, i could solve the energy normalization for a multipass butterworth filter (for scaling the cutoff frequency as function of the butterworth order and number of passes to normalize the energy of the impulse response):
http://www.rs-met.com/documents/dsp/ButterworthEnergy.html
i have no idea how i would otherwise have evaluated the integral - perhaps i would have tried my hand on applying the residue theorem or something - but don't have to because sage could just do it for me. and it will make it easier and less error prone to solve all sorts of equation systems that pop up in interpolation and filter design problems

@RobinSchmidt
Copy link
Owner

RobinSchmidt commented Dec 2, 2018

finally i have found some use for the gamma function. haha!

template<class T>
T rsPrototypeDesigner<T>::butterworthEnergy(int N, int M)
{
  T k = T(0.5)/N;
  return T(PI*tgamma(M-k) / (N*tgamma(M)*tgamma(1-k)*sin(k*PI)));

  // The formula was found with SageMath, using this input:
  // var("N M")
  // assume(N >= 1)
  // assume(M >= 1)
  // assume(N, 'integer')
  // assume(M, 'integer')
  // assume(2*M*N-1 > 0)   # follows from N >= 1, M >= 1 but sage needs it
  // f(x) = 1 / (1 + x^(2*N))^M
  // integral(f(x), x, -oo, oo)
}

@elanhickler
Copy link
Contributor Author

you lost me at "energy normalization"

@elanhickler
Copy link
Contributor Author

this thread is to be continued once you update your JUCE to latest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants