Advantage of vectorize function

Advantage of vectorize function - Data Analysis Using Truth Tables - 消息

#1 已发布: 2019/7/6 02:51:39
NDTM Amarasekera

NDTM Amarasekera

130个赞,共352个帖子。

组: 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.92 MiB)已下载 1518 次。
Rainfal_Data.xlsx (486.22 KiB)已下载 1135 次。
Look within!... The secret is inside you. Best Regards Eng. NDTM Amarasekera - Sri Lanka
3位用户喜欢此帖子
Radovan Omorjan 2019/7/6 04:23:00, frapuano 2019/7/6 05:13:00, Davide Carpi 2019/7/6 11:20:00
#2 已发布: 2019/9/19 12:23:07
NDTM Amarasekera

NDTM Amarasekera

130个赞,共352个帖子。

组: 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.91 KiB)已下载 1475 次。

DataAnalysis_Results.png

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

Jean Giraud

983个赞,共6,866个帖子。

组: 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.54 KiB)已下载 1469 次。
Utilities Matrix Truth Table [UNSORTED alyles].sm (15.01 KiB)已下载 1321 次。
Utilities Matrix Truth Table [Locate row_col].sm (43.39 KiB)已下载 1350 次。
#4 已发布: 2020/4/13 13:20:47
NDTM Amarasekera

NDTM Amarasekera

130个赞,共352个帖子。

组: 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.1 KiB)已下载 1457 次。
rainfall_KalaOyaBAsin.xlsx (585.15 KiB)已下载 1099 次。
Look within!... The secret is inside you. Best Regards Eng. NDTM Amarasekera - Sri Lanka
#5 已发布: 2020/4/13 13:47:05
Jean Giraud

Jean Giraud

983个赞,共6,866个帖子。

组: User

Wrote

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


Sorry mon Ami ... SS 6179 does not open ... Jean
#6 已发布: 2020/4/13 14:04:20
NDTM Amarasekera

NDTM Amarasekera

130个赞,共352个帖子。

组: User

Sorry. PDF attached.

SPI_cal-Millawana_Multiple_R5.pdf (1.03 MiB)已下载 922 次。
Look within!... The secret is inside you. Best Regards Eng. NDTM Amarasekera - Sri Lanka
2位用户喜欢此帖子
Davide Carpi 2020/4/14 09:24:00, frapuano 2020/4/14 11:57:00
#7 已发布: 2020/4/14 09:04:19
Jean Giraud

Jean Giraud

983个赞,共6,866个帖子。

组: User

Thanks for the *.PDF ... superb quality !
#8 已发布: 2020/11/12 03:56:59
NDTM Amarasekera

NDTM Amarasekera

130个赞,共352个帖子。

组: 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位用户喜欢此帖子
sergio 2020/11/12 05:23:00
#9 已发布: 2020/11/16 14:13:48
NDTM Amarasekera

NDTM Amarasekera

130个赞,共352个帖子。

组: 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.17 KiB)已下载 1456 次。

DATE_Strings.png
Look within!... The secret is inside you. Best Regards Eng. NDTM Amarasekera - Sri Lanka
1位用户喜欢此帖子
sergio 2020/11/17 14:39:00
#10 已发布: 2020/11/16 20:48:19
Jean Giraud

Jean Giraud

983个赞,共6,866个帖子。

组: User

The secret is inside your nice piece of work ... superb, thanks.
Take care my Friend ... Jean
#11 已发布: 2020/11/16 23:58:06
Alvaro

Alvaro

1,139个赞,共1,805个帖子。

组: 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.56 KiB)已下载 1392 次。

Clipboard01.jpg

Best regards.
Alvaro.
2位用户喜欢此帖子
sergio 2020/11/17 14:39:00, NDTM Amarasekera 2020/11/17 22:29:00
#12 已发布: 2020/11/17 01:41:25
NDTM Amarasekera

NDTM Amarasekera

130个赞,共352个帖子。

组: 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 已发布: 2020/11/17 09:44:04
Jean Giraud

Jean Giraud

983个赞,共6,866个帖子。

组: User

You too Alvaro: take care, thanks ... Jean
#14 已发布: 2021/2/2 04:35:43
NDTM Amarasekera

NDTM Amarasekera

130个赞,共352个帖子。

组: 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.62 KiB)已下载 1440 次。
String2Num.png

Look within!... The secret is inside you. Best Regards Eng. NDTM Amarasekera - Sri Lanka
1位用户喜欢此帖子
Alvaro 2021/2/2 15:35:00
#15 已发布: 2021/2/2 11:27:50
Jean Giraud

Jean Giraud

983个赞,共6,866个帖子。

组: User

Wrote

Revised program to handle date strings.


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

#16 已发布: 2021/2/2 15:44:06
Alvaro

Alvaro

1,139个赞,共1,805个帖子。

组: 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.47 KiB)已下载 1426 次。

EvalTest.pdf (73.82 KiB)已下载 783 次。

Best regards.
Alvaro.

1位用户喜欢此帖子
sergio 2021/2/3 06:33:00
#17 已发布: 2021/2/2 18:53:27
Jean Giraud

Jean Giraud

983个赞,共6,866个帖子。

组: 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.84 KiB)已下载 1414 次。
#18 已发布: 2021/2/2 19:26:52
Ruben Sidranski

Ruben Sidranski

17个赞,共465个帖子。

组: 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 已发布: 2021/2/2 19:54:30
Alvaro

Alvaro

1,139个赞,共1,805个帖子。

组: 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 已发布: 2021/2/2 22:13:47
Jean Giraud

Jean Giraud

983个赞,共6,866个帖子。

组: 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
  • 有新帖
  • 无新帖