Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Is this the shortest way of creating these functions
The program works well using these function blocks , but am sure the big guys wod do the same thing using less time and space. my program is to use Craemer's ruld to compute matric operation , can anyone assist please?

C#
const int MAX_SIZE = 20;//constructor with a max size of 20 sq matrix.

// Level 1 Functions
void print_message();
void initialize(float &, float *, float *, float *);
void allocate_floats(int &, float *&, float *&, float *&);
void initialize_dynamic_memory(float *, int);
void get_matrices(float [][MAX_SIZE], float *, int);
void calculate_variable_matrix(float &, float *, float *, float [][MAX_SIZE], float *, int);
void print_results(float *, float *, int, float);
void return_memory(float *, float *, float *);

// Level 2 Functions
void calculate_determinant(float &, float [][MAX_SIZE], int);
void calculate_modified_determinant(float *, float [][MAX_SIZE], float [], int);
void calculate_variables(float *, float *, float, int);
void print_determinants(float *, int, float);
void print_variables(float *, int, float);

// Level 3 Functions
void copy_matrix(float[][MAX_SIZE], float [][MAX_SIZE], int);
bool swap_rows(float [][MAX_SIZE], int, int);
Posted
Comments
Richard MacCutchan 27-Nov-11 10:35am    
All you have shown is a list of function declarations, from which it's impossible to guess anything.
carlmack 27-Nov-11 10:39am    
hey guys hahah i am just learning the art, i am just looking how to use this new skillin my daily computation ,but a little flair would not hurt, haha
anyway could u look at my codes and give ma a feed back?
some aspects i took from my text and some from the net, but i knew what i wanted to do, so any assistance would be great.
thank you
Richard MacCutchan 27-Nov-11 10:45am    
Did you actually bother to read my comment?
carlmack 27-Nov-11 10:54am    
can i post my codes here
RaviRanjanKr 27-Nov-11 15:20pm    
who stop you to post your codes. if you have problem you can post your effort to find out solution.

1 solution

Cramer's rule is indeed very ineffective. In linear algebra used in application mathematics in computer algorithms, Gaussian Elimination is commonly used. Gaussian Elimination is way more effective. The benefit of Cramer's Rule it just the ease of use in manual calculations, not in computer algorithms. Computational complexity of directly applied Cramer's Rule is O(N4), while Gaussian Elimination is O(N3).

See:
http://en.wikipedia.org/wiki/Cramer%27s_rule[^],
http://en.wikipedia.org/wiki/Gaussian_elimination[^].

One widely used variation of Gauss method is Gauss–Jordan Elimination: http://en.wikipedia.org/wiki/Gauss-Jordan_elimination[^].

More exactly, in 2010 a new method of calculation based on Cramer's Rule was published. It was proven that the computational complexity of the new method is O(N3).

This is the reference:
Ken Habgood and Itamar Arel. 2010. Revisiting Cramer's rule for solving dense linear systems. In Proceedings of the 2010 Spring Simulation Multiconference (SpringSim '10).

Unfortunately, I'm not familiar with this work; and I don't have a Web reference, sorry.

[EDIT]

You can find some C++ or C implementation on the Web:
http://www.crbond.com/linear.htm[^],
http://icodesnip.com/snippet/cpp/gauss-jordan-elimination-dreamincode[^],
http://www.dreamincode.net/code/snippet1312.htm[^].

Google to find what suits you the best.

—SA
 
Share this answer
 
v2
Comments
CPallini 27-Nov-11 15:25pm    
My 5.
Sergey Alexandrovich Kryukov 27-Nov-11 15:59pm    
Thank you.
--SA
Stefan_Lang 28-Nov-11 8:28am    
Wow, and then I thought I was the math guy here. Didn't even know about Cramer's rule, although the name sounded familiar (once spelled right :-) ).

My 5!
Sergey Alexandrovich Kryukov 28-Nov-11 11:12am    
Thank you very much, Stefan.

I don't wanted to disappoint you, but we had Cramer's rule in algebra lessons in 8 or 9the grade of our regular school, mandatory to everyone (meaning, learning letters and reading started in 1st grade), and we had only 10 grades all together. Universities assume knowledge of beginner's calculus at the moment of entry exam (but exams are supposed to be in elementary mathematics which can be more tricky than calculus), something that most engineers in US barely get at the end of the college. So...
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900