Skip to content

error when run the test example #29

@XMUSpeechLab

Description

@XMUSpeechLab

Hello, I run the following example code, but got error for the umappp::initialize function.

#include "umappp/umappp.hpp"
#include "umappp/knncolle/knncolle.hpp"
#include
#include
#include

int main() {
// 1. 准备高维数据(示例数据)
const int ndim = 5; // 高维数据维度
const int nobs = 1000; // 样本数量
std::vector data(ndim * nobs);

// 生成随机高维数据(实际应用中替换为你的数据)
std::mt19937_64 rng(42);
std::normal_distribution<double> dist(0, 1.0);
for (int i = 0; i < ndim * nobs; ++i) {
    data[i] = dist(rng);
}

// 2. 配置UMAP参数
umappp::Options opt;
opt.num_neighbors = 15;      // 近邻数量
opt.num_epochs = 500;        // 迭代次数
opt.min_dist = 0.1;          // 最小距离
opt.learning_rate = 1.0;     // 学习率
opt.num_threads = 4;         // 线程数

// 3. 配置近邻搜索算法(使用VP树+欧氏距离)
knncolle::VptreeBuilder<int, double, double> vp_builder(
    std::make_shared<knncolle::EuclideanDistance<double, double>>()
);

// 4. 初始化嵌入结果存储
const int out_dim = 2;       // 降维到2维(可视化常用)
std::vector<double> embedding(nobs * out_dim);

// 5. 初始化UMAP状态
auto status = umappp::initialize(
    ndim,
    nobs,
    data.data(),
    vp_builder,
    out_dim,
    embedding.data(),
    opt
);

// 6. 运行UMAP降维算法
status.run(embedding.data());

// 7. 输出结果(前5个样本的2维坐标)
std::cout << "UMAP降维结果(前5个样本):" << std::endl;
for (int i = 0; i < 5; ++i) {
    std::cout << "样本 " << i << ": ("
        << embedding[i * out_dim] << ", "
        << embedding[i * out_dim + 1] << ")" << std::endl;
}

return 0;

}

further debug to the error point, it locate at the following part of GenealBlcokPanelKernel.h in Eigen:
// copy the remaining columns one at a time (nr==1)
for (Index j2 = packet_cols4; j2 < cols; ++j2) {
if (PanelMode) count += offset;
const LinearMapper dm0 = rhs.getLinearMapper(0, j2);
for (Index k = 0; k < depth; k++) {
blockB[count] = cj(dm0(k));
count += 1;
}
if (PanelMode) count += (stride - offset - depth);
}

Can anyone give some tips or help? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions