| 951 | } |
| 952 | |
| 953 | int get_nearest_power_of_two (int value, int *output) |
| 954 | { |
| 955 | if (value < 0) |
| 956 | { |
| 957 | data_logger->error ("Value must be postive. Value:{}", value); |
| 958 | return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR; |
| 959 | } |
| 960 | if (value == 1) |
| 961 | { |
| 962 | *output = 2; |
| 963 | return (int)BrainFlowExitCodes::STATUS_OK; |
| 964 | } |
| 965 | |
| 966 | int32_t v = (int32_t)value; |
| 967 | v--; |
| 968 | v |= v >> 1; |
| 969 | v |= v >> 2; |
| 970 | v |= v >> 4; |
| 971 | v |= v >> 8; |
| 972 | v |= v >> 16; |
| 973 | v++; // next power of 2 |
| 974 | int x = v >> 1; // previous power of 2 |
| 975 | *output = (v - value) > (value - x) ? x : v; |
| 976 | return (int)BrainFlowExitCodes::STATUS_OK; |
| 977 | } |
| 978 | |
| 979 | int write_file ( |
| 980 | const double *data, int num_rows, int num_cols, const char *file_name, const char *file_mode) |
no outgoing calls
no test coverage detected