コード例 #1
0
        public VectorSparse <T> GetSubVectorExcept(int idxremove)
        {
            VectorSparse <T> subvec = new VectorSparse <T>(Size - 1, this.GetDefault);

            foreach (var i_val in EnumElements())
            {
                int i = i_val.Item1; if (i == idxremove)
                {
                    continue;
                }
                T   val = i_val.Item2;
                int si  = (i < idxremove) ? i : (i - 1);
                subvec[si] = val;
            }
            return(subvec);
        }
コード例 #2
0
        public VectorSparse <T> GetRowVector(int col)
        {
            HDebug.AssertAnd(0 <= col, col < RowSize);
            VectorSparse <T> vec = new VectorSparse <T>(RowSize, GetDefault: GetDefault);

            if (diagonal[col] != null)
            {
                vec[col] = diagonal[col];
            }
            foreach (var r_val in offdiagonal[col])
            {
                int r   = r_val.Key;
                T   val = r_val.Value;
                vec[r] = val;
            }
            return(vec);
        }
コード例 #3
0
        public VectorSparse <T> GetSubVector(IList <int> idxs)
        {
            VectorSparse <T> subvec = new VectorSparse <T>(idxs.Count, this.GetDefault);

            Dictionary <int, int> idx_subidx = idxs.HToDictionaryAsValueIndex();

            foreach (var i_val in EnumElements())
            {
                int i = i_val.Item1; if (idx_subidx.ContainsKey(i) == false)
                {
                    continue;
                }
                T   val = i_val.Item2;
                int si  = idx_subidx[i];
                subvec[si] = val;
            }
            return(subvec);
        }