Rank: 2851 based on 49 downloads (last 30 days) and 8 files submitted
photo

Riccardo Dessi

E-mail
Company/University
DIEE (University of Cagliari)
Lat/Long
39.2291, 9.109184

Personal Profile:

 

Watch this Author's files

 

Files Posted by Riccardo Dessi View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
07 May 2014 Screenshot sort1.m sort vector algorithm Author: Riccardo Dessi standard sort vectors... 4 4
  • 2.0
2.0 | 1 rating
06 May 2014 Screenshot lumy2.m PA=LU factorization (version 2 with permuted known term) Author: Riccardo Dessi lu factorization perm... 5 0
06 May 2014 Screenshot lumy.m PLU factorization Author: Riccardo Dessi lu factorization part... 6 0
06 May 2014 Screenshot forward.m forward substitution solver Author: Riccardo Dessi forward substitution ... 5 0
06 May 2014 Screenshot backward.m backward substitution solver Author: Riccardo Dessi backward substitution... 3 0
Comments and Ratings by Riccardo Dessi
Updated File Comments Rating
14 May 2014 sort1.m sort vector algorithm Author: Riccardo Dessi

Dear Jan, thank u to have posted your opinion. So the algorithm is not efficient as the matlab function "sort", we are speaking about a "selection sort" in which we have a complexity of n^2 (if n is the vector dmension), with other better algorithm we can have even n*log(n). But as u know perfectly, general in sorting, it's very hard to be faster than matlab, cause it uses inside routines. My function, obviously, don't want to be a substitution of the matlab's function, contrarily wants to be a guide line for who is starting to program in matlab and who is approaching for the first time to sort algorithm implementation . Nothing else :) In that sense you agree, is not specified in the description. I will update it!! thank u.

Comments and Ratings on Riccardo Dessi's Files View all
Updated File Comment by Comments Rating
15 May 2014 sort1.m sort vector algorithm Author: Riccardo Dessi Jan Simon

@John: Together with your comments, the code is valuable for teaching. You see a working piece of code and the details, how to improve it until it is useful and usable. Therefore I can imagine, that this submission could be expanded to a tutorial including the different versions of the code, a copy of the comments and finally a nice and cute version. Then the "result" is not the final version, but the documentation of the progress of improvement.

Sorting has been discussed too often to be exciting anymore. But a well documented development from bad to good code is rare in the FEX and I would give a high rating. I imagine comments in the code for each modification like better names of variables, more flexible input handling, etc.

14 May 2014 sort1.m sort vector algorithm Author: Riccardo Dessi John D'Errico

As Jan points out, there are problems with this code. IF it is designed to be a teaching tool, then do a good job of teaching!

A GOOD tool would have well written help. This code lacks an H1 line, that first line of the help that lookfor uses. (Learn about H1 lines, and how and why one would use lookfor.)

At least the help in this tool does describe the arguments, and list them. However, GOOD help would have more than just that. It would have a "see also" line. Since this is claimed to be a teaching tool, it would tell the user what basic class of sort is used!

A very good tool would have a date in it, and possibly even a version number to track revisions. It would have the name of the author and an e-mail address so they could be reached if a problem is found.

Finally, a good tool would have internal comments in the code. These comments would explain what a block of code does. That way when a novice DOES read through the tool, they can learn something from those comments. This tool has essentially no internal comments, at least no useful ones.

A good tool has well written code. That means you use intelligently named variables, that describe their use in the code. Such self documenting code helps the novice. It helps you if you ever need to revise the code because a bug was found. And remember that even MATLAB changes occasionally, so you might need to modify your code just to make it continuously upwardly compatible. So variable names like temp and temp2 are nearly the worst kind of thing I can imagine for variable names. (Ok, I suppose a name like i01ii1o1I0ioo is worse.) But seriously, use good names that describe what the variable holds. MATLAB does not charge for spare characters in a name, so use a few!

I've not even yet touched the code itself. Yes, sort exists, and one should certainly use it, NOT a limited tool with less capability that will run far more slowly.

The code does have a default for the second argument, so that is good. That second argument is required to be provided in full if it is provided. So the user cannot simply be lazy and supply 'a' or 'd' instead. In fact, GOOD, FRIENDLY code would allow such partial completions. If you are going to teach something, do a good job of it! In fact, the existing code is not even case insensitive on the type argument. All of these things are trivially handled by the strcmp suite of tools. So learn to use things like strncmpi, or lower, etc.

As Jan pointed out, the else continue branch is silly in an if statement.

There are other things I don't like about the code. For example, if you pass in a row vector, it returns a column vector! It always returns a column vector as a result. This is just unfriendly behavior. Vectors should ALWAYS stay the same shape where that makes sense.

And, of course, this code fails to work on arrays at all.

I would rate this as about 2 stars. Why? It is not complete dreck code. (I'd have given it 1 star then.) But as a teaching tool, it is seriously lacking good elements that I would want to see in a teaching tool. And since the only person who should ever consider looking at this is a novice who wants to learn what a sort is and how to write one, this code lacks the most important elements a teaching code should have.

(As a note to the author, IF you revise it, let me know and I will consider revising the rating I gave it.)

14 May 2014 sort1.m sort vector algorithm Author: Riccardo Dessi Riccardo Dessi

Dear Jan, thank u to have posted your opinion. So the algorithm is not efficient as the matlab function "sort", we are speaking about a "selection sort" in which we have a complexity of n^2 (if n is the vector dmension), with other better algorithm we can have even n*log(n). But as u know perfectly, general in sorting, it's very hard to be faster than matlab, cause it uses inside routines. My function, obviously, don't want to be a substitution of the matlab's function, contrarily wants to be a guide line for who is starting to program in matlab and who is approaching for the first time to sort algorithm implementation . Nothing else :) In that sense you agree, is not specified in the description. I will update it!! thank u.

10 May 2014 sort1.m sort vector algorithm Author: Riccardo Dessi Jan Simon

This is definitely not a "standard" sorting algorithm, because it has a bad efficiency. What's wrong with QuickSort or InsertionSort, BubbleSort or QuickerSort? What is the benefit compared to the much faster SORT command?

The "else continue" statement is a waste of time. You can simply omit it.

Contact us