当前位置: 首页>>代码示例>>C++>>正文


C++ BaseMatrix::Ncols方法代码示例

本文整理汇总了C++中BaseMatrix::Ncols方法的典型用法代码示例。如果您正苦于以下问题:C++ BaseMatrix::Ncols方法的具体用法?C++ BaseMatrix::Ncols怎么用?C++ BaseMatrix::Ncols使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BaseMatrix的用法示例。


在下文中一共展示了BaseMatrix::Ncols方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: assert

    void IdentityMatrix<TYPE>::Solve(const BaseMatrix<TYPE>& in, BaseMatrix<TYPE>& out) const
    {
        int n = GeneralMatrix<TYPE>::nrows;
        assert(n == in.Nrows());
        assert(in.Ncols() == out.Ncols() && in.Nrows() == out.Nrows());

        std::shared_ptr<LinearEquationSolver<TYPE> > solver = this->MakeSolver();
        solver->Solve(in, out);
    }
开发者ID:oxmcvusd,项目名称:NewQuant,代码行数:9,代码来源:IdentityMatrix.cpp

示例2: NPDException

 void CholeskySolver<TYPE>::Solve(const BaseMatrix<TYPE> &in, BaseMatrix<TYPE> &out) const
 {
     assert(in.Nrows() == lm.Ncols());
     assert(in.Nrows() == out.Nrows() && in.Ncols() == out.Ncols());
     if (LinearEquationSolver<TYPE>::fail)
     {
         Singleton<Tracer>::Instance()->AddMessage("CholeskySolver::Solve(in, out)");
         throw NPDException(SimpleSolver<TYPE>::mat);
     }
     Matrix<TYPE> temp(out.Nrows(), out.Ncols());
     lm.Solve(in, temp);
     t(lm).Solve(temp, out);
 }
开发者ID:oxmcvusd,项目名称:NewQuant,代码行数:13,代码来源:CholeskySolver.cpp

示例3: LogicError

 void LUsolverNoPivot<TYPE>::Solve(const BaseMatrix<TYPE> &in, BaseMatrix<TYPE> &out) const
 {
     assert(in.Nrows() == combine.Ncols());
     assert(in.Nrows() == out.Nrows() && in.Ncols() == out.Ncols());
     if (LinearEquationSolver<TYPE>::IsFailed())
     {
         Singleton<Tracer>::Instance()->AddMessage("LUsolverNoPivot::Solve");
         throw LogicError("LUsolverNoPivot: LU decomposition is failed");
     }
     Matrix<TYPE> t(in.Nrows(), in.Ncols());
     LUsolver<TYPE>::lm.Solve(in, t);
     LUsolver<TYPE>::um.Solve(t, out);
 }
开发者ID:oxmcvusd,项目名称:NewQuant,代码行数:13,代码来源:LUsolverNoPivot.cpp

示例4: SingularException

 void BandLUsolverPartialPivot<TYPE>::Solve(const BaseMatrix<TYPE> &in, BaseMatrix<TYPE> &out) const
 {
     assert(in.Nrows() == combine.Ncols());
     assert(in.Nrows() == out.Nrows() && in.Ncols() == out.Ncols());
     if (LinearEquationSolver<TYPE>::IsFailed())
     {
         Singleton<Tracer>::Instance()->AddMessage("BandLUsolverPartialPivot::Solve");
         throw SingularException(BandLUsolver<TYPE>::mat);
     }
     const PermuteMatrix<TYPE> &lp = BandLUsolver<TYPE>::left;
     Matrix<TYPE> t(in.Nrows(), in.Ncols());
     lm.Solve(c_perm(lp, in), t);
     um.Solve(t, out);
 }
开发者ID:oxmcvusd,项目名称:NewQuant,代码行数:14,代码来源:BandLUsolverPartialPivot.cpp

示例5: assert

 void SymmetricBandMatrix<TYPE>::operator<<(const BaseMatrix<TYPE>& bm)
 {
     if (&bm == this)
     {
         return;
     }
     assert(bm.Nrows() == GeneralMatrix<TYPE>::nrows && bm.Ncols() == GeneralMatrix<TYPE>::ncols);
     int n = GeneralMatrix<TYPE>::nrows, lb = this->BandWidth().Lower();
     if (bm.Search(*this) == 0)
     {
         for (int i = 0; i <= lb; ++i)
         {
             for (int j = 1; j <= n - i; ++j)
             {
                 operator()(j + i, j) = bm(j + i, j);
             }
         }
     }
     else
     {
         SymmetricBandMatrix<TYPE> t(n, lb);
         t << bm;
         this->Swap(t);
     }
 }
开发者ID:oxmcvusd,项目名称:NewQuant,代码行数:25,代码来源:SymmetricBandMatrix.cpp

示例6: SingularException

    void ConstantSolver<TYPE>::Solve(const BaseMatrix<TYPE> &in, BaseMatrix<TYPE> &out) const
    {
        if (LinearEquationSolver<TYPE>::IsFailed())
        {
            Singleton<Tracer>::Instance()->AddMessage("ConstantSolver::Solve");
            throw SingularException(SimpleSolver<TYPE>::mat);
        }

        int r = SimpleSolver<TYPE>::mat.Nrows();
        int c = SimpleSolver<TYPE>::mat.Ncols();

        assert(r == 1 && c == 1 && c == in.Nrows());
        assert(in.Ncols() == out.Ncols() && in.Nrows() == out.Nrows());

        const BaseMatrix<TYPE> &m = SimpleSolver<TYPE>::mat;
        for (int i = 1; i <= c; ++i)
        {
            for (int j = r; j >= 1; --j)
            {
                out(j, i) = in(j, i) / m(j, j);
            }
        }
    }
开发者ID:oxmcvusd,项目名称:NewQuant,代码行数:23,代码来源:ConstantSolver.cpp

示例7: SingularException

    void IdentitySolver<TYPE>::Solve(const BaseMatrix<TYPE> &in, BaseMatrix<TYPE> &out) const
    {
        if (LinearEquationSolver<TYPE>::IsFailed())
        {
            Singleton<Tracer>::Instance()->AddMessage("IdentitySolver::Solve");
            throw SingularException(SimpleSolver<TYPE>::mat);
        }

        int n = SimpleSolver<TYPE>::mat.Nrows();

        assert(n == in.Nrows());
        assert(in.Ncols() == out.Ncols() && in.Nrows() == out.Nrows());

        TYPE t = SimpleSolver<TYPE>::mat(1, 1);
        int c = in.Ncols();
        for (int i = 1; i <= c; ++i)
        {
            for (int j = n; j >= 1; --j)
            {
                out(j, i) = in(j, i) / t;
            }
        }

    }
开发者ID:oxmcvusd,项目名称:NewQuant,代码行数:24,代码来源:IdentitySolver.cpp

示例8: assert

    void CholeskySolver<TYPE>::CholeskyDecomposition(const BaseMatrix<TYPE> &bm)
    {
        assert(bm.Nrows() == bm.Ncols());

        int n = lm.Nrows();
        const TYPE &e = SimpleSolver<TYPE>::epsilon;
        TYPE temp;
        for (int i = 1; i <= n; ++i)
        {
            if (i == 1)
            {
                temp = bm(i, i);
            }
            else
            {
                temp = bm(i, i) - (c_sub(lm, i, i, 1, i - 1) * t(c_sub(lm, i, i, 1, i - 1)))(1, 1);
            }
            if (temp <= e)
            {
                LinearEquationSolver<TYPE>::fail = true;
                return;
            }
            else
            {
                lm(i, i) = std::sqrt(temp);
                for (int j = i + 1; j <= n; ++j)
                {
                    if (i == 1)
                    {
                        lm(j, i) = bm(j, i) / lm(i, i);
                    }
                    else
                    {
                        lm(j, i) = (bm(j, i) - (c_sub(lm, i, i, 1, i - 1) * t(c_sub(lm, j, j, 1, i - 1)))(1, 1)) / lm(i, i);
                    }
                }
            }
        }
    }
开发者ID:oxmcvusd,项目名称:NewQuant,代码行数:39,代码来源:CholeskySolver.cpp


注:本文中的BaseMatrix::Ncols方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。