digitalmars.D - Runtime unit lib
- BCS <BCS_member pathlink.com> Feb 21 2006
- Thomas Kuehne <thomas-dloop kuehne.cn> Feb 22 2006
- BCS <BCS_member pathlink.com> Feb 22 2006
- Thomas Kuehne <thomas-dloop kuehne.cn> Feb 22 2006
- BCS <BCS_member pathlink.com> Feb 22 2006
- Thomas Kuehne <thomas-dloop kuehne.cn> Feb 23 2006
- BCS <BCS_member pathlink.com> Feb 23 2006
- Thomas Kuehne <thomas-dloop kuehne.cn> Feb 23 2006
- BCS <BCS_member pathlink.com> Feb 23 2006
- BCS <BCS_member pathlink.com> Feb 24 2006
- Sai <Sai_member pathlink.com> Feb 25 2006
- BCS <BCS_member pathlink.com> Feb 25 2006
- "Charles" <noone nowhere.com> Feb 22 2006
- BCS <BCS_member pathlink.com> Feb 22 2006
- Sai <Sai_member pathlink.com> Feb 22 2006
- BCS <BCS_member pathlink.com> Feb 22 2006
- Chris Lajoie <ctlajoie___remove___this___ ___gmail.com> Feb 24 2006
- BCS <BCS_member pathlink.com> Feb 27 2006
I have put together a runtime unit type library. While I was writing the unittest I recognized that the most likely error is an error in the convention table (something that can't be checked by the person who wrote that part). Therefor, Would someone please (without looking at my table of conversion factors) finish writing the unittest for the lib? It shouldn't be hard, just get the file and a units conversion table and add some more lines like those around line 644. here it is: http://www.webpages.uidaho.edu/~shro8822/unit_.d ps: I am submitting this for inclusion in Phobos.
Feb 21 2006
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 BCS schrieb am 2006-02-22:I have put together a runtime unit type library. While I was writing the unittest I recognized that the most likely error is an error in the convention table (something that can't be checked by the person who wrote that part). Therefor, Would someone please (without looking at my table of conversion factors) finish writing the unittest for the lib? It shouldn't be hard, just get the file and a units conversion table and add some more lines like those around line 644. here it is: http://www.webpages.uidaho.edu/~shro8822/unit_.d
Acre US or international ? Cal international table calorie, thermochemical calorie or ... ? Hp metric, us or ... horsepower? Leter -> Liter? mile, inch british, natic, imperial or ... ? R Rankine, Reaumur or ... ? Fahrenheit and lot's of metric units seem to be missing. Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFD/Fgg3w+/yD4P9tIRAmcCAJ0cOnVal+PXaZcCag5MjU1b44Cn8wCguKDf qx9/Ra66opwQBsv3kNVs74s= =UwGB -----END PGP SIGNATURE-----
Feb 22 2006
In article <0q1uc3-rb3.ln1 birke.kuehne.cn>, Thomas Kuehne says...-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 BCS schrieb am 2006-02-22:I have put together a runtime unit type library. While I was writing the unittest I recognized that the most likely error is an error in the convention table (something that can't be checked by the person who wrote that part). Therefor, Would someone please (without looking at my table of conversion factors) finish writing the unittest for the lib? It shouldn't be hard, just get the file and a units conversion table and add some more lines like those around line 644. here it is: http://www.webpages.uidaho.edu/~shro8822/unit_.d
Acre US or international ? Cal international table calorie, thermochemical calorie or ... ? Hp metric, us or ... horsepower? Leter -> Liter?
oopsmile, inch british, natic, imperial or ... ?
5280'R Rankine, Reaumur or ... ?
RankineFahrenheit and lot's of metric units seem to be missing.
Fahrenheit has an offset so... I didn't put in units like PSI that are named by there definition. I put in all of the units that my table had that looked useful (who besides the GB DMV needs stones?) More units can be added later. non metric units are US (I think). ver 2 fothcoming, several things will change a bit.
Feb 22 2006
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 BCS schrieb am 2006-02-22:In article <0q1uc3-rb3.ln1 birke.kuehne.cn>, Thomas Kuehne says...
[snip]mile, inch british, natic, imperial or ... ?
5280'
[snip]non metric units are US (I think).
Except for inch, all conversions seem to be correct. Could you please send me your email - the basic conversion unittest is rather large for posting (ca. 647K). Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFD/NoA3w+/yD4P9tIRAgr+AKCEHKUcwpu+m2FvmOQlWJowjYMCgwCfZQR8 IFJFE9kXLfgLQSWrHSvOdrI= =kJBv -----END PGP SIGNATURE-----
Feb 22 2006
WOW!! Thanks! That is impressive. If I may ask, how did you make that? Some
sort
of script I assume? I ask because the Phobos source en-total is 1MB and 647k is
kinda large. Can you think of any way to cut down the code size using a data
table of some kind?
e.g.
enum Types {Foot, Inch, Pound, ...)
real[Types.max][Types.max] test_values;
test_values[Types.Foot][Types.Foot] = 1; // real value is convrtion
test_values[Types.Foot][Types.Inch] = 12;
test_values[Types.Foot][Types.Pound] = real.nan; //nan on no convertion
...
Unit u;
real v;
foreach(int from, real[] ra; test_values)
foreach(int to, real r; test_values)
{
switch(from)
{
case Type.Foot: u = Foot(1); break;
case Type.Inch: u = Inch(1); break;
case Type.Pound: u = Pound(1); break;
...
}
try
switch(from)
{
case Type.Foot: v = u.Foot(); break;
case Type.Inch: v = u.Inch(); break;
case Type.Pound: v =u.Pound(); break;
...
}
catch (ExceptionUnitMisMatch)
{
assert(isnan(r));
continue;
}
assert(!isnan(r));
}
Thomas Kuehne wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
BCS schrieb am 2006-02-22:
In article <0q1uc3-rb3.ln1 birke.kuehne.cn>, Thomas Kuehne says...
[snip]
mile, inch
british, natic, imperial or ... ?
5280'
[snip]
non metric units are US (I think).
Except for inch, all conversions seem to be correct.
Could you please send me your email - the basic
conversion unittest is rather large for posting (ca. 647K).
Thomas
-----BEGIN PGP SIGNATURE-----
iD8DBQFD/NoA3w+/yD4P9tIRAgr+AKCEHKUcwpu+m2FvmOQlWJowjYMCgwCfZQR8
IFJFE9kXLfgLQSWrHSvOdrI=
=kJBv
-----END PGP SIGNATURE-----
Feb 22 2006
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 BCS schrieb am 2006-02-23:WOW!! Thanks! That is impressive. If I may ask, how did you make that? Some sort of script I assume?
No script, just one hundred and one monkeys typing all day ;)I ask because the Phobos source en-total is 1MB and 647k is kinda large. Can you think of any way to cut down the code size using a data table of some kind?
How about 40K? Thomas
Feb 23 2006
Thomas Kuehne wrote:-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 BCS schrieb am 2006-02-23:WOW!! Thanks! That is impressive. If I may ask, how did you make that? Some sort of script I assume?
No script, just one hundred and one monkeys typing all day ;)I ask because the Phobos source en-total is 1MB and 647k is kinda large. Can you think of any way to cut down the code size using a data table of some kind?
How about 40K? Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFD/Xmz3w+/yD4P9tIRAognAJ9htrCXzYmDCOjRygLkkMfF3WsJsgCgohwt uSKoGesdYlzAUbGXNBs0qO8= =6E2G -----END PGP SIGNATURE-----
Sweet!!! That's about what I was expecting. Thanks!! Two things (more curiosity than anything): -> How long did the first version take to compile for you? On my box (Linux 550MHz P-III) DMD ran for ~ 70 sec. -> What did you use for a convention table? I want to pout that in the doc comments. A fixed version (inch, cal and hp corrected) of the lib will be up in a few minutes.
Feb 23 2006
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 BCS schrieb am 2006-02-23: [snip]Two things (more curiosity than anything): -> How long did the first version take to compile for you? On my box (Linux 550MHz P-III) DMD ran for ~ 70 sec.
ca. 29 sec (with some backround activity)-> What did you use for a convention table? I want to put that in the doc comments.
units version 1.80 the data file lists following sources: # Most units data was drawn from # 1. NIST Special Publication 811, 1995 Edition # 2. CRC Handbook of Chemistry and Physics 70th edition # 3. Oxford English Dictionary # 4. Websters New Universal Unabridged Dictionary # 5. Units of Measure by Stephen Dresner # 6. A Dictionary of English Weights and Measures by Ronald Zupko # 7. British Weights and Measures by Ronald Zupko # 8. Realm of Measure by Isaac Asimov # 9. United States standards of weights and measures, their # creation and creators by Arthur H. Frazier. # 10. French weights and measures before the Revolution: a # dictionary of provincial and local units by Ronald Zupko # 11. Weights and Measures: their ancient origins and their # development in Great Britain up to AD 1855 by FG Skinner # 12. The World of Measurements by H. Arthur Klein # 13. For Good Measure by William Johnstone # 14. NTC's Encyclopedia of International Weights and Measures # by William Johnstone # 15. Sizes by John Lord # 16. Sizesaurus by Stephen Strauss # 17. CODATA Recommended Values of Physical Constants available at # http://physics.nist.gov/cuu/Constants/index.html # 18. How Many? A Dictionary of Units of Measurement. Available at # http://www.unc.edu/~rowlett/units/index.html # 19. Numericana. http://www.numericana.com # Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFD/haw3w+/yD4P9tIRAg9YAJ4sdDt8Sbdgn+UyR+fAGAMZzy3GxwCgqQSa 6j6MksKajqf4g4aUCf50T3E= =ydtA -----END PGP SIGNATURE-----
Feb 23 2006
In article <geh1d3-v56.ln1 birke.kuehne.cn>, Thomas Kuehne says...-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 BCS schrieb am 2006-02-23: [snip]Two things (more curiosity than anything): -> How long did the first version take to compile for you? On my box (Linux 550MHz P-III) DMD ran for ~ 70 sec.
ca. 29 sec (with some backround activity)
what kind of system?-> What did you use for a convention table? I want to put that in the doc comments.
units version 1.80
Crumbs! That's where I got the _new_ valuse for the convertions from. Now I have to find a new scource.the data file lists following sources: # Most units data was drawn from # 1. NIST Special Publication 811, 1995 Edition # 2. CRC Handbook of Chemistry and Physics 70th edition # 3. Oxford English Dictionary # 4. Websters New Universal Unabridged Dictionary # 5. Units of Measure by Stephen Dresner # 6. A Dictionary of English Weights and Measures by Ronald Zupko # 7. British Weights and Measures by Ronald Zupko # 8. Realm of Measure by Isaac Asimov # 9. United States standards of weights and measures, their # creation and creators by Arthur H. Frazier. # 10. French weights and measures before the Revolution: a # dictionary of provincial and local units by Ronald Zupko # 11. Weights and Measures: their ancient origins and their # development in Great Britain up to AD 1855 by FG Skinner # 12. The World of Measurements by H. Arthur Klein # 13. For Good Measure by William Johnstone # 14. NTC's Encyclopedia of International Weights and Measures # by William Johnstone # 15. Sizes by John Lord # 16. Sizesaurus by Stephen Strauss # 17. CODATA Recommended Values of Physical Constants available at # http://physics.nist.gov/cuu/Constants/index.html # 18. How Many? A Dictionary of Units of Measurement. Available at # http://www.unc.edu/~rowlett/units/index.html # 19. Numericana. http://www.numericana.com # Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFD/haw3w+/yD4P9tIRAg9YAJ4sdDt8Sbdgn+UyR+fAGAMZzy3GxwCgqQSa 6j6MksKajqf4g4aUCf50T3E= =ydtA -----END PGP SIGNATURE-----
Feb 23 2006
A new version of the units lib is up at http://www.webpages.uidaho.edu/~shro8822/unit.d Several other libs are also up at: http://www.webpages.uidaho.edu/~shro8822/point_math.d http://www.webpages.uidaho.edu/~shro8822/point_lib.d I would like to submit them all for inclusion in Phobos
Feb 24 2006
Great, I always wanted to write one! Actually I already have one but it is more like an units interpreter. However, my library has an additional feature, it can take fractional powers of dimensions in p/q form where p and q are integers. I am interested in adding this feature to your library, its easy. This feature is very useful for engineers, especially mechanical engineers where fractional power of dimensions appear every where. eg. time period of a simple pendulum. So, do you mind if I take a whack at it ? One question, why you left out angle and candela from fundamental units ? later one is used a lot in optics. my units interpreter is at: http://mechsys4.me.udel.edu/home/banala/units.html its not very userfriendly as of yet, just ported it to D and DWT. Sai In article <dto5k2$10iq$1 digitaldaemon.com>, BCS says...A new version of the units lib is up at http://www.webpages.uidaho.edu/~shro8822/unit.d Several other libs are also up at: http://www.webpages.uidaho.edu/~shro8822/point_math.d http://www.webpages.uidaho.edu/~shro8822/point_lib.d I would like to submit them all for inclusion in Phobos
Feb 25 2006
In article <dtprks$1m30$1 digitaldaemon.com>, Sai says...Great, I always wanted to write one! Actually I already have one but it is more like an units interpreter. However, my library has an additional feature, it can take fractional powers of dimensions in p/q form where p and q are integers. I am interested in adding this feature to your library, its easy. This feature is very useful for engineers, especially mechanical engineers where fractional power of dimensions appear every where. eg. time period of a simple pendulum.
Go ahead, fine by me. I was thinking of adding integer powers my self. One request, I have tried to keep the unit control part as separable as possible so that it would be easy to strip out for performance reasons.So, do you mind if I take a whack at it ? One question, why you left out angle and candela from fundamental units ? later one is used a lot in optics.
Each fundamental unit used adds a int to the struct and adds more overhead to programs using this library. While not quite as handy, angles can be treated as unit-less (IIRC SI does this) and the candela can be treated as power per area (CGS, US and MKS do this).my units interpreter is at: http://mechsys4.me.udel.edu/home/banala/units.html its not very userfriendly as of yet, just ported it to D and DWT. Sai
This whole lib is rely a bit of a kluge because most of the time units can be determined statically and should be checked statically. I have plans for a template to do this but it will require implicit template specialization, so that's on hold for now.In article <dto5k2$10iq$1 digitaldaemon.com>, BCS says...A new version of the units lib is up at http://www.webpages.uidaho.edu/~shro8822/unit.d Several other libs are also up at: http://www.webpages.uidaho.edu/~shro8822/point_math.d http://www.webpages.uidaho.edu/~shro8822/point_lib.d I would like to submit them all for inclusion in Phobos
Feb 25 2006
This looks sweet. Sorry for my ignorance but what does feqrel() do ? Charlie "BCS" <BCS_member pathlink.com> wrote in message news:dtgd32$407$1 digitaldaemon.com...I have put together a runtime unit type library. While I was writing the unittest I recognized that the most likely error is an error in the
table (something that can't be checked by the person who wrote that part). Therefor, Would someone please (without looking at my table of conversion factors) finish writing the unittest for the lib? It shouldn't be hard, just get the file and a units conversion table and
some more lines like those around line 644. here it is: http://www.webpages.uidaho.edu/~shro8822/unit_.d ps: I am submitting this for inclusion in Phobos.
Feb 22 2006
"to how many bit are the args the same?" its in std.math In article <dti61k$2gpd$1 digitaldaemon.com>, Charles says...This looks sweet. Sorry for my ignorance but what does feqrel() do ? Charlie "BCS" <BCS_member pathlink.com> wrote in message news:dtgd32$407$1 digitaldaemon.com...I have put together a runtime unit type library. While I was writing the unittest I recognized that the most likely error is an error in the
table (something that can't be checked by the person who wrote that part). Therefor, Would someone please (without looking at my table of conversion factors) finish writing the unittest for the lib? It shouldn't be hard, just get the file and a units conversion table and
some more lines like those around line 644. here it is: http://www.webpages.uidaho.edu/~shro8822/unit_.d ps: I am submitting this for inclusion in Phobos.
Feb 22 2006
http://www.gnu.org/software/units/units.html Above tool seem to have a pretty good collection of units. It would be nice if the 'runtime unit lib' in discussion can generate arbitrary fundamental units and user defined conversions at runtime (like currency, steradian, bit, music_note etc). Sai
Feb 22 2006
Sai wrote:http://www.gnu.org/software/units/units.html Above tool seem to have a pretty good collection of units. It would be nice if the 'runtime unit lib' in discussion can generate arbitrary fundamental units and user defined conversions at runtime (like currency, steradian, bit, music_note etc). Sai
I'll check that out
Feb 22 2006
BCS wrote:I have put together a runtime unit type library. While I was writing the unittest I recognized that the most likely error is an error in the convention table (something that can't be checked by the person who wrote that part). Therefor, Would someone please (without looking at my table of conversion factors) finish writing the unittest for the lib? It shouldn't be hard, just get the file and a units conversion table and add some more lines like those around line 644. here it is: http://www.webpages.uidaho.edu/~shro8822/unit_.d
While I'm sure your units code will be great as part of phobos, I'm actually more interested (surprised rather) in where your file is hosted. I believe we go to school in the same state. :) I'm in the middle of my second year at Boise State University. Chris
Feb 24 2006
Chris Lajoie wrote:BCS wrote:http://www.webpages.uidaho.edu/~shro8822/unit_.d
While I'm sure your units code will be great as part of phobos, I'm actually more interested (surprised rather) in where your file is hosted. I believe we go to school in the same state. :) I'm in the middle of my second year at Boise State University. Chris
project I'm ocationaly involved in works right here in town. "It's a small world after all ..."
Feb 27 2006









BCS <BCS_member pathlink.com> 