I have problems with sparse matrices. I know how to create them, but I can't carry out operations with them. See the following simple example:

`T=5;`

declare sparse matrix H;

H = spEye(T) - spCreate(T, T, ones(T-1, 1), seqa(2,1,T-1), seqa(1,1,T-1));

This is fine so far. However, how could I calculate `H'*H`

? Or multiply it with another matrix, such as `H*ones(T,1)`

? I tried `H2 = spTrTDense(H, ones(T,1))`

, but it gave an error message ("G0554 : Unable to create sparse matrix").

## 8 Answers

0

Can I obtain an answer to this question? Or is it so trivial that I should have found the solution in the manual? I looked for it, but I didn't find it.

0

I think something is going wrong in the initialization.

Try this:

```
sparse matrix H;
T = 5;
H = spEye(T);
H = H + spcreate(T,T,ones(T-1,1),seqa(2,1,T-1), seqa(1,1,T-1));
print H'*H;
```

0

Thanks a lot for the answer. Now it works, although I don't see what makes the difference. I was also able to multiply `H`

by a dense matrix: `H * ones(T, 1)`

although it becomes a dense matrix which I need to convert into a sparse matrix.

If I can make a request for newer version of Gauss is to make sparse matrix operations easier and better. In Matlab it works very well, but I'd like to have it in Gauss too.

0

Sorry for bothering again, but it's getting weird. The code excerpt you gave me works. More precisely, this one:

`sparse matrix H;`

T=5;

`H = spEye(T);`

```
H = H + spCreate(T,T,ones(T-1,1),seqa(2,1,T-1), seqa(1,1,T-1));
```

```
print H'*H;
```

```
```

However, when I change the sign in the fourth row to -, it gives me the same error message as above.

0

Sorry for bothering again, but it's getting weird. The code excerpt you gave me works. More precisely, this one:

`sparse matrix H;`

T = 5;

H = spEye(T);

H = H + spCreate(T, T, ones(T-1, 1), seqa(2, 1, T-1), seqa(1, 1, T-1));

print H'*H;

However, when I change the sign in the fourth row to -, it gives me the same error message as above. I don't understand this, is it some bug?

0

Could someone help me out why the above example works with the `+`

and doesn't with the `-`

sign?

Moreover, Would it be possible to see working examples for operations between sparse and dense matrices? I checked the manual, but it's very vague about sparse matrices. (I use Gauss 24.)

0

This looks like a bug. The development team is looking into this.

0

Thanks a lot. I suppose that there will be an update for Gauss 24 soon. I hope operations with sparse matrices will work well after that.

## Your Answer

## 8 Answers

Can I obtain an answer to this question? Or is it so trivial that I should have found the solution in the manual? I looked for it, but I didn't find it.

I think something is going wrong in the initialization.

Try this:

```
sparse matrix H;
T = 5;
H = spEye(T);
H = H + spcreate(T,T,ones(T-1,1),seqa(2,1,T-1), seqa(1,1,T-1));
print H'*H;
```

Thanks a lot for the answer. Now it works, although I don't see what makes the difference. I was also able to multiply `H`

by a dense matrix: `H * ones(T, 1)`

although it becomes a dense matrix which I need to convert into a sparse matrix.

If I can make a request for newer version of Gauss is to make sparse matrix operations easier and better. In Matlab it works very well, but I'd like to have it in Gauss too.

Sorry for bothering again, but it's getting weird. The code excerpt you gave me works. More precisely, this one:

`sparse matrix H;`

T=5;

`H = spEye(T);`

```
H = H + spCreate(T,T,ones(T-1,1),seqa(2,1,T-1), seqa(1,1,T-1));
```

```
print H'*H;
```

```
```

However, when I change the sign in the fourth row to -, it gives me the same error message as above.

`sparse matrix H;`

T = 5;

H = spEye(T);

H = H + spCreate(T, T, ones(T-1, 1), seqa(2, 1, T-1), seqa(1, 1, T-1));

print H'*H;

However, when I change the sign in the fourth row to -, it gives me the same error message as above. I don't understand this, is it some bug?

Could someone help me out why the above example works with the `+`

and doesn't with the `-`

sign?

Moreover, Would it be possible to see working examples for operations between sparse and dense matrices? I checked the manual, but it's very vague about sparse matrices. (I use Gauss 24.)

This looks like a bug. The development team is looking into this.

Thanks a lot. I suppose that there will be an update for Gauss 24 soon. I hope operations with sparse matrices will work well after that.