using sparse matrix and vpa function simultaneously
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Shreechandan
el 15 de Feb. de 2025
Comentada: Walter Roberson
el 17 de Feb. de 2025
i am using the following code in my 3D FEM analysis
digits(16)
k_bc=vpa(k_bc);
U=k_bc\f_bc.
residual=norm(k_bc*U-f_bc).
Now to decrease the residual i have taken the variable to symbolic domain.Now when i use vpa i loose my sparcity of stiffness matrix causing a slow calculation rate but give lower value of residual and when i use sparse matrix the residual value is high because of the large condition number of k_bc of the order 10e14(i think it is a result of lagrange shape function beig used in Galerkin's FEM).how to use both sparcity and vpa simultaneously to have lowervalue to residual and still have higher speed
0 comentarios
Respuesta aceptada
John D'Errico
el 15 de Feb. de 2025
Editada: John D'Errico
el 16 de Feb. de 2025
I wanted a nice bright red Lambo for Christmas. Nope. Did not happen, nor was it ever going to happen. The same applies to you. You can want whatever you want, but that does not mean it is possible, at least not in the near future.
Sparse matrices are not supported for symbolic computations. And VPA is a purely symbolic thing. Why would they not mix sparse and symbolic? Because there is little gain to be had from the mixture. If your matrix is sparse, then adding or multiplying zero to a non-zero element costs essentially nothing in time. (It is only on truly large sparse matrices that there is even a gain in terms of double precision.) And if there is no perceived gain, then The MathWorks will not see any gain to be had by investing a significant amount of their programming resources on something that will offer little gain to their clients.
You might hope beyond hope that MathWorks decides to implement a quad precision option one day, and include sparse matrices in that. This is not a totally impossible hope. If you really, really need it, then you can try sending in a request to tech support. If nobody ever asks for some capability, they will never bother to provide it. And that is far more likely to succeed, since there are already in existence quad procision libraries available. All they would need to do then is link in the right libraries. (To implement a symbolic sparse capability (i.e., that allows VPA) would mean they would need to wwrite it ALL. And that would be one hell of a lot more work.) So send in a feature request to MathWorks. It can't hurt.
If you really truly need this tomorrow, then you will need to go outside of MATLAB, calling in the code for those quad precision libraries yourself. You would need to call them in Fortran or C, compiled as mex.
I'm sorry. You can always hope for next year, just like I can hope for that Lamborghini under the tree next year. Yeah, right. Can you imagine trying to drive it on the dirt road to my home? It would get lost in the potholes. ;-(
Seriously, you can have a fast result, or a good result. I'd suggest just getting a large cup of coffee while you wait for the good result. Pop open the largest book you have, and dive in while it cooks.
2 comentarios
Walter Roberson
el 17 de Feb. de 2025
Why not work with vpa in an academic environment if you need it to meet your goals ?
You could try https://blogs.mathworks.com/cleve/2017/05/22/quadruple-precision-128-bit-floating-point-arithmetic/ which would be significantly slower than double precision, but just might be faster than vpa(). It does not have sparse support.
Más respuestas (1)
Walter Roberson
el 15 de Feb. de 2025
Sparse matrices are implemented for double precision, and for logical. As of R2025a Pre-Release they are also implemented for single precision.
Sparse matrices are not implemented for any other numeric type, or for object classes such as symbolic expressions.
Ver también
Categorías
Más información sobre General Applications en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!