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


C++ Indices::Size方法代码示例

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


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

示例1: GenerateTwoPartition

            /**
                Generates the
             */
            std::vector<std::pair<Indices, Indices>> GenerateTwoPartition(const Indices& indices) const {
                assert(indices.Size() > 1);

                std::vector<std::pair<Indices, Indices>> result;

                // Take the first letter
                auto first = indices[0];

                for (int i=1; i<indices.Size(); i++) {
                    auto current = indices[i];

                    Indices remaining = indices;

                    Indices gamma;
                    gamma.Insert(first);
                    gamma.Insert(current);

                    remaining.Remove(i);
                    remaining.Remove(0);

                    result.push_back({ gamma, remaining });
                }

                return result;
            }
开发者ID:constructivegravity,项目名称:construct,代码行数:28,代码来源:base_tensor.hpp

示例2: Generate

            Tensor::Tensor Generate(const Indices& indices) const {
                // Expect all the ranges to be in space
                unsigned order = indices.Size();
                for (auto& index : indices) {
                    if (index.GetRange() != Common::Range(1,3)) {
                        // throw error
                    }
                }

                // We cannot build anything with one index!
                if (indices.Size() == 1) return Tensor::Tensor::Zero();

                Tensor::Tensor result = Tensor::Tensor::Zero();
                unsigned variableCounter = 0;

                // Calculate
                unsigned numEpsilon = (indices.Size() % 2 == 0) ? 0 : 1;
                unsigned numGammas  = (indices.Size() % 2 == 0) ? indices.Size()/2  : (indices.Size()-3)/2;

                std::vector<Indices> possibleIndices;

                if (numEpsilon == 1) {
                    possibleIndices = GenerateOddRank(indices);
                } else {
                    possibleIndices = GenerateEvenRank(indices);
                }

                std::vector<Tensor::Tensor> tensors;

                for (auto& newIndices : possibleIndices) {
                    // Create variable
                    Tensor::Scalar variable ("e", ++variableCounter);

                    tensors.push_back(variable * Tensor::Tensor::EpsilonGamma(numEpsilon, numGammas, newIndices));
                }

                return Tensor::Tensor::Add(tensors);
            }
开发者ID:constructivegravity,项目名称:construct,代码行数:38,代码来源:base_tensor.hpp

示例3: GenerateEvenRank

            std::vector<Indices> GenerateEvenRank(const Indices& indices) const {
                auto res = GenerateTwoPartition(indices);
                std::vector<Indices> result;

                if (indices.Size() == 2) {

                    for (auto& pair : res) {
                        result.push_back(pair.first);
                    }
                } else {
                    for (auto& pair : res) {
                        auto newComb = GenerateEvenRank(pair.second);
                        for (auto &v : newComb) {
                            auto current = pair.first;
                            current.Append(v);
                            result.push_back(current);
                        }
                    }
                }

                return result;
            }
开发者ID:constructivegravity,项目名称:construct,代码行数:22,代码来源:base_tensor.hpp


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