pub fn gen_partition_size(
    num_notes: f32,
    length: i32,
    max_file_count: f32,
    partition_depth: i32,
) -> u32 {
    if partition_depth > (num_notes as i32) {
        panic!("Partition depth must be greater than number of notes in MIDI sequence");
    }
    let num_sequences = num_notes.powi(length);
    if num_notes == 1.0 || ((num_sequences as f32) <= max_file_count) {
        if partition_depth > 1 {
            panic!("Total number of sequences is {} and max_files is {}, partition depth must be 1", num_sequences, max_file_count);
        }
        return length as u32;
    }
    let max_directories = num_sequences / max_file_count;
    let base = num_notes.powi(partition_depth);
    max_directories.log(base).ceil() as u32
}
/// Calculate number of MIDI notes per partition.
///
/// # Arguments
///
/// * `num_notes`: number of possible notes (duplicates allowed)
/// * `length`: length of generated MIDI sequences (see: [gen_sequences](fn.gen_sequences.html))
/// * `max_file_count`: maximum number of files per partition (recommended <= 4K)
/// * `partition_depth`: number of partitions
///
/// # Preconditions
///
/// * `num_notes` > 0
/// * `length` > 0
/// * `max_files_count` > 0
/// * `partition_depth` > 0
/// * `partition_depth` <= `num_notes`
/// * if `num_notes`<sup>`length`</sup> <= `max_file_count`, `partition_depth` == 1
///
/// # Examples
///
/// ```rust
/// let partition_size = atm::utils::gen_partition_size(8.0, 12, 4096.0, 2);
///
/// // With these parameters, the calculation would be:
/// // https://www.wolframalpha.com/input/?i=ceil%28log64%28max%288%5E12%2F4096%2C+1%29%29%29
/// assert_eq!(4, partition_size)
/// ```
///
/// # Notes:
///
/// Most modern filesystems do not perform well with more than 4K files per folder,
/// and XFS is no exception.  In order to prevent overloading a single folder, we decided
/// to partition sequences by their hash, which is just the integer representation of
/// the MIDI notes in the sequence (see: [libatm::MIDIFile::gen_hash](../../libatm/struct.MIDIFile.html#method.gen_hash)),
/// such that no folder would contain more than `max_file_count` number of files. The formula works as follows:
///
/// let N = num_notes<sup>length</sup> <b>(number of files to be generated)</b> </br>
/// let D = max(N / max_file_count, 1) <b>(maximum number of directories to generate)</b> </br>
/// let B = num_notes<sup>partition_depth</sup> <b>(logarithm base)</b> </br>
/// partition_size = <b>ceil(log<sub>B</sub>(D))</b>
///
/// NOTE: If `num_notes` is 1 or num_notes<sup>length</sup> is less than or equal to
/// `max_file_count` then the function will simply return `length` (see Preconditions above).
Calculate number of MIDI notes per partition.
Calculate number of MIDI notes per partition .
pub fn gen_partition_size(
    num_notes: f32,
    length: i32,
    max_file_count: f32,
    partition_depth: i32,
) -> u32 {
    if partition_depth > (num_notes as i32) {
        panic!("Partition depth must be greater than number of notes in MIDI sequence");
    }
    let num_sequences = num_notes.powi(length);
    if num_notes == 1.0 || ((num_sequences as f32) <= max_file_count) {
        if partition_depth > 1 {
            panic!("Total number of sequences is {} and max_files is {}, partition depth must be 1", num_sequences, max_file_count);
        }
        return length as u32;
    }
    let max_directories = num_sequences / max_file_count;
    let base = num_notes.powi(partition_depth);
    max_directories.log(base).ceil() as u32
}
pub fn gen_partition_size ( num_notes : f32 , length : i32 , max_file_count : f32 , partition_depth : i32 , ) -> u32 { if partition_depth > ( num_notes as i32 ) { panic ! ( " " ) ; } let num_sequences = num_notes . powi ( length ) ; if num_notes == 1.0 || ( ( num_sequences as f32 ) <= max_file_count ) { if partition_depth > 1 { panic ! ( " " num_sequences max_file_count ) ; } return length as u32 ; } let max_directories = num_sequences / max_file_count ; let base = num_notes . powi ( partition_depth ) ; max_directories . log ( base ) . ceil ( ) as u32 }
Calculate number of MIDI notes per partition.
Calculate number of MIDI notes per partition .
num_notes
f32
length
i32
max_file_count
f32
partition_depth
i32
num_notes
f32
length
i32
max_file_count
f32
partition_depth
i32
preconditions
None
examples
None
notes:
Most modern filesystems do not perform well with more than 4K files per folder,
and XFS is no exception.  In order to prevent overloading a single folder, we decided
to partition sequences by their hash, which is just the integer representation of
the MIDI notes in the sequence ),
such that no folder would contain more than `max_file_count` number of files. The formula works as follows.

let N = num_noteslength (number of files to be generated) 
let D = max(N / max_file_count, 1) (maximum number of directories to generate) 
let B = num_notespartition_depth (logarithm base) 
partition_size = ceil(logB(D))

If `num_notes` is 1 or num_noteslength is less than or equal to
`max_file_count` then the function will simply return `length` .
Most modern filesystems do not perform well with more than 4K files per folder and XFS is no exception . In order to prevent overloading a single folder we decided to partition sequences by their hash which is just the integer representation of the MIDI notes in the sequence ) such that no folder would contain more than ` max_file_count ` number of files . The formula works as follows . let N = num_noteslength ( number of files to be generated ) let D = max ( N / max_file_count 1 ) ( maximum number of directories to generate ) let B = num_notespartition_depth ( logarithm base ) partition_size = ceil ( logB ( D )) If ` num_notes ` is 1 or num_noteslength is less than or equal to ` max_file_count ` then the function will simply return ` length ` .