Thread overview | ||||||
---|---|---|---|---|---|---|
|
January 12, 2003 D Scientific Classes? | ||||
---|---|---|---|---|
| ||||
Daniel proposed some sort of scientific classes for D, among other supporting library functions. What kind of functionality would that include? Are there similar classes for other languages that would make good examples? I'm guessing that it would contain a lot of constants, and maybe functions for converting between units, what else? I would like to help with something like that, but I don't really know what it would entail. -Jon |
January 12, 2003 Re: D Scientific Classes? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan Andrew | "Jonathan Andrew" <jon@ece.arizona.edu> escreveu na mensagem news:3E206267.70801@ece.arizona.edu... > Daniel proposed some sort of scientific classes for D, among other supporting library functions. What kind of functionality would that include? Are there similar classes for other languages that would make good examples? I'm guessing that it would contain a lot of constants, and maybe functions for converting between units, what else? I would like to help with something like that, but I don't really know what it would entail. > > -Jon > Hi, I'm thinking about safe quantities (value unit pairs) for type-preserving algebra, classes to represent vectors, vector fields, spaces, equations, standard graphs for rendering. Lot's of stuff. I have lots of thoughts about it (was physics major once, before quitting college :-( and have some good background, mostly calculus and mathematics applied to physics). IMHO we can use a simple approach to defining units. A basic CGSUnit class, with internal variables keeping track of each dimension's power, lots of constants and some factory methods to create specialized units (speed, mass, etc.). If Walter add support in D templates for values, like c++ does, we can make instance TUnit(1,0,0) length, be a different type than instance TUnit(0,1,0) mass, with type safe algebra. Make it fast enough and more people will start using it, at least for type-check the equations before trying to release it using doubles. An application like http://www.jonelo.de/java/nc/ gives me some ideas of what we need to implement, but not how, the code is a bit ugly. http://www.dautelle.com/jade/ provides a scientific library. I have links for works in other languages (C++, Ada, etc.) to get a basic start of what we need to do. Best regards, Daniel Yokomiso. "Why should I care about posterity? What's posterity ever done for me?" - Groucho Marx --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.435 / Virus Database: 244 - Release Date: 30/12/2002 |
January 12, 2003 Re: D Scientific Classes? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Yokomiso |
>
>Hi,
>
> I'm thinking about safe quantities (value unit pairs) for
>type-preserving algebra, classes to represent vectors, vector fields, spaces, equations, standard graphs for rendering. Lot's of stuff. I have lots of thoughts about it (was physics major once, before quitting college :-( and have some good background, mostly calculus and mathematics applied to physics). IMHO we can use a simple approach to defining units. A basic CGSUnit class, with internal variables keeping track of each dimension's power, lots of constants and some factory methods to create specialized units (speed, mass, etc.). If Walter add support in D templates for values, like c++ does, we can make instance TUnit(1,0,0) length, be a different type than instance TUnit(0,1,0) mass, with type safe algebra. Make it fast enough and more people will start using it, at least for type-check the equations before trying to release it using doubles. An application like http://www.jonelo.de/java/nc/ gives me some ideas of what we need to implement, but not how, the code is a bit ugly. http://www.dautelle.com/jade/ provides a scientific library. I have links for works in other languages (C++, Ada, etc.) to get a basic start of what we need to do.
>
> Best regards,
> Daniel Yokomiso.
>
>"Why should I care about posterity? What's posterity ever done for me?" - Groucho Marx
>
>
>---
>Outgoing mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.435 / Virus Database: 244 - Release Date: 30/12/2002
>
>
I'll check out those links and maybe we can come up with something good. One idea I had, (if properties get implemented) is to use a property for the units of each of the quantities, and then the settor could do the appropriate conversion if you wanted to change units. Maybe in the constructor you could define the units, i.e.
mylength = new CGSUnit(10, KM);
Which would make mylength a scientific quantity of 10 kilometers. Although I must confess I don't really care for the name CGSUnit too much... maybe "Quantity" or something of that nature, but its probably too early to worry about naming schemes.
-Jon
|
January 13, 2003 Re: D Scientific Classes? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan Andrew | "Jonathan Andrew" <Jonathan_member@pathlink.com> escreveu na mensagem news:avsi68$a6d$1@digitaldaemon.com... > > > > >Hi, > > > > I'm thinking about safe quantities (value unit pairs) for > >type-preserving algebra, classes to represent vectors, vector fields, spaces, equations, standard graphs for rendering. Lot's of stuff. I have lots of thoughts about it (was physics major once, before quitting college > >:-( and have some good background, mostly calculus and mathematics applied > >to physics). IMHO we can use a simple approach to defining units. A basic CGSUnit class, with internal variables keeping track of each dimension's power, lots of constants and some factory methods to create specialized units (speed, mass, etc.). If Walter add support in D templates for values, > >like c++ does, we can make instance TUnit(1,0,0) length, be a different type > >than instance TUnit(0,1,0) mass, with type safe algebra. Make it fast enough > >and more people will start using it, at least for type-check the equations > >before trying to release it using doubles. An application like http://www.jonelo.de/java/nc/ gives me some ideas of what we need to implement, but not how, the code is a bit ugly. http://www.dautelle.com/jade/ provides a scientific library. I have links for works in other languages (C++, Ada, etc.) to get a basic start of what > >we need to do. > > > > Best regards, > > Daniel Yokomiso. > > > >"Why should I care about posterity? What's posterity ever done for me?" - Groucho Marx > > > > > >--- > >Outgoing mail is certified Virus Free. > >Checked by AVG anti-virus system (http://www.grisoft.com). > >Version: 6.0.435 / Virus Database: 244 - Release Date: 30/12/2002 > > > > > > I'll check out those links and maybe we can come up with something good. One > idea I had, (if properties get implemented) is to use a property for the units > of each of the quantities, and then the settor could do the appropriate conversion if you wanted to change units. Maybe in the constructor you could > define the units, i.e. > > mylength = new CGSUnit(10, KM); > > Which would make mylength a scientific quantity of 10 kilometers. Although I must confess I don't really care for the name CGSUnit too much... maybe "Quantity" or something of that nature, but its probably too early to worry > about naming schemes. > > -Jon > Well, with overloaded method names we can use scaling operations to do the trick: mylength = 10 * KM; where KM has the type Length and a value of 1. This type must be able to be type safe, and AFAIK we need dimensions in some unit system to do that. SI uses seven dimensions, CGS uses 3. The tricky part is when we do something like: mylength = 10 * KM + 123 * FEET With this kind of code we need to make the appropriate conversions and keep a adequate precision. Using properties to define the kind of units (e.g. meters vs. miles) may be better for value showing, not for the values. Something like: mylength = 10 * KM; mytime = 2 * MINUTE; myspeed = mylength / mytime; units.time = HOUR; units.length = FEET; printf("%.*s\r\n", units.toString(myspeed)); Best regards, Daniel Yokomiso. "Later in this talk, I intend to define the universe and give three examples." - Larry Wall --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.435 / Virus Database: 244 - Release Date: 31/12/2002 |
Copyright © 1999-2021 by the D Language Foundation