# After update receiving error in uq\_blockwise\_inverse

**URL:** <https://uqworld.org/t/after-update-receiving-error-in-uq-blockwise-inverse/238>\
**Category:** Community Q&A and How To\
**Tags:** pce\
**Created:** [September 24, 2019, 10:00pm UTC](https://uqworld.org/t/after-update-receiving-error-in-uq-blockwise-inverse/238 "2019-09-24T22:00:47Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Farshud\_Sorourifar](https://uqworld.org/user_avatar/uqworld.org/farshud_sorourifar/32/260_2.png) [@Farshud\_Sorourifar](https://uqworld.org/u/Farshud_Sorourifar)\
**Post date:** [September 24, 2019, 10:00pm UTC](https://uqworld.org/t/after-update-receiving-error-in-uq-blockwise-inverse/238/1 "2019-09-24T22:00:47Z")

</div>

Hello, I am using UQlab 1.3.0, and using PCE to build a surrogate from existing data. It was functioning before the update, and some changes, I am receiving the following error when I try to execute

myPCE = uq\_createModel(MetaOpts);

> Warning: Warning: numerical instability!! Gamma for  
> LAR iteration 2 was set to 0 to prevent crashes.
> 
> > In uq\_lar (line 268)  
> > In uq\_PCE\_lars (line 60)  
> > In uq\_PCE\_calculate\_coefficients\_regression (line 197)  
> > In uq\_PCE\_calculate\_coefficients (line 47)  
> > In uq\_calculateMetamodel (line 18)  
> > In uq\_initialize\_uq\_metamodel (line 358)  
> > In uq\_core\_module/run\_initialization\_script  
> > In uq\_core\_model/add\_module  
> > In uq\_createModel  
> > In PCE\_CE (line 66)  
> > Incorrect dimensions for matrix multiplication.  
> > Check that the number of columns in the first matrix  
> > matches the number of rows in the second matrix. To  
> > perform elementwise multiplication, use ‘.\*’.
> 
> ```
> Error in uq_blockwise_inverse (line 26)
> SCinv = 1/(D - C*Ainv*B);
> 
> ```
> 
> Error in uq\_lar (line 214)  
> M = uq\_blockwise\_inverse(M,x,x’,r) ;
> 
> Error in uq\_PCE\_lars (line 60)  
> lar\_results = uq\_lar(Psi, Y, lar\_options);
> 
> Error in uq\_PCE\_calculate\_coefficients\_regression  
> (line 197)  
> lars\_results =  
> uq\_PCE\_lars(univ\_p\_val,  
> current\_model);
> 
> Error in uq\_PCE\_calculate\_coefficients (line 47)  
> uq\_PCE\_calculate\_coefficients\_regression(current\_model);
> 
> Error in uq\_calculateMetamodel (line 18)  
> success =  
> uq\_PCE\_calculate\_coefficients(current\_model);
> 
> Error in uq\_initialize\_uq\_metamodel (line 358)  
> success = uq\_calculateMetamodel(current\_model);
> 
> Error in PCE\_CE (line 66)  
> myPCE = uq\_createModel(MetaOpts);

I’ve tried to undo all the changes I’ve made, but this error keeps showing up. I should note, that the dimensions of my input are 12, and the output is 10. The coefficient for the first output variable solves, and the error is given when solving for the coefficients for the second output variable.

My appologies if I am unclear in explaining my problem, any help as to where I should troubleshoot would be appreciated. I’ve verified that the input and output data sets for training and validation match(MetaOpts.ExpDesign, MetaOpts.ValidationSet), and (InputOpts.Marginals) is appropriatly dimensioned as well.

---

<div class="post-metadata">

**Author:** ![nluethen](https://uqworld.org/user_avatar/uqworld.org/nluethen/32/218_2.png) [@nluethen](https://uqworld.org/u/nluethen)\
**Post date:** [September 25, 2019, 3:36pm UTC](https://uqworld.org/t/after-update-receiving-error-in-uq-blockwise-inverse/238/2 "2019-09-25T15:36:38Z")

</div>

Hi @Farshud_Sorourifar, welcome to UQWorld!

Between UQLab Release 1.2.1 and 1.3.0 there were no changes in the PCE module, so the error must be caused by something else.

First, make sure that only one version of UQLab, the updated one, is on your Matlab path, so that older versions don’t interfere when you run your script.

If that doesn’t help, try to re-install UQLab, in case something went wrong during the update process. You can find the files and the installation instructions here: [https://uqftp.ethz.ch/uqlab\_releases/download.html](https://uqftp.ethz.ch/uqlab_releases/download.html) Again, make sure that only this version of UQLab is on the Matlab path when you run your script.

If the error persists, please send us your code and if possible also the data, so that we can investigate the issue.

Good luck!

---

<div class="post-metadata">

**Author:** ![Farshud\_Sorourifar](https://uqworld.org/user_avatar/uqworld.org/farshud_sorourifar/32/260_2.png) [@Farshud\_Sorourifar](https://uqworld.org/u/Farshud_Sorourifar)\
**Post date:** [September 27, 2019, 8:54pm UTC](https://uqworld.org/t/after-update-receiving-error-in-uq-blockwise-inverse/238/3 "2019-09-27T20:54:51Z")

</div>

Thank you, I have been able to figure it out (sort of).

In case anyone is having similar issues:  
There was an issue in uq\_lar.m on line 234.  
a\_coeff = [a\_coeff idx] was not being read. I corrected the issue by copying this line to 216 (just below M = uq\_blockwise\_inverse(M,x,x’,r)).

Additional comments:  
What is strange is that this line(a\_coeff = [a\_coeff idx] ) has to be in both places for the code to work, but now I can only evaluate polynomials of 1. This is fine for me, since prior to these issues, the lowest validation error was using a a degree one polynomial anyways.  
If anyone has any clue as to why this issue first occurred, I would be interested.

Thanks!  
Farshud

---

<div class="post-metadata">

**Author:** ![nluethen](https://uqworld.org/user_avatar/uqworld.org/nluethen/32/218_2.png) [@nluethen](https://uqworld.org/u/nluethen)\
**Post date:** [September 30, 2019, 3:21pm UTC](https://uqworld.org/t/after-update-receiving-error-in-uq-blockwise-inverse/238/4 "2019-09-30T15:21:52Z")

</div>

Hi Farshud, good to hear that you could find a solution for your problem.  
However, this is such a weird error that we would like to understand what exactly went wrong, and correct it if there is indeed a bug.

It sounds very strange that the code in line 234 should not be executed in your case. How did you test this? If this line is copied to both places as you describe, it might happen that the regressor is added twice, which can lead to further problems… so we would not recommend solving the problem this way. And what do you mean with “now I can only evaluate polynomials of [degree] 1”? Does the computation always stop at degree 1? This is maybe not such a good long-term solution then… 😉

We would be very grateful if you could repeat your calculations with a fresh install of UQLab, just to make sure it is not an issue with the update process. You don’t need to delete your old version, just make a new folder and download the files there. You can use the same license.p file that you have already. Then, type uqlab\_install in the core folder of the new version. When you are asked whether to remove other versions of UQLab from the Matlab path, click Yes. (You can switch back to your other UQLab version anytime by the same procedure, by typing uqlab\_install in the core folder and removing all other versions of Matlab from the path.)

Thanks for your help in investigating this issue!

---

<div class="post-metadata">

**Author:** ![Farshud\_Sorourifar](https://uqworld.org/user_avatar/uqworld.org/farshud_sorourifar/32/260_2.png) [@Farshud\_Sorourifar](https://uqworld.org/u/Farshud_Sorourifar)\
**Post date:** [September 30, 2019, 7:47pm UTC](https://uqworld.org/t/after-update-receiving-error-in-uq-blockwise-inverse/238/5 "2019-09-30T19:47:37Z")

</div>

Hello Nora,

Before making any changes, I did delete uqlab and did a fresh install. I will try it again later this week and see if anything changes though.

I realized that line 231 was not being executed while trying to trace the error, and found the value of a\_coeff to be unchanged in the iteration before the crash. It was changing in the two iterations before the crash.

As far as only evaluating degree one polynomials, I get an error on line 254 ( c = 1/sqrt((s’\*M)\*s) ) when setting MetaOpts.Degree=1:n, or MetaOpts.Degree=n for any n greater than 1, or using MetaOpts.PCE.Degree=n for any n, including 1. In the previous install, setting MetaOpts.Degree=n:m would only evaluate polynomials of degree n, now it crashes. I agree that this was not a good long term solution.

Additionally, I should mention I am using Matlab R2019a in Linux Mint. I can also send you my script and the data files if you would like to verify the problem.

Thanks for all your help,

Farshud Sorourifar

---

<div class="post-metadata">

**Author:** ![nluethen](https://uqworld.org/user_avatar/uqworld.org/nluethen/32/218_2.png) [@nluethen](https://uqworld.org/u/nluethen)\
**Post date:** [October 1, 2019, 8:40am UTC](https://uqworld.org/t/after-update-receiving-error-in-uq-blockwise-inverse/238/6 "2019-10-01T08:40:10Z")

</div>

Hi Farshud,

That’s a good idea. Once you have repeated the tests with a fresh install (with correct Matlab path and without any modifications), please let us know the result!

Then, if the error is still there, it would indeed be good if you could send us your script and the data, so that we can investigate the issue.

---

<div class="post-metadata">

**Author:** ![Farshud\_Sorourifar](https://uqworld.org/user_avatar/uqworld.org/farshud_sorourifar/32/260_2.png) [@Farshud\_Sorourifar](https://uqworld.org/u/Farshud_Sorourifar)\
**Post date:** [October 5, 2019, 11:02pm UTC](https://uqworld.org/t/after-update-receiving-error-in-uq-blockwise-inverse/238/7 "2019-10-05T23:02:18Z")

</div>

After a fresh install, I still have the same issue. Unfortunately, I can’t upload my code here(due to being a new user, and the training/validation sets are in .csv files). Is there an email address that I can send the files to?

---

<div class="post-metadata">

**Author:** ![damarginal](https://uqworld.org/user_avatar/uqworld.org/damarginal/32/73_2.png) [@damarginal](https://uqworld.org/u/damarginal)\
**Post date:** [October 6, 2019, 10:03pm UTC](https://uqworld.org/t/after-update-receiving-error-in-uq-blockwise-inverse/238/8 "2019-10-06T22:03:24Z")

</div>

Hi @Farshud_Sorourifar, if you zip all the files, how big is it? If it’s still below 4MB, I might be able to give you access to post your file here.

---

<div class="post-metadata">

**Author:** ![Farshud\_Sorourifar](https://uqworld.org/user_avatar/uqworld.org/farshud_sorourifar/32/260_2.png) [@Farshud\_Sorourifar](https://uqworld.org/u/Farshud_Sorourifar)\
**Post date:** [October 6, 2019, 10:41pm UTC](https://uqworld.org/t/after-update-receiving-error-in-uq-blockwise-inverse/238/9 "2019-10-06T22:41:54Z")

</div>

Thank you!  
The zip is less than 1MB, so I could post here

---

<div class="post-metadata">

**Author:** ![damarginal](https://uqworld.org/user_avatar/uqworld.org/damarginal/32/73_2.png) [@damarginal](https://uqworld.org/u/damarginal)\
**Post date:** [October 7, 2019, 7:08am UTC](https://uqworld.org/t/after-update-receiving-error-in-uq-blockwise-inverse/238/10 "2019-10-07T07:08:13Z")

</div>

You should be able to attach the file now, just drag and drop it to your post editor. Don’t forget to explain what’s what if they are not self-explanatory 🙂 . Let me know if it doesn’t work. Thanks!

---

<div class="post-metadata">

**Author:** ![Farshud\_Sorourifar](https://uqworld.org/user_avatar/uqworld.org/farshud_sorourifar/32/260_2.png) [@Farshud\_Sorourifar](https://uqworld.org/u/Farshud_Sorourifar)\
**Post date:** [October 7, 2019, 4:45pm UTC](https://uqworld.org/t/after-update-receiving-error-in-uq-blockwise-inverse/238/11 "2019-10-07T16:45:27Z")

</div>

Thank you! There is a readme.txt in the folder that explains what’s going on, but it is pretty straight forward.

[uqlab\_support.zip](https://uqworld.org/uploads/short-url/7139iNTdNlqBHC8P6DJUd8EoSeU.zip) (692.8 KB)

---

<div class="post-metadata">

**Author:** ![nluethen](https://uqworld.org/user_avatar/uqworld.org/nluethen/32/218_2.png) [@nluethen](https://uqworld.org/u/nluethen)\
**Post date:** [October 7, 2019, 5:36pm UTC](https://uqworld.org/t/after-update-receiving-error-in-uq-blockwise-inverse/238/12 "2019-10-07T17:36:22Z")

</div>

Thanks Farshud! I will have a look at it and come back to you in a few days. 🙂

---

<div class="post-metadata">

**Author:** ![nluethen](https://uqworld.org/user_avatar/uqworld.org/nluethen/32/218_2.png) [@nluethen](https://uqworld.org/u/nluethen)\
**Post date:** [October 7, 2019, 6:25pm UTC](https://uqworld.org/t/after-update-receiving-error-in-uq-blockwise-inverse/238/13 "2019-10-07T18:25:42Z")

</div>

Hi Farshud,

You are right, there is a problem in uq\_lar. For now, it should work if after line 224 of uq\_lar.m  
`i_coeff(i_coeff == idx) = [];`  
you add the line  
`M = pinv(Psi(:,a_coeff)'*Psi(:,a_coeff));`  
(When a basis element is skipped due to instability, of course also the matrix M needs to be updated.)  
We will fix this soon in the code for everyone. Thank you very much for bringing this to our attention!

With this change, your code runs on my computer without problems, also for higher degree PCE. Does it work for you as well?

---

<div class="post-metadata">

**Author:** ![Farshud\_Sorourifar](https://uqworld.org/user_avatar/uqworld.org/farshud_sorourifar/32/260_2.png) [@Farshud\_Sorourifar](https://uqworld.org/u/Farshud_Sorourifar)\
**Post date:** [October 7, 2019, 7:16pm UTC](https://uqworld.org/t/after-update-receiving-error-in-uq-blockwise-inverse/238/14 "2019-10-07T19:16:28Z")

</div>

Yep, that fixed my problems! Thank you so much!

---

<div class="post-metadata">

**Author:** ![nluethen](https://uqworld.org/user_avatar/uqworld.org/nluethen/32/218_2.png) [@nluethen](https://uqworld.org/u/nluethen)\
**Post date:** [October 8, 2019, 2:12pm UTC](https://uqworld.org/t/after-update-receiving-error-in-uq-blockwise-inverse/238/15 "2019-10-08T14:12:51Z")

</div>

Great! 🙂 Good that it works now, and thanks again for making us aware of this issue!

---

<div class="post-metadata">

**Author:** ![damarginal](https://uqworld.org/user_avatar/uqworld.org/damarginal/32/73_2.png) [@damarginal](https://uqworld.org/u/damarginal)\
**Post date:** [October 8, 2019, 2:31pm UTC](https://uqworld.org/t/after-update-receiving-error-in-uq-blockwise-inverse/238/16 "2019-10-08T14:31:50Z")

</div>

Closed on October 8, 2019, 2:31pm UTC


