Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next release #74

Merged
merged 9 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use std::int and std::uint
  • Loading branch information
takenori-y committed Dec 17, 2024
commit 4e9cff73e48d6e1e9183f0dc349cf4a829ad4d87
10 changes: 5 additions & 5 deletions include/SPTK/utils/int24_t.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#ifndef SPTK_UTILS_INT24_T_H_
#define SPTK_UTILS_INT24_T_H_

#include <cstdint> // uint8_t
#include <cstdint> // std::uint8_t

namespace sptk {

Expand Down Expand Up @@ -57,9 +57,9 @@ class int24_t {
}

int24_t& operator=(int input) {
value[0] = (reinterpret_cast<uint8_t*>(&input))[0];
value[1] = (reinterpret_cast<uint8_t*>(&input))[1];
value[2] = (reinterpret_cast<uint8_t*>(&input))[2];
value[0] = (reinterpret_cast<std::uint8_t*>(&input))[0];
value[1] = (reinterpret_cast<std::uint8_t*>(&input))[1];
value[2] = (reinterpret_cast<std::uint8_t*>(&input))[2];
return *this;
}

Expand Down Expand Up @@ -176,7 +176,7 @@ class int24_t {
}

protected:
uint8_t value[3];
std::uint8_t value[3];
};

} // namespace sptk
Expand Down
10 changes: 5 additions & 5 deletions include/SPTK/utils/uint24_t.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#ifndef SPTK_UTILS_UINT24_T_H_
#define SPTK_UTILS_UINT24_T_H_

#include <cstdint> // uint8_t
#include <cstdint> // std::uint8_t

namespace sptk {

Expand Down Expand Up @@ -52,9 +52,9 @@ class uint24_t {
}

uint24_t& operator=(int input) {
value[0] = (reinterpret_cast<uint8_t*>(&input))[0];
value[1] = (reinterpret_cast<uint8_t*>(&input))[1];
value[2] = (reinterpret_cast<uint8_t*>(&input))[2];
value[0] = (reinterpret_cast<std::uint8_t*>(&input))[0];
value[1] = (reinterpret_cast<std::uint8_t*>(&input))[1];
value[2] = (reinterpret_cast<std::uint8_t*>(&input))[2];
return *this;
}

Expand Down Expand Up @@ -171,7 +171,7 @@ class uint24_t {
}

protected:
uint8_t value[3];
std::uint8_t value[3];
};

} // namespace sptk
Expand Down
3 changes: 2 additions & 1 deletion src/analysis/pitch_extraction_by_reaper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@

#include "SPTK/analysis/pitch_extraction_by_reaper.h"

#include <stdint.h> // int16_t, int32_t

#include <algorithm> // std::copy, std::fill, std::transform
#include <cmath> // std::ceil
#include <cstdint> // int16_t
#include <vector> // std::vector

#include "REAPER/epoch_tracker/epoch_tracker.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@

namespace {

uint64_t CalculateBinomialCoefficient(int n, int k) {
std::uint64_t CalculateBinomialCoefficient(int n, int k) {
if (0 == k || n == k) {
return 1;
}

std::vector<uint64_t> buffer(n);
std::vector<std::uint64_t> buffer(n);
for (int i(0); i < n; ++i) {
buffer[i] = 1;
for (int j(i - 1); 0 < j; --j) {
Expand Down Expand Up @@ -114,7 +114,8 @@ bool AutocorrelationToCompositeSinusoidalModeling::Run(
for (int l(0); l < length; ++l) {
long double sum(0.0);
for (int k(0); k <= l; ++k) {
const uint64_t binomial_coefficient(CalculateBinomialCoefficient(l, k));
const std::uint64_t binomial_coefficient(
CalculateBinomialCoefficient(l, k));
const int index((l < 2 * k) ? (2 * k - l) : (l - 2 * k));
sum += (binomial_coefficient)*input[index];
}
Expand Down
3 changes: 2 additions & 1 deletion src/generation/normal_distributed_random_value_generation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

#include "SPTK/generation/normal_distributed_random_value_generation.h"

#include <cmath> // std::log, std::sqrt
#include <cmath> // std::log, std::sqrt
#include <cstdint> // std::uint64_t

namespace {

Expand Down
18 changes: 9 additions & 9 deletions src/main/bcp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// ------------------------------------------------------------------------ //

#include <algorithm> // std::max
#include <cstdint> // int8_t, int16_t, int32_t, int64_t, etc.
#include <cstdint> // std::int8_t, std::int16_t, std::int32_t, etc.
#include <cstring> // std::strncmp
#include <fstream> // std::ifstream
#include <iomanip> // std::setprecision, std::setw
Expand Down Expand Up @@ -189,43 +189,43 @@ class BlockCopyWrapper {
double pad_value)
: block_copy_(NULL) {
if ("c" == data_type) {
block_copy_ = new BlockCopy<int8_t>(
block_copy_ = new BlockCopy<std::int8_t>(
input_start_number, input_end_number, input_block_length,
output_start_number, output_block_length, pad_value);
} else if ("s" == data_type) {
block_copy_ = new BlockCopy<int16_t>(
block_copy_ = new BlockCopy<std::int16_t>(
input_start_number, input_end_number, input_block_length,
output_start_number, output_block_length, pad_value);
} else if ("h" == data_type) {
block_copy_ = new BlockCopy<sptk::int24_t>(
input_start_number, input_end_number, input_block_length,
output_start_number, output_block_length, sptk::int24_t(pad_value));
} else if ("i" == data_type) {
block_copy_ = new BlockCopy<int32_t>(
block_copy_ = new BlockCopy<std::int32_t>(
input_start_number, input_end_number, input_block_length,
output_start_number, output_block_length, pad_value);
} else if ("l" == data_type) {
block_copy_ = new BlockCopy<int64_t>(
block_copy_ = new BlockCopy<std::int64_t>(
input_start_number, input_end_number, input_block_length,
output_start_number, output_block_length, pad_value);
} else if ("C" == data_type) {
block_copy_ = new BlockCopy<uint8_t>(
block_copy_ = new BlockCopy<std::uint8_t>(
input_start_number, input_end_number, input_block_length,
output_start_number, output_block_length, pad_value);
} else if ("S" == data_type) {
block_copy_ = new BlockCopy<uint16_t>(
block_copy_ = new BlockCopy<std::uint16_t>(
input_start_number, input_end_number, input_block_length,
output_start_number, output_block_length, pad_value);
} else if ("H" == data_type) {
block_copy_ = new BlockCopy<sptk::uint24_t>(
input_start_number, input_end_number, input_block_length,
output_start_number, output_block_length, sptk::uint24_t(pad_value));
} else if ("I" == data_type) {
block_copy_ = new BlockCopy<uint32_t>(
block_copy_ = new BlockCopy<std::uint32_t>(
input_start_number, input_end_number, input_block_length,
output_start_number, output_block_length, pad_value);
} else if ("L" == data_type) {
block_copy_ = new BlockCopy<uint64_t>(
block_copy_ = new BlockCopy<std::uint64_t>(
input_start_number, input_end_number, input_block_length,
output_start_number, output_block_length, pad_value);
} else if ("f" == data_type) {
Expand Down
18 changes: 9 additions & 9 deletions src/main/bcut.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License. //
// ------------------------------------------------------------------------ //

#include <cstdint> // int8_t, int16_t, int32_t, int64_t, etc.
#include <cstdint> // std::int8_t, std::int16_t, std::int32_t, etc.
#include <cstring> // std::strncmp
#include <fstream> // std::ifstream
#include <iomanip> // std::setw
Expand Down Expand Up @@ -127,34 +127,34 @@ class BinaryCutWrapper {
: binary_cut_(NULL) {
if ("c" == data_type) {
binary_cut_ =
new BinaryCut<int8_t>(start_number, end_number, block_length);
new BinaryCut<std::int8_t>(start_number, end_number, block_length);
} else if ("s" == data_type) {
binary_cut_ =
new BinaryCut<int16_t>(start_number, end_number, block_length);
new BinaryCut<std::int16_t>(start_number, end_number, block_length);
} else if ("h" == data_type) {
binary_cut_ =
new BinaryCut<sptk::int24_t>(start_number, end_number, block_length);
} else if ("i" == data_type) {
binary_cut_ =
new BinaryCut<int32_t>(start_number, end_number, block_length);
new BinaryCut<std::int32_t>(start_number, end_number, block_length);
} else if ("l" == data_type) {
binary_cut_ =
new BinaryCut<int64_t>(start_number, end_number, block_length);
new BinaryCut<std::int64_t>(start_number, end_number, block_length);
} else if ("C" == data_type) {
binary_cut_ =
new BinaryCut<uint8_t>(start_number, end_number, block_length);
new BinaryCut<std::uint8_t>(start_number, end_number, block_length);
} else if ("S" == data_type) {
binary_cut_ =
new BinaryCut<uint16_t>(start_number, end_number, block_length);
new BinaryCut<std::uint16_t>(start_number, end_number, block_length);
} else if ("H" == data_type) {
binary_cut_ =
new BinaryCut<sptk::uint24_t>(start_number, end_number, block_length);
} else if ("I" == data_type) {
binary_cut_ =
new BinaryCut<uint32_t>(start_number, end_number, block_length);
new BinaryCut<std::uint32_t>(start_number, end_number, block_length);
} else if ("L" == data_type) {
binary_cut_ =
new BinaryCut<uint64_t>(start_number, end_number, block_length);
new BinaryCut<std::uint64_t>(start_number, end_number, block_length);
} else if ("f" == data_type) {
binary_cut_ =
new BinaryCut<float>(start_number, end_number, block_length);
Expand Down
31 changes: 16 additions & 15 deletions src/main/dmp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// limitations under the License. //
// ------------------------------------------------------------------------ //

#include <cstdint> // std::int8_t, std::int16_t, std::int32_t, etc.
#include <cstring> // std::strncmp
#include <fstream> // std::ifstream
#include <iomanip> // std::setw
Expand Down Expand Up @@ -122,43 +123,43 @@ class DataDumpWrapper {
if ("c" == data_type) {
if (print_format.empty()) print_format = "%d";
data_dump_ =
new DataDump<int8_t>(print_format, minimum_index, maximum_index);
new DataDump<std::int8_t>(print_format, minimum_index, maximum_index);
} else if ("s" == data_type) {
if (print_format.empty()) print_format = "%d";
data_dump_ =
new DataDump<int16_t>(print_format, minimum_index, maximum_index);
data_dump_ = new DataDump<std::int16_t>(print_format, minimum_index,
maximum_index);
} else if ("h" == data_type) {
if (print_format.empty()) print_format = "%d";
data_dump_ = new DataDump<sptk::int24_t>(print_format, minimum_index,
maximum_index);
} else if ("i" == data_type) {
if (print_format.empty()) print_format = "%d";
data_dump_ =
new DataDump<int32_t>(print_format, minimum_index, maximum_index);
data_dump_ = new DataDump<std::int32_t>(print_format, minimum_index,
maximum_index);
} else if ("l" == data_type) {
if (print_format.empty()) print_format = "%lld";
data_dump_ =
new DataDump<int64_t>(print_format, minimum_index, maximum_index);
data_dump_ = new DataDump<std::int64_t>(print_format, minimum_index,
maximum_index);
} else if ("C" == data_type) {
if (print_format.empty()) print_format = "%u";
data_dump_ =
new DataDump<uint8_t>(print_format, minimum_index, maximum_index);
data_dump_ = new DataDump<std::uint8_t>(print_format, minimum_index,
maximum_index);
} else if ("S" == data_type) {
if (print_format.empty()) print_format = "%u";
data_dump_ =
new DataDump<uint16_t>(print_format, minimum_index, maximum_index);
data_dump_ = new DataDump<std::uint16_t>(print_format, minimum_index,
maximum_index);
} else if ("H" == data_type) {
if (print_format.empty()) print_format = "%u";
data_dump_ = new DataDump<sptk::uint24_t>(print_format, minimum_index,
maximum_index);
} else if ("I" == data_type) {
if (print_format.empty()) print_format = "%u";
data_dump_ =
new DataDump<uint32_t>(print_format, minimum_index, maximum_index);
data_dump_ = new DataDump<std::uint32_t>(print_format, minimum_index,
maximum_index);
} else if ("L" == data_type) {
if (print_format.empty()) print_format = "%llu";
data_dump_ =
new DataDump<uint64_t>(print_format, minimum_index, maximum_index);
data_dump_ = new DataDump<std::uint64_t>(print_format, minimum_index,
maximum_index);
} else if ("f" == data_type) {
if (print_format.empty()) print_format = "%g";
data_dump_ =
Expand Down
2 changes: 1 addition & 1 deletion src/main/fd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ int main(int argc, char* argv[]) {
}
std::istream& input_stream(ifs.is_open() ? ifs : std::cin);

uint8_t data;
std::uint8_t data;
std::ostringstream stored_characters;

for (int index(start_index); sptk::ReadStream(&data, &input_stream);
Expand Down
50 changes: 25 additions & 25 deletions src/main/merge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// ------------------------------------------------------------------------ //

#include <algorithm> // std::copy
#include <cstdint> // int8_t, int16_t, int32_t, int64_t, etc.
#include <cstdint> // std::int8_t, std::int16_t, std::int32_t, etc.
#include <cstring> // std::strncmp
#include <fstream> // std::ifstream
#include <iomanip> // std::setw
Expand Down Expand Up @@ -184,45 +184,45 @@ class VectorMergeWrapper {
bool overwrite_mode, std::istream* insert_stream)
: merge_(NULL) {
if ("c" == data_type) {
merge_ =
new VectorMerge<int8_t>(insert_point, input_length, insert_length,
recursive, overwrite_mode, insert_stream);
merge_ = new VectorMerge<std::int8_t>(insert_point, input_length,
insert_length, recursive,
overwrite_mode, insert_stream);
} else if ("s" == data_type) {
merge_ =
new VectorMerge<int16_t>(insert_point, input_length, insert_length,
recursive, overwrite_mode, insert_stream);
merge_ = new VectorMerge<std::int16_t>(insert_point, input_length,
insert_length, recursive,
overwrite_mode, insert_stream);
} else if ("h" == data_type) {
merge_ = new VectorMerge<sptk::int24_t>(insert_point, input_length,
insert_length, recursive,
overwrite_mode, insert_stream);
} else if ("i" == data_type) {
merge_ =
new VectorMerge<int32_t>(insert_point, input_length, insert_length,
recursive, overwrite_mode, insert_stream);
merge_ = new VectorMerge<std::int32_t>(insert_point, input_length,
insert_length, recursive,
overwrite_mode, insert_stream);
} else if ("l" == data_type) {
merge_ =
new VectorMerge<int64_t>(insert_point, input_length, insert_length,
recursive, overwrite_mode, insert_stream);
merge_ = new VectorMerge<std::int64_t>(insert_point, input_length,
insert_length, recursive,
overwrite_mode, insert_stream);
} else if ("C" == data_type) {
merge_ =
new VectorMerge<uint8_t>(insert_point, input_length, insert_length,
recursive, overwrite_mode, insert_stream);
merge_ = new VectorMerge<std::uint8_t>(insert_point, input_length,
insert_length, recursive,
overwrite_mode, insert_stream);
} else if ("S" == data_type) {
merge_ =
new VectorMerge<uint16_t>(insert_point, input_length, insert_length,
recursive, overwrite_mode, insert_stream);
merge_ = new VectorMerge<std::uint16_t>(insert_point, input_length,
insert_length, recursive,
overwrite_mode, insert_stream);
} else if ("H" == data_type) {
merge_ = new VectorMerge<sptk::uint24_t>(insert_point, input_length,
insert_length, recursive,
overwrite_mode, insert_stream);
} else if ("I" == data_type) {
merge_ =
new VectorMerge<uint32_t>(insert_point, input_length, insert_length,
recursive, overwrite_mode, insert_stream);
merge_ = new VectorMerge<std::uint32_t>(insert_point, input_length,
insert_length, recursive,
overwrite_mode, insert_stream);
} else if ("L" == data_type) {
merge_ =
new VectorMerge<uint64_t>(insert_point, input_length, insert_length,
recursive, overwrite_mode, insert_stream);
merge_ = new VectorMerge<std::uint64_t>(insert_point, input_length,
insert_length, recursive,
overwrite_mode, insert_stream);
} else if ("f" == data_type) {
merge_ = new VectorMerge<float>(insert_point, input_length, insert_length,
recursive, overwrite_mode, insert_stream);
Expand Down
Loading