using "If statement" for the list
Hello,
I am wondering how to use "if statement" for editing "list". I attached the file for your understanding. What I am trying to do is "if the value is less than 0.5, apply the scale object1, if the value is greater than 0.5, apply the scale object2". In the file, I did this for a single number but I am struggling with "list".
Q1. For this example, I used "a message box" with 5 numbers. However, for the real application, I am going to use 512 values. I would really appreciate if you could kindly let me know how to handle this.
Q2. After this, I am also considering to use "if statement" for "jit.expr". It would be great, if you could also show me another example of using "jit.expr" to scale these values inside the "jit.matrix". Thank you so much and happy New Year.
this approach is a start: split the matrix into 2 separate ones using the >=p and <p operators and then scale them manually with jit.expr; however you'd need to somehow deal with the zero values that replace the previous values when passed through the jit.ops
but i'm pretty sure there's a better way to do this with a single jit.expr object
Since you're evaluating each list element individually, I think it would be easier and give you more versatility to do whatever you need if you process them individually as well.
1. Break down the list
2. Process numbers freely
3. Build the list again (do you really need the processed values back as a list?)
remember if using pedro's approach to use the @zlmaxsize attribute for lists longer than 256 items
@FLOATING POINT and @PEDRO SANTOS thank you all. I think both really help to me in a different way. I will take a closer look at these codes and I will reply to this if I have additional question. Happy New Year!!
@PEDRO yes it would be great if I could have the same order after the numbers are combined.
Hello,
I have one more question in connection with mapping. I am stuck with applying exponential values in the scale object with the list.
For example, I would like to
1. map the values "0.0 - 0.5" to "0.0 - 0.7" with the exponential base value "0.25".
2. map the values "0.5-1.0" to "0.7 - 1.0" with the exponential base value "2.0".
Thank you so much.
in the reference for scale object it says:
the value for the scaling curve must be higher than 0. and is converted according to the following expression:
((x-in_low)/(in_high-in_low) == 0) ? out_low : (((x-in_low)/(in_high-in_low)) > 0) ? (out_low + (out_high-out_low) * ((x-in_low)/(in_high-in_low))^exp) : ( out_low + (out_high-out_low) * -((((-x+in_low)/(in_high-in_low)))^(exp)))
so you should be able to adapt an expr box to this (you wouldn't need the whole expression, as your scaling parameters and input values are limited to specific ranges)
Sorry for asking again. I am afraid that I am not 100% getting this formula.
As far as I understand, it seems like...
in_low -> lowest input.
in_high->highest input.
out_low-> lowest output value.
out_high->highest output value.
For x, do I need to put "the exponential curve value" here, for example 0.25 or 2.0"? Please correct me if I am wrong. I really appreciate your help @FLOATING POINT.
in_low -> lowest input. in_high->highest input. out_low-> lowest output value. out_high->highest output value.
yes that's how I understand it
For x, do I need to put "the exponential curve value" here, for example 0.25 or 2.0"?
no, I believe x is the input value (ie your value between zero and 0.5, and 0.5 to 1) that you want mapped.
the exp is the exponential value that would be either 0.25 or 2 in your application
so, for example
this:( out_low + (out_high-out_low) * -((((-x+in_low)/(in_high-in_low)))^(exp)))
would become something like:
0.7 + ((1-0.7) * -1.0)*(pow((( -$f1+0.5)/(1-0.5)))), 2))
(my parentheses might be unbalanced btw, but you should get the idea)
(also this fragment may not actually be applicable to your situation-- you have to evaluate the conditionals first, ie the "?" and ":" parts of the statement)
I would suggest using [jit.gen] and inside use the [scale] object. Then don't "split" the matrix, but scale for both and afterwards combine both scaled matrices based on if the original values were < or > then 0.5. Here is an example:
@TIMO this really helps. Thank you so much.