---
title: "iemisc: Examples from GNU Octave Rem, Mod, and fractdiff Compatible Functions"
author: "Irucka Embry, E.I.T. (EcoC²S)"
date: "`r Sys.Date()`"
lang: en-us
urlcolor: blue
output:
  rmarkdown::pdf_document:
    highlight: kate
    toc: true
    latex_engine: xelatex
vignette: >
  %\VignetteIndexEntry{iemisc Examples from GNU Octave Rem, Mod, and fractdiff Compatible Functions}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

\bigskip

# Rem Examples (R style)

```{r, warning = FALSE, message = FALSE, tidy = TRUE}

library("iemisc")

# Examples from GNU Octave

x <- 23.4
y <- 20
z <- 0

Rem(x, y)

Rem(y, x)

Rem(x, z)

Rem(y, z)

Rem(z, x)

Rem(z, y)

Rem (-1, 3)


# Examples from FreeMat

Rem(18, 12)

Rem(6, 5)

Rem(2 * pi, pi)

Rem(c(1, 3, 5, 2), 2)

Rem(c(9, 3, 2, 0), c(1, 0, 2, 2))
```

\bigskip
\bigskip

# rem Examples (GNU Octave style)

```{octave eval = FALSE}

% check against GNU Octave

% Examples from GNU Octave

x = 23.4

y = 20

z = 0

rem(x, y)

rem(y, x)

rem(x, z)

rem(y, z)

rem(z, x)

rem(z, y)

rem(-1, 3)


% Examples from FreeMat

rem(18, 12)

rem(6, 5)

rem(2 * pi, pi)

rem([1, 3, 5, 2], 2)

rem([9 3 2 0], [1 0 2 2])



% results

>> x = 23.4
x =  23.400
>>
>> y = 20
y =  20
>>
>> z = 0
z = 0
>>
>> rem(x, y)
ans =  3.4000
>>
>> rem(y, x)
ans =  20
>>
>> rem(x, z)
ans = NaN
>>
>> rem(y, z)
ans = NaN
>>
>> rem(z, x)
ans = 0
>>
>> rem(z, y)
ans = 0
>>
>> rem(-1, 3)
ans = -1
>>
>>
>> % Examples from FreeMat
>>
>> rem(18, 12)
ans =  6
>>
>> rem(6, 5)
ans =  1
>>
>> rem(2 * pi, pi)
ans = 0
>>
>> rem([1, 3, 5, 2], 2)
ans =

   1   1   1   0

>>
>> rem([9 3 2 0], [1 0 2 2])
ans =

     0   NaN     0     0

>>
```

\bigskip
\bigskip

# Mod_octave Examples (R style)

```{r, warning = FALSE, message = FALSE, tidy = TRUE}

library("iemisc")

# Examples from FreeMat

Mod_octave(6, 5)

Mod_octave(2 * pi, pi)

Mod_octave(c(1, 3, 5, 2), 2)

Mod_octave(c(9, 3, 2, 0), c(1, 0, 2, 2))

Mod_octave(-1, 3)
```

\bigskip
\bigskip

# mod Examples (GNU Octave style)

```{octave eval = FALSE}

% check against GNU Octave

% Examples from FreeMat

mod(18, 12)

mod(6, 5)

mod(2*pi, pi)

mod([1, 3, 5, 2], 2)

mod([9 3 2 0], [1 0 2 2])

mod(-1, 3)



% results

>> mod(18, 12)
ans =  6
>>
>> mod(6, 5)
ans =  1
>>
>> mod(2*pi, pi)
ans = 0
>>
>> mod([1, 3, 5, 2], 2)
ans =

   1   1   1   0

>>
>> mod([9 3 2 0], [1 0 2 2])
ans =

   0   3   0   0

>>
>> mod(-1, 3)
ans =  2
>>
```

\bigskip
\bigskip

# fractdiff Example (R style)

```{r, warning = FALSE, message = FALSE, tidy = TRUE}

library("iemisc")
import::from(ramify, mat)

# values from https://github.com/simaki/fracdiff

a <- mat("1, 2, 4, 7, 0")

fractdiff(x = a, d = 0.5)
```

\bigskip
\bigskip

# fractdiff Example (GNU Octave style)

```{octave eval = FALSE}

% check against GNU Octave

a = [1, 2, 4, 7, 0]

fractdiff(a, d = 0.5)



% results

>> a = [1, 2, 4, 7, 0]
a =

   1   2   4   7   0

>>
>> fractdiff(a, d = 0.5)
ans =

   1.0000   1.5000   2.8750   4.6875  -4.1641

>>
```

\bigskip
\bigskip
\bigskip
\bigskip

## Works Cited

John W. Eaton, David Bateman, Søren Hauberg, and Rik Wehbring (October 2021). *GNU Octave: A high-level interactive language for numerical computations: Edition 6 for Octave version 6.4.0*. https://www.gnu.org/software/octave/octave.pdf. Page 547.

\bigskip
\bigskip

# EcoC²S Links

EcoC²S Home -- https://www.ecoccs.com/  
About EcoC²S -- https://www.ecoccs.com/about_ecoc2s.html  
Products -- https://www.questionuniverse.com/products.html  
EcoC²S Media -- https://www.ecoccs.com/media.html  
EcoC²S Resources -- https://www.ecoccs.com/resources.html  
R Trainings and Resources provided by EcoC²S (Irucka Embry, E.I.T.) -- https://www.ecoccs.com/rtraining.html  

\bigskip
\bigskip

# Copyright and License

All R code written by Irucka Embry is distributed under the GPL-3 (or later) license, see the [GNU General Public License {GPL} page](https://www.gnu.org/licenses/gpl-3.0.html).  

All written content originally created by Irucka Embry is copyrighted under the Creative Commons Attribution-ShareAlike 4.0 International License. All other written content retains the copyright of the original author(s).  


```{r, echo = FALSE, out.width = '100%'}
linguisticsdown::include_graphics2("https://i.creativecommons.org/l/by-sa/4.0/88x31.png")
```

This work is licensed under a [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/).  
