Hi all,
-- For many applications it is nice to be able to operate on vector slices instead of the whole vector. For example, computing the mass balance for diffusion (in 1D) can be expressed as: v[internals] = D[internals] *. (c[1:butSecondLast] - 2 * c[internals] + c[3:last]) / (dx[internals] *. dx[internals]) With v[1] and v[last] to be specified by boundary conditions. So, first, is there such a facility now and I just can't see it? If not, what can be the best way of implementing it? I thought of creating class PMVectorSlice that contains a point to original vector and the vector of indices. So, every `v at:n` for a slice `v` will translate to `contents at: (indices at: n)`, where `contents` is the pointer to the original vector. The only problem I see with this is that `DhbVector` is an `Array` with all nice features and iterators coming with it, and I'm not sure how to achieve this for the slice. Unless, we don't pretend that slice a is a vector in full rights, and only limited operations are available for it. Cheers, Alexey You received this message because you are subscribed to the Google Groups "SciSmalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
Hi Alexey, wouldnt it be better if the slice would again be a PMVector so that it will be usable in the usual way? for example you could make PMVectorSlice a factory that spits out vectors or simply add an instance creation method on the class side of PMVector. wouldnt that be enough?On Mon, Apr 11, 2016 at 10:25 AM, Alexey Cherkaev <[hidden email]> wrote:
You received this message because you are subscribed to the Google Groups "SciSmalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
and there already is a facility to do this: a:=#(1 2 33 4 5)asDhbVector . "a DhbVector(1 2 33)" a copyFrom: 2 to:3. "a DhbVector(2 33)" On Mon, Apr 11, 2016 at 1:54 PM, werner kassens <[hidden email]> wrote:
You received this message because you are subscribed to the Google Groups "SciSmalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
and i wouldnt duplicate a rather standard method like copyFrom:To: (which has 422 senders)
-- werner You received this message because you are subscribed to the Google Groups "SciSmalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
In reply to this post by werner kassens-2
Hi Werner,
-- On 11 April 2016 at 13:54, werner kassens <[hidden email]> wrote:
I guess I want the slice to be lvalue: in the example below, `v[internals]` is only a part of the vector, `v[1]` and `v[last]` still need to be assigned. Making a slice a proper vector would mean I would need to reassemble the final vector.
Cheers, Alexey You received this message because you are subscribed to the Google Groups "SciSmalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
In reply to this post by werner kassens-2
On 11 April 2016 at 14:10, werner kassens <[hidden email]> wrote:
I think closer to what I want is `#replaceFrom:to:with:`: I can assign internal points with it and can deal with external points separately. You received this message because you are subscribed to the Google Groups "SciSmalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
yes indeed. wernerOn Mon, Apr 11, 2016 at 2:22 PM, Alexey Cherkaev <[hidden email]> wrote:
You received this message because you are subscribed to the Google Groups "SciSmalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
On Monday, April 11, 2016 at 2:24:09 PM UTC+2, werner kassens wrote:
It's taking a while getting used to different conventions: in Matlab/Scilab slices are what you would use; they even have special syntax for them. You received this message because you are subscribed to the Google Groups "SciSmalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
yes, of course <friendly grin>. sometimes it simply helps talking a bit and occasionally one knows the answer to a question, one posts, the moment one presses the send button <grin>. wernerOn Mon, Apr 11, 2016 at 4:07 PM, Alexey Cherkaev <[hidden email]> wrote:
You received this message because you are subscribed to the Google Groups "SciSmalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
In reply to this post by Alexey Cherkaev
A vector slice is just a subspace defined by a matrix (a projection). So, I would not create a special method, but a factory of projection matrix on a desired space (slice). Cheers, Didier On Mon, Apr 11, 2016 at 10:25 AM, Alexey Cherkaev <[hidden email]> wrote:
You received this message because you are subscribed to the Google Groups "SciSmalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
Free forum by Nabble - Scala forum | Edit this page |