Eigen学习之aligned_allocator

本文详细介绍了Eigen库中STL兼容的aligned_allocator模板类,用于处理需要非标准对齐的数据类型,如MatrixXd。提供了不同对齐需求的例子,并解释了如何控制对齐字节数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

https://eigen.tuxfamily.org/dox/classEigen_1_1aligned__allocator.html

Eigen::aligned_allocator< T > Class Template Reference

Detailed Description

template<class T>
class Eigen::aligned_allocator< T >

STL compatible allocator to use with types requiring a non standrad alignment.

The memory is aligned as for dynamically aligned matrix/array types such as MatrixXd. By default, it will thus provide at least 16 bytes alignment and more in following cases:

  • 32 bytes alignment if AVX is enabled.
  • 64 bytes alignment if AVX512 is enabled.

This can be controled using the EIGEN_MAX_ALIGN_BYTES macro as documented there .

Example:

// Matrix4f requires 16 bytes alignment:

std::map< int, Matrix4f, std::less<int>,

aligned_allocator<std::pair<const int, Matrix4f> > > my_map_mat4;

// Vector3f does not require 16 bytes alignment, no need to use Eigen's allocator:

std::map< int, Vector3f > my_map_vec3;

See also

Using STL Containers with Eigen.

Inherits allocator< T >.

The documentation for this class was generated from the following file:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值