Re: Dimension of sequences

new topic     » goto parent     » topic index » view thread      » older message » newer message

Hello Al,

Al Getz wrote:
> 
> Fernando Bauer wrote:
> > 
> > Al Getz wrote:
> > > 
> > > Hello again,
> > > 
> > 
> > Hello Al! Thanks for your comments.
> > 
> > > 
> > > The game of chess if often referred to as having move sequences that
> > > exist on the edge of a multi-dimensional object, so i suppose
> > > you could say the same thing about a sequence.
> > > 
> > 
> > Sorry, I didn't understand this.
> > 
> > > My question would be say you defined the 'dimension' of a sequence
> > > as the product of the max of all the inner sequences written out
> > > such as 1x2x3 as is sometimes customary with arrays.  What would
> > > you use this information for in a program?
> > > 
> > 
> > Examples:
> > a)A 2D sequence (a matrix) can represent a system of simultaneous linear
> > equations.
> > Then, you can use your description (a x b) to find out if the system has
> > possibly
> > none, one or many solutions.
> > b)To know if a sequence represent a square matrix. For example, to know if
> > you
> > can calculate its determinant.
> > 
> > > When i did my jpeg decoder program in Euphoria i used sequences
> > > like arrays where every level had the same length:
> > >   s=repeat(0,10)
> > >   s=repeat(s,4)
> > >   s=repeat(s,9)
> > >   s=repeat(s,5)
> > > and this builds up a structure similar to a C style array where
> > > every level has the same length.
> > 
> > That is what I'm calling rectangular sequence. Perhaps we could call it
> > "array
> > sequence".
> > 
> > >  The above code creates 5 
> > > three dimensional 'arrays' that can be accessed by index.
> > > I would have no problem calling this a 10x4x9x5 or a 5x9x4x10
> > > 'sequence', 
> > 
> > Ok, you can call this way, but this isn't the dimension that I was talking
> > about.
> > This is the number of atoms (after you compute the product).
> > 
> > >but the actual common useage seems to be to use
> > > every element, but then again i could easily see an app that
> > > although includes a given element, does not in fact use that
> > > element in the program, ever, and of course the implication of
> > > this is that an element missing altogether (only possible with 
> > > a sequence) does not necessarily decrease the length because
> > > the other sequences at the same level contain more elements:
> > >   s={
> > >       {1,2,3,4},
> > >       {5,6,7}
> > >     }
> > > is still a 2x4 sequence.
> > > 
> > 
> > If this is true, why *can't* I sum, subtract, multiply, etc, sequences with
> > the same description ?
> > The information of the structure of the sequence is lost in that
> > representation.
> > I think if you eliminate an atom of a retangular sequence (array sequence),
> > it can't have the same description any longer.
> > 
> > > If you want to get more detailed, you might have to start enumerating
> > > every element and returning a sequence that corresponds to that
> > > sequence.  As with the above, this would be:
> > >   m={4,3}
> > > I guess this would simply be a sequence with the lengths of all 
> > > first level sequences arranged in the same structure as the
> > > original sequence, which would still have to be perused.
> > > Again i would have to wonder about how useful this would be unless
> > > the sequence isnt that big.  For example, "When do i need to know
> > > the actual structure of the sequence in full?"
> > > 
> > 
> > To serialize sequences, which is necessary in several situations: saving and
> > restoring sequences to/from files, transmission of sequences via serial
> > networks.
> > 
> > > Some applications would be interesting to hear about at this point.
> > >
> > 
> > Any application that uses EDS, save and restore the full structures of
> > sequences
> > to/from the database.
> >  
> > > 
> > > Al
> > > 
> > > E boa sorte com sua programacao Euphoria!
> > 
> > Obrigado. Para voce tambem!
> > 
> > > 
> > > My bumper sticker: "I brake for LED's"
> > > 
> > 
> > Regards,
> >    Fernando
> 
> Hi Fernando,
> 
> Ok, since you seem to have shown that there would be some use lets
> look a little farther...
Ok. But just to be clear: you are talking about structure of sequences, and my
original question is about "dimension" of sequences (or "Depth" as Igor prefers).

> 
> First off, i made a mistake when i showed the possible detailed
> dimensions for the sequence
>   s={
>       {1,2,3,4},
>       {5,6,7}
>     }
> 
> which should probably be more like this:
>   m={2,{4,3}}
> 
> but does this even really work for all sequences?
> Also notice this will get a little hard to read too, almost
> as bad as trying to find the individual lengths of the original
> sub sequences and if there even are any.
> 
> I did a math program a while back that used matrixes too, and what
> i did to see if one matrix was compatible with another was to test
> for the two dimensions (or only one if needed).  For
>   s={{1,2},{3,4},{5,6}}
> the two tests would be
>   v=length(s)
> and
>   h=length(s[1])
> With this info i was able to tell if a multiplication could
> be done with either a vector or another matrix, or if the
> maxtrix was square, or even if the matrix was really a vector.
> 
> Going to one more dimension, you probably have this being application
> specific where you know in advance that all the sub sequences are
> matixes and you have to test them as any other one, except first
> you have to extract the individual matrix:
>   s={{1,2},{3,4},{5,6}}
>   MyMatrixes={s,s,s}
>   for k=1 to length(MyMatrixes) do
>     Dims=Test(MyMatrixes[k])
>   end for
> 
> Compare two more complex matrixes:
>   s={1,{2,3},4,5}
>   t={1,2,{3,4},5}
> 
> How do we indicate the dims without repeating almost the
> whole sequence?
>  ms={1,2,1,1}
>  mt={1,1,2,1}
> perhaps?
Using your concept of dim, I think it's more correct:
ms = {a,2,a,a}
mt = {a,a,2,a}

where a = dim of an atom. (a!= 0) because the dim of {} is zero.

> 
> Then the matrix might be even more complex:
>   s={1,{2,{3,6}},4,5}
> and dims:
>   m={1,{1,{2}},1,1}
> and reading or parsing the dims sequence might be almost as hard
> as parsing the original sequence to query its dimensions.
> 
> On the other hand, if we do define the dims as the set of
> max dims we might end up with something like this:
>   m={4,{2{1}}}
> which is at least a bit simpler than the original sequence.
> 
> BTW, by 1x2x3 that doesnt mean multiply all the numbers to get 6,
> but rather shows the dimensions in the same way that the dimensions
> of C arrays.  The numbers dont get multiplied but stay separate:
>   (1,2,3)
Yes. I said that because in Euphoria 1x2x3 is an expression which results in an
atom.
Then it would be more correct to say, for example, {1,2,3} in this case.

> 
> Lastly, you'd have to think about how this is going to be 
> implemented in the language.  During the build of any sequence
> the dimension array would have to be maintained and this would
> slow down the sequence a bit more too.  You'd have to see just
> how much effect this would have on the overall speed.
> 
> 
> Al
> 
> E boa sorte com sua programacao Euphoria!
> 
> 
> My bumper sticker: "I brake for LED's"
> 

Regards,
   Fernando

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu