Advantage of vectorize function

Advantage of vectorize function - Data Analysis Using Truth Tables - Messages

#1 Posted: 7/6/2019 2:51:39 AM
NDTM Amarasekera

NDTM Amarasekera

130 likes in 352 posts.

Group: User

On the request of a fellow Engineer, the attached SM program was developed
to find the Standardized Precipitation Index (SPI).
58 years of daily precipitation data was available.

The SPI is widely used to analyze meteorological drought on a range of
time scales. There are proprietary software packages for this purpose.

The “vectorize” function was pretty handy and fast in analyzing various conditions.

Vectorize function.png

SPI_cal-Rev & Improved-Final.sm (1 MiB) downloaded 162 time(s).
Rainfal_Data.xlsx (486 KiB) downloaded 117 time(s).
Look within!... The secret is inside you. Best Regards Eng. NDTM Amarasekera - Sri Lanka
3 users liked this post
Radovan Omorjan 7/6/2019 4:23:00 AM, frapuano 7/6/2019 5:13:00 AM, Davide Carpi 7/6/2019 11:20:00 AM
#2 Posted: 9/19/2019 12:23:07 PM
NDTM Amarasekera

NDTM Amarasekera

130 likes in 352 posts.

Group: User

Attached file may be useful in handling data, where it may be
necessary to extract numerical values removing any strings, or
negative values, zeros etc.

Data Analysis Using Truth Table.sm (78 KiB) downloaded 92 time(s).

DataAnalysis_Results.png

DataAnalysis_Cond.png
Look within!... The secret is inside you. Best Regards Eng. NDTM Amarasekera - Sri Lanka
#3 Posted: 9/19/2019 12:44:46 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

Attached file may be useful in handling data, where it may be
necessary to extract numerical values removing any strings, or
negative values, zeros etc.


Maybe more or otherwise in there.

Utilities Matrix Truth Table.sm (59 KiB) downloaded 99 time(s).
Utilities Matrix Truth Table [UNSORTED alyles].sm (15 KiB) downloaded 90 time(s).
Utilities Matrix Truth Table [Locate row_col].sm (43 KiB) downloaded 95 time(s).
#4 Posted: 4/13/2020 1:20:47 PM
NDTM Amarasekera

NDTM Amarasekera

130 likes in 352 posts.

Group: User

Advantage of vectorize function revisited.
Another practical example attached, with extensive use of the vectorize function. No loops used.
Comments by Martin, Jean, Razonar and others on this subject much appreciated.
Hope this may be useful for beginners.
Cheers

Vect_Augment.PNG
SPI_cal-Millawana_Multiple_R5.sm (178 KiB) downloaded 91 time(s).
rainfall_KalaOyaBAsin.xlsx (585 KiB) downloaded 66 time(s).
Look within!... The secret is inside you. Best Regards Eng. NDTM Amarasekera - Sri Lanka
#5 Posted: 4/13/2020 1:47:05 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

Comments by Martin, Jean, Razonar and others on this subject much appreciated.


Sorry mon Ami ... SS 6179 does not open ... Jean
#6 Posted: 4/13/2020 2:04:20 PM
NDTM Amarasekera

NDTM Amarasekera

130 likes in 352 posts.

Group: User

Sorry. PDF attached.

SPI_cal-Millawana_Multiple_R5.pdf (1 MiB) downloaded 109 time(s).
Look within!... The secret is inside you. Best Regards Eng. NDTM Amarasekera - Sri Lanka
2 users liked this post
Davide Carpi 4/14/2020 9:24:00 AM, frapuano 4/14/2020 11:57:00 AM
#7 Posted: 4/14/2020 9:04:19 AM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Thanks for the *.PDF ... superb quality !
#8 Posted: 11/12/2020 3:56:59 AM
NDTM Amarasekera

NDTM Amarasekera

130 likes in 352 posts.

Group: User

I have found this useful in day to day work.
Data imported from MS Excel sheet, and using "findrows" function to sum daily data to monthly totals.

Vect_Grouping.png
Look within!... The secret is inside you. Best Regards Eng. NDTM Amarasekera - Sri Lanka
1 users liked this post
sergio 11/12/2020 5:23:00 AM
#9 Posted: 11/16/2020 2:13:48 PM
NDTM Amarasekera

NDTM Amarasekera

130 likes in 352 posts.

Group: User

Attached is a simplified version of a project work for demonstration only.
The data file consists of date strings, and hence, had to be transformed into numeric.
Hope this may be useful for beginners. Vectorize function very useful in this exercise.

Handling DATE STRINGS.sm (16 KiB) downloaded 73 time(s).

DATE_Strings.png
Look within!... The secret is inside you. Best Regards Eng. NDTM Amarasekera - Sri Lanka
1 users liked this post
sergio 11/17/2020 2:39:00 PM
#10 Posted: 11/16/2020 8:48:19 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

The secret is inside your nice piece of work ... superb, thanks.
Take care my Friend ... Jean
#11 Posted: 11/16/2020 11:58:06 PM
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 likes in 1675 posts.

Group: User

Wrote

Attached is a simplified version of a project work for demonstration only.
The data file consists of date strings, and hence, had to be transformed into numeric.
Hope this may be useful for beginners. Vectorize function very useful in this exercise.



Hi. Handling data strings you have also this cheat for convert dates to numeric matrices.

Handling DATE STRINGS.sm (20 KiB) downloaded 72 time(s).

Clipboard01.jpg

Best regards.
Alvaro.
2 users liked this post
sergio 11/17/2020 2:39:00 PM, NDTM Amarasekera 11/17/2020 10:29:00 PM
#12 Posted: 11/17/2020 1:41:25 AM
NDTM Amarasekera

NDTM Amarasekera

130 likes in 352 posts.

Group: User

Thank you Jean for your kind words and encouragements. Take care.

Thank you Razonar for the superb alternative. Take care.
Look within!... The secret is inside you. Best Regards Eng. NDTM Amarasekera - Sri Lanka
#13 Posted: 11/17/2020 9:44:04 AM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

You too Alvaro: take care, thanks ... Jean
#14 Posted: 2/2/2021 4:35:43 AM
NDTM Amarasekera

NDTM Amarasekera

130 likes in 352 posts.

Group: User

Wrote

Attached is a simplified version of a project work for demonstration only.
The data file consists of date strings, and hence, had to be transformed into numeric.
Hope this may be useful for beginners. Vectorize function very useful in this exercise.

Revised program to handle date strings.

Handling DATE STRINGS+Alvaro.sm (43 KiB) downloaded 61 time(s).
String2Num.png

Look within!... The secret is inside you. Best Regards Eng. NDTM Amarasekera - Sri Lanka
1 users liked this post
Alvaro Diaz Falconi 2/2/2021 3:35:00 PM
#15 Posted: 2/2/2021 11:27:50 AM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

Revised program to handle date strings.


Thanks Collab for that most useful work.
Saved ... for future use.
Cheers ... Jean

#16 Posted: 2/2/2021 3:44:06 PM
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 likes in 1675 posts.

Group: User

Wrote

Attached is a simplified version of a project work for demonstration only.



Hi Amarasekera. Yes, that one, thanks. The fact you're showing despite to me about the speed in procedures with arrays. In the attached some comments about the need to redefining M:=M where M is a matrix argument in a procedure.

Clipboard01.jpg

EvalTest.sm (17 KiB) downloaded 67 time(s).

EvalTest.pdf (73 KiB) downloaded 53 time(s).

Best regards.
Alvaro.

1 users liked this post
sergio 2/3/2021 6:33:00 AM
#17 Posted: 2/2/2021 6:53:27 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Your last Speedy Gonzalez is the Smath Numerical Fairy.
As it looks, pure numerical code coincidence as a fact.
Slightly adapted for convenience SS 6179
Thanks, cheers ... Jean

Maths eval(,) TEST.sm (16 KiB) downloaded 65 time(s).
#18 Posted: 2/2/2021 7:26:52 PM
Ruben Sidranski

Ruben Sidranski

17 likes in 463 posts.

Group: User

Wrote

Hi Amarasekera. Yes, that one, thanks. The fact you're showing despite to me about the speed in procedures with arrays. In the attached some comments about the need to redefining M:=M where M is a matrix argument in a procedure.
Best regards.
Alvaro.


Alvaro,
Are you showing that by redefining Mo variable, within the program, it speeds it up 30 fold? That makes no sense
The only thing that remotely comes to mind is that M, being defined within the program structure as M:=Mo, is not having to read for the variable from the outside.
Have you, or anyone else, tried this on other programs?
#19 Posted: 2/2/2021 7:54:30 PM
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 likes in 1675 posts.

Group: User

Wrote


Alvaro,
Are you showing that by redefining Mo variable, within the program, it speeds it up 30 fold? That makes no sense



Yes. Please, try to check in your environment if this is true also. (Notice that my laptop is very slow, because always is running something else or overloaded by some other procedures)

Wrote


Have you, or anyone else, tried this on other programs?



Yes. For this was the issue in the original Amarasekera work, and why I say that he was the first showing this behavior. But I have other codes where using M:=M speed up slow procedures. Actually anything with a loop over a matrix.

Here intermediate timing result, which I can't explain

Clipboard01.jpg

Best regards.
#20 Posted: 2/2/2021 10:13:47 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

The only thing that remotely comes to mind is that M, being defined within the program structure as M:=Mo, is not having to read for the variable from the outside.
Have you, or anyone else, tried this on other programs?


What's wrong or incorrect in there is length it shouldn't exist in Smath

EvenFaster.PNG
  • New Posts New Posts
  • No New Posts No New Posts