[GENERAL] Extended unit

2005-01-25 Thread Pailloncy Jean-Gerard
Hi, My question is purely theoretical. I add use in my time in University some software that use "extended type". For each variable, we define the mandatory "classic type" as integer, float, double array of. And we define an optional "extended type" as the unit in the MKSA system (Meter, Kilogra

Re: [GENERAL] Extended unit

2005-01-25 Thread Martijn van Oosterhout
On Tue, Jan 25, 2005 at 10:40:15AM +0100, Pailloncy Jean-Gerard wrote: > Hi, > > My question is purely theoretical. > > I add use in my time in University some software that use "extended > type". > For each variable, we define the mandatory "classic type" as integer, > float, double array of.

Re: [GENERAL] Extended unit

2005-01-25 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2005-01-25 10:40:15 +0100: > I add use in my time in University some software that use "extended > type". > For each variable, we define the mandatory "classic type" as integer, > float, double array of. > And we define an optional "extended type" as the unit in the MKSA >

Re: [GENERAL] Extended unit

2005-01-25 Thread Pailloncy Jean-Gerard
Is CREATE TYPE what you're looking for? http://www.postgresql.org/docs/8.0/static/sql-createtype.html No. I'll try to give an exemple of what I want: I suppose I have the following table CREATE TABLE experiment ( distanceDOUBLE, timeDOUBLE, speed DOUBLE )

Re: [GENERAL] Extended unit

2005-01-25 Thread Alban Hertroys
Martijn van Oosterhout wrote: On Tue, Jan 25, 2005 at 10:40:15AM +0100, Pailloncy Jean-Gerard wrote: This "extended type" was wonderful, because there was warning/error if "extend type" does not match in any computation: you can not add apple to orange. I think it's a wonderful idea. You could u

Re: [GENERAL] Extended unit

2005-01-25 Thread Martijn van Oosterhout
On Tue, Jan 25, 2005 at 05:17:21PM +0100, Alban Hertroys wrote: > Martijn van Oosterhout wrote: > >I think it's a wonderful idea. You could use a similar mechanism to > >implement: > > > >- Currencies (so you can't add dollars to pounds) > >- Timezone aware timestamps (so a time in Australia looks

Re: [GENERAL] Extended unit

2005-01-25 Thread Tom Lane
Martijn van Oosterhout writes: > We're talking here about a database with indexes to speed up > intersection tests for arbitrary polygons, extensions to handle > encryption, full text indexing and even builtin XML support. ... none of which require any extensions to the core type system. AFAICS

Re: [GENERAL] Extended unit

2005-01-25 Thread Martijn van Oosterhout
On Tue, Jan 25, 2005 at 02:31:40PM -0500, Tom Lane wrote: > AFAICS this could easily be implemented as a user-defined type, along > the lines of > > CREATE TYPE measurement AS (value double, units text); > > and if you want to constrain a particular column to contain only one > value of uni

Re: [GENERAL] Extended unit

2005-01-25 Thread Tom Lane
Martijn van Oosterhout writes: > On Tue, Jan 25, 2005 at 02:31:40PM -0500, Tom Lane wrote: >> AFAICS this could easily be implemented as a user-defined type, along >> the lines of >> CREATE TYPE measurement AS (value double, units text); >> and if you want to constrain a particular column to conta

Re: [GENERAL] Extended unit

2005-01-25 Thread Pailloncy Jean-Gerard
... none of which require any extensions to the core type system. AFAICS this could easily be implemented as a user-defined type, along the lines of CREATE TYPE measurement AS (value double, units text); and if you want to constrain a particular column to contain only one value of units, us

Re: [GENERAL] Extended unit

2005-01-25 Thread Tom Lane
Pailloncy Jean-Gerard <[EMAIL PROTECTED]> writes: > I do not want for each column and each row to store the value and the > unit. > I do want to put the unit in the definition of the column and the check > on the parser before any execution. If you do that, you foreclose the ability to store mi

Re: [GENERAL] Extended unit

2005-01-26 Thread Richard Huxton
Tom Lane wrote: Pailloncy Jean-Gerard <[EMAIL PROTECTED]> writes: I do not want for each column and each row to store the value and the unit. I do want to put the unit in the definition of the column and the check on the parser before any execution. If you do that, you foreclose the ability to

Re: [GENERAL] Extended unit

2005-01-26 Thread Martijn van Oosterhout
On Tue, Jan 25, 2005 at 11:41:28PM +0100, Pailloncy Jean-Gerard wrote: > I have begining to put all the SI unit in a table. > I am writing the function to check the unit in a standard way. > I plan to use the user-defined type proposed by Tom Lane. > The check are done at execution time. > > But I

Re: [GENERAL] Extended unit

2005-01-26 Thread Martijn van Oosterhout
On Wed, Jan 26, 2005 at 09:06:16AM +, Richard Huxton wrote: > Tom Lane wrote: > >If you do that, you foreclose the ability to store mixed values in a > >single column, in return for what? Saving a couple of bytes per value? > >(I suppose that in a serious implementation we'd store the units as

Re: [GENERAL] Extended unit

2005-01-26 Thread Pailloncy Jean-Gerard
It strikes me that the right level of constraint is the quantity being represented: length / mass / time / velocity. Then you could store any of: '1inch', '2m', '3km', '4light-years' in a "length" column. Ofcourse, only one of those is in SI units :) Just like the interval type, all this could be h

Re: [GENERAL] Extended unit

2005-01-26 Thread Michael Glaesemann
On Jan 26, 2005, at 20:06, Pailloncy Jean-Gerard wrote: It strikes me that the right level of constraint is the quantity being represented: length / mass / time / velocity. Then you could store any of: '1inch', '2m', '3km', '4light-years' in a "length" column. Ofcourse, only one of those is in S

Re: [GENERAL] Extended unit

2005-01-26 Thread Martijn van Oosterhout
On Wed, Jan 26, 2005 at 12:06:15PM +0100, Pailloncy Jean-Gerard wrote: > If I have a column with "speed DOUBLE(m1s-1)" > I want to be able to put in in any unit format. > If I want special output, I would have a function > doubleunit_to_char(speed,'si') that will output "3 m/s" and > doubleunit_to_

Re: [GENERAL] Extended unit

2005-01-26 Thread Csaba Nagy
Hi all, I wonder if it makes sense to implement the units as separate data types ? Cause that's what they are really. So "amper" would be a data type which aliases one of the numeric data types (depending on what precision range you need), but does not allow to be added with anything else than "am

Re: [GENERAL] Extended unit

2005-01-26 Thread Frank D. Engel, Jr.
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 That's not necessarily a constant; there is evidence to suggest that the speed of light is slowing down over time. If that is indeed the case, then as light travels more slowly, a light year will become shorter. http://www.ldolphin.org/speedo.html

Re: [GENERAL] Extended unit

2005-01-26 Thread Robby Russell
On Wed, 2005-01-26 at 08:45 -0500, Frank D. Engel, Jr. wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > That's not necessarily a constant; there is evidence to suggest that > the speed of light is slowing down over time. If that is indeed the > case, then as light travels more slowl

Re: [GENERAL] Extended unit

2005-01-26 Thread Greg Stark
Martijn van Oosterhout writes: > Now, how to store the relationships between them to handle > multiplication and division. Probably go back to base types... I've thought about this myself quite a bit. I decided that trying to implement multiplication and division is a bad idea. What you really

Re: [GENERAL] Extended unit

2005-01-26 Thread PFC
If you allow multiplication and division, you'd need to store not only one type, but an expression like m.s^-2, etc. You'll end up with something with Maple. Isn't there some free open source algebraic computation toolkit with equations and units somewhere ? ---(end

Re: [GENERAL] Extended unit

2005-01-26 Thread PFC
I wonder if it makes sense to implement the units as separate data types ? Cause that's what they are really. So "amper" would be a data type which aliases one of the numeric data types (depending on what precision range you need), but does not allow to be added with anything else than "amper". Any

Re: [GENERAL] Extended unit

2005-01-27 Thread Pailloncy Jean-Gerard
If you allow multiplication and division, you'd need to store not only one type, but an expression like m.s^-2, etc. You'll end up with something with Maple. Isn't there some free open source algebraic computation toolkit with equations and units somewhere ? Yes and no. I am in the (slow) proce

Re: [GENERAL] Extended unit

2005-01-27 Thread Pailloncy Jean-Gerard
ision range you need), but does not allow to be added with anything else than "amper". Any other interaction with other units (read data types) would be achieved by defining the needed operators on the respective data types (read units). You'd have to create a postgres datatype for every variatio

Re: [GENERAL] Extended unit

2005-01-27 Thread Frank D. Engel, Jr.
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Yep: http://www-fourier.ujf-grenoble.fr/~parisse/giac.html Try things like: convert(4_acre, _in^2) (I'm in TI-89 mode, if that makes any difference I don't know). On Jan 26, 2005, at 6:57 PM, PFC wrote: Isn't there some free open source algebraic comput

Re: [GENERAL] Extended unit

2005-01-27 Thread Shawn Harrison
Frank D. Engel, Jr. wrote [01/27/05 9:19 AM]: On Jan 26, 2005, at 6:57 PM, PFC wrote: Isn't there some free open source algebraic computation toolkit with equations and units somewhere ? A very simple but effective system that I have used quite a lot for "computation with units" is a Python modul

Re: [GENERAL] Extended unit

2005-01-27 Thread Greg Stark
> Frank D. Engel, Jr. wrote [01/27/05 9:19 AM]: > > On Jan 26, 2005, at 6:57 PM, PFC wrote: > > > >> Isn't there some free open source algebraic computation toolkit with > >> equations and units somewhere ? You mean like the traditional units program available on virtually all Unix machines?

Re: [GENERAL] Extended unit

2005-01-27 Thread Pailloncy Jean-Gerard
Hi, Some word from my test work. I try first to just have a parser that can manage a string of unit. like 'm s-1 kg2.5 A3.5/7.2' The parser accept : - any letters for the unit - a + or - or nothing before the power - a fractional power - the unit separator is space ;-/ The system normalize the frac

Re: [GENERAL] Extended unit

2005-01-28 Thread Pailloncy Jean-Gerard
De: [EMAIL PROTECTED] Objet: Rép : [GENERAL] Extended unit Date: 28 janvier 2005 18:18:18 GMT+01:00 À:[EMAIL PROTECTED] I have done a new version with - a new conversion function - possibility to enter value as fraction - addition of the operator

Re: [GENERAL] Extended unit

2005-01-31 Thread Alban Hertroys
Greg Stark wrote: You mean like the traditional units program available on virtually all Unix machines? $ units 2084 units, 71 prefixes, 32 nonlinear units You have: 1 lightyear/fortnight You want: m/s * 7.8213711e+09 / 1.2785482e-10 That's the program I sugg

Re: [GENERAL] Extended unit

2005-01-31 Thread Martijn van Oosterhout
On Mon, Jan 31, 2005 at 11:57:41AM +0100, Alban Hertroys wrote: > Greg Stark wrote: > >That's the program I suggested writing a function to hand this work off to > >(presumably in the form of a dynamic library). Keep the postgres code > >agnostic > >about the semantics of the units. As long as you

Re: [GENERAL] Extended unit

2005-01-31 Thread Greg Stark
RTFM. You have: tempK(1) You want: tempC -272.15 -- greg ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match