CodeCentral Submissions for Carlo Galotto
http://downloads.embarcadero.com/
CodeCentral Submissions for Carlo GalottoAlgebra between physical quantitiesBased on the MKSA (Meter, Kilogram, Second, Ampere) metric system, it allows managing a physical data as any other intrinsic type of data of the programming language. The framework is extendible to any kind of quantity foreseen by the MKSA metric system. Only the dimension declaration of the physical quantity is required. All the operations (sum, difference, division, multiplication) and admissible conversion (e.g. from mm to cm) between different units of measurement have been implemented. The quantities can be expressed both in a linear and logarithmic scale (dB). The framework is going to be extended in such away that it will be complaint with the IS (International System) and will allow conversion between different system of measurement (e.g. from feet to meters). In the following declaration it will be evident the analogy between the type of data and unit of measure (MHz), between the variable and the quantity (frequency) and between the value and the measurement (350) of the quantity:MHz frequency = 350;The framework redefines the arithmetic (*, /, +, -) and comparisons (<, >, !=, ==) operators so that we can write simple and safe code as the following:m L1;// declares L1 to be meterscm L2 = 20;// declares L2 to be 20 centimetres mm L3 = L2; // here the measurement of L3 is 200 millimetresL1 = 2;// assigns to L1 the value of 2 meters L1 += L2 + 60;// it is equivalent to sum 20 cm + 60 cm + 2 metres; // the result 2.8 meters is held in L1if(L1 > L3)// compares two homogenous quantities having different unitscm2 Area = L1*L2; //The measurement of the Area is 56000 square centimetres Any illegal operation (such as to sum MHz and millimetres) will be detected run time rising an exception.The trick of the previous code is related to the possibility to define different types of data (m, cm, cm2, Mhz, …) initialising in a different way the same template class (see the code for more details).
http://downloads.embarcadero.com/Item/17180
2002-01-07T22:14:482002-01-07T22:14:48http://downloads.embarcadero.com/Item/17180A GPIB IOStream LibraryAn example of specialisation of the Standard IOStream Library to usefully connect a computer to devices equipped with the standard (IEEE488) GPIB interface. The proposed framework extends the standard IOStream to support a generic (read as platform independent) GPIB interface.The example program and the GPIB framework were compiled with C++ Builder 5.0. We used a PC with Windows9x, the National Instrument PCI-GPIB card and the NI4288.2M driver for the testing.Updated release compliant with C++ Builder 5.Added a useful HTML help to allow a easier use of the library.
http://downloads.embarcadero.com/Item/14584
2002-01-06T11:52:542002-01-06T11:52:54http://downloads.embarcadero.com/Item/14584Piecewise Functions and Expression TemplatesThe intent of this framework is to use expression templates to build any kind of piecewise functions in a easy and extendible way. Incapsulating all kinds of functions with its paramaters in a class is not an easy deal if you try using the standard callback functions mechanism.The complexity grows even more in defining the domain of each piece of function.This framework is complete enough to allow to write directly the piecewise function using a human algebric format almost as you would do on a piece of paper. Here below some examples of how to use the framework PieseWiceFn<double> fn1( 1/(x-1), x > 1 ); // 1 PieseWiceFn<double> fn2( -x*x + 3.14*x + 1 ); // 2 PieseWiceFn<double> fn3; // 3 fn3.Add( m*x-c, x >= c/m && x < 2*c/m ); // 3.1 fn3.Add( -m*(x-2*c/m)+c, x >= 2*c/m && x <= 3*c/m ); // 3.2 double y = fn1(1.4); // 4in //1 the domain of x is every real (double) number greather than 1.in //2 domain of x is every real numberin //3 and the followings we build a parameterised (m, c) triangle function.in //4 the function fn3 is evaluated for x equal to 1.4
http://downloads.embarcadero.com/Item/17105
2001-11-26T22:47:532001-11-26T22:47:53http://downloads.embarcadero.com/Item/17105