Page **1** of **1**

### Dataset of linear systems

Posted: **Sat Jul 23, 2016 5:21 pm UTC**

by **kolobisbiko**

Hi,

I want a dataset of linear system of equations in order to test some methods in matlab (gaussian elimination,LU....) but i can't find anything. Can you help me?

### Re: Dataset of linear systems

Posted: **Sun Jul 24, 2016 1:28 am UTC**

by **doogly**

You can just make them up, no?

### Re: Dataset of linear systems

Posted: **Sun Jul 24, 2016 5:01 pm UTC**

by **cyanyoshi**

A=rand(m,n), b = rand(m,1) ?

### Re: Dataset of linear systems

Posted: **Mon Jul 25, 2016 12:49 am UTC**

by **Cauchy**

Well that would generate matrices of maximal rank with probability 1, right? Maybe TC wants to also have examples with more linear dependencies.

### Re: Dataset of linear systems

Posted: **Mon Jul 25, 2016 4:13 am UTC**

by **MostlyHarmless**

If you want a matrix of a particular rank, you could randomly generate the SVD. This seems to work:

Code: Select all

`[U,R] = qr(rand(m,m)); `

[V,R] = qr(rand(n,n));

S = zeros(m,n);

for i = 1:r

S(i,i) = rand(1)

end

A = U*S*V'

### Re: Dataset of linear systems

Posted: **Sat Sep 10, 2016 6:29 pm UTC**

by **kolobisbiko**

Thank you for the answers and sorry for the delay, I had a health problem.

I want to find an already existed dataset because i want my results to be comparable with the results of other people.

Please help me, it is for my postgraduate work

### Re: Dataset of linear systems

Posted: **Mon Sep 19, 2016 11:46 pm UTC**

by **MostlyHarmless**

kolobisbiko wrote:Thank you for the answers and sorry for the delay, I had a health problem.

I want to find an already existed dataset because i want my results to be comparable with the results of other people.

Please help me, it is for my postgraduate work

I don't understand. You mentioned in the first post that you were testing matrix factoring methods in matlab. If you're testing new algorithms, people typically construct random matrices with the appropriate structure (plus maybe some worst case problems).

This is the first example I googled; it's fairly typical.

If you're using known algorithms, then the performance should be well documented in mathematical/CS literature. Matlab might make that slightly more difficult, since most of the code is not freely available. That said, the documentation should always tell you what algorithm is being used, and you can (almost certainly) trust matlab to implement it correctly. If you want to double check these performances for your own practice/enlightenment, you can follow along with something like

this.

Are you trying to write unit tests for something? I don't know of any standard linear systems used for testing, but you should probably use simple things like diagonal and tridiagonal systems.

Does that help?

### Re: Dataset of linear systems

Posted: **Tue Sep 20, 2016 8:54 am UTC**

by **kolobisbiko**

Yes. I am using known algorithms....I want to create a database in order to use it in WEKA (machine learning)....

1)I have to find linear systems os equations(matrices),

2)after I do that I have to use Matlab and run the known algorithms( Jacobi,Gauss Seidel, Gauss eliminaion...) in those matrices and find out which methods diverge-coverge for each matrix and choose the best method (for each matrix) from the methods which coverge

3)then I have to create a Database in order to use it in WEKA

Problems:

[*]I can't find a collection of linear systems of equation(matrices). I don't want to be very large (because i will run matlab in laptop)

[*]I can't find the matlab codes of the methods which solve linear systems(Jacobi,Gauss-seidel..)...and i want to be sure that these methods run in Matlab

You said that could be difficult with matlab.....can you suggest an alternative?

### Re: Dataset of linear systems

Posted: **Tue Sep 20, 2016 7:46 pm UTC**

by **MostlyHarmless**

1) I still maintain that you should use random matrices. Some solvers (e.g. Gaussian elimination or QR factorization) work on almost every (in the technical sense) matrix, so you can just randomly generate each element. Other solvers (e.g. the Jacobi method or conjugate gradient) need a special structure, but it's relatively easy to make random matrices that are, for example, diagonally dominant or symmetric and positive definite.

2) The convergence properties of these methods are well known already. You could test your code by using matrices for which the methods should diverge, but there is no need to find convergence criteria yourself. I used

Trefethen and Bau, but there are plenty of other good references.

3) There are already quite a few existing libraries for solving linear systems, including open source versions like scipy. If you want to roll your own, that's entirely understandable.

As to your problems:

1) Again, you should make your own random matrices. You can make them as small or large as you want for testing purposes.

2) There is a lot of sample code for these methods available online and in textbooks. I believe the Trefethen and Bau book has examples, and there are plenty of others available elsewhere. It seems like you're still learning about these methods, so it would probably be instructive for you to code them up yourself as well.

3) All of these methods will run in Matlab just fine. What I meant was that if you use something like the backslash command, you can't be sure what method will be used and you won't be able to look at the source code. If you write your own method (which you'd have to for Jacobi or GS), it will work perfectly well. That said, if you're actually interested in performance then you probably shouldn't be working in Matlab. Most of the serious numerical work I know is done in C or Fortran, just because they're so much faster.

### Re: Dataset of linear systems

Posted: **Tue Sep 20, 2016 9:29 pm UTC**

by **kolobisbiko**

Thank's again for the reply.

First of all, I don't have any knowledge in programming. I have only used 2-3 times Matlab.

1)I want to solve the linear systems of equations(matrices) but it is not necessary to use Matlab, I chose Matlab because I have used it before......If there is another (easier) way to solve the systems,with 4-6 known methods, it would be great. I do not have to create my own code I can use existing codes...

In other words,I want to solve the systems,I just want an easy way cause I don't know programming but I want to know the time, the number of reps of each method etc.

2)I searched in Google for Scipy and I read that Python is necessary(I do not know anything about Python).If you know another "tool" where I can choose which method will be used to solve each system please let me know. I am only interested in perfomance of each method.

3) The professor who supervises me told me that it would be better if I use allready known problems(matrices) that's why i don't create me own matrices.

4) about Trefethen and Bau,I'm sure it's a great book but I can't afford it...

In conclusion, I want to find a collection of matrices (50-60 I suppose) and a way to solve the systems with known methods but I also want the perfomance of each method

I would appreciate it if you could help me

### Re: Dataset of linear systems

Posted: **Wed Sep 21, 2016 5:06 am UTC**

by **MostlyHarmless**

Alright. Matlab should be fine for your purposes. It has several builtin solvers/matrix factorization routines for things like LU decomposition, QR decomposition, Cholesky factorization, GMRES and PCG. You can solve systems with these commands in a few lines of code. You specifically mentioned Jacobi and Gauss-Seidel, but these are not included in any commonly used libraries that I know of (they're typically much slower than some of the methods above). Since you're new to coding and numerical solvers, you really should code them up yourself; they're still taught because they're easy to use/analyze and give a good sense of how iterative methods work.

You should also really look for a numerical linear algebra textbook through the library, but there are other useful free resources.

This is a good place to start. In particular, the video on iteration methods should get you started on Jacobi and GS.

I'm not going to make 50-60 matrices for you, and I doubt you'll find that sort of collection online. Again, random matrices are your best choice here. If your professor really wants you to use something else, they should give a recommendation. That said, there are two good test cases that you might want to use:

1) Diagonal matrices (i.e., nonzero entries on the main diagonal and zeros elsewhere) of various sizes. It really doesn't matter what the nonzeros are. This is an incredibly easy case to solve, and even naive methods like calculating the inverse should be very fast. At the very least, it will let you spot big errors in your code.

2) The matrix M from

here (with various sizes). It's symmetric, positive definite and fairly sparse, so most of the common methods work and are at least acceptable. You can also calculate the inverse exactly, so it's easy to get error estimates, but the inverse is dense so naive methods are very slow.

### Re: Dataset of linear systems

Posted: **Wed Sep 21, 2016 9:16 am UTC**

by **kolobisbiko**

I didn't know that there are bultin solvers for linear systems in Matlab, I thought I had to find the codes by myself.

I don't want to create my own codes(Jacobi,Gauss Seidel) beacause I want to focus in machine learning(Weka)..Matlab is only a necessary step in order to choose the best solver for each Matrix and create my dataset which I am going to use in Weka.

I prefer existing Matrices because I want to know the features of each matrix in order to use them to create the dataset for Weka.

Your link with the videos is going to help me very much.

I have some questions though:

1)I wonder if you know how large systems can be solved by Matlab using my laptop....I dont't want to wait a lifetime.

2)Does the builtin solvers work for sparse Matrices?( in case I find some sparse Matrices on the web,cause non sparse matrices it's more difficult)...

I hope I will find some Matrices here

http://math.nist.gov/MatrixMarket/,

http://www.cise.ufl.edu/research/sparse/matrices/ 3) In case I create my own matrices is there a "tool" which can find the features of each matrix(dimensions,trace and others)

Thank's again for the help, I can tell you know a lot of things about Matlab and arithmetic analysis.

### Re: Dataset of linear systems

Posted: **Wed Sep 21, 2016 10:29 pm UTC**

by **MostlyHarmless**

1) On my laptop (which is nothing special) and with a 2012 version of Matlab I can solve 10,000 x 10,000 dense systems in ~20 secons, but I can't store a 100,000 x 100,000 dense matrix. (I believe this is because Matlab insists on using contiguous blocks of memory for matrices. Sparse systems can be substantially larger.

2) Yes. Most of the builtin solvers/factoring methods are set up so that if you give matrices of sparse type as input you will get matrices of sparse type as output. This is better suited to some methods than others (e.g., the inverse of a sparse matrix has almost no zero entries, so using the sparse type will just slow you down).

3) There are many such tools. Those particular examples can be found with the size() and trace() functions, but you should check the linear algebra section of the documentation for more.

### Re: Dataset of linear systems

Posted: **Fri Sep 23, 2016 3:56 pm UTC**

by **kolobisbiko**

I want to find the properties of a matrix is there a "tool",software for that?

I don't think matlab can provide such information.....I want 10+ properties

### Re: Dataset of linear systems

Posted: **Sat Sep 24, 2016 10:00 am UTC**

by **Demki**

kolobisbiko wrote:I want to find the properties of a matrix is there a "tool",software for that?

I don't think matlab can provide such information.....I want 10+ properties

What properties are you talking about?

### Re: Dataset of linear systems

Posted: **Sat Sep 24, 2016 10:23 am UTC**

by **kolobisbiko**

Size,norm,trace and other .....the more the better. Matlab can provide me only a few of these properties/features but i need more

I read somewhere about SALSA/Anamod but it was impossible for me to download it. The process was very complicated(I've never seen something like that before)

I talked to my professor and we decided to work with sparse matrices,because we found a large collection

http://www.cise.ufl.edu/research/sparse/matrices/ and use the builtin solvers for linear systems with sparce matrices

It is cruicial to get over that obstacle because it is necessary for weka to know all these features/properties of the matrices. I seached but i couldn't find anything that could help me

### Re: Dataset of linear systems

Posted: **Sat Sep 24, 2016 3:45 pm UTC**

by **cyanyoshi**

MATLAB has built-in functions that can calculate pretty much anything you'd ever want to know about a matrix, including the three you mentioned. The more specific you are, the better we can help.

### Re: Dataset of linear systems

Posted: **Sat Sep 24, 2016 4:11 pm UTC**

by **kolobisbiko**

Here

http://www.cise.ufl.edu/research/sparse/matrices/GHS_indef/boyd1.html we can see some (sparse)matrix properties, they are given for each Matrix...but I would like more properties for each (sparse)Matrix

I don't need specific properties I just need more, I don't know which properties are going to be usefull that's why I will use WEKA to choose the "best" of them.So I need a lot of properties.

If you know some Matlab functions that can give me additional properties of a sparse matrix , it would be great.

### Re: Dataset of linear systems

Posted: **Sat Sep 24, 2016 6:18 pm UTC**

by **MostlyHarmless**

https://www.mathworks.com/help/matlab/linear-algebra.htmlYou can use Matlab to calculate pretty much anything you're interested in -- most of it with only a line or two of code. Are you having any trouble understanding the Matlab commands? The properties you mentioned (size, norm, trace, e.g.) have corresponding Matlab functions (with the same names, no less).

### Re: Dataset of linear systems

Posted: **Sat Sep 24, 2016 7:23 pm UTC**

by **kolobisbiko**

Thanks again for the reply,

These functions work for dense matrices....I need functions for sparse matrices

I found only three: norm(S,'fro'),normest(S),sprank(S).....the functions must return numbers or yes/no(not vectors,matrices)

### Re: Dataset of linear systems

Posted: **Sat Sep 24, 2016 9:53 pm UTC**

by **MostlyHarmless**

All of those commands work with sparse matrices. Some may be much slower than others, but that's because some require intermediate steps with many nonzero elements. For instance, it is difficult to calculate the 2-norm of a big matrix even if it is sparse. That's not a Matlab problem, it's just a math problem. However, there shouldn't be any difficulty calculating the dimensions or trace or some other norms (the 2-norm and sup-norm should be particularly fast).

See, for example,

http://www.mathworks.com/help/matlab/math/sparse-matrix-operations.html

### Re: Dataset of linear systems

Posted: **Sun Sep 25, 2016 10:03 pm UTC**

by **kolobisbiko**

Thank you all for the help. You helped me very much.