00001 /* $Revision: 1.5 $ $Date: 2006/09/08 18:56:52 $ $Author: dgl $ $Name: $ $Id: Musimat.h,v 1.5 2006/09/08 18:56:52 dgl Exp $ */ 00002 #ifndef MUSIMAT_H 00003 #define MUSIMAT_H 00004 00005 // The Musimat Tutorial � 2006 Gareth Loy 00006 // Derived from Chapter 9 and Appendix B of "Musimathics Vol. 1" � 2006 Gareth Loy 00007 // and published exclusively by The MIT Press. 00008 // This program is released WITHOUT ANY WARRANTY; without even the implied 00009 // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00010 // For information on usage and redistribution, and for a DISCLAIMER OF ALL 00011 // WARRANTIES, see the file, "LICENSE.txt," in this distribution. 00012 // "Musimathics" is available here: http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&tid=10916 00013 // Gareth Loy's Musimathics website: http://www.musimathics.com/ 00014 // The Musimat website: http://www.musimat.com/ 00015 // This program is released under the terms of the GNU General Public License 00016 // available here: http://www.gnu.org/licenses/gpl.txt 00020 00021 using namespace std; 00022 00023 #include "Aliases.h" 00024 #include "MathFuns.h" 00025 #include "Complex.h" 00026 #include "List.h" 00027 #include "Matrix.h" 00028 #include "Rational.h" 00029 #include "Rhythm.h" 00030 #include "Pitch.h" 00031 00034 extern Const Real Pi; 00035 00040 00042 typedef List<Integer> IntegerList; 00043 00045 typedef List<Real> RealList; 00046 00048 typedef List<String> StringList; 00049 00051 typedef List<Complex> ComplexList; 00052 00054 typedef List<Pitch> PitchList; 00055 00057 typedef List<Rational> RationalList; 00058 00060 typedef List<Rhythm> RhythmList; 00062 00066 00068 typedef Matrix<Integer> IntegerMatrix; 00069 00071 typedef Matrix<Real> RealMatrix; 00072 00074 typedef Matrix<String> StringMatrix; 00075 00077 typedef Matrix<Complex> ComplexMatrix; 00078 00080 typedef Matrix<Pitch> PitchMatrix; 00081 00083 typedef Matrix<Rational> RationalMatrix; 00084 00086 typedef Matrix<Rhythm> RhythmMatrix; 00087 00089 00090 00091 #include "Random.h" 00092 #include "Dynamics.h" 00093 #include "Pitches.h" 00094 #include "Row.h" 00095 00101 00104 template<class ListType> inline Real Max( ListType L ) { Return( L.max() ); } 00105 inline Complex Max( ComplexList L ) { Return( L.max() ); } 00106 inline Integer Max( IntegerList L ) { Return( L.max() ); } 00107 inline Rhythm Max( RhythmList L ) { Return( L.max() ); } 00108 inline Rational Max( RationalList L ) { Return( L.max() ); } 00109 inline Pitch Max( PitchList L ) { Return( L.max() ); } 00110 00113 template<class ListType> inline Integer MaxPos( ListType L ) { Return( L.maxPos() ); } 00114 00117 template<class Type> inline Real Min( Type L ) { Return( L.min() ); } 00118 inline Complex Min( ComplexList L ) { Return( L.min() ); } 00119 inline Integer Min( IntegerList L ) { Return( L.min() ); } 00120 inline Rhythm Min( RhythmList L ) { Return( L.min() ); } 00121 inline Rational Min( RationalList L ) { Return( L.min() ); } 00122 inline Pitch Min( PitchList L ) { Return( L.min() ); } 00123 00126 template<class Type> inline Integer MinPos( Type L ) { Return( L.minPos() ); } 00128 00133 00136 template<class Type> Void Print(Type i) { cout << i << endl; } 00137 00140 template<class Type> Void Print(String s, Type i) { cout << s << i << endl; } 00142 00147 00150 Integer Length( RhythmList Reference L ); 00151 00155 Integer Length( String s ); 00157 00161 RationalList RealListToRationalList( RealList R ); 00162 00166 inline PitchList IntegerListToPitchList( IntegerList Reference L ) 00167 { 00168 PitchList P; 00169 For( Integer i = 0; i < Length( L ); i++ ) 00170 P[i] = L[i]; 00171 Return P; 00172 } 00173 00177 inline IntegerList PitchListToIntegerList( PitchList Reference P ) 00178 { 00179 IntegerList L; 00180 For( Integer i = 0; i < Length( P ); i++ ) 00181 L[i] = P[i]; 00182 Return L; 00183 } 00184 00185 #endif // MUSIMAT_H 00186