Ejemplo n.º 1
0
        /// <summary>
        /// see <see cref="MatrixBase.CreateVec"/>
        /// </summary>
        protected override VectorBase CreateVec <T>(T a, IPartitioning len, out bool CopyIsShallow)
        {
            if (a.Count != len.LocalLength)
            {
                throw new ArgumentException("count of a must be at least 'len'!", "len");
            }
            if (len.MPI_Comm != this.ColPartition.MPI_Comm)
            {
                throw new ArgumentException();
            }


            IPartitioning part_a = len;

            double[] _a_stor = a as double[]; // try to do a shallow copy and save mem. and time
            if (_a_stor == null)
            {
                // shallow copy didn't worked
                _a_stor       = ArrayTools.List2Array <double>(a, 0, len.LocalLength);
                CopyIsShallow = false;
            }
            else
            {
                CopyIsShallow = true;
            }
            return(new MtVector(part_a, _a_stor));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// see <see cref="MatrixBase.CreateVec{T}(T,IPartitioning,out bool)"/>
        /// </summary>
        protected override VectorBase CreateVec <T>(T a, IPartitioning len, out bool CopyIsShallow)
        {
            if (a.Count != len.LocalLength)
            {
                throw new ArgumentException("count of a must be at least 'len'!", "len");
            }
            if (len.MPI_Comm != this.ColPartition.MPI_Comm)
            {
                throw new ArgumentException();
            }


            IPartitioning part_a = len;

            double[] _a_stor = ArrayTools.List2Array <double>(a, 0, len.LocalLength);
            CopyIsShallow = false;
            return(new clVector(part_a, _a_stor, device));
        }