Line intersections

Line intersections - An example of translation of a function from Matlab to Smath - Сообщения

#21 Опубликовано: 16.02.2018 09:01:36
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1675 понравились пользователям.

Группа: User

Wrote

Just an exercise on Smath to test functionalities and capabilities.
Try the attached file and play with it.

Thanks
Marco
InterX.sm (85 КиБ) скачан 168 раз(а).



Hi Marco. Here some comments about your great file. As you suggest, I play with it.
Best regards.
Alvaro.

InterX.r1.sm (77 КиБ) скачан 83 раз(а).

1 пользователям понравился этот пост
Andrey Ivashov 16.02.2018 12:30:00
#22 Опубликовано: 16.02.2018 11:55:14
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

Try the attached file and play with it.



1. Marco => still computing after 15 min ? !
2. Alvaro => red from top to bottom
#23 Опубликовано: 16.02.2018 12:24:05
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

Try the attached file and play with it.


Attached is about timing in work sheet.
Observe the sequential timing [black].
t0:=time(1) is in collapsed area.

Contour_8 Hypersurface.sm (1 МиБ) скачан 59 раз(а).

#24 Опубликовано: 16.02.2018 12:31:14
Andrey Ivashov

Andrey Ivashov

2271 сообщений из 3734 понравились пользователям.

Группа: Super Administrator

Wrote

Hi Marco. Here some comments about your great file. As you suggest, I play with it.
Best regards.
Alvaro.


1 min 53 sec on my windows tablet pc.
#25 Опубликовано: 16.02.2018 13:09:46
Fridel Selitsky

Fridel Selitsky

520 сообщений из 451 понравились пользователям.

Группа: User

Wrote



1 min 53 sec on my windows tablet pc.


SMath Studio 0.99.6611 time(0)-to =83.735 s on my windows10


#26 Опубликовано: 16.02.2018 13:31:34
NDTM Amarasekera

NDTM Amarasekera

130 сообщений из 352 понравились пользователям.

Группа: User

Wrote

Originally Posted by: Andrey Ivashov [url=/forum/yaf_postsm47126_Line-intersections.aspx#post47126][/url]

1 min 53 sec on my windows tablet pc.
SMath Studio 0.99.6611time(0)-to =83.735 son my windows10



Time taken in my win 10 laptop with SS 0.99.6619 shown.

InterXr1.JPG
Look within!... The secret is inside you. Best Regards Eng. NDTM Amarasekera - Sri Lanka
#27 Опубликовано: 16.02.2018 13:54:42
Davide Carpi

Davide Carpi

1417 сообщений из 2873 понравились пользователям.

Группа: Moderator

5 min 25 s (win 10 x64, intel i5 quad core 2.40GHz)
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#28 Опубликовано: 16.02.2018 15:07:54
Davide Carpi

Davide Carpi

1417 сообщений из 2873 понравились пользователям.

Группа: Moderator

Wrote

5 min 25 s (win 10 x64, intel i5 quad core 2.40GHz)



reduced to 30-35 seconds using ranged indices to replace stack/augment/submatrix (most heavy operations were in stack/augment under loops)

InterX.r1 - ranged indices.sm (87 КиБ) скачан 76 раз(а).
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
1 пользователям понравился этот пост
Andrey Ivashov 16.02.2018 15:13:00
#29 Опубликовано: 16.02.2018 15:11:46
Andrey Ivashov

Andrey Ivashov

2271 сообщений из 3734 понравились пользователям.

Группа: Super Administrator

18 seconds on my env.

Great! Thank you Davide!
#30 Опубликовано: 16.02.2018 15:49:26
Andrey Ivashov

Andrey Ivashov

2271 сообщений из 3734 понравились пользователям.

Группа: Super Administrator

BTW, I would suggest to use another version of plotG which is much faster then previous one (and simplier):
plotG.PNG

plotG(x,y,char,size,color):line(k:range(1,rows(x)),augment(x,y,el(r3,k):char,el(r4,k):size,el(r5,k):color),2,1)
plotG(xy,char,size,color):line(k:range(1,rows(xy)),augment(xy,el(r3,k):char,el(r4,k):size,el(r5,k):color),2,1)

Best regards.
1 пользователям понравился этот пост
Davide Carpi 16.02.2018 20:54:00
#31 Опубликовано: 16.02.2018 16:18:55
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1675 понравились пользователям.

Группа: User

Hi. Just one more thing, I guess: the only one remaining matlab function, mwfind replaced. (Orignal work have many) If I'm not wrong, it is now 100% SMath native. But double the amazing time obtained by Davide. But it's just a "scalar" implementation, sure there are better ones.

Best regards.

Alvaro.

PD: I don't replace plotG because don't understand very well that syntax.

InterX.r1 - ranged indices.sm (90 КиБ) скачан 60 раз(а).
#32 Опубликовано: 16.02.2018 16:45:48
Andrey Ivashov

Andrey Ivashov

2271 сообщений из 3734 понравились пользователям.

Группа: Super Administrator

Wrote

I don't replace plotG because don't understand very well that syntax.


It is simple - ranged indexes used.

Just take a look at the speed:
plotG_2.PNG

Best regards.
#33 Опубликовано: 16.02.2018 16:59:17
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1675 понравились пользователям.

Группа: User

Wrote

Wrote

I don't replace plotG because don't understand very well that syntax.


It is simple - ranged indexes used.



Thanks for the explanation, now I see the speed increment, and I don't think that it could be that big difference before you show it.

But actually the plotG(4) routine was which confuse me. I prefer

plotG(xy,char,size,color):if(cols(xy)>1,plotG(col(xy,1),col(xy,2),char,size,color),plotG(Re(xy),Im(xy),char,size,color))

because I think that any good plot implementation must to use complexes but not couple of reals. So, if xy argument have only one column, one can assume that data are as Z = X + iY.

Best regards.

Alvaro.
#34 Опубликовано: 16.02.2018 17:08:15
Davide Carpi

Davide Carpi

1417 сообщений из 2873 понравились пользователям.

Группа: Moderator

Цитата

because I think that any good plot implementation must to use complexes but not couple of reals. So, if xy argument have only one column, one can assume that data are as Z = X + iY.



Andrey misses this detail of your function about the complex values, but you can still do it; keep the if statement and replace the loops (the case with more than a column as shown by Andrey doesn't require the col() functions, this is redundant and time consuming... If you think that more than 2 columns might be provided, add the case and a single sumbatrix instead )
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
1 пользователям понравился этот пост
Alvaro Diaz Falconi 16.02.2018 17:45:00
#35 Опубликовано: 16.02.2018 18:24:21
Arie

Arie

93 сообщений из 285 понравились пользователям.

Группа: User

Wrote

But double the amazing time obtained by Davide. But it's just a "scalar" implementation, sure there are better ones.



Here's my pure SMATH find function. with similar time to MWFIND.

InterX.r1 - ranged indices_alyles.sm (94 КиБ) скачан 79 раз(а).
Feel free to join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
4 пользователям понравился этот пост
Andrey Ivashov 16.02.2018 18:41:00, sergio 17.02.2018 06:31:00, Davide Carpi 16.02.2018 20:57:00, Alvaro Diaz Falconi 16.02.2018 22:03:00
#36 Опубликовано: 17.02.2018 09:35:24
Martin Kraska

Martin Kraska

1222 сообщений из 2150 понравились пользователям.

Группа: Moderator

Wrote

BTW, I would suggest to use another version of plotG which is much faster then previous one (and simplier):
plotG.PNG

plotG(x,y,char,size,color):line(k:range(1,rows(x)),augment(x,y,el(r3,k):char,el(r4,k):size,el(r5,k):color),2,1)
plotG(xy,char,size,color):line(k:range(1,rows(xy)),augment(xy,el(r3,k):char,el(r4,k):size,el(r5,k):color),2,1)

Best regards.



For such uses it would be good if the augment and stack functions could expand scalar arguments (or more generally any arguments not matching the maximum number of rows or cols) to uniformly populated vectors of the required size).

Then the above example wouldn't even need a helper function as you could write
augment(x,y,"*",10,"red"

Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
2 пользователям понравился этот пост
Davide Carpi 17.02.2018 15:23:00, Radovan Omorjan 17.02.2018 12:43:00
#37 Опубликовано: 17.02.2018 09:39:40
Andrey Ivashov

Andrey Ivashov

2271 сообщений из 3734 понравились пользователям.

Группа: Super Administrator

Very good suggestion, Martin! I think I could do this.

Best regards.
4 пользователям понравился этот пост
Davide Carpi 17.02.2018 15:23:00, frapuano 17.02.2018 10:20:00, Radovan Omorjan 17.02.2018 12:43:00, Martin Kraska 17.02.2018 09:41:00
#38 Опубликовано: 17.02.2018 13:20:11
Radovan Omorjan

Radovan Omorjan

325 сообщений из 2052 понравились пользователям.

Группа: Moderator

Wrote

For such uses it would be good if the augment and stack functions could expand scalar arguments (or more generally any arguments not matching the maximum number of rows or cols) to uniformly populated vectors of the required size).

Then the above example wouldn't even need a helper function as you could write

augment(x,y,"*",10,"red"


I also vote for that augment() and stack () functionality.

In that case, we could even have "plot" functions (with the same functionality as augment())

plot(x,y)
plot(x,y,"*"
plot(x,y,"*",10)
plot(x,y,"*",10,"red"
This efforts are, of course, not justified if the micro Mathematics plot style would be introduced.

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
1 пользователям понравился этот пост
frapuano 19.02.2018 07:14:00
#39 Опубликовано: 18.02.2018 22:58:48
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Hello Marco,

I'm trying for the intersection of the two Trifolium, .
blue => native ... red => rotated.
They are created in "Page1 Trifolium.sm
Then recalled for the InterX(T1,T2)
Nothing happens >>> 1 hr ? [Win 7 Starter Edition ... 1.66 GHz]
Is it supposed to work ? Thanks in advance.

Page1 Trifolium.sm (32 КиБ) скачан 49 раз(а).

Maths InterseX [Marco].sm (51 КиБ) скачан 51 раз(а).
#40 Опубликовано: 19.02.2018 00:26:16
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1675 понравились пользователям.

Группа: User

Hi Jean.

You are using an old version of the program. Try this one.

Notice that the point (0,0) is found several times by the algorithm. It could be interesting to check if it get the correct number of crosses at the origin.

Best regards.

Alvaro.

cross.jpg

InterX.r1 - ranged indices_alyles.sm (88 КиБ) скачан 68 раз(а).
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений