Date: Fri, 22 Feb 1991 14:48 CST Subject: Re: Units Organization: DEI Padova University Summary: The solution (?) Lines: 57 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