0s autopkgtest [18:10:10]: starting date and time: 2025-03-15 18:10:10+0000 0s autopkgtest [18:10:10]: git checkout: 325255d2 Merge branch 'pin-any-arch' into 'ubuntu/production' 0s autopkgtest [18:10:10]: host juju-7f2275-prod-proposed-migration-environment-20; command line: /home/ubuntu/autopkgtest/runner/autopkgtest --output-dir /tmp/autopkgtest-work.veu_3saw/out --timeout-copy=6000 --setup-commands /home/ubuntu/autopkgtest-cloud/worker-config-production/setup-canonical.sh --apt-pocket=proposed=src:glibc --apt-upgrade r-cran-matrixstats --timeout-short=300 --timeout-copy=20000 --timeout-build=20000 --env=ADT_TEST_TRIGGERS=glibc/2.41-1ubuntu2 -- ssh -s /home/ubuntu/autopkgtest/ssh-setup/nova -- --flavor autopkgtest-s390x --security-groups autopkgtest-juju-7f2275-prod-proposed-migration-environment-20@bos03-s390x-18.secgroup --name adt-plucky-s390x-r-cran-matrixstats-20250315-181010-juju-7f2275-prod-proposed-migration-environment-20-808cdcfa-602f-41f9-98fd-be11820184a5 --image adt/ubuntu-plucky-s390x-server --keyname testbed-juju-7f2275-prod-proposed-migration-environment-20 --net-id=net_prod-proposed-migration-s390x -e TERM=linux -e ''"'"'http_proxy=http://squid.internal:3128'"'"'' -e ''"'"'https_proxy=http://squid.internal:3128'"'"'' -e ''"'"'no_proxy=127.0.0.1,127.0.1.1,login.ubuntu.com,localhost,localdomain,novalocal,internal,archive.ubuntu.com,ports.ubuntu.com,security.ubuntu.com,ddebs.ubuntu.com,changelogs.ubuntu.com,keyserver.ubuntu.com,launchpadlibrarian.net,launchpadcontent.net,launchpad.net,10.24.0.0/24,keystone.ps5.canonical.com,objectstorage.prodstack5.canonical.com,radosgw.ps5.canonical.com'"'"'' --mirror=http://ftpmaster.internal/ubuntu/ 90s autopkgtest [18:11:40]: testbed dpkg architecture: s390x 90s autopkgtest [18:11:40]: testbed apt version: 2.9.33 90s autopkgtest [18:11:40]: @@@@@@@@@@@@@@@@@@@@ test bed setup 90s autopkgtest [18:11:40]: testbed release detected to be: None 91s autopkgtest [18:11:41]: updating testbed package index (apt update) 91s Get:1 http://ftpmaster.internal/ubuntu plucky-proposed InRelease [126 kB] 92s Hit:2 http://ftpmaster.internal/ubuntu plucky InRelease 92s Hit:3 http://ftpmaster.internal/ubuntu plucky-updates InRelease 92s Hit:4 http://ftpmaster.internal/ubuntu plucky-security InRelease 92s Get:5 http://ftpmaster.internal/ubuntu plucky-proposed/main Sources [99.7 kB] 92s Get:6 http://ftpmaster.internal/ubuntu plucky-proposed/multiverse Sources [15.8 kB] 92s Get:7 http://ftpmaster.internal/ubuntu plucky-proposed/universe Sources [379 kB] 93s Get:8 http://ftpmaster.internal/ubuntu plucky-proposed/main s390x Packages [113 kB] 93s Get:9 http://ftpmaster.internal/ubuntu plucky-proposed/main s390x c-n-f Metadata [1824 B] 93s Get:10 http://ftpmaster.internal/ubuntu plucky-proposed/restricted s390x c-n-f Metadata [116 B] 93s Get:11 http://ftpmaster.internal/ubuntu plucky-proposed/universe s390x Packages [320 kB] 93s Get:12 http://ftpmaster.internal/ubuntu plucky-proposed/universe s390x c-n-f Metadata [13.4 kB] 93s Get:13 http://ftpmaster.internal/ubuntu plucky-proposed/multiverse s390x Packages [3776 B] 93s Get:14 http://ftpmaster.internal/ubuntu plucky-proposed/multiverse s390x c-n-f Metadata [240 B] 93s Fetched 1073 kB in 2s (708 kB/s) 94s Reading package lists... 94s Reading package lists... 94s Building dependency tree... 94s Reading state information... 95s Calculating upgrade... 95s Calculating upgrade... 95s The following packages were automatically installed and are no longer required: 95s libnsl2 libpython3.12-minimal libpython3.12-stdlib libpython3.12t64 95s linux-headers-6.11.0-8 linux-headers-6.11.0-8-generic 95s linux-modules-6.11.0-8-generic linux-tools-6.11.0-8 95s linux-tools-6.11.0-8-generic 95s Use 'sudo apt autoremove' to remove them. 95s The following packages will be upgraded: 95s pinentry-curses python3-jinja2 strace 95s 3 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 95s Need to get 652 kB of archives. 95s After this operation, 27.6 kB of additional disk space will be used. 95s Get:1 http://ftpmaster.internal/ubuntu plucky/main s390x strace s390x 6.13+ds-1ubuntu1 [500 kB] 95s Get:2 http://ftpmaster.internal/ubuntu plucky/main s390x pinentry-curses s390x 1.3.1-2ubuntu3 [42.9 kB] 95s Get:3 http://ftpmaster.internal/ubuntu plucky/main s390x python3-jinja2 all 3.1.5-2ubuntu1 [109 kB] 96s Fetched 652 kB in 1s (844 kB/s) 96s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 81428 files and directories currently installed.) 96s Preparing to unpack .../strace_6.13+ds-1ubuntu1_s390x.deb ... 96s Unpacking strace (6.13+ds-1ubuntu1) over (6.11-0ubuntu1) ... 96s Preparing to unpack .../pinentry-curses_1.3.1-2ubuntu3_s390x.deb ... 96s Unpacking pinentry-curses (1.3.1-2ubuntu3) over (1.3.1-2ubuntu2) ... 96s Preparing to unpack .../python3-jinja2_3.1.5-2ubuntu1_all.deb ... 96s Unpacking python3-jinja2 (3.1.5-2ubuntu1) over (3.1.5-2) ... 96s Setting up pinentry-curses (1.3.1-2ubuntu3) ... 96s Setting up python3-jinja2 (3.1.5-2ubuntu1) ... 96s Setting up strace (6.13+ds-1ubuntu1) ... 96s Processing triggers for man-db (2.13.0-1) ... 97s Reading package lists... 97s Building dependency tree... 97s Reading state information... 97s Solving dependencies... 97s The following packages will be REMOVED: 97s libnsl2* libpython3.12-minimal* libpython3.12-stdlib* libpython3.12t64* 97s linux-headers-6.11.0-8* linux-headers-6.11.0-8-generic* 97s linux-modules-6.11.0-8-generic* linux-tools-6.11.0-8* 97s linux-tools-6.11.0-8-generic* 97s 0 upgraded, 0 newly installed, 9 to remove and 5 not upgraded. 97s After this operation, 167 MB disk space will be freed. 97s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 81428 files and directories currently installed.) 97s Removing linux-tools-6.11.0-8-generic (6.11.0-8.8) ... 97s Removing linux-tools-6.11.0-8 (6.11.0-8.8) ... 97s Removing libpython3.12t64:s390x (3.12.9-1) ... 97s Removing libpython3.12-stdlib:s390x (3.12.9-1) ... 97s Removing libnsl2:s390x (1.3.0-3build3) ... 97s Removing libpython3.12-minimal:s390x (3.12.9-1) ... 97s Removing linux-headers-6.11.0-8-generic (6.11.0-8.8) ... 97s Removing linux-headers-6.11.0-8 (6.11.0-8.8) ... 98s Removing linux-modules-6.11.0-8-generic (6.11.0-8.8) ... 98s Processing triggers for libc-bin (2.41-1ubuntu1) ... 98s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 56328 files and directories currently installed.) 98s Purging configuration files for libpython3.12-minimal:s390x (3.12.9-1) ... 98s Purging configuration files for linux-modules-6.11.0-8-generic (6.11.0-8.8) ... 99s autopkgtest [18:11:49]: upgrading testbed (apt dist-upgrade and autopurge) 99s Reading package lists... 99s Building dependency tree... 99s Reading state information... 99s Calculating upgrade...Starting pkgProblemResolver with broken count: 0 99s Starting 2 pkgProblemResolver with broken count: 0 99s Done 99s Entering ResolveByKeep 99s 100s Calculating upgrade... 100s The following packages will be upgraded: 100s libc-bin libc-dev-bin libc6 libc6-dev locales 100s 5 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 100s Need to get 9512 kB of archives. 100s After this operation, 8192 B of additional disk space will be used. 100s Get:1 http://ftpmaster.internal/ubuntu plucky-proposed/main s390x libc6-dev s390x 2.41-1ubuntu2 [1678 kB] 101s Get:2 http://ftpmaster.internal/ubuntu plucky-proposed/main s390x libc-dev-bin s390x 2.41-1ubuntu2 [24.3 kB] 101s Get:3 http://ftpmaster.internal/ubuntu plucky-proposed/main s390x libc6 s390x 2.41-1ubuntu2 [2892 kB] 101s Get:4 http://ftpmaster.internal/ubuntu plucky-proposed/main s390x libc-bin s390x 2.41-1ubuntu2 [671 kB] 101s Get:5 http://ftpmaster.internal/ubuntu plucky-proposed/main s390x locales all 2.41-1ubuntu2 [4246 kB] 102s Preconfiguring packages ... 102s Fetched 9512 kB in 2s (4569 kB/s) 102s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 56326 files and directories currently installed.) 102s Preparing to unpack .../libc6-dev_2.41-1ubuntu2_s390x.deb ... 102s Unpacking libc6-dev:s390x (2.41-1ubuntu2) over (2.41-1ubuntu1) ... 102s Preparing to unpack .../libc-dev-bin_2.41-1ubuntu2_s390x.deb ... 102s Unpacking libc-dev-bin (2.41-1ubuntu2) over (2.41-1ubuntu1) ... 102s Preparing to unpack .../libc6_2.41-1ubuntu2_s390x.deb ... 102s Unpacking libc6:s390x (2.41-1ubuntu2) over (2.41-1ubuntu1) ... 102s Setting up libc6:s390x (2.41-1ubuntu2) ... 102s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 56326 files and directories currently installed.) 102s Preparing to unpack .../libc-bin_2.41-1ubuntu2_s390x.deb ... 102s Unpacking libc-bin (2.41-1ubuntu2) over (2.41-1ubuntu1) ... 102s Setting up libc-bin (2.41-1ubuntu2) ... 103s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 56326 files and directories currently installed.) 103s Preparing to unpack .../locales_2.41-1ubuntu2_all.deb ... 103s Unpacking locales (2.41-1ubuntu2) over (2.41-1ubuntu1) ... 103s Setting up locales (2.41-1ubuntu2) ... 103s Generating locales (this might take a while)... 104s en_US.UTF-8... done 104s Generation complete. 104s Setting up libc-dev-bin (2.41-1ubuntu2) ... 104s Setting up libc6-dev:s390x (2.41-1ubuntu2) ... 104s Processing triggers for man-db (2.13.0-1) ... 105s Processing triggers for systemd (257.3-1ubuntu3) ... 106s Reading package lists... 106s Building dependency tree... 106s Reading state information... 106s Starting pkgProblemResolver with broken count: 0 106s Starting 2 pkgProblemResolver with broken count: 0 106s Done 106s Solving dependencies... 106s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 106s autopkgtest [18:11:56]: rebooting testbed after setup commands that affected boot 124s autopkgtest [18:12:14]: testbed running kernel: Linux 6.14.0-10-generic #10-Ubuntu SMP Wed Mar 12 14:53:49 UTC 2025 127s autopkgtest [18:12:17]: @@@@@@@@@@@@@@@@@@@@ apt-source r-cran-matrixstats 128s Get:1 http://ftpmaster.internal/ubuntu plucky/universe r-cran-matrixstats 1.5.0-1 (dsc) [2228 B] 128s Get:2 http://ftpmaster.internal/ubuntu plucky/universe r-cran-matrixstats 1.5.0-1 (tar) [212 kB] 128s Get:3 http://ftpmaster.internal/ubuntu plucky/universe r-cran-matrixstats 1.5.0-1 (diff) [4864 B] 129s gpgv: Signature made Sat Jan 18 11:46:01 2025 UTC 129s gpgv: using RSA key 724D609337113C710550D7473C26763F6C67E6E2 129s gpgv: Can't check signature: No public key 129s dpkg-source: warning: cannot verify inline signature for ./r-cran-matrixstats_1.5.0-1.dsc: no acceptable signature found 129s autopkgtest [18:12:19]: testing package r-cran-matrixstats version 1.5.0-1 129s autopkgtest [18:12:19]: build not needed 131s autopkgtest [18:12:21]: test run-unit-test: preparing testbed 131s Reading package lists... 131s Building dependency tree... 131s Reading state information... 132s Starting pkgProblemResolver with broken count: 0 132s Starting 2 pkgProblemResolver with broken count: 0 132s Done 132s The following NEW packages will be installed: 132s fontconfig fontconfig-config fonts-dejavu-core fonts-dejavu-mono 132s fonts-glyphicons-halflings fonts-mathjax libblas3 libcairo2 libdatrie1 132s libdeflate0 libfontconfig1 libfreetype6 libgfortran5 libgomp1 libgraphite2-3 132s libharfbuzz0b libice6 libjbig0 libjpeg-turbo8 libjpeg8 libjs-bootstrap 132s libjs-highlight.js libjs-jquery libjs-jquery-datatables libjs-mathjax 132s liblapack3 libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 132s libpaper-utils libpaper2 libpixman-1-0 libsharpyuv0 libsm6 libtcl8.6 132s libthai-data libthai0 libtiff6 libtk8.6 libwebp7 libxcb-render0 libxcb-shm0 132s libxft2 libxrender1 libxss1 libxt6t64 node-normalize.css r-base-core 132s r-cran-base64enc r-cran-cli r-cran-colorspace r-cran-commonmark 132s r-cran-digest r-cran-evaluate r-cran-fansi r-cran-farver r-cran-ggplot2 132s r-cran-glue r-cran-gtable r-cran-highr r-cran-isoband r-cran-knitr 132s r-cran-labeling r-cran-lattice r-cran-lifecycle r-cran-magrittr 132s r-cran-markdown r-cran-mass r-cran-matrix r-cran-matrixstats r-cran-mgcv 132s r-cran-microbenchmark r-cran-munsell r-cran-nlme r-cran-pillar 132s r-cran-pkgconfig r-cran-r.cache r-cran-r.devices r-cran-r.methodss3 132s r-cran-r.oo r-cran-r.rsp r-cran-r.utils r-cran-r6 r-cran-rcolorbrewer 132s r-cran-rlang r-cran-scales r-cran-tibble r-cran-utf8 r-cran-vctrs 132s r-cran-viridislite r-cran-withr r-cran-xfun r-cran-yaml tcl tcl8.6 unzip 132s x11-common xdg-utils zip 132s 0 upgraded, 99 newly installed, 0 to remove and 0 not upgraded. 132s Need to get 86.4 MB of archives. 132s After this operation, 193 MB of additional disk space will be used. 132s Get:1 http://ftpmaster.internal/ubuntu plucky/main s390x libfreetype6 s390x 2.13.3+dfsg-1 [431 kB] 132s Get:2 http://ftpmaster.internal/ubuntu plucky/main s390x fonts-dejavu-mono all 2.37-8 [502 kB] 133s Get:3 http://ftpmaster.internal/ubuntu plucky/main s390x fonts-dejavu-core all 2.37-8 [835 kB] 133s Get:4 http://ftpmaster.internal/ubuntu plucky/main s390x fontconfig-config s390x 2.15.0-2ubuntu1 [37.5 kB] 133s Get:5 http://ftpmaster.internal/ubuntu plucky/main s390x libfontconfig1 s390x 2.15.0-2ubuntu1 [150 kB] 133s Get:6 http://ftpmaster.internal/ubuntu plucky/main s390x fontconfig s390x 2.15.0-2ubuntu1 [191 kB] 133s Get:7 http://ftpmaster.internal/ubuntu plucky/universe s390x fonts-glyphicons-halflings all 1.009~3.4.1+dfsg-3 [118 kB] 133s Get:8 http://ftpmaster.internal/ubuntu plucky/main s390x fonts-mathjax all 2.7.9+dfsg-1 [2208 kB] 133s Get:9 http://ftpmaster.internal/ubuntu plucky/main s390x libblas3 s390x 3.12.1-2 [252 kB] 133s Get:10 http://ftpmaster.internal/ubuntu plucky/main s390x libpixman-1-0 s390x 0.44.0-3 [201 kB] 133s Get:11 http://ftpmaster.internal/ubuntu plucky/main s390x libxcb-render0 s390x 1.17.0-2 [17.0 kB] 133s Get:12 http://ftpmaster.internal/ubuntu plucky/main s390x libxcb-shm0 s390x 1.17.0-2 [5862 B] 133s Get:13 http://ftpmaster.internal/ubuntu plucky/main s390x libxrender1 s390x 1:0.9.10-1.1build1 [20.4 kB] 133s Get:14 http://ftpmaster.internal/ubuntu plucky/main s390x libcairo2 s390x 1.18.2-2 [580 kB] 133s Get:15 http://ftpmaster.internal/ubuntu plucky/main s390x libdatrie1 s390x 0.2.13-3build1 [20.6 kB] 133s Get:16 http://ftpmaster.internal/ubuntu plucky/main s390x libdeflate0 s390x 1.23-1 [46.1 kB] 133s Get:17 http://ftpmaster.internal/ubuntu plucky/main s390x libgfortran5 s390x 15-20250222-0ubuntu1 [620 kB] 133s Get:18 http://ftpmaster.internal/ubuntu plucky/main s390x libgomp1 s390x 15-20250222-0ubuntu1 [152 kB] 133s Get:19 http://ftpmaster.internal/ubuntu plucky/main s390x libgraphite2-3 s390x 1.3.14-2ubuntu1 [79.8 kB] 133s Get:20 http://ftpmaster.internal/ubuntu plucky/main s390x libharfbuzz0b s390x 10.2.0-1 [538 kB] 133s Get:21 http://ftpmaster.internal/ubuntu plucky/main s390x x11-common all 1:7.7+23ubuntu3 [21.7 kB] 133s Get:22 http://ftpmaster.internal/ubuntu plucky/main s390x libice6 s390x 2:1.1.1-1 [45.4 kB] 133s Get:23 http://ftpmaster.internal/ubuntu plucky/main s390x libjpeg-turbo8 s390x 2.1.5-3ubuntu2 [147 kB] 133s Get:24 http://ftpmaster.internal/ubuntu plucky/main s390x libjpeg8 s390x 8c-2ubuntu11 [2146 B] 133s Get:25 http://ftpmaster.internal/ubuntu plucky/universe s390x libjs-bootstrap all 3.4.1+dfsg-3 [129 kB] 133s Get:26 http://ftpmaster.internal/ubuntu plucky/universe s390x libjs-highlight.js all 9.18.5+dfsg1-2 [385 kB] 133s Get:27 http://ftpmaster.internal/ubuntu plucky/main s390x libjs-jquery all 3.6.1+dfsg+~3.5.14-1 [328 kB] 133s Get:28 http://ftpmaster.internal/ubuntu plucky/universe s390x libjs-jquery-datatables all 1.11.5+dfsg-2 [146 kB] 133s Get:29 http://ftpmaster.internal/ubuntu plucky/main s390x liblapack3 s390x 3.12.1-2 [2971 kB] 133s Get:30 http://ftpmaster.internal/ubuntu plucky/main s390x libthai-data all 0.1.29-2build1 [158 kB] 133s Get:31 http://ftpmaster.internal/ubuntu plucky/main s390x libthai0 s390x 0.1.29-2build1 [20.7 kB] 133s Get:32 http://ftpmaster.internal/ubuntu plucky/main s390x libpango-1.0-0 s390x 1.56.2-1 [253 kB] 133s Get:33 http://ftpmaster.internal/ubuntu plucky/main s390x libpangoft2-1.0-0 s390x 1.56.2-1 [50.2 kB] 133s Get:34 http://ftpmaster.internal/ubuntu plucky/main s390x libpangocairo-1.0-0 s390x 1.56.2-1 [28.2 kB] 133s Get:35 http://ftpmaster.internal/ubuntu plucky/main s390x libpaper2 s390x 2.2.5-0.3 [17.2 kB] 133s Get:36 http://ftpmaster.internal/ubuntu plucky/main s390x libpaper-utils s390x 2.2.5-0.3 [15.3 kB] 133s Get:37 http://ftpmaster.internal/ubuntu plucky/main s390x libsharpyuv0 s390x 1.5.0-0.1 [16.7 kB] 133s Get:38 http://ftpmaster.internal/ubuntu plucky/main s390x libsm6 s390x 2:1.2.4-1 [18.4 kB] 133s Get:39 http://ftpmaster.internal/ubuntu plucky/main s390x libtcl8.6 s390x 8.6.16+dfsg-1 [1034 kB] 133s Get:40 http://ftpmaster.internal/ubuntu plucky/main s390x libjbig0 s390x 2.1-6.1ubuntu2 [33.1 kB] 133s Get:41 http://ftpmaster.internal/ubuntu plucky/main s390x libwebp7 s390x 1.5.0-0.1 [210 kB] 133s Get:42 http://ftpmaster.internal/ubuntu plucky/main s390x libtiff6 s390x 4.5.1+git230720-4ubuntu4 [217 kB] 133s Get:43 http://ftpmaster.internal/ubuntu plucky/main s390x libxft2 s390x 2.3.6-1build1 [49.6 kB] 134s Get:44 http://ftpmaster.internal/ubuntu plucky/main s390x libxss1 s390x 1:1.2.3-1build3 [7396 B] 134s Get:45 http://ftpmaster.internal/ubuntu plucky/main s390x libtk8.6 s390x 8.6.16-1 [830 kB] 134s Get:46 http://ftpmaster.internal/ubuntu plucky/main s390x libxt6t64 s390x 1:1.2.1-1.2build1 [184 kB] 134s Get:47 http://ftpmaster.internal/ubuntu plucky/universe s390x node-normalize.css all 8.0.1-5 [10.8 kB] 134s Get:48 http://ftpmaster.internal/ubuntu plucky/main s390x zip s390x 3.0-14ubuntu2 [187 kB] 134s Get:49 http://ftpmaster.internal/ubuntu plucky/main s390x unzip s390x 6.0-28ubuntu6 [186 kB] 134s Get:50 http://ftpmaster.internal/ubuntu plucky/main s390x xdg-utils all 1.2.1-2ubuntu1 [66.0 kB] 134s Get:51 http://ftpmaster.internal/ubuntu plucky/universe s390x r-base-core s390x 4.4.3-1 [28.6 MB] 136s Get:52 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-base64enc s390x 0.1-3-3 [28.0 kB] 136s Get:53 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-cli s390x 3.6.4-1 [1379 kB] 136s Get:54 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-colorspace s390x 2.1-1+dfsg-1 [1567 kB] 137s Get:55 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-commonmark s390x 1.9.2-2 [142 kB] 137s Get:56 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-digest s390x 0.6.37-1 [205 kB] 137s Get:57 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-evaluate all 1.0.3-1 [114 kB] 137s Get:58 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-fansi s390x 1.0.5-1 [615 kB] 137s Get:59 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-farver s390x 2.1.2-1 [1353 kB] 137s Get:60 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-glue s390x 1.8.0-1 [164 kB] 137s Get:61 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-rlang s390x 1.1.5-1 [1713 kB] 137s Get:62 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-lifecycle all 1.0.4+dfsg-1 [110 kB] 137s Get:63 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-gtable all 0.3.6+dfsg-1 [199 kB] 137s Get:64 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-isoband s390x 0.2.7-1 [1481 kB] 137s Get:65 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-mass s390x 7.3-64-1 [1113 kB] 137s Get:66 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-lattice s390x 0.22-6-1 [1340 kB] 137s Get:67 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-nlme s390x 3.1.167-1 [2323 kB] 137s Get:68 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-matrix s390x 1.7-3-1 [4449 kB] 138s Get:69 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-mgcv s390x 1.9-1-1 [3348 kB] 138s Get:70 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-labeling all 0.4.3-1 [62.1 kB] 138s Get:71 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-munsell all 0.5.1-1 [213 kB] 138s Get:72 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-r6 all 2.6.1-1 [101 kB] 138s Get:73 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-rcolorbrewer all 1.1-3-1build1 [55.4 kB] 138s Get:74 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-viridislite all 0.4.2-2 [1088 kB] 138s Get:75 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-scales all 1.3.0-1 [603 kB] 138s Get:76 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-magrittr s390x 2.0.3-1 [154 kB] 138s Get:77 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-utf8 s390x 1.2.4-1 [143 kB] 138s Get:78 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-vctrs s390x 0.6.5-1 [1448 kB] 138s Get:79 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-pillar all 1.10.1+dfsg-1 [453 kB] 138s Get:80 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-pkgconfig all 2.0.3-2build1 [19.7 kB] 138s Get:81 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-tibble s390x 3.2.1+dfsg-3 [420 kB] 138s Get:82 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-withr all 3.0.2+dfsg-1 [214 kB] 138s Get:83 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-ggplot2 all 3.5.1+dfsg-1 [3940 kB] 139s Get:84 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-xfun s390x 0.51+dfsg-1 [574 kB] 139s Get:85 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-highr all 0.11+dfsg-1 [38.5 kB] 139s Get:86 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-yaml s390x 2.3.10-1 [113 kB] 139s Get:87 http://ftpmaster.internal/ubuntu plucky/main s390x libjs-mathjax all 2.7.9+dfsg-1 [5665 kB] 139s Get:88 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-knitr all 1.49+dfsg-1 [859 kB] 139s Get:89 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-markdown all 1.13-1 [162 kB] 139s Get:90 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-matrixstats s390x 1.5.0-1 [539 kB] 139s Get:91 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-microbenchmark s390x 1.5.0-1 [67.2 kB] 139s Get:92 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-r.methodss3 all 1.8.2-1 [84.0 kB] 139s Get:93 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-r.oo all 1.27.0-1 [979 kB] 139s Get:94 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-r.utils all 2.13.0-1 [1423 kB] 140s Get:95 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-r.cache all 0.16.0-1 [113 kB] 140s Get:96 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-r.devices all 2.17.2+ds-1 [398 kB] 140s Get:97 http://ftpmaster.internal/ubuntu plucky/main s390x tcl8.6 s390x 8.6.16+dfsg-1 [14.8 kB] 140s Get:98 http://ftpmaster.internal/ubuntu plucky/main s390x tcl s390x 8.6.14build1 [4124 B] 140s Get:99 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-r.rsp all 0.46.0+ds-1 [1412 kB] 140s Preconfiguring packages ... 140s Fetched 86.4 MB in 8s (10.9 MB/s) 140s Selecting previously unselected package libfreetype6:s390x. 140s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 56326 files and directories currently installed.) 140s Preparing to unpack .../00-libfreetype6_2.13.3+dfsg-1_s390x.deb ... 140s Unpacking libfreetype6:s390x (2.13.3+dfsg-1) ... 140s Selecting previously unselected package fonts-dejavu-mono. 140s Preparing to unpack .../01-fonts-dejavu-mono_2.37-8_all.deb ... 140s Unpacking fonts-dejavu-mono (2.37-8) ... 140s Selecting previously unselected package fonts-dejavu-core. 140s Preparing to unpack .../02-fonts-dejavu-core_2.37-8_all.deb ... 140s Unpacking fonts-dejavu-core (2.37-8) ... 140s Selecting previously unselected package fontconfig-config. 140s Preparing to unpack .../03-fontconfig-config_2.15.0-2ubuntu1_s390x.deb ... 140s Unpacking fontconfig-config (2.15.0-2ubuntu1) ... 140s Selecting previously unselected package libfontconfig1:s390x. 140s Preparing to unpack .../04-libfontconfig1_2.15.0-2ubuntu1_s390x.deb ... 140s Unpacking libfontconfig1:s390x (2.15.0-2ubuntu1) ... 140s Selecting previously unselected package fontconfig. 140s Preparing to unpack .../05-fontconfig_2.15.0-2ubuntu1_s390x.deb ... 140s Unpacking fontconfig (2.15.0-2ubuntu1) ... 141s Selecting previously unselected package fonts-glyphicons-halflings. 141s Preparing to unpack .../06-fonts-glyphicons-halflings_1.009~3.4.1+dfsg-3_all.deb ... 141s Unpacking fonts-glyphicons-halflings (1.009~3.4.1+dfsg-3) ... 141s Selecting previously unselected package fonts-mathjax. 141s Preparing to unpack .../07-fonts-mathjax_2.7.9+dfsg-1_all.deb ... 141s Unpacking fonts-mathjax (2.7.9+dfsg-1) ... 141s Selecting previously unselected package libblas3:s390x. 141s Preparing to unpack .../08-libblas3_3.12.1-2_s390x.deb ... 141s Unpacking libblas3:s390x (3.12.1-2) ... 141s Selecting previously unselected package libpixman-1-0:s390x. 141s Preparing to unpack .../09-libpixman-1-0_0.44.0-3_s390x.deb ... 141s Unpacking libpixman-1-0:s390x (0.44.0-3) ... 141s Selecting previously unselected package libxcb-render0:s390x. 141s Preparing to unpack .../10-libxcb-render0_1.17.0-2_s390x.deb ... 141s Unpacking libxcb-render0:s390x (1.17.0-2) ... 141s Selecting previously unselected package libxcb-shm0:s390x. 141s Preparing to unpack .../11-libxcb-shm0_1.17.0-2_s390x.deb ... 141s Unpacking libxcb-shm0:s390x (1.17.0-2) ... 141s Selecting previously unselected package libxrender1:s390x. 141s Preparing to unpack .../12-libxrender1_1%3a0.9.10-1.1build1_s390x.deb ... 141s Unpacking libxrender1:s390x (1:0.9.10-1.1build1) ... 141s Selecting previously unselected package libcairo2:s390x. 141s Preparing to unpack .../13-libcairo2_1.18.2-2_s390x.deb ... 141s Unpacking libcairo2:s390x (1.18.2-2) ... 141s Selecting previously unselected package libdatrie1:s390x. 141s Preparing to unpack .../14-libdatrie1_0.2.13-3build1_s390x.deb ... 141s Unpacking libdatrie1:s390x (0.2.13-3build1) ... 141s Selecting previously unselected package libdeflate0:s390x. 141s Preparing to unpack .../15-libdeflate0_1.23-1_s390x.deb ... 141s Unpacking libdeflate0:s390x (1.23-1) ... 141s Selecting previously unselected package libgfortran5:s390x. 141s Preparing to unpack .../16-libgfortran5_15-20250222-0ubuntu1_s390x.deb ... 141s Unpacking libgfortran5:s390x (15-20250222-0ubuntu1) ... 141s Selecting previously unselected package libgomp1:s390x. 141s Preparing to unpack .../17-libgomp1_15-20250222-0ubuntu1_s390x.deb ... 141s Unpacking libgomp1:s390x (15-20250222-0ubuntu1) ... 141s Selecting previously unselected package libgraphite2-3:s390x. 141s Preparing to unpack .../18-libgraphite2-3_1.3.14-2ubuntu1_s390x.deb ... 141s Unpacking libgraphite2-3:s390x (1.3.14-2ubuntu1) ... 141s Selecting previously unselected package libharfbuzz0b:s390x. 141s Preparing to unpack .../19-libharfbuzz0b_10.2.0-1_s390x.deb ... 141s Unpacking libharfbuzz0b:s390x (10.2.0-1) ... 141s Selecting previously unselected package x11-common. 141s Preparing to unpack .../20-x11-common_1%3a7.7+23ubuntu3_all.deb ... 141s Unpacking x11-common (1:7.7+23ubuntu3) ... 141s Selecting previously unselected package libice6:s390x. 141s Preparing to unpack .../21-libice6_2%3a1.1.1-1_s390x.deb ... 141s Unpacking libice6:s390x (2:1.1.1-1) ... 141s Selecting previously unselected package libjpeg-turbo8:s390x. 141s Preparing to unpack .../22-libjpeg-turbo8_2.1.5-3ubuntu2_s390x.deb ... 141s Unpacking libjpeg-turbo8:s390x (2.1.5-3ubuntu2) ... 141s Selecting previously unselected package libjpeg8:s390x. 141s Preparing to unpack .../23-libjpeg8_8c-2ubuntu11_s390x.deb ... 141s Unpacking libjpeg8:s390x (8c-2ubuntu11) ... 141s Selecting previously unselected package libjs-bootstrap. 141s Preparing to unpack .../24-libjs-bootstrap_3.4.1+dfsg-3_all.deb ... 141s Unpacking libjs-bootstrap (3.4.1+dfsg-3) ... 141s Selecting previously unselected package libjs-highlight.js. 141s Preparing to unpack .../25-libjs-highlight.js_9.18.5+dfsg1-2_all.deb ... 141s Unpacking libjs-highlight.js (9.18.5+dfsg1-2) ... 141s Selecting previously unselected package libjs-jquery. 141s Preparing to unpack .../26-libjs-jquery_3.6.1+dfsg+~3.5.14-1_all.deb ... 141s Unpacking libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 141s Selecting previously unselected package libjs-jquery-datatables. 141s Preparing to unpack .../27-libjs-jquery-datatables_1.11.5+dfsg-2_all.deb ... 141s Unpacking libjs-jquery-datatables (1.11.5+dfsg-2) ... 141s Selecting previously unselected package liblapack3:s390x. 141s Preparing to unpack .../28-liblapack3_3.12.1-2_s390x.deb ... 141s Unpacking liblapack3:s390x (3.12.1-2) ... 141s Selecting previously unselected package libthai-data. 141s Preparing to unpack .../29-libthai-data_0.1.29-2build1_all.deb ... 141s Unpacking libthai-data (0.1.29-2build1) ... 141s Selecting previously unselected package libthai0:s390x. 141s Preparing to unpack .../30-libthai0_0.1.29-2build1_s390x.deb ... 141s Unpacking libthai0:s390x (0.1.29-2build1) ... 141s Selecting previously unselected package libpango-1.0-0:s390x. 141s Preparing to unpack .../31-libpango-1.0-0_1.56.2-1_s390x.deb ... 141s Unpacking libpango-1.0-0:s390x (1.56.2-1) ... 141s Selecting previously unselected package libpangoft2-1.0-0:s390x. 141s Preparing to unpack .../32-libpangoft2-1.0-0_1.56.2-1_s390x.deb ... 141s Unpacking libpangoft2-1.0-0:s390x (1.56.2-1) ... 141s Selecting previously unselected package libpangocairo-1.0-0:s390x. 141s Preparing to unpack .../33-libpangocairo-1.0-0_1.56.2-1_s390x.deb ... 141s Unpacking libpangocairo-1.0-0:s390x (1.56.2-1) ... 141s Selecting previously unselected package libpaper2:s390x. 141s Preparing to unpack .../34-libpaper2_2.2.5-0.3_s390x.deb ... 141s Unpacking libpaper2:s390x (2.2.5-0.3) ... 141s Selecting previously unselected package libpaper-utils. 141s Preparing to unpack .../35-libpaper-utils_2.2.5-0.3_s390x.deb ... 141s Unpacking libpaper-utils (2.2.5-0.3) ... 141s Selecting previously unselected package libsharpyuv0:s390x. 141s Preparing to unpack .../36-libsharpyuv0_1.5.0-0.1_s390x.deb ... 141s Unpacking libsharpyuv0:s390x (1.5.0-0.1) ... 141s Selecting previously unselected package libsm6:s390x. 141s Preparing to unpack .../37-libsm6_2%3a1.2.4-1_s390x.deb ... 141s Unpacking libsm6:s390x (2:1.2.4-1) ... 141s Selecting previously unselected package libtcl8.6:s390x. 141s Preparing to unpack .../38-libtcl8.6_8.6.16+dfsg-1_s390x.deb ... 141s Unpacking libtcl8.6:s390x (8.6.16+dfsg-1) ... 141s Selecting previously unselected package libjbig0:s390x. 141s Preparing to unpack .../39-libjbig0_2.1-6.1ubuntu2_s390x.deb ... 141s Unpacking libjbig0:s390x (2.1-6.1ubuntu2) ... 141s Selecting previously unselected package libwebp7:s390x. 141s Preparing to unpack .../40-libwebp7_1.5.0-0.1_s390x.deb ... 141s Unpacking libwebp7:s390x (1.5.0-0.1) ... 141s Selecting previously unselected package libtiff6:s390x. 141s Preparing to unpack .../41-libtiff6_4.5.1+git230720-4ubuntu4_s390x.deb ... 141s Unpacking libtiff6:s390x (4.5.1+git230720-4ubuntu4) ... 141s Selecting previously unselected package libxft2:s390x. 141s Preparing to unpack .../42-libxft2_2.3.6-1build1_s390x.deb ... 141s Unpacking libxft2:s390x (2.3.6-1build1) ... 141s Selecting previously unselected package libxss1:s390x. 141s Preparing to unpack .../43-libxss1_1%3a1.2.3-1build3_s390x.deb ... 141s Unpacking libxss1:s390x (1:1.2.3-1build3) ... 141s Selecting previously unselected package libtk8.6:s390x. 141s Preparing to unpack .../44-libtk8.6_8.6.16-1_s390x.deb ... 141s Unpacking libtk8.6:s390x (8.6.16-1) ... 141s Selecting previously unselected package libxt6t64:s390x. 141s Preparing to unpack .../45-libxt6t64_1%3a1.2.1-1.2build1_s390x.deb ... 141s Unpacking libxt6t64:s390x (1:1.2.1-1.2build1) ... 141s Selecting previously unselected package node-normalize.css. 141s Preparing to unpack .../46-node-normalize.css_8.0.1-5_all.deb ... 141s Unpacking node-normalize.css (8.0.1-5) ... 141s Selecting previously unselected package zip. 141s Preparing to unpack .../47-zip_3.0-14ubuntu2_s390x.deb ... 141s Unpacking zip (3.0-14ubuntu2) ... 141s Selecting previously unselected package unzip. 141s Preparing to unpack .../48-unzip_6.0-28ubuntu6_s390x.deb ... 141s Unpacking unzip (6.0-28ubuntu6) ... 141s Selecting previously unselected package xdg-utils. 141s Preparing to unpack .../49-xdg-utils_1.2.1-2ubuntu1_all.deb ... 141s Unpacking xdg-utils (1.2.1-2ubuntu1) ... 141s Selecting previously unselected package r-base-core. 141s Preparing to unpack .../50-r-base-core_4.4.3-1_s390x.deb ... 141s Unpacking r-base-core (4.4.3-1) ... 142s Selecting previously unselected package r-cran-base64enc. 142s Preparing to unpack .../51-r-cran-base64enc_0.1-3-3_s390x.deb ... 142s Unpacking r-cran-base64enc (0.1-3-3) ... 142s Selecting previously unselected package r-cran-cli. 142s Preparing to unpack .../52-r-cran-cli_3.6.4-1_s390x.deb ... 142s Unpacking r-cran-cli (3.6.4-1) ... 142s Selecting previously unselected package r-cran-colorspace. 142s Preparing to unpack .../53-r-cran-colorspace_2.1-1+dfsg-1_s390x.deb ... 142s Unpacking r-cran-colorspace (2.1-1+dfsg-1) ... 142s Selecting previously unselected package r-cran-commonmark. 142s Preparing to unpack .../54-r-cran-commonmark_1.9.2-2_s390x.deb ... 142s Unpacking r-cran-commonmark (1.9.2-2) ... 142s Selecting previously unselected package r-cran-digest. 142s Preparing to unpack .../55-r-cran-digest_0.6.37-1_s390x.deb ... 142s Unpacking r-cran-digest (0.6.37-1) ... 142s Selecting previously unselected package r-cran-evaluate. 142s Preparing to unpack .../56-r-cran-evaluate_1.0.3-1_all.deb ... 142s Unpacking r-cran-evaluate (1.0.3-1) ... 142s Selecting previously unselected package r-cran-fansi. 142s Preparing to unpack .../57-r-cran-fansi_1.0.5-1_s390x.deb ... 142s Unpacking r-cran-fansi (1.0.5-1) ... 142s Selecting previously unselected package r-cran-farver. 142s Preparing to unpack .../58-r-cran-farver_2.1.2-1_s390x.deb ... 142s Unpacking r-cran-farver (2.1.2-1) ... 142s Selecting previously unselected package r-cran-glue. 142s Preparing to unpack .../59-r-cran-glue_1.8.0-1_s390x.deb ... 142s Unpacking r-cran-glue (1.8.0-1) ... 142s Selecting previously unselected package r-cran-rlang. 142s Preparing to unpack .../60-r-cran-rlang_1.1.5-1_s390x.deb ... 142s Unpacking r-cran-rlang (1.1.5-1) ... 142s Selecting previously unselected package r-cran-lifecycle. 142s Preparing to unpack .../61-r-cran-lifecycle_1.0.4+dfsg-1_all.deb ... 142s Unpacking r-cran-lifecycle (1.0.4+dfsg-1) ... 142s Selecting previously unselected package r-cran-gtable. 142s Preparing to unpack .../62-r-cran-gtable_0.3.6+dfsg-1_all.deb ... 142s Unpacking r-cran-gtable (0.3.6+dfsg-1) ... 142s Selecting previously unselected package r-cran-isoband. 142s Preparing to unpack .../63-r-cran-isoband_0.2.7-1_s390x.deb ... 142s Unpacking r-cran-isoband (0.2.7-1) ... 142s Selecting previously unselected package r-cran-mass. 142s Preparing to unpack .../64-r-cran-mass_7.3-64-1_s390x.deb ... 142s Unpacking r-cran-mass (7.3-64-1) ... 142s Selecting previously unselected package r-cran-lattice. 142s Preparing to unpack .../65-r-cran-lattice_0.22-6-1_s390x.deb ... 142s Unpacking r-cran-lattice (0.22-6-1) ... 142s Selecting previously unselected package r-cran-nlme. 142s Preparing to unpack .../66-r-cran-nlme_3.1.167-1_s390x.deb ... 142s Unpacking r-cran-nlme (3.1.167-1) ... 142s Selecting previously unselected package r-cran-matrix. 142s Preparing to unpack .../67-r-cran-matrix_1.7-3-1_s390x.deb ... 142s Unpacking r-cran-matrix (1.7-3-1) ... 142s Selecting previously unselected package r-cran-mgcv. 142s Preparing to unpack .../68-r-cran-mgcv_1.9-1-1_s390x.deb ... 142s Unpacking r-cran-mgcv (1.9-1-1) ... 142s Selecting previously unselected package r-cran-labeling. 142s Preparing to unpack .../69-r-cran-labeling_0.4.3-1_all.deb ... 142s Unpacking r-cran-labeling (0.4.3-1) ... 142s Selecting previously unselected package r-cran-munsell. 142s Preparing to unpack .../70-r-cran-munsell_0.5.1-1_all.deb ... 142s Unpacking r-cran-munsell (0.5.1-1) ... 142s Selecting previously unselected package r-cran-r6. 142s Preparing to unpack .../71-r-cran-r6_2.6.1-1_all.deb ... 142s Unpacking r-cran-r6 (2.6.1-1) ... 142s Selecting previously unselected package r-cran-rcolorbrewer. 142s Preparing to unpack .../72-r-cran-rcolorbrewer_1.1-3-1build1_all.deb ... 142s Unpacking r-cran-rcolorbrewer (1.1-3-1build1) ... 142s Selecting previously unselected package r-cran-viridislite. 142s Preparing to unpack .../73-r-cran-viridislite_0.4.2-2_all.deb ... 142s Unpacking r-cran-viridislite (0.4.2-2) ... 142s Selecting previously unselected package r-cran-scales. 142s Preparing to unpack .../74-r-cran-scales_1.3.0-1_all.deb ... 142s Unpacking r-cran-scales (1.3.0-1) ... 142s Selecting previously unselected package r-cran-magrittr. 142s Preparing to unpack .../75-r-cran-magrittr_2.0.3-1_s390x.deb ... 142s Unpacking r-cran-magrittr (2.0.3-1) ... 142s Selecting previously unselected package r-cran-utf8. 142s Preparing to unpack .../76-r-cran-utf8_1.2.4-1_s390x.deb ... 142s Unpacking r-cran-utf8 (1.2.4-1) ... 142s Selecting previously unselected package r-cran-vctrs. 142s Preparing to unpack .../77-r-cran-vctrs_0.6.5-1_s390x.deb ... 142s Unpacking r-cran-vctrs (0.6.5-1) ... 142s Selecting previously unselected package r-cran-pillar. 142s Preparing to unpack .../78-r-cran-pillar_1.10.1+dfsg-1_all.deb ... 142s Unpacking r-cran-pillar (1.10.1+dfsg-1) ... 142s Selecting previously unselected package r-cran-pkgconfig. 142s Preparing to unpack .../79-r-cran-pkgconfig_2.0.3-2build1_all.deb ... 142s Unpacking r-cran-pkgconfig (2.0.3-2build1) ... 142s Selecting previously unselected package r-cran-tibble. 142s Preparing to unpack .../80-r-cran-tibble_3.2.1+dfsg-3_s390x.deb ... 142s Unpacking r-cran-tibble (3.2.1+dfsg-3) ... 142s Selecting previously unselected package r-cran-withr. 142s Preparing to unpack .../81-r-cran-withr_3.0.2+dfsg-1_all.deb ... 142s Unpacking r-cran-withr (3.0.2+dfsg-1) ... 142s Selecting previously unselected package r-cran-ggplot2. 142s Preparing to unpack .../82-r-cran-ggplot2_3.5.1+dfsg-1_all.deb ... 142s Unpacking r-cran-ggplot2 (3.5.1+dfsg-1) ... 142s Selecting previously unselected package r-cran-xfun. 142s Preparing to unpack .../83-r-cran-xfun_0.51+dfsg-1_s390x.deb ... 142s Unpacking r-cran-xfun (0.51+dfsg-1) ... 142s Selecting previously unselected package r-cran-highr. 142s Preparing to unpack .../84-r-cran-highr_0.11+dfsg-1_all.deb ... 142s Unpacking r-cran-highr (0.11+dfsg-1) ... 142s Selecting previously unselected package r-cran-yaml. 142s Preparing to unpack .../85-r-cran-yaml_2.3.10-1_s390x.deb ... 142s Unpacking r-cran-yaml (2.3.10-1) ... 142s Selecting previously unselected package libjs-mathjax. 142s Preparing to unpack .../86-libjs-mathjax_2.7.9+dfsg-1_all.deb ... 142s Unpacking libjs-mathjax (2.7.9+dfsg-1) ... 143s Selecting previously unselected package r-cran-knitr. 143s Preparing to unpack .../87-r-cran-knitr_1.49+dfsg-1_all.deb ... 143s Unpacking r-cran-knitr (1.49+dfsg-1) ... 143s Selecting previously unselected package r-cran-markdown. 143s Preparing to unpack .../88-r-cran-markdown_1.13-1_all.deb ... 143s Unpacking r-cran-markdown (1.13-1) ... 143s Selecting previously unselected package r-cran-matrixstats. 143s Preparing to unpack .../89-r-cran-matrixstats_1.5.0-1_s390x.deb ... 143s Unpacking r-cran-matrixstats (1.5.0-1) ... 143s Selecting previously unselected package r-cran-microbenchmark. 143s Preparing to unpack .../90-r-cran-microbenchmark_1.5.0-1_s390x.deb ... 143s Unpacking r-cran-microbenchmark (1.5.0-1) ... 143s Selecting previously unselected package r-cran-r.methodss3. 143s Preparing to unpack .../91-r-cran-r.methodss3_1.8.2-1_all.deb ... 143s Unpacking r-cran-r.methodss3 (1.8.2-1) ... 143s Selecting previously unselected package r-cran-r.oo. 143s Preparing to unpack .../92-r-cran-r.oo_1.27.0-1_all.deb ... 143s Unpacking r-cran-r.oo (1.27.0-1) ... 143s Selecting previously unselected package r-cran-r.utils. 143s Preparing to unpack .../93-r-cran-r.utils_2.13.0-1_all.deb ... 143s Unpacking r-cran-r.utils (2.13.0-1) ... 143s Selecting previously unselected package r-cran-r.cache. 143s Preparing to unpack .../94-r-cran-r.cache_0.16.0-1_all.deb ... 143s Unpacking r-cran-r.cache (0.16.0-1) ... 143s Selecting previously unselected package r-cran-r.devices. 143s Preparing to unpack .../95-r-cran-r.devices_2.17.2+ds-1_all.deb ... 143s Unpacking r-cran-r.devices (2.17.2+ds-1) ... 143s Selecting previously unselected package tcl8.6. 143s Preparing to unpack .../96-tcl8.6_8.6.16+dfsg-1_s390x.deb ... 143s Unpacking tcl8.6 (8.6.16+dfsg-1) ... 143s Selecting previously unselected package tcl. 143s Preparing to unpack .../97-tcl_8.6.14build1_s390x.deb ... 143s Unpacking tcl (8.6.14build1) ... 143s Selecting previously unselected package r-cran-r.rsp. 143s Preparing to unpack .../98-r-cran-r.rsp_0.46.0+ds-1_all.deb ... 143s Unpacking r-cran-r.rsp (0.46.0+ds-1) ... 143s Setting up libgraphite2-3:s390x (1.3.14-2ubuntu1) ... 143s Setting up libpixman-1-0:s390x (0.44.0-3) ... 143s Setting up libsharpyuv0:s390x (1.5.0-0.1) ... 143s Setting up fonts-mathjax (2.7.9+dfsg-1) ... 143s Setting up libjs-mathjax (2.7.9+dfsg-1) ... 143s Setting up libxrender1:s390x (1:0.9.10-1.1build1) ... 143s Setting up libdatrie1:s390x (0.2.13-3build1) ... 143s Setting up libxcb-render0:s390x (1.17.0-2) ... 143s Setting up fonts-glyphicons-halflings (1.009~3.4.1+dfsg-3) ... 143s Setting up unzip (6.0-28ubuntu6) ... 143s Setting up x11-common (1:7.7+23ubuntu3) ... 143s Setting up libdeflate0:s390x (1.23-1) ... 143s Setting up libxcb-shm0:s390x (1.17.0-2) ... 143s Setting up libgomp1:s390x (15-20250222-0ubuntu1) ... 143s Setting up libjbig0:s390x (2.1-6.1ubuntu2) ... 143s Setting up zip (3.0-14ubuntu2) ... 143s Setting up libblas3:s390x (3.12.1-2) ... 143s update-alternatives: using /usr/lib/s390x-linux-gnu/blas/libblas.so.3 to provide /usr/lib/s390x-linux-gnu/libblas.so.3 (libblas.so.3-s390x-linux-gnu) in auto mode 143s Setting up libfreetype6:s390x (2.13.3+dfsg-1) ... 143s Setting up fonts-dejavu-mono (2.37-8) ... 143s Setting up libtcl8.6:s390x (8.6.16+dfsg-1) ... 143s Setting up fonts-dejavu-core (2.37-8) ... 143s Setting up libjpeg-turbo8:s390x (2.1.5-3ubuntu2) ... 143s Setting up libgfortran5:s390x (15-20250222-0ubuntu1) ... 143s Setting up libwebp7:s390x (1.5.0-0.1) ... 143s Setting up libjs-highlight.js (9.18.5+dfsg1-2) ... 143s Setting up libharfbuzz0b:s390x (10.2.0-1) ... 143s Setting up libthai-data (0.1.29-2build1) ... 143s Setting up libxss1:s390x (1:1.2.3-1build3) ... 143s Setting up libpaper2:s390x (2.2.5-0.3) ... 143s Setting up libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 143s Setting up node-normalize.css (8.0.1-5) ... 143s Setting up xdg-utils (1.2.1-2ubuntu1) ... 143s update-alternatives: using /usr/bin/xdg-open to provide /usr/bin/open (open) in auto mode 143s Setting up libjs-bootstrap (3.4.1+dfsg-3) ... 143s Setting up libjpeg8:s390x (8c-2ubuntu11) ... 143s Setting up libice6:s390x (2:1.1.1-1) ... 143s Setting up tcl8.6 (8.6.16+dfsg-1) ... 143s Setting up liblapack3:s390x (3.12.1-2) ... 143s update-alternatives: using /usr/lib/s390x-linux-gnu/lapack/liblapack.so.3 to provide /usr/lib/s390x-linux-gnu/liblapack.so.3 (liblapack.so.3-s390x-linux-gnu) in auto mode 143s Setting up fontconfig-config (2.15.0-2ubuntu1) ... 143s Setting up libpaper-utils (2.2.5-0.3) ... 143s Setting up libjs-jquery-datatables (1.11.5+dfsg-2) ... 143s Setting up libthai0:s390x (0.1.29-2build1) ... 143s Setting up libtiff6:s390x (4.5.1+git230720-4ubuntu4) ... 143s Setting up tcl (8.6.14build1) ... 143s Setting up libfontconfig1:s390x (2.15.0-2ubuntu1) ... 143s Setting up libsm6:s390x (2:1.2.4-1) ... 143s Setting up fontconfig (2.15.0-2ubuntu1) ... 146s Regenerating fonts cache... done. 146s Setting up libxft2:s390x (2.3.6-1build1) ... 146s Setting up libtk8.6:s390x (8.6.16-1) ... 146s Setting up libpango-1.0-0:s390x (1.56.2-1) ... 146s Setting up libcairo2:s390x (1.18.2-2) ... 146s Setting up libxt6t64:s390x (1:1.2.1-1.2build1) ... 146s Setting up libpangoft2-1.0-0:s390x (1.56.2-1) ... 146s Setting up libpangocairo-1.0-0:s390x (1.56.2-1) ... 146s Setting up r-base-core (4.4.3-1) ... 146s Creating config file /etc/R/Renviron with new version 146s Setting up r-cran-labeling (0.4.3-1) ... 146s Setting up r-cran-lattice (0.22-6-1) ... 146s Setting up r-cran-nlme (3.1.167-1) ... 146s Setting up r-cran-farver (2.1.2-1) ... 146s Setting up r-cran-viridislite (0.4.2-2) ... 146s Setting up r-cran-commonmark (1.9.2-2) ... 146s Setting up r-cran-r6 (2.6.1-1) ... 146s Setting up r-cran-magrittr (2.0.3-1) ... 146s Setting up r-cran-microbenchmark (1.5.0-1) ... 146s Setting up r-cran-rlang (1.1.5-1) ... 146s Setting up r-cran-matrixstats (1.5.0-1) ... 146s Setting up r-cran-xfun (0.51+dfsg-1) ... 146s Setting up r-cran-withr (3.0.2+dfsg-1) ... 146s Setting up r-cran-base64enc (0.1-3-3) ... 146s Setting up r-cran-digest (0.6.37-1) ... 146s Setting up r-cran-yaml (2.3.10-1) ... 146s Setting up r-cran-evaluate (1.0.3-1) ... 146s Setting up r-cran-highr (0.11+dfsg-1) ... 146s Setting up r-cran-fansi (1.0.5-1) ... 146s Setting up r-cran-mass (7.3-64-1) ... 146s Setting up r-cran-glue (1.8.0-1) ... 146s Setting up r-cran-cli (3.6.4-1) ... 146s Setting up r-cran-lifecycle (1.0.4+dfsg-1) ... 146s Setting up r-cran-r.methodss3 (1.8.2-1) ... 146s Setting up r-cran-pkgconfig (2.0.3-2build1) ... 146s Setting up r-cran-utf8 (1.2.4-1) ... 146s Setting up r-cran-colorspace (2.1-1+dfsg-1) ... 146s Setting up r-cran-markdown (1.13-1) ... 146s Setting up r-cran-rcolorbrewer (1.1-3-1build1) ... 146s Setting up r-cran-isoband (0.2.7-1) ... 146s Setting up r-cran-gtable (0.3.6+dfsg-1) ... 146s Setting up r-cran-matrix (1.7-3-1) ... 146s Setting up r-cran-knitr (1.49+dfsg-1) ... 146s Setting up r-cran-mgcv (1.9-1-1) ... 146s Setting up r-cran-vctrs (0.6.5-1) ... 146s Setting up r-cran-pillar (1.10.1+dfsg-1) ... 146s Setting up r-cran-munsell (0.5.1-1) ... 146s Setting up r-cran-tibble (3.2.1+dfsg-3) ... 146s Setting up r-cran-r.oo (1.27.0-1) ... 146s Setting up r-cran-scales (1.3.0-1) ... 146s Setting up r-cran-r.utils (2.13.0-1) ... 146s Setting up r-cran-ggplot2 (3.5.1+dfsg-1) ... 146s Setting up r-cran-r.devices (2.17.2+ds-1) ... 146s Setting up r-cran-r.cache (0.16.0-1) ... 146s Setting up r-cran-r.rsp (0.46.0+ds-1) ... 146s Processing triggers for libc-bin (2.41-1ubuntu2) ... 146s Processing triggers for man-db (2.13.0-1) ... 147s Processing triggers for install-info (7.1.1-1) ... 148s autopkgtest [18:12:38]: test run-unit-test: [----------------------- 148s 148s R version 4.4.3 (2025-02-28) -- "Trophy Case" 148s Copyright (C) 2025 The R Foundation for Statistical Computing 148s Platform: s390x-ibm-linux-gnu 148s 148s R is free software and comes with ABSOLUTELY NO WARRANTY. 148s You are welcome to redistribute it under certain conditions. 148s Type 'license()' or 'licence()' for distribution details. 148s 148s R is a collaborative project with many contributors. 148s Type 'contributors()' for more information and 148s 'citation()' on how to cite R or R packages in publications. 148s 148s Type 'demo()' for some demos, 'help()' for on-line help, or 148s 'help.start()' for an HTML browser interface to help. 148s Type 'q()' to quit R. 148s 148s > library("matrixStats") 148s > 148s > allocArray_R <- function(nrow, ncol, value = NA) { 148s + array(data = value, dim = dim) 148s + } 148s > 148s > values <- list( 148s + -1L, 0L, +1L, NA_integer_, .Machine$integer.max, 148s + -1, 0, +1, NA_real_, NaN, -Inf, +Inf, 148s + .Machine$double.xmin, .Machine$double.xmax, 148s + .Machine$double.eps, .Machine$double.neg.eps, 148s + FALSE, TRUE, NA 148s + ) 148s > 148s > dim <- c(2L, 4L, 3L) 148s > for (value in values) { 148s + x0 <- allocArray_R(dim, value = value) 148s + x <- allocArray(dim, value = value) 148s + if (!identical(x, x0)) { 148s + str(list(dim = dim, value = value, x = x, x0 = x0)) 148s + stopifnot(identical(x, x0)) 148s + } 148s + } 148s > 148s 148s R version 4.4.3 (2025-02-28) -- "Trophy Case" 148s Copyright (C) 2025 The R Foundation for Statistical Computing 148s Platform: s390x-ibm-linux-gnu 148s 148s R is free software and comes with ABSOLUTELY NO WARRANTY. 148s You are welcome to redistribute it under certain conditions. 148s Type 'license()' or 'licence()' for distribution details. 148s 148s R is a collaborative project with many contributors. 148s Type 'contributors()' for more information and 148s 'citation()' on how to cite R or R packages in publications. 148s 148s Type 'demo()' for some demos, 'help()' for on-line help, or 148s 'help.start()' for an HTML browser interface to help. 148s Type 'q()' to quit R. 148s 148s > library("matrixStats") 148s > 148s > allocMatrix_R <- function(nrow, ncol, value = NA) { 148s + matrix(data = value, nrow = nrow, ncol = ncol) 148s + } 148s > 148s > values <- list( 148s + -1L, 0L, +1L, NA_integer_, .Machine$integer.max, 148s + -1, 0, +1, NA_real_, NaN, -Inf, +Inf, 148s + .Machine$double.xmin, .Machine$double.xmax, 148s + .Machine$double.eps, .Machine$double.neg.eps, 148s + FALSE, TRUE, NA 148s + ) 148s > 148s > nrow <- 2L 148s > ncol <- 3L 148s > for (value in values) { 148s + x0 <- allocMatrix_R(nrow, ncol, value = value) 148s + x <- allocMatrix(nrow, ncol, value = value) 148s + if (!identical(x, x0)) { 148s + str(list(nrow = nrow, ncol = ncol, value = value, x = x, x0 = x0)) 148s + stopifnot(identical(x, x0)) 148s + } 148s + } 148s > 148s 148s R version 4.4.3 (2025-02-28) -- "Trophy Case" 148s Copyright (C) 2025 The R Foundation for Statistical Computing 148s Platform: s390x-ibm-linux-gnu 148s 148s R is free software and comes with ABSOLUTELY NO WARRANTY. 148s You are welcome to redistribute it under certain conditions. 148s Type 'license()' or 'licence()' for distribution details. 148s 148s R is a collaborative project with many contributors. 148s Type 'contributors()' for more information and 148s 'citation()' on how to cite R or R packages in publications. 148s 148s Type 'demo()' for some demos, 'help()' for on-line help, or 148s 'help.start()' for an HTML browser interface to help. 148s Type 'q()' to quit R. 148s 148s > library("matrixStats") 148s > 148s > allocVector_R <- function(length, value = NA) { 148s + x <- vector(mode = typeof(value), length = length) 148s + if (!is.finite(value) || value != 0) x[] <- value 148s + x 148s + } 148s > 148s > values <- list( 148s + -1L, 0L, +1L, NA_integer_, .Machine$integer.max, 148s + -1, 0, +1, NA_real_, NaN, -Inf, +Inf, 148s + .Machine$double.xmin, .Machine$double.xmax, 148s + .Machine$double.eps, .Machine$double.neg.eps, 148s + FALSE, TRUE, NA 148s + ) 148s > 148s > n <- 10L 148s > for (value in values) { 148s + x0 <- allocVector_R(n, value = value) 148s + x <- allocVector(n, value = value) 148s + if (!identical(x, x0)) { 148s + str(list(n = n, value = value, x = x, x0 = x0)) 148s + stopifnot(identical(x, x0)) 148s + } 148s + } 148s > 148s 148s R version 4.4.3 (2025-02-28) -- "Trophy Case" 148s Copyright (C) 2025 The R Foundation for Statistical Computing 148s Platform: s390x-ibm-linux-gnu 148s 148s R is free software and comes with ABSOLUTELY NO WARRANTY. 148s You are welcome to redistribute it under certain conditions. 148s Type 'license()' or 'licence()' for distribution details. 148s 148s R is a collaborative project with many contributors. 148s Type 'contributors()' for more information and 148s 'citation()' on how to cite R or R packages in publications. 148s 148s Type 'demo()' for some demos, 'help()' for on-line help, or 148s 'help.start()' for an HTML browser interface to help. 148s Type 'q()' to quit R. 148s 148s > library("matrixStats") 148s > 148s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 148s > # Setup 148s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 148s > data <- data.frame( 148s + logical = c(TRUE, FALSE, TRUE), 148s + integer = 1:3, 148s + double = seq(from = 1.0, to = 3.0, by = 1.0), 148s + complex = seq(from = 1.0, to = 3.0, by = 1.0) + 1.0i, 148s + character = letters[1:3], 148s + stringsAsFactors = FALSE 148s + ) 148s > 148s > modes <- names(data) 148s > 148s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 148s > # Special cases 148s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 148s > cat("NULL...\n") 148s NULL... 148s > stopifnot(identical(anyMissing(NULL), FALSE)) 148s > cat("NULL...done\n") 148s NULL...done 148s > 148s > cat("raw...\n") 148s raw... 148s > stopifnot(identical(anyMissing(as.raw(0:2)), FALSE)) 148s > cat("raw...done\n") 148s raw...done 148s > 148s > cat("list(NULL)...\n") 148s list(NULL)... 148s > stopifnot(identical(anyMissing(list(NULL)), FALSE)) 148s > cat("list(NULL)...done\n") 148s list(NULL)...done 148s > 148s > 148s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 148s > # Scalars, vectors, and matrices of various modes 148s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 148s > for (mode in modes) { 148s + cat(sprintf("Mode: %s...\n", mode)) 148s + values <- data[[mode]] 148s + 148s + # Scalars 148s + cat(" scalar\n") 148s + x <- values[1L] 148s + print(x) 148s + stopifnot(identical(anyMissing(x), FALSE)) 148s + is.na(x) <- TRUE 148s + print(x) 148s + stopifnot(identical(anyMissing(x), TRUE)) 148s + 148s + # Vectors 148s + cat(" vector\n") 148s + x <- values 149s + print(x) 149s + stopifnot(identical(anyMissing(x), FALSE)) 149s + is.na(x)[2L] <- TRUE 149s + print(x) 149s + stopifnot(identical(anyMissing(x), TRUE)) 149s + 149s + # Matrices 149s + cat(" matrix\n") 149s + x <- matrix(c(values, values), ncol = 2L) 149s + print(x) 149s + stopifnot(identical(anyMissing(x), FALSE)) 149s + is.na(x)[2L] <- TRUE 149s + print(x) 149s + stopifnot(identical(anyMissing(x), TRUE)) 149s + 149s + cat(sprintf("Mode: %s...done\n", mode)) 149s + } # for (mode ...) 149s Mode: logical... 149s scalar 149s [1] TRUE 149s [1] NA 149s vector 149s [1] TRUE FALSE TRUE 149s [1] TRUE NA TRUE 149s matrix 149s [,1] [,2] 149s [1,] TRUE TRUE 149s [2,] FALSE FALSE 149s [3,] TRUE TRUE 149s [,1] [,2] 149s [1,] TRUE TRUE 149s [2,] NA FALSE 149s [3,] TRUE TRUE 149s Mode: logical...done 149s Mode: integer... 149s scalar 149s [1] 1 149s [1] NA 149s vector 149s [1] 1 2 3 149s [1] 1 NA 3 149s matrix 149s [,1] [,2] 149s [1,] 1 1 149s [2,] 2 2 149s [3,] 3 3 149s [,1] [,2] 149s [1,] 1 1 149s [2,] NA 2 149s [3,] 3 3 149s Mode: integer...done 149s Mode: double... 149s scalar 149s [1] 1 149s [1] NA 149s vector 149s [1] 1 2 3 149s [1] 1 NA 3 149s matrix 149s [,1] [,2] 149s [1,] 1 1 149s [2,] 2 2 149s [3,] 3 3 149s [,1] [,2] 149s [1,] 1 1 149s [2,] NA 2 149s [3,] 3 3 149s Mode: double...done 149s Mode: complex... 149s scalar 149s [1] 1+1i 149s [1] NA 149s vector 149s [1] 1+1i 2+1i 3+1i 149s [1] 1+1i NA 3+1i 149s matrix 149s [,1] [,2] 149s [1,] 1+1i 1+1i 149s [2,] 2+1i 2+1i 149s [3,] 3+1i 3+1i 149s [,1] [,2] 149s [1,] 1+1i 1+1i 149s [2,] NA 2+1i 149s [3,] 3+1i 3+1i 149s Mode: complex...done 149s Mode: character... 149s scalar 149s [1] "a" 149s [1] NA 149s vector 149s [1] "a" "b" "c" 149s [1] "a" NA "c" 149s matrix 149s [,1] [,2] 149s [1,] "a" "a" 149s [2,] "b" "b" 149s [3,] "c" "c" 149s [,1] [,2] 149s [1,] "a" "a" 149s [2,] NA "b" 149s [3,] "c" "c" 149s Mode: character...done 149s > 149s > 149s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 149s > # Data frames 149s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 149s > cat("data.frame...\n") 149s data.frame... 149s > x <- data 149s > stopifnot(identical(anyMissing(x), FALSE)) 149s > for (mode in modes) { 149s + x <- data 149s + is.na(x[[mode]])[2L] <- TRUE 149s + print(x) 149s + stopifnot(identical(anyMissing(x), TRUE)) 149s + } # for (mode ...) 149s logical integer double complex character 149s 1 TRUE 1 1 1+1i a 149s 2 NA 2 2 2+1i b 149s 3 TRUE 3 3 3+1i c 149s logical integer double complex character 149s 1 TRUE 1 1 1+1i a 149s 2 FALSE NA 2 2+1i b 149s 3 TRUE 3 3 3+1i c 149s logical integer double complex character 149s 1 TRUE 1 1 1+1i a 149s 2 FALSE 2 NA 2+1i b 149s 3 TRUE 3 3 3+1i c 149s logical integer double complex character 149s 1 TRUE 1 1 1+1i a 149s 2 FALSE 2 2 NA b 149s 3 TRUE 3 3 3+1i c 149s logical integer double complex character 149s 1 TRUE 1 1 1+1i a 149s 2 FALSE 2 2 2+1i 149s 3 TRUE 3 3 3+1i c 149s > cat("data.frame...done\n") 149s data.frame...done 149s > 149s > 149s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 149s > # Lists 149s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 149s > cat("list...\n") 149s list... 149s > x <- as.list(data) 149s > stopifnot(identical(anyMissing(x), FALSE)) 149s > for (mode in modes) { 149s + x <- as.list(data) 149s + is.na(x[[mode]])[2L] <- TRUE 149s + print(x) 149s + stopifnot(identical(anyMissing(x), TRUE)) 149s + } # for (mode ...) 149s $logical 149s [1] TRUE NA TRUE 149s 149s $integer 149s [1] 1 2 3 149s 149s $double 149s [1] 1 2 3 149s 149s $complex 149s [1] 1+1i 2+1i 3+1i 149s 149s $character 149s [1] "a" "b" "c" 149s 149s $logical 149s [1] TRUE FALSE TRUE 149s 149s $integer 149s [1] 1 NA 3 149s 149s $double 149s [1] 1 2 3 149s 149s $complex 149s [1] 1+1i 2+1i 3+1i 149s 149s $character 149s [1] "a" "b" "c" 149s 149s $logical 149s [1] TRUE FALSE TRUE 149s 149s $integer 149s [1] 1 2 3 149s 149s $double 149s [1] 1 NA 3 149s 149s $complex 149s [1] 1+1i 2+1i 3+1i 149s 149s $character 149s [1] "a" "b" "c" 149s 149s $logical 149s [1] TRUE FALSE TRUE 149s 149s $integer 149s [1] 1 2 3 149s 149s $double 149s [1] 1 2 3 149s 149s $complex 149s [1] 1+1i NA 3+1i 149s 149s $character 149s [1] "a" "b" "c" 149s 149s $logical 149s [1] TRUE FALSE TRUE 149s 149s $integer 149s [1] 1 2 3 149s 149s $double 149s [1] 1 2 3 149s 149s $complex 149s [1] 1+1i 2+1i 3+1i 149s 149s $character 149s [1] "a" NA "c" 149s 149s > cat("list...done\n") 149s list...done 149s > 149s 149s R version 4.4.3 (2025-02-28) -- "Trophy Case" 149s Copyright (C) 2025 The R Foundation for Statistical Computing 149s Platform: s390x-ibm-linux-gnu 149s 149s R is free software and comes with ABSOLUTELY NO WARRANTY. 149s You are welcome to redistribute it under certain conditions. 149s Type 'license()' or 'licence()' for distribution details. 149s 149s R is a collaborative project with many contributors. 149s Type 'contributors()' for more information and 149s 'citation()' on how to cite R or R packages in publications. 149s 149s Type 'demo()' for some demos, 'help()' for on-line help, or 149s 'help.start()' for an HTML browser interface to help. 149s Type 'q()' to quit R. 149s 149s > library("matrixStats") 149s > 149s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 149s > # Subsetted tests 149s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 149s > source("utils/validateIndicesFramework.R") 149s > x <- runif(4, min = -3, max = 3) 149s > x[2] <- NA 149s > for (mode in c("integer", "numeric")) { 149s + storage.mode(x) <- mode 149s + for (idxs in index_cases) { 149s + validateIndicesTestVector(x, idxs, 149s + ftest = anyMissing, fsure = function(x, ...) { 149s + anyValue(x, value = NA) 149s + }) 149s + } 149s + } 149s > 149s 149s R version 4.4.3 (2025-02-28) -- "Trophy Case" 149s Copyright (C) 2025 The R Foundation for Statistical Computing 149s Platform: s390x-ibm-linux-gnu 149s 149s R is free software and comes with ABSOLUTELY NO WARRANTY. 149s You are welcome to redistribute it under certain conditions. 149s Type 'license()' or 'licence()' for distribution details. 149s 149s R is a collaborative project with many contributors. 149s Type 'contributors()' for more information and 149s 'citation()' on how to cite R or R packages in publications. 149s 149s Type 'demo()' for some demos, 'help()' for on-line help, or 149s 'help.start()' for an HTML browser interface to help. 149s Type 'q()' to quit R. 149s 149s > ## Don't test with valgrind 149s > if (Sys.getenv("_R_CHECK_USE_VALGRIND_") == "") { 149s + 149s + ## 3. Make sure all suggested packages are installed / can be loaded 149s + pkgs <- c("base64enc", "ggplot2", "knitr", "markdown", "microbenchmark", 149s + "R.devices", "R.rsp") 149s + if (all(unlist(lapply(pkgs, FUN = requireNamespace)))) { 149s + html <- matrixStats:::benchmark("binCounts") 149s + print(html) 149s + } 149s + 149s + rm(list = "pkgs") 149s + 149s + } 149s Loading required namespace: base64enc 149s Loading required namespace: ggplot2 149s Loading required namespace: knitr 149s Loading required namespace: markdown 149s Loading required namespace: microbenchmark 149s Loading required namespace: R.devices 149s Loading required namespace: R.rsp 150s integer: unsorted 152s integer: sorted 153s double: unsorted 156s double: sorted 157s RspFileProduct: 157s Pathname: /tmp/autopkgtest.0UdmrW/autopkgtest_tmp/reports/binCounts.html 157s File size: 73.06 kB (74811 bytes) 157s Content type: text/html 157s Metadata 'author': 'Henrik Bengtsson' 157s Metadata 'title': 'binCounts() benchmarks' 157s Metadata 'date': '2014-05-25' 157s Has processor: FALSE 157s > 157s Warning message: 157s In par(parT) : argument 1 does not name a graphical parameter 157s 157s R version 4.4.3 (2025-02-28) -- "Trophy Case" 157s Copyright (C) 2025 The R Foundation for Statistical Computing 157s Platform: s390x-ibm-linux-gnu 157s 157s R is free software and comes with ABSOLUTELY NO WARRANTY. 157s You are welcome to redistribute it under certain conditions. 157s Type 'license()' or 'licence()' for distribution details. 157s 157s R is a collaborative project with many contributors. 157s Type 'contributors()' for more information and 157s 'citation()' on how to cite R or R packages in publications. 157s 157s Type 'demo()' for some demos, 'help()' for on-line help, or 157s 'help.start()' for an HTML browser interface to help. 157s Type 'q()' to quit R. 157s 157s > library("matrixStats") 157s > library("stats") 157s > 157s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 157s > # Local functions 157s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 157s > binCounts_hist <- function(x, bx, right = FALSE, ...) { 157s + n0 <- graphics::hist(x, breaks = bx, right = right, 157s + include.lowest = TRUE, plot = FALSE)$counts 157s + } 157s > 157s > 157s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 157s > # Non-sorted and sorted positions 157s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 157s > nx <- 1000L # Number of data points 157s > nb <- 200L # Number of bins 157s > 157s > # Uniformely distributed bins 157s > bx <- seq(from = 0, to = 1, length.out = nb + 1L) 157s > bx <- c(-1, bx, 2) 157s > 157s > # Sample data points 157s > set.seed(0xBEEF) 157s > x <- runif(nx, min = 0, max = 1) 157s > 157s > for (kk in 1:2) { 157s + n0 <- binCounts_hist(x, bx = bx) 157s + n1 <- binCounts(x, bx = bx) 157s + # Sanity check 157s + stopifnot(identical(n1, n0)) 157s + 157s + # Check reversed 157s + n1r <- rev(binCounts(-x, bx = rev(-bx), right = TRUE)) 157s + stopifnot(identical(n1r, n1)) 157s + 157s + # Retry with a sorted vector 157s + x <- sort(x) 157s + } # for (kk in 1:2) 157s > 157s > 157s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 157s > # Missing values 157s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 157s > x <- 1:40 157s > x[20] <- NA_integer_ 157s > nx <- length(x) 157s > 157s > # Bins 157s > bx <- c(0.5, 50.5, 100.5, 150.5, 200.5) 157s > 157s > y_smooth0 <- binCounts_hist(x, bx = bx) 157s > y_smooth <- binCounts(x, bx = bx) 157s > # Sanity check 157s > stopifnot(all.equal(y_smooth, y_smooth0)) 157s > 157s > 157s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 157s > # Border cases 157s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 157s > x <- 1:10 157s > bx <- min(x) - c(10, 1) 157s > y_smooth <- binCounts(x, bx = bx) 157s > stopifnot(all.equal(y_smooth, 0L)) 157s > bx <- range(x) 157s > y_smooth <- binCounts(x, bx = bx) 157s > stopifnot(all.equal(y_smooth, length(x) - 1L)) 157s > bx <- max(x) + c(1, 10) 157s > y_smooth <- binCounts(x, bx = bx) 157s > stopifnot(all.equal(y_smooth, 0L)) 157s > 157s > # Every second empty 157s > x <- 1:10 157s > bx <- rep(x, each = 2L) 157s > y_smooth <- binCounts(x, bx = bx) 157s > stopifnot(all.equal(y_smooth, rep(c(0L, 1L), length.out = length(bx) - 1L))) 157s > ## NOTE: binCounts_hist() does not give the same last bin count 157s > 157s > 157s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 157s > # Exception handling 157s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 157s > # Zero bin boundaries (invalid bin definition) 157s > bx <- double(0L) 157s > res <- try(y_smooth <- binCounts(1:10, bx = bx), silent = TRUE) 157s > stopifnot(inherits(res, "try-error")) 157s > 157s > # One bin boundary (invalid bin definition) 157s > bx <- double(1L) 157s > res <- try(y_smooth <- binCounts(1:10, bx = bx), silent = TRUE) 157s > stopifnot(inherits(res, "try-error")) 157s > 157s 157s R version 4.4.3 (2025-02-28) -- "Trophy Case" 157s Copyright (C) 2025 The R Foundation for Statistical Computing 157s Platform: s390x-ibm-linux-gnu 157s 157s R is free software and comes with ABSOLUTELY NO WARRANTY. 157s You are welcome to redistribute it under certain conditions. 157s Type 'license()' or 'licence()' for distribution details. 157s 157s R is a collaborative project with many contributors. 157s Type 'contributors()' for more information and 157s 'citation()' on how to cite R or R packages in publications. 157s 157s Type 'demo()' for some demos, 'help()' for on-line help, or 157s 'help.start()' for an HTML browser interface to help. 157s Type 'q()' to quit R. 157s 158s > library("matrixStats") 158s > 158s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 158s > # Local functions 158s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 158s > binCounts_hist <- function(x, bx, right = FALSE, ...) { 158s + n0 <- graphics::hist(x, breaks = bx, right = right, 158s + include.lowest = TRUE, plot = FALSE)$counts 158s + } 158s > 158s > 158s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 158s > # Subsetted tests 158s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 158s > source("utils/validateIndicesFramework.R") 158s > x <- runif(6, min = -6, max = 6) 158s > storage.mode(x) <- "integer" 158s > bx <- c(-6, 0, 3, 4, 10) 158s > for (idxs in index_cases) { 158s + validateIndicesTestVector(x, idxs, 158s + ftest = binCounts, fsure = binCounts_hist, 158s + bx = bx, right = FALSE) 158s + validateIndicesTestVector(x, idxs, 158s + ftest = binCounts, fsure = binCounts_hist, 158s + bx = bx, right = TRUE) 158s + } 158s > 158s 158s R version 4.4.3 (2025-02-28) -- "Trophy Case" 158s Copyright (C) 2025 The R Foundation for Statistical Computing 158s Platform: s390x-ibm-linux-gnu 158s 158s R is free software and comes with ABSOLUTELY NO WARRANTY. 158s You are welcome to redistribute it under certain conditions. 158s Type 'license()' or 'licence()' for distribution details. 158s 158s R is a collaborative project with many contributors. 158s Type 'contributors()' for more information and 158s 'citation()' on how to cite R or R packages in publications. 158s 158s Type 'demo()' for some demos, 'help()' for on-line help, or 158s 'help.start()' for an HTML browser interface to help. 158s Type 'q()' to quit R. 158s 158s > library("matrixStats") 158s > library("stats") 158s > 158s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 158s > # Naive R implementation of binMeans() 158s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 158s > binMeans0 <- function(y, x, bx, na.rm = TRUE, count = TRUE, right = FALSE) { 158s + n_smooth <- length(bx) - 1L 158s + res <- double(n_smooth) 158s + counts <- rep(NaN, times = n_smooth) 158s + 158s + if (na.rm) { 158s + keep <- !is.na(x) & !is.na(y) 158s + x <- x[keep] 158s + y <- y[keep] 158s + } 158s + 158s + # For each bin... 158s + for (kk in seq_len(n_smooth)) { 158s + if (right) { 158s + idxs <- which(bx[kk] < x & x <= bx[kk + 1L]) 158s + } else { 158s + idxs <- which(bx[kk] <= x & x < bx[kk + 1L]) 158s + } 158s + y_kk <- y[idxs] 158s + res[kk] <- mean(y_kk) 158s + counts[kk] <- length(idxs) 158s + } # for (kk ...) 158s + 158s + if (count) attr(res, "count") <- counts 158s + res 158s + } 158s > 158s > 158s > 158s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 158s > # Case #1 158s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 158s > x <- 1:100 158s > nx <- length(x) 158s > y <- double(nx) 158s > y[1:25] <- 5 158s > y[51:75] <- -5 158s > y <- y + rnorm(nx) 158s > 158s > # Bins 158s > bx <- c(0.5, 25.5, 50.5, 75.5, 100.5) 158s > 158s > y_smooth0 <- binMeans0(y, x = x, bx = bx) 158s > y_smooth <- binMeans(y, x = x, bx = bx) 158s > n_smooth <- binCounts(x, bx = bx) 158s > # Sanity check 158s > stopifnot(all.equal(y_smooth, y_smooth0)) 158s > stopifnot(all.equal(attr(y_smooth, "count"), n_smooth)) 158s > 158s > y_smooth0r <- rev(binMeans0(y, x = -x, bx = rev(-bx), 158s + count = FALSE, right = TRUE)) 158s > y_smoothr <- rev(binMeans(y, x = -x, bx = rev(-bx), 158s + count = FALSE, right = TRUE)) 158s > # Sanity check 158s > stopifnot(all.equal(y_smooth0r, y_smooth0, check.attributes = FALSE)) 158s > stopifnot(all.equal(y_smoothr, y_smooth0r)) 158s > 158s > 158s > # Integer input 158s > y <- as.integer(y) 158s > y_smooth0 <- binMeans0(y, x = x, bx = bx) 158s > y_smooth <- binMeans(y, x = x, bx = bx) 158s > n_smooth <- binCounts(x, bx = bx) 158s > # Sanity check 158s > stopifnot(is.integer(y), 158s + all.equal(y_smooth, y_smooth0), 158s + all.equal(attr(y_smooth, "count"), n_smooth)) 158s > 158s > # Logical input 158s > y <- as.logical(y) 158s > y_smooth0 <- binMeans0(y, x = x, bx = bx) 158s > y_smooth <- binMeans(y, x = x, bx = bx) 158s > n_smooth <- binCounts(x, bx = bx) 158s > # Sanity check 158s > stopifnot(is.logical(y), 158s + all.equal(y_smooth, y_smooth0), 158s + all.equal(attr(y_smooth, "count"), n_smooth)) 158s > 158s > 158s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 158s > # Case #2 158s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 158s > nx <- 1e3 158s > x <- runif(nx) 158s > y <- runif(nx) 158s > 158s > nb <- 10 158s > bx <- do.call(seq, c(as.list(range(x)), length.out = nb)) 158s > bx1 <- c(bx[-1], bx[nb] + 1) 158s > 158s > y_smooth0 <- binMeans0(y, x = x, bx = bx1) 158s > y_smooth <- binMeans(y, x = x, bx = bx1) 158s > n_smooth <- binCounts(x, bx = bx1) 158s > y_smoothr <- rev(binMeans(y, x = -x, bx = rev(-bx1), right = TRUE)) 158s > 158s > # Sanity check 158s > stopifnot(all.equal(y_smooth, y_smooth0)) 158s > stopifnot(all.equal(attr(y_smooth, "count"), n_smooth)) 158s > stopifnot(all.equal(y_smoothr, y_smooth, check.attributes = FALSE)) 158s > 158s > 158s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 158s > # Empty bins 158s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 158s > x <- c(6:8, 16:19) 158s > nx <- length(x) 158s > y <- runif(nx) 158s > bx <- c(0, 5, 10, 15, 20, 25) 158s > y_smooth0 <- binMeans0(y, x = x, bx = bx) 158s > y_smooth <- binMeans(y, x = x, bx = bx) 158s > n_smooth <- binCounts(x, bx = bx) 158s > stopifnot(all.equal(attr(y_smooth, "count"), n_smooth)) 158s > stopifnot(all.equal(y_smooth, y_smooth0)) 158s > 158s > 158s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 158s > # Missing values 158s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 158s > x <- 1:100 158s > x[50] <- NA_integer_ 158s > nx <- length(x) 158s > y <- double(nx) 158s > y[1:25] <- 5 158s > y[51:75] <- -5 158s > y[82:92] <- NA_real_ 158s > y <- y + rnorm(nx) 158s > 158s > # Bins 158s > bx <- c(0.5, 25.5, 75.5, 82.5, 100.5) 158s > 158s > y_smooth0 <- binMeans0(y, x = x, bx = bx) 158s > y_smooth <- binMeans(y, x = x, bx = bx) 158s > # Sanity check 158s > stopifnot(all.equal(y_smooth, y_smooth0)) 158s > 158s > 158s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 158s > # Exception handling 158s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 158s > # Zero bin boundaries (invalid bin definition) 158s > bx <- double(0L) 158s > res <- try(y_smooth <- binMeans(x = 1:5, y = 1:5, bx = bx), silent = TRUE) 158s > stopifnot(inherits(res, "try-error")) 158s > 158s > # One bin boundary (invalid bin definition) 158s > bx <- double(1L) 158s > res <- try(y_smooth <- binMeans(x = 1:5, y = 1:5, bx = bx), silent = TRUE) 158s > stopifnot(inherits(res, "try-error")) 158s > 158s 158s R version 4.4.3 (2025-02-28) -- "Trophy Case" 158s Copyright (C) 2025 The R Foundation for Statistical Computing 158s Platform: s390x-ibm-linux-gnu 158s 158s R is free software and comes with ABSOLUTELY NO WARRANTY. 158s You are welcome to redistribute it under certain conditions. 158s Type 'license()' or 'licence()' for distribution details. 158s 158s R is a collaborative project with many contributors. 158s Type 'contributors()' for more information and 158s 'citation()' on how to cite R or R packages in publications. 158s 158s Type 'demo()' for some demos, 'help()' for on-line help, or 158s 'help.start()' for an HTML browser interface to help. 158s Type 'q()' to quit R. 158s 158s > library("matrixStats") 158s > 158s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 158s > # Naive R implementation of binMeans() 158s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 158s > binMeans0 <- function(y, x, bx, na.rm = TRUE, count = TRUE, right = FALSE) { 158s + n_smooth <- length(bx) - 1L 158s + res <- double(n_smooth) 158s + counts <- rep(NaN, times = n_smooth) 158s + 158s + if (na.rm) { 158s + keep <- !is.na(x) & !is.na(y) 158s + x <- x[keep] 158s + y <- y[keep] 158s + } 158s + 158s + # For each bin... 158s + for (kk in seq_len(n_smooth)) { 158s + if (right) { 158s + idxs <- which(bx[kk] < x & x <= bx[kk + 1L]) 158s + } else { 158s + idxs <- which(bx[kk] <= x & x < bx[kk + 1L]) 158s + } 158s + y_kk <- y[idxs] 158s + res[kk] <- mean(y_kk) 158s + counts[kk] <- length(idxs) 158s + } # for (kk ...) 158s + 158s + if (count) attr(res, "count") <- counts 158s + res 158s + } 158s > 158s > 158s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 158s > # Subsetted tests 158s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 158s > source("utils/validateIndicesFramework.R") 158s > y <- runif(6, min = -6, max = 6) 158s > x <- runif(6, min = -6, max = 6) 158s > storage.mode(x) <- "integer" 158s > bx <- c(-6, 0, 3, 4, 10) 158s > for (idxs in index_cases) { 158s + for (na.rm in c(TRUE, FALSE)) { 158s + validateIndicesTestVector_w(y, x, idxs, 158s + ftest = binMeans, fsure = binMeans0, 158s + bx = bx, na.rm = na.rm, 158s + count = TRUE, right = FALSE) 158s + validateIndicesTestVector_w(y, x, idxs, 158s + ftest = binMeans, fsure = binMeans0, 158s + bx = bx, na.rm = na.rm, 158s + count = TRUE, right = TRUE) 158s + } 158s + } 158s > 158s 158s R version 4.4.3 (2025-02-28) -- "Trophy Case" 158s Copyright (C) 2025 The R Foundation for Statistical Computing 158s Platform: s390x-ibm-linux-gnu 158s 158s R is free software and comes with ABSOLUTELY NO WARRANTY. 158s You are welcome to redistribute it under certain conditions. 158s Type 'license()' or 'licence()' for distribution details. 158s 158s R is a collaborative project with many contributors. 158s Type 'contributors()' for more information and 158s 'citation()' on how to cite R or R packages in publications. 158s 158s Type 'demo()' for some demos, 'help()' for on-line help, or 158s 'help.start()' for an HTML browser interface to help. 158s Type 'q()' to quit R. 158s 158s > library("matrixStats") 158s > 158s > count_R <- function(x, value = TRUE, na.rm = FALSE, ...) { 158s + if (is.na(value)) { 158s + counts <- sum(is.na(x)) 158s + } else { 158s + counts <- sum(x == value, na.rm = na.rm) 158s + } 158s + as.integer(counts) 158s + } 158s > 158s > 158s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 158s > # Data type: integer and numeric 158s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 158s > for (mode in c("integer", "double")) { 158s + x <- runif(20 * 5, min = -3, max = 3) 158s + x[sample.int(length(x), size = 7)] <- 0 158s + storage.mode(x) <- mode 158s + 158s + for (na.rm in c(FALSE, TRUE)) { 158s + # Count zeros 158s + n0 <- count_R(x, value = 0, na.rm = na.rm) 158s + n1 <- count(x, value = 0, na.rm = na.rm) 158s + stopifnot(identical(n1, n0)) 158s + all <- allValue(x, value = 0, na.rm = na.rm) 158s + any <- anyValue(x, value = 0, na.rm = na.rm) 158s + 158s + # Count NAs 158s + n0 <- count_R(x, value = NA, na.rm = na.rm) 158s + n1 <- count(x, value = NA, na.rm = na.rm) 158s + stopifnot(identical(n1, n0)) 158s + all <- allValue(x, value = NA, na.rm = na.rm) 158s + any <- anyValue(x, value = NA, na.rm = na.rm) 158s + 158s + if (mode == "integer") { 158s + ux <- unique(as.vector(x)) 158s + n0 <- n1 <- integer(length(x)) 158s + for (value in ux) { 158s + n0 <- n0 + count_R(x, value = value, na.rm = na.rm) 158s + n1 <- n1 + count(x, value = value, na.rm = na.rm) 158s + stopifnot(identical(n1, n0)) 158s + } 158s + stopifnot(all(n0 == ncol(x))) 158s + } # if (mode == "integer") 158s + 158s + } # for (na.rm ...) 158s + } # for (mode ...) 158s > 158s > # All NAs 158s > na_list <- list(NA_integer_, NA_real_, NaN) 158s > for (na_value in na_list) { 158s + x <- rep(na_value, times = 10L) 158s + for (na.rm in c(FALSE, TRUE)) { 158s + n0 <- count_R(x, na.rm = na.rm) 158s + n1 <- count(x, na.rm = na.rm) 158s + stopifnot(identical(n1, n0)) 158s + 158s + # Count NAs 158s + n0 <- count_R(x, value = NA, na.rm = na.rm) 158s + n1 <- count(x, value = NA, na.rm = na.rm) 158s + stopifnot(identical(n1, n0)) 158s + any <- anyValue(x, value = NA, na.rm = na.rm) 158s + all <- allValue(x, value = NA, na.rm = na.rm) 158s + stopifnot(any) 158s + stopifnot(all) 158s + } 158s + } # for (na_value ...) 158s > 158s > 158s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 158s > # Data type: logical 158s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 158s > x <- logical(length = 10L) 158s > x[3:7] <- TRUE 158s > 158s > # Row/column counts 158s > for (na.rm in c(FALSE, TRUE)) { 158s + n0 <- count_R(x, na.rm = na.rm) 158s + n1 <- count(x, na.rm = na.rm) 158s + stopifnot(identical(n1, n0)) 158s + 158s + n_true <- count(x, value = TRUE, na.rm = na.rm) 158s + n_false <- count(x, value = FALSE, na.rm = na.rm) 158s + stopifnot(n_true + n_false == ncol(x)) 158s + 158s + # Count NAs 158s + n0 <- count_R(x, value = NA, na.rm = na.rm) 158s + n1 <- count(x, value = NA, na.rm = na.rm) 158s + stopifnot(identical(n1, n0)) 158s + } 158s > 158s 158s R version 4.4.3 (2025-02-28) -- "Trophy Case" 158s Copyright (C) 2025 The R Foundation for Statistical Computing 158s Platform: s390x-ibm-linux-gnu 158s 158s R is free software and comes with ABSOLUTELY NO WARRANTY. 158s You are welcome to redistribute it under certain conditions. 158s Type 'license()' or 'licence()' for distribution details. 158s 158s R is a collaborative project with many contributors. 158s Type 'contributors()' for more information and 158s 'citation()' on how to cite R or R packages in publications. 158s 158s Type 'demo()' for some demos, 'help()' for on-line help, or 158s 'help.start()' for an HTML browser interface to help. 158s Type 'q()' to quit R. 158s 158s > library("matrixStats") 158s > 158s > count_R <- function(x, value = TRUE, na.rm = FALSE, ...) { 158s + if (is.na(value)) { 158s + counts <- sum(is.na(x)) 158s + } else { 158s + counts <- sum(x == value, na.rm = na.rm) 158s + } 158s + as.integer(counts) 158s + } 158s > 158s > 158s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 158s > # Subsetted tests 158s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 158s > source("utils/validateIndicesFramework.R") 158s > x <- runif(6, min = -3, max = 3) 158s > storage.mode(x) <- "integer" 158s > for (idxs in index_cases) { 158s + validateIndicesTestVector(x, idxs, 158s + ftest = count, fsure = count_R, 158s + value = 0, na.rm = TRUE) 158s + validateIndicesTestVector(x, idxs, 158s + ftest = count, fsure = count_R, 158s + value = 0, na.rm = FALSE) 158s + validateIndicesTestVector(x, idxs, 158s + ftest = count, fsure = count_R, 158s + value = NA_integer_) 158s + } 158s > 159s 159s R version 4.4.3 (2025-02-28) -- "Trophy Case" 159s Copyright (C) 2025 The R Foundation for Statistical Computing 159s Platform: s390x-ibm-linux-gnu 159s 159s R is free software and comes with ABSOLUTELY NO WARRANTY. 159s You are welcome to redistribute it under certain conditions. 159s Type 'license()' or 'licence()' for distribution details. 159s 159s R is a collaborative project with many contributors. 159s Type 'contributors()' for more information and 159s 'citation()' on how to cite R or R packages in publications. 159s 159s Type 'demo()' for some demos, 'help()' for on-line help, or 159s 'help.start()' for an HTML browser interface to help. 159s Type 'q()' to quit R. 159s 159s > library("matrixStats") 159s > 159s > diff2_R <- function(..., useNames = TRUE){ 159s + res <- diff(...) 159s + if (!useNames) names(res) <- NULL 159s + res 159s + } 159s > 159s > set.seed(0x42) 159s > 159s > for (mode in c("integer", "double")) { 159s + x <- rnorm(10, sd = 5) 159s + storage.mode(x) <- mode 159s + str(x) 159s + 159s + for (has_na in c(FALSE, TRUE)) { 159s + for (setNames in c(TRUE, FALSE)) { 159s + for (useNames in c(TRUE, FALSE)) { 159s + if (has_na) { 159s + x[sample(1:10, size = 3)] <- NA 159s + } 159s + if (setNames) { 159s + names(x) <- LETTERS[1:10] 159s + } 159s + for (l in 1:3) { 159s + for (d in 1:4) { 159s + cat(sprintf("%s: NAs = %s, lag = %d, differences = %d, setNames = %d, useNames = %d\n", 159s + mode, has_na, l, d, setNames, useNames)) 159s + y0 <- diff2_R(x, lag = l, differences = d, useNames = useNames) 159s + str(y0) 159s + y1 <- diff2(x, lag = l, differences = d, useNames = useNames) 159s + str(y1) 159s + stopifnot(identical(y1, y0)) 159s + } 159s + } 159s + } 159s + } 159s + } # for (has_na ...) 159s + } 159s int [1:10] 11 1 2 0 -1 -3 -3 6 0 0 159s integer: NAs = FALSE, lag = 1, differences = 1, setNames = 1, useNames = 1 159s Named int [1:9] -10 1 -2 -1 -2 0 9 -6 0 159s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 159s Named int [1:9] -10 1 -2 -1 -2 0 9 -6 0 159s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 159s integer: NAs = FALSE, lag = 1, differences = 2, setNames = 1, useNames = 1 159s Named int [1:8] 11 -3 1 -1 2 9 -15 6 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s Named int [1:8] 11 -3 1 -1 2 9 -15 6 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s integer: NAs = FALSE, lag = 1, differences = 3, setNames = 1, useNames = 1 159s Named int [1:7] -14 4 -2 3 7 -24 21 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s Named int [1:7] -14 4 -2 3 7 -24 21 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s integer: NAs = FALSE, lag = 1, differences = 4, setNames = 1, useNames = 1 159s Named int [1:6] 18 -6 5 4 -31 45 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s Named int [1:6] 18 -6 5 4 -31 45 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s integer: NAs = FALSE, lag = 2, differences = 1, setNames = 1, useNames = 1 159s Named int [1:8] -9 -1 -3 -3 -2 9 3 -6 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s Named int [1:8] -9 -1 -3 -3 -2 9 3 -6 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s integer: NAs = FALSE, lag = 2, differences = 2, setNames = 1, useNames = 1 159s Named int [1:6] 6 -2 1 12 5 -15 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s Named int [1:6] 6 -2 1 12 5 -15 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s integer: NAs = FALSE, lag = 2, differences = 3, setNames = 1, useNames = 1 159s Named int [1:4] -5 14 4 -27 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s Named int [1:4] -5 14 4 -27 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s integer: NAs = FALSE, lag = 2, differences = 4, setNames = 1, useNames = 1 159s Named int [1:2] 9 -41 159s - attr(*, "names")= chr [1:2] "I" "J" 159s Named int [1:2] 9 -41 159s - attr(*, "names")= chr [1:2] "I" "J" 159s integer: NAs = FALSE, lag = 3, differences = 1, setNames = 1, useNames = 1 159s Named int [1:7] -11 -2 -5 -3 7 3 3 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s Named int [1:7] -11 -2 -5 -3 7 3 3 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s integer: NAs = FALSE, lag = 3, differences = 2, setNames = 1, useNames = 1 159s Named int [1:4] 8 9 8 6 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s Named int [1:4] 8 9 8 6 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s integer: NAs = FALSE, lag = 3, differences = 3, setNames = 1, useNames = 1 159s Named int -2 159s - attr(*, "names")= chr "J" 159s Named int -2 159s - attr(*, "names")= chr "J" 159s integer: NAs = FALSE, lag = 3, differences = 4, setNames = 1, useNames = 1 159s Named int(0) 159s - attr(*, "names")= chr(0) 159s Named int(0) 159s - attr(*, "names")= chr(0) 159s integer: NAs = FALSE, lag = 1, differences = 1, setNames = 1, useNames = 0 159s int [1:9] -10 1 -2 -1 -2 0 9 -6 0 159s int [1:9] -10 1 -2 -1 -2 0 9 -6 0 159s integer: NAs = FALSE, lag = 1, differences = 2, setNames = 1, useNames = 0 159s int [1:8] 11 -3 1 -1 2 9 -15 6 159s int [1:8] 11 -3 1 -1 2 9 -15 6 159s integer: NAs = FALSE, lag = 1, differences = 3, setNames = 1, useNames = 0 159s int [1:7] -14 4 -2 3 7 -24 21 159s int [1:7] -14 4 -2 3 7 -24 21 159s integer: NAs = FALSE, lag = 1, differences = 4, setNames = 1, useNames = 0 159s int [1:6] 18 -6 5 4 -31 45 159s int [1:6] 18 -6 5 4 -31 45 159s integer: NAs = FALSE, lag = 2, differences = 1, setNames = 1, useNames = 0 159s int [1:8] -9 -1 -3 -3 -2 9 3 -6 159s int [1:8] -9 -1 -3 -3 -2 9 3 -6 159s integer: NAs = FALSE, lag = 2, differences = 2, setNames = 1, useNames = 0 159s int [1:6] 6 -2 1 12 5 -15 159s int [1:6] 6 -2 1 12 5 -15 159s integer: NAs = FALSE, lag = 2, differences = 3, setNames = 1, useNames = 0 159s int [1:4] -5 14 4 -27 159s int [1:4] -5 14 4 -27 159s integer: NAs = FALSE, lag = 2, differences = 4, setNames = 1, useNames = 0 159s int [1:2] 9 -41 159s int [1:2] 9 -41 159s integer: NAs = FALSE, lag = 3, differences = 1, setNames = 1, useNames = 0 159s int [1:7] -11 -2 -5 -3 7 3 3 159s int [1:7] -11 -2 -5 -3 7 3 3 159s integer: NAs = FALSE, lag = 3, differences = 2, setNames = 1, useNames = 0 159s int [1:4] 8 9 8 6 159s int [1:4] 8 9 8 6 159s integer: NAs = FALSE, lag = 3, differences = 3, setNames = 1, useNames = 0 159s int -2 159s int -2 159s integer: NAs = FALSE, lag = 3, differences = 4, setNames = 1, useNames = 0 159s int(0) 159s int(0) 159s integer: NAs = FALSE, lag = 1, differences = 1, setNames = 0, useNames = 1 159s Named int [1:9] -10 1 -2 -1 -2 0 9 -6 0 159s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 159s Named int [1:9] -10 1 -2 -1 -2 0 9 -6 0 159s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 159s integer: NAs = FALSE, lag = 1, differences = 2, setNames = 0, useNames = 1 159s Named int [1:8] 11 -3 1 -1 2 9 -15 6 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s Named int [1:8] 11 -3 1 -1 2 9 -15 6 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s integer: NAs = FALSE, lag = 1, differences = 3, setNames = 0, useNames = 1 159s Named int [1:7] -14 4 -2 3 7 -24 21 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s Named int [1:7] -14 4 -2 3 7 -24 21 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s integer: NAs = FALSE, lag = 1, differences = 4, setNames = 0, useNames = 1 159s Named int [1:6] 18 -6 5 4 -31 45 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s Named int [1:6] 18 -6 5 4 -31 45 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s integer: NAs = FALSE, lag = 2, differences = 1, setNames = 0, useNames = 1 159s Named int [1:8] -9 -1 -3 -3 -2 9 3 -6 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s Named int [1:8] -9 -1 -3 -3 -2 9 3 -6 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s integer: NAs = FALSE, lag = 2, differences = 2, setNames = 0, useNames = 1 159s Named int [1:6] 6 -2 1 12 5 -15 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s Named int [1:6] 6 -2 1 12 5 -15 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s integer: NAs = FALSE, lag = 2, differences = 3, setNames = 0, useNames = 1 159s Named int [1:4] -5 14 4 -27 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s Named int [1:4] -5 14 4 -27 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s integer: NAs = FALSE, lag = 2, differences = 4, setNames = 0, useNames = 1 159s Named int [1:2] 9 -41 159s - attr(*, "names")= chr [1:2] "I" "J" 159s Named int [1:2] 9 -41 159s - attr(*, "names")= chr [1:2] "I" "J" 159s integer: NAs = FALSE, lag = 3, differences = 1, setNames = 0, useNames = 1 159s Named int [1:7] -11 -2 -5 -3 7 3 3 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s Named int [1:7] -11 -2 -5 -3 7 3 3 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s integer: NAs = FALSE, lag = 3, differences = 2, setNames = 0, useNames = 1 159s Named int [1:4] 8 9 8 6 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s Named int [1:4] 8 9 8 6 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s integer: NAs = FALSE, lag = 3, differences = 3, setNames = 0, useNames = 1 159s Named int -2 159s - attr(*, "names")= chr "J" 159s Named int -2 159s - attr(*, "names")= chr "J" 159s integer: NAs = FALSE, lag = 3, differences = 4, setNames = 0, useNames = 1 159s Named int(0) 159s - attr(*, "names")= chr(0) 159s Named int(0) 159s - attr(*, "names")= chr(0) 159s integer: NAs = FALSE, lag = 1, differences = 1, setNames = 0, useNames = 0 159s int [1:9] -10 1 -2 -1 -2 0 9 -6 0 159s int [1:9] -10 1 -2 -1 -2 0 9 -6 0 159s integer: NAs = FALSE, lag = 1, differences = 2, setNames = 0, useNames = 0 159s int [1:8] 11 -3 1 -1 2 9 -15 6 159s int [1:8] 11 -3 1 -1 2 9 -15 6 159s integer: NAs = FALSE, lag = 1, differences = 3, setNames = 0, useNames = 0 159s int [1:7] -14 4 -2 3 7 -24 21 159s int [1:7] -14 4 -2 3 7 -24 21 159s integer: NAs = FALSE, lag = 1, differences = 4, setNames = 0, useNames = 0 159s int [1:6] 18 -6 5 4 -31 45 159s int [1:6] 18 -6 5 4 -31 45 159s integer: NAs = FALSE, lag = 2, differences = 1, setNames = 0, useNames = 0 159s int [1:8] -9 -1 -3 -3 -2 9 3 -6 159s int [1:8] -9 -1 -3 -3 -2 9 3 -6 159s integer: NAs = FALSE, lag = 2, differences = 2, setNames = 0, useNames = 0 159s int [1:6] 6 -2 1 12 5 -15 159s int [1:6] 6 -2 1 12 5 -15 159s integer: NAs = FALSE, lag = 2, differences = 3, setNames = 0, useNames = 0 159s int [1:4] -5 14 4 -27 159s int [1:4] -5 14 4 -27 159s integer: NAs = FALSE, lag = 2, differences = 4, setNames = 0, useNames = 0 159s int [1:2] 9 -41 159s int [1:2] 9 -41 159s integer: NAs = FALSE, lag = 3, differences = 1, setNames = 0, useNames = 0 159s int [1:7] -11 -2 -5 -3 7 3 3 159s int [1:7] -11 -2 -5 -3 7 3 3 159s integer: NAs = FALSE, lag = 3, differences = 2, setNames = 0, useNames = 0 159s int [1:4] 8 9 8 6 159s int [1:4] 8 9 8 6 159s integer: NAs = FALSE, lag = 3, differences = 3, setNames = 0, useNames = 0 159s int -2 159s int -2 159s integer: NAs = FALSE, lag = 3, differences = 4, setNames = 0, useNames = 0 159s int(0) 159s int(0) 159s integer: NAs = TRUE, lag = 1, differences = 1, setNames = 1, useNames = 1 159s Named int [1:9] NA NA NA NA NA 0 9 -6 0 159s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 159s Named int [1:9] NA NA NA NA NA 0 9 -6 0 159s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 159s integer: NAs = TRUE, lag = 1, differences = 2, setNames = 1, useNames = 1 159s Named int [1:8] NA NA NA NA NA 9 -15 6 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s Named int [1:8] NA NA NA NA NA 9 -15 6 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s integer: NAs = TRUE, lag = 1, differences = 3, setNames = 1, useNames = 1 159s Named int [1:7] NA NA NA NA NA -24 21 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s Named int [1:7] NA NA NA NA NA -24 21 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s integer: NAs = TRUE, lag = 1, differences = 4, setNames = 1, useNames = 1 159s Named int [1:6] NA NA NA NA NA 45 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s Named int [1:6] NA NA NA NA NA 45 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s integer: NAs = TRUE, lag = 2, differences = 1, setNames = 1, useNames = 1 159s Named int [1:8] -9 NA NA NA NA 9 3 -6 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s Named int [1:8] -9 NA NA NA NA 9 3 -6 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s integer: NAs = TRUE, lag = 2, differences = 2, setNames = 1, useNames = 1 159s Named int [1:6] NA NA NA NA NA -15 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s Named int [1:6] NA NA NA NA NA -15 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s integer: NAs = TRUE, lag = 2, differences = 3, setNames = 1, useNames = 1 159s Named int [1:4] NA NA NA NA 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s Named int [1:4] NA NA NA NA 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s integer: NAs = TRUE, lag = 2, differences = 4, setNames = 1, useNames = 1 159s Named int [1:2] NA NA 159s - attr(*, "names")= chr [1:2] "I" "J" 159s Named int [1:2] NA NA 159s - attr(*, "names")= chr [1:2] "I" "J" 159s integer: NAs = TRUE, lag = 3, differences = 1, setNames = 1, useNames = 1 159s Named int [1:7] NA NA -5 NA NA 3 3 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s Named int [1:7] NA NA -5 NA NA 3 3 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s integer: NAs = TRUE, lag = 3, differences = 2, setNames = 1, useNames = 1 159s Named int [1:4] NA NA 8 NA 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s Named int [1:4] NA NA 8 NA 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s integer: NAs = TRUE, lag = 3, differences = 3, setNames = 1, useNames = 1 159s Named int NA 159s - attr(*, "names")= chr "J" 159s Named int NA 159s - attr(*, "names")= chr "J" 159s integer: NAs = TRUE, lag = 3, differences = 4, setNames = 1, useNames = 1 159s Named int(0) 159s - attr(*, "names")= chr(0) 159s Named int(0) 159s - attr(*, "names")= chr(0) 159s integer: NAs = TRUE, lag = 1, differences = 1, setNames = 1, useNames = 0 159s int [1:9] NA NA NA NA NA 0 9 NA NA 159s int [1:9] NA NA NA NA NA 0 9 NA NA 159s integer: NAs = TRUE, lag = 1, differences = 2, setNames = 1, useNames = 0 159s int [1:8] NA NA NA NA NA 9 NA NA 159s int [1:8] NA NA NA NA NA 9 NA NA 159s integer: NAs = TRUE, lag = 1, differences = 3, setNames = 1, useNames = 0 159s int [1:7] NA NA NA NA NA NA NA 159s int [1:7] NA NA NA NA NA NA NA 159s integer: NAs = TRUE, lag = 1, differences = 4, setNames = 1, useNames = 0 159s int [1:6] NA NA NA NA NA NA 159s int [1:6] NA NA NA NA NA NA 159s integer: NAs = TRUE, lag = 2, differences = 1, setNames = 1, useNames = 0 159s int [1:8] NA NA NA NA NA 9 NA -6 159s int [1:8] NA NA NA NA NA 9 NA -6 159s integer: NAs = TRUE, lag = 2, differences = 2, setNames = 1, useNames = 0 159s int [1:6] NA NA NA NA NA -15 159s int [1:6] NA NA NA NA NA -15 159s integer: NAs = TRUE, lag = 2, differences = 3, setNames = 1, useNames = 0 159s int [1:4] NA NA NA NA 159s int [1:4] NA NA NA NA 159s integer: NAs = TRUE, lag = 2, differences = 4, setNames = 1, useNames = 0 159s int [1:2] NA NA 159s int [1:2] NA NA 159s integer: NAs = TRUE, lag = 3, differences = 1, setNames = 1, useNames = 0 159s int [1:7] NA NA NA NA NA NA 3 159s int [1:7] NA NA NA NA NA NA 3 159s integer: NAs = TRUE, lag = 3, differences = 2, setNames = 1, useNames = 0 159s int [1:4] NA NA NA NA 159s int [1:4] NA NA NA NA 159s integer: NAs = TRUE, lag = 3, differences = 3, setNames = 1, useNames = 0 159s int NA 159s int NA 159s integer: NAs = TRUE, lag = 3, differences = 4, setNames = 1, useNames = 0 159s int(0) 159s int(0) 159s integer: NAs = TRUE, lag = 1, differences = 1, setNames = 0, useNames = 1 159s Named int [1:9] NA NA NA NA NA NA NA NA NA 159s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 159s Named int [1:9] NA NA NA NA NA NA NA NA NA 159s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 159s integer: NAs = TRUE, lag = 1, differences = 2, setNames = 0, useNames = 1 159s Named int [1:8] NA NA NA NA NA NA NA NA 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s Named int [1:8] NA NA NA NA NA NA NA NA 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s integer: NAs = TRUE, lag = 1, differences = 3, setNames = 0, useNames = 1 159s Named int [1:7] NA NA NA NA NA NA NA 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s Named int [1:7] NA NA NA NA NA NA NA 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s integer: NAs = TRUE, lag = 1, differences = 4, setNames = 0, useNames = 1 159s Named int [1:6] NA NA NA NA NA NA 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s Named int [1:6] NA NA NA NA NA NA 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s integer: NAs = TRUE, lag = 2, differences = 1, setNames = 0, useNames = 1 159s Named int [1:8] NA NA NA NA NA NA NA NA 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s Named int [1:8] NA NA NA NA NA NA NA NA 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s integer: NAs = TRUE, lag = 2, differences = 2, setNames = 0, useNames = 1 159s Named int [1:6] NA NA NA NA NA NA 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s Named int [1:6] NA NA NA NA NA NA 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s integer: NAs = TRUE, lag = 2, differences = 3, setNames = 0, useNames = 1 159s Named int [1:4] NA NA NA NA 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s Named int [1:4] NA NA NA NA 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s integer: NAs = TRUE, lag = 2, differences = 4, setNames = 0, useNames = 1 159s Named int [1:2] NA NA 159s - attr(*, "names")= chr [1:2] "I" "J" 159s Named int [1:2] NA NA 159s - attr(*, "names")= chr [1:2] "I" "J" 159s integer: NAs = TRUE, lag = 3, differences = 1, setNames = 0, useNames = 1 159s Named int [1:7] NA NA NA NA NA NA 3 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s Named int [1:7] NA NA NA NA NA NA 3 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s integer: NAs = TRUE, lag = 3, differences = 2, setNames = 0, useNames = 1 159s Named int [1:4] NA NA NA NA 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s Named int [1:4] NA NA NA NA 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s integer: NAs = TRUE, lag = 3, differences = 3, setNames = 0, useNames = 1 159s Named int NA 159s - attr(*, "names")= chr "J" 159s Named int NA 159s - attr(*, "names")= chr "J" 159s integer: NAs = TRUE, lag = 3, differences = 4, setNames = 0, useNames = 1 159s Named int(0) 159s - attr(*, "names")= chr(0) 159s Named int(0) 159s - attr(*, "names")= chr(0) 159s integer: NAs = TRUE, lag = 1, differences = 1, setNames = 0, useNames = 0 159s int [1:9] NA NA NA NA NA NA NA NA NA 159s int [1:9] NA NA NA NA NA NA NA NA NA 159s integer: NAs = TRUE, lag = 1, differences = 2, setNames = 0, useNames = 0 159s int [1:8] NA NA NA NA NA NA NA NA 159s int [1:8] NA NA NA NA NA NA NA NA 159s integer: NAs = TRUE, lag = 1, differences = 3, setNames = 0, useNames = 0 159s int [1:7] NA NA NA NA NA NA NA 159s int [1:7] NA NA NA NA NA NA NA 159s integer: NAs = TRUE, lag = 1, differences = 4, setNames = 0, useNames = 0 159s int [1:6] NA NA NA NA NA NA 159s int [1:6] NA NA NA NA NA NA 159s integer: NAs = TRUE, lag = 2, differences = 1, setNames = 0, useNames = 0 159s int [1:8] NA NA NA NA NA NA NA NA 159s int [1:8] NA NA NA NA NA NA NA NA 159s integer: NAs = TRUE, lag = 2, differences = 2, setNames = 0, useNames = 0 159s int [1:6] NA NA NA NA NA NA 159s int [1:6] NA NA NA NA NA NA 159s integer: NAs = TRUE, lag = 2, differences = 3, setNames = 0, useNames = 0 159s int [1:4] NA NA NA NA 159s int [1:4] NA NA NA NA 159s integer: NAs = TRUE, lag = 2, differences = 4, setNames = 0, useNames = 0 159s int [1:2] NA NA 159s int [1:2] NA NA 159s integer: NAs = TRUE, lag = 3, differences = 1, setNames = 0, useNames = 0 159s int [1:7] NA NA NA NA NA NA 3 159s int [1:7] NA NA NA NA NA NA 3 159s integer: NAs = TRUE, lag = 3, differences = 2, setNames = 0, useNames = 0 159s int [1:4] NA NA NA NA 159s int [1:4] NA NA NA NA 159s integer: NAs = TRUE, lag = 3, differences = 3, setNames = 0, useNames = 0 159s int NA 159s int NA 159s integer: NAs = TRUE, lag = 3, differences = 4, setNames = 0, useNames = 0 159s int(0) 159s int(0) 159s num [1:10] 2.586 -0.344 0.33 9.155 -3.254 ... 159s double: NAs = FALSE, lag = 1, differences = 1, setNames = 1, useNames = 1 159s Named num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 159s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 159s Named num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 159s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 159s double: NAs = FALSE, lag = 1, differences = 2, setNames = 1, useNames = 1 159s Named num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s Named num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s double: NAs = FALSE, lag = 1, differences = 3, setNames = 1, useNames = 1 159s Named num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s Named num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s double: NAs = FALSE, lag = 1, differences = 4, setNames = 1, useNames = 1 159s Named num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s Named num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s double: NAs = FALSE, lag = 2, differences = 1, setNames = 1, useNames = 1 159s Named num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s Named num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s double: NAs = FALSE, lag = 2, differences = 2, setNames = 1, useNames = 1 159s Named num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s Named num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s double: NAs = FALSE, lag = 2, differences = 3, setNames = 1, useNames = 1 159s Named num [1:4] 0.368 42.988 15.396 -29.313 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s Named num [1:4] 0.368 42.988 15.396 -29.313 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s double: NAs = FALSE, lag = 2, differences = 4, setNames = 1, useNames = 1 159s Named num [1:2] 15 -72.3 159s - attr(*, "names")= chr [1:2] "I" "J" 159s Named num [1:2] 15 -72.3 159s - attr(*, "names")= chr [1:2] "I" "J" 159s double: NAs = FALSE, lag = 3, differences = 1, setNames = 1, useNames = 1 159s Named num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s Named num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s double: NAs = FALSE, lag = 3, differences = 2, setNames = 1, useNames = 1 159s Named num [1:4] -23.52 7.92 11.38 23.27 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s Named num [1:4] -23.52 7.92 11.38 23.27 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s double: NAs = FALSE, lag = 3, differences = 3, setNames = 1, useNames = 1 159s Named num 46.8 159s - attr(*, "names")= chr "J" 159s Named num 46.8 159s - attr(*, "names")= chr "J" 159s double: NAs = FALSE, lag = 3, differences = 4, setNames = 1, useNames = 1 159s Named num(0) 159s - attr(*, "names")= chr(0) 159s Named num(0) 159s - attr(*, "names")= chr(0) 159s double: NAs = FALSE, lag = 1, differences = 1, setNames = 1, useNames = 0 159s num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 159s num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 159s double: NAs = FALSE, lag = 1, differences = 2, setNames = 1, useNames = 0 159s num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 159s num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 159s double: NAs = FALSE, lag = 1, differences = 3, setNames = 1, useNames = 0 159s num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 159s num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 159s double: NAs = FALSE, lag = 1, differences = 4, setNames = 1, useNames = 0 159s num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 159s num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 159s double: NAs = FALSE, lag = 2, differences = 1, setNames = 1, useNames = 0 159s num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 159s num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 159s double: NAs = FALSE, lag = 2, differences = 2, setNames = 1, useNames = 0 159s num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 159s num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 159s double: NAs = FALSE, lag = 2, differences = 3, setNames = 1, useNames = 0 159s num [1:4] 0.368 42.988 15.396 -29.313 159s num [1:4] 0.368 42.988 15.396 -29.313 159s double: NAs = FALSE, lag = 2, differences = 4, setNames = 1, useNames = 0 159s num [1:2] 15 -72.3 159s num [1:2] 15 -72.3 159s double: NAs = FALSE, lag = 3, differences = 1, setNames = 1, useNames = 0 159s num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 159s num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 159s double: NAs = FALSE, lag = 3, differences = 2, setNames = 1, useNames = 0 159s num [1:4] -23.52 7.92 11.38 23.27 159s num [1:4] -23.52 7.92 11.38 23.27 159s double: NAs = FALSE, lag = 3, differences = 3, setNames = 1, useNames = 0 159s num 46.8 159s num 46.8 159s double: NAs = FALSE, lag = 3, differences = 4, setNames = 1, useNames = 0 159s num(0) 159s num(0) 159s double: NAs = FALSE, lag = 1, differences = 1, setNames = 0, useNames = 1 159s Named num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 159s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 159s Named num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 159s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 159s double: NAs = FALSE, lag = 1, differences = 2, setNames = 0, useNames = 1 159s Named num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s Named num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s double: NAs = FALSE, lag = 1, differences = 3, setNames = 0, useNames = 1 159s Named num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s Named num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s double: NAs = FALSE, lag = 1, differences = 4, setNames = 0, useNames = 1 159s Named num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s Named num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s double: NAs = FALSE, lag = 2, differences = 1, setNames = 0, useNames = 1 159s Named num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s Named num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s double: NAs = FALSE, lag = 2, differences = 2, setNames = 0, useNames = 1 159s Named num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s Named num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s double: NAs = FALSE, lag = 2, differences = 3, setNames = 0, useNames = 1 159s Named num [1:4] 0.368 42.988 15.396 -29.313 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s Named num [1:4] 0.368 42.988 15.396 -29.313 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s double: NAs = FALSE, lag = 2, differences = 4, setNames = 0, useNames = 1 159s Named num [1:2] 15 -72.3 159s - attr(*, "names")= chr [1:2] "I" "J" 159s Named num [1:2] 15 -72.3 159s - attr(*, "names")= chr [1:2] "I" "J" 159s double: NAs = FALSE, lag = 3, differences = 1, setNames = 0, useNames = 1 159s Named num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s Named num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s double: NAs = FALSE, lag = 3, differences = 2, setNames = 0, useNames = 1 159s Named num [1:4] -23.52 7.92 11.38 23.27 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s Named num [1:4] -23.52 7.92 11.38 23.27 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s double: NAs = FALSE, lag = 3, differences = 3, setNames = 0, useNames = 1 159s Named num 46.8 159s - attr(*, "names")= chr "J" 159s Named num 46.8 159s - attr(*, "names")= chr "J" 159s double: NAs = FALSE, lag = 3, differences = 4, setNames = 0, useNames = 1 159s Named num(0) 159s - attr(*, "names")= chr(0) 159s Named num(0) 159s - attr(*, "names")= chr(0) 159s double: NAs = FALSE, lag = 1, differences = 1, setNames = 0, useNames = 0 159s num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 159s num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 159s double: NAs = FALSE, lag = 1, differences = 2, setNames = 0, useNames = 0 159s num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 159s num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 159s double: NAs = FALSE, lag = 1, differences = 3, setNames = 0, useNames = 0 159s num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 159s num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 159s double: NAs = FALSE, lag = 1, differences = 4, setNames = 0, useNames = 0 159s num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 159s num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 159s double: NAs = FALSE, lag = 2, differences = 1, setNames = 0, useNames = 0 159s num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 159s num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 159s double: NAs = FALSE, lag = 2, differences = 2, setNames = 0, useNames = 0 159s num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 159s num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 159s double: NAs = FALSE, lag = 2, differences = 3, setNames = 0, useNames = 0 159s num [1:4] 0.368 42.988 15.396 -29.313 159s num [1:4] 0.368 42.988 15.396 -29.313 159s double: NAs = FALSE, lag = 2, differences = 4, setNames = 0, useNames = 0 159s num [1:2] 15 -72.3 159s num [1:2] 15 -72.3 159s double: NAs = FALSE, lag = 3, differences = 1, setNames = 0, useNames = 0 159s num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 159s num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 159s double: NAs = FALSE, lag = 3, differences = 2, setNames = 0, useNames = 0 159s num [1:4] -23.52 7.92 11.38 23.27 159s num [1:4] -23.52 7.92 11.38 23.27 159s double: NAs = FALSE, lag = 3, differences = 3, setNames = 0, useNames = 0 159s num 46.8 159s num 46.8 159s double: NAs = FALSE, lag = 3, differences = 4, setNames = 0, useNames = 0 159s num(0) 159s num(0) 159s double: NAs = TRUE, lag = 1, differences = 1, setNames = 1, useNames = 1 159s Named num [1:9] -2.929 0.673 8.826 NA NA ... 159s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 159s Named num [1:9] -2.929 0.673 8.826 NA NA ... 159s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 159s double: NAs = TRUE, lag = 1, differences = 2, setNames = 1, useNames = 1 159s Named num [1:8] 3.6 8.15 NA NA NA ... 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s Named num [1:8] 3.6 8.15 NA NA NA ... 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s double: NAs = TRUE, lag = 1, differences = 3, setNames = 1, useNames = 1 159s Named num [1:7] 4.55 NA NA NA NA ... 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s Named num [1:7] 4.55 NA NA NA NA ... 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s double: NAs = TRUE, lag = 1, differences = 4, setNames = 1, useNames = 1 159s Named num [1:6] NA NA NA NA NA NA 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s Named num [1:6] NA NA NA NA NA NA 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s double: NAs = TRUE, lag = 2, differences = 1, setNames = 1, useNames = 1 159s Named num [1:8] -2.26 9.5 NA NA NA ... 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s Named num [1:8] -2.26 9.5 NA NA NA ... 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s double: NAs = TRUE, lag = 2, differences = 2, setNames = 1, useNames = 1 159s Named num [1:6] NA NA NA NA NA NA 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s Named num [1:6] NA NA NA NA NA NA 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s double: NAs = TRUE, lag = 2, differences = 3, setNames = 1, useNames = 1 159s Named num [1:4] NA NA NA NA 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s Named num [1:4] NA NA NA NA 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s double: NAs = TRUE, lag = 2, differences = 4, setNames = 1, useNames = 1 159s Named num [1:2] NA NA 159s - attr(*, "names")= chr [1:2] "I" "J" 159s Named num [1:2] NA NA 159s - attr(*, "names")= chr [1:2] "I" "J" 159s double: NAs = TRUE, lag = 3, differences = 1, setNames = 1, useNames = 1 159s Named num [1:7] 6.57 NA NA -16.95 NA ... 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s Named num [1:7] 6.57 NA NA -16.95 NA ... 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s double: NAs = TRUE, lag = 3, differences = 2, setNames = 1, useNames = 1 159s Named num [1:4] -23.5 NA NA 23.3 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s Named num [1:4] -23.5 NA NA 23.3 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s double: NAs = TRUE, lag = 3, differences = 3, setNames = 1, useNames = 1 159s Named num 46.8 159s - attr(*, "names")= chr "J" 159s Named num 46.8 159s - attr(*, "names")= chr "J" 159s double: NAs = TRUE, lag = 3, differences = 4, setNames = 1, useNames = 1 159s Named num(0) 159s - attr(*, "names")= chr(0) 159s Named num(0) 159s - attr(*, "names")= chr(0) 159s double: NAs = TRUE, lag = 1, differences = 1, setNames = 1, useNames = 0 159s num [1:9] NA 0.673 8.826 NA NA ... 159s num [1:9] NA 0.673 8.826 NA NA ... 159s double: NAs = TRUE, lag = 1, differences = 2, setNames = 1, useNames = 0 159s num [1:8] NA 8.15 NA NA NA ... 159s num [1:8] NA 8.15 NA NA NA ... 159s double: NAs = TRUE, lag = 1, differences = 3, setNames = 1, useNames = 0 159s num [1:7] NA NA NA NA NA NA NA 159s num [1:7] NA NA NA NA NA NA NA 159s double: NAs = TRUE, lag = 1, differences = 4, setNames = 1, useNames = 0 159s num [1:6] NA NA NA NA NA NA 159s num [1:6] NA NA NA NA NA NA 159s double: NAs = TRUE, lag = 2, differences = 1, setNames = 1, useNames = 0 159s num [1:8] NA 9.5 NA NA NA ... 159s num [1:8] NA 9.5 NA NA NA ... 159s double: NAs = TRUE, lag = 2, differences = 2, setNames = 1, useNames = 0 159s num [1:6] NA NA NA NA NA NA 159s num [1:6] NA NA NA NA NA NA 159s double: NAs = TRUE, lag = 2, differences = 3, setNames = 1, useNames = 0 159s num [1:4] NA NA NA NA 159s num [1:4] NA NA NA NA 159s double: NAs = TRUE, lag = 2, differences = 4, setNames = 1, useNames = 0 159s num [1:2] NA NA 159s num [1:2] NA NA 159s double: NAs = TRUE, lag = 3, differences = 1, setNames = 1, useNames = 0 159s num [1:7] NA NA NA NA NA NA NA 159s num [1:7] NA NA NA NA NA NA NA 159s double: NAs = TRUE, lag = 3, differences = 2, setNames = 1, useNames = 0 159s num [1:4] NA NA NA NA 159s num [1:4] NA NA NA NA 159s double: NAs = TRUE, lag = 3, differences = 3, setNames = 1, useNames = 0 159s num NA 159s num NA 159s double: NAs = TRUE, lag = 3, differences = 4, setNames = 1, useNames = 0 159s num(0) 159s num(0) 159s double: NAs = TRUE, lag = 1, differences = 1, setNames = 0, useNames = 1 159s Named num [1:9] NA 0.673 8.826 NA NA ... 159s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 159s Named num [1:9] NA 0.673 8.826 NA NA ... 159s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 159s double: NAs = TRUE, lag = 1, differences = 2, setNames = 0, useNames = 1 159s Named num [1:8] NA 8.15 NA NA NA ... 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s Named num [1:8] NA 8.15 NA NA NA ... 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s double: NAs = TRUE, lag = 1, differences = 3, setNames = 0, useNames = 1 159s Named num [1:7] NA NA NA NA NA NA NA 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s Named num [1:7] NA NA NA NA NA NA NA 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s double: NAs = TRUE, lag = 1, differences = 4, setNames = 0, useNames = 1 159s Named num [1:6] NA NA NA NA NA NA 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s Named num [1:6] NA NA NA NA NA NA 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s double: NAs = TRUE, lag = 2, differences = 1, setNames = 0, useNames = 1 159s Named num [1:8] NA 9.5 NA NA NA ... 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s Named num [1:8] NA 9.5 NA NA NA ... 159s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 159s double: NAs = TRUE, lag = 2, differences = 2, setNames = 0, useNames = 1 159s Named num [1:6] NA NA NA NA NA NA 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s Named num [1:6] NA NA NA NA NA NA 159s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 159s double: NAs = TRUE, lag = 2, differences = 3, setNames = 0, useNames = 1 159s Named num [1:4] NA NA NA NA 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s Named num [1:4] NA NA NA NA 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s double: NAs = TRUE, lag = 2, differences = 4, setNames = 0, useNames = 1 159s Named num [1:2] NA NA 159s - attr(*, "names")= chr [1:2] "I" "J" 159s Named num [1:2] NA NA 159s - attr(*, "names")= chr [1:2] "I" "J" 159s double: NAs = TRUE, lag = 3, differences = 1, setNames = 0, useNames = 1 159s Named num [1:7] NA NA NA NA NA NA NA 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s Named num [1:7] NA NA NA NA NA NA NA 159s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 159s double: NAs = TRUE, lag = 3, differences = 2, setNames = 0, useNames = 1 159s Named num [1:4] NA NA NA NA 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s Named num [1:4] NA NA NA NA 159s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 159s double: NAs = TRUE, lag = 3, differences = 3, setNames = 0, useNames = 1 159s Named num NA 159s - attr(*, "names")= chr "J" 159s Named num NA 159s - attr(*, "names")= chr "J" 159s double: NAs = TRUE, lag = 3, differences = 4, setNames = 0, useNames = 1 159s Named num(0) 159s - attr(*, "names")= chr(0) 159s Named num(0) 159s - attr(*, "names")= chr(0) 159s double: NAs = TRUE, lag = 1, differences = 1, setNames = 0, useNames = 0 159s num [1:9] NA 0.673 8.826 NA NA ... 159s num [1:9] NA 0.673 8.826 NA NA ... 159s double: NAs = TRUE, lag = 1, differences = 2, setNames = 0, useNames = 0 159s num [1:8] NA 8.15 NA NA NA ... 159s num [1:8] NA 8.15 NA NA NA ... 159s double: NAs = TRUE, lag = 1, differences = 3, setNames = 0, useNames = 0 159s num [1:7] NA NA NA NA NA NA NA 159s num [1:7] NA NA NA NA NA NA NA 159s double: NAs = TRUE, lag = 1, differences = 4, setNames = 0, useNames = 0 159s num [1:6] NA NA NA NA NA NA 159s num [1:6] NA NA NA NA NA NA 159s double: NAs = TRUE, lag = 2, differences = 1, setNames = 0, useNames = 0 159s num [1:8] NA 9.5 NA NA NA ... 159s num [1:8] NA 9.5 NA NA NA ... 159s double: NAs = TRUE, lag = 2, differences = 2, setNames = 0, useNames = 0 159s num [1:6] NA NA NA NA NA NA 159s num [1:6] NA NA NA NA NA NA 159s double: NAs = TRUE, lag = 2, differences = 3, setNames = 0, useNames = 0 159s num [1:4] NA NA NA NA 159s num [1:4] NA NA NA NA 159s double: NAs = TRUE, lag = 2, differences = 4, setNames = 0, useNames = 0 159s num [1:2] NA NA 159s num [1:2] NA NA 159s double: NAs = TRUE, lag = 3, differences = 1, setNames = 0, useNames = 0 159s num [1:7] NA NA NA NA NA NA NA 159s num [1:7] NA NA NA NA NA NA NA 159s double: NAs = TRUE, lag = 3, differences = 2, setNames = 0, useNames = 0 159s num [1:4] NA NA NA NA 159s num [1:4] NA NA NA NA 159s double: NAs = TRUE, lag = 3, differences = 3, setNames = 0, useNames = 0 159s num NA 159s num NA 159s double: NAs = TRUE, lag = 3, differences = 4, setNames = 0, useNames = 0 159s num(0) 159s num(0) 159s > 159s 159s R version 4.4.3 (2025-02-28) -- "Trophy Case" 159s Copyright (C) 2025 The R Foundation for Statistical Computing 159s Platform: s390x-ibm-linux-gnu 159s 159s R is free software and comes with ABSOLUTELY NO WARRANTY. 159s You are welcome to redistribute it under certain conditions. 159s Type 'license()' or 'licence()' for distribution details. 159s 159s R is a collaborative project with many contributors. 159s Type 'contributors()' for more information and 159s 'citation()' on how to cite R or R packages in publications. 159s 159s Type 'demo()' for some demos, 'help()' for on-line help, or 159s 'help.start()' for an HTML browser interface to help. 159s Type 'q()' to quit R. 159s 159s > library("matrixStats") 159s > 159s > diff2_R <- function(..., useNames=NA){ 159s + res <- diff(...) 159s + if (!useNames) names(res) <- NULL 159s + res 159s + } 159s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 159s > # Subsetted tests 159s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 159s > source("utils/validateIndicesFramework.R") 159s > x <- runif(6, min = -6, max = 6) 159s > for (setNames in c(TRUE, FALSE)) { 159s + if (setNames) names(x) <- LETTERS[1:6] 159s + else names(x) <- NULL 159s + for (l in 1:2) { 159s + for (d in 1:2) { 159s + for (idxs in index_cases) { 159s + for (useNames in c(TRUE, FALSE)) { 159s + validateIndicesTestVector(x, idxs, 159s + ftest = diff2, fsure = diff2_R, 159s + lag = l, differences = d, useNames = useNames) 159s + } 159s + } 159s + } 159s + } 159s + } 159s > 159s 159s R version 4.4.3 (2025-02-28) -- "Trophy Case" 159s Copyright (C) 2025 The R Foundation for Statistical Computing 159s Platform: s390x-ibm-linux-gnu 159s 159s R is free software and comes with ABSOLUTELY NO WARRANTY. 159s You are welcome to redistribute it under certain conditions. 159s Type 'license()' or 'licence()' for distribution details. 159s 159s R is a collaborative project with many contributors. 159s Type 'contributors()' for more information and 159s 'citation()' on how to cite R or R packages in publications. 159s 159s Type 'demo()' for some demos, 'help()' for on-line help, or 159s 'help.start()' for an HTML browser interface to help. 159s Type 'q()' to quit R. 159s 159s > library("matrixStats") 159s > 159s > indexByRow_R1 <- function(dim, idxs = NULL, ...) { 159s + n <- prod(dim) 159s + x <- matrix(seq_len(n), nrow = dim[2L], ncol = dim[1L], byrow = TRUE) 159s + if (!is.null(idxs)) 159s + x <- x[idxs] 159s + as.vector(x) 159s + } 159s > 159s > 159s > indexByRow_R2 <- function(dim, idxs = NULL, ...) { 159s + n <- prod(dim) 159s + if (is.null(idxs)) { 159s + x <- matrix(seq_len(n), nrow = dim[2L], ncol = dim[1L], byrow = TRUE) 159s + as.vector(x) 159s + } else { 159s + idxs <- idxs - 1L 159s + cols <- idxs %/% dim[2L] 159s + rows <- idxs %% dim[2L] 159s + cols + dim[1L] * rows + 1L 159s + } 159s + } 159s > 159s > 159s > dim <- c(5L, 4L) 159s > x <- matrix(NA_integer_, nrow = dim[1L], ncol = dim[2L]) 159s > y <- t(x) 159s > idxs_by_cols <- seq_along(x) 159s > 159s > # Assign by columns 159s > x[idxs_by_cols] <- idxs_by_cols 159s > print(x) 159s [,1] [,2] [,3] [,4] 159s [1,] 1 6 11 16 159s [2,] 2 7 12 17 159s [3,] 3 8 13 18 159s [4,] 4 9 14 19 159s [5,] 5 10 15 20 159s > 159s > # Truth 159s > y0 <- t(x) 159s > idxs_by_rows <- as.vector(y0) 159s > 159s > # Assert 159s > idxs <- indexByRow(dim) 159s > stopifnot(all.equal(idxs, idxs_by_rows)) 159s > y <- x 159s > y[idxs_by_rows] <- idxs 159s > print(y) 159s [,1] [,2] [,3] [,4] 159s [1,] 1 6 11 16 159s [2,] 2 7 12 17 159s [3,] 3 8 13 18 159s [4,] 4 9 14 19 159s [5,] 5 10 15 20 159s > stopifnot(all(as.vector(y) == as.vector(x))) 159s > 159s > idxs_R1 <- indexByRow_R1(dim) 159s > stopifnot(all.equal(idxs_R1, idxs_by_rows)) 159s > 159s > idxs_R2 <- indexByRow_R2(dim) 159s > stopifnot(all.equal(idxs_R2, idxs_by_rows)) 159s > 159s > # Assert 159s > idxs_by_cols <- seq(from = 1, to = length(x), by = 3L) 159s > idxs_by_rows <- as.vector(t(x)[idxs_by_cols]) 159s > 159s > idxs <- indexByRow(dim, idxs = idxs_by_cols) 159s > stopifnot(all(idxs == idxs_by_rows)) 159s > 159s > idxs_R1 <- indexByRow_R1(dim, idxs = idxs_by_cols) 159s > stopifnot(all(idxs_R1 == idxs_by_rows)) 159s > 159s > idxs_R2 <- indexByRow_R2(dim, idxs = idxs_by_cols) 159s > stopifnot(all(idxs_R2 == idxs_by_rows)) 159s > 159s > 159s > ## DEFUNCT: Backward compatibility 159s > res <- tryCatch({ 159s + idxs1 <- indexByRow(x) 159s + }, error = identity) 159s > stopifnot(inherits(res, "error")) 159s > 159s > 159s > ## Exceptions: 159s > ## Too large matrices are not supported, which happens 159s > ## when prod(dim) > .Machine$integer.max 159s > dim_too_large <- c(.Machine$integer.max, 2L) 159s > res <- tryCatch({ 159s + idxs <- indexByRow(dim_too_large, idxs = 1L) 159s + }, error = identity) 159s > stopifnot(inherits(res, "error")) 159s > 159s > ## Non-positive indices are not supported 159s > res <- tryCatch({ 159s + idxs <- indexByRow(c(1,1), idxs = 0L) 159s + }, error = identity) 159s > stopifnot(inherits(res, "error")) 159s > 159s > res <- tryCatch({ 159s + idxs <- indexByRow(c(1,1), idxs = -1L) 159s + }, error = identity) 159s > stopifnot(inherits(res, "error")) 159s > 159s 159s R version 4.4.3 (2025-02-28) -- "Trophy Case" 159s Copyright (C) 2025 The R Foundation for Statistical Computing 159s Platform: s390x-ibm-linux-gnu 159s 159s R is free software and comes with ABSOLUTELY NO WARRANTY. 159s You are welcome to redistribute it under certain conditions. 159s Type 'license()' or 'licence()' for distribution details. 159s 159s R is a collaborative project with many contributors. 159s Type 'contributors()' for more information and 159s 'citation()' on how to cite R or R packages in publications. 159s 159s Type 'demo()' for some demos, 'help()' for on-line help, or 159s 'help.start()' for an HTML browser interface to help. 159s Type 'q()' to quit R. 159s 159s > library("matrixStats") 159s > library("stats") 159s > 159s > logSumExp_R <- function(lx, na.rm = FALSE) { 159s + log(sum(exp(lx), na.rm = na.rm)) 159s + } 159s > 159s > ## R-help thread \emph{'[R] Beyond double-precision?'} on May 9, 2009. 159s > 159s > for (mode in c("integer", "double")) { 159s + cat("mode: ", mode, "\n", sep = "") 159s + 159s + set.seed(1) 159s + x <- runif(20, min = 1.0, max = 3.0) 159s + storage.mode(x) <- mode 159s + str(x) 159s + 159s + ## The logarithm of the harmonic mean 159s + y0 <- log(1 / mean(1 / x)) 159s + print(y0) ## -1.600885 159s + 159s + lx <- log(x) 159s + y1 <- log(length(x)) - logSumExp(-lx) 159s + print(y1) ## [1] -1.600885 159s + 159s + # Sanity check 159s + stopifnot(all.equal(y1, y0)) 159s + 159s + y2 <- log(length(x)) - logSumExp_R(-lx) 159s + # Sanity check 159s + stopifnot(all.equal(y2, y0)) 159s + } # for (mode ...) 160s mode: integer 160s int [1:20] 1 1 2 2 1 2 2 2 2 1 ... 160s [1] 0.3215836 160s [1] 0.3215836 160s mode: double 160s num [1:20] 1.53 1.74 2.15 2.82 1.4 ... 160s [1] 0.6673156 160s [1] 0.6673156 160s > 160s > 160s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 160s > # Missing values 160s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 160s > ## NA values 160s > lx <- c(1, 2, 3) 160s > lx[2] <- NA_real_ 160s > y0 <- logSumExp_R(lx, na.rm = FALSE) 160s > y <- logSumExp(lx, na.rm = FALSE) 160s > print(y) 160s [1] NA 160s > stopifnot(identical(y, NA_real_)) 160s > stopifnot(all.equal(y, y0)) 160s > 160s > y0 <- logSumExp_R(lx, na.rm = TRUE) 160s > y <- logSumExp(lx, na.rm = TRUE) 160s > print(y) 160s [1] 3.126928 160s > stopifnot(all.equal(y, y0)) 160s > 160s > ## NaN values 160s > lx <- c(1, 2, 3) 160s > lx[2] <- NaN 160s > y0 <- logSumExp_R(lx, na.rm = FALSE) 160s > y <- logSumExp(lx, na.rm = FALSE) 160s > print(y) 160s [1] NA 160s > stopifnot(identical(y, NA_real_)) 160s > stopifnot(all.equal(y, y0)) 160s > 160s > y0 <- logSumExp_R(lx, na.rm = TRUE) 160s > y <- logSumExp(lx, na.rm = TRUE) 160s > print(y) 160s [1] 3.126928 160s > stopifnot(all.equal(y, y0)) 160s > 160s > 160s > 160s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 160s > # Corner cases 160s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 160s > ## Zero-length vectors 160s > lx <- numeric(0L) 160s > y0 <- logSumExp_R(lx) 160s > y <- logSumExp(lx) 160s > print(y) 160s [1] -Inf 160s > stopifnot(identical(y, -Inf)) 160s > stopifnot(all.equal(y, y0)) 160s > 160s > ## Vectors of length one 160s > lx <- 1.0 160s > y0 <- logSumExp_R(lx) 160s > y <- logSumExp(lx) 160s > print(y) 160s [1] 1 160s > stopifnot(identical(y, lx)) 160s > stopifnot(all.equal(y, y0)) 160s > 160s > lx <- NA_real_ 160s > y0 <- logSumExp_R(lx, na.rm = TRUE) 160s > y <- logSumExp(lx, na.rm = TRUE) 160s > print(y) 160s [1] -Inf 160s > stopifnot(identical(y, -Inf)) 160s > stopifnot(all.equal(y, y0)) 160s > 160s > ## All missing values 160s > lx <- c(NA_real_, NA_real_) 160s > y0 <- logSumExp_R(lx, na.rm = TRUE) 160s > y <- logSumExp(lx, na.rm = TRUE) 160s > print(y) 160s [1] -Inf 160s > stopifnot(identical(y, -Inf)) 160s > stopifnot(all.equal(y, y0)) 160s > 160s > lx <- c(NA_real_, NA_real_) 160s > y0 <- logSumExp_R(lx, na.rm = FALSE) 160s > y <- logSumExp(lx, na.rm = FALSE) 160s > print(y) 160s [1] NA 160s > stopifnot(identical(y, NA_real_)) 160s > stopifnot(all.equal(y, y0)) 160s > 160s > 160s > ## +Inf values 160s > lx <- c(1, 2, +Inf) 160s > y0 <- logSumExp_R(lx) 160s > y <- logSumExp(lx) 160s > print(y) 160s [1] Inf 160s > stopifnot(identical(y, +Inf)) 160s > stopifnot(all.equal(y, y0)) 160s > 160s > ## First element is a missing value, cf. PR #33 160s > lx <- c(NA_real_, 1) 160s > y0 <- logSumExp_R(lx) 160s > print(y0) 160s [1] NA 160s > y <- logSumExp(lx, na.rm = FALSE) 160s > print(y) 160s [1] NA 160s > stopifnot(identical(y, NA_real_)) 160s > stopifnot(all.equal(y, y0)) 160s > 160s > y0 <- logSumExp_R(lx, na.rm = TRUE) 160s > print(y0) 160s [1] 1 160s > y <- logSumExp(lx, na.rm = TRUE) 160s > print(y) 160s [1] 1 160s > stopifnot(identical(y, 1)) 160s > stopifnot(all.equal(y, y0)) 160s > 160s > ## Multiple -Inf values, cf. issue #84 160s > lx <- c(-Inf, -Inf) 160s > y0 <- logSumExp_R(lx) 160s > y <- logSumExp(lx) 160s > print(y) 160s [1] -Inf 160s > stopifnot(identical(y, -Inf)) 160s > stopifnot(all.equal(y, y0)) 160s > 160s > lx <- c(-Inf, 5, -Inf) 160s > y0 <- logSumExp_R(lx) 160s > y <- logSumExp(lx) 160s > print(y) 160s [1] 5 160s > stopifnot(identical(y, 5)) 160s > stopifnot(all.equal(y, y0)) 160s > 160s 160s R version 4.4.3 (2025-02-28) -- "Trophy Case" 160s Copyright (C) 2025 The R Foundation for Statistical Computing 160s Platform: s390x-ibm-linux-gnu 160s 160s R is free software and comes with ABSOLUTELY NO WARRANTY. 160s You are welcome to redistribute it under certain conditions. 160s Type 'license()' or 'licence()' for distribution details. 160s 160s R is a collaborative project with many contributors. 160s Type 'contributors()' for more information and 160s 'citation()' on how to cite R or R packages in publications. 160s 160s Type 'demo()' for some demos, 'help()' for on-line help, or 160s 'help.start()' for an HTML browser interface to help. 160s Type 'q()' to quit R. 160s 160s > library("matrixStats") 160s > 160s > logSumExp_R <- function(lx, na.rm = FALSE) { 160s + log(sum(exp(lx), na.rm = na.rm)) 160s + } 160s > 160s > 160s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 160s > # Subsetted tests 160s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 160s > source("utils/validateIndicesFramework.R") 160s > x <- runif(6, min = -6, max = 6) 160s > for (idxs in index_cases) { 160s + validateIndicesTestVector(x, idxs, 160s + ftest = logSumExp, fsure = logSumExp_R, 160s + na.rm = FALSE) 160s + validateIndicesTestVector(x, idxs, 160s + ftest = logSumExp, fsure = logSumExp_R, 160s + na.rm = TRUE) 160s + } 160s > 160s 160s R version 4.4.3 (2025-02-28) -- "Trophy Case" 160s Copyright (C) 2025 The R Foundation for Statistical Computing 160s Platform: s390x-ibm-linux-gnu 160s 160s R is free software and comes with ABSOLUTELY NO WARRANTY. 160s You are welcome to redistribute it under certain conditions. 160s Type 'license()' or 'licence()' for distribution details. 160s 160s R is a collaborative project with many contributors. 160s Type 'contributors()' for more information and 160s 'citation()' on how to cite R or R packages in publications. 160s 160s Type 'demo()' for some demos, 'help()' for on-line help, or 160s 'help.start()' for an HTML browser interface to help. 160s Type 'q()' to quit R. 160s 160s > library("matrixStats") 160s > 160s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 160s > # Consistency checks 160s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 160s > set.seed(1) 160s > 160s > mean2_R <- function(x, na.rm = FALSE, idxs = NULL) { 160s + if (is.null(idxs)) { 160s + mean(x, na.rm = na.rm) 160s + } else { 160s + mean(x[idxs], na.rm = na.rm) 160s + } 160s + } # mean2_R() 160s > 160s > 160s > cat("Consistency checks:\n") 160s Consistency checks: 160s > for (kk in 1:20) { 160s + cat("Random test #", kk, "\n", sep = "") 160s + 160s + # Simulate data in a matrix of any shape 160s + n <- sample(100L, size = 1L) 160s + x <- rnorm(n, sd = 100) 160s + 160s + # Add NAs? 160s + if ((kk %% 4) %in% c(3, 0)) { 160s + cat("Adding NAs\n") 160s + nna <- sample(n, size = 1L) 160s + na_values <- c(NA_real_, NaN) 160s + t <- sample(na_values, size = nna, replace = TRUE) 160s + x[sample(length(x), size = nna)] <- t 160s + } 160s + 160s + # Integer or double? 160s + if ((kk %% 4) %in% c(2, 0)) { 160s + cat("Coercing to integers\n") 160s + storage.mode(x) <- "integer" 160s + } 160s + 160s + na.rm <- sample(c(TRUE, FALSE), size = 1L) 160s + 160s + # Sum over all 160s + y0 <- mean2_R(x, na.rm = na.rm) 160s + y1 <- mean2(x, na.rm = na.rm) 160s + stopifnot(all.equal(y1, y0)) 160s + 160s + # Sum over subset 160s + nidxs <- sample(n, size = 1L) 160s + idxs <- sample(n, size = nidxs) 160s + y0 <- mean2_R(x, na.rm = na.rm, idxs = idxs) 160s + y1 <- mean2(x, na.rm = na.rm, idxs = idxs) 160s + stopifnot(all.equal(y1, y0)) 160s + 160s + if (storage.mode(x) == "integer") { 160s + storage.mode(x) <- "logical" 160s + 160s + y0 <- mean2_R(x, na.rm = na.rm) 160s + y1 <- mean2(x, na.rm = na.rm) 160s + stopifnot(all.equal(y1, y0)) 160s + 160s + y0 <- mean2_R(x, na.rm = na.rm, idxs = idxs) 160s + y1 <- mean2(x, na.rm = na.rm, idxs = idxs) 160s + stopifnot(all.equal(y1, y0)) 160s + } 160s + } # for (kk ...) 160s Random test #1 160s Random test #2 160s Coercing to integers 160s Random test #3 160s Adding NAs 160s Random test #4 160s Adding NAs 160s Coercing to integers 160s Random test #5 160s Random test #6 160s Coercing to integers 160s Random test #7 160s Adding NAs 160s Random test #8 160s Adding NAs 160s Coercing to integers 160s Random test #9 160s Random test #10 160s Coercing to integers 160s Random test #11 160s Adding NAs 160s Random test #12 160s Adding NAs 160s Coercing to integers 160s Random test #13 160s Random test #14 160s Coercing to integers 160s Random test #15 160s Adding NAs 160s Random test #16 160s Adding NAs 160s Coercing to integers 160s Random test #17 160s Random test #18 160s Coercing to integers 160s Random test #19 160s Adding NAs 160s Random test #20 160s Adding NAs 160s Coercing to integers 160s > 160s > 160s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 160s > # Special cases 160s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 160s > for (na.rm in c(FALSE, TRUE)) { 160s + # Averaging over zero elements (integers) 160s + x <- integer(0) 160s + s1 <- mean(x, na.rm = na.rm) 160s + s2 <- mean2(x, na.rm = na.rm) 160s + stopifnot(identical(s1, s2)) 160s + 160s + x <- 1:5 160s + idxs <- integer(0) 160s + s1 <- mean(x[idxs], na.rm = na.rm) 160s + s2 <- mean2(x, idxs = idxs, na.rm = na.rm) 160s + stopifnot(identical(s1, s2)) 160s + 160s + # Averaging over NA_integer_:s 160s + x <- rep(NA_integer_, times = 5L) 160s + s1 <- mean(x, na.rm = na.rm) 160s + s2 <- mean2(x, na.rm = na.rm) 160s + stopifnot(identical(s1, s2)) 160s + 160s + x <- rep(NA_integer_, times = 5L) 160s + idxs <- 1:3 160s + s1 <- mean(x[idxs], na.rm = na.rm) 160s + s2 <- mean2(x, idxs = idxs, na.rm = na.rm) 160s + stopifnot(identical(s1, s2)) 160s + 160s + 160s + # Averaging over zero elements (doubles) 160s + x <- double(0) 160s + s1 <- mean(x) 160s + s2 <- mean2(x) 160s + stopifnot(identical(s1, s2)) 160s + 160s + x <- as.double(1:10) 160s + idxs <- integer(0) 160s + s1 <- mean(x[idxs]) 160s + s2 <- mean2(x, idxs = idxs) 160s + stopifnot(identical(s1, s2)) 160s + 160s + # Averaging over NA_real_:s 160s + x <- rep(NA_real_, times = 5L) 160s + s1 <- mean(x, na.rm = na.rm) 160s + s2 <- mean2(x, na.rm = na.rm) 160s + stopifnot(identical(s1, s2)) 160s + 160s + x <- rep(NA_real_, times = 5L) 160s + idxs <- 1:3 160s + s1 <- mean(x[idxs], na.rm = na.rm) 160s + s2 <- mean2(x, idxs = idxs, na.rm = na.rm) 160s + stopifnot(identical(s1, s2)) 160s + 160s + # Averaging over -Inf:s 160s + x <- rep(-Inf, times = 3L) 160s + s1 <- mean(x, na.rm = na.rm) 160s + s2 <- mean2(x, na.rm = na.rm) 160s + stopifnot(identical(s1, s2)) 160s + 160s + # Averaging over +Inf:s 160s + x <- rep(+Inf, times = 3L) 160s + s1 <- mean(x, na.rm = na.rm) 160s + s2 <- mean2(x, na.rm = na.rm) 160s + stopifnot(identical(s1, s2)) 160s + 160s + # Averaging over mix of -Inf:s and +Inf:s 160s + x <- rep(c(-Inf, +Inf), times = 3L) 160s + s1 <- mean(x, na.rm = na.rm) 160s + s2 <- mean2(x, na.rm = na.rm) 160s + stopifnot(identical(s1, s2)) 160s + 160s + # Averaging over mix of -Inf:s and +Inf:s and numerics 160s + x <- rep(c(-Inf, +Inf, 3.14), times = 2L) 160s + s1 <- mean(x, na.rm = na.rm) 160s + s2 <- mean2(x, na.rm = na.rm) 160s + stopifnot(identical(s1, s2)) 160s + 160s + # Averaging over mix of NaN, NA, +Inf, and numerics 160s + x <- c(NaN, NA, +Inf, 3.14) 160s + s1 <- mean(x, na.rm = na.rm) 160s + s2 <- mean2(x, na.rm = na.rm) 160s + if (na.rm) { 160s + stopifnot(identical(s2, s1)) 160s + } else { 160s + stopifnot(is.na(s1), is.na(s2)) 160s + ## NOTE, due to compiler optimization, it is not guaranteed that NA is 160s + ## returned here (as one would expect). NaN might very well be returned, 160s + ## when both NA and NaN are involved. This is an accepted feature in R, 160s + ## which is documented in help("is.nan"). See also 160s + ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 160s + ## Thus, we cannot guarantee that s1 is identical to s0. 160s + } 160s + 160s + # Averaging over mix of NaN, NA_real_, +Inf, and numerics 160s + x <- c(NA_real_, NaN, +Inf, 3.14) 160s + s1 <- mean(x, na.rm = na.rm) 160s + s2 <- mean2(x, na.rm = na.rm) 160s + if (na.rm) { 160s + stopifnot(identical(s2, s1)) 160s + } else { 160s + stopifnot(is.na(s1), is.na(s2)) 160s + ## NOTE, due to compiler optimization, it is not guaranteed that NA is 160s + ## returned here (as one would expect). NaN might very well be returned, 160s + ## when both NA and NaN are involved. This is an accepted feature in R, 160s + ## which is documented in help("is.nan"). See also 160s + ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 160s + ## Thus, we cannot guarantee that s1 is identical to s0. 160s + } 160s + } 160s > 160s > 160s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 160s > # Argument 'idxs' 160s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 160s > x <- 1:5 160s > idxs_list <- list( 160s + integer = 1:3, 160s + double = as.double(1:3), 160s + logical = (x <= 3) 160s + ) 160s > 160s > for (idxs in idxs_list) { 160s + cat("idxs:\n") 160s + str(idxs) 160s + s1 <- mean(x[idxs], na.rm = TRUE) 160s + s2 <- mean2(x, idxs = idxs, na.rm = TRUE) 160s + stopifnot(identical(s1, s2)) 160s + } 160s idxs: 160s int [1:3] 1 2 3 160s idxs: 160s num [1:3] 1 2 3 160s idxs: 160s logi [1:5] TRUE TRUE TRUE FALSE FALSE 160s > 160s 160s R version 4.4.3 (2025-02-28) -- "Trophy Case" 160s Copyright (C) 2025 The R Foundation for Statistical Computing 160s Platform: s390x-ibm-linux-gnu 160s 160s R is free software and comes with ABSOLUTELY NO WARRANTY. 160s You are welcome to redistribute it under certain conditions. 160s Type 'license()' or 'licence()' for distribution details. 160s 160s R is a collaborative project with many contributors. 160s Type 'contributors()' for more information and 160s 'citation()' on how to cite R or R packages in publications. 160s 160s Type 'demo()' for some demos, 'help()' for on-line help, or 160s 'help.start()' for an HTML browser interface to help. 160s Type 'q()' to quit R. 160s 160s > library("matrixStats") 160s > 160s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 160s > # Subsetted tests 160s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 160s > source("utils/validateIndicesFramework.R") 160s > x <- runif(6, min = -6, max = 6) 160s > storage.mode(x) <- "integer" 160s > for (idxs in index_cases) { 160s + validateIndicesTestVector(x, idxs, 160s + ftest = mean2, fsure = mean, 160s + na.rm = FALSE) 160s + validateIndicesTestVector(x, idxs, 160s + ftest = mean2, fsure = mean, 160s + na.rm = TRUE) 160s + } 160s > 160s 160s R version 4.4.3 (2025-02-28) -- "Trophy Case" 160s Copyright (C) 2025 The R Foundation for Statistical Computing 160s Platform: s390x-ibm-linux-gnu 160s 160s R is free software and comes with ABSOLUTELY NO WARRANTY. 160s You are welcome to redistribute it under certain conditions. 160s Type 'license()' or 'licence()' for distribution details. 160s 160s R is a collaborative project with many contributors. 160s Type 'contributors()' for more information and 160s 'citation()' on how to cite R or R packages in publications. 160s 160s Type 'demo()' for some demos, 'help()' for on-line help, or 160s 'help.start()' for an HTML browser interface to help. 160s Type 'q()' to quit R. 160s 160s > library("matrixStats") 160s > 160s > for (mode in c("integer", "double")) { 160s + cat("mode: ", mode, "\n", sep = "") 160s + 160s + # Empty vector 160s + x <- 0 160s + storage.mode(x) <- mode 160s + y <- prod(x, na.rm = TRUE) 160s + print(y) 160s + z <- product(x, na.rm = TRUE) 160s + print(z) 160s + stopifnot(all.equal(z, y)) 160s + 160s + # Test negative values 160s + x <- c(1, -4, 2) 160s + storage.mode(x) <- mode 160s + y <- prod(x, na.rm = TRUE) 160s + print(y) 160s + z <- product(x, na.rm = TRUE) 160s + print(z) 160s + stopifnot(all.equal(z, y)) 160s + 160s + # Test missing values 160s + x <- c(1, NA, NaN, 2) 160s + storage.mode(x) <- mode 160s + y <- prod(x, na.rm = TRUE) 160s + print(y) 160s + z <- product(x, na.rm = TRUE) 160s + print(z) 160s + stopifnot(all.equal(z, y)) 160s + 160s + x <- c(1, NA, NaN, 2) 160s + storage.mode(x) <- mode 160s + y <- prod(x, na.rm = FALSE) 160s + print(y) 160s + z <- product(x, na.rm = FALSE) 160s + print(z) 160s + stopifnot(all(is.na(z), is.na(y))) 160s + 160s + x <- c(1, NaN, 2) 160s + storage.mode(x) <- mode 160s + y <- prod(x, na.rm = FALSE) 160s + print(y) 160s + stopifnot(is.na(y)) 160s + z <- product(x, na.rm = FALSE) 160s + print(z) 160s + stopifnot(is.na(z)) 160s + 160s + } # for (mode ...) 160s mode: integer 160s [1] 0 160s [1] 0 160s [1] -8 160s [1] -8 160s [1] 2 160s [1] 2 160s [1] NA 160s [1] NA 160s [1] NA 160s [1] NA 160s mode: double 160s [1] 0 160s [1] 0 160s [1] -8 160s [1] -8 160s [1] 2 160s [1] 2 160s [1] NA 160s [1] NA 160s [1] NaN 160s [1] NA 160s > 160s > 160s > # NAs following 0s 160s > x <- c(0L, NA_integer_) 160s > y <- prod(x, na.rm = FALSE) 160s > print(y) 160s [1] NA 160s > z <- product(x, na.rm = FALSE) 160s > print(z) 160s [1] NA 160s > stopifnot(identical(z, y)) 160s > 160s 160s R version 4.4.3 (2025-02-28) -- "Trophy Case" 160s Copyright (C) 2025 The R Foundation for Statistical Computing 160s Platform: s390x-ibm-linux-gnu 160s 160s R is free software and comes with ABSOLUTELY NO WARRANTY. 160s You are welcome to redistribute it under certain conditions. 160s Type 'license()' or 'licence()' for distribution details. 160s 160s R is a collaborative project with many contributors. 160s Type 'contributors()' for more information and 160s 'citation()' on how to cite R or R packages in publications. 160s 160s Type 'demo()' for some demos, 'help()' for on-line help, or 160s 'help.start()' for an HTML browser interface to help. 160s Type 'q()' to quit R. 160s 160s > library("matrixStats") 161s > 161s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 161s > # Subsetted tests 161s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 161s > source("utils/validateIndicesFramework.R") 161s > x <- runif(6, min = -6, max = 6) 161s > storage.mode(x) <- "integer" 161s > for (idxs in index_cases) { 161s + validateIndicesTestVector(x, idxs, 161s + ftest = product, fsure = prod, 161s + na.rm = TRUE) 161s + validateIndicesTestVector(x, idxs, 161s + ftest = product, fsure = prod, 161s + na.rm = FALSE) 161s + } 161s > 161s 161s R version 4.4.3 (2025-02-28) -- "Trophy Case" 161s Copyright (C) 2025 The R Foundation for Statistical Computing 161s Platform: s390x-ibm-linux-gnu 161s 161s R is free software and comes with ABSOLUTELY NO WARRANTY. 161s You are welcome to redistribute it under certain conditions. 161s Type 'license()' or 'licence()' for distribution details. 161s 161s R is a collaborative project with many contributors. 161s Type 'contributors()' for more information and 161s 'citation()' on how to cite R or R packages in publications. 161s 161s Type 'demo()' for some demos, 'help()' for on-line help, or 161s 'help.start()' for an HTML browser interface to help. 161s Type 'q()' to quit R. 161s 161s > library("matrixStats") 161s > library("utils") ## utils::str 161s > 161s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 161s > # Local functions 161s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 161s > psortKM_R <- function(x, k, m) { 161s + x <- sort(x) 161s + x[(k - m + 1):k] 161s + } 161s > 161s > psortKM_R2 <- function(x, k, m) { 161s + partial <- (k - m + 1):k 161s + x <- sort.int(x, partial = partial) 161s + x[partial] 161s + } 161s > 161s > 161s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 161s > # Consistency checks 161s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 161s > set.seed(1) 161s > 161s > cat("Consistency checks:\n") 161s Consistency checks: 161s > x <- 1:30 161s > x[18:20] <- 20 161s > y <- sample(x) 161s > cat("x:\n") 161s x: 161s > str(x) 161s num [1:30] 1 2 3 4 5 6 7 8 9 10 ... 161s > cat("sample(x):\n") 161s sample(x): 161s > str(y) 161s num [1:30] 25 4 7 1 2 23 11 14 20 20 ... 161s > 161s > for (k in c(1L, 2L, 20L, 21L, length(x))) { 161s + for (m in 1:min(5L, k)) { 161s + px0 <- psortKM_R(x, k = k, m = m) 161s + px0b <- psortKM_R2(x, k = k, m = m) 161s + stopifnot(identical(px0b, px0)) 161s + px1 <- matrixStats:::.psortKM(x, k = k, m = m) 161s + cat(sprintf(".psortKM(x, k = %d, m = %d):\n", k, m)) 161s + print(px1) 161s + stopifnot(identical(px1, px0)) 161s + 161s + py0 <- psortKM_R(y, k = k, m = m) 161s + py0b <- psortKM_R2(y, k = k, m = m) 161s + stopifnot(identical(py0b, py0)) 161s + py1 <- matrixStats:::.psortKM(y, k = k, m = m) 161s + cat(sprintf(".psortKM(y, k = %d, m = %d):\n", k, m)) 161s + print(py1) 161s + stopifnot(identical(py1, py0)) 161s + stopifnot(identical(py1, px1)) 161s + } # for (m ...) 161s + } # for (k ...) 161s .psortKM(x, k = 1, m = 1): 161s [1] 1 161s .psortKM(y, k = 1, m = 1): 161s [1] 1 161s .psortKM(x, k = 2, m = 1): 161s [1] 2 161s .psortKM(y, k = 2, m = 1): 161s [1] 2 161s .psortKM(x, k = 2, m = 2): 161s [1] 1 2 161s .psortKM(y, k = 2, m = 2): 161s [1] 1 2 161s .psortKM(x, k = 20, m = 1): 161s [1] 20 161s .psortKM(y, k = 20, m = 1): 161s [1] 20 161s .psortKM(x, k = 20, m = 2): 161s [1] 20 20 161s .psortKM(y, k = 20, m = 2): 161s [1] 20 20 161s .psortKM(x, k = 20, m = 3): 161s [1] 20 20 20 161s .psortKM(y, k = 20, m = 3): 161s [1] 20 20 20 161s .psortKM(x, k = 20, m = 4): 161s [1] 17 20 20 20 161s .psortKM(y, k = 20, m = 4): 161s [1] 17 20 20 20 161s .psortKM(x, k = 20, m = 5): 161s [1] 16 17 20 20 20 161s .psortKM(y, k = 20, m = 5): 161s [1] 16 17 20 20 20 161s .psortKM(x, k = 21, m = 1): 161s [1] 21 161s .psortKM(y, k = 21, m = 1): 161s [1] 21 161s .psortKM(x, k = 21, m = 2): 161s [1] 20 21 161s .psortKM(y, k = 21, m = 2): 161s [1] 20 21 161s .psortKM(x, k = 21, m = 3): 161s [1] 20 20 21 161s .psortKM(y, k = 21, m = 3): 161s [1] 20 20 21 161s .psortKM(x, k = 21, m = 4): 161s [1] 20 20 20 21 161s .psortKM(y, k = 21, m = 4): 161s [1] 20 20 20 21 161s .psortKM(x, k = 21, m = 5): 161s [1] 17 20 20 20 21 161s .psortKM(y, k = 21, m = 5): 161s [1] 17 20 20 20 21 161s .psortKM(x, k = 30, m = 1): 161s [1] 30 161s .psortKM(y, k = 30, m = 1): 161s [1] 30 161s .psortKM(x, k = 30, m = 2): 161s [1] 29 30 161s .psortKM(y, k = 30, m = 2): 161s [1] 29 30 161s .psortKM(x, k = 30, m = 3): 161s [1] 28 29 30 161s .psortKM(y, k = 30, m = 3): 161s [1] 28 29 30 161s .psortKM(x, k = 30, m = 4): 161s [1] 27 28 29 30 161s .psortKM(y, k = 30, m = 4): 161s [1] 27 28 29 30 161s .psortKM(x, k = 30, m = 5): 161s [1] 26 27 28 29 30 161s .psortKM(y, k = 30, m = 5): 161s [1] 26 27 28 29 30 161s > 161s 161s R version 4.4.3 (2025-02-28) -- "Trophy Case" 161s Copyright (C) 2025 The R Foundation for Statistical Computing 161s Platform: s390x-ibm-linux-gnu 161s 161s R is free software and comes with ABSOLUTELY NO WARRANTY. 161s You are welcome to redistribute it under certain conditions. 161s Type 'license()' or 'licence()' for distribution details. 161s 161s R is a collaborative project with many contributors. 161s Type 'contributors()' for more information and 161s 'citation()' on how to cite R or R packages in publications. 161s 161s Type 'demo()' for some demos, 'help()' for on-line help, or 161s 'help.start()' for an HTML browser interface to help. 161s Type 'q()' to quit R. 161s 161s > library("matrixStats") 161s > 161s > rowAlls_R <- function(x, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) { 161s + if (is.na(value)) { 161s + res <- apply(is.na(x), MARGIN = 1L, FUN = all, na.rm = na.rm) 161s + } else { 161s + y <- x == value 161s + 161s + # Preserve dimnames attribute 161s + dim <- dim(x) # for 0xN and Mx0 cases; needed in R (< 3.4.0) 161s + if (!isTRUE(all.equal(dim(y), dim))) { 161s + dim(y) <- dim 161s + dimnames(y) <- dimnames(x) 161s + } 161s + 161s + res <- apply(y, MARGIN = 1L, FUN = all, na.rm = na.rm) 161s + } 161s + if (!useNames) names(res) <- NULL 161s + res 161s + } 161s > 161s > rowAnys_R <- function(x, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) { 161s + if (is.na(value)) { 161s + res <- apply(is.na(x), MARGIN = 1L, FUN = any, na.rm = na.rm) 161s + } else { 161s + y <- x == value 161s + 161s + # Preserve dimnames attribute 161s + dim <- dim(x) # for 0xN and Mx0 cases; needed in R (< 3.4.0) 161s + if (!isTRUE(all.equal(dim(y), dim))) { 161s + dim(y) <- dim 161s + dimnames(y) <- dimnames(x) 161s + } 161s + 161s + res <- apply(y, MARGIN = 1L, FUN = any, na.rm = na.rm) 161s + } 161s + if (!useNames) names(res) <- NULL 161s + res 161s + } 161s > 161s > rowAnyMissings_R <- function(x, ..., useNames = TRUE) { 161s + res <- apply(x, MARGIN = 1L, FUN = anyMissing) 161s + if (!useNames) names(res) <- NULL 161s + res 161s + } 161s > 161s > 161s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 161s > # Data type: logical 161s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 161s > x <- matrix(FALSE, nrow = 10L, ncol = 4L) 161s > x[7:8, 2:3] <- TRUE 161s > x[1:3, ] <- TRUE 161s > x[, 1] <- TRUE 161s > x[4, ] <- FALSE 161s > x[, 4] <- FALSE 161s > x[2, ] <- FALSE 161s > x[3, ] <- TRUE 161s > 161s > # To check names attribute 161s > dimnames <- list(letters[1:10], LETTERS[1:4]) 161s > 161s > for (kk in 1:3) { 161s + if (kk == 2) { 161s + x[2, 2] <- NA 161s + } else if (kk == 3) { 161s + x[, 2] <- NA 161s + x[2, ] <- NA 161s + } 161s + 161s + # Test with and without dimnames on x 161s + for (setDimnames in c(TRUE, FALSE)) { 161s + dimnames(x) <- if (setDimnames) dimnames else NULL 161s + 161s + for (na.rm in c(FALSE, TRUE)) { 161s + # Check names attribute 161s + for (useNames in c(TRUE, FALSE)) { 161s + m0 <- rowAlls_R(x, na.rm = na.rm, useNames = useNames) 161s + m1 <- rowAlls(x, na.rm = na.rm, useNames = useNames) 161s + m2 <- colAlls(t(x), na.rm = na.rm, useNames = useNames) 161s + str(list("all()", m0 = m0, m1 = m1, m2 = m2)) 161s + stopifnot(identical(m1, m0)) 161s + stopifnot(identical(m2, m0)) 161s + 161s + m0 <- rowAnys_R(x, na.rm = na.rm, useNames = useNames) 161s + m1 <- rowAnys(x, na.rm = na.rm, useNames = useNames) 161s + m2 <- colAnys(t(x), na.rm = na.rm, useNames = useNames) 161s + str(list("any()", m0 = m0, m1 = m1, m2 = m2)) 161s + stopifnot(identical(m1, m0)) 161s + stopifnot(identical(m2, m0)) 161s + 161s + m0 <- rowAnyMissings_R(x, useNames = useNames) 161s + m1 <- rowAnyMissings(x, useNames = useNames) 161s + m2 <- colAnyMissings(t(x), useNames = useNames) 161s + str(list("anyMissing()", m0 = m0, m1 = m1, m2 = m2)) 161s + stopifnot(identical(m1, m0)) 161s + stopifnot(identical(m2, m0)) 161s + } 161s + } 161s + } 161s + } # for (kk ...) 161s List of 4 161s $ : chr "all()" 161s $ m0: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m1: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m2: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s List of 4 161s $ : chr "any()" 161s $ m0: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m1: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m2: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s List of 4 161s $ : chr "anyMissing()" 161s $ m0: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m1: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m2: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s List of 4 161s $ : chr "all()" 161s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "any()" 161s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s List of 4 161s $ : chr "anyMissing()" 161s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "all()" 161s $ m0: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m1: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m2: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s List of 4 161s $ : chr "any()" 161s $ m0: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m1: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m2: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s List of 4 161s $ : chr "anyMissing()" 161s $ m0: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m1: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m2: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s List of 4 161s $ : chr "all()" 161s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "any()" 161s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s List of 4 161s $ : chr "anyMissing()" 161s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "all()" 161s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "any()" 161s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s List of 4 161s $ : chr "anyMissing()" 161s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "all()" 161s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "any()" 161s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s List of 4 161s $ : chr "anyMissing()" 161s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "all()" 161s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "any()" 161s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s List of 4 161s $ : chr "anyMissing()" 161s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "all()" 161s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "any()" 161s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s List of 4 161s $ : chr "anyMissing()" 161s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "all()" 161s $ m0: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m1: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m2: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s List of 4 161s $ : chr "any()" 161s $ m0: Named logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m1: Named logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m2: Named logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s List of 4 161s $ : chr "anyMissing()" 161s $ m0: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m1: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m2: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s List of 4 161s $ : chr "all()" 161s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "any()" 161s $ m0: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 161s $ m1: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 161s $ m2: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 161s List of 4 161s $ : chr "anyMissing()" 161s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "all()" 161s $ m0: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m1: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m2: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s List of 4 161s $ : chr "any()" 161s $ m0: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m1: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m2: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s List of 4 161s $ : chr "anyMissing()" 161s $ m0: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m1: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m2: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s List of 4 161s $ : chr "all()" 161s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "any()" 161s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s List of 4 161s $ : chr "anyMissing()" 161s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "all()" 161s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "any()" 161s $ m0: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 161s $ m1: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 161s $ m2: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 161s List of 4 161s $ : chr "anyMissing()" 161s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "all()" 161s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "any()" 161s $ m0: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 161s $ m1: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 161s $ m2: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 161s List of 4 161s $ : chr "anyMissing()" 161s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "all()" 161s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "any()" 161s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s List of 4 161s $ : chr "anyMissing()" 161s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "all()" 161s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "any()" 161s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s List of 4 161s $ : chr "anyMissing()" 161s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "all()" 161s $ m0: Named logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m1: Named logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m2: Named logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s List of 4 161s $ : chr "any()" 161s $ m0: Named logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m1: Named logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m2: Named logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s List of 4 161s $ : chr "anyMissing()" 161s $ m0: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m1: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m2: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s List of 4 161s $ : chr "all()" 161s $ m0: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "any()" 161s $ m0: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 161s $ m1: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 161s $ m2: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 161s List of 4 161s $ : chr "anyMissing()" 161s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 161s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 161s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 161s List of 4 161s $ : chr "all()" 161s $ m0: Named logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m1: Named logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m2: Named logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s List of 4 161s $ : chr "any()" 161s $ m0: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m1: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m2: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s List of 4 161s $ : chr "anyMissing()" 161s $ m0: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m1: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s $ m2: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 161s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 161s List of 4 161s $ : chr "all()" 161s $ m0: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "any()" 161s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s List of 4 161s $ : chr "anyMissing()" 161s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 161s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 161s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 161s List of 4 161s $ : chr "all()" 161s $ m0: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "any()" 161s $ m0: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 161s $ m1: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 161s $ m2: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 161s List of 4 161s $ : chr "anyMissing()" 161s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 161s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 161s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 161s List of 4 161s $ : chr "all()" 161s $ m0: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "any()" 161s $ m0: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 161s $ m1: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 161s $ m2: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 161s List of 4 161s $ : chr "anyMissing()" 161s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 161s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 161s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 161s List of 4 161s $ : chr "all()" 161s $ m0: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "any()" 161s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s List of 4 161s $ : chr "anyMissing()" 161s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 161s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 161s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 161s List of 4 161s $ : chr "all()" 161s $ m0: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 161s $ m1: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 161s $ m2: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 161s List of 4 161s $ : chr "any()" 161s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 161s List of 4 161s $ : chr "anyMissing()" 161s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 161s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 161s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 161s > 161s > 161s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 161s > # Data type: integer 161s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 161s > x <- matrix(rep(1:6, length.out = 4 * 5), nrow = 4L, ncol = 5L) 161s > x[2, ] <- 7L 161s > x[3, 1] <- 7L 161s > x[2:3, 3:4] <- NA_integer_ 161s > 161s > # To check names attribute 161s > dimnames <- list(letters[1:4], LETTERS[1:5]) 161s > 161s > # Row/column counts 161s > value <- 7L 161s > 161s > # Test with and without dimnames on x 161s > for (setDimnames in c(TRUE, FALSE)) { 161s + dimnames(x) <- if (setDimnames) dimnames else NULL 161s + for (na.rm in c(FALSE, TRUE)) { 161s + # Check names attribute 161s + for (useNames in c(TRUE, FALSE)) { 161s + r0 <- rowAlls_R(x, value = value, na.rm = na.rm, useNames = useNames) 161s + r1 <- rowAlls(x, value = value, na.rm = na.rm, useNames = useNames) 161s + r2 <- colAlls(t(x), value = value, na.rm = na.rm, useNames = useNames) 161s + stopifnot(identical(r1, r0)) 161s + stopifnot(identical(r2, r1)) 161s + if (!useNames && !setDimnames) { 161s + for (rr in seq_len(nrow(x))) { 161s + c <- allValue(x[rr, ], value = value, na.rm = na.rm) 161s + stopifnot(identical(c, r1[rr])) 161s + c <- allValue(x[rr, ], value = value, na.rm = na.rm) 161s + stopifnot(identical(c, r1[rr])) 161s + } 161s + } 161s + 161s + r0 <- rowAnys_R(x, value = value, na.rm = na.rm, useNames = useNames) 161s + r1 <- rowAnys(x, value = value, na.rm = na.rm, useNames = useNames) 161s + r2 <- colAnys(t(x), value = value, na.rm = na.rm, useNames = useNames) 161s + stopifnot(identical(r1, r0)) 161s + stopifnot(identical(r2, r1)) 161s + if (!useNames && !setDimnames) { 161s + for (rr in seq_len(nrow(x))) { 161s + c <- anyValue(x[rr, ], value = value, na.rm = na.rm) 161s + stopifnot(identical(c, r1[rr])) 161s + c <- anyValue(x[rr, ], value = value, na.rm = na.rm) 161s + stopifnot(identical(c, r1[rr])) 161s + } 161s + } 161s + } 161s + } 161s + } 161s > 161s > 161s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 161s > # rowAlls(x) et al. on numeric 'x' with logical 'value' 161s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 161s > x <- matrix(0, nrow = 4L, ncol = 5L) 161s > x[2:4, 2] <- (1:3) / 4 161s > x[2, 2:4] <- (1:3) / 4 161s > x[3:4, 3] <- (3:4) / 4 161s > x[3, 3:4] <- (3:4) / 4 161s > x[1:4, 5] <- (1:4) / 5 161s > x[4, 4] <- NA_real_ 161s > 161s > # To check names attribute 161s > dimnames <- list(letters[1:4], LETTERS[1:5]) 161s > 161s > for (value in c(TRUE, FALSE)) { 161s + for (na.rm in c(FALSE, TRUE)) { 161s + y0 <- suppressWarnings(apply(x, MARGIN = 1L, FUN = function(e) any(as.logical(e) == value, na.rm = na.rm))) 161s + y <- rowAnys(x, na.rm = na.rm, value = value) 161s + stopifnot(identical(y, y0)) 161s + # Check names attribute 161s + dimnames(x) <- dimnames 161s + y <- rowAnys(x, na.rm = na.rm, value = value, useNames = FALSE) 161s + stopifnot(all.equal(y, y0)) 161s + y0 <- suppressWarnings(apply(x, MARGIN = 1L, FUN = function(e) any(as.logical(e) == value, na.rm = na.rm))) 161s + y <- rowAnys(x, na.rm = na.rm, value = value, useNames = TRUE) 161s + stopifnot(all.equal(y, y0)) 161s + dimnames(x) <- NULL 161s + 161s + y0 <- suppressWarnings(apply(x, MARGIN = 2L, FUN = function(e) any(as.logical(e) == value, na.rm = na.rm))) 161s + y <- colAnys(x, na.rm = na.rm, value = value) 161s + stopifnot(identical(y, y0)) 161s + # Check names attribute 161s + dimnames(x) <- dimnames 161s + y <- colAnys(x, na.rm = na.rm, value = value, useNames = FALSE) 161s + stopifnot(all.equal(y, y0)) 161s + y0 <- suppressWarnings(apply(x, MARGIN = 2L, FUN = function(e) any(as.logical(e) == value, na.rm = na.rm))) 161s + y <- colAnys(x, na.rm = na.rm, value = value, useNames = TRUE) 161s + stopifnot(all.equal(y, y0)) 161s + dimnames(x) <- NULL 161s + 161s + y0 <- suppressWarnings(apply(x, MARGIN = 1L, FUN = function(e) all(as.logical(e) == value, na.rm = na.rm))) 161s + y <- rowAlls(x, na.rm = na.rm, value = value) 161s + stopifnot(identical(y, y0)) 161s + # Check names attribute 161s + dimnames(x) <- dimnames 161s + y <- rowAlls(x, na.rm = na.rm, value = value, useNames = FALSE) 161s + stopifnot(all.equal(y, y0)) 161s + y0 <- suppressWarnings(apply(x, MARGIN = 1L, FUN = function(e) all(as.logical(e) == value, na.rm = na.rm))) 161s + y <- rowAlls(x, na.rm = na.rm, value = value, useNames = TRUE) 161s + stopifnot(all.equal(y, y0)) 161s + dimnames(x) <- NULL 161s + 161s + y0 <- suppressWarnings(apply(x, MARGIN = 2L, FUN = function(e) all(as.logical(e) == value, na.rm = na.rm))) 161s + y <- colAlls(x, na.rm = na.rm, value = value) 161s + stopifnot(identical(y, y0)) 161s + print(y0) 161s + # Check names attribute 161s + dimnames(x) <- dimnames 161s + y <- colAlls(x, na.rm = na.rm, value = value, useNames = FALSE) 161s + stopifnot(all.equal(y, y0)) 161s + y0 <- suppressWarnings(apply(x, MARGIN = 2L, FUN = function(e) all(as.logical(e) == value, na.rm = na.rm))) 161s + y <- colAlls(x, na.rm = na.rm, value = value, useNames = TRUE) 161s + stopifnot(all.equal(y, y0)) 161s + dimnames(x) <- NULL 161s + } ## for (na.rm ...) 161s + } ## for(value ...) 161s [1] FALSE FALSE FALSE FALSE TRUE 161s [1] FALSE FALSE FALSE FALSE TRUE 161s [1] TRUE FALSE FALSE FALSE FALSE 161s [1] TRUE FALSE FALSE FALSE FALSE 161s > 161s > 161s > 161s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 161s > # Data type: character (not sure if this should be supported) 161s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 161s > all_R <- function(x, value = TRUE, ...) { 161s + if (is.na(value)) { 161s + all(is.na(x), ...) 161s + } else { 161s + all(x == value, ...) 161s + } 161s + } 161s > 161s > any_R <- function(x, value = TRUE, ...) { 161s + if (is.na(value)) { 161s + any(is.na(x), ...) 161s + } else { 161s + any(x == value, ...) 161s + } 161s + } 161s > 161s > x <- matrix(rep(letters, length.out = 10 * 5), nrow = 10L, ncol = 5L) 161s > x[2, ] <- "g" 161s > x[2:4, 3:4] <- NA_character_ 161s > 161s > # To check names attribute 161s > dimnames <- list(letters[1:10], LETTERS[1:5]) 161s > 161s > # Test with and without dimnames on x 161s > for (setDimnames in c(TRUE, FALSE)) { 161s + dimnames(x) <- if (setDimnames) dimnames else NULL 161s + 161s + # Row/column counts 161s + for (value in c("g", NA_character_)) { 161s + for (na.rm in c(FALSE, TRUE)) { 161s + # Check names attribute 161s + for (useNames in c(TRUE, FALSE)) { 161s + r0 <- rowAlls_R(x, value = value, na.rm = na.rm, useNames = useNames) 161s + r1 <- rowAlls(x, value = value, na.rm = na.rm, useNames = useNames) 161s + r2 <- colAlls(t(x), value = value, na.rm = na.rm, useNames = useNames) 161s + stopifnot(identical(r1, r0)) 161s + stopifnot(identical(r2, r1)) 161s + if (!useNames && !setDimnames) { 161s + for (rr in seq_len(nrow(x))) { 161s + c0 <- all_R(x[rr, ], value, na.rm = na.rm) 161s + c <- allValue(x[rr, ], value = value, na.rm = na.rm) 161s + stopifnot(identical(c, r1[rr])) 161s + stopifnot(identical(c, c0)) 161s + } 161s + } 161s + 161s + r0 <- rowAnys_R(x, value = value, na.rm = na.rm, useNames = useNames) 161s + r1 <- rowAnys(x, value = value, na.rm = na.rm, useNames = useNames) 161s + r2 <- colAnys(t(x), value = value, na.rm = na.rm, useNames = useNames) 161s + stopifnot(identical(r1, r0)) 161s + stopifnot(identical(r2, r1)) 161s + if (!useNames && !setDimnames) { 161s + for (rr in seq_len(nrow(x))) { 161s + c0 <- any_R(x[rr, ], value, na.rm = na.rm) 161s + c <- anyValue(x[rr, ], value = value, na.rm = na.rm) 161s + stopifnot(identical(c, c0)) 161s + stopifnot(identical(c, r1[rr])) 161s + } 161s + } 161s + } 161s + } 161s + } 161s + } 161s > 161s > 161s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 161s > # NA 0 test 161s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 161s > x <- matrix(0, nrow = 3L, ncol = 3L) 161s > x[1, ] <- c(NA_real_, NA_real_, 0) 161s > x[3, ] <- c(1, 0, 1) 161s > 161s > dimnames <- list(letters[1:3], LETTERS[1:3]) 161s > 161s > # Test with and without dimnames on x 161s > for (setDimnames in c(TRUE, FALSE)) { 161s + dimnames(x) <- if (setDimnames) dimnames else NULL 161s + # Check names attribute 161s + for (useNames in c(TRUE, FALSE)) { 161s + r0 <- rowAnys_R(x, value = 0, useNames = useNames) 161s + r1 <- rowAnys(x, value = 0, useNames = useNames) 161s + stopifnot(identical(r0, r1)) 161s + } 161s + } 161s > 161s 161s R version 4.4.3 (2025-02-28) -- "Trophy Case" 161s Copyright (C) 2025 The R Foundation for Statistical Computing 161s Platform: s390x-ibm-linux-gnu 161s 161s R is free software and comes with ABSOLUTELY NO WARRANTY. 161s You are welcome to redistribute it under certain conditions. 161s Type 'license()' or 'licence()' for distribution details. 161s 161s R is a collaborative project with many contributors. 161s Type 'contributors()' for more information and 161s 'citation()' on how to cite R or R packages in publications. 161s 161s Type 'demo()' for some demos, 'help()' for on-line help, or 161s 'help.start()' for an HTML browser interface to help. 161s Type 'q()' to quit R. 161s 161s > library("matrixStats") 161s > 161s > rowAlls_R <- function(x, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) { 161s + if (is.na(value)) { 161s + res <- apply(is.na(x), MARGIN = 1L, FUN = all, na.rm = na.rm) 161s + } else { 161s + y <- x == value 161s + 161s + # Preserve dimnames attribute 161s + dim <- dim(x) # for 0xN and Mx0 cases; needed in R (< 3.4.0) 161s + if (!isTRUE(all.equal(dim(y), dim))) { 161s + dim(y) <- dim 161s + dimnames(y) <- dimnames(x) 161s + } 161s + 161s + res <- apply(y, MARGIN = 1L, FUN = all, na.rm = na.rm) 161s + } 161s + if (!useNames) names(res) <- NULL 161s + res 161s + } 161s > 161s > rowAnys_R <- function(x, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) { 161s + if (is.na(value)) { 161s + res <- apply(is.na(x), MARGIN = 1L, FUN = any, na.rm = na.rm) 161s + } else { 161s + y <- x == value 161s + 161s + # Preserve dimnames attribute 161s + dim <- dim(x) # for 0xN and Mx0 cases; needed in R (< 3.4.0) 161s + if (!isTRUE(all.equal(dim(y), dim))) { 161s + dim(y) <- dim 161s + dimnames(y) <- dimnames(x) 161s + } 161s + 161s + res <- apply(y, MARGIN = 1L, FUN = any, na.rm = na.rm) 161s + } 161s + if (!useNames) names(res) <- NULL 161s + res 161s + } 161s > 161s > rowAnyMissings_R <- function(x, ..., useNames = TRUE) { 161s + res <- apply(x, MARGIN = 1L, FUN = anyMissing) 161s + if (!useNames) names(res) <- NULL 161s + res 161s + } 161s > 161s > 161s > all_R <- function(x, value = TRUE, ...) { 161s + if (is.na(value)) { 161s + all(is.na(x), ...) 161s + } else { 161s + all(x == value, ...) 161s + } 161s + } 161s > 161s > any_R <- function(x, value = TRUE, ...) { 161s + if (is.na(value)) { 161s + any(is.na(x), ...) 161s + } else { 161s + any(x == value, ...) 161s + } 161s + } 161s > 161s > 161s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 161s > # Subsetted tests 161s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 161s > source("utils/validateIndicesFramework.R") 161s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 161s > storage.mode(x) <- "integer" 161s > x[2:3, ] <- NA_integer_ 161s > x[2, 1] <- 0L 161s > x[4:5, ] <- 0L 161s > x[4, 6] <- NA_integer_ 161s > 161s > # To check names attribute 161s > dimnames <- list(letters[1:6], LETTERS[1:6]) 161s > 161s > # Test with and without dimnames on x 161s > for (setDimnames in c(TRUE, FALSE)) { 161s + if (setDimnames) dimnames(x) <- dimnames 161s + else dimnames(x) <- NULL 161s + 161s + count <- 0L 161s + for (rows in index_cases) { 161s + for (cols in index_cases) { 161s + count <- count + 1L 161s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 161s + useNames <- c(TRUE, FALSE) 161s + useNames <- useNames[count %% length(useNames) + 1] 161s + 161s + validateIndicesTestMatrix(x, rows, cols, 161s + ftest = rowAlls, fsure = rowAlls_R, 161s + value = 0, na.rm = TRUE, useNames = useNames) 161s + validateIndicesTestMatrix(x, rows, cols, 161s + ftest = rowAlls, fsure = rowAlls_R, 161s + value = 0, na.rm = FALSE, useNames = useNames) 161s + validateIndicesTestMatrix(x, rows, cols, 161s + ftest = rowAlls, fsure = rowAlls_R, 161s + value = NA_integer_, useNames = useNames) 161s + validateIndicesTestMatrix(x, rows, cols, 161s + fcoltest = colAlls, fsure = rowAlls_R, 161s + value = 0, na.rm = TRUE, useNames = useNames) 161s + validateIndicesTestMatrix(x, rows, cols, 161s + fcoltest = colAlls, fsure = rowAlls_R, 161s + value = 0, na.rm = FALSE, useNames = useNames) 161s + validateIndicesTestMatrix(x, rows, cols, 161s + fcoltest = colAlls, fsure = rowAlls_R, 161s + value = NA_integer_, useNames = useNames) 161s + 161s + validateIndicesTestMatrix(x, rows, cols, 161s + ftest = rowAnys, fsure = rowAnys_R, 161s + value = 0, na.rm = TRUE, useNames = useNames) 161s + validateIndicesTestMatrix(x, rows, cols, 161s + ftest = rowAnys, fsure = rowAnys_R, 161s + value = 0, na.rm = FALSE, useNames = useNames) 161s + validateIndicesTestMatrix(x, rows, cols, 161s + ftest = rowAnys, fsure = rowAnys_R, 161s + value = NA_integer_, useNames = useNames) 161s + validateIndicesTestMatrix(x, rows, cols, 161s + fcoltest = colAnys, fsure = rowAnys_R, 161s + value = 0, na.rm = TRUE, useNames = useNames) 161s + validateIndicesTestMatrix(x, rows, cols, 161s + fcoltest = colAnys, fsure = rowAnys_R, 161s + value = 0, na.rm = FALSE, useNames = useNames) 161s + validateIndicesTestMatrix(x, rows, cols, 161s + fcoltest = colAnys, fsure = rowAnys_R, 161s + value = NA_integer_, useNames = useNames) 161s + 161s + validateIndicesTestMatrix(x, rows, cols, 161s + ftest = rowAnyMissings, 161s + fsure = rowAnyMissings_R, useNames = useNames) 161s + validateIndicesTestMatrix(x, rows, cols, 161s + fcoltest = colAnyMissings, 161s + fsure = rowAnyMissings_R, useNames = useNames) 161s + } 161s + } 161s + } 163s > 163s > for (rr in seq_len(nrow(x))) { 163s + for (idxs in index_cases) { 163s + validateIndicesTestVector(x[rr, ], idxs, 163s + ftest = allValue, fsure = all_R, 163s + value = 0, na.rm = TRUE) 163s + validateIndicesTestVector(x[rr, ], idxs, 163s + ftest = allValue, fsure = all_R, 163s + value = 0, na.rm = FALSE) 163s + validateIndicesTestVector(x[rr, ], idxs, 163s + ftest = allValue, fsure = all_R, 163s + value = NA_integer_) 163s + 163s + validateIndicesTestVector(x[rr, ], idxs, 163s + ftest = anyValue, fsure = any_R, 163s + value = 0, na.rm = TRUE) 163s + validateIndicesTestVector(x[rr, ], idxs, 163s + ftest = anyValue, fsure = any_R, 163s + value = 0, na.rm = FALSE) 163s + validateIndicesTestVector(x[rr, ], idxs, 163s + ftest = anyValue, fsure = any_R, 163s + value = NA_integer_) 163s + } 163s + } 163s > 163s > 163s > storage.mode(x) <- "character" 163s > # Test with and without dimnames on x 163s > for (setDimnames in c(TRUE, FALSE)) { 163s + if (setDimnames) dimnames(x) <- dimnames 163s + else dimnames(x) <- NULL 163s + for (rows in index_cases) { 163s + for (cols in index_cases) { 163s + # Check names attribute 163s + for (useNames in c(TRUE, FALSE)) { 163s + validateIndicesTestMatrix(x, rows, cols, 163s + ftest = rowAlls, fsure = rowAlls_R, 163s + value = "0", na.rm = TRUE, useNames = useNames) 163s + validateIndicesTestMatrix(x, rows, cols, 163s + ftest = rowAlls, fsure = rowAlls_R, 163s + value = "0", na.rm = FALSE, useNames = useNames) 163s + validateIndicesTestMatrix(x, rows, cols, 163s + ftest = rowAlls, fsure = rowAlls_R, 163s + value = NA_character_, useNames = useNames) 163s + validateIndicesTestMatrix(x, rows, cols, 163s + fcoltest = colAlls, fsure = rowAlls_R, 163s + value = "0", na.rm = TRUE, useNames = useNames) 163s + validateIndicesTestMatrix(x, rows, cols, 163s + fcoltest = colAlls, fsure = rowAlls_R, 163s + value = "0", na.rm = FALSE, useNames = useNames) 163s + validateIndicesTestMatrix(x, rows, cols, 163s + fcoltest = colAlls, fsure = rowAlls_R, 163s + value = NA_character_, useNames = useNames) 163s + 163s + validateIndicesTestMatrix(x, rows, cols, 163s + ftest = rowAnys, fsure = rowAnys_R, 163s + value = "0", na.rm = TRUE, useNames = useNames) 163s + validateIndicesTestMatrix(x, rows, cols, 163s + ftest = rowAnys, fsure = rowAnys_R, 163s + value = "0", na.rm = FALSE, useNames = useNames) 163s + validateIndicesTestMatrix(x, rows, cols, 163s + ftest = rowAnys, fsure = rowAnys_R, 163s + value = NA_character_, useNames = useNames) 163s + validateIndicesTestMatrix(x, rows, cols, 163s + fcoltest = colAnys, fsure = rowAnys_R, 163s + value = "0", na.rm = TRUE, useNames = useNames) 163s + validateIndicesTestMatrix(x, rows, cols, 163s + fcoltest = colAnys, fsure = rowAnys_R, 163s + value = "0", na.rm = FALSE, useNames = useNames) 163s + validateIndicesTestMatrix(x, rows, cols, 163s + fcoltest = colAnys, fsure = rowAnys_R, 163s + value = NA_character_, useNames = useNames) 163s + 163s + validateIndicesTestMatrix(x, rows, cols, 163s + ftest = rowAnyMissings, 163s + fsure = rowAnyMissings_R, useNames = useNames) 163s + validateIndicesTestMatrix(x, rows, cols, 163s + fcoltest = colAnyMissings, 163s + fsure = rowAnyMissings_R, useNames = useNames) 163s + } 163s + } 163s + } 163s + } 167s > 167s > for (rr in seq_len(nrow(x))) { 167s + for (idxs in index_cases) { 167s + validateIndicesTestVector(x[rr, ], idxs, 167s + ftest = allValue, fsure = all_R, 167s + value = "0", na.rm = TRUE) 167s + validateIndicesTestVector(x[rr, ], idxs, 167s + ftest = allValue, fsure = all_R, 167s + value = "0", na.rm = FALSE) 167s + validateIndicesTestVector(x[rr, ], idxs, 167s + ftest = allValue, fsure = all_R, 167s + value = NA_integer_) 167s + 167s + validateIndicesTestVector(x[rr, ], idxs, 167s + ftest = anyValue, fsure = any_R, 167s + value = "0", na.rm = TRUE) 167s + validateIndicesTestVector(x[rr, ], idxs, 167s + ftest = anyValue, fsure = any_R, 167s + value = "0", na.rm = FALSE) 167s + validateIndicesTestVector(x[rr, ], idxs, 167s + ftest = anyValue, fsure = any_R, 167s + value = NA_integer_) 167s + } 167s + } 167s > 167s 167s R version 4.4.3 (2025-02-28) -- "Trophy Case" 167s Copyright (C) 2025 The R Foundation for Statistical Computing 167s Platform: s390x-ibm-linux-gnu 167s 167s R is free software and comes with ABSOLUTELY NO WARRANTY. 167s You are welcome to redistribute it under certain conditions. 167s Type 'license()' or 'licence()' for distribution details. 167s 167s R is a collaborative project with many contributors. 167s Type 'contributors()' for more information and 167s 'citation()' on how to cite R or R packages in publications. 167s 167s Type 'demo()' for some demos, 'help()' for on-line help, or 167s 'help.start()' for an HTML browser interface to help. 167s Type 'q()' to quit R. 167s 167s > library("matrixStats") 167s > 167s > X <- matrix(rnorm(20 * 6), nrow = 20, ncol = 6) 167s > rownames(X) <- LETTERS[1:nrow(X)] 167s > colnames(X) <- letters[1:ncol(X)] 167s > print(X) 167s a b c d e f 167s A -1.05643267 -1.0444941 -2.17523133 -0.19497156 -0.7147938 2.532771378 167s B 0.27329141 0.5310064 -0.82155755 -0.39574393 -1.8617365 -0.431631604 167s C -0.36149331 -0.2214180 0.54855056 -1.02861313 0.3304815 -1.416955967 167s D -0.44425086 -0.6712114 1.04497442 1.56165944 -0.8979856 1.617847854 167s E 0.28644421 1.3852142 -0.64077527 -0.08574159 -0.1864349 -2.031370512 167s F 1.54194241 -0.5237407 -0.02802491 -2.19454721 0.8188492 0.385539871 167s G -0.90337330 1.5216644 -0.20740063 0.99689951 -0.9677632 0.412576148 167s H -0.49849269 0.5576375 0.41796792 -1.06156135 -0.6013133 -0.207653949 167s I -0.57033548 -0.7167125 0.62721217 0.27327977 -0.1452185 -0.427630979 167s J 0.13329297 0.4642179 0.05384313 -0.55778668 0.5931117 0.546052830 167s K -0.80564473 -1.2173928 -0.21845119 -1.83726339 1.3658666 -0.313377448 167s L 1.03619239 -0.2990373 0.72057044 -1.36820982 2.2907838 -0.049177586 167s M 1.54351995 0.2650364 0.81942933 0.22216665 -2.0751068 -0.003171305 167s N 0.84056429 0.2927813 -2.27272184 1.01168058 -0.7305434 0.762958095 167s O 0.87600213 -0.7244557 -1.18060876 1.54200401 -0.2638194 -0.765416460 167s P -0.13008445 0.8308236 1.09621978 -0.02337656 -0.5849260 -0.145619034 167s Q -0.03951182 -0.2418263 -0.59517626 1.31867616 -0.3984414 0.700077687 167s R -0.83148265 -0.7431304 -0.89523083 -0.51651597 -1.7403291 -0.836095780 167s S 1.17783267 -0.8282347 -0.68424693 0.87417611 1.1711444 -1.183984613 167s T -0.95937524 0.3730069 0.97525460 0.24176288 0.5058086 0.170284693 167s > 167s > 167s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 167s > # Apply rowMeans() for 3 sets of 2 columns 167s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 167s > nbr_of_sets <- 3L 167s > S <- matrix(1:ncol(X), ncol = nbr_of_sets) 167s > colnames(S) <- sprintf("s%d", 1:nbr_of_sets) 167s > print(S) 167s s1 s2 s3 167s [1,] 1 3 5 167s [2,] 2 4 6 167s > 167s > Z <- rowAvgsPerColSet(X, S = S) 167s > print(Z) 167s s1 s2 s3 167s A -1.05046337 -1.18510145 0.908988806 167s B 0.40214889 -0.60865074 -1.146684061 167s C -0.29145564 -0.24003128 -0.543237251 167s D -0.55773111 1.30331693 0.359931134 167s E 0.83582919 -0.36325843 -1.108902720 167s F 0.50910087 -1.11128606 0.602194541 167s G 0.30914553 0.39474944 -0.277593526 167s H 0.02957238 -0.32179671 -0.404483629 167s I -0.64352399 0.45024597 -0.286424730 167s J 0.29875544 -0.25197177 0.569582280 167s K -1.01151878 -1.02785729 0.526244562 167s L 0.36857755 -0.32381969 1.120803117 167s M 0.90427815 0.52079799 -1.039139047 167s N 0.56667280 -0.63052063 0.016207346 167s O 0.07577323 0.18069762 -0.514617937 167s P 0.35036957 0.53642161 -0.365272507 167s Q -0.14066909 0.36174995 0.150818119 167s R -0.78730652 -0.70587340 -1.288212462 167s S 0.17479898 0.09496459 -0.006420122 167s T -0.29318417 0.60850874 0.338046628 167s > 167s > # Validation 167s > Z0 <- cbind(s1 = rowMeans(X[, 1:2]), s2 = rowMeans(X[, 3:4]), 167s + s3 = rowMeans(X[, 5:6])) 167s > stopifnot(identical(drop(Z), Z0)) 167s > 167s > 167s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 167s > # Apply colMeans() for 5 sets of 4 rows 167s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 167s > nbr_of_sets <- 5L 167s > S <- matrix(1:nrow(X), ncol = nbr_of_sets) 167s > colnames(S) <- sprintf("s%d", 1:nbr_of_sets) 167s > print(S) 167s s1 s2 s3 s4 s5 167s [1,] 1 5 9 13 17 167s [2,] 2 6 10 14 18 167s [3,] 3 7 11 15 19 167s [4,] 4 8 12 16 20 167s > 167s > Z <- colAvgsPerRowSet(X, S = S) 167s > print(Z) 167s a b c d e f 167s s1 -0.39722136 -0.3515293 -0.3508160 -0.0144173 -0.7860086 0.57550792 167s s2 0.10663016 0.7351938 -0.1145582 -0.5862377 -0.2341656 -0.36022711 167s s3 -0.05162372 -0.4422312 0.2957936 -0.8724950 1.0261359 -0.06103330 167s s4 0.78250048 0.1660464 -0.3844204 0.6881187 -0.9135989 -0.03781218 167s s5 -0.16313426 -0.3600461 -0.2998499 0.4795248 -0.1154544 -0.28742950 167s > 167s > # Validation 167s > Z0 <- rbind(s1 = colMeans(X[1:4, ]), s2 = colMeans(X[5:8, ]), 167s + s3 = colMeans(X[9:12, ]), s4 = colMeans(X[13:16, ]), 167s + s5 = colMeans(X[17:20, ])) 167s > stopifnot(identical(drop(Z), Z0)) 167s > 167s > 167s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 167s > # When there is only one "complete" set 167s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 167s > nbr_of_sets <- 1L 167s > S <- matrix(1:ncol(X), ncol = nbr_of_sets) 167s > colnames(S) <- sprintf("s%d", 1:nbr_of_sets) 167s > print(S) 167s s1 167s [1,] 1 167s [2,] 2 167s [3,] 3 167s [4,] 4 167s [5,] 5 167s [6,] 6 167s > 167s > Z <- rowAvgsPerColSet(X, S = S, FUN = rowMeans) 167s > print(Z) 167s s1 167s A -4.421920e-01 167s B -4.510620e-01 167s C -3.582414e-01 167s D 3.685057e-01 167s E -2.121107e-01 167s F 3.115791e-06 167s G 1.421005e-01 167s H -2.322360e-01 167s I -1.599009e-01 167s J 2.054553e-01 167s K -5.043772e-01 167s L 3.885203e-01 167s M 1.286457e-01 167s N -1.588016e-02 167s O -8.604903e-02 167s P 1.738396e-01 167s Q 1.239663e-01 167s R -9.271308e-01 167s S 8.778115e-02 167s T 2.177904e-01 167s > 167s > Z0 <- rowMeans(X) 167s > stopifnot(identical(drop(Z), Z0)) 167s > 167s > 167s > nbr_of_sets <- 1L 167s > S <- matrix(1:nrow(X), ncol = nbr_of_sets) 167s > colnames(S) <- sprintf("s%d", 1:nbr_of_sets) 167s > print(S) 167s s1 167s [1,] 1 167s [2,] 2 167s [3,] 3 167s [4,] 4 167s [5,] 5 167s [6,] 6 167s [7,] 7 167s [8,] 8 167s [9,] 9 167s [10,] 10 167s [11,] 11 167s [12,] 12 167s [13,] 13 167s [14,] 14 167s [15,] 15 167s [16,] 16 167s [17,] 17 167s [18,] 18 167s [19,] 19 167s [20,] 20 167s > 167s > Z <- colAvgsPerRowSet(X, S = S, FUN = colMeans) 167s > print(Z) 167s a b c d e f 167s s1 0.05543026 -0.05051327 -0.1707702 -0.0611013 -0.2046183 -0.03419883 167s > 167s > Z0 <- colMeans(X) 167s > stopifnot(identical(drop(Z), Z0)) 167s > 167s > 167s > 167s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 167s > # Use weights 167s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 167s > nbr_of_sets <- 3L 167s > S <- matrix(1:ncol(X), ncol = nbr_of_sets) 167s > colnames(S) <- sprintf("s%d", 1:nbr_of_sets) 167s > print(S) 167s s1 s2 s3 167s [1,] 1 3 5 167s [2,] 2 4 6 167s > 167s > W <- matrix(runif(length(X)), nrow = nrow(X), ncol = ncol(X)) 167s > Z1 <- rowAvgsPerColSet(X, W = W, S = S, FUN = rowWeightedMeans) 167s > print(Z1) 167s s1 s2 s3 167s A -1.05046337 -1.18510145 0.908988806 167s B 0.40214889 -0.60865074 -1.146684061 167s C -0.29145564 -0.24003128 -0.543237251 167s D -0.55773111 1.30331693 0.359931134 167s E 0.83582919 -0.36325843 -1.108902720 167s F 0.50910087 -1.11128606 0.602194541 167s G 0.30914553 0.39474944 -0.277593526 167s H 0.02957238 -0.32179671 -0.404483629 167s I -0.64352399 0.45024597 -0.286424730 167s J 0.29875544 -0.25197177 0.569582280 167s K -1.01151878 -1.02785729 0.526244562 167s L 0.36857755 -0.32381969 1.120803117 167s M 0.90427815 0.52079799 -1.039139047 167s N 0.56667280 -0.63052063 0.016207346 167s O 0.07577323 0.18069762 -0.514617937 167s P 0.35036957 0.53642161 -0.365272507 167s Q -0.14066909 0.36174995 0.150818119 167s R -0.78730652 -0.70587340 -1.288212462 167s S 0.17479898 0.09496459 -0.006420122 167s T -0.29318417 0.60850874 0.338046628 167s > Z2 <- colAvgsPerRowSet(X, W = W, S = S, FUN = colWeightedMeans) 167s > print(Z2) 167s a b c d e f 167s s1 -0.3915706 -0.2567439 -1.4983944 -0.2953577 -1.2882651 1.0505699 167s s2 -0.4028721 -0.4463147 0.7967625 0.2665232 -0.2837521 0.1004459 167s s3 0.9141933 0.4307367 -0.3344001 -1.1401444 0.3162071 -0.8229153 167s > 167s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 167s > # Result should always be a matrix, including when nrow(X) <= 1 167s > # (https://github.com/HenrikBengtsson/matrixStats/issues/108) 167s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 167s > X <- matrix(1:3, nrow = 1L, ncol = 3L) 167s > S <- matrix(1, nrow = 1L, ncol = 1L) 167s > Z1 <- rowAvgsPerColSet(X, S = S) 167s > stopifnot(is.matrix(Z1)) 167s > Z2 <- rowAvgsPerColSet(X, S = S, rows = 0) 167s > stopifnot(is.matrix(Z2)) 167s > 167s > 167s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 167s > # Works with many, one or zero columns / rows 167s > # (https://github.com/HenrikBengtsson/matrixStats/issues/172) 167s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 167s > S <- cbind(1:2, 3:4, 5:6) 167s > X <- matrix(rnorm(2 * 6), nrow = 6, ncol = 2) 167s > Z2 <- colAvgsPerRowSet(X, S = S, FUN = colSums2) 167s > Z2_ref <- rbind(colSums2(X[S[,1], ,drop=FALSE]), 167s + colSums2(X[S[,2], ,drop=FALSE]), 167s + colSums2(X[S[,3], ,drop=FALSE])) 167s > stopifnot(identical(Z2, Z2_ref)) 167s > X <- matrix(rnorm(6), nrow = 6, ncol = 1) 167s > Z1 <- colAvgsPerRowSet(X, S = S, FUN = colSums2) 167s > Z1_ref <- rbind(colSums2(X[S[,1], ,drop=FALSE]), 167s + colSums2(X[S[,2], ,drop=FALSE]), 167s + colSums2(X[S[,3], ,drop=FALSE])) 167s > stopifnot(identical(Z1, Z1_ref)) 167s > X <- matrix(numeric(0), nrow = 6, ncol = 0) 167s > Z0 <- colAvgsPerRowSet(X, S = S, FUN = colSums2) 167s > Z0_ref <- matrix(numeric(0), nrow = ncol(S), ncol = 0) 167s > stopifnot(identical(Z0, unname(Z0_ref))) 167s > 167s > 167s > S <- rbind(1:4, 5:8) 167s > X <- matrix(rnorm(n = 2 * 8), nrow = 2, ncol = 8) 167s > Z2 <- rowAvgsPerColSet(X, S = S, FUN = rowMeans2) 167s > Z2_ref <- cbind(rowMeans2(X[,S[,1],drop=FALSE]), 167s + rowMeans2(X[,S[,2],drop=FALSE]), 167s + rowMeans2(X[,S[,3],drop=FALSE]), 167s + rowMeans2(X[,S[,4],drop=FALSE])) 167s > stopifnot(identical(Z2, Z2_ref)) 167s > X <- matrix(rnorm(n = 8), nrow = 1, ncol = 8) 167s > Z1 <- rowAvgsPerColSet(X, S = S, FUN = rowMeans2) 167s > Z1_ref <- cbind(rowMeans2(X[,S[,1],drop=FALSE]), 167s + rowMeans2(X[,S[,2],drop=FALSE]), 167s + rowMeans2(X[,S[,3],drop=FALSE]), 167s + rowMeans2(X[,S[,4],drop=FALSE])) 167s > stopifnot(identical(Z1, Z1_ref)) 167s > X <- matrix(numeric(0), nrow = 0, ncol = 8) 167s > Z0 <- rowAvgsPerColSet(X, S = S, FUN = rowMeans2) 167s > Z0_ref <- matrix(numeric(0), nrow = 0, ncol = ncol(S)) 167s > stopifnot(identical(Z0, Z0_ref)) 167s > 167s 167s R version 4.4.3 (2025-02-28) -- "Trophy Case" 167s Copyright (C) 2025 The R Foundation for Statistical Computing 167s Platform: s390x-ibm-linux-gnu 167s 167s R is free software and comes with ABSOLUTELY NO WARRANTY. 167s You are welcome to redistribute it under certain conditions. 167s Type 'license()' or 'licence()' for distribution details. 167s 167s R is a collaborative project with many contributors. 167s Type 'contributors()' for more information and 167s 'citation()' on how to cite R or R packages in publications. 167s 167s Type 'demo()' for some demos, 'help()' for on-line help, or 167s 'help.start()' for an HTML browser interface to help. 167s Type 'q()' to quit R. 167s 167s > library("matrixStats") 167s > 167s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 167s > # Subsetted tests 167s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 167s > source("utils/validateIndicesFramework.R") 167s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 167s > #W <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 167s > for (rows in index_cases) { 167s + for (cols in index_cases) { 167s + if (is.null(rows)) { 167s + rows <- seq_len(nrow(x)) 167s + rows_finite <- rows 167s + } else { 167s + rows_finite <- rows[is.finite(rows)] 167s + } 167s + 167s + if (is.null(cols)) { 167s + cols <- seq_len(ncol(x)) 167s + cols_finite <- cols 167s + } else { 167s + cols_finite <- cols[is.finite(cols)] 167s + } 167s + 167s + suppressWarnings({ 167s + actual <- tryCatch({ 167s + rowAvgsPerColSet(x, rows = rows, S = matrix(cols, ncol = 1), 167s + FUN = rowMeans) 167s + }, error = function(c) "error") 167s + expect <- tryCatch({ 167s + rowMeans(x[rows, cols_finite, drop = FALSE], na.rm = TRUE) 167s + }, error = function(c) "error") 167s + }) 167s + stopifnot(all.equal(as.vector(actual), expect)) 167s + 167s + suppressWarnings({ 167s + actual <- tryCatch({ 167s + colAvgsPerRowSet(x, cols = cols, S = matrix(rows, ncol = 1), 167s + FUN = colMeans) 167s + }, error = function(c) "error") 167s + expect <- tryCatch({ 167s + colMeans(x[rows_finite, cols, drop = FALSE], na.rm = TRUE) 167s + }, error = function(c) "error") 167s + }) 167s + stopifnot(all.equal(as.vector(actual), expect)) 167s + } 167s + } 167s > 167s 167s R version 4.4.3 (2025-02-28) -- "Trophy Case" 167s Copyright (C) 2025 The R Foundation for Statistical Computing 167s Platform: s390x-ibm-linux-gnu 167s 167s R is free software and comes with ABSOLUTELY NO WARRANTY. 167s You are welcome to redistribute it under certain conditions. 167s Type 'license()' or 'licence()' for distribution details. 167s 167s R is a collaborative project with many contributors. 167s Type 'contributors()' for more information and 167s 'citation()' on how to cite R or R packages in publications. 167s 167s Type 'demo()' for some demos, 'help()' for on-line help, or 167s 'help.start()' for an HTML browser interface to help. 167s Type 'q()' to quit R. 167s 167s > library("matrixStats") 167s > 167s > x <- matrix(1:27, ncol = 3) 167s > 167s > # To check names attribute 167s > dimnames <- list(letters[1:9], LETTERS[1:3]) 167s > 167s > rowCollapse_R <- function(x, idxs, ..., useNames = TRUE) { 167s + res <- x[, idxs] 167s + # Preserve names attribute? 167s + if (!useNames) names(res) <- NULL 167s + res 167s + } 167s > 167s > idxs <- 1L 167s > # Test with and without dimnames on x 167s > for (setDimnames in c(TRUE, FALSE)) { 167s + if (setDimnames) dimnames(x) <- dimnames 167s + else dimnames(x) <- NULL 167s + # Check names attribute 167s + for (useNames in c(TRUE, FALSE)) { 167s + y_truth <- rowCollapse_R(x, idxs, useNames = useNames) 167s + y <- rowCollapse(x, idxs, useNames = useNames) 167s + stopifnot(identical(y, y_truth)) 167s + y2 <- colCollapse(t(x), idxs, useNames = useNames) 167s + stopifnot(identical(y2, y)) 167s + } 167s + } 167s > 167s > idxs <- 2L 167s > # Test with and without dimnames on x 167s > for (setDimnames in c(TRUE, FALSE)) { 167s + if (setDimnames) dimnames(x) <- dimnames 167s + else dimnames(x) <- NULL 167s + # Check names attribute 167s + for (useNames in c(TRUE, FALSE)) { 167s + y_truth <- rowCollapse_R(x, idxs, useNames = useNames) 167s + y <- rowCollapse(x, idxs, useNames = useNames) 167s + stopifnot(identical(y, y_truth)) 167s + y2 <- colCollapse(t(x), idxs, useNames = useNames) 167s + stopifnot(identical(y2, y)) 167s + } 167s + } 167s > 167s > 167s > rowCollapse_R <- function(x, idxs, ..., useNames = TRUE) { 167s + res <- c(x[1:5, 1], x[6:9, 3]) 167s + # Preserve names attribute? 167s + if (!useNames) names(res) <- NULL 167s + res 167s + } 167s > 167s > idxs <- c(1, 1, 1, 1, 1, 3, 3, 3, 3) 167s > # Test with and without dimnames on x 167s > for (setDimnames in c(TRUE, FALSE)) { 167s + if (setDimnames) dimnames(x) <- dimnames 167s + else dimnames(x) <- NULL 167s + # Check names attribute 167s + for (useNames in c(TRUE, FALSE)) { 167s + y_truth <- rowCollapse_R(x, idxs, useNames = useNames) 167s + y <- rowCollapse(x, idxs, useNames = useNames) 167s + stopifnot(identical(y, y_truth)) 167s + y2 <- colCollapse(t(x), idxs, useNames = useNames) 167s + stopifnot(identical(y2, y)) 167s + } 167s + } 167s > 167s > 167s > rowCollapse_R <- function(x, idxs, ..., useNames = TRUE) { 167s + res <- c(x[1, 1], x[2, 2], x[3, 3], x[4, 1], x[5, 2], 167s + x[6, 3], x[7, 1], x[8, 2], x[9, 3]) 167s + # Preserve names attribute? 167s + if (useNames) { 167s + names <- rownames(x) 167s + if (!is.null(names)) names(res) <- names 167s + } 167s + res 167s + } 167s > 167s > idxs <- 1:3 167s > # Test with and without dimnames on x 167s > for (setDimnames in c(TRUE, FALSE)) { 167s + if (setDimnames) dimnames(x) <- dimnames 167s + else dimnames(x) <- NULL 167s + # Check names attribute 167s + for (useNames in c(TRUE, FALSE)) { 167s + y_truth <- rowCollapse_R(x, idxs, useNames = useNames) 167s + y <- rowCollapse(x, idxs, useNames = useNames) 167s + stopifnot(identical(y, y_truth)) 167s + y2 <- colCollapse(t(x), idxs, useNames = useNames) 167s + stopifnot(identical(y2, y)) 167s + } 167s + } 167s > 168s 168s R version 4.4.3 (2025-02-28) -- "Trophy Case" 168s Copyright (C) 2025 The R Foundation for Statistical Computing 168s Platform: s390x-ibm-linux-gnu 168s 168s R is free software and comes with ABSOLUTELY NO WARRANTY. 168s You are welcome to redistribute it under certain conditions. 168s Type 'license()' or 'licence()' for distribution details. 168s 168s R is a collaborative project with many contributors. 168s Type 'contributors()' for more information and 168s 'citation()' on how to cite R or R packages in publications. 168s 168s Type 'demo()' for some demos, 'help()' for on-line help, or 168s 'help.start()' for an HTML browser interface to help. 168s Type 'q()' to quit R. 168s 168s > library("matrixStats") 168s > 168s > rowCollapse_R <- function(x, idxs, ..., useNames = TRUE) { 168s + ans <- c() 168s + storage.mode(ans) <- storage.mode(x) 168s + for (ii in seq_len(length(idxs))) { 168s + ans[ii] <- x[ii, idxs[ii]] 168s + } 168s + 168s + # Preserve names attribute 168s + if (useNames) { 168s + names <- rownames(x) 168s + if (!is.null(names)) names(ans) <- names 168s + } 168s + 168s + ans 168s + } 168s > 168s > 168s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 168s > # Subsetted tests 168s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 168s > source("utils/validateIndicesFramework.R") 168s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 168s > storage.mode(x) <- "integer" 168s > 168s > # To check names attribute 168s > dimnames <- list(letters[1:6], LETTERS[1:6]) 168s > 168s > for (rows in index_cases) { 168s + if (is.null(rows)) rows <- seq_len(nrow(x)) 168s + 168s + for (idxs in list(2L, seq_len(6L))) { 168s + for (useNames in c(TRUE, FALSE)) { 168s + suppressWarnings({ 168s + actual <- tryCatch(rowCollapse(x, idxs, rows = rows, useNames = useNames), 168s + error = function(c) "error") 168s + expect <- tryCatch({ 168s + idxs_0 <- rep(idxs, length.out = nrow(x))[rows] 168s + rowCollapse_R(x[rows, , drop = FALSE], idxs_0, useNames = useNames) 168s + }, error = function(c) "error") 168s + }) 168s + stopifnot(all.equal(actual, expect)) 168s + 168s + suppressWarnings({ 168s + actual <- tryCatch(colCollapse(t(x), idxs, cols = rows, useNames = useNames), 168s + error = function(c) "error") 168s + }) 168s + stopifnot(all.equal(actual, expect)) 168s + 168s + # Check names attribute 168s + dimnames(x) <- dimnames 168s + suppressWarnings({ 168s + actual <- tryCatch(rowCollapse(x, idxs, rows = rows, useNames = useNames), 168s + error = function(c) "error") 168s + expect <- tryCatch({ 168s + idxs_0 <- rep(idxs, length.out = nrow(x))[rows] 168s + rowCollapse_R(x[rows, , drop = FALSE], idxs_0, useNames = useNames) 168s + }, error = function(c) "error") 168s + }) 168s + stopifnot(all.equal(actual, expect)) 168s + 168s + suppressWarnings({ 168s + actual <- tryCatch(colCollapse(t(x), idxs, cols = rows, useNames = useNames), 168s + error = function(c) "error") 168s + }) 168s + stopifnot(all.equal(actual, expect)) 168s + 168s + dimnames(x) <- NULL 168s + } 168s + } 168s + } 168s > 168s 168s R version 4.4.3 (2025-02-28) -- "Trophy Case" 168s Copyright (C) 2025 The R Foundation for Statistical Computing 168s Platform: s390x-ibm-linux-gnu 168s 168s R is free software and comes with ABSOLUTELY NO WARRANTY. 168s You are welcome to redistribute it under certain conditions. 168s Type 'license()' or 'licence()' for distribution details. 168s 168s R is a collaborative project with many contributors. 168s Type 'contributors()' for more information and 168s 'citation()' on how to cite R or R packages in publications. 168s 168s Type 'demo()' for some demos, 'help()' for on-line help, or 168s 'help.start()' for an HTML browser interface to help. 168s Type 'q()' to quit R. 168s 168s > library("matrixStats") 168s > 168s > rowCounts_R <- function(x, value = TRUE, na.rm = FALSE, ...) { 168s + if (is.na(value)) { 168s + counts <- apply(x, MARGIN = 1L, FUN = function(x) 168s + sum(is.na(x)) 168s + ) 168s + } else { 168s + counts <- apply(x, MARGIN = 1L, FUN = function(x) 168s + sum(x == value, na.rm = na.rm) 168s + ) 168s + } 168s + # Preserve names attribute 168s + names <- names(counts) 168s + counts <- as.integer(counts) 168s + if (useNames && !is.null(names)) names(counts) <- names 168s + counts 168s + } 168s > 168s > 168s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 168s > # Data type: integer and numeric 168s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 168s > for (mode in c("integer", "double")) { 168s + x <- matrix(runif(10 * 5, min = -3, max = 3), nrow = 10L, ncol = 5L) 168s + x[sample.int(length(x), size = 7L)] <- 0 168s + storage.mode(x) <- mode 168s + 168s + dimnames = list(letters[1:10], LETTERS[1:5]) 168s + 168s + # Test with and without dimnames on x 168s + for (setDimnames in c(TRUE, FALSE)) { 168s + if (setDimnames) dimnames(x) <- dimnames 168s + else dimnames(x) <- NULL 168s + for (na.rm in c(FALSE, TRUE)) { 168s + # Check names attribute 168s + for (useNames in c(TRUE, FALSE)) { 168s + # Count zeros 168s + r0 <- rowCounts_R(x, value = 0, na.rm = na.rm, useNames = useNames) 168s + r1 <- rowCounts(x, value = 0, na.rm = na.rm, useNames = useNames) 168s + r2 <- colCounts(t(x), value = 0, na.rm = na.rm, useNames = useNames) 168s + stopifnot(identical(r1, r0)) 168s + stopifnot(identical(r2, r0)) 168s + 168s + # Count NAs 168s + r0 <- rowCounts_R(x, value = NA, na.rm = na.rm, useNames = useNames) 168s + r1 <- rowCounts(x, value = NA, na.rm = na.rm, useNames = useNames) 168s + r2 <- colCounts(t(x), value = NA, na.rm = na.rm, useNames = useNames) 168s + stopifnot(identical(r1, r0)) 168s + stopifnot(identical(r2, r0)) 168s + 168s + if (mode == "integer") { 168s + ux <- unique(as.vector(x)) 168s + r0 <- r1 <- r2 <- integer(nrow(x)) 168s + for (value in ux) { 168s + r0 <- r0 + rowCounts_R(x, value = value, na.rm = na.rm, useNames = useNames) 168s + r1 <- r1 + rowCounts(x, value = value, na.rm = na.rm, useNames = useNames) 168s + r2 <- r2 + colCounts(t(x), value = value, na.rm = na.rm, useNames = useNames) 168s + stopifnot(identical(r1, r0)) 168s + stopifnot(identical(r2, r0)) 168s + } 168s + stopifnot(all(r0 == ncol(x))) 168s + } # if (mode == "integer") 168s + } # for (useNames ...) 168s + } # for (na.rm ...) 168s + } # for (setDimnames ...) 168s + } # for (mode ...) 168s > 168s > 168s > # All NAs 168s > na_list <- list(NA_integer_, NA_real_, NaN) 168s > for (na_value in na_list) { 168s + x <- matrix(na_value, nrow = 10L, ncol = 5L) 168s + # Test with and without dimnames on x 168s + for (setDimnames in c(TRUE, FALSE)) { 168s + if (setDimnames) dimnames(x) <- dimnames 168s + else dimnames(x) <- NULL 168s + for (na.rm in c(FALSE, TRUE)) { 168s + # Check names attribute 168s + for (useNames in c(TRUE, FALSE)) { 168s + r0 <- rowCounts_R(x, na.rm = na.rm, useNames = useNames) 168s + r1 <- rowCounts(x, na.rm = na.rm, useNames = useNames) 168s + r2 <- colCounts(t(x), na.rm = na.rm, useNames = useNames) 168s + stopifnot(identical(r1, r0)) 168s + stopifnot(identical(r2, r0)) 168s + 168s + # Count NAs 168s + r0 <- rowCounts_R(x, value = NA, na.rm = na.rm, useNames = useNames) 168s + r1 <- rowCounts(x, value = NA, na.rm = na.rm, useNames = useNames) 168s + r2 <- colCounts(t(x), value = NA, na.rm = na.rm, useNames = useNames) 168s + stopifnot(all(r0 == ncol(x))) 168s + stopifnot(identical(r1, r0)) 168s + stopifnot(identical(r2, r0)) 168s + } 168s + } 168s + } 168s + } # for (na_value ...) 168s > 168s > 168s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 168s > # Data type: logical 168s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 168s > x <- matrix(FALSE, nrow = 10L, ncol = 4L) 168s > x[7:8, 2:3] <- TRUE 168s > x[1:3, ] <- TRUE 168s > x[, 1] <- TRUE 168s > x[4, ] <- FALSE 168s > x[, 4] <- FALSE 168s > x[2, ] <- FALSE 168s > x[3, ] <- TRUE 168s > 168s > # To check names attribute 168s > dimnames <- list(letters[1:10], LETTERS[1:4]) 168s > 168s > # Test with and without dimnames on x 168s > for (setDimnames in c(TRUE, FALSE)) { 168s + if (setDimnames) dimnames(x) <- dimnames 168s + else dimnames(x) <- NULL 168s + # Row/column counts 168s + for (na.rm in c(FALSE, TRUE)) { 168s + # Check names attribute 168s + for (useNames in c(TRUE, FALSE)) { 168s + r0 <- rowCounts_R(x, na.rm = na.rm, useNames = useNames) 168s + r1 <- rowCounts(x, na.rm = na.rm, useNames = useNames) 168s + r2 <- colCounts(t(x), na.rm = na.rm, useNames = useNames) 168s + stopifnot(identical(r1, r0)) 168s + stopifnot(identical(r2, r0)) 168s + 168s + r_true <- rowCounts(x, value = TRUE, na.rm = na.rm, useNames = useNames) 168s + r_false <- rowCounts(x, value = FALSE, na.rm = na.rm, useNames = useNames) 168s + stopifnot(r_true + r_false == ncol(x)) 168s + 168s + c_true <- colCounts(x, value = TRUE, na.rm = na.rm, useNames = useNames) 168s + c_false <- colCounts(x, value = FALSE, na.rm = na.rm, useNames = useNames) 168s + stopifnot(c_true + c_false == nrow(x)) 168s + 168s + # Count NAs 168s + r0 <- rowCounts_R(x, value = NA, na.rm = na.rm, useNames = useNames) 168s + r1 <- rowCounts(x, value = NA, na.rm = na.rm, useNames = useNames) 168s + r2 <- colCounts(t(x), value = NA, na.rm = na.rm, useNames = useNames) 168s + stopifnot(identical(r1, r0)) 168s + stopifnot(identical(r2, r0)) 168s + } 168s + } 168s + } 168s > 168s > 168s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 168s > # Data type: character (not sure if this should be supported) 168s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 168s > x <- matrix(rep(letters, length.out = 10 * 5), nrow = 10L, ncol = 5L) 168s > x[2:3, 3:4] <- NA_character_ 168s > 168s > # Row/column counts 168s > for (na.rm in c(FALSE, TRUE)) { 168s + for (value in c("g", NA_character_)) { 168s + r0 <- rowCounts_R(x, value = value, na.rm = na.rm) 168s + r1 <- rowCounts(x, value = value, na.rm = na.rm) 168s + r2 <- colCounts(t(x), value = value, na.rm = na.rm) 168s + stopifnot(identical(r1, r0)) 168s + stopifnot(identical(r2, r0)) 168s + 168s + c <- count(x[1, ], value = value, na.rm = na.rm) 168s + stopifnot(identical(c, r1[1])) 168s + 168s + c <- count(x[2, ], value = value, na.rm = na.rm) 168s + stopifnot(identical(c, r1[2])) 168s + } 168s + } 168s > 168s > # NA row 168s > x <- matrix(0, nrow = 2L, ncol = 2L) 168s > x[1, ] <- NA_integer_ 168s > 168s > dimnames <- list(letters[1:2], LETTERS[1:2]) 168s > 168s > # Test with and without dimnames on x 168s > for (setDimnames in c(TRUE, FALSE)) { 168s + if (setDimnames) dimnames(x) <- dimnames 168s + else dimnames(x) <- NULL 168s + # Check names attribute 168s + for (useNames in c(TRUE, FALSE)) { 168s + r0 <- rowCounts(x, value = 0, useNames = useNames) 168s + r1 <- rowCounts_R(x, value = 0, useNames = useNames) 168s + stopifnot(identical(r0, r1)) 168s + } 168s + } 168s > 168s 168s R version 4.4.3 (2025-02-28) -- "Trophy Case" 168s Copyright (C) 2025 The R Foundation for Statistical Computing 168s Platform: s390x-ibm-linux-gnu 168s 168s R is free software and comes with ABSOLUTELY NO WARRANTY. 168s You are welcome to redistribute it under certain conditions. 168s Type 'license()' or 'licence()' for distribution details. 168s 168s R is a collaborative project with many contributors. 168s Type 'contributors()' for more information and 168s 'citation()' on how to cite R or R packages in publications. 168s 168s Type 'demo()' for some demos, 'help()' for on-line help, or 168s 'help.start()' for an HTML browser interface to help. 168s Type 'q()' to quit R. 168s 168s > library("matrixStats") 168s > 168s > rowCounts_R <- function(x, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) { 168s + if (is.na(value)) { 168s + counts <- apply(x, MARGIN = 1L, FUN = function(x) 168s + sum(is.na(x)) 168s + ) 168s + } else { 168s + counts <- apply(x, MARGIN = 1L, FUN = function(x) 168s + sum(x == value, na.rm = na.rm) 168s + ) 168s + } 168s + # Preserve names attribute 168s + names <- names(counts) 168s + counts <- as.integer(counts) 168s + if (useNames && !is.null(names)) names(counts) <- names 168s + counts 168s + } # rowCounts_R() 168s > 168s > 168s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 168s > # Subsetted tests 168s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 168s > source("utils/validateIndicesFramework.R") 168s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 168s > x[2:3, 3:4] <- NA_real_ 168s > storage.mode(x) <- "integer" 168s > 168s > # To check names attribute 168s > dimnames <- list(letters[1:6], LETTERS[1:6]) 168s > 168s > # Test with and without dimnames on x 168s > for (setDimnames in c(TRUE, FALSE)) { 168s + if (setDimnames) dimnames(x) <- dimnames 168s + else dimnames(x) <- NULL 168s + for (rows in index_cases) { 168s + for (cols in index_cases) { 168s + # Check names attribute 168s + for (useNames in c(TRUE, FALSE)) { 168s + validateIndicesTestMatrix(x, rows, cols, 168s + ftest = rowCounts, fsure = rowCounts_R, 168s + value = 0, na.rm = TRUE, useNames = useNames) 168s + validateIndicesTestMatrix(x, rows, cols, 168s + fcoltest = colCounts, fsure = rowCounts_R, 168s + value = 0, na.rm = TRUE, useNames = useNames) 168s + for (value in c(0, NA_integer_)) { 168s + validateIndicesTestMatrix(x, rows, cols, 168s + ftest = rowCounts, fsure = rowCounts_R, 168s + value = value, useNames = useNames) 168s + validateIndicesTestMatrix(x, rows, cols, 168s + fcoltest = colCounts, fsure = rowCounts_R, 168s + value = value, useNames = useNames) 168s + } 168s + } 168s + } 168s + } 168s + } 170s > 170s > x <- matrix(rep(letters, length.out = 6 * 6), nrow = 6, ncol = 6) 170s > x[2:3, 3:4] <- NA_character_ 170s > # Test with and without dimnames on x 170s > for (setDimnames in c(TRUE, FALSE)) { 170s + if (setDimnames) dimnames(x) <- dimnames 170s + else dimnames(x) <- NULL 170s + 170s + count <- 0L 170s + for (rows in index_cases) { 170s + for (cols in index_cases) { 170s + count <- count + 1L 170s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 170s + useNames <- c(TRUE, FALSE) 170s + useNames <- useNames[count %% length(useNames) + 1] 170s + 170s + validateIndicesTestMatrix(x, rows, cols, 170s + ftest = rowCounts, fsure = rowCounts_R, 170s + value = "g", na.rm = TRUE, useNames = useNames) 170s + validateIndicesTestMatrix(x, rows, cols, 170s + fcoltest = colCounts, fsure = rowCounts_R, 170s + value = "g", na.rm = TRUE, useNames = useNames) 170s + for (value in c("g", NA_character_)) { 170s + validateIndicesTestMatrix(x, rows, cols, 170s + ftest = rowCounts, fsure = rowCounts_R, 170s + value = value, useNames = useNames) 170s + validateIndicesTestMatrix(x, rows, cols, 170s + fcoltest = colCounts, fsure = rowCounts_R, 170s + value = value, useNames = useNames) 170s + } 170s + } 170s + } 170s + } 170s > 170s 170s R version 4.4.3 (2025-02-28) -- "Trophy Case" 170s Copyright (C) 2025 The R Foundation for Statistical Computing 170s Platform: s390x-ibm-linux-gnu 170s 170s R is free software and comes with ABSOLUTELY NO WARRANTY. 170s You are welcome to redistribute it under certain conditions. 170s Type 'license()' or 'licence()' for distribution details. 170s 170s R is a collaborative project with many contributors. 170s Type 'contributors()' for more information and 170s 'citation()' on how to cite R or R packages in publications. 170s 170s Type 'demo()' for some demos, 'help()' for on-line help, or 170s 'help.start()' for an HTML browser interface to help. 170s Type 'q()' to quit R. 170s 170s > library("matrixStats") 171s > 171s > rowCummins_R <- function(x, ..., useNames = TRUE) { 171s + suppressWarnings({ 171s + y <- t(apply(x, MARGIN = 1L, FUN = cummin)) 171s + }) 171s + 171s + # Preserve dimnames attribute? 171s + dim(y) <- dim(x) 171s + dimnames(y) <- if (useNames) dimnames(x) else NULL 171s + y 171s + } 171s > 171s > rowCummaxs_R <- function(x, ..., useNames = TRUE) { 171s + mode <- storage.mode(x) 171s + # Change mode because a bug is detected on cummax for integer in R-3.2.0 171s + storage.mode(x) <- "numeric" 171s + suppressWarnings({ 171s + y <- t(apply(x, MARGIN = 1L, FUN = cummax)) 171s + }) 171s + 171s + # Preserve dimnames attribute? 171s + dim(y) <- dim(x) 171s + dimnames(y) <- if (useNames) dimnames(x) else NULL 171s + 171s + y 171s + } 171s > 171s > 171s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 171s > # With and without some NAs 171s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 171s > for (mode in c("logical", "integer", "double")) { 171s + for (add_na in c(FALSE, TRUE)) { 171s + cat("add_na = ", add_na, "\n", sep = "") 171s + 171s + x <- matrix(1:50, nrow = 10L, ncol = 5L) 171s + diag(x) <- 0 171s + if (add_na) { 171s + x[3:7, c(2, 4)] <- NA_real_ 171s + } 171s + cat("mode: ", mode, "\n", sep = "") 171s + storage.mode(x) <- mode 171s + str(x) 171s + 171s + # To check dimnames attribute 171s + dimnames <- list(letters[1:10], LETTERS[1:5]) 171s + 171s + # Test with and without dimnames on x 171s + for (setDimnames in c(TRUE, FALSE)) { 171s + if (setDimnames) dimnames(x) <- dimnames 171s + else dimnames(x) <- NULL 171s + # Check names attribute 171s + for (useNames in c(TRUE, FALSE)) { 171s + # Row/column ranges 171s + r0 <- rowCummins_R(x, useNames = useNames) 171s + r1 <- rowCummins(x, useNames = useNames) 171s + r2 <- t(colCummins(t(x), useNames = useNames)) 171s + stopifnot(all.equal(r1, r2)) 171s + stopifnot(all.equal(r1, r0)) 171s + stopifnot(all.equal(r2, r0)) 171s + 171s + r0 <- rowCummaxs_R(x, useNames = useNames) 171s + r1 <- rowCummaxs(x, useNames = useNames) 171s + r2 <- t(colCummaxs(t(x), useNames = useNames)) 171s + stopifnot(all.equal(r1, r2)) 171s + stopifnot(all.equal(r1, r0)) 171s + stopifnot(all.equal(r2, r0)) 171s + } # for (useNames ...) 171s + } # for (setDimnames ...) 171s + } # for (add_na ...) 171s + } # for (mode ...) 171s add_na = FALSE 171s mode: logical 171s logi [1:10, 1:5] FALSE TRUE TRUE TRUE TRUE TRUE ... 171s add_na = TRUE 171s mode: logical 171s logi [1:10, 1:5] FALSE TRUE TRUE TRUE TRUE TRUE ... 171s add_na = FALSE 171s mode: integer 171s int [1:10, 1:5] 0 2 3 4 5 6 7 8 9 10 ... 171s add_na = TRUE 171s mode: integer 171s int [1:10, 1:5] 0 2 3 4 5 6 7 8 9 10 ... 171s add_na = FALSE 171s mode: double 171s num [1:10, 1:5] 0 2 3 4 5 6 7 8 9 10 ... 171s add_na = TRUE 171s mode: double 171s num [1:10, 1:5] 0 2 3 4 5 6 7 8 9 10 ... 171s > 171s > 171s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 171s > # All NAs 171s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 171s > for (mode in c("logical", "integer", "double")) { 171s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 171s + cat("mode: ", mode, "\n", sep = "") 171s + storage.mode(x) <- mode 171s + str(x) 171s + 171s + # Test with and without dimnames on x 171s + for (setDimnames in c(TRUE, FALSE)) { 171s + if (setDimnames) dimnames(x) <- dimnames 171s + else dimnames(x) <- NULL 171s + # Check names attribute 171s + for (useNames in c(TRUE, FALSE)) { 171s + r0 <- rowCummins_R(x, useNames = useNames) 171s + r1 <- rowCummins(x, useNames = useNames) 171s + r2 <- t(colCummins(t(x), useNames = useNames)) 171s + stopifnot(all.equal(r1, r2)) 171s + stopifnot(all.equal(r1, r0)) 171s + stopifnot(all.equal(r2, r0)) 171s + 171s + r0 <- rowCummaxs_R(x, useNames = useNames) 171s + r1 <- rowCummaxs(x, useNames = useNames) 171s + r2 <- t(colCummaxs(t(x), useNames = useNames)) 171s + stopifnot(all.equal(r1, r2)) 171s + stopifnot(all.equal(r1, r0)) 171s + stopifnot(all.equal(r2, r0)) 171s + } # for (useNames ...) 171s + } # for (setDimnames ...) 171s + } # for (mode ...) 171s mode: logical 171s logi [1:10, 1:5] NA NA NA NA NA NA ... 171s mode: integer 171s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 171s mode: double 171s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 171s > 171s > 171s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 171s > # A 1x1 matrix 171s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 171s > for (mode in c("logical", "integer", "double")) { 171s + x <- matrix(0, nrow = 1L, ncol = 1L) 171s + cat("mode: ", mode, "\n", sep = "") 171s + storage.mode(x) <- mode 171s + str(x) 171s + 171s + # To check dimnames attribute 171s + dimnames <- list("a", "A") 171s + 171s + # Test with and without dimnames on x 171s + for (setDimnames in c(TRUE, FALSE)) { 171s + if (setDimnames) dimnames(x) <- dimnames 171s + else dimnames(x) <- NULL 171s + # Check names attribute 171s + for (useNames in c(TRUE, FALSE)) { 171s + r0 <- rowCummins_R(x, useNames = useNames) 171s + r1 <- rowCummins(x, useNames = useNames) 171s + r2 <- t(colCummins(t(x), useNames = useNames)) 171s + stopifnot(all.equal(r1, r2)) 171s + stopifnot(all.equal(r1, r0)) 171s + stopifnot(all.equal(r2, r0)) 171s + 171s + r0 <- rowCummaxs_R(x, useNames = useNames) 171s + r1 <- rowCummaxs(x, useNames = useNames) 171s + r2 <- t(colCummaxs(t(x), useNames = useNames)) 171s + stopifnot(all.equal(r1, r2)) 171s + stopifnot(all.equal(r1, r0)) 171s + stopifnot(all.equal(r2, r0)) 171s + } # for (useNames ...) 171s + } # for (setDimnames ...) 171s + } # for (mode ...) 171s mode: logical 171s logi [1, 1] FALSE 171s mode: integer 171s int [1, 1] 0 171s mode: double 171s num [1, 1] 0 171s > 171s > 171s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 171s > # Corner cases 171s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 171s > for (mode in c("logical", "integer", "double")) { 171s + cat("mode: ", mode, "\n", sep = "") 171s + value <- 0 171s + storage.mode(value) <- mode 171s + value0 <- if (mode == "logical") 0L else value 171s + 171s + # A 0x0 matrix 171s + x <- matrix(value, nrow = 0L, ncol = 0L) 171s + str(x) 171s + r0 <- matrix(value0, nrow = nrow(x), ncol = ncol(x)) 171s + r1 <- rowCummins(x) 171s + r2 <- t(colCummins(t(x))) 171s + stopifnot(all.equal(r1, r2)) 171s + stopifnot(all.equal(r1, r0)) 171s + stopifnot(all.equal(r2, r0)) 171s + 171s + # A 0xK matrix 171s + x <- matrix(value, nrow = 0L, ncol = 5L) 171s + str(x) 171s + colnames <- LETTERS[1:5] 171s + # Test with and without dimnames on x 171s + for (setDimnames in c(TRUE, FALSE)) { 171s + if (setDimnames) colnames(x) <- colnames 171s + else dimnames(x) <- NULL 171s + # Check names attribute 171s + for (useNames in c(TRUE, FALSE)) { 171s + r0 <- rowCummins_R(x, useNames = useNames) 171s + r1 <- rowCummins(x, useNames = useNames) 171s + r2 <- t(colCummins(t(x), useNames = useNames)) 171s + stopifnot(all.equal(r1, r2)) 171s + stopifnot(all.equal(r1, r0)) 171s + stopifnot(all.equal(r2, r0)) 171s + r0 <- rowCummaxs_R(x, useNames = useNames) 171s + r1 <- rowCummaxs(x, useNames = useNames) 171s + r2 <- t(colCummaxs(t(x), useNames = useNames)) 171s + stopifnot(all.equal(r1, r2)) 171s + stopifnot(all.equal(r1, r0)) 171s + stopifnot(all.equal(r2, r0)) 171s + } # for (useNames ...) 171s + } # for (setDimnames ...) 171s + 171s + # A Nx0 matrix 171s + x <- matrix(value, nrow = 5L, ncol = 0L) 171s + str(x) 171s + rownames <- LETTERS[1:5] 171s + # Test with and without dimnames on x 171s + for (setDimnames in c(TRUE, FALSE)) { 171s + if (setDimnames) rownames(x) <- rownames 171s + else dimnames(x) <- NULL 171s + # Check names attribute 171s + for (useNames in c(TRUE, FALSE)) { 171s + r0 <- rowCummins_R(x, useNames = useNames) 171s + r1 <- rowCummins(x, useNames = useNames) 171s + r2 <- t(colCummins(t(x), useNames = useNames)) 171s + stopifnot(all.equal(r1, r2)) 171s + stopifnot(all.equal(r1, r0)) 171s + stopifnot(all.equal(r2, r0)) 171s + 171s + r0 <- rowCummaxs_R(x, useNames = useNames) 171s + r1 <- rowCummaxs(x, useNames = useNames) 171s + r2 <- t(colCummaxs(t(x), useNames = useNames)) 171s + stopifnot(all.equal(r1, r2)) 171s + stopifnot(all.equal(r1, r0)) 171s + stopifnot(all.equal(r2, r0)) 171s + } # for (useNames ...) 171s + } # for (setDimnames ...) 171s + } # for (mode ...) 171s mode: logical 171s logi[0 , 0 ] 171s logi[0 , 1:5] 171s logi[1:5, 0 ] 171s mode: integer 171s int[0 , 0 ] 171s int[0 , 1:5] 171s int[1:5, 0 ] 171s mode: double 171s num[0 , 0 ] 171s num[0 , 1:5] 171s num[1:5, 0 ] 171s > 171s 171s R version 4.4.3 (2025-02-28) -- "Trophy Case" 171s Copyright (C) 2025 The R Foundation for Statistical Computing 171s Platform: s390x-ibm-linux-gnu 171s 171s R is free software and comes with ABSOLUTELY NO WARRANTY. 171s You are welcome to redistribute it under certain conditions. 171s Type 'license()' or 'licence()' for distribution details. 171s 171s R is a collaborative project with many contributors. 171s Type 'contributors()' for more information and 171s 'citation()' on how to cite R or R packages in publications. 171s 171s Type 'demo()' for some demos, 'help()' for on-line help, or 171s 'help.start()' for an HTML browser interface to help. 171s Type 'q()' to quit R. 171s 171s > library("matrixStats") 171s > 171s > rowCummins_R <- function(x, ..., useNames = TRUE) { 171s + suppressWarnings({ 171s + y <- t(apply(x, MARGIN = 1L, FUN = cummin)) 171s + }) 171s + 171s + # Preserve dimnames attribute? 171s + dim(y) <- dim(x) 171s + dimnames(y) <- if (useNames) dimnames(x) else NULL 171s + 171s + y 171s + } 171s > 171s > rowCummaxs_R <- function(x, ..., useNames = TRUE) { 171s + mode <- storage.mode(x) 171s + # Change mode because a bug is detected on cummax for integer in R-3.2.0 171s + storage.mode(x) <- "numeric" 171s + suppressWarnings({ 171s + y <- t(apply(x, MARGIN = 1L, FUN = cummax)) 171s + }) 171s + 171s + # Preserve dimnames attribute? 171s + dim(y) <- dim(x) 171s + dimnames(y) <- if (useNames) dimnames(x) else NULL 171s + 171s + storage.mode(y) <- mode 171s + y 171s + } 171s > 171s > 171s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 171s > # Subsetted tests 171s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 171s > source("utils/validateIndicesFramework.R") 171s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 171s > storage.mode(x) <- "integer" 171s > 171s > # To check dimnames attribute 171s > dimnames <- list(letters[1:6], LETTERS[1:6]) 171s > 171s > # Test with and without dimnames on x 171s > for (setDimnames in c(TRUE, FALSE)) { 171s + if (setDimnames) dimnames(x) <- dimnames 171s + else dimnames(x) <- NULL 171s + for (rows in index_cases) { 171s + for (cols in index_cases) { 171s + # Check names attribute 171s + for (useNames in c(TRUE, FALSE)) { 171s + validateIndicesTestMatrix(x, rows, cols, 171s + ftest = rowCummins, fsure = rowCummins_R, useNames = useNames,verbose=TRUE) 171s + validateIndicesTestMatrix(x, rows, cols, 171s + ftest = function(x, rows, cols, ..., useNames) { 171s + t(colCummins(t(x), rows = cols, cols = rows, useNames = useNames)) 171s + }, fsure = rowCummins_R, useNames = useNames) 171s + 171s + validateIndicesTestMatrix(x, rows, cols, 171s + ftest = rowCummaxs, fsure = rowCummaxs_R, useNames = useNames) 171s + validateIndicesTestMatrix(x, rows, cols, 171s + ftest = function(x, rows, cols, ..., useNames) { 171s + t(colCummaxs(t(x), rows = cols, cols = rows, useNames = useNames)) 171s + }, fsure = rowCummaxs_R, useNames = useNames) 171s + } 171s + } 171s + } 171s + } 172s > 173s 173s R version 4.4.3 (2025-02-28) -- "Trophy Case" 173s Copyright (C) 2025 The R Foundation for Statistical Computing 173s Platform: s390x-ibm-linux-gnu 173s 173s R is free software and comes with ABSOLUTELY NO WARRANTY. 173s You are welcome to redistribute it under certain conditions. 173s Type 'license()' or 'licence()' for distribution details. 173s 173s R is a collaborative project with many contributors. 173s Type 'contributors()' for more information and 173s 'citation()' on how to cite R or R packages in publications. 173s 173s Type 'demo()' for some demos, 'help()' for on-line help, or 173s 'help.start()' for an HTML browser interface to help. 173s Type 'q()' to quit R. 173s 173s > library("matrixStats") 173s > 173s > rowCumprods_R <- function(x, ..., useNames = TRUE) { 173s + suppressWarnings({ 173s + y <- t(apply(x, MARGIN = 1L, FUN = cumprod)) 173s + }) 173s + 173s + # Preserve dimnames attribute? 173s + dim(y) <- dim(x) 173s + dimnames(y) <- if (useNames) dimnames(x) else NULL 173s + 173s + y 173s + } 173s > 173s > 173s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 173s > # With and without some NAs 173s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 173s > for (mode in c("logical", "integer", "double")) { 173s + for (add_na in c(FALSE, TRUE)) { 173s + cat("add_na = ", add_na, "\n", sep = "") 173s + 173s + x <- matrix(1:50, nrow = 10L, ncol = 5L) 173s + if (add_na) { 173s + x[3:7, c(2, 4)] <- NA_real_ 173s + } 173s + cat("mode: ", mode, "\n", sep = "") 173s + storage.mode(x) <- mode 173s + str(x) 173s + 173s + # To check dimnames attribute 173s + dimnames <- list(letters[1:10], LETTERS[1:5]) 173s + 173s + # Test with and without dimnames on x 173s + for (setDimnames in c(TRUE, FALSE)) { 173s + if (setDimnames) dimnames(x) <- dimnames 173s + else dimnames(x) <- NULL 173s + # Check names attribute 173s + for (useNames in c(TRUE, FALSE)) { 173s + # Row/column ranges 173s + r0 <- rowCumprods_R(x, useNames = useNames) 173s + r1 <- rowCumprods(x, useNames = useNames) 173s + r2 <- t(colCumprods(t(x), useNames = useNames)) 173s + stopifnot(all.equal(r1, r2)) 173s + stopifnot(all.equal(r1, r0)) 173s + stopifnot(all.equal(r2, r0)) 173s + } # for (useNames ...) 173s + } # for (setDimnames ...) 173s + } # for (add_na ...) 173s + } # for (mode ...) 173s add_na = FALSE 173s mode: logical 173s logi [1:10, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 173s add_na = TRUE 173s mode: logical 173s logi [1:10, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 173s add_na = FALSE 173s mode: integer 173s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 173s add_na = TRUE 173s mode: integer 173s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 173s add_na = FALSE 173s mode: double 173s num [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 173s add_na = TRUE 173s mode: double 173s num [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 173s > 173s > 173s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 173s > # All NAs 173s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 173s > for (mode in c("logical", "integer", "double")) { 173s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 173s + cat("mode: ", mode, "\n", sep = "") 173s + storage.mode(x) <- mode 173s + str(x) 173s + 173s + # Test with and without dimnames on x 173s + for (setDimnames in c(TRUE, FALSE)) { 173s + if (setDimnames) dimnames(x) <- dimnames 173s + else dimnames(x) <- NULL 173s + # Check names attribute 173s + for (useNames in c(TRUE, FALSE)) { 173s + # Row/column ranges 173s + r0 <- rowCumprods_R(x, useNames = useNames) 173s + r1 <- rowCumprods(x, useNames = useNames) 173s + r2 <- t(colCumprods(t(x), useNames = useNames)) 173s + stopifnot(all.equal(r1, r2)) 173s + stopifnot(all.equal(r1, r0)) 173s + stopifnot(all.equal(r2, r0)) 173s + } # for (useNames ...) 173s + } # for (setDimnames ...) 173s + } # for (mode ...) 173s mode: logical 173s logi [1:10, 1:5] NA NA NA NA NA NA ... 173s mode: integer 173s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 173s mode: double 173s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 173s > 173s > 173s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 173s > # A 1x1 matrix 173s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 173s > for (mode in c("logical", "integer", "double")) { 173s + x <- matrix(0, nrow = 1L, ncol = 1L) 173s + cat("mode: ", mode, "\n", sep = "") 173s + storage.mode(x) <- mode 173s + str(x) 173s + 173s + dimnames <- list("a", "A") 173s + # Test with and without dimnames on x 173s + for (setDimnames in c(TRUE, FALSE)) { 173s + if (setDimnames) dimnames(x) <- dimnames 173s + else dimnames(x) <- NULL 173s + # Check names attribute 173s + for (useNames in c(TRUE, FALSE)) { 173s + # Row/column ranges 173s + r0 <- rowCumprods_R(x, useNames = useNames) 173s + r1 <- rowCumprods(x, useNames = useNames) 173s + r2 <- t(colCumprods(t(x), useNames = useNames)) 173s + stopifnot(all.equal(r1, r2)) 173s + stopifnot(all.equal(r1, r0)) 173s + stopifnot(all.equal(r2, r0)) 173s + } # for (useNames ...) 173s + } # for (setDimnames ...) 173s + } 173s mode: logical 173s logi [1, 1] FALSE 173s mode: integer 173s int [1, 1] 0 173s mode: double 173s num [1, 1] 0 173s > 173s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 173s > # BUG FIX TEST: Assert zeros don't trump NAs in integer matrices 173s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 173s > for (mode in c("logical", "integer", "double")) { 173s + x <- matrix(NA_real_, nrow = 3L, ncol = 2L) 173s + x[1, 2] <- 0 173s + x[2, 2] <- 1 173s + x[3, 1] <- 0 173s + storage.mode(x) <- mode 173s + cat("mode: ", mode, "\n", sep = "") 173s + str(x) 173s + 173s + dimnames <- list(letters[1:3], LETTERS[1:2]) 173s + # Test with and without dimnames on x 173s + for (setDimnames in c(TRUE, FALSE)) { 173s + if (setDimnames) dimnames(x) <- dimnames 173s + else dimnames(x) <- NULL 173s + # Check names attribute 173s + for (useNames in c(TRUE, FALSE)) { 173s + # Row/column ranges 173s + r0 <- rowCumprods_R(x, useNames = useNames) 173s + r1 <- rowCumprods(x, useNames = useNames) 173s + r2 <- t(colCumprods(t(x), useNames = useNames)) 173s + stopifnot(all.equal(r1, r2)) 173s + stopifnot(all.equal(r1, r0)) 173s + stopifnot(all.equal(r2, r0)) 173s + } # for (useNames ...) 173s + } # for (setDimnames ...) 173s + } 173s mode: logical 173s logi [1:3, 1:2] NA NA FALSE FALSE TRUE NA 173s mode: integer 173s int [1:3, 1:2] NA NA 0 0 1 NA 173s mode: double 173s num [1:3, 1:2] NA NA 0 0 1 NA 173s > 173s > 173s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 173s > # Corner cases 173s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 173s > for (mode in c("logical", "integer", "double")) { 173s + cat("mode: ", mode, "\n", sep = "") 173s + value <- 0 173s + storage.mode(value) <- mode 173s + if (mode == "logical") value2 <- 0L 173s + 173s + # A 0x0 matrix 173s + x <- matrix(value, nrow = 0L, ncol = 0L) 173s + str(x) 173s + r0 <- matrix(value2, nrow = nrow(x), ncol = ncol(x)) 173s + r1 <- rowCumprods(x) 173s + r2 <- t(colCumprods(t(x))) 173s + stopifnot(all.equal(r1, r2)) 173s + stopifnot(all.equal(r1, r0)) 173s + stopifnot(all.equal(r2, r0)) 173s + 173s + # A 0xK matrix 173s + x <- matrix(value, nrow = 0L, ncol = 5L) 173s + str(x) 173s + colnames <- LETTERS[1:5] 173s + # Test with and without dimnames on x 173s + for (setDimnames in c(TRUE, FALSE)) { 173s + if (setDimnames) colnames(x) <- colnames 173s + else dimnames(x) <- NULL 173s + # Check names attribute 173s + for (useNames in c(TRUE, FALSE)) { 173s + r0 <- rowCumprods_R(x, useNames = useNames) 173s + r1 <- rowCumprods(x, useNames = useNames) 173s + r2 <- t(rowCumprods(t(x), useNames = useNames)) 173s + stopifnot(all.equal(r1, r2)) 173s + stopifnot(all.equal(r1, r0)) 173s + stopifnot(all.equal(r2, r0)) 173s + } # for (useNames ...) 173s + } # for (setDimnames ...) 173s + 173s + # A Nx0 matrix 173s + x <- matrix(value, nrow = 5L, ncol = 0L) 173s + str(x) 173s + rownames <- LETTERS[1:5] 173s + # Test with and without dimnames on x 173s + for (setDimnames in c(TRUE, FALSE)) { 173s + if (setDimnames) rownames(x) <- rownames 173s + else dimnames(x) <- NULL 173s + # Check names attribute 173s + for (useNames in c(TRUE, FALSE)) { 173s + r0 <- rowCumprods_R(x, useNames = useNames) 173s + r1 <- rowCumprods(x, useNames = useNames) 173s + r2 <- t(rowCumprods(t(x), useNames = useNames)) 173s + stopifnot(all.equal(r1, r2)) 173s + stopifnot(all.equal(r1, r0)) 173s + stopifnot(all.equal(r2, r0)) 173s + } # for (useNames ...) 173s + } # for (setDimnames ...) 173s + } # for (mode ...) 173s mode: logical 173s logi[0 , 0 ] 173s logi[0 , 1:5] 173s logi[1:5, 0 ] 173s mode: integer 173s int[0 , 0 ] 173s int[0 , 1:5] 173s int[1:5, 0 ] 173s mode: double 173s num[0 , 0 ] 173s num[0 , 1:5] 173s num[1:5, 0 ] 173s > 173s 173s R version 4.4.3 (2025-02-28) -- "Trophy Case" 173s Copyright (C) 2025 The R Foundation for Statistical Computing 173s Platform: s390x-ibm-linux-gnu 173s 173s R is free software and comes with ABSOLUTELY NO WARRANTY. 173s You are welcome to redistribute it under certain conditions. 173s Type 'license()' or 'licence()' for distribution details. 173s 173s R is a collaborative project with many contributors. 173s Type 'contributors()' for more information and 173s 'citation()' on how to cite R or R packages in publications. 173s 173s Type 'demo()' for some demos, 'help()' for on-line help, or 173s 'help.start()' for an HTML browser interface to help. 173s Type 'q()' to quit R. 173s 173s > library("matrixStats") 173s > 173s > rowCumprods_R <- function(x, ..., useNames = TRUE) { 173s + suppressWarnings({ 173s + y <- t(apply(x, MARGIN = 1L, FUN = cumprod)) 173s + }) 173s + 173s + # Preserve dimnames attribute? 173s + dim(y) <- dim(x) 173s + dimnames(y) <- if (useNames) dimnames(x) else NULL 173s + 173s + y 173s + } 173s > 173s > 173s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 173s > # Subsetted tests 173s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 173s > source("utils/validateIndicesFramework.R") 173s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 173s > storage.mode(x) <- "integer" 173s > 173s > # To check dimnames attribute 173s > dimnames <- list(letters[1:6], LETTERS[1:6]) 173s > 173s > # Test with and without dimnames on x 173s > for (setDimnames in c(TRUE, FALSE)) { 173s + if (setDimnames) dimnames(x) <- dimnames 173s + else dimnames(x) <- NULL 173s + for (rows in index_cases) { 173s + for (cols in index_cases) { 173s + # Check names attribute 173s + for (useNames in c(TRUE, FALSE)) { 173s + validateIndicesTestMatrix(x, rows, cols, 173s + ftest = rowCumprods, fsure = rowCumprods_R, useNames = useNames) 173s + validateIndicesTestMatrix(x, rows, cols, 173s + ftest = function(x, rows, cols, ..., useNames) { 173s + t(colCumprods(t(x), rows = cols, cols = rows, useNames = useNames)) 173s + }, fsure = rowCumprods_R, useNames = useNames) 173s + } 173s + } 173s + } 173s + } 174s > 174s 174s R version 4.4.3 (2025-02-28) -- "Trophy Case" 174s Copyright (C) 2025 The R Foundation for Statistical Computing 174s Platform: s390x-ibm-linux-gnu 174s 174s R is free software and comes with ABSOLUTELY NO WARRANTY. 174s You are welcome to redistribute it under certain conditions. 174s Type 'license()' or 'licence()' for distribution details. 174s 174s R is a collaborative project with many contributors. 174s Type 'contributors()' for more information and 174s 'citation()' on how to cite R or R packages in publications. 174s 174s Type 'demo()' for some demos, 'help()' for on-line help, or 174s 'help.start()' for an HTML browser interface to help. 174s Type 'q()' to quit R. 174s 174s > library("matrixStats") 174s > 174s > rowCumsums_R <- function(x, ..., useNames = TRUE) { 174s + suppressWarnings({ 174s + y <- t(apply(x, MARGIN = 1L, FUN = cumsum)) 174s + }) 174s + 174s + # Preserve dimnames attribute? 174s + dim(y) <- dim(x) 174s + dimnames(y) <- if (useNames) dimnames(x) else NULL 174s + 174s + y 174s + } 174s > 174s > 174s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 174s > # With and without some NAs 174s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 174s > dimnames <- list(letters[1:10], LETTERS[1:5]) # to check dimnames attribute 174s > for (mode in c("logical", "integer", "double")) { 174s + for (add_na in c(FALSE, TRUE)) { 174s + cat("add_na = ", add_na, "\n", sep = "") 174s + 174s + x <- matrix(1:50, nrow = 10L, ncol = 5L) 174s + if (add_na) { 174s + x[3:7, c(2, 4)] <- NA_real_ 174s + } 174s + cat("mode: ", mode, "\n", sep = "") 174s + storage.mode(x) <- mode 174s + str(x) 174s + 174s + # Test with and without dimnames on x 174s + for (setDimnames in c(TRUE, FALSE)) { 174s + if (setDimnames) dimnames(x) <- dimnames 174s + else dimnames(x) <- NULL 174s + # Check names attribute 174s + for (useNames in c(TRUE, FALSE)) { 174s + # Row/column ranges 174s + r0 <- rowCumsums_R(x, useNames = useNames) 174s + r1 <- rowCumsums(x, useNames = useNames) 174s + r2 <- t(colCumsums(t(x), useNames = useNames)) 174s + stopifnot(all.equal(r1, r2)) 174s + stopifnot(all.equal(r1, r0)) 174s + stopifnot(all.equal(r2, r0)) 174s + } # for (useNames ...) 174s + } # for (setDimnames ...) 174s + } # for (add_na ...) 174s + } 174s add_na = FALSE 174s mode: logical 174s logi [1:10, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 174s add_na = TRUE 174s mode: logical 174s logi [1:10, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 174s add_na = FALSE 174s mode: integer 174s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 174s add_na = TRUE 174s mode: integer 174s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 174s add_na = FALSE 174s mode: double 174s num [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 174s add_na = TRUE 174s mode: double 174s num [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 174s > 174s > 174s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 174s > # All NAs 174s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 174s > for (mode in c("logical", "integer", "double")) { 174s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 174s + cat("mode: ", mode, "\n", sep = "") 174s + storage.mode(x) <- mode 174s + str(x) 174s + 174s + # Test with and without dimnames on x 174s + for (setDimnames in c(TRUE, FALSE)) { 174s + if (setDimnames) dimnames(x) <- dimnames 174s + else dimnames(x) <- NULL 174s + # Check names attribute 174s + for (useNames in c(TRUE, FALSE)) { 174s + # Row/column ranges 174s + r0 <- rowCumsums_R(x, useNames = useNames) 174s + r1 <- rowCumsums(x, useNames = useNames) 174s + r2 <- t(colCumsums(t(x), useNames = useNames)) 174s + stopifnot(all.equal(r1, r2)) 174s + stopifnot(all.equal(r1, r0)) 174s + stopifnot(all.equal(r2, r0)) 174s + } # for (useNames ...) 174s + } # for (setDimnames ...) 174s + } # for (mode ...) 174s mode: logical 174s logi [1:10, 1:5] NA NA NA NA NA NA ... 174s mode: integer 174s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 174s mode: double 174s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 174s > 174s > 174s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 174s > # A 1x1 matrix 174s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 174s > dimnames <- list("a", "A") # to check dimnames attribute 174s > for (mode in c("logical", "integer", "double")) { 174s + x <- matrix(0, nrow = 1L, ncol = 1L) 174s + cat("mode: ", mode, "\n", sep = "") 174s + storage.mode(x) <- mode 174s + str(x) 174s + 174s + r0 <- rowCumsums_R(x) 174s + r1 <- rowCumsums(x) 174s + r2 <- t(colCumsums(t(x))) 174s + stopifnot(all.equal(r1, r2)) 174s + stopifnot(all.equal(r1, r0)) 174s + stopifnot(all.equal(r2, r0)) 174s + 174s + # Check dimnames attribute 174s + dimnames(x) <- dimnames 174s + # r0 <- rowCumsums_R(x) 174s + # > r0 174s + # a 174s + # [1,] 0 174s + r1 <- rowCumsums(x, useNames = TRUE) 174s + r2 <- t(colCumsums(t(x), useNames = TRUE)) 174s + stopifnot(identical(dimnames(r1), dimnames)) 174s + stopifnot(identical(dimnames(r2), dimnames)) 174s + dimnames(x) <- NULL 174s + } 174s mode: logical 174s logi [1, 1] FALSE 174s mode: integer 174s int [1, 1] 0 174s mode: double 174s num [1, 1] 0 174s > 174s > 174s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 174s > # Corner cases 174s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 174s > names <- LETTERS[1:5] # to check dimnames attribute 174s > for (mode in c("logical", "integer", "double")) { 174s + cat("mode: ", mode, "\n", sep = "") 174s + value <- 0 174s + storage.mode(value) <- mode 174s + value2 <- value 174s + if (mode == "logical") value2 <- 0L 174s + 174s + # A 0x0 matrix 174s + x <- matrix(value, nrow = 0L, ncol = 0L) 174s + str(x) 174s + r0 <- matrix(value2, nrow = nrow(x), ncol = ncol(x)) 174s + r1 <- rowCumsums(x) 174s + r2 <- t(colCumsums(t(x))) 174s + stopifnot(all.equal(r1, r2)) 174s + stopifnot(all.equal(r1, r0)) 174s + stopifnot(all.equal(r2, r0)) 174s + 174s + # A 0xK matrix 174s + x <- matrix(value, nrow = 0L, ncol = 5L) 174s + str(x) 174s + colnames <- LETTERS[1:5] 174s + # Test with and without dimnames on x 174s + for (setDimnames in c(TRUE, FALSE)) { 174s + if (setDimnames) colnames(x) <- colnames 174s + else dimnames(x) <- NULL 174s + # Check names attribute 174s + for (useNames in c(TRUE, FALSE)) { 174s + r0 <- rowCumsums_R(x, useNames = useNames) 174s + r1 <- rowCumsums(x, useNames = useNames) 174s + r2 <- t(rowCumsums(t(x), useNames = useNames)) 174s + stopifnot(all.equal(r1, r2)) 174s + stopifnot(all.equal(r1, r0)) 174s + stopifnot(all.equal(r2, r0)) 174s + } # for (useNames ...) 174s + } # for (setDimnames ...) 174s + 174s + # A Nx0 matrix 174s + x <- matrix(value, nrow = 5L, ncol = 0L) 174s + str(x) 174s + rownames <- LETTERS[1:5] 174s + # Test with and without dimnames on x 174s + for (setDimnames in c(TRUE, FALSE)) { 174s + if (setDimnames) rownames(x) <- rownames 174s + else dimnames(x) <- NULL 174s + # Check names attribute 174s + for (useNames in c(TRUE, FALSE)) { 174s + r0 <- rowCumsums_R(x, useNames = useNames) 174s + r1 <- rowCumsums(x, useNames = useNames) 174s + r2 <- t(rowCumsums(t(x), useNames = useNames)) 174s + stopifnot(all.equal(r1, r2)) 174s + stopifnot(all.equal(r1, r0)) 174s + stopifnot(all.equal(r2, r0)) 174s + } # for (useNames ...) 174s + } # for (setDimnames ...) 174s + } # for (mode ...) 174s mode: logical 174s logi[0 , 0 ] 174s logi[0 , 1:5] 174s logi[1:5, 0 ] 174s mode: integer 174s int[0 , 0 ] 174s int[0 , 1:5] 174s int[1:5, 0 ] 174s mode: double 174s num[0 , 0 ] 174s num[0 , 1:5] 174s num[1:5, 0 ] 174s > 174s 174s R version 4.4.3 (2025-02-28) -- "Trophy Case" 174s Copyright (C) 2025 The R Foundation for Statistical Computing 174s Platform: s390x-ibm-linux-gnu 174s 174s R is free software and comes with ABSOLUTELY NO WARRANTY. 174s You are welcome to redistribute it under certain conditions. 174s Type 'license()' or 'licence()' for distribution details. 174s 174s R is a collaborative project with many contributors. 174s Type 'contributors()' for more information and 174s 'citation()' on how to cite R or R packages in publications. 174s 174s Type 'demo()' for some demos, 'help()' for on-line help, or 174s 'help.start()' for an HTML browser interface to help. 174s Type 'q()' to quit R. 174s 174s > library("matrixStats") 174s > 174s > rowCumsums_R <- function(x, ..., useNames = TRUE) { 174s + suppressWarnings({ 174s + y <- t(apply(x, MARGIN = 1L, FUN = cumsum)) 174s + }) 174s + 174s + # Preserve dimnames attribute? 174s + dim(y) <- dim(x) 174s + dimnames(y) <- if (useNames) dimnames(x) else NULL 174s + 174s + y 174s + } 174s > 174s > 174s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 174s > # Subsetted tests 174s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 174s > source("utils/validateIndicesFramework.R") 174s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 174s > storage.mode(x) <- "integer" 174s > 174s > # To check dimnames attribute 174s > dimnames <- list(letters[1:6], LETTERS[1:6]) 174s > 174s > # Test with and without dimnames on x 174s > for (setDimnames in c(TRUE, FALSE)) { 174s + if (setDimnames) dimnames(x) <- dimnames 174s + else dimnames(x) <- NULL 174s + for (rows in index_cases) { 174s + for (cols in index_cases) { 174s + # Check names attribute 174s + for (useNames in c(TRUE, FALSE)) { 174s + validateIndicesTestMatrix(x, rows, cols, 174s + ftest = rowCumsums, fsure = rowCumsums_R, useNames = useNames) 174s + validateIndicesTestMatrix(x, rows, cols, 174s + ftest = function(x, rows, cols, ..., useNames) { 174s + t(colCumsums(t(x), rows = cols, cols = rows, useNames = useNames)) 174s + }, fsure = rowCumsums_R, useNames = useNames) 174s + } 174s + } 174s + } 174s + } 175s > 175s 175s R version 4.4.3 (2025-02-28) -- "Trophy Case" 175s Copyright (C) 2025 The R Foundation for Statistical Computing 175s Platform: s390x-ibm-linux-gnu 175s 175s R is free software and comes with ABSOLUTELY NO WARRANTY. 175s You are welcome to redistribute it under certain conditions. 175s Type 'license()' or 'licence()' for distribution details. 175s 175s R is a collaborative project with many contributors. 175s Type 'contributors()' for more information and 175s 'citation()' on how to cite R or R packages in publications. 175s 175s Type 'demo()' for some demos, 'help()' for on-line help, or 175s 'help.start()' for an HTML browser interface to help. 175s Type 'q()' to quit R. 175s 175s > library("matrixStats") 175s > 175s > rowDiffs_R <- function(x, lag = 1L, differences = 1L, ..., useNames = TRUE) { 175s + ncol2 <- ncol(x) - lag * differences 175s + if (ncol2 <= 0) { 175s + y <- matrix(x[integer(0L)], nrow = nrow(x), ncol = 0L) 175s + # Preserve names attribute 175s + if (useNames && !is.null(rownames(x))) rownames(y) <- rownames(x) 175s + return(y) 175s + } 175s + suppressWarnings({ 175s + y <- apply(x, MARGIN = 1L, FUN = diff, lag = lag, differences = differences) 175s + }) 175s + y <- t(y) 175s + 175s + # Preserve dimnames attribute 175s + dim(y) <- c(nrow(x), ncol2) 175s + if (useNames && !is.null(dimnames(x))) { 175s + colnames <- colnames(x) 175s + if (!is.null(colnames)) { 175s + len <- length(colnames) 175s + colnames <- colnames[(len - ncol2 + 1):len] 175s + } 175s + dimnames(y) <- list(rownames(x), colnames) 175s + } 175s + else dimnames(y) <- NULL 175s + 175s + y 175s + } 175s > 175s > 175s > set.seed(0x42) 175s > 175s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 175s > # With and without some NAs 175s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 175s > for (mode in c("integer", "double")) { 175s + cat("mode: ", mode, "\n", sep = "") 175s + 175s + for (add_na in c(FALSE, TRUE)) { 175s + cat("add_na = ", add_na, "\n", sep = "") 175s + 175s + x <- matrix(sample(10 * 8) + 0.1, nrow = 10L, ncol = 8L) 175s + if (add_na) { 175s + x[3:7, c(2, 4)] <- NA_real_ 175s + } 175s + storage.mode(x) <- mode 175s + str(x) 175s + 175s + dimnames <- list(letters[1:10], LETTERS[1:8]) 175s + 175s + # Test with and without dimnames on x 175s + for (setDimnames in c(TRUE, FALSE)) { 175s + if (setDimnames) dimnames(x) <- dimnames 175s + else dimnames(x) <- NULL 175s + # Check dimnames attribute 175s + for (useNames in c(TRUE, FALSE)) { 175s + for (lag in 1:4) { 175s + for (differences in 1:3) { 175s + cat(sprintf("mode: %s, lag = %d, differences = %d\n", 175s + mode, lag, differences)) 175s + # Row/column ranges 175s + r0 <- rowDiffs_R(x, lag = lag, differences = differences, useNames = useNames) 175s + r1 <- rowDiffs(x, lag = lag, differences = differences, useNames = useNames) 175s + r2 <- t(colDiffs(t(x), lag = lag, differences = differences, useNames = useNames)) 175s + stopifnot(all.equal(r1, r0)) 175s + stopifnot(all.equal(r2, r0)) 175s + stopifnot(all.equal(r1, r2)) 175s + } 175s + } 175s + } # for (useNames ...) 175s + } # for (setDimnames ...) 175s + } # for (add_na ...) 175s + } # for (mode ...) 175s mode: integer 175s add_na = FALSE 175s int [1:10, 1:8] 68 26 29 47 48 10 1 38 16 40 ... 175s mode: integer, lag = 1, differences = 1 175s mode: integer, lag = 1, differences = 2 175s mode: integer, lag = 1, differences = 3 175s mode: integer, lag = 2, differences = 1 175s mode: integer, lag = 2, differences = 2 175s mode: integer, lag = 2, differences = 3 175s mode: integer, lag = 3, differences = 1 175s mode: integer, lag = 3, differences = 2 175s mode: integer, lag = 3, differences = 3 175s mode: integer, lag = 4, differences = 1 175s mode: integer, lag = 4, differences = 2 175s mode: integer, lag = 4, differences = 3 175s mode: integer, lag = 1, differences = 1 175s mode: integer, lag = 1, differences = 2 175s mode: integer, lag = 1, differences = 3 175s mode: integer, lag = 2, differences = 1 175s mode: integer, lag = 2, differences = 2 175s mode: integer, lag = 2, differences = 3 175s mode: integer, lag = 3, differences = 1 175s mode: integer, lag = 3, differences = 2 175s mode: integer, lag = 3, differences = 3 175s mode: integer, lag = 4, differences = 1 175s mode: integer, lag = 4, differences = 2 175s mode: integer, lag = 4, differences = 3 175s mode: integer, lag = 1, differences = 1 175s mode: integer, lag = 1, differences = 2 175s mode: integer, lag = 1, differences = 3 175s mode: integer, lag = 2, differences = 1 175s mode: integer, lag = 2, differences = 2 175s mode: integer, lag = 2, differences = 3 175s mode: integer, lag = 3, differences = 1 175s mode: integer, lag = 3, differences = 2 175s mode: integer, lag = 3, differences = 3 175s mode: integer, lag = 4, differences = 1 175s mode: integer, lag = 4, differences = 2 175s mode: integer, lag = 4, differences = 3 175s mode: integer, lag = 1, differences = 1 175s mode: integer, lag = 1, differences = 2 175s mode: integer, lag = 1, differences = 3 175s mode: integer, lag = 2, differences = 1 175s mode: integer, lag = 2, differences = 2 175s mode: integer, lag = 2, differences = 3 175s mode: integer, lag = 3, differences = 1 175s mode: integer, lag = 3, differences = 2 175s mode: integer, lag = 3, differences = 3 175s mode: integer, lag = 4, differences = 1 175s mode: integer, lag = 4, differences = 2 175s mode: integer, lag = 4, differences = 3 175s add_na = TRUE 175s int [1:10, 1:8] 80 71 7 52 79 22 31 10 29 63 ... 175s mode: integer, lag = 1, differences = 1 175s mode: integer, lag = 1, differences = 2 175s mode: integer, lag = 1, differences = 3 175s mode: integer, lag = 2, differences = 1 175s mode: integer, lag = 2, differences = 2 175s mode: integer, lag = 2, differences = 3 175s mode: integer, lag = 3, differences = 1 175s mode: integer, lag = 3, differences = 2 175s mode: integer, lag = 3, differences = 3 175s mode: integer, lag = 4, differences = 1 175s mode: integer, lag = 4, differences = 2 175s mode: integer, lag = 4, differences = 3 175s mode: integer, lag = 1, differences = 1 175s mode: integer, lag = 1, differences = 2 175s mode: integer, lag = 1, differences = 3 175s mode: integer, lag = 2, differences = 1 175s mode: integer, lag = 2, differences = 2 175s mode: integer, lag = 2, differences = 3 175s mode: integer, lag = 3, differences = 1 175s mode: integer, lag = 3, differences = 2 175s mode: integer, lag = 3, differences = 3 175s mode: integer, lag = 4, differences = 1 175s mode: integer, lag = 4, differences = 2 175s mode: integer, lag = 4, differences = 3 175s mode: integer, lag = 1, differences = 1 175s mode: integer, lag = 1, differences = 2 175s mode: integer, lag = 1, differences = 3 175s mode: integer, lag = 2, differences = 1 175s mode: integer, lag = 2, differences = 2 175s mode: integer, lag = 2, differences = 3 175s mode: integer, lag = 3, differences = 1 175s mode: integer, lag = 3, differences = 2 175s mode: integer, lag = 3, differences = 3 175s mode: integer, lag = 4, differences = 1 175s mode: integer, lag = 4, differences = 2 175s mode: integer, lag = 4, differences = 3 175s mode: integer, lag = 1, differences = 1 175s mode: integer, lag = 1, differences = 2 175s mode: integer, lag = 1, differences = 3 175s mode: integer, lag = 2, differences = 1 175s mode: integer, lag = 2, differences = 2 175s mode: integer, lag = 2, differences = 3 175s mode: integer, lag = 3, differences = 1 175s mode: integer, lag = 3, differences = 2 175s mode: integer, lag = 3, differences = 3 175s mode: integer, lag = 4, differences = 1 175s mode: integer, lag = 4, differences = 2 175s mode: integer, lag = 4, differences = 3 175s mode: double 175s add_na = FALSE 175s num [1:10, 1:8] 36.1 15.1 27.1 63.1 62.1 58.1 28.1 19.1 41.1 3.1 ... 175s mode: double, lag = 1, differences = 1 175s mode: double, lag = 1, differences = 2 175s mode: double, lag = 1, differences = 3 175s mode: double, lag = 2, differences = 1 175s mode: double, lag = 2, differences = 2 175s mode: double, lag = 2, differences = 3 175s mode: double, lag = 3, differences = 1 175s mode: double, lag = 3, differences = 2 175s mode: double, lag = 3, differences = 3 175s mode: double, lag = 4, differences = 1 175s mode: double, lag = 4, differences = 2 175s mode: double, lag = 4, differences = 3 175s mode: double, lag = 1, differences = 1 175s mode: double, lag = 1, differences = 2 175s mode: double, lag = 1, differences = 3 175s mode: double, lag = 2, differences = 1 175s mode: double, lag = 2, differences = 2 175s mode: double, lag = 2, differences = 3 175s mode: double, lag = 3, differences = 1 175s mode: double, lag = 3, differences = 2 175s mode: double, lag = 3, differences = 3 175s mode: double, lag = 4, differences = 1 175s mode: double, lag = 4, differences = 2 175s mode: double, lag = 4, differences = 3 175s mode: double, lag = 1, differences = 1 175s mode: double, lag = 1, differences = 2 175s mode: double, lag = 1, differences = 3 175s mode: double, lag = 2, differences = 1 175s mode: double, lag = 2, differences = 2 175s mode: double, lag = 2, differences = 3 175s mode: double, lag = 3, differences = 1 175s mode: double, lag = 3, differences = 2 175s mode: double, lag = 3, differences = 3 175s mode: double, lag = 4, differences = 1 175s mode: double, lag = 4, differences = 2 175s mode: double, lag = 4, differences = 3 175s mode: double, lag = 1, differences = 1 175s mode: double, lag = 1, differences = 2 175s mode: double, lag = 1, differences = 3 175s mode: double, lag = 2, differences = 1 175s mode: double, lag = 2, differences = 2 175s mode: double, lag = 2, differences = 3 175s mode: double, lag = 3, differences = 1 175s mode: double, lag = 3, differences = 2 175s mode: double, lag = 3, differences = 3 175s mode: double, lag = 4, differences = 1 175s mode: double, lag = 4, differences = 2 175s mode: double, lag = 4, differences = 3 175s add_na = TRUE 175s num [1:10, 1:8] 67.1 80.1 45.1 8.1 39.1 66.1 27.1 71.1 47.1 46.1 ... 175s mode: double, lag = 1, differences = 1 175s mode: double, lag = 1, differences = 2 175s mode: double, lag = 1, differences = 3 175s mode: double, lag = 2, differences = 1 175s mode: double, lag = 2, differences = 2 175s mode: double, lag = 2, differences = 3 175s mode: double, lag = 3, differences = 1 175s mode: double, lag = 3, differences = 2 175s mode: double, lag = 3, differences = 3 175s mode: double, lag = 4, differences = 1 175s mode: double, lag = 4, differences = 2 175s mode: double, lag = 4, differences = 3 175s mode: double, lag = 1, differences = 1 175s mode: double, lag = 1, differences = 2 175s mode: double, lag = 1, differences = 3 175s mode: double, lag = 2, differences = 1 175s mode: double, lag = 2, differences = 2 175s mode: double, lag = 2, differences = 3 175s mode: double, lag = 3, differences = 1 175s mode: double, lag = 3, differences = 2 175s mode: double, lag = 3, differences = 3 175s mode: double, lag = 4, differences = 1 175s mode: double, lag = 4, differences = 2 175s mode: double, lag = 4, differences = 3 175s mode: double, lag = 1, differences = 1 175s mode: double, lag = 1, differences = 2 175s mode: double, lag = 1, differences = 3 175s mode: double, lag = 2, differences = 1 175s mode: double, lag = 2, differences = 2 175s mode: double, lag = 2, differences = 3 175s mode: double, lag = 3, differences = 1 175s mode: double, lag = 3, differences = 2 175s mode: double, lag = 3, differences = 3 175s mode: double, lag = 4, differences = 1 175s mode: double, lag = 4, differences = 2 175s mode: double, lag = 4, differences = 3 175s mode: double, lag = 1, differences = 1 175s mode: double, lag = 1, differences = 2 175s mode: double, lag = 1, differences = 3 175s mode: double, lag = 2, differences = 1 175s mode: double, lag = 2, differences = 2 175s mode: double, lag = 2, differences = 3 175s mode: double, lag = 3, differences = 1 175s mode: double, lag = 3, differences = 2 175s mode: double, lag = 3, differences = 3 175s mode: double, lag = 4, differences = 1 175s mode: double, lag = 4, differences = 2 175s mode: double, lag = 4, differences = 3 175s > 175s > 175s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 175s > # All NAs 175s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 175s > for (mode in c("integer", "double")) { 175s + cat("mode: ", mode, "\n", sep = "") 175s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 175s + storage.mode(x) <- mode 175s + str(x) 175s + 175s + dimnames <- list(letters[1:10], LETTERS[1:5]) 175s + 175s + # Test with and without dimnames on x 175s + for (setDimnames in c(TRUE, FALSE)) { 175s + if (setDimnames) dimnames(x) <- dimnames 175s + else dimnames(x) <- NULL 175s + # Check dimnames attribute 175s + for (useNames in c(TRUE, FALSE)) { 175s + r0 <- rowDiffs_R(x, useNames = useNames) 175s + r1 <- rowDiffs(x, useNames = useNames) 175s + r2 <- t(colDiffs(t(x), useNames = useNames)) 175s + stopifnot(all.equal(r1, r0)) 175s + stopifnot(all.equal(r2, r0)) 175s + stopifnot(all.equal(r1, r2)) 175s + } # for (useNames ...) 175s + } # for (setDimnames ...) 175s + } # for (mode ...) 175s mode: integer 175s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 175s mode: double 175s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 175s > 175s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 175s > # A 1x1 matrix 175s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 175s > x <- matrix(0, nrow = 1L, ncol = 1L) 175s > dimnames <- list("a", "A") 175s > # Test with and without dimnames on x 175s > for (setDimnames in c(TRUE, FALSE)) { 175s + if (setDimnames) dimnames(x) <- dimnames 175s + else dimnames(x) <- NULL 175s + # Check dimnames attribute 175s + for (useNames in c(TRUE, FALSE)) { 175s + r0 <- rowDiffs_R(x, useNames = useNames) 175s + r1 <- rowDiffs(x, useNames = useNames) 175s + r2 <- t(colDiffs(t(x), useNames = useNames)) 175s + stopifnot(all.equal(r1, r0)) 175s + stopifnot(all.equal(r2, r0)) 175s + stopifnot(all.equal(r1, r2)) 175s + } # for (useNames ...) 175s + } # for (setDimnames ...) 175s > 175s 175s R version 4.4.3 (2025-02-28) -- "Trophy Case" 175s Copyright (C) 2025 The R Foundation for Statistical Computing 175s Platform: s390x-ibm-linux-gnu 175s 175s R is free software and comes with ABSOLUTELY NO WARRANTY. 175s You are welcome to redistribute it under certain conditions. 175s Type 'license()' or 'licence()' for distribution details. 175s 175s R is a collaborative project with many contributors. 175s Type 'contributors()' for more information and 175s 'citation()' on how to cite R or R packages in publications. 175s 175s Type 'demo()' for some demos, 'help()' for on-line help, or 175s 'help.start()' for an HTML browser interface to help. 175s Type 'q()' to quit R. 175s 175s > library("matrixStats") 175s > 175s > rowDiffs_R <- function(x, lag = 1L, differences = 1L, ..., useNames = TRUE) { 175s + ncol2 <- ncol(x) - lag * differences 175s + if (ncol2 <= 0) { 175s + y <- matrix(x[integer(0L)], nrow = nrow(x), ncol = 0L) 175s + # Preserve names attribute 175s + if (useNames && !is.null(rownames(x))) rownames(y) <- rownames(x) 175s + return(y) 175s + } 175s + suppressWarnings({ 175s + y <- apply(x, MARGIN = 1L, FUN = diff, lag = lag, differences = differences) 175s + }) 175s + y <- t(y) 175s + 175s + # Preserve dimnames attribute 175s + dim(y) <- c(nrow(x), ncol2) 175s + if (useNames && !is.null(dimnames(x))) { 175s + colnames <- colnames(x) 175s + if (!is.null(colnames)) { 175s + len <- length(colnames) 175s + colnames <- colnames[(len - ncol2 + 1):len] 175s + } 175s + dimnames(y) <- list(rownames(x), colnames) 175s + } 175s + else dimnames(y) <- NULL 175s + 175s + y 175s + } 175s > 175s > 175s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 175s > # Subsetted tests 175s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 175s > source("utils/validateIndicesFramework.R") 175s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 175s > storage.mode(x) <- "integer" 175s > 175s > # To check dimnames attribute 175s > dimnames <- list(letters[1:6], LETTERS[1:6]) 175s > 175s > # Test with and without dimnames on x 175s > for (setDimnames in c(TRUE, FALSE)) { 175s + if (setDimnames) dimnames(x) <- dimnames 175s + else dimnames(x) <- NULL 175s + 175s + count <- 0L 175s + for (rows in index_cases) { 175s + for (cols in index_cases) { 175s + count <- count + 1L 175s + for (lag in 1:2) { 175s + for (differences in 1:3) { 175s + # Check dimnames attribute 175s + useNames <- c(TRUE, FALSE) 175s + useNames <- useNames[count %% length(useNames) + 1] 175s + validateIndicesTestMatrix(x, rows, cols, 175s + ftest = rowDiffs, fsure = rowDiffs_R, 175s + lag = lag, differences = differences, useNames = useNames) 175s + validateIndicesTestMatrix(x, rows, cols, 175s + ftest = function(x, rows, cols, ..., useNames) { 175s + t(colDiffs(t(x), rows = cols, cols = rows, ..., useNames = useNames)) 175s + }, fsure = rowDiffs_R, 175s + lag = lag, differences = differences, useNames = useNames) 175s + } 175s + } 175s + } 175s + } 175s + } 178s > 178s 178s R version 4.4.3 (2025-02-28) -- "Trophy Case" 178s Copyright (C) 2025 The R Foundation for Statistical Computing 178s Platform: s390x-ibm-linux-gnu 178s 178s R is free software and comes with ABSOLUTELY NO WARRANTY. 178s You are welcome to redistribute it under certain conditions. 178s Type 'license()' or 'licence()' for distribution details. 178s 178s R is a collaborative project with many contributors. 178s Type 'contributors()' for more information and 178s 'citation()' on how to cite R or R packages in publications. 178s 178s Type 'demo()' for some demos, 'help()' for on-line help, or 178s 'help.start()' for an HTML browser interface to help. 178s Type 'q()' to quit R. 178s 178s > library("matrixStats") 178s > 178s > rowIQRs_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 178s + quantile_na <- function(x, ..., na.rm = FALSE) { 178s + if (!na.rm && anyMissing(x)) 178s + return(c(NA_real_, NA_real_)) 178s + quantile(x, ..., na.rm = na.rm) 178s + } 178s + q <- apply(x, MARGIN = 1L, FUN = quantile_na, 178s + probs = c(0.25, 0.75), na.rm = na.rm) 178s + rownames(q) <- NULL # Not needed anymore 178s + 178s + # Preserve names attribute 178s + dim(q) <- c(2L, nrow(x)) 178s + colnames(q) <- if (useNames) rownames(x) else NULL 178s + 178s + q[2L, , drop = TRUE] - q[1L, , drop = TRUE] 178s + } 178s > 178s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 178s > # Test with multiple quantiles 178s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 178s > for (mode in c("integer", "double")) { 178s + cat("mode: ", mode, "\n", sep = "") 178s + x <- matrix(1:100 + 0.1, nrow = 10, ncol = 10) 178s + storage.mode(x) <- mode 178s + str(x) 178s + 178s + # To check names attribute 178s + dimnames <- list(letters[1:10], LETTERS[1:10]) 178s + 178s + for (add_na in c(FALSE, TRUE)) { 178s + if (add_na) { 178s + x[3:5, 6:9] <- NA 178s + } 178s + # Test with and without dimnames on x 178s + for (setDimnames in c(TRUE, FALSE)) { 178s + if (setDimnames) dimnames(x) <- dimnames 178s + else dimnames(x) <- NULL 178s + for (na.rm in c(FALSE, TRUE)) { 178s + # Check names attribute 178s + for (useNames in c(TRUE, FALSE)) { 178s + probs <- c(0, 0.5, 1) 178s + q0 <- rowIQRs_R(x, na.rm = na.rm, useNames = useNames) 178s + print(q0) 178s + q1 <- rowIQRs(x, na.rm = na.rm, useNames = useNames) 178s + print(q1) 178s + stopifnot(all.equal(q1, q0)) 178s + q2 <- colIQRs(t(x), na.rm = na.rm, useNames = useNames) 178s + stopifnot(all.equal(q2, q0)) 178s + 178s + q <- iqr(x[3, ], na.rm = na.rm) 178s + print(q) 178s + } # for (useNames ...) 178s + } # for (na.rm ...) 178s + } # for (setDimnames ...) 178s + } # for (add_na ...) 178s + } # for (mode ...) 178s mode: integer 178s int [1:10, 1:10] 1 2 3 4 5 6 7 8 9 10 ... 178s a b c d e f g h i j 178s 45 45 45 45 45 45 45 45 45 45 178s a b c d e f g h i j 178s 45 45 45 45 45 45 45 45 45 45 178s [1] 45 178s [1] 45 45 45 45 45 45 45 45 45 45 178s [1] 45 45 45 45 45 45 45 45 45 45 178s [1] 45 178s a b c d e f g h i j 178s 45 45 45 45 45 45 45 45 45 45 178s a b c d e f g h i j 178s 45 45 45 45 45 45 45 45 45 45 178s [1] 45 178s [1] 45 45 45 45 45 45 45 45 45 45 178s [1] 45 45 45 45 45 45 45 45 45 45 178s [1] 45 178s [1] 45 45 45 45 45 45 45 45 45 45 178s [1] 45 45 45 45 45 45 45 45 45 45 178s [1] 45 178s [1] 45 45 45 45 45 45 45 45 45 45 178s [1] 45 45 45 45 45 45 45 45 45 45 178s [1] 45 178s [1] 45 45 45 45 45 45 45 45 45 45 178s [1] 45 45 45 45 45 45 45 45 45 45 178s [1] 45 178s [1] 45 45 45 45 45 45 45 45 45 45 178s [1] 45 45 45 45 45 45 45 45 45 45 178s [1] 45 178s a b c d e f g h i j 178s 45 45 NA NA NA 45 45 45 45 45 178s a b c d e f g h i j 178s 45 45 NA NA NA 45 45 45 45 45 178s [1] NA 178s [1] 45 45 NA NA NA 45 45 45 45 45 178s [1] 45 45 NA NA NA 45 45 45 45 45 178s [1] NA 178s a b c d e f g h i j 178s 45 45 25 25 25 45 45 45 45 45 178s a b c d e f g h i j 178s 45 45 25 25 25 45 45 45 45 45 178s [1] 25 178s [1] 45 45 25 25 25 45 45 45 45 45 178s [1] 45 45 25 25 25 45 45 45 45 45 178s [1] 25 178s [1] 45 45 NA NA NA 45 45 45 45 45 178s [1] 45 45 NA NA NA 45 45 45 45 45 178s [1] NA 178s [1] 45 45 NA NA NA 45 45 45 45 45 178s [1] 45 45 NA NA NA 45 45 45 45 45 178s [1] NA 178s [1] 45 45 25 25 25 45 45 45 45 45 178s [1] 45 45 25 25 25 45 45 45 45 45 178s [1] 25 178s [1] 45 45 25 25 25 45 45 45 45 45 178s [1] 45 45 25 25 25 45 45 45 45 45 178s [1] 25 178s mode: double 178s num [1:10, 1:10] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 178s a b c d e f g h i j 178s 45 45 45 45 45 45 45 45 45 45 178s a b c d e f g h i j 178s 45 45 45 45 45 45 45 45 45 45 178s [1] 45 178s [1] 45 45 45 45 45 45 45 45 45 45 178s [1] 45 45 45 45 45 45 45 45 45 45 178s [1] 45 178s a b c d e f g h i j 178s 45 45 45 45 45 45 45 45 45 45 178s a b c d e f g h i j 178s 45 45 45 45 45 45 45 45 45 45 178s [1] 45 178s [1] 45 45 45 45 45 45 45 45 45 45 178s [1] 45 45 45 45 45 45 45 45 45 45 178s [1] 45 178s [1] 45 45 45 45 45 45 45 45 45 45 178s [1] 45 45 45 45 45 45 45 45 45 45 178s [1] 45 178s [1] 45 45 45 45 45 45 45 45 45 45 178s [1] 45 45 45 45 45 45 45 45 45 45 178s [1] 45 178s [1] 45 45 45 45 45 45 45 45 45 45 178s [1] 45 45 45 45 45 45 45 45 45 45 178s [1] 45 178s [1] 45 45 45 45 45 45 45 45 45 45 178s [1] 45 45 45 45 45 45 45 45 45 45 178s [1] 45 178s a b c d e f g h i j 178s 45 45 NA NA NA 45 45 45 45 45 178s a b c d e f g h i j 178s 45 45 NA NA NA 45 45 45 45 45 178s [1] NA 178s [1] 45 45 NA NA NA 45 45 45 45 45 178s [1] 45 45 NA NA NA 45 45 45 45 45 178s [1] NA 178s a b c d e f g h i j 178s 45 45 25 25 25 45 45 45 45 45 178s a b c d e f g h i j 178s 45 45 25 25 25 45 45 45 45 45 178s [1] 25 178s [1] 45 45 25 25 25 45 45 45 45 45 178s [1] 45 45 25 25 25 45 45 45 45 45 178s [1] 25 178s [1] 45 45 NA NA NA 45 45 45 45 45 178s [1] 45 45 NA NA NA 45 45 45 45 45 178s [1] NA 178s [1] 45 45 NA NA NA 45 45 45 45 45 178s [1] 45 45 NA NA NA 45 45 45 45 45 178s [1] NA 178s [1] 45 45 25 25 25 45 45 45 45 45 178s [1] 45 45 25 25 25 45 45 45 45 45 178s [1] 25 178s [1] 45 45 25 25 25 45 45 45 45 45 178s [1] 45 45 25 25 25 45 45 45 45 45 178s [1] 25 178s > 178s > 178s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 178s > # Test corner cases 178s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 178s > for (mode in c("integer", "double")) { 178s + cat("mode: ", mode, "\n", sep = "") 178s + # Empty vectors 178s + x <- integer(0L) 178s + storage.mode(x) <- mode 178s + str(x) 178s + q <- iqr(x) 178s + print(q) 178s + stopifnot(identical(q, NA_real_)) 178s + 178s + # Scalar 178s + x <- 1L 178s + storage.mode(x) <- mode 178s + str(x) 178s + q <- iqr(x) 178s + str(q) 178s + stopifnot(identical(q, 0)) 178s + } 178s mode: integer 178s int(0) 178s [1] NA 178s int 1 178s num 0 178s mode: double 178s num(0) 178s [1] NA 178s num 1 178s num 0 178s > 178s > 178s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 178s > # Single row matrices 178s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 178s > x <- matrix(1, nrow = 1L, ncol = 2L) 178s > dimnames <- list("a", LETTERS[1:2]) 178s > # Test with and without dimnames on x 178s > for (setDimnames in c(TRUE, FALSE)) { 178s + if (setDimnames) dimnames(x) <- dimnames 178s + else dimnames(x) <- NULL 178s + # Check names attribute 178s + for (useNames in c(TRUE, FALSE)) { 178s + q0 <- rowIQRs_R(x, useNames = useNames) 178s + q1 <- rowIQRs(x, useNames = useNames) 178s + q2 <- colIQRs(t(x), useNames = useNames) 178s + stopifnot(all.equal(q0, q1)) 178s + stopifnot(all.equal(q0, q2)) 178s + } 178s + } 178s > 178s > x <- matrix(1, nrow = 2L, ncol = 1L) 178s > q <- colIQRs(x) 178s > stopifnot(identical(q, 0)) 178s > 178s 178s R version 4.4.3 (2025-02-28) -- "Trophy Case" 178s Copyright (C) 2025 The R Foundation for Statistical Computing 178s Platform: s390x-ibm-linux-gnu 178s 178s R is free software and comes with ABSOLUTELY NO WARRANTY. 178s You are welcome to redistribute it under certain conditions. 178s Type 'license()' or 'licence()' for distribution details. 178s 178s R is a collaborative project with many contributors. 178s Type 'contributors()' for more information and 178s 'citation()' on how to cite R or R packages in publications. 178s 178s Type 'demo()' for some demos, 'help()' for on-line help, or 178s 'help.start()' for an HTML browser interface to help. 178s Type 'q()' to quit R. 178s 178s > library("matrixStats") 178s > 178s > rowIQRs_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 178s + quantile_na <- function(x, ..., na.rm = FALSE) { 178s + if (!na.rm && anyMissing(x)) 178s + return(c(NA_real_, NA_real_)) 178s + quantile(x, ..., na.rm = na.rm) 178s + } 178s + q <- apply(x, MARGIN = 1L, FUN = quantile_na, 178s + probs = c(0.25, 0.75), na.rm = na.rm) 178s + rownames(q) <- NULL # Not needed anymore 178s + 178s + # Preserve names attribute 178s + dim(q) <- c(2L, nrow(x)) 178s + colnames(q) <- if (useNames) rownames(x) else NULL 178s + 178s + q[2L, , drop = TRUE] - q[1L, , drop = TRUE] 178s + } 178s > 178s > 178s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 178s > # Subsetted tests 178s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 178s > source("utils/validateIndicesFramework.R") 178s > x <- runif(6, min = -6, max = 6) 178s > for (idxs in index_cases) { 178s + for (na.rm in c(TRUE, FALSE)) { 178s + validateIndicesTestVector(x, idxs, ftest = iqr, fsure = function(x, na.rm) { 178s + dim(x) <- c(1L, length(x)) 178s + rowIQRs_R(x, na.rm = na.rm) 178s + }, na.rm = na.rm) 178s + } 178s + } 178s > 178s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 178s > 178s > # To check names attribute 178s > dimnames <- list(letters[1:6], LETTERS[1:6]) 178s > 178s > # Test with and without dimnames on x 178s > for (setDimnames in c(TRUE, FALSE)) { 178s + if (setDimnames) dimnames(x) <- dimnames 178s + else dimnames(x) <- NULL 178s + 178s + count <- 0L 178s + for (rows in index_cases) { 178s + for (cols in index_cases) { 178s + count <- count + 1L 178s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 178s + useNames <- c(TRUE, FALSE) 178s + useNames <- useNames[count %% length(useNames) + 1] 178s + 178s + validateIndicesTestMatrix(x, rows, cols, 178s + ftest = rowIQRs, fsure = rowIQRs_R, 178s + na.rm = na.rm, useNames = useNames) 178s + validateIndicesTestMatrix(x, rows, cols, 178s + fcoltest = colIQRs, fsure = rowIQRs_R, 178s + na.rm = na.rm, useNames = useNames) 178s + } 178s + } 178s + } 179s > 179s 179s R version 4.4.3 (2025-02-28) -- "Trophy Case" 179s Copyright (C) 2025 The R Foundation for Statistical Computing 179s Platform: s390x-ibm-linux-gnu 179s 179s R is free software and comes with ABSOLUTELY NO WARRANTY. 179s You are welcome to redistribute it under certain conditions. 179s Type 'license()' or 'licence()' for distribution details. 179s 179s R is a collaborative project with many contributors. 179s Type 'contributors()' for more information and 179s 'citation()' on how to cite R or R packages in publications. 179s 179s Type 'demo()' for some demos, 'help()' for on-line help, or 179s 'help.start()' for an HTML browser interface to help. 179s Type 'q()' to quit R. 179s 179s > # Test inspired by the harmonic mean example in R-help 179s > # thread '[R] Beyond double-precision?' on May 9, 2009. 179s > 179s > library("matrixStats") 179s > library("stats") 179s > 179s > logSumExp0 <- function(lx) { 179s + idx_max <- which.max(lx) 179s + log1p(sum(exp(lx[-idx_max] - lx[idx_max]))) + lx[idx_max] 179s + } 179s > 179s > n <- 200L 179s > set.seed(1) 179s > 179s > for (mode in c("integer", "double")) { 179s + cat("mode: ", mode, "\n", sep = "") 179s + x <- matrix(runif(n, min = 1.0, max = 3.0), nrow = 20L) 179s + storage.mode(x) <- mode 179s + str(x) 179s + 179s + # The logarithm of the harmonic mean by rows 179s + y_h <- log(1 / rowMeans(1 / x)) 179s + str(y_h) 179s + 179s + lx_neg <- -log(x) 179s + 179s + y0 <- log(ncol(x)) - apply(lx_neg, MARGIN = 1L, FUN = logSumExp0) 179s + stopifnot(all.equal(y0, y_h)) 179s + 179s + y1 <- log(ncol(x)) - apply(lx_neg, MARGIN = 1L, FUN = logSumExp) 179s + stopifnot(all.equal(y1, y0)) 179s + 179s + y2 <- log(ncol(x)) - rowLogSumExps(lx_neg) 179s + stopifnot(all.equal(y2, y0)) 179s + 179s + y3 <- log(ncol(x)) - colLogSumExps(t(lx_neg)) 179s + stopifnot(all.equal(y3, y0)) 179s + 179s + 179s + # The logarithm of the harmonic mean by columns 179s + y_h <- log(1 / colMeans(1 / x)) 179s + str(y_h) 179s + 179s + y0 <- log(nrow(x)) - apply(lx_neg, MARGIN = 2L, FUN = logSumExp0) 179s + stopifnot(all.equal(y0, y_h)) 179s + 179s + y1 <- log(nrow(x)) - apply(lx_neg, MARGIN = 2L, FUN = logSumExp) 179s + stopifnot(all.equal(y1, y0)) 179s + 179s + y2 <- log(nrow(x)) - colLogSumExps(lx_neg) 179s + stopifnot(all.equal(y2, y0)) 179s + 179s + y3 <- log(nrow(x)) - rowLogSumExps(t(lx_neg)) 179s + stopifnot(all.equal(y3, y0)) 179s + 179s + # Testing names 179s + rownames(lx_neg) <- seq_len(nrow(x)) 179s + colnames(lx_neg) <- seq_len(ncol(x)) 179s + y2 <- rowLogSumExps(lx_neg, useNames = TRUE) 179s + stopifnot(identical(names(y2), rownames(lx_neg))) 179s + y3 <- colLogSumExps(t(lx_neg), useNames = TRUE) 179s + stopifnot(identical(names(y3), rownames(lx_neg))) 179s + } # for (mode ...) 179s mode: integer 179s int [1:20, 1:10] 1 1 2 2 1 2 2 2 2 1 ... 179s num [1:20] 0.357 0.223 0.223 0.288 0.511 ... 179s num [1:10] 0.322 0.223 0.322 0.255 0.255 ... 179s mode: double 179s num [1:20, 1:10] 1.54 1.44 2.03 1.54 1.36 ... 179s num [1:20] 0.526 0.466 0.734 0.638 0.604 ... 179s num [1:10] 0.627 0.582 0.617 0.474 0.418 ... 179s > 179s > 179s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 179s > # Corner cases 179s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 179s > ## Zero-size matrices 179s > lx <- matrix(numeric(0L), nrow = 0L, ncol = 0L) 179s > y <- rowLogSumExps(lx) 179s > print(y) 179s numeric(0) 179s > stopifnot(length(y) == nrow(lx)) 179s > 179s > y <- colLogSumExps(lx) 179s > print(y) 179s numeric(0) 179s > stopifnot(length(y) == ncol(lx)) 179s > 179s > ## Zero-height matrices 179s > lx <- matrix(numeric(0L), nrow = 0L, ncol = 5L) 179s > y <- rowLogSumExps(lx) 179s > print(y) 179s numeric(0) 179s > stopifnot(length(y) == nrow(lx)) 179s > 179s > y <- colLogSumExps(lx) 179s > print(y) 179s [1] -Inf -Inf -Inf -Inf -Inf 179s > stopifnot(length(y) == ncol(lx)) 179s > stopifnot(all(y == -Inf)) 179s > 179s > ## Zero-width matrices 179s > lx <- matrix(numeric(0L), nrow = 5L, ncol = 0L) 179s > y <- colLogSumExps(lx) 179s > print(y) 179s numeric(0) 179s > stopifnot(length(y) == ncol(lx)) 179s > 179s > y <- rowLogSumExps(lx) 179s > print(y) 179s [1] -Inf -Inf -Inf -Inf -Inf 179s > stopifnot(length(y) == nrow(lx)) 179s > stopifnot(all(y == -Inf)) 179s > 179s > 179s > ## Matrices with one element 179s > lx <- matrix(1.0, nrow = 1L, ncol = 1L) 179s > y <- rowLogSumExps(lx) 179s > print(y) 179s [1] 1 179s > stopifnot(length(y) == nrow(lx)) 179s > stopifnot(all(y == lx)) 179s > 179s > y <- colLogSumExps(lx) 179s > print(y) 179s [1] 1 179s > stopifnot(length(y) == ncol(lx)) 179s > stopifnot(all(y == lx)) 179s > 179s > ## All missing values 179s > lx <- matrix(NA_real_, nrow = 1L, ncol = 1L) 179s > y <- rowLogSumExps(lx, na.rm = TRUE) 179s > print(y) 179s [1] -Inf 179s > stopifnot(length(y) == nrow(lx)) 179s > stopifnot(identical(y, -Inf)) 179s > 179s > lx <- matrix(NA_real_, nrow = 1L, ncol = 1L) 179s > y <- colLogSumExps(lx, na.rm = TRUE) 179s > print(y) 179s [1] -Inf 179s > stopifnot(length(y) == ncol(lx)) 179s > stopifnot(identical(y, -Inf)) 179s > 179s > lx <- matrix(NA_real_, nrow = 2L, ncol = 2L) 179s > y <- rowLogSumExps(lx, na.rm = TRUE) 179s > print(y) 179s [1] -Inf -Inf 179s > stopifnot(length(y) == nrow(lx)) 179s > stopifnot(all(y == -Inf)) 179s > 179s > y <- rowLogSumExps(lx, na.rm = FALSE) 179s > print(y) 179s [1] NA NA 179s > stopifnot(length(y) == nrow(lx)) 179s > stopifnot(all(is.na(y) & !is.nan(y))) 179s > 179s > lx <- matrix(NA_real_, nrow = 2L, ncol = 2L) 179s > y <- colLogSumExps(lx, na.rm = TRUE) 179s > print(y) 179s [1] -Inf -Inf 179s > stopifnot(length(y) == ncol(lx)) 179s > stopifnot(all(y == -Inf)) 179s > 179s > y <- colLogSumExps(lx, na.rm = FALSE) 179s > print(y) 179s [1] NA NA 179s > stopifnot(length(y) == ncol(lx)) 179s > stopifnot(all(is.na(y) & !is.nan(y))) 179s > 179s > ## +Inf values 179s > lx <- matrix(c(1, 2, +Inf), nrow = 3L, ncol = 2L) 179s > y <- colLogSumExps(lx, na.rm = TRUE) 179s > print(y) 179s [1] Inf Inf 179s > stopifnot(length(y) == ncol(lx)) 179s > stopifnot(all(y == +Inf)) 179s > 179s > ## multiple -Inf values 179s > lx <- matrix(c(-Inf, -Inf), nrow = 2L, ncol = 3L) 179s > y <- rowLogSumExps(lx) 179s > print(y) 179s [1] -Inf -Inf 179s > stopifnot(length(y) == nrow(lx)) 179s > stopifnot(all(y == -Inf)) 179s > 179s > lx <- matrix(c(-Inf, 5, -Inf), nrow = 2L, ncol = 3L, byrow = TRUE) 179s > y <- rowLogSumExps(lx) 179s > print(y) 179s [1] 5 5 179s > stopifnot(length(y) == nrow(lx)) 179s > stopifnot(all(y == 5)) 179s > 179s > ## Bug report #104 (https://github.com/HenrikBengtsson/matrixStats/issues/104) 179s > ## (This would core dump on Windows) 179s > x <- matrix(0.0, nrow = 2L, ncol = 32762L) 179s > y <- colLogSumExps(x) 179s > str(y) 179s num [1:32762] 0.693 0.693 0.693 0.693 0.693 ... 179s > 179s > ## Bug report #120 (https://github.com/HenrikBengtsson/matrixStats/issues/120) 179s > ## (This would error if x had rownames/colnames and non-NULL rows/cols were 179s > ## used) 179s > x <- matrix(runif(6), nrow = 2L, ncol = 3L, 179s + dimnames = list(c("A", "B"), c("a", "b", "c"))) 179s > y <- colLogSumExps(x, cols = 3:1, useNames = TRUE) 179s > stopifnot(names(y) == c("c", "b", "a")) 179s > y <- rowLogSumExps(x, rows = 2, useNames = TRUE) 179s > stopifnot(names(y) == "B") 179s > 179s > 179s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 179s > # Check names attributes 179s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 179s > 179s > ## Create isFALSE() if running on an old version of R 179s > if (!exists("isFALSE", mode="function")) { 179s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 179s + } 179s > 179s > rowLogSumExps_R <- function(x, ..., useNames = TRUE) { 179s + res <- apply(x, MARGIN = 1L, FUN = function(rx, ...) { 179s + log(sum(exp(rx), ...)) 179s + }, ...) 179s + if (isFALSE(useNames)) names(res) <- NULL 179s + res 179s + } 179s > 179s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6L, ncol = 6L) 179s > 179s > # To check names attribute 179s > dimnames <- list(letters[1:6], LETTERS[1:6]) 179s > 179s > # Test with and without dimnames on x 179s > for (setDimnames in c(TRUE, FALSE)) { 179s + if (setDimnames) dimnames(x) <- dimnames 179s + else dimnames(x) <- NULL 179s + for (useNames in c(TRUE, FALSE)) { 179s + y0 <- rowLogSumExps_R(x, useNames = useNames) 179s + y1 <- rowLogSumExps(x, useNames = useNames) 179s + y2 <- colLogSumExps(t(x), useNames = useNames) 179s + stopifnot(all.equal(y1, y0)) 179s + stopifnot(all.equal(y2, y0)) 179s + } 179s + } 179s > 179s 179s R version 4.4.3 (2025-02-28) -- "Trophy Case" 179s Copyright (C) 2025 The R Foundation for Statistical Computing 179s Platform: s390x-ibm-linux-gnu 179s 179s R is free software and comes with ABSOLUTELY NO WARRANTY. 179s You are welcome to redistribute it under certain conditions. 179s Type 'license()' or 'licence()' for distribution details. 179s 179s R is a collaborative project with many contributors. 179s Type 'contributors()' for more information and 179s 'citation()' on how to cite R or R packages in publications. 179s 179s Type 'demo()' for some demos, 'help()' for on-line help, or 179s 'help.start()' for an HTML browser interface to help. 179s Type 'q()' to quit R. 179s 180s > library("matrixStats") 180s > 180s > ## Create isFALSE() if running on an old version of R 180s > if (!exists("isFALSE", mode="function")) { 180s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 180s + } 180s > 180s > rowLogSumExps_R <- function(x, ..., useNames = TRUE) { 180s + res <- apply(x, MARGIN = 1L, FUN = function(rx, ...) { 180s + log(sum(exp(rx), ...)) 180s + }, ...) 180s + if (isFALSE(useNames)) names(res) <- NULL 180s + res 180s + } 180s > 180s > 180s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 180s > # Subsetted tests 180s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 180s > source("utils/validateIndicesFramework.R") 180s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 180s > 180s > # To check names attribute 180s > dimnames <- list(letters[1:6], LETTERS[1:6]) 180s > 180s > # Test with and without dimnames on x 180s > for (setDimnames in c(TRUE, FALSE)) { 180s + if (setDimnames) dimnames(x) <- dimnames 180s + else dimnames(x) <- NULL 180s + for (rows in index_cases) { 180s + for (cols in index_cases) { 180s + for (na.rm in c(TRUE, FALSE)) { 180s + for (useNames in c(TRUE, FALSE)) { 180s + validateIndicesTestMatrix(x, rows, cols, 180s + ftest = rowLogSumExps, 180s + fsure = rowLogSumExps_R, 180s + na.rm = na.rm, useNames = useNames) 180s + validateIndicesTestMatrix(x, rows, cols, 180s + fcoltest = colLogSumExps, 180s + fsure = rowLogSumExps_R, 180s + na.rm = na.rm, useNames = useNames) 180s + } 180s + } 180s + } 180s + } 180s + } 180s > 180s 180s R version 4.4.3 (2025-02-28) -- "Trophy Case" 180s Copyright (C) 2025 The R Foundation for Statistical Computing 180s Platform: s390x-ibm-linux-gnu 180s 180s R is free software and comes with ABSOLUTELY NO WARRANTY. 180s You are welcome to redistribute it under certain conditions. 180s Type 'license()' or 'licence()' for distribution details. 180s 180s R is a collaborative project with many contributors. 180s Type 'contributors()' for more information and 180s 'citation()' on how to cite R or R packages in publications. 180s 180s Type 'demo()' for some demos, 'help()' for on-line help, or 180s 'help.start()' for an HTML browser interface to help. 180s Type 'q()' to quit R. 180s 180s > library("matrixStats") 180s > 180s > ## Always allow testing of the 'center' argument (as long as it's not defunct) 180s > options(matrixStats.center.onUse = "ignore") 180s > 180s > rowMads_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 180s + suppressWarnings({ 180s + res <- apply(x, MARGIN = 1L, FUN = mad, na.rm = na.rm) 180s + }) 180s + if (!useNames) names(res) <- NULL 180s + res 180s + } 180s > 180s > colMads_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 180s + suppressWarnings({ 180s + res <- apply(x, MARGIN = 2L, FUN = mad, na.rm = na.rm) 180s + }) 180s + if (!useNames) names(res) <- NULL 180s + res 180s + } 180s > 180s > rowMads_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 180s + center <- rowMedians(x, cols = cols, na.rm = na.rm, useNames = FALSE) 180s + rowMads(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 181s + } 181s > 181s > colMads_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 181s + center <- colMedians(x, rows = rows, na.rm = na.rm, useNames = FALSE) 181s + colMads(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 181s + } 181s > 181s > 181s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 181s > # A 3x3 matrix (no ties) 181s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 181s > for (mode in c("integer", "double")) { 181s + x <- matrix(c(1, 2, 3, 2, 3, 4, 3, 4, 5) + 0.1, nrow = 3, ncol = 3) 181s + cat("mode: ", mode, "\n", sep = "") 181s + storage.mode(x) <- mode 181s + str(x) 181s + 181s + # To check name attribute 181s + dimnames <- list(letters[1:3], LETTERS[1:3]) 181s + 181s + # Test with and without dimnames on x 181s + for (setDimnames in c(TRUE, FALSE)) { 181s + if (setDimnames) dimnames(x) <- dimnames 181s + else dimnames(x) <- NULL 181s + tx <- t(x) 181s + # Check names attribute 181s + for (useNames in c(TRUE, FALSE)) { 181s + cat("rowMads():\n") 181s + center <- rowMedians(x, na.rm = TRUE, useNames = useNames) 181s + r0 <- rowMads_R(x, na.rm = TRUE, useNames = useNames) 181s + r1 <- rowMads(x, na.rm = TRUE, useNames = useNames) 181s + r1b <- rowMads_center(x, na.rm = TRUE, useNames = useNames) 181s + r1c <- rowMads(x, center = center, na.rm = TRUE, useNames = useNames) 181s + r2 <- colMads(tx, na.rm = TRUE, useNames = useNames) 181s + r2b <- colMads_center(tx, na.rm = TRUE, useNames = useNames) 181s + stopifnot(all.equal(r1, r2)) 181s + stopifnot(all.equal(r1, r0)) 181s + stopifnot(all.equal(r1b, r1)) 181s + stopifnot(all.equal(r1c, r1)) 181s + stopifnot(all.equal(r2, r0)) 181s + stopifnot(all.equal(r2b, r2)) 181s + 181s + cat("colMads():\n") 181s + center <- colMedians(x, na.rm = TRUE, useNames = useNames) 181s + r0 <- colMads_R(x, na.rm = TRUE, useNames = useNames) 181s + r1 <- colMads(x, na.rm = TRUE, useNames = useNames) 181s + r1b <- colMads_center(x, na.rm = TRUE, useNames = useNames) 181s + r1c <- colMads(x, center = center, na.rm = TRUE, useNames = useNames) 181s + r2 <- rowMads(tx, na.rm = TRUE, useNames = useNames) 181s + r2b <- rowMads_center(tx, na.rm = TRUE, useNames = useNames) 181s + stopifnot(all.equal(r1, r2)) 181s + stopifnot(all.equal(r1, r0)) 181s + stopifnot(all.equal(r1b, r1)) 181s + stopifnot(all.equal(r1c, r1)) 181s + stopifnot(all.equal(r2, r0)) 181s + stopifnot(all.equal(r2b, r2)) 181s + } 181s + } 181s + } 181s mode: integer 181s int [1:3, 1:3] 1 2 3 2 3 4 3 4 5 181s rowMads(): 181s colMads(): 181s rowMads(): 181s colMads(): 181s rowMads(): 181s colMads(): 181s rowMads(): 181s colMads(): 181s mode: double 181s num [1:3, 1:3] 1.1 2.1 3.1 2.1 3.1 4.1 3.1 4.1 5.1 181s rowMads(): 181s colMads(): 181s rowMads(): 181s colMads(): 181s rowMads(): 181s colMads(): 181s rowMads(): 181s colMads(): 181s > 181s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 181s > # Ties: a 4x4 matrix 181s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 181s > for (mode in c("integer", "double")) { 181s + x <- matrix(c(1:4, 2:5, 3:6, 4:7) + 0.1, nrow = 4, ncol = 4) 181s + cat("mode: ", mode, "\n", sep = "") 181s + storage.mode(x) <- mode 181s + str(x) 181s + tx <- t(x) 181s + 181s + # To check name attribute 181s + dimnames <- list(letters[1:4], LETTERS[1:4]) 181s + 181s + # Test with and without dimnames on x 181s + for (setDimnames in c(TRUE, FALSE)) { 181s + if (setDimnames) dimnames(x) <- dimnames 181s + else dimnames(x) <- NULL 181s + tx <- t(x) 181s + # Check names attribute 181s + for (useNames in c(TRUE, FALSE)) { 181s + cat("rowMads():\n") 181s + r0 <- rowMads_R(x, na.rm = TRUE, useNames = useNames) 181s + r1 <- rowMads(x, na.rm = TRUE, useNames = useNames) 181s + r2 <- colMads(tx, na.rm = TRUE, useNames = useNames) 181s + stopifnot(all.equal(r1, r2)) 181s + stopifnot(all.equal(r1, r0)) 181s + stopifnot(all.equal(r2, r0)) 181s + 181s + cat("colMads():\n") 181s + r0 <- colMads_R(x, na.rm = TRUE, useNames = useNames) 181s + r1 <- colMads(x, na.rm = TRUE, useNames = useNames) 181s + r2 <- rowMads(tx, na.rm = TRUE, useNames = useNames) 181s + stopifnot(all.equal(r1, r2)) 181s + stopifnot(all.equal(r1, r0)) 181s + stopifnot(all.equal(r2, r0)) 181s + } 181s + } 181s + } 181s mode: integer 181s int [1:4, 1:4] 1 2 3 4 2 3 4 5 3 4 ... 181s rowMads(): 181s colMads(): 181s rowMads(): 181s colMads(): 181s rowMads(): 181s colMads(): 181s rowMads(): 181s colMads(): 181s mode: double 181s num [1:4, 1:4] 1.1 2.1 3.1 4.1 2.1 3.1 4.1 5.1 3.1 4.1 ... 181s rowMads(): 181s colMads(): 181s rowMads(): 181s colMads(): 181s rowMads(): 181s colMads(): 181s rowMads(): 181s colMads(): 181s > tx <- NULL 181s > 181s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 181s > # No ties: a 3x3 matrix with an NA value 181s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 181s > for (mode in c("integer", "double")) { 181s + x <- matrix(c(1, 2, 3, 2, 3, 4, 3, 4, 5) + 0.1, nrow = 3, ncol = 3) 181s + x[2, 2] <- NA_real_ 181s + 181s + cat("mode: ", mode, "\n", sep = "") 181s + storage.mode(x) <- mode 181s + str(x) 181s + tx <- t(x) 181s + 181s + # To check name attribute 181s + dimnames <- list(letters[1:3], LETTERS[1:3]) 181s + 181s + # Test with and without dimnames on x 181s + for (setDimnames in c(TRUE, FALSE)) { 181s + if (setDimnames) dimnames(x) <- dimnames 181s + else dimnames(x) <- NULL 181s + tx <- t(x) 181s + # Check names attribute 181s + for (useNames in c(TRUE, FALSE)) { 181s + cat("rowMads():\n") 181s + r0 <- rowMads_R(x, na.rm = TRUE, useNames = useNames) 181s + r1 <- rowMads(x, na.rm = TRUE, useNames = useNames) 181s + r2 <- colMads(tx, na.rm = TRUE, useNames = useNames) 181s + stopifnot(all.equal(r1, r2)) 181s + stopifnot(all.equal(r1, r0)) 181s + stopifnot(all.equal(r2, r0)) 181s + 181s + cat("colMads():\n") 181s + r0 <- colMads_R(x, na.rm = TRUE, useNames = useNames) 181s + r1 <- colMads(x, na.rm = TRUE, useNames = useNames) 181s + r2 <- rowMads(tx, na.rm = TRUE, useNames = useNames) 181s + stopifnot(all.equal(r1, r2)) 181s + stopifnot(all.equal(r1, r0)) 181s + stopifnot(all.equal(r2, r0)) 181s + } 181s + } 181s + } 181s mode: integer 181s int [1:3, 1:3] 1 2 3 2 NA 4 3 4 5 181s rowMads(): 181s colMads(): 181s rowMads(): 181s colMads(): 181s rowMads(): 181s colMads(): 181s rowMads(): 181s colMads(): 181s mode: double 181s num [1:3, 1:3] 1.1 2.1 3.1 2.1 NA 4.1 3.1 4.1 5.1 181s rowMads(): 181s colMads(): 181s rowMads(): 181s colMads(): 181s rowMads(): 181s colMads(): 181s rowMads(): 181s colMads(): 181s > tx <- NULL 181s > 181s > 181s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 181s > # With and without some NAs 181s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 181s > for (add_na in c(FALSE, TRUE)) { 181s + cat("add_na = ", add_na, "\n", sep = "") 181s + 181s + x <- matrix(1:50, nrow = 10L, ncol = 5L) 181s + if (add_na) { 181s + x[3:7, c(2, 4)] <- NA_real_ 181s + } 181s + 181s + # To check name attribute 181s + dimnames <- list(letters[1:10], LETTERS[1:5]) 181s + 181s + # Test with and without dimnames on x 181s + for (setDimnames in c(TRUE, FALSE)) { 181s + if (setDimnames) dimnames(x) <- dimnames 181s + else dimnames(x) <- NULL 181s + tx <- t(x) 181s + # Row/column ranges 181s + for (na.rm in c(FALSE, TRUE)) { 181s + # Check names attribute 181s + for (useNames in c(TRUE, FALSE)) { 181s + cat("na.rm = ", na.rm, "\n", sep = "") 181s + cat("rowMads():\n") 181s + center <- rowMedians(x, na.rm = na.rm, useNames = useNames) 181s + r0 <- rowMads_R(x, na.rm = na.rm, useNames = useNames) 181s + r1 <- rowMads(x, na.rm = na.rm, useNames = useNames) 181s + r2 <- rowMads(x, center = center, na.rm = na.rm, useNames = useNames) 181s + r3 <- colMads(tx, na.rm = na.rm, useNames = useNames) 181s + stopifnot(all.equal(r1, r0)) 181s + stopifnot(all.equal(r2, r0)) 181s + stopifnot(all.equal(r2, r1)) 181s + stopifnot(all.equal(r3, r0)) 181s + stopifnot(all.equal(r3, r1)) 181s + stopifnot(all.equal(r3, r2)) 181s + 181s + cat("colMads():\n") 181s + center <- colMedians(x, na.rm = na.rm, useNames = useNames) 181s + r0 <- colMads_R(x, na.rm = na.rm, useNames = useNames) 181s + r1 <- colMads(x, na.rm = na.rm, useNames = useNames) 181s + r2 <- colMads(x, center = center, na.rm = na.rm, useNames = useNames) 181s + r3 <- rowMads(tx, na.rm = na.rm, useNames = useNames) 181s + stopifnot(all.equal(r1, r0)) 181s + stopifnot(all.equal(r2, r0)) 181s + stopifnot(all.equal(r2, r1)) 181s + stopifnot(all.equal(r3, r0)) 181s + stopifnot(all.equal(r3, r1)) 181s + stopifnot(all.equal(r3, r2)) 181s + } 181s + } 181s + } 181s + tx <- NULL 181s + } # for (add_na ...) 181s add_na = FALSE 181s na.rm = FALSE 181s rowMads(): 181s colMads(): 181s na.rm = FALSE 181s rowMads(): 181s colMads(): 181s na.rm = TRUE 181s rowMads(): 181s colMads(): 181s na.rm = TRUE 181s rowMads(): 181s colMads(): 181s na.rm = FALSE 181s rowMads(): 181s colMads(): 181s na.rm = FALSE 181s rowMads(): 181s colMads(): 181s na.rm = TRUE 181s rowMads(): 181s colMads(): 181s na.rm = TRUE 181s rowMads(): 181s colMads(): 181s add_na = TRUE 181s na.rm = FALSE 181s rowMads(): 181s colMads(): 181s na.rm = FALSE 181s rowMads(): 181s colMads(): 181s na.rm = TRUE 181s rowMads(): 181s colMads(): 181s na.rm = TRUE 181s rowMads(): 181s colMads(): 181s na.rm = FALSE 181s rowMads(): 181s colMads(): 181s na.rm = FALSE 181s rowMads(): 181s colMads(): 181s na.rm = TRUE 181s rowMads(): 181s colMads(): 181s na.rm = TRUE 181s rowMads(): 181s colMads(): 181s > 181s > 181s > 181s > 181s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 181s > # All NAs 181s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 181s > x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 181s > # Test with and without dimnames on x 181s > for (setDimnames in c(TRUE, FALSE)) { 181s + if (setDimnames) dimnames(x) <- dimnames 181s + else dimnames(x) <- NULL 181s + tx <- t(x) 181s + # Row/column ranges 181s + for (na.rm in c(FALSE, TRUE)) { 181s + # Check names attribute 181s + for (useNames in c(TRUE, FALSE)) { 181s + cat("na.rm = ", na.rm, "\n", sep = "") 181s + r0 <- rowMads_R(x, na.rm = na.rm, useNames = useNames) 181s + if (na.rm) r0[is.na(r0)] <- NaN 181s + r1 <- rowMads(x, na.rm = na.rm, useNames = useNames) 181s + r2 <- colMads(tx, na.rm = na.rm, useNames = useNames) 181s + stopifnot(all.equal(r1, r0)) 181s + stopifnot(all.equal(r2, r0)) 181s + stopifnot(all.equal(r1, r2)) 181s + } 181s + } 181s + } 181s na.rm = FALSE 181s na.rm = FALSE 181s na.rm = TRUE 181s na.rm = TRUE 181s na.rm = FALSE 181s na.rm = FALSE 181s na.rm = TRUE 181s na.rm = TRUE 181s > tx <- NULL 181s > 181s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 181s > # A 1x1 matrix 181s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 181s > x <- matrix(0, nrow = 1L, ncol = 1L) 181s > dimnames <- list("a", "A") 181s > # Test with and without dimnames on x 181s > for (setDimnames in c(TRUE, FALSE)) { 181s + if (setDimnames) dimnames(x) <- dimnames 181s + else dimnames(x) <- NULL 181s + tx <- t(x) 181s + # Row/column ranges 181s + for (na.rm in c(FALSE, TRUE)) { 181s + # Check names attribute 181s + for (useNames in c(TRUE, FALSE)) { 181s + cat("na.rm = ", na.rm, "\n", sep = "") 181s + r0 <- rowMads_R(x, na.rm = na.rm, useNames = useNames) 181s + r1 <- rowMads(x, na.rm = na.rm, useNames = useNames) 181s + r2 <- colMads(tx, na.rm = na.rm, useNames = useNames) 181s + stopifnot(all.equal(r1, r0)) 181s + stopifnot(all.equal(r2, r0)) 181s + stopifnot(all.equal(r1, r2)) 181s + } 181s + } 181s + } 181s na.rm = FALSE 181s na.rm = FALSE 181s na.rm = TRUE 181s na.rm = TRUE 181s na.rm = FALSE 181s na.rm = FALSE 181s na.rm = TRUE 181s na.rm = TRUE 181s > 181s > 181s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 181s > # A 0x0 matrix 181s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 181s > x <- matrix(double(0), nrow = 0, ncol = 0) 181s > tx <- t(x) 181s > for (na.rm in c(FALSE, TRUE)) { 181s + cat("na.rm = ", na.rm, "\n", sep = "") 181s + r0 <- rowMads_R(x, na.rm = na.rm) 181s + r1 <- rowMads(x, na.rm = na.rm) 181s + r2 <- colMads(tx, na.rm = na.rm) 181s + stopifnot(all.equal(r1, r2)) 181s + stopifnot(all.equal(r1, r0)) 181s + stopifnot(all.equal(r2, r0)) 181s + } 181s na.rm = FALSE 181s na.rm = TRUE 181s > 181s 181s R version 4.4.3 (2025-02-28) -- "Trophy Case" 181s Copyright (C) 2025 The R Foundation for Statistical Computing 181s Platform: s390x-ibm-linux-gnu 181s 181s R is free software and comes with ABSOLUTELY NO WARRANTY. 181s You are welcome to redistribute it under certain conditions. 181s Type 'license()' or 'licence()' for distribution details. 181s 181s R is a collaborative project with many contributors. 181s Type 'contributors()' for more information and 181s 'citation()' on how to cite R or R packages in publications. 181s 181s Type 'demo()' for some demos, 'help()' for on-line help, or 181s 'help.start()' for an HTML browser interface to help. 181s Type 'q()' to quit R. 181s 181s > library("matrixStats") 181s > 181s > ## Always allow testing of the 'center' argument (as long as it's not defunct) 181s > options(matrixStats.center.onUse = "ignore") 181s > 181s > rowMads_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 181s + suppressWarnings({ 181s + res <- apply(x, MARGIN = 1L, FUN = mad, na.rm = na.rm) 181s + }) 181s + if (!useNames) names(res) <- NULL 181s + res 181s + } 181s > 181s > colMads_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 181s + suppressWarnings({ 181s + res <- apply(x, MARGIN = 2L, FUN = mad, na.rm = na.rm) 181s + }) 181s + if (!useNames) names(res) <- NULL 181s + res 181s + } 181s > 181s > rowMads_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 181s + center <- rowMedians(x, cols = cols, na.rm = na.rm, useNames = FALSE) 181s + rowMads(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 181s + } 181s > 181s > colMads_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 181s + center <- colMedians(x, rows = rows, na.rm = na.rm, useNames = FALSE) 181s + colMads(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 181s + } 181s > 181s > 181s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 181s > # Subsetted tests 181s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 181s > source("utils/validateIndicesFramework.R") 181s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 181s > storage.mode(x) <- "integer" 181s > 181s > # To check names attribute 181s > dimnames <- list(letters[1:6], LETTERS[1:6]) 181s > 181s > # Test with and without dimnames on x 181s > for (setDimnames in c(TRUE, FALSE)) { 181s + if (setDimnames) dimnames(x) <- dimnames 181s + else dimnames(x) <- NULL 181s + 181s + count <- 0L 181s + for (rows in index_cases) { 181s + for (cols in index_cases) { 181s + count <- count + 1L 181s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 181s + useNames <- c(TRUE, FALSE) 181s + useNames <- useNames[count %% length(useNames) + 1] 181s + 181s + validateIndicesTestMatrix(x, rows, cols, 181s + ftest = rowMads, fsure = rowMads_R, 181s + na.rm = na.rm, useNames = useNames) 181s + validateIndicesTestMatrix(x, rows, cols, 181s + ftest = rowMads_center, fsure = rowMads_R, 181s + na.rm = na.rm, useNames = useNames) 181s + 181s + validateIndicesTestMatrix(x, rows, cols, 181s + fcoltest = colMads, fsure = rowMads_R, 181s + na.rm = na.rm, useNames = useNames) 181s + validateIndicesTestMatrix(x, rows, cols, 181s + fcoltest = colMads_center, fsure = rowMads_R, 181s + na.rm = na.rm, useNames = useNames) 181s + } 181s + } 181s + } 181s > 182s 182s R version 4.4.3 (2025-02-28) -- "Trophy Case" 182s Copyright (C) 2025 The R Foundation for Statistical Computing 182s Platform: s390x-ibm-linux-gnu 182s 182s R is free software and comes with ABSOLUTELY NO WARRANTY. 182s You are welcome to redistribute it under certain conditions. 182s Type 'license()' or 'licence()' for distribution details. 182s 182s R is a collaborative project with many contributors. 182s Type 'contributors()' for more information and 182s 'citation()' on how to cite R or R packages in publications. 182s 182s Type 'demo()' for some demos, 'help()' for on-line help, or 182s 'help.start()' for an HTML browser interface to help. 182s Type 'q()' to quit R. 182s 182s > library("matrixStats") 182s > 182s > rowMeans_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 182s + res <- rowMeans(x, na.rm = na.rm) 182s + if (!useNames) names(res) <- NULL 182s + res 182s + } 182s > 182s > colMeans_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 182s + res <- colMeans(x, na.rm = na.rm) 182s + if (!useNames) names(res) <- NULL 182s + res 182s + } 182s > 182s > for (mode in c("integer", "logical", "double")) { 182s + x <- matrix(-4:4, nrow = 3, ncol = 3) 182s + storage.mode(x) <- mode 182s + if (mode == "double") x <- x + 0.1 182s + 182s + # To check names attribute 182s + dimnames <- list(letters[1:3], LETTERS[1:3]) 182s + 182s + # Test with and without dimnames on x 182s + for (setDimnames in c(TRUE, FALSE)) { 182s + if (setDimnames) dimnames(x) <- dimnames 182s + else dimnames(x) <- NULL 182s + # Check names attribute 182s + for (useNames in c(TRUE, FALSE)) { 182s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 182s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + 182s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 182s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + } 182s + } 182s + } 182s > 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > # Special case: Single-element matrix 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > cat("Special case: Single-element matrix:\n") 182s Special case: Single-element matrix: 182s > for (mode in c("integer", "logical", "double")) { 182s + x <- matrix(1, nrow = 1, ncol = 1) 182s + storage.mode(x) <- mode 182s + 182s + # To check names attribute 182s + dimnames <- list("a", "A") 182s + 182s + # Test with and without dimnames on x 182s + for (setDimnames in c(TRUE, FALSE)) { 182s + if (setDimnames) dimnames(x) <- dimnames 182s + else dimnames(x) <- NULL 182s + # Check names attribute 182s + for (useNames in c(TRUE, FALSE)) { 182s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 182s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + 182s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 182s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + } 182s + } 182s + } 182s > 182s > 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > # Special case: Empty matrix 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > cat("Special case: Empty matrix:\n") 182s Special case: Empty matrix: 182s > for (mode in c("integer", "logical", "double")) { 182s + x <- matrix(integer(0), nrow = 0, ncol = 0) 182s + storage.mode(x) <- mode 182s + 182s + y0 <- rowMeans(x, na.rm = FALSE) 182s + y1 <- rowMeans2(x, na.rm = FALSE) 182s + stopifnot(all.equal(y1, y0)) 182s + 182s + y0 <- colMeans(x, na.rm = FALSE) 182s + y1 <- colMeans2(x, na.rm = FALSE) 182s + stopifnot(all.equal(y1, y0)) 182s + } 182s > 182s > 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > # Special case: All NAs 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > cat("Special case: All NAs:\n") 182s Special case: All NAs: 182s > for (mode in c("integer", "logical", "double")) { 182s + x <- matrix(NA_integer_, nrow = 3, ncol = 3) 182s + storage.mode(x) <- mode 182s + 182s + # To check names attribute 182s + dimnames <- list(letters[1:3], LETTERS[1:3]) 182s + 182s + # Test with and without dimnames on x 182s + for (setDimnames in c(TRUE, FALSE)) { 182s + if (setDimnames) dimnames(x) <- dimnames 182s + else dimnames(x) <- NULL 182s + # Check names attribute 182s + for (useNames in c(TRUE, FALSE)) { 182s + y0 <- rowMeans_R(x, na.rm = TRUE, useNames = useNames) 182s + y1 <- rowMeans2(x, na.rm = TRUE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + 182s + y0 <- colMeans_R(x, na.rm = TRUE, useNames = useNames) 182s + y1 <- colMeans2(x, na.rm = TRUE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + } 182s + } 182s + } 182s > 182s > 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > # Special case: All NaNs 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > cat("Special case: All NaNs:\n") 182s Special case: All NaNs: 182s > x <- matrix(NA_real_, nrow = 3, ncol = 3) 182s > 182s > # Test with and without dimnames on x 182s > for (setDimnames in c(TRUE, FALSE)) { 182s + if (setDimnames) dimnames(x) <- dimnames 182s + else dimnames(x) <- NULL 182s + # Check names attribute 182s + for (useNames in c(TRUE, FALSE)) { 182s + y0 <- rowMeans_R(x, na.rm = TRUE, useNames = useNames) 182s + y1 <- rowMeans2(x, na.rm = TRUE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + 182s + y0 <- colMeans_R(x, na.rm = TRUE, useNames = useNames) 182s + y1 <- colMeans2(x, na.rm = TRUE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + } 182s + } 182s > 182s > 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > # Special case: All Infs 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > cat("Special case: All Infs:\n") 182s Special case: All Infs: 182s > x <- matrix(Inf, nrow = 3, ncol = 3) 182s > 182s > # Test with and without dimnames on x 182s > for (setDimnames in c(TRUE, FALSE)) { 182s + if (setDimnames) dimnames(x) <- dimnames 182s + else dimnames(x) <- NULL 182s + # Check names attribute 182s + for (useNames in c(TRUE, FALSE)) { 182s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 182s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + 182s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 182s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + } 182s + } 182s > 182s > 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > # Special case: All -Infs 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > cat("Special case: All -Infs:\n") 182s Special case: All -Infs: 182s > x <- matrix(-Inf, nrow = 3, ncol = 3) 182s > 182s > # Test with and without dimnames on x 182s > for (setDimnames in c(TRUE, FALSE)) { 182s + if (setDimnames) dimnames(x) <- dimnames 182s + else dimnames(x) <- NULL 182s + # Check names attribute 182s + for (useNames in c(TRUE, FALSE)) { 182s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 182s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + 182s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 182s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + } 182s + } 182s > 182s > 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > # Special case: Infs and -Infs 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > cat("Special case: Infs and -Infs:\n") 182s Special case: Infs and -Infs: 182s > x <- matrix(c(-Inf, +Inf), nrow = 4, ncol = 4) 182s > 182s > # To check names attribute 182s > dimnames <- list(letters[1:4], LETTERS[1:4]) 182s > 182s > # Test with and without dimnames on x 182s > for (setDimnames in c(TRUE, FALSE)) { 182s + if (setDimnames) dimnames(x) <- dimnames 182s + else dimnames(x) <- NULL 182s + # Check names attribute 182s + for (useNames in c(TRUE, FALSE)) { 182s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 182s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + 182s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 182s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + } 182s + } 182s > 182s > 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > # Special case: NaNs and NAs 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > cat("Special case: NaNs and NAs:\n") 182s Special case: NaNs and NAs: 182s > x <- matrix(c(NaN, NA_real_), nrow = 4, ncol = 4) 182s > 182s > # Test with and without dimnames on x 182s > for (setDimnames in c(TRUE, FALSE)) { 182s + if (setDimnames) dimnames(x) <- dimnames 182s + else dimnames(x) <- NULL 182s + # Check names attribute 182s + for (useNames in c(TRUE, FALSE)) { 182s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 182s + str(y0) 182s + stopifnot(all(is.na(y0)), length(unique(y0)) >= 1L) 182s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 182s + str(y1) 182s + stopifnot(all(is.na(y1)), length(unique(y1)) >= 1L) 182s + stopifnot(all.equal(y1, y0)) 182s + 182s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 182s + stopifnot(all(is.na(y0)), length(unique(y0)) == 1L) 182s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 182s + stopifnot(all(is.na(y1)), length(unique(y1)) == 1L) 182s + stopifnot(all.equal(y1, y0)) 182s + } 182s + } 182s Named num [1:4] NaN NA NaN NA 182s - attr(*, "names")= chr [1:4] "a" "b" "c" "d" 182s Named num [1:4] NaN NA NaN NA 182s - attr(*, "names")= chr [1:4] "a" "b" "c" "d" 182s num [1:4] NaN NA NaN NA 182s num [1:4] NaN NA NaN NA 182s num [1:4] NaN NA NaN NA 182s num [1:4] NaN NA NaN NA 182s num [1:4] NaN NA NaN NA 182s num [1:4] NaN NA NaN NA 182s > ## NOTE, due to compiler optimization, it is not guaranteed that NA is 182s > ## returned here (as one would expect). NaN might very well be returned, 182s > ## when both NA and NaN are involved. This is an accepted feature in R, 182s > ## which is documented in help("is.nan"). See also 182s > ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 182s > ## Thus, we cannot guarantee that y1 is identical to y0. 182s > 182s > 182s > 182s > 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > # Special case: Integer overflow with ties 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > cat("Special case: Integer overflow with ties:\n") 182s Special case: Integer overflow with ties: 182s > x <- matrix(.Machine$integer.max, nrow = 4, ncol = 4) 182s > 182s > # Test with and without dimnames on x 182s > for (setDimnames in c(TRUE, FALSE)) { 182s + if (setDimnames) dimnames(x) <- dimnames 182s + else dimnames(x) <- NULL 182s + # Check names attribute 182s + for (useNames in c(TRUE, FALSE)) { 182s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 182s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + 182s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 182s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + } 182s + } 182s > 182s > 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > # Consistency checks 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > set.seed(1) 182s > 182s > cat("Consistency checks:\n") 182s Consistency checks: 182s > n_sims <- if (Sys.getenv("_R_CHECK_USE_VALGRIND_") != "") 4L else 20L 182s > for (kk in seq_len(n_sims)) { 182s + cat("Random test #", kk, "\n", sep = "") 182s + 182s + # Simulate data in a matrix of any shape 182s + dim <- sample(50:200, size = 2) 182s + n <- prod(dim) 182s + x <- rnorm(n, sd = 100) 182s + dim(x) <- dim 182s + 182s + # Add NAs? 182s + if ((kk %% 4) %in% c(3, 0)) { 182s + cat("Adding NAs\n") 182s + nna <- sample(n, size = 1) 182s + na_values <- c(NA_real_, NaN) 182s + t <- sample(na_values, size = nna, replace = TRUE) 182s + x[sample(length(x), size = nna)] <- t 182s + } 182s + 182s + # Mode? 182s + modes <- "double" 182s + if ((kk %% 4) %in% c(2, 0)) { 182s + modes <- c("integer", "logical") 182s + } 182s + 182s + for (mode in modes) { 182s + if (mode != "double") { 182s + cat(sprintf("Coercing from %s to %s\n", storage.mode(x), mode)) 182s + storage.mode(x) <- mode 182s + } 182s + 182s + na.rm <- sample(c(TRUE, FALSE), size = 1) 182s + 182s + # rowMeans2(): 182s + y0 <- rowMeans(x, na.rm = na.rm) 182s + y1 <- rowMeans2(x, na.rm = na.rm) 182s + stopifnot(all.equal(y1, y0)) 182s + y2 <- colMeans2(t(x), na.rm = na.rm) 182s + stopifnot(all.equal(y2, y0)) 182s + 182s + # colMeans2(): 182s + y0 <- colMeans(x, na.rm = na.rm) 182s + y1 <- colMeans2(x, na.rm = na.rm) 182s + stopifnot(all.equal(y1, y0)) 182s + y2 <- rowMeans2(t(x), na.rm = na.rm) 182s + stopifnot(all.equal(y2, y0)) 182s + } 182s + } # for (kk ...) 182s Random test #1 182s Random test #2 182s Coercing from double to integer 182s Coercing from integer to logical 182s Random test #3 182s Adding NAs 182s Random test #4 182s Adding NAs 182s Coercing from double to integer 182s Coercing from integer to logical 182s Random test #5 182s Random test #6 182s Coercing from double to integer 182s Coercing from integer to logical 182s Random test #7 182s Adding NAs 182s Random test #8 182s Adding NAs 182s Coercing from double to integer 182s Coercing from integer to logical 182s Random test #9 182s Random test #10 182s Coercing from double to integer 182s Coercing from integer to logical 182s Random test #11 182s Adding NAs 182s Random test #12 182s Adding NAs 182s Coercing from double to integer 182s Coercing from integer to logical 182s Random test #13 182s Random test #14 182s Coercing from double to integer 182s Coercing from integer to logical 182s Random test #15 182s Adding NAs 182s Random test #16 182s Adding NAs 182s Coercing from double to integer 182s Coercing from integer to logical 182s Random test #17 182s Random test #18 182s Coercing from double to integer 182s Coercing from integer to logical 182s Random test #19 182s Adding NAs 182s Random test #20 182s Adding NAs 182s Coercing from double to integer 182s Coercing from integer to logical 182s > 182s 182s R version 4.4.3 (2025-02-28) -- "Trophy Case" 182s Copyright (C) 2025 The R Foundation for Statistical Computing 182s Platform: s390x-ibm-linux-gnu 182s 182s R is free software and comes with ABSOLUTELY NO WARRANTY. 182s You are welcome to redistribute it under certain conditions. 182s Type 'license()' or 'licence()' for distribution details. 182s 182s R is a collaborative project with many contributors. 182s Type 'contributors()' for more information and 182s 'citation()' on how to cite R or R packages in publications. 182s 182s Type 'demo()' for some demos, 'help()' for on-line help, or 182s 'help.start()' for an HTML browser interface to help. 182s Type 'q()' to quit R. 182s 182s > library("matrixStats") 182s > 182s > rowMeans_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 182s + res <- rowMeans(x, na.rm = na.rm) 182s + if (!useNames) names(res) <- NULL 182s + res 182s + } 182s > 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > # Subsetted tests 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > source("utils/validateIndicesFramework.R") 182s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 182s > storage.mode(x) <- "integer" 182s > 182s > # To check names attribute 182s > dimnames <- list(letters[1:6], LETTERS[1:6]) 182s > 182s > # Test with and without dimnames on x 182s > for (setDimnames in c(TRUE, FALSE)) { 182s + if (setDimnames) dimnames(x) <- dimnames 182s + else dimnames(x) <- NULL 182s + 182s + count <- 0L 182s + for (rows in index_cases) { 182s + for (cols in index_cases) { 182s + count <- count + 1L 182s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 182s + useNames <- c(TRUE, FALSE) 182s + useNames <- useNames[count %% length(useNames) + 1] 182s + 182s + validateIndicesTestMatrix(x, rows, cols, 182s + ftest = rowMeans2, fsure = rowMeans_R, 182s + na.rm = na.rm, useNames = useNames) 182s + validateIndicesTestMatrix(x, rows, cols, 182s + fcoltest = colMeans2, fsure = rowMeans_R, 182s + na.rm = na.rm, useNames = useNames) 182s + } 182s + } 182s + } 182s > 182s 182s R version 4.4.3 (2025-02-28) -- "Trophy Case" 182s Copyright (C) 2025 The R Foundation for Statistical Computing 182s Platform: s390x-ibm-linux-gnu 182s 182s R is free software and comes with ABSOLUTELY NO WARRANTY. 182s You are welcome to redistribute it under certain conditions. 182s Type 'license()' or 'licence()' for distribution details. 182s 182s R is a collaborative project with many contributors. 182s Type 'contributors()' for more information and 182s 'citation()' on how to cite R or R packages in publications. 182s 182s Type 'demo()' for some demos, 'help()' for on-line help, or 182s 'help.start()' for an HTML browser interface to help. 182s Type 'q()' to quit R. 182s 182s > library("matrixStats") 182s > 182s > rowMedians_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 182s + res <- apply(x, MARGIN = 1L, FUN = median, na.rm = na.rm) 182s + if (!useNames) names(res) <- NULL 182s + res 182s + } 182s > 182s > colMedians_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 182s + res <- apply(x, MARGIN = 2L, FUN = median, na.rm = na.rm) 182s + if (!useNames) names(res) <- NULL 182s + res 182s + } 182s > 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > # Special case: Non-ties 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > cat("Special case: Non-ties:\n") 182s Special case: Non-ties: 182s > for (mode in c("integer", "double")) { 182s + x <- matrix(1:9 + 0.1, nrow = 3, ncol = 3) 182s + storage.mode(x) <- mode 182s + 182s + # To check names attribute 182s + dimnames <- list(letters[1:3], LETTERS[1:3]) 182s + 182s + # Test with and without dimnames on x 182s + for (setDimnames in c(TRUE, FALSE)) { 182s + if (setDimnames) dimnames(x) <- dimnames 182s + else dimnames(x) <- NULL 182s + # Check names attribute 182s + for (useNames in c(TRUE, FALSE)) { 182s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 182s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + 182s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 182s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + } 182s + } 182s + } 182s > 182s > 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > # Special case: Ties 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > cat("Special case: Ties:\n") 182s Special case: Ties: 182s > for (mode in c("integer", "double")) { 182s + x <- matrix(1:16 + 0.1, nrow = 4, ncol = 4) 182s + storage.mode(x) <- mode 182s + 182s + # To check names attribute 182s + dimnames <- list(letters[1:4], LETTERS[1:4]) 182s + 182s + # Test with and without dimnames on x 182s + for (setDimnames in c(TRUE, FALSE)) { 182s + if (setDimnames) dimnames(x) <- dimnames 182s + else dimnames(x) <- NULL 182s + # Check names attribute 182s + for (useNames in c(TRUE, FALSE)) { 182s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 182s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + 182s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 182s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + } 182s + } 182s + } 182s > 182s > 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > # Special case: Single-element matrix 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > cat("Special case: Single-element matrix:\n") 182s Special case: Single-element matrix: 182s > for (mode in c("integer", "double")) { 182s + x <- matrix(1, nrow = 1, ncol = 1) 182s + storage.mode(x) <- mode 182s + 182s + # To check names attribute 182s + dimnames <- list("a", "A") 182s + 182s + # Test with and without dimnames on x 182s + for (setDimnames in c(TRUE, FALSE)) { 182s + if (setDimnames) dimnames(x) <- dimnames 182s + else dimnames(x) <- NULL 182s + # Check names attribute 182s + for (useNames in c(TRUE, FALSE)) { 182s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 182s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + 182s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 182s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + } 182s + } 182s + } 182s > 182s > 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > # Special case: Empty matrix 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > cat("Special case: Empty matrix:\n") 182s Special case: Empty matrix: 182s > for (mode in c("integer", "double")) { 182s + x <- matrix(integer(0), nrow = 0, ncol = 0) 182s + storage.mode(x) <- mode 182s + 182s + y0 <- rowMedians_R(x, na.rm = FALSE) 182s + y1 <- rowMedians(x, na.rm = FALSE) 182s + stopifnot(all.equal(y1, y0)) 182s + 182s + y0 <- colMedians_R(x, na.rm = FALSE) 182s + y1 <- colMedians(x, na.rm = FALSE) 182s + stopifnot(all.equal(y1, y0)) 182s + } 182s > 182s > 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > # Special case: All NAs 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > cat("Special case: All NAs:\n") 182s Special case: All NAs: 182s > for (mode in c("integer", "double")) { 182s + x <- matrix(NA_integer_, nrow = 3, ncol = 3) 182s + storage.mode(x) <- mode 182s + 182s + # To check names attribute 182s + dimnames <- list(letters[1:3], LETTERS[1:3]) 182s + 182s + # Test with and without dimnames on x 182s + for (setDimnames in c(TRUE, FALSE)) { 182s + if (setDimnames) dimnames(x) <- dimnames 182s + else dimnames(x) <- NULL 182s + # Check names attribute 182s + for (useNames in c(TRUE, FALSE)) { 182s + y0 <- rowMedians_R(x, na.rm = TRUE, useNames = useNames) 182s + y1 <- rowMedians(x, na.rm = TRUE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + 182s + y0 <- colMedians_R(x, na.rm = TRUE, useNames = useNames) 182s + y1 <- colMedians(x, na.rm = TRUE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + } 182s + } 182s + } 182s > 182s > 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > # Special case: All NaNs 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > cat("Special case: All NaNs:\n") 182s Special case: All NaNs: 182s > x <- matrix(NA_real_, nrow = 3, ncol = 3) 182s > 182s > # Test with and without dimnames on x 182s > for (setDimnames in c(TRUE, FALSE)) { 182s + if (setDimnames) dimnames(x) <- dimnames 182s + else dimnames(x) <- NULL 182s + # Check names attribute 182s + for (useNames in c(TRUE, FALSE)) { 182s + y0 <- rowMedians_R(x, na.rm = TRUE, useNames = useNames) 182s + y1 <- rowMedians(x, na.rm = TRUE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + 182s + y0 <- colMedians_R(x, na.rm = TRUE, useNames = useNames) 182s + y1 <- colMedians(x, na.rm = TRUE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + } 182s + } 182s > 182s > 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > # Special case: All Infs 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > cat("Special case: All Infs:\n") 182s Special case: All Infs: 182s > x <- matrix(Inf, nrow = 3, ncol = 3) 182s > 182s > # Test with and without dimnames on x 182s > for (setDimnames in c(TRUE, FALSE)) { 182s + if (setDimnames) dimnames(x) <- dimnames 182s + else dimnames(x) <- NULL 182s + # Check names attribute 182s + for (useNames in c(TRUE, FALSE)) { 182s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 182s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + 182s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 182s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + } 182s + } 182s > 182s > 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > # Special case: All -Infs 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > cat("Special case: All -Infs:\n") 182s Special case: All -Infs: 182s > x <- matrix(-Inf, nrow = 3, ncol = 3) 182s > 182s > # Test with and without dimnames on x 182s > for (setDimnames in c(TRUE, FALSE)) { 182s + if (setDimnames) dimnames(x) <- dimnames 182s + else dimnames(x) <- NULL 182s + # Check names attribute 182s + for (useNames in c(TRUE, FALSE)) { 182s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 182s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + 182s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 182s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + } 182s + } 182s > 182s > 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > # Special case: Infs and -Infs 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > cat("Special case: Infs and -Infs:\n") 182s Special case: Infs and -Infs: 182s > x <- matrix(c(-Inf, +Inf), nrow = 4, ncol = 4) 182s > 182s > # To check names attribute 182s > dimnames <- list(letters[1:4], LETTERS[1:4]) 182s > 182s > # Test with and without dimnames on x 182s > for (setDimnames in c(TRUE, FALSE)) { 182s + if (setDimnames) dimnames(x) <- dimnames 182s + else dimnames(x) <- NULL 182s + # Check names attribute 182s + for (useNames in c(TRUE, FALSE)) { 182s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 182s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + 182s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 182s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + } 182s + } 182s > 182s > 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > # Special case: Integer overflow with ties 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > cat("Special case: Integer overflow with ties:\n") 182s Special case: Integer overflow with ties: 182s > x <- matrix(.Machine$integer.max, nrow = 4, ncol = 4) 182s > 182s > # Test with and without dimnames on x 182s > for (setDimnames in c(TRUE, FALSE)) { 182s + if (setDimnames) dimnames(x) <- dimnames 182s + else dimnames(x) <- NULL 182s + # Check names attribute 182s + for (useNames in c(TRUE, FALSE)) { 182s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 182s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + 182s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 182s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 182s + stopifnot(all.equal(y1, y0)) 182s + } 182s + } 182s > 182s > 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > # Consistency checks 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > set.seed(1) 182s > 182s > cat("Consistency checks:\n") 182s Consistency checks: 182s > n_sims <- if (Sys.getenv("_R_CHECK_USE_VALGRIND_") != "") 4L else 20L 182s > for (kk in seq_len(n_sims)) { 182s + cat("Random test #", kk, "\n", sep = "") 182s + 182s + # Simulate data in a matrix of any shape 182s + dim <- sample(50:200, size = 2) 182s + n <- prod(dim) 182s + x <- rnorm(n, sd = 100) 182s + dim(x) <- dim 182s + 182s + # Add NAs? 182s + if ((kk %% 4) %in% c(3, 0)) { 182s + cat("Adding NAs\n") 182s + nna <- sample(n, size = 1) 182s + na_values <- c(NA_real_, NaN) 182s + t <- sample(na_values, size = nna, replace = TRUE) 182s + x[sample(length(x), size = nna)] <- t 182s + } 182s + 182s + # Integer or double? 182s + if ((kk %% 4) %in% c(2, 0)) { 182s + cat("Coercing to integers\n") 182s + storage.mode(x) <- "integer" 182s + } 182s + 182s + na.rm <- sample(c(TRUE, FALSE), size = 1) 182s + 182s + # rowMedians(): 182s + y0 <- rowMedians_R(x, na.rm = na.rm) 182s + y1 <- rowMedians(x, na.rm = na.rm) 182s + stopifnot(all.equal(y1, y0)) 182s + y2 <- colMedians(t(x), na.rm = na.rm) 182s + stopifnot(all.equal(y2, y0)) 182s + 182s + # colMedians(): 182s + y0 <- colMedians_R(x, na.rm = na.rm) 182s + y1 <- colMedians(x, na.rm = na.rm) 182s + stopifnot(all.equal(y1, y0)) 182s + y2 <- rowMedians(t(x), na.rm = na.rm) 182s + stopifnot(all.equal(y2, y0)) 182s + } # for (kk ...) 182s Random test #1 182s Random test #2 182s Coercing to integers 182s Random test #3 182s Adding NAs 182s Random test #4 182s Adding NAs 182s Coercing to integers 182s Random test #5 182s Random test #6 182s Coercing to integers 182s Random test #7 182s Adding NAs 183s Random test #8 183s Adding NAs 183s Coercing to integers 183s Random test #9 183s Random test #10 183s Coercing to integers 183s Random test #11 183s Adding NAs 183s Random test #12 183s Adding NAs 183s Coercing to integers 183s Random test #13 183s Random test #14 183s Coercing to integers 183s Random test #15 183s Adding NAs 183s Random test #16 183s Adding NAs 183s Coercing to integers 183s Random test #17 183s Random test #18 183s Coercing to integers 183s Random test #19 183s Adding NAs 183s Random test #20 183s Adding NAs 183s Coercing to integers 183s > 183s 183s R version 4.4.3 (2025-02-28) -- "Trophy Case" 183s Copyright (C) 2025 The R Foundation for Statistical Computing 183s Platform: s390x-ibm-linux-gnu 183s 183s R is free software and comes with ABSOLUTELY NO WARRANTY. 183s You are welcome to redistribute it under certain conditions. 183s Type 'license()' or 'licence()' for distribution details. 183s 183s R is a collaborative project with many contributors. 183s Type 'contributors()' for more information and 183s 'citation()' on how to cite R or R packages in publications. 183s 183s Type 'demo()' for some demos, 'help()' for on-line help, or 183s 'help.start()' for an HTML browser interface to help. 183s Type 'q()' to quit R. 183s 183s > library("matrixStats") 183s > 183s > rowMedians_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 183s + res <- apply(x, MARGIN = 1L, FUN = median, na.rm = na.rm) 183s + if (!useNames) names(res) <- NULL 183s + res 183s + } 183s > 183s > colMedians_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 183s + res <- apply(x, MARGIN = 2L, FUN = median, na.rm = na.rm) 183s + if (!useNames) names(res) <- NULL 183s + res 183s + } 183s > 183s > 183s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 183s > # Subsetted tests 183s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 183s > source("utils/validateIndicesFramework.R") 183s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 183s > storage.mode(x) <- "integer" 183s > 183s > # To check names attribute 183s > dimnames <- list(letters[1:6], LETTERS[1:6]) 183s > 183s > # Test with and without dimnames on x 183s > for (setDimnames in c(TRUE, FALSE)) { 183s + if (setDimnames) dimnames(x) <- dimnames 183s + else dimnames(x) <- NULL 183s + 183s + count <- 0L 183s + for (rows in index_cases) { 183s + for (cols in index_cases) { 183s + count <- count + 1L 183s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 183s + useNames <- c(TRUE, FALSE) 183s + useNames <- useNames[count %% length(useNames) + 1] 183s + 183s + validateIndicesTestMatrix(x, rows, cols, 183s + ftest = rowMedians, fsure = rowMedians_R, 183s + na.rm = na.rm, useNames = useNames) 183s + validateIndicesTestMatrix(x, rows, cols, 183s + fcoltest = colMedians, fsure = rowMedians_R, 183s + na.rm = na.rm, useNames = useNames) 183s + } 183s + } 183s + } 183s > 183s 183s R version 4.4.3 (2025-02-28) -- "Trophy Case" 183s Copyright (C) 2025 The R Foundation for Statistical Computing 183s Platform: s390x-ibm-linux-gnu 183s 183s R is free software and comes with ABSOLUTELY NO WARRANTY. 183s You are welcome to redistribute it under certain conditions. 183s Type 'license()' or 'licence()' for distribution details. 183s 183s R is a collaborative project with many contributors. 183s Type 'contributors()' for more information and 183s 'citation()' on how to cite R or R packages in publications. 183s 183s Type 'demo()' for some demos, 'help()' for on-line help, or 183s 'help.start()' for an HTML browser interface to help. 183s Type 'q()' to quit R. 183s 183s > library("matrixStats") 183s > library("stats") 183s > 183s > asWhich <- function(probs, max) { 183s + idx <- as.integer(round(probs * max)) 183s + if (idx < 1L) { 183s + idx <- 1L 183s + } else if (idx > max) { 183s + idx <- max 183s + } 183s + idx 183s + } # asWhich() 183s > 183s > rowOrderStats_R <- function(x, probs, ..., useNames = TRUE) { 183s + ans <- apply(x, MARGIN = 1L, FUN = quantile, probs = probs, type = 3L) 183s + 183s + # Remove Attributes 183s + if (!useNames || length(ans) == 0L) attributes(ans) <- NULL 183s + ans 183s + } # rowOrderStats_R() 183s > 183s > 183s > set.seed(1) 183s > 183s > 183s > # Simulate data in a matrix of any shape 183s > nrow <- 60L 183s > ncol <- 30L 183s > x <- rnorm(nrow * ncol) 183s > dim(x) <- c(nrow, ncol) 183s > probs <- 0.3 183s > which <- asWhich(probs, max = ncol) 183s > 183s > y0 <- rowOrderStats_R(x, probs = probs) 183s > y1 <- rowOrderStats(x, which = which) 183s > stopifnot(all.equal(y1, y0)) 183s > y2 <- colOrderStats(t(x), which = which) 183s > stopifnot(all.equal(y2, y0)) 183s > 183s > 183s > 183s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 183s > # Consistency checks 183s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 183s > for (mode in c("integer", "double")) { 183s + cat("Consistency checks without NAs:\n") 183s + for (kk in 1:3) { 183s + cat("Random test #", kk, "\n", sep = "") 183s + 183s + # Simulate data in a matrix of any shape 183s + nrow <- sample(20L, size = 1L) 183s + ncol <- sample(20L, size = 1L) 183s + x <- rnorm(nrow * ncol) 183s + dim(x) <- c(nrow, ncol) 183s + 183s + cat("mode: ", mode, "\n", sep = "") 183s + storage.mode(x) <- mode 183s + str(x) 183s + 183s + probs <- runif(1) 183s + which <- asWhich(probs, max = ncol) 183s + 183s + y0 <- rowOrderStats_R(x, probs = probs) 183s + y1 <- rowOrderStats(x, which = which) 183s + stopifnot(all.equal(y1, y0)) 183s + y2 <- colOrderStats(t(x), which = which) 183s + stopifnot(all.equal(y2, y0)) 183s + } # for (kk in ...) 183s + } # for (mode ...) 183s Consistency checks without NAs: 183s Random test #1 183s mode: integer 183s int [1:14, 1:6] 0 0 1 0 2 -1 1 0 0 0 ... 183s Random test #2 183s mode: integer 183s int [1:8, 1:13] 0 0 1 -2 0 0 0 0 1 0 ... 183s Random test #3 183s mode: integer 183s int [1:20, 1:17] 0 0 0 0 1 0 1 0 0 -1 ... 183s Consistency checks without NAs: 183s Random test #1 183s mode: double 183s num [1:9, 1:5] -1.4286 -0.00386 -0.70456 -0.29242 -0.49607 ... 183s Random test #2 183s mode: double 183s num [1:11, 1:20] -0.796 0.482 -0.952 0.5 1.242 ... 183s Random test #3 183s mode: double 183s num [1:7, 1:18] 1.553 -2.405 0.167 -0.403 -1.746 ... 183s > 183s > 183s > # Check names attribute 183s > x <- matrix(1:9 + 0.1, nrow = 3L, ncol = 3L) 183s > 183s > probs <- runif(1) 183s > which <- asWhich(probs, max = ncol(x)) 183s > 183s > dimnames <- list(letters[1:3], LETTERS[1:3]) 183s > 183s > # Test with and without dimnames on x 183s > for (setDimnames in c(TRUE, FALSE)) { 183s + if (setDimnames) dimnames(x) <- dimnames 183s + else dimnames(x) <- NULL 183s + # Check names attribute 183s + for (useNames in c(TRUE, FALSE)) { 183s + y0 <- rowOrderStats_R(x, probs = probs, useNames = useNames) 183s + y1 <- rowOrderStats(x, which = which, useNames = useNames) 183s + stopifnot(all.equal(y1, y0)) 183s + y2 <- colOrderStats(t(x), which = which, useNames = useNames) 183s + stopifnot(all.equal(y2, y0)) 183s + } 183s + } 183s > 183s 183s R version 4.4.3 (2025-02-28) -- "Trophy Case" 183s Copyright (C) 2025 The R Foundation for Statistical Computing 183s Platform: s390x-ibm-linux-gnu 183s 183s R is free software and comes with ABSOLUTELY NO WARRANTY. 183s You are welcome to redistribute it under certain conditions. 183s Type 'license()' or 'licence()' for distribution details. 183s 183s R is a collaborative project with many contributors. 183s Type 'contributors()' for more information and 183s 'citation()' on how to cite R or R packages in publications. 183s 183s Type 'demo()' for some demos, 'help()' for on-line help, or 183s 'help.start()' for an HTML browser interface to help. 183s Type 'q()' to quit R. 183s 183s > library("matrixStats") 183s > 183s > rowOrderStats_R <- function(x, probs, ..., useNames = TRUE) { 183s + ans <- apply(x, MARGIN = 1L, FUN = quantile, probs = probs, type = 3L) 183s + 183s + # Remove Attributes 183s + if (!useNames || length(ans) == 0L) attributes(ans) <- NULL 183s + ans 183s + } # rowOrderStats_R() 183s > 183s > 183s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 183s > # Subsetted tests 183s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 183s > source("utils/validateIndicesFramework.R") 183s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 183s > storage.mode(x) <- "integer" 183s > 183s > # To check names attribute 183s > dimnames <- list(letters[1:6], LETTERS[1:6]) 183s > 183s > probs <- 0.3 183s > # Test with and without dimnames on x 183s > for (setDimnames in c(TRUE, FALSE)) { 183s + if (setDimnames) dimnames(x) <- dimnames 183s + else dimnames(x) <- NULL 183s + for (rows in index_cases) { 183s + for (cols in index_cases) { 183s + # Check names attribute 183s + for (useNames in c(TRUE, FALSE)) { 183s + if (is.null(cols)) which <- round(probs * ncol(x)) 183s + else { 183s + xxrows <- rows 183s + suppressWarnings({ 183s + xx <- tryCatch(x[, cols, drop = FALSE], error = function(c) "error") 183s + if (identical(xx, "error")) which <- 0L 183s + else which <- round(probs * ncol(xx)) 183s + }) 183s + } 183s + if (which == 0L) next 183s + 183s + validateIndicesTestMatrix(x, rows, cols, 183s + ftest = rowOrderStats, fsure = rowOrderStats_R, 183s + which = which, probs = probs, useNames = useNames) 183s + validateIndicesTestMatrix(x, rows, cols, 183s + fcoltest = colOrderStats, fsure = rowOrderStats_R, 183s + which = which, probs = probs, useNames = useNames) 183s + } 183s + } 183s + } 183s + } 184s > 184s 184s R version 4.4.3 (2025-02-28) -- "Trophy Case" 184s Copyright (C) 2025 The R Foundation for Statistical Computing 184s Platform: s390x-ibm-linux-gnu 184s 184s R is free software and comes with ABSOLUTELY NO WARRANTY. 184s You are welcome to redistribute it under certain conditions. 184s Type 'license()' or 'licence()' for distribution details. 184s 184s R is a collaborative project with many contributors. 184s Type 'contributors()' for more information and 184s 'citation()' on how to cite R or R packages in publications. 184s 184s Type 'demo()' for some demos, 'help()' for on-line help, or 184s 'help.start()' for an HTML browser interface to help. 184s Type 'q()' to quit R. 184s 184s > library("matrixStats") 184s > 184s > rowProds_R <- function(x, FUN = prod, na.rm = FALSE, ..., useNames = TRUE) { 184s + res <- apply(x, MARGIN = 1L, FUN = FUN, na.rm = na.rm) 184s + if (!useNames) names(res) <- NULL 184s + res 184s + } 184s > 184s > all.equal.na <- function(target, current, ...) { 184s + # Computations involving NaN may return NaN or NA, cf. ?is.nan 184s + current[is.nan(current)] <- NA_real_ 184s + target[is.nan(target)] <- NA_real_ 184s + all.equal(target, current, ...) 184s + } 184s > 184s > for (mode in c("integer", "double")) { 184s + # Missing values 184s + x <- matrix(c(1, NA, NaN, 1, 1, 0, 1, 0), nrow = 4, ncol = 2) 184s + cat("mode: ", mode, "\n", sep = "") 184s + storage.mode(x) <- mode 184s + str(x) 184s + 184s + # To check names attribute 184s + dimnames <- list(letters[1:4], LETTERS[1:2]) 184s + 184s + # Test with and without dimnames on x 184s + for (setDimnames in c(TRUE, FALSE)) { 184s + if (setDimnames) dimnames(x) <- dimnames 184s + else dimnames(x) <- NULL 184s + # Check names attribute 184s + for (useNames in c(TRUE, FALSE)) { 184s + y0 <- rowProds_R(x, na.rm = TRUE, useNames = useNames) 184s + print(y0) 184s + y1 <- rowProds(x, na.rm = TRUE, useNames = useNames) 184s + print(y1) 184s + y2 <- colProds(t(x), na.rm = TRUE, useNames = useNames) 184s + print(y2) 184s + stopifnot(all.equal(y1, y0)) 184s + stopifnot(all.equal(y2, y1)) 184s + 184s + # Missing values 184s + y0 <- rowProds_R(x, na.rm = FALSE, useNames = useNames) 184s + print(y0) 184s + y1 <- rowProds(x, na.rm = FALSE, useNames = useNames) 184s + print(y1) 184s + y2 <- colProds(t(x), na.rm = FALSE, useNames = useNames) 184s + print(y2) 184s + stopifnot(all.equal(y1, y0)) 184s + stopifnot(all.equal(y2, y1)) 184s + 184s + # "Empty" rows 184s + y0 <- rowProds_R(x[integer(0), , drop = FALSE], na.rm = FALSE, useNames = useNames) 184s + print(y0) 184s + y1 <- rowProds(x[integer(0), , drop = FALSE], na.rm = FALSE, useNames = useNames) 184s + print(y1) 184s + y2 <- colProds(t(x[integer(0), , drop = FALSE]), na.rm = FALSE, useNames = useNames) 184s + print(y2) 184s + stopifnot(all.equal.na(y1, y0)) 184s + stopifnot(all.equal(y2, y1)) 184s + stopifnot(length(y1) == 0L) 184s + 184s + # Using product() 184s + y1 <- rowProds(x, method = "expSumLog", na.rm = FALSE, useNames = useNames) 184s + print(y1) 184s + y2 <- colProds(t(x), method = "expSumLog", na.rm = FALSE, useNames = useNames) 184s + print(y2) 184s + stopifnot(all.equal(y2, y1)) 184s + } 184s + } 184s + } # for (mode ...) 184s mode: integer 184s int [1:4, 1:2] 1 NA NA 1 1 0 1 0 184s a b c d 184s 1 0 1 0 184s a b c d 184s 1 0 1 0 184s a b c d 184s 1 0 1 0 184s a b c d 184s 1 NA NA 0 184s a b c d 184s 1 NA NA 0 184s a b c d 184s 1 NA NA 0 184s numeric(0) 184s numeric(0) 184s numeric(0) 184s a b c d 184s 1 NA NA 0 184s a b c d 184s 1 NA NA 0 184s [1] 1 0 1 0 184s [1] 1 0 1 0 184s [1] 1 0 1 0 184s [1] 1 NA NA 0 184s [1] 1 NA NA 0 184s [1] 1 NA NA 0 184s numeric(0) 184s numeric(0) 184s numeric(0) 184s [1] 1 NA NA 0 184s [1] 1 NA NA 0 184s [1] 1 0 1 0 184s [1] 1 0 1 0 184s [1] 1 0 1 0 184s [1] 1 NA NA 0 184s [1] 1 NA NA 0 184s [1] 1 NA NA 0 184s numeric(0) 184s numeric(0) 184s numeric(0) 184s [1] 1 NA NA 0 184s [1] 1 NA NA 0 184s [1] 1 0 1 0 184s [1] 1 0 1 0 184s [1] 1 0 1 0 184s [1] 1 NA NA 0 184s [1] 1 NA NA 0 184s [1] 1 NA NA 0 184s numeric(0) 184s numeric(0) 184s numeric(0) 184s [1] 1 NA NA 0 184s [1] 1 NA NA 0 184s mode: double 184s num [1:4, 1:2] 1 NA NaN 1 1 0 1 0 184s a b c d 184s 1 0 1 0 184s a b c d 184s 1 0 1 0 184s a b c d 184s 1 0 1 0 184s a b c d 184s 1 NA NaN 0 184s a b c d 184s 1 NA NaN 0 184s a b c d 184s 1 NA NaN 0 184s numeric(0) 184s numeric(0) 184s numeric(0) 184s a b c d 184s 1 NA NA 0 184s a b c d 184s 1 NA NA 0 184s [1] 1 0 1 0 184s [1] 1 0 1 0 184s [1] 1 0 1 0 184s [1] 1 NA NaN 0 184s [1] 1 NA NaN 0 184s [1] 1 NA NaN 0 184s numeric(0) 184s numeric(0) 184s numeric(0) 184s [1] 1 NA NA 0 184s [1] 1 NA NA 0 184s [1] 1 0 1 0 184s [1] 1 0 1 0 184s [1] 1 0 1 0 184s [1] 1 NA NaN 0 184s [1] 1 NA NaN 0 184s [1] 1 NA NaN 0 184s numeric(0) 184s numeric(0) 184s numeric(0) 184s [1] 1 NA NA 0 184s [1] 1 NA NA 0 184s [1] 1 0 1 0 184s [1] 1 0 1 0 184s [1] 1 0 1 0 184s [1] 1 NA NaN 0 184s [1] 1 NA NaN 0 184s [1] 1 NA NaN 0 184s numeric(0) 184s numeric(0) 184s numeric(0) 184s [1] 1 NA NA 0 184s [1] 1 NA NA 0 184s > 184s > 184s > # Bug report 2012-06-25 184s > x <- matrix(c(1, 1, 1, 1, 1, 0, 1, 0), nrow = 4, ncol = 2) 184s > y0 <- rowProds_R(x) 184s > print(y0) 184s [1] 1 0 1 0 184s > y1 <- rowProds(x) 184s > print(y1) 184s [1] 1 0 1 0 184s > y2 <- colProds(t(x)) 184s > print(y2) 184s [1] 1 0 1 0 184s > stopifnot(all.equal.na(y1, y0)) 184s > stopifnot(all.equal.na(y1, x[, 1] * x[, 2])) 184s > stopifnot(all.equal.na(y2, y1)) 184s > # Check names attribute 184s > dimnames(x) <- dimnames 184s > y0 <- rowProds_R(x, useNames = TRUE) 184s > print(y0) 184s a b c d 184s 1 0 1 0 184s > y1 <- rowProds(x, useNames = TRUE) 184s > print(y1) 184s a b c d 184s 1 0 1 0 184s > y2 <- colProds(t(x), useNames = TRUE) 184s > print(y2) 184s a b c d 184s 1 0 1 0 184s > stopifnot(all.equal.na(y1, y0)) 184s > stopifnot(all.equal.na(y1, x[, 1] * x[, 2])) 184s > stopifnot(all.equal.na(y2, y1)) 184s > 184s > # Bug report 2014-03-25 ("all rows contains a zero") 184s > x <- matrix(c(0, 1, 1, 0), nrow = 2, ncol = 2) 184s > # To check names attribute 184s > dimnames <- list(letters[1:2], LETTERS[1:2]) 184s > y0 <- rowProds_R(x) 184s > print(y0) 184s [1] 0 0 184s > y1 <- rowProds(x) 184s > print(y1) 184s [1] 0 0 184s > y2 <- colProds(t(x)) 184s > print(y2) 184s [1] 0 0 184s > stopifnot(all.equal.na(y1, y0)) 184s > stopifnot(all.equal.na(y1, c(0, 0))) 184s > stopifnot(all.equal.na(y2, y1)) 184s > # Check names attribute 184s > dimnames(x) <- dimnames 184s > y0 <- rowProds_R(x, useNames = TRUE) 184s > print(y0) 184s a b 184s 0 0 184s > y1 <- rowProds(x, useNames = TRUE) 184s > print(y1) 184s a b 184s 0 0 184s > y2 <- colProds(t(x), useNames = TRUE) 184s > print(y2) 184s a b 184s 0 0 184s > stopifnot(all.equal.na(y1, y0)) 184s > stopifnot(all.equal.na(y2, y1)) 184s > 185s 185s R version 4.4.3 (2025-02-28) -- "Trophy Case" 185s Copyright (C) 2025 The R Foundation for Statistical Computing 185s Platform: s390x-ibm-linux-gnu 185s 185s R is free software and comes with ABSOLUTELY NO WARRANTY. 185s You are welcome to redistribute it under certain conditions. 185s Type 'license()' or 'licence()' for distribution details. 185s 185s R is a collaborative project with many contributors. 185s Type 'contributors()' for more information and 185s 'citation()' on how to cite R or R packages in publications. 185s 185s Type 'demo()' for some demos, 'help()' for on-line help, or 185s 'help.start()' for an HTML browser interface to help. 185s Type 'q()' to quit R. 185s 185s > library("matrixStats") 185s > 185s > rowProds_R <- function(x, FUN = prod, na.rm = FALSE, ..., useNames = TRUE) { 185s + res <- apply(x, MARGIN = 1L, FUN = FUN, na.rm = na.rm) 185s + if (!useNames) names(res) <- NULL 185s + res 185s + } 185s > 185s > 185s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 185s > # Subsetted tests 185s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 185s > source("utils/validateIndicesFramework.R") 185s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 185s > storage.mode(x) <- "integer" 185s > 185s > # To check names attribute 185s > dimnames <- list(letters[1:6], LETTERS[1:6]) 185s > 185s > # Test with and without dimnames on x 185s > for (setDimnames in c(TRUE, FALSE)) { 185s + if (setDimnames) dimnames(x) <- dimnames 185s + else dimnames(x) <- NULL 185s + for (rows in index_cases) { 185s + for (cols in index_cases) { 185s + for (na.rm in c(TRUE, FALSE)) { 185s + for (useNames in c(TRUE, FALSE)) { 185s + validateIndicesTestMatrix(x, rows, cols, 185s + ftest = rowProds, fsure = rowProds_R, 185s + method = "expSumLog", 185s + FUN = product, na.rm = na.rm, useNames = useNames) 185s + validateIndicesTestMatrix(x, rows, cols, 185s + fcoltest = colProds, fsure = rowProds_R, 185s + method = "expSumLog", 185s + FUN = product, na.rm = na.rm, useNames = useNames) 185s + } 185s + } 185s + } 185s + } 185s + } 185s > 185s 185s R version 4.4.3 (2025-02-28) -- "Trophy Case" 185s Copyright (C) 2025 The R Foundation for Statistical Computing 185s Platform: s390x-ibm-linux-gnu 185s 185s R is free software and comes with ABSOLUTELY NO WARRANTY. 185s You are welcome to redistribute it under certain conditions. 185s Type 'license()' or 'licence()' for distribution details. 185s 185s R is a collaborative project with many contributors. 185s Type 'contributors()' for more information and 185s 'citation()' on how to cite R or R packages in publications. 185s 185s Type 'demo()' for some demos, 'help()' for on-line help, or 185s 'help.start()' for an HTML browser interface to help. 185s Type 'q()' to quit R. 185s 186s > library("matrixStats") 186s > 186s > ## Create isFALSE() if running on an old version of R 186s > if (!exists("isFALSE", mode="function")) { 186s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 186s + } 186s > 186s > rowQuantiles_R <- function(x, probs = c(0, 0.25, 0.50, 0.75, 1), na.rm = FALSE, drop = TRUE, type = 7L, ..., useNames = TRUE) { 186s + q <- apply(x, MARGIN = 1L, FUN = function(x, probs, na.rm) { 186s + if (!na.rm && any(is.na(x))) { 186s + na_value <- NA_real_ 186s + if (type != 7L) storage.mode(na_value) <- storage.mode(x) 186s + rep(na_value, times = length(probs)) 186s + } else { 186s + as.vector(quantile(x, probs = probs, na.rm = na.rm, type = type, names = FALSE, ...)) 186s + } 186s + }, probs = probs, na.rm = na.rm) 186s + 186s + if (!is.null(dim(q))) q <- t(q) 186s + else dim(q) <- c(nrow(x), length(probs)) 186s + 186s + colnames(q) <- matrixStats:::quantile_probs_names(probs) 186s + rownames(q) <- rownames(x) 186s + if (isFALSE(useNames)) dimnames(q) <- NULL 186s + 186s + if (drop) q <- drop(q) 186s + q 186s + } 186s > 186s > 186s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 186s > # Test with multiple quantiles 186s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 186s > for (mode in c("logical", "integer", "double")) { 186s + cat("mode: ", mode, "\n", sep = "") 186s + x <- matrix(1:40 + 0.1, nrow = 8, ncol = 5) 186s + storage.mode(x) <- mode 186s + dimnames <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 186s + str(x) 186s + 186s + probs <- c(0, 0.5, 1) 186s + # Test with and without dimnames on x 186s + for (setDimnames in c(TRUE, FALSE)) { 186s + if (setDimnames) dimnames(x) <- dimnames 186s + else dimnames(x) <- NULL 186s + # Check names attribute 186s + for (useNames in c(TRUE, FALSE)) { 186s + q0 <- rowQuantiles_R(x, probs = probs, useNames = useNames) 186s + print(q0) 186s + q1 <- rowQuantiles(x, probs = probs, useNames = useNames) 186s + print(q1) 186s + stopifnot(all.equal(q1, q0)) 186s + q2 <- colQuantiles(t(x), probs = probs, useNames = useNames) 186s + stopifnot(all.equal(q2, q0)) 186s + } 186s + } 186s + } # for (mode ...) 186s mode: logical 186s logi [1:8, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 186s 0% 50% 100% 186s a 1 1 1 186s b 1 1 1 186s c 1 1 1 186s d 1 1 1 186s e 1 1 1 186s f 1 1 1 186s g 1 1 1 186s h 1 1 1 186s 0% 50% 100% 186s a 1 1 1 186s b 1 1 1 186s c 1 1 1 186s d 1 1 1 186s e 1 1 1 186s f 1 1 1 186s g 1 1 1 186s h 1 1 1 186s [,1] [,2] [,3] 186s [1,] 1 1 1 186s [2,] 1 1 1 186s [3,] 1 1 1 186s [4,] 1 1 1 186s [5,] 1 1 1 186s [6,] 1 1 1 186s [7,] 1 1 1 186s [8,] 1 1 1 186s [,1] [,2] [,3] 186s [1,] 1 1 1 186s [2,] 1 1 1 186s [3,] 1 1 1 186s [4,] 1 1 1 186s [5,] 1 1 1 186s [6,] 1 1 1 186s [7,] 1 1 1 186s [8,] 1 1 1 186s 0% 50% 100% 186s [1,] 1 1 1 186s [2,] 1 1 1 186s [3,] 1 1 1 186s [4,] 1 1 1 186s [5,] 1 1 1 186s [6,] 1 1 1 186s [7,] 1 1 1 186s [8,] 1 1 1 186s 0% 50% 100% 186s [1,] 1 1 1 186s [2,] 1 1 1 186s [3,] 1 1 1 186s [4,] 1 1 1 186s [5,] 1 1 1 186s [6,] 1 1 1 186s [7,] 1 1 1 186s [8,] 1 1 1 186s [,1] [,2] [,3] 186s [1,] 1 1 1 186s [2,] 1 1 1 186s [3,] 1 1 1 186s [4,] 1 1 1 186s [5,] 1 1 1 186s [6,] 1 1 1 186s [7,] 1 1 1 186s [8,] 1 1 1 186s [,1] [,2] [,3] 186s [1,] 1 1 1 186s [2,] 1 1 1 186s [3,] 1 1 1 186s [4,] 1 1 1 186s [5,] 1 1 1 186s [6,] 1 1 1 186s [7,] 1 1 1 186s [8,] 1 1 1 186s mode: integer 186s int [1:8, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 186s 0% 50% 100% 186s a 1 17 33 186s b 2 18 34 186s c 3 19 35 186s d 4 20 36 186s e 5 21 37 186s f 6 22 38 186s g 7 23 39 186s h 8 24 40 186s 0% 50% 100% 186s a 1 17 33 186s b 2 18 34 186s c 3 19 35 186s d 4 20 36 186s e 5 21 37 186s f 6 22 38 186s g 7 23 39 186s h 8 24 40 186s [,1] [,2] [,3] 186s [1,] 1 17 33 186s [2,] 2 18 34 186s [3,] 3 19 35 186s [4,] 4 20 36 186s [5,] 5 21 37 186s [6,] 6 22 38 186s [7,] 7 23 39 186s [8,] 8 24 40 186s [,1] [,2] [,3] 186s [1,] 1 17 33 186s [2,] 2 18 34 186s [3,] 3 19 35 186s [4,] 4 20 36 186s [5,] 5 21 37 186s [6,] 6 22 38 186s [7,] 7 23 39 186s [8,] 8 24 40 186s 0% 50% 100% 186s [1,] 1 17 33 186s [2,] 2 18 34 186s [3,] 3 19 35 186s [4,] 4 20 36 186s [5,] 5 21 37 186s [6,] 6 22 38 186s [7,] 7 23 39 186s [8,] 8 24 40 186s 0% 50% 100% 186s [1,] 1 17 33 186s [2,] 2 18 34 186s [3,] 3 19 35 186s [4,] 4 20 36 186s [5,] 5 21 37 186s [6,] 6 22 38 186s [7,] 7 23 39 186s [8,] 8 24 40 186s [,1] [,2] [,3] 186s [1,] 1 17 33 186s [2,] 2 18 34 186s [3,] 3 19 35 186s [4,] 4 20 36 186s [5,] 5 21 37 186s [6,] 6 22 38 186s [7,] 7 23 39 186s [8,] 8 24 40 186s [,1] [,2] [,3] 186s [1,] 1 17 33 186s [2,] 2 18 34 186s [3,] 3 19 35 186s [4,] 4 20 36 186s [5,] 5 21 37 186s [6,] 6 22 38 186s [7,] 7 23 39 186s [8,] 8 24 40 186s mode: double 186s num [1:8, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 186s 0% 50% 100% 186s a 1.1 17.1 33.1 186s b 2.1 18.1 34.1 186s c 3.1 19.1 35.1 186s d 4.1 20.1 36.1 186s e 5.1 21.1 37.1 186s f 6.1 22.1 38.1 186s g 7.1 23.1 39.1 186s h 8.1 24.1 40.1 186s 0% 50% 100% 186s a 1.1 17.1 33.1 186s b 2.1 18.1 34.1 186s c 3.1 19.1 35.1 186s d 4.1 20.1 36.1 186s e 5.1 21.1 37.1 186s f 6.1 22.1 38.1 186s g 7.1 23.1 39.1 186s h 8.1 24.1 40.1 186s [,1] [,2] [,3] 186s [1,] 1.1 17.1 33.1 186s [2,] 2.1 18.1 34.1 186s [3,] 3.1 19.1 35.1 186s [4,] 4.1 20.1 36.1 186s [5,] 5.1 21.1 37.1 186s [6,] 6.1 22.1 38.1 186s [7,] 7.1 23.1 39.1 186s [8,] 8.1 24.1 40.1 186s [,1] [,2] [,3] 186s [1,] 1.1 17.1 33.1 186s [2,] 2.1 18.1 34.1 186s [3,] 3.1 19.1 35.1 186s [4,] 4.1 20.1 36.1 186s [5,] 5.1 21.1 37.1 186s [6,] 6.1 22.1 38.1 186s [7,] 7.1 23.1 39.1 186s [8,] 8.1 24.1 40.1 186s 0% 50% 100% 186s [1,] 1.1 17.1 33.1 186s [2,] 2.1 18.1 34.1 186s [3,] 3.1 19.1 35.1 186s [4,] 4.1 20.1 36.1 186s [5,] 5.1 21.1 37.1 186s [6,] 6.1 22.1 38.1 186s [7,] 7.1 23.1 39.1 186s [8,] 8.1 24.1 40.1 186s 0% 50% 100% 186s [1,] 1.1 17.1 33.1 186s [2,] 2.1 18.1 34.1 186s [3,] 3.1 19.1 35.1 186s [4,] 4.1 20.1 36.1 186s [5,] 5.1 21.1 37.1 186s [6,] 6.1 22.1 38.1 186s [7,] 7.1 23.1 39.1 186s [8,] 8.1 24.1 40.1 186s [,1] [,2] [,3] 186s [1,] 1.1 17.1 33.1 186s [2,] 2.1 18.1 34.1 186s [3,] 3.1 19.1 35.1 186s [4,] 4.1 20.1 36.1 186s [5,] 5.1 21.1 37.1 186s [6,] 6.1 22.1 38.1 186s [7,] 7.1 23.1 39.1 186s [8,] 8.1 24.1 40.1 186s [,1] [,2] [,3] 186s [1,] 1.1 17.1 33.1 186s [2,] 2.1 18.1 34.1 186s [3,] 3.1 19.1 35.1 186s [4,] 4.1 20.1 36.1 186s [5,] 5.1 21.1 37.1 186s [6,] 6.1 22.1 38.1 186s [7,] 7.1 23.1 39.1 186s [8,] 8.1 24.1 40.1 186s > 186s > 186s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 186s > # Test with a single quantile 186s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 186s > for (mode in c("logical", "integer", "double")) { 186s + cat("mode: ", mode, "\n", sep = "") 186s + x <- matrix(1:40, nrow = 8, ncol = 5) 186s + storage.mode(x) <- mode 186s + dimnames <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 186s + str(x) 186s + 186s + probs <- c(0.5) 186s + # Test with and without dimnames on x 186s + for (setDimnames in c(TRUE, FALSE)) { 186s + if (setDimnames) dimnames(x) <- dimnames 186s + else dimnames(x) <- NULL 186s + # Check names attribute 186s + for (useNames in c(TRUE, FALSE)) { 186s + q0 <- rowQuantiles_R(x, probs = probs, useNames = useNames) 186s + print(q0) 186s + q1 <- rowQuantiles(x, probs = probs, useNames = useNames) 186s + print(q1) 186s + stopifnot(all.equal(q1, q0)) 186s + q2 <- colQuantiles(t(x), probs = probs, useNames = useNames) 186s + stopifnot(all.equal(q2, q0)) 186s + } 186s + } 186s + } # for (mode ...) 186s mode: logical 186s logi [1:8, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 186s a b c d e f g h 186s 1 1 1 1 1 1 1 1 186s a b c d e f g h 186s 1 1 1 1 1 1 1 1 186s [1] 1 1 1 1 1 1 1 1 186s [1] 1 1 1 1 1 1 1 1 186s [1] 1 1 1 1 1 1 1 1 186s [1] 1 1 1 1 1 1 1 1 186s [1] 1 1 1 1 1 1 1 1 186s [1] 1 1 1 1 1 1 1 1 186s mode: integer 186s int [1:8, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 186s a b c d e f g h 186s 17 18 19 20 21 22 23 24 186s a b c d e f g h 186s 17 18 19 20 21 22 23 24 186s [1] 17 18 19 20 21 22 23 24 186s [1] 17 18 19 20 21 22 23 24 186s [1] 17 18 19 20 21 22 23 24 186s [1] 17 18 19 20 21 22 23 24 186s [1] 17 18 19 20 21 22 23 24 186s [1] 17 18 19 20 21 22 23 24 186s mode: double 186s num [1:8, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 186s a b c d e f g h 186s 17 18 19 20 21 22 23 24 186s a b c d e f g h 186s 17 18 19 20 21 22 23 24 186s [1] 17 18 19 20 21 22 23 24 186s [1] 17 18 19 20 21 22 23 24 186s [1] 17 18 19 20 21 22 23 24 186s [1] 17 18 19 20 21 22 23 24 186s [1] 17 18 19 20 21 22 23 24 186s [1] 17 18 19 20 21 22 23 24 186s > 186s > 186s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 186s > # Consistency checks 186s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 186s > set.seed(1) 186s > 186s > probs <- seq(from = 0, to = 1, by = 0.25) 186s > 186s > cat("Consistency checks:\n") 186s Consistency checks: 186s > n_sims <- if (Sys.getenv("_R_CHECK_USE_VALGRIND_") != "") 6L else 24L 186s > for (kk in seq_len(n_sims)) { 186s + cat("Random test #", kk, "\n", sep = "") 186s + 186s + # Simulate data in a matrix of any shape 186s + dim <- sample(20:60, size = 2L) 186s + n <- prod(dim) 186s + x <- rnorm(n, sd = 100) 186s + dim(x) <- dim 186s + dimnames <- lapply(dim(x), FUN = function(n) rep(letters, length.out = n)) 186s + 186s + # Add NAs? 186s + has_na <- ((kk %% 2) == 0L) 186s + if (has_na) { 186s + cat("Adding NAs\n") 186s + nna <- sample(n, size = 1) 186s + na_values <- c(NA_real_, NaN) 186s + t <- sample(na_values, size = nna, replace = TRUE) 186s + x[sample(length(x), size = nna)] <- t 186s + } 186s + 186s + # Logical, integer, or double? 186s + mode <- "numeric" 186s + if ((kk %% 6) %in% 1:2) { 186s + cat("Coercing to logical\n") 186s + mode <- "logical" 186s + } else if ((kk %% 6) %in% 3:4) { 186s + cat("Coercing to integers\n") 186s + mode <- "integer" 186s + } 186s + storage.mode(x) <- mode 186s + 186s + str(x) 186s + 186s + # rowQuantiles(): 186s + for (type in 1:9) { 186s + cat(sprintf("type=%d, has_na=%s:\n", type, has_na)) 186s + # Test with and without dimnames on x 186s + for (setDimnames in c(TRUE, FALSE)) { 186s + if (setDimnames) dimnames(x) <- dimnames 186s + else dimnames(x) <- NULL 186s + # Check names attribute 186s + for (useNames in c(TRUE, FALSE)) { 186s + q0 <- rowQuantiles_R(x, probs = probs, na.rm = has_na, type = type, useNames = useNames) 186s + q1 <- rowQuantiles(x, probs = probs, na.rm = has_na, type = type, useNames = useNames) 186s + stopifnot(all.equal(q1, q0)) 186s + q2 <- colQuantiles(t(x), probs = probs, na.rm = has_na, type = type, useNames = useNames) 186s + stopifnot(all.equal(q2, q0)) 186s + } 186s + } 186s + } 186s + } # for (kk ...) 186s Random test #1 186s Coercing to logical 186s logi [1:23, 1:58] TRUE TRUE TRUE TRUE TRUE TRUE ... 186s type=1, has_na=FALSE: 186s type=2, has_na=FALSE: 186s type=3, has_na=FALSE: 186s type=4, has_na=FALSE: 186s type=5, has_na=FALSE: 186s type=6, has_na=FALSE: 186s type=7, has_na=FALSE: 186s type=8, has_na=FALSE: 186s type=9, has_na=FALSE: 186s Random test #2 186s Adding NAs 186s Coercing to logical 186s logi [1:58, 1:33] TRUE TRUE TRUE TRUE TRUE NA ... 186s type=1, has_na=TRUE: 186s type=2, has_na=TRUE: 186s type=3, has_na=TRUE: 186s type=4, has_na=TRUE: 186s type=5, has_na=TRUE: 186s type=6, has_na=TRUE: 186s type=7, has_na=TRUE: 186s type=8, has_na=TRUE: 186s type=9, has_na=TRUE: 186s Random test #3 186s Coercing to integers 186s int [1:28, 1:60] 119 -164 115 -129 209 -175 2 -32 120 -28 ... 186s type=1, has_na=FALSE: 186s type=2, has_na=FALSE: 186s type=3, has_na=FALSE: 186s type=4, has_na=FALSE: 186s type=5, has_na=FALSE: 186s type=6, has_na=FALSE: 186s type=7, has_na=FALSE: 186s type=8, has_na=FALSE: 186s type=9, has_na=FALSE: 186s Random test #4 186s Adding NAs 186s Coercing to integers 186s int [1:54, 1:35] 147 11 116 -50 NA -69 132 NA 114 NA ... 186s type=1, has_na=TRUE: 187s type=2, has_na=TRUE: 187s type=3, has_na=TRUE: 187s type=4, has_na=TRUE: 187s type=5, has_na=TRUE: 187s type=6, has_na=TRUE: 187s type=7, has_na=TRUE: 187s type=8, has_na=TRUE: 187s type=9, has_na=TRUE: 187s Random test #5 187s num [1:39, 1:53] 5.94 -27.16 -30.78 173 126.05 ... 187s type=1, has_na=FALSE: 187s type=2, has_na=FALSE: 187s type=3, has_na=FALSE: 187s type=4, has_na=FALSE: 187s type=5, has_na=FALSE: 187s type=6, has_na=FALSE: 187s type=7, has_na=FALSE: 187s type=8, has_na=FALSE: 187s type=9, has_na=FALSE: 187s Random test #6 187s Adding NAs 187s num [1:46, 1:22] 197 -107 15 148 -110 ... 187s type=1, has_na=TRUE: 187s type=2, has_na=TRUE: 187s type=3, has_na=TRUE: 187s type=4, has_na=TRUE: 187s type=5, has_na=TRUE: 187s type=6, has_na=TRUE: 187s type=7, has_na=TRUE: 187s type=8, has_na=TRUE: 188s type=9, has_na=TRUE: 188s Random test #7 188s Coercing to logical 188s logi [1:21, 1:51] TRUE TRUE TRUE TRUE TRUE TRUE ... 188s type=1, has_na=FALSE: 188s type=2, has_na=FALSE: 188s type=3, has_na=FALSE: 188s type=4, has_na=FALSE: 188s type=5, has_na=FALSE: 188s type=6, has_na=FALSE: 188s type=7, has_na=FALSE: 188s type=8, has_na=FALSE: 188s type=9, has_na=FALSE: 188s Random test #8 188s Adding NAs 188s Coercing to logical 188s logi [1:33, 1:53] NA NA TRUE TRUE TRUE TRUE ... 188s type=1, has_na=TRUE: 188s type=2, has_na=TRUE: 188s type=3, has_na=TRUE: 188s type=4, has_na=TRUE: 188s type=5, has_na=TRUE: 188s type=6, has_na=TRUE: 188s type=7, has_na=TRUE: 188s type=8, has_na=TRUE: 188s type=9, has_na=TRUE: 188s Random test #9 188s Coercing to integers 188s int [1:53, 1:24] -73 10 -73 -5 44 -107 -100 95 58 -50 ... 188s type=1, has_na=FALSE: 188s type=2, has_na=FALSE: 188s type=3, has_na=FALSE: 188s type=4, has_na=FALSE: 188s type=5, has_na=FALSE: 188s type=6, has_na=FALSE: 188s type=7, has_na=FALSE: 188s type=8, has_na=FALSE: 188s type=9, has_na=FALSE: 188s Random test #10 188s Adding NAs 188s Coercing to integers 188s int [1:44, 1:20] NA -140 NA -57 -252 NA NA 20 NA NA ... 188s type=1, has_na=TRUE: 188s type=2, has_na=TRUE: 188s type=3, has_na=TRUE: 189s type=4, has_na=TRUE: 189s type=5, has_na=TRUE: 189s type=6, has_na=TRUE: 189s type=7, has_na=TRUE: 189s type=8, has_na=TRUE: 189s type=9, has_na=TRUE: 189s Random test #11 189s num [1:54, 1:23] -160.87 74.13 196.08 7.27 4.92 ... 189s type=1, has_na=FALSE: 189s type=2, has_na=FALSE: 189s type=3, has_na=FALSE: 189s type=4, has_na=FALSE: 189s type=5, has_na=FALSE: 189s type=6, has_na=FALSE: 189s type=7, has_na=FALSE: 189s type=8, has_na=FALSE: 189s type=9, has_na=FALSE: 189s Random test #12 189s Adding NAs 189s num [1:59, 1:27] -139.2 -86.3 NA -40.7 NA ... 189s type=1, has_na=TRUE: 189s type=2, has_na=TRUE: 189s type=3, has_na=TRUE: 189s type=4, has_na=TRUE: 189s type=5, has_na=TRUE: 189s type=6, has_na=TRUE: 189s type=7, has_na=TRUE: 189s type=8, has_na=TRUE: 189s type=9, has_na=TRUE: 190s Random test #13 190s Coercing to logical 190s logi [1:53, 1:60] TRUE TRUE TRUE TRUE TRUE TRUE ... 190s type=1, has_na=FALSE: 190s type=2, has_na=FALSE: 190s type=3, has_na=FALSE: 190s type=4, has_na=FALSE: 190s type=5, has_na=FALSE: 190s type=6, has_na=FALSE: 190s type=7, has_na=FALSE: 190s type=8, has_na=FALSE: 190s type=9, has_na=FALSE: 190s Random test #14 190s Adding NAs 190s Coercing to logical 190s logi [1:22, 1:57] TRUE TRUE TRUE TRUE TRUE TRUE ... 190s type=1, has_na=TRUE: 190s type=2, has_na=TRUE: 190s type=3, has_na=TRUE: 190s type=4, has_na=TRUE: 190s type=5, has_na=TRUE: 190s type=6, has_na=TRUE: 190s type=7, has_na=TRUE: 190s type=8, has_na=TRUE: 190s type=9, has_na=TRUE: 190s Random test #15 190s Coercing to integers 190s int [1:20, 1:34] 78 -41 183 190 -71 37 0 -4 -86 27 ... 190s type=1, has_na=FALSE: 190s type=2, has_na=FALSE: 190s type=3, has_na=FALSE: 190s type=4, has_na=FALSE: 190s type=5, has_na=FALSE: 190s type=6, has_na=FALSE: 190s type=7, has_na=FALSE: 190s type=8, has_na=FALSE: 190s type=9, has_na=FALSE: 190s Random test #16 190s Adding NAs 190s Coercing to integers 190s int [1:42, 1:37] NA 12 -15 41 -28 17 NA -74 NA NA ... 190s type=1, has_na=TRUE: 190s type=2, has_na=TRUE: 190s type=3, has_na=TRUE: 190s type=4, has_na=TRUE: 190s type=5, has_na=TRUE: 190s type=6, has_na=TRUE: 190s type=7, has_na=TRUE: 190s type=8, has_na=TRUE: 191s type=9, has_na=TRUE: 191s Random test #17 191s num [1:42, 1:29] -50.51 -6.51 -117.59 135.58 226.87 ... 191s type=1, has_na=FALSE: 191s type=2, has_na=FALSE: 191s type=3, has_na=FALSE: 191s type=4, has_na=FALSE: 191s type=5, has_na=FALSE: 191s type=6, has_na=FALSE: 191s type=7, has_na=FALSE: 191s type=8, has_na=FALSE: 191s type=9, has_na=FALSE: 191s Random test #18 191s Adding NAs 191s num [1:57, 1:39] 223 156.8 -44.6 -127.5 -147.7 ... 191s type=1, has_na=TRUE: 191s type=2, has_na=TRUE: 191s type=3, has_na=TRUE: 191s type=4, has_na=TRUE: 191s type=5, has_na=TRUE: 191s type=6, has_na=TRUE: 191s type=7, has_na=TRUE: 191s type=8, has_na=TRUE: 191s type=9, has_na=TRUE: 191s Random test #19 191s Coercing to logical 191s logi [1:52, 1:57] TRUE TRUE TRUE TRUE TRUE TRUE ... 191s type=1, has_na=FALSE: 191s type=2, has_na=FALSE: 191s type=3, has_na=FALSE: 191s type=4, has_na=FALSE: 191s type=5, has_na=FALSE: 192s type=6, has_na=FALSE: 192s type=7, has_na=FALSE: 192s type=8, has_na=FALSE: 192s type=9, has_na=FALSE: 192s Random test #20 192s Adding NAs 192s Coercing to logical 192s logi [1:25, 1:48] NA TRUE NA NA NA NA ... 192s type=1, has_na=TRUE: 192s type=2, has_na=TRUE: 192s type=3, has_na=TRUE: 192s type=4, has_na=TRUE: 192s type=5, has_na=TRUE: 192s type=6, has_na=TRUE: 192s type=7, has_na=TRUE: 192s type=8, has_na=TRUE: 192s type=9, has_na=TRUE: 192s Random test #21 192s Coercing to integers 192s int [1:53, 1:27] 3 -30 203 -49 19 -45 -138 28 46 -44 ... 192s type=1, has_na=FALSE: 192s type=2, has_na=FALSE: 192s type=3, has_na=FALSE: 192s type=4, has_na=FALSE: 192s type=5, has_na=FALSE: 192s type=6, has_na=FALSE: 192s type=7, has_na=FALSE: 192s type=8, has_na=FALSE: 192s type=9, has_na=FALSE: 192s Random test #22 192s Adding NAs 192s Coercing to integers 192s int [1:48, 1:36] -131 NA NA -201 45 -17 NA 57 NA NA ... 192s type=1, has_na=TRUE: 192s type=2, has_na=TRUE: 192s type=3, has_na=TRUE: 192s type=4, has_na=TRUE: 192s type=5, has_na=TRUE: 192s type=6, has_na=TRUE: 192s type=7, has_na=TRUE: 192s type=8, has_na=TRUE: 192s type=9, has_na=TRUE: 193s Random test #23 193s num [1:23, 1:43] -99.2 -68.8 -86.7 -104.2 48 ... 193s type=1, has_na=FALSE: 193s type=2, has_na=FALSE: 193s type=3, has_na=FALSE: 193s type=4, has_na=FALSE: 193s type=5, has_na=FALSE: 193s type=6, has_na=FALSE: 193s type=7, has_na=FALSE: 193s type=8, has_na=FALSE: 193s type=9, has_na=FALSE: 193s Random test #24 193s Adding NAs 193s num [1:53, 1:29] NaN -67.6 10.8 -88.4 130.1 ... 193s type=1, has_na=TRUE: 193s type=2, has_na=TRUE: 193s type=3, has_na=TRUE: 193s type=4, has_na=TRUE: 193s type=5, has_na=TRUE: 193s type=6, has_na=TRUE: 193s type=7, has_na=TRUE: 193s type=8, has_na=TRUE: 193s type=9, has_na=TRUE: 193s > 193s > 193s > 193s > for (mode in c("logical", "integer", "double")) { 193s + naValue <- NA_real_ 193s + storage.mode(naValue) <- mode 193s + 193s + someValue <- 1 193s + storage.mode(someValue) <- mode 193s + 193s + for (type in 1:9) { 193s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 193s + # All NA 193s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 193s + x <- matrix(naValue, nrow = 3L, ncol = 4L) 193s + dimnames <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 193s + # Test with and without dimnames on x 193s + for (setDimnames in c(TRUE, FALSE)) { 193s + if (setDimnames) dimnames(x) <- dimnames 193s + else dimnames(x) <- NULL 193s + # Check names attribute 193s + for (useNames in c(TRUE, FALSE)) { 193s + qr0 <- rowQuantiles_R(x, type = type, useNames = useNames) 193s + 193s + qr <- rowQuantiles(x, type = type, useNames = useNames) 193s + stopifnot(identical(qr, qr0)) 193s + 193s + # x <- matrix(naValue, nrow = 4L, ncol = 3L) 193s + qc <- colQuantiles(t(x), type = type, useNames = useNames) 193s + 193s + stopifnot(identical(qc, qr)) 193s + } 193s + } 193s + 193s + 193s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 193s + # Empty matrices 193s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 193s + probs <- c(0, 0.25, 0.75, 1) 193s + x <- matrix(naValue, nrow = 0L, ncol = 0L) 193s + dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 193s + q <- rowQuantiles(x, probs = probs, type = type, useNames = TRUE) 193s + stopifnot(identical(dim(q), c(nrow(x), length(probs)))) 193s + q <- colQuantiles(x, probs = probs, type = type, useNames = TRUE) 193s + stopifnot(identical(dim(q), c(ncol(x), length(probs)))) 193s + 193s + x <- matrix(naValue, nrow = 2L, ncol = 0L) 193s + dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 193s + q <- rowQuantiles(x, probs = probs, type = type, useNames = TRUE) 193s + stopifnot(identical(dim(q), c(nrow(x), length(probs)))) 193s + 193s + x <- matrix(naValue, nrow = 0L, ncol = 2L) 193s + dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 193s + q <- colQuantiles(x, probs = probs, type = type, useNames = TRUE) 193s + stopifnot(identical(dim(q), c(ncol(x), length(probs)))) 193s + 193s + 193s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 193s + # Single column matrices 193s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 193s + probs <- c(0, 0.25, 0.75, 1) 193s + x <- matrix(someValue, nrow = 2L, ncol = 1L) 193s + dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 193s + qr <- rowQuantiles(x, probs = probs, type = type, useNames = TRUE) 193s + print(qr) 193s + 193s + x <- matrix(someValue, nrow = 1L, ncol = 2L) 193s + dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 193s + qc <- colQuantiles(x, probs = probs, type = type, useNames = TRUE) 193s + print(qc) 193s + 193s + stopifnot(identical(qc, qr)) 193s + } 193s + } 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s 0% 25% 75% 100% 193s a 1 1 1 1 193s b 1 1 1 1 193s > 193s 193s R version 4.4.3 (2025-02-28) -- "Trophy Case" 193s Copyright (C) 2025 The R Foundation for Statistical Computing 193s Platform: s390x-ibm-linux-gnu 193s 193s R is free software and comes with ABSOLUTELY NO WARRANTY. 193s You are welcome to redistribute it under certain conditions. 193s Type 'license()' or 'licence()' for distribution details. 193s 193s R is a collaborative project with many contributors. 193s Type 'contributors()' for more information and 193s 'citation()' on how to cite R or R packages in publications. 193s 193s Type 'demo()' for some demos, 'help()' for on-line help, or 193s 'help.start()' for an HTML browser interface to help. 193s Type 'q()' to quit R. 193s 193s > library("matrixStats") 193s > 193s > ## Create isFALSE() if running on an old version of R 193s > if (!exists("isFALSE", mode="function")) { 193s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 193s + } 193s > 193s > rowQuantiles_R <- function(x, probs, na.rm = FALSE, drop = TRUE, ..., useNames = TRUE) { 193s + q <- apply(x, MARGIN = 1L, FUN = function(x, probs, na.rm) { 193s + if (!na.rm && any(is.na(x))) { 193s + na_value <- NA_real_ 193s + storage.mode(na_value) <- storage.mode(x) 193s + rep(na_value, times = length(probs)) 193s + 193s + } else { 193s + as.vector(quantile(x, probs = probs, na.rm = na.rm, names = FALSE, ...)) 193s + } 193s + }, probs = probs, na.rm = na.rm) 193s + 193s + if (!is.null(dim(q))) q <- t(q) 193s + else dim(q) <- c(nrow(x), length(probs)) 193s + 193s + colnames(q) <- matrixStats:::quantile_probs_names(probs) 193s + rownames(q) <- rownames(x) 193s + if (isFALSE(useNames)) dimnames(q) <- NULL 193s + 193s + if (drop) q <- drop(q) 193s + q 193s + } 193s > 193s > 193s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 193s > # Subsetted tests 193s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 193s > source("utils/validateIndicesFramework.R") 193s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 193s > dimnames <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 193s > probs <- c(0, 0.25, 0.75, 1) 193s > # Test with and without dimnames on x 193s > for (setDimnames in c(TRUE, FALSE)) { 193s + if (setDimnames) dimnames(x) <- dimnames 193s + else dimnames(x) <- NULL 193s + 193s + count <- 0L 193s + for (rows in index_cases) { 193s + for (cols in index_cases) { 193s + count <- count + 1L 193s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 193s + useNames <- c(TRUE, FALSE) 193s + useNames <- useNames[count %% length(useNames) + 1] 193s + 193s + validateIndicesTestMatrix(x, rows, cols, 193s + ftest = rowQuantiles, fsure = rowQuantiles_R, 193s + probs = probs, na.rm = na.rm, drop = FALSE, useNames = useNames) 193s + validateIndicesTestMatrix(x, rows, cols, 193s + fcoltest = colQuantiles, fsure = rowQuantiles_R, 193s + probs = probs, na.rm = na.rm, drop = FALSE, useNames = useNames) 193s + } 193s + } 193s + } 194s > 194s > 194s 194s R version 4.4.3 (2025-02-28) -- "Trophy Case" 194s Copyright (C) 2025 The R Foundation for Statistical Computing 194s Platform: s390x-ibm-linux-gnu 194s 194s R is free software and comes with ABSOLUTELY NO WARRANTY. 194s You are welcome to redistribute it under certain conditions. 194s Type 'license()' or 'licence()' for distribution details. 194s 194s R is a collaborative project with many contributors. 194s Type 'contributors()' for more information and 194s 'citation()' on how to cite R or R packages in publications. 194s 194s Type 'demo()' for some demos, 'help()' for on-line help, or 194s 'help.start()' for an HTML browser interface to help. 194s Type 'q()' to quit R. 194s 194s > library("matrixStats") 194s > 194s > rowMins_R <- function(x, ..., useNames = TRUE) { 194s + suppressWarnings({ 194s + res <- apply(x, MARGIN = 1L, FUN = min, ...) 194s + }) 194s + if (!useNames) names(res) <- NULL 194s + res 194s + } # rowMins_R() 194s > 194s > rowMaxs_R <- function(x, ..., useNames = TRUE) { 194s + suppressWarnings({ 194s + res <- apply(x, MARGIN = 1L, FUN = max, ...) 194s + }) 194s + if (!useNames) names(res) <- NULL 194s + res 194s + } # rowMaxs_R() 194s > 194s > rowRanges_R <- function(x, ..., useNames = TRUE) { 194s + suppressWarnings({ 194s + ans <- t(apply(x, MARGIN = 1L, FUN = range, ...)) 194s + }) 194s + 194s + # Preserve rownames attribute 194s + dim <- c(dim(x)[1], 2L) 194s + if (!isTRUE(all.equal(dim(ans), dim))) { 194s + dim(ans) <- dim 194s + rownames <- rownames(x) 194s + if (!is.null(dimnames)) rownames(ans) <- rownames 194s + } 194s + if (!useNames) dimnames(ans) <- NULL 194s + ans 194s + } # rowRanges_R() 194s > 194s > 194s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 194s > # With and without some NAs 194s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 194s > for (mode in c("integer", "double")) { 194s + cat("mode: ", mode, "\n", sep = "") 194s + 194s + for (add_na in c(FALSE, TRUE)) { 194s + cat("add_na = ", add_na, "\n", sep = "") 194s + 194s + x <- matrix(1:50 + 0.1, nrow = 10L, ncol = 5L) 194s + if (add_na) { 194s + x[3:7, c(2, 4)] <- NA_real_ 194s + } 194s + storage.mode(x) <- mode 194s + str(x) 194s + 194s + # To check names attribute 194s + dimnames <- list(letters[1:10], LETTERS[1:5]) 194s + 194s + # Test with and without dimnames on x 194s + for (setDimnames in c(TRUE, FALSE)) { 194s + if (setDimnames) dimnames(x) <- dimnames 194s + else dimnames(x) <- NULL 194s + # Row/column extremes 194s + for (na.rm in c(FALSE, TRUE)) { 194s + # Check names attribute 194s + for (useNames in c(TRUE, FALSE)) { 194s + cat("na.rm = ", na.rm, "\n", sep = "") 194s + 194s + # Ranges 194s + cat("range:\n") 194s + r0 <- rowRanges_R(x, na.rm = na.rm, useNames = useNames) 194s + r1 <- rowRanges(x, na.rm = na.rm, useNames = useNames) 194s + r2 <- colRanges(t(x), na.rm = na.rm, useNames = useNames) 194s + stopifnot(all.equal(r1, r2)) 194s + stopifnot(all.equal(r1, r0)) 194s + 194s + # Min 194s + cat("min:\n") 194s + m0 <- rowMins_R(x, na.rm = na.rm, useNames = useNames) 194s + m1 <- rowMins(x, na.rm = na.rm, useNames = useNames) 194s + m2 <- colMins(t(x), na.rm = na.rm, useNames = useNames) 194s + stopifnot(all.equal(m1, m2)) 194s + stopifnot(all.equal(m1, m0)) 194s + 194s + # Max 194s + cat("max:\n") 194s + m0 <- rowMaxs_R(x, na.rm = na.rm, useNames = useNames) 194s + m1 <- rowMaxs(x, na.rm = na.rm, useNames = useNames) 194s + m2 <- colMaxs(t(x), na.rm = na.rm, useNames = useNames) 194s + stopifnot(all.equal(m1, m2)) 194s + stopifnot(all.equal(m1, m0)) 194s + } 194s + } 194s + } 194s + } # for (add_na ...) 194s + } # for (mode ...) 194s mode: integer 194s add_na = FALSE 194s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 194s na.rm = FALSE 194s range: 194s min: 194s max: 194s na.rm = FALSE 194s range: 194s min: 194s max: 194s na.rm = TRUE 194s range: 194s min: 194s max: 194s na.rm = TRUE 194s range: 194s min: 194s max: 194s na.rm = FALSE 194s range: 194s min: 194s max: 194s na.rm = FALSE 194s range: 194s min: 194s max: 194s na.rm = TRUE 194s range: 194s min: 194s max: 194s na.rm = TRUE 194s range: 194s min: 194s max: 194s add_na = TRUE 194s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 194s na.rm = FALSE 194s range: 194s min: 194s max: 194s na.rm = FALSE 194s range: 194s min: 194s max: 194s na.rm = TRUE 194s range: 194s min: 194s max: 194s na.rm = TRUE 194s range: 194s min: 194s max: 194s na.rm = FALSE 194s range: 194s min: 194s max: 194s na.rm = FALSE 194s range: 194s min: 194s max: 194s na.rm = TRUE 194s range: 194s min: 194s max: 194s na.rm = TRUE 194s range: 194s min: 194s max: 194s mode: double 194s add_na = FALSE 194s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 194s na.rm = FALSE 194s range: 194s min: 194s max: 194s na.rm = FALSE 194s range: 194s min: 194s max: 194s na.rm = TRUE 194s range: 194s min: 194s max: 194s na.rm = TRUE 194s range: 194s min: 194s max: 194s na.rm = FALSE 194s range: 194s min: 194s max: 194s na.rm = FALSE 194s range: 194s min: 194s max: 194s na.rm = TRUE 194s range: 194s min: 194s max: 194s na.rm = TRUE 194s range: 194s min: 194s max: 194s add_na = TRUE 194s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 194s na.rm = FALSE 194s range: 194s min: 194s max: 194s na.rm = FALSE 194s range: 194s min: 194s max: 194s na.rm = TRUE 194s range: 194s min: 194s max: 194s na.rm = TRUE 194s range: 194s min: 194s max: 194s na.rm = FALSE 194s range: 194s min: 194s max: 194s na.rm = FALSE 194s range: 194s min: 194s max: 194s na.rm = TRUE 194s range: 194s min: 194s max: 194s na.rm = TRUE 194s range: 194s min: 194s max: 194s > 194s > 194s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 194s > # All NAs 194s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 194s > for (mode in c("integer", "double")) { 194s + cat("mode: ", mode, "\n", sep = "") 194s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 194s + storage.mode(x) <- mode 194s + str(x) 194s + 194s + # Test with and without dimnames on x 194s + for (setDimnames in c(TRUE, FALSE)) { 194s + if (setDimnames) dimnames(x) <- dimnames 194s + else dimnames(x) <- NULL 194s + for (na.rm in c(FALSE, TRUE)) { 194s + # Check names attribute 194s + for (useNames in c(TRUE, FALSE)) { 194s + cat("na.rm = ", na.rm, "\n", sep = "") 194s + r0 <- rowRanges_R(x, na.rm = na.rm, useNames = useNames) 194s + r1 <- rowRanges(x, na.rm = na.rm, useNames = useNames) 194s + r2 <- colRanges(t(x), na.rm = na.rm, useNames = useNames) 194s + stopifnot(all.equal(r1, r2)) 194s + stopifnot(all.equal(r1, r0)) 194s + } 194s + } 194s + } 194s + } # for (mode ...) 194s mode: integer 194s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 194s na.rm = FALSE 194s na.rm = FALSE 194s na.rm = TRUE 194s na.rm = TRUE 194s na.rm = FALSE 194s na.rm = FALSE 194s na.rm = TRUE 194s na.rm = TRUE 194s mode: double 194s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 194s na.rm = FALSE 194s na.rm = FALSE 194s na.rm = TRUE 194s na.rm = TRUE 194s na.rm = FALSE 194s na.rm = FALSE 194s na.rm = TRUE 194s na.rm = TRUE 194s > 194s > 194s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 194s > # Special cases 194s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 194s > # Nx0 matrix 194s > x <- matrix(double(0L), nrow = 5L, ncol = 0L) 194s > r0 <- rowRanges_R(x) 194s > #r1 <- rowRanges(x) 194s > #r_truth <- matrix(c(Inf, -Inf), nrow = nrow(x), ncol = 2L, byrow = TRUE) 194s > #stopifnot(all.equal(r1, r_truth)) 194s > 194s > # 0xN matrix 194s > x <- t(x) 194s > #r1 <- colRanges(x) 194s > #stopifnot(all.equal(r1, r_truth)) 194s > 194s > # Nx1 matrix 194s > x <- matrix(1:5, nrow = 5L, ncol = 1L) 194s > # To check names attribute 194s > dimnames <- list(letters[1:5], "A") 194s > r1 <- rowRanges(x) 194s > r_truth <- matrix(1:5, nrow = nrow(x), ncol = 2L, byrow = FALSE) 194s > stopifnot(all.equal(r1, r_truth)) 194s > # Check names attribute 194s > dimnames(x) <- dimnames 194s > r0 <- rowRanges_R(x, useNames = TRUE) 194s > r1 <- rowRanges(x, useNames = TRUE) 194s > stopifnot(all.equal(r1, r0)) 194s > dimnames(x) <- NULL 194s > 194s > # 1xN matrix 194s > x <- t(x) 194s > r1 <- colRanges(x) 194s > stopifnot(all.equal(r1, r_truth)) 194s > # Check names attribute 194s > dimnames(x) <- list("a", LETTERS[1:5]) 194s > r1 <- colRanges(x, useNames = TRUE) 194s > stopifnot(identical(rownames(r1), colnames(x))) 194s > 194s > 194s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 194s > # Additional tests with NA_integer_, NA_real, NaN, -Inf, +Inf 194s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 194s > x <- matrix(1:12, nrow = 4L, ncol = 3L) 194s > 194s > na_list <- list( 194s + "integer" = matrix(1:12, nrow = 4L, ncol = 3L), 194s + "integer w/ NA" = matrix(NA_integer_, nrow = 4L, ncol = 3L), 194s + "real" = matrix(as.double(1:12), nrow = 4L, ncol = 3L), 194s + "real w/ NA" = matrix(NA_real_, nrow = 4L, ncol = 3L) 194s + ) 194s > 194s > na <- na_list[["real"]] 194s > na[2, 2] <- NA 194s > na_list[["real + NA cell"]] <- na 194s > 194s > na <- na_list[["real"]] 194s > na[2, ] <- NA 194s > na_list[["real + NA row"]] <- na 194s > 194s > na <- na_list[["real"]] 194s > na[2, ] <- NaN 194s > na_list[["real + NaN row"]] <- na 194s > 194s > na <- na_list[["real"]] 194s > na[2, 2] <- Inf 194s > na_list[["real + Inf cell"]] <- na 194s > 194s > na <- na_list[["real"]] 194s > na[2, ] <- Inf 194s > na_list[["real + Inf row"]] <- na 194s > 194s > na <- na_list[["real"]] 194s > na[2, 2] <- NaN 194s > na_list[["real + NaN cell"]] <- na 194s > 194s > na <- na_list[["real w/ NA"]] 194s > na[2, 2] <- NaN 194s > na_list[["real w/ NA + NaN cell"]] <- na 194s > 194s > na <- na_list[["real w/ NA"]] 194s > na[2, ] <- NaN 194s > na_list[["real w/ NA + NaN row"]] <- na 194s > 194s > # To check names attribute 194s > dimnames <- list(letters[1:4], LETTERS[1:3]) 194s > 194s > # Test with and without dimnames on x 194s > for (setDimnames in c(TRUE, FALSE)) { 194s + if (setDimnames) dimnames(x) <- dimnames 194s + else dimnames(x) <- NULL 194s + for (na.rm in c(FALSE, TRUE)) { 194s + for (name in names(na_list)) { 194s + # Check names attribute 194s + for (useNames in c(TRUE, FALSE)) { 194s + na <- na_list[[name]] 194s + cat(sprintf("%s (%s) w/ na.rm = %s:\n", name, typeof(na), na.rm)) 194s + print(na) 194s + 194s + cat(" min:\n") 194s + y0 <- rowMins_R(na, na.rm = na.rm, useNames = useNames) 194s + str(y0) 194s + y1 <- rowMins(na, na.rm = na.rm, useNames = useNames) 194s + str(y1) 194s + stopifnot(all.equal(y1, y0)) 194s + y1c <- colMins(t(na), na.rm = na.rm, useNames = useNames) 194s + str(y1c) 194s + stopifnot(all.equal(y1c, y1)) 194s + 194s + cat(" max:\n") 194s + y0 <- rowMaxs_R(na, na.rm = na.rm, useNames = useNames) 194s + str(y0) 194s + y1 <- rowMaxs(na, na.rm = na.rm, useNames = useNames) 194s + str(y1) 194s + stopifnot(all.equal(y1, y0)) 194s + y1c <- colMaxs(t(na), na.rm = na.rm, useNames = useNames) 194s + str(y1c) 194s + stopifnot(all.equal(y1c, y1)) 194s + 194s + cat(" range:\n") 194s + y0 <- rowRanges_R(na, na.rm = na.rm, useNames = useNames) 194s + str(y0) 194s + y1 <- rowRanges(na, na.rm = na.rm, useNames = useNames) 194s + str(y1) 194s + stopifnot(all.equal(y1, y0)) 194s + y1c <- colRanges(t(na), na.rm = na.rm, useNames = useNames) 194s + str(y1c) 194s + stopifnot(all.equal(y1c, y1)) 194s + } 194s + } # for (name ...) 194s + } # for (na.rm ...) 194s + } 194s integer (integer) w/ na.rm = FALSE: 194s [,1] [,2] [,3] 194s [1,] 1 5 9 194s [2,] 2 6 10 194s [3,] 3 7 11 194s [4,] 4 8 12 194s min: 194s int [1:4] 1 2 3 4 194s int [1:4] 1 2 3 4 194s int [1:4] 1 2 3 4 194s max: 194s int [1:4] 9 10 11 12 194s int [1:4] 9 10 11 12 194s int [1:4] 9 10 11 12 194s range: 194s int [1:4, 1:2] 1 2 3 4 9 10 11 12 194s int [1:4, 1:2] 1 2 3 4 9 10 11 12 194s int [1:4, 1:2] 1 2 3 4 9 10 11 12 194s integer (integer) w/ na.rm = FALSE: 194s [,1] [,2] [,3] 194s [1,] 1 5 9 194s [2,] 2 6 10 194s [3,] 3 7 11 194s [4,] 4 8 12 194s min: 194s int [1:4] 1 2 3 4 194s int [1:4] 1 2 3 4 194s int [1:4] 1 2 3 4 194s max: 194s int [1:4] 9 10 11 12 194s int [1:4] 9 10 11 12 194s int [1:4] 9 10 11 12 194s range: 194s int [1:4, 1:2] 1 2 3 4 9 10 11 12 194s int [1:4, 1:2] 1 2 3 4 9 10 11 12 194s int [1:4, 1:2] 1 2 3 4 9 10 11 12 194s integer w/ NA (integer) w/ na.rm = FALSE: 194s [,1] [,2] [,3] 194s [1,] NA NA NA 194s [2,] NA NA NA 194s [3,] NA NA NA 194s [4,] NA NA NA 194s min: 195s int [1:4] NA NA NA NA 195s int [1:4] NA NA NA NA 195s int [1:4] NA NA NA NA 195s max: 195s int [1:4] NA NA NA NA 195s int [1:4] NA NA NA NA 195s int [1:4] NA NA NA NA 195s range: 195s int [1:4, 1:2] NA NA NA NA NA NA NA NA 195s int [1:4, 1:2] NA NA NA NA NA NA NA NA 195s int [1:4, 1:2] NA NA NA NA NA NA NA NA 195s integer w/ NA (integer) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NA NA NA 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s int [1:4] NA NA NA NA 195s int [1:4] NA NA NA NA 195s int [1:4] NA NA NA NA 195s max: 195s int [1:4] NA NA NA NA 195s int [1:4] NA NA NA NA 195s int [1:4] NA NA NA NA 195s range: 195s int [1:4, 1:2] NA NA NA NA NA NA NA NA 195s int [1:4, 1:2] NA NA NA NA NA NA NA NA 195s int [1:4, 1:2] NA NA NA NA NA NA NA NA 195s real (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 6 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s max: 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s range: 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s real (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 6 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s max: 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s range: 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s real w/ NA (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NA NA NA 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s max: 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s range: 195s num [1:4, 1:2] NA NA NA NA NA NA NA NA 195s num [1:4, 1:2] NA NA NA NA NA NA NA NA 195s num [1:4, 1:2] NA NA NA NA NA NA NA NA 195s real w/ NA (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NA NA NA 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s max: 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s range: 195s num [1:4, 1:2] NA NA NA NA NA NA NA NA 195s num [1:4, 1:2] NA NA NA NA NA NA NA NA 195s num [1:4, 1:2] NA NA NA NA NA NA NA NA 195s real + NA cell (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 NA 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 NA 3 4 195s num [1:4] 1 NA 3 4 195s num [1:4] 1 NA 3 4 195s max: 195s num [1:4] 9 NA 11 12 195s num [1:4] 9 NA 11 12 195s num [1:4] 9 NA 11 12 195s range: 195s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 195s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 195s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 195s real + NA cell (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 NA 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 NA 3 4 195s num [1:4] 1 NA 3 4 195s num [1:4] 1 NA 3 4 195s max: 195s num [1:4] 9 NA 11 12 195s num [1:4] 9 NA 11 12 195s num [1:4] 9 NA 11 12 195s range: 195s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 195s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 195s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 195s real + NA row (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] NA NA NA 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 NA 3 4 195s num [1:4] 1 NA 3 4 195s num [1:4] 1 NA 3 4 195s max: 195s num [1:4] 9 NA 11 12 195s num [1:4] 9 NA 11 12 195s num [1:4] 9 NA 11 12 195s range: 195s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 195s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 195s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 195s real + NA row (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] NA NA NA 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 NA 3 4 195s num [1:4] 1 NA 3 4 195s num [1:4] 1 NA 3 4 195s max: 195s num [1:4] 9 NA 11 12 195s num [1:4] 9 NA 11 12 195s num [1:4] 9 NA 11 12 195s range: 195s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 195s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 195s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 195s real + NaN row (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] NaN NaN NaN 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 NaN 3 4 195s num [1:4] 1 NaN 3 4 195s num [1:4] 1 NaN 3 4 195s max: 195s num [1:4] 9 NaN 11 12 195s num [1:4] 9 NaN 11 12 195s num [1:4] 9 NaN 11 12 195s range: 195s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 195s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 195s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 195s real + NaN row (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] NaN NaN NaN 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 NaN 3 4 195s num [1:4] 1 NaN 3 4 195s num [1:4] 1 NaN 3 4 195s max: 195s num [1:4] 9 NaN 11 12 195s num [1:4] 9 NaN 11 12 195s num [1:4] 9 NaN 11 12 195s range: 195s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 195s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 195s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 195s real + Inf cell (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 Inf 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s max: 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s range: 195s num [1:4, 1:2] 1 2 3 4 9 ... 195s num [1:4, 1:2] 1 2 3 4 9 ... 195s num [1:4, 1:2] 1 2 3 4 9 ... 195s real + Inf cell (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 Inf 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s max: 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s range: 195s num [1:4, 1:2] 1 2 3 4 9 ... 195s num [1:4, 1:2] 1 2 3 4 9 ... 195s num [1:4, 1:2] 1 2 3 4 9 ... 195s real + Inf row (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] Inf Inf Inf 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s max: 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s range: 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s real + Inf row (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] Inf Inf Inf 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s max: 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s range: 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s real + NaN cell (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 NaN 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 NaN 3 4 195s num [1:4] 1 NaN 3 4 195s num [1:4] 1 NaN 3 4 195s max: 195s num [1:4] 9 NaN 11 12 195s num [1:4] 9 NaN 11 12 195s num [1:4] 9 NaN 11 12 195s range: 195s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 195s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 195s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 195s real + NaN cell (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 NaN 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 NaN 3 4 195s num [1:4] 1 NaN 3 4 195s num [1:4] 1 NaN 3 4 195s max: 195s num [1:4] 9 NaN 11 12 195s num [1:4] 9 NaN 11 12 195s num [1:4] 9 NaN 11 12 195s range: 195s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 195s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 195s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 195s real w/ NA + NaN cell (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NA NaN NA 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s max: 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s range: 195s num [1:4, 1:2] NA NA NA NA NA NA NA NA 195s num [1:4, 1:2] NA NA NA NA NA NA NA NA 195s num [1:4, 1:2] NA NA NA NA NA NA NA NA 195s real w/ NA + NaN cell (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NA NaN NA 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s max: 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s range: 195s num [1:4, 1:2] NA NA NA NA NA NA NA NA 195s num [1:4, 1:2] NA NA NA NA NA NA NA NA 195s num [1:4, 1:2] NA NA NA NA NA NA NA NA 195s real w/ NA + NaN row (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NaN NaN NaN 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s num [1:4] NA NaN NA NA 195s num [1:4] NA NaN NA NA 195s num [1:4] NA NaN NA NA 195s max: 195s num [1:4] NA NaN NA NA 195s num [1:4] NA NaN NA NA 195s num [1:4] NA NaN NA NA 195s range: 195s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 195s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 195s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 195s real w/ NA + NaN row (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NaN NaN NaN 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s num [1:4] NA NaN NA NA 195s num [1:4] NA NaN NA NA 195s num [1:4] NA NaN NA NA 195s max: 195s num [1:4] NA NaN NA NA 195s num [1:4] NA NaN NA NA 195s num [1:4] NA NaN NA NA 195s range: 195s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 195s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 195s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 195s integer (integer) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 6 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s int [1:4] 1 2 3 4 195s int [1:4] 1 2 3 4 195s int [1:4] 1 2 3 4 195s max: 195s int [1:4] 9 10 11 12 195s int [1:4] 9 10 11 12 195s int [1:4] 9 10 11 12 195s range: 195s int [1:4, 1:2] 1 2 3 4 9 10 11 12 195s int [1:4, 1:2] 1 2 3 4 9 10 11 12 195s int [1:4, 1:2] 1 2 3 4 9 10 11 12 195s integer (integer) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 6 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s int [1:4] 1 2 3 4 195s int [1:4] 1 2 3 4 195s int [1:4] 1 2 3 4 195s max: 195s int [1:4] 9 10 11 12 195s int [1:4] 9 10 11 12 195s int [1:4] 9 10 11 12 195s range: 195s int [1:4, 1:2] 1 2 3 4 9 10 11 12 195s int [1:4, 1:2] 1 2 3 4 9 10 11 12 195s int [1:4, 1:2] 1 2 3 4 9 10 11 12 195s integer w/ NA (integer) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NA NA NA 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s max: 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s range: 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s integer w/ NA (integer) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NA NA NA 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s max: 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s range: 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s real (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 6 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s max: 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s range: 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s real (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 6 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s max: 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s range: 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s real w/ NA (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NA NA NA 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s max: 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s range: 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s real w/ NA (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NA NA NA 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s max: 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s range: 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s real + NA cell (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 NA 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s max: 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s range: 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s real + NA cell (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 NA 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s max: 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s range: 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s real + NA row (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] NA NA NA 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s max: 195s num [1:4] 9 -Inf 11 12 195s num [1:4] 9 -Inf 11 12 195s num [1:4] 9 -Inf 11 12 195s range: 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s real + NA row (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] NA NA NA 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s max: 195s num [1:4] 9 -Inf 11 12 195s num [1:4] 9 -Inf 11 12 195s num [1:4] 9 -Inf 11 12 195s range: 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s real + NaN row (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] NaN NaN NaN 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s max: 195s num [1:4] 9 -Inf 11 12 195s num [1:4] 9 -Inf 11 12 195s num [1:4] 9 -Inf 11 12 195s range: 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s real + NaN row (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] NaN NaN NaN 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s max: 195s num [1:4] 9 -Inf 11 12 195s num [1:4] 9 -Inf 11 12 195s num [1:4] 9 -Inf 11 12 195s range: 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s real + Inf cell (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 Inf 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s max: 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s range: 195s num [1:4, 1:2] 1 2 3 4 9 ... 195s num [1:4, 1:2] 1 2 3 4 9 ... 195s num [1:4, 1:2] 1 2 3 4 9 ... 195s real + Inf cell (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 Inf 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s max: 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s range: 195s num [1:4, 1:2] 1 2 3 4 9 ... 195s num [1:4, 1:2] 1 2 3 4 9 ... 195s num [1:4, 1:2] 1 2 3 4 9 ... 195s real + Inf row (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] Inf Inf Inf 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s max: 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s range: 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s real + Inf row (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] Inf Inf Inf 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s max: 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s range: 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s real + NaN cell (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 NaN 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s max: 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s range: 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s real + NaN cell (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 NaN 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s max: 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s range: 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s real w/ NA + NaN cell (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NA NaN NA 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s max: 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s range: 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s real w/ NA + NaN cell (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NA NaN NA 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s max: 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s range: 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s real w/ NA + NaN row (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NaN NaN NaN 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s max: 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s range: 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s real w/ NA + NaN row (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NaN NaN NaN 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s max: 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s range: 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s integer (integer) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 6 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s int [1:4] 1 2 3 4 195s int [1:4] 1 2 3 4 195s int [1:4] 1 2 3 4 195s max: 195s int [1:4] 9 10 11 12 195s int [1:4] 9 10 11 12 195s int [1:4] 9 10 11 12 195s range: 195s int [1:4, 1:2] 1 2 3 4 9 10 11 12 195s int [1:4, 1:2] 1 2 3 4 9 10 11 12 195s int [1:4, 1:2] 1 2 3 4 9 10 11 12 195s integer (integer) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 6 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s int [1:4] 1 2 3 4 195s int [1:4] 1 2 3 4 195s int [1:4] 1 2 3 4 195s max: 195s int [1:4] 9 10 11 12 195s int [1:4] 9 10 11 12 195s int [1:4] 9 10 11 12 195s range: 195s int [1:4, 1:2] 1 2 3 4 9 10 11 12 195s int [1:4, 1:2] 1 2 3 4 9 10 11 12 195s int [1:4, 1:2] 1 2 3 4 9 10 11 12 195s integer w/ NA (integer) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NA NA NA 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s int [1:4] NA NA NA NA 195s int [1:4] NA NA NA NA 195s int [1:4] NA NA NA NA 195s max: 195s int [1:4] NA NA NA NA 195s int [1:4] NA NA NA NA 195s int [1:4] NA NA NA NA 195s range: 195s int [1:4, 1:2] NA NA NA NA NA NA NA NA 195s int [1:4, 1:2] NA NA NA NA NA NA NA NA 195s int [1:4, 1:2] NA NA NA NA NA NA NA NA 195s integer w/ NA (integer) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NA NA NA 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s int [1:4] NA NA NA NA 195s int [1:4] NA NA NA NA 195s int [1:4] NA NA NA NA 195s max: 195s int [1:4] NA NA NA NA 195s int [1:4] NA NA NA NA 195s int [1:4] NA NA NA NA 195s range: 195s int [1:4, 1:2] NA NA NA NA NA NA NA NA 195s int [1:4, 1:2] NA NA NA NA NA NA NA NA 195s int [1:4, 1:2] NA NA NA NA NA NA NA NA 195s real (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 6 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s max: 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s range: 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s real (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 6 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s max: 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s range: 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s real w/ NA (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NA NA NA 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s max: 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s range: 195s num [1:4, 1:2] NA NA NA NA NA NA NA NA 195s num [1:4, 1:2] NA NA NA NA NA NA NA NA 195s num [1:4, 1:2] NA NA NA NA NA NA NA NA 195s real w/ NA (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NA NA NA 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s max: 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s range: 195s num [1:4, 1:2] NA NA NA NA NA NA NA NA 195s num [1:4, 1:2] NA NA NA NA NA NA NA NA 195s num [1:4, 1:2] NA NA NA NA NA NA NA NA 195s real + NA cell (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 NA 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 NA 3 4 195s num [1:4] 1 NA 3 4 195s num [1:4] 1 NA 3 4 195s max: 195s num [1:4] 9 NA 11 12 195s num [1:4] 9 NA 11 12 195s num [1:4] 9 NA 11 12 195s range: 195s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 195s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 195s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 195s real + NA cell (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 NA 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 NA 3 4 195s num [1:4] 1 NA 3 4 195s num [1:4] 1 NA 3 4 195s max: 195s num [1:4] 9 NA 11 12 195s num [1:4] 9 NA 11 12 195s num [1:4] 9 NA 11 12 195s range: 195s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 195s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 195s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 195s real + NA row (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] NA NA NA 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 NA 3 4 195s num [1:4] 1 NA 3 4 195s num [1:4] 1 NA 3 4 195s max: 195s num [1:4] 9 NA 11 12 195s num [1:4] 9 NA 11 12 195s num [1:4] 9 NA 11 12 195s range: 195s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 195s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 195s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 195s real + NA row (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] NA NA NA 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 NA 3 4 195s num [1:4] 1 NA 3 4 195s num [1:4] 1 NA 3 4 195s max: 195s num [1:4] 9 NA 11 12 195s num [1:4] 9 NA 11 12 195s num [1:4] 9 NA 11 12 195s range: 195s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 195s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 195s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 195s real + NaN row (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] NaN NaN NaN 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 NaN 3 4 195s num [1:4] 1 NaN 3 4 195s num [1:4] 1 NaN 3 4 195s max: 195s num [1:4] 9 NaN 11 12 195s num [1:4] 9 NaN 11 12 195s num [1:4] 9 NaN 11 12 195s range: 195s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 195s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 195s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 195s real + NaN row (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] NaN NaN NaN 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 NaN 3 4 195s num [1:4] 1 NaN 3 4 195s num [1:4] 1 NaN 3 4 195s max: 195s num [1:4] 9 NaN 11 12 195s num [1:4] 9 NaN 11 12 195s num [1:4] 9 NaN 11 12 195s range: 195s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 195s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 195s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 195s real + Inf cell (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 Inf 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s max: 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s range: 195s num [1:4, 1:2] 1 2 3 4 9 ... 195s num [1:4, 1:2] 1 2 3 4 9 ... 195s num [1:4, 1:2] 1 2 3 4 9 ... 195s real + Inf cell (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 Inf 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s max: 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s range: 195s num [1:4, 1:2] 1 2 3 4 9 ... 195s num [1:4, 1:2] 1 2 3 4 9 ... 195s num [1:4, 1:2] 1 2 3 4 9 ... 195s real + Inf row (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] Inf Inf Inf 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s max: 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s range: 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s real + Inf row (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] Inf Inf Inf 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s max: 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s range: 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s real + NaN cell (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 NaN 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 NaN 3 4 195s num [1:4] 1 NaN 3 4 195s num [1:4] 1 NaN 3 4 195s max: 195s num [1:4] 9 NaN 11 12 195s num [1:4] 9 NaN 11 12 195s num [1:4] 9 NaN 11 12 195s range: 195s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 195s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 195s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 195s real + NaN cell (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 NaN 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 NaN 3 4 195s num [1:4] 1 NaN 3 4 195s num [1:4] 1 NaN 3 4 195s max: 195s num [1:4] 9 NaN 11 12 195s num [1:4] 9 NaN 11 12 195s num [1:4] 9 NaN 11 12 195s range: 195s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 195s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 195s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 195s real w/ NA + NaN cell (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NA NaN NA 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s max: 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s range: 195s num [1:4, 1:2] NA NA NA NA NA NA NA NA 195s num [1:4, 1:2] NA NA NA NA NA NA NA NA 195s num [1:4, 1:2] NA NA NA NA NA NA NA NA 195s real w/ NA + NaN cell (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NA NaN NA 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s max: 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s num [1:4] NA NA NA NA 195s range: 195s num [1:4, 1:2] NA NA NA NA NA NA NA NA 195s num [1:4, 1:2] NA NA NA NA NA NA NA NA 195s num [1:4, 1:2] NA NA NA NA NA NA NA NA 195s real w/ NA + NaN row (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NaN NaN NaN 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s num [1:4] NA NaN NA NA 195s num [1:4] NA NaN NA NA 195s num [1:4] NA NaN NA NA 195s max: 195s num [1:4] NA NaN NA NA 195s num [1:4] NA NaN NA NA 195s num [1:4] NA NaN NA NA 195s range: 195s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 195s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 195s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 195s real w/ NA + NaN row (double) w/ na.rm = FALSE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NaN NaN NaN 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s num [1:4] NA NaN NA NA 195s num [1:4] NA NaN NA NA 195s num [1:4] NA NaN NA NA 195s max: 195s num [1:4] NA NaN NA NA 195s num [1:4] NA NaN NA NA 195s num [1:4] NA NaN NA NA 195s range: 195s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 195s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 195s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 195s integer (integer) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 6 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s int [1:4] 1 2 3 4 195s int [1:4] 1 2 3 4 195s int [1:4] 1 2 3 4 195s max: 195s int [1:4] 9 10 11 12 195s int [1:4] 9 10 11 12 195s int [1:4] 9 10 11 12 195s range: 195s int [1:4, 1:2] 1 2 3 4 9 10 11 12 195s int [1:4, 1:2] 1 2 3 4 9 10 11 12 195s int [1:4, 1:2] 1 2 3 4 9 10 11 12 195s integer (integer) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 6 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s int [1:4] 1 2 3 4 195s int [1:4] 1 2 3 4 195s int [1:4] 1 2 3 4 195s max: 195s int [1:4] 9 10 11 12 195s int [1:4] 9 10 11 12 195s int [1:4] 9 10 11 12 195s range: 195s int [1:4, 1:2] 1 2 3 4 9 10 11 12 195s int [1:4, 1:2] 1 2 3 4 9 10 11 12 195s int [1:4, 1:2] 1 2 3 4 9 10 11 12 195s integer w/ NA (integer) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NA NA NA 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s max: 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s range: 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s integer w/ NA (integer) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NA NA NA 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s max: 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s range: 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s real (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 6 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s max: 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s range: 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s real (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 6 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s max: 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s range: 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s real w/ NA (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NA NA NA 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s max: 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s range: 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s real w/ NA (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NA NA NA 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s max: 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s range: 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s real + NA cell (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 NA 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s max: 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s range: 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s real + NA cell (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 NA 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s max: 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s range: 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s real + NA row (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] NA NA NA 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s max: 195s num [1:4] 9 -Inf 11 12 195s num [1:4] 9 -Inf 11 12 195s num [1:4] 9 -Inf 11 12 195s range: 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s real + NA row (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] NA NA NA 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s max: 195s num [1:4] 9 -Inf 11 12 195s num [1:4] 9 -Inf 11 12 195s num [1:4] 9 -Inf 11 12 195s range: 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s real + NaN row (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] NaN NaN NaN 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s max: 195s num [1:4] 9 -Inf 11 12 195s num [1:4] 9 -Inf 11 12 195s num [1:4] 9 -Inf 11 12 195s range: 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s real + NaN row (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] NaN NaN NaN 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s max: 195s num [1:4] 9 -Inf 11 12 195s num [1:4] 9 -Inf 11 12 195s num [1:4] 9 -Inf 11 12 195s range: 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s real + Inf cell (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 Inf 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s max: 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s range: 195s num [1:4, 1:2] 1 2 3 4 9 ... 195s num [1:4, 1:2] 1 2 3 4 9 ... 195s num [1:4, 1:2] 1 2 3 4 9 ... 195s real + Inf cell (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 Inf 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s max: 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s range: 195s num [1:4, 1:2] 1 2 3 4 9 ... 195s num [1:4, 1:2] 1 2 3 4 9 ... 195s num [1:4, 1:2] 1 2 3 4 9 ... 195s real + Inf row (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] Inf Inf Inf 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s max: 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s range: 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s real + Inf row (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] Inf Inf Inf 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s num [1:4] 1 Inf 3 4 195s max: 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s num [1:4] 9 Inf 11 12 195s range: 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s num [1:4, 1:2] 1 Inf 3 4 9 ... 195s real + NaN cell (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 NaN 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s max: 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s range: 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s real + NaN cell (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] 1 5 9 195s [2,] 2 NaN 10 195s [3,] 3 7 11 195s [4,] 4 8 12 195s min: 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s num [1:4] 1 2 3 4 195s max: 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s num [1:4] 9 10 11 12 195s range: 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s num [1:4, 1:2] 1 2 3 4 9 10 11 12 195s real w/ NA + NaN cell (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NA NaN NA 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s max: 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s range: 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s real w/ NA + NaN cell (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NA NaN NA 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s max: 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s range: 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s real w/ NA + NaN row (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NaN NaN NaN 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s max: 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s range: 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s real w/ NA + NaN row (double) w/ na.rm = TRUE: 195s [,1] [,2] [,3] 195s [1,] NA NA NA 195s [2,] NaN NaN NaN 195s [3,] NA NA NA 195s [4,] NA NA NA 195s min: 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s num [1:4] Inf Inf Inf Inf 195s max: 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s num [1:4] -Inf -Inf -Inf -Inf 195s range: 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 195s > 195s 195s R version 4.4.3 (2025-02-28) -- "Trophy Case" 195s Copyright (C) 2025 The R Foundation for Statistical Computing 195s Platform: s390x-ibm-linux-gnu 195s 195s R is free software and comes with ABSOLUTELY NO WARRANTY. 195s You are welcome to redistribute it under certain conditions. 195s Type 'license()' or 'licence()' for distribution details. 195s 195s R is a collaborative project with many contributors. 195s Type 'contributors()' for more information and 195s 'citation()' on how to cite R or R packages in publications. 195s 195s Type 'demo()' for some demos, 'help()' for on-line help, or 195s 'help.start()' for an HTML browser interface to help. 195s Type 'q()' to quit R. 195s 195s > library("matrixStats") 195s > 195s > rowMins_R <- function(x, ..., useNames = TRUE) { 195s + suppressWarnings({ 195s + res <- apply(x, MARGIN = 1L, FUN = min, ...) 195s + }) 195s + if (!useNames) names(res) <- NULL 195s + res 195s + } # rowMins_R() 195s > 195s > rowMaxs_R <- function(x, ..., useNames = TRUE) { 195s + suppressWarnings({ 195s + res <- apply(x, MARGIN = 1L, FUN = max, ...) 195s + }) 195s + if (!useNames) names(res) <- NULL 195s + res 195s + } # rowMaxs_R() 195s > 195s > rowRanges_R <- function(x, ..., useNames = TRUE) { 195s + suppressWarnings({ 195s + ans <- t(apply(x, MARGIN = 1L, FUN = range, ...)) 195s + }) 195s + 195s + # Preserve rownames attribute 195s + dim <- c(dim(x)[1], 2L) 195s + if (!isTRUE(all.equal(dim(ans), dim))) { 195s + dim(ans) <- dim 195s + rownames <- rownames(x) 195s + if (!is.null(dimnames)) rownames(ans) <- rownames 195s + } 195s + if (!useNames) dimnames(ans) <- NULL 195s + ans 195s + } # rowRanges_R() 195s > 195s > 195s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 195s > # Subsetted tests 195s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 195s > source("utils/validateIndicesFramework.R") 195s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 195s > storage.mode(x) <- "integer" 195s > 195s > # To check rownames/names attributes 195s > dimnames <- list(letters[1:6], LETTERS[1:6]) 195s > 195s > # Test with and without dimnames on x 195s > for (setDimnames in c(TRUE, FALSE)) { 195s + if (setDimnames) dimnames(x) <- dimnames 195s + else dimnames(x) <- NULL 195s + 195s + count <- 0L 195s + for (rows in index_cases) { 195s + for (cols in index_cases) { 195s + count <- count + 1L 195s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 195s + useNames <- c(TRUE, FALSE) 195s + useNames <- useNames[count %% length(useNames) + 1] 195s + 195s + validateIndicesTestMatrix(x, rows, cols, 195s + ftest = rowRanges, fsure = rowRanges_R, 195s + na.rm = na.rm, useNames = useNames) 195s + validateIndicesTestMatrix(x, rows, cols, 195s + ftest = rowMins, fsure = rowMins_R, 195s + na.rm = na.rm, useNames = useNames) 195s + validateIndicesTestMatrix(x, rows, cols, 195s + ftest = rowMaxs, fsure = rowMaxs_R, 195s + na.rm = na.rm, useNames = useNames) 195s + 195s + validateIndicesTestMatrix(x, rows, cols, 195s + fcoltest = colRanges, fsure = rowRanges_R, 195s + na.rm = na.rm, useNames = useNames) 195s + validateIndicesTestMatrix(x, rows, cols, 195s + fcoltest = colMins, fsure = rowMins_R, 195s + na.rm = na.rm, useNames = useNames) 195s + validateIndicesTestMatrix(x, rows, cols, 195s + fcoltest = colMaxs, fsure = rowMaxs_R, 195s + na.rm = na.rm, useNames = useNames) 195s + } 195s + } 195s + } 196s > 196s 196s R version 4.4.3 (2025-02-28) -- "Trophy Case" 196s Copyright (C) 2025 The R Foundation for Statistical Computing 196s Platform: s390x-ibm-linux-gnu 196s 196s R is free software and comes with ABSOLUTELY NO WARRANTY. 196s You are welcome to redistribute it under certain conditions. 196s Type 'license()' or 'licence()' for distribution details. 196s 196s R is a collaborative project with many contributors. 196s Type 'contributors()' for more information and 196s 'citation()' on how to cite R or R packages in publications. 196s 196s Type 'demo()' for some demos, 'help()' for on-line help, or 196s 'help.start()' for an HTML browser interface to help. 196s Type 'q()' to quit R. 196s 196s > library("matrixStats") 196s > 196s > dense_rank <- function(x) match(x, table = sort(unique(x))) 196s > 196s > rowRanks_R <- function(x, ties.method, ..., useNames = TRUE) { 196s + if (ties.method == "dense") { 196s + res <- t(apply(x, MARGIN = 1L, FUN = dense_rank)) 196s + } else { 196s + res <- t(apply(x, MARGIN = 1L, FUN = rank, na.last = "keep", ties.method = ties.method)) 196s + } 196s + 196s + # Preserve dimnames attribute? 196s + dim(res) <- dim(x) 196s + dimnames(res) <- if (useNames) dimnames(x) else NULL 196s + 196s + res 196s + } 196s > 196s > colRanks_R <- function(x, ties.method, preserveShape = FALSE, ..., useNames = TRUE) { 196s + if (ties.method == "dense") { 196s + res <- t(apply(x, MARGIN = 2L, FUN = dense_rank)) 196s + } else { 196s + res <- t(apply(x, MARGIN = 2L, FUN = rank, na.last = "keep", ties.method = ties.method)) 196s + } 196s + 196s + # Preserve dimnames attribute? 196s + tx <- t(x) 196s + dim(res) <- dim(tx) 196s + dimnames(res) <- if (useNames) dimnames(tx) else NULL 196s + 196s + if (preserveShape) res <- t(res) 196s + res 196s + } 196s > 196s > set.seed(1) 196s > 196s > cat("Consistency checks:\n") 196s Consistency checks: 196s > xs <- vector("list", length = 4L) 196s > for (kk in 1:4) { 196s + 196s + # Simulate data in a matrix of any shape 196s + dim <- sample(40:80, size = 2L) 196s + n <- prod(dim) 196s + x <- rnorm(n, sd = 10) 196s + dim(x) <- dim 196s + 196s + # Add NAs? 196s + if ((kk %% 4) %in% c(3, 0)) { 196s + cat("Adding NAs\n") 196s + nna <- sample(n, size = 1L) 196s + x[sample(length(x), size = nna)] <- NA_real_ 196s + } 196s + 196s + # Integer or double? 196s + if ((kk %% 4) %in% c(2, 0)) { 196s + cat("Coercing to integers\n") 196s + storage.mode(x) <- "integer" 196s + } 196s + 196s + xs[[kk]] <- x 196s + } # for (kk ...) 196s Coercing to integers 196s Adding NAs 196s Adding NAs 196s Coercing to integers 196s > str(xs) 196s List of 4 196s $ : num [1:43, 1:78] 13.3 12.72 4.15 -15.4 -9.29 ... 196s $ : int [1:46, 1:61] 2 11 -16 -5 19 5 26 -13 1 -9 ... 196s $ : num [1:42, 1:47] NA -22.3 NA NA NA ... 196s $ : int [1:42, 1:78] NA NA NA NA NA NA NA NA NA NA ... 196s > 196s > for (kk in 1:4) { 196s + cat("Random test #", kk, "\n", sep = "") 196s + x <- xs[[kk]] 196s + tx <- t(x) 196s + 196s + for (ties in c("max", "min", "average", "first", "last", "dense")) { 196s + cat(sprintf("ties.method = %s\n", ties)) 196s + # rowRanks(): 196s + y1 <- matrixStats::rowRanks(x, ties.method = ties) 196s + y2 <- rowRanks_R(x, ties.method = ties) 196s + stopifnot(identical(y1, y2)) 196s + 196s + y3 <- matrixStats::colRanks(tx, ties.method = ties) 196s + stopifnot(identical(y1, y3)) 196s + 196s + # colRanks(): 196s + y1 <- matrixStats::colRanks(x, ties.method = ties) 196s + y2 <- colRanks_R(x, ties.method = ties) 196s + stopifnot(identical(y1, y2)) 196s + 196s + y3 <- matrixStats::rowRanks(tx, ties.method = ties) 196s + stopifnot(identical(y1, y3)) 196s + } 196s + } # for (kk ...) 196s Random test #1 196s ties.method = max 196s ties.method = min 196s ties.method = average 196s ties.method = first 196s ties.method = last 196s ties.method = dense 196s Random test #2 196s ties.method = max 196s ties.method = min 196s ties.method = average 196s ties.method = first 196s ties.method = last 196s ties.method = dense 196s Random test #3 196s ties.method = max 196s ties.method = min 196s ties.method = average 196s ties.method = first 196s ties.method = last 196s ties.method = dense 196s Random test #4 196s ties.method = max 196s ties.method = min 196s ties.method = average 196s ties.method = first 196s ties.method = last 196s ties.method = dense 196s > 196s > # Note, below we know ties.method %in% c("min", "max", "average") is correct 196s > 196s > cat("Consistency checks for random:\n") 196s Consistency checks for random: 196s > tolerance <- 0.1 196s > nsamples <- 10000 196s > for (kk in 1:4) { 196s + cat("Random test #", kk, "\n", sep = "") 196s + x <- xs[[kk]] 196s + tx <- t(x) 196s + 196s + for (ties in c("random")) { 196s + cat(sprintf("ties.method = %s\n", ties)) 196s + 196s + ## rowRanks(): 196s + y0 <- rowRanks_R(x, ties.method = ties) 196s + y1 <- matrixStats::rowRanks(x, ties.method = ties) 196s + 196s + ## Assert symmetric rank differences 196s + d <- y1 - y0 196s + stopifnot(all(rowSums(d) == 0, na.rm = TRUE)) 196s + 196s + ## Assert within [min, max] 196s + y2min <- matrixStats::rowRanks(x, ties.method = "min") 196s + y2max <- matrixStats::rowRanks(x, ties.method = "max") 196s + stopifnot(all(y1 >= y2min, na.rm = TRUE) && all(y1 <= y2max, na.rm = TRUE)) 196s + ## Assert near average 196s + y1list <- replicate(nsamples, matrixStats::rowRanks(x, ties.method = ties), simplify = FALSE) 196s + y1mean <- Reduce(`+`, y1list) / nsamples 196s + y2avg <- matrixStats::rowRanks(x, ties.method = "average") 196s + stopifnot(all(abs(y1mean - y2avg) < tolerance, na.rm = TRUE)) 196s + 196s + ## colRanks(): 196s + y0 <- colRanks_R(x, ties.method = ties) 196s + y1 <- matrixStats::colRanks(x, ties.method = ties) 196s + 196s + ## Assert symmetric rank differences 196s + d <- y1 - y0 196s + stopifnot(all(rowSums(d) == 0, na.rm = TRUE)) 196s + 196s + ## Assert within [min, max] 196s + y2min <- matrixStats::colRanks(x, ties.method = "min") 196s + y2max <- matrixStats::colRanks(x, ties.method = "max") 196s + stopifnot(all(y1 >= y2min, na.rm = TRUE) && all(y1 <= y2max, na.rm = TRUE)) 196s + y1list <- replicate(nsamples, matrixStats::colRanks(x, ties.method = ties), simplify = FALSE) 196s + y1mean <- Reduce(`+`, y1list) / nsamples 196s + ## Assert near average 196s + y2avg <- matrixStats::colRanks(x, ties.method = "average") 196s + stopifnot(all(abs(y1mean - y2avg) < tolerance, na.rm = TRUE)) 196s + } 196s + } # for (kk ...) 196s Random test #1 196s ties.method = random 200s Random test #2 200s ties.method = random 203s Random test #3 203s ties.method = random 203s Random test #4 203s ties.method = random 205s > 205s > 205s > ## Exception handling 205s > x <- matrix(1:12, nrow = 3L, ncol = 4L) 205s > y <- try(rowRanks(x, ties.method = "unknown"), silent = TRUE) 205s > stopifnot(inherits(y, "try-error")) 205s > 205s > y <- try(colRanks(x, ties.method = "unknown"), silent = TRUE) 205s > stopifnot(inherits(y, "try-error")) 205s > 205s > dimnames <- list(letters[1:3], LETTERS[1:4]) 205s > for (mode in c("integer", "double")){ 205s + storage.mode(x) <- mode 205s + # Test with and without dimnames on x 205s + for (setDimnames in c(TRUE, FALSE)) { 205s + if (setDimnames) dimnames(x) <- dimnames 205s + else dimnames(x) <- NULL 205s + # Check names attribute 205s + for (useNames in c(TRUE, FALSE)) { 205s + for (ties in c("max", "min", "average", "first", "last", "dense", "random")) { 205s + cat(sprintf("ties.method = %s\n", ties)) 205s + # rowRanks(): 205s + y1 <- matrixStats::rowRanks(x, ties.method = ties, useNames = useNames) 205s + y2 <- rowRanks_R(x, ties.method = ties, useNames = useNames) 205s + stopifnot(identical(y1, y2)) 205s + 205s + y3 <- matrixStats::colRanks(t(x), ties.method = ties, useNames = useNames) 205s + stopifnot(identical(y1, y3)) 205s + 205s + # colRanks(): 205s + y1 <- matrixStats::colRanks(x, ties.method = ties, useNames = useNames) 205s + y2 <- colRanks_R(x, ties.method = ties, useNames = useNames) 205s + stopifnot(identical(y1, y2)) 205s + 205s + y3 <- matrixStats::rowRanks(t(x), ties.method = ties, useNames = useNames) 205s + stopifnot(identical(y1, y3)) 205s + 205s + # Check preserveShape 205s + y1 <- matrixStats::colRanks(x, ties.method = ties, preserveShape = TRUE, useNames = useNames) 205s + y2 <- colRanks_R(x, ties.method = ties, preserveShape = TRUE, useNames = useNames) 205s + stopifnot(identical(y1, y2)) 205s + } 205s + } 205s + } 205s + } 205s ties.method = max 205s ties.method = min 205s ties.method = average 205s ties.method = first 205s ties.method = last 205s ties.method = dense 205s ties.method = random 205s ties.method = max 205s ties.method = min 205s ties.method = average 205s ties.method = first 205s ties.method = last 205s ties.method = dense 205s ties.method = random 205s ties.method = max 205s ties.method = min 205s ties.method = average 205s ties.method = first 205s ties.method = last 205s ties.method = dense 205s ties.method = random 205s ties.method = max 205s ties.method = min 205s ties.method = average 205s ties.method = first 205s ties.method = last 205s ties.method = dense 205s ties.method = random 205s ties.method = max 205s ties.method = min 205s ties.method = average 205s ties.method = first 205s ties.method = last 205s ties.method = dense 205s ties.method = random 205s ties.method = max 205s ties.method = min 205s ties.method = average 205s ties.method = first 205s ties.method = last 205s ties.method = dense 205s ties.method = random 205s ties.method = max 205s ties.method = min 205s ties.method = average 205s ties.method = first 205s ties.method = last 205s ties.method = dense 205s ties.method = random 205s ties.method = max 205s ties.method = min 205s ties.method = average 205s ties.method = first 205s ties.method = last 205s ties.method = dense 205s ties.method = random 205s > 205s 205s R version 4.4.3 (2025-02-28) -- "Trophy Case" 205s Copyright (C) 2025 The R Foundation for Statistical Computing 205s Platform: s390x-ibm-linux-gnu 205s 205s R is free software and comes with ABSOLUTELY NO WARRANTY. 205s You are welcome to redistribute it under certain conditions. 205s Type 'license()' or 'licence()' for distribution details. 205s 205s R is a collaborative project with many contributors. 205s Type 'contributors()' for more information and 205s 'citation()' on how to cite R or R packages in publications. 205s 205s Type 'demo()' for some demos, 'help()' for on-line help, or 205s 'help.start()' for an HTML browser interface to help. 205s Type 'q()' to quit R. 205s 205s > library("matrixStats") 205s > 205s > rowRanks_R <- function(x, ties.method = "average", ..., useNames = TRUE) { 205s + ans <- t(apply(x, MARGIN = 1L, FUN = rank, na.last = "keep", 205s + ties.method = ties.method)) 205s + 205s + # Preserve dimnames attribute? 205s + dim(ans) <- dim(x) 205s + dimnames(ans) <- if (useNames) dimnames(x) else NULL 205s + 205s + ans 205s + } 205s > 205s > colRanks_R <- function(x, ties.method, preserveShape = FALSE, ..., useNames = TRUE) { 205s + ans <- t(apply(x, MARGIN = 2L, FUN = rank, na.last = "keep", ties.method = ties.method)) 205s + 205s + # Preserve dimnames attribute? 205s + tx <- t(x) 205s + dim(ans) <- dim(tx) 205s + dimnames(ans) <- if (useNames) dimnames(tx) else NULL 205s + 205s + if (preserveShape) ans <- t(ans) 205s + ans 205s + } 205s > 205s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 205s > # Subsetted tests 205s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 205s > source("utils/validateIndicesFramework.R") 205s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 205s > storage.mode(x) <- "integer" 205s > 205s > # To check dimnames attribute 205s > dimnames <- list(letters[1:6], LETTERS[1:6]) 205s > 205s > colRanks_R_t <- function(x, rows, cols, ..., useNames = TRUE) { 205s + t(colRanks(t(x), rows = cols, cols = rows, preserveShape = TRUE, ..., useNames = useNames)) 205s + } 205s > 205s > # Test with and without dimnames on x 205s > for (setDimnames in c(TRUE, FALSE)) { 205s + if (setDimnames) dimnames(x) <- dimnames 205s + else dimnames(x) <- NULL 205s + 205s + count <- 0L 205s + for (rows in index_cases) { 205s + for (cols in index_cases) { 205s + count <- count + 1L 205s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 205s + useNames <- c(TRUE, FALSE) 205s + useNames <- useNames[count %% length(useNames) + 1] 205s + 205s + validateIndicesTestMatrix(x, rows, cols, 205s + ftest = rowRanks, fsure = rowRanks_R, 205s + ties.method = "average", useNames = useNames) 205s + 205s + validateIndicesTestMatrix(x, rows, cols, 205s + ftest = colRanks_R_t, fsure = rowRanks_R, 205s + ties.method = "average", useNames = useNames) 205s + 205s + for (perserveShape in c(TRUE, FALSE)) { 205s + validateIndicesTestMatrix(x, rows, cols, 205s + ftest = colRanks, fsure = colRanks_R, 205s + ties.method = "average", perserveShape = perserveShape, 205s + useNames = useNames) 205s + } 205s + } 205s + } 205s + } 206s > 206s 206s R version 4.4.3 (2025-02-28) -- "Trophy Case" 206s Copyright (C) 2025 The R Foundation for Statistical Computing 206s Platform: s390x-ibm-linux-gnu 206s 206s R is free software and comes with ABSOLUTELY NO WARRANTY. 206s You are welcome to redistribute it under certain conditions. 206s Type 'license()' or 'licence()' for distribution details. 206s 206s R is a collaborative project with many contributors. 206s Type 'contributors()' for more information and 206s 'citation()' on how to cite R or R packages in publications. 206s 206s Type 'demo()' for some demos, 'help()' for on-line help, or 206s 'help.start()' for an HTML browser interface to help. 206s Type 'q()' to quit R. 206s 206s > library("matrixStats") 206s > 206s > ## Always allow testing of the 'center' argument (as long as it's not defunct) 206s > options(matrixStats.center.onUse = "ignore") 206s > 206s > ## Create isFALSE() if running on an old version of R 206s > if (!exists("isFALSE", mode="function")) { 206s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 206s + } 206s > 206s > rowSds_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = TRUE) { 206s + suppressWarnings({ 206s + sigma <- apply(x, MARGIN = 1L, FUN = sd, na.rm = na.rm) 206s + }) 206s + stopifnot(!any(is.infinite(sigma))) 206s + 206s + # Keep naming support consistency same as rowSds() 206s + if (is.null(center) || ncol(x) <= 1L) { 206s + if (isFALSE(useNames)) names(sigma) <- NULL 206s + } 206s + else if (isFALSE(useNames)) names(sigma) <- NULL 206s + sigma 206s + } 206s > 206s > colSds_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = TRUE) { 206s + suppressWarnings({ 206s + sigma <- apply(x, MARGIN = 2L, FUN = sd, na.rm = na.rm) 206s + }) 206s + stopifnot(!any(is.infinite(sigma))) 206s + 206s + # Keep naming support consistency same as colSds() 206s + if (is.null(center) || nrow(x) <= 1L) { 206s + if (isFALSE(useNames)) names(sigma) <- NULL 206s + } 206s + if (isFALSE(useNames)) names(sigma) <- NULL 206s + sigma 206s + } 206s > 206s > 206s > rowSds_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 206s + center <- rowWeightedMeans(x, cols = cols, na.rm = na.rm, useNames = FALSE) 206s + sigma <- rowSds(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 206s + stopifnot(!any(is.infinite(sigma))) 206s + sigma 206s + } 206s > 206s > colSds_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 206s + center <- colWeightedMeans(x, rows = rows, na.rm = na.rm, useNames = FALSE) 206s + sigma <- colSds(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 206s + stopifnot(!any(is.infinite(sigma))) 206s + sigma 206s + } 206s > 206s > 206s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 206s > # With and without some NAs 206s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 206s > for (mode in c("integer", "double")) { 206s + for (add_na in c(FALSE, TRUE)) { 206s + cat("add_na = ", add_na, "\n", sep = "") 206s + 206s + x <- matrix(1:50 + 0.1, nrow = 10L, ncol = 5L) 206s + if (add_na) { 206s + x[3:7, c(2, 4)] <- NA_real_ 206s + } 206s + cat("mode: ", mode, "\n", sep = "") 206s + storage.mode(x) <- mode 206s + str(x) 206s + 206s + # To check names attribute 206s + dimnames <- list(letters[1:10], LETTERS[1:5]) 206s + 206s + # Test with and without dimnames on x 206s + for (setDimnames in c(TRUE, FALSE)) { 206s + if (setDimnames) dimnames(x) <- dimnames 206s + else dimnames(x) <- NULL 206s + # Row/column ranges 206s + for (na.rm in c(FALSE, TRUE)) { 206s + # Check names attribute 206s + for (useNames in c(TRUE, FALSE)) { 206s + r0 <- rowSds_R(x, na.rm = na.rm, useNames = useNames) 206s + r1 <- rowSds(x, na.rm = na.rm, useNames = useNames) 206s + r1b <- rowSds_center(x, na.rm = na.rm, useNames = useNames) 206s + r2 <- colSds(t(x), na.rm = na.rm, useNames = useNames) 206s + r2b <- colSds_center(t(x), na.rm = na.rm, useNames = useNames) 206s + stopifnot(all.equal(r1, r2)) 206s + stopifnot(all.equal(r1, r0)) 206s + stopifnot(all.equal(r2, r0)) 206s + stopifnot(all.equal(r1b, r2b)) 206s + stopifnot( 206s + !any(is.infinite(r1)), 206s + !any(is.infinite(r2)), 206s + !any(is.infinite(r1b)), 206s + !any(is.infinite(r2b)) 206s + ) 206s + } 206s + } 206s + } 206s + } # for (add_na ...) 206s + } 206s add_na = FALSE 206s mode: integer 206s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 206s add_na = TRUE 206s mode: integer 206s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 206s add_na = FALSE 206s mode: double 206s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 206s add_na = TRUE 206s mode: double 206s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 206s > 206s > 206s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 206s > # All NAs 206s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 206s > for (mode in c("integer", "double")) { 206s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 206s + cat("mode: ", mode, "\n", sep = "") 206s + storage.mode(x) <- mode 206s + str(x) 206s + 206s + # Test with and without dimnames on x 206s + for (setDimnames in c(TRUE, FALSE)) { 206s + if (setDimnames) dimnames(x) <- dimnames 206s + else dimnames(x) <- NULL 206s + # Row/column ranges 206s + for (na.rm in c(FALSE, TRUE)) { 206s + # Check names attribute 206s + for (useNames in c(TRUE, FALSE)) { 206s + r0 <- rowSds_R(x, na.rm = na.rm, useNames = useNames) 206s + r1 <- rowSds(x, na.rm = na.rm, useNames = useNames) 206s + r1b <- rowSds_center(x, na.rm = na.rm, useNames = useNames) 206s + r2 <- colSds(t(x), na.rm = na.rm, useNames = useNames) 206s + r2b <- colSds_center(t(x), na.rm = na.rm, useNames = useNames) 206s + stopifnot(all.equal(r1, r2)) 206s + stopifnot(all.equal(r1, r0)) 206s + stopifnot(all.equal(r2, r0)) 206s + stopifnot(all.equal(r1b, r2b)) 206s + stopifnot( 206s + !any(is.infinite(r1)), 206s + !any(is.infinite(r2)), 206s + !any(is.infinite(r1b)), 206s + !any(is.infinite(r2b)) 206s + ) 206s + } 206s + } 206s + } 206s + } 206s mode: integer 206s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 206s mode: double 206s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 206s > 206s > 206s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 206s > # A 1x1 matrix 206s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 206s > x <- matrix(0, nrow = 1L, ncol = 1L) 206s > dimnames <- list("a", "A") 206s > for (na.rm in c(FALSE, TRUE)) { 206s + cat("na.rm = ", na.rm, "\n", sep = "") 206s + 206s + # Test with and without dimnames on x 206s + for (setDimnames in c(TRUE, FALSE)) { 206s + if (setDimnames) dimnames(x) <- dimnames 206s + else dimnames(x) <- NULL 206s + # Row/column ranges 206s + for (na.rm in c(FALSE, TRUE)) { 206s + # Check names attribute 206s + for (useNames in c(TRUE, FALSE)) { 206s + r0 <- rowSds_R(x, na.rm = na.rm, useNames = useNames) 206s + r1 <- rowSds(x, na.rm = na.rm, useNames = useNames) 206s + r1b <- rowSds_center(x, na.rm = na.rm, useNames = useNames) 206s + r2 <- colSds(t(x), na.rm = na.rm, useNames = useNames) 206s + r2b <- colSds_center(t(x), na.rm = na.rm, useNames = useNames) 206s + stopifnot(all.equal(r1, r2)) 206s + stopifnot(all.equal(r1, r0)) 206s + stopifnot(all.equal(r2, r0)) 206s + stopifnot(all.equal(r1b, r2b)) 206s + stopifnot( 206s + !any(is.infinite(r1)), 206s + !any(is.infinite(r2)), 206s + !any(is.infinite(r1b)), 206s + !any(is.infinite(r2b)) 206s + ) 206s + } 206s + } 206s + } 206s + } 206s na.rm = FALSE 206s na.rm = TRUE 206s > 206s 206s R version 4.4.3 (2025-02-28) -- "Trophy Case" 206s Copyright (C) 2025 The R Foundation for Statistical Computing 206s Platform: s390x-ibm-linux-gnu 206s 206s R is free software and comes with ABSOLUTELY NO WARRANTY. 206s You are welcome to redistribute it under certain conditions. 206s Type 'license()' or 'licence()' for distribution details. 206s 206s R is a collaborative project with many contributors. 206s Type 'contributors()' for more information and 206s 'citation()' on how to cite R or R packages in publications. 206s 206s Type 'demo()' for some demos, 'help()' for on-line help, or 206s 'help.start()' for an HTML browser interface to help. 206s Type 'q()' to quit R. 206s 206s > library("matrixStats") 206s > 206s > ## Always allow testing of the 'center' argument (as long as it's not defunct) 206s > options(matrixStats.center.onUse = "ignore") 206s > 206s > ## Create isFALSE() if running on an old version of R 206s > if (!exists("isFALSE", mode="function")) { 206s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 206s + } 206s > 206s > rowSds_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = TRUE) { 206s + suppressWarnings({ 206s + sigma <- apply(x, MARGIN = 1L, FUN = sd, na.rm = na.rm) 206s + }) 206s + stopifnot(!any(is.infinite(sigma))) 206s + 206s + # Keep naming support consistency same as rowSds() 206s + if (is.null(center) || ncol(x) <= 1L) { 206s + if (isFALSE(useNames)) names(sigma) <- NULL 206s + } 206s + else if (isFALSE(useNames)) names(sigma) <- NULL 206s + sigma 206s + } 206s > 206s > colSds_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = TRUE) { 206s + suppressWarnings({ 206s + sigma <- apply(x, MARGIN = 2L, FUN = sd, na.rm = na.rm) 206s + }) 206s + stopifnot(!any(is.infinite(sigma))) 206s + 206s + # Keep naming support consistency same as colSds() 206s + if (is.null(center) || nrow(x) <= 1L) { 206s + if (isFALSE(useNames)) names(sigma) <- NULL 206s + } 206s + else if (isFALSE(useNames)) names(sigma) <- NULL 206s + sigma 206s + } 206s > 206s > 206s > rowSds_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 206s + center <- rowWeightedMeans(x, cols = cols, na.rm = na.rm, useNames = FALSE) 206s + sigma <- rowSds(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 206s + stopifnot(!any(is.infinite(sigma))) 206s + sigma 206s + } 206s > 206s > colSds_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 206s + center <- colWeightedMeans(x, rows = rows, na.rm = na.rm, useNames = FALSE) 206s + sigma <- colSds(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 206s + stopifnot(!any(is.infinite(sigma))) 206s + sigma 206s + } 206s > 206s > 206s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 206s > # Subsetted tests 206s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 206s > source("utils/validateIndicesFramework.R") 206s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 206s > storage.mode(x) <- "integer" 206s > 206s > # To check names attribute 206s > dimnames <- list(letters[1:6], LETTERS[1:6]) 206s > 206s > # Test with and without dimnames on x 206s > for (setDimnames in c(TRUE, FALSE)) { 206s + if (setDimnames) dimnames(x) <- dimnames 206s + else dimnames(x) <- NULL 206s + 206s + count <- 0L 206s + for (rows in index_cases) { 206s + for (cols in index_cases) { 206s + count <- count + 1L 206s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 206s + useNames <- c(TRUE, FALSE) 206s + useNames <- useNames[count %% length(useNames) + 1] 206s + 206s + validateIndicesTestMatrix(x, rows, cols, 206s + ftest = rowSds, fsure = rowSds_R, 206s + na.rm = na.rm, useNames = useNames) 206s + validateIndicesTestMatrix(x, rows, cols, 206s + ftest = rowSds_center, fsure = rowSds_R, 206s + na.rm = na.rm, center = TRUE, useNames = useNames) 206s + 206s + validateIndicesTestMatrix(x, rows, cols, 206s + fcoltest = colSds, fsure = rowSds_R, 206s + na.rm = na.rm, useNames = useNames) 206s + validateIndicesTestMatrix(x, rows, cols, 206s + fcoltest = colSds_center, fsure = rowSds_R, 206s + na.rm = na.rm, center = TRUE, useNames = useNames) 206s + } 206s + } 206s + } 207s > 207s 207s R version 4.4.3 (2025-02-28) -- "Trophy Case" 207s Copyright (C) 2025 The R Foundation for Statistical Computing 207s Platform: s390x-ibm-linux-gnu 207s 207s R is free software and comes with ABSOLUTELY NO WARRANTY. 207s You are welcome to redistribute it under certain conditions. 207s Type 'license()' or 'licence()' for distribution details. 207s 207s R is a collaborative project with many contributors. 207s Type 'contributors()' for more information and 207s 'citation()' on how to cite R or R packages in publications. 207s 207s Type 'demo()' for some demos, 'help()' for on-line help, or 207s 'help.start()' for an HTML browser interface to help. 207s Type 'q()' to quit R. 207s 207s > library("matrixStats") 207s > 207s > rowSums2_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 207s + ## FIXME: sum() may overflow for integers, whereas 207s + ## base::rowSums() doesn't. What should rowSums2() do? 207s + ## apply(x, MARGIN = 1L, FUN = sum, na.rm = na.rm) 207s + res <- rowSums(x, na.rm = na.rm) 207s + if (!useNames) names(res) <- NULL 207s + res 207s + } 207s > 207s > colSums2_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 207s + ## FIXME: sum() may overflow for integers, whereas 207s + ## base::colSums() doesn't. What should colSums2() do? 207s + ## apply(x, MARGIN = 2L, FUN = sum, na.rm = na.rm) 207s + res <- colSums(x, na.rm = na.rm) 207s + if (!useNames) names(res) <- NULL 207s + res 207s + } 207s > 207s > for (mode in c("integer", "logical", "double")) { 207s + x <- matrix(-4:4, nrow = 3, ncol = 3) 207s + storage.mode(x) <- mode 207s + if (mode == "double") x <- x + 0.1 207s + 207s + # To check names attribute 207s + dimnames <- list(letters[1:3], LETTERS[1:3]) 207s + 207s + # Test with and without dimnames on x 207s + for (setDimnames in c(TRUE, FALSE)) { 207s + if (setDimnames) dimnames(x) <- dimnames 207s + else dimnames(x) <- NULL 207s + # Check names attribute 207s + for (useNames in c(TRUE, FALSE)) { 207s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 207s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 207s + stopifnot(all.equal(y1, y0)) 207s + 207s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 207s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 207s + stopifnot(all.equal(y1, y0)) 207s + } 207s + } 207s + } 207s > 207s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207s > # Special case: Single-element matrix 207s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207s > cat("Special case: Single-element matrix:\n") 207s Special case: Single-element matrix: 207s > for (mode in c("integer", "logical", "double")) { 207s + x <- matrix(1, nrow = 1, ncol = 1) 207s + storage.mode(x) <- mode 207s + 207s + # To check names attribute 207s + dimnames <- list("a", "A") 207s + 207s + # Test with and without dimnames on x 207s + for (setDimnames in c(TRUE, FALSE)) { 207s + if (setDimnames) dimnames(x) <- dimnames 207s + else dimnames(x) <- NULL 207s + # Check names attribute 207s + for (useNames in c(TRUE, FALSE)) { 207s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 207s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 207s + stopifnot(all.equal(y1, y0)) 207s + 207s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 207s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 207s + stopifnot(all.equal(y1, y0)) 207s + } 207s + } 207s + } 207s > 207s > 207s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207s > # Special case: Empty matrix 207s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207s > cat("Special case: Empty matrix:\n") 207s Special case: Empty matrix: 207s > for (mode in c("integer", "logical", "double")) { 207s + x <- matrix(integer(0), nrow = 0, ncol = 0) 207s + storage.mode(x) <- mode 207s + 207s + y0 <- rowSums2_R(x, na.rm = FALSE) 207s + y1 <- rowSums2(x, na.rm = FALSE) 207s + stopifnot(all.equal(y1, y0)) 207s + 207s + y0 <- colSums2_R(x, na.rm = FALSE) 207s + y1 <- colSums2(x, na.rm = FALSE) 207s + stopifnot(all.equal(y1, y0)) 207s + } 207s > 207s > 207s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207s > # Special case: All NAs 207s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207s > cat("Special case: All NAs:\n") 207s Special case: All NAs: 207s > for (mode in c("integer", "logical", "double")) { 207s + x <- matrix(NA_integer_, nrow = 3, ncol = 3) 207s + storage.mode(x) <- mode 207s + 207s + # To check names attribute 207s + dimnames <- list(letters[1:3], LETTERS[1:3]) 207s + 207s + # Test with and without dimnames on x 207s + for (setDimnames in c(TRUE, FALSE)) { 207s + if (setDimnames) dimnames(x) <- dimnames 207s + else dimnames(x) <- NULL 207s + # Check names attribute 207s + for (useNames in c(TRUE, FALSE)) { 207s + y0 <- rowSums2_R(x, na.rm = TRUE, useNames = useNames) 207s + y1 <- rowSums2(x, na.rm = TRUE, useNames = useNames) 207s + stopifnot(all.equal(y1, y0)) 207s + 207s + y0 <- colSums2_R(x, na.rm = TRUE, useNames = useNames) 207s + y1 <- colSums2(x, na.rm = TRUE, useNames = useNames) 207s + stopifnot(all.equal(y1, y0)) 207s + } 207s + } 207s + } 207s > 207s > 207s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207s > # Special case: All NaNs 207s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207s > cat("Special case: All NaNs:\n") 207s Special case: All NaNs: 207s > x <- matrix(NA_real_, nrow = 3, ncol = 3) 207s > 207s > # Test with and without dimnames on x 207s > for (setDimnames in c(TRUE, FALSE)) { 207s + if (setDimnames) dimnames(x) <- dimnames 207s + else dimnames(x) <- NULL 207s + # Check names attribute 207s + for (useNames in c(TRUE, FALSE)) { 207s + y0 <- rowSums2_R(x, na.rm = TRUE, useNames = useNames) 207s + y1 <- rowSums2(x, na.rm = TRUE, useNames = useNames) 207s + stopifnot(all.equal(y1, y0)) 207s + 207s + y0 <- colSums2_R(x, na.rm = TRUE, useNames = useNames) 207s + y1 <- colSums2(x, na.rm = TRUE, useNames = useNames) 207s + stopifnot(all.equal(y1, y0)) 207s + } 207s + } 207s > 207s > 207s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207s > # Special case: All Infs 207s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207s > cat("Special case: All Infs:\n") 207s Special case: All Infs: 207s > x <- matrix(Inf, nrow = 3, ncol = 3) 207s > 207s > # Test with and without dimnames on x 207s > for (setDimnames in c(TRUE, FALSE)) { 207s + if (setDimnames) dimnames(x) <- dimnames 207s + else dimnames(x) <- NULL 207s + # Check names attribute 207s + for (useNames in c(TRUE, FALSE)) { 207s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 207s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 207s + stopifnot(all.equal(y1, y0)) 207s + 207s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 207s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 207s + stopifnot(all.equal(y1, y0)) 207s + } 207s + } 207s > 207s > 207s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207s > # Special case: All -Infs 207s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207s > cat("Special case: All -Infs:\n") 207s Special case: All -Infs: 207s > x <- matrix(-Inf, nrow = 3, ncol = 3) 207s > 207s > # Test with and without dimnames on x 207s > for (setDimnames in c(TRUE, FALSE)) { 207s + if (setDimnames) dimnames(x) <- dimnames 207s + else dimnames(x) <- NULL 207s + # Check names attribute 207s + for (useNames in c(TRUE, FALSE)) { 207s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 207s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 207s + stopifnot(all.equal(y1, y0)) 207s + 207s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 207s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 207s + stopifnot(all.equal(y1, y0)) 207s + } 207s + } 207s > 207s > 207s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207s > # Special case: Infs and -Infs 207s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207s > cat("Special case: Infs and -Infs:\n") 207s Special case: Infs and -Infs: 207s > x <- matrix(c(-Inf, +Inf), nrow = 4, ncol = 4) 207s > 207s > # To check names attribute 207s > dimnames <- list(letters[1:4], LETTERS[1:4]) 207s > 207s > # Test with and without dimnames on x 207s > for (setDimnames in c(TRUE, FALSE)) { 207s + if (setDimnames) dimnames(x) <- dimnames 207s + else dimnames(x) <- NULL 207s + # Check names attribute 207s + for (useNames in c(TRUE, FALSE)) { 207s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 207s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 207s + stopifnot(all.equal(y1, y0)) 207s + 207s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 207s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 207s + stopifnot(all.equal(y1, y0)) 207s + } 207s + } 207s > 207s > 207s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207s > # Special case: NaNs and NAs 207s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207s > cat("Special case: Infs and -Infs:\n") 207s Special case: Infs and -Infs: 207s > x <- matrix(c(NaN, NA_real_), nrow = 4, ncol = 4) 207s > 207s > y0 <- rowSums(x, na.rm = FALSE) 207s > str(y0) 207s num [1:4] NaN NA NaN NA 207s > stopifnot(all(is.na(y0)), length(unique(y0)) >= 1L) 207s > y1 <- rowSums2(x, na.rm = FALSE) 207s > str(y0) 207s num [1:4] NaN NA NaN NA 207s > stopifnot(all(is.na(y1)), length(unique(y1)) >= 1L) 207s > stopifnot(all.equal(y1, y0)) 207s > 207s > y0 <- colSums(x, na.rm = FALSE) 207s > stopifnot(all(is.na(y0)), length(unique(y0)) == 1L) 207s > y1 <- colSums2(x, na.rm = FALSE) 207s > stopifnot(all(is.na(y1)), length(unique(y1)) == 1L) 207s > ## NOTE, due to compiler optimization, it is not guaranteed that NA is 207s > ## returned here (as one would expect). NaN might very well be returned, 207s > ## when both NA and NaN are involved. This is an accepted feature in R, 207s > ## which is documented in help("is.nan"). See also 207s > ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 207s > ## Thus, we cannot guarantee that y1 is identical to y0. 207s > 207s > 207s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207s > # Special case: Integer overflow with ties 207s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207s > cat("Special case: Integer overflow with ties:\n") 207s Special case: Integer overflow with ties: 207s > x <- matrix(.Machine$integer.max, nrow = 4, ncol = 4) 207s > 207s > # Test with and without dimnames on x 207s > for (setDimnames in c(TRUE, FALSE)) { 207s + if (setDimnames) dimnames(x) <- dimnames 207s + else dimnames(x) <- NULL 207s + # Check names attribute 207s + for (useNames in c(TRUE, FALSE)) { 207s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 207s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 207s + stopifnot(all.equal(y1, y0)) 207s + 207s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 207s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 207s + stopifnot(all.equal(y1, y0)) 207s + } 207s + } 207s > 207s > 207s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207s > # Consistency checks 207s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207s > set.seed(1) 207s > 207s > cat("Consistency checks:\n") 207s Consistency checks: 207s > n_sims <- if (Sys.getenv("_R_CHECK_USE_VALGRIND_") != "") 4L else 20L 207s > for (kk in seq_len(n_sims)) { 207s + cat("Random test #", kk, "\n", sep = "") 207s + 207s + # Simulate data in a matrix of any shape 207s + dim <- sample(50:200, size = 2) 207s + n <- prod(dim) 207s + x <- rnorm(n, sd = 100) 207s + dim(x) <- dim 207s + 207s + # Add NAs? 207s + if ((kk %% 4) %in% c(3, 0)) { 207s + cat("Adding NAs\n") 207s + nna <- sample(n, size = 1) 207s + na_values <- c(NA_real_, NaN) 207s + t <- sample(na_values, size = nna, replace = TRUE) 207s + x[sample(length(x), size = nna)] <- t 207s + } 207s + 207s + # Mode? 207s + modes <- "double" 207s + if ((kk %% 4) %in% c(2, 0)) { 207s + modes <- c("integer", "logical") 207s + } 207s + 207s + for (mode in modes) { 207s + if (mode != "double") { 207s + cat(sprintf("Coercing from %s to %s\n", storage.mode(x), mode)) 207s + storage.mode(x) <- mode 207s + } 207s + 207s + na.rm <- sample(c(TRUE, FALSE), size = 1) 207s + 207s + # rowSums2(): 207s + y0 <- rowSums2_R(x, na.rm = na.rm) 207s + y1 <- rowSums2(x, na.rm = na.rm) 207s + stopifnot(all.equal(y1, y0)) 207s + y2 <- colSums2(t(x), na.rm = na.rm) 207s + stopifnot(all.equal(y2, y0)) 207s + 207s + # colSums2(): 207s + y0 <- colSums2_R(x, na.rm = na.rm) 207s + y1 <- colSums2(x, na.rm = na.rm) 207s + stopifnot(all.equal(y1, y0)) 207s + y2 <- rowSums2(t(x), na.rm = na.rm) 207s + stopifnot(all.equal(y2, y0)) 207s + } 207s + } # for (kk ...) 207s Random test #1 207s Random test #2 207s Coercing from double to integer 207s Coercing from integer to logical 207s Random test #3 207s Adding NAs 207s Random test #4 207s Adding NAs 207s Coercing from double to integer 207s Coercing from integer to logical 207s Random test #5 207s Random test #6 207s Coercing from double to integer 207s Coercing from integer to logical 207s Random test #7 207s Adding NAs 207s Random test #8 207s Adding NAs 207s Coercing from double to integer 207s Coercing from integer to logical 207s Random test #9 207s Random test #10 207s Coercing from double to integer 207s Coercing from integer to logical 207s Random test #11 207s Adding NAs 207s Random test #12 207s Adding NAs 207s Coercing from double to integer 207s Coercing from integer to logical 207s Random test #13 207s Random test #14 207s Coercing from double to integer 207s Coercing from integer to logical 207s Random test #15 207s Adding NAs 207s Random test #16 207s Adding NAs 207s Coercing from double to integer 207s Coercing from integer to logical 207s Random test #17 207s Random test #18 207s Coercing from double to integer 207s Coercing from integer to logical 207s Random test #19 207s Adding NAs 207s Random test #20 207s Adding NAs 207s Coercing from double to integer 207s Coercing from integer to logical 207s > 207s 207s R version 4.4.3 (2025-02-28) -- "Trophy Case" 207s Copyright (C) 2025 The R Foundation for Statistical Computing 207s Platform: s390x-ibm-linux-gnu 207s 207s R is free software and comes with ABSOLUTELY NO WARRANTY. 207s You are welcome to redistribute it under certain conditions. 207s Type 'license()' or 'licence()' for distribution details. 207s 207s R is a collaborative project with many contributors. 207s Type 'contributors()' for more information and 207s 'citation()' on how to cite R or R packages in publications. 207s 207s Type 'demo()' for some demos, 'help()' for on-line help, or 207s 'help.start()' for an HTML browser interface to help. 207s Type 'q()' to quit R. 207s 207s > library("matrixStats") 207s > 207s > rowSums2_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 207s + ## FIXME: sum() may overflow for integers, whereas 207s + ## base::rowSums() doesn't. What should rowSums2() do? 207s + ## apply(x, MARGIN = 1L, FUN = sum, na.rm = na.rm) 207s + res <- rowSums(x, na.rm = na.rm) 207s + if (!useNames) names(res) <- NULL 207s + res 207s + } 207s > 207s > colSums2_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 207s + ## FIXME: sum() may overflow for integers, whereas 207s + ## base::colSums() doesn't. What should colSums2() do? 207s + ## apply(x, MARGIN = 2L, FUN = sum, na.rm = na.rm) 207s + res <- colSums(x, na.rm = na.rm) 207s + if (!useNames) names(res) <- NULL 207s + res 207s + } 207s > 207s > 207s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207s > # Subsetted tests 207s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207s > source("utils/validateIndicesFramework.R") 207s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 207s > storage.mode(x) <- "integer" 207s > 207s > # To check names attribute 207s > dimnames <- list(letters[1:6], LETTERS[1:6]) 207s > 207s > # Test with and without dimnames on x 207s > for (setDimnames in c(TRUE, FALSE)) { 207s + if (setDimnames) dimnames(x) <- dimnames 207s + else dimnames(x) <- NULL 207s + for (rows in index_cases) { 207s + for (cols in index_cases) { 207s + for (na.rm in c(TRUE, FALSE)) { 207s + for (useNames in c(TRUE, FALSE)) { 207s + validateIndicesTestMatrix(x, rows, cols, 207s + ftest = rowSums2, fsure = rowSums2_R, 207s + na.rm = na.rm, useNames = useNames) 207s + validateIndicesTestMatrix(x, rows, cols, 207s + fcoltest = colSums2, fsure = rowSums2_R, 207s + na.rm = na.rm, useNames = useNames) 207s + } 207s + } 207s + } 207s + } 207s + } 208s > 208s 208s R version 4.4.3 (2025-02-28) -- "Trophy Case" 208s Copyright (C) 2025 The R Foundation for Statistical Computing 208s Platform: s390x-ibm-linux-gnu 208s 208s R is free software and comes with ABSOLUTELY NO WARRANTY. 208s You are welcome to redistribute it under certain conditions. 208s Type 'license()' or 'licence()' for distribution details. 208s 208s R is a collaborative project with many contributors. 208s Type 'contributors()' for more information and 208s 'citation()' on how to cite R or R packages in publications. 208s 208s Type 'demo()' for some demos, 'help()' for on-line help, or 208s 'help.start()' for an HTML browser interface to help. 208s Type 'q()' to quit R. 208s 208s > library("matrixStats") 208s > 208s > nrow <- 6L 208s > ncol <- 5L 208s > data <- matrix(0:4, nrow = nrow, ncol = ncol) 208s > 208s > # To check names attribute 208s > dimnames <- list(letters[1:6], LETTERS[1:5]) 208s > 208s > modes <- c("integer", "logical", "raw") 208s > for (mode in modes) { 208s + cat(sprintf("Mode: %s...\n", mode)) 208s + 208s + x <- data 208s + if (mode == "logical") x <- x - 2L 208s + if (mode != "raw") x[c(2,5,7)] <- NA_integer_ 208s + storage.mode(x) <- mode 208s + print(x) 208s + 208s + unique_values <- unique(as.vector(x)) 208s + nbr_of_unique_values <- length(unique_values) 208s + 208s + y <- rowTabulates(x) 208s + print(y) 208s + stopifnot( 208s + identical(dim(y), c(nrow, nbr_of_unique_values)), 208s + all(y >= 0) 208s + ) 208s + if (mode != "raw") { 208s + y0 <- t(table(x, row(x), useNA = "always")[, seq_len(nrow(x))]) 208s + stopifnot(all(y == y0)) 208s + } 208s + # Check names attribute 208s + dimnames(x) <- dimnames 208s + y1 <- rowTabulates(x, useNames = FALSE) 208s + stopifnot(all.equal(y1, y)) 208s + y <- rowTabulates(x, useNames = TRUE) 208s + stopifnot(identical(rownames(y), rownames(x))) 208s + dimnames(x) <- NULL 208s + 208s + y <- colTabulates(x) 208s + print(y) 208s + stopifnot( 208s + identical(dim(y), c(ncol, nbr_of_unique_values)), 208s + all(y >= 0) 208s + ) 208s + if (mode != "raw") { 208s + y0 <- t(table(x, col(x), useNA = "always")[, seq_len(ncol(x))]) 208s + stopifnot(all(y == y0)) 208s + } 208s + # Check names attribute 208s + dimnames(x) <- dimnames 208s + y1 <- colTabulates(x, useNames = FALSE) 208s + stopifnot(all.equal(y1, y)) 208s + y <- colTabulates(x, useNames = TRUE) 208s + stopifnot(identical(rownames(y), colnames(x))) 208s + dimnames(x) <- NULL 208s + 208s + # Count only certain values 208s + if (mode == "integer") { 208s + subset <- c(0:2, NA_integer_) 208s + } else if (mode == "logical") { 208s + subset <- c(TRUE, FALSE, NA) 208s + } else { 208s + subset <- c(0:2) 208s + } 208s + y <- rowTabulates(x, values = subset) 208s + print(y) 208s + stopifnot(identical(dim(y), c(nrow, length(subset)))) 208s + # Check names attribute 208s + dimnames(x) <- dimnames 208s + y1 <- rowTabulates(x, values = subset, useNames = FALSE) 208s + stopifnot(all.equal(y1, y)) 208s + y <- rowTabulates(x, values = subset, useNames = TRUE) 208s + stopifnot(identical(rownames(y), rownames(x))) 208s + dimnames(x) <- NULL 208s + 208s + y <- colTabulates(x, values = subset) 208s + print(y) 208s + stopifnot(identical(dim(y), c(ncol, length(subset)))) 208s + # Check names attribute 208s + dimnames(x) <- dimnames 208s + y1 <- colTabulates(x, values = subset, useNames = FALSE) 208s + stopifnot(all.equal(y1, y)) 208s + y <- colTabulates(x, values = subset, useNames = TRUE) 208s + stopifnot(identical(rownames(y), colnames(x))) 208s + dimnames(x) <- NULL 208s + 208s + # Raw 208s + if (mode %in% c("integer", "raw")) { 208s + subset <- c(0:2) 208s + 208s + y <- rowTabulates(x, values = as.raw(subset)) 208s + print(y) 208s + stopifnot(identical(dim(y), c(nrow, length(subset)))) 208s + # Check names attribute 208s + dimnames(x) <- dimnames 208s + y1 <- rowTabulates(x, values = as.raw(subset), useNames = FALSE) 208s + stopifnot(all.equal(y1, y)) 208s + y3 <- rowTabulates(x, values = as.raw(subset), useNames = TRUE) 208s + stopifnot(identical(rownames(y3), rownames(x))) 208s + dimnames(x) <- NULL 208s + 208s + y2 <- colTabulates(t(x), values = as.raw(subset)) 208s + print(y2) 208s + stopifnot( 208s + identical(dim(y2), c(nrow, length(subset))), 208s + identical(y2, y) 208s + ) 208s + # Check names attribute 208s + dimnames(x) <- dimnames 208s + y1 <- colTabulates(t(x), values = as.raw(subset), useNames = FALSE) 208s + stopifnot(all.equal(y1, y)) 208s + y <- colTabulates(t(x), values = as.raw(subset), useNames = TRUE) 208s + stopifnot(identical(rownames(y), colnames(t(x)))) 208s + dimnames(x) <- NULL 208s + } 208s + 208s + cat(sprintf("Mode: %s...done\n", mode)) 208s + } # for (mode ...) 208s Mode: integer... 208s [,1] [,2] [,3] [,4] [,5] 208s [1,] 0 NA 2 3 4 208s [2,] NA 2 3 4 0 208s [3,] 2 3 4 0 1 208s [4,] 3 4 0 1 2 208s [5,] NA 0 1 2 3 208s [6,] 0 1 2 3 4 208s 0 1 2 3 4 208s [1,] 1 0 1 1 1 1 208s [2,] 1 0 1 1 1 1 208s [3,] 1 1 1 1 1 0 208s [4,] 1 1 1 1 1 0 208s [5,] 1 1 1 1 0 1 208s [6,] 1 1 1 1 1 0 208s 0 1 2 3 4 208s [1,] 2 0 1 1 0 2 208s [2,] 1 1 1 1 1 1 208s [3,] 1 1 2 1 1 0 208s [4,] 1 1 1 2 1 0 208s [5,] 1 1 1 1 2 0 208s 0 1 2 208s [1,] 1 0 1 1 208s [2,] 1 0 1 1 208s [3,] 1 1 1 0 208s [4,] 1 1 1 0 208s [5,] 1 1 1 1 208s [6,] 1 1 1 0 208s 0 1 2 208s [1,] 2 0 1 2 208s [2,] 1 1 1 1 208s [3,] 1 1 2 0 208s [4,] 1 1 1 0 208s [5,] 1 1 1 0 208s 0x0 0x1 0x2 208s [1,] 1 0 1 208s [2,] 1 0 1 208s [3,] 1 1 1 208s [4,] 1 1 1 208s [5,] 1 1 1 208s [6,] 1 1 1 208s 0x0 0x1 0x2 208s [1,] 1 0 1 208s [2,] 1 0 1 208s [3,] 1 1 1 208s [4,] 1 1 1 208s [5,] 1 1 1 208s [6,] 1 1 1 208s Mode: integer...done 208s Mode: logical... 208s [,1] [,2] [,3] [,4] [,5] 208s [1,] TRUE NA FALSE TRUE TRUE 208s [2,] NA FALSE TRUE TRUE TRUE 208s [3,] FALSE TRUE TRUE TRUE TRUE 208s [4,] TRUE TRUE TRUE TRUE FALSE 208s [5,] NA TRUE TRUE FALSE TRUE 208s [6,] TRUE TRUE FALSE TRUE TRUE 208s FALSE TRUE 208s [1,] 1 3 1 208s [2,] 1 3 1 208s [3,] 1 4 0 208s [4,] 1 4 0 208s [5,] 1 3 1 208s [6,] 1 4 0 208s FALSE TRUE 208s [1,] 1 3 2 208s [2,] 1 4 1 208s [3,] 2 4 0 208s [4,] 1 5 0 208s [5,] 1 5 0 208s TRUE FALSE 208s [1,] 3 1 1 208s [2,] 3 1 1 208s [3,] 4 1 0 208s [4,] 4 1 0 208s [5,] 3 1 1 208s [6,] 4 1 0 208s TRUE FALSE 208s [1,] 3 1 2 208s [2,] 4 1 1 208s [3,] 4 2 0 208s [4,] 5 1 0 208s [5,] 5 1 0 208s Mode: logical...done 208s Mode: raw... 208s [,1] [,2] [,3] [,4] [,5] 208s [1,] 00 01 02 03 04 208s [2,] 01 02 03 04 00 208s [3,] 02 03 04 00 01 208s [4,] 03 04 00 01 02 208s [5,] 04 00 01 02 03 208s [6,] 00 01 02 03 04 208s 0x0 0x1 0x2 0x3 0x4 208s [1,] 1 1 1 1 1 208s [2,] 1 1 1 1 1 208s [3,] 1 1 1 1 1 208s [4,] 1 1 1 1 1 208s [5,] 1 1 1 1 1 208s [6,] 1 1 1 1 1 208s 0x0 0x1 0x2 0x3 0x4 208s [1,] 2 1 1 1 1 208s [2,] 1 2 1 1 1 208s [3,] 1 1 2 1 1 208s [4,] 1 1 1 2 1 208s [5,] 1 1 1 1 2 208s 0 1 2 208s [1,] 1 1 1 208s [2,] 1 1 1 208s [3,] 1 1 1 208s [4,] 1 1 1 208s [5,] 1 1 1 208s [6,] 1 1 1 208s 0 1 2 208s [1,] 2 1 1 208s [2,] 1 2 1 208s [3,] 1 1 2 208s [4,] 1 1 1 208s [5,] 1 1 1 208s 0x0 0x1 0x2 208s [1,] 1 1 1 208s [2,] 1 1 1 208s [3,] 1 1 1 208s [4,] 1 1 1 208s [5,] 1 1 1 208s [6,] 1 1 1 208s 0x0 0x1 0x2 208s [1,] 1 1 1 208s [2,] 1 1 1 208s [3,] 1 1 1 208s [4,] 1 1 1 208s [5,] 1 1 1 208s [6,] 1 1 1 208s Mode: raw...done 208s > 208s 208s R version 4.4.3 (2025-02-28) -- "Trophy Case" 208s Copyright (C) 2025 The R Foundation for Statistical Computing 208s Platform: s390x-ibm-linux-gnu 208s 208s R is free software and comes with ABSOLUTELY NO WARRANTY. 208s You are welcome to redistribute it under certain conditions. 208s Type 'license()' or 'licence()' for distribution details. 208s 208s R is a collaborative project with many contributors. 208s Type 'contributors()' for more information and 208s 'citation()' on how to cite R or R packages in publications. 208s 208s Type 'demo()' for some demos, 'help()' for on-line help, or 208s 'help.start()' for an HTML browser interface to help. 208s Type 'q()' to quit R. 208s 208s > library("matrixStats") 208s > 208s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 208s > # Subsetted tests 208s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 208s > source("utils/validateIndicesFramework.R") 209s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 209s > storage.mode(x) <- "integer" 209s > 209s > # To check names attribute 209s > dimnames <- list(letters[1:6], LETTERS[1:6]) 209s > 209s > # Test with and without dimnames on x 209s > for (setDimnames in c(TRUE, FALSE)) { 209s + if (setDimnames) dimnames(x) <- dimnames 209s + else dimnames(x) <- NULL 209s + 209s + count <- 0L 209s + for (rows in index_cases) { 209s + for (cols in index_cases) { 209s + count <- count + 1L 209s + useNames <- c(TRUE, FALSE) 209s + useNames <- useNames[count %% length(useNames) + 1] 209s + 209s + validateIndicesTestMatrix(x, rows, cols, 209s + ftest = rowTabulates, fsure = rowTabulates, useNames = useNames) 209s + validateIndicesTestMatrix(x, rows, cols, 209s + ftest = rowTabulates, fsure = rowTabulates, 209s + values = 1:3, useNames = useNames) 209s + 209s + validateIndicesTestMatrix(x, rows, cols, 209s + ftest = colTabulates, fsure = colTabulates, useNames = useNames) 209s + validateIndicesTestMatrix(x, rows, cols, 209s + ftest = colTabulates, fsure = colTabulates, 209s + values = 1:3, useNames = useNames) 209s + } 209s + } 209s + } 210s > 210s 210s R version 4.4.3 (2025-02-28) -- "Trophy Case" 210s Copyright (C) 2025 The R Foundation for Statistical Computing 210s Platform: s390x-ibm-linux-gnu 210s 210s R is free software and comes with ABSOLUTELY NO WARRANTY. 210s You are welcome to redistribute it under certain conditions. 210s Type 'license()' or 'licence()' for distribution details. 210s 210s R is a collaborative project with many contributors. 210s Type 'contributors()' for more information and 210s 'citation()' on how to cite R or R packages in publications. 210s 210s Type 'demo()' for some demos, 'help()' for on-line help, or 210s 'help.start()' for an HTML browser interface to help. 210s Type 'q()' to quit R. 210s 210s > library("matrixStats") 210s > 210s > fcns <- list( 210s + rowVarDiffs = list(rowVarDiffs, colVarDiffs), 210s + rowSdDiffs = list(rowSdDiffs, colSdDiffs), 210s + rowMadDiffs = list(rowMadDiffs, colMadDiffs), 210s + rowIQRDiffs = list(rowIQRDiffs, colIQRDiffs) 210s + ) 210s > 210s > for (fcn in names(fcns)) { 210s + cat(sprintf("%s()...\n", fcn)) 210s + row_fcn <- fcns[[fcn]][[1L]] 210s + col_fcn <- fcns[[fcn]][[2L]] 210s + 210s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 210s + # With and without some NAs 210s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 210s + for (mode in c("integer", "double")) { 210s + for (add_na in c(FALSE, TRUE)) { 210s + cat("add_na = ", add_na, "\n", sep = "") 210s + 210s + x <- matrix(1:50 + 0.1, nrow = 10L, ncol = 5L) 210s + if (add_na) { 210s + x[3:7, c(2, 4)] <- NA_real_ 210s + } 210s + cat("mode: ", mode, "\n", sep = "") 210s + storage.mode(x) <- mode 210s + str(x) 210s + 210s + # To check names attribute 210s + dimnames <- list(letters[1:10], LETTERS[1:5]) 210s + 210s + # Test with and without dimnames on x 210s + for (setDimnames in c(TRUE, FALSE)) { 210s + if (setDimnames) dimnames(x) <- dimnames 210s + else dimnames(x) <- NULL 210s + # Row/column ranges 210s + for (na.rm in c(FALSE, TRUE)) { 210s + # Check names attribute 210s + for (useNames in c(TRUE, FALSE)) { 210s + cat("na.rm = ", na.rm, "\n", sep = "") 210s + r1 <- row_fcn(x, na.rm = na.rm, useNames = useNames) 210s + r2 <- col_fcn(t(x), na.rm = na.rm, useNames = useNames) 210s + stopifnot(all.equal(r1, r2)) 210s + } 210s + } 210s + } 210s + } # for (add_na ...) 210s + } 210s + 210s + 210s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 210s + # All NAs 210s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 210s + for (mode in c("integer", "double")) { 210s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 210s + cat("mode: ", mode, "\n", sep = "") 210s + storage.mode(x) <- mode 210s + str(x) 210s + 210s + # Test with and without dimnames on x 210s + for (setDimnames in c(TRUE, FALSE)) { 210s + if (setDimnames) dimnames(x) <- dimnames 210s + else dimnames(x) <- NULL 210s + # Row/column ranges 210s + for (na.rm in c(FALSE, TRUE)) { 210s + # Check names attribute 210s + for (useNames in c(TRUE, FALSE)) { 210s + cat("na.rm = ", na.rm, "\n", sep = "") 210s + r1 <- row_fcn(x, na.rm = na.rm, useNames = useNames) 210s + r2 <- col_fcn(t(x), na.rm = na.rm, useNames = useNames) 210s + stopifnot(all.equal(r1, r2)) 210s + } 210s + } 210s + } 210s + } 210s + 210s + 210s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 210s + # A 1x1 matrix 210s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 210s + x <- matrix(0, nrow = 1L, ncol = 1L) 210s + dimnames <- list("a", "A") 210s + # Test with and without dimnames on x 210s + for (setDimnames in c(TRUE, FALSE)) { 210s + if (setDimnames) dimnames(x) <- dimnames 210s + else dimnames(x) <- NULL 210s + # Row/column ranges 210s + for (na.rm in c(FALSE, TRUE)) { 210s + # Check names attribute 210s + for (useNames in c(TRUE, FALSE)) { 210s + cat("na.rm = ", na.rm, "\n", sep = "") 210s + r1 <- row_fcn(x, na.rm = na.rm, useNames = useNames) 210s + r2 <- col_fcn(t(x), na.rm = na.rm, useNames = useNames) 210s + stopifnot(all.equal(r1, r2)) 210s + } 210s + } 210s + } 210s + 210s + cat(sprintf("%s()...DONE\n", fcn)) 210s + } # for (fcn ...) 210s rowVarDiffs()... 210s add_na = FALSE 210s mode: integer 210s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s add_na = TRUE 210s mode: integer 210s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s add_na = FALSE 210s mode: double 210s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s add_na = TRUE 210s mode: double 210s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s mode: integer 210s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s mode: double 210s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s rowVarDiffs()...DONE 210s rowSdDiffs()... 210s add_na = FALSE 210s mode: integer 210s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s add_na = TRUE 210s mode: integer 210s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s add_na = FALSE 210s mode: double 210s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s add_na = TRUE 210s mode: double 210s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s mode: integer 210s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s mode: double 210s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s rowSdDiffs()...DONE 210s rowMadDiffs()... 210s add_na = FALSE 210s mode: integer 210s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s add_na = TRUE 210s mode: integer 210s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s add_na = FALSE 210s mode: double 210s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s add_na = TRUE 210s mode: double 210s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s mode: integer 210s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s mode: double 210s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s rowMadDiffs()...DONE 210s rowIQRDiffs()... 210s add_na = FALSE 210s mode: integer 210s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s add_na = TRUE 210s mode: integer 210s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s add_na = FALSE 210s mode: double 210s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s add_na = TRUE 210s mode: double 210s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s mode: integer 210s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s mode: double 210s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s na.rm = FALSE 210s na.rm = FALSE 210s na.rm = TRUE 210s na.rm = TRUE 210s rowIQRDiffs()...DONE 210s > 210s 210s R version 4.4.3 (2025-02-28) -- "Trophy Case" 210s Copyright (C) 2025 The R Foundation for Statistical Computing 210s Platform: s390x-ibm-linux-gnu 210s 210s R is free software and comes with ABSOLUTELY NO WARRANTY. 210s You are welcome to redistribute it under certain conditions. 210s Type 'license()' or 'licence()' for distribution details. 210s 210s R is a collaborative project with many contributors. 210s Type 'contributors()' for more information and 210s 'citation()' on how to cite R or R packages in publications. 210s 210s Type 'demo()' for some demos, 'help()' for on-line help, or 210s 'help.start()' for an HTML browser interface to help. 210s Type 'q()' to quit R. 210s 210s > library("matrixStats") 210s > 210s > fcns <- list( 210s + madDiff = c(rowMadDiffs, colMadDiffs), 210s + iqrDiff = c(rowIQRDiffs, colIQRDiffs) 210s + ) 210s > 210s > 210s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 210s > # Subsetted tests 210s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 210s > source("utils/validateIndicesFramework.R") 210s > # To check names attribute 210s > dimnames <- list(letters[1:6], LETTERS[1:6]) 210s > trim <- runif(1, min = 0, max = 0.5) 210s > for (fcn in names(fcns)) { 210s + cat(sprintf("subsetted tests on %s()...\n", fcn)) 210s + row_fcn <- fcns[[fcn]][[1L]] 210s + col_fcn <- fcns[[fcn]][[2L]] 210s + 210s + for (mode in c("numeric", "integer")) { 210s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6L, ncol = 6L) 210s + storage.mode(x) <- mode 210s + if (mode == "numeric") x[1:2, 3:4] <- Inf 210s + 210s + # Test with and without dimnames on x 210s + for (setDimnames in c(TRUE, FALSE)) { 210s + if (setDimnames) dimnames(x) <- dimnames 210s + else dimnames(x) <- NULL 210s + 210s + count <- 0L 210s + for (diff in 1:2) { 210s + for (rows in index_cases) { 210s + for (cols in index_cases) { 210s + count <- count + 1L 210s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 210s + useNames <- c(TRUE, FALSE) 210s + useNames <- useNames[count %% length(useNames) + 1] 210s + validateIndicesTestMatrix(x, rows, cols, 210s + ftest = row_fcn, fsure = row_fcn, 210s + na.rm = na.rm, diff = diff, trim = trim, useNames = useNames) 210s + validateIndicesTestMatrix(x, rows, cols, 210s + fcoltest = col_fcn, fsure = row_fcn, 210s + na.rm = na.rm, diff = diff, trim = trim, useNames = useNames) 210s + } 210s + } 210s + } 210s + } 210s + } 210s + cat(sprintf("%s()...DONE\n", fcn)) 210s + } 210s subsetted tests on madDiff()... 212s madDiff()...DONE 212s subsetted tests on iqrDiff()... 214s iqrDiff()...DONE 214s > 214s 214s R version 4.4.3 (2025-02-28) -- "Trophy Case" 214s Copyright (C) 2025 The R Foundation for Statistical Computing 214s Platform: s390x-ibm-linux-gnu 214s 214s R is free software and comes with ABSOLUTELY NO WARRANTY. 214s You are welcome to redistribute it under certain conditions. 214s Type 'license()' or 'licence()' for distribution details. 214s 214s R is a collaborative project with many contributors. 214s Type 'contributors()' for more information and 214s 'citation()' on how to cite R or R packages in publications. 214s 214s Type 'demo()' for some demos, 'help()' for on-line help, or 214s 'help.start()' for an HTML browser interface to help. 214s Type 'q()' to quit R. 214s 214s > library("matrixStats") 214s > 214s > fcns <- list( 214s + varDiff = c(rowVarDiffs, colVarDiffs), 214s + sdDiff = c(rowSdDiffs, colSdDiffs) 214s + ) 214s > 214s > 214s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 214s > # Subsetted tests 214s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 214s > source("utils/validateIndicesFramework.R") 214s > # To check names attribute 214s > dimnames <- list(letters[1:6], LETTERS[1:6]) 214s > trim <- runif(1, min = 0, max = 0.5) 214s > for (fcn in names(fcns)) { 214s + cat(sprintf("subsetted tests on %s()...\n", fcn)) 214s + row_fcn <- fcns[[fcn]][[1L]] 214s + col_fcn <- fcns[[fcn]][[2L]] 214s + 214s + for (mode in c("numeric", "integer")) { 214s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6L, ncol = 6L) 214s + storage.mode(x) <- mode 214s + if (mode == "numeric") x[1:2, 3:4] <- Inf 214s + 214s + # Test with and without dimnames on x 214s + for (setDimnames in c(TRUE, FALSE)) { 214s + if (setDimnames) dimnames(x) <- dimnames 214s + else dimnames(x) <- NULL 214s + 214s + count <- 0L 214s + for (diff in 1:2) { 214s + for (rows in index_cases) { 214s + for (cols in index_cases) { 214s + count <- count + 1L 214s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 214s + useNames <- c(TRUE, FALSE) 214s + useNames <- useNames[count %% length(useNames) + 1] 214s + 214s + validateIndicesTestMatrix(x, rows, cols, 214s + ftest = row_fcn, fsure = row_fcn, 214s + na.rm = na.rm, diff = diff, trim = trim, useNames = useNames) 214s + validateIndicesTestMatrix(x, rows, cols, 214s + fcoltest = col_fcn, fsure = row_fcn, 214s + na.rm = na.rm, diff = diff, trim = trim, useNames = useNames) 214s + } 214s + } 214s + } 214s + } 214s + } 214s + cat(sprintf("%s()...DONE\n", fcn)) 214s + } 214s subsetted tests on varDiff()... 215s varDiff()...DONE 215s subsetted tests on sdDiff()... 217s sdDiff()...DONE 217s > 217s 217s R version 4.4.3 (2025-02-28) -- "Trophy Case" 217s Copyright (C) 2025 The R Foundation for Statistical Computing 217s Platform: s390x-ibm-linux-gnu 217s 217s R is free software and comes with ABSOLUTELY NO WARRANTY. 217s You are welcome to redistribute it under certain conditions. 217s Type 'license()' or 'licence()' for distribution details. 217s 217s R is a collaborative project with many contributors. 217s Type 'contributors()' for more information and 217s 'citation()' on how to cite R or R packages in publications. 217s 217s Type 'demo()' for some demos, 'help()' for on-line help, or 217s 'help.start()' for an HTML browser interface to help. 217s Type 'q()' to quit R. 217s 217s > library("matrixStats") 217s > 217s > ## Always allow testing of the 'center' argument (as long as it's not defunct) 217s > options(matrixStats.center.onUse = "ignore") 217s > options(matrixStats.vars.formula.freq = Inf) 217s > 217s > ## Create isFALSE() if running on an old version of R 217s > if (!exists("isFALSE", mode="function")) { 217s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 217s + } 217s > 217s > rowVars_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = TRUE) { 217s + suppressWarnings({ 217s + res <- apply(x, MARGIN = 1L, FUN = var, na.rm = na.rm) 217s + }) 217s + stopifnot(!any(is.infinite(res))) 217s + 217s + # Keep naming support consistency same as rowVars() 217s + if (is.null(center) || ncol(x) <= 1L) { 217s + if (isFALSE(useNames)) names(res) <- NULL 217s + } 217s + else if (isFALSE(useNames)) names(res) <- NULL 217s + res 217s + } 217s > 217s > colVars_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = TRUE) { 217s + suppressWarnings({ 217s + res <- apply(x, MARGIN = 2L, FUN = var, na.rm = na.rm) 217s + }) 217s + stopifnot(!any(is.infinite(res))) 217s + 217s + # Keep naming support consistency same as colVars() 217s + if (is.null(center) || ncol(x) <= 1L) { 217s + if (isFALSE(useNames)) names(res) <- NULL 217s + } 217s + else if (isFALSE(useNames)) names(res) <- NULL 217s + res 217s + } 217s > 217s > 217s > rowVars_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 217s + center <- rowWeightedMeans(x, cols = cols, na.rm = na.rm, useNames = FALSE) 217s + res <- rowVars(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 217s + stopifnot(!any(is.infinite(res))) 217s + res 217s + } 217s > 217s > colVars_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 217s + center <- colWeightedMeans(x, rows = rows, na.rm = na.rm, useNames = FALSE) 217s + res <- colVars(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 217s + stopifnot(!any(is.infinite(res))) 217s + res 217s + } 217s > 217s > rowVars_center_naive <- function(x, rows = NULL, cols = NULL, center = NULL, na.rm = FALSE, ..., useNames = TRUE) { 217s + x <- sweep(x, MARGIN = 1, STATS = as.array(center), FUN = "-") 217s + x[is.infinite(center), ] <- NaN 217s + res <- rowVars(x, rows = rows, cols = cols, center = rep(0, times = nrow(x)), na.rm = na.rm, useNames = useNames) 217s + stopifnot(!any(is.infinite(res))) 217s + res 217s + } 217s > 217s > colVars_center_naive <- function(x, rows = NULL, cols = NULL, center = NULL, na.rm = FALSE, ..., useNames = TRUE) { 217s + x <- sweep(x, MARGIN = 2, STATS = as.array(center), FUN = "-") 217s + x[, is.infinite(center)] <- NaN 217s + res <- colVars(x, rows = rows, cols = cols, center = rep(0, times = ncol(x)), na.rm = na.rm, useNames = useNames) 217s + stopifnot(!any(is.infinite(res))) 217s + res 217s + } 217s > 217s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 217s > # With and without some NAs or Infs 217s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 217s > for (mode in c("integer", "double")) { 217s + if (mode == "integer") { 217s + specials <- c(0L, NA_integer_) 217s + delta <- 0L 217s + } else { 217s + specials <- c(0, NA_real_, Inf) 217s + delta <- 0.1 217s + } 217s + 217s + for (special in specials) { 217s + cat("special = ", special, "\n", sep = "") 217s + x <- matrix(1:50 + delta, nrow = 10L, ncol = 5L) 217s + x[3:7, c(2, 4)] <- special 217s + cat("mode: ", mode, "\n", sep = "") 217s + str(x) 217s + stopifnot(storage.mode(x) == mode) 217s + 217s + # To check names attribute 217s + dimnames <- list(letters[1:10], LETTERS[1:5]) 217s + 217s + # Test with and without dimnames on x 217s + for (setDimnames in c(TRUE, FALSE)) { 217s + if (setDimnames) dimnames(x) <- dimnames 217s + else dimnames(x) <- NULL 217s + # Row/column variance 217s + for (na.rm in c(FALSE, TRUE)) { 217s + # Check names attribute 217s + for (useNames in c(TRUE, FALSE)) { 217s + cat("na.rm = ", na.rm, "\n", sep = "") 217s + center <- rowMeans(x, na.rm = na.rm) 217s + 217s + r0 <- rowVars_R(x, na.rm = na.rm, useNames = useNames) 217s + r1 <- rowVars(x, na.rm = na.rm, useNames = useNames) 217s + r1b <- rowVars_center(x, na.rm = na.rm, useNames = useNames) 217s + r1c <- rowVars(x, center = center, na.rm = na.rm, useNames = useNames) 217s + 217s + tx <- t(x) 217s + r2 <- colVars(tx, na.rm = na.rm, useNames = useNames) 217s + r2b <- colVars_center(tx, na.rm = na.rm, useNames = useNames) 217s + r2c <- colVars(tx, center = center, na.rm = na.rm, useNames = useNames) 217s + tx <- NULL 217s + 217s + stopifnot(all.equal(r1, r2)) 217s + stopifnot(all.equal(r1, r0)) 217s + stopifnot(all.equal(r1b, r1c)) 217s + stopifnot(all.equal(r2, r0)) 217s + stopifnot(all.equal(r2b, r2c)) 217s + 217s + center <- colMeans(x, na.rm = na.rm) 217s + 217s + r3 <- colVars(x, center = center, na.rm = na.rm, useNames = useNames) 217s + r3b <- colVars_center_naive(x, center = center, na.rm = na.rm, useNames = useNames) 217s + r3c <- rowVars(t(x), center = center, na.rm = na.rm, useNames = useNames) 217s + r3d <- rowVars_center_naive(t(x), center = center, na.rm = na.rm, useNames = useNames) 217s + stopifnot(all.equal(r3b, r3)) 217s + stopifnot(all.equal(r3c, r3)) 217s + stopifnot(all.equal(r3d, r3)) 217s + 217s + stopifnot( 217s + !any(is.infinite(r0)), 217s + !any(is.infinite(r1)), 217s + !any(is.infinite(r2)), 217s + !any(is.infinite(r3)), 217s + !any(is.infinite(r1b)), 217s + !any(is.infinite(r1c)), 217s + !any(is.infinite(r2b)), 217s + !any(is.infinite(r2c)), 217s + !any(is.infinite(r3b)), 217s + !any(is.infinite(r3c)), 217s + !any(is.infinite(r3d)) 217s + ) 217s + } 217s + } 217s + } 217s + } # for (special ...) 217s + } 217s special = 0 217s mode: integer 217s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 217s na.rm = FALSE 217s na.rm = FALSE 217s na.rm = TRUE 217s na.rm = TRUE 217s na.rm = FALSE 217s na.rm = FALSE 217s na.rm = TRUE 217s na.rm = TRUE 217s special = NA 217s mode: integer 217s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 217s na.rm = FALSE 217s na.rm = FALSE 217s na.rm = TRUE 217s na.rm = TRUE 217s na.rm = FALSE 217s na.rm = FALSE 217s na.rm = TRUE 217s na.rm = TRUE 217s special = 0 217s mode: double 217s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 217s na.rm = FALSE 217s na.rm = FALSE 217s na.rm = TRUE 217s na.rm = TRUE 217s na.rm = FALSE 217s na.rm = FALSE 217s na.rm = TRUE 217s na.rm = TRUE 217s special = NA 217s mode: double 217s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 217s na.rm = FALSE 217s na.rm = FALSE 217s na.rm = TRUE 217s na.rm = TRUE 217s na.rm = FALSE 217s na.rm = FALSE 217s na.rm = TRUE 217s na.rm = TRUE 217s special = Inf 217s mode: double 217s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 217s na.rm = FALSE 217s na.rm = FALSE 217s na.rm = TRUE 217s na.rm = TRUE 217s na.rm = FALSE 217s na.rm = FALSE 217s na.rm = TRUE 217s na.rm = TRUE 217s > 217s > 217s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 217s > # All NAs 217s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 217s > for (mode in c("integer", "double")) { 217s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 217s + cat("mode: ", mode, "\n", sep = "") 217s + storage.mode(x) <- mode 217s + str(x) 217s + 217s + # Test with and without dimnames on x 217s + for (setDimnames in c(TRUE, FALSE)) { 217s + if (setDimnames) dimnames(x) <- dimnames 217s + else dimnames(x) <- NULL 217s + # Row/column variance 217s + for (na.rm in c(FALSE, TRUE)) { 217s + # Check names attribute 217s + for (useNames in c(TRUE, FALSE)) { 217s + cat("na.rm = ", na.rm, "\n", sep = "") 217s + 217s + r0 <- rowVars_R(x, na.rm = na.rm, useNames = useNames) 217s + r1 <- rowVars(x, na.rm = na.rm, useNames = useNames) 217s + r1b <- rowVars_center(x, na.rm = na.rm, useNames = useNames) 217s + r2 <- colVars(t(x), na.rm = na.rm, useNames = useNames) 217s + r2b <- colVars_center(t(x), na.rm = na.rm, useNames = useNames) 217s + stopifnot(all.equal(r1, r2)) 217s + stopifnot(all.equal(r1, r0)) 217s + stopifnot(all.equal(r2, r0)) 217s + stopifnot(all.equal(r1b, r2b)) 217s + stopifnot( 217s + !any(is.infinite(r0)), 217s + !any(is.infinite(r1)), 217s + !any(is.infinite(r2)), 217s + !any(is.infinite(r1b)), 217s + !any(is.infinite(r2b)) 217s + ) 217s + } 217s + } 217s + } 217s + } 217s mode: integer 217s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 217s na.rm = FALSE 217s na.rm = FALSE 217s na.rm = TRUE 217s na.rm = TRUE 217s na.rm = FALSE 217s na.rm = FALSE 217s na.rm = TRUE 217s na.rm = TRUE 217s mode: double 217s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 217s na.rm = FALSE 217s na.rm = FALSE 217s na.rm = TRUE 217s na.rm = TRUE 217s na.rm = FALSE 217s na.rm = FALSE 217s na.rm = TRUE 217s na.rm = TRUE 217s > 217s > 217s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 217s > # A 1x1 matrix 217s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 217s > x <- matrix(0, nrow = 1L, ncol = 1L) 217s > dimnames <- list("a", "A") 217s > # Test with and without dimnames on x 217s > for (setDimnames in c(TRUE, FALSE)) { 217s + if (setDimnames) dimnames(x) <- dimnames 217s + else dimnames(x) <- NULL 217s + # Row/column variance 217s + for (na.rm in c(FALSE, TRUE)) { 217s + # Check names attribute 217s + for (useNames in c(TRUE, FALSE)) { 217s + cat("na.rm = ", na.rm, "\n", sep = "") 217s + 217s + r0 <- rowVars_R(x, na.rm = na.rm, useNames = useNames) 217s + r1 <- rowVars(x, na.rm = na.rm, useNames = useNames) 217s + r1b <- rowVars_center(x, na.rm = na.rm, useNames = useNames) 217s + r2 <- colVars(t(x), na.rm = na.rm, useNames = useNames) 217s + r2b <- colVars_center(t(x), na.rm = na.rm, useNames = useNames) 217s + stopifnot(all.equal(r1, r2)) 217s + stopifnot(all.equal(r1, r0)) 217s + stopifnot(all.equal(r2, r0)) 217s + stopifnot(all.equal(r1b, r2b)) 217s + stopifnot( 217s + !any(is.infinite(r0)), 217s + !any(is.infinite(r1)), 217s + !any(is.infinite(r2)), 217s + !any(is.infinite(r1b)), 217s + !any(is.infinite(r2b)) 217s + ) 217s + } 217s + } 217s + } 217s na.rm = FALSE 217s na.rm = FALSE 217s na.rm = TRUE 217s na.rm = TRUE 217s na.rm = FALSE 217s na.rm = FALSE 217s na.rm = TRUE 217s na.rm = TRUE 217s > 217s > 217s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 217s > # center and .dim 217s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 217s > m <- matrix(1:12, nrow = 3L, ncol = 4L) 217s > a <- array(m, dim = c(3, 2, 2)) 217s > stopifnot(prod(dim(a)) == prod(dim(m))) 217s > 217s > y0 <- rowVars(m, dim. = dim(m)) 217s > print(y0) 217s [1] 15 15 15 217s > y1 <- rowVars(a, dim. = dim(m)) 217s > print(y1) 217s [1] 15 15 15 217s > stopifnot(identical(y1, y0)) 217s > stopifnot( 217s + !any(is.infinite(y0)), 217s + !any(is.infinite(y1)) 217s + ) 217s > 217s > mu <- rowMeans(m) 217s > y0 <- rowVars(m, center = mu, dim. = dim(m)) 217s > print(y0) 217s [1] 15 15 15 217s > y1 <- rowVars(a, center = mu, dim. = dim(m)) 217s > print(y1) 217s [1] 15 15 15 217s > stopifnot(identical(y1, y0)) 217s > stopifnot( 217s + !any(is.infinite(y0)), 217s + !any(is.infinite(y1)) 217s + ) 217s > 217s > 217s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 217s > # Corner cases 217s > # https://github.com/HenrikBengtsson/matrixStats/issues/195 217s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 217s > x <- matrix(c(1,2,3,4), nrow = 2L, ncol = 2L) 217s > x[1,1] <- NA_real_ 217s > x[1,2] <- Inf 217s > 217s > center <- colMeans2(x, na.rm = TRUE) 217s > y <- colVars(x, center = center, na.rm = TRUE) 217s > stopifnot(!any(is.infinite(y))) 217s > 217s > x <- t(x) 217s > center <- rowMeans2(x, na.rm = TRUE) 217s > y <- rowVars(x, center = center, na.rm = TRUE) 217s > stopifnot(!any(is.infinite(y))) 217s > 217s 217s R version 4.4.3 (2025-02-28) -- "Trophy Case" 217s Copyright (C) 2025 The R Foundation for Statistical Computing 217s Platform: s390x-ibm-linux-gnu 217s 217s R is free software and comes with ABSOLUTELY NO WARRANTY. 217s You are welcome to redistribute it under certain conditions. 217s Type 'license()' or 'licence()' for distribution details. 217s 217s R is a collaborative project with many contributors. 217s Type 'contributors()' for more information and 217s 'citation()' on how to cite R or R packages in publications. 217s 217s Type 'demo()' for some demos, 'help()' for on-line help, or 217s 'help.start()' for an HTML browser interface to help. 217s Type 'q()' to quit R. 217s 217s > library("matrixStats") 217s > 217s > ## Always allow testing of the 'center' argument (as long as it's not defunct) 217s > options(matrixStats.center.onUse = "ignore") 217s > 217s > ## Create isFALSE() if running on an old version of R 217s > if (!exists("isFALSE", mode="function")) { 217s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 217s + } 217s > 217s > rowVars_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = TRUE) { 217s + suppressWarnings({ 217s + res <- apply(x, MARGIN = 1L, FUN = var, na.rm = na.rm) 217s + }) 217s + stopifnot(!any(is.infinite(res))) 217s + 217s + # Keep naming support consistency same as rowVars() 217s + if (is.null(center) || ncol(x) <= 1L) { 217s + if (isFALSE(useNames)) names(res) <- NULL 217s + } 217s + else if (isFALSE(useNames)) names(res) <- NULL 217s + res 217s + } 217s > 217s > colVars_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = TRUE) { 217s + suppressWarnings({ 217s + res <- apply(x, MARGIN = 2L, FUN = var, na.rm = na.rm) 217s + }) 217s + stopifnot(!any(is.infinite(res))) 217s + 217s + # Keep naming support consistency same as colVars() 217s + if (is.null(center) || nrow(x) <= 1L) { 217s + if (isFALSE(useNames)) names(res) <- NULL 217s + } 217s + else if (isFALSE(useNames)) names(res) <- NULL 217s + res 217s + } 217s > 217s > 217s > rowVars_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 217s + center <- rowWeightedMeans(x, cols = cols, na.rm = na.rm, useNames = FALSE) 217s + res <- rowVars(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 217s + stopifnot(!any(is.infinite(res))) 217s + res 217s + } 217s > 217s > colVars_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 217s + center <- colWeightedMeans(x, rows = rows, na.rm = na.rm, useNames = FALSE) 217s + res <- colVars(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 217s + stopifnot(!any(is.infinite(res))) 217s + res 217s + } 217s > 217s > 217s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 217s > # Subsetted tests 217s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 217s > source("utils/validateIndicesFramework.R") 217s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 217s > storage.mode(x) <- "integer" 217s > 217s > # To check names attribute 217s > dimnames <- list(letters[1:6], LETTERS[1:6]) 217s > 217s > # Test with and without dimnames on x 217s > for (setDimnames in c(TRUE, FALSE)) { 217s + if (setDimnames) dimnames(x) <- dimnames 217s + else dimnames(x) <- NULL 217s + 217s + count <- 0L 217s + for (rows in index_cases) { 217s + for (cols in index_cases) { 217s + count <- count + 1L 217s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 217s + useNames <- c(TRUE, FALSE) 217s + useNames <- useNames[count %% length(useNames) + 1] 217s + 217s + validateIndicesTestMatrix(x, rows, cols, 217s + ftest = rowVars, fsure = rowVars_R, 217s + na.rm = na.rm, useNames = useNames) 217s + validateIndicesTestMatrix(x, rows, cols, 217s + ftest = rowVars_center, fsure = rowVars_R, 217s + na.rm = na.rm, center = TRUE, useNames = useNames) 217s + 217s + validateIndicesTestMatrix(x, rows, cols, 217s + fcoltest = colVars, fsure = rowVars_R, 217s + na.rm = na.rm, useNames = useNames) 217s + validateIndicesTestMatrix(x, rows, cols, 217s + fcoltest = colVars_center, fsure = rowVars_R, 217s + na.rm = na.rm, center = TRUE, useNames = useNames) 217s + } 217s + } 217s + } 218s > 218s 218s R version 4.4.3 (2025-02-28) -- "Trophy Case" 218s Copyright (C) 2025 The R Foundation for Statistical Computing 218s Platform: s390x-ibm-linux-gnu 218s 218s R is free software and comes with ABSOLUTELY NO WARRANTY. 218s You are welcome to redistribute it under certain conditions. 218s Type 'license()' or 'licence()' for distribution details. 218s 218s R is a collaborative project with many contributors. 218s Type 'contributors()' for more information and 218s 'citation()' on how to cite R or R packages in publications. 218s 218s Type 'demo()' for some demos, 'help()' for on-line help, or 218s 'help.start()' for an HTML browser interface to help. 218s Type 'q()' to quit R. 218s 218s > library("matrixStats") 218s > 218s > ## Create isFALSE() if running on an old version of R 218s > if (!exists("isFALSE", mode="function")) { 218s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 218s + } 218s > 218s > rowWeightedMeans_R <- function(x, w, na.rm = FALSE, ..., useNames = TRUE) { 218s + res <- apply(x, MARGIN = 1L, FUN = weighted.mean, w = w, na.rm = na.rm, ...) 218s + 218s + # Keep naming support consistency same as rowWeightedMeans() 218s + idxs <- which(is.na(w) | w != 0) 218s + nw <- length(idxs) 218s + if (na.rm) na.rm <- anyMissing(x) 218s + if ((!is.null(w) && nw == 0L) || isFALSE(na.rm)) { 218s + if (!useNames) names(res) <- NULL 218s + } 218s + else if (isFALSE(useNames)) names(res) <- NULL 218s + 218s + res 218s + } 218s > 218s > colWeightedMeans_R <- function(x, w, na.rm = FALSE, ..., useNames = TRUE) { 218s + res <- apply(x, MARGIN = 2L, FUN = weighted.mean, w = w, na.rm = na.rm, ...) 218s + 218s + # Keep naming support consistency same as colWeightedMeans() 218s + idxs <- which(is.na(w) | w != 0) 218s + nw <- length(idxs) 218s + if (!is.null(w) && nw == 0L) { 218s + if (!useNames) names(res) <- NULL 218s + } 218s + else if (isFALSE(useNames)) names(res) <- NULL 218s + 218s + res 218s + } 218s > 218s > set.seed(1) 218s > 218s > x <- matrix(rnorm(20), nrow = 5, ncol = 4) 218s > print(x) 218s [,1] [,2] [,3] [,4] 218s [1,] -0.6264538 -0.8204684 1.5117812 -0.04493361 218s [2,] 0.1836433 0.4874291 0.3898432 -0.01619026 218s [3,] -0.8356286 0.7383247 -0.6212406 0.94383621 218s [4,] 1.5952808 0.5757814 -2.2146999 0.82122120 218s [5,] 0.3295078 -0.3053884 1.1249309 0.59390132 218s > 218s > # To check names attribute 218s > dimnames <- list(letters[1:5], LETTERS[1:4]) 218s > 218s > # Non-weighted row averages 218s > x_est0 <- rowMeans(x) 218s > x_est1 <- rowWeightedMeans(x) 218s > print(x_est1) 218s [1] 0.004981341 0.261181337 0.056322931 0.194395865 0.435737906 218s > stopifnot(all.equal(x_est1, x_est0)) 218s > x_est2 <- colWeightedMeans(t(x)) 218s > stopifnot(all.equal(x_est2, x_est0)) 218s > # Check names attribute 218s > dimnames(x) <- dimnames 218s > x_est1 <- rowWeightedMeans(x, useNames = FALSE) 218s > x_est2 <- colWeightedMeans(t(x), useNames = FALSE) 218s > stopifnot(all.equal(x_est1, x_est0)) 218s > stopifnot(all.equal(x_est2, x_est0)) 218s > x_est0 <- rowMeans(x) 218s > x_est1 <- rowWeightedMeans(x, useNames = TRUE) 218s > x_est2 <- colWeightedMeans(t(x), useNames = TRUE) 218s > stopifnot(all.equal(x_est1, x_est0)) 218s > stopifnot(all.equal(x_est2, x_est0)) 218s > dimnames(x) <- NULL 218s > 218s > 218s > # Weighted row averages (uniform weights) 218s > w <- rep(2.5, times = ncol(x)) 218s > x_est0 <- rowMeans(x) 218s > x_est1 <- rowWeightedMeans(x, w = w) 218s > print(x_est1) 218s [1] 0.004981341 0.261181337 0.056322931 0.194395865 0.435737906 218s > stopifnot(all.equal(x_est1, x_est0)) 218s > x_est2 <- colWeightedMeans(t(x), w = w) 218s > stopifnot(all.equal(x_est2, x_est0)) 218s > # Test with and without dimnames on x 218s > for (setDimnames in c(TRUE, FALSE)) { 218s + if (setDimnames) dimnames(x) <- dimnames 218s + else dimnames(x) <- NULL 218s + # Check names attribute 218s + for (useNames in c(TRUE, FALSE)) { 218s + x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames) 218s + x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames) 218s + stopifnot(all.equal(x_est1, x_est0)) 218s + x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames) 218s + x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames) 218s + stopifnot(all.equal(x_est1, x_est0)) 218s + } 218s + } 218s > 218s > 218s > # Weighted row averages (excluding some columns) 218s > w <- c(1, 1, 0, 1) 218s > x_est0 <- rowMeans(x[, (w == 1), drop = FALSE]) 218s > x_est1 <- rowWeightedMeans(x, w = w) 218s > print(x_est1) 218s [1] -0.4972853 0.2182940 0.2821774 0.9974278 0.2060069 218s > stopifnot(all.equal(x_est1, x_est0)) 218s > x_est2 <- colWeightedMeans(t(x), w = w) 218s > stopifnot(all.equal(x_est2, x_est0)) 218s > # Test with and without dimnames on x 218s > for (setDimnames in c(TRUE, FALSE)) { 218s + if (setDimnames) dimnames(x) <- dimnames 218s + else dimnames(x) <- NULL 218s + # Check names attribute 218s + for (useNames in c(TRUE, FALSE)) { 218s + x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames) 218s + x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames) 218s + stopifnot(all.equal(x_est1, x_est0)) 218s + x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames) 218s + x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames) 218s + stopifnot(all.equal(x_est1, x_est0)) 218s + } 218s + } 218s > 218s > 218s > # Weighted row averages (excluding some columns) 218s > w <- c(0, 1, 0, 0) 218s > x_est0 <- rowMeans(x[, (w == 1), drop = FALSE]) 218s > x_est1 <- rowWeightedMeans(x, w = w) 218s > stopifnot(all.equal(x_est1, x_est0)) 218s > x_est2 <- colWeightedMeans(t(x), w = w) 218s > stopifnot(all.equal(x_est2, x_est0)) 218s > # Test with and without dimnames on x 218s > for (setDimnames in c(TRUE, FALSE)) { 218s + if (setDimnames) dimnames(x) <- dimnames 218s + else dimnames(x) <- NULL 218s + # Check names attribute 218s + for (useNames in c(TRUE, FALSE)) { 218s + x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames) 218s + x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames) 218s + stopifnot(all.equal(x_est1, x_est0)) 218s + x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames) 218s + x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames) 218s + stopifnot(all.equal(x_est1, x_est0)) 218s + } 218s + } 218s > 218s > 218s > # Weighted row averages (all zero weights) 218s > w <- c(0, 0, 0, 0) 218s > x_est0 <- rowMeans(x[, (w == 1), drop = FALSE]) 218s > x_est1 <- rowWeightedMeans(x, w = w) 218s > stopifnot(all.equal(x_est1, x_est0)) 218s > x_est2 <- colWeightedMeans(t(x), w = w) 218s > stopifnot(all.equal(x_est2, x_est0)) 218s > # Test with and without dimnames on x 218s > for (setDimnames in c(TRUE, FALSE)) { 218s + if (setDimnames) dimnames(x) <- dimnames 218s + else dimnames(x) <- NULL 218s + # Check names attribute 218s + for (useNames in c(TRUE, FALSE)) { 218s + x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames) 218s + x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames) 218s + stopifnot(all.equal(x_est1, x_est0)) 218s + x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames) 218s + x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames) 218s + stopifnot(all.equal(x_est1, x_est0)) 218s + } 218s + } 218s > 218s > 218s > # Weighted averages by rows and columns 218s > w <- 1:4 218s > x_est1 <- rowWeightedMeans(x, w = w) 218s > print(x_est1) 218s [1] 0.20882185 0.22632701 0.25526439 -0.06123714 0.54691290 218s > x_est2 <- colWeightedMeans(t(x), w = w) 218s > stopifnot(all.equal(x_est2, x_est1)) 218s > # Test with and without dimnames on x 218s > for (setDimnames in c(TRUE, FALSE)) { 218s + if (setDimnames) dimnames(x) <- dimnames 218s + else dimnames(x) <- NULL 218s + # Check names attribute 218s + for (useNames in c(TRUE, FALSE)) { 218s + x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames) 218s + x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames) 218s + stopifnot(all.equal(x_est1, x_est0)) 218s + x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames) 218s + x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames) 218s + stopifnot(all.equal(x_est1, x_est0)) 218s + } 218s + } 218s > 218s > 218s > x[sample(length(x), size = 0.3 * length(x))] <- NA 218s > print(x) 218s [,1] [,2] [,3] [,4] 218s [1,] -0.6264538 NA 1.5117812 -0.04493361 218s [2,] 0.1836433 NA NA -0.01619026 218s [3,] -0.8356286 0.7383247 -0.6212406 0.94383621 218s [4,] 1.5952808 NA -2.2146999 0.82122120 218s [5,] 0.3295078 NA NA 0.59390132 218s > 218s > # Non-weighted row averages with missing values 218s > x_est0 <- rowMeans(x, na.rm = TRUE) 218s > x_est1 <- rowWeightedMeans(x, na.rm = TRUE) 218s > print(x_est1) 218s [1] 0.28013125 0.08372653 0.05632293 0.06726737 0.46170455 218s > stopifnot(all.equal(x_est1, x_est0)) 218s > x_est2 <- colWeightedMeans(t(x), na.rm = TRUE) 218s > stopifnot(all.equal(x_est2, x_est0)) 218s > # Check names attribute 218s > dimnames(x) <- dimnames 218s > x_est1 <- rowWeightedMeans(x, na.rm = TRUE, useNames = FALSE) 218s > x_est2 <- colWeightedMeans(t(x), na.rm = TRUE, useNames = FALSE) 218s > stopifnot(all.equal(x_est1, x_est0)) 218s > stopifnot(all.equal(x_est2, x_est0)) 218s > x_est0 <- rowMeans(x, na.rm = TRUE) 218s > x_est1 <- rowWeightedMeans(x, na.rm = TRUE, useNames = TRUE) 218s > x_est2 <- colWeightedMeans(t(x), na.rm = TRUE, useNames = TRUE) 218s > stopifnot(all.equal(x_est1, x_est0)) 218s > stopifnot(all.equal(x_est2, x_est0)) 218s > dimnames(x) <- NULL 218s > 218s > 218s > # Weighted row averages with missing values 218s > x_est0 <- apply(x, MARGIN = 1L, FUN = weighted.mean, w = w, na.rm = TRUE) 218s > print(x_est0) 218s [1] 0.46614441 0.02377645 0.25526439 -0.22049176 0.54102261 218s > x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE) 218s > print(x_est1) 218s [1] 0.46614441 0.02377645 0.25526439 -0.22049176 0.54102261 218s > stopifnot(all.equal(x_est1, x_est0)) 218s > x_est2 <- colWeightedMeans(t(x), w = w, na.rm = TRUE) 218s > stopifnot(all.equal(x_est2, x_est0)) 218s > # Test with and without dimnames on x 218s > for (setDimnames in c(TRUE, FALSE)) { 218s + if (setDimnames) dimnames(x) <- dimnames 218s + else dimnames(x) <- NULL 218s + # Check names attribute 218s + for (useNames in c(TRUE, FALSE)) { 218s + x_est0 <- rowWeightedMeans_R(x, w = w, na.rm = TRUE, useNames = useNames) 218s + x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE, useNames = useNames) 218s + stopifnot(all.equal(x_est1, x_est0)) 218s + x_est0 <- colWeightedMeans_R(t(x), w = w, na.rm = TRUE, useNames = useNames) 218s + x_est1 <- colWeightedMeans(t(x), w = w, na.rm = TRUE, useNames = useNames) 218s + stopifnot(all.equal(x_est1, x_est0)) 218s + } 218s + } 218s > 218s > 218s > # Weighted averages by rows and columns 218s > w <- 1:4 218s > x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE) 218s > x_est2 <- colWeightedMeans(t(x), w = w, na.rm = TRUE) 218s > stopifnot(all.equal(x_est2, x_est1)) 218s > # Test with and without dimnames on x 218s > for (setDimnames in c(TRUE, FALSE)) { 218s + if (setDimnames) dimnames(x) <- dimnames 218s + else dimnames(x) <- NULL 218s + # Check names attribute 218s + for (useNames in c(TRUE, FALSE)) { 218s + x_est0 <- rowWeightedMeans_R(x, w = w, na.rm = TRUE, useNames = useNames) 218s + x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE, useNames = useNames) 218s + stopifnot(all.equal(x_est1, x_est0)) 218s + x_est0 <- colWeightedMeans_R(t(x), w = w, na.rm = TRUE, useNames = useNames) 218s + x_est1 <- colWeightedMeans(t(x), w = w, na.rm = TRUE, useNames = useNames) 218s + stopifnot(all.equal(x_est1, x_est0)) 218s + } 218s + } 218s > 218s > 218s > # w contains missing value 218s > w[1] <- NA_integer_ 218s > x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE) 218s > x_est2 <- colWeightedMeans(t(x), w = w, na.rm = TRUE) 218s > stopifnot(all.equal(x_est2, x_est1)) 218s > # Test with and without dimnames on x 218s > for (setDimnames in c(TRUE, FALSE)) { 218s + if (setDimnames) dimnames(x) <- dimnames 218s + else dimnames(x) <- NULL 218s + # Check names attribute 218s + for (useNames in c(TRUE, FALSE)) { 218s + x_est0 <- rowWeightedMeans_R(x, w = w, na.rm = TRUE, useNames = useNames) 218s + x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE, useNames = useNames) 218s + stopifnot(all.equal(x_est1, x_est0)) 218s + x_est0 <- colWeightedMeans_R(t(x), w = w, na.rm = TRUE, useNames = useNames) 218s + x_est1 <- colWeightedMeans(t(x), w = w, na.rm = TRUE, useNames = useNames) 218s + stopifnot(all.equal(x_est1, x_est0)) 218s + } 218s + } 218s > 218s > x_est1 <- rowWeightedMeans(x, w = w, na.rm = FALSE) 218s > x_est2 <- colWeightedMeans(t(x), w = w, na.rm = FALSE) 218s > stopifnot(all.equal(x_est2, x_est1)) 218s > # Test with and without dimnames on x 218s > for (setDimnames in c(TRUE, FALSE)) { 218s + if (setDimnames) dimnames(x) <- dimnames 218s + else dimnames(x) <- NULL 218s + # Check names attribute 218s + for (useNames in c(TRUE, FALSE)) { 218s + x_est0 <- rowWeightedMeans_R(x, w = w, na.rm = FALSE, useNames = useNames) 218s + x_est1 <- rowWeightedMeans(x, w = w, na.rm = FALSE, useNames = useNames) 218s + stopifnot(all.equal(x_est1, x_est0)) 218s + x_est0 <- colWeightedMeans_R(t(x), w = w, na.rm = FALSE, useNames = useNames) 218s + x_est1 <- colWeightedMeans(t(x), w = w, na.rm = FALSE, useNames = useNames) 218s + stopifnot(all.equal(x_est1, x_est0)) 218s + } 218s + } 218s > 218s 218s R version 4.4.3 (2025-02-28) -- "Trophy Case" 218s Copyright (C) 2025 The R Foundation for Statistical Computing 218s Platform: s390x-ibm-linux-gnu 218s 218s R is free software and comes with ABSOLUTELY NO WARRANTY. 218s You are welcome to redistribute it under certain conditions. 218s Type 'license()' or 'licence()' for distribution details. 218s 218s R is a collaborative project with many contributors. 218s Type 'contributors()' for more information and 218s 'citation()' on how to cite R or R packages in publications. 218s 218s Type 'demo()' for some demos, 'help()' for on-line help, or 218s 'help.start()' for an HTML browser interface to help. 218s Type 'q()' to quit R. 218s 218s > library("matrixStats") 218s > 218s > ## Create isFALSE() if running on an old version of R 218s > if (!exists("isFALSE", mode="function")) { 218s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 218s + } 218s > 218s > rowWeightedMeans_R <- function(x, w, na.rm = FALSE, ..., useNames = TRUE) { 218s + res <- apply(x, MARGIN = 1L, FUN = weighted.mean, w = w, na.rm = na.rm, ...) 218s + 218s + # Keep naming support consistency same as rowWeightedMeans() 218s + idxs <- which(is.na(w) | w != 0) 218s + nw <- length(idxs) 218s + if (na.rm) na.rm <- anyMissing(x) 218s + if ((!is.null(w) && nw == 0L) || isFALSE(na.rm)) { 218s + if (!useNames) names(res) <- NULL 218s + } 218s + else if (isFALSE(useNames)) names(res) <- NULL 218s + 218s + res 218s + } 218s > 218s > colWeightedMeans_R <- function(x, w, na.rm = FALSE, ..., useNames = TRUE) { 218s + res <- apply(x, MARGIN = 1L, FUN = weighted.mean, w = w, na.rm = na.rm, ...) 218s + 218s + # Keep naming support consistency same as colWeightedMeans() 218s + idxs <- which(is.na(w) | w != 0) 218s + nw <- length(idxs) 218s + if (!is.null(w) && nw == 0L) { 218s + if (!useNames) names(res) <- NULL 218s + } 218s + else if (isFALSE(useNames)) names(res) <- NULL 218s + 218s + res 218s + } 218s > 218s > 218s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 218s > # Subsetted tests 218s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 218s > source("utils/validateIndicesFramework.R") 218s > # To check names attribute 218s > dimnames <- list(letters[1:6], LETTERS[1:6]) 218s > for (mode in c("numeric", "integer", "logical")) { 218s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 218s + w <- runif(6, min = 0, max = 6) 218s + storage.mode(x) <- mode 218s + storage.mode(w) <- if (mode == "logical") "integer" else mode 218s + if (mode == "numeric") w[1] <- Inf 218s + 218s + # Test with and without dimnames on x 218s + for (setDimnames in c(TRUE, FALSE)) { 218s + if (setDimnames) dimnames(x) <- dimnames 218s + else dimnames(x) <- NULL 218s + 218s + count <- 0L 218s + for (rows in index_cases) { 218s + for (cols in index_cases) { 218s + count <- count + 1L 218s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 218s + useNames <- c(TRUE, FALSE) 218s + useNames <- useNames[count %% length(useNames) + 1] 218s + 218s + validateIndicesTestMatrix_w(x, w, rows, cols, 218s + ftest = rowWeightedMeans, fsure = rowWeightedMeans_R, 218s + na.rm = na.rm, useNames = useNames) 218s + validateIndicesTestMatrix_w(x, w, rows, cols, 218s + fcoltest = colWeightedMeans, fsure = colWeightedMeans_R, 218s + na.rm = na.rm, useNames = useNames) 218s + } 218s + } 218s + } 218s + } 219s > 219s 219s R version 4.4.3 (2025-02-28) -- "Trophy Case" 219s Copyright (C) 2025 The R Foundation for Statistical Computing 219s Platform: s390x-ibm-linux-gnu 219s 219s R is free software and comes with ABSOLUTELY NO WARRANTY. 219s You are welcome to redistribute it under certain conditions. 219s Type 'license()' or 'licence()' for distribution details. 219s 219s R is a collaborative project with many contributors. 219s Type 'contributors()' for more information and 219s 'citation()' on how to cite R or R packages in publications. 219s 219s Type 'demo()' for some demos, 'help()' for on-line help, or 219s 'help.start()' for an HTML browser interface to help. 219s Type 'q()' to quit R. 219s 219s > library("matrixStats") 219s > 219s > ## Create isFALSE() if running on an old version of R 219s > if (!exists("isFALSE", mode="function")) { 219s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 219s + } 219s > 219s > rowWeightedMedians_R <- function(x, w, na.rm = FALSE, ..., useNames = TRUE) { 219s + res <- apply(x, MARGIN = 1L, FUN = weightedMedian, w = w, na.rm = na.rm, ...) 219s + 219s + # Keep naming support consistency same as rowWeightedMedians() 219s + if (!is.null(w)) { 219s + if (isFALSE(useNames)) names(res) <- NULL 219s + } 219s + else if (!useNames) names(res) <- NULL 219s + 219s + res 219s + } 219s > 219s > colWeightedMedians_R <- function(x, w, na.rm = FALSE, ..., useNames = TRUE) { 219s + res <- apply(x, MARGIN = 2L, FUN = weightedMedian, w = w, na.rm = na.rm, ...) 219s + 219s + # Keep naming support consistency same as colWeightedMedians() 219s + if (!is.null(w)) { 219s + if (isFALSE(useNames)) names(res) <- NULL 219s + } 219s + else if (!useNames) names(res) <- NULL 219s + 219s + res 219s + } 219s > 219s > set.seed(1) 219s > 219s > x <- matrix(rnorm(20), nrow = 5, ncol = 4) 219s > print(x) 219s [,1] [,2] [,3] [,4] 219s [1,] -0.6264538 -0.8204684 1.5117812 -0.04493361 219s [2,] 0.1836433 0.4874291 0.3898432 -0.01619026 219s [3,] -0.8356286 0.7383247 -0.6212406 0.94383621 219s [4,] 1.5952808 0.5757814 -2.2146999 0.82122120 219s [5,] 0.3295078 -0.3053884 1.1249309 0.59390132 219s > 219s > # To check names attribute 219s > dimnames <- list(letters[1:5], LETTERS[1:4]) 219s > 219s > # Non-weighted row medians 219s > x_est0 <- rowMedians(x) 219s > x_est1 <- rowWeightedMedians(x) 219s > stopifnot(all.equal(x_est1, x_est0)) 219s > x_est2 <- colWeightedMedians(t(x)) 219s > stopifnot(all.equal(x_est2, x_est0)) 219s > # Test with and without dimnames on x 219s > for (setDimnames in c(TRUE, FALSE)) { 219s + if (setDimnames) dimnames(x) <- dimnames 219s + else dimnames(x) <- NULL 219s + # Check names attribute 219s + for (useNames in c(TRUE, FALSE)) { 219s + x_est0 <- rowMedians(x, useNames = useNames) 219s + x_est1 <- rowWeightedMedians(x, useNames = useNames) 219s + x_est2 <- colWeightedMedians(t(x), useNames = useNames) 219s + stopifnot(all.equal(x_est1, x_est0)) 219s + stopifnot(all.equal(x_est2, x_est0)) 219s + } 219s + } 219s > 219s > 219s > # Weighted row medians (uniform weights) 219s > w <- rep(2.5, times = ncol(x)) 219s > x_est0 <- rowMedians(x) 219s > x_est1 <- rowWeightedMedians(x, w = w) 219s > stopifnot(all.equal(x_est1, x_est0)) 219s > x_est2 <- colWeightedMedians(t(x), w = w) 219s > stopifnot(all.equal(x_est2, x_est0)) 219s > # Test with and without dimnames on x 219s > for (setDimnames in c(TRUE, FALSE)) { 219s + if (setDimnames) dimnames(x) <- dimnames 219s + else dimnames(x) <- NULL 219s + # Check names attribute 219s + for (useNames in c(TRUE, FALSE)) { 219s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 219s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 219s + stopifnot(all.equal(x_est1, x_est0)) 219s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 219s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 219s + stopifnot(all.equal(x_est1, x_est0)) 219s + } 219s + } 219s > 219s > 219s > # Weighted row medians (excluding some columns) 219s > w <- c(1, 1, 0, 1) 219s > x_est0 <- rowMedians(x[, (w == 1), drop = FALSE]) 219s > x_est1 <- rowWeightedMedians(x, w = w) 219s > stopifnot(all.equal(x_est1, x_est0)) 219s > x_est2 <- colWeightedMedians(t(x), w = w) 219s > stopifnot(all.equal(x_est2, x_est0)) 219s > # Test with and without dimnames on x 219s > for (setDimnames in c(TRUE, FALSE)) { 219s + if (setDimnames) dimnames(x) <- dimnames 219s + else dimnames(x) <- NULL 219s + # Check names attribute 219s + for (useNames in c(TRUE, FALSE)) { 219s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 219s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 219s + stopifnot(all.equal(x_est1, x_est0)) 219s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 219s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 219s + stopifnot(all.equal(x_est1, x_est0)) 219s + } 219s + } 219s > 219s > # Weighted row medians (excluding some columns) 219s > w <- c(0, 1, 0, 0) 219s > x_est0 <- rowMedians(x[, (w == 1), drop = FALSE]) 219s > x_est1 <- rowWeightedMedians(x, w = w) 219s > stopifnot(all.equal(x_est1, x_est0)) 219s > x_est2 <- colWeightedMedians(t(x), w = w) 219s > stopifnot(all.equal(x_est2, x_est0)) 219s > # Test with and without dimnames on x 219s > for (setDimnames in c(TRUE, FALSE)) { 219s + if (setDimnames) dimnames(x) <- dimnames 219s + else dimnames(x) <- NULL 219s + # Check names attribute 219s + for (useNames in c(TRUE, FALSE)) { 219s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 219s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 219s + stopifnot(all.equal(x_est1, x_est0)) 219s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 219s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 219s + stopifnot(all.equal(x_est1, x_est0)) 219s + } 219s + } 219s > 219s > # Weighted row medians (all zero weights) 219s > w <- c(0, 0, 0, 0) 219s > x_est0 <- rowMedians(x[, (w == 1), drop = FALSE]) 219s > x_est1 <- rowWeightedMedians(x, w = w) 219s > stopifnot(all.equal(x_est1, x_est0)) 219s > x_est2 <- colWeightedMedians(t(x), w = w) 219s > stopifnot(all.equal(x_est2, x_est0)) 219s > # Test with and without dimnames on x 219s > for (setDimnames in c(TRUE, FALSE)) { 219s + if (setDimnames) dimnames(x) <- dimnames 219s + else dimnames(x) <- NULL 219s + # Check names attribute 219s + for (useNames in c(TRUE, FALSE)) { 219s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 219s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 219s + stopifnot(all.equal(x_est1, x_est0)) 219s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 219s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 219s + stopifnot(all.equal(x_est1, x_est0)) 219s + } 219s + } 219s > 219s > # Weighted medians by rows and columns 219s > w <- 1:4 219s > x_est1 <- rowWeightedMedians(x, w = w) 219s > x_est2 <- colWeightedMedians(t(x), w = w) 219s > stopifnot(all.equal(x_est2, x_est1)) 219s > # Test with and without dimnames on x 219s > for (setDimnames in c(TRUE, FALSE)) { 219s + if (setDimnames) dimnames(x) <- dimnames 219s + else dimnames(x) <- NULL 219s + # Check names attribute 219s + for (useNames in c(TRUE, FALSE)) { 219s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 219s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 219s + stopifnot(all.equal(x_est1, x_est0)) 219s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 219s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 219s + stopifnot(all.equal(x_est1, x_est0)) 219s + } 219s + } 219s > 219s > 219s > # Weighted row medians with missing values 219s > x_est0 <- apply(x, MARGIN = 1L, FUN = weightedMedian, w = w, na.rm = TRUE) 219s > print(x_est0) 219s [1] -0.04493361 0.23519330 0.73832471 0.65759463 0.59390132 219s > x_est1 <- rowWeightedMedians(x, w = w, na.rm = TRUE) 219s > print(x_est1) 219s [1] -0.04493361 0.23519330 0.73832471 0.65759463 0.59390132 219s > stopifnot(all.equal(x_est1, x_est0)) 219s > x_est2 <- colWeightedMedians(t(x), w = w) 219s > stopifnot(all.equal(x_est2, x_est0)) 219s > # Test with and without dimnames on x 219s > for (setDimnames in c(TRUE, FALSE)) { 219s + if (setDimnames) dimnames(x) <- dimnames 219s + else dimnames(x) <- NULL 219s + # Check names attribute 219s + for (useNames in c(TRUE, FALSE)) { 219s + x_est0 <- rowWeightedMedians_R(x, w = w, na.rm = TRUE, useNames = useNames) 219s + x_est1 <- rowWeightedMedians(x, w = w, na.rm = TRUE, useNames = useNames) 219s + stopifnot(all.equal(x_est1, x_est0)) 219s + x_est0 <- colWeightedMedians_R(t(x), w = w, na.rm = TRUE, useNames = useNames) 219s + x_est1 <- colWeightedMedians(t(x), w = w, na.rm = TRUE, useNames = useNames) 219s + stopifnot(all.equal(x_est1, x_est0)) 219s + } 219s + } 219s > 219s > # Weighted medians by rows and columns 219s > w <- 1:4 219s > x_est1 <- rowWeightedMedians(x, w = w, na.rm = TRUE) 219s > x_est2 <- colWeightedMedians(t(x), w = w, na.rm = TRUE) 219s > stopifnot(all.equal(x_est2, x_est1)) 219s > # Test with and without dimnames on x 219s > for (setDimnames in c(TRUE, FALSE)) { 219s + if (setDimnames) dimnames(x) <- dimnames 219s + else dimnames(x) <- NULL 219s + # Check names attribute 219s + for (useNames in c(TRUE, FALSE)) { 219s + x_est0 <- rowWeightedMedians_R(x, w = w, na.rm = TRUE, useNames = useNames) 219s + x_est1 <- rowWeightedMedians(x, w = w, na.rm = TRUE, useNames = useNames) 219s + stopifnot(all.equal(x_est1, x_est0)) 219s + x_est0 <- colWeightedMedians_R(t(x), w = w, na.rm = TRUE, useNames = useNames) 219s + x_est1 <- colWeightedMedians(t(x), w = w, na.rm = TRUE, useNames = useNames) 219s + stopifnot(all.equal(x_est1, x_est0)) 219s + } 219s + } 219s > 219s > 219s > # Inf weight 219s > x <- matrix(1:2, nrow = 1, ncol = 2) 219s > w <- c(7, Inf) 219s > x_est1 <- rowWeightedMedians(x, w = w) 219s > x_est2 <- colWeightedMedians(t(x), w = w) 219s > stopifnot(identical(2, x_est1)) 219s > stopifnot(identical(2, x_est2)) 219s > # Test with and without dimnames on x 219s > dimnames <- list("a", LETTERS[1:2]) 219s > for (setDimnames in c(TRUE, FALSE)) { 219s + if (setDimnames) dimnames(x) <- dimnames 219s + else dimnames(x) <- NULL 219s + # Check names attribute 219s + for (useNames in c(TRUE, FALSE)) { 219s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 219s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 219s + stopifnot(all.equal(x_est1, x_est0)) 219s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 219s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 219s + stopifnot(all.equal(x_est1, x_est0)) 219s + } 219s + } 219s > 219s 219s R version 4.4.3 (2025-02-28) -- "Trophy Case" 219s Copyright (C) 2025 The R Foundation for Statistical Computing 219s Platform: s390x-ibm-linux-gnu 219s 219s R is free software and comes with ABSOLUTELY NO WARRANTY. 219s You are welcome to redistribute it under certain conditions. 219s Type 'license()' or 'licence()' for distribution details. 219s 219s R is a collaborative project with many contributors. 219s Type 'contributors()' for more information and 219s 'citation()' on how to cite R or R packages in publications. 219s 219s Type 'demo()' for some demos, 'help()' for on-line help, or 219s 'help.start()' for an HTML browser interface to help. 219s Type 'q()' to quit R. 219s 219s > library("matrixStats") 219s > 219s > ## Create isFALSE() if running on an old version of R 219s > if (!exists("isFALSE", mode="function")) { 219s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 219s + } 219s > 219s > rowWeightedMedians_R <- function(x, w, na.rm = FALSE, ..., useNames = TRUE) { 219s + res <- apply(x, MARGIN = 1L, FUN = weightedMedian, w = w, na.rm = na.rm, ...) 219s + 219s + # Keep naming support consistency same as rowWeightedMedians() 219s + if (!is.null(w)) { 219s + if (isFALSE(useNames)) names(res) <- NULL 219s + } 219s + else if (!useNames) names(res) <- NULL 219s + 219s + res 219s + } 219s > 219s > 219s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 219s > # Subsetted tests 219s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 219s > source("utils/validateIndicesFramework.R") 220s > # To check names attribute 220s > dimnames <- list(letters[1:6], LETTERS[1:6]) 220s > for (mode in c("numeric", "integer", "logical")) { 220s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 220s + w <- runif(6, min = 0, max = 6) 220s + storage.mode(x) <- mode 220s + storage.mode(w) <- if (mode == "logical") "integer" else mode 220s + if (mode == "numeric") w[1] <- Inf 220s + 220s + # Test with and without dimnames on x 220s + for (setDimnames in c(TRUE, FALSE)) { 220s + if (setDimnames) dimnames(x) <- dimnames 220s + else dimnames(x) <- NULL 220s + 220s + count <- 0L 220s + for (rows in index_cases) { 220s + for (cols in index_cases) { 220s + count <- count + 1L 220s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 220s + useNames <- c(TRUE, FALSE) 220s + useNames <- useNames[count %% length(useNames) + 1] 220s + 220s + validateIndicesTestMatrix_w(x, w, rows, cols, 220s + ftest = rowWeightedMedians, 220s + fsure = rowWeightedMedians_R, 220s + na.rm = na.rm, useNames = useNames) 220s + validateIndicesTestMatrix_w(x, w, rows, cols, 220s + fcoltest = colWeightedMedians, 220s + fsure = rowWeightedMedians_R, 220s + na.rm = na.rm, useNames = useNames) 220s + } 220s + } 220s + } 220s + } 220s > 220s 220s R version 4.4.3 (2025-02-28) -- "Trophy Case" 220s Copyright (C) 2025 The R Foundation for Statistical Computing 220s Platform: s390x-ibm-linux-gnu 220s 220s R is free software and comes with ABSOLUTELY NO WARRANTY. 220s You are welcome to redistribute it under certain conditions. 220s Type 'license()' or 'licence()' for distribution details. 220s 220s R is a collaborative project with many contributors. 220s Type 'contributors()' for more information and 220s 'citation()' on how to cite R or R packages in publications. 220s 220s Type 'demo()' for some demos, 'help()' for on-line help, or 220s 'help.start()' for an HTML browser interface to help. 220s Type 'q()' to quit R. 220s 220s > library("matrixStats") 220s > 220s > set.seed(1) 220s > 220s > x <- matrix(rnorm(20), nrow = 5L, ncol = 4L) 220s > print(x) 220s [,1] [,2] [,3] [,4] 220s [1,] -0.6264538 -0.8204684 1.5117812 -0.04493361 220s [2,] 0.1836433 0.4874291 0.3898432 -0.01619026 220s [3,] -0.8356286 0.7383247 -0.6212406 0.94383621 220s [4,] 1.5952808 0.5757814 -2.2146999 0.82122120 220s [5,] 0.3295078 -0.3053884 1.1249309 0.59390132 220s > 220s > # To check names attribute 220s > dimnames <- list(letters[1:5], LETTERS[1:4]) 220s > 220s > # Weighted row variances (uniform weights - all w = 1) 220s > # Non-weighted row variances 220s > x_est0 <- rowVars(x) 220s > w <- rep(1, times = ncol(x)) 220s > x_est1 <- rowWeightedVars(x, w = w) 220s > print(x_est1) 220s [1] 1.11767161 0.05022969 0.83582537 2.76819528 0.35351857 220s > stopifnot(all.equal(x_est1, x_est0)) 220s > x_est2 <- colWeightedVars(t(x), w = w) 220s > stopifnot(all.equal(x_est2, x_est0)) 220s > # Check names attribute 220s > dimnames(x) <- dimnames 220s > x_est1 <- rowWeightedVars(x, w = w, useNames = FALSE) 220s > x_est2 <- colWeightedVars(t(x), w = w, useNames = FALSE) 220s > stopifnot(all.equal(x_est1, x_est0)) 220s > stopifnot(all.equal(x_est2, x_est0)) 220s > x_est0 <- rowVars(x, useNames = TRUE) 220s > x_est1 <- rowWeightedVars(x, w = w, useNames = TRUE) 220s > x_est2 <- colWeightedVars(t(x), w = w, useNames = TRUE) 220s > stopifnot(all.equal(x_est1, x_est0)) 220s > stopifnot(all.equal(x_est2, x_est0)) 220s > dimnames(x) <- NULL 220s > 220s > 220s > # Weighted row variances (uniform weights - all w = 3) 220s > x3 <- cbind(x, x, x) 220s > x_est0 <- rowVars(x3) 220s > w <- rep(3, times = ncol(x)) 220s > x_est1 <- rowWeightedVars(x, w = w) 220s > print(x_est1) 220s [1] 0.91445859 0.04109702 0.68385712 2.26488705 0.28924246 220s > stopifnot(all.equal(x_est1, x_est0)) 220s > x_est2 <- colWeightedVars(t(x), w = w) 220s > stopifnot(all.equal(x_est2, x_est0)) 220s > # Check names attribute 220s > dimnames(x) <- dimnames 220s > x_est1 <- rowWeightedVars(x, w = w, useNames = FALSE) 220s > x_est2 <- colWeightedVars(t(x), w = w, useNames = FALSE) 220s > stopifnot(all.equal(x_est1, x_est0)) 220s > stopifnot(all.equal(x_est2, x_est0)) 220s > x3 <- cbind(x, x, x) 220s > x_est0 <- rowVars(x3, useNames = TRUE) 220s > x_est1 <- rowWeightedVars(x, w = w, useNames = TRUE) 220s > x_est2 <- colWeightedVars(t(x), w = w, useNames = TRUE) 220s > stopifnot(all.equal(x_est1, x_est0)) 220s > stopifnot(all.equal(x_est2, x_est0)) 220s > dimnames(x) <- NULL 220s > 220s > 220s > # Weighted row variances (excluding some columns) 220s > w <- c(1, 1, 0, 1) 220s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE]) 220s > x_est1 <- rowWeightedVars(x, w = w) 220s > print(x_est1) 220s [1] 0.16287693 0.06430861 0.94767651 0.28313135 0.21361984 220s > stopifnot(all.equal(x_est1, x_est0)) 220s > x_est2 <- colWeightedVars(t(x), w = w) 220s > stopifnot(all.equal(x_est2, x_est0)) 220s > # Check names attribute 220s > dimnames(x) <- dimnames 220s > x_est1 <- rowWeightedVars(x, w = w, useNames = FALSE) 220s > x_est2 <- colWeightedVars(t(x), w = w, useNames = FALSE) 220s > stopifnot(all.equal(x_est1, x_est0)) 220s > stopifnot(all.equal(x_est2, x_est0)) 220s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE], useNames = TRUE) 220s > x_est1 <- rowWeightedVars(x, w = w, useNames = TRUE) 220s > x_est2 <- colWeightedVars(t(x), w = w, useNames = TRUE) 220s > stopifnot(all.equal(x_est1, x_est0)) 220s > stopifnot(all.equal(x_est2, x_est0)) 220s > dimnames(x) <- NULL 220s > 220s > 221s > # Weighted row variances (excluding some columns) 221s > w <- c(0, 1, 0, 0) 221s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE]) 221s > x_est1 <- rowWeightedVars(x, w = w) 221s > #stopifnot(all.equal(x_est1, x_est0)) 221s > x_est2 <- colWeightedVars(t(x), w = w) 221s > stopifnot(all.equal(x_est2, x_est1)) 221s > # Check names attribute 221s > dimnames(x) <- dimnames 221s > x_est1 <- rowWeightedVars(x, w = w, useNames = FALSE) 221s > x_est2 <- colWeightedVars(t(x), w = w, useNames = FALSE) 221s > stopifnot(all.equal(x_est1, x_est0)) 221s > stopifnot(all.equal(x_est2, x_est0)) 221s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE], useNames = TRUE) 221s > x_est1 <- rowWeightedVars(x, w = w, useNames = TRUE) 221s > x_est2 <- colWeightedVars(t(x), w = w, useNames = TRUE) 221s > stopifnot(all.equal(x_est1, x_est0)) 221s > stopifnot(all.equal(x_est2, x_est0)) 221s > dimnames(x) <- NULL 221s > 221s > 221s > # Weighted row variances (all zero weights) 221s > w <- c(0, 0, 0, 0) 221s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE]) 221s > x_est1 <- rowWeightedVars(x, w = w) 221s > stopifnot(all.equal(x_est1, x_est0)) 221s > x_est2 <- colWeightedVars(t(x), w = w) 221s > stopifnot(all.equal(x_est2, x_est0)) 221s > # Check names attribute 221s > dimnames(x) <- dimnames 221s > x_est1 <- rowWeightedVars(x, w = w, useNames = FALSE) 221s > x_est2 <- colWeightedVars(t(x), w = w, useNames = FALSE) 221s > stopifnot(all.equal(x_est1, x_est0)) 221s > stopifnot(all.equal(x_est2, x_est0)) 221s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE], useNames = TRUE) 221s > x_est1 <- rowWeightedVars(x, w = w, useNames = TRUE) 221s > x_est2 <- colWeightedVars(t(x), w = w, useNames = TRUE) 221s > stopifnot(all.equal(x_est1, x_est0)) 221s > stopifnot(all.equal(x_est2, x_est0)) 221s > dimnames(x) <- NULL 221s > 221s > # Weighted variances by rows and columns 221s > w <- 1:4 221s > # Test with and without dimnames on x 221s > for (setDimnames in c(TRUE, FALSE)) { 221s + if (setDimnames) dimnames(x) <- dimnames 221s + else dimnames(x) <- NULL 221s + # Check names attribute 221s + for (useNames in c(TRUE, FALSE)) { 221s + x_est1 <- rowWeightedVars(x, w = w, useNames = useNames) 221s + print(x_est1) 221s + x_est2 <- colWeightedVars(t(x), w = w, useNames = useNames) 221s + stopifnot(all.equal(x_est2, x_est1)) 221s + } 221s + } 221s a b c d e 221s 0.90747094 0.05040463 0.65089440 2.28697479 0.27902734 221s [1] 0.90747094 0.05040463 0.65089440 2.28697479 0.27902734 221s [1] 0.90747094 0.05040463 0.65089440 2.28697479 0.27902734 221s [1] 0.90747094 0.05040463 0.65089440 2.28697479 0.27902734 221s > 221s > 221s > x[sample(length(x), size = 0.3 * length(x))] <- NA 221s > print(x) 221s [,1] [,2] [,3] [,4] 221s [1,] -0.6264538 NA 1.5117812 -0.04493361 221s [2,] 0.1836433 NA NA -0.01619026 221s [3,] -0.8356286 0.7383247 -0.6212406 0.94383621 221s [4,] 1.5952808 NA -2.2146999 0.82122120 221s [5,] 0.3295078 NA NA 0.59390132 221s > 221s > # Non-weighted row variances with missing values 221s > x_est0 <- rowVars(x, na.rm = TRUE) 221s > x_est1 <- rowWeightedVars(x, w = rep(1, times = ncol(x)), na.rm = TRUE) 221s > print(x_est1) 221s [1] 1.22226258 0.01996673 0.83582537 4.05532299 0.03495197 221s > stopifnot(all.equal(x_est1, x_est0)) 221s > x_est2 <- colWeightedVars(t(x), w = rep(1, times = ncol(x)), na.rm = TRUE) 221s > stopifnot(all.equal(x_est2, x_est0)) 221s > # Check names attribute 221s > dimnames(x) <- dimnames 221s > x_est1 <- rowWeightedVars(x, w = rep(1, times = ncol(x)), na.rm = TRUE, useNames = FALSE) 221s > x_est2 <- colWeightedVars(t(x), w = rep(1, times = ncol(x)), na.rm = TRUE, useNames = FALSE) 221s > stopifnot(all.equal(x_est1, x_est0)) 221s > stopifnot(all.equal(x_est2, x_est0)) 221s > x_est0 <- rowVars(x, na.rm = TRUE, useNames = TRUE) 221s > x_est1 <- rowWeightedVars(x, w = rep(1, times = ncol(x)), na.rm = TRUE, useNames = TRUE) 221s > x_est2 <- colWeightedVars(t(x), w = rep(1, times = ncol(x)), na.rm = TRUE, useNames = TRUE) 221s > stopifnot(all.equal(x_est1, x_est0)) 221s > stopifnot(all.equal(x_est2, x_est0)) 221s > dimnames(x) <- NULL 221s > 221s > 221s > # Weighted row variances with missing values 221s > # Test with and without dimnames on x 221s > for (setDimnames in c(TRUE, FALSE)) { 221s + if (setDimnames) dimnames(x) <- dimnames 221s + else dimnames(x) <- NULL 221s + # Check names attribute 221s + for (useNames in c(TRUE, FALSE)) { 221s + x_est1 <- rowWeightedVars(x, w = w, na.rm = TRUE, useNames = useNames) 221s + print(x_est1) 221s + x_est2 <- colWeightedVars(t(x), w = w, na.rm = TRUE, useNames = useNames) 221s + stopifnot(all.equal(x_est2, x_est1)) 221s + } 221s + } 221s a b c d e 221s 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 221s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 221s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 221s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 221s > 221s > 221s > # Weighted variances by rows and columns 221s > w <- 1:4 221s > # Test with and without dimnames on x 221s > for (setDimnames in c(TRUE, FALSE)) { 221s + if (setDimnames) dimnames(x) <- dimnames 221s + else dimnames(x) <- NULL 221s + # Check names attribute 221s + for (useNames in c(TRUE, FALSE)) { 221s + x_est1 <- rowWeightedVars(x, w = w, na.rm = TRUE, useNames = useNames) 221s + print(x_est1) 221s + x_est2 <- colWeightedVars(t(x), w = w, na.rm = TRUE, useNames = useNames) 221s + stopifnot(all.equal(x_est2, x_est1)) 221s + } 221s + } 221s a b c d e 221s 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 221s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 221s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 221s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 221s > 221s > 221s > # Weighted row standard deviation (excluding some columns) 221s > w <- c(1, 1, 0, 1) 221s > ## FIXME: rowVars()/rowSds() needs na.rm = FALSE (wrong default) 221s > x_est0 <- rowSds(x[, (w == 1), drop = FALSE], na.rm = FALSE) 221s > x_est1 <- rowWeightedSds(x, w = w) 221s > print(x_est1) 221s [1] NA NA 0.9734868 NA NA 221s > stopifnot(all.equal(x_est1, x_est0)) 221s > x_est2 <- colWeightedSds(t(x), w = w, na.rm = FALSE) 221s > stopifnot(all.equal(x_est2, x_est0)) 221s > # Check names attribute 221s > dimnames(x) <- dimnames 221s > x_est1 <- rowWeightedSds(x, w = w, na.rm = FALSE, useNames = FALSE) 221s > x_est2 <- colWeightedSds(t(x), w = w, na.rm = FALSE, useNames = FALSE) 221s > stopifnot(all.equal(x_est1, x_est0)) 221s > stopifnot(all.equal(x_est2, x_est0)) 221s > x_est0 <- rowSds(x[, (w == 1), drop = FALSE], na.rm = FALSE, useNames = TRUE) 221s > x_est1 <- rowWeightedSds(x, w = w, na.rm = FALSE, useNames = TRUE) 221s > x_est2 <- colWeightedSds(t(x), w = w, na.rm = FALSE, useNames = TRUE) 221s > stopifnot(all.equal(x_est1, x_est0)) 221s > stopifnot(all.equal(x_est2, x_est0)) 221s > dimnames(x) <- NULL 221s > 221s > 221s > # Weighted row MADs (excluding some columns) 221s > w <- c(1, 1, 0, 1) 221s > x_est0 <- rowMads(x[, (w == 1), drop = FALSE]) 221s > x_est1 <- rowWeightedMads(x, w = w) 221s > print(x_est1) 221s [1] NA NA 0.3046914 NA NA 221s > stopifnot(all.equal(x_est1, x_est0)) 221s > x_est2 <- colWeightedMads(t(x), w = w) 221s > stopifnot(all.equal(x_est2, x_est0)) 221s > # Check names attribute 221s > dimnames(x) <- dimnames 221s > x_est1 <- rowWeightedMads(x, w = w, useNames = FALSE) 221s > x_est2 <- colWeightedMads(t(x), w = w, useNames = FALSE) 221s > stopifnot(all.equal(x_est1, x_est0)) 221s > stopifnot(all.equal(x_est2, x_est0)) 221s > x_est0 <- rowMads(x[, (w == 1), drop = FALSE], useNames = TRUE) 221s > x_est1 <- rowWeightedMads(x, w = w, useNames = TRUE) 221s > x_est2 <- colWeightedMads(t(x), w = w, useNames = TRUE) 221s > stopifnot(all.equal(x_est1, x_est0)) 221s > stopifnot(all.equal(x_est2, x_est0)) 221s > dimnames(x) <- NULL 221s > 221s 221s R version 4.4.3 (2025-02-28) -- "Trophy Case" 221s Copyright (C) 2025 The R Foundation for Statistical Computing 221s Platform: s390x-ibm-linux-gnu 221s 221s R is free software and comes with ABSOLUTELY NO WARRANTY. 221s You are welcome to redistribute it under certain conditions. 221s Type 'license()' or 'licence()' for distribution details. 221s 221s R is a collaborative project with many contributors. 221s Type 'contributors()' for more information and 221s 'citation()' on how to cite R or R packages in publications. 221s 221s Type 'demo()' for some demos, 'help()' for on-line help, or 221s 'help.start()' for an HTML browser interface to help. 221s Type 'q()' to quit R. 221s 221s > library("matrixStats") 221s > 221s > fcns <- list( 221s + weightedVar = c(rowWeightedVars, colWeightedVars), 221s + weightedSd = c(rowWeightedSds, colWeightedSds), 221s + weightedMad = c(rowWeightedMads, colWeightedMads) 221s + ) 221s > 221s > 221s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 221s > # Subsetted tests 221s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 221s > source("utils/validateIndicesFramework.R") 221s > # To check names attribute 221s > dimnames <- list(letters[1:6], LETTERS[1:6]) 221s > for (fcn in names(fcns)) { 221s + cat(sprintf("subsetted tests on matrix %s()...\n", fcn)) 221s + row_fcn <- fcns[[fcn]][[1]] 221s + col_fcn <- fcns[[fcn]][[2]] 221s + 221s + for (mode in c("numeric", "integer")) { 221s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 221s + w <- runif(6, min = 0, max = 6) 221s + storage.mode(x) <- mode 221s + storage.mode(w) <- mode 221s + if (mode == "numeric") w[1] <- Inf 221s + 221s + # Test with and without dimnames on x 221s + for (setDimnames in c(TRUE, FALSE)) { 221s + if (setDimnames) dimnames(x) <- dimnames 221s + else dimnames(x) <- NULL 221s + 221s + count <- 0L 221s + for (rows in index_cases) { 221s + for (cols in index_cases) { 221s + count <- count + 1L 221s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 221s + useNames <- c(TRUE, FALSE) 221s + useNames <- useNames[count %% length(useNames) + 1] 221s + 221s + validateIndicesTestMatrix_w(x, w, rows, cols, 221s + ftest = row_fcn, fsure = row_fcn, 221s + na.rm = na.rm, useNames = useNames) 221s + validateIndicesTestMatrix_w(x, w, rows, cols, 221s + fcoltest = col_fcn, fsure = row_fcn, 221s + na.rm = na.rm, useNames = useNames) 221s + } 221s + } 221s + } 221s + } 221s + cat(sprintf("%s()...DONE\n", fcn)) 221s + } 221s subsetted tests on matrix weightedVar()... 221s weightedVar()...DONE 221s subsetted tests on matrix weightedSd()... 222s weightedSd()...DONE 222s subsetted tests on matrix weightedMad()... 222s weightedMad()...DONE 222s > 222s 222s R version 4.4.3 (2025-02-28) -- "Trophy Case" 222s Copyright (C) 2025 The R Foundation for Statistical Computing 222s Platform: s390x-ibm-linux-gnu 222s 222s R is free software and comes with ABSOLUTELY NO WARRANTY. 222s You are welcome to redistribute it under certain conditions. 222s Type 'license()' or 'licence()' for distribution details. 222s 222s R is a collaborative project with many contributors. 222s Type 'contributors()' for more information and 222s 'citation()' on how to cite R or R packages in publications. 222s 222s Type 'demo()' for some demos, 'help()' for on-line help, or 222s 'help.start()' for an HTML browser interface to help. 222s Type 'q()' to quit R. 222s 223s > library("matrixStats") 223s > 223s > signTabulate0 <- function(x, ...) { 223s + nneg <- sum(x < 0, na.rm = TRUE) 223s + nzero <- sum(x == 0, na.rm = TRUE) 223s + npos <- sum(x > 0, na.rm = TRUE) 223s + nna <- sum(is.na(x)) 223s + nneginf <- sum(is.infinite(x) & x < 0, na.rm = TRUE) 223s + nposinf <- sum(is.infinite(x) & x > 0, na.rm = TRUE) 223s + res <- c(nneg, nzero, npos, nna, nneginf, nposinf) 223s + res <- as.double(res) 223s + names(res) <- c("-1", "0", "+1", "NA", "-Inf", "+Inf") 223s + if (is.integer(x)) res <- res[1:4] 223s + res 223s + } # signTabulate0() 223s > 223s > 223s > # Simulate data 223s > set.seed(0xBEEF) 223s > n <- 100L 223s > x <- runif(n) 223s > x[sample(n, size = 0.1 * n)] <- 0 223s > x[sample(n, size = 0.1 * n)] <- NA_real_ 223s > x[sample(n, size = 0.1 * n)] <- -Inf 223s > x[sample(n, size = 0.1 * n)] <- +Inf 223s > 223s > # Doubles 223s > message("Doubles:") 223s > counts0 <- signTabulate0(x) 223s > print(counts0) 223s -1 0 +1 NA -Inf +Inf 223s 9 7 77 7 9 10 223s > counts1 <- signTabulate(x) 223s > print(counts1) 223s -1 0 +1 NA -Inf +Inf 223s 9 7 77 7 9 10 223s > stopifnot(identical(counts1, counts0)) 223s > 223s > # Integers 223s > message("Integers:") 223s > x <- suppressWarnings(as.integer(x)) 223s > counts0 <- signTabulate0(x) 223s > print(counts0) 223s -1 0 +1 NA 223s Doubles: 223s Integers: 223s 0 74 0 26 223s > counts1 <- signTabulate(x) 223s > print(counts1) 223s -1 0 +1 NA 223s 0 74 0 26 223s > stopifnot(identical(counts1, counts0)) 223s > 223s 223s R version 4.4.3 (2025-02-28) -- "Trophy Case" 223s Copyright (C) 2025 The R Foundation for Statistical Computing 223s Platform: s390x-ibm-linux-gnu 223s 223s R is free software and comes with ABSOLUTELY NO WARRANTY. 223s You are welcome to redistribute it under certain conditions. 223s Type 'license()' or 'licence()' for distribution details. 223s 223s R is a collaborative project with many contributors. 223s Type 'contributors()' for more information and 223s 'citation()' on how to cite R or R packages in publications. 223s 223s Type 'demo()' for some demos, 'help()' for on-line help, or 223s 'help.start()' for an HTML browser interface to help. 223s Type 'q()' to quit R. 223s 223s > library("matrixStats") 223s > 223s > signTabulate0 <- function(x, ...) { 223s + nneg <- sum(x < 0, na.rm = TRUE) 223s + nzero <- sum(x == 0, na.rm = TRUE) 223s + npos <- sum(x > 0, na.rm = TRUE) 223s + nna <- sum(is.na(x)) 223s + nneginf <- sum(is.infinite(x) & x < 0, na.rm = TRUE) 223s + nposinf <- sum(is.infinite(x) & x > 0, na.rm = TRUE) 223s + res <- c(nneg, nzero, npos, nna, nneginf, nposinf) 223s + res <- as.double(res) 223s + names(res) <- c("-1", "0", "+1", "NA", "-Inf", "+Inf") 223s + if (is.integer(x)) res <- res[1:4] 223s + res 223s + } # signTabulate0() 223s > 223s > 223s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 223s > # Subsetted tests 223s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 223s > source("utils/validateIndicesFramework.R") 223s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 223s > x[2:3, 4:5] <- +Inf 223s > x[4:5, 1:2] <- -Inf 223s > for (idxs in index_cases) { 223s + validateIndicesTestVector(x, idxs, 223s + ftest = signTabulate, fsure = signTabulate0) 223s + } 223s > 223s 223s R version 4.4.3 (2025-02-28) -- "Trophy Case" 223s Copyright (C) 2025 The R Foundation for Statistical Computing 223s Platform: s390x-ibm-linux-gnu 223s 223s R is free software and comes with ABSOLUTELY NO WARRANTY. 223s You are welcome to redistribute it under certain conditions. 223s Type 'license()' or 'licence()' for distribution details. 223s 223s R is a collaborative project with many contributors. 223s Type 'contributors()' for more information and 223s 'citation()' on how to cite R or R packages in publications. 223s 223s Type 'demo()' for some demos, 'help()' for on-line help, or 223s 'help.start()' for an HTML browser interface to help. 223s Type 'q()' to quit R. 223s 223s > library("matrixStats") 223s > options(warn = 1) 223s > 223s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 223s > # Consistency checks 223s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 223s > set.seed(1) 223s > 223s > sum2_R <- function(x, na.rm = FALSE, idxs = NULL) { 223s + if (is.null(idxs)) { 223s + sum(x, na.rm = na.rm) 223s + } else { 223s + sum(x[idxs], na.rm = na.rm) 223s + } 223s + } # sum2_R() 223s > 223s > 223s > cat("Consistency checks:\n") 223s Consistency checks: 223s > for (kk in 1:20) { 223s + cat("Random test #", kk, "\n", sep = "") 223s + 223s + # Simulate data in a matrix of any shape 223s + n <- sample(1e3, size = 1L) 223s + x <- rnorm(n, sd = 100) 223s + 223s + # Add NAs? 223s + if ((kk %% 4) %in% c(3, 0)) { 223s + cat("Adding NAs\n") 223s + nna <- sample(n, size = 1L) 223s + na_values <- c(NA_real_, NaN) 223s + t <- sample(na_values, size = nna, replace = TRUE) 223s + x[sample(length(x), size = nna)] <- t 223s + } 223s + 223s + # Integer or double? 223s + if ((kk %% 4) %in% c(2, 0)) { 223s + cat("Coercing to integers\n") 223s + storage.mode(x) <- "integer" 223s + } 223s + 223s + na.rm <- sample(c(TRUE, FALSE), size = 1L) 223s + 223s + # Sum over all 223s + y0 <- sum2_R(x, na.rm = na.rm) 223s + y1 <- sum2(x, na.rm = na.rm) 223s + stopifnot(all.equal(y1, y0)) 223s + 223s + # Sum over subset 223s + nidxs <- sample(n, size = 1L) 223s + idxs <- sample(n, size = nidxs) 223s + y0 <- sum2_R(x, na.rm = na.rm, idxs = idxs) 223s + y1 <- sum2(x, na.rm = na.rm, idxs = idxs) 223s + stopifnot(all.equal(y1, y0)) 223s + 223s + if (storage.mode(x) == "integer") { 223s + storage.mode(x) <- "logical" 223s + 223s + y0 <- sum2_R(x, na.rm = na.rm) 223s + y1 <- sum2(x, na.rm = na.rm) 223s + stopifnot(all.equal(y1, y0)) 223s + 223s + y0 <- sum2_R(x, na.rm = na.rm, idxs = idxs) 223s + y1 <- sum2(x, na.rm = na.rm, idxs = idxs) 223s + stopifnot(all.equal(y1, y0)) 223s + } 223s + } # for (kk ...) 223s Random test #1 223s Random test #2 223s Coercing to integers 223s Random test #3 223s Adding NAs 223s Random test #4 223s Adding NAs 223s Coercing to integers 223s Random test #5 223s Random test #6 223s Coercing to integers 223s Random test #7 223s Adding NAs 223s Random test #8 223s Adding NAs 223s Coercing to integers 223s Random test #9 223s Random test #10 223s Coercing to integers 223s Random test #11 223s Adding NAs 223s Random test #12 223s Adding NAs 223s Coercing to integers 223s Random test #13 223s Random test #14 223s Coercing to integers 223s Random test #15 223s Adding NAs 223s Random test #16 223s Adding NAs 223s Coercing to integers 223s Random test #17 223s Random test #18 223s Coercing to integers 223s Random test #19 223s Adding NAs 223s Random test #20 223s Adding NAs 223s Coercing to integers 223s > 223s > 223s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 223s > # All missing values 223s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 223s > for (n in 0:2) { 223s + for (na.rm in c(FALSE, TRUE)) { 223s + x <- rep(NA_real_, times = n) 223s + y0 <- sum(x, na.rm = na.rm) 223s + y <- sum2(x, na.rm = na.rm) 223s + stopifnot(all.equal(y, y0)) 223s + 223s + x <- rep(NA_integer_, times = n) 223s + y0 <- sum(x, na.rm = na.rm) 223s + y <- sum2(x, na.rm = na.rm) 223s + stopifnot(all.equal(y, y0)) 223s + 223s + x <- rep(NA, times = n) 223s + y0 <- sum(x, na.rm = na.rm) 223s + y <- sum2(x, na.rm = na.rm) 223s + stopifnot(all.equal(y, y0)) 223s + } 223s + } 223s > 223s > 223s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 223s > # Special cases 223s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 223s > for (na.rm in c(FALSE, TRUE)) { 223s + # Summing over zero elements (integers) 223s + x <- integer(0) 223s + s1 <- sum(x, na.rm = na.rm) 223s + s2 <- sum2(x, na.rm = na.rm) 223s + stopifnot(identical(s1, s2)) 223s + 223s + x <- 1:10 223s + idxs <- integer(0) 223s + s1 <- sum(x[idxs], na.rm = na.rm) 223s + s2 <- sum2(x, idxs = idxs, na.rm = na.rm) 223s + stopifnot(identical(s1, s2)) 223s + 223s + # Summing over NA_integer_:s 223s + x <- rep(NA_integer_, times = 10L) 223s + s1 <- sum(x, na.rm = na.rm) 223s + s2 <- sum2(x, na.rm = na.rm) 223s + stopifnot(identical(s1, s2)) 223s + 223s + x <- rep(NA_integer_, times = 10L) 223s + idxs <- 1:5 223s + s1 <- sum(x[idxs], na.rm = na.rm) 223s + s2 <- sum2(x, idxs = idxs, na.rm = na.rm) 223s + stopifnot(identical(s1, s2)) 223s + 223s + 223s + # Summing over zero elements (doubles) 223s + x <- double(0) 223s + s1 <- sum(x) 223s + s2 <- sum2(x) 223s + stopifnot( 223s + identical(s1, 0), 223s + identical(s1, s2) 223s + ) 223s + 223s + x <- as.double(1:10) 223s + idxs <- integer(0) 223s + s1 <- sum(x[idxs]) 223s + s2 <- sum2(x, idxs = idxs) 223s + stopifnot( 223s + identical(s1, 0), 223s + identical(s1, s2) 223s + ) 223s + 223s + # Summing over NA_real_:s 223s + x <- rep(NA_real_, times = 10L) 223s + s1 <- sum(x, na.rm = na.rm) 223s + s2 <- sum2(x, na.rm = na.rm) 223s + stopifnot( 223s + !na.rm || s1 == 0, 223s + identical(s1, s2) 223s + ) 223s + 223s + x <- rep(NA_real_, times = 10L) 223s + idxs <- 1:5 223s + s1 <- sum(x[idxs], na.rm = na.rm) 223s + s2 <- sum2(x, idxs = idxs, na.rm = na.rm) 223s + stopifnot( 223s + !na.rm || s1 == 0, 223s + identical(s1, s2) 223s + ) 223s + 223s + # Summing over -Inf:s 223s + x <- rep(-Inf, times = 3L) 223s + s1 <- sum(x, na.rm = na.rm) 223s + s2 <- sum2(x, na.rm = na.rm) 223s + stopifnot( 223s + is.infinite(s1) && s1 < 0, 223s + identical(s1, s2) 223s + ) 223s + 223s + # Summing over +Inf:s 223s + x <- rep(+Inf, times = 3L) 223s + s1 <- sum(x, na.rm = na.rm) 223s + s2 <- sum2(x, na.rm = na.rm) 223s + stopifnot(identical(s1, s2)) 223s + stopifnot( 223s + is.infinite(s1) && s1 > 0, 223s + identical(s1, s2) 223s + ) 223s + 223s + # Summing over mix of -Inf:s and +Inf:s 223s + x <- rep(c(-Inf, +Inf), times = 3L) 223s + s1 <- sum(x, na.rm = na.rm) 223s + s2 <- sum2(x, na.rm = na.rm) 223s + stopifnot( 223s + is.nan(s1), 223s + identical(s1, s2) 223s + ) 223s + 223s + # Summing over mix of -Inf:s and +Inf:s and numerics 223s + x <- rep(c(-Inf, +Inf, 3.14), times = 2L) 223s + s1 <- sum(x, na.rm = na.rm) 223s + s2 <- sum2(x, na.rm = na.rm) 223s + stopifnot( 223s + is.nan(s1), 223s + identical(s1, s2) 223s + ) 223s + 223s + # Summing over mix of NaN, NA, +Inf, and numerics 223s + x <- c(NaN, NA, +Inf, 3.14) 223s + s1 <- sum(x, na.rm = na.rm) 223s + s2 <- sum2(x, na.rm = na.rm) 223s + if (na.rm) { 223s + stopifnot( 223s + is.infinite(s1) && s1 > 0, 223s + identical(s2, s1) 223s + ) 223s + } else { 223s + stopifnot(is.na(s1), is.na(s2)) 223s + ## NOTE, due to compiler optimization, it is not guaranteed that NA is 223s + ## returned here (as one would expect). NaN might very well be returned, 223s + ## when both NA and NaN are involved. This is an accepted feature in R, 223s + ## which is documented in help("is.nan"). See also 223s + ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 223s + ## Thus, we cannot guarantee that s1 is identical to s0. 223s + } 223s + 223s + # Summing over mix of NaN, NA, +Inf, and numerics 223s + x <- c(NA, NaN, +Inf, 3.14) 223s + s1 <- sum(x, na.rm = na.rm) 223s + s2 <- sum2(x, na.rm = na.rm) 223s + if (na.rm) { 223s + stopifnot( 223s + is.infinite(s1) && s1 > 0, 223s + identical(s2, s1) 223s + ) 223s + } else { 223s + stopifnot(is.na(s1), is.na(s2)) 223s + ## NOTE, due to compiler optimization, it is not guaranteed that NA is 223s + ## returned here (as one would expect). NaN might very well be returned, 223s + ## when both NA and NaN are involved. This is an accepted feature in R, 223s + ## which is documented in help("is.nan"). See also 223s + ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 223s + ## Thus, we cannot guarantee that s1 is identical to s0. 223s + } 223s + } 223s > 223s > 223s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 223s > # Summing of large integers 223s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 223s > x <- c(.Machine$integer.max, 1L, -.Machine$integer.max) 223s > 223s > # Total gives integer overflow 223s > s1 <- sum(x[1:2]) # NA_integer_ w/ warning 223s > s2 <- sum2(x[1:2]) # NA_integer_ w/ warning 223s > stopifnot( 223s + identical(s2, NA_integer_) 223s + ) 223s > 223s > ## Assert above warning 223s > res <- tryCatch({ 223s + s2 <- sum2(x[1:2]) 223s + }, warning = identity) 223s > stopifnot(inherits(res, "warning")) 223s > 223s > 223s > # Total gives integer overflow (coerce to numeric) 223s > s1 <- sum(as.numeric(x[1:2])) # 2147483648 223s Warning in sum2(x[1:2]) : 223s Integer overflow. Use sum2(..., mode = "double") to avoid this. 223s > s2 <- sum2(as.numeric(x[1:2])) # 2147483648 223s > s3 <- sum2(x[1:2], mode = "double") # 2147483648 223s > stopifnot( 223s + identical(s1, 2147483648), 223s + identical(s1, s2), 223s + identical(s1, s3) 223s + ) 223s > 223s > # Cumulative sum would give integer overflow but not the total 223s > s1 <- sum(x) # 1L 223s > s2 <- sum2(x) # 1L 223s > stopifnot( 223s + identical(s1, 1L), 223s + identical(s1, s2) 223s + ) 223s Warning in sum2(x, mode = "integer") : 223s sum2(x, mode = "integer") called with typeof(x) == "double"; did you mean to use as.integer(sum2(x))? 223s > 223s > # Input is double but coercing result to integer 223s > x <- c(1, 2, 3.1) 223s > s1 <- sum2(x) 223s > s2 <- sum2(x, mode = "integer") 223s > stopifnot( 223s + identical(as.integer(s1), s2) 223s + ) 223s > 223s > ## Assert above warning 223s > res <- tryCatch({ 223s + s2 <- sum2(x, mode = "integer") 223s + }, warning = identity) 223s > stopifnot(inherits(res, "warning")) 223s > 223s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 223s > # Summing of large doubles 223s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 223s > ## Double overflow 223s > x <- rep(.Machine$double.xmax, times = 2L) 223s > y0 <- sum(x) 223s > print(y0) 223s [1] Inf 223s > y <- sum2(x) 223s > print(y) 223s [1] Inf 223s > stopifnot( 223s + is.infinite(y) && y > 0, 223s + identical(y, y0) 223s + ) 223s > 223s > x <- rep(-.Machine$double.xmax, times = 2L) 223s > y0 <- sum(x) 223s > print(y0) 223s [1] -Inf 223s > y <- sum2(x) 223s > print(y) 223s [1] -Inf 223s > stopifnot( 223s + is.infinite(y) && y < 0, 223s + identical(y, y0) 223s + ) 223s > 223s > 223s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 223s > # Argument 'idxs' 223s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 223s > x <- 1:10 223s > idxs_list <- list( 223s + integer = 1:5, 223s + double = as.double(1:5), 223s + logical = (x <= 5) 223s + ) 223s > 223s > for (idxs in idxs_list) { 223s + cat("idxs:\n") 223s + str(idxs) 223s + s1 <- sum(x[idxs], na.rm = TRUE) 223s + s2 <- sum2(x, idxs = idxs, na.rm = TRUE) 223s + stopifnot(identical(s1, s2)) 223s + } 223s idxs: 223s int [1:5] 1 2 3 4 5 223s idxs: 223s num [1:5] 1 2 3 4 5 223s idxs: 223s logi [1:10] TRUE TRUE TRUE TRUE TRUE FALSE ... 223s > 223s 223s R version 4.4.3 (2025-02-28) -- "Trophy Case" 223s Copyright (C) 2025 The R Foundation for Statistical Computing 223s Platform: s390x-ibm-linux-gnu 223s 223s R is free software and comes with ABSOLUTELY NO WARRANTY. 223s You are welcome to redistribute it under certain conditions. 223s Type 'license()' or 'licence()' for distribution details. 223s 223s R is a collaborative project with many contributors. 223s Type 'contributors()' for more information and 223s 'citation()' on how to cite R or R packages in publications. 223s 223s Type 'demo()' for some demos, 'help()' for on-line help, or 223s 'help.start()' for an HTML browser interface to help. 223s Type 'q()' to quit R. 223s 223s > library("matrixStats") 223s > 223s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 223s > # Subsetted tests 223s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 223s > source("utils/validateIndicesFramework.R") 223s > x <- runif(6, min = -6, max = 6) 223s > storage.mode(x) <- "integer" 223s > for (idxs in index_cases) { 223s + validateIndicesTestVector(x, idxs, 223s + ftest = sum2, fsure = sum, 223s + na.rm = FALSE) 223s + validateIndicesTestVector(x, idxs, 223s + ftest = sum2, fsure = sum, 223s + na.rm = TRUE) 223s + } 223s > 223s 223s R version 4.4.3 (2025-02-28) -- "Trophy Case" 223s Copyright (C) 2025 The R Foundation for Statistical Computing 223s Platform: s390x-ibm-linux-gnu 223s 223s R is free software and comes with ABSOLUTELY NO WARRANTY. 223s You are welcome to redistribute it under certain conditions. 223s Type 'license()' or 'licence()' for distribution details. 223s 223s R is a collaborative project with many contributors. 223s Type 'contributors()' for more information and 223s 'citation()' on how to cite R or R packages in publications. 223s 223s Type 'demo()' for some demos, 'help()' for on-line help, or 223s 'help.start()' for an HTML browser interface to help. 223s Type 'q()' to quit R. 223s 224s > library("matrixStats") 224s > 224s > set.seed(1) 224s > x <- rnorm(1e4) 224s > 224s > 224s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 224s > # Variance estimators 224s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 224s > sigma2_a <- var(x) 224s > cat(sprintf("var(x) = %g\n", sigma2_a)) 224s var(x) = 1.02487 224s > 224s > sigma2_b <- varDiff(x) 224s > cat(sprintf("varDiff(x) = %g\n", sigma2_b)) 224s varDiff(x) = 1.01224 224s > 224s > d <- abs(sigma2_b - sigma2_a) 224s > cat(sprintf("Absolute difference = %g\n", d)) 224s Absolute difference = 0.0126268 224s > stopifnot(d < 0.02) 224s > 224s > 224s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 224s > # Standard deviation estimators 224s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 224s > sigma_a <- sd(x) 224s > cat(sprintf("sd(x) = %g\n", sigma_a)) 224s sd(x) = 1.01236 224s > 224s > sigma_b <- sdDiff(x) 224s > cat(sprintf("sdDiff(x) = %g\n", sigma_b)) 224s sdDiff(x) = 1.0061 224s > 224s > d <- abs(sigma_b - sigma_a) 224s > cat(sprintf("Absolute difference = %g\n", d)) 224s Absolute difference = 0.00625567 224s > stopifnot(d < 0.01) 224s > 224s > # Sanity checks 224s > stopifnot(abs(sigma2_a - sigma_a ^ 2) < 1e-9) 224s > stopifnot(abs(sigma2_b - sigma_b ^ 2) < 1e-9) 224s > 224s > 224s > sigma_a2 <- mad(x) 224s > cat(sprintf("mad(x) = %g\n", sigma_a2)) 224s mad(x) = 0.998376 224s > 224s > sigma_b2 <- madDiff(x) 224s > cat(sprintf("madDiff(x) = %g\n", sigma_b2)) 224s madDiff(x) = 1.02513 224s > 224s > d <- abs(sigma_b2 - sigma_a2) 224s > cat(sprintf("Absolute difference = %g\n", d)) 224s Absolute difference = 0.0267497 224s > stopifnot(d < 0.05) 224s > 224s > 224s > sigma_a3 <- IQR(x) 224s > cat(sprintf("IQR(x) = %g\n", sigma_a3)) 224s IQR(x) = 1.35105 224s > 224s > sigma_b3 <- iqrDiff(x) 224s > cat(sprintf("iqrDiff(x) = %g\n", sigma_b3)) 224s iqrDiff(x) = 1.37797 224s > 224s > d <- abs(sigma_b3 - sigma_a3) 224s > cat(sprintf("Absolute difference = %g\n", d)) 224s Absolute difference = 0.0269152 224s > stopifnot(d < 0.05) 224s > 224s > 224s > 224s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 224s > # Trimmed estimators 224s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 224s > y <- x 224s > outliers <- sample(length(x), size = 0.1 * length(x)) 224s > y[outliers] <- 100 * y[outliers] 224s > 224s > sigma_ao <- sd(y[-outliers]) 224s > cat(sprintf("sd(y) = %g\n", sigma_ao)) 224s sd(y) = 1.01166 224s > 224s > sigma_bo <- sdDiff(y[-outliers]) 224s > cat(sprintf("sdDiff(y) = %g\n", sigma_bo)) 224s sdDiff(y) = 1.00743 224s > 224s > d <- abs(sigma_b - sigma_a) 224s > cat(sprintf("Absolute difference = %g\n", d)) 224s Absolute difference = 0.00625567 224s > stopifnot(d < 0.01) 224s > 224s > sigma_bot <- sdDiff(y, trim = 0.05) 224s > cat(sprintf("sdDiff(y, trim = 0.05) = %g\n", sigma_bot)) 224s sdDiff(y, trim = 0.05) = 7.74327 224s > 224s > d <- abs(sigma_bot - sigma_a) 224s > cat(sprintf("Absolute difference = %g\n", d)) 224s Absolute difference = 6.73091 224s > #stopifnot(d < 1e-3) 224s > 224s > sigma_cot <- madDiff(y, trim = 0.05) 224s > cat(sprintf("madDiff(y, trim = 0.05) = %g\n", sigma_cot)) 224s madDiff(y, trim = 0.05) = 1.15278 224s > 224s > sigma_dot <- iqrDiff(y, trim = 0.05) 224s > cat(sprintf("iqrDiff(y, trim = 0.05) = %g\n", sigma_dot)) 224s iqrDiff(y, trim = 0.05) = 1.55762 224s > 224s > 224s > fcns <- list( 224s + varDiff = varDiff, 224s + sdDiff = sdDiff, 224s + madDiff = madDiff, 224s + iqrDiff = iqrDiff 224s + ) 224s > 224s > for (name in names(fcns)) { 224s + cat(sprintf("%s()...\n", name)) 224s + fcn <- fcns[[name]] 224s + 224s + for (mode in c("integer", "double")) { 224s + cat("mode: ", mode, "", sep = "") 224s + for (n in 0:3) { 224s + x <- runif(n, min = -5, max = 5) 224s + storage.mode(x) <- mode 224s + str(x) 224s + 224s + y <- fcn(x) 224s + yt <- fcn(x, trim = 0.1) 224s + str(list("non-trimmed" = y, trimmed = yt)) 224s + } # for (mode ...) 224s + } 224s + 224s + cat(sprintf("%s()...DONE\n", name)) 224s + } # for (name ...) 224s varDiff()... 224s mode: integer int(0) 224s List of 2 224s $ non-trimmed: num NA 224s $ trimmed : num NA 224s int -4 224s List of 2 224s $ non-trimmed: num NA 224s $ trimmed : num NA 224s int [1:2] 3 2 224s List of 2 224s $ non-trimmed: num NA 224s $ trimmed : num NA 224s int [1:3] 1 4 -1 224s List of 2 224s $ non-trimmed: num 16 224s $ trimmed : num 16 224s mode: double num(0) 224s List of 2 224s $ non-trimmed: num NA 224s $ trimmed : num NA 224s num -0.794 224s List of 2 224s $ non-trimmed: num NA 224s $ trimmed : num NA 224s num [1:2] 0.897 -3.728 224s List of 2 224s $ non-trimmed: num NA 224s $ trimmed : num NA 224s num [1:3] 2.07 -1.13 1.94 224s List of 2 224s $ non-trimmed: num 9.83 224s $ trimmed : num 9.83 224s varDiff()...DONE 224s sdDiff()... 224s mode: integer int(0) 224s List of 2 224s $ non-trimmed: num NA 224s $ trimmed : num NA 224s int 2 224s List of 2 224s $ non-trimmed: num NA 224s $ trimmed : num NA 224s int [1:2] -4 1 224s List of 2 224s $ non-trimmed: num NA 224s $ trimmed : num NA 224s int [1:3] -2 1 -1 224s List of 2 224s $ non-trimmed: num 2.5 224s $ trimmed : num 2.5 224s mode: double num(0) 224s List of 2 224s $ non-trimmed: num NA 224s $ trimmed : num NA 224s num -3.78 224s List of 2 224s $ non-trimmed: num NA 224s $ trimmed : num NA 224s num [1:2] -2.04 2.38 224s List of 2 224s $ non-trimmed: num NA 224s $ trimmed : num NA 224s num [1:3] 1.42 -2.14 1.14 224s List of 2 224s $ non-trimmed: num 3.42 224s $ trimmed : num 3.42 224s sdDiff()...DONE 224s madDiff()... 224s mode: integer int(0) 224s List of 2 224s $ non-trimmed: num NA 224s $ trimmed : num NA 224s int -1 224s List of 2 224s $ non-trimmed: num NA 224s $ trimmed : num NA 224s int [1:2] -1 4 224s List of 2 224s $ non-trimmed: num NA 224s $ trimmed : num NA 224s int [1:3] -1 0 -3 224s List of 2 224s $ non-trimmed: num 2.1 224s $ trimmed : num 2.1 224s mode: double num(0) 224s List of 2 224s $ non-trimmed: num NA 224s $ trimmed : num NA 224s num -1.13 224s List of 2 224s $ non-trimmed: num NA 224s $ trimmed : num NA 224s num [1:2] -1.7 -1.21 224s List of 2 224s $ non-trimmed: num NA 224s $ trimmed : num NA 224s num [1:3] -2.39 -0.464 3.086 224s List of 2 224s $ non-trimmed: num 0.851 224s $ trimmed : num 0.851 224s madDiff()...DONE 224s iqrDiff()... 224s mode: integer int(0) 224s List of 2 224s $ non-trimmed: num NA 224s $ trimmed : num NA 224s int 3 224s List of 2 224s $ non-trimmed: num 0 224s $ trimmed : num 0 224s int [1:2] -3 4 224s List of 2 224s $ non-trimmed: num 0 224s $ trimmed : num 0 224s int [1:3] 0 -2 -2 224s List of 2 224s $ non-trimmed: num 0.707 224s $ trimmed : num 0.707 224s mode: double num(0) 224s List of 2 224s $ non-trimmed: num NA 224s $ trimmed : num NA 224s num -4.46 224s List of 2 224s $ non-trimmed: num 0 224s $ trimmed : num 0 224s num [1:2] 3.67 1.02 224s List of 2 224s $ non-trimmed: num 0 224s $ trimmed : num 0 224s num [1:3] -0.537 -2.733 2.857 224s List of 2 224s $ non-trimmed: num 2.75 224s $ trimmed : num 2.75 224s iqrDiff()...DONE 224s > 224s 224s R version 4.4.3 (2025-02-28) -- "Trophy Case" 224s Copyright (C) 2025 The R Foundation for Statistical Computing 224s Platform: s390x-ibm-linux-gnu 224s 224s R is free software and comes with ABSOLUTELY NO WARRANTY. 224s You are welcome to redistribute it under certain conditions. 224s Type 'license()' or 'licence()' for distribution details. 224s 224s R is a collaborative project with many contributors. 224s Type 'contributors()' for more information and 224s 'citation()' on how to cite R or R packages in publications. 224s 224s Type 'demo()' for some demos, 'help()' for on-line help, or 224s 'help.start()' for an HTML browser interface to help. 224s Type 'q()' to quit R. 224s 224s > library("matrixStats") 224s > 224s > fcns <- list( 224s + varDiff = varDiff, 224s + sdDiff = sdDiff, 224s + madDiff = madDiff, 224s + iqrDiff = iqrDiff 224s + ) 224s > 224s > 224s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 224s > # Subsetted tests 224s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 224s > source("utils/validateIndicesFramework.R") 224s > for (name in names(fcns)) { 224s + cat(sprintf("subsetted tests on %s()...\n", name)) 224s + fcn <- fcns[[name]] 224s + 224s + for (mode in c("numeric", "integer")) { 224s + x <- runif(6, min = -6, max = 6) 224s + storage.mode(x) <- mode 224s + trim <- runif(1, min = 0, max = 0.5) 224s + if (mode == "numeric") x[1] <- Inf 224s + 224s + for (diff in 1:2) { 224s + for (idxs in index_cases) { 224s + validateIndicesTestVector(x, idxs, 224s + ftest = fcn, fsure = fcn, 224s + na.rm = TRUE, diff = diff, trim = trim) 224s + validateIndicesTestVector(x, idxs, 224s + ftest = fcn, fsure = fcn, 224s + na.rm = FALSE, diff = diff, trim = trim) 224s + } 224s + } 224s + } 224s + cat(sprintf("%s()...DONE\n", name)) 224s + } 224s subsetted tests on varDiff()... 224s varDiff()...DONE 224s subsetted tests on sdDiff()... 224s sdDiff()...DONE 224s subsetted tests on madDiff()... 224s madDiff()...DONE 224s subsetted tests on iqrDiff()... 224s iqrDiff()...DONE 224s > 224s 224s R version 4.4.3 (2025-02-28) -- "Trophy Case" 224s Copyright (C) 2025 The R Foundation for Statistical Computing 224s Platform: s390x-ibm-linux-gnu 224s 224s R is free software and comes with ABSOLUTELY NO WARRANTY. 224s You are welcome to redistribute it under certain conditions. 224s Type 'license()' or 'licence()' for distribution details. 224s 224s R is a collaborative project with many contributors. 224s Type 'contributors()' for more information and 224s 'citation()' on how to cite R or R packages in publications. 224s 224s Type 'demo()' for some demos, 'help()' for on-line help, or 224s 'help.start()' for an HTML browser interface to help. 224s Type 'q()' to quit R. 224s 224s > library("matrixStats") 224s > 224s > for (mode in c("logical", "integer", "double")) { 224s + cat("mode: ", mode, "", sep = "") 224s + n <- 2L 224s + x <- runif(n, min = -5, max = 5) 224s + if (mode == "logical") { 224s + x <- x > 0 224s + } 224s + storage.mode(x) <- mode 224s + str(x) 224s + 224s + cat("All weights are 1\n") 224s + w <- rep(1, times = n) 224s + m0 <- weighted.mean(x, w) 224s + m1 <- weightedMean(x, w) 224s + str(list(m0 = m0, m1 = m1)) 224s + stopifnot(identical(m1, m0)) 224s + 224s + cat("First weight is 5\n") 224s + # Pull the mean towards zero 224s + w[1] <- 5 224s + str(w) 224s + m0 <- weighted.mean(x, w) 224s + m1 <- weightedMean(x, w) 224s + str(list(m0 = m0, m1 = m1)) 224s + stopifnot(identical(m1, m0)) 224s + 224s + cat("All weights are 0\n") 224s + # All weights set to zero 224s + w <- rep(0, times = n) 224s + m0 <- weighted.mean(x, w) 224s + m1 <- weightedMean(x, w) 224s + str(list(m0 = m0, m1 = m1)) 224s + stopifnot(identical(m1, m0)) 224s + 224s + cat("First weight is 8.5\n") 224s + # Put even more weight on the zero 224s + w[1] <- 8.5 224s + m0 <- weighted.mean(x, w) 224s + m1 <- weightedMean(x, w) 224s + str(list(m0 = m0, m1 = m1)) 224s + stopifnot(identical(m1, m0)) 224s + 224s + cat("First weight is Inf\n") 224s + # All weight on the first value 224s + w[1] <- Inf 224s + m0 <- weighted.mean(x, w) 224s + m1 <- weightedMean(x, w) 224s + str(list(m0 = m0, m1 = m1)) 224s + stopifnot(identical(m1, m0)) 224s + 224s + cat("Last weight is Inf\n") 224s + # All weight on the last value 224s + w[1] <- 1 224s + w[n] <- Inf 224s + m0 <- weighted.mean(x, w) 224s + m1 <- weightedMean(x, w) 224s + str(list(m0 = m0, m1 = m1)) 224s + stopifnot(identical(m1, m0)) 224s + } # for (mode ...) 224s mode: logical logi [1:2] FALSE TRUE 224s All weights are 1 224s List of 2 224s $ m0: num 0.5 224s $ m1: num 0.5 224s First weight is 5 224s num [1:2] 5 1 224s List of 2 224s $ m0: num 0.167 224s $ m1: num 0.167 224s All weights are 0 224s List of 2 224s $ m0: num NaN 224s $ m1: num NaN 224s First weight is 8.5 224s List of 2 224s $ m0: num 0 224s $ m1: num 0 224s First weight is Inf 224s List of 2 224s $ m0: num NaN 224s $ m1: num NaN 224s Last weight is Inf 224s List of 2 224s $ m0: num NaN 224s $ m1: num NaN 224s mode: integer int [1:2] -1 -3 224s All weights are 1 224s List of 2 224s $ m0: num -2 224s $ m1: num -2 224s First weight is 5 224s num [1:2] 5 1 224s List of 2 224s $ m0: num -1.33 224s $ m1: num -1.33 224s All weights are 0 224s List of 2 224s $ m0: num NaN 224s $ m1: num NaN 224s First weight is 8.5 224s List of 2 224s $ m0: num -1 224s $ m1: num -1 224s First weight is Inf 224s List of 2 224s $ m0: num NaN 224s $ m1: num NaN 224s Last weight is Inf 224s List of 2 224s $ m0: num NaN 224s $ m1: num NaN 224s mode: double num [1:2] -2.75 3.2 224s All weights are 1 224s List of 2 224s $ m0: num 0.224 224s $ m1: num 0.224 224s First weight is 5 224s num [1:2] 5 1 224s List of 2 224s $ m0: num -1.76 224s $ m1: num -1.76 224s All weights are 0 224s List of 2 224s $ m0: num NaN 224s $ m1: num NaN 224s First weight is 8.5 224s List of 2 224s $ m0: num -2.75 224s $ m1: num -2.75 224s First weight is Inf 224s List of 2 224s $ m0: num NaN 224s $ m1: num NaN 224s Last weight is Inf 224s List of 2 224s $ m0: num NaN 224s $ m1: num NaN 224s > 224s > 224s > message("*** Testing for missing values") 224s *** Testing for missing values 224s > # NA tests 224s > xs <- list(A = c(1, 2, 3), B = c(NA, 2, 3), C = c(NA, 2, 3)) 224s > ws <- list(A = c(1, 1, 1), B = c(NA, 1, 1), C = c(1, NA, 1)) 224s > ## NOTE: The (B, B) case with na.rm = TRUE is interesting because 224s > ## even if NAs in 'w' are not dropped by na.rm = TRUE, this one 224s > ## is because 'x' is dropped and therefore that first element 224s > ## is skipped in the computation. It basically does 224s > ## keep <- !is.na(x); x <- x[keep]; w <- w[keep] 224s > ## without looking at 'w'. 224s > for (x in xs) { 224s + for (mode in c("logical", "integer", "double")) { 224s + storage.mode(x) <- mode 224s + for (w in ws) { 224s + for (na.rm in c(FALSE, TRUE)) { 224s + cat(sprintf("mode: %s, na.rm = %s\n", mode, na.rm)) 224s + str(list(x = x, w = w)) 224s + m0 <- weighted.mean(x, w, na.rm = na.rm) 224s + m1 <- weightedMean(x, w, na.rm = na.rm) 224s + str(list(m0 = m0, m1 = m1)) 224s + stopifnot(all.equal(m1, m0)) 224s + } 224s + } 224s + } 224s + } 224s mode: logical, na.rm = FALSE 224s List of 2 224s $ x: logi [1:3] TRUE TRUE TRUE 224s $ w: num [1:3] 1 1 1 224s List of 2 224s $ m0: num 1 224s $ m1: num 1 224s mode: logical, na.rm = TRUE 224s List of 2 224s $ x: logi [1:3] TRUE TRUE TRUE 224s $ w: num [1:3] 1 1 1 224s List of 2 224s $ m0: num 1 224s $ m1: num 1 224s mode: logical, na.rm = FALSE 224s List of 2 224s $ x: logi [1:3] TRUE TRUE TRUE 224s $ w: num [1:3] NA 1 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: logical, na.rm = TRUE 224s List of 2 224s $ x: logi [1:3] TRUE TRUE TRUE 224s $ w: num [1:3] NA 1 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: logical, na.rm = FALSE 224s List of 2 224s $ x: logi [1:3] TRUE TRUE TRUE 224s $ w: num [1:3] 1 NA 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: logical, na.rm = TRUE 224s List of 2 224s $ x: logi [1:3] TRUE TRUE TRUE 224s $ w: num [1:3] 1 NA 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: integer, na.rm = FALSE 224s List of 2 224s $ x: int [1:3] 1 1 1 224s $ w: num [1:3] 1 1 1 224s List of 2 224s $ m0: num 1 224s $ m1: num 1 224s mode: integer, na.rm = TRUE 224s List of 2 224s $ x: int [1:3] 1 1 1 224s $ w: num [1:3] 1 1 1 224s List of 2 224s $ m0: num 1 224s $ m1: num 1 224s mode: integer, na.rm = FALSE 224s List of 2 224s $ x: int [1:3] 1 1 1 224s $ w: num [1:3] NA 1 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: integer, na.rm = TRUE 224s List of 2 224s $ x: int [1:3] 1 1 1 224s $ w: num [1:3] NA 1 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: integer, na.rm = FALSE 224s List of 2 224s $ x: int [1:3] 1 1 1 224s $ w: num [1:3] 1 NA 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: integer, na.rm = TRUE 224s List of 2 224s $ x: int [1:3] 1 1 1 224s $ w: num [1:3] 1 NA 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: double, na.rm = FALSE 224s List of 2 224s $ x: num [1:3] 1 1 1 224s $ w: num [1:3] 1 1 1 224s List of 2 224s $ m0: num 1 224s $ m1: num 1 224s mode: double, na.rm = TRUE 224s List of 2 224s $ x: num [1:3] 1 1 1 224s $ w: num [1:3] 1 1 1 224s List of 2 224s $ m0: num 1 224s $ m1: num 1 224s mode: double, na.rm = FALSE 224s List of 2 224s $ x: num [1:3] 1 1 1 224s $ w: num [1:3] NA 1 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: double, na.rm = TRUE 224s List of 2 224s $ x: num [1:3] 1 1 1 224s $ w: num [1:3] NA 1 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: double, na.rm = FALSE 224s List of 2 224s $ x: num [1:3] 1 1 1 224s $ w: num [1:3] 1 NA 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: double, na.rm = TRUE 224s List of 2 224s $ x: num [1:3] 1 1 1 224s $ w: num [1:3] 1 NA 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: logical, na.rm = FALSE 224s List of 2 224s $ x: logi [1:3] NA TRUE TRUE 224s $ w: num [1:3] 1 1 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: logical, na.rm = TRUE 224s List of 2 224s $ x: logi [1:3] NA TRUE TRUE 224s $ w: num [1:3] 1 1 1 224s List of 2 224s $ m0: num 1 224s $ m1: num 1 224s mode: logical, na.rm = FALSE 224s List of 2 224s $ x: logi [1:3] NA TRUE TRUE 224s $ w: num [1:3] NA 1 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: logical, na.rm = TRUE 224s List of 2 224s $ x: logi [1:3] NA TRUE TRUE 224s $ w: num [1:3] NA 1 1 224s List of 2 224s $ m0: num 1 224s $ m1: num 1 224s mode: logical, na.rm = FALSE 224s List of 2 224s $ x: logi [1:3] NA TRUE TRUE 224s $ w: num [1:3] 1 NA 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: logical, na.rm = TRUE 224s List of 2 224s $ x: logi [1:3] NA TRUE TRUE 224s $ w: num [1:3] 1 NA 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: integer, na.rm = FALSE 224s List of 2 224s $ x: int [1:3] NA 1 1 224s $ w: num [1:3] 1 1 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: integer, na.rm = TRUE 224s List of 2 224s $ x: int [1:3] NA 1 1 224s $ w: num [1:3] 1 1 1 224s List of 2 224s $ m0: num 1 224s $ m1: num 1 224s mode: integer, na.rm = FALSE 224s List of 2 224s $ x: int [1:3] NA 1 1 224s $ w: num [1:3] NA 1 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: integer, na.rm = TRUE 224s List of 2 224s $ x: int [1:3] NA 1 1 224s $ w: num [1:3] NA 1 1 224s List of 2 224s $ m0: num 1 224s $ m1: num 1 224s mode: integer, na.rm = FALSE 224s List of 2 224s $ x: int [1:3] NA 1 1 224s $ w: num [1:3] 1 NA 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: integer, na.rm = TRUE 224s List of 2 224s $ x: int [1:3] NA 1 1 224s $ w: num [1:3] 1 NA 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: double, na.rm = FALSE 224s List of 2 224s $ x: num [1:3] NA 1 1 224s $ w: num [1:3] 1 1 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: double, na.rm = TRUE 224s List of 2 224s $ x: num [1:3] NA 1 1 224s $ w: num [1:3] 1 1 1 224s List of 2 224s $ m0: num 1 224s $ m1: num 1 224s mode: double, na.rm = FALSE 224s List of 2 224s $ x: num [1:3] NA 1 1 224s $ w: num [1:3] NA 1 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: double, na.rm = TRUE 224s List of 2 224s $ x: num [1:3] NA 1 1 224s $ w: num [1:3] NA 1 1 224s List of 2 224s $ m0: num 1 224s $ m1: num 1 224s mode: double, na.rm = FALSE 224s List of 2 224s $ x: num [1:3] NA 1 1 224s $ w: num [1:3] 1 NA 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: double, na.rm = TRUE 224s List of 2 224s $ x: num [1:3] NA 1 1 224s $ w: num [1:3] 1 NA 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: logical, na.rm = FALSE 224s List of 2 224s $ x: logi [1:3] NA TRUE TRUE 224s $ w: num [1:3] 1 1 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: logical, na.rm = TRUE 224s List of 2 224s $ x: logi [1:3] NA TRUE TRUE 224s $ w: num [1:3] 1 1 1 224s List of 2 224s $ m0: num 1 224s $ m1: num 1 224s mode: logical, na.rm = FALSE 224s List of 2 224s $ x: logi [1:3] NA TRUE TRUE 224s $ w: num [1:3] NA 1 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: logical, na.rm = TRUE 224s List of 2 224s $ x: logi [1:3] NA TRUE TRUE 224s $ w: num [1:3] NA 1 1 224s List of 2 224s $ m0: num 1 224s $ m1: num 1 224s mode: logical, na.rm = FALSE 224s List of 2 224s $ x: logi [1:3] NA TRUE TRUE 224s $ w: num [1:3] 1 NA 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: logical, na.rm = TRUE 224s List of 2 224s $ x: logi [1:3] NA TRUE TRUE 224s $ w: num [1:3] 1 NA 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: integer, na.rm = FALSE 224s List of 2 224s $ x: int [1:3] NA 1 1 224s $ w: num [1:3] 1 1 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: integer, na.rm = TRUE 224s List of 2 224s $ x: int [1:3] NA 1 1 224s $ w: num [1:3] 1 1 1 224s List of 2 224s $ m0: num 1 224s $ m1: num 1 224s mode: integer, na.rm = FALSE 224s List of 2 224s $ x: int [1:3] NA 1 1 224s $ w: num [1:3] NA 1 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: integer, na.rm = TRUE 224s List of 2 224s $ x: int [1:3] NA 1 1 224s $ w: num [1:3] NA 1 1 224s List of 2 224s $ m0: num 1 224s $ m1: num 1 224s mode: integer, na.rm = FALSE 224s List of 2 224s $ x: int [1:3] NA 1 1 224s $ w: num [1:3] 1 NA 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: integer, na.rm = TRUE 224s List of 2 224s $ x: int [1:3] NA 1 1 224s $ w: num [1:3] 1 NA 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: double, na.rm = FALSE 224s List of 2 224s $ x: num [1:3] NA 1 1 224s $ w: num [1:3] 1 1 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: double, na.rm = TRUE 224s List of 2 224s $ x: num [1:3] NA 1 1 224s $ w: num [1:3] 1 1 1 224s List of 2 224s $ m0: num 1 224s $ m1: num 1 224s mode: double, na.rm = FALSE 224s List of 2 224s $ x: num [1:3] NA 1 1 224s $ w: num [1:3] NA 1 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: double, na.rm = TRUE 224s List of 2 224s $ x: num [1:3] NA 1 1 224s $ w: num [1:3] NA 1 1 224s List of 2 224s $ m0: num 1 224s $ m1: num 1 224s mode: double, na.rm = FALSE 224s List of 2 224s $ x: num [1:3] NA 1 1 224s $ w: num [1:3] 1 NA 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s mode: double, na.rm = TRUE 224s List of 2 224s $ x: num [1:3] NA 1 1 224s $ w: num [1:3] 1 NA 1 224s List of 2 224s $ m0: num NA 224s $ m1: num NA 224s > 224s 224s R version 4.4.3 (2025-02-28) -- "Trophy Case" 224s Copyright (C) 2025 The R Foundation for Statistical Computing 224s Platform: s390x-ibm-linux-gnu 224s 224s R is free software and comes with ABSOLUTELY NO WARRANTY. 224s You are welcome to redistribute it under certain conditions. 224s Type 'license()' or 'licence()' for distribution details. 224s 224s R is a collaborative project with many contributors. 224s Type 'contributors()' for more information and 224s 'citation()' on how to cite R or R packages in publications. 224s 224s Type 'demo()' for some demos, 'help()' for on-line help, or 224s 'help.start()' for an HTML browser interface to help. 224s Type 'q()' to quit R. 224s 224s > library("matrixStats") 224s > 224s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 224s > # Subsetted tests 224s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 224s > source("utils/validateIndicesFramework.R") 224s > for (mode in c("numeric", "integer")) { 224s + x <- runif(6, min = -6, max = 6) 224s + w <- runif(6, min = 0, max = 6) 224s + storage.mode(x) <- mode 224s + storage.mode(w) <- mode 224s + if (mode == "numeric") w[1] <- Inf 224s + 224s + for (idxs in index_cases) { 224s + validateIndicesTestVector_w(x, w, idxs, 224s + ftest = weightedMean, fsure = weighted.mean, 224s + na.rm = TRUE, refine = TRUE) 224s + validateIndicesTestVector_w(x, w, idxs, 224s + ftest = weightedMean, fsure = weighted.mean, 224s + na.rm = FALSE, refine = TRUE) 224s + } 224s + } 224s > 225s 225s R version 4.4.3 (2025-02-28) -- "Trophy Case" 225s Copyright (C) 2025 The R Foundation for Statistical Computing 225s Platform: s390x-ibm-linux-gnu 225s 225s R is free software and comes with ABSOLUTELY NO WARRANTY. 225s You are welcome to redistribute it under certain conditions. 225s Type 'license()' or 'licence()' for distribution details. 225s 225s R is a collaborative project with many contributors. 225s Type 'contributors()' for more information and 225s 'citation()' on how to cite R or R packages in publications. 225s 225s Type 'demo()' for some demos, 'help()' for on-line help, or 225s 'help.start()' for an HTML browser interface to help. 225s Type 'q()' to quit R. 225s 225s > library("matrixStats") 225s > 225s > x <- 1:5 225s > y <- weightedMedian(x) 225s > y <- weightedMedian(x, w = c(NA, Inf, NA, Inf, NA), na.rm = TRUE) 225s > print(y) 225s [1] 3 225s > 225s > y <- weightedMedian(x, w = c(NA, Inf, NA, Inf, NA), na.rm = FALSE) 225s > print(y) 225s [1] NA 225s > stopifnot(is.na(y)) 225s > 225s > x <- 1:10 225s > n <- length(x) 225s > 225s > y1 <- median(x) # 5.5 225s > y2 <- weightedMedian(x) # 5.5 225s > stopifnot(all.equal(y1, y2)) 225s > 225s > 225s > w <- rep(1, times = n) 225s > y1 <- weightedMedian(x, w) # 5.5 (default) 225s > y2a <- weightedMedian(x, ties = "weighted") # 5.5 (default) 225s > y2b <- weightedMedian(x, ties = "min") # 5 225s > y2c <- weightedMedian(x, ties = "max") # 6 225s > stopifnot(all.equal(y2a, y1)) 225s > 225s > y3 <- weightedMedian(x, w) # 5.5 (default) 225s > 225s > 225s > # Pull the median towards zero 225s > w[1] <- 5 225s > y1 <- weightedMedian(x, w) # 3.5 225s > y <- c(rep(0, times = w[1]), x[-1]) # Only possible for integer weights 225s > y2 <- median(y) # 3.5 225s > stopifnot(all.equal(y1, y2)) 225s > 225s > # Put even more weight on the zero 225s > w[1] <- 8.5 225s > y <- weightedMedian(x, w) # 2 225s > 225s > # All weight on the first value 225s > w[1] <- Inf 225s > y <- weightedMedian(x, w) # 1 225s > 225s > # All weight on the last value 225s > w[1] <- 1 225s > w[n] <- Inf 225s > y <- weightedMedian(x, w) # 10 225s > 225s > # All weights set to zero 225s > w <- rep(0, times = n) 225s > y <- weightedMedian(x, w) # NA 225s > 225s > x <- 1:4 225s > w <- rep(1, times = 4) 225s > for (mode in c("integer", "double")) { 225s + storage.mode(x) <- mode 225s + for (ties in c("weighted", "mean", "min", "max")) { 225s + cat(sprintf("ties = %s\n", ties)) 225s + y <- weightedMedian(x, w, ties = ties) 225s + } 225s + } 225s ties = weighted 225s ties = mean 225s ties = min 225s ties = max 225s ties = weighted 225s ties = mean 225s ties = min 225s ties = max 225s > 225s > set.seed(0x42) 225s > 225s > y <- weightedMedian(x = double(0L)) 225s > print(y) 225s [1] NA 225s > stopifnot(length(y) == 1L) 225s > stopifnot(is.na(y)) 225s > 225s > y <- weightedMedian(x = x[1]) 225s > print(y) 225s [1] 1 225s > stopifnot(length(y) == 1L) 225s > stopifnot(all.equal(y, x[1])) 225s > 225s > 225s > n <- 1e3 225s > x <- runif(n) 225s > w <- runif(n, min = 0, max = 1) 225s > for (mode in c("integer", "double")) { 225s + storage.mode(x) <- mode 225s + for (ties in c("weighted", "mean", "min", "max")) { 225s + y <- weightedMedian(x, w, ties = ties) 225s + cat(sprintf("mode = %s, ties = %s, result = %g\n", mode, ties, y)) 225s + } 225s + } 225s mode = integer, ties = weighted, result = 0 225s mode = integer, ties = mean, result = 0 225s mode = integer, ties = min, result = 0 225s mode = integer, ties = max, result = 0 225s mode = double, ties = weighted, result = 0 225s mode = double, ties = mean, result = 0 225s mode = double, ties = min, result = 0 225s mode = double, ties = max, result = 0 225s > 225s > 225s > # A large vector 225s > n <- 1e5 225s > x <- runif(n) 225s > w <- runif(n, min = 0, max = 1) 225s > y <- weightedMedian(x, w) 225s > 225s > y <- weightedMedian(x, w, ties = "min") 225s > 225s > 225s > # Single Number 225s > xs <- c(1, NA_integer_) 225s > ws <- c(1, NA_integer_) 225s > for (x in xs) { 225s + for (w in ws) { 225s + y <- weightedMedian(x = x, w = w) 225s + if (is.na(w)) z <- NA_real_ 225s + else z <- x[1] 225s + stopifnot(all.equal(y, z)) 225s + } 225s + } 225s > 225s > ## Logical 225s > x1 <- c(TRUE, FALSE, TRUE) 225s > w0 <- c(0, 0, 0) 225s > stopifnot(!is.finite(weightedMedian(x1, w0)), 225s + !is.infinite(weightedMedian(x1, w0))) 225s > 225s > w1 <- c(1, 1, 1) 225s > stopifnot(weightedMedian(x1, w1) == 1) 225s > 225s > w2 <- c(1, 2, 3) 225s > stopifnot(weightedMedian(x1, w2) == 1) 225s > 225s > ### NA 225s > stopifnot(is.na(weightedMedian(c(TRUE, FALSE, NA), 225s + c(1, 2, 3))), 225s + all.equal(weightedMedian(c(TRUE, FALSE, NA), 225s + c(1, 2, 3), 225s + na.rm = TRUE), 225s + weightedMedian(c(TRUE, FALSE), 225s + c(1, 2)))) 225s > ### Identical to as.integer() 225s > x <- rcauchy(100) 225s > w <- abs(rcauchy(100)) 225s > stopifnot(all.equal(weightedMedian(x > 0, w), 225s + weightedMedian(as.integer(x > 0), w))) 225s > 225s > 225s > 225s 225s R version 4.4.3 (2025-02-28) -- "Trophy Case" 225s Copyright (C) 2025 The R Foundation for Statistical Computing 225s Platform: s390x-ibm-linux-gnu 225s 225s R is free software and comes with ABSOLUTELY NO WARRANTY. 225s You are welcome to redistribute it under certain conditions. 225s Type 'license()' or 'licence()' for distribution details. 225s 225s R is a collaborative project with many contributors. 225s Type 'contributors()' for more information and 225s 'citation()' on how to cite R or R packages in publications. 225s 225s Type 'demo()' for some demos, 'help()' for on-line help, or 225s 'help.start()' for an HTML browser interface to help. 225s Type 'q()' to quit R. 225s 225s > library("matrixStats") 225s > 225s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 225s > # Subsetted tests 225s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 225s > source("utils/validateIndicesFramework.R") 225s > for (mode in c("numeric", "integer")) { 225s + x <- runif(6, min = -6, max = 6) 225s + w <- runif(6, min = 0, max = 6) 225s + storage.mode(x) <- mode 225s + storage.mode(w) <- mode 225s + if (mode == "numeric") w[1] <- Inf 225s + 225s + for (idxs in index_cases) { 225s + validateIndicesTestVector_w(x, w, idxs, 225s + ftest = weightedMedian, 225s + fsure = weightedMedian, 225s + na.rm = TRUE) 225s + validateIndicesTestVector_w(x, w, idxs, 225s + ftest = weightedMedian, 225s + fsure = weightedMedian, 225s + na.rm = FALSE) 225s + 225s + for (ties in c("weighted", "mean", "min", "max")) { 225s + validateIndicesTestVector_w(x, w, idxs, 225s + ftest = weightedMedian, 225s + fsure = weightedMedian, 225s + na.rm = TRUE, ties = ties) 225s + validateIndicesTestVector_w(x, w, idxs, 225s + ftest = weightedMedian, 225s + fsure = weightedMedian, 225s + na.rm = FALSE, ties = ties) 225s + } 225s + } 225s + } 225s > 225s 225s R version 4.4.3 (2025-02-28) -- "Trophy Case" 225s Copyright (C) 2025 The R Foundation for Statistical Computing 225s Platform: s390x-ibm-linux-gnu 225s 225s R is free software and comes with ABSOLUTELY NO WARRANTY. 225s You are welcome to redistribute it under certain conditions. 225s Type 'license()' or 'licence()' for distribution details. 225s 225s R is a collaborative project with many contributors. 225s Type 'contributors()' for more information and 225s 'citation()' on how to cite R or R packages in publications. 225s 225s Type 'demo()' for some demos, 'help()' for on-line help, or 225s 'help.start()' for an HTML browser interface to help. 225s Type 'q()' to quit R. 225s 225s > library("matrixStats") 225s > 225s > weightedVar_R <- function(x, w) { 225s + mu <- weighted.mean(x, w = w) 225s + sum(w * (x - mu) ^ 2) / (sum(w) - 1) 225s + } 225s > 225s > 225s > n <- 10 225s > x <- as.double(1:n) 225s > 225s > message("*** weightedVar() ...") 225s > 225s > message("- Zero elements") 225s > m0 <- var(integer(0)) 225s *** weightedVar() ... 225s - Zero elements 225s > m1 <- weightedVar(integer(0), w = integer(0)) 225s > str(list(m0 = m0, m1 = m1)) 225s List of 2 225s $ m0: num NA 225s $ m1: int NA 225s > stopifnot(all.equal(m1, m0)) 225s > 225s > 225s > message("- One elements") 225s - One elements 225s > m0 <- var(1) 225s > m1 <- weightedVar(1) 225s > str(list(m0 = m0, m1 = m1)) 225s List of 2 225s $ m0: num NA 225s $ m1: num NA 225s > stopifnot(all.equal(m1, m0)) 225s > 225s > 225s > message("- Uniform weights (all w = 1)") 225s - Uniform weights (all w = 1) 225s > m0 <- var(x) 225s > w <- rep(1, times = n) 225s > m1 <- weightedVar(x, w = w) 225s > str(list(m0 = m0, m1 = m1)) 225s List of 2 225s $ m0: num 9.17 225s $ m1: num 9.17 225s > stopifnot(all.equal(m1, m0)) 225s > 225s > 225s > message("- Uniform weights (all w = 3)") 225s > m0 <- var(rep(x, each = 3)) 225s - Uniform weights (all w = 3) 225s > w <- rep(3, times = n) 225s > m1 <- weightedVar(x, w = w) 225s > str(list(m0 = m0, m1 = m1)) 225s List of 2 225s $ m0: num 8.53 225s $ m1: num 8.53 225s > stopifnot(all.equal(m1, m0)) 225s > 225s > 225s > message("- Uniform weights on the first five elements") 225s > idxs <- 1:5 225s > m0 <- var(x[1:5]) 225s > w <- rep(0, times = n) 225s > w[idxs] <- 1 225s > m1 <- weightedVar(x, w = w) 225s - Uniform weights on the first five elements 225s > str(list(m0 = m0, m1 = m1)) 225s List of 2 225s $ m0: num 2.5 225s $ m1: num 2.5 225s > stopifnot(all.equal(m1, m0)) 225s > 225s > 225s > message("- Uniform weights on every second elements") 225s > idxs <- seq(from = 1, to = n, by = 2) 225s - Uniform weights on every second elements 225s > m0 <- var(x[idxs]) 225s > w <- rep(0, times = n) 225s > w[idxs] <- 1 225s > m1 <- weightedVar(x, w = w) 225s > str(list(m0 = m0, m1 = m1)) 225s List of 2 225s $ m0: num 10 225s $ m1: num 10 225s > stopifnot(all.equal(m1, m0)) 225s > 225s - All weights are zero 225s > 225s > message("- All weights are zero") 225s > idxs <- integer(0L) 225s > m0 <- var(x[idxs]) 225s > w <- rep(0, times = n) 225s > w[idxs] <- 1 225s > m1 <- weightedVar(x, w = w) 225s > str(list(m0 = m0, m1 = m1)) 225s List of 2 225s $ m0: num NA 225s $ m1:- Infinite weight on first element 225s num NA 225s > stopifnot(all.equal(m1, m0)) 225s > 225s > message("- Infinite weight on first element") 225s > idxs <- 1L 225s > m0 <- var(x[idxs]) 225s > w <- rep(0, times = n) 225s > w[idxs] <- Inf 225s > m1 <- weightedVar(x, w = w) 225s > str(list(m0 = m0, m1 = m1)) 225s List of 2 225s $ m0: num NA 225s $ m1: num NA 225s > stopifnot(all.equal(m1, m0)) 225s > 225s > message("- Missing-value weight on first element") 225s - Missing-value weight on first element 225s > idxs <- 1L 225s > w <- rep(1, times = n) 225s > w[idxs] <- NA_real_ 225s > m1 <- weightedVar(x, w = w) 225s > str(list(m1 = m1)) 225s List of 1 225s $ m1: num NA 225s > stopifnot(identical(m1, NA_real_)) 225s > 225s > 225s - Frequency weights 225s > message("- Frequency weights") 225s > 225s > ## From https://en.wikipedia.org/wiki/Weighted_arithmetic_mean 225s > y <- c(2, 2, 4, 5, 5, 5) 225s > x <- unique(y) 225s > w <- table(y) 225s > stopifnot(names(w) == x) 225s > 225s > m0 <- weightedVar(x, w = w) 225s > m1 <- var(y) 225s > stopifnot(all.equal(m1, m0)) 225s > m2 <- weightedVar(x, w = w) 225s > str(list(m0 = m0, m1 = m1, m2 = m2)) 225s List of 3 225s $ m0: num 2.17 225s $ m1: num 2.17 225s $ m2: num 2.17 225s > stopifnot(all.equal(m2, m0)) 225s > 225s > ## From https://github.com/HenrikBengtsson/matrixStats/issues/72 225s > large <- c(21, 8, 26, 1, 15, 33, 12, 25, 0, 84) 225s > years <- c(41706, 9301, 33678, 3082, 27040, 44188, 10049, 30591, 2275, 109831) 225s > 225s > m0 <- weightedVar(large, w = years) 225s > m1 <- weightedVar(large, w = years) 225s > str(list(m0 = m0, m1 = m1)) 225s List of 2 225s $ m0: num 899 225s $ m1: num 899 225s > stopifnot(all.equal(m1, m0)) 225s > 225s > message("*** weightedVar() ... DONE") 225s > 225s *** weightedVar() ... DONE 225s 225s R version 4.4.3 (2025-02-28) -- "Trophy Case" 225s Copyright (C) 2025 The R Foundation for Statistical Computing 225s Platform: s390x-ibm-linux-gnu 225s 225s R is free software and comes with ABSOLUTELY NO WARRANTY. 225s You are welcome to redistribute it under certain conditions. 225s Type 'license()' or 'licence()' for distribution details. 225s 225s R is a collaborative project with many contributors. 225s Type 'contributors()' for more information and 225s 'citation()' on how to cite R or R packages in publications. 225s 225s Type 'demo()' for some demos, 'help()' for on-line help, or 225s 'help.start()' for an HTML browser interface to help. 225s Type 'q()' to quit R. 225s 225s > library("matrixStats") 225s > 225s > fcns <- list( 225s + weightedVar = weightedVar, 225s + weightedSd = weightedSd, 225s + weightedMad = weightedMad 225s + ) 225s > 225s > for (name in names(fcns)) { 225s + cat(sprintf("%s()...\n", name)) 225s + fcn <- fcns[[name]] 225s + 225s + for (mode in c("integer", "double")) { 225s + cat("mode: ", mode, "\n", sep = "") 225s + n <- 15L 225s + x <- runif(n, min = -5, max = 5) 225s + storage.mode(x) <- mode 225s + str(x) 225s + 225s + for (add_na in c(FALSE, TRUE)) { 225s + cat("add_na: ", add_na, "\n", sep = "") 225s + if (add_na) { 225s + x[c(5, 7)] <- NA 225s + } 225s + str(x) 225s + 225s + for (na.rm in c(FALSE, TRUE)) { 225s + cat("na.rm: ", na.rm, "\n", sep = "") 225s + 225s + cat("Weights are not specified (all are 1)\n") 225s + m1 <- fcn(x, na.rm = na.rm) 225s + str(list(m1 = m1)) 225s + 225s + cat("All weights are 1\n") 225s + w <- rep(1, times = n) 225s + m1 <- fcn(x, w, na.rm = na.rm) 225s + str(list(m1 = m1)) 225s + 225s + cat("First weight is 5\n") 225s + # Pull the mean towards zero 225s + w[1] <- 5 225s + str(w) 225s + m1 <- fcn(x, w, na.rm = na.rm) 225s + str(list(m1 = m1)) 225s + 225s + cat("All weights are 0\n") 225s + # All weights set to zero 225s + w <- rep(0, times = n) 225s + m1 <- fcn(x, w, na.rm = na.rm) 225s + str(list(m1 = m1)) 225s + 225s + cat("First weight is 8.5\n") 225s + # Put even more weight on the zero 225s + w[1] <- 8.5 225s + m1 <- fcn(x, w, na.rm = na.rm) 225s + str(list(m1 = m1)) 225s + 225s + cat("First weight is Inf\n") 225s + # All weight on the first value 225s + w[1] <- Inf 225s + m1 <- fcn(x, w, na.rm = na.rm) 225s + str(list(m1 = m1)) 225s + 225s + cat("Last weight is Inf\n") 225s + # All weight on the last value 225s + w[1] <- 1 225s + w[n] <- Inf 225s + m1 <- fcn(x, w, na.rm = na.rm) 225s + str(list(m1 = m1)) 225s + 225s + cat("Last weight is NA\n") 225s + # All weight on the last value 225s + w[1] <- 1 225s + w[n] <- NA_real_ 225s + m1 <- fcn(x, w, na.rm = na.rm) 225s + str(list(m1 = m1)) 225s + } # for (na.rm ...) 225s + } # for (add_na ...) 225s + } # for (mode ...) 225s + 225s + cat(sprintf("%s()...DONE\n", name)) 225s + } # for (name ...) 225s weightedVar()... 225s mode: integer 225s int [1:15] -3 -3 -3 -1 0 2 -3 -3 -4 -2 ... 225s add_na: FALSE 225s int [1:15] -3 -3 -3 -1 0 2 -3 -3 -4 -2 ... 225s na.rm: FALSE 225s Weights are not specified (all are 1) 225s List of 1 225s $ m1: num 7.69 225s All weights are 1 225s List of 1 225s $ m1: num 7.69 225s First weight is 5 225s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 225s List of 1 225s $ m1: num 6.99 225s All weights are 0 225s List of 1 225s $ m1: int NA 225s First weight is 8.5 225s List of 1 225s $ m1: int NA 225s First weight is Inf 225s List of 1 225s $ m1: int NA 225s Last weight is Inf 225s List of 1 225s $ m1: int NA 225s Last weight is NA 225s List of 1 225s $ m1: int NA 225s na.rm: TRUE 225s Weights are not specified (all are 1) 225s List of 1 225s $ m1: num 7.69 225s All weights are 1 225s List of 1 225s $ m1: num 7.69 225s First weight is 5 225s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 225s List of 1 225s $ m1: num 6.99 225s All weights are 0 225s List of 1 225s $ m1: int NA 225s First weight is 8.5 225s List of 1 225s $ m1: int NA 225s First weight is Inf 225s List of 1 225s $ m1: int NA 225s Last weight is Inf 225s List of 1 225s $ m1: int NA 225s Last weight is NA 225s List of 1 225s $ m1: int NA 225s add_na: TRUE 225s int [1:15] -3 -3 -3 -1 NA 2 NA -3 -4 -2 ... 225s na.rm: FALSE 225s Weights are not specified (all are 1) 225s List of 1 225s $ m1: int NA 225s All weights are 1 225s List of 1 225s $ m1: int NA 225s First weight is 5 225s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 225s List of 1 225s $ m1: int NA 225s All weights are 0 225s List of 1 225s $ m1: int NA 225s First weight is 8.5 225s List of 1 225s $ m1: int NA 225s First weight is Inf 225s List of 1 225s $ m1: int NA 225s Last weight is Inf 225s List of 1 225s $ m1: int NA 225s Last weight is NA 225s List of 1 225s $ m1: int NA 225s na.rm: TRUE 225s Weights are not specified (all are 1) 225s List of 1 225s $ m1: num 8.44 225s All weights are 1 225s List of 1 225s $ m1: num 8.44 225s First weight is 5 225s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 225s List of 1 225s $ m1: num 7.56 225s All weights are 0 225s List of 1 225s $ m1: int NA 225s First weight is 8.5 225s List of 1 225s $ m1: int NA 225s First weight is Inf 225s List of 1 225s $ m1: int NA 225s Last weight is Inf 225s List of 1 225s $ m1: int NA 225s Last weight is NA 225s List of 1 225s $ m1: int NA 225s mode: double 225s num [1:15] -3.587 0.409 -4.13 3.292 -1.165 ... 225s add_na: FALSE 225s num [1:15] -3.587 0.409 -4.13 3.292 -1.165 ... 225s na.rm: FALSE 225s Weights are not specified (all are 1) 225s List of 1 225s $ m1: num 12 225s All weights are 1 225s List of 1 225s $ m1: num 12 225s First weight is 5 225s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 225s List of 1 225s $ m1: num 11.9 225s All weights are 0 225s List of 1 225s $ m1: num NA 225s First weight is 8.5 225s List of 1 225s $ m1: num NA 225s First weight is Inf 225s List of 1 225s $ m1: num NA 225s Last weight is Inf 225s List of 1 225s $ m1: num NA 225s Last weight is NA 225s List of 1 225s $ m1: num NA 225s na.rm: TRUE 225s Weights are not specified (all are 1) 225s List of 1 225s $ m1: num 12 225s All weights are 1 225s List of 1 225s $ m1: num 12 225s First weight is 5 225s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 225s List of 1 225s $ m1: num 11.9 225s All weights are 0 225s List of 1 225s $ m1: num NA 225s First weight is 8.5 225s List of 1 225s $ m1: num NA 225s First weight is Inf 225s List of 1 225s $ m1: num NA 225s Last weight is Inf 225s List of 1 225s $ m1: num NA 225s Last weight is NA 225s List of 1 225s $ m1: num NA 225s add_na: TRUE 225s num [1:15] -3.587 0.409 -4.13 3.292 NA ... 225s na.rm: FALSE 225s Weights are not specified (all are 1) 225s List of 1 225s $ m1: num NA 225s All weights are 1 225s List of 1 225s $ m1: num NA 225s First weight is 5 225s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 225s List of 1 225s $ m1: num NA 225s All weights are 0 225s List of 1 225s $ m1: num NA 225s First weight is 8.5 225s List of 1 225s $ m1: num NA 225s First weight is Inf 225s List of 1 225s $ m1: num NA 225s Last weight is Inf 225s List of 1 225s $ m1: num NA 225s Last weight is NA 225s List of 1 225s $ m1: num NA 225s na.rm: TRUE 225s Weights are not specified (all are 1) 225s List of 1 225s $ m1: num 11.7 225s All weights are 1 225s List of 1 225s $ m1: num 11.7 225s First weight is 5 225s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 225s List of 1 225s $ m1: num 12.3 225s All weights are 0 225s List of 1 225s $ m1: num NA 225s First weight is 8.5 225s List of 1 225s $ m1: num NA 225s First weight is Inf 225s List of 1 225s $ m1: num NA 225s Last weight is Inf 225s List of 1 225s $ m1: num NA 225s Last weight is NA 225s List of 1 225s $ m1: num NA 225s weightedVar()...DONE 225s weightedSd()... 225s mode: integer 225s int [1:15] 3 3 0 -1 -2 0 -2 0 1 1 ... 225s add_na: FALSE 225s int [1:15] 3 3 0 -1 -2 0 -2 0 1 1 ... 225s na.rm: FALSE 225s Weights are not specified (all are 1) 225s List of 1 225s $ m1: num 2.31 225s All weights are 1 225s List of 1 225s $ m1: num 2.31 225s First weight is 5 225s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 225s List of 1 225s $ m1: num 2.35 225s All weights are 0 225s List of 1 225s $ m1: num NA 225s First weight is 8.5 225s List of 1 225s $ m1: num NA 225s First weight is Inf 225s List of 1 225s $ m1: num NA 225s Last weight is Inf 225s List of 1 225s $ m1: num NA 225s Last weight is NA 225s List of 1 225s $ m1: num NA 225s na.rm: TRUE 225s Weights are not specified (all are 1) 225s List of 1 225s $ m1: num 2.31 225s All weights are 1 225s List of 1 225s $ m1: num 2.31 225s First weight is 5 225s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 225s List of 1 225s $ m1: num 2.35 225s All weights are 0 225s List of 1 225s $ m1: num NA 225s First weight is 8.5 225s List of 1 225s $ m1: num NA 225s First weight is Inf 225s List of 1 225s $ m1: num NA 225s Last weight is Inf 225s List of 1 225s $ m1: num NA 225s Last weight is NA 225s List of 1 225s $ m1: num NA 225s add_na: TRUE 225s int [1:15] 3 3 0 -1 NA 0 NA 0 1 1 ... 225s na.rm: FALSE 225s Weights are not specified (all are 1) 225s List of 1 225s $ m1: num NA 225s All weights are 1 225s List of 1 225s $ m1: num NA 225s First weight is 5 225s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 225s List of 1 225s $ m1: num NA 225s All weights are 0 225s List of 1 225s $ m1: num NA 225s First weight is 8.5 225s List of 1 225s $ m1: num NA 225s First weight is Inf 225s List of 1 225s $ m1: num NA 225s Last weight is Inf 225s List of 1 225s $ m1: num NA 225s Last weight is NA 225s List of 1 225s $ m1: num NA 225s na.rm: TRUE 225s Weights are not specified (all are 1) 225s List of 1 225s $ m1: num 2.3 225s All weights are 1 225s List of 1 225s $ m1: num 2.3 225s First weight is 5 225s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 225s List of 1 225s $ m1: num 2.26 225s All weights are 0 225s List of 1 225s $ m1: num NA 225s First weight is 8.5 225s List of 1 225s $ m1: num NA 225s First weight is Inf 225s List of 1 225s $ m1: num NA 225s Last weight is Inf 225s List of 1 225s $ m1: num NA 225s Last weight is NA 225s List of 1 225s $ m1: num NA 225s mode: double 225s num [1:15] 0.587 0.453 -2.808 0.407 -2.04 ... 225s add_na: FALSE 225s num [1:15] 0.587 0.453 -2.808 0.407 -2.04 ... 225s na.rm: FALSE 225s Weights are not specified (all are 1) 225s List of 1 225s $ m1: num 2.08 225s All weights are 1 225s List of 1 225s $ m1: num 2.08 225s First weight is 5 225s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 225s List of 1 225s $ m1: num 2.01 225s All weights are 0 225s List of 1 225s $ m1: num NA 225s First weight is 8.5 225s List of 1 225s $ m1: num NA 225s First weight is Inf 225s List of 1 225s $ m1: num NA 225s Last weight is Inf 225s List of 1 225s $ m1: num NA 225s Last weight is NA 225s List of 1 225s $ m1: num NA 225s na.rm: TRUE 225s Weights are not specified (all are 1) 225s List of 1 225s $ m1: num 2.08 225s All weights are 1 225s List of 1 225s $ m1: num 2.08 225s First weight is 5 225s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 225s List of 1 225s $ m1: num 2.01 225s All weights are 0 225s List of 1 225s $ m1: num NA 225s First weight is 8.5 225s List of 1 225s $ m1: num NA 225s First weight is Inf 225s List of 1 225s $ m1: num NA 225s Last weight is Inf 225s List of 1 225s $ m1: num NA 225s Last weight is NA 225s List of 1 225s $ m1: num NA 225s add_na: TRUE 225s num [1:15] 0.587 0.453 -2.808 0.407 NA ... 225s na.rm: FALSE 225s Weights are not specified (all are 1) 225s List of 1 225s $ m1: num NA 225s All weights are 1 225s List of 1 225s $ m1: num NA 225s First weight is 5 225s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 225s List of 1 225s $ m1: num NA 225s All weights are 0 225s List of 1 225s $ m1: num NA 225s First weight is 8.5 225s List of 1 225s $ m1: num NA 225s First weight is Inf 225s List of 1 225s $ m1: num NA 225s Last weight is Inf 225s List of 1 225s $ m1: num NA 225s Last weight is NA 225s List of 1 225s $ m1: num NA 225s na.rm: TRUE 225s Weights are not specified (all are 1) 225s List of 1 225s $ m1: num 2.09 225s All weights are 1 225s List of 1 225s $ m1: num 2.09 225s First weight is 5 225s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 225s List of 1 225s $ m1: num 1.95 225s All weights are 0 225s List of 1 225s $ m1: num NA 225s First weight is 8.5 225s List of 1 225s $ m1: num NA 225s First weight is Inf 225s List of 1 225s $ m1: num NA 225s Last weight is Inf 225s List of 1 225s $ m1: num NA 225s Last weight is NA 225s List of 1 225s $ m1: num NA 225s weightedSd()...DONE 225s weightedMad()... 225s mode: integer 225s int [1:15] 0 3 4 -1 0 -4 4 2 1 -3 ... 225s add_na: FALSE 225s int [1:15] 0 3 4 -1 0 -4 4 2 1 -3 ... 225s na.rm: FALSE 225s Weights are not specified (all are 1) 225s List of 1 225s $ m1: num 2.97 225s All weights are 1 225s List of 1 225s $ m1: num 2.97 225s First weight is 5 225s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 225s List of 1 225s $ m1: num 2.97 225s All weights are 0 225s List of 1 225s $ m1: int NA 225s First weight is 8.5 225s List of 1 225s $ m1: int 0 225s First weight is Inf 225s List of 1 225s $ m1: int 0 225s Last weight is Inf 225s List of 1 225s $ m1: int 0 225s Last weight is NA 225s List of 1 225s $ m1: int NA 225s na.rm: TRUE 225s Weights are not specified (all are 1) 225s List of 1 225s $ m1: num 2.97 225s All weights are 1 225s List of 1 225s $ m1: num 2.97 225s First weight is 5 225s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 225s List of 1 225s $ m1: num 2.97 225s All weights are 0 225s List of 1 225s $ m1: int NA 225s First weight is 8.5 225s List of 1 225s $ m1: int 0 225s First weight is Inf 225s List of 1 225s $ m1: int 0 225s Last weight is Inf 225s List of 1 225s $ m1: int 0 225s Last weight is NA 225s List of 1 225s $ m1: int NA 225s add_na: TRUE 225s int [1:15] 0 3 4 -1 NA -4 NA 2 1 -3 ... 225s na.rm: FALSE 225s Weights are not specified (all are 1) 225s List of 1 225s $ m1: num NA 225s All weights are 1 225s List of 1 225s $ m1: int NA 225s First weight is 5 225s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 225s List of 1 225s $ m1: int NA 225s All weights are 0 225s List of 1 225s $ m1: int NA 225s First weight is 8.5 225s List of 1 225s $ m1: int 0 225s First weight is Inf 225s List of 1 225s $ m1: int 0 225s Last weight is Inf 225s List of 1 225s $ m1: int 0 225s Last weight is NA 225s List of 1 225s $ m1: int NA 225s na.rm: TRUE 225s Weights are not specified (all are 1) 225s List of 1 225s $ m1: num 2.97 225s All weights are 1 225s List of 1 225s $ m1: num 2.97 225s First weight is 5 225s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 225s List of 1 225s $ m1: num 2.97 225s All weights are 0 225s List of 1 225s $ m1: int NA 225s First weight is 8.5 225s List of 1 225s $ m1: int 0 225s First weight is Inf 225s List of 1 225s $ m1: int 0 225s Last weight is Inf 225s List of 1 225s $ m1: int 0 225s Last weight is NA 225s List of 1 225s $ m1: int NA 225s mode: double 225s num [1:15] -4.37 -2.16 1.83 -1.06 -4.48 ... 225s add_na: FALSE 225s num [1:15] -4.37 -2.16 1.83 -1.06 -4.48 ... 225s na.rm: FALSE 225s Weights are not specified (all are 1) 225s List of 1 225s $ m1: num 4.05 225s All weights are 1 225s List of 1 225s $ m1: num 4.05 225s First weight is 5 225s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 225s List of 1 225s $ m1: num 4.88 225s All weights are 0 225s List of 1 225s $ m1: num NA 225s First weight is 8.5 225s List of 1 225s $ m1: num 0 225s First weight is Inf 225s List of 1 225s $ m1: num 0 225s Last weight is Inf 225s List of 1 225s $ m1: num 0 225s Last weight is NA 225s List of 1 225s $ m1: num NA 225s na.rm: TRUE 225s Weights are not specified (all are 1) 225s List of 1 225s $ m1: num 4.05 225s All weights are 1 225s List of 1 225s $ m1: num 4.05 225s First weight is 5 225s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 225s List of 1 225s $ m1: num 4.88 225s All weights are 0 225s List of 1 225s $ m1: num NA 225s First weight is 8.5 225s List of 1 225s $ m1: num 0 225s First weight is Inf 225s List of 1 225s $ m1: num 0 225s Last weight is Inf 225s List of 1 225s $ m1: num 0 225s Last weight is NA 225s List of 1 225s $ m1: num NA 225s add_na: TRUE 225s num [1:15] -4.37 -2.16 1.83 -1.06 NA ... 225s na.rm: FALSE 225s Weights are not specified (all are 1) 225s List of 1 225s $ m1: num NA 225s All weights are 1 225s List of 1 225s $ m1: num NA 225s First weight is 5 225s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 225s List of 1 225s $ m1: num NA 225s All weights are 0 225s List of 1 225s $ m1: num NA 225s First weight is 8.5 225s List of 1 225s $ m1: num 0 225s First weight is Inf 225s List of 1 225s $ m1: num 0 225s Last weight is Inf 225s List of 1 225s $ m1: num 0 225s Last weight is NA 225s List of 1 225s $ m1: num NA 225s na.rm: TRUE 225s Weights are not specified (all are 1) 225s List of 1 225s $ m1: num 4.05 225s All weights are 1 225s List of 1 225s $ m1: num 4.05 225s First weight is 5 225s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 225s List of 1 225s $ m1: num 4.88 225s All weights are 0 225s List of 1 225s $ m1: num NA 225s First weight is 8.5 225s List of 1 225s $ m1: num 0 225s First weight is Inf 225s List of 1 225s $ m1: num 0 225s Last weight is Inf 225s List of 1 225s $ m1: num 0 225s Last weight is NA 225s List of 1 225s $ m1: num NA 225s weightedMad()...DONE 225s > 226s 226s R version 4.4.3 (2025-02-28) -- "Trophy Case" 226s Copyright (C) 2025 The R Foundation for Statistical Computing 226s Platform: s390x-ibm-linux-gnu 226s 226s R is free software and comes with ABSOLUTELY NO WARRANTY. 226s You are welcome to redistribute it under certain conditions. 226s Type 'license()' or 'licence()' for distribution details. 226s 226s R is a collaborative project with many contributors. 226s Type 'contributors()' for more information and 226s 'citation()' on how to cite R or R packages in publications. 226s 226s Type 'demo()' for some demos, 'help()' for on-line help, or 226s 'help.start()' for an HTML browser interface to help. 226s Type 'q()' to quit R. 226s 226s > library("matrixStats") 226s > 226s > fcns <- list( 226s + weightedVar = weightedVar, 226s + weightedSd = weightedSd, 226s + weightedMad = weightedMad 226s + ) 226s > 226s > 226s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 226s > # Subsetted tests 226s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 226s > source("utils/validateIndicesFramework.R") 226s > for (name in names(fcns)) { 226s + cat(sprintf("subsetted tests on %s()...\n", name)) 226s + fcn <- fcns[[name]] 226s + 226s + for (mode in c("numeric", "integer")) { 226s + x <- runif(6, min = -6, max = 6) 226s + w <- runif(6, min = 0, max = 6) 226s + storage.mode(x) <- mode 226s + storage.mode(w) <- mode 226s + if (mode == "numeric") w[1] <- Inf 226s + 226s + for (idxs in index_cases) { 226s + validateIndicesTestVector_w(x, w, idxs, 226s + ftest = fcn, fsure = fcn, 226s + na.rm = TRUE) 226s + validateIndicesTestVector_w(x, w, idxs, 226s + ftest = fcn, fsure = fcn, 226s + na.rm = FALSE) 226s + } 226s + } 226s + cat(sprintf("%s()...DONE\n", name)) 226s + } 226s subsetted tests on weightedVar()... 226s weightedVar()...DONE 226s subsetted tests on weightedSd()... 226s weightedSd()...DONE 226s subsetted tests on weightedMad()... 226s weightedMad()...DONE 226s > 226s 226s R version 4.4.3 (2025-02-28) -- "Trophy Case" 226s Copyright (C) 2025 The R Foundation for Statistical Computing 226s Platform: s390x-ibm-linux-gnu 226s 226s R is free software and comes with ABSOLUTELY NO WARRANTY. 226s You are welcome to redistribute it under certain conditions. 226s Type 'license()' or 'licence()' for distribution details. 226s 226s R is a collaborative project with many contributors. 226s Type 'contributors()' for more information and 226s 'citation()' on how to cite R or R packages in publications. 226s 226s Type 'demo()' for some demos, 'help()' for on-line help, or 226s 'help.start()' for an HTML browser interface to help. 226s Type 'q()' to quit R. 226s 226s > library("matrixStats") 226s > 226s > x_OP_y_R <- function(x, y, OP, na.rm = FALSE) { 226s + if (na.rm) { 226s + xnok <- is.na(x) 226s + ynok <- is.na(y) 226s + anok <- xnok & ynok 226s + unit <- switch(OP, 226s + "+" = 0, 226s + "-" = NA_real_, 226s + "*" = 1, 226s + "/" = NA_real_, 226s + stop("Unknown 'OP' operator: ", OP) 226s + ) 226s + x[xnok] <- unit 226s + y[ynok] <- unit 226s + } 226s + 226s + ans <- switch(OP, 226s + "+" = x + y, 226s + "-" = x - y, 226s + "*" = x * y, 226s + "/" = x / y, 226s + stop("Unknown 'OP' operator: ", OP) 226s + ) 226s + 226s + if (na.rm) { 226s + ans[anok] <- NA_real_ 226s + } 226s + 226s + ans 226s + } # x_OP_y_R() 226s > 226s > 226s > 226s > t_tx_OP_y_R <- function(x, y, OP, na.rm = FALSE) { 226s + t(x_OP_y_R(x = t(x), y = y, OP = OP, na.rm = na.rm)) 226s + } 226s > 226s > 226s > 226s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 226s > # No missing values 226s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 226s > x <- matrix(1:16, nrow = 4, ncol = 4) 226s > y <- 1:nrow(x) 226s > storage.mode(y) <- storage.mode(x) 226s > 226s > for (OP in c("+", "-", "*", "/")) { 226s + for (na.rm in c(FALSE, TRUE)) { 226s + cat(sprintf("OP = '%s', na.rm = %s\n", OP, na.rm)) 226s + 226s + a0 <- x_OP_y_R(x, y, OP, na.rm = na.rm) 226s + a1 <- x_OP_y(x, y, OP, na.rm = na.rm) 226s + str(a1) 226s + stopifnot(all.equal(a1, a0)) 226s + 226s + b0 <- t_tx_OP_y_R(x, y, OP, na.rm = na.rm) 226s + b1 <- t_tx_OP_y(x, y, OP, na.rm = na.rm) 226s + str(b1) 226s + stopifnot(all.equal(b1, b0)) 226s + } 226s + } 226s OP = '+', na.rm = FALSE 226s int [1:4, 1:4] 2 4 6 8 6 8 10 12 10 12 ... 226s int [1:4, 1:4] 2 3 4 5 7 8 9 10 12 13 ... 226s OP = '+', na.rm = TRUE 226s int [1:4, 1:4] 2 4 6 8 6 8 10 12 10 12 ... 226s int [1:4, 1:4] 2 3 4 5 7 8 9 10 12 13 ... 226s OP = '-', na.rm = FALSE 226s int [1:4, 1:4] 0 0 0 0 4 4 4 4 8 8 ... 226s int [1:4, 1:4] 0 1 2 3 3 4 5 6 6 7 ... 226s OP = '-', na.rm = TRUE 226s int [1:4, 1:4] 0 0 0 0 4 4 4 4 8 8 ... 226s int [1:4, 1:4] 0 1 2 3 3 4 5 6 6 7 ... 226s OP = '*', na.rm = FALSE 226s int [1:4, 1:4] 1 4 9 16 5 12 21 32 9 20 ... 226s int [1:4, 1:4] 1 2 3 4 10 12 14 16 27 30 ... 226s OP = '*', na.rm = TRUE 226s int [1:4, 1:4] 1 4 9 16 5 12 21 32 9 20 ... 226s int [1:4, 1:4] 1 2 3 4 10 12 14 16 27 30 ... 226s OP = '/', na.rm = FALSE 226s num [1:4, 1:4] 1 1 1 1 5 ... 226s num [1:4, 1:4] 1 2 3 4 2.5 ... 226s OP = '/', na.rm = TRUE 226s num [1:4, 1:4] 1 1 1 1 5 ... 226s num [1:4, 1:4] 1 2 3 4 2.5 ... 226s > 226s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 226s > # Missing values in x, y, or both. 226s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 226s > for (which in c("x", "y", "both")) { 226s + x <- matrix(1:16, nrow = 4, ncol = 4) 226s + y <- 1:nrow(x) 226s + storage.mode(y) <- storage.mode(x) 226s + 226s + if (which == "x") { 226s + x[3:6] <- NA_real_ 226s + } else if (which == "y") { 226s + y[c(1, 3)] <- NA_real_ 226s + } else if (which == "both") { 226s + x[3:6] <- NA_real_ 226s + y[c(1, 3)] <- NA_real_ 226s + } 226s + 226s + for (OP in c("+", "-", "*", "/")) { 226s + for (na.rm in c(FALSE, TRUE)) { 226s + cat(sprintf("OP = '%s', na.rm = %s\n", OP, na.rm)) 226s + a0 <- x_OP_y_R(x, y, OP, na.rm = na.rm) 226s + a1 <- x_OP_y(x, y, OP, na.rm = na.rm) 226s + str(a1) 226s + stopifnot(all.equal(a1, a0)) 226s + 226s + b0 <- t_tx_OP_y_R(x, y, OP, na.rm = na.rm) 226s + b1 <- t_tx_OP_y(x, y, OP, na.rm = na.rm) 226s + str(b1) 226s + stopifnot(all.equal(b1, b0)) 226s + } 226s + } 226s + } 226s OP = '+', na.rm = FALSE 226s num [1:4, 1:4] 2 4 NA NA NA NA 10 12 10 12 ... 226s num [1:4, 1:4] 2 3 NA NA NA NA 9 10 12 13 ... 226s OP = '+', na.rm = TRUE 226s num [1:4, 1:4] 2 4 3 4 1 2 10 12 10 12 ... 226s num [1:4, 1:4] 2 3 1 1 2 2 9 10 12 13 ... 226s OP = '-', na.rm = FALSE 226s num [1:4, 1:4] 0 0 NA NA NA NA 4 4 8 8 ... 226s num [1:4, 1:4] 0 1 NA NA NA NA 5 6 6 7 ... 226s OP = '-', na.rm = TRUE 226s num [1:4, 1:4] 0 0 NA NA NA NA 4 4 8 8 ... 226s num [1:4, 1:4] 0 1 NA NA NA NA 5 6 6 7 ... 226s OP = '*', na.rm = FALSE 226s num [1:4, 1:4] 1 4 NA NA NA NA 21 32 9 20 ... 226s num [1:4, 1:4] 1 2 NA NA NA NA 14 16 27 30 ... 226s OP = '*', na.rm = TRUE 226s num [1:4, 1:4] 1 4 3 4 1 2 21 32 9 20 ... 226s num [1:4, 1:4] 1 2 1 1 2 2 14 16 27 30 ... 226s OP = '/', na.rm = FALSE 226s num [1:4, 1:4] 1 1 NA NA NA ... 226s num [1:4, 1:4] 1 2 NA NA NA ... 226s OP = '/', na.rm = TRUE 226s num [1:4, 1:4] 1 1 NA NA NA ... 226s num [1:4, 1:4] 1 2 NA NA NA ... 226s OP = '+', na.rm = FALSE 226s num [1:4, 1:4] NA 4 NA 8 NA 8 NA 12 NA 12 ... 226s num [1:4, 1:4] NA NA NA NA 7 8 9 10 NA NA ... 226s OP = '+', na.rm = TRUE 226s num [1:4, 1:4] 1 4 3 8 5 8 7 12 9 12 ... 226s num [1:4, 1:4] 1 2 3 4 7 8 9 10 9 10 ... 226s OP = '-', na.rm = FALSE 226s num [1:4, 1:4] NA 0 NA 0 NA 4 NA 4 NA 8 ... 226s num [1:4, 1:4] NA NA NA NA 3 4 5 6 NA NA ... 226s OP = '-', na.rm = TRUE 226s num [1:4, 1:4] NA 0 NA 0 NA 4 NA 4 NA 8 ... 226s num [1:4, 1:4] NA NA NA NA 3 4 5 6 NA NA ... 226s OP = '*', na.rm = FALSE 226s num [1:4, 1:4] NA 4 NA 16 NA 12 NA 32 NA 20 ... 226s num [1:4, 1:4] NA NA NA NA 10 12 14 16 NA NA ... 226s OP = '*', na.rm = TRUE 226s num [1:4, 1:4] 1 4 3 16 5 12 7 32 9 20 ... 226s num [1:4, 1:4] 1 2 3 4 10 12 14 16 9 10 ... 226s OP = '/', na.rm = FALSE 226s num [1:4, 1:4] NA 1 NA 1 NA 3 NA 2 NA 5 ... 226s num [1:4, 1:4] NA NA NA NA 2.5 3 3.5 4 NA NA ... 226s OP = '/', na.rm = TRUE 226s num [1:4, 1:4] NA 1 NA 1 NA 3 NA 2 NA 5 ... 226s num [1:4, 1:4] NA NA NA NA 2.5 3 3.5 4 NA NA ... 226s OP = '+', na.rm = FALSE 226s num [1:4, 1:4] NA 4 NA NA NA NA NA 12 NA 12 ... 226s num [1:4, 1:4] NA NA NA NA NA NA 9 10 NA NA ... 226s OP = '+', na.rm = TRUE 226s num [1:4, 1:4] 1 4 NA 4 NA 2 7 12 9 12 ... 226s num [1:4, 1:4] 1 2 NA NA 2 2 9 10 9 10 ... 226s OP = '-', na.rm = FALSE 226s num [1:4, 1:4] NA 0 NA NA NA NA NA 4 NA 8 ... 226s num [1:4, 1:4] NA NA NA NA NA NA 5 6 NA NA ... 226s OP = '-', na.rm = TRUE 226s num [1:4, 1:4] NA 0 NA NA NA NA NA 4 NA 8 ... 226s num [1:4, 1:4] NA NA NA NA NA NA 5 6 NA NA ... 226s OP = '*', na.rm = FALSE 226s num [1:4, 1:4] NA 4 NA NA NA NA NA 32 NA 20 ... 226s num [1:4, 1:4] NA NA NA NA NA NA 14 16 NA NA ... 226s OP = '*', na.rm = TRUE 226s num [1:4, 1:4] 1 4 NA 4 NA 2 7 32 9 20 ... 226s num [1:4, 1:4] 1 2 NA NA 2 2 14 16 9 10 ... 226s OP = '/', na.rm = FALSE 226s num [1:4, 1:4] NA 1 NA NA NA NA NA 2 NA 5 ... 226s num [1:4, 1:4] NA NA NA NA NA NA 3.5 4 NA NA ... 226s OP = '/', na.rm = TRUE 226s num [1:4, 1:4] NA 1 NA NA NA NA NA 2 NA 5 ... 226s num [1:4, 1:4] NA NA NA NA NA NA 3.5 4 NA NA ... 226s > 226s > 226s > 226s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 226s > # Length differences 226s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 226s > x <- matrix(1:8, nrow = 2, ncol = 4) 226s > y <- 1:ncol(x) 226s > storage.mode(y) <- storage.mode(x) 226s > 226s > for (OP in c("+", "-", "*", "/")) { 226s + for (na.rm in c(FALSE, TRUE)) { 226s + cat(sprintf("OP = '%s', na.rm = %s\n", OP, na.rm)) 226s + 226s + a0 <- x_OP_y_R(x, y, OP, na.rm = na.rm) 226s + a1 <- x_OP_y(x, y, OP, na.rm = na.rm) 226s + str(a1) 226s + stopifnot(all.equal(a1, a0)) 226s + 226s + b0 <- t_tx_OP_y_R(x, y, OP, na.rm = na.rm) 226s + b1 <- t_tx_OP_y(x, y, OP, na.rm = na.rm) 226s + str(b1) 226s + stopifnot(all.equal(b1, b0)) 226s + } 226s + } 226s OP = '+', na.rm = FALSE 226s int [1:2, 1:4] 2 4 6 8 6 8 10 12 226s int [1:2, 1:4] 2 3 5 6 8 9 11 12 226s OP = '+', na.rm = TRUE 226s int [1:2, 1:4] 2 4 6 8 6 8 10 12 226s int [1:2, 1:4] 2 3 5 6 8 9 11 12 226s OP = '-', na.rm = FALSE 226s int [1:2, 1:4] 0 0 0 0 4 4 4 4 226s int [1:2, 1:4] 0 1 1 2 2 3 3 4 226s OP = '-', na.rm = TRUE 226s int [1:2, 1:4] 0 0 0 0 4 4 4 4 226s int [1:2, 1:4] 0 1 1 2 2 3 3 4 226s OP = '*', na.rm = FALSE 226s int [1:2, 1:4] 1 4 9 16 5 12 21 32 226s int [1:2, 1:4] 1 2 6 8 15 18 28 32 226s OP = '*', na.rm = TRUE 226s int [1:2, 1:4] 1 4 9 16 5 12 21 32 226s int [1:2, 1:4] 1 2 6 8 15 18 28 32 226s OP = '/', na.rm = FALSE 226s num [1:2, 1:4] 1 1 1 1 5 ... 226s num [1:2, 1:4] 1 2 1.5 2 1.67 ... 226s OP = '/', na.rm = TRUE 226s num [1:2, 1:4] 1 1 1 1 5 ... 226s num [1:2, 1:4] 1 2 1.5 2 1.67 ... 226s > 226s > 226s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 226s > # All missing values 226s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 226s > xs <- list( 226s + A = matrix(1:2, nrow = 2, ncol = 2), 226s + B = matrix(NA_integer_, nrow = 2, ncol = 2) 226s + ) 226s > ys <- list( 226s + A = 1L, 226s + B = NA_integer_ 226s + ) 226s > 226s > for (x in xs) { 226s + for (y in ys) { 226s + for (mode in c("logical", "integer", "double")) { 226s + storage.mode(x) <- mode 226s + storage.mode(y) <- mode 226s + str(list(x = x, y = y)) 226s + 226s + for (OP in c("+", "-", "*", "/")) { 226s + for (na.rm in c(FALSE, TRUE)) { 226s + cat(sprintf("mode = '%s', OP = '%s', na.rm = %s\n", mode, OP, na.rm)) 226s + suppressWarnings({ 226s + z0 <- x_OP_y_R(x, y, OP, na.rm = na.rm) 226s + z <- x_OP_y(x, y, OP, na.rm = na.rm) 226s + }) 226s + str(z) 226s + stopifnot(all.equal(z, z0)) 226s + } 226s + } 226s + } # for (mode ...) 226s + } # for (y ...) 226s + } # for (x ...) 226s List of 2 226s $ x: logi [1:2, 1:2] TRUE TRUE TRUE TRUE 226s $ y: logi TRUE 226s mode = 'logical', OP = '+', na.rm = FALSE 226s int [1:2, 1:2] 2 2 2 2 226s mode = 'logical', OP = '+', na.rm = TRUE 226s int [1:2, 1:2] 2 2 2 2 226s mode = 'logical', OP = '-', na.rm = FALSE 226s int [1:2, 1:2] 0 0 0 0 226s mode = 'logical', OP = '-', na.rm = TRUE 226s int [1:2, 1:2] 0 0 0 0 226s mode = 'logical', OP = '*', na.rm = FALSE 226s int [1:2, 1:2] 1 1 1 1 226s mode = 'logical', OP = '*', na.rm = TRUE 226s int [1:2, 1:2] 1 1 1 1 226s mode = 'logical', OP = '/', na.rm = FALSE 226s num [1:2, 1:2] 1 1 1 1 226s mode = 'logical', OP = '/', na.rm = TRUE 226s num [1:2, 1:2] 1 1 1 1 226s List of 2 226s $ x: int [1:2, 1:2] 1 1 1 1 226s $ y: int 1 226s mode = 'integer', OP = '+', na.rm = FALSE 226s int [1:2, 1:2] 2 2 2 2 226s mode = 'integer', OP = '+', na.rm = TRUE 226s int [1:2, 1:2] 2 2 2 2 226s mode = 'integer', OP = '-', na.rm = FALSE 226s int [1:2, 1:2] 0 0 0 0 226s mode = 'integer', OP = '-', na.rm = TRUE 226s int [1:2, 1:2] 0 0 0 0 226s mode = 'integer', OP = '*', na.rm = FALSE 226s int [1:2, 1:2] 1 1 1 1 226s mode = 'integer', OP = '*', na.rm = TRUE 226s int [1:2, 1:2] 1 1 1 1 226s mode = 'integer', OP = '/', na.rm = FALSE 226s num [1:2, 1:2] 1 1 1 1 226s mode = 'integer', OP = '/', na.rm = TRUE 226s num [1:2, 1:2] 1 1 1 1 226s List of 2 226s $ x: num [1:2, 1:2] 1 1 1 1 226s $ y: num 1 226s mode = 'double', OP = '+', na.rm = FALSE 226s num [1:2, 1:2] 2 2 2 2 226s mode = 'double', OP = '+', na.rm = TRUE 226s num [1:2, 1:2] 2 2 2 2 226s mode = 'double', OP = '-', na.rm = FALSE 226s num [1:2, 1:2] 0 0 0 0 226s mode = 'double', OP = '-', na.rm = TRUE 226s num [1:2, 1:2] 0 0 0 0 226s mode = 'double', OP = '*', na.rm = FALSE 226s num [1:2, 1:2] 1 1 1 1 226s mode = 'double', OP = '*', na.rm = TRUE 226s num [1:2, 1:2] 1 1 1 1 226s mode = 'double', OP = '/', na.rm = FALSE 226s num [1:2, 1:2] 1 1 1 1 226s mode = 'double', OP = '/', na.rm = TRUE 226s num [1:2, 1:2] 1 1 1 1 226s List of 2 226s $ x: logi [1:2, 1:2] TRUE TRUE TRUE TRUE 226s $ y: logi NA 226s mode = 'logical', OP = '+', na.rm = FALSE 226s int [1:2, 1:2] NA NA NA NA 226s mode = 'logical', OP = '+', na.rm = TRUE 226s int [1:2, 1:2] 1 1 1 1 226s mode = 'logical', OP = '-', na.rm = FALSE 226s int [1:2, 1:2] NA NA NA NA 226s mode = 'logical', OP = '-', na.rm = TRUE 226s int [1:2, 1:2] NA NA NA NA 226s mode = 'logical', OP = '*', na.rm = FALSE 226s int [1:2, 1:2] NA NA NA NA 226s mode = 'logical', OP = '*', na.rm = TRUE 226s int [1:2, 1:2] 1 1 1 1 226s mode = 'logical', OP = '/', na.rm = FALSE 226s num [1:2, 1:2] NA NA NA NA 226s mode = 'logical', OP = '/', na.rm = TRUE 226s num [1:2, 1:2] NA NA NA NA 226s List of 2 226s $ x: int [1:2, 1:2] 1 1 1 1 226s $ y: int NA 226s mode = 'integer', OP = '+', na.rm = FALSE 226s int [1:2, 1:2] NA NA NA NA 226s mode = 'integer', OP = '+', na.rm = TRUE 226s int [1:2, 1:2] 1 1 1 1 226s mode = 'integer', OP = '-', na.rm = FALSE 226s int [1:2, 1:2] NA NA NA NA 226s mode = 'integer', OP = '-', na.rm = TRUE 226s int [1:2, 1:2] NA NA NA NA 226s mode = 'integer', OP = '*', na.rm = FALSE 226s int [1:2, 1:2] NA NA NA NA 226s mode = 'integer', OP = '*', na.rm = TRUE 226s int [1:2, 1:2] 1 1 1 1 226s mode = 'integer', OP = '/', na.rm = FALSE 226s num [1:2, 1:2] NA NA NA NA 226s mode = 'integer', OP = '/', na.rm = TRUE 226s num [1:2, 1:2] NA NA NA NA 226s List of 2 226s $ x: num [1:2, 1:2] 1 1 1 1 226s $ y: num NA 226s mode = 'double', OP = '+', na.rm = FALSE 226s num [1:2, 1:2] NA NA NA NA 226s mode = 'double', OP = '+', na.rm = TRUE 226s num [1:2, 1:2] 1 1 1 1 226s mode = 'double', OP = '-', na.rm = FALSE 226s num [1:2, 1:2] NA NA NA NA 226s mode = 'double', OP = '-', na.rm = TRUE 226s num [1:2, 1:2] NA NA NA NA 226s mode = 'double', OP = '*', na.rm = FALSE 226s num [1:2, 1:2] NA NA NA NA 226s mode = 'double', OP = '*', na.rm = TRUE 226s num [1:2, 1:2] 1 1 1 1 226s mode = 'double', OP = '/', na.rm = FALSE 226s num [1:2, 1:2] NA NA NA NA 226s mode = 'double', OP = '/', na.rm = TRUE 226s num [1:2, 1:2] NA NA NA NA 226s List of 2 226s $ x: logi [1:2, 1:2] NA NA NA NA 226s $ y: logi TRUE 226s mode = 'logical', OP = '+', na.rm = FALSE 226s int [1:2, 1:2] NA NA NA NA 226s mode = 'logical', OP = '+', na.rm = TRUE 226s int [1:2, 1:2] 1 1 1 1 226s mode = 'logical', OP = '-', na.rm = FALSE 226s int [1:2, 1:2] NA NA NA NA 226s mode = 'logical', OP = '-', na.rm = TRUE 226s int [1:2, 1:2] NA NA NA NA 226s mode = 'logical', OP = '*', na.rm = FALSE 226s int [1:2, 1:2] NA NA NA NA 226s mode = 'logical', OP = '*', na.rm = TRUE 226s int [1:2, 1:2] 1 1 1 1 226s mode = 'logical', OP = '/', na.rm = FALSE 226s num [1:2, 1:2] NA NA NA NA 226s mode = 'logical', OP = '/', na.rm = TRUE 226s num [1:2, 1:2] NA NA NA NA 226s List of 2 226s $ x: int [1:2, 1:2] NA NA NA NA 226s $ y: int 1 226s mode = 'integer', OP = '+', na.rm = FALSE 226s int [1:2, 1:2] NA NA NA NA 226s mode = 'integer', OP = '+', na.rm = TRUE 226s int [1:2, 1:2] 1 1 1 1 226s mode = 'integer', OP = '-', na.rm = FALSE 226s int [1:2, 1:2] NA NA NA NA 226s mode = 'integer', OP = '-', na.rm = TRUE 226s int [1:2, 1:2] NA NA NA NA 226s mode = 'integer', OP = '*', na.rm = FALSE 226s int [1:2, 1:2] NA NA NA NA 226s mode = 'integer', OP = '*', na.rm = TRUE 226s int [1:2, 1:2] 1 1 1 1 226s mode = 'integer', OP = '/', na.rm = FALSE 226s num [1:2, 1:2] NA NA NA NA 226s mode = 'integer', OP = '/', na.rm = TRUE 226s num [1:2, 1:2] NA NA NA NA 226s List of 2 226s $ x: num [1:2, 1:2] NA NA NA NA 226s $ y: num 1 226s mode = 'double', OP = '+', na.rm = FALSE 226s num [1:2, 1:2] NA NA NA NA 226s mode = 'double', OP = '+', na.rm = TRUE 226s num [1:2, 1:2] 1 1 1 1 226s mode = 'double', OP = '-', na.rm = FALSE 226s num [1:2, 1:2] NA NA NA NA 226s mode = 'double', OP = '-', na.rm = TRUE 226s num [1:2, 1:2] NA NA NA NA 226s mode = 'double', OP = '*', na.rm = FALSE 226s num [1:2, 1:2] NA NA NA NA 226s mode = 'double', OP = '*', na.rm = TRUE 226s num [1:2, 1:2] 1 1 1 1 226s mode = 'double', OP = '/', na.rm = FALSE 226s num [1:2, 1:2] NA NA NA NA 226s mode = 'double', OP = '/', na.rm = TRUE 226s num [1:2, 1:2] NA NA NA NA 226s List of 2 226s $ x: logi [1:2, 1:2] NA NA NA NA 226s $ y: logi NA 226s mode = 'logical', OP = '+', na.rm = FALSE 226s int [1:2, 1:2] NA NA NA NA 226s mode = 'logical', OP = '+', na.rm = TRUE 226s int [1:2, 1:2] NA NA NA NA 226s mode = 'logical', OP = '-', na.rm = FALSE 226s int [1:2, 1:2] NA NA NA NA 226s mode = 'logical', OP = '-', na.rm = TRUE 226s int [1:2, 1:2] NA NA NA NA 226s mode = 'logical', OP = '*', na.rm = FALSE 226s int [1:2, 1:2] NA NA NA NA 226s mode = 'logical', OP = '*', na.rm = TRUE 226s int [1:2, 1:2] NA NA NA NA 226s mode = 'logical', OP = '/', na.rm = FALSE 226s num [1:2, 1:2] NA NA NA NA 226s mode = 'logical', OP = '/', na.rm = TRUE 226s num [1:2, 1:2] NA NA NA NA 226s List of 2 226s $ x: int [1:2, 1:2] NA NA NA NA 226s $ y: int NA 226s mode = 'integer', OP = '+', na.rm = FALSE 226s int [1:2, 1:2] NA NA NA NA 226s mode = 'integer', OP = '+', na.rm = TRUE 226s int [1:2, 1:2] NA NA NA NA 226s mode = 'integer', OP = '-', na.rm = FALSE 226s int [1:2, 1:2] NA NA NA NA 226s mode = 'integer', OP = '-', na.rm = TRUE 226s int [1:2, 1:2] NA NA NA NA 226s mode = 'integer', OP = '*', na.rm = FALSE 226s int [1:2, 1:2] NA NA NA NA 226s mode = 'integer', OP = '*', na.rm = TRUE 226s int [1:2, 1:2] NA NA NA NA 226s mode = 'integer', OP = '/', na.rm = FALSE 226s num [1:2, 1:2] NA NA NA NA 226s mode = 'integer', OP = '/', na.rm = TRUE 226s num [1:2, 1:2] NA NA NA NA 226s List of 2 226s $ x: num [1:2, 1:2] NA NA NA NA 226s $ y: num NA 226s mode = 'double', OP = '+', na.rm = FALSE 226s num [1:2, 1:2] NA NA NA NA 226s mode = 'double', OP = '+', na.rm = TRUE 226s num [1:2, 1:2] NA NA NA NA 226s mode = 'double', OP = '-', na.rm = FALSE 226s num [1:2, 1:2] NA NA NA NA 226s mode = 'double', OP = '-', na.rm = TRUE 226s num [1:2, 1:2] NA NA NA NA 226s mode = 'double', OP = '*', na.rm = FALSE 226s num [1:2, 1:2] NA NA NA NA 226s mode = 'double', OP = '*', na.rm = TRUE 226s num [1:2, 1:2] NA NA NA NA 226s mode = 'double', OP = '/', na.rm = FALSE 226s num [1:2, 1:2] NA NA NA NA 226s mode = 'double', OP = '/', na.rm = TRUE 226s num [1:2, 1:2] NA NA NA NA 226s > 226s 226s R version 4.4.3 (2025-02-28) -- "Trophy Case" 226s Copyright (C) 2025 The R Foundation for Statistical Computing 226s Platform: s390x-ibm-linux-gnu 226s 226s R is free software and comes with ABSOLUTELY NO WARRANTY. 226s You are welcome to redistribute it under certain conditions. 226s Type 'license()' or 'licence()' for distribution details. 226s 226s R is a collaborative project with many contributors. 226s Type 'contributors()' for more information and 226s 'citation()' on how to cite R or R packages in publications. 226s 226s Type 'demo()' for some demos, 'help()' for on-line help, or 226s 'help.start()' for an HTML browser interface to help. 226s Type 'q()' to quit R. 226s 226s > library("matrixStats") 226s > 226s > x_OP_y_R <- function(x, y, OP, na.rm = FALSE) { 226s + if (na.rm) { 226s + xnok <- is.na(x) 226s + ynok <- is.na(y) 226s + anok <- xnok & ynok 226s + unit <- switch(OP, 226s + "+" = 0, 226s + "-" = NA_real_, 226s + "*" = 1, 226s + "/" = NA_real_, 226s + stop("Unknown 'OP' operator: ", OP) 226s + ) 226s + x[xnok] <- unit 226s + y[ynok] <- unit 226s + } 226s + 226s + ans <- switch(OP, 226s + "+" = x + y, 226s + "-" = x - y, 226s + "*" = x * y, 226s + "/" = x / y, 226s + stop("Unknown 'OP' operator: ", OP) 226s + ) 226s + 226s + if (na.rm) { 226s + ans[anok] <- NA_real_ 226s + } 226s + 226s + ans 226s + } # x_OP_y_R() 226s > 226s > 226s > t_tx_OP_y_R <- function(x, y, OP, na.rm = FALSE) { 226s + t(x_OP_y_R(x = t(x), y = y, OP = OP, na.rm = na.rm)) 226s + } 226s > 226s > 226s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 226s > # Subsetted tests 226s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 226s > source("utils/validateIndicesFramework.R") 226s > for (OP in c("+", "-", "*", "/")) { 226s + for (mode in c("numeric", "integer", "logical")) { 226s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6L, ncol = 6L) 226s + y <- runif(6, min = 0, max = 6) 226s + storage.mode(x) <- mode 226s + storage.mode(y) <- mode 226s + if (mode == "numeric") y[1] <- Inf 226s + 226s + for (xrows in index_cases) { 226s + for (xcols in index_cases) { 226s + if (is.null(xrows)) xrows <- seq_len(nrow(x)) 226s + if (is.null(xcols)) xcols <- seq_len(ncol(x)) 226s + 226s + for (yidxs in list(xrows, xcols)) { 226s + for (na.rm in c(TRUE, FALSE)) { 226s + 226s + suppressWarnings({ 226s + actual <- tryCatch( 226s + x_OP_y(x, y, OP, xrows = xrows, xcols = xcols, yidxs = yidxs, 226s + na.rm = na.rm), 226s + error = function(c) "error" 226s + ) 226s + 226s + expect <- tryCatch( 226s + x_OP_y_R(x[xrows, xcols, drop = FALSE], y[yidxs], OP, 226s + na.rm = na.rm), 226s + error = function(c) "error" 226s + ) 226s + }) 226s + stopifnot(all.equal(as.vector(actual), as.vector(expect))) 226s + 226s + suppressWarnings({ 226s + actual <- tryCatch( 226s + t_tx_OP_y(x, y, OP, xrows = xrows, xcols = xcols, yidxs = yidxs, 226s + na.rm = na.rm), 226s + error = function(c) "error" 226s + ) 226s + 226s + expect <- tryCatch( 226s + t_tx_OP_y_R(x[xrows, xcols, drop = FALSE], y[yidxs], OP, 226s + na.rm = na.rm), 226s + error = function(c) "error" 226s + ) 226s + }) 226s + stopifnot(all.equal(as.vector(actual), as.vector(expect))) 226s + } 226s + } 226s + } 226s + } 226s + } 226s + } 230s > 230s 230s R version 4.4.3 (2025-02-28) -- "Trophy Case" 230s Copyright (C) 2025 The R Foundation for Statistical Computing 230s Platform: s390x-ibm-linux-gnu 230s 230s R is free software and comes with ABSOLUTELY NO WARRANTY. 230s You are welcome to redistribute it under certain conditions. 230s Type 'license()' or 'licence()' for distribution details. 230s 230s R is a collaborative project with many contributors. 230s Type 'contributors()' for more information and 230s 'citation()' on how to cite R or R packages in publications. 230s 230s Type 'demo()' for some demos, 'help()' for on-line help, or 230s 'help.start()' for an HTML browser interface to help. 230s Type 'q()' to quit R. 230s 230s > ## These tests need to be last of all tests, otherwise 230s > ## covr::package_coverage() gives an error. 230s > cat("1. Loading package\n") 230s 1. Loading package 230s > loadNamespace("matrixStats") 230s 230s > stopifnot("matrixStats" %in% loadedNamespaces()) 230s > 230s > cat("2. Unloading package\n") 230s 2. Unloading package 230s > unloadNamespace("matrixStats") 230s > stopifnot(!"matrixStats" %in% loadedNamespaces()) 230s > 230s > if (FALSE) { 230s + ## 'covr' gives "Error in library("matrixStats") : 230s + ## there is no package called 'matrixStats'" here, cf. 230s + ## https://travis-ci.org/HenrikBengtsson/matrixStats/builds/48015577 230s + 230s + cat("3. Attaching package\n") 230s + library("matrixStats") 230s + stopifnot("package:matrixStats" %in% search()) 230s + 230s + cat("4. Detaching package\n") 230s + detach("package:matrixStats") 230s + stopifnot(!"package:matrixStats" %in% search()) 230s + stopifnot("matrixStats" %in% loadedNamespaces()) 230s + 230s + cat("5. Unloading package\n") 230s + unloadNamespace("matrixStats") 230s + stopifnot(!"matrixStats" %in% loadedNamespaces()) 230s + 230s + cat("6. Attaching package (again)\n") 230s + library("matrixStats") 230s + stopifnot("package:matrixStats" %in% search()) 230s + 230s + cat("7. Detaching package (again)\n") 230s + detach("package:matrixStats") 230s + stopifnot(!"package:matrixStats" %in% search()) 230s + stopifnot("matrixStats" %in% loadedNamespaces()) 230s + } 230s > 230s > cat("7. DONE\n") 230s 7. DONE 230s > 230s autopkgtest [18:14:00]: test run-unit-test: -----------------------] 231s run-unit-test PASS 231s autopkgtest [18:14:01]: test run-unit-test: - - - - - - - - - - results - - - - - - - - - - 231s autopkgtest [18:14:01]: test pkg-r-autopkgtest: preparing testbed 336s autopkgtest [18:15:46]: testbed dpkg architecture: s390x 336s autopkgtest [18:15:46]: testbed apt version: 2.9.33 337s autopkgtest [18:15:47]: @@@@@@@@@@@@@@@@@@@@ test bed setup 337s autopkgtest [18:15:47]: testbed release detected to be: plucky 337s autopkgtest [18:15:47]: updating testbed package index (apt update) 338s Get:1 http://ftpmaster.internal/ubuntu plucky-proposed InRelease [126 kB] 338s Hit:2 http://ftpmaster.internal/ubuntu plucky InRelease 338s Hit:3 http://ftpmaster.internal/ubuntu plucky-updates InRelease 338s Hit:4 http://ftpmaster.internal/ubuntu plucky-security InRelease 338s Get:5 http://ftpmaster.internal/ubuntu plucky-proposed/universe Sources [379 kB] 339s Get:6 http://ftpmaster.internal/ubuntu plucky-proposed/main Sources [99.7 kB] 339s Get:7 http://ftpmaster.internal/ubuntu plucky-proposed/multiverse Sources [15.8 kB] 339s Get:8 http://ftpmaster.internal/ubuntu plucky-proposed/main s390x Packages [113 kB] 339s Get:9 http://ftpmaster.internal/ubuntu plucky-proposed/main s390x c-n-f Metadata [1824 B] 339s Get:10 http://ftpmaster.internal/ubuntu plucky-proposed/restricted s390x c-n-f Metadata [116 B] 339s Get:11 http://ftpmaster.internal/ubuntu plucky-proposed/universe s390x Packages [320 kB] 339s Get:12 http://ftpmaster.internal/ubuntu plucky-proposed/universe s390x c-n-f Metadata [13.4 kB] 339s Get:13 http://ftpmaster.internal/ubuntu plucky-proposed/multiverse s390x Packages [3776 B] 339s Get:14 http://ftpmaster.internal/ubuntu plucky-proposed/multiverse s390x c-n-f Metadata [240 B] 339s Fetched 1073 kB in 1s (1118 kB/s) 339s Reading package lists... 340s Reading package lists... 340s Building dependency tree... 340s Reading state information... 340s Calculating upgrade... 340s Calculating upgrade... 340s The following packages were automatically installed and are no longer required: 340s libnsl2 libpython3.12-minimal libpython3.12-stdlib libpython3.12t64 340s linux-headers-6.11.0-8 linux-headers-6.11.0-8-generic 340s linux-modules-6.11.0-8-generic linux-tools-6.11.0-8 340s linux-tools-6.11.0-8-generic 340s Use 'sudo apt autoremove' to remove them. 340s The following packages will be upgraded: 340s pinentry-curses python3-jinja2 strace 341s 3 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 341s Need to get 652 kB of archives. 341s After this operation, 27.6 kB of additional disk space will be used. 341s Get:1 http://ftpmaster.internal/ubuntu plucky/main s390x strace s390x 6.13+ds-1ubuntu1 [500 kB] 341s Get:2 http://ftpmaster.internal/ubuntu plucky/main s390x pinentry-curses s390x 1.3.1-2ubuntu3 [42.9 kB] 341s Get:3 http://ftpmaster.internal/ubuntu plucky/main s390x python3-jinja2 all 3.1.5-2ubuntu1 [109 kB] 341s Fetched 652 kB in 1s (898 kB/s) 341s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 81428 files and directories currently installed.) 341s Preparing to unpack .../strace_6.13+ds-1ubuntu1_s390x.deb ... 341s Unpacking strace (6.13+ds-1ubuntu1) over (6.11-0ubuntu1) ... 342s Preparing to unpack .../pinentry-curses_1.3.1-2ubuntu3_s390x.deb ... 342s Unpacking pinentry-curses (1.3.1-2ubuntu3) over (1.3.1-2ubuntu2) ... 342s Preparing to unpack .../python3-jinja2_3.1.5-2ubuntu1_all.deb ... 342s Unpacking python3-jinja2 (3.1.5-2ubuntu1) over (3.1.5-2) ... 342s Setting up pinentry-curses (1.3.1-2ubuntu3) ... 342s Setting up python3-jinja2 (3.1.5-2ubuntu1) ... 342s Setting up strace (6.13+ds-1ubuntu1) ... 342s Processing triggers for man-db (2.13.0-1) ... 342s Reading package lists... 342s Building dependency tree... 342s Reading state information... 343s Solving dependencies... 343s The following packages will be REMOVED: 343s libnsl2* libpython3.12-minimal* libpython3.12-stdlib* libpython3.12t64* 343s linux-headers-6.11.0-8* linux-headers-6.11.0-8-generic* 343s linux-modules-6.11.0-8-generic* linux-tools-6.11.0-8* 343s linux-tools-6.11.0-8-generic* 343s 0 upgraded, 0 newly installed, 9 to remove and 5 not upgraded. 343s After this operation, 167 MB disk space will be freed. 343s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 81428 files and directories currently installed.) 343s Removing linux-tools-6.11.0-8-generic (6.11.0-8.8) ... 343s Removing linux-tools-6.11.0-8 (6.11.0-8.8) ... 343s Removing libpython3.12t64:s390x (3.12.9-1) ... 343s Removing libpython3.12-stdlib:s390x (3.12.9-1) ... 343s Removing libnsl2:s390x (1.3.0-3build3) ... 343s Removing libpython3.12-minimal:s390x (3.12.9-1) ... 343s Removing linux-headers-6.11.0-8-generic (6.11.0-8.8) ... 343s Removing linux-headers-6.11.0-8 (6.11.0-8.8) ... 344s Removing linux-modules-6.11.0-8-generic (6.11.0-8.8) ... 344s Processing triggers for libc-bin (2.41-1ubuntu1) ... 344s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 56328 files and directories currently installed.) 344s Purging configuration files for libpython3.12-minimal:s390x (3.12.9-1) ... 344s Purging configuration files for linux-modules-6.11.0-8-generic (6.11.0-8.8) ... 344s autopkgtest [18:15:54]: upgrading testbed (apt dist-upgrade and autopurge) 344s Reading package lists... 345s Building dependency tree... 345s Reading state information... 345s Calculating upgrade...Starting pkgProblemResolver with broken count: 0 345s Starting 2 pkgProblemResolver with broken count: 0 345s Done 345s Entering ResolveByKeep 345s 345s Calculating upgrade... 345s The following packages will be upgraded: 345s libc-bin libc-dev-bin libc6 libc6-dev locales 346s 5 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 346s Need to get 9512 kB of archives. 346s After this operation, 8192 B of additional disk space will be used. 346s Get:1 http://ftpmaster.internal/ubuntu plucky-proposed/main s390x libc6-dev s390x 2.41-1ubuntu2 [1678 kB] 346s Get:2 http://ftpmaster.internal/ubuntu plucky-proposed/main s390x libc-dev-bin s390x 2.41-1ubuntu2 [24.3 kB] 346s Get:3 http://ftpmaster.internal/ubuntu plucky-proposed/main s390x libc6 s390x 2.41-1ubuntu2 [2892 kB] 346s Get:4 http://ftpmaster.internal/ubuntu plucky-proposed/main s390x libc-bin s390x 2.41-1ubuntu2 [671 kB] 346s Get:5 http://ftpmaster.internal/ubuntu plucky-proposed/main s390x locales all 2.41-1ubuntu2 [4246 kB] 347s Preconfiguring packages ... 347s Fetched 9512 kB in 1s (9278 kB/s) 347s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 56326 files and directories currently installed.) 347s Preparing to unpack .../libc6-dev_2.41-1ubuntu2_s390x.deb ... 347s Unpacking libc6-dev:s390x (2.41-1ubuntu2) over (2.41-1ubuntu1) ... 347s Preparing to unpack .../libc-dev-bin_2.41-1ubuntu2_s390x.deb ... 347s Unpacking libc-dev-bin (2.41-1ubuntu2) over (2.41-1ubuntu1) ... 347s Preparing to unpack .../libc6_2.41-1ubuntu2_s390x.deb ... 347s Unpacking libc6:s390x (2.41-1ubuntu2) over (2.41-1ubuntu1) ... 347s Setting up libc6:s390x (2.41-1ubuntu2) ... 347s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 56326 files and directories currently installed.) 347s Preparing to unpack .../libc-bin_2.41-1ubuntu2_s390x.deb ... 347s Unpacking libc-bin (2.41-1ubuntu2) over (2.41-1ubuntu1) ... 347s Setting up libc-bin (2.41-1ubuntu2) ... 347s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 56326 files and directories currently installed.) 347s Preparing to unpack .../locales_2.41-1ubuntu2_all.deb ... 347s Unpacking locales (2.41-1ubuntu2) over (2.41-1ubuntu1) ... 347s Setting up locales (2.41-1ubuntu2) ... 348s Generating locales (this might take a while)... 349s en_US.UTF-8... done 349s Generation complete. 349s Setting up libc-dev-bin (2.41-1ubuntu2) ... 349s Setting up libc6-dev:s390x (2.41-1ubuntu2) ... 349s Processing triggers for man-db (2.13.0-1) ... 349s Processing triggers for systemd (257.3-1ubuntu3) ... 350s Reading package lists... 350s Building dependency tree... 350s Reading state information... 351s Starting pkgProblemResolver with broken count: 0 351s Starting 2 pkgProblemResolver with broken count: 0 351s Done 351s Solving dependencies... 351s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 351s autopkgtest [18:16:01]: rebooting testbed after setup commands that affected boot 374s Reading package lists... 374s Building dependency tree... 374s Reading state information... 374s Starting pkgProblemResolver with broken count: 0 374s Starting 2 pkgProblemResolver with broken count: 0 374s Done 374s The following NEW packages will be installed: 374s build-essential cpp cpp-14 cpp-14-s390x-linux-gnu cpp-s390x-linux-gnu 374s dctrl-tools fontconfig fontconfig-config fonts-dejavu-core fonts-dejavu-mono 374s fonts-glyphicons-halflings fonts-mathjax g++ g++-14 g++-14-s390x-linux-gnu 374s g++-s390x-linux-gnu gcc gcc-14 gcc-14-s390x-linux-gnu gcc-s390x-linux-gnu 374s gfortran gfortran-14 gfortran-14-s390x-linux-gnu gfortran-s390x-linux-gnu 374s icu-devtools libasan8 libblas-dev libblas3 libbz2-dev libcairo2 libcc1-0 374s libdatrie1 libdeflate-dev libdeflate0 libfontconfig1 libfreetype6 374s libgcc-14-dev libgfortran-14-dev libgfortran5 libgomp1 libgraphite2-3 374s libharfbuzz0b libice6 libicu-dev libisl23 libitm1 libjbig0 libjpeg-dev 374s libjpeg-turbo8 libjpeg-turbo8-dev libjpeg8 libjpeg8-dev libjs-bootstrap 374s libjs-highlight.js libjs-jquery libjs-jquery-datatables libjs-mathjax 374s liblapack-dev liblapack3 liblzma-dev libmpc3 libncurses-dev libpango-1.0-0 374s libpangocairo-1.0-0 libpangoft2-1.0-0 libpaper-utils libpaper2 libpcre2-16-0 374s libpcre2-32-0 libpcre2-dev libpcre2-posix3 libpixman-1-0 libpkgconf3 374s libpng-dev libreadline-dev libsharpyuv0 libsm6 libstdc++-14-dev libtcl8.6 374s libthai-data libthai0 libtiff6 libtirpc-dev libtk8.6 libubsan1 libwebp7 374s libxcb-render0 libxcb-shm0 libxft2 libxrender1 libxss1 libxt6t64 374s node-normalize.css pkg-r-autopkgtest pkgconf pkgconf-bin r-base-core 374s r-base-dev r-cran-base64enc r-cran-cli r-cran-colorspace r-cran-commonmark 374s r-cran-evaluate r-cran-fansi r-cran-farver r-cran-ggplot2 r-cran-glue 374s r-cran-gtable r-cran-highr r-cran-isoband r-cran-knitr r-cran-labeling 374s r-cran-lattice r-cran-lifecycle r-cran-magrittr r-cran-markdown r-cran-mass 374s r-cran-matrix r-cran-matrixstats r-cran-mgcv r-cran-munsell r-cran-nlme 374s r-cran-pillar r-cran-pkgconfig r-cran-r6 r-cran-rcolorbrewer r-cran-rlang 374s r-cran-scales r-cran-tibble r-cran-utf8 r-cran-vctrs r-cran-viridislite 374s r-cran-withr r-cran-xfun r-cran-yaml unzip x11-common xdg-utils zip 374s zlib1g-dev 374s 0 upgraded, 140 newly installed, 0 to remove and 0 not upgraded. 374s Need to get 164 MB of archives. 374s After this operation, 465 MB of additional disk space will be used. 374s Get:1 http://ftpmaster.internal/ubuntu plucky/main s390x libisl23 s390x 0.27-1 [704 kB] 375s Get:2 http://ftpmaster.internal/ubuntu plucky/main s390x libmpc3 s390x 1.3.1-1build2 [57.8 kB] 375s Get:3 http://ftpmaster.internal/ubuntu plucky/main s390x cpp-14-s390x-linux-gnu s390x 14.2.0-17ubuntu3 [9572 kB] 376s Get:4 http://ftpmaster.internal/ubuntu plucky/main s390x cpp-14 s390x 14.2.0-17ubuntu3 [1028 B] 376s Get:5 http://ftpmaster.internal/ubuntu plucky/main s390x cpp-s390x-linux-gnu s390x 4:14.2.0-1ubuntu1 [5556 B] 376s Get:6 http://ftpmaster.internal/ubuntu plucky/main s390x cpp s390x 4:14.2.0-1ubuntu1 [22.4 kB] 376s Get:7 http://ftpmaster.internal/ubuntu plucky/main s390x libcc1-0 s390x 15-20250222-0ubuntu1 [49.2 kB] 376s Get:8 http://ftpmaster.internal/ubuntu plucky/main s390x libgomp1 s390x 15-20250222-0ubuntu1 [152 kB] 376s Get:9 http://ftpmaster.internal/ubuntu plucky/main s390x libitm1 s390x 15-20250222-0ubuntu1 [31.2 kB] 376s Get:10 http://ftpmaster.internal/ubuntu plucky/main s390x libasan8 s390x 15-20250222-0ubuntu1 [2970 kB] 376s Get:11 http://ftpmaster.internal/ubuntu plucky/main s390x libubsan1 s390x 15-20250222-0ubuntu1 [1212 kB] 376s Get:12 http://ftpmaster.internal/ubuntu plucky/main s390x libgcc-14-dev s390x 14.2.0-17ubuntu3 [1037 kB] 376s Get:13 http://ftpmaster.internal/ubuntu plucky/main s390x gcc-14-s390x-linux-gnu s390x 14.2.0-17ubuntu3 [18.7 MB] 377s Get:14 http://ftpmaster.internal/ubuntu plucky/main s390x gcc-14 s390x 14.2.0-17ubuntu3 [526 kB] 377s Get:15 http://ftpmaster.internal/ubuntu plucky/main s390x gcc-s390x-linux-gnu s390x 4:14.2.0-1ubuntu1 [1204 B] 377s Get:16 http://ftpmaster.internal/ubuntu plucky/main s390x gcc s390x 4:14.2.0-1ubuntu1 [5004 B] 377s Get:17 http://ftpmaster.internal/ubuntu plucky/main s390x libstdc++-14-dev s390x 14.2.0-17ubuntu3 [2611 kB] 377s Get:18 http://ftpmaster.internal/ubuntu plucky/main s390x g++-14-s390x-linux-gnu s390x 14.2.0-17ubuntu3 [11.0 MB] 377s Get:19 http://ftpmaster.internal/ubuntu plucky/main s390x g++-14 s390x 14.2.0-17ubuntu3 [21.8 kB] 377s Get:20 http://ftpmaster.internal/ubuntu plucky/main s390x g++-s390x-linux-gnu s390x 4:14.2.0-1ubuntu1 [956 B] 377s Get:21 http://ftpmaster.internal/ubuntu plucky/main s390x g++ s390x 4:14.2.0-1ubuntu1 [1080 B] 377s Get:22 http://ftpmaster.internal/ubuntu plucky/main s390x build-essential s390x 12.10ubuntu1 [4930 B] 377s Get:23 http://ftpmaster.internal/ubuntu plucky/main s390x dctrl-tools s390x 2.24-3build3 [106 kB] 377s Get:24 http://ftpmaster.internal/ubuntu plucky/main s390x libfreetype6 s390x 2.13.3+dfsg-1 [431 kB] 377s Get:25 http://ftpmaster.internal/ubuntu plucky/main s390x fonts-dejavu-mono all 2.37-8 [502 kB] 377s Get:26 http://ftpmaster.internal/ubuntu plucky/main s390x fonts-dejavu-core all 2.37-8 [835 kB] 377s Get:27 http://ftpmaster.internal/ubuntu plucky/main s390x fontconfig-config s390x 2.15.0-2ubuntu1 [37.5 kB] 377s Get:28 http://ftpmaster.internal/ubuntu plucky/main s390x libfontconfig1 s390x 2.15.0-2ubuntu1 [150 kB] 377s Get:29 http://ftpmaster.internal/ubuntu plucky/main s390x fontconfig s390x 2.15.0-2ubuntu1 [191 kB] 377s Get:30 http://ftpmaster.internal/ubuntu plucky/universe s390x fonts-glyphicons-halflings all 1.009~3.4.1+dfsg-3 [118 kB] 377s Get:31 http://ftpmaster.internal/ubuntu plucky/main s390x fonts-mathjax all 2.7.9+dfsg-1 [2208 kB] 377s Get:32 http://ftpmaster.internal/ubuntu plucky/main s390x libgfortran5 s390x 15-20250222-0ubuntu1 [620 kB] 377s Get:33 http://ftpmaster.internal/ubuntu plucky/main s390x libgfortran-14-dev s390x 14.2.0-17ubuntu3 [654 kB] 377s Get:34 http://ftpmaster.internal/ubuntu plucky/main s390x gfortran-14-s390x-linux-gnu s390x 14.2.0-17ubuntu3 [10.3 MB] 377s Get:35 http://ftpmaster.internal/ubuntu plucky/main s390x gfortran-14 s390x 14.2.0-17ubuntu3 [13.6 kB] 377s Get:36 http://ftpmaster.internal/ubuntu plucky/main s390x gfortran-s390x-linux-gnu s390x 4:14.2.0-1ubuntu1 [1012 B] 377s Get:37 http://ftpmaster.internal/ubuntu plucky/main s390x gfortran s390x 4:14.2.0-1ubuntu1 [1160 B] 377s Get:38 http://ftpmaster.internal/ubuntu plucky/main s390x icu-devtools s390x 76.1-1ubuntu2 [225 kB] 378s Get:39 http://ftpmaster.internal/ubuntu plucky/main s390x libblas3 s390x 3.12.1-2 [252 kB] 378s Get:40 http://ftpmaster.internal/ubuntu plucky/main s390x libblas-dev s390x 3.12.1-2 [254 kB] 378s Get:41 http://ftpmaster.internal/ubuntu plucky/main s390x libbz2-dev s390x 1.0.8-6 [39.1 kB] 378s Get:42 http://ftpmaster.internal/ubuntu plucky/main s390x libpixman-1-0 s390x 0.44.0-3 [201 kB] 378s Get:43 http://ftpmaster.internal/ubuntu plucky/main s390x libxcb-render0 s390x 1.17.0-2 [17.0 kB] 378s Get:44 http://ftpmaster.internal/ubuntu plucky/main s390x libxcb-shm0 s390x 1.17.0-2 [5862 B] 378s Get:45 http://ftpmaster.internal/ubuntu plucky/main s390x libxrender1 s390x 1:0.9.10-1.1build1 [20.4 kB] 378s Get:46 http://ftpmaster.internal/ubuntu plucky/main s390x libcairo2 s390x 1.18.2-2 [580 kB] 378s Get:47 http://ftpmaster.internal/ubuntu plucky/main s390x libdatrie1 s390x 0.2.13-3build1 [20.6 kB] 378s Get:48 http://ftpmaster.internal/ubuntu plucky/main s390x libdeflate0 s390x 1.23-1 [46.1 kB] 378s Get:49 http://ftpmaster.internal/ubuntu plucky/main s390x libdeflate-dev s390x 1.23-1 [52.2 kB] 378s Get:50 http://ftpmaster.internal/ubuntu plucky/main s390x libgraphite2-3 s390x 1.3.14-2ubuntu1 [79.8 kB] 378s Get:51 http://ftpmaster.internal/ubuntu plucky/main s390x libharfbuzz0b s390x 10.2.0-1 [538 kB] 378s Get:52 http://ftpmaster.internal/ubuntu plucky/main s390x x11-common all 1:7.7+23ubuntu3 [21.7 kB] 378s Get:53 http://ftpmaster.internal/ubuntu plucky/main s390x libice6 s390x 2:1.1.1-1 [45.4 kB] 378s Get:54 http://ftpmaster.internal/ubuntu plucky/main s390x libicu-dev s390x 76.1-1ubuntu2 [12.2 MB] 378s Get:55 http://ftpmaster.internal/ubuntu plucky/main s390x libjpeg-turbo8 s390x 2.1.5-3ubuntu2 [147 kB] 378s Get:56 http://ftpmaster.internal/ubuntu plucky/main s390x libjpeg-turbo8-dev s390x 2.1.5-3ubuntu2 [281 kB] 378s Get:57 http://ftpmaster.internal/ubuntu plucky/main s390x libjpeg8 s390x 8c-2ubuntu11 [2146 B] 378s Get:58 http://ftpmaster.internal/ubuntu plucky/main s390x libjpeg8-dev s390x 8c-2ubuntu11 [1484 B] 378s Get:59 http://ftpmaster.internal/ubuntu plucky/main s390x libjpeg-dev s390x 8c-2ubuntu11 [1484 B] 378s Get:60 http://ftpmaster.internal/ubuntu plucky/universe s390x libjs-bootstrap all 3.4.1+dfsg-3 [129 kB] 378s Get:61 http://ftpmaster.internal/ubuntu plucky/universe s390x libjs-highlight.js all 9.18.5+dfsg1-2 [385 kB] 378s Get:62 http://ftpmaster.internal/ubuntu plucky/main s390x libjs-jquery all 3.6.1+dfsg+~3.5.14-1 [328 kB] 378s Get:63 http://ftpmaster.internal/ubuntu plucky/universe s390x libjs-jquery-datatables all 1.11.5+dfsg-2 [146 kB] 378s Get:64 http://ftpmaster.internal/ubuntu plucky/main s390x liblapack3 s390x 3.12.1-2 [2971 kB] 378s Get:65 http://ftpmaster.internal/ubuntu plucky/main s390x liblapack-dev s390x 3.12.1-2 [5967 kB] 378s Get:66 http://ftpmaster.internal/ubuntu plucky/main s390x libncurses-dev s390x 6.5+20250216-2 [407 kB] 378s Get:67 http://ftpmaster.internal/ubuntu plucky/main s390x libthai-data all 0.1.29-2build1 [158 kB] 378s Get:68 http://ftpmaster.internal/ubuntu plucky/main s390x libthai0 s390x 0.1.29-2build1 [20.7 kB] 378s Get:69 http://ftpmaster.internal/ubuntu plucky/main s390x libpango-1.0-0 s390x 1.56.2-1 [253 kB] 378s Get:70 http://ftpmaster.internal/ubuntu plucky/main s390x libpangoft2-1.0-0 s390x 1.56.2-1 [50.2 kB] 378s Get:71 http://ftpmaster.internal/ubuntu plucky/main s390x libpangocairo-1.0-0 s390x 1.56.2-1 [28.2 kB] 378s Get:72 http://ftpmaster.internal/ubuntu plucky/main s390x libpaper2 s390x 2.2.5-0.3 [17.2 kB] 378s Get:73 http://ftpmaster.internal/ubuntu plucky/main s390x libpaper-utils s390x 2.2.5-0.3 [15.3 kB] 378s Get:74 http://ftpmaster.internal/ubuntu plucky/main s390x libpcre2-16-0 s390x 10.45-1 [259 kB] 378s Get:75 http://ftpmaster.internal/ubuntu plucky/main s390x libpcre2-32-0 s390x 10.45-1 [245 kB] 379s Get:76 http://ftpmaster.internal/ubuntu plucky/main s390x libpcre2-posix3 s390x 10.45-1 [7080 B] 379s Get:77 http://ftpmaster.internal/ubuntu plucky/main s390x libpcre2-dev s390x 10.45-1 [899 kB] 379s Get:78 http://ftpmaster.internal/ubuntu plucky/main s390x libpkgconf3 s390x 1.8.1-4 [31.2 kB] 379s Get:79 http://ftpmaster.internal/ubuntu plucky/main s390x zlib1g-dev s390x 1:1.3.dfsg+really1.3.1-1ubuntu1 [898 kB] 379s Get:80 http://ftpmaster.internal/ubuntu plucky/main s390x libpng-dev s390x 1.6.47-1 [278 kB] 379s Get:81 http://ftpmaster.internal/ubuntu plucky/main s390x libreadline-dev s390x 8.2-6 [187 kB] 379s Get:82 http://ftpmaster.internal/ubuntu plucky/main s390x libsharpyuv0 s390x 1.5.0-0.1 [16.7 kB] 379s Get:83 http://ftpmaster.internal/ubuntu plucky/main s390x libsm6 s390x 2:1.2.4-1 [18.4 kB] 379s Get:84 http://ftpmaster.internal/ubuntu plucky/main s390x libtcl8.6 s390x 8.6.16+dfsg-1 [1034 kB] 379s Get:85 http://ftpmaster.internal/ubuntu plucky/main s390x libjbig0 s390x 2.1-6.1ubuntu2 [33.1 kB] 379s Get:86 http://ftpmaster.internal/ubuntu plucky/main s390x libwebp7 s390x 1.5.0-0.1 [210 kB] 379s Get:87 http://ftpmaster.internal/ubuntu plucky/main s390x libtiff6 s390x 4.5.1+git230720-4ubuntu4 [217 kB] 379s Get:88 http://ftpmaster.internal/ubuntu plucky/main s390x libxft2 s390x 2.3.6-1build1 [49.6 kB] 379s Get:89 http://ftpmaster.internal/ubuntu plucky/main s390x libxss1 s390x 1:1.2.3-1build3 [7396 B] 379s Get:90 http://ftpmaster.internal/ubuntu plucky/main s390x libtk8.6 s390x 8.6.16-1 [830 kB] 379s Get:91 http://ftpmaster.internal/ubuntu plucky/main s390x libxt6t64 s390x 1:1.2.1-1.2build1 [184 kB] 379s Get:92 http://ftpmaster.internal/ubuntu plucky/universe s390x node-normalize.css all 8.0.1-5 [10.8 kB] 379s Get:93 http://ftpmaster.internal/ubuntu plucky/main s390x zip s390x 3.0-14ubuntu2 [187 kB] 379s Get:94 http://ftpmaster.internal/ubuntu plucky/main s390x unzip s390x 6.0-28ubuntu6 [186 kB] 379s Get:95 http://ftpmaster.internal/ubuntu plucky/main s390x xdg-utils all 1.2.1-2ubuntu1 [66.0 kB] 379s Get:96 http://ftpmaster.internal/ubuntu plucky/universe s390x r-base-core s390x 4.4.3-1 [28.6 MB] 380s Get:97 http://ftpmaster.internal/ubuntu plucky/main s390x liblzma-dev s390x 5.6.4-1 [183 kB] 380s Get:98 http://ftpmaster.internal/ubuntu plucky/main s390x pkgconf-bin s390x 1.8.1-4 [21.5 kB] 380s Get:99 http://ftpmaster.internal/ubuntu plucky/main s390x pkgconf s390x 1.8.1-4 [16.7 kB] 380s Get:100 http://ftpmaster.internal/ubuntu plucky/main s390x libtirpc-dev s390x 1.3.4+ds-1.3 [196 kB] 380s Get:101 http://ftpmaster.internal/ubuntu plucky/universe s390x r-base-dev all 4.4.3-1 [4176 B] 380s Get:102 http://ftpmaster.internal/ubuntu plucky/universe s390x pkg-r-autopkgtest all 20231212ubuntu1 [6448 B] 380s Get:103 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-base64enc s390x 0.1-3-3 [28.0 kB] 380s Get:104 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-cli s390x 3.6.4-1 [1379 kB] 380s Get:105 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-colorspace s390x 2.1-1+dfsg-1 [1567 kB] 380s Get:106 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-commonmark s390x 1.9.2-2 [142 kB] 380s Get:107 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-evaluate all 1.0.3-1 [114 kB] 380s Get:108 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-fansi s390x 1.0.5-1 [615 kB] 380s Get:109 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-farver s390x 2.1.2-1 [1353 kB] 381s Get:110 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-glue s390x 1.8.0-1 [164 kB] 381s Get:111 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-rlang s390x 1.1.5-1 [1713 kB] 381s Get:112 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-lifecycle all 1.0.4+dfsg-1 [110 kB] 381s Get:113 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-gtable all 0.3.6+dfsg-1 [199 kB] 381s Get:114 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-isoband s390x 0.2.7-1 [1481 kB] 381s Get:115 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-mass s390x 7.3-64-1 [1113 kB] 381s Get:116 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-lattice s390x 0.22-6-1 [1340 kB] 381s Get:117 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-nlme s390x 3.1.167-1 [2323 kB] 381s Get:118 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-matrix s390x 1.7-3-1 [4449 kB] 381s Get:119 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-mgcv s390x 1.9-1-1 [3348 kB] 382s Get:120 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-labeling all 0.4.3-1 [62.1 kB] 382s Get:121 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-munsell all 0.5.1-1 [213 kB] 382s Get:122 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-r6 all 2.6.1-1 [101 kB] 382s Get:123 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-rcolorbrewer all 1.1-3-1build1 [55.4 kB] 382s Get:124 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-viridislite all 0.4.2-2 [1088 kB] 382s Get:125 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-scales all 1.3.0-1 [603 kB] 382s Get:126 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-magrittr s390x 2.0.3-1 [154 kB] 382s Get:127 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-utf8 s390x 1.2.4-1 [143 kB] 382s Get:128 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-vctrs s390x 0.6.5-1 [1448 kB] 382s Get:129 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-pillar all 1.10.1+dfsg-1 [453 kB] 382s Get:130 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-pkgconfig all 2.0.3-2build1 [19.7 kB] 382s Get:131 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-tibble s390x 3.2.1+dfsg-3 [420 kB] 382s Get:132 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-withr all 3.0.2+dfsg-1 [214 kB] 382s Get:133 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-ggplot2 all 3.5.1+dfsg-1 [3940 kB] 382s Get:134 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-xfun s390x 0.51+dfsg-1 [574 kB] 382s Get:135 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-highr all 0.11+dfsg-1 [38.5 kB] 382s Get:136 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-yaml s390x 2.3.10-1 [113 kB] 382s Get:137 http://ftpmaster.internal/ubuntu plucky/main s390x libjs-mathjax all 2.7.9+dfsg-1 [5665 kB] 383s Get:138 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-knitr all 1.49+dfsg-1 [859 kB] 383s Get:139 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-markdown all 1.13-1 [162 kB] 383s Get:140 http://ftpmaster.internal/ubuntu plucky/universe s390x r-cran-matrixstats s390x 1.5.0-1 [539 kB] 383s Preconfiguring packages ... 383s Fetched 164 MB in 8s (19.5 MB/s) 383s Selecting previously unselected package libisl23:s390x. 383s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 56326 files and directories currently installed.) 383s Preparing to unpack .../000-libisl23_0.27-1_s390x.deb ... 383s Unpacking libisl23:s390x (0.27-1) ... 383s Selecting previously unselected package libmpc3:s390x. 383s Preparing to unpack .../001-libmpc3_1.3.1-1build2_s390x.deb ... 383s Unpacking libmpc3:s390x (1.3.1-1build2) ... 383s Selecting previously unselected package cpp-14-s390x-linux-gnu. 383s Preparing to unpack .../002-cpp-14-s390x-linux-gnu_14.2.0-17ubuntu3_s390x.deb ... 383s Unpacking cpp-14-s390x-linux-gnu (14.2.0-17ubuntu3) ... 383s Selecting previously unselected package cpp-14. 383s Preparing to unpack .../003-cpp-14_14.2.0-17ubuntu3_s390x.deb ... 383s Unpacking cpp-14 (14.2.0-17ubuntu3) ... 383s Selecting previously unselected package cpp-s390x-linux-gnu. 383s Preparing to unpack .../004-cpp-s390x-linux-gnu_4%3a14.2.0-1ubuntu1_s390x.deb ... 383s Unpacking cpp-s390x-linux-gnu (4:14.2.0-1ubuntu1) ... 383s Selecting previously unselected package cpp. 383s Preparing to unpack .../005-cpp_4%3a14.2.0-1ubuntu1_s390x.deb ... 383s Unpacking cpp (4:14.2.0-1ubuntu1) ... 383s Selecting previously unselected package libcc1-0:s390x. 383s Preparing to unpack .../006-libcc1-0_15-20250222-0ubuntu1_s390x.deb ... 383s Unpacking libcc1-0:s390x (15-20250222-0ubuntu1) ... 384s Selecting previously unselected package libgomp1:s390x. 384s Preparing to unpack .../007-libgomp1_15-20250222-0ubuntu1_s390x.deb ... 384s Unpacking libgomp1:s390x (15-20250222-0ubuntu1) ... 384s Selecting previously unselected package libitm1:s390x. 384s Preparing to unpack .../008-libitm1_15-20250222-0ubuntu1_s390x.deb ... 384s Unpacking libitm1:s390x (15-20250222-0ubuntu1) ... 384s Selecting previously unselected package libasan8:s390x. 384s Preparing to unpack .../009-libasan8_15-20250222-0ubuntu1_s390x.deb ... 384s Unpacking libasan8:s390x (15-20250222-0ubuntu1) ... 384s Selecting previously unselected package libubsan1:s390x. 384s Preparing to unpack .../010-libubsan1_15-20250222-0ubuntu1_s390x.deb ... 384s Unpacking libubsan1:s390x (15-20250222-0ubuntu1) ... 384s Selecting previously unselected package libgcc-14-dev:s390x. 384s Preparing to unpack .../011-libgcc-14-dev_14.2.0-17ubuntu3_s390x.deb ... 384s Unpacking libgcc-14-dev:s390x (14.2.0-17ubuntu3) ... 384s Selecting previously unselected package gcc-14-s390x-linux-gnu. 384s Preparing to unpack .../012-gcc-14-s390x-linux-gnu_14.2.0-17ubuntu3_s390x.deb ... 384s Unpacking gcc-14-s390x-linux-gnu (14.2.0-17ubuntu3) ... 384s Selecting previously unselected package gcc-14. 384s Preparing to unpack .../013-gcc-14_14.2.0-17ubuntu3_s390x.deb ... 384s Unpacking gcc-14 (14.2.0-17ubuntu3) ... 384s Selecting previously unselected package gcc-s390x-linux-gnu. 384s Preparing to unpack .../014-gcc-s390x-linux-gnu_4%3a14.2.0-1ubuntu1_s390x.deb ... 384s Unpacking gcc-s390x-linux-gnu (4:14.2.0-1ubuntu1) ... 384s Selecting previously unselected package gcc. 384s Preparing to unpack .../015-gcc_4%3a14.2.0-1ubuntu1_s390x.deb ... 384s Unpacking gcc (4:14.2.0-1ubuntu1) ... 384s Selecting previously unselected package libstdc++-14-dev:s390x. 384s Preparing to unpack .../016-libstdc++-14-dev_14.2.0-17ubuntu3_s390x.deb ... 384s Unpacking libstdc++-14-dev:s390x (14.2.0-17ubuntu3) ... 384s Selecting previously unselected package g++-14-s390x-linux-gnu. 384s Preparing to unpack .../017-g++-14-s390x-linux-gnu_14.2.0-17ubuntu3_s390x.deb ... 384s Unpacking g++-14-s390x-linux-gnu (14.2.0-17ubuntu3) ... 384s Selecting previously unselected package g++-14. 384s Preparing to unpack .../018-g++-14_14.2.0-17ubuntu3_s390x.deb ... 384s Unpacking g++-14 (14.2.0-17ubuntu3) ... 384s Selecting previously unselected package g++-s390x-linux-gnu. 384s Preparing to unpack .../019-g++-s390x-linux-gnu_4%3a14.2.0-1ubuntu1_s390x.deb ... 384s Unpacking g++-s390x-linux-gnu (4:14.2.0-1ubuntu1) ... 384s Selecting previously unselected package g++. 384s Preparing to unpack .../020-g++_4%3a14.2.0-1ubuntu1_s390x.deb ... 384s Unpacking g++ (4:14.2.0-1ubuntu1) ... 384s Selecting previously unselected package build-essential. 384s Preparing to unpack .../021-build-essential_12.10ubuntu1_s390x.deb ... 384s Unpacking build-essential (12.10ubuntu1) ... 384s Selecting previously unselected package dctrl-tools. 384s Preparing to unpack .../022-dctrl-tools_2.24-3build3_s390x.deb ... 384s Unpacking dctrl-tools (2.24-3build3) ... 384s Selecting previously unselected package libfreetype6:s390x. 384s Preparing to unpack .../023-libfreetype6_2.13.3+dfsg-1_s390x.deb ... 384s Unpacking libfreetype6:s390x (2.13.3+dfsg-1) ... 384s Selecting previously unselected package fonts-dejavu-mono. 384s Preparing to unpack .../024-fonts-dejavu-mono_2.37-8_all.deb ... 384s Unpacking fonts-dejavu-mono (2.37-8) ... 384s Selecting previously unselected package fonts-dejavu-core. 384s Preparing to unpack .../025-fonts-dejavu-core_2.37-8_all.deb ... 384s Unpacking fonts-dejavu-core (2.37-8) ... 384s Selecting previously unselected package fontconfig-config. 384s Preparing to unpack .../026-fontconfig-config_2.15.0-2ubuntu1_s390x.deb ... 384s Unpacking fontconfig-config (2.15.0-2ubuntu1) ... 384s Selecting previously unselected package libfontconfig1:s390x. 384s Preparing to unpack .../027-libfontconfig1_2.15.0-2ubuntu1_s390x.deb ... 384s Unpacking libfontconfig1:s390x (2.15.0-2ubuntu1) ... 384s Selecting previously unselected package fontconfig. 384s Preparing to unpack .../028-fontconfig_2.15.0-2ubuntu1_s390x.deb ... 384s Unpacking fontconfig (2.15.0-2ubuntu1) ... 384s Selecting previously unselected package fonts-glyphicons-halflings. 384s Preparing to unpack .../029-fonts-glyphicons-halflings_1.009~3.4.1+dfsg-3_all.deb ... 384s Unpacking fonts-glyphicons-halflings (1.009~3.4.1+dfsg-3) ... 384s Selecting previously unselected package fonts-mathjax. 384s Preparing to unpack .../030-fonts-mathjax_2.7.9+dfsg-1_all.deb ... 384s Unpacking fonts-mathjax (2.7.9+dfsg-1) ... 385s Selecting previously unselected package libgfortran5:s390x. 385s Preparing to unpack .../031-libgfortran5_15-20250222-0ubuntu1_s390x.deb ... 385s Unpacking libgfortran5:s390x (15-20250222-0ubuntu1) ... 385s Selecting previously unselected package libgfortran-14-dev:s390x. 385s Preparing to unpack .../032-libgfortran-14-dev_14.2.0-17ubuntu3_s390x.deb ... 385s Unpacking libgfortran-14-dev:s390x (14.2.0-17ubuntu3) ... 385s Selecting previously unselected package gfortran-14-s390x-linux-gnu. 385s Preparing to unpack .../033-gfortran-14-s390x-linux-gnu_14.2.0-17ubuntu3_s390x.deb ... 385s Unpacking gfortran-14-s390x-linux-gnu (14.2.0-17ubuntu3) ... 385s Selecting previously unselected package gfortran-14. 385s Preparing to unpack .../034-gfortran-14_14.2.0-17ubuntu3_s390x.deb ... 385s Unpacking gfortran-14 (14.2.0-17ubuntu3) ... 385s Selecting previously unselected package gfortran-s390x-linux-gnu. 385s Preparing to unpack .../035-gfortran-s390x-linux-gnu_4%3a14.2.0-1ubuntu1_s390x.deb ... 385s Unpacking gfortran-s390x-linux-gnu (4:14.2.0-1ubuntu1) ... 385s Selecting previously unselected package gfortran. 385s Preparing to unpack .../036-gfortran_4%3a14.2.0-1ubuntu1_s390x.deb ... 385s Unpacking gfortran (4:14.2.0-1ubuntu1) ... 385s Selecting previously unselected package icu-devtools. 385s Preparing to unpack .../037-icu-devtools_76.1-1ubuntu2_s390x.deb ... 385s Unpacking icu-devtools (76.1-1ubuntu2) ... 385s Selecting previously unselected package libblas3:s390x. 385s Preparing to unpack .../038-libblas3_3.12.1-2_s390x.deb ... 385s Unpacking libblas3:s390x (3.12.1-2) ... 385s Selecting previously unselected package libblas-dev:s390x. 385s Preparing to unpack .../039-libblas-dev_3.12.1-2_s390x.deb ... 385s Unpacking libblas-dev:s390x (3.12.1-2) ... 385s Selecting previously unselected package libbz2-dev:s390x. 385s Preparing to unpack .../040-libbz2-dev_1.0.8-6_s390x.deb ... 385s Unpacking libbz2-dev:s390x (1.0.8-6) ... 385s Selecting previously unselected package libpixman-1-0:s390x. 385s Preparing to unpack .../041-libpixman-1-0_0.44.0-3_s390x.deb ... 385s Unpacking libpixman-1-0:s390x (0.44.0-3) ... 385s Selecting previously unselected package libxcb-render0:s390x. 385s Preparing to unpack .../042-libxcb-render0_1.17.0-2_s390x.deb ... 385s Unpacking libxcb-render0:s390x (1.17.0-2) ... 385s Selecting previously unselected package libxcb-shm0:s390x. 385s Preparing to unpack .../043-libxcb-shm0_1.17.0-2_s390x.deb ... 385s Unpacking libxcb-shm0:s390x (1.17.0-2) ... 385s Selecting previously unselected package libxrender1:s390x. 385s Preparing to unpack .../044-libxrender1_1%3a0.9.10-1.1build1_s390x.deb ... 385s Unpacking libxrender1:s390x (1:0.9.10-1.1build1) ... 385s Selecting previously unselected package libcairo2:s390x. 385s Preparing to unpack .../045-libcairo2_1.18.2-2_s390x.deb ... 385s Unpacking libcairo2:s390x (1.18.2-2) ... 385s Selecting previously unselected package libdatrie1:s390x. 385s Preparing to unpack .../046-libdatrie1_0.2.13-3build1_s390x.deb ... 385s Unpacking libdatrie1:s390x (0.2.13-3build1) ... 385s Selecting previously unselected package libdeflate0:s390x. 385s Preparing to unpack .../047-libdeflate0_1.23-1_s390x.deb ... 385s Unpacking libdeflate0:s390x (1.23-1) ... 385s Selecting previously unselected package libdeflate-dev:s390x. 385s Preparing to unpack .../048-libdeflate-dev_1.23-1_s390x.deb ... 385s Unpacking libdeflate-dev:s390x (1.23-1) ... 385s Selecting previously unselected package libgraphite2-3:s390x. 385s Preparing to unpack .../049-libgraphite2-3_1.3.14-2ubuntu1_s390x.deb ... 385s Unpacking libgraphite2-3:s390x (1.3.14-2ubuntu1) ... 385s Selecting previously unselected package libharfbuzz0b:s390x. 385s Preparing to unpack .../050-libharfbuzz0b_10.2.0-1_s390x.deb ... 385s Unpacking libharfbuzz0b:s390x (10.2.0-1) ... 385s Selecting previously unselected package x11-common. 385s Preparing to unpack .../051-x11-common_1%3a7.7+23ubuntu3_all.deb ... 385s Unpacking x11-common (1:7.7+23ubuntu3) ... 385s Selecting previously unselected package libice6:s390x. 385s Preparing to unpack .../052-libice6_2%3a1.1.1-1_s390x.deb ... 385s Unpacking libice6:s390x (2:1.1.1-1) ... 385s Selecting previously unselected package libicu-dev:s390x. 385s Preparing to unpack .../053-libicu-dev_76.1-1ubuntu2_s390x.deb ... 385s Unpacking libicu-dev:s390x (76.1-1ubuntu2) ... 385s Selecting previously unselected package libjpeg-turbo8:s390x. 385s Preparing to unpack .../054-libjpeg-turbo8_2.1.5-3ubuntu2_s390x.deb ... 385s Unpacking libjpeg-turbo8:s390x (2.1.5-3ubuntu2) ... 385s Selecting previously unselected package libjpeg-turbo8-dev:s390x. 385s Preparing to unpack .../055-libjpeg-turbo8-dev_2.1.5-3ubuntu2_s390x.deb ... 385s Unpacking libjpeg-turbo8-dev:s390x (2.1.5-3ubuntu2) ... 385s Selecting previously unselected package libjpeg8:s390x. 385s Preparing to unpack .../056-libjpeg8_8c-2ubuntu11_s390x.deb ... 385s Unpacking libjpeg8:s390x (8c-2ubuntu11) ... 385s Selecting previously unselected package libjpeg8-dev:s390x. 385s Preparing to unpack .../057-libjpeg8-dev_8c-2ubuntu11_s390x.deb ... 385s Unpacking libjpeg8-dev:s390x (8c-2ubuntu11) ... 385s Selecting previously unselected package libjpeg-dev:s390x. 385s Preparing to unpack .../058-libjpeg-dev_8c-2ubuntu11_s390x.deb ... 385s Unpacking libjpeg-dev:s390x (8c-2ubuntu11) ... 385s Selecting previously unselected package libjs-bootstrap. 385s Preparing to unpack .../059-libjs-bootstrap_3.4.1+dfsg-3_all.deb ... 385s Unpacking libjs-bootstrap (3.4.1+dfsg-3) ... 385s Selecting previously unselected package libjs-highlight.js. 385s Preparing to unpack .../060-libjs-highlight.js_9.18.5+dfsg1-2_all.deb ... 385s Unpacking libjs-highlight.js (9.18.5+dfsg1-2) ... 385s Selecting previously unselected package libjs-jquery. 385s Preparing to unpack .../061-libjs-jquery_3.6.1+dfsg+~3.5.14-1_all.deb ... 385s Unpacking libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 385s Selecting previously unselected package libjs-jquery-datatables. 385s Preparing to unpack .../062-libjs-jquery-datatables_1.11.5+dfsg-2_all.deb ... 385s Unpacking libjs-jquery-datatables (1.11.5+dfsg-2) ... 385s Selecting previously unselected package liblapack3:s390x. 385s Preparing to unpack .../063-liblapack3_3.12.1-2_s390x.deb ... 385s Unpacking liblapack3:s390x (3.12.1-2) ... 385s Selecting previously unselected package liblapack-dev:s390x. 385s Preparing to unpack .../064-liblapack-dev_3.12.1-2_s390x.deb ... 385s Unpacking liblapack-dev:s390x (3.12.1-2) ... 386s Selecting previously unselected package libncurses-dev:s390x. 386s Preparing to unpack .../065-libncurses-dev_6.5+20250216-2_s390x.deb ... 386s Unpacking libncurses-dev:s390x (6.5+20250216-2) ... 386s Selecting previously unselected package libthai-data. 386s Preparing to unpack .../066-libthai-data_0.1.29-2build1_all.deb ... 386s Unpacking libthai-data (0.1.29-2build1) ... 386s Selecting previously unselected package libthai0:s390x. 386s Preparing to unpack .../067-libthai0_0.1.29-2build1_s390x.deb ... 386s Unpacking libthai0:s390x (0.1.29-2build1) ... 386s Selecting previously unselected package libpango-1.0-0:s390x. 386s Preparing to unpack .../068-libpango-1.0-0_1.56.2-1_s390x.deb ... 386s Unpacking libpango-1.0-0:s390x (1.56.2-1) ... 386s Selecting previously unselected package libpangoft2-1.0-0:s390x. 386s Preparing to unpack .../069-libpangoft2-1.0-0_1.56.2-1_s390x.deb ... 386s Unpacking libpangoft2-1.0-0:s390x (1.56.2-1) ... 386s Selecting previously unselected package libpangocairo-1.0-0:s390x. 386s Preparing to unpack .../070-libpangocairo-1.0-0_1.56.2-1_s390x.deb ... 386s Unpacking libpangocairo-1.0-0:s390x (1.56.2-1) ... 386s Selecting previously unselected package libpaper2:s390x. 386s Preparing to unpack .../071-libpaper2_2.2.5-0.3_s390x.deb ... 386s Unpacking libpaper2:s390x (2.2.5-0.3) ... 386s Selecting previously unselected package libpaper-utils. 386s Preparing to unpack .../072-libpaper-utils_2.2.5-0.3_s390x.deb ... 386s Unpacking libpaper-utils (2.2.5-0.3) ... 386s Selecting previously unselected package libpcre2-16-0:s390x. 386s Preparing to unpack .../073-libpcre2-16-0_10.45-1_s390x.deb ... 386s Unpacking libpcre2-16-0:s390x (10.45-1) ... 386s Selecting previously unselected package libpcre2-32-0:s390x. 386s Preparing to unpack .../074-libpcre2-32-0_10.45-1_s390x.deb ... 386s Unpacking libpcre2-32-0:s390x (10.45-1) ... 386s Selecting previously unselected package libpcre2-posix3:s390x. 386s Preparing to unpack .../075-libpcre2-posix3_10.45-1_s390x.deb ... 386s Unpacking libpcre2-posix3:s390x (10.45-1) ... 386s Selecting previously unselected package libpcre2-dev:s390x. 386s Preparing to unpack .../076-libpcre2-dev_10.45-1_s390x.deb ... 386s Unpacking libpcre2-dev:s390x (10.45-1) ... 386s Selecting previously unselected package libpkgconf3:s390x. 386s Preparing to unpack .../077-libpkgconf3_1.8.1-4_s390x.deb ... 386s Unpacking libpkgconf3:s390x (1.8.1-4) ... 386s Selecting previously unselected package zlib1g-dev:s390x. 386s Preparing to unpack .../078-zlib1g-dev_1%3a1.3.dfsg+really1.3.1-1ubuntu1_s390x.deb ... 386s Unpacking zlib1g-dev:s390x (1:1.3.dfsg+really1.3.1-1ubuntu1) ... 386s Selecting previously unselected package libpng-dev:s390x. 386s Preparing to unpack .../079-libpng-dev_1.6.47-1_s390x.deb ... 386s Unpacking libpng-dev:s390x (1.6.47-1) ... 386s Selecting previously unselected package libreadline-dev:s390x. 386s Preparing to unpack .../080-libreadline-dev_8.2-6_s390x.deb ... 386s Unpacking libreadline-dev:s390x (8.2-6) ... 386s Selecting previously unselected package libsharpyuv0:s390x. 386s Preparing to unpack .../081-libsharpyuv0_1.5.0-0.1_s390x.deb ... 386s Unpacking libsharpyuv0:s390x (1.5.0-0.1) ... 386s Selecting previously unselected package libsm6:s390x. 386s Preparing to unpack .../082-libsm6_2%3a1.2.4-1_s390x.deb ... 386s Unpacking libsm6:s390x (2:1.2.4-1) ... 386s Selecting previously unselected package libtcl8.6:s390x. 386s Preparing to unpack .../083-libtcl8.6_8.6.16+dfsg-1_s390x.deb ... 386s Unpacking libtcl8.6:s390x (8.6.16+dfsg-1) ... 386s Selecting previously unselected package libjbig0:s390x. 386s Preparing to unpack .../084-libjbig0_2.1-6.1ubuntu2_s390x.deb ... 386s Unpacking libjbig0:s390x (2.1-6.1ubuntu2) ... 386s Selecting previously unselected package libwebp7:s390x. 386s Preparing to unpack .../085-libwebp7_1.5.0-0.1_s390x.deb ... 386s Unpacking libwebp7:s390x (1.5.0-0.1) ... 386s Selecting previously unselected package libtiff6:s390x. 386s Preparing to unpack .../086-libtiff6_4.5.1+git230720-4ubuntu4_s390x.deb ... 386s Unpacking libtiff6:s390x (4.5.1+git230720-4ubuntu4) ... 386s Selecting previously unselected package libxft2:s390x. 386s Preparing to unpack .../087-libxft2_2.3.6-1build1_s390x.deb ... 386s Unpacking libxft2:s390x (2.3.6-1build1) ... 386s Selecting previously unselected package libxss1:s390x. 386s Preparing to unpack .../088-libxss1_1%3a1.2.3-1build3_s390x.deb ... 386s Unpacking libxss1:s390x (1:1.2.3-1build3) ... 386s Selecting previously unselected package libtk8.6:s390x. 386s Preparing to unpack .../089-libtk8.6_8.6.16-1_s390x.deb ... 386s Unpacking libtk8.6:s390x (8.6.16-1) ... 386s Selecting previously unselected package libxt6t64:s390x. 386s Preparing to unpack .../090-libxt6t64_1%3a1.2.1-1.2build1_s390x.deb ... 386s Unpacking libxt6t64:s390x (1:1.2.1-1.2build1) ... 386s Selecting previously unselected package node-normalize.css. 386s Preparing to unpack .../091-node-normalize.css_8.0.1-5_all.deb ... 386s Unpacking node-normalize.css (8.0.1-5) ... 386s Selecting previously unselected package zip. 386s Preparing to unpack .../092-zip_3.0-14ubuntu2_s390x.deb ... 386s Unpacking zip (3.0-14ubuntu2) ... 386s Selecting previously unselected package unzip. 386s Preparing to unpack .../093-unzip_6.0-28ubuntu6_s390x.deb ... 386s Unpacking unzip (6.0-28ubuntu6) ... 386s Selecting previously unselected package xdg-utils. 386s Preparing to unpack .../094-xdg-utils_1.2.1-2ubuntu1_all.deb ... 386s Unpacking xdg-utils (1.2.1-2ubuntu1) ... 386s Selecting previously unselected package r-base-core. 386s Preparing to unpack .../095-r-base-core_4.4.3-1_s390x.deb ... 386s Unpacking r-base-core (4.4.3-1) ... 386s Selecting previously unselected package liblzma-dev:s390x. 386s Preparing to unpack .../096-liblzma-dev_5.6.4-1_s390x.deb ... 386s Unpacking liblzma-dev:s390x (5.6.4-1) ... 386s Selecting previously unselected package pkgconf-bin. 386s Preparing to unpack .../097-pkgconf-bin_1.8.1-4_s390x.deb ... 386s Unpacking pkgconf-bin (1.8.1-4) ... 386s Selecting previously unselected package pkgconf:s390x. 386s Preparing to unpack .../098-pkgconf_1.8.1-4_s390x.deb ... 386s Unpacking pkgconf:s390x (1.8.1-4) ... 386s Selecting previously unselected package libtirpc-dev:s390x. 386s Preparing to unpack .../099-libtirpc-dev_1.3.4+ds-1.3_s390x.deb ... 386s Unpacking libtirpc-dev:s390x (1.3.4+ds-1.3) ... 386s Selecting previously unselected package r-base-dev. 386s Preparing to unpack .../100-r-base-dev_4.4.3-1_all.deb ... 386s Unpacking r-base-dev (4.4.3-1) ... 386s Selecting previously unselected package pkg-r-autopkgtest. 386s Preparing to unpack .../101-pkg-r-autopkgtest_20231212ubuntu1_all.deb ... 386s Unpacking pkg-r-autopkgtest (20231212ubuntu1) ... 386s Selecting previously unselected package r-cran-base64enc. 386s Preparing to unpack .../102-r-cran-base64enc_0.1-3-3_s390x.deb ... 386s Unpacking r-cran-base64enc (0.1-3-3) ... 386s Selecting previously unselected package r-cran-cli. 386s Preparing to unpack .../103-r-cran-cli_3.6.4-1_s390x.deb ... 386s Unpacking r-cran-cli (3.6.4-1) ... 386s Selecting previously unselected package r-cran-colorspace. 386s Preparing to unpack .../104-r-cran-colorspace_2.1-1+dfsg-1_s390x.deb ... 386s Unpacking r-cran-colorspace (2.1-1+dfsg-1) ... 386s Selecting previously unselected package r-cran-commonmark. 386s Preparing to unpack .../105-r-cran-commonmark_1.9.2-2_s390x.deb ... 386s Unpacking r-cran-commonmark (1.9.2-2) ... 386s Selecting previously unselected package r-cran-evaluate. 386s Preparing to unpack .../106-r-cran-evaluate_1.0.3-1_all.deb ... 386s Unpacking r-cran-evaluate (1.0.3-1) ... 386s Selecting previously unselected package r-cran-fansi. 386s Preparing to unpack .../107-r-cran-fansi_1.0.5-1_s390x.deb ... 386s Unpacking r-cran-fansi (1.0.5-1) ... 386s Selecting previously unselected package r-cran-farver. 386s Preparing to unpack .../108-r-cran-farver_2.1.2-1_s390x.deb ... 386s Unpacking r-cran-farver (2.1.2-1) ... 387s Selecting previously unselected package r-cran-glue. 387s Preparing to unpack .../109-r-cran-glue_1.8.0-1_s390x.deb ... 387s Unpacking r-cran-glue (1.8.0-1) ... 387s Selecting previously unselected package r-cran-rlang. 387s Preparing to unpack .../110-r-cran-rlang_1.1.5-1_s390x.deb ... 387s Unpacking r-cran-rlang (1.1.5-1) ... 387s Selecting previously unselected package r-cran-lifecycle. 387s Preparing to unpack .../111-r-cran-lifecycle_1.0.4+dfsg-1_all.deb ... 387s Unpacking r-cran-lifecycle (1.0.4+dfsg-1) ... 387s Selecting previously unselected package r-cran-gtable. 387s Preparing to unpack .../112-r-cran-gtable_0.3.6+dfsg-1_all.deb ... 387s Unpacking r-cran-gtable (0.3.6+dfsg-1) ... 387s Selecting previously unselected package r-cran-isoband. 387s Preparing to unpack .../113-r-cran-isoband_0.2.7-1_s390x.deb ... 387s Unpacking r-cran-isoband (0.2.7-1) ... 387s Selecting previously unselected package r-cran-mass. 387s Preparing to unpack .../114-r-cran-mass_7.3-64-1_s390x.deb ... 387s Unpacking r-cran-mass (7.3-64-1) ... 387s Selecting previously unselected package r-cran-lattice. 387s Preparing to unpack .../115-r-cran-lattice_0.22-6-1_s390x.deb ... 387s Unpacking r-cran-lattice (0.22-6-1) ... 387s Selecting previously unselected package r-cran-nlme. 387s Preparing to unpack .../116-r-cran-nlme_3.1.167-1_s390x.deb ... 387s Unpacking r-cran-nlme (3.1.167-1) ... 387s Selecting previously unselected package r-cran-matrix. 387s Preparing to unpack .../117-r-cran-matrix_1.7-3-1_s390x.deb ... 387s Unpacking r-cran-matrix (1.7-3-1) ... 387s Selecting previously unselected package r-cran-mgcv. 387s Preparing to unpack .../118-r-cran-mgcv_1.9-1-1_s390x.deb ... 387s Unpacking r-cran-mgcv (1.9-1-1) ... 387s Selecting previously unselected package r-cran-labeling. 387s Preparing to unpack .../119-r-cran-labeling_0.4.3-1_all.deb ... 387s Unpacking r-cran-labeling (0.4.3-1) ... 387s Selecting previously unselected package r-cran-munsell. 387s Preparing to unpack .../120-r-cran-munsell_0.5.1-1_all.deb ... 387s Unpacking r-cran-munsell (0.5.1-1) ... 387s Selecting previously unselected package r-cran-r6. 387s Preparing to unpack .../121-r-cran-r6_2.6.1-1_all.deb ... 387s Unpacking r-cran-r6 (2.6.1-1) ... 387s Selecting previously unselected package r-cran-rcolorbrewer. 387s Preparing to unpack .../122-r-cran-rcolorbrewer_1.1-3-1build1_all.deb ... 387s Unpacking r-cran-rcolorbrewer (1.1-3-1build1) ... 387s Selecting previously unselected package r-cran-viridislite. 387s Preparing to unpack .../123-r-cran-viridislite_0.4.2-2_all.deb ... 387s Unpacking r-cran-viridislite (0.4.2-2) ... 387s Selecting previously unselected package r-cran-scales. 387s Preparing to unpack .../124-r-cran-scales_1.3.0-1_all.deb ... 387s Unpacking r-cran-scales (1.3.0-1) ... 387s Selecting previously unselected package r-cran-magrittr. 387s Preparing to unpack .../125-r-cran-magrittr_2.0.3-1_s390x.deb ... 387s Unpacking r-cran-magrittr (2.0.3-1) ... 387s Selecting previously unselected package r-cran-utf8. 387s Preparing to unpack .../126-r-cran-utf8_1.2.4-1_s390x.deb ... 387s Unpacking r-cran-utf8 (1.2.4-1) ... 387s Selecting previously unselected package r-cran-vctrs. 387s Preparing to unpack .../127-r-cran-vctrs_0.6.5-1_s390x.deb ... 387s Unpacking r-cran-vctrs (0.6.5-1) ... 387s Selecting previously unselected package r-cran-pillar. 387s Preparing to unpack .../128-r-cran-pillar_1.10.1+dfsg-1_all.deb ... 387s Unpacking r-cran-pillar (1.10.1+dfsg-1) ... 387s Selecting previously unselected package r-cran-pkgconfig. 387s Preparing to unpack .../129-r-cran-pkgconfig_2.0.3-2build1_all.deb ... 387s Unpacking r-cran-pkgconfig (2.0.3-2build1) ... 387s Selecting previously unselected package r-cran-tibble. 387s Preparing to unpack .../130-r-cran-tibble_3.2.1+dfsg-3_s390x.deb ... 387s Unpacking r-cran-tibble (3.2.1+dfsg-3) ... 387s Selecting previously unselected package r-cran-withr. 387s Preparing to unpack .../131-r-cran-withr_3.0.2+dfsg-1_all.deb ... 387s Unpacking r-cran-withr (3.0.2+dfsg-1) ... 387s Selecting previously unselected package r-cran-ggplot2. 387s Preparing to unpack .../132-r-cran-ggplot2_3.5.1+dfsg-1_all.deb ... 387s Unpacking r-cran-ggplot2 (3.5.1+dfsg-1) ... 387s Selecting previously unselected package r-cran-xfun. 387s Preparing to unpack .../133-r-cran-xfun_0.51+dfsg-1_s390x.deb ... 387s Unpacking r-cran-xfun (0.51+dfsg-1) ... 387s Selecting previously unselected package r-cran-highr. 387s Preparing to unpack .../134-r-cran-highr_0.11+dfsg-1_all.deb ... 387s Unpacking r-cran-highr (0.11+dfsg-1) ... 387s Selecting previously unselected package r-cran-yaml. 387s Preparing to unpack .../135-r-cran-yaml_2.3.10-1_s390x.deb ... 387s Unpacking r-cran-yaml (2.3.10-1) ... 387s Selecting previously unselected package libjs-mathjax. 387s Preparing to unpack .../136-libjs-mathjax_2.7.9+dfsg-1_all.deb ... 387s Unpacking libjs-mathjax (2.7.9+dfsg-1) ... 388s Selecting previously unselected package r-cran-knitr. 388s Preparing to unpack .../137-r-cran-knitr_1.49+dfsg-1_all.deb ... 388s Unpacking r-cran-knitr (1.49+dfsg-1) ... 388s Selecting previously unselected package r-cran-markdown. 388s Preparing to unpack .../138-r-cran-markdown_1.13-1_all.deb ... 388s Unpacking r-cran-markdown (1.13-1) ... 388s Selecting previously unselected package r-cran-matrixstats. 388s Preparing to unpack .../139-r-cran-matrixstats_1.5.0-1_s390x.deb ... 388s Unpacking r-cran-matrixstats (1.5.0-1) ... 388s Setting up libgraphite2-3:s390x (1.3.14-2ubuntu1) ... 388s Setting up libpixman-1-0:s390x (0.44.0-3) ... 388s Setting up libsharpyuv0:s390x (1.5.0-0.1) ... 388s Setting up libncurses-dev:s390x (6.5+20250216-2) ... 388s Setting up fonts-mathjax (2.7.9+dfsg-1) ... 388s Setting up libjs-mathjax (2.7.9+dfsg-1) ... 388s Setting up libxrender1:s390x (1:0.9.10-1.1build1) ... 388s Setting up libdatrie1:s390x (0.2.13-3build1) ... 388s Setting up libxcb-render0:s390x (1.17.0-2) ... 388s Setting up fonts-glyphicons-halflings (1.009~3.4.1+dfsg-3) ... 388s Setting up unzip (6.0-28ubuntu6) ... 388s Setting up x11-common (1:7.7+23ubuntu3) ... 388s Setting up libdeflate0:s390x (1.23-1) ... 388s Setting up libxcb-shm0:s390x (1.17.0-2) ... 388s Setting up libreadline-dev:s390x (8.2-6) ... 388s Setting up libgomp1:s390x (15-20250222-0ubuntu1) ... 388s Setting up libjbig0:s390x (2.1-6.1ubuntu2) ... 388s Setting up libpcre2-16-0:s390x (10.45-1) ... 388s Setting up zip (3.0-14ubuntu2) ... 388s Setting up libpcre2-32-0:s390x (10.45-1) ... 388s Setting up libblas3:s390x (3.12.1-2) ... 388s update-alternatives: using /usr/lib/s390x-linux-gnu/blas/libblas.so.3 to provide /usr/lib/s390x-linux-gnu/libblas.so.3 (libblas.so.3-s390x-linux-gnu) in auto mode 388s Setting up libtirpc-dev:s390x (1.3.4+ds-1.3) ... 388s Setting up libpkgconf3:s390x (1.8.1-4) ... 388s Setting up libfreetype6:s390x (2.13.3+dfsg-1) ... 388s Setting up fonts-dejavu-mono (2.37-8) ... 388s Setting up libmpc3:s390x (1.3.1-1build2) ... 388s Setting up libtcl8.6:s390x (8.6.16+dfsg-1) ... 388s Setting up icu-devtools (76.1-1ubuntu2) ... 388s Setting up fonts-dejavu-core (2.37-8) ... 388s Setting up pkgconf-bin (1.8.1-4) ... 388s Setting up libjpeg-turbo8:s390x (2.1.5-3ubuntu2) ... 388s Setting up libgfortran5:s390x (15-20250222-0ubuntu1) ... 388s Setting up libwebp7:s390x (1.5.0-0.1) ... 388s Setting up liblzma-dev:s390x (5.6.4-1) ... 388s Setting up libubsan1:s390x (15-20250222-0ubuntu1) ... 388s Setting up zlib1g-dev:s390x (1:1.3.dfsg+really1.3.1-1ubuntu1) ... 388s Setting up libpcre2-posix3:s390x (10.45-1) ... 388s Setting up libjs-highlight.js (9.18.5+dfsg1-2) ... 388s Setting up libasan8:s390x (15-20250222-0ubuntu1) ... 388s Setting up libharfbuzz0b:s390x (10.2.0-1) ... 388s Setting up libthai-data (0.1.29-2build1) ... 388s Setting up libxss1:s390x (1:1.2.3-1build3) ... 388s Setting up libpaper2:s390x (2.2.5-0.3) ... 388s Setting up libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 388s Setting up libisl23:s390x (0.27-1) ... 388s Setting up libdeflate-dev:s390x (1.23-1) ... 388s Setting up node-normalize.css (8.0.1-5) ... 388s Setting up libicu-dev:s390x (76.1-1ubuntu2) ... 388s Setting up xdg-utils (1.2.1-2ubuntu1) ... 388s update-alternatives: using /usr/bin/xdg-open to provide /usr/bin/open (open) in auto mode 388s Setting up libcc1-0:s390x (15-20250222-0ubuntu1) ... 388s Setting up libblas-dev:s390x (3.12.1-2) ... 388s update-alternatives: using /usr/lib/s390x-linux-gnu/blas/libblas.so to provide /usr/lib/s390x-linux-gnu/libblas.so (libblas.so-s390x-linux-gnu) in auto mode 388s Setting up dctrl-tools (2.24-3build3) ... 388s Setting up libjs-bootstrap (3.4.1+dfsg-3) ... 388s Setting up libitm1:s390x (15-20250222-0ubuntu1) ... 388s Setting up libbz2-dev:s390x (1.0.8-6) ... 388s Setting up libjpeg8:s390x (8c-2ubuntu11) ... 388s Setting up libice6:s390x (2:1.1.1-1) ... 388s Setting up libjpeg-turbo8-dev:s390x (2.1.5-3ubuntu2) ... 388s Setting up liblapack3:s390x (3.12.1-2) ... 388s update-alternatives: using /usr/lib/s390x-linux-gnu/lapack/liblapack.so.3 to provide /usr/lib/s390x-linux-gnu/liblapack.so.3 (liblapack.so.3-s390x-linux-gnu) in auto mode 388s Setting up libpcre2-dev:s390x (10.45-1) ... 388s Setting up fontconfig-config (2.15.0-2ubuntu1) ... 388s Setting up libpng-dev:s390x (1.6.47-1) ... 388s Setting up libpaper-utils (2.2.5-0.3) ... 388s Setting up libjs-jquery-datatables (1.11.5+dfsg-2) ... 388s Setting up pkgconf:s390x (1.8.1-4) ... 388s Setting up libthai0:s390x (0.1.29-2build1) ... 388s Setting up liblapack-dev:s390x (3.12.1-2) ... 388s update-alternatives: using /usr/lib/s390x-linux-gnu/lapack/liblapack.so to provide /usr/lib/s390x-linux-gnu/liblapack.so (liblapack.so-s390x-linux-gnu) in auto mode 388s Setting up cpp-14-s390x-linux-gnu (14.2.0-17ubuntu3) ... 388s Setting up cpp-14 (14.2.0-17ubuntu3) ... 388s Setting up libtiff6:s390x (4.5.1+git230720-4ubuntu4) ... 388s Setting up libfontconfig1:s390x (2.15.0-2ubuntu1) ... 388s Setting up libgcc-14-dev:s390x (14.2.0-17ubuntu3) ... 388s Setting up libjpeg8-dev:s390x (8c-2ubuntu11) ... 388s Setting up libstdc++-14-dev:s390x (14.2.0-17ubuntu3) ... 388s Setting up libsm6:s390x (2:1.2.4-1) ... 388s Setting up libgfortran-14-dev:s390x (14.2.0-17ubuntu3) ... 388s Setting up fontconfig (2.15.0-2ubuntu1) ... 390s Regenerating fonts cache... done. 390s Setting up libxft2:s390x (2.3.6-1build1) ... 390s Setting up cpp-s390x-linux-gnu (4:14.2.0-1ubuntu1) ... 390s Setting up libtk8.6:s390x (8.6.16-1) ... 390s Setting up libpango-1.0-0:s390x (1.56.2-1) ... 390s Setting up libjpeg-dev:s390x (8c-2ubuntu11) ... 390s Setting up libcairo2:s390x (1.18.2-2) ... 390s Setting up gcc-14-s390x-linux-gnu (14.2.0-17ubuntu3) ... 390s Setting up gcc-s390x-linux-gnu (4:14.2.0-1ubuntu1) ... 390s Setting up libxt6t64:s390x (1:1.2.1-1.2build1) ... 390s Setting up g++-14-s390x-linux-gnu (14.2.0-17ubuntu3) ... 390s Setting up cpp (4:14.2.0-1ubuntu1) ... 390s Setting up libpangoft2-1.0-0:s390x (1.56.2-1) ... 390s Setting up libpangocairo-1.0-0:s390x (1.56.2-1) ... 390s Setting up gfortran-14-s390x-linux-gnu (14.2.0-17ubuntu3) ... 390s Setting up g++-s390x-linux-gnu (4:14.2.0-1ubuntu1) ... 390s Setting up gcc-14 (14.2.0-17ubuntu3) ... 390s Setting up r-base-core (4.4.3-1) ... 390s Creating config file /etc/R/Renviron with new version 390s Setting up r-cran-labeling (0.4.3-1) ... 390s Setting up r-cran-lattice (0.22-6-1) ... 390s Setting up r-cran-nlme (3.1.167-1) ... 390s Setting up r-cran-farver (2.1.2-1) ... 390s Setting up r-cran-viridislite (0.4.2-2) ... 390s Setting up r-cran-commonmark (1.9.2-2) ... 390s Setting up g++-14 (14.2.0-17ubuntu3) ... 390s Setting up r-cran-r6 (2.6.1-1) ... 390s Setting up gfortran-14 (14.2.0-17ubuntu3) ... 390s Setting up r-cran-magrittr (2.0.3-1) ... 390s Setting up r-cran-rlang (1.1.5-1) ... 390s Setting up r-cran-matrixstats (1.5.0-1) ... 390s Setting up gfortran-s390x-linux-gnu (4:14.2.0-1ubuntu1) ... 390s Setting up r-cran-xfun (0.51+dfsg-1) ... 390s Setting up r-cran-withr (3.0.2+dfsg-1) ... 390s Setting up r-cran-base64enc (0.1-3-3) ... 390s Setting up r-cran-yaml (2.3.10-1) ... 390s Setting up r-cran-evaluate (1.0.3-1) ... 390s Setting up r-cran-highr (0.11+dfsg-1) ... 390s Setting up r-cran-fansi (1.0.5-1) ... 390s Setting up r-cran-mass (7.3-64-1) ... 390s Setting up r-cran-glue (1.8.0-1) ... 390s Setting up r-cran-cli (3.6.4-1) ... 390s Setting up r-cran-lifecycle (1.0.4+dfsg-1) ... 390s Setting up gcc (4:14.2.0-1ubuntu1) ... 390s Setting up r-cran-pkgconfig (2.0.3-2build1) ... 390s Setting up r-cran-utf8 (1.2.4-1) ... 390s Setting up r-cran-colorspace (2.1-1+dfsg-1) ... 390s Setting up r-cran-markdown (1.13-1) ... 390s Setting up r-cran-rcolorbrewer (1.1-3-1build1) ... 390s Setting up r-cran-isoband (0.2.7-1) ... 390s Setting up r-cran-gtable (0.3.6+dfsg-1) ... 390s Setting up r-cran-matrix (1.7-3-1) ... 390s Setting up r-cran-knitr (1.49+dfsg-1) ... 390s Setting up r-cran-mgcv (1.9-1-1) ... 390s Setting up g++ (4:14.2.0-1ubuntu1) ... 390s update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode 390s Setting up build-essential (12.10ubuntu1) ... 390s Setting up r-cran-vctrs (0.6.5-1) ... 390s Setting up r-cran-pillar (1.10.1+dfsg-1) ... 390s Setting up r-cran-munsell (0.5.1-1) ... 390s Setting up r-cran-tibble (3.2.1+dfsg-3) ... 390s Setting up gfortran (4:14.2.0-1ubuntu1) ... 390s update-alternatives: using /usr/bin/gfortran to provide /usr/bin/f95 (f95) in auto mode 390s update-alternatives: warning: skip creation of /usr/share/man/man1/f95.1.gz because associated file /usr/share/man/man1/gfortran.1.gz (of link group f95) doesn't exist 390s update-alternatives: using /usr/bin/gfortran to provide /usr/bin/f77 (f77) in auto mode 390s update-alternatives: warning: skip creation of /usr/share/man/man1/f77.1.gz because associated file /usr/share/man/man1/gfortran.1.gz (of link group f77) doesn't exist 390s Setting up r-cran-scales (1.3.0-1) ... 390s Setting up r-base-dev (4.4.3-1) ... 390s Setting up r-cran-ggplot2 (3.5.1+dfsg-1) ... 390s Setting up pkg-r-autopkgtest (20231212ubuntu1) ... 390s Processing triggers for libc-bin (2.41-1ubuntu2) ... 390s Processing triggers for man-db (2.13.0-1) ... 392s Processing triggers for install-info (7.1.1-1) ... 395s autopkgtest [18:16:45]: test pkg-r-autopkgtest: /usr/share/dh-r/pkg-r-autopkgtest 395s autopkgtest [18:16:45]: test pkg-r-autopkgtest: [----------------------- 395s Test: Try to load the R library matrixStats 395s 395s R version 4.4.3 (2025-02-28) -- "Trophy Case" 395s Copyright (C) 2025 The R Foundation for Statistical Computing 395s Platform: s390x-ibm-linux-gnu 395s 395s R is free software and comes with ABSOLUTELY NO WARRANTY. 395s You are welcome to redistribute it under certain conditions. 395s Type 'license()' or 'licence()' for distribution details. 395s 395s R is a collaborative project with many contributors. 395s Type 'contributors()' for more information and 395s 'citation()' on how to cite R or R packages in publications. 395s 395s Type 'demo()' for some demos, 'help()' for on-line help, or 395s 'help.start()' for an HTML browser interface to help. 395s Type 'q()' to quit R. 395s 395s > library('matrixStats') 395s > 395s > 395s Other tests are currently unsupported! 395s They will be progressively added. 395s autopkgtest [18:16:45]: test pkg-r-autopkgtest: -----------------------] 396s autopkgtest [18:16:46]: test pkg-r-autopkgtest: - - - - - - - - - - results - - - - - - - - - - 396s pkg-r-autopkgtest PASS 396s autopkgtest [18:16:46]: @@@@@@@@@@@@@@@@@@@@ summary 396s run-unit-test PASS 396s pkg-r-autopkgtest PASS 415s nova [W] Using flock in prodstack6-s390x 415s Creating nova instance adt-plucky-s390x-r-cran-matrixstats-20250315-181010-juju-7f2275-prod-proposed-migration-environment-20-808cdcfa-602f-41f9-98fd-be11820184a5 from image adt/ubuntu-plucky-s390x-server-20250315.img (UUID 3d3557fa-fd0f-4bba-9b89-8d5964e09f61)... 415s nova [W] Timed out waiting for 6494b6ca-2760-4816-8c83-563b9c756da0 to get deleted. 415s nova [W] Using flock in prodstack6-s390x 415s Creating nova instance adt-plucky-s390x-r-cran-matrixstats-20250315-181010-juju-7f2275-prod-proposed-migration-environment-20-808cdcfa-602f-41f9-98fd-be11820184a5 from image adt/ubuntu-plucky-s390x-server-20250315.img (UUID 3d3557fa-fd0f-4bba-9b89-8d5964e09f61)... 415s nova [W] Timed out waiting for eb14f54a-283a-4afa-baf4-239ee1549285 to get deleted.