コード例 #1
0
        /// <summary>
        /// Converts an array that contains multiple Matlab return parameters back into a list of .NET doubles.
        /// </summary>
        /// <param name="toList">MWArray variable, returned from Matlab code.</param>
        /// <returns>List of .NET doubles.</returns>
        public static List <double> MyToDoubleList(this MWArray toList)
        {
            var matNumericArray = toList;
            var netArray        = (MWNumericArray)matNumericArray.ToArray();

            var result = new List <double>();

            // Console.Write("{0}", netArray[1]);
            for (int i = 1; i <= netArray.NumberOfElements; i++)                             // Matlab arrays are 1-based, thus the odd indexing.
            {
                result.Add(netArray[i].ToScalarDouble());
            }
            return(result);
        }
コード例 #2
0
ファイル: Formula.cs プロジェクト: yufeijie/learngit
        public static double DTC_SRC_Mgain2(double Td, double fs, double Q)
        {
            double         value  = -1;
            MWArray        output = solve.solve_DTCSRC_Mgain2(Td, fs, Q);
            MWNumericArray result = (MWNumericArray)output;

            value = result.ToScalarDouble();
            if (value < 0)
            {
                Console.WriteLine("Wrong DTC_SRC_Mgain1!");
                System.Environment.Exit(-1);
            }
            return(value);
        }
コード例 #3
0
ファイル: MainWindow.xaml.cs プロジェクト: VASoftLab/SAR-400
        private void ButtonNeuralOpenPanel_Click(object sender, RoutedEventArgs e)
        {
            WindowNeuralControlPanel wnd = new WindowNeuralControlPanel();

            wnd.Show();

            if (wnd.DialogResult == true)
            {
                SARNeural neural = new SARNeural();
                MWArray   output = neural.Predict(wnd.X1, wnd.X2, wnd.X3, wnd.X4, wnd.X5, wnd.X6, wnd.X7, wnd.X8, wnd.X9, wnd.X10, wnd.X11, wnd.X12);
                double[,] values = (double[, ])((MWNumericArray)output).ToArray(MWArrayComponent.Real);


                RecorderCommand command = new RecorderCommand
                {
                    Duration = TimeSpan.FromSeconds(2.0),
                    Joints   = new List <CostumeJoint>
                    {
                        new CostumeJoint()
                        {
                            Name = "R.ShoulderF", Value = (float)values[0, 0]
                        },
                        new CostumeJoint()
                        {
                            Name = "R.ShoulderS", Value = (float)values[0, 1]
                        },
                        new CostumeJoint()
                        {
                            Name = "R.ElbowR", Value = (float)values[0, 2]
                        },
                        new CostumeJoint()
                        {
                            Name = "R.Elbow", Value = (float)values[0, 3]
                        },
                        new CostumeJoint()
                        {
                            Name = "R.WristR", Value = (float)values[0, 4]
                        },
                        new CostumeJoint()
                        {
                            Name = "R.WritsS", Value = (float)values[0, 5]
                        }
                    }
                };

                RobotAnswer answer = Robot.ExecuteCommand(command.Joints, command.Duration);
                AppLog.Write(answer.ToString());
            }
        }
コード例 #4
0
        public void FromMatlabArray(MWArray data)
        {
            var k = data.ToArray();

            for (int i = 0; i < k.GetLength(0); i++)
            {
                for (int j = 0; j < k.GetLength(1); j++)
                {
                    object a = k.GetValue(i, j);
                    byte   b = (byte)a;
                    Pixel  p = new Pixel((int)b, (int)b, (int)b, 255);
                    SetPixel(j, i, p);
                }
            }
        }
コード例 #5
0
        // MATLAB Functions
        /// <summary>
        /// Performs upsampling and downsampling on an array of values
        /// </summary>
        /// <param name="values"> The input array to resample </param>
        /// <param name="ratio"> The ratio between upsampling and downsampling to perform </param>
        /// <returns> The resampled array </returns>
        public static List <float> MATLAB_Resample(float[] values, float ratio)
        {
            // Prepare Input for MATLAB function
            Processing proc = new Processing();

            MWArray[] input = new MWArray[2];
            input[0] = new MWNumericArray(values);
            input[1] = ratio;
            // Call MATLAB function
            return((
                       (double[])(
                           (MWNumericArray)proc.m_resample(1, input[0], input[1])[0]
                           ).ToVector(MWArrayComponent.Real)
                       ).ToList().Select(temp => (float)temp).ToList());
        }
コード例 #6
0
ファイル: MatchingHelper.cs プロジェクト: andykmc/vision
        public static double[] resultsForReranking; //stores the image number when images are categories covered by similarity matrix

        public static string matchClass()
        {
            //MessageBox.Show("match initialize");
            MatchingClass matchtest = null;
            MWCharArray   output    = null;
            MWArray       MWresult  = null;

            matchtest = new MatchingClass();
            //MessageBox.Show("start match");
            MWresult           = matchtest.build_matching_test_correct_csharp2();
            output             = (MWCharArray)MWresult[1, 1];
            matchedClass       = output.ToString();
            rerankingImageName = -1;
            return(matchedClass);
        }
コード例 #7
0
        /// <summary>
        /// Converts MWArray input, which is a MATLAB structure, to an array of MWArray
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static MWArray[] GetMWStructureFields(MWArray input)
        {
            var castInput = (MWStructArray)input;

            var fields = castInput.FieldNames;

            MWArray[] result = new MWArray[fields.Length];

            for (int i = 0; i < fields.Length; i++)
            {
                result[i] = castInput.GetField(fields[i]);
            }

            return(result);
        }
コード例 #8
0
        private void startDehaze_Click(object sender, EventArgs e)
        {
            //string Atext, convCoretext;
            //convCoretext = textBox3.Text;
            //Atext = textBox4.Text;
            double Anum, convCorenum;

            Anum        = 0;
            convCorenum = 0;

            DehazeFunctionV2.Class1 v2c1 = new DehazeFunctionV2.Class1();
            MWArray[] resultlist         = new MWArray[2];
            resultlist = v2c1.DehazeFunctionV2(2, pathname, Anum, convCorenum);
            MWNumericArray Atmospherelight = (MWNumericArray)resultlist[0];
            MWNumericArray SSIM            = (MWNumericArray)resultlist[1];

            textBox2.Text = SSIM.ToString();
            textBox4.Text = Atmospherelight.ToString();
            textBox3.Text = "15";
            string pathname2;

            pathname2 = "D:\\op\\cache\\temp.jpg";  //获得文件的绝对路径
                                                    //this.pictureBox2.Load(pathname2);//load貌似过时了?
                                                    // this.pictureBox2.Image = Image.FromFile(pathname2);
                                                    //    pictureBox2.Image.Dispose();
            FileStream pFileStream = new FileStream(pathname2, FileMode.Open, FileAccess.Read);

            outputImg.Image = Image.FromStream(pFileStream);
            pFileStream.Close();
            pFileStream.Dispose();

            //DheazeFunction.Class1 v1c1 = new DheazeFunction.Class1();
            //MWArray[] resultlist = new MWArray[2];
            //resultlist = v1c1.DheazeFunction(1, pathname);
            //MWNumericArray Atmospherelight = (MWNumericArray)resultlist[0];

            //textBox4.Text = Atmospherelight.ToString();
            //textBox3.Text = "15";
            //string pathname2;
            //pathname2 = "D:\\op\\cache\\temp.jpg";  //获得文件的绝对路径
            //                                       //this.pictureBox2.Load(pathname2);//load貌似过时了?
            //                                       // this.pictureBox2.Image = Image.FromFile(pathname2);
            //                                       //    pictureBox2.Image.Dispose();
            //FileStream pFileStream = new FileStream(pathname2, FileMode.Open, FileAccess.Read);
            //outputImg.Image = Image.FromStream(pFileStream);
            //pFileStream.Close();
            //pFileStream.Dispose();
        }
コード例 #9
0
 private void data()
 {
     try
     {
         readData.readdata output = new readData.readdata();
         MWArray           a      = a_box.Text;
         MWArray           X      = Convert.ToInt32(b_box.Text);
         MWArray           n      = Convert.ToInt32(c_box.Text);
         MWArray           dim    = Convert.ToInt32(d_box.Text);
         output.readData(a, X, n, dim);
     }
     catch
     {
         MessageBox.Show("数据有误", "警告");
     }
 }
コード例 #10
0
        public double[] NextNormalRandomMatrix(double mu, double sigma, int samples)
        {
            var     norm    = new Normrand.MATLAB_NormalRandom();
            MWArray M_mu    = new MWNumericArray(mu);
            MWArray M_sigma = new MWNumericArray(sigma);
            MWArray M_n     = new MWNumericArray(1);
            MWArray M_m     = new MWNumericArray(samples);
            MWArray R       = norm.Normrand(M_mu, M_sigma, M_n, M_m);
            var     result  = new double[samples];

            for (int i = 0; i < samples; i++)
            {
                result[i] = ((MWNumericArray)R[i + 1]).ToScalarDouble();
            }
            return(result);
        }
コード例 #11
0
        public void calculate(out string out1, out string out2)
        {
            out1 = "";
            out2 = "";
            double[] a = { 1, 2, 3, 4, 5, 6 }; //定义两个输入参数
            double[] b = { 1, 1, 1, 1, 1, 1 }; //它们是两个一维静态数组

            double[,] c = new double[3, 2];    //定义C#中接收输出参数的类型
            double[,] d = new double[3, 2];    //是两个二维数组

            //把两个输入参数都转换成中间类型,中间类型也是矩阵所以要指明维数
            //这里将两个输入参数转换为两个三行两列的矩阵
            MWNumericArray matlab_a = new MWNumericArray(3, 2, a);
            MWNumericArray matlab_b = new MWNumericArray(3, 2, b);

            //输入参数成功转化为两个MWArray元素类型
            MWArray[] agrsIn = new MWArray[] { matlab_a, matlab_b };

            //声明输出参数是两个MWArray元素类型,一定要写数量
            MWArray[] agrsOut = new MWArray[2];

            //调用matlab函数,2表示输出参数的个数,输出参数前需要加 ref 关键字
            //此例实现了两个三行两列的矩阵相加减
            m2CClass.MatrixOpera(2, ref agrsOut, agrsIn);

            //把两个输出参数转换成中间类型
            MWNumericArray net_c = agrsOut[0] as MWNumericArray; //matlab函数第一个输出参数
            MWNumericArray net_d = agrsOut[1] as MWNumericArray; //第二个输出参数

            //转换成C#中的接收参数
            c = (double[, ])net_c.ToArray();//转化为二维数组
            d = (double[, ])net_d.ToArray();
            //一定要注意最后接收参数的转化,不同类型的接收参数用的转换函数不同
            //二维数组用ToArray()函数转换
            //一维数组用ToVector(MWArrayComponent.Real)函数转换
            //单个double值用ToScalarDouble()函数转换
            //单个int值用ToScalarInteger()函数转换

            for (int i = 0; i <= 2; i++)//输出结果验证
            {
                for (int j = 0; j <= 1; j++)
                {
                    out1 += c[i, j].ToString() + " ";
                    out2 += d[i, j].ToString() + " ";
                }
            }
        }
コード例 #12
0
        /// <summary>
        /// 自动对齐
        /// </summary>
        /// <param name="ww">输入参考波形1的数据</param>
        ///WW(1,:):左高低
        ///WW(2,:):右高低
        ///WW(3,:):左轨向
        ///WW(4,:):右轨向
        ///WW(5,:):轨距------(总共5列数据)
        /// <param name="ww1">参考波形2的数据</param>
        /// <returns>移动的点数</returns>
        /// 备注:波形1不动,波形2减去点数
        ///       波形2不动,波形1加上点数
        public int AutoTranslation(float[][] ww, float[][] ww1)
        {
            int retVal = 0;

            int            rowLen_ww = ww.GetLength(0);
            int            colLen_ww = ww[0].Length;
            MWNumericArray d_ww      = new MWNumericArray(MWArrayComplexity.Real, rowLen_ww, colLen_ww);

            //matlab中矩阵的下标是从1开始的,而C#是从0开始的
            for (int i = 0; i < rowLen_ww; i++)
            {
                for (int j = 0; j < colLen_ww; j++)
                {
                    d_ww[i + 1, j + 1] = ww[i][j];
                }
            }

            int            rowLen_ww1 = ww1.GetLength(0);
            int            colLen_ww1 = ww1[0].Length;
            MWNumericArray d_ww1      = new MWNumericArray(MWArrayComplexity.Real, rowLen_ww1, colLen_ww1);

            //matlab中矩阵的下标是从1开始的,而C#是从0开始的
            for (int i = 0; i < rowLen_ww1; i++)
            {
                for (int j = 0; j < colLen_ww1; j++)
                {
                    d_ww1[i + 1, j + 1] = ww1[i][j];
                }
            }

            try
            {
                //调用算法
                MWArray resultArray = ppmc.sub_preprocessing_alignment_data(d_ww, d_ww1);
                //MWArray resultArray = null;
                double[,] tmpArray = (double[, ])(resultArray.ToArray());

                retVal = (int)tmpArray[0, 0];
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }


            return(retVal);
        }
コード例 #13
0
ファイル: GlobalFocus.cs プロジェクト: oliverhk/AutoScan
        private float MatlabPeek(List <float> zposList, List <byte[, ]> bytelist, int max_cnt)
        {
            MWCellArray mwcell = new MWCellArray(max_cnt, 1);

            for (int i = 0; i < max_cnt; i++)
            {
                MWNumericArray mwarr = bytelist[i];
                mwcell[i + 1, 1] = mwarr;
            }
            MWNumericArray mwz   = zposList.ToArray();
            MWArray        mwret = this.myDll2.GlobalFocusOfSinglePointROIForDll(mwz, mwcell);

            float[,] ret = (float[, ])((MWNumericArray)mwret).ToArray(MWArrayComponent.Real);
            float new_z_pos_m = ret[0, 0];

            return(new_z_pos_m);
        }
コード例 #14
0
        public void getGasCalculate(string database, string tableName, double l, double r, double t, out double dist, out double tick)
        {
            MWCharArray    dataPath  = new MWCharArray(database);
            MWCharArray    table     = new MWCharArray(tableName);
            MWNumericArray length    = new MWNumericArray(l);
            MWNumericArray radius    = new MWNumericArray(r);
            MWNumericArray thickness = new MWNumericArray(t);

            MWArray[] argsOut = new MWArray[2];
            MWArray[] argsIn  = new MWArray[] { dataPath, table, length, radius, thickness };
            m2CClass.GasLeak(2, ref argsOut, argsIn);
            MWNumericArray distance = argsOut[0] as MWNumericArray;
            MWNumericArray timeTick = argsOut[1] as MWNumericArray;

            dist = (double)distance.ToScalarDouble();
            tick = (double)timeTick.ToScalarDouble();
        }
コード例 #15
0
ファイル: Form1.cs プロジェクト: shirsks14/BoomDesktop
        void graph(string fileName)
        {
            //chart1.Series["Data"].Points.AddXY(;
            //chart1.Series["Data"].ChartType =
            //            SeriesChartType.FastLine;
            //chart1.Series["Data"].Color = Color.Red;

            label5.Visible = true;
            try
            {
                plotSound = new soundPlotter.PlotSound();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.InnerException);
            }
            try
            {
                MWCharArray input = new MWCharArray(fileName);
                fileSelected = fileName;
                MWArray[] result = new MWArray[2];

                result        = plotSound.plotSound(2, input);
                textBox3.Text = result[0].ToString();

                //double tempo = Convert.ToDouble(result[1].ToString());
                textBox4.Text = Convert.ToDouble(result[1].ToString()).ToString();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.InnerException);
            }
            string[] temp = fileName.Split('\\');
            label6.Text    = temp[temp.Length - 1];
            label5.Visible = false;
            IntPtr foundwindow = FindWindow("sunawtframe", "figure 2");

            SetParent(foundwindow, panel1.Handle);
            MoveWindow(foundwindow, -5, -80, panel1.Width + 10, panel1.Height + 90);

            foundwindow = FindWindow("sunawtframe", "figure 1");
            SetParent(foundwindow, panel2.Handle);
            MoveWindow(foundwindow, -5, -80, panel2.Width + 10, panel2.Height + 90);
            //SetWindowPos(foundwindow, -2, 0, 0, 800, 600, 0x0040);
            //SetWindowLong(foundwindow, GWL_STYLE, WS_SYSMENU);
        }
コード例 #16
0
ファイル: FocusHelper.cs プロジェクト: oliverhk/AutoScan
        public float MatlabQPeek(List <float> zposList, List <byte[, ]> bytelist, int max_cnt, ref float z_pos1, ref float z_pos2, ref float z_pos3, ref float new_z_pos_m, bool bDirty, ref int bFineFlag)
        {
            DateTime starT    = DateTime.Now;
            int      loop_cnt = 0;
            float    rect_cnt = 0;
            float    rect     = 0;

            try
            {
                MWCellArray mwcell = new MWCellArray(max_cnt, 1);
                for (int i = 0; i < max_cnt; i++)
                {
                    MWNumericArray mwarr = bytelist[i];
                    mwcell[i + 1, 1] = mwarr;
                }
                MWNumericArray mwz = zposList.ToArray();
                loop_cnt = bDirty == false ? 0 : 1;
                MWNumericArray mwCnt = loop_cnt;
                //MWArray mwret = this.qFocus.QuickFocusOfSinglePointROIForDll(mwz, mwcell);
                MWArray mwret = this.qfprep.QuickFocusOfSinglePointROIForDll(mwz, mwcell, mwCnt);
                float[,] ret = (float[, ])((MWNumericArray)mwret).ToArray(MWArrayComponent.Real);
                z_pos1       = ret[0, 0];
                z_pos2       = ret[0, 1];
                z_pos3       = ret[0, 2];
                new_z_pos_m  = ret[0, 3];
                bFineFlag    = (int)ret[0, 4];
                z_pos1       = z_pos1 > 0.4 ? 0 : z_pos1;
                z_pos2       = z_pos2 > 0.4 ? 0 : z_pos2;
                z_pos3       = z_pos3 > 0.4 ? 0 : z_pos3;
                if (rect_cnt == 1)
                {
                    loop_cnt++;
                }
                else
                {
                    loop_cnt = 0;
                }
                rect = new_z_pos_m;
            }
            catch (Exception ex)
            { LogHelper.AppLoger.Error(ex); }
            finally
            {
            }
            return(rect);
        }
コード例 #17
0
        public double[] passaAlta(double[] sinal, int polos, int fc, int fs)
        {
            double[] res = new double[sinal.Length];

            MWNumericArray aux_res2 = new MWNumericArray(new double[sinal.Length]);
            MWNumericArray xdt      = new MWNumericArray(new double[sinal.Length]);
            Array          aux_res3 = null;
            Fltros         obj      = new Fltros();

            xdt = sinal;
            MWArray aux_res = obj.HighPassFilt(xdt, polos, fc, fs);

            aux_res2 = (MWNumericArray)aux_res;
            aux_res3 = aux_res2.ToVector(MWArrayComponent.Real);
            res      = (double[])aux_res3;
            return(res);
        }
コード例 #18
0
ファイル: FocusHelper.cs プロジェクト: oliverhk/AutoScan
        public void MatlabFitting(Dictionary <Point, float> dicMap)
        {
            try
            {
                int max = dicMap.Count;
                double[,] dbx = new double[max, 3];
                MWCellArray   mwary  = new MWCellArray(max, 3);
                List <Point>  lst    = new List <Point>(dicMap.Keys);
                StringBuilder strDat = new StringBuilder();
                for (int i = 0; i < lst.Count; i++)
                {
                    Point p = lst[i];
                    float v = dicMap[p];
                    //float[] fv = new float[3] { (float)p.X, (float)p.Y, v };
                    dbx[i, 0] = (double)p.X;
                    dbx[i, 1] = (double)p.Y;
                    dbx[i, 2] = (double)v;
                    strDat.AppendFormat("{0},{1},{2}", p.X, p.Y, v);
                    strDat.AppendFormat(System.Environment.NewLine);
                }

                //save result to file
                string path = @"c:\map\";
                if (!System.IO.Directory.Exists(path))
                {
                    System.IO.Directory.CreateDirectory(path);
                }
                var          utf8WithoutBom = new System.Text.UTF8Encoding(true);
                FileStream   fs             = new FileStream(path + "final_data.csv", FileMode.Create);
                StreamWriter sw             = new StreamWriter(fs, utf8WithoutBom);
                sw.Write(strDat.ToString());
                //清空缓冲区
                sw.Flush();
                //关闭流
                sw.Close();
                fs.Close();

                MWNumericArray x     = new MWNumericArray(dbx);
                MWArray        mwret = this.gfPrep.PreMapFunction(x);
                //float[,] ret = (float[,])((MWNumericArray)mwret).ToArray(MWArrayComponent.Real);
            }
            catch (Exception ex)
            {
                LogHelper.AppLoger.Error(ex);
            }
        }
コード例 #19
0
        public ProblemOutput Solve(ProblemInput problem)
        {
            ProblemOutput solution = new ProblemOutput
            {
                D             = problem.D,
                HasSolution   = false,
                Value         = double.NaN,
                Solution      = Enumerable.Repeat(double.NaN, problem.N).ToArray(),
                SkipedIndexes = problem.SkipedIndexes
            };

            if (problem.N > 0)
            {
                MWArray[]      input = new MWArray[4];
                MWNumericArray _h    = problem.Quadratic;
                MWNumericArray _f    = problem.Linear;
                MWNumericArray _A    = problem.ConstraintMatrix;
                MWNumericArray _B    = problem.ConstraintValues;
                input[0] = _h;
                input[1] = _f;
                input[2] = _A;
                input[3] = _B;
                try
                {
                    SolveQPClass r      = new SolveQPClass();
                    MWArray[]    result = new MWArray[3];
                    r.SolveQP(result.Length, ref result, input);
                    bool success = ((MWNumericArray)result[2]).ToScalarDouble() > 0;
                    if (success)
                    {
                        double[] x   = (double[])(((MWNumericArray)result[0]).ToVector(MWArrayComponent.Real));
                        double   val = ((MWNumericArray)result[1]).ToScalarDouble();
                        solution.HasSolution = success;
                        solution.Value       = -val;
                        solution.Solution    = x;
                    }
                    r.Dispose();
                }
                catch (Exception e)
                {
                    return(solution);
                }
            }
            return(solution);
        }
コード例 #20
0
        /// <summary>
        /// 调用matlab算法
        /// </summary>
        /// <param name="CSinput"></param>
        /// <param name="PortName"></param>
        public void Anaylase(double[] CSinput, string PortName)
        {
            //int retSize = 256; 256, i, retSize, mwin
            double[,] CSoutput = new double[2, 256];
            MWArray        i    = 2;
            MWNumericArray mwin = new MWNumericArray(CSinput);

            try
            {
                CSoutput = (double[, ])((MWNumericArray)myClass.xhcl(mwin)).ToArray(MWArrayComponent.Real);

                InsertData(CSoutput, PortName, "ret");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "ERROR");
            }
        }
コード例 #21
0
 public bool GetSignature(string SignaturePath, int UserId)
 {
     //int fakeId = 4;
     #region MATLAB
     var signaturePath = HttpContext.Current.Server.MapPath(SignaturePath);
     Matlab.SignatureVerification.Signature sig = new Matlab.SignatureVerification.Signature();
     MWArray mw    = sig.main(signaturePath, UserId);
     double  value = (double)((MWNumericArray)mw).ToVector(MWArrayComponent.Real).GetValue(0);
     if (value > 0.5)
     {
         return(true);
     }
     else
     {
         return(false);
     }
     #endregion
 }
コード例 #22
0
 public static void GetPath(int [] jobsequence, int [] emergency)
 {
     try
     {
         sequence1 = null;
         sequence2 = null;
         MWArray[] trans = new MWArray[] { swarmsize, (MWNumericArray)jobsequence, (MWNumericArray)emergency };
         Dyna.PSOUpdate(3, ref ending, trans);
         MWNumericArray x1 = ending[1] as MWNumericArray;
         MWNumericArray x2 = ending[2] as MWNumericArray;
         sequence1 = (double[, ])x1.ToArray();
         sequence2 = (double[, ])x2.ToArray();
     }
     catch (Exception str)
     {
         MessageBox.Show("Error!!" + str.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #23
0
        public Image Apply(Image img)
        {
            MWArray arr = m_assets.ConnectedComponent(img.ToSingleMatlabArray());
            var     d   = arr.ToArray();

            Elements = new CCElement[d.GetLength(0)];
            for (int i = 0; i < d.GetLength(0); i++)
            {
                var ooo = d.GetValue(i, 0);
                Elements[i].Center_X = (double)ooo;

                ooo = d.GetValue(i, 1);
                Elements[i].Center_Y = (double)ooo;

                ooo = d.GetValue(i, 2);
                Elements[i].Area = (double)ooo;
            }
            return(img);
        }
コード例 #24
0
        /// <summary>
        /// Gets the rectangle where the brain is located
        /// </summary>
        public int[] CropBrain()
        {
            int[] brainRect = new int[4];
            try
            {
                MWArray[] res = new MWArray[4];
                res          = FEC.CropBrain(4, this.imagePath);
                brainRect[0] = int.Parse(res[0].ToString());
                brainRect[1] = int.Parse(res[1].ToString());
                brainRect[2] = int.Parse(res[2].ToString());
                brainRect[3] = int.Parse(res[3].ToString());

                return(brainRect);
            }
            catch (Exception ex)
            {
                return(brainRect);
            }
        }
コード例 #25
0
ファイル: SRC.cs プロジェクト: yufeijie/learngit
        /// <summary>
        /// 设计主电路元件参数
        /// </summary>
        private void DesignCircuitParam()
        {
            double P   = math_Pfull;
            double Vin = math_Vin;
            double Vo  = math_Vo;
            double No  = math_No;
            double fs  = math_fs;
            double Td  = math_Tdead;
            double Q   = math_Q;

            double RL = No * Math.Pow(Vo, 2) / P; //负载等效电阻
            double n  = Vin / Vo;                 //变比
            double ws = 2 * Math.PI * fs;
            double Re = 8 * n * n * RL / (No * Math.PI * Math.PI);
            double Zr = Re * Q; //谐振阻抗

            //求解Vo_act和wr
            MWArray        output = Formula.solve.solveSRC_wr(P, Vin, n, fs, Zr, Td);
            MWNumericArray result = (MWNumericArray)output;
            double         Vo_act = result[1].ToScalarDouble(); //实际输出电压
            double         wr     = result[2].ToScalarDouble(); //谐振角速度

            if (Vo_act > Vo || Vo_act < Vo / 2)
            {
                Console.WriteLine("Wrong Vo!");
                Environment.Exit(-1);
            }

            if (wr > ws || wr < ws / 2)
            {
                Console.WriteLine("Wrong wr!");
                Environment.Exit(-1);
            }

            math_n      = n;
            math_fr     = wr / 2 / Math.PI;
            math_Lr     = Zr / wr;
            math_Cr     = 1 / Zr / wr;
            math_ψ      = 0.5 * Vo * n / fs;
            math_VSpmax = Vin;
            math_VSsmax = Vo;
            math_VCfmax = Vo;
        }
コード例 #26
0
        private void IndoorWindow_Simulation_Apply_Click(object sender, RoutedEventArgs e)
        {
            double[] Location_Tx = { 1, 14, 1 };
            double[] Location_Rx = { 2, 12, 2 };

            MWNumericArray Location_Tx_m = new MWNumericArray(1, 3, Location_Tx);
            MWNumericArray Location_Rx_m = new MWNumericArray(1, 3, Location_Rx);

            Console.Write(Location_Tx_m.ToString());


            MWArray[]       agrsOut      = new MWArray[14];
            raytracingClass raytracing_m = new raytracingClass();

            agrsOut = raytracing_m.raytracing(14, 0, rayparameter.Power_Tx, rayparameter.Frequency_Tx, 6.4, 0.0004, 1, 1, Location_Tx_m, Location_Rx_m, 0);
            OutputWindow OutputWin = new OutputWindow();

            OutputWin.Show();
        }
コード例 #27
0
ファイル: VitalSignsService.cs プロジェクト: aaana/rfid
        public FrequencyInfo offlineAnalyze(string fileName)
        {
            Console.WriteLine("Start analyzing offline file:" + fileName);

            MWCharArray filename = fileName;

            MWArray[] argsIn = new MWArray[] { filename };
            MWArray[] result = new MWArray[3];
            vitalSignsExtract.offlineVitalSignsExtract(3, ref result, argsIn);
            double[,] temp = (double[, ])result[0].ToArray();
            int num = temp.GetLength(1);

            double[] breath    = new double[num];
            double[] heartbeat = new double[num];
            double[] t         = new double[num];
            for (int i = 0; i < num; i++)
            {
                breath[i]    = temp[1, i];
                heartbeat[i] = temp[2, i];
                t[i]         = temp[0, i];
            }
            double        meanBreath    = (double)(MWNumericArray)result[1];
            double        meanHeartbeat = (double)(MWNumericArray)result[2];
            FrequencyInfo frequency     = new FrequencyInfo(breath, heartbeat, t, meanBreath, meanHeartbeat, 0);

            /*
             * double[,] time = (double[,])result[1].ToArray();
             * int num = frequency.GetLength(1);
             * int[] breath = new int[num];
             * heartbeat = new int[num];
             * t = new double[num];
             * for(int i = 0; i < num; i++)
             * {
             *  breath[i] = (int)frequency[0, i];
             *  heartbeat[i] = (int)frequency[1, i];
             *  t[i] = time[0, i];
             * }
             * return breath;*/
            Console.WriteLine("Analysis ends");
            return(frequency);
            //throw new NotImplementedException();
        }
コード例 #28
0
        public double[][] NextNormalRandomMatrix(double mu, double sigma, int n, int m)
        {
            var     norm    = new Normrand.MATLAB_NormalRandom();
            MWArray M_mu    = new MWNumericArray(mu);
            MWArray M_sigma = new MWNumericArray(sigma);
            MWArray M_n     = new MWNumericArray(n);
            MWArray M_m     = new MWNumericArray(m);
            MWArray R       = norm.Normrand(M_mu, M_sigma, M_n, M_m);
            var     result  = new double[n][];

            for (int i = 0; i < n; i++)
            {
                result[i] = new double[m];
                for (int j = 0; j < m; j++)
                {
                    result[i][j] = ((MWNumericArray)R[i + 1, j + 1]).ToScalarDouble();
                }
            }
            return(result);
        }
コード例 #29
0
ファイル: JYFilter.cs プロジェクト: ziyushijie/SharpToolDemo
        /// <summary>
        /// Kaiser Window Filter
        /// </summary>
        /// <param name="inputData">Input waform data</param>
        /// <param name="f">Band edges</param>
        /// <param name="a"> Desired amplitude on the bands define by f</param>
        /// <param name="dev">Passband ripple and stopband attenuation</param>
        /// <param name="fs">Samplerate</param>
        /// <returns>Output waveform data</returns>
        public static double[] Kaiser(double[] inputData, double[] f, double[] a, double[] dev, double fs)
        {
            MWNumericArray inputDataMatlab = inputData;
            MWNumericArray fMatlab         = f;
            MWNumericArray aMatlab         = a;
            MWNumericArray devMatlab       = dev;
            MWArray        fsMatlab        = fs;

            MWArray[] resultMatlab;
            double[,] result2D;
            double[] result;

            DSPClass dspTask = new DSPClass();

            resultMatlab = dspTask.Kaiser(1, inputDataMatlab, fMatlab, aMatlab, devMatlab, fsMatlab);

            result2D = (double[, ])resultMatlab[0].ToArray();
            result   = new double[result2D.Length];
            Buffer.BlockCopy(result2D, 0, result, 0, result2D.Length * sizeof(double));
            return(result);
        }
コード例 #30
0
ファイル: Image.cs プロジェクト: Forpatril/Diploma
        public Image(string path)
        {
            MWNumericArray descriptor = null;
            MWCharArray mw_path;
            try
            {
                mw_path = new MWCharArray(path);
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString());
                return;
            }
            
            Loader Loader = new Loader();
            image = Loader.loadimage(mw_path);
            descriptor = (MWNumericArray)image;
            try
            {
                Array = new ImageArray((double[,])descriptor.ToArray(MWArrayComponent.Real));
            }
            catch (InvalidCastException exc)
            {
                descriptor = null;
                mw_path = null;
                Loader = null;
                GC.Collect();
                return;
            }

            Height = Array.Array.GetLength(0);
            Width = Array.Array.GetLength(1);
            GetBitmap();

            descriptor = null;
            mw_path = null;
            Loader = null;
            GC.Collect();
        }
コード例 #31
0
        static void Main(string[] args)
        {
            MWArray In  = null;
            MWArray Out = null;

            try {
                DiffTpye testMethod = new DiffTpye(); //创建一个实例
                In = 4;                               //此处发生隐式转换

                //double数组
                Out = testMethod.magicDouble(In);
                Console.WriteLine("The doubleArray result is :\n{0}\n", (MWNumericArray)Out);

                //char数组
                Out = testMethod.magicChar(In);
                Console.WriteLine("The CharArray result is :\n{0}\n", Out);

                //cell数组
                Out = testMethod.magicCell(In);
                //Return Out.ToArray()
                //    {object[1, 1]}
                //      [0, 0]: {double[4, 4]}

                Console.WriteLine("The CellArray result is :\n{0}\n", Out);
                //Return ((MWCellArray)Out).ToArray().GetValue(0,0)
                //{double[4, 4]}

                //struct数组
                Out = testMethod.magicStruct(In);

                Console.WriteLine("The StructArray result is :\n{0}", ((MWStructArray)Out).GetField("value"));
                //Return ((MWStructArray)Out).GetField("value").ToArray()
                //   {double[4, 4]}
            } catch (Exception e) {
                Console.WriteLine(e);
            } finally {
                Console.Read();
            }
        }
コード例 #32
0
        //@param s_id subject id
        //@param ecg_in a single sample value of the subject's ECG
        public void enrollment(double[] ecg_in, int s_id)
        {
            for( int i = 0; i < ecg_in.Length; i++)
            {
                ecg[i] = ecg_in[i];
            }

            //Create a MWArray to pass value into converted matlab function
                MWNumericArray subj_id = new MWNumericArray(s_id);
                MWNumericArray ecg_raw = new MWNumericArray(1280, 1, ecg);
                MWArray temp = AClass.process(ecg_raw, M);  //process ecg data(filter and AC)

                //autocorrelated signal is added to both gallery
                MWArray gal = new MWNumericArray();
                gal = gallery;
                gallery = AClass.addtogallery(gal, temp);

                MWArray gal1 = new MWNumericArray();
                gal1 = enrollee_gallery;
                enrollee_gallery = AClass.addtogallery(gal1, temp);

                //subject id is added to the id vector
                MWArray id_temp = new MWNumericArray();
                id_temp = id;
                id = AClass.addtoid(id_temp, subj_id);

                MWArray id_temp1 = new MWNumericArray();
                id_temp1 = enrollee_id;
                enrollee_id = AClass.addtoid(id_temp1, subj_id);

                //the weight matric is calculated
                weights = AClass.dlda(gallery, id);

                //enrollee gallery is projected
                projected_gallery = AClass.projection(gallery, weights); //use enrollee gallery if want to project enrollee gallery
        }
コード例 #33
0
 /// <summary>
 /// Provides a single output, 2-input MWArray interface to the addtogallery
 /// M-function.
 /// </summary>
 /// <remarks>
 /// </remarks>
 /// <param name="gal">Input argument #1</param>
 /// <param name="addition">Input argument #2</param>
 /// <returns>An MWArray containing the first output argument.</returns>
 ///
 public MWArray addtogallery(MWArray gal, MWArray addition)
 {
     return mcr.EvaluateFunction("addtogallery", gal, addition);
 }
コード例 #34
0
 /// <summary>
 /// Provides an interface for the pdchsim function in which the input and output
 /// arguments are specified as an array of MWArrays.
 /// </summary>
 /// <remarks>
 /// This method will allocate and return by reference the output argument
 /// array.<newpara></newpara>
 /// </remarks>
 /// <param name="numArgsOut">The number of output arguments to return</param>
 /// <param name= "argsOut">Array of MWArray output arguments</param>
 /// <param name= "argsIn">Array of MWArray input arguments</param>
 ///
 public void pdchsim(int numArgsOut, ref MWArray[] argsOut, MWArray[] argsIn)
   {
     mcr.EvaluateFunction("pdchsim", numArgsOut, ref argsOut, argsIn);
   }
コード例 #35
0
 /// <summary>
 /// Provides a single output, 2-input interface to the pdchsim M-function.
 /// </summary>
 /// <remarks>
 /// </remarks>
 /// <param name="traffic">Input argument #1</param>
 /// <param name="pdchuse">Input argument #2</param>
 /// <returns>An MWArray containing the first output argument.</returns>
 ///
 public MWArray pdchsim(MWArray traffic, MWArray pdchuse)
   {
     return mcr.EvaluateFunction("pdchsim", traffic, pdchuse);
   }
コード例 #36
0
 /// <summary>
 /// Provides the standard 4-input interface to the newton M-function.
 /// </summary>
 /// <remarks>
 /// M-Documentation:
 /// [x, y] = newton(A,b,x0,niter);
 /// solves the linear least squares problem with nonnegative variables using the
 /// newton's algorithm in [1].
 /// Input:
 /// A:      [MxN] matrix 
 /// b:      [Mx1] vector
 /// x0:     [Nx1] vector of initial values. x0 > 0. Default value: ones(n,1)
 /// niter:  Number of iterations. Default value: 10
 /// Output
 /// x:      solution
 /// y:      complementary solution
 /// [1] Portugal, Judice and Vicente, A comparison of block pivoting and
 /// interior point algorithms for linear least squares problems with
 /// nonnegative variables, Mathematics of Computation, 63(1994), pp. 625-643
 /// Uriel Roque
 /// 02.05.2006
 /// </remarks>
 /// <param name="numArgsOut">The number of output arguments to return.</param>
 /// <param name="A">Input argument #1</param>
 /// <param name="b">Input argument #2</param>
 /// <param name="x0">Input argument #3</param>
 /// <param name="niter">Input argument #4</param>
 /// <returns>An Array of length "numArgsOut" containing the output
 /// arguments.</returns>
 ///
 public MWArray[] newton(int numArgsOut, MWArray A, MWArray b,
                         MWArray x0, MWArray niter)
   {
     return mcr.EvaluateFunction(numArgsOut, "newton", A, b, x0, niter);
   }
コード例 #37
0
 /// <summary>
 /// Provides a single output, 4-input interface to the newton M-function.
 /// </summary>
 /// <remarks>
 /// M-Documentation:
 /// [x, y] = newton(A,b,x0,niter);
 /// solves the linear least squares problem with nonnegative variables using the
 /// newton's algorithm in [1].
 /// Input:
 /// A:      [MxN] matrix 
 /// b:      [Mx1] vector
 /// x0:     [Nx1] vector of initial values. x0 > 0. Default value: ones(n,1)
 /// niter:  Number of iterations. Default value: 10
 /// Output
 /// x:      solution
 /// y:      complementary solution
 /// [1] Portugal, Judice and Vicente, A comparison of block pivoting and
 /// interior point algorithms for linear least squares problems with
 /// nonnegative variables, Mathematics of Computation, 63(1994), pp. 625-643
 /// Uriel Roque
 /// 02.05.2006
 /// </remarks>
 /// <param name="A">Input argument #1</param>
 /// <param name="b">Input argument #2</param>
 /// <param name="x0">Input argument #3</param>
 /// <param name="niter">Input argument #4</param>
 /// <returns>An MWArray containing the first output argument.</returns>
 ///
 public MWArray newton(MWArray A, MWArray b, MWArray x0, MWArray niter)
   {
     return mcr.EvaluateFunction("newton", A, b, x0, niter);
   }
コード例 #38
0
 /// <summary>
 /// Provides a single output, 1-input interface to the newton M-function.
 /// </summary>
 /// <remarks>
 /// M-Documentation:
 /// [x, y] = newton(A,b,x0,niter);
 /// solves the linear least squares problem with nonnegative variables using the
 /// newton's algorithm in [1].
 /// Input:
 /// A:      [MxN] matrix 
 /// b:      [Mx1] vector
 /// x0:     [Nx1] vector of initial values. x0 > 0. Default value: ones(n,1)
 /// niter:  Number of iterations. Default value: 10
 /// Output
 /// x:      solution
 /// y:      complementary solution
 /// [1] Portugal, Judice and Vicente, A comparison of block pivoting and
 /// interior point algorithms for linear least squares problems with
 /// nonnegative variables, Mathematics of Computation, 63(1994), pp. 625-643
 /// Uriel Roque
 /// 02.05.2006
 /// </remarks>
 /// <param name="A">Input argument #1</param>
 /// <returns>An MWArray containing the first output argument.</returns>
 ///
 public MWArray newton(MWArray A)
   {
     return mcr.EvaluateFunction("newton", A);
   }
コード例 #39
0
ファイル: Loader.cs プロジェクト: Forpatril/Diploma
 /// <summary>
 /// Provides the standard 1-input MWArray interface to the loadimage M-function.
 /// </summary>
 /// <remarks>
 /// </remarks>
 /// <param name="numArgsOut">The number of output arguments to return.</param>
 /// <param name="path">Input argument #1</param>
 /// <returns>An Array of length "numArgsOut" containing the output
 /// arguments.</returns>
 ///
 public MWArray[] loadimage(int numArgsOut, MWArray path)
 {
   return mcr.EvaluateFunction(numArgsOut, "loadimage", path);
 }
コード例 #40
0
 /// <summary>
 /// Provides an interface for the addtoid function in which the input and output
 /// arguments are specified as an array of MWArrays.
 /// </summary>
 /// <remarks>
 /// This method will allocate and return by reference the output argument
 /// array.<newpara></newpara>
 /// </remarks>
 /// <param name="numArgsOut">The number of output arguments to return</param>
 /// <param name= "argsOut">Array of MWArray output arguments</param>
 /// <param name= "argsIn">Array of MWArray input arguments</param>
 ///
 public void addtoid(int numArgsOut, ref MWArray[] argsOut, MWArray[] argsIn)
 {
     mcr.EvaluateFunction("addtoid", numArgsOut, ref argsOut, argsIn);
 }
コード例 #41
0
 /// <summary>
 /// Provides a single output, 2-input MWArray interface to the projection
 /// M-function.
 /// </summary>
 /// <remarks>
 /// </remarks>
 /// <param name="input">Input argument #1</param>
 /// <param name="weight">Input argument #2</param>
 /// <returns>An MWArray containing the first output argument.</returns>
 ///
 public MWArray projection(MWArray input, MWArray weight)
 {
     return mcr.EvaluateFunction("projection", input, weight);
 }
コード例 #42
0
 /// <summary>
 /// Provides the standard 2-input MWArray interface to the addtoid M-function.
 /// </summary>
 /// <remarks>
 /// </remarks>
 /// <param name="numArgsOut">The number of output arguments to return.</param>
 /// <param name="id">Input argument #1</param>
 /// <param name="subj_id">Input argument #2</param>
 /// <returns>An Array of length "numArgsOut" containing the output
 /// arguments.</returns>
 ///
 public MWArray[] addtoid(int numArgsOut, MWArray id, MWArray subj_id)
 {
     return mcr.EvaluateFunction(numArgsOut, "addtoid", id, subj_id);
 }
コード例 #43
0
 /// <summary>
 /// Provides a single output, 2-input MWArray interface to the addtoid M-function.
 /// </summary>
 /// <remarks>
 /// </remarks>
 /// <param name="id">Input argument #1</param>
 /// <param name="subj_id">Input argument #2</param>
 /// <returns>An MWArray containing the first output argument.</returns>
 ///
 public MWArray addtoid(MWArray id, MWArray subj_id)
 {
     return mcr.EvaluateFunction("addtoid", id, subj_id);
 }
コード例 #44
0
 /// <summary>
 /// Provides the standard 2-input MWArray interface to the addtogallery M-function.
 /// </summary>
 /// <remarks>
 /// </remarks>
 /// <param name="numArgsOut">The number of output arguments to return.</param>
 /// <param name="gal">Input argument #1</param>
 /// <param name="addition">Input argument #2</param>
 /// <returns>An Array of length "numArgsOut" containing the output
 /// arguments.</returns>
 ///
 public MWArray[] addtogallery(int numArgsOut, MWArray gal,
                               MWArray addition)
 {
     return mcr.EvaluateFunction(numArgsOut, "addtogallery",
                                 gal, addition);
 }
コード例 #45
0
 /// <summary>
 /// Provides an interface for the SchwartzAndSmith function in which the input and
 /// output
 /// arguments are specified as an array of MWArrays.
 /// </summary>
 /// <remarks>
 /// This method will allocate and return by reference the output argument
 /// array.<newpara></newpara>
 /// M-Documentation:
 /// Script: MAIN - fonction principale du programme
 /// Permet la vue globable sur tout le processing
 /// </remarks>
 /// <param name="numArgsOut">The number of output arguments to return</param>
 /// <param name= "argsOut">Array of MWArray output arguments</param>
 /// <param name= "argsIn">Array of MWArray input arguments</param>
 ///
 public void SchwartzAndSmith(int numArgsOut, ref MWArray[] argsOut, MWArray[] argsIn)
 {
   mcr.EvaluateFunction("SchwartzAndSmith", numArgsOut, ref argsOut, argsIn);
 }
コード例 #46
0
 /// <summary>
 /// Provides a single output, 1-input MWArrayinterface to the SchwartzAndSmith
 /// M-function.
 /// </summary>
 /// <remarks>
 /// M-Documentation:
 /// Script: MAIN - fonction principale du programme
 /// Permet la vue globable sur tout le processing
 /// </remarks>
 /// <param name="maxiter">Input argument #1</param>
 /// <returns>An MWArray containing the first output argument.</returns>
 ///
 public MWArray SchwartzAndSmith(MWArray maxiter)
 {
   return mcr.EvaluateFunction("SchwartzAndSmith", maxiter);
 }
コード例 #47
0
ファイル: Loader.cs プロジェクト: Forpatril/Diploma
 /// <summary>
 /// Provides a single output, 1-input MWArrayinterface to the loadimage M-function.
 /// </summary>
 /// <remarks>
 /// </remarks>
 /// <param name="path">Input argument #1</param>
 /// <returns>An MWArray containing the first output argument.</returns>
 ///
 public MWArray loadimage(MWArray path)
 {
   return mcr.EvaluateFunction("loadimage", path);
 }
コード例 #48
0
 /// <summary>
 /// Provides a single output, 3-input MWArrayinterface to the SchwartzAndSmith
 /// M-function.
 /// </summary>
 /// <remarks>
 /// M-Documentation:
 /// Script: MAIN - fonction principale du programme
 /// Permet la vue globable sur tout le processing
 /// </remarks>
 /// <param name="maxiter">Input argument #1</param>
 /// <param name="x0">Input argument #2</param>
 /// <param name="e0">Input argument #3</param>
 /// <returns>An MWArray containing the first output argument.</returns>
 ///
 public MWArray SchwartzAndSmith(MWArray maxiter, MWArray x0, MWArray e0)
 {
   return mcr.EvaluateFunction("SchwartzAndSmith", maxiter, x0, e0);
 }
コード例 #49
0
ファイル: Loader.cs プロジェクト: Forpatril/Diploma
 /// <summary>
 /// Provides an interface for the loadimage function in which the input and output
 /// arguments are specified as an array of MWArrays.
 /// </summary>
 /// <remarks>
 /// This method will allocate and return by reference the output argument
 /// array.<newpara></newpara>
 /// </remarks>
 /// <param name="numArgsOut">The number of output arguments to return</param>
 /// <param name= "argsOut">Array of MWArray output arguments</param>
 /// <param name= "argsIn">Array of MWArray input arguments</param>
 ///
 public void loadimage(int numArgsOut, ref MWArray[] argsOut, MWArray[] argsIn)
 {
   mcr.EvaluateFunction("loadimage", numArgsOut, ref argsOut, argsIn);
 }
コード例 #50
0
 /// <summary>
 /// Provides a single output, 6-input MWArrayinterface to the SchwartzAndSmith
 /// M-function.
 /// </summary>
 /// <remarks>
 /// M-Documentation:
 /// Script: MAIN - fonction principale du programme
 /// Permet la vue globable sur tout le processing
 /// </remarks>
 /// <param name="maxiter">Input argument #1</param>
 /// <param name="x0">Input argument #2</param>
 /// <param name="e0">Input argument #3</param>
 /// <param name="maturity">Input argument #4</param>
 /// <param name="y">Input argument #5</param>
 /// <param name="k_in1">Input argument #6</param>
 /// <returns>An MWArray containing the first output argument.</returns>
 ///
 public MWArray SchwartzAndSmith(MWArray maxiter, MWArray x0, MWArray e0, MWArray 
                           maturity, MWArray y, MWArray k_in1)
 {
   return mcr.EvaluateFunction("SchwartzAndSmith", maxiter, x0, e0, maturity, y, k_in1);
 }
コード例 #51
0
 /// <summary>
 /// Provides a single output, 2-input interface to the newton M-function.
 /// </summary>
 /// <remarks>
 /// M-Documentation:
 /// [x, y] = newton(A,b,x0,niter);
 /// solves the linear least squares problem with nonnegative variables using the
 /// newton's algorithm in [1].
 /// Input:
 /// A:      [MxN] matrix 
 /// b:      [Mx1] vector
 /// x0:     [Nx1] vector of initial values. x0 > 0. Default value: ones(n,1)
 /// niter:  Number of iterations. Default value: 10
 /// Output
 /// x:      solution
 /// y:      complementary solution
 /// [1] Portugal, Judice and Vicente, A comparison of block pivoting and
 /// interior point algorithms for linear least squares problems with
 /// nonnegative variables, Mathematics of Computation, 63(1994), pp. 625-643
 /// Uriel Roque
 /// 02.05.2006
 /// </remarks>
 /// <param name="A">Input argument #1</param>
 /// <param name="b">Input argument #2</param>
 /// <returns>An MWArray containing the first output argument.</returns>
 ///
 public MWArray newton(MWArray A, MWArray b)
   {
     return mcr.EvaluateFunction("newton", A, b);
   }
コード例 #52
0
 /// <summary>
 /// Provides a single output, 10-input MWArrayinterface to the SchwartzAndSmith
 /// M-function.
 /// </summary>
 /// <remarks>
 /// M-Documentation:
 /// Script: MAIN - fonction principale du programme
 /// Permet la vue globable sur tout le processing
 /// </remarks>
 /// <param name="maxiter">Input argument #1</param>
 /// <param name="x0">Input argument #2</param>
 /// <param name="e0">Input argument #3</param>
 /// <param name="maturity">Input argument #4</param>
 /// <param name="y">Input argument #5</param>
 /// <param name="k_in1">Input argument #6</param>
 /// <param name="mu_e_in1">Input argument #7</param>
 /// <param name="sigma_x_in1">Input argument #8</param>
 /// <param name="sigma_e_in1">Input argument #9</param>
 /// <param name="p_xe_in1">Input argument #10</param>
 /// <returns>An MWArray containing the first output argument.</returns>
 ///
 public MWArray SchwartzAndSmith(MWArray maxiter, MWArray x0, MWArray e0, MWArray 
                           maturity, MWArray y, MWArray k_in1, MWArray mu_e_in1, 
                           MWArray sigma_x_in1, MWArray sigma_e_in1, MWArray p_xe_in1)
 {
   return mcr.EvaluateFunction("SchwartzAndSmith", maxiter, x0, e0, maturity, y, k_in1, mu_e_in1, sigma_x_in1, sigma_e_in1, p_xe_in1);
 }
コード例 #53
0
 /// <summary>
 /// Provides the standard 2-input interface to the newton M-function.
 /// </summary>
 /// <remarks>
 /// M-Documentation:
 /// [x, y] = newton(A,b,x0,niter);
 /// solves the linear least squares problem with nonnegative variables using the
 /// newton's algorithm in [1].
 /// Input:
 /// A:      [MxN] matrix 
 /// b:      [Mx1] vector
 /// x0:     [Nx1] vector of initial values. x0 > 0. Default value: ones(n,1)
 /// niter:  Number of iterations. Default value: 10
 /// Output
 /// x:      solution
 /// y:      complementary solution
 /// [1] Portugal, Judice and Vicente, A comparison of block pivoting and
 /// interior point algorithms for linear least squares problems with
 /// nonnegative variables, Mathematics of Computation, 63(1994), pp. 625-643
 /// Uriel Roque
 /// 02.05.2006
 /// </remarks>
 /// <param name="numArgsOut">The number of output arguments to return.</param>
 /// <param name="A">Input argument #1</param>
 /// <param name="b">Input argument #2</param>
 /// <returns>An Array of length "numArgsOut" containing the output
 /// arguments.</returns>
 ///
 public MWArray[] newton(int numArgsOut, MWArray A, MWArray b)
   {
     return mcr.EvaluateFunction(numArgsOut, "newton", A, b);
   }
コード例 #54
0
 /// <summary>
 /// Provides the standard 3-input MWArray interface to the SchwartzAndSmith
 /// M-function.
 /// </summary>
 /// <remarks>
 /// M-Documentation:
 /// Script: MAIN - fonction principale du programme
 /// Permet la vue globable sur tout le processing
 /// </remarks>
 /// <param name="numArgsOut">The number of output arguments to return.</param>
 /// <param name="maxiter">Input argument #1</param>
 /// <param name="x0">Input argument #2</param>
 /// <param name="e0">Input argument #3</param>
 /// <returns>An Array of length "numArgsOut" containing the output
 /// arguments.</returns>
 ///
 public MWArray[] SchwartzAndSmith(int numArgsOut, MWArray maxiter, MWArray x0, 
                             MWArray e0)
 {
   return mcr.EvaluateFunction(numArgsOut, "SchwartzAndSmith", maxiter, x0, e0);
 }
コード例 #55
0
 /// <summary>
 /// Provides an interface for the newton function in which the input and output
 /// arguments are specified as an array of MWArrays.
 /// </summary>
 /// <remarks>
 /// This method will allocate and return by reference the output argument
 /// array.<newpara></newpara>
 /// M-Documentation:
 /// [x, y] = newton(A,b,x0,niter);
 /// solves the linear least squares problem with nonnegative variables using the
 /// newton's algorithm in [1].
 /// Input:
 /// A:      [MxN] matrix 
 /// b:      [Mx1] vector
 /// x0:     [Nx1] vector of initial values. x0 > 0. Default value: ones(n,1)
 /// niter:  Number of iterations. Default value: 10
 /// Output
 /// x:      solution
 /// y:      complementary solution
 /// [1] Portugal, Judice and Vicente, A comparison of block pivoting and
 /// interior point algorithms for linear least squares problems with
 /// nonnegative variables, Mathematics of Computation, 63(1994), pp. 625-643
 /// Uriel Roque
 /// 02.05.2006
 /// </remarks>
 /// <param name="numArgsOut">The number of output arguments to return</param>
 /// <param name= "argsOut">Array of MWArray output arguments</param>
 /// <param name= "argsIn">Array of MWArray input arguments</param>
 ///
 public void newton(int numArgsOut, ref MWArray[] argsOut, MWArray[] argsIn)
   {
     mcr.EvaluateFunction("newton", numArgsOut, ref argsOut, argsIn);
   }
コード例 #56
0
 /// <summary>
 /// Provides the standard 6-input MWArray interface to the SchwartzAndSmith
 /// M-function.
 /// </summary>
 /// <remarks>
 /// M-Documentation:
 /// Script: MAIN - fonction principale du programme
 /// Permet la vue globable sur tout le processing
 /// </remarks>
 /// <param name="numArgsOut">The number of output arguments to return.</param>
 /// <param name="maxiter">Input argument #1</param>
 /// <param name="x0">Input argument #2</param>
 /// <param name="e0">Input argument #3</param>
 /// <param name="maturity">Input argument #4</param>
 /// <param name="y">Input argument #5</param>
 /// <param name="k_in1">Input argument #6</param>
 /// <returns>An Array of length "numArgsOut" containing the output
 /// arguments.</returns>
 ///
 public MWArray[] SchwartzAndSmith(int numArgsOut, MWArray maxiter, MWArray x0, 
                             MWArray e0, MWArray maturity, MWArray y, MWArray k_in1)
 {
   return mcr.EvaluateFunction(numArgsOut, "SchwartzAndSmith", maxiter, x0, e0, maturity, y, k_in1);
 }
コード例 #57
0
 /// <summary>
 /// Provides the standard 2-input interface to the pdchsim M-function.
 /// </summary>
 /// <remarks>
 /// </remarks>
 /// <param name="numArgsOut">The number of output arguments to return.</param>
 /// <param name="traffic">Input argument #1</param>
 /// <param name="pdchuse">Input argument #2</param>
 /// <returns>An Array of length "numArgsOut" containing the output
 /// arguments.</returns>
 ///
 public MWArray[] pdchsim(int numArgsOut, MWArray traffic, MWArray pdchuse)
   {
     return mcr.EvaluateFunction(numArgsOut, "pdchsim", traffic, pdchuse);
   }
コード例 #58
0
 /// <summary>
 /// Provides the standard 12-input MWArray interface to the SchwartzAndSmith
 /// M-function.
 /// </summary>
 /// <remarks>
 /// M-Documentation:
 /// Script: MAIN - fonction principale du programme
 /// Permet la vue globable sur tout le processing
 /// </remarks>
 /// <param name="numArgsOut">The number of output arguments to return.</param>
 /// <param name="maxiter">Input argument #1</param>
 /// <param name="x0">Input argument #2</param>
 /// <param name="e0">Input argument #3</param>
 /// <param name="maturity">Input argument #4</param>
 /// <param name="y">Input argument #5</param>
 /// <param name="k_in1">Input argument #6</param>
 /// <param name="mu_e_in1">Input argument #7</param>
 /// <param name="sigma_x_in1">Input argument #8</param>
 /// <param name="sigma_e_in1">Input argument #9</param>
 /// <param name="p_xe_in1">Input argument #10</param>
 /// <param name="lambda_e_in1">Input argument #11</param>
 /// <param name="lambda_x_in1">Input argument #12</param>
 /// <returns>An Array of length "numArgsOut" containing the output
 /// arguments.</returns>
 ///
 public MWArray[] SchwartzAndSmith(int numArgsOut, MWArray maxiter, MWArray x0, 
                             MWArray e0, MWArray maturity, MWArray y, MWArray k_in1, 
                             MWArray mu_e_in1, MWArray sigma_x_in1, MWArray 
                             sigma_e_in1, MWArray p_xe_in1, MWArray lambda_e_in1, 
                             MWArray lambda_x_in1)
 {
   return mcr.EvaluateFunction(numArgsOut, "SchwartzAndSmith", maxiter, x0, e0, maturity, y, k_in1, mu_e_in1, sigma_x_in1, sigma_e_in1, p_xe_in1, lambda_e_in1, lambda_x_in1);
 }
コード例 #59
0
 /// <summary>
 /// Provides the standard 1-input MWArray interface to the F_EigenSys M-function.
 /// </summary>
 /// <remarks>
 /// M-Documentation:
 /// Syntax: [eVec,eVal]=F_EigenSys(M);
 /// - Eigen values and vectors of M, sorted by decreasing eigen values.
 /// Author: Lu Juwei - U of Toronto
 /// Created in 27 May 2001
 /// Modified in 6 August 2003
 /// </remarks>
 /// <param name="numArgsOut">The number of output arguments to return.</param>
 /// <param name="M">Input argument #1</param>
 /// <returns>An Array of length "numArgsOut" containing the output
 /// arguments.</returns>
 ///
 public MWArray[] F_EigenSys(int numArgsOut, MWArray M)
 {
     return mcr.EvaluateFunction(numArgsOut, "F_EigenSys", M);
 }
コード例 #60
0
 /// <summary>
 /// Provides an interface for the F_EigenSys function in which the input and output
 /// arguments are specified as an array of MWArrays.
 /// </summary>
 /// <remarks>
 /// This method will allocate and return by reference the output argument
 /// array.<newpara></newpara>
 /// M-Documentation:
 /// Syntax: [eVec,eVal]=F_EigenSys(M);
 /// - Eigen values and vectors of M, sorted by decreasing eigen values.
 /// Author: Lu Juwei - U of Toronto
 /// Created in 27 May 2001
 /// Modified in 6 August 2003
 /// </remarks>
 /// <param name="numArgsOut">The number of output arguments to return</param>
 /// <param name= "argsOut">Array of MWArray output arguments</param>
 /// <param name= "argsIn">Array of MWArray input arguments</param>
 ///
 public void F_EigenSys(int numArgsOut, ref MWArray[] argsOut, MWArray[] argsIn)
 {
     mcr.EvaluateFunction("F_EigenSys", numArgsOut, ref argsOut, argsIn);
 }