Example #1
0
        /// <summary>
        /// see <see cref="IMonkeyImplicitPrecond.DoPrecond"/>
        /// </summary>
        override public void DoPrecond()
        {
            m_PcOutput.CopyFrom(m_PcInput);

            // iterate
            // =======
            for (int i = 1; i < m_NoOfIter; i++)
            {
                // Jacobi iteration
                // ================
                //((CPU.RefMatrix)m_Matrix).useSingle = true;
                m_Matrix.SpMV_Expert(-1.0, _xComm, 0.0, tmp); // tmp = -M*x
                //((CPU.RefMatrix)m_Matrix).useSingle = true;
                tmp.Acc(1.0, m_PcInput);                      // tmp = -M*x + m_PcInput
                if (m_UnderRelaxationFactor != 1.0)
                {
                    tmp.Scale(m_UnderRelaxationFactor);
                }


                if (m_UnderRelaxationFactor != 1.0)
                {
                    tmp.Scale(m_UnderRelaxationFactor);
                }
                tmp.MultiplyElementWise(m_InvDiag);

                m_PcOutput.Acc(1.0, tmp);               //m_PcOutput = m_PcOutput + tmp
            }
        }
Example #2
0
        /// <summary>
        /// this function implements the preconditioning according to the neumann preconditioner
        /// </summary>
        public override void DoPrecond()
        {
            mPcOutput.CopyFrom(mPcInput);

            for (int i = 1; i < m_NoOfIter; i++)
            {
                //_yNew = _yOld - m_matrix*_yOld;
                m_matrix.SpMV_Expert(-1.0, _yComm, 0.0, yNew);  //yNew = -m_matrix * yComm = -m_Matrix*yOld
                yNew.Acc(1.0, yOld);                            //yNew = yOld - m_Matrix*yOld;

                mPcOutput.Acc(1.0, yNew);                       //mPcOutput = mPcOutput + yNew
                yOld.Swap(yNew);
            }
        }