PC Review


Reply
Thread Tools Rate Thread

Convert Functions ...

 
 
shapper
Guest
Posts: n/a
 
      9th May 2009
Hello,

I am converting a few Matlab functions to C#.
Each function has 2 to 8 inputs being 1 or 2 an array with 1xN
dimension.
All functions return 1 or 2 arrays.

What would be the best way, in terms of performance and usability, to
create these functions?

I see the following options:

1. Make each function a class with properties that are inputs.
Then a method Run that makes the calculation.
I am not sure if it is "to much" to create a class for each
function.

2. Create a class MatlabFunctions and inside have static methods for
each function with the inputs.

Which one would be the best way to implement it?

The calculation inside the functions differ a lot.
Some are quite simple ... others are a little bit more complex.
And some functions rely on other functions to for their own
calculations.

And are there better options than 1 and 2?

Thank You,
Miguel
 
Reply With Quote
 
 
 
 
Arne Vajhøj
Guest
Posts: n/a
 
      9th May 2009
shapper wrote:
> I am converting a few Matlab functions to C#.
> Each function has 2 to 8 inputs being 1 or 2 an array with 1xN
> dimension.
> All functions return 1 or 2 arrays.
>
> What would be the best way, in terms of performance and usability, to
> create these functions?
>
> I see the following options:
>
> 1. Make each function a class with properties that are inputs.
> Then a method Run that makes the calculation.
> I am not sure if it is "to much" to create a class for each
> function.
>
> 2. Create a class MatlabFunctions and inside have static methods for
> each function with the inputs.
>
> Which one would be the best way to implement it?
>
> The calculation inside the functions differ a lot.
> Some are quite simple ... others are a little bit more complex.
> And some functions rely on other functions to for their own
> calculations.


#2 would be the standard for simple calculation.

The more complex the calculations and especially if
multiple algorithms to implement the calculation exists
the more attractive #1 becomes.

Arne
 
Reply With Quote
 
Pavel Minaev
Guest
Posts: n/a
 
      9th May 2009
On May 8, 6:11*pm, shapper <mdmo...@gmail.com> wrote:
> I am converting a few Matlab functions to C#.
> Each function has 2 to 8 inputs being 1 or 2 an array with 1xN
> dimension.
> All functions return 1 or 2 arrays.
>
> What would be the best way, in terms of performance and usability, to
> create these functions?
>
> I see the following options:
>
> 1. Make each function a class with properties that are inputs.
> * * Then a method Run that makes the calculation.
> * * I am not sure if it is "to much" to create a class for each
> function.


It doesn't make much sense, anyway. Why a class when it doesn't model
any entity or concept in any useful way?

> 2. Create a class MatlabFunctions and inside have static methods for
> each function with the inputs.


That's the most straightforward way, and I don't see any downsides.

 
Reply With Quote
 
Ratnesh Maurya
Guest
Posts: n/a
 
      9th May 2009
On May 9, 6:11*am, shapper <mdmo...@gmail.com> wrote:
> Hello,
>
> I am converting a few Matlab functions to C#.
> Each function has 2 to 8 inputs being 1 or 2 an array with 1xN
> dimension.
> All functions return 1 or 2 arrays.
>
> What would be the best way, in terms of performance and usability, to
> create these functions?
>
> I see the following options:
>
> 1. Make each function a class with properties that are inputs.
> * * Then a method Run that makes the calculation.
> * * I am not sure if it is "to much" to create a class for each
> function.
>
> 2. Create a class MatlabFunctions and inside have static methods for
> each function with the inputs.
>
> Which one would be the best way to implement it?
>
> The calculation inside the functions differ a lot.
> Some are quite simple ... others are a little bit more complex.
> And some functions rely on other functions to for their own
> calculations.
>
> And are there better options than 1 and 2?
>
> Thank You,
> Miguel


Hi Miguel,

I will go for #2, I would like #1 only if you are keeping some data or
result in the class which can be reused later in the same class.

Cheers,
-Ratnesh
S7 Software
 
Reply With Quote
 
Ratnesh Maurya
Guest
Posts: n/a
 
      9th May 2009
On May 9, 6:11*am, shapper <mdmo...@gmail.com> wrote:
> Hello,
>
> I am converting a few Matlab functions to C#.
> Each function has 2 to 8 inputs being 1 or 2 an array with 1xN
> dimension.
> All functions return 1 or 2 arrays.
>
> What would be the best way, in terms of performance and usability, to
> create these functions?
>
> I see the following options:
>
> 1. Make each function a class with properties that are inputs.
> * * Then a method Run that makes the calculation.
> * * I am not sure if it is "to much" to create a class for each
> function.
>
> 2. Create a class MatlabFunctions and inside have static methods for
> each function with the inputs.
>
> Which one would be the best way to implement it?
>
> The calculation inside the functions differ a lot.
> Some are quite simple ... others are a little bit more complex.
> And some functions rely on other functions to for their own
> calculations.
>
> And are there better options than 1 and 2?
>
> Thank You,
> Miguel


Hi Miguel,

I will go for #2, I would like #1 only if you are keeping some data or
result in the class which can be reused later in the same class.

Cheers,
-Ratnesh
S7 Software
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to convert cell formula functions to code functions Adnan Microsoft Excel Misc 1 1st Oct 2008 08:30 PM
Where are the CONVERT & CAST functions in MDB? =?Utf-8?B?QWxsZW5fTg==?= Microsoft Access VBA Modules 12 26th Feb 2007 08:32 AM
convert time functions to numbers =?Utf-8?B?cGF0dHk=?= Microsoft Excel Worksheet Functions 1 31st Oct 2006 04:30 AM
How do I convert functions that are zero into a null ? =?Utf-8?B?Tmljaw==?= Microsoft Excel Worksheet Functions 4 12th May 2005 12:44 AM
Convert Excel 4 Macro Functions Joe Microsoft Excel Worksheet Functions 5 29th Mar 2004 07:21 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:41 PM.