base.nbd: Next Best Divisor

Description Usage Arguments Details Value Examples

View source: R/utility.r

Description

Given integers n and d, with n>d, this function finds the "next best divisor" of n which is greater than or equal to d.

Usage

1
base.nbd(n, d)

Arguments

n

The divident (number divided into).

d

The candidate divisor.

Details

Suprisingly useful for thinking about processor grid shapes.

Value

The "next best divisor" interger

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
spmd.code <- "
  suppressMessages(library(pbdMPI))
  suppressMessages(library(pbdBASE))
  init.grid()

  base.nbd(100, 10) # 10 divides 100, so 10 is returned
  base.nbd(100, 11) # 11 does not, so the 'next best' divisor, 20, is returned

  finalize()
"
pbdMPI::execmpi(spmd.code = spmd.code, nranks = 1L)

RBigData/pbdBASE documentation built on Oct. 29, 2021, 6:19 p.m.