math oriented script

math oriented script

am 04.04.2008 00:09:40 von RickM

I have a file that looks lik this:

dbRestorePin _cell "datainref[10]" "datainref[10]" 1 34 0 0 35
'((-11.500 163.490) (-11.300 163.690)) _cellname
dbRestorePin _cell "datainm[3]" "datainm[3]" 1 34 0 0 35 '((-11.500
140.530) (-11.300 140.730)) _cellname
dbRestorePin _cell "datainm[7]" "datainm[7]" 1 34 0 0 35 '((-11.500
143.810) (-11.300 144.010)) _cellname
dbRestorePin _cell "resetn" "resetn" 1 34 0 0 35 '((988.300 114.290)
(988.500 114.490)) _cellname

I need to subtract 0.1 from the first group
^^^^^^^^^^^^^^

and add .1 to the second
group
^^^^^^^^^^^^^^

Any suggestions would be appreciated

Thanks

Rick

Re: math oriented script

am 04.04.2008 03:09:26 von Ed Morton

On 4/3/2008 5:09 PM, rickm@galaxy.nsc.com wrote:
> I have a file that looks lik this:
>
> dbRestorePin _cell "datainref[10]" "datainref[10]" 1 34 0 0 35
> '((-11.500 163.490) (-11.300 163.690)) _cellname
> dbRestorePin _cell "datainm[3]" "datainm[3]" 1 34 0 0 35 '((-11.500
> 140.530) (-11.300 140.730)) _cellname
> dbRestorePin _cell "datainm[7]" "datainm[7]" 1 34 0 0 35 '((-11.500
> 143.810) (-11.300 144.010)) _cellname
> dbRestorePin _cell "resetn" "resetn" 1 34 0 0 35 '((988.300 114.290)
> (988.500 114.490)) _cellname
>
> I need to subtract 0.1 from the first group
> ^^^^^^^^^^^^^^
>
> and add .1 to the second
> group
> ^^^^^^^^^^^^^^
>
> Any suggestions would be appreciated

Explain what a "group" is and show some expected output for the above input.
Also, tell us if there's line-wrapping in the above.

Ed.

Re: math oriented script

am 04.04.2008 16:21:07 von RickM

The formating of the original post is not right. Heres a second
try.

1) There are no wraps
2) The groups are -11.500 163.490 which are pointed out with the
^^^^^^

I have a file that looks lik this:

dbRestorePin _cell "datainref[10]" "datainref[10]" 1 34 0 0 35
'((-11.500 163.490) (-11.300 163.690)) _cellname
dbRestorePin _cell "datainm[3]" "datainm[3]" 1 34 0 0 35 '((-11.500
140.530) (-11.300 140.730)) _cellname

I need to subtract 0.1 from the first
group ^^^^^^^^^^^^^^
and add .1 to the second
group
^^^^^^^^^^^^^^

> Explain what a "group" is and show some expected output for the above input.
> Also, tell us if there's line-wrapping in the above.
>
> Ed.

Re: math oriented script

am 04.04.2008 16:25:04 von RickM

The formating is still wrong, hopefully this makes sense anyway.


On Apr 4, 7:21 am, ri...@galaxy.nsc.com wrote:
> The formating of the original post is not right. Heres a second
> try.
>
> 1) There are no wraps
> 2) The groups are -11.500 163.490 which are pointed out with the
> ^^^^^^
>
> I have a file that looks lik this:
>
> dbRestorePin _cell "datainref[10]" "datainref[10]" 1 34 0 0 35
> '((-11.500 163.490) (-11.300 163.690)) _cellname
> dbRestorePin _cell "datainm[3]" "datainm[3]" 1 34 0 0 35 '((-11.500
> 140.530) (-11.300 140.730)) _cellname
>
> I need to subtract 0.1 from the first
> group ^^^^^^^^^^^^^^
> and add .1 to the second
> group
> ^^^^^^^^^^^^^^
>
> > Explain what a "group" is and show some expected output for the above input.
> > Also, tell us if there's line-wrapping in the above.
>
> > Ed.

Re: math oriented script

am 04.04.2008 16:53:02 von Ed Morton

On 4/4/2008 9:25 AM, rickm@galaxy.nsc.com wrote:
> The formating is still wrong, hopefully this makes sense anyway.
>
>
> On Apr 4, 7:21 am, ri...@galaxy.nsc.com wrote:
>
>>The formating of the original post is not right. Heres a second
>>try.
>>
>>1) There are no wraps

So your input with line numbers added in front is:

1 dbRestorePin _cell "datainref[10]" "datainref[10]" 1 34 0 0 35
2 '((-11.500 163.490) (-11.300 163.690)) _cellname
3 dbRestorePin _cell "datainm[3]" "datainm[3]" 1 34 0 0 35 '((-11.500
4 140.530) (-11.300 140.730)) _cellname

Right? That seems to be 2 "records". Is each record always split over exactly 2
lines? If not how can we tell the start/end of each record (e.g. maybe they go
from "dbRestorePin" to "_cellname")?

>>2) The groups are -11.500 163.490 which are pointed out with the
>>^^^^^^

I see some "^^^^^"s but they don't seem to line up with anything.

Is it true that in this record:

dbRestorePin _cell "datainref[10]" "datainref[10]" 1 34 0 0 35
'((-11.500 163.490) (-11.300 163.690)) _cellname

the first group is "-11.500 163.490" and the second group is "-11.300 163.690"
while in the second record:

dbRestorePin _cell "datainm[3]" "datainm[3]" 1 34 0 0 35 '((-11.500
140.530) (-11.300 140.730)) _cellname

the first group is "-11.500 140.530" and the second group is "-11.300 140.730"?

>>I have a file that looks lik this:
>>
>> dbRestorePin _cell "datainref[10]" "datainref[10]" 1 34 0 0 35
>>'((-11.500 163.490) (-11.300 163.690)) _cellname
>> dbRestorePin _cell "datainm[3]" "datainm[3]" 1 34 0 0 35 '((-11.500
>>140.530) (-11.300 140.730)) _cellname
>>
>> I need to subtract 0.1 from the first
>>group ^^^^^^^^^^^^^^
>> and add .1 to the second
>>group
>>^^^^^^^^^^^^^^

How do you subtract from a group? Do you want to subtract from each number in
each group so your expected output would be:

1 dbRestorePin _cell "datainref[10]" "datainref[10]" 1 34 0 0 35
2 '((-11.600 163.390) (-11.200 163.790)) _cellname
3 dbRestorePin _cell "datainm[3]" "datainm[3]" 1 34 0 0 35 '((-11.600
4 140.430) (-11.200 140.830)) _cellname

If any of that is wrong, do what I suggested here:

>>>Explain what a "group" is and show some expected output for the above input.

Regards,

Ed.

>>>Also, tell us if there's line-wrapping in the above.
>>
>>> Ed.
>>
>

Re: math oriented script

am 04.04.2008 22:29:18 von wayne

Ed Morton wrote:
>
> On 4/3/2008 5:09 PM, rickm@galaxy.nsc.com wrote:
>> I have a file that looks lik this:
>>
>> dbRestorePin _cell "datainref[10]" "datainref[10]" 1 34 0 0 35
>> '((-11.500 163.490) (-11.300 163.690)) _cellname
>> dbRestorePin _cell "datainm[3]" "datainm[3]" 1 34 0 0 35 '((-11.500
>> 140.530) (-11.300 140.730)) _cellname
>> dbRestorePin _cell "datainm[7]" "datainm[7]" 1 34 0 0 35 '((-11.500
>> 143.810) (-11.300 144.010)) _cellname
>> dbRestorePin _cell "resetn" "resetn" 1 34 0 0 35 '((988.300 114.290)
>> (988.500 114.490)) _cellname
>>
>> I need to subtract 0.1 from the first group
>> ^^^^^^^^^^^^^^
>>
>> and add .1 to the second
>> group
>> ^^^^^^^^^^^^^^
>>
>> Any suggestions would be appreciated
>
> Explain what a "group" is and show some expected output for the above input.
> Also, tell us if there's line-wrapping in the above.
>
> Ed.
>

Use regular expressions (perl or awk) to isolate the numbers.
then add/subtract from them, and write out the result.

It seems the numbers are in
blah blah ( (num1 space num2 ) (num3 space num4 ) ) blah blah

and you want to subtract 0.1 from num1 and num2, while adding
0.1 to num3 and num4.

If that is all correct, here's some code to do this:

while ( <> ) {
/^(.*\(\()(-?\d+\.\d+) (-?\d+.\d+)(\) +\()(-?\d+\.\d+) (-?\d+\.\d+)(.*)$/;
my $num1 = $2 - 0.1;
my $num2 = $3 - 0.1;
my $num3 = $5 + 0.1;
my $num4 = $6 + 0.1;
printf( "%s%.3f %.3f%s%.3f %.3f%s\n", "$1", "$num1", "$num2",
"$4", "$num3", "$num4", "$7" );
}

Ugly, but I'm no Perl or RE expert. And it does seem to work on your test data.
If you need a POSIX solution use similar code for AWK.

-Wayne