Conversation
|
Hi @pmli, I see you have added the |
|
Hi @sdrave. I guess it's not necessary. |
|
@sdrave Can |
|
I would say it is perfectly fine to add additional optional arguments to specializations. So, yes. Unless there is a reason to have this for arbitrary backends, I would only add this to |
|
That's a good point about solving shifted systems. Do any PDE libraries support complex valued arrays? Is it realistic that they would add it? If not, I guess the alternative is rewriting complex systems as real systems of double the size. |
|
I did a little research: FEniCS does not support complex vectors, deal.II supports complex vectors but recommends assembling as a real system, DUNE supports complex vectors in general, but this is not very well tested. |
|
So, should I put |
|
For now, I would say, only add it to |
src/pymor/vectorarrays/block.py
Outdated
| return BlockVectorArray([subspace.zeros(count=count, reserve=reserve) for subspace in self.subspaces], self) | ||
| def zeros(self, count=1, reserve=0, dtype=None): | ||
| return BlockVectorArray([subspace.zeros(count=count, reserve=reserve, dtype=None) | ||
| for subspace in self.subspaces], self) |
There was a problem hiding this comment.
If I remember our discussion correctly, zeros should probably have no dtype argument and there should be no dtype=None in the subspace.zeros call?
There was a problem hiding this comment.
I guess we agreed on your option 2 in #333, but then limited dtype in zeros to NumpyVectorArray in this thread. Then I realized that it would make sense that BlockVectorArray.zeros also has dtype if it is created from NumpyVectorArrays. Now I see that this code would not work for arbitrary BlockVectorArray.
I'm not sure what to do here. Should I add a check isinstance(subspace, NumpyVectorSpace), or add dtype everywhere, or remove it from everywhere?
There was a problem hiding this comment.
Then I realized that it would make sense that BlockVectorArray.zeros also has dtype if it is created from NumpyVectorArrays.
Could you give an example?
There was a problem hiding this comment.
Yes, sure. In sys-mor branch, algorithms.sylvester creates an empty vectorarray from A.source. Operator A can be a BlockOperator, e.g. when transforming a second order system into a first order system (see discretizations.iosys.SecondOrderSystem.to_lti).
There was a problem hiding this comment.
Ok, to ask the other way around: Are there situations where it would be crucial to have a dtype argument for zeros or empty? As far as I can see, there are mainly two possibilities:
- automatic type promotion is not allowed for some reason
- automatic type promotion would be to expensive (probably in terms of memory)
There was a problem hiding this comment.
Another possibility is implementing mixed precision algorithms, e.g. switching between single and double precision, but that will probably not happen soon, if ever.
I don't know if automatic type promotion could be prohibitively expensive in practice. So, I guess it is not very crucial to have a dtype argument.
There was a problem hiding this comment.
I would assume that for mixed precision algorithms you would want to have good control where which precision is used, so the precision should probably be part of the VectorSpace. - Since copies are usually relatively cheap, I would agree to remove the dtype argument until we see a specific need for the functionality.
There was a problem hiding this comment.
Ok, good, I will work on the branch this week.
Could you please take a look at the questions in the first post here?
|
Hi @pmli, regarding your questions:
I would say, we should not put any effort into this for now. If we would change this, we should write proper tests. And since I am not aware of anyone really using the code right now, this feels like a waste of effort.
Well, the easiest thing to try would be to add some VectorArray fixtures with complex data in
Yes. I believe we are still waiting for @andreasbuhr, to fully work out a proposal ... |
Conflicts: src/pymor/operators/constructions.py
|
Hi @pmli, I had another look at this PR. Looks fine to me, I only added type Promotion also to |
This pull request is to enable automatic type promotion and correct handling of complex types. This is as discussed in #333, except unlike there, I decided not to include special handling when imaginary part is zero. The main reason is that I noticed that such conditions can be handled in "higher-level" functions (e.g. reductors). Also, it just seems like too much work to do it in all "lower-level" function (e.g. operator and vectorarray methods)...
So far, I only made some changes in
vectorarraysandoperators. @pymor/pymor-devs @andreasbuhr, please check the changes, and see if additional changes are necessary.Besides
vectorarraysandoperators, I noticed one thing inalgorithmswhich should be changed. In line 341 inalgorithms/genericsolvers.py, the assignment doesn't work for complex numbers. Do we want to touch LGMRES code?I haven't noticed any other
ComplexWarnings orTypeErrors (like in #333), but in future, we should probably include tests with complex data (and mixtures or float and complex data). Is this something easy to enable in the current testing framework?There is also a general question of handling complex numbers, like in
dot(see #259). Should this be a separate pull request?