Esempio n. 1
0
        public static void Compute(Matrix x, Vector y, int wind,
                                   out double[] minSQ,
                                   out double[] TQ,
                                   out int[] Indices,
                                   VectorType vtype = VectorType.Column)
        {
            if (x == null || y == null)
            {
                throw new ArgumentException("");
            }
            int row      = x.RowCount;
            int col      = x.ColumnCount;
            int scount   = vtype == VectorType.Row ? row : col;
            int valCount = vtype == VectorType.Row ? col : row;

            if (valCount != y.Count)
            {
                throw new ArgumentException("x,y的长度不一致");
            }
            var SQm = new DenseMatrix(row, col);
            var TQm = new DenseVector(scount);

            for (int k = 0; k < scount; k++)
            {
                Vector tSQ;
                double tTQ;
                Vector x1;
                x1 = (Vector)(vtype == VectorType.Row ? x.Row(k) : x.Column(k));
                Compute(x1, y, wind, out tSQ, out tTQ);
                if (vtype == VectorType.Row)
                {
                    SQm.SetRow(k, tSQ);
                }
                else
                {
                    SQm.SetColumn(k, tSQ);
                }
                TQm[k] = tTQ;
            }


            TQ = Matlab.SortDesc(TQm, out Indices).ToArray();

            double[] mSQ;
            int[]    mSQidx;
            Matlab.Min(SQm, out mSQ, out mSQidx, vtype);

            minSQ = new double[scount];


            for (int i = 0; i < scount; i++)
            {
                minSQ[i] = mSQ[Indices[i]];
            }
        }