CodePlexProject Hosting for Open Source Software

Quantity System is an attempt to make a framework to support scientific calculations through units conversions and quantities predictions.

Based on Dimensional approach not Units approach.

The first to differentiate between Torque, and Work, Angle, and Solid Angle.

- Complex Scalar C{3 5}
- C{4 3}<L> + C{5 2}<m^3> *etc.*

- Quaternion Scalar H{3 4 2 1}

- absolute and magnitude operators |x| and ||x|| has been converted into _|x|_ and _||x||_ in favor of introducing the differential operator '|'

- @F|$x to derive for x
- @|$x * @F another way to derive the function
- @F|$x|$y^2 partial derivation for x then y two times.
- @|$x|$y^2 * @F equivalent way of derivation.

- fv = {@f @g @i(z)} is the ability to store the function into vectors, matrices, and tensors to make further calculations
- function can be summed, subtracted, and all other basic operation which in turn are calculated based on symbolic calculations
- converting between Symbolic Quantity and Function vice versa
- @s = $x+$y^2 will produce s(x,y) = x+y^2 which in turn can be called as s(3,4)

- functions can be added also to symbolic variables.
- f(x) =x @f=@f+$x

- Nable operator \/
- Gradient which means \/* vector field can be achieved when multiplying \/*@F

- Range operator ..
- To create vectors from..to v = 1..10

- DIP : Device Independent Pixel (Thanks for Starnuto for the addition) the unit is used extensively in WPF applications.

I hope by this release that I illustrate some of the power beyond blending symbolic calculations and numerical calculations.

Example: T3 = <|2 3; 4 6|4 3; 1 3|> this is like the hyper cube.

for more order tensors you can embed this syntax in a recursive fashion

Example: T4 = <| <|2 3; 4 6|4 3; 1 3|> | <|2 3; 4 6|4 3; 1 3|> |> which gives you a tensor from the fourth order

a=$x+$y

b=$x-$y

a*b will produce x^2+y^2

Yes as you guessed to express a symbolic quantity you prefix the letter or letters with dollar sign '$'

so

And it is available in all the mathematical types i.e. Matrix

m = [$x $y $z; 4 3 2; $u $v $w]

determinant can be obtained by two vertical bars aruond m

|M| will produce DimensionlessQuantity: 3*x*w-2*x*v+2*y*u-4*y*w+4*z*v-3*z*u <1>

and yet these symbols are quantities, so $x<ft>+40<m> is valid expression but $v<m/s> + $ws<m/s^2> is not valid because of dimensionality differnence.

all of this calculation has been made by my beloved library http://symbolicalgebra.codeplex.com

"Ahmed" >> 1 will produce "hmedA"

- Standard Deviation '!%'
- s[1 !% 10] produce standard deviation for the sequence elements from 1 to 10

- Enhanced the sequence declaration to include the starting and ending index variables during evaluation
- g[k=m->n](x) ..> n - k*x #m is the starting index, and n is the ending index which can be used in the items evaluation.

- Getting range from parameterized sequence return vector or matrix or tensor based on what you have written in symbolic quantities
- g[n](x) ..> x^n
- g[0..3] result in { 1 x x^2 x^3}

- Access element from vector by indexing V[0]

- Access vector from Matrix by indexing M[0] or scalar by M[0,0]
- Determinant is now expanded for more than 3x3 elements (and I borrowed the code, so it is not the fastest as usuall :) )
- Outer product for matrix added '(*)' (Kronecker product)

- Elements access by indexing maximum to the order of the tensor
- T4 is 4th order tensor if you specify T4[0] then you access the third order tensor in it
- T4[0,0] you access the matrix
- T4[0,0,0] is vector
- finally T4[0,0,0,0] you got your scalar there

- Addition and Subtraction of Tensor for any order
- Tensor Order 1 * Tensor Order 1 = Tensor Order 2 (Dyadic operation) { looks like the outer product of two vectors ;) try the two please}

- SpecificEnergy
- MolarDensity
- MolarSpecificHeat
- MolarVolume

- <MBTU> Million British Thermal Units
- <MMBTU> Million Million British Thermal Units
- <cal> Calorie = 4.184 <J>
- <lbcal> Pound Calorie

- Fixed a destructive error: 5^-3 was evaluating in bad behaviour because i was translating -3 to (-1*3) then the priority of '^' precede the priority (NOW FIXED)
- A lot of fixes has been done
**please check the check-in history from previous release**

a = a + (a + ( a + a + (((((((((((((((((((a + 1<mg/s>))))))))))))))))))) + 0.1<slug/h>)+ 0.2<g/s>)

was taking a huge amount of time, but now it works flawesly.

- Qs> a = "Hello There"
- Qs> Windows:MessageBox(a)
- Qs> Windows:MessageBox( "3+4 = " + (3+4));

Qs> {3 4 2} (*) {5 6 3}

QsMatrix:

15<1> 18<1> 9<1>

20<1> 24<1> 12<1>

10<1> 12<1> 6<1>

Qs> v(y) = y/3

Qs> w = @u + @v #this will return w(x,y) function

also by using '@' operator you can select a specific function with parameter '@f(y)' for example

- f(x) = x
- f(y) = y^2
- f(z) = z^3
- vv = f(z=f(y=f(x=math:sin(val=10))))

- 2- f(x) = 3+u will result in QsParameterNotFoundException: u. due to u is not in the parameter list.

- Qs> g[n](x) ..> x^n
- Qs> g[4] return _(x)=x^4
- Qs> fg = g[0++10] # will return function fg(x) = _(x) = x^0+x^1+...

- Operation of Vector - Scalar Fixed :(

In future I am intending to support Tensors also.

Don't forget to download the specifications :)

please enjoy this fine alpha release :)

QsScalar class that is wrapping the AnyQuantity<double> class

QsScalar is inherited from QsValue

Three Classes inherited from QsValue

1) QsScalar

2) QsVector

3) QsMatrix

Later the Qs will also support Tensor with rank 3 {any suggestions is appreciated}

please notice that the matrix calculations is not the best algorithm available.

when you form a unit <ms.s> milli second * second

the result is <s^2> and an overflow occur due to the milli prefix

this milli factor goes to the value part

so if you entered 2<ms.s> the result will be 0.002<s^2>

however the framework is always try to get the best expression it can have.

for example if you make 2<Gm.mm> giga Metre * milli Metre the result will be 2<km^2>

but if there were no corresponding prefix for the overflow then the prefix is removed

and overflow flag in the unit is raised, and the quantity value is altered as shown

in the first example.

- Vector support:

a= {2 3 4} or a={2,3,5}

- Dot product for vectors New opertaor

{2,3,4} . { 5 6 3}

- Crosss product for vectors of 3 components use 'x' letter New Operator

{3<m> 2<A> 4<N>} x {2<ft> 2<mA> 3<pdl>}

- Vector Norm ||_||:

||{3 5 3 2 1}|| or ||a||

- Factorial of Vector gets all the factorial of its components

- calling a function with vector as input result in vector as a result.

- Matrix support

m1 = [2 3 4; 3 2 1; {5 4 3}]

- Matrix multiplication

- Determinant for matrix using determinant operator

| a |

| [ 2 3 4; 3 2 1; 5 2 3] |

only for 2x2 and 3x3 matrices.

LU decomposition methods comes later.

- Sequence new range operator '..' i.e. 's[n..m]':

returns vector if elements are scalars.

returns matrix if elements are vectors.

- Enhancments in parsing and exceptions handling.

- RotationalStiffness Torque / Angle

- Momentum Mass * Velocity

- MassMomentOfInteria I <kg.m!^2> like the regular mass

- AngularMomentum Mass Moment Of Interia * Angular Velocity

I had fun and hard time playing with microsoft DLR to reach this status.

I am introducing a new Sequence concept in my calculator for expressing the Series in math.

for example to define the exponential http://en.wikipedia.org/wiki/Exponential_function function you can declare a sequence

then get the value as a Series

The feature is very important especially if you want to make a numerical differential function

- Factorial has been enhanced to include real positive numbers i.e. writing 3.5<m>! = 11.6317283996629 <m^3.5>
- Heavy optimizations for calculations - now calling the same conversion from unit to unit is cached during the session.
- Enhacing Qs hosting to be used dynamically inside any .NET applications using DLR hosting APIs.
- ScriptRuntime sr = Qs.Qs.CreateRuntime();
- var QsScope = sr.ExecuteFile("test.qs");
- var QsEngine = sr.GetEngine("Qs");
- var a = QsEngine.Execute("a=5<m>", QsScope) as AnyQuantity<double>;

- Specific Weight quantity added it is the result of greek letter gamma = Density * Acceleration

- Gravitional System namespace under metric namespace added three new units (finally I figured out what it is really mean :) )
- <hyl> for mass
- <gf> Gramforce
- <p> small letter for Pond unit which equal to <gf> Remeber <P> in capital is Poise
- <grain> renamed to <gr> Grain unit
- <pdl> Poundal unit added = <lbm.ft/s^2>

- Differentiate between Radius Length and Normal Length on the unit entering bases so now you can easily create Torque quantity with units like 40<N.m!>. The '!' unit modifier tell the calculator that we need Radius Length instead of normal length. This is valid for all length units like ft, in, yd, etc.

- Factorial Operator '!' added for calculating factorials for integer numbers {working on real numbers later}.
- so this is a valid calculation 5<kg>! / 4<L>!
- Functions also is getting used from factorials
- Qs> C(n,k) = n!/(k!*(n-k)!) #Combinications
- Qs> P(n,r) = n!/(n-r)! #Permutations

- Enhancing the raise to power to include fraction exponents. this means you can get the square root to the quantity.
- 100<kg>^0.5 = 10<kg^0.5>
- more over this is a valid operation: 20<m> + 30<ft^2>^0.5 + 10<ha>^0.5
- however you can't create quantities based on fraction unit exponents {I don't think we need this for now}

- Optimization for the whole calculator for more speed specifically for the double storage type and for the parsing code.

- Functions now can refer to global variables in the scope if they were declared. given that there is no parameter with the same name.
- Qs> a=10
- Qs> f(x) = x/a

- DLR engine is separated now from the calculator (this way you can call the engine and host the calculator in your .net language)

- VolumeFlowRate

- <cfm> Cubic feet per minute
- <gpm> Gallon per minute

- Power operator has been add x^2 -- Cautious {you only can raise to dimensionless numbers}
- More toward DLR support: the program is entirely run under QsHost which subclass DLR ConsoleHost
- Functions appear for the first time

Declaration is normal like ordinary math

Qs> f(x) = x^2+64

Qs> f(x,y) = x/y

Called

Qs> 10 - f(f(40,20)) + 20

DimensionlessQuantity: -38 <1>

}

- Correct the <1> unit in parsing which affected <1/kg> and all units
- Calculating numbers that start with sign - or
__(fixed) so this is valid a=-2____324--392__50<m/ft> - Adding Angle Quantity to Dimensionless Quantities is valid now

-----------------------------------------

Qs> 1 + 10 <rad>

DimensionlessQuantity: 11 <1>

Qs> 1 + 10 <deg>

DimensionlessQuantity: 1.17453292519943 <1>

Qs> 10<deg> + 1

Angle: 67.2957795130823 deg

Qs> 10<rad> + 1

Angle: 11 rad

-------------------------------------------------

}

and with units taken into consideration also.

- Molar Mass g/mol
- Heat Capacity J/K

- lbmol pound mol

- Colors changed :)
- SpecificVolume Quantity Added
- Calculations of operators priority fixed and Parenthesis support added.

- Add support for parsing units with exponent like <cm^2>
- Add support for simple mixed units with one '/' division character <kg.m/s^2> gives Force Quantity
- The first use the DLR Expressions instead of Linq Expressions

{also because built in linq expressions make errors in mono under linux :( }

- psi for pound per square inch for pressure

- Fixing of Metric Prefix multiplication and division (although need testing).
- conversion from metric units had an error because exponent wasn't taken in consideration.

- Electric Charge
- Electromotive Force
- Capacitance
- Electric Conductance
- Electric Resistance
- Magnetic Flux
- Magnetic Flux Density
- Inductance
- Luminous Flux
- Illuminance
- Catalytic Activity

- Coulomb 'C'
- Farad 'F'
- Volt 'V'
- Siemens 'S'
- Ohm 'ohm'
- Weber 'Wb'
- Tesla 'T'
- Henry 'H'
- Lumen 'lm'
- Lux 'lx'
- Katal 'kat' => mol/s

- AstronomicalUnit symbol changed from 'AU' to 'au'
- Light Year Length added 'ly'
- Parsec unit length 'pc' with metric support
- Solar Mass unit 'Mo'
- Julian Year unit 'a'

- Are unit of area symnol changed from 'a' to 'are'

- u unified mass of atom added 'u' = 'Da'
- Dalton transfered to Natural Units

- Second 's' transfered to Shared unit system

- Angle units
- Arc Degree unit added 'deg' ==>this is simple the angle degrees
- Arc Minute unit 'arcmin'
- Arc Second unit 'arcsec'
- Milli Arc Second 'mas'
- Gradian unit 'grad'
- Revolution unit 'r' whole one cycle = 360<deg>

- Angstrom Transfered to Misc namespace

- Time units
- Minute unit 'min'
- Hour unit 'h'
- Day unit 'd'

- Volume units
- Cubit Centimetre 'cc'

Last edited Mar 21 at 8:49 AM by IBlueSun, version 27