SMath Studio Forum
»
SMath Studio
»
Questions
»
Most efficient way to build SMath matrix in VB.NET (plugin development)
Rank: Advanced Member Groups: Registered
Joined: 03/03/2014(UTC) Posts: 418 Was thanked: 125 time(s) in 96 post(s)
|
Hi all, I have discovered recently that excel_IO plugin is way too slow in outputting LARGE excel ranges to SMath (30000+ elements). The slowness narrows down to this part of the code: Code:
Dim myResult As List(Of Term) = New List(Of Term)
For Each matValue As String In result_temp3
myResult.AddRange(SMath.Manager.Converter.ToTerms(matValue))
Next
If counter > 2 Then
myResult.AddRange(SMath.Manager.Converter.ToTerms(range_rows.ToString))
myResult.AddRange(SMath.Manager.Converter.ToTerms(range_cols.ToString))
myResult.Add(New Term(Functions.Mat, TermType.Function, (2 + (range_cols * range_rows))))
End If
I am certain about the source of slowness because initially my code had two For Loops: one to format strings to satisfy SMath requirements and another one listed above. Later I have condensed those two For Loops into one. Performance DID NOT improve. Is there any other way to pass a matrix to SMAth? Any input is appreciated. Thanks!
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 12/03/2011(UTC) Posts: 101 Location: Chicago
Was thanked: 16 time(s) in 7 post(s)
|
Alex-
What is the last line doing for you?
Are you trying to size/format the matrix and then populate it element by element?
The code is hard for me, so maybe I don't recognize your approach.
Could you simply read the data line by line and append the set with each one and then at the end with range_rows, range_columns) for the same effect?
Since SMath syntax seems to be
mat(R1C1,R1C2,R1C3,R2C1,R2C2,R2C3,nROWs,nCOLS)
to get matrix of
R1C1 R1C2 R1C3 R2C1 R2C2 R2C3
I have been 'making' matrices to use in SMath via Excel in .csv files and text editor.
Using the .csv file already has everything formatted as needed. I take my data in csv, open it in editor, delete the CR/LF's so it becomes one long line and append the rows,cols) at the end. Copy and paste into SMAth and its there. My only trouble sometimes is counting the right number of rows/columns if I change things.
|
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 03/03/2014(UTC) Posts: 418 Was thanked: 125 time(s) in 96 post(s)
|
Originally Posted by: sinneD Alex- Since SMath syntax seems to be
mat(R1C1,R1C2,R1C3,R2C1,R2C2,R2C3,nROWs,nCOLS)
I have been 'making' matrices to use in SMath via Excel in .csv files and text editor.
Do you have a plugin code (C# or VB.NET) that would pass a string mat(R1C1,R1C2,R1C3,R2C1,R2C2,R2C3,nROWs,nCOLS) back to SMath without an error? I have tried it in the past, but passing a simple string did not quite work...
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,648 Location: Italy Was thanked: 1331 time(s) in 876 post(s)
|
How much slow? With importData.XLSX I can import a 1100x111 matrix of numbers in ~7-8 seconds (optimization: numeric) The code is the same: Code: // return selectionContent values to SMath
List<Term> myResult = new List<Term>();
foreach (string matValue in selectionContent)
{
myResult.AddRange(Converter.ToTerms(matValue));
}
myResult.AddRange(Converter.ToTerms(selectionHeight.ToString()));
myResult.AddRange(Converter.ToTerms(selectionWidth.ToString()));
myResult.Add(new Term(Functions.Mat, TermType.Function, 2 + (selectionHeight * selectionWidth)));
// output to SMath
return myResult.ToArray();
Edited by user 10 December 2015 18:11:01(UTC)
| Reason: Not specified |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
SMath Studio Forum
»
SMath Studio
»
Questions
»
Most efficient way to build SMath matrix in VB.NET (plugin development)
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.