草庐IT

matrix_size

全部标签

c++ - size_type 和 int 之间的区别

#include#includeusingnamespacestd;intmain(){vectorstudent_marks(20);for(vector::size_typei=0;i>student_marks[i];}return0;}我在某处读到,最好使用size_type代替int。它真的会对实现产生巨大影响吗?使用size_type有什么好处? 最佳答案 vector::size_type保证涵盖vector大小的所有可能值范围.一个int不是。请注意vector::size_type通常与std::size_t相同,

c++ - 变长数组 : How to create a buffer with variable size in C++

我目前正在编写一个移动平均线类。目标是在创建Running_Average类的新对象时能够将缓冲区大小指定为构造函数的一部分。#include#include"Complex.h"#include#include#include#includeusingnamespacestd;classRunning_Average{public:doublesum=0;doubleaverage=0;inti;doubleAverage(void);//MemberfunctionsdeclarationvoidAddSample(double);Running_Average(int);};Ru

c++ - 根据 size() 排序 vector

我有一个像vector>v(points);这样的二维vector其中坐标类是:classcoordinate{public:intx;inty;coordinate(){x=0;y=0;}};积分是20。如何基于v[i].size()对单个vectorv[i]进行排序,即基于插入v[i]的坐标对象的数量。??? 最佳答案 1)创建一个根据大小比较两个vector的函数:boolless_vectors(constvector&a,constvector&b){returna.size()2)用它排序sort(v.begin(),v

c++ - 从 std::array 等获取 size_type 的惯用方法

由thisquestion触发,我想出了以下代码(在我的回答中是boost::array,但同样适用于std::array):template::size_typesize>voidDataTransform(std::arraydata){}我对::size_type一点都不满意.我必须以一定的大小进行实例化,才能知道size_type.对于std::array我本可以使用size_t,那么一般情况呢?如果size_type怎么办不是size_t?或者更一般的(即不适用于std::array)如果size_type怎么办?不同的尺寸是不同的(愚蠢但可能)?我知道这个问题相当学术,有很

c++ - 如何将 Eigen::Matrix4f 转换为 Eigen::Affine3f

关闭。这个问题需要debuggingdetails.它目前不接受答案。编辑问题以包含desiredbehavior,aspecificproblemorerror,andtheshortestcodenecessarytoreproducetheproblem.这将有助于其他人回答问题。关闭7年前。Improvethisquestion我想将矩阵从Eigen::Matrix4f转换为Eigen::Affine3f有人帮忙吗?谢谢

c++ - 在哪里可以找到 C++ STL 中 vector 的 size_type 定义?

将vector的size()函数的结果转换为unsignedint似乎是安全的。不过,我怎么能确定呢?我的文档不清楚size_type是如何定义的。 最佳答案 不要假定容器大小的类型(或在其中键入的任何其他内容)。今天?目前最好的解决方案是使用:std::vector::size_type其中T是您的类型。例如:std::vector::size_typei;std::vector::size_typej;std::vector>::size_typek;(使用typedef可以帮助使其更好地阅读)对于迭代器和“内部”STL容器中的

c++ - 在没有参数列表的情况下无效使用模板名称 ‘Matrix’

这是我的Matrix.cpp文件。(有一个单独的Matrix.h文件)#include#include#include"Matrix.h"usingnamespacestd;Matrix::Matrix(intr,intc,Tfill=1){if(r>maxLength||c>maxLength){cerr这给出了以下内容error:invaliduseoftemplate-name‘Matrix’withoutanargumentlist我的代码有什么问题?编辑:矩阵类定义为template编辑:这是我的Matrix.h文件:#include#include#definemaxLen

c++ - 错误 : initializer fails to determine size of ‘K’

我在行中收到错误“初始化器无法确定‘K’的大小”intK[]=newint[Vertices->total];如何解决? 最佳答案 改变intK[]=newint[Vertices->total];到int*K=newint[Vertices->total];第一个是Java创建数组的方法,其中K是对整数数组的引用。但是在C++中,我们需要让K成为一个指向整数类型的指针。 关于c++-错误:initializerfailstodeterminesizeof‘K’,我们在StackOver

【深度学习每日小知识】Co-occurrence matrix 共现矩阵

共生矩阵或共生分布(也称为:灰度共生矩阵GLCM)是在图像上定义为共生像素值(灰度值或颜色)分布的矩阵)在给定的偏移量处。它被用作纹理分析的方法,具有多种应用,特别是在医学图像分析中。方法给定灰度图像,共生矩阵计算具有特定值和偏移量的像素对在图像中出现的频率。偏移量(Δx,Δy)(\Deltax,\Deltay)(Δx,Δy)是一个位置运算符,可以应用于图像中的任何像素(忽略边缘效应):例如,(1,2)(1,2)(1,2)可以表示“一向下,二向右”。对于给定的偏移量,具有p个不同像素值的图像将产生一个p×pp\timespp×p共生矩阵。共现矩阵的值(i,j)th(i,j)^{th}(i,j)

c++ - 使用 std::array::size 实例化 std::array 时出错

示例代码test.cpp#include#includeintmain(){//OKconststd::arrayarray_int={42,1337};std::arrayarray_float_ok;//Errorconststd::arrayarray_string={"foo","bar"};std::arrayarray_float_error;return0;}使用g++4.8.4(Ubuntu14.04)编译g++-Wall-std=c++0xtest.cpp-otest给出如下错误信息test.cpp:Infunction‘intmain()’:test.cpp:14: