how to write code to do array manipulations

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
RoBu_286116
Level 1
Level 1

We need to generate some complex math curves. Inotherwords. . . in normal ansi c, one can, for example, just say a=1:.1:5   and then say   b=exp(a).   I don't know how to do that in PSOC's code section.   This can't be that difficult.    I can write this in matlab in an instant.

The eventual goal is to generate an error curve, which is a type of sigmoid curve.   This also involves dividing two math functions, in an element by element fashion. This is easily done in normal C code by saying:  result=array1 (with a dot after it), division sign, and then array 2

Anybody out there got any experience doing these sort of things ?    

Thanks. Bob

0 Likes
1 Solution
SuMa_296631
Level 5
Level 5
50 replies posted 25 replies posted 10 replies posted

I must admit that I have never seen the ability to declare a range like, or use arrays/ranges as arguments and return values to 'standard' functions that in 'ansi c' - python (especially numpy) yes; matlab/octave yes. And porting those languages to an embedded system might be possible but is it worth it? (Or am I just showing my ignorance of teh capabilities of whatever PSoC device you are using?)

The same goes for your description of array division.

The 'normal c' way of doing this is using a for loop and iterating over the elements of both arrays.

Can you provide a reference to the ANSI C Standard where this is done?

Also which PSoC device are you targeting? I would think you need to go for one with a floating point processor in built. Even then, transcendental functions can be relatively slow if you are not careful, especially when you are trying to apply them to large(ish) arrays.

Susan

View solution in original post

3 Replies
SuMa_296631
Level 5
Level 5
50 replies posted 25 replies posted 10 replies posted

I must admit that I have never seen the ability to declare a range like, or use arrays/ranges as arguments and return values to 'standard' functions that in 'ansi c' - python (especially numpy) yes; matlab/octave yes. And porting those languages to an embedded system might be possible but is it worth it? (Or am I just showing my ignorance of teh capabilities of whatever PSoC device you are using?)

The same goes for your description of array division.

The 'normal c' way of doing this is using a for loop and iterating over the elements of both arrays.

Can you provide a reference to the ANSI C Standard where this is done?

Also which PSoC device are you targeting? I would think you need to go for one with a floating point processor in built. Even then, transcendental functions can be relatively slow if you are not careful, especially when you are trying to apply them to large(ish) arrays.

Susan

Rakshith
Moderator
Moderator
Moderator
250 likes received 1000 replies posted 750 replies posted

Adding to SuMa_296631​'s response, it would be easier for us to provide a workaround for your request if you share the code. Can you please share the code that you want to implement in PSoC Creator?

Regards,

Rakshith M B

Thanks and Regards,
Rakshith M B
0 Likes

You might be interested to GNU Scientific Library.

https://www.gnu.org/software/gsl/doc/html/

Refer to the Vector and Matrices section.

0 Likes