[comp.sys.handhelds] Units

egraeler@uceng.UC.EDU (Eric S Graeler) (01/27/91)

Is there a way to take x_V time y_A and have the result come out xy_W instead
of xy_V*A or is there a way to convert the result into the result so the units
are consolidated.

				Eric Graeler
				egraeler@uceng.uc.edu

edp@jareth.enet.dec.com (Eric Postpischil (Always mount a scratch monkey.)) (01/28/91)

In article <7333@uceng.UC.EDU>, egraeler@uceng.UC.EDU (Eric S Graeler) writes:

>Is there a way to take x_V time y_A and have the result come out xy_W instead
>of xy_V*A or is there a way to convert the result into the result so the units
>are consolidated.

Given n_V*A, you can convert to Watts by pressing left-shift W if that menu is
displayed.  You could write a program that multiplied and attempted to convert
the result to Watts, and you could even assign that program to the * key so it
was executed when you pressed the key.  My 48's been shipped to HP for an
upgrade, or I'd help you out some more with code.  Send mail if you do need more
help.


				-- edp (Eric Postpischil)
				"Always mount a scratch monkey."
				edp@jareth.enet.dec.com

egraeler@uceng.UC.EDU (Eric S Graeler) (01/31/91)

>>Is there a way to take x_V time y_A and have the result come out xy_W instead
>>of xy_V*A or is there a way to convert the result into the result so the units
>>are display as xy_W

To be more specific I was wondering if there is a way to have any given unit
expression be compressed to it most simple(complex?) form.

I guess I want a function that is the opposite of 'UBASE' .  That is if you
take the UBASE of V*A or W you get kg*m^2/s^3.  Is there a way to make
kg*m^2/s^3 get converted back into W, or perform the converse of 'UBASE' on
any other unit expression.

Eric Graeler
egraeler@uceng.uc.edu

ares@alessia.dei.unipd.it (Nicola Catacchio 259126) (02/22/91)

In article <7343@uceng.UC.EDU>, egraeler@uceng.UC.EDU (Eric S Graeler) writes:
>>>Is there a way to take x_V time y_A and have the result come out xy_W instead
>>of xy_V*A or is there a way to convert the result into the result so the units
>>>are display as xy_W
> To be more specific I was wondering if there is a way to have any given unit
> expression be compressed to it most simple(complex?) form.
	The first problem is to know what you want from it: and I think the
problem was well defined.
	This problem has two possible answers: the first easy, the other
not so much.
	The first one involves vectors algebra; you must consider the unit
as a vector whose components are the powers which each S.I. unit composing
your unit is raised to: I think that you can get this representation with a
routine posted on this group some time ago.
	Example : the unit V (volts) that, in S.I. has the expression
kg*m^2/(A*s^3),must be expressed in this way : 
			[2 -3  1 -1 0] 	Where:
meters___________________^  ^  ^  ^ ^-------------------cd     
     seconds________________|  |  |__________amperes
                          kilograms
	Then, define a matrix in which every column is composed by the powers
describing as shown above the units you want to get the final result : given  
some condition on this matrix ( it must be nxn (square?) and its determinant
be not equal to zero),you can get the correct powers you need to raise your
'custom units' simply by dividing that vector by this matrix.
	In this way the powers appear in the resulting vector in the same
order the units to which they are  associated are described in the matrix.
	So, you have to choose the units you want to be used, describe
them as a vector, and assemble n vectors (n=number of S.I. units) to get
the matrix to re-arrange the units representation.
	If in the representation you don't make use of some of those 
S.I. units ,simply add to your matrix a 0s column with a 1 in the position 
corresponding to the unit you don't need: i.e. in some calculation
of electrical units, you may need to express Volts and Watts instead
of kilograms and Amperes: the transposed (TRN) matrix will be
Volts			[[ 2  -3   1  -1   0 ]
Watts			 [ 2  -3   1   0   0 ]
Seconds			 [ 0   1   0   0   0 ]
Meters			 [ 1   0   0   0   0 ]
Candela 		 [ 0   0   0   0   1 ]]

	This system is fast but has a limitation: the max number of units
availables can't be greater than five!
	I think that what you meant was a program that, in some way,
make a choice between a certain number of possible equivalent representations
of the unit picking up the shorter or so.
	This is a VERY difficult problem.
	You need a sort of 'branch and bound' algorithm that analises a tree
with ALL the possible expressions of a certain unit that can be a VERY
large number.
	Maybe a sort of euristic algorithm can be found, but the problem 
itself is still very complicate.

	Nicola Catacchio
				ares@alessia.dei.unipd.it