Index: /trunk/archive/pslib/include/psMath.h
===================================================================
--- /trunk/archive/pslib/include/psMath.h	(revision 217)
+++ /trunk/archive/pslib/include/psMath.h	(revision 218)
@@ -1,101 +1,4 @@
 #if !defined (PS_MATH_H)
 #define PS_MATH_H
-
-typedef enum {				// type of val is:
-    PS_DATA_FLOAT,			// float (.f)
-    PS_DATA_INT,			// int (.i)
-    PS_DATA_ARRAY,			// array (.v)
-    PS_DATA_IMAGE,			// image (.v)
-    PS_DATA_NTYPE			// Number of types; must be last
-} psDataItemType;
-
-/// basic data structure.
-typedef struct {
-    int id;
-    char *name;
-    psDataItemType type;
-    union {
-	float f;
-	int i;
-	void *v;
-    }
-} psDataItem;
-
-psDataItem *
-psDataItemBinaryOp (psDataItem *out,	///< destination value (may be NULL) 
-		    psDataItem *in1,	///< first input value 
-		    char *operator,	///< operator 
-		    psDataItem *in2	///< second input value 
-);
-
-psDataItem *
-psDataItemUnaryOp (psDataItem *out,	///< destination value (may be NULL) 
-		   psDataItem *in1,	///< input value 
-		   char *operator	///< operator 
-);
-
-/*** test: given an image "A", calculate log (a^2) ***/
-
-/*** example 1: data type abstraction */
-
-/*
-psImage A, Y;
-psDI a, b, x, y;
-
-a.v = A;
-a.type = PS_DATA_IMAGE;
-x.f = 2.0;
-x.type = PS_DATA_FLOAT;
-
-b = psDataItemBinaryOp (NULL, a, "^", x);
-y = psDataItemUnaryOp (NULL, b, "log");
-Y = y.v;
-*/
-
-/*** example 2: explicit functions ***/
-
-/*
-psImage A, B, Y;
-
-B = psImageOpScalar (NULL, A, "^", 2.0);
-Y = psImageOp (NULL, B, "log");
-*/
-
-/* in the later example, we would have the following functions */
-
-/// Perform a binary operation on two images.
-psImage *
-psImageOpImage (psImage *out,		///< destination image (may be NULL) 
-		psImage *in1,		///< first input image 
-		char *operator,		///< operator 
-		psImage *in2		///< second input image 
-);
-
-/// Perform a binary operation on two images.
-psImage *
-psImageOpScalar (psImage *out,		///< destination image (may be NULL) 
-		 psImage *in1,		///< input image 
-		 char *operator,	///< operator 
-		 float in2		///< input float 
-);
-
-/// Perform a binary operation on two images.
-psImage *
-psScalarOpImage (psImage *out,		///< destination image (may be NULL) 
-		 float in1,		///< input float 
-		 char *operator,	///< operator 
-		 psImage *in2		///< input image 
-);
-
-/** for a set of N data types, you need a collection of N^2 - 1 functions **/
-
-/*** example 3: embedded data type */
-
-/*
-psImage A, B, Y;
-
-B = psBinaryOp (NULL, A, "^", psScalar(2));
-Y = psUnaryOp (NULL, B, "log");
-*/
 
 /** in this method, the data types (psImage, psVector) include embedded information about their data type in
@@ -106,4 +9,29 @@
  */
 
+/** Perform a binary operation on two data items (psImage, psVector, psScalar). */
+psType *
+psBinaryOp (void *out,			///< destination (may be NULL) 
+	    void *in1,			///< first input
+	    char *operator,		///< operator 
+	    void *in2			///< second input
+);
+
+/** Perform a binary operation on two data items (psImage, psVector, psScalar). */
+psType *
+psUnaryOp (void *out,			///< destination (may be NULL) 
+	   void *in,			///< input
+	   char *operator,		///< operator 
+);
+
+/** create a psType-ed structure from a constant value. */
+p_ps_Scalar *
+psScalar (double value);
+
+/** create a psType-ed structure from a specified type  */
+p_ps_Scalar *
+psScalarType (char *mode, 		///< type description 
+	      ...			///< value (or values) of specified types
+);
+
 typedef struct {
     psType type;
@@ -112,6 +40,31 @@
 	float f;
 	double d;
+	complex float c;
     }
 } p_psScalar;
 
+/* examples of usage:
+
+psImage A, B, C;
+psVector X, Y;
+
+calculate C = sin(A^2)
+
+B = psBinaryOp (NULL, A, "^", psScalar(2));
+C = psUnaryOp (NULL, B, "sin");
+psFree (B);
+
+calculate Y = X^2
+
+Y = psBinaryOp (NULL, Y, "^", psScalar(2));
+
+Y = psBinaryOp (NULL, A, "^", X);
+
+Y = psBinaryOp (NULL, A, "^", psVectorTranspose(X));
+
+psFree (B);
+
+*/
+
+
 #endif
Index: /trunk/archive/pslib/include/psStdArrays.h
===================================================================
--- /trunk/archive/pslib/include/psStdArrays.h	(revision 217)
+++ /trunk/archive/pslib/include/psStdArrays.h	(revision 218)
@@ -8,30 +8,31 @@
 /** Types of the elements of vectors, matrices, etc. */
 enum {
-    PS_TYPE_CHAR,			//!< Character
-    PS_TYPE_SHORT,			//!< Short integer
-    PS_TYPE_INT,			//!< Integer
-    PS_TYPE_LONG,			//!< Long integer
-    PS_TYPE_UCHAR,			//!< Unsigned character
-    PS_TYPE_USHORT,			//!< Unsigned short integer
-    PS_TYPE_UINT,			//!< Unsigned integer
-    PS_TYPE_ULONG,			//!< Unsigned long integer
-    PS_TYPE_FLOAT,			//!< Floating point
-    PS_TYPE_DOUBLE,			//!< Double-precision floating point
-    PS_TYPE_COMPLEX			//!< Complex numbers consisting of floating point
-    PS_TYPE_OTHER			//!< Something else that's not supported for arithmetic
+    PS_TYPE_CHAR,			///< Character
+    PS_TYPE_SHORT,			///< Short integer
+    PS_TYPE_INT,			///< Integer
+    PS_TYPE_LONG,			///< Long integer
+    PS_TYPE_UCHAR,			///< Unsigned character
+    PS_TYPE_USHORT,			///< Unsigned short integer
+    PS_TYPE_UINT,			///< Unsigned integer
+    PS_TYPE_ULONG,			///< Unsigned long integer
+    PS_TYPE_FLOAT,			///< Floating point
+    PS_TYPE_DOUBLE,			///< Double-precision floating point
+    PS_TYPE_COMPLEX			///< Complex numbers consisting of floating point
+    PS_TYPE_OTHER			///< Something else that's not supported for arithmetic
 } psElemType;
 
 /** Dimensions of a data type */
 enum {
-    PS_DIMEN_SCALAR,			//!< Scalar
-    PS_DIMEN_VECTOR,			//!< A vector
-    PS_DIMEN_MATRIX,			//!< A matrix
-    PS_DIMEN_OTHER			//!< Something else that's not supported for arithmetic
+    PS_DIMEN_SCALAR,			///< Scalar
+    PS_DIMEN_VECTOR,			///< A vector
+    PS_DIMEN_TRANSV,			///< A transposed vector
+    PS_DIMEN_MATRIX,			///< A matrix
+    PS_DIMEN_OTHER			///< Something else that's not supported for arithmetic
 } psDimen;
 
 /** The type of a data type */
 typedef struct {
-    enum psElemType type;		//!< The type
-    enum psDimen dimen;			//!< The dimensionality
+    enum psElemType type;		///< The type
+    enum psDimen dimen;			///< The dimensionality
 } psType;
 
@@ -71,20 +72,20 @@
 /** An array of real numbers */
 typedef struct {
-    enum psType type;			//!< Type of data.  THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
-    int size;				//!< Total number of elements available
-    int n;				//!< Number of elements in use
-    float *arr;				//!< The array data
+    enum psType type;			///< Type of data.  THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
+    int size;				///< Total number of elements available
+    int n;				///< Number of elements in use
+    float *arr;				///< The array data
 } psFloatArray;
 
 /** Constructor */
-psFloatArray *psFloatArrayAlloc(int s,	//!< Total number of elements to make available
-				int n	//!< Number of elements that will be used
+psFloatArray *psFloatArrayAlloc(int s,	///< Total number of elements to make available
+				int n	///< Number of elements that will be used
     );
 /** Reallocator */
-psFloatArray *psFloatArrayRealloc(psFloatArray *myArray, //!< Array to reallocate
-				  int s	//!< Total number of elements to make available
+psFloatArray *psFloatArrayRealloc(psFloatArray *myArray, ///< Array to reallocate
+				  int s	///< Total number of elements to make available
     );
 /** Destructor */
-void psFloatArrayFree(psFloatArray *restrict myArray //!< Array to free
+void psFloatArrayFree(psFloatArray *restrict myArray ///< Array to free
     );
 
@@ -93,7 +94,7 @@
 /** Define a vector as an array of real numbers */
 typedef psFloatArray psVector;
-#define psVectorAlloc(S,N) psFloatArrayAlloc(S,N) //!< Constructor
-#define psVectorRealloc(A,S) psFloatArrayRealloc(A,S) //!< Reallocator
-#define psVectorFree(A) psFloatArrayFree(A) //!< Destructor
+#define psVectorAlloc(S,N) psFloatArrayAlloc(S,N) ///< Constructor
+#define psVectorRealloc(A,S) psFloatArrayRealloc(A,S) ///< Reallocator
+#define psVectorFree(A) psFloatArrayFree(A) ///< Destructor
 
 /************************************************************************************************************/
@@ -101,20 +102,20 @@
 /** An array of complex numbers */
 typedef struct {
-    enum psType type;			//!< Type of data.  THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
-    int size;				//!< Total number of elements available
-    int n;				//!< Number of elements in use
-    complex float *arr;			//!< The array data
+    enum psType type;			///< Type of data.  THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
+    int size;				///< Total number of elements available
+    int n;				///< Number of elements in use
+    complex float *arr;			///< The array data
 } psComplexArray;
 
 /** Constructor */
-psComplexArray *psComplexArrayAlloc(int s, //!< Total number of elements to make available
-				    int n	//!< Number of elements that will be used
+psComplexArray *psComplexArrayAlloc(int s, ///< Total number of elements to make available
+				    int n	///< Number of elements that will be used
     );
 /** Reallocator */
-psComplexArray *psComplexArrayRealloc(psComplexArray *myArray, //!< Array to reallocate
-				      int s	//!< Total number of elements to make available
+psComplexArray *psComplexArrayRealloc(psComplexArray *myArray, ///< Array to reallocate
+				      int s	///< Total number of elements to make available
     );
 /** Destructor */
-void psComplexArrayFree(psComplexArray *restrict myArray //!< Array to free
+void psComplexArrayFree(psComplexArray *restrict myArray ///< Array to free
     );
 
@@ -123,20 +124,20 @@
 /** An array of integers */
 typedef struct {
-    enum psType type;			//!< Type of data.  THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
-    int size;				//!< Total number of elements available
-    int n;				//!< Number of elements in use
-    int *arr;				//!< The array data
+    enum psType type;			///< Type of data.  THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
+    int size;				///< Total number of elements available
+    int n;				///< Number of elements in use
+    int *arr;				///< The array data
 } psIntArray;
 
 /** Constructor */
-psIntArray *psIntArrayAlloc(int s,	//!< Total number of elements to make available
-			    int n	//!< Number of elements that will be used
+psIntArray *psIntArrayAlloc(int s,	///< Total number of elements to make available
+			    int n	///< Number of elements that will be used
     );
 /** Reallocator */
-psIntArray *psIntArrayRealloc(psIntArray *myArray, //!< Array to reallocate
-			      int s	//!< Total number of elements to make available
+psIntArray *psIntArrayRealloc(psIntArray *myArray, ///< Array to reallocate
+			      int s	///< Total number of elements to make available
     );
 /** Destructor */
-void psIntArrayFree(psIntArray *restrict myArray //!< Array to free
+void psIntArrayFree(psIntArray *restrict myArray ///< Array to free
     );
 
@@ -145,20 +146,20 @@
 /** An array of double-precision real numbers */
 typedef struct {
-    enum psType type;			//!< Type of data.  THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
-    int size;				//!< Total number of elements available
-    int n;				//!< Number of elements in use
-    double *arr;			//!< The array data
+    enum psType type;			///< Type of data.  THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
+    int size;				///< Total number of elements available
+    int n;				///< Number of elements in use
+    double *arr;			///< The array data
 } psDoubleArray;
 
 /** Constructor */
-psDoubleArray *psDoubleArrayAlloc(int s, //!< Total number of elements to make available
-				  int n	//!< Number of elements that will be used
+psDoubleArray *psDoubleArrayAlloc(int s, ///< Total number of elements to make available
+				  int n	///< Number of elements that will be used
     );
 /** Reallocator */
-psDoubleArray *psDoubleArrayRealloc(psDoubleArray *myArray, //!< Array to reallocate
-				    int s	//!< Total number of elements to make available
+psDoubleArray *psDoubleArrayRealloc(psDoubleArray *myArray, ///< Array to reallocate
+				    int s	///< Total number of elements to make available
     );
 /** Destructor */
-void psDoubleArrayFree(psDoubleArray *restrict myArray //!< Array to free
+void psDoubleArrayFree(psDoubleArray *restrict myArray ///< Array to free
     );
 
@@ -167,20 +168,20 @@
 /** An array of real vectors */
 typedef struct {
-    enum psType type;			//!< Type of data.  THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
-    int size;				//!< Total number of elements available
-    int n;				//!< Number of elements in use
-    psFloatArray *arr;			//!< The array data
+    enum psType type;			///< Type of data.  THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
+    int size;				///< Total number of elements available
+    int n;				///< Number of elements in use
+    psFloatArray *arr;			///< The array data
 } psVectorArray;
 
 /** Constructor */
-psVectorArray *psVectorArrayAlloc(int s, //!< Total number of elements to make available
-				  int n	//!< Number of elements that will be used
+psVectorArray *psVectorArrayAlloc(int s, ///< Total number of elements to make available
+				  int n	///< Number of elements that will be used
     );
 /** Reallocator */
-psVectorArray *psVectorArrayRealloc(psVectorArray *myArray, //!< Array to reallocate
-				    int s	//!< Total number of elements to make available
+psVectorArray *psVectorArrayRealloc(psVectorArray *myArray, ///< Array to reallocate
+				    int s	///< Total number of elements to make available
     );
 /** Destructor */
-void psVectorArrayFree(psVectorArray *restrict myArray //!< Array to free
+void psVectorArrayFree(psVectorArray *restrict myArray ///< Array to free
     );
 
