<commit_before>#ifndef TENSOR_METHODS_NONCONST_H
#define TENSOR_METHODS_NONCONST_H

FASTOR_INLINE void fill(T num0) {
    FASTOR_INDEX i = 0UL;
    using V = simd_vector_type;
    V _vec(num0);
    for (; i<ROUND_DOWN(size(),V::Size); i+=V::Size) {
        _vec.store(&_data[i],false);
    }
    for (; i<size(); ++i) _data[i] = num0;
}

FASTOR_INLINE void iota(T num0=0) {
    iota_impl(_data, &_data[size()], num0);
}

FASTOR_INLINE void arange(T num0=0) {
    iota_impl(_data, &_data[size()], num0);
    // T num = static_cast<T>(num0);
    // using V = SIMDVector<T,simd_abi_type>;
    // V _vec;
    // FASTOR_INDEX i=0;
    // for (; i<ROUND_DOWN(size(),V::Size); i+=V::Size) {
    //     _vec.set_sequential(T(i)+num);
    //     _vec.store(&_data[i]);
    // }
    // for (; i<size(); ++i) _data[i] = T(i)+num;
}

FASTOR_INLINE void zeros() {
    using V = simd_vector_type;
    V _zeros;
    FASTOR_INDEX i=0;
    for (; i<ROUND_DOWN(size(),V::Size); i+=V::Size) {
        _zeros.store(&_data[i]);
    }
    for (; i<size(); ++i) _data[i] = 0;
}

FASTOR_INLINE void ones() {
    this->fill(static_cast<T>(1));
}

FASTOR_INLINE void eye2() {
    // Second order identity tensor (identity matrices)
    static_assert(sizeof...(Rest)==2, "CANNOT BUILD AN IDENTITY TENSOR");
    static_assert(no_of_unique<Rest...>::value==1, "TENSOR MUST BE UNIFORM");
    constexpr FASTOR_INDEX N = get_value<2,Rest...>::value;
    zeros();
    for (FASTOR_INDEX i=0; i<N; ++i) {
        _data[i*N+i] = (T)1;
    }
}

FASTOR_INLINE void eye() {
    // Arbitrary order identity tensor
    static_assert(sizeof...(Rest)>=2, "CANNOT BUILD AN IDENTITY TENSOR");
    static_assert(no_of_unique<Rest...>::value==1, "TENSOR MUST BE UNIFORM");
    zeros();

    constexpr int ndim = sizeof...(Rest);<commit_msg>Fix store in zeros for unalinged data<commit_after>#ifndef TENSOR_METHODS_NONCONST_H
#define TENSOR_METHODS_NONCONST_H

FASTOR_INLINE void fill(T num0) {
    FASTOR_INDEX i = 0UL;
    using V = simd_vector_type;
    V _vec(num0);
    for (; i<ROUND_DOWN(size(),V::Size); i+=V::Size) {
        _vec.store(&_data[i],false);
    }
    for (; i<size(); ++i) _data[i] = num0;
}

FASTOR_INLINE void iota(T num0=0) {
    iota_impl(_data, &_data[size()], num0);
}

FASTOR_INLINE void arange(T num0=0) {
    iota_impl(_data, &_data[size()], num0);
    // T num = static_cast<T>(num0);
    // using V = SIMDVector<T,simd_abi_type>;
    // V _vec;
    // FASTOR_INDEX i=0;
    // for (; i<ROUND_DOWN(size(),V::Size); i+=V::Size) {
    //     _vec.set_sequential(T(i)+num);
    //     _vec.store(&_data[i],false);
    // }
    // for (; i<size(); ++i) _data[i] = T(i)+num;
}

FASTOR_INLINE void zeros() {
    using V = simd_vector_type;
    V _zeros;
    FASTOR_INDEX i=0;
    for (; i<ROUND_DOWN(size(),V::Size); i+=V::Size) {
        _zeros.store(&_data[i],false);
    }
    for (; i<size(); ++i) _data[i] = 0;
}

FASTOR_INLINE void ones() {
    this->fill(static_cast<T>(1));
}

FASTOR_INLINE void eye2() {
    // Second order identity tensor (identity matrices)
    static_assert(sizeof...(Rest)==2, "CANNOT BUILD AN IDENTITY TENSOR");
    static_assert(no_of_unique<Rest...>::value==1, "TENSOR MUST BE UNIFORM");
    constexpr FASTOR_INDEX N = get_value<2,Rest...>::value;
    zeros();
    for (FASTOR_INDEX i=0; i<N; ++i) {
        _data[i*N+i] = (T)1;
    }
}

FASTOR_INLINE void eye() {
    // Arbitrary order identity tensor
    static_assert(sizeof...(Rest)>=2, "CANNOT BUILD AN IDENTITY TENSOR");
    static_assert(no_of_unique<Rest...>::value==1, "TENSOR MUST BE UNIFORM");
    zeros();

    constexpr int ndim = sizeof...(Rest);
{'fraction_non_alphanumeric': 0.18553285477636663, 'fraction_numerical': 0.012700165654334622, 'mean_word_length': 3.3389221556886226, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '749278', 'n_tokens_mistral': 1522, 'n_tokens_neox': 1474, 'n_words': 283}