vector中v[i]与v.at(i)的区别

void f(vector<int> &v)
{
  v[5];    // A
  v.at[5];  // B
}

如果v非空,A行和B行没有任何区别。如果v为空,B行会抛出std::out_of_range异常,A行的行为未定义。

c++标准不要求vector<T>::operator[]进行下标越界检查,原因是为了效率,总是强制下标越界检查会增加程序的性能开销。设计vector是用来代替内置数组的,所以效率问题也应该考虑。不过使用operator[]就要自己承担越界风险了。

如果需要下标越界检查,请使用at。但是请注意,这时候的性能也是响应的会受影响,因为越界检查增加了性能的开销。


转载自:http://www.cnblogs.com/zhuyf87/archive/2012/12/06/2805579.html

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
MSR Identity Toolbox: A Matlab Toolbox for Speaker Recognition Research Version 1.0 Seyed Omid Sadjadi, Malcolm Slaney, and Larry Heck Microsoft Research, Conversational Systems Research Center (CSRC) [email protected], {mslaney,larry.heck}@microsoft.com This report serves as a user manual for the tools available in the Microsoft Research (MSR) Identity Toolbox. This toolbox contains a collection of Matlab tools and routines that can be used for research and development in speaker recognition. It provides researchers with a test bed for developing new front-end and back-end techniques, allowing replicable evaluation of new advancements. It will also help newcomers in the field by lowering the “barrier to entry”, enabling them to quickly build baseline systems for their experiments. Although the focus of this toolbox is on speaker recognition, it can also be used for other speech related applications such as language, dialect and accent identification. In recent years, the design of robust and effective speaker recognition algorithms has attracted significant research effort from academic and commercial institutions. Speaker recognition has evolved substantially over the past 40 years; from discrete vector quantization (VQ) based systems to adapted Gaussian mixture model (GMM) solutions, and more recently to factor analysis based Eigenvoice (i-vector) frameworks. The Identity Toolbox provides tools that implement both the conventional GMM-UBM and state-of-the-art i-vector based speaker recognition strategies. A speaker recognition system includes two primary components: a front-end and a back-end. The front-end transforms acoustic waveforms into more compact and less redundant representations called acoustic features. Cepstral features are most often used for speaker recognition. It is practical to only retain the high signal-to-noise ratio (SNR) regions of the waveform, therefore there is also a need for a speech activity detector (SAD) in the fr
MATLAB用于支持向量机-svm_v251.rar MATLAB用于支持向量机 Support Vector Machine toolbox for Matlab Version 2.51, January 2002 Contents.m contains a brief description of all parts of this toolbox. Main features are: - Except for the QP solver, all parts are written in plain Matlab. This   guarantees for easy modification. Special kinds of kernels that require   much computation (such as the Fisher kernel, which is based on a model of   the data) can easily be incorporated. - Extension to multi-class problems via error correcting output codes is   included. - Unless many other SVM toolboxes, this one can handle SVMs with 1norm   or 2norm of the slack variables. - For both cases, a decomposition algorithm is implemented for the training   routine, together with efficient working set selection strategies.   The training algorithm uses many of the ideas proposed by Thorsten   Joachims for his SVMlight. It thus should exhibit a scaling behaviour that   is comparable to SVMlight. This toolbox optionally makes use of a Matlab wrapper for an interior point code in LOQO style . To compile the wrapper, run   mex loqo.c pr_loqo.c Make sure you have turned on the compiler optimizations in mexopts.sh The LOQO code can be retrieved from   http://www.kernel-machines.org/code/prloqo.tar.gz The wrapper comes directly from Steve Gunn. Copyright Anton Schwaighofer mailto:[email protected] This program is released unter the GNU General Public License. See License.txt for details. Changes in version 2.51: - fixed bug in SVMTRAIN that prevented correct initialisation with   NET.recompute==Inf Changes in version 2.5: - Handling of multi-class problems with ECOC - NET.recompute is set to Inf by default, thus all training is done   incrementally by default. - Handling the case of all training examples being -1 or 1 correctly Changes in version 2.4: - Better selection of the initial working set - Added workaround for a Matlab quadprog bug with badly conditioned   matrices - There is now a new kernel function 'rbffull' where a full matrix    C may be put into an RBF kernel:   K = exp'*C*) Changes in version 2.3: - slightly more compact debug output Changes in version 2.2: - New default values for parameter qpsize that make the whole toolbox   *much* faster - Workaround for a Matlab bug with sparse matrices - Changed the definition of the RBF-Kernel: from |x-y|^2/   to |x-y|^2/. This means that all parameter settings for old   versions need to be updated! - A few minor things I can't remember Changes in version 2.1: Fixed a nasty bug at the KKT check Changes in version 2.0: All relevant routines have been updated to allow the use of a SVM with 2norm of the slack variables .

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值