1. Comparing 2d sequences

How can I compare two 2d sequences dimensioned like this:
repeat(repeat(1,100),100)
        (Each element ranging from 1 to 10, for example)
And create a 2d "mask" sequence with zeros where
the corresponding elements of the 2 sequences are different ?
I'm using the and_bits function but it sometimes (and don't know why)
        give
me something wrong.
        I tried this function:

function compare(sequence seqa,sequence seqb)
    for h=1 to length(seqa) do
        for v=1 to length(seqa[1]) do
            if seqa[h][v] != seqb[h][v] then tmpComp[h][v]=0 end if
        end for
    end for
    return tmpComp
end function

        But it's VERY slow. How can I do this ???

(When each element of the compared sequence is 1 or 2, and_bits work
perfectly...)
                Thanks,

---
Ricardo Niederberger Cabral
<rnc at infolink.com.br>

new topic     » topic index » view message » categorize

2. Re: Comparing 2d sequences

At 17:40 97-06-03 -0300, you wrote:

>How can I compare two 2d sequences dimensioned like this:
>repeat(repeat(1,100),100)
>        (Each element ranging from 1 to 10, for example)


function Compare2D(sequence a, sequence b)
    return not a - b
end function
Jacques Deschenes
Baie-Comeau, Quebec
Canada
desja at quebectel.com

new topic     » goto parent     » topic index » view message » categorize

3. Re: Comparing 2d sequences

At 17:40 97-06-03 -0300, you wrote:

>How can I compare two 2d sequences dimensioned like this:
>repeat(repeat(1,100),100)
>        (Each element ranging from 1 to 10, for example)
>And create a 2d "mask" sequence with zeros where
>the corresponding elements of the 2 sequences are different ?
>        I'm using the and_bits function but it sometimes (and don't know
why) give
>me something wrong.


 OOPS! I forgot the parenthisis,

function Compare2D(sequence a, sequence b)
  return not (a-b)
end function
Jacques Deschenes
Baie-Comeau, Quebec
Canada
desja at quebectel.com

new topic     » goto parent     » topic index » view message » categorize

4. Re: Comparing 2d sequences

> >How can I compare two 2d sequences dimensioned like this:
> >repeat(repeat(1,100),100)
> >        (Each element ranging from 1 to 10, for example)
> >And create a 2d "mask" sequence with zeros where
> >the corresponding elements of the 2 sequences are different ?
> >        I'm using the and_bits function but it sometimes (and don't know
> why) give
> >me something wrong.
> function Compare2D(sequence a, sequence b)
>   return not (a-b)
> end function

        Thank you, but I want to know what is different between two 2D sequences
by reading a "mask" sequence (with the same length of the compared
sequences) where each 0 means that the corresponding element in both
compared sequences are different.


(Sorry if it's not clear, because I'm not a native english speaker)
---
Ricardo Niederberger Cabral
<rnc at infolink.com.br>

new topic     » goto parent     » topic index » view message » categorize

5. Re: Comparing 2d sequences

On Tue, 10 Jun 1997 20:38:15 -0300 Ricardo Niederberger Cabral
<rnc at INFOLINK.COM.BR> writes:

>> function Compare2D(sequence a, sequence b)
>>   return not (a-b)
>> end function
>
>        Thank you, but I want to know what is different between two 2D
>sequences
>by reading a "mask" sequence (with the same length of the compared
>sequences) where each 0 means that the corresponding element in both
>compared sequences are different.
>

Ricardo !!!

Please test the code.
This code does exactly as you ask.
It will return 1's for all that are the same and
return 0's for all that are different.

The logic is

2Dseq = {{1,2},{3,4}} - {{1,1},{6,4}}
--2Dseq now equals {{0,1},{-3,0}}
2Dseq = not 2Dseq
--2Dseq now equals {{1,0},{0,1}}

I did not create this routine BUT
That is how I would have done it my self.

ENJOY.

--Lucius Lamar Hilley III
--  E-mail at luciuslhilleyiii at juno.com
--  I support transferring of files less than 60K.
--  I can Decode both UU and Base64 format.

new topic     » goto parent     » topic index » view message » categorize

6. Re: Comparing 2d sequences

At 20:38 97-06-10 -0300, you wrote:
>---------------------- Information from the mail header -----------------------
>Sender:       Euphoria Programming for MS-DOS <EUPHORIA at
>MIAMIU.ACS.MUOHIO.EDU>
>Poster:       Ricardo Niederberger Cabral <rnc at INFOLINK.COM.BR>
>Subject:      Re: Comparing 2d sequences
>-------------------------------------------------------------------------------
>
>> >How can I compare two 2d sequences dimensioned like this:
>> >repeat(repeat(1,100),100)
>> >        (Each element ranging from 1 to 10, for example)
>> >And create a 2d "mask" sequence with zeros where
>> >the corresponding elements of the 2 sequences are different ?
>> >        I'm using the and_bits function but it sometimes (and don't know
>> why) give
>> >me something wrong.
>> function Compare2D(sequence a, sequence b)
>>   return not (a-b)
>> end function
>
>        Thank you, but I want to know what is different between two 2D
sequences
>by reading a "mask" sequence (with the same length of the compared
>sequences) where each 0 means that the corresponding element in both
>compared sequences are different.
>
>
>(Sorry if it's not clear, because I'm not a native english speaker)
>---
>Ricardo Niederberger Cabral
><rnc at infolink.com.br>
>

If I understood What you meant, it's what it does.

example:

sequence a, b
a = {{5,6,2,3,9},{5,2,6,4}}
b = {{10,1,2,4,9},{5,2,8,4}}

the above funtion applied to a,b  will give: {{0,0,1,0,1},{1,1,0,1}}

if you want that the mask preserve the identicals elements value you simply
multiply the result by one of the compared sequence.

function Compare2D(sequence a, sequence b)
   return (not (a-b))*a
end function

for the same value of a and b as above this function will return:
{{0,0,2,0,9},{5,2,0,4}}

  If it's not what you want  write the result of the function you want
applied to the above a and b and post it here.


Jacques Deschenes
Baie-Comeau, Quebec
Canada
desja at quebectel.com

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu