public ILDXGraphSurf3D(ILDXPanel panel, ILBaseArray sourceArray,
                        ILClippingData clippingContainer)
     : base(sourceArray, clippingContainer)
 {
     m_localClipping = new ILClippingData();
     if (!sourceArray.IsMatrix)
     {
         throw new ILArgumentException("source arrray must be matrix!");
     }
     if (!sourceArray.IsNumeric)
     {
         throw new ILArgumentException("source arrray must be numeric!");
     }
     m_dxPanel = panel;
     m_dxPanel.GraphicsDeviceReset += new ILGraphicsDeviceResetEvent(m_dxPanel_GraphicsDeviceReset);
     m_cols          = m_sourceArray.Dimensions[0];
     m_rows          = m_sourceArray.Dimensions[1];
     m_Vertcount     = m_rows * m_cols;
     m_primitiveType = PrimitiveType.TriangleList;
     m_vertexReady   = false;
     m_indexReady    = false;
     m_rowsInChunk   = 1; // primitives per chunk
     m_primsInChunk  = m_cols * 2 * m_rowsInChunk;
     updateClipping();
     Configure();
 }
Example #2
0
        public void Test_Empty()
        {
            int errorCode = 0;

            try {
                ILBaseArray[] data = new ILBaseArray[60];
                for (int i = 0; i < data.Length; i++)
                {
                    data[i] = new ILArray <Int16>(new Int16[1] {
                        (Int16)i
                    });
                }
                ILCell           A   = new ILCell(data, 20, 3);
                ILArray <double> ind = new double[0] {
                };
                ILBaseArray elem     = A[null, ind];
                if (!(elem is ILCell))
                {
                    throw new Exception("empty return from ILCell should be ILCell");
                }
                Success();
            } catch (Exception e) {
                Error(errorCode, e.Message);
            }
        }
 /// <summary>
 /// create composite shape
 /// </summary>
 /// <param name="panel">hosting panel</param>
 /// <param name="verticesPerShape">number of vertices per shape</param>
 /// <param name="X">x coordinates vector </param>
 /// <param name="Y">y coordinates vector </param>
 /// <param name="Z">z coordinates vector </param>
 /// <param name="colors">matrix with <see cref="ILNumerics.Drawing.Shapes.ILShape.VertexCount"/>
 /// rows, 3 columns for (R,G,B) or 4 columns for
 /// (A,R,G,B) for every vertex specified by X,Y,Z. Elements must range from 0..255. If colors
 /// has 3 columns only, alpha values of 255 are used as default.</param>
 /// <param name="mapping">Mapping of shapes, composes shapes out of vertices. Matrix having
 /// <see cref="ILNumerics.Drawing.Shapes.ILShape&lt;T>.VerticesPerShape"/> rows.
 /// Every element in a column specifies the index of a vertex according to its position in X,Y,Z.
 /// The <see cref="ILNumerics.Drawing.Shapes.ILShape&lt;T>.VerticesPerShape"/> elements in a column therefore
 /// compose a single shape. Vertices may get used arbitrary times (or not at all). All elements must be
 /// positive integer values in range 0...[<see cref="ILNumerics.Drawing.Shapes.ILShape.VertexCount"/>-1].</param>
 public ILCompositeShape(ILPanel panel, int verticesPerShape, ILBaseArray X, ILBaseArray Y, ILBaseArray Z, ILBaseArray colors, ILBaseArray mapping)
     : base(panel, X.Length, verticesPerShape)
 {
     Update(X, Y, Z, mapping, colors);
     Opacity   = 255;
     m_shading = ShadingStyles.Interpolate;
 }
Example #4
0
        /// <summary>
        /// create new lit surface, provide data for X,Y and Z coordinates
        /// </summary>
        /// <param name="panel">the panel hosting the scene</param>
        /// <param name="X">X coordinates matrix, same size as Z or null</param>
        /// <param name="Y">Y coordinates matrix, same size as Z or null</param>
        /// <param name="Z">Z data matrix, at least 2 rows, 2 columns</param>
        /// <param name="colormap">colormap used for auto coloring the surface</param>
        public ILLitSurface(ILPanel panel, ILBaseArray X, ILBaseArray Y, ILBaseArray Z, ILColormap colormap)
            : base(panel)
        {
            if (Z == null || Z.Dimensions[0] < 2 || Z.Dimensions[1] < 2)
            {
                throw new ArgumentException("invalid parameter size: Z");
            }
            if (X == null || !X.Dimensions.IsSameSize(Z.Dimensions))
            {
                throw new ArgumentException("invalid parameter size: X");
            }
            if (Y == null || !Y.Dimensions.IsSameSize(Z.Dimensions))
            {
                throw new ArgumentException("invalid parameter size: Y");
            }
            m_quads            = new ILLitQuads(panel, Z.Dimensions.NumberOfElements);
            m_quads.Label.Text = "";
            m_quads.Shading    = ShadingStyles.Interpolate;
            Add(m_quads);
            m_colorMap = colormap;
            ZValues    = Z;
            XValues    = X;
            YValues    = Y;

            Invalidate();
        }
        /// <summary>
        /// update composite shape
        /// </summary>
        /// <param name="X">x coordinates, vector of length <see cref="ILNumerics.Drawing.Shapes.ILShape.VertexCount"/></param>
        /// <param name="Y">y coordinates, vector of length <see cref="ILNumerics.Drawing.Shapes.ILShape.VertexCount"/></param>
        /// <param name="Z">z coordinates, vector of length <see cref="ILNumerics.Drawing.Shapes.ILShape.VertexCount"/></param>
        /// <param name="mapping">Mapping of shapes, composes shapes out of vertices. Matrix having
        /// <see cref="ILNumerics.Drawing.Shapes.ILShape&lt;T>.VerticesPerShape"/> rows.
        /// Every element in a column specifies the index of a vertex according to its position in X,Y,Z.
        /// The <see cref="ILNumerics.Drawing.Shapes.ILShape&lt;T>.VerticesPerShape"/> elements in a column therefore
        /// compose a single shape. Vertices may get used arbitrary times (or not at all). All elements must be
        /// positive integer values in range 0...[<see cref="ILNumerics.Drawing.Shapes.ILShape.VertexCount"/>-1].</param>
        /// <remarks>All vertices of the shape are updated with the data specified in X,Y and Z. Neither the colors or any
        /// other data of vertices are changed. The shape is invalidated for reconfiguration at next redraw. </remarks>
        public void Update(ILBaseArray X, ILBaseArray Y, ILBaseArray Z, ILBaseArray mapping)
        {
            if (!X.IsVector || !Y.IsVector || !Z.IsVector || X.Length != Y.Length || Y.Length != Z.Length)
            {
                throw new ILArgumentException("numeric vectors of same length expected for: X, Y and Z");
            }
            if (mapping == null || mapping.IsEmpty || !mapping.IsMatrix || !mapping.IsNumeric || mapping.Dimensions[0] != VerticesPerShape)
            {
                throw new ILArgumentException("mapping must be a numeric matrix, " + VerticesPerShape.ToString() + " rows, each column specifies indices for the vertices of a single shape.");
            }
            if (mapping is ILArray <int> )
            {
                m_shapeIndices = (mapping as ILArray <int>).C;
            }
            else
            {
                m_shapeIndices = ILMath.toint32(mapping);
            }
            ILArray <float> fX = ILMath.tosingle(X);
            ILArray <float> fY = ILMath.tosingle(Y);
            ILArray <float> fZ = ILMath.tosingle(Z);

            for (int i = 0; i < m_vertices.Length; i++)
            {
                m_vertices[i].XPosition = fX.GetValue(i);
                m_vertices[i].YPosition = fY.GetValue(i);
                m_vertices[i].ZPosition = fZ.GetValue(i);
            }
            Invalidate();
        }
 /// <summary>
 /// create new bordered shape, provide initial vertex data
 /// </summary>
 /// <param name="panel">panel hosting the scene</param>
 /// <param name="X">X coordinates, vector of length 'VertexCount'</param>
 /// <param name="Y">Y coordinates, vector of length 'VertexCount'</param>
 /// <param name="Z">Z coordinates, vector of length 'VertexCount'</param>
 public ILBorderedShape(ILPanel panel, ILBaseArray X, ILBaseArray Y, ILBaseArray Z)
     : this(panel, (X != null && X.IsVector) ? X.Length
                    : (Y != null && Y.IsVector) ? Y.Length
                    : (Z != null && Z.IsVector) ? Z.Length
                    : 0)
 {
     Update(X, Y, Z);
 }
Example #7
0
 /// <summary>
 /// Number of dimensions of A
 /// </summary>
 /// <param name="A">input array</param>
 /// <returns>if A is null: 0 - else number of dimensions of A</returns>
 /// <remarks>this is an alias/abreviation for A.Dimensions.NumberOfDimensions</remarks>
 ///
 public static int ndims(ILBaseArray A)
 {
     if (object.Equals(A, null))
     {
         return(0);
     }
     return(A.Dimensions.NumberOfDimensions);
 }
Example #8
0
 /// <summary>
 /// Number of elements of A
 /// </summary>
 /// <param name="A">input array</param>
 /// <returns>number of elements of A</returns>
 /// <remarks>this is an alias/abreviation for A.Dimensions.NumberOfElements</remarks>
 public static int numel(ILBaseArray A)
 {
     if (object.Equals(A, null))
     {
         return(0);
     }
     return(A.Dimensions.NumberOfElements);
 }
Example #9
0
 public ILOGLSurfaceGraph(ILOGLPanel panel, ILBaseArray X,
                          ILBaseArray Y, ILBaseArray Z, ILBaseArray C,
                          ILClippingData clippingContainer)
     : base(panel, X, Y, Z, C, clippingContainer)
 {
     m_indexReady  = false;
     m_vertexReady = false;
 }
Example #10
0
 /// <summary>
 /// length of one specific dimension of A
 /// </summary>
 /// <param name="A">input array</param>
 /// <param name="dim">number of dimension to query the length for</param>
 /// <returns>length of dimension 'dim'</returns>
 public static int size(ILBaseArray A, int dim)
 {
     if (object.Equals(A, null) || dim < 0)
     {
         throw new ILArgumentException("size: A must not be null");
     }
     return(A.Dimensions[dim]);
 }
Example #11
0
 /// <summary>
 /// create lines composite shape
 /// </summary>
 /// <param name="panel">hosting panel</param>
 /// <param name="X">x coordinates vector </param>
 /// <param name="Y">y coordinates vector </param>
 /// <param name="Z">z coordinates vector </param>
 /// <param name="colors">matrix with <see cref="ILNumerics.Drawing.Shapes.ILShape.VertexCount"/>
 /// rows, 3 columns for (R,G,B) or 4 columns for
 /// (A,R,G,B) for every vertex specified by X,Y,Z. Elements must range from 0..255. If colors
 /// has 3 columns only, alpha values of 255 are used as default.</param>
 /// <param name="mapping">Mapping of shapes, composes shapes out of vertices. Matrix having
 /// 2 rows. Every element in a column specifies the index of a vertex according to its position in X,Y,Z.
 /// The 2 elements in a column therefore compose a single line. Vertices may get used arbitrary times
 /// (or not at all). All elements must be positive integer values in range
 /// 0...[<see cref="ILNumerics.Drawing.Shapes.ILShape.VertexCount"/>-1].</param>
 public ILLines(ILPanel panel, ILBaseArray X, ILBaseArray Y, ILBaseArray Z, ILBaseArray colors, ILBaseArray mapping)
     : base(panel, 2, X, Y, Z, colors, mapping)
 {
     m_fillColor           = Color.Blue;
     m_properties          = new ILLineProperties();
     m_properties.Color    = Color.Blue;
     m_properties.Changed += new EventHandler(m_properties_Changed);
 }
Example #12
0
 /// <summary>
 /// longest dimension of A
 /// </summary>
 /// <param name="A">input array</param>
 /// <returns>if A is null:0 - length of longest dimension of A</returns>
 /// <remarks>this is an alias/abreviation for A.Dimensions.Longest</remarks>
 public static int length(ILBaseArray A)
 {
     if (object.Equals(A, null))
     {
         return(0);
     }
     return(A.Dimensions.Longest);
 }
Example #13
0
 public ILDXGraphPlot2D(ILDXPanel panel, ILBaseArray sourceArray,
                        ILClippingData clippingContainer)
     : base(sourceArray, clippingContainer)
 {
     m_dxPanel   = panel;
     m_graphType = GraphType.Plot2D;
     m_dxPanel.GraphicsDeviceReset += new ILGraphicsDeviceResetEvent(m_dxPanel_GraphicsDeviceReset);
     create();
 }
Example #14
0
 /// <summary>
 /// construct new surface graph, provide all 3 coordinates
 /// </summary>
 /// <param name="panel">panel this graph is to be hosted in</param>
 /// <param name="X">X coordinates</param>
 /// <param name="Y">Y coordinates</param>
 /// <param name="Z">Z coordinates</param>
 /// <param name="C">Color values</param>
 /// <param name="clippingContainer"></param>
 public ILSurfaceGraph (ILPanel panel, ILBaseArray X, ILBaseArray Y, 
                        ILBaseArray Z, ILBaseArray C, ILClippingData clippingContainer)
     : base (panel, X,Y,Z,C, clippingContainer) {
     m_graphType = GraphType.Surf; 
     m_wireLines.Width = 1;
     m_wireLines.Antialiasing = false; 
     m_wireLines.Color = System.Drawing.Color.Blue;
     m_opacity = 0.84f;
 }
 /// <summary>
 /// create composite shape
 /// </summary>
 /// <param name="panel">hosting panel</param>
 /// <param name="verticesPerShape">number of vertices per shape</param>
 /// <param name="X">x coordinates vector </param>
 /// <param name="Y">y coordinates vector </param>
 /// <param name="Z">z coordinates vector </param>
 /// <remarks>The constructor creates a new composite shape out of all vertices specified in X,Y and Z.
 /// Every vertex is only used once. Every shape uses
 /// <see cref="ILNumerics.Drawing.Shapes.ILShape&lt;T>.VerticesPerShape"/> vertices one after another.</remarks>
 public ILCompositeShape(ILPanel panel, int verticesPerShape, ILBaseArray X, ILBaseArray Y, ILBaseArray Z)
     : base(panel, X.Length, verticesPerShape)
 {
     Update(X, Y, Z);
     m_shapeIndices = ILMath.toint32(
         ILMath.counter(0.0, 1.0, VerticesPerShape, m_vertCount / VerticesPerShape));
     Opacity   = 255;
     m_shading = ShadingStyles.Flat;
 }
Example #16
0
 /// <summary>
 /// create a new 3D Bar Graph plot, provide data matrix
 /// </summary>
 /// <param name="panel">panel hosting the scene</param>
 /// <param name="data">data matrix, at least 2x2 entries</param>
 public ILBarGraph3D(ILPanel panel, ILBaseArray data)
     : base(panel)
 {
     if (data == null)
     {
         throw new ILArgumentException("data argument must not be null!");
     }
     create(data, Colormaps.ILNumerics);
 }
Example #17
0
 /// <summary>
 /// construct new surface graph, provide all 3 coordinates
 /// </summary>
 /// <param name="panel">panel this graph is to be hosted in</param>
 /// <param name="X">X coordinates</param>
 /// <param name="Y">Y coordinates</param>
 /// <param name="Z">Z coordinates</param>
 /// <param name="C">Color values</param>
 /// <param name="clippingContainer"></param>
 public ILSurfaceGraph(ILPanel panel, ILBaseArray X, ILBaseArray Y,
                       ILBaseArray Z, ILBaseArray C, ILClippingData clippingContainer)
     : base(panel, X, Y, Z, C, clippingContainer)
 {
     m_graphType              = GraphType.Surf;
     m_wireLines.Width        = 1;
     m_wireLines.Antialiasing = false;
     m_wireLines.Color        = System.Drawing.Color.Blue;
     m_opacity = 0.84f;
 }
Example #18
0
 public ILImageSCGraph (ILPanel panel, ILBaseArray X, ILBaseArray Y,
                         ILBaseArray Z,ILBaseArray C,
                         ILClippingData clippingContainer)
     : base (panel, X,Y,Z,C, clippingContainer) {
     m_cols = m_sourceArray.Dimensions[1]+1; 
     m_rows = m_sourceArray.Dimensions[0]+1; 
     m_Vertcount = m_rows * m_cols;
     // defaults
     m_zPosition = float.NegativeInfinity;
 }
        /// <summary>
        /// Add new graph(s) of arbitrary type, provide both axis data
        /// </summary>
        /// <param name="xData">x coordinates </param>
        /// <param name="graphType">type of graph to be added</param>
        /// <param name="yData">y coordinates</param>
        /// <returns>List with newly created graph(s)</returns>
        /// <remarks>The return value will be a list of all graphs created (and added),
        /// since more than one graph may have been specified. This depends on the
        /// shape of the data provided.
        /// <para>Currently only Plot2D graphs are supported as GraphType! </para></remarks>
        /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if the data provided are nor
        /// numeric or the size for one of the arrays <typeparamref name="xData"/> or <typeparamref name="yData"/>
        /// do not match. </exception>
        public List <ILGraph> Add(ILBaseArray xData, ILBaseArray yData, GraphType graphType)
        {
            if (!yData.IsNumeric || !xData.IsNumeric)
            {
                throw new ILArgumentException("Add graph: data arrays must be numeric!");
            }
            List <ILGraph>  ret = new List <ILGraph>();
            ILGraph         newGraph;
            ILArray <float> tmpDataY, tmpDataX;

            lock (this) {
                #region add each graph type seperately
                switch (graphType)
                {
                case GraphType.Plot2D:
                    if (!yData.Dimensions.IsSameSize(xData.Dimensions))
                    {
                        throw new ILArgumentException("Add graph: for X/Y plots, the size of X and Y must be equal!");
                    }
                    if (yData.IsVector || yData.IsScalar)
                    {
                        newGraph = m_graphFact.CreateGraph(yData, graphType, xData);
                        Add(newGraph);
                        newGraph.Changed += new ILGraphChangedEvent(GraphChanged);
                        m_clippingData.Update(newGraph.Limits);
                        ret.Add(newGraph);
                    }
                    else if (yData.IsMatrix)
                    {
                        // plot columns
                        m_clippingData.EventingSuspend();
                        tmpDataY = ILMath.tosingle(yData);
                        tmpDataX = ILMath.tosingle(xData);
                        for (int c = 0; c < tmpDataY.Dimensions[1]; c++)
                        {
                            newGraph = m_graphFact.CreateGraph(tmpDataY[null, c], graphType, tmpDataX[null, c]);
                            Add(newGraph);
                            newGraph.Changed += new ILGraphChangedEvent(GraphChanged);
                            ret.Add(newGraph);
                            m_clippingData.Update(newGraph.Limits);
                        }
                        m_clippingData.EventingResume();
                    }
                    // trigger change event
                    OnChange(ret[0], GraphCollectionChangeReason.Added, null);
                    break;

                default:
                    throw new ILDrawingException("graph type is not supported in that mode yet!");
                }
                #endregion
            }
            return(ret);
        }
Example #20
0
        /// <summary>
        /// [internal] constructor - do not use this! Use ILPanel.Graphs.Add...() instead!
        /// </summary>
        /// <param name="panel">panel hosting the scene</param>
        /// <param name="XData">x data array</param>
        /// <param name="YData">y data array</param>
        /// <param name="clippingContainer">hosting panels clipping data</param>
        public ILPlot2DGraph(ILPanel panel, ILBaseArray XData, ILBaseArray YData,
                             ILClippingData clippingContainer)
            : base(panel, clippingContainer)
        {
            if (!XData.IsVector)
            {
                throw new ILArgumentException("Plot2D: supplied data must be a real vector!");
            }
            if (!YData.IsVector)
            {
                throw new ILArgumentException("Plot2D: XData and YData must be real vectors!");
            }
            if (YData.Length != XData.Length)
            {
                throw new ILArgumentException("Plot2D: XData and YData must have the same length!");
            }
            int             pos = 0;
            ILArray <float> dataX, dataY;
            C4bV3f          vert = new C4bV3f();

            if (XData is ILArray <float> )
            {
                dataX = (ILArray <float>)XData;
            }
            else
            {
                dataX = ILMath.tosingle(XData);
            }
            if (YData is ILArray <float> )
            {
                dataY = (ILArray <float>)YData;
            }
            else
            {
                dataY = ILMath.tosingle(YData);
            }
            m_vertices            = new C4bV3f[dataX.Length + 1];
            m_vertexCount         = m_vertices.Length;
            m_startID             = m_vertexCount - 1;
            m_updateCount         = 0;
            m_properties          = new ILLineProperties();
            m_properties.Color    = Color.DarkBlue;
            m_properties.Changed += new EventHandler(m_properties_Changed);
            foreach (float val in dataX.Values)
            {
                vert.Position     = new ILPoint3Df(val, dataY.GetValue(pos), 0);
                vert.Color        = m_properties.Color;
                m_vertices[pos++] = vert;
            }
            m_marker          = new ILMarker(panel);
            m_marker.Changed += new EventHandler(m_marker_Changed);
            m_graphType       = GraphType.Plot2D;
            updateClipping();
        }
Example #21
0
        /// <summary>
        /// update vertices, may also alter number of line segments
        /// </summary>
        /// <param name="X">X coordinates</param>
        /// <param name="Y">Y coordinates</param>
        /// <param name="Z">Z coordinates</param>
        public override void Update(ILBaseArray X, ILBaseArray Y, ILBaseArray Z)
        {
            int newLen = Math.Max(Math.Max(X.Length, Y.Length), Z.Length);

            if (VertexCount != newLen)
            {
                m_numVerticesPerShape = newLen;
                Resize(newLen);
            }
            base.Update(X, Y, Z);
        }
Example #22
0
        public void Test_NameRestrictions()
        {
            int errorCode = 0;

            try {
                ILMatFile        ml = new ILMatFile();
                ILArray <double> A  = ILMath.rand(3, 23, 2);
                ml["hallo"] = A;
                ILBaseArray res = ml["hallo"];
                if (!res.Equals(A))
                {
                    throw new Exception("invalid array returned for : 'hallo'");
                }
                try {
                    ml[""] = A + 1;
                    throw new Exception("empty names are not allowed!");
                } catch (ILArgumentException) {
                    Info("empty name signaled correctly");
                }
                try {
                    ml["1fsdf"] = A + 1;
                    throw new Exception("names starting with numbers are not allowed!");
                } catch (ILArgumentException) {
                    Info("names starting with numbers signaled correctly");
                }
                try {
                    ml["invaldi name"] = A + 1;
                    throw new Exception("names with blank space are not allowed!");
                } catch (ILArgumentException) {
                    Info("names with blank space signaled correctly");
                }
                try {
                    ml["a$me"] = A + 1;
                    throw new Exception("names with invalid characters are not allowed!");
                } catch (ILArgumentException e) {
                    Info("names with invalid characters signaled correctly");
                }
                try {
                    A = (ILArray <double>)ml["hallo_"];
                    throw new Exception("key not found expected");
                } catch (ILArgumentException e) {
                    Info("missing key signaled correctly");
                }
                errorCode   = 2;
                ml["hallo"] = null;
                if (ml.Arrays.Length != 0)
                {
                    throw new Exception("unable to remove array from MatFile");
                }
                Success();
            } catch (Exception e) {
                Error(errorCode, e.Message);
            }
        }
Example #23
0
 public ILImageSCGraph(ILPanel panel, ILBaseArray X, ILBaseArray Y,
                       ILBaseArray Z, ILBaseArray C,
                       ILClippingData clippingContainer)
     : base(panel, X, Y, Z, C, clippingContainer)
 {
     m_cols      = m_sourceArray.Dimensions[1] + 1;
     m_rows      = m_sourceArray.Dimensions[0] + 1;
     m_Vertcount = m_rows * m_cols;
     // defaults
     m_zPosition = float.NegativeInfinity;
 }
Example #24
0
 public ILOGLImageSCGraph (ILOGLPanel panel, ILBaseArray X,
                           ILBaseArray Y,ILBaseArray Z,ILBaseArray C,  
                          ILClippingData clippingContainer) 
      : base(panel,X,Y,Z,C, clippingContainer) { 
     m_panel = panel; 
     m_localClipping.ZMax = 0; 
     m_localClipping.ZMin = 0; 
     m_localClipping.XMax = (float)m_cols+0.5f;
     m_localClipping.XMin = -0.5f; 
     m_localClipping.YMax = (float)m_rows+0.5f; 
     m_localClipping.YMin = -0.5f; 
 }
Example #25
0
 /// <summary>
 /// create new line, give vertices positions also
 /// </summary>
 /// <param name="panel">panel hosting the scene</param>
 /// <param name="X">X coordinates</param>
 /// <param name="Y">Y coordinates</param>
 /// <param name="Z">Z coordinates</param>
 public ILLine(ILPanel panel, ILBaseArray X, ILBaseArray Y, ILBaseArray Z)
     : base(panel, X, Y, Z)
 {
     m_fillColor             = Color.Black;
     m_border.Visible        = false;
     m_oldestVertexID        = 0;
     m_properties            = new ILLineProperties();
     m_properties.Changed   += new EventHandler(m_properties_Changed);
     m_properties.Color      = Color.Blue;
     m_shading               = ShadingStyles.Flat;
     m_autoLimitsUpdateCount = Vertices.Length;
 }
        /// <summary>
        /// Add a new surface graph, provide all coordinate data
        /// </summary>
        /// <param name="Z">matrix holding Z coordinates (heights)</param>
        /// <returns>reference to newly created surface graph</returns>
        public ILSurfaceGraph AddSurfGraph(ILBaseArray X, ILBaseArray Y, ILBaseArray Z, ILBaseArray C)
        {
            ILSurfaceGraph ret;

            ret = (ILSurfaceGraph)m_graphFact.CreateGraph(Z, GraphType.Surf, X, Y, C);
            m_clippingData.Update(ret.Limits);
            Add(ret);
            ret.Changed += new ILGraphChangedEvent(GraphChanged);
            // trigger change event
            OnChange(ret, GraphCollectionChangeReason.Added, null);
            return(ret);
        }
 public ILOGLImageSCGraph(ILOGLPanel panel, ILBaseArray X,
                          ILBaseArray Y, ILBaseArray Z, ILBaseArray C,
                          ILClippingData clippingContainer)
     : base(panel, X, Y, Z, C, clippingContainer)
 {
     m_panel = panel;
     m_localClipping.ZMax = 0;
     m_localClipping.ZMin = 0;
     m_localClipping.XMax = (float)m_cols + 0.5f;
     m_localClipping.XMin = -0.5f;
     m_localClipping.YMax = (float)m_rows + 0.5f;
     m_localClipping.YMin = -0.5f;
 }
Example #28
0
        /// <summary>
        /// create specific graph type for Direct3D use
        /// </summary>
        /// <param name="data">numeric array, shape depends on plot type</param>
        /// <param name="properties">graph properties</param>
        /// <param name="additionalParams">additional parameter, currently not used</param>
        /// <returns>ILGraph object</returns>
        public override ILGraph CreateGraph(ILBaseArray data, GraphType graphType, params object[] additionalParams)
        {
            switch (graphType)
            {
            case GraphType.Plot2D:
                return(new ILDXGraphPlot2D(this, data, m_graphs.Clipping));

            case GraphType.Surf:
                return(new ILDXGraphSurf3D(this, data, m_graphs.Clipping));

            default:
                throw new ILInvalidOperationException("Graph type not supported: " + graphType.ToString());
            }
        }
Example #29
0
        /// <summary>
        /// create new lines composite shape
        /// </summary>
        /// <param name="panel">panel hosting the scene</param>
        /// <param name="X">X coords vector</param>
        /// <param name="Y">Y coords vector</param>
        /// <param name="Z">Z coords vector</param>
        /// <param name="mapping">Mapping of shapes, composes shapes out of vertices. Matrix having
        /// 2 rows. Every element in a column specifies the index of a vertex according to its position in X,Y,Z.
        /// The 2 elements in a column therefore compose a single line. Vertices may get used arbitrary times
        /// (or not at all). All elements must be positive integer values in range
        /// 0...[<see cref="ILNumerics.Drawing.Shapes.ILShape.VertexCount"/>-1].</param>
        public ILLines(ILPanel panel, ILBaseArray X, ILBaseArray Y, ILBaseArray Z, ILBaseArray mapping)
            : base(panel, 2, X, Y, Z, mapping)
        {
            m_fillColor           = Color.Blue;
            m_properties          = new ILLineProperties();
            m_properties.Color    = Color.Blue;
            m_properties.Changed += new EventHandler(m_properties_Changed);
            ILColorEnumerator colors = new ILColorEnumerator();

            for (int i = 0; i < m_vertCount; i++)
            {
                m_vertices[i].Color = colors.NextColor();
            }
        }
        /// <summary>
        /// Add new X/Y 2D line graph(s), provide X and Y coordinates
        /// </summary>
        /// <param name="X">X coordinates. If this is a matrix, every column will produce an individual graph.</param>
        /// <param name="Y">Y coordinates. Same size than 'X'.</param>
        /// <returns>Array of newly created graph(s)</returns>
        public ILPlot2DGraph[] AddPlot2DGraph(ILBaseArray XData, ILBaseArray YData)
        {
            List <ILGraph>       graphs      = Add(XData, YData, GraphType.Plot2D);
            List <ILPlot2DGraph> ret         = new List <ILPlot2DGraph>();
            ILColorEnumerator    cenumerator = new ILColorEnumerator(Colormaps.Lines);

            foreach (ILGraph g in graphs)
            {
                ILPlot2DGraph plot2DGraph = (ILPlot2DGraph)g;
                ret.Add(plot2DGraph);
                plot2DGraph.Line.Color = cenumerator.NextColor();
            }
            return(ret.ToArray());
        }
Example #31
0
        /// <summary>
        /// size of array A
        /// </summary>
        /// <param name="A">input array</param>
        /// <returns>double ILArray with the length of each dimension of A.</returns>
        /// <remarks>If A is null, an empty array will be returned. Otherwise the array returned will always be a row vector of length s. s &gt;= 2</remarks>
        public static ILArray <double> size(ILBaseArray A)
        {
            if (object.Equals(A, null))
            {
                return(ILArray <double> .empty(0, 0));
            }
            int numDim = A.Dimensions.NumberOfDimensions;

            double [] retArr = new double[numDim];
            for (int i = 0; i < numDim; i++)
            {
                retArr[i] = A.Dimensions[i];
            }
            return(new ILArray <double>(retArr, 1, numDim));
        }
Example #32
0
        /// <summary>
        /// Create specific graph (device dependent)
        /// </summary>
        /// <param name="data">numeric data to be visualized, any numeric type is accepted</param>
        /// <param name="type">type of graph to be created</param>
        /// <param name="additionalParams">user defined parameter, depend on concrete device type</param>
        /// <returns>Concrete ILGraph object</returns>
        public ILGraph CreateGraph(ILBaseArray data, GraphType graphType, params object[] parameter)
        {
            switch (graphType)
            {
            case GraphType.Plot2D:
                if (parameter != null && parameter.Length == 1 &&
                    parameter[0] != null && parameter[0] is ILBaseArray)
                {
                    return(new ILOGLPlot2DGraph(this, parameter[0] as ILBaseArray,
                                                data, m_graphs.Limits));
                }
                else
                {
                    return(new ILOGLPlot2DGraph(this, data, m_graphs.Limits));
                }

            case GraphType.Surf:
                if (parameter == null || parameter.Length == 0)
                {
                    return(new ILOGLSurfaceGraph(this, null, null, data, null, m_graphs.Limits));
                }
                if (parameter.Length == 2)
                {
                    return(new ILOGLSurfaceGraph(this, data, parameter[0] as ILBaseArray,
                                                 parameter[1] as ILBaseArray, null, m_graphs.Limits));
                }
                else if (parameter.Length == 1)
                {
                    return(new ILOGLSurfaceGraph(this, null, null, data,
                                                 parameter[0] as ILBaseArray, m_graphs.Limits));
                }
                else if (parameter.Length == 3)
                {
                    return(new ILOGLSurfaceGraph(this, parameter[0] as ILBaseArray, parameter[1] as ILBaseArray,
                                                 data, parameter[2] as ILBaseArray, m_graphs.Limits));
                }
                else
                {
                    throw new ILArgumentException("graph creation: invalid number of arguments! (surface)");
                }

            case GraphType.Imagesc:
                return(new ILOGLImageSCGraph(this, null, null, data, null, m_graphs.Limits));

            default:
                throw new ILInvalidOperationException("Graph type not supported: " + graphType.ToString());
            }
        }
Example #33
0
        protected void createQuads(ILBaseArray data)
        {
            if (data == null || data.Length == 0)
            {
                Clear();
                m_quads = new ILQuad[0];
            }
            else
            {
                Clear();
                m_quads = new ILQuad[data.Length];
                ILColorEnumerator colors = new ILColorEnumerator();
                ILArray <float>   fData  = null;
                if (data is ILArray <float> )
                {
                    fData = (ILArray <float>)data;
                }
                else
                {
                    fData = ILMath.tosingle(data);
                }
                for (int i = 0; i < m_quads.Length; i++)
                {
                    m_quads[i] = new ILQuad(m_panel);
                    m_quads[i].Border.Visible = true;
                    m_quads[i].FillColor      = colors.NextColor();
                    ILPoint3Df pos = new ILPoint3Df();
                    pos.X = i - m_barWidth / 2;
                    pos.Y = 0;
                    pos.Z = -0.5f;
                    m_quads[i].Vertices[0].Position = pos;
                    pos.X += m_barWidth;
                    m_quads[i].Vertices[1].Position = pos;
                    pos.Y += fData.GetValue(i);
                    m_quads[i].Vertices[2].Position = pos;
                    pos.X -= m_barWidth;
                    m_quads[i].Vertices[3].Position = pos;
                    // label the bar
                    m_quads[i].Label.Text   = i.ToString();
                    m_quads[i].Label.Anchor = new PointF(.5f, -1);

                    // bars will be transparent, oldest fading to OpacityOldest
                    m_quads[i].Opacity = (byte)(m_oldestOpacity + i * (255 - m_oldestOpacity) / m_quads.Length);
                    // add the bar to the scene graph node (base)
                    Add(m_quads[i]);
                }
            }
        }
Example #34
0
        public void Test_Empty() {
            int errorCode = 0; 
            try {
				ILBaseArray[] data = new ILBaseArray[60]; 
				for (int i = 0; i < data.Length; i++)
					data[i] = new ILArray<Int16>(new Int16[1]{(Int16)i}); 
				ILCell A = new ILCell(data,20,3);
                ILArray<double> ind = new double[0]{};
                ILBaseArray elem = A[null,ind]; 
                if (!(elem is ILCell)) 
                    throw new Exception("empty return from ILCell should be ILCell");
                Success();
			} catch (Exception e) {
				Error(errorCode ,e.Message);
			}
		}
Example #35
0
 public ILDXGraphSurf3D (  ILDXPanel panel, ILBaseArray sourceArray,
                              ILClippingData clippingContainer) 
                            : base(sourceArray,clippingContainer) {
     m_localClipping = new ILClippingData(); 
     if (!sourceArray.IsMatrix) 
         throw new ILArgumentException ("source arrray must be matrix!"); 
     if (!sourceArray.IsNumeric) 
         throw new ILArgumentException ("source arrray must be numeric!"); 
     m_dxPanel = panel;
     m_dxPanel.GraphicsDeviceReset += new ILGraphicsDeviceResetEvent(m_dxPanel_GraphicsDeviceReset);
     m_cols = m_sourceArray.Dimensions[0]; 
     m_rows = m_sourceArray.Dimensions[1]; 
     m_Vertcount = m_rows * m_cols; 
     m_primitiveType = PrimitiveType.TriangleList; 
     m_vertexReady = false;
     m_indexReady = false; 
     m_rowsInChunk = 1; // primitives per chunk
     m_primsInChunk = m_cols * 2 * m_rowsInChunk; 
     updateClipping();
     Configure(); 
 }
Example #36
0
 /// <summary>
 /// create a new 3D Bar Graph plot, provide data matrix
 /// </summary>
 /// <param name="panel">panel hosting the scene</param>
 /// <param name="data">data matrix, at least 2x2 entries</param>
 public ILBarGraph3D(ILPanel panel, ILBaseArray data) 
 : base(panel) {
     if (data == null)
         throw new ILArgumentException("data argument must not be null!");
     create(data, Colormaps.ILNumerics); 
 }
Example #37
0
 /// <summary>
 /// create specific graph type for Direct3D use
 /// </summary>
 /// <param name="data">numeric array, shape depends on plot type</param>
 /// <param name="properties">graph properties</param>
 /// <param name="additionalParams">additional parameter, currently not used</param>
 /// <returns>ILGraph object</returns>
 public override ILGraph CreateGraph(ILBaseArray data, GraphType graphType, params object[] additionalParams) {
     switch(graphType) {
         case GraphType.Plot2D:
             return new ILDXGraphPlot2D(this, data,m_graphs.Clipping); 
         case GraphType.Surf:
             return new ILDXGraphSurf3D(this, data,m_graphs.Clipping); 
         default: 
             throw new ILInvalidOperationException("Graph type not supported: " + graphType.ToString()); 
     }
 }
Example #38
0
 /// <summary>
 /// construct new filled graph
 /// </summary>
 /// <param name="panel">panel hosting the graph</param>
 /// <param name="X">X coords, if null, range 0..[cols of Z] will be created</param>
 /// <param name="Y">Y coords, if null, range 0..[rows of Z] will be created</param>
 /// <param name="Z">Z coords (heights)</param>
 /// <param name="C">Colors for Z</param>
 /// <param name="clippingContainer">gloabal limits of panel</param>
 public ILFilledGraph (ILPanel panel, ILBaseArray X, ILBaseArray Y,
                       ILBaseArray Z, ILBaseArray C, ILClippingData clippingContainer) 
         : base (panel, clippingContainer) {
     #region argument checking
     m_localClipping.EventingSuspend(); 
     if (Z == null || !Z.IsMatrix) 
         throw new ILArgumentException ("ILFilledGraph: Z must be matrix!"); 
     if (!Z.IsNumeric) 
         throw new ILArgumentException ("ILFilledGraph: Z must be numeric!"); 
     m_sourceArray = ILMath.tosingle(Z); 
     m_rows = m_sourceArray.Dimensions[0]; 
     m_cols = m_sourceArray.Dimensions[1]; 
     ILArray<float> tmp; 
     if (!object.Equals (X,null) && !X.IsEmpty) {
         if (!X.IsMatrix || !X.IsNumeric) {
             throw new ILArgumentException ("ILFilledGraph: X must be numeric matrix!"); 
         }
         if (X.Dimensions.IsSameSize(Z.Dimensions)) {
             tmp = ILMath.tosingle(X); 
             tmp.ExportValues(ref m_xCoords); 
             m_localClipping.XMax = tmp.MaxValue; 
             m_localClipping.XMin = tmp.MinValue; 
         } else {
             throw new ILArgumentException ("ILFilledGraph: X must be of same size than Z!"); 
         }
     } else {
         ILMath.tosingle(ILMath.repmat(ILMath.counter(0.0,1.0,1,m_cols),m_rows,1)).ExportValues(ref m_xCoords); 
         m_localClipping.XMin = 0; 
         m_localClipping.XMax = m_cols-1; 
     }
     if (!object.Equals(Y,null) && !Y.IsEmpty) {
         if (!Y.IsMatrix || !Y.IsNumeric) {
             throw new ILArgumentException ("ILFilledGraph: Y must be numeric matrix!"); 
         }
         if (Y.Dimensions.IsSameSize(Z.Dimensions)) {
             tmp = ILMath.tosingle(Y); 
             tmp.ExportValues(ref m_yCoords); 
             m_localClipping.YMax = tmp.MaxValue; 
             m_localClipping.YMin = tmp.MinValue; 
         } else {
             throw new ILArgumentException ("ILFilledGraph: Y must be same size than Z!"); 
         }
     } else {
         ILMath.tosingle(ILMath.repmat(ILMath.counter(0.0,1.0,m_rows,1),1,m_cols)).ExportValues(ref m_yCoords); 
         m_localClipping.YMax = m_rows-1; 
         m_localClipping.YMin = 0; 
     }
     if (object.Equals(C,null) || C.IsEmpty) {
         m_colors = null; 
     } else {
         m_colors = ILMath.tosingle(C);
     }  
     m_localClipping.ZMax = m_sourceArray.MaxValue; 
     m_localClipping.ZMin = m_sourceArray.MinValue; 
     #endregion
     m_Vertcount = m_rows * m_cols; 
     m_vertexReady = false;
     m_indexReady = false; 
     // default view properties
     m_opacity = 1.0f; 
     m_wireLines = new ILLineProperties();
     m_wireLines.Changed += new EventHandler(m_wireLines_Changed);
     m_filled = true; 
     m_localClipping.EventingResume(); 
 }
Example #39
0
 private void create(ILBaseArray data, Colormaps colormap) {
     ILArray<float> dataF = ILNumerics.BuiltInFunctions.ILMath.tosingle(data); 
     m_boxes = new ILLitBox3D[data.Dimensions[0],data.Dimensions[1]];
     float maxY = data.Dimensions[0] * (m_barLengthY + m_paddingY);
     // prepare coloring for top quads 
     ILColormap cmap = new ILColormap(colormap); 
     float minV,maxV,mult;
     dataF.GetLimits(out minV, out maxV);
     if (maxV > minV) {
         mult = (cmap.Length - 1) / (maxV - minV);
     } else {
         minV = 0; 
         mult = 0;
     }
     for (int r = 0; r < data.Dimensions[0]; r++) {
         for (int c = 0; c < data.Dimensions[1]; c++) {
             float val = dataF.GetValue(r, c);  
             ILPoint3Df max = new ILPoint3Df(
                 (float)(c * (m_paddingX + m_barLengthX) + m_barLengthX)
                 , (float)(maxY - r * (m_paddingY + m_barLengthY))
                 , val);
             ILPoint3Df min = new ILPoint3Df(
                 max.X - m_barLengthX
                 , max.Y - m_barLengthY
                 , 0);
             Color topColor = cmap.Map((double)(val - minV) * mult); 
             ILLitBox3D box = new ILLitBox3D(m_panel,min,max,m_barColor,topColor);
             box.GradientColor = m_barColorGradient;
             box.TopLabel.Color = topColor;
             box.TopLabel.Text = ""; 
             m_boxes[r, c] = box; 
             Add(box); 
         }
     }
 }
Example #40
0
 /// <summary>
 /// Convert arbitrary numeric array to specific type
 /// </summary>
 /// <param name="X">numeric array, arbitrary numeric type</param>
 /// <returns>Array of specific inner type</returns>
 /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if X is not numeric</exception>
 public static ILArray< Int32 >  toint32 (ILBaseArray X) {
     return (ILArray< Int32 >)convert( NumericType.Int32 ,X); 
 }
Example #41
0
 /// <summary>
 /// Convert arbitrary numeric array to specific type
 /// </summary>
 /// <param name="X">numeric array, arbitrary numeric type</param>
 /// <returns>Array of specific inner type</returns>
 /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if X is not numeric</exception>
 public static ILArray< char >  tochar (ILBaseArray X) {
     return (ILArray< char >)convert( NumericType.Char ,X); 
 }
Example #42
0
        public void Test_Addressing() {
            int errorCode = 0; 
            try {
				ILBaseArray[] data = new ILBaseArray[60]; 
				for (int i = 0; i < data.Length; i++)
					data[i] = new ILArray<Int16>(new Int16[1]{(Int16)i}); 
				ILCell A = new ILCell(data,20,3);
                A.Name = "A"; 
				errorCode = 1;
                A[1,1] = ILMath.vector(10,100);
                A[2,1] = ILMath.vector(-10,-1,-100); 
                errorCode = 2; 
                // test subarray access: single
                ILBaseArray ret = A[23]; 
                ret.Name = "ret"; 
                errorCode = 3;
                // single element returned should be inner ILBaseArray
                if (!(ret is ILArray<Int16>))
                    throw new Exception("ILCell: single element returned should be of ILArray<double> type");
                ILArray<Int16> a23 = (ILArray<Int16>)ret; 
                a23.Name = "a23"; 
                if (!a23.IsScalar || a23 != 23.0) 
                    throw new Exception("ILCell: returned element value mismatch! Expected: 23, found:" + a23.GetValue(0));
                errorCode = 4;
                // test subarray access: multiple via vector (sequential)
                // - put Cell into cell 
                ILArray<double> element1 = ILMath.vector(10,2,20); 
                element1.Name = "element1"; 
                ILArray<double> element2 = ILMath.vector(20,2,30); 
                element2.Name = "element2"; 
                ILCell innerCell = new ILCell(new ILBaseArray[]{element1,element2},2,1); 
                A[3,1] = innerCell; 
                ILArray<double> ind = new ILArray<double>(new double[]{20.0,21.0,22.0,23.0,24.0}); 
                ind.Name = "ind"; 
                ILCell cellresult_vect = (ILCell)A[ind]; 
                cellresult_vect.Name = "cellresult_vect";
                if (!cellresult_vect.IsRowVector || cellresult_vect.Dimensions[0] != 1 
                    ||cellresult_vect.Dimensions[1] != 5) 
                    throw new Exception("ILCell: index access dimension mismatch: should be ILCell 1x5! ");
                if (!(cellresult_vect[0,0] is ILArray<short>) || !(cellresult_vect[0,1] is ILArray<double>)
                    || !(cellresult_vect[0,2] is ILArray<double>) || !(cellresult_vect[0,3] is ILCell)
                    || !(cellresult_vect[0,4] is ILArray<short>))
                    throw new Exception("ILCell: index access failed. Inner element mismatch for vector indices.");
                errorCode = 5;
                // test if elements returned are properly referenced (detached from original)
                ILArray<short> tmps = (ILArray<short>) cellresult_vect[0,0]; 
                tmps.Name = "tmps"; 
                if (!tmps.IsScalar || (tmps != 20.0)) 
                    throw new Exception("ILCell: invalid value returned: expected:20, found:" + tmps.GetValue(0));
                ILArray<double> tmp = (ILArray<double>) cellresult_vect[1]; 
                tmp.Name = "tmp"; 
                if (!tmp.IsVector || (bool)(tmp.Length != 91) || (bool)(tmp[0] != 10) || (bool)(tmp["end"] != 100))
                    throw new Exception("ILCell: invalid value returned: expected double vector 10:2:20");
                tmp = (ILArray<double>) cellresult_vect[2]; 
                if (!tmp.IsVector || (bool)(tmp.Length != 91) || (bool)(tmp[0] != -10) || (bool)(tmp["end"] != -100)) 
                    throw new Exception("ILCell: invalid value returned: expected vector 20:2:30");
                tmps = (ILArray<short>) cellresult_vect[4]; 
                if (!tmps.IsScalar || (bool)(tmps["end"] != 24.0)) 
                    throw new Exception("ILCell: invalid value returned: expected short 24, found: " + tmps.GetValue(0));
                cellresult_vect[0,3,1,0,1] = -111.0; 
                if ((ILArray<double>)cellresult_vect[0,3,1,0,1] != -111.0) 
                    throw new Exception("ILCell: invalid result of inner element index access: expected: -111.0, found: "+ ((ILArray<double>)cellresult_vect[0,3,1,0,1]).GetValue(0)); 
                errorCode = 6;
                // test if original still intact 
                if (!A[3,1,1,0,1].IsScalar || (ILArray<double>)A[3,1,1,0,1] != 22.0) 
                    throw new Exception("ILCell: original should not be altered if reference was altered! A[3,1,1,0,1] = " + ((ILArray<double>)A[3,1,1,0,1]).GetValue(0)); 
                // test subarray access: matrix (sequential)   **********************************************
                errorCode = 7;
                ind = new ILArray<double>(new double[6]{20.0,21.0,22.0,23.0,24.0,25.0},3,2); 
                ind.Name = "ind"; 
                cellresult_vect = (ILCell)A[ind]; 
                cellresult_vect.Name = "cellresult_vect";
                if (!cellresult_vect.IsMatrix || cellresult_vect.Dimensions[0] != 3 
                    ||cellresult_vect.Dimensions[1] != 2) 
                    throw new Exception("ILCell: index access dimension mismatch: should be ILCell 3x2! ");
                if (   !(cellresult_vect[0,0] is ILArray<short>)  || !(cellresult_vect[1,0] is ILArray<double>)
                    || !(cellresult_vect[2,0] is ILArray<double>) || !(cellresult_vect[0,1] is ILCell)
                    || !(cellresult_vect[1,1] is ILArray<short>)  || !(cellresult_vect[2,1] is ILArray<short>))
                    throw new Exception("ILCell: index access failed. Inner element mismatch for vector indices.");
                if (   !(cellresult_vect[0] is ILArray<short>)  || !(cellresult_vect[1] is ILArray<double>)
                    || !(cellresult_vect[2] is ILArray<double>) || !(cellresult_vect[3] is ILCell)
                    || !(cellresult_vect[4] is ILArray<short>)  || !(cellresult_vect[5] is ILArray<short>))
                    throw new Exception("ILCell: index access failed. Inner element mismatch for vector indices.");
                errorCode = 8;
                // test if elements returned are properly referenced (detached from original)
                tmps = (ILArray<short>) cellresult_vect[0,0]; 
                tmps.Name = "tmps"; 
                if (!tmps.IsScalar || (byte)tmps != 20.0) 
                    throw new Exception("ILCell: invalid value returned: expected:20, found:" + tmps.GetValue(0));
                tmp = (ILArray<double>) cellresult_vect[1]; 
                tmp.Name = "tmp"; 
                if (!tmp.IsVector || tmp.Length != 91 || tmp[0]!=10.0 || tmp["end"]!=100.0) 
                    throw new Exception("ILCell: invalid value returned: expected double vector 10:2:20");
                tmp = (ILArray<double>) cellresult_vect[2]; 
                if (!tmp.IsVector || tmp.Length != 91 || tmp[0]!=-10.0 || tmp["end"]!=-100.0) 
                    throw new Exception("ILCell: invalid value returned: expected vector 20:2:30");
                tmps = (ILArray<short>) cellresult_vect[4]; 
                if (!tmps.IsScalar || (byte)tmps["end"] != 24.0) 
                    throw new Exception("ILCell: invalid value returned: expected short 24, found: " + tmps.GetValue(0));
                cellresult_vect[0,1,1,0,1] = -111.0; 
                if ((double)(ILArray<double>)cellresult_vect[0,1,1,0,1] != -111.0) 
                    throw new Exception("ILCell: invalid result of inner element index access: expected: -111.0, found: "+ ((ILArray<double>)cellresult_vect[0,3,1,0,1]).GetValue(0)); 
                errorCode = 9;
                // test if original still untouched 
                if ((ILArray<double>)A[3,1,1,0,1] != 22.0) 
                    throw new Exception("ILCell: original should not be altered if reference was altered! A[3,1,1,0,1] = " + ((ILArray<double>)A[3,1,1,0,1]).GetValue(0)); 
                // test sequential index array set acces 
                innerCell = new ILCell(4,3,2); 
                innerCell[0] = ILMath.vector(20,-3,-100); 
                innerCell[1] = ((ILArray<double>)innerCell[0] < 0.0); 
                ILCell rangedsource = new ILCell(new ILBaseArray [] {
                        new ILArray<int>(3333), 
                        new ILLogicalArray(1), 
                        ILMath.vector(1000,2000),
                        innerCell},2,2); 
                ILArray<double> range = new ILArray<double>(new double[]{0,51,52,59}); 
                A[range] = rangedsource; 
                if (!(A[0] is ILArray<int>)) throw new Exception ("ILCell: seq.ranged set mismatch. index 0"); 
                if (!(A[51] is ILLogicalArray)) throw new Exception ("ILCell: seq.ranged set mismatch. index 1"); 
                if (!(A[52] is ILArray<double>)) throw new Exception ("ILCell: seq.ranged set mismatch. index 2"); 
                if (!(A[59] is ILCell)) throw new Exception ("ILCell: seq.ranged set mismatch. index 3"); 
                errorCode = 10;
                // test detached referencing (alter elements of query result)
                // test index access for ranges via ILBaseArray[]
                data = new ILBaseArray[60]; 
				for (int i = 0; i < data.Length; i++)
					data[i] = new ILArray<Int16>(new Int16[]{(Int16)i}); 
				A = new ILCell(data,20,3);
                A.Name = "A"; 
                ILArray<double> r = ILMath.vector(0,2); 
                ILArray<short> c = (ILArray<short>)ILMath.ones(NumericType.Int16,1); 
                ILCell rangeGet = (ILCell) A[r,c]; 
                if (rangeGet.Dimensions[0] != 3 || rangeGet.Dimensions[1] != 1)
                    throw new Exception("ILCell: ranged index get access via ILBaseArray failed. Wrong dimension returned."); 
                if ((ILArray<short>)rangeGet[0,0] != 20.0) throw new Exception("ILCell: invalid index returned: exp.20, found:" + ((ILArray<int>)rangeGet[0,0]).GetValue(0)); 
                A[0,1] = new ILArray<double>(17,18,1000); 
                if ((ILArray<short>)rangeGet[0,0] != 20.0) throw new Exception("ILCell: invalid index returned: exp.20, found:" + ((ILArray<double>)rangeGet[0,0]).GetValue(0) + ". The reference returned was not detached properly!"); 
                errorCode = 11;
                // test ranged setter 
                A[c,r] = A[c+10,r]; 
                if ((ILArray<short>)A[1,1] != 31.0) throw new Exception("Wrong value found after copying part of cell to other position.");
                A[1,1] = -1122.0; 
                if ((ILArray<short>)A[11,1] != 31.0 || (ILArray<double>)A[1,1] != -1122.0) throw new Exception ("wrong value stored or reference not properly un-linked in ILCell."); 
                // test removal of elements 
                errorCode = 12; 
                A[new ILArray<double>(new double[]{4.0,5.0,11.0}),null] = null; 
                if (A.Dimensions[0] != 17 || A.Dimensions[1] != 3) throw new Exception("ILCell removal via ILBaseArray[] failed.");
                A[new ILArray<double>(new double[]{4.0,5.0,11.0})] = null; 
                if (A.Dimensions[0] != 1 || A.Dimensions[1] != 48) throw new Exception("ILCell removal via sequential indexes failed!");
                errorCode = 13; 
                // test if error on removal will restore old dimensions 
                A = new ILCell(2,3,2); 
                ind = new double[]{15,16,22,223}; 
                try {
                    A[ind] = null;
                    throw new Exception("ILCell remove: index out of range not signaled!");
                } catch(Exception) {}
                if (A.Dimensions[0] != 2 || A.Dimensions[1] != 3 || A.Dimensions[2]!= 2) 
                    throw  new Exception("ILCell: error on remove should restore old dimensions!");

                Success();
			} catch (Exception e) {
				Error(errorCode ,e.Message);
			}
		}
Example #43
0
 /// <summary>
 /// Convert arbitrary numeric array to specific type
 /// </summary>
 /// <param name="X">numeric array, arbitrary numeric type</param>
 /// <returns>Array of specific inner type</returns>
 /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if X is not numeric</exception>
 public static ILArray</*!HC:inType1*/ double > /*!HC:funcName*/ todouble (ILBaseArray X) {
     return (ILArray</*!HC:inType1*/ double >)convert(/*!HC:inTypeName*/ NumericType.Double ,X); 
 }
Example #44
0
 /// <summary>
 /// Convert arbitrary numeric array to specific type
 /// </summary>
 /// <param name="X">numeric array, arbitrary numeric type</param>
 /// <returns>Array of specific inner type</returns>
 /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if X is not numeric</exception>
 public static ILArray< complex >  tocomplex (ILBaseArray X) {
     return (ILArray< complex >)convert( NumericType.Complex ,X); 
 }
Example #45
0
        private void TestQuickSortDescIDX(int dim, int len) {
            try {
                // asc along dimension (already ordered values) 
                int[] dims = new int[4] {5,4,3,2}; 
                dims[dim] = len; 
                ILArray<double> A = ILMath.counter(dims); 
                ILArray<double> ind; 
                ILArray<double> result = ILMath.sort(A, out ind, dim, true); 
                ILArray<double> expect = null; 
                ILArray<double> expectInd; 
                expectInd = ILMath.counter(A.Dimensions[dim]-1,-1.0,1, A.Dimensions[dim]);
                ILBaseArray[] revDims = new ILBaseArray[dims.Length];
                revDims[dim] = expectInd; 
                expect = A[revDims]; 
                if (!result.Equals(expect))
                    throw new Exception("invalid values"); 

                int [] dimsEx = new int[dims.Length];
                expectInd = ILMath.repmat(expectInd,A.Dimensions.SequentialIndexDistance(dim),1);
                sortIDXTestHelper001(dim, dims, ref expectInd, dimsEx);
                expectInd = ILMath.repmat(expectInd,dimsEx); 
                if (!ind.Equals(expectInd))
                    throw new Exception("invalid indices"); 
                // reverse values ... 
                A = ILMath.counter(A.Dimensions.NumberOfElements, -1.0, dims); 
                result = ILMath.sort(A,out ind, dim ,true); 
                if (!result.Equals(A.C))
                    throw new Exception("invalid values"); 

                expectInd = ILMath.counter(0.0,1.0,1, A.Dimensions[dim]);
                expectInd = ILMath.repmat(expectInd,A.Dimensions.SequentialIndexDistance(dim),1);
                sortIDXTestHelper001(dim, dims, ref expectInd, dimsEx);
                expectInd = ILMath.repmat(expectInd,dimsEx); 
                if (!ind.Equals(expectInd))
                    throw new Exception("invalid indices"); 
                // test scalar 
                A = 3.0; 
                result = ILMath.sort(A,out ind,0,true); 
                if (result != 3.0) {
                    throw new Exception("invalid values: scalar");
                }
                if (ind != 0.0) 
                    throw new Exception("invalid indices"); 
                // test empty 
                A = ILArray<double>.empty(); 
                if (!ILMath.sort(A,out ind, 0,true).IsEmpty)
                    throw new Exception("invalid values: empty");
                if (!ind.IsEmpty) {
                    throw new Exception("invalid indices"); 
                }
                Success(); 
            } catch (Exception e) {
                Error(0, e.Message); 
            }
        }
Example #46
0
        protected void createQuads(ILBaseArray data) {
            if (data == null || data.Length == 0) {
                Clear(); 
                m_quads = new ILQuad[0];
            } else {
                Clear(); 
                m_quads = new ILQuad[data.Length]; 
                ILColorEnumerator colors = new ILColorEnumerator(); 
                ILArray<float> fData = null; 
                if (data is ILArray<float>) {
                    fData = (ILArray<float>)data; 
                } else {
                    fData = ILMath.tosingle(data);
                }
                for (int i = 0; i < m_quads.Length; i++) {
                    m_quads[i] = new ILQuad(m_panel); 
                    m_quads[i].Border.Visible = true; 
                    m_quads[i].FillColor = colors.NextColor(); 
                    ILPoint3Df pos = new ILPoint3Df(); 
                    pos.X = i - m_barWidth / 2; 
                    pos.Y = 0; 
                    pos.Z = -0.5f; 
                    m_quads[i].Vertices[0].Position = pos; 
                    pos.X += m_barWidth; 
                    m_quads[i].Vertices[1].Position = pos; 
                    pos.Y += fData.GetValue(i); 
                    m_quads[i].Vertices[2].Position = pos; 
                    pos.X -= m_barWidth; 
                    m_quads[i].Vertices[3].Position = pos; 
                    // label the bar
                    m_quads[i].Label.Text = i.ToString(); 
                    m_quads[i].Label.Anchor = new PointF(.5f,-1);   

                    // bars will be transparent, oldest fading to OpacityOldest
                    m_quads[i].Opacity = (byte)(m_oldestOpacity + i * (255 - m_oldestOpacity) / m_quads.Length); 
                    // add the bar to the scene graph node (base)
                    Add(m_quads[i]); 
                }
            }
        }
Example #47
0
 /// <summary>
 /// Create specific graph (device dependent)
 /// </summary>
 /// <param name="data">numeric data to be visualized, any numeric type is accepted</param>
 /// <param name="type">type of graph to be created</param>
 /// <param name="additionalParams">user defined parameter, depend on concrete device type</param>
 /// <returns>Concrete ILGraph object</returns>
 public ILGraph CreateGraph(ILBaseArray data, GraphType graphType, params object[] parameter) {
     switch (graphType) {
         case GraphType.Plot2D:
             if (parameter != null && parameter.Length == 1 
                 && parameter[0] != null && parameter[0] is ILBaseArray) {
                 return new ILOGLPlot2DGraph(this,parameter[0] as ILBaseArray,
                                             data,m_graphs.Limits); 
             } else {
                 return new ILOGLPlot2DGraph(this, data,m_graphs.Limits);
             }
         case GraphType.Surf:
             if (parameter == null || parameter.Length == 0) 
                 return new ILOGLSurfaceGraph(this,null,null,data,null,m_graphs.Limits); 
             if (parameter.Length == 2) {
                 return new ILOGLSurfaceGraph(this,data,parameter[0] as ILBaseArray,
                                              parameter[1] as ILBaseArray ,null,m_graphs.Limits); 
             } else if (parameter.Length == 1) {
                 return new ILOGLSurfaceGraph(this,null,null,data, 
                                              parameter[0] as ILBaseArray,m_graphs.Limits);
             } else if (parameter.Length == 3) {
                 return new ILOGLSurfaceGraph(this,parameter[0] as ILBaseArray, parameter[1] as ILBaseArray, 
                                              data,parameter[2] as ILBaseArray, m_graphs.Limits); 
             } else 
                 throw new ILArgumentException ("graph creation: invalid number of arguments! (surface)"); 
         case GraphType.Imagesc:
             return new ILOGLImageSCGraph(this,null,null,data,null,m_graphs.Limits);
         default:
             throw new ILInvalidOperationException("Graph type not supported: " + graphType.ToString());
     }
 }
Example #48
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="outValue">Array of BaseArray of output parameter. outValue must be 
        /// at least of lenght 1, at most of length 3. The meanings are: 
        /// <list type="bullet">
        /// <item>One parameter: the sequential indices of all nonzero elements of X are returned.</item>
        /// <item>Two parameter: The first BaseArray returned in 'outValue' will hold the row indices of 
        /// nonzero elements of X, the second BaseArray will hold the column indices of those nonzero elements.</item>
        /// <item>If Length of outValue is 3, the rows and columns of nonzero elements are returned as the 
        /// first and second BaseArray elements. The third array will hold a (shallow) copy of those 
        /// nonzero elements found.</item>
        /// </list>
        /// </param>
        /// <param name="X">Array of input parameter. This must be at least 1 BaseArray holding 
        /// the input array for evaluation. If this array has length of 2, the second element must 
        /// be a scalar array of type <![CDATA[ILArray<double> or ILArray<int> or ILArray<float> or ILArray<byte>]]> 
        /// specifying the integer number of values to be returned. If this value is smaller 0, Find will 
        /// return that number of nonzero elements of X from the end of X.</param>
        /// <remarks>In order to specify the mode of Find, the length of the arrays 'outValue' and 
        /// 'X' will be recognized only. Any initial values of elements in 'outValue' will 
        /// be destroyed. The elements of X will not be altered.</remarks>
        public static void Find(ILBaseArray [] outValue, params ILBaseArray [] X) {
            if (outValue.Length > 3)
                throw new ILException ( "Find: Too many out parameters specified." );
            if (outValue.Length < 1)
                throw new ILException ( "Find: Too less out parameters specified." );
            if (X.Length < 1)
                throw new ILException ( "Find: Input array must be specified." );
            if (X.Length > 2)
                throw new ILException ( "Find: Too many parameters specified. At most 2 parameters allowed." );
            int limit = 0;
            if (X.Length == 2) {
                if (!X[1].IsScalar)
                    throw new ILArgumentSizeException ( "Find: the 'limit' parameter must be integer and scalar!" );
                if (X [1] is ILArray<double>)
                    limit = (int) ( (ILArray<double>) X [1] ).GetValue(0);
                else if (X [1] is ILArray<float>)
                    limit = (int) ( (ILArray<float>) X [1] ).GetValue(0);
                else if (X [1] is ILArray<int>)
                    limit = ( (ILArray<int>) X[1]).GetValue(0);
                else if (X [1] is ILArray<Int32>)
                    limit = (int) ( (ILArray<Int32>) X [1] ).GetValue(0);
                else if (X [1] is ILArray<Int64>)
                    limit = (int) ( (ILArray<Int64>) X [1] ).GetValue(0);
                else if (X [1] is ILArray<byte>)
                    limit = (int) ( (ILArray<byte>) X [1] ).GetValue(0);
                else if (X [1] is ILArray<char>)
                    limit = (int) ( (ILArray<char>) X [1] ).GetValue(0);
                else
                    throw new ILArgumentTypeException ( "Find: Limit parameter must be of any signed numeric type and must not be complex." );
            }  
            ILArray<double> C = null; 
            if (outValue.Length > 1) C = ILArray<double>.empty(0,0); 
            if (false) {
            #region HYCALPER LOOPSTART UNTYPED 
            } else if (X[0] is /*!HC:inCls1*/ ILArray<double> )  {
                /*!HC:inCls1*/ ILArray<double> V = null; 
                if (outValue.Length == 3)
                    V = /*!HC:inCls1*/ ILArray<double> .empty(0,0);
                outValue[0] = ILNumerics.BuiltInFunctions.ILMath.find ( (/*!HC:inCls1*/ ILArray<double> ) X [0], limit, ref C, ref V);
                if (outValue.Length > 1) 
                    outValue[1] = C; 
                if (outValue.Length == 3)
                    outValue[2] = V; 
                return; 
            #endregion HYCALPER LOOPEND UNTYPED
#region HYCALPER AUTO GENERATED CODE
// DO NOT EDIT INSIDE THIS REGION !! CHANGES WILL BE LOST !! 
            } else if (X[0] is  ILArray<complex> )  {
                ILArray<complex> V = null; 
                if (outValue.Length == 3)
                    V =  ILArray<complex> .empty(0,0);
                outValue[0] = ILNumerics.BuiltInFunctions.ILMath.find ( ( ILArray<complex> ) X [0], limit, ref C, ref V);
                if (outValue.Length > 1) 
                    outValue[1] = C; 
                if (outValue.Length == 3)
                    outValue[2] = V; 
                return; 
            } else if (X[0] is  ILArray<byte> )  {
                ILArray<byte> V = null; 
                if (outValue.Length == 3)
                    V =  ILArray<byte> .empty(0,0);
                outValue[0] = ILNumerics.BuiltInFunctions.ILMath.find ( ( ILArray<byte> ) X [0], limit, ref C, ref V);
                if (outValue.Length > 1) 
                    outValue[1] = C; 
                if (outValue.Length == 3)
                    outValue[2] = V; 
                return; 

#endregion HYCALPER AUTO GENERATED CODE

            } else {
                throw new ILException ( "Function 'Find' is not defined for Arrays of Type "
                    + X [0].GetType ().ToString () );
            }
        }
Example #49
0
        /// <summary>
        /// create new 2D bar graph
        /// </summary>
        /// <param name="panel">hosting panel</param>
        /// <param name="data">numeric vector data, heights of bars</param>
        public ILBarGraph2D (ILPanel panel, ILBaseArray data) 
            : base (panel) {
            // spacing between + width of bars
            m_barWidth = 0.6f;
            m_oldestOpacity = 255; 
            // create the bars
            createQuads(data); 
            m_legendSampleLabel = new ILLabel(m_panel);
            m_legendSampleLabel.Text = "Bars";

            m_legendTextLabel = new ILLabel(m_panel);
            m_legendTextLabel.Text = "3D";

            m_oldestBarIndex = 0; 
        }
Example #50
0
 internal ILOGLPlot2DGraph  ( ILPanel panel, ILBaseArray sourceArray,
                           ILClippingData clippingContainer) 
                         : base(panel, sourceArray,clippingContainer) {
 }
Example #51
0
 /// <summary>
 /// Convert arbitrary (numeric) array to other inner type
 /// </summary>
 /// <param name="typeName">Numeric type for output</param>
 /// <param name="X">input array, arbitrary inner type</param>
 /// <returns>Numeric array with specified inner element type</returns>
 public static ILBaseArray convert(NumericType typeName, ILBaseArray X) {
     if (X is ILArray<double>) {
         return convert(typeName,X as ILArray<double>);  
     } else if (X is ILArray<float>) {
         return convert(typeName,X as ILArray<float>); 
     } else if (X is ILArray<complex>) {
         return convert(typeName,X as ILArray<complex>);  
     } else if (X is ILArray<fcomplex>) {
         return convert(typeName,X as ILArray<fcomplex>);
     } else if (X is ILArray<byte>) {
         return convert(typeName,X as ILArray<byte>);  
     } else if (X is ILArray<char>) {
         return convert(typeName,X as ILArray<char>);
     } else if (X is ILArray<Int16>) {
         return convert(typeName,X as ILArray<Int16>);  
     } else if (X is ILArray<Int32>) {
         return convert(typeName,X as ILArray<Int32>);  
     } else if (X is ILArray<Int64>) {
         return convert(typeName,X as ILArray<Int64>);  
     } else if (X is ILArray<UInt16>) {
         return convert(typeName,X as ILArray<UInt16>); 
     } else if (X is ILArray<UInt32>) {
         return convert(typeName,X as ILArray<UInt32>);  
     } else if (X is ILArray<UInt64>) {
         return convert(typeName,X as ILArray<UInt64>);  
     } else 
         throw new ILArgumentException("convert: cannot convert invalid (non numeric) inner data type: '" + X.GetType().GetGenericArguments()[0].Name + "'");
 }
Example #52
0
 internal ILOGLPlot2DGraph  ( ILPanel panel, ILBaseArray xData, ILBaseArray yData,
                           ILClippingData clippingContainer) 
                         : base(panel, xData, yData, clippingContainer) {
 }
Example #53
0
 /// <summary>
 /// Convert arbitrary numeric array to specific type
 /// </summary>
 /// <param name="X">numeric array, arbitrary numeric type</param>
 /// <returns>Array of specific inner type</returns>
 /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if X is not numeric</exception>
 public static ILArray< Int64 >  toint64 (ILBaseArray X) {
     return (ILArray< Int64 >)convert( NumericType.Int64 ,X); 
 }
Example #54
0
 public ILOGLSurfaceGraph (  ILOGLPanel panel, ILBaseArray X,
                             ILBaseArray Y, ILBaseArray Z, ILBaseArray C,
                             ILClippingData clippingContainer) 
                       : base(panel,X,Y,Z,C,clippingContainer) {
     m_indexReady = false; 
     m_vertexReady = false; 
 }
Example #55
0
 /// <summary>
 /// Convert arbitrary numeric array to specific type
 /// </summary>
 /// <param name="X">numeric array, arbitrary numeric type</param>
 /// <returns>Array of specific inner type</returns>
 /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if X is not numeric</exception>
 public static ILArray< Int16 >  toint16 (ILBaseArray X) {
     return (ILArray< Int16 >)convert( NumericType.Int16 ,X); 
 }
Example #56
0
 public void Test_StreamMatlab(string filename, ILBaseArray arr) {
     int errorCode = 0;
     try {
         using (FileStream s = new FileStream(filename,FileMode.Create)) {
             arr.ToStream(s,"",ILArrayStreamSerializationFlags.Matlab);    
         }
         // test -> read back 
         ILMatFile inp = new ILMatFile(filename); 
         if (inp.Arrays.Length != 1)
             throw new Exception("invalid number of arrays after read back from matfile!");
         ILBaseArray reread = inp.Arrays[0]; 
         if (!reread.Equals (arr)) 
             throw new Exception("invalid values after re-reading from mat file!");
         string msg = ""; 
         if (arr.GetType().GetGenericArguments().Length > 0)
             msg = "<" + arr.GetType().GetGenericArguments()[0].Name + "> " + arr.Dimensions.ToString(); 
         else if (arr is ILLogicalArray)
             msg = "<logical> " + arr.Dimensions.ToString(); 
         else 
             msg = "<???l> " + arr.Dimensions.ToString(); 
         Success(msg);
     } catch (Exception e) {
         Error(errorCode, e.Message);
     }
 }
Example #57
0
 /// <summary>
 /// Convert arbitrary numeric array to specific type
 /// </summary>
 /// <param name="X">numeric array, arbitrary numeric type</param>
 /// <returns>Array of specific inner type</returns>
 /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if X is not numeric</exception>
 public static ILArray< byte >  tobyte (ILBaseArray X) {
     return (ILArray< byte >)convert( NumericType.Byte ,X); 
 }
Example #58
0
        /// <summary>
        /// maximum
        /// </summary>
        /// <param name="inParameter"> system.Array of ILBaseArray's. The number of elements 
        /// in inParams specifies the mode of max: 
        /// <list type="bullet">
        /// <item> 1:  Single array element. the function will give the maximum of elements 
        /// along the first non singleton dimension. If the length of outParamter is 2, the
        /// indices of the elements with maximum values found is given back as second return 
        /// value. [Matlab: [i,y] = max(A)]</item>
        /// <item> 2: first element: input Array. Second element: second input array. Either 
        /// one may be a scalar. the function gives back the maximum value of corresponding 
        /// elements of both input arrays as single otuput parameter. [Matlab: y = max(A,B)]</item>
        /// <item> 3: first element: input array. second element will be ignored, third element 
        /// will specify the dimension to operate along. If the length of outParameter specified 
        /// is 2, the indices of maximum elements into the operation dimension will be given back 
        /// also. [MAtlab: [y,i] = max(A,[],d)]</item>
        /// </list>  
        /// </param>
        /// <param name="outParameter">[output] return maximum value as requested. If the number of outParameter
        /// equals 2 on entry, the indices of corresponding maximum valued elements are returned also.</param>
        /// <remarks>Following types are supported: /*!HC:ENUM:TinCls:*/ <![CDATA[ ILArray<complex>, ILArray<byte>]]> /*!HC:/ENUM*/.
        /// The dimension specifier may be any positive (including 0) scalar value inside ILArray 
        /// of type double or int or float. 
        /// The length of outParameter specifies the number of values returned. 
        /// The initial content of outParameter argument will be destroyed on return. </remarks>
        public static void max(ref ILBaseArray[] outParameter, params ILBaseArray[] inParameter) {
            try {
                switch (inParameter.Length) {
                    case 0:
                        throw new ILArgumentTypeException("max: to less arguments supplied!");
                    case 1:
                        switch (outParameter.Length) {
                            case 0:
                            case 1:
                                // y = max(A)
                                if (false) {
                                }
                                #region HYCALPER LOOPSTART
                                else if (inParameter[0] is /*!HC:TinCls*/ ILArray<double> ) {
                                    outParameter = new ILBaseArray[1];
                                    outParameter[0] = BuiltInFunctions.ILMath.max((/*!HC:TinCls*/ ILArray<double> )inParameter[0]);
                                    return;
                                }
                                #endregion HYCALPER LOOPEND
#region HYCALPER AUTO GENERATED CODE
// DO NOT EDIT INSIDE THIS REGION !! CHANGES WILL BE LOST !! 
                                else if (inParameter[0] is  ILArray<byte> ) {
                                    outParameter = new ILBaseArray[1];
                                    outParameter[0] = BuiltInFunctions.ILMath.max(( ILArray<byte> )inParameter[0]);
                                    return;
                                }
                                else if (inParameter[0] is  ILArray<complex> ) {
                                    outParameter = new ILBaseArray[1];
                                    outParameter[0] = BuiltInFunctions.ILMath.max(( ILArray<complex> )inParameter[0]);
                                    return;
                                }

#endregion HYCALPER AUTO GENERATED CODE
                                else {
                                    throw new ILArgumentTypeException("max is not supported for arguments of type " + inParameter[0].GetType().Name); 
                                }
                            case 2:
                                // [y,i] = max(A)
                                if (false) {
                                #region HYCALPER LOOPSTART
                                } else if (inParameter[0] is /*!HC:TinCls*/ ILArray<double> ) {
                                    ILArray<double> I = ILArray<double>.empty(0,0);
                                    outParameter = new ILBaseArray[2];
                                    outParameter[0] = BuiltInFunctions.ILMath.max((/*!HC:TinCls*/ ILArray<double> )inParameter[0], ref I, -1);
                                    outParameter[1] = I;
                                #endregion HYCALPER LOOPEND
#region HYCALPER AUTO GENERATED CODE
// DO NOT EDIT INSIDE THIS REGION !! CHANGES WILL BE LOST !! 
                                } else if (inParameter[0] is  ILArray<byte> ) {
                                    ILArray<double> I = ILArray<double>.empty(0,0);
                                    outParameter = new ILBaseArray[2];
                                    outParameter[0] = BuiltInFunctions.ILMath.max(( ILArray<byte> )inParameter[0], ref I, -1);
                                    outParameter[1] = I;
                                } else if (inParameter[0] is  ILArray<complex> ) {
                                    ILArray<double> I = ILArray<double>.empty(0,0);
                                    outParameter = new ILBaseArray[2];
                                    outParameter[0] = BuiltInFunctions.ILMath.max(( ILArray<complex> )inParameter[0], ref I, -1);
                                    outParameter[1] = I;

#endregion HYCALPER AUTO GENERATED CODE
                                } else {
                                    throw new ILArgumentTypeException("max(A) is not supported for A of type " + inParameter[0].GetType().Name); 
                                }
                                break;
                            default:
                                throw new ILArgumentNumberException("max: too many output parameter requested for max(A)!");
                        }
                        break;
                    case 2:
                        switch (outParameter.Length) {
                            case 0:
                            case 1:
                                // y = max(A,B)
                                if (false) {
                                #region HYCALPER LOOPSTART
                                } else if (inParameter[0] is /*!HC:TinCls*/ ILArray<double> ) {
                                    outParameter = new ILBaseArray[1];
                                    outParameter[0] = BuiltInFunctions.ILMath.max((/*!HC:TinCls*/ ILArray<double> )inParameter[0], (/*!HC:TinCls*/ ILArray<double> )inParameter[1]);
                                #endregion HYCALPER LOOPEND
#region HYCALPER AUTO GENERATED CODE
// DO NOT EDIT INSIDE THIS REGION !! CHANGES WILL BE LOST !! 
                                } else if (inParameter[0] is  ILArray<byte> ) {
                                    outParameter = new ILBaseArray[1];
                                    outParameter[0] = BuiltInFunctions.ILMath.max(( ILArray<byte> )inParameter[0], ( ILArray<byte> )inParameter[1]);
                                } else if (inParameter[0] is  ILArray<complex> ) {
                                    outParameter = new ILBaseArray[1];
                                    outParameter[0] = BuiltInFunctions.ILMath.max(( ILArray<complex> )inParameter[0], ( ILArray<complex> )inParameter[1]);

#endregion HYCALPER AUTO GENERATED CODE
                                } else {
                                    throw new ILArgumentTypeException("max is not supported for input array of type " + inParameter[0].GetType().Name);
                                }
                                break;
                            default:
                                throw new ILArgumentNumberException("max: too many output parameter requested for max(A,B)!");
                        }
                        break;
                    case 3:
                        switch (outParameter.Length) {
                            case 0:
                            case 1:
                                // y = max(A,[],dim)
                                if (false) {
                                #region HYCALPER LOOPSTART
                                } else if (inParameter[0] is /*!HC:TinCls*/ ILArray<double> ) {
                                    ILArray<double> I = null;
                                    outParameter = new ILBaseArray[1];
                                    if (!inParameter[2].IsScalar)
                                        throw new ILArgumentSizeException("max: dimension argument must be positive, scalar double array!");
                                    int dimension = 0;
                                    try {
                                        dimension = (int)(((ILArray<double> )inParameter[2])[0, 0]);
                                    } catch (Exception) {
                                        throw new ILArgumentSizeException("max: dimension argument must be positive, scalar double array!");
                                    }
                                    outParameter[0] = BuiltInFunctions.ILMath.max((/*!HC:TinCls*/ ILArray<double> )inParameter[0], ref I, dimension);
                                #endregion HYCALPER LOOPEND
#region HYCALPER AUTO GENERATED CODE
// DO NOT EDIT INSIDE THIS REGION !! CHANGES WILL BE LOST !! 
                                } else if (inParameter[0] is  ILArray<byte> ) {
                                    ILArray<double> I = null;
                                    outParameter = new ILBaseArray[1];
                                    if (!inParameter[2].IsScalar)
                                        throw new ILArgumentSizeException("max: dimension argument must be positive, scalar double array!");
                                    int dimension = 0;
                                    try {
                                        dimension = (int)(((ILArray<double> )inParameter[2])[0, 0]);
                                    } catch (Exception) {
                                        throw new ILArgumentSizeException("max: dimension argument must be positive, scalar double array!");
                                    }
                                    outParameter[0] = BuiltInFunctions.ILMath.max(( ILArray<byte> )inParameter[0], ref I, dimension);
                                } else if (inParameter[0] is  ILArray<complex> ) {
                                    ILArray<double> I = null;
                                    outParameter = new ILBaseArray[1];
                                    if (!inParameter[2].IsScalar)
                                        throw new ILArgumentSizeException("max: dimension argument must be positive, scalar double array!");
                                    int dimension = 0;
                                    try {
                                        dimension = (int)(((ILArray<double> )inParameter[2])[0, 0]);
                                    } catch (Exception) {
                                        throw new ILArgumentSizeException("max: dimension argument must be positive, scalar double array!");
                                    }
                                    outParameter[0] = BuiltInFunctions.ILMath.max(( ILArray<complex> )inParameter[0], ref I, dimension);

#endregion HYCALPER AUTO GENERATED CODE
                                } else {
                                    throw new ILArgumentTypeException("max is not supported for input array of type " + inParameter[0].GetType().Name);
                                }
                                break;
                            case 2:
                                // [y,i] = max(A,[],dim)
                                if (false) {
                                #region HYCALPER LOOPSTART
                                } else if (inParameter[0] is /*!HC:TinCls*/ ILArray<double> ) {
                                    ILArray<double> I = ILArray<double>.empty(0,0);
                                    outParameter = new ILBaseArray[2];
                                    if (!inParameter[2].IsScalar)
                                        throw new ILArgumentSizeException("max: dimension argument must be positive, scalar double array!");
                                    int dimension = 0;
                                    try {
                                        dimension = (int)(((ILArray<double>)inParameter[2])[0, 0]);
                                    } catch (Exception) {
                                        throw new ILArgumentSizeException("max: dimension argument must be positive, scalar double array!");
                                    }
                                    outParameter[0] = BuiltInFunctions.ILMath.max((/*!HC:TinCls*/ ILArray<double> )inParameter[0], ref I, dimension);
                                    outParameter[1] = I;
                                #endregion HYCALPER LOOPEND
#region HYCALPER AUTO GENERATED CODE
// DO NOT EDIT INSIDE THIS REGION !! CHANGES WILL BE LOST !! 
                                } else if (inParameter[0] is  ILArray<byte> ) {
                                    ILArray<double> I = ILArray<double>.empty(0,0);
                                    outParameter = new ILBaseArray[2];
                                    if (!inParameter[2].IsScalar)
                                        throw new ILArgumentSizeException("max: dimension argument must be positive, scalar double array!");
                                    int dimension = 0;
                                    try {
                                        dimension = (int)(((ILArray<double>)inParameter[2])[0, 0]);
                                    } catch (Exception) {
                                        throw new ILArgumentSizeException("max: dimension argument must be positive, scalar double array!");
                                    }
                                    outParameter[0] = BuiltInFunctions.ILMath.max(( ILArray<byte> )inParameter[0], ref I, dimension);
                                    outParameter[1] = I;
                                } else if (inParameter[0] is  ILArray<complex> ) {
                                    ILArray<double> I = ILArray<double>.empty(0,0);
                                    outParameter = new ILBaseArray[2];
                                    if (!inParameter[2].IsScalar)
                                        throw new ILArgumentSizeException("max: dimension argument must be positive, scalar double array!");
                                    int dimension = 0;
                                    try {
                                        dimension = (int)(((ILArray<double>)inParameter[2])[0, 0]);
                                    } catch (Exception) {
                                        throw new ILArgumentSizeException("max: dimension argument must be positive, scalar double array!");
                                    }
                                    outParameter[0] = BuiltInFunctions.ILMath.max(( ILArray<complex> )inParameter[0], ref I, dimension);
                                    outParameter[1] = I;

#endregion HYCALPER AUTO GENERATED CODE
                                } else {
                                    throw new ILArgumentTypeException("max is not supported for input array of type " + inParameter[0].GetType().Name);
                                }
                                break;
                            default:
                                throw new ILArgumentNumberException("max: wrong number of output parameter requested for max(A,B) !");
                        }
                        break;
                    default:
                        throw new ILArgumentNumberException("max: too many input arguments! ");
                }
            } catch (Exception e) {
                throw new ILException("max: could not complete operation: " + e.Message); 
            }

        }
Example #59
0
 /// <summary>
 /// Convert arbitrary numeric array to specific type
 /// </summary>
 /// <param name="X">numeric array, arbitrary numeric type</param>
 /// <returns>Array of specific inner type</returns>
 /// <exception cref="ILNumerics.Exceptions.ILArgumentException">if X is not numeric</exception>
 public static ILArray< float >  tosingle (ILBaseArray X) {
     return (ILArray< float >)convert( NumericType.Single ,X); 
 }
Example #60
0
        /// <summary>
        /// mean of array A
        /// </summary>
        /// <param name="inParameters">variable input parameter of type ILBaseArray. 
        /// <list type="bullet">
        /// <item> mean(A), where A is an ILArray of type supported, will give the 
        /// mean along the first non singleton dimension.</item>
        /// <item> mean (A, D) where A is a N-D array of type 
        /// supported and D is s single scalar sized ILArray of type double or int: returnes 
        /// mean of elements of A along dimension dim.</item>
        /// </list></param>
        /// <param name="outParameters"> Output. Depending on the 
        /// length of A and on the type of its elements the output return value will be a single 
        /// ILBaseArray with mean of elements along dimension specified 
        /// or along first non singleton dimension. The type of the single ILArray 
        /// returned will be the same as the underlying type of A.</param>
        /// <remarks> This function is supported for all numeric arrays: /*!HC:ENUM:inCls1:*/ <![CDATA[ ILArray<complex>, ILArray<byte>]]> /*!HC:/ENUM*/. 
        /// It does return a <![CDATA[ILArray<BaseT>]]> for all input arrays, where BaseT is the inner
        /// type of the input array.
        /// </remarks>
        public static void mean(ILBaseArray[] outParameters, params ILBaseArray[] inParameters) {
            if (outParameters.Length != 1) 
                throw new ILArgumentNumberException ("Mean: one output parameter expected.");
            switch (inParameters.Length) {
                case 0:
                    throw new ILArgumentNumberException("mean: too less arguments specified.");
                case 1:
                    if (false) {
                    #region HYCALPER LOOPSTART 
                    } else if (inParameters[0] is /*!HC:inCls1*/ ILArray<double> ) { 
                        outParameters[0] = BuiltInFunctions.ILMath.mean((/*!HC:inCls1*/ ILArray<double> ) inParameters[0]);
                    #endregion HYCALPER LOOPEND
#region HYCALPER AUTO GENERATED CODE
// DO NOT EDIT INSIDE THIS REGION !! CHANGES WILL BE LOST !! 
                    } else if (inParameters[0] is  ILArray<byte> ) { 
                        outParameters[0] = BuiltInFunctions.ILMath.mean(( ILArray<byte> ) inParameters[0]);
                    } else if (inParameters[0] is  ILArray<complex> ) { 
                        outParameters[0] = BuiltInFunctions.ILMath.mean(( ILArray<complex> ) inParameters[0]);

#endregion HYCALPER AUTO GENERATED CODE
                    } else 
                        throw new ILArgumentTypeException("Mean is not defined for arrays of type " + inParameters[0].GetType().Name);
                    break; 
                case 2:
                    double dimensionArg = 0.0; 
                    if (!inParameters[1].IsScalar) {
                        throw new ILArgumentSizeException("mean: dimension argument must be positiv and scalar!"); 
                    }
                    if (false) {
                    #region HYCALPER LOOPSTART 
                    } else if (inParameters[1] is /*!HC:inCls1*/ ILArray<double> ) {
                            dimensionArg = (double) ((/*!HC:inCls1*/ ILArray<double> )inParameters[1]).GetValue(0,0);
                    #endregion HYCALPER LOOPEND 
#region HYCALPER AUTO GENERATED CODE
// DO NOT EDIT INSIDE THIS REGION !! CHANGES WILL BE LOST !! 
                    } else if (inParameters[1] is  ILArray<byte> ) {
                            dimensionArg = (double) (( ILArray<byte> )inParameters[1]).GetValue(0,0);
                    } else if (inParameters[1] is  ILArray<complex> ) {
                            dimensionArg = (double) (( ILArray<complex> )inParameters[1]).GetValue(0,0);

#endregion HYCALPER AUTO GENERATED CODE
                    } else  
                        throw new ILArgumentTypeException ("mean: dimension argument must be positiv and scalar!");
                    if (false) {
                    #region HYCALPER LOOPSTART 
                    } else if (inParameters[0] is /*!HC:inCls1*/ ILArray<double> ) { 
                        outParameters[0] = BuiltInFunctions.ILMath.mean((/*!HC:inCls1*/ ILArray<double> ) inParameters[0], (int) dimensionArg);
                    #endregion HYCALPER LOOPEND
#region HYCALPER AUTO GENERATED CODE
// DO NOT EDIT INSIDE THIS REGION !! CHANGES WILL BE LOST !! 
                    } else if (inParameters[0] is  ILArray<byte> ) { 
                        outParameters[0] = BuiltInFunctions.ILMath.mean(( ILArray<byte> ) inParameters[0], (int) dimensionArg);
                    } else if (inParameters[0] is  ILArray<complex> ) { 
                        outParameters[0] = BuiltInFunctions.ILMath.mean(( ILArray<complex> ) inParameters[0], (int) dimensionArg);

#endregion HYCALPER AUTO GENERATED CODE
                    } else 
                        throw new ILArgumentTypeException("Mean is not defined for arrays of type " + inParameters[0].GetType().Name);
                    break; 
                default:
                    throw new ILArgumentNumberException("mean: too many arguments specified.");
            }
        }