Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline wb.c  
#1 Posted : 21 April 2022 20:07:51(UTC)
wb.c


Rank: Advanced Member

Groups: Registered
Joined: 02/04/2018(UTC)
Posts: 135
United States

Was thanked: 22 time(s) in 19 post(s)
Version: 0.99 (Build: 7921)

The rounding function concept for a vector seems to work fine, but I am having trouble with a function that works on a vector containing multiple vectors.
Any ideas on how to make this work?

2022-04-21 13_02_27-SMath Solver - [Rounding Values in Vectors Function Concepts.sm_].png
2022-04-21 13_03_06-SMath Solver - [Rounding Values in Vectors Function Concepts.sm_].png

Rounding Values in Vectors Function Concepts.sm (18kb) downloaded 12 time(s).

Edited by user 26 April 2022 00:31:32(UTC)  | Reason: Not specified

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline overlord  
#2 Posted : 21 April 2022 20:35:30(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,129
Turkey

Was thanked: 510 time(s) in 340 post(s)
Originally Posted by: wb.c Go to Quoted Post
The rounding function concept for a vector seems to work fine, but I am having trouble with a function that works on a vector containing multiple vectors.
Any ideas on how to make this work?

You can use recursive for that.
You have to also check if rounded row is a vector.
It can work with both vector and nested vector.
Here is your code revised.

Regards

PS: MarB's solution with Razonar's addition is better actually.
I would use that instead of mine, more elegant.
My version is just a brute algorithm.

Rounding Values in Vectors Function Concepts.sm (24kb) downloaded 2 time(s).

rounding_matrices.sm (11kb) downloaded 21 time(s).

Click to enlarge

Edited by user 22 April 2022 23:37:49(UTC)  | Reason: Not specified

Offline ndtma  
#3 Posted : 21 April 2022 20:40:42(UTC)
ndtma


Rank: Advanced Member

Groups: Registered
Joined: 05/06/2014(UTC)
Posts: 348
Man
Sri Lanka
Location: Colombo

Was thanked: 127 time(s) in 82 post(s)
Another approach

round_matrix.jpg
Look within!... The secret is inside you.
Best Regards
Eng. NDTM Amarasekera - Sri Lanka
Offline ndtma  
#4 Posted : 21 April 2022 20:58:17(UTC)
ndtma


Rank: Advanced Member

Groups: Registered
Joined: 05/06/2014(UTC)
Posts: 348
Man
Sri Lanka
Location: Colombo

Was thanked: 127 time(s) in 82 post(s)
Above method will not work if the nested arrays are of different sizes.
Following method will work for any nested array.

Round_diff_Arr_sizes.jpg
Look within!... The secret is inside you.
Best Regards
Eng. NDTM Amarasekera - Sri Lanka
thanks 1 user thanked ndtma for this useful post.
on 21/04/2022(UTC)
Offline Ber7  
#5 Posted : 21 April 2022 21:10:48(UTC)
Ber7


Rank: Advanced Member

Groups: Registered
Joined: 15/07/2010(UTC)
Posts: 437
Man
Israel
Location: Beer-Sheva

Was thanked: 520 time(s) in 288 post(s)
Almost the same
Variant.png
Variant.sm (9kb) downloaded 7 time(s).
thanks 2 users thanked Ber7 for this useful post.
on 21/04/2022(UTC),  on 21/04/2022(UTC)
Offline overlord  
#6 Posted : 21 April 2022 21:13:35(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,129
Turkey

Was thanked: 510 time(s) in 340 post(s)
Code revised to solve not just vectors but matrices too.
Now very complicated matrices can be rounded.

Regards

PS: MarB's solution with Razonar's addition is better actually.
I would use that instead of mine, more elegant.
My version is just a brute algorithm.

rounding_matrices.sm (11kb) downloaded 21 time(s).

Click to enlarge

Edited by user 22 April 2022 23:38:21(UTC)  | Reason: Not specified

thanks 4 users thanked overlord for this useful post.
on 21/04/2022(UTC),  on 21/04/2022(UTC),  on 21/04/2022(UTC),  on 22/04/2022(UTC)
Offline wb.c  
#7 Posted : 21 April 2022 21:16:07(UTC)
wb.c


Rank: Advanced Member

Groups: Registered
Joined: 02/04/2018(UTC)
Posts: 135
United States

Was thanked: 22 time(s) in 19 post(s)
Great ideas everyone, thanks for the input and improvements.
Offline Ber7  
#8 Posted : 21 April 2022 23:42:27(UTC)
Ber7


Rank: Advanced Member

Groups: Registered
Joined: 15/07/2010(UTC)
Posts: 437
Man
Israel
Location: Beer-Sheva

Was thanked: 520 time(s) in 288 post(s)
Short code option
Variant1.png
Variant1.sm (6kb) downloaded 4 time(s).

Edited by user 22 April 2022 01:17:06(UTC)  | Reason: Not specified

Offline Jean Giraud  
#9 Posted : 22 April 2022 01:38:00(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Good idea to always start code native Smath ... given user extended.

Round matrix.PNG
Offline overlord  
#10 Posted : 22 April 2022 01:44:19(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,129
Turkey

Was thanked: 510 time(s) in 340 post(s)
You can also shorten function like this.

2022-04-22_01-43.png
Offline MarB  
#11 Posted : 22 April 2022 13:39:35(UTC)
MarB


Rank: Advanced Member

Groups: Registered
Joined: 21/10/2016(UTC)
Posts: 84

Was thanked: 21 time(s) in 17 post(s)
A very short way is to use recursion:

roundM.sm (10kb) downloaded 7 time(s).

roundM.png

Edited by user 22 April 2022 13:56:32(UTC)  | Reason: Not specified

thanks 4 users thanked MarB for this useful post.
on 22/04/2022(UTC),  on 22/04/2022(UTC),  on 22/04/2022(UTC),  on 22/04/2022(UTC)
Offline Jean Giraud  
#12 Posted : 22 April 2022 15:33:12(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Up to this point, proposals round nested vectors.
Dealing with big numbers is also available.
123456789123456789 ... 987654321987654321
123000000000000000 typical
Offline overlord  
#13 Posted : 22 April 2022 15:44:08(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,129
Turkey

Was thanked: 510 time(s) in 340 post(s)
Originally Posted by: MarB Go to Quoted Post
A very short way is to use recursion.

This is just magnificent. Two heads are better than one.
I couldn't hit off how to do it with vectorize.

Kudos
Offline Ber7  
#14 Posted : 22 April 2022 16:07:55(UTC)
Ber7


Rank: Advanced Member

Groups: Registered
Joined: 15/07/2010(UTC)
Posts: 437
Man
Israel
Location: Beer-Sheva

Was thanked: 520 time(s) in 288 post(s)
Originally Posted by: MarB Go to Quoted Post
A very short way is to use recursion:

Wonderful!
Offline Razonar  
#15 Posted : 22 April 2022 17:29:14(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,368
Uruguay

Was thanked: 829 time(s) in 525 post(s)
Originally Posted by: MarB Go to Quoted Post
A very short way is to use recursion ...


Brillant solution. Adding eval to the SMath's round enables symbolic evaluations too.

Clipboard01.jpg

Best regards.
Alvaro.

Offline mkraska  
#16 Posted : 22 April 2022 23:35:17(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,990
Germany

Was thanked: 1128 time(s) in 724 post(s)
Minimalistic solution for Maximalists.

rounding_matrices_Maxima.png
rounding_matrices_Maxima.sm (5kb) downloaded 7 time(s).
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
thanks 2 users thanked mkraska for this useful post.
on 23/04/2022(UTC),  on 23/04/2022(UTC)
Offline Jean Giraud  
#17 Posted : 23 April 2022 01:36:17(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
... twin vectors from function
Advanced Engineering applications.

Round Vectors.PNG
Offline overlord  
#18 Posted : 23 April 2022 02:56:06(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,129
Turkey

Was thanked: 510 time(s) in 340 post(s)
Originally Posted by: mkraska Go to Quoted Post
Minimalistic solution for Maximalists.

Sometimes I really wish I could use Maxima plugin under linux.
Offline mkraska  
#19 Posted : 23 April 2022 12:31:05(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,990
Germany

Was thanked: 1128 time(s) in 724 post(s)
Originally Posted by: overlord Go to Quoted Post
Originally Posted by: mkraska Go to Quoted Post
Minimalistic solution for Maximalists.

Sometimes I really wish I could use Maxima plugin under linux.


It is on my todo list and I think it is possible, but currently priority is on another project which also involves using Maxima and is entirely open source:

https://github.com/mkraska/meclib
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.