Non square matrix error

getting non-square matrices in error #1575

Comments

I’m trying to solve a generalized eigenvalue problem Av = eBv where v = [w; b] and both w and b are functions. The script:

returns the error

indicating that A and B are not square. They should be. Note the term 0*diff(b,2) in the definition for matrix A. This is done to make sure that b is interpreted as a function and not a scalar (rather then hack in chebop/linearize.m as suggested in #1566 that if used gives the same error as above).

FYI, this eigenvalue problem is a version the Taylor-Goldstein equation that is linear, rather than quadratic, in the eigenvalue.

Any suggestions of where I have gone wrong would be helpful.

The text was updated successfully, but these errors were encountered:

@nickhale @tobydriscoll would you have expected this to work, i.e. should the projection algorithm for linear operators be able to deal with this?

In line 368 of @linop/eigs , which is the culprit for crashing and reads

I have just before the crash

Also, at that time, we have

A simpler version of the code that I could get to crash with the same error is:

I’m a bit confused by your first question. If you are asking if the problem is correctly posed, the answer is yes. I have solved the same equations using standard finite-difference matrix methods in matlab.

I also tried your slimmed down version of the problem and got the same error again, as did you. It seems to me that the problem has to do with the incorporation of the boundary conditions, that according to my slowly growing understanding of chebfun, should result in square matrices. But this is deep enough in chebfun that I can’t easily see where the problem might be.

@asgeirbirkis @khelfrich Has this problem been resolved? I am working on a similar problem and finding the same error.

For future readers: I believe this problem has to do with the fact that @khelfrich is imposing two boundary conditions on b even though no derivatives in b exist in this problem. I do not think the introduction of the 0.*diff(b,2) term solves this problem. It probably introduces NaNs which the eigs function is attempting to eliminate or ignore in the projection. In other words, even though this problem may be well-posed and compatible with finite-difference methods, the spectral methods used in Chebfun lead to issues. The «N minus 2» rank phenomenon is common in incompressible spectral CFD formulations, particularly when pressure is involved. I suspect that is the issue here.

READ  Tvip 530 прошивка android

I have not yet resolved my issue, but it is very closely related to the above.

Bottom line: I believe the problem here is not with the algorithm, but rather with well-posedness. However, I believe Chebfun could be a bit more informative and helpful when it encounters this error.

I too am having a similar problem, it still seems the example by @asgeirbirkis does not work in chebfun.

Do we have to just accept this kind of problem can’t be solved in Chebfun?

@chebfunuser is correct: the 0.*diff(b,2) term does not fool chebop in to thinking the problem is second-order in b and hence giving a square system. However, you can fool it by using realmin*diff(b, 2) , i.e.,

© 2023 GitHub, Inc.

You can’t perform that action at this time.

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.

Источник

Non square matrix error

I’m not sure, but if X is a vector, shouldn’t X^2 give the same result as X*X?

I think Mathcad is doing wrong here, as squaring should be interpreted as scalar product.

The vector with each element squared I would only expect as a result when I use vectorize.

Or am i missing the point?

BTW, the effect is the same in MC15 and Prime2.

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Notify Moderator

If you vectorize X*X you match x^2

Isn’t a dot product suppose to provide a scalar?

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Notify Moderator

Isn’t a dot product suppose to provide a scalar?

Yes, thats exactly what I was talking about. I’d expect to be X^2 a scalar, too.

In my opinion itt should only be the vectorization which applies the operation singly to each element.

X^(-1) should return an error, if X is not a square matrix, etc.

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Notify Moderator

When X is a column vector, then X*X should return an error if Mathcad were complying with the normal rules of vector multiplication. However, all versions of Mathcad I’m aware of (going back to 3) have deliberately chosen to treat X*X as though it were the transpose of X (ie a row vector) multiplied by X, and have chosen to implement X^2 as an element by element operation. These are not strictly errors, but choices (poor choices possibly, but deliberate!).

If you let X be a non-square matrix (rather than a single-column vector) you get the expected error message for both X*X and X^2.

READ  Ramos mos1 max прошивка

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Notify Moderator

Thanks for your explanations, Allan.

In one point I don’t agree. Let X be a column vector, so X^T*X (interpreted as a matrix product) should (it doesn’t in MC) return a 1×1 matrix, while the scalar product X*X is supposed to return a scalar.

It’s OK that Mathcad does not provide different operators for matrix product and dot product (while it could) and defaults to dot (scalar) product in the case of X*X.

The surprising part for me was that automatic vectorizing and therefore the difference between X*X and X^2. But I could image that its more convenient in some situations to have that auto vectorizing done rather than being confronted with an error.

Funny I didn’t stumbled upon this much sooner. Maybe I did and haven’t thought enough about it.

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Notify Moderator

Werner Exinger wrote:

Thanks for your explanations, Allan.

In one point I don’t agree. Let X be a column vector, so X^T*X (interpreted as a matrix product) should (it doesn’t in MC) return a 1×1 matrix, while the scalar product X*X is supposed to return a scalar.

Yes; for consistency, X^T*X should be a 1×1 matrix, which, in Mathcad, is different from a scalar (personally, I prefer to think of a 1×1 matrix as a scalar!).

I guess Mathcad takes the approach it does here because it doesn’t consider row vectors to be true vectors (most «vector» operators in Mathcad don’t work on row vectors). Coming from a Matlab background I find this annoying — but I’ve learned to live with it over the years!

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Notify Moderator

Yes; for consistency, X^T*X should be a 1×1 matrix, which, in Mathcad, is different from a scalar (personally, I prefer to think of a 1×1 matrix as a scalar!).

I guess Mathcad takes the approach it does here because it doesn’t consider row vectors to be true vectors (most «vector» operators in Mathcad don’t work on row vectors). Coming from a Matlab background I find this annoying — but I’ve learned to live with it over the years!

Yes Alan (sorry for the double «l» in the last post), I agree and usually consider a 1×1 matrix a scalar myself, too. Just was doing some hair splitting

The inability of MC to accept row vectors is annoying but usually can be worked around using transpose quite well.

Wonder if Prime will be doing better in that respect — at least we sem to be able to extract rows equally easy from matrices as columns now.

Источник

Non square matrix error

Success! Subscription added.

Success! Subscription removed.

READ  Philips 47pfl6097t 60 прошивка

Sorry, you must verify to complete this action. Please click the verification link in your email. You may re-send via your profile.

  • Intel Communities
  • Developer Software Forums
  • Toolkits & SDKs
  • Intel® oneAPI Math Kernel Library
  • Re: PDSYRK causes MPI_Abort on non square matrices

PDSYRK causes MPI_Abort on non square matrices

  • Subscribe to RSS Feed
  • Mark Topic as New
  • Mark Topic as Read
  • Float this Topic for Current User
  • Bookmark
  • Subscribe
  • Mute
  • Printer Friendly Page
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

In the file that I am attaching, I am simply trying to compute the matrix multiplication A^T*A using the scalapack routine PDSYRK . Matrix A is randomly generated in row major order, and since scalapack uses column major order, I am calling pdsyrk_ in the non-transpose mode. The program works when A is a square matrix, but it calls MPI_Abort (error code -8) when I run it on non-square matrices.

What am I doing wrong?

Code Samples

Error

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

Thanks for providing the source code and commands to reproduce the error.

We are able to reproduce the error which you are facing.

For Non-Square Matrix, use Transpose mode in the PDSYRK API call. We tried to run the code in Transpose mode and it is working.

Источник

RGA, non-square matrix inverse

0 Comments

Accepted Answer

0 Comments

More Answers (0)

See Also

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Americas

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文 Chinese
    • English
  • 日本 Japanese (日本語)
  • 한국 Korean (한국어)

Accelerating the pace of engineering and science

MathWorks is the leading developer of mathematical computing software for engineers and scientists.

Источник

Smartadm.ru