void calculate_sa(const unsigned char* c, typename int_vector<fixedIntWidth>::size_type len, int_vector<fixedIntWidth>& sa) { typedef typename int_vector<fixedIntWidth>::size_type size_type; if (len <= 1) { // handle special case sa = int_vector<fixedIntWidth>(len,0); return; } bool small_file = (sizeof(len) <= 4 or len < 0x7FFFFFFFULL); if (small_file) { uint8_t oldIntWidth = sa.width(); if (32 == fixedIntWidth or (0==fixedIntWidth and 32 >= oldIntWidth)) { sa.width(32); sa.resize(len); divsufsort(c, (int32_t*)sa.m_data, len); // copy integers back to the right positions if (oldIntWidth!=32) { for (size_type i=0; i<len; ++i) { sa.set_int(i*oldIntWidth, sa.get_int(i<<5, 32), oldIntWidth); } sa.width(oldIntWidth); sa.resize(len); } } else { if (sa.width() < bits::hi(len)+1) { throw std::logic_error("width of int_vector is to small for the text!!!"); } int_vector<> sufarray(len,0,32); divsufsort(c, (int32_t*)sufarray.m_data, len); for (size_type i=0; i<len; ++i) { sa[i] = sufarray[i]; } } } else { uint8_t oldIntWidth = sa.width(); sa.width(64); sa.resize(len); divsufsort64(c, (int64_t*)sa.m_data, len); // copy integers back to the right positions if (oldIntWidth!=64) { for (size_type i=0; i<len; ++i) { sa.set_int(i*oldIntWidth, sa.get_int(i<<6, 64), oldIntWidth); } sa.width(oldIntWidth); sa.resize(len); } } }