This file is indexed.

/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/multiarray_api.txt is in python-numpy 1:1.12.1-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
===========
NumPy C-API
===========
::

  unsigned int
  PyArray_GetNDArrayCVersion(void )


Included at the very first so not auto-grabbed and thus not labeled.

::

  int
  PyArray_SetNumericOps(PyObject *dict)

Set internal structure with number functions that all arrays will use

::

  PyObject *
  PyArray_GetNumericOps(void )

Get dictionary showing number functions that all arrays will use

::

  int
  PyArray_INCREF(PyArrayObject *mp)

For object arrays, increment all internal references.

::

  int
  PyArray_XDECREF(PyArrayObject *mp)

Decrement all internal references for object arrays.
(or arrays with object fields)

::

  void
  PyArray_SetStringFunction(PyObject *op, int repr)

Set the array print function to be a Python function.

::

  PyArray_Descr *
  PyArray_DescrFromType(int type)

Get the PyArray_Descr structure for a type.

::

  PyObject *
  PyArray_TypeObjectFromType(int type)

Get a typeobject from a type-number -- can return NULL.

New reference

::

  char *
  PyArray_Zero(PyArrayObject *arr)

Get pointer to zero of correct type for array.

::

  char *
  PyArray_One(PyArrayObject *arr)

Get pointer to one of correct type for array

::

  PyObject *
  PyArray_CastToType(PyArrayObject *arr, PyArray_Descr *dtype, int
                     is_f_order)

For backward compatibility

Cast an array using typecode structure.
steals reference to dtype --- cannot be NULL

This function always makes a copy of arr, even if the dtype
doesn't change.

::

  int
  PyArray_CastTo(PyArrayObject *out, PyArrayObject *mp)

Cast to an already created array.

::

  int
  PyArray_CastAnyTo(PyArrayObject *out, PyArrayObject *mp)

Cast to an already created array.  Arrays don't have to be "broadcastable"
Only requirement is they have the same number of elements.

::

  int
  PyArray_CanCastSafely(int fromtype, int totype)

Check the type coercion rules.

::

  npy_bool
  PyArray_CanCastTo(PyArray_Descr *from, PyArray_Descr *to)

leaves reference count alone --- cannot be NULL

PyArray_CanCastTypeTo is equivalent to this, but adds a 'casting'
parameter.

::

  int
  PyArray_ObjectType(PyObject *op, int minimum_type)

Return the typecode of the array a Python object would be converted to

Returns the type number the result should have, or NPY_NOTYPE on error.

::

  PyArray_Descr *
  PyArray_DescrFromObject(PyObject *op, PyArray_Descr *mintype)

new reference -- accepts NULL for mintype

::

  PyArrayObject **
  PyArray_ConvertToCommonType(PyObject *op, int *retn)


::

  PyArray_Descr *
  PyArray_DescrFromScalar(PyObject *sc)

Return descr object from array scalar.

New reference

::

  PyArray_Descr *
  PyArray_DescrFromTypeObject(PyObject *type)


::

  npy_intp
  PyArray_Size(PyObject *op)

Compute the size of an array (in number of items)

::

  PyObject *
  PyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base)

Get scalar-equivalent to a region of memory described by a descriptor.

::

  PyObject *
  PyArray_FromScalar(PyObject *scalar, PyArray_Descr *outcode)

Get 0-dim array from scalar

0-dim array from array-scalar object
always contains a copy of the data
unless outcode is NULL, it is of void type and the referrer does
not own it either.

steals reference to outcode

::

  void
  PyArray_ScalarAsCtype(PyObject *scalar, void *ctypeptr)

Convert to c-type

no error checking is performed -- ctypeptr must be same type as scalar
in case of flexible type, the data is not copied
into ctypeptr which is expected to be a pointer to pointer

::

  int
  PyArray_CastScalarToCtype(PyObject *scalar, void
                            *ctypeptr, PyArray_Descr *outcode)

Cast Scalar to c-type

The output buffer must be large-enough to receive the value
Even for flexible types which is different from ScalarAsCtype
where only a reference for flexible types is returned

This may not work right on narrow builds for NumPy unicode scalars.

::

  int
  PyArray_CastScalarDirect(PyObject *scalar, PyArray_Descr
                           *indescr, void *ctypeptr, int outtype)

Cast Scalar to c-type

::

  PyObject *
  PyArray_ScalarFromObject(PyObject *object)

Get an Array Scalar From a Python Object

Returns NULL if unsuccessful but error is only set if another error occurred.
Currently only Numeric-like object supported.

::

  PyArray_VectorUnaryFunc *
  PyArray_GetCastFunc(PyArray_Descr *descr, int type_num)

Get a cast function to cast from the input descriptor to the
output type_number (must be a registered data-type).
Returns NULL if un-successful.

::

  PyObject *
  PyArray_FromDims(int nd, int *d, int type)

Construct an empty array from dimensions and typenum

::

  PyObject *
  PyArray_FromDimsAndDataAndDescr(int nd, int *d, PyArray_Descr
                                  *descr, char *data)

Like FromDimsAndData but uses the Descr structure instead of typecode
as input.

::

  PyObject *
  PyArray_FromAny(PyObject *op, PyArray_Descr *newtype, int
                  min_depth, int max_depth, int flags, PyObject
                  *context)

Does not check for NPY_ARRAY_ENSURECOPY and NPY_ARRAY_NOTSWAPPED in flags
Steals a reference to newtype --- which can be NULL

::

  PyObject *
  PyArray_EnsureArray(PyObject *op)

This is a quick wrapper around PyArray_FromAny(op, NULL, 0, 0, ENSUREARRAY)
that special cases Arrays and PyArray_Scalars up front
It *steals a reference* to the object
It also guarantees that the result is PyArray_Type
Because it decrefs op if any conversion needs to take place
so it can be used like PyArray_EnsureArray(some_function(...))

::

  PyObject *
  PyArray_EnsureAnyArray(PyObject *op)


::

  PyObject *
  PyArray_FromFile(FILE *fp, PyArray_Descr *dtype, npy_intp num, char
                   *sep)


Given a ``FILE *`` pointer ``fp``, and a ``PyArray_Descr``, return an
array corresponding to the data encoded in that file.

If the dtype is NULL, the default array type is used (double).
If non-null, the reference is stolen and if dtype->subarray is true dtype
will be decrefed even on success.

The number of elements to read is given as ``num``; if it is < 0, then
then as many as possible are read.

If ``sep`` is NULL or empty, then binary data is assumed, else
text data, with ``sep`` as the separator between elements. Whitespace in
the separator matches any length of whitespace in the text, and a match
for whitespace around the separator is added.

For memory-mapped files, use the buffer interface. No more data than
necessary is read by this routine.

::

  PyObject *
  PyArray_FromString(char *data, npy_intp slen, PyArray_Descr
                     *dtype, npy_intp num, char *sep)


Given a pointer to a string ``data``, a string length ``slen``, and
a ``PyArray_Descr``, return an array corresponding to the data
encoded in that string.

If the dtype is NULL, the default array type is used (double).
If non-null, the reference is stolen.

If ``slen`` is < 0, then the end of string is used for text data.
It is an error for ``slen`` to be < 0 for binary data (since embedded NULLs
would be the norm).

The number of elements to read is given as ``num``; if it is < 0, then
then as many as possible are read.

If ``sep`` is NULL or empty, then binary data is assumed, else
text data, with ``sep`` as the separator between elements. Whitespace in
the separator matches any length of whitespace in the text, and a match
for whitespace around the separator is added.

::

  PyObject *
  PyArray_FromBuffer(PyObject *buf, PyArray_Descr *type, npy_intp
                     count, npy_intp offset)


::

  PyObject *
  PyArray_FromIter(PyObject *obj, PyArray_Descr *dtype, npy_intp count)


steals a reference to dtype (which cannot be NULL)

::

  PyObject *
  PyArray_Return(PyArrayObject *mp)


Return either an array or the appropriate Python object if the array
is 0d and matches a Python type.
steals reference to mp

::

  PyObject *
  PyArray_GetField(PyArrayObject *self, PyArray_Descr *typed, int
                   offset)

Get a subset of bytes from each element of the array
steals reference to typed, must not be NULL

::

  int
  PyArray_SetField(PyArrayObject *self, PyArray_Descr *dtype, int
                   offset, PyObject *val)

Set a subset of bytes from each element of the array
steals reference to dtype, must not be NULL

::

  PyObject *
  PyArray_Byteswap(PyArrayObject *self, npy_bool inplace)


::

  PyObject *
  PyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape, int
                 refcheck, NPY_ORDER order)

Resize (reallocate data).  Only works if nothing else is referencing this
array and it is contiguous.  If refcheck is 0, then the reference count is
not checked and assumed to be 1.  You still must own this data and have no
weak-references and no base object.

::

  int
  PyArray_MoveInto(PyArrayObject *dst, PyArrayObject *src)

Move the memory of one array into another, allowing for overlapping data.

Returns 0 on success, negative on failure.

::

  int
  PyArray_CopyInto(PyArrayObject *dst, PyArrayObject *src)

Copy an Array into another array.
Broadcast to the destination shape if necessary.

Returns 0 on success, -1 on failure.

::

  int
  PyArray_CopyAnyInto(PyArrayObject *dst, PyArrayObject *src)

Copy an Array into another array -- memory must not overlap
Does not require src and dest to have "broadcastable" shapes
(only the same number of elements).

TODO: For NumPy 2.0, this could accept an order parameter which
only allows NPY_CORDER and NPY_FORDER.  Could also rename
this to CopyAsFlat to make the name more intuitive.

Returns 0 on success, -1 on error.

::

  int
  PyArray_CopyObject(PyArrayObject *dest, PyObject *src_object)


::

  PyObject *
  PyArray_NewCopy(PyArrayObject *obj, NPY_ORDER order)

Copy an array.

::

  PyObject *
  PyArray_ToList(PyArrayObject *self)

To List

::

  PyObject *
  PyArray_ToString(PyArrayObject *self, NPY_ORDER order)


::

  int
  PyArray_ToFile(PyArrayObject *self, FILE *fp, char *sep, char *format)

To File

::

  int
  PyArray_Dump(PyObject *self, PyObject *file, int protocol)


::

  PyObject *
  PyArray_Dumps(PyObject *self, int protocol)


::

  int
  PyArray_ValidType(int type)

Is the typenum valid?

::

  void
  PyArray_UpdateFlags(PyArrayObject *ret, int flagmask)

Update Several Flags at once.

::

  PyObject *
  PyArray_New(PyTypeObject *subtype, int nd, npy_intp *dims, int
              type_num, npy_intp *strides, void *data, int itemsize, int
              flags, PyObject *obj)

Generic new array creation routine.

::

  PyObject *
  PyArray_NewFromDescr(PyTypeObject *subtype, PyArray_Descr *descr, int
                       nd, npy_intp *dims, npy_intp *strides, void
                       *data, int flags, PyObject *obj)

Generic new array creation routine.

steals a reference to descr. On failure or when dtype->subarray is
true, dtype will be decrefed.

::

  PyArray_Descr *
  PyArray_DescrNew(PyArray_Descr *base)

base cannot be NULL

::

  PyArray_Descr *
  PyArray_DescrNewFromType(int type_num)


::

  double
  PyArray_GetPriority(PyObject *obj, double default_)

Get Priority from object

::

  PyObject *
  PyArray_IterNew(PyObject *obj)

Get Iterator.

::

  PyObject *
  PyArray_MultiIterNew(int n, ... )

Get MultiIterator,

::

  int
  PyArray_PyIntAsInt(PyObject *o)


::

  npy_intp
  PyArray_PyIntAsIntp(PyObject *o)


::

  int
  PyArray_Broadcast(PyArrayMultiIterObject *mit)


::

  void
  PyArray_FillObjectArray(PyArrayObject *arr, PyObject *obj)

Assumes contiguous

::

  int
  PyArray_FillWithScalar(PyArrayObject *arr, PyObject *obj)


::

  npy_bool
  PyArray_CheckStrides(int elsize, int nd, npy_intp numbytes, npy_intp
                       offset, npy_intp *dims, npy_intp *newstrides)


::

  PyArray_Descr *
  PyArray_DescrNewByteorder(PyArray_Descr *self, char newendian)


returns a copy of the PyArray_Descr structure with the byteorder
altered:
no arguments:  The byteorder is swapped (in all subfields as well)
single argument:  The byteorder is forced to the given state
(in all subfields as well)

Valid states:  ('big', '>') or ('little' or '<')
('native', or '=')

If a descr structure with | is encountered it's own
byte-order is not changed but any fields are:


Deep bytorder change of a data-type descriptor
Leaves reference count of self unchanged --- does not DECREF self ***

::

  PyObject *
  PyArray_IterAllButAxis(PyObject *obj, int *inaxis)

Get Iterator that iterates over all but one axis (don't use this with
PyArray_ITER_GOTO1D).  The axis will be over-written if negative
with the axis having the smallest stride.

::

  PyObject *
  PyArray_CheckFromAny(PyObject *op, PyArray_Descr *descr, int
                       min_depth, int max_depth, int requires, PyObject
                       *context)

steals a reference to descr -- accepts NULL

::

  PyObject *
  PyArray_FromArray(PyArrayObject *arr, PyArray_Descr *newtype, int
                    flags)

steals reference to newtype --- acc. NULL

::

  PyObject *
  PyArray_FromInterface(PyObject *origin)


::

  PyObject *
  PyArray_FromStructInterface(PyObject *input)


::

  PyObject *
  PyArray_FromArrayAttr(PyObject *op, PyArray_Descr *typecode, PyObject
                        *context)


::

  NPY_SCALARKIND
  PyArray_ScalarKind(int typenum, PyArrayObject **arr)

ScalarKind

Returns the scalar kind of a type number, with an
optional tweak based on the scalar value itself.
If no scalar is provided, it returns INTPOS_SCALAR
for both signed and unsigned integers, otherwise
it checks the sign of any signed integer to choose
INTNEG_SCALAR when appropriate.

::

  int
  PyArray_CanCoerceScalar(int thistype, int neededtype, NPY_SCALARKIND
                          scalar)


Determines whether the data type 'thistype', with
scalar kind 'scalar', can be coerced into 'neededtype'.

::

  PyObject *
  PyArray_NewFlagsObject(PyObject *obj)


Get New ArrayFlagsObject

::

  npy_bool
  PyArray_CanCastScalar(PyTypeObject *from, PyTypeObject *to)

See if array scalars can be cast.

TODO: For NumPy 2.0, add a NPY_CASTING parameter.

::

  int
  PyArray_CompareUCS4(npy_ucs4 *s1, npy_ucs4 *s2, size_t len)


::

  int
  PyArray_RemoveSmallest(PyArrayMultiIterObject *multi)

Adjusts previously broadcasted iterators so that the axis with
the smallest sum of iterator strides is not iterated over.
Returns dimension which is smallest in the range [0,multi->nd).
A -1 is returned if multi->nd == 0.

don't use with PyArray_ITER_GOTO1D because factors are not adjusted

::

  int
  PyArray_ElementStrides(PyObject *obj)


::

  void
  PyArray_Item_INCREF(char *data, PyArray_Descr *descr)


::

  void
  PyArray_Item_XDECREF(char *data, PyArray_Descr *descr)


::

  PyObject *
  PyArray_FieldNames(PyObject *fields)

Return the tuple of ordered field names from a dictionary.

::

  PyObject *
  PyArray_Transpose(PyArrayObject *ap, PyArray_Dims *permute)

Return Transpose.

::

  PyObject *
  PyArray_TakeFrom(PyArrayObject *self0, PyObject *indices0, int
                   axis, PyArrayObject *out, NPY_CLIPMODE clipmode)

Take

::

  PyObject *
  PyArray_PutTo(PyArrayObject *self, PyObject*values0, PyObject
                *indices0, NPY_CLIPMODE clipmode)

Put values into an array

::

  PyObject *
  PyArray_PutMask(PyArrayObject *self, PyObject*values0, PyObject*mask0)

Put values into an array according to a mask.

::

  PyObject *
  PyArray_Repeat(PyArrayObject *aop, PyObject *op, int axis)

Repeat the array.

::

  PyObject *
  PyArray_Choose(PyArrayObject *ip, PyObject *op, PyArrayObject
                 *out, NPY_CLIPMODE clipmode)


::

  int
  PyArray_Sort(PyArrayObject *op, int axis, NPY_SORTKIND which)

Sort an array in-place

::

  PyObject *
  PyArray_ArgSort(PyArrayObject *op, int axis, NPY_SORTKIND which)

ArgSort an array

::

  PyObject *
  PyArray_SearchSorted(PyArrayObject *op1, PyObject *op2, NPY_SEARCHSIDE
                       side, PyObject *perm)


Search the sorted array op1 for the location of the items in op2. The
result is an array of indexes, one for each element in op2, such that if
the item were to be inserted in op1 just before that index the array
would still be in sorted order.

Parameters
----------
op1 : PyArrayObject *
Array to be searched, must be 1-D.
op2 : PyObject *
Array of items whose insertion indexes in op1 are wanted
side : {NPY_SEARCHLEFT, NPY_SEARCHRIGHT}
If NPY_SEARCHLEFT, return first valid insertion indexes
If NPY_SEARCHRIGHT, return last valid insertion indexes
perm : PyObject *
Permutation array that sorts op1 (optional)

Returns
-------
ret : PyObject *
New reference to npy_intp array containing indexes where items in op2
could be validly inserted into op1. NULL on error.

Notes
-----
Binary search is used to find the indexes.

::

  PyObject *
  PyArray_ArgMax(PyArrayObject *op, int axis, PyArrayObject *out)

ArgMax

::

  PyObject *
  PyArray_ArgMin(PyArrayObject *op, int axis, PyArrayObject *out)

ArgMin

::

  PyObject *
  PyArray_Reshape(PyArrayObject *self, PyObject *shape)

Reshape

::

  PyObject *
  PyArray_Newshape(PyArrayObject *self, PyArray_Dims *newdims, NPY_ORDER
                   order)

New shape for an array

::

  PyObject *
  PyArray_Squeeze(PyArrayObject *self)


return a new view of the array object with all of its unit-length
dimensions squeezed out if needed, otherwise
return the same array.

::

  PyObject *
  PyArray_View(PyArrayObject *self, PyArray_Descr *type, PyTypeObject
               *pytype)

View
steals a reference to type -- accepts NULL

::

  PyObject *
  PyArray_SwapAxes(PyArrayObject *ap, int a1, int a2)

SwapAxes

::

  PyObject *
  PyArray_Max(PyArrayObject *ap, int axis, PyArrayObject *out)

Max

::

  PyObject *
  PyArray_Min(PyArrayObject *ap, int axis, PyArrayObject *out)

Min

::

  PyObject *
  PyArray_Ptp(PyArrayObject *ap, int axis, PyArrayObject *out)

Ptp

::

  PyObject *
  PyArray_Mean(PyArrayObject *self, int axis, int rtype, PyArrayObject
               *out)

Mean

::

  PyObject *
  PyArray_Trace(PyArrayObject *self, int offset, int axis1, int
                axis2, int rtype, PyArrayObject *out)

Trace

::

  PyObject *
  PyArray_Diagonal(PyArrayObject *self, int offset, int axis1, int
                   axis2)

Diagonal

In NumPy versions prior to 1.7,  this function always returned a copy of
the diagonal array. In 1.7, the code has been updated to compute a view
onto 'self', but it still copies this array before returning, as well as
setting the internal WARN_ON_WRITE flag. In a future version, it will
simply return a view onto self.

::

  PyObject *
  PyArray_Clip(PyArrayObject *self, PyObject *min, PyObject
               *max, PyArrayObject *out)

Clip

::

  PyObject *
  PyArray_Conjugate(PyArrayObject *self, PyArrayObject *out)

Conjugate

::

  PyObject *
  PyArray_Nonzero(PyArrayObject *self)

Nonzero

TODO: In NumPy 2.0, should make the iteration order a parameter.

::

  PyObject *
  PyArray_Std(PyArrayObject *self, int axis, int rtype, PyArrayObject
              *out, int variance)

Set variance to 1 to by-pass square-root calculation and return variance
Std

::

  PyObject *
  PyArray_Sum(PyArrayObject *self, int axis, int rtype, PyArrayObject
              *out)

Sum

::

  PyObject *
  PyArray_CumSum(PyArrayObject *self, int axis, int rtype, PyArrayObject
                 *out)

CumSum

::

  PyObject *
  PyArray_Prod(PyArrayObject *self, int axis, int rtype, PyArrayObject
               *out)

Prod

::

  PyObject *
  PyArray_CumProd(PyArrayObject *self, int axis, int
                  rtype, PyArrayObject *out)

CumProd

::

  PyObject *
  PyArray_All(PyArrayObject *self, int axis, PyArrayObject *out)

All

::

  PyObject *
  PyArray_Any(PyArrayObject *self, int axis, PyArrayObject *out)

Any

::

  PyObject *
  PyArray_Compress(PyArrayObject *self, PyObject *condition, int
                   axis, PyArrayObject *out)

Compress

::

  PyObject *
  PyArray_Flatten(PyArrayObject *a, NPY_ORDER order)

Flatten

::

  PyObject *
  PyArray_Ravel(PyArrayObject *arr, NPY_ORDER order)

Ravel
Returns a contiguous array

::

  npy_intp
  PyArray_MultiplyList(npy_intp *l1, int n)

Multiply a List

::

  int
  PyArray_MultiplyIntList(int *l1, int n)

Multiply a List of ints

::

  void *
  PyArray_GetPtr(PyArrayObject *obj, npy_intp*ind)

Produce a pointer into array

::

  int
  PyArray_CompareLists(npy_intp *l1, npy_intp *l2, int n)

Compare Lists

::

  int
  PyArray_AsCArray(PyObject **op, void *ptr, npy_intp *dims, int
                   nd, PyArray_Descr*typedescr)

Simulate a C-array
steals a reference to typedescr -- can be NULL

::

  int
  PyArray_As1D(PyObject **op, char **ptr, int *d1, int typecode)

Convert to a 1D C-array

::

  int
  PyArray_As2D(PyObject **op, char ***ptr, int *d1, int *d2, int
               typecode)

Convert to a 2D C-array

::

  int
  PyArray_Free(PyObject *op, void *ptr)

Free pointers created if As2D is called

::

  int
  PyArray_Converter(PyObject *object, PyObject **address)


Useful to pass as converter function for O& processing in PyArgs_ParseTuple.

This conversion function can be used with the "O&" argument for
PyArg_ParseTuple.  It will immediately return an object of array type
or will convert to a NPY_ARRAY_CARRAY any other object.

If you use PyArray_Converter, you must DECREF the array when finished
as you get a new reference to it.

::

  int
  PyArray_IntpFromSequence(PyObject *seq, npy_intp *vals, int maxvals)

PyArray_IntpFromSequence
Returns the number of integers converted or -1 if an error occurred.
vals must be large enough to hold maxvals

::

  PyObject *
  PyArray_Concatenate(PyObject *op, int axis)

Concatenate

Concatenate an arbitrary Python sequence into an array.
op is a python object supporting the sequence interface.
Its elements will be concatenated together to form a single
multidimensional array. If axis is NPY_MAXDIMS or bigger, then
each sequence object will be flattened before concatenation

::

  PyObject *
  PyArray_InnerProduct(PyObject *op1, PyObject *op2)

Numeric.innerproduct(a,v)

::

  PyObject *
  PyArray_MatrixProduct(PyObject *op1, PyObject *op2)

Numeric.matrixproduct(a,v)
just like inner product but does the swapaxes stuff on the fly

::

  PyObject *
  PyArray_CopyAndTranspose(PyObject *op)

Copy and Transpose

Could deprecate this function, as there isn't a speed benefit over
calling Transpose and then Copy.

::

  PyObject *
  PyArray_Correlate(PyObject *op1, PyObject *op2, int mode)

Numeric.correlate(a1,a2,mode)

::

  int
  PyArray_TypestrConvert(int itemsize, int gentype)

Typestr converter

::

  int
  PyArray_DescrConverter(PyObject *obj, PyArray_Descr **at)

Get typenum from an object -- None goes to NPY_DEFAULT_TYPE
This function takes a Python object representing a type and converts it
to a the correct PyArray_Descr * structure to describe the type.

Many objects can be used to represent a data-type which in NumPy is
quite a flexible concept.

This is the central code that converts Python objects to
Type-descriptor objects that are used throughout numpy.

Returns a new reference in *at, but the returned should not be
modified as it may be one of the canonical immutable objects or
a reference to the input obj.

::

  int
  PyArray_DescrConverter2(PyObject *obj, PyArray_Descr **at)

Get typenum from an object -- None goes to NULL

::

  int
  PyArray_IntpConverter(PyObject *obj, PyArray_Dims *seq)

Get intp chunk from sequence

This function takes a Python sequence object and allocates and
fills in an intp array with the converted values.

Remember to free the pointer seq.ptr when done using
PyDimMem_FREE(seq.ptr)**

::

  int
  PyArray_BufferConverter(PyObject *obj, PyArray_Chunk *buf)

Get buffer chunk from object

this function takes a Python object which exposes the (single-segment)
buffer interface and returns a pointer to the data segment

You should increment the reference count by one of buf->base
if you will hang on to a reference

You only get a borrowed reference to the object. Do not free the
memory...

::

  int
  PyArray_AxisConverter(PyObject *obj, int *axis)

Get axis from an object (possibly None) -- a converter function,

See also PyArray_ConvertMultiAxis, which also handles a tuple of axes.

::

  int
  PyArray_BoolConverter(PyObject *object, npy_bool *val)

Convert an object to true / false

::

  int
  PyArray_ByteorderConverter(PyObject *obj, char *endian)

Convert object to endian

::

  int
  PyArray_OrderConverter(PyObject *object, NPY_ORDER *val)

Convert an object to FORTRAN / C / ANY / KEEP

::

  unsigned char
  PyArray_EquivTypes(PyArray_Descr *type1, PyArray_Descr *type2)


This function returns true if the two typecodes are
equivalent (same basic kind and same itemsize).

::

  PyObject *
  PyArray_Zeros(int nd, npy_intp *dims, PyArray_Descr *type, int
                is_f_order)

Zeros

steals a reference to type. On failure or when dtype->subarray is
true, dtype will be decrefed.
accepts NULL type

::

  PyObject *
  PyArray_Empty(int nd, npy_intp *dims, PyArray_Descr *type, int
                is_f_order)

Empty

accepts NULL type
steals referenct to type

::

  PyObject *
  PyArray_Where(PyObject *condition, PyObject *x, PyObject *y)

Where

::

  PyObject *
  PyArray_Arange(double start, double stop, double step, int type_num)

Arange,

::

  PyObject *
  PyArray_ArangeObj(PyObject *start, PyObject *stop, PyObject
                    *step, PyArray_Descr *dtype)


ArangeObj,

this doesn't change the references

::

  int
  PyArray_SortkindConverter(PyObject *obj, NPY_SORTKIND *sortkind)

Convert object to sort kind

::

  PyObject *
  PyArray_LexSort(PyObject *sort_keys, int axis)

LexSort an array providing indices that will sort a collection of arrays
lexicographically.  The first key is sorted on first, followed by the second key
-- requires that arg"merge"sort is available for each sort_key

Returns an index array that shows the indexes for the lexicographic sort along
the given axis.

::

  PyObject *
  PyArray_Round(PyArrayObject *a, int decimals, PyArrayObject *out)

Round

::

  unsigned char
  PyArray_EquivTypenums(int typenum1, int typenum2)


::

  int
  PyArray_RegisterDataType(PyArray_Descr *descr)

Register Data type
Does not change the reference count of descr

::

  int
  PyArray_RegisterCastFunc(PyArray_Descr *descr, int
                           totype, PyArray_VectorUnaryFunc *castfunc)

Register Casting Function
Replaces any function currently stored.

::

  int
  PyArray_RegisterCanCast(PyArray_Descr *descr, int
                          totype, NPY_SCALARKIND scalar)

Register a type number indicating that a descriptor can be cast
to it safely

::

  void
  PyArray_InitArrFuncs(PyArray_ArrFuncs *f)

Initialize arrfuncs to NULL

::

  PyObject *
  PyArray_IntTupleFromIntp(int len, npy_intp *vals)

PyArray_IntTupleFromIntp

::

  int
  PyArray_TypeNumFromName(char *str)


::

  int
  PyArray_ClipmodeConverter(PyObject *object, NPY_CLIPMODE *val)

Convert an object to NPY_RAISE / NPY_CLIP / NPY_WRAP

::

  int
  PyArray_OutputConverter(PyObject *object, PyArrayObject **address)

Useful to pass as converter function for O& processing in
PyArgs_ParseTuple for output arrays

::

  PyObject *
  PyArray_BroadcastToShape(PyObject *obj, npy_intp *dims, int nd)

Get Iterator broadcast to a particular shape

::

  void
  _PyArray_SigintHandler(int signum)


::

  void*
  _PyArray_GetSigintBuf(void )


::

  int
  PyArray_DescrAlignConverter(PyObject *obj, PyArray_Descr **at)


Get type-descriptor from an object forcing alignment if possible
None goes to DEFAULT type.

any object with the .fields attribute and/or .itemsize attribute (if the
.fields attribute does not give the total size -- i.e. a partial record
naming).  If itemsize is given it must be >= size computed from fields

The .fields attribute must return a convertible dictionary if present.
Result inherits from NPY_VOID.

::

  int
  PyArray_DescrAlignConverter2(PyObject *obj, PyArray_Descr **at)


Get type-descriptor from an object forcing alignment if possible
None goes to NULL.

::

  int
  PyArray_SearchsideConverter(PyObject *obj, void *addr)

Convert object to searchsorted side

::

  PyObject *
  PyArray_CheckAxis(PyArrayObject *arr, int *axis, int flags)

PyArray_CheckAxis

check that axis is valid
convert 0-d arrays to 1-d arrays

::

  npy_intp
  PyArray_OverflowMultiplyList(npy_intp *l1, int n)

Multiply a List of Non-negative numbers with over-flow detection.

::

  int
  PyArray_CompareString(char *s1, char *s2, size_t len)


::

  PyObject *
  PyArray_MultiIterFromObjects(PyObject **mps, int n, int nadd, ... )

Get MultiIterator from array of Python objects and any additional

PyObject **mps -- array of PyObjects
int n - number of PyObjects in the array
int nadd - number of additional arrays to include in the iterator.

Returns a multi-iterator object.

::

  int
  PyArray_GetEndianness(void )


::

  unsigned int
  PyArray_GetNDArrayCFeatureVersion(void )

Returns the built-in (at compilation time) C API version

::

  PyObject *
  PyArray_Correlate2(PyObject *op1, PyObject *op2, int mode)

correlate(a1,a2,mode)

This function computes the usual correlation (correlate(a1, a2) !=
correlate(a2, a1), and conjugate the second argument for complex inputs

::

  PyObject*
  PyArray_NeighborhoodIterNew(PyArrayIterObject *x, npy_intp
                              *bounds, int mode, PyArrayObject*fill)

A Neighborhood Iterator object.

::

  void
  PyArray_SetDatetimeParseFunction(PyObject *op)

This function is scheduled to be removed

TO BE REMOVED - NOT USED INTERNALLY.

::

  void
  PyArray_DatetimeToDatetimeStruct(npy_datetime val, NPY_DATETIMEUNIT
                                   fr, npy_datetimestruct *result)

Fill the datetime struct from the value and resolution unit.

TO BE REMOVED - NOT USED INTERNALLY.

::

  void
  PyArray_TimedeltaToTimedeltaStruct(npy_timedelta val, NPY_DATETIMEUNIT
                                     fr, npy_timedeltastruct *result)

Fill the timedelta struct from the timedelta value and resolution unit.

TO BE REMOVED - NOT USED INTERNALLY.

::

  npy_datetime
  PyArray_DatetimeStructToDatetime(NPY_DATETIMEUNIT
                                   fr, npy_datetimestruct *d)

Create a datetime value from a filled datetime struct and resolution unit.

TO BE REMOVED - NOT USED INTERNALLY.

::

  npy_datetime
  PyArray_TimedeltaStructToTimedelta(NPY_DATETIMEUNIT
                                     fr, npy_timedeltastruct *d)

Create a timdelta value from a filled timedelta struct and resolution unit.

TO BE REMOVED - NOT USED INTERNALLY.

::

  NpyIter *
  NpyIter_New(PyArrayObject *op, npy_uint32 flags, NPY_ORDER
              order, NPY_CASTING casting, PyArray_Descr*dtype)

Allocate a new iterator for one array object.

::

  NpyIter *
  NpyIter_MultiNew(int nop, PyArrayObject **op_in, npy_uint32
                   flags, NPY_ORDER order, NPY_CASTING
                   casting, npy_uint32 *op_flags, PyArray_Descr
                   **op_request_dtypes)

Allocate a new iterator for more than one array object, using
standard NumPy broadcasting rules and the default buffer size.

::

  NpyIter *
  NpyIter_AdvancedNew(int nop, PyArrayObject **op_in, npy_uint32
                      flags, NPY_ORDER order, NPY_CASTING
                      casting, npy_uint32 *op_flags, PyArray_Descr
                      **op_request_dtypes, int oa_ndim, int
                      **op_axes, npy_intp *itershape, npy_intp
                      buffersize)

Allocate a new iterator for multiple array objects, and advanced
options for controlling the broadcasting, shape, and buffer size.

::

  NpyIter *
  NpyIter_Copy(NpyIter *iter)

Makes a copy of the iterator

::

  int
  NpyIter_Deallocate(NpyIter *iter)

Deallocate an iterator

::

  npy_bool
  NpyIter_HasDelayedBufAlloc(NpyIter *iter)

Whether the buffer allocation is being delayed

::

  npy_bool
  NpyIter_HasExternalLoop(NpyIter *iter)

Whether the iterator handles the inner loop

::

  int
  NpyIter_EnableExternalLoop(NpyIter *iter)

Removes the inner loop handling (so HasExternalLoop returns true)

::

  npy_intp *
  NpyIter_GetInnerStrideArray(NpyIter *iter)

Get the array of strides for the inner loop (when HasExternalLoop is true)

This function may be safely called without holding the Python GIL.

::

  npy_intp *
  NpyIter_GetInnerLoopSizePtr(NpyIter *iter)

Get a pointer to the size of the inner loop  (when HasExternalLoop is true)

This function may be safely called without holding the Python GIL.

::

  int
  NpyIter_Reset(NpyIter *iter, char **errmsg)

Resets the iterator to its initial state

If errmsg is non-NULL, it should point to a variable which will
receive the error message, and no Python exception will be set.
This is so that the function can be called from code not holding
the GIL.

::

  int
  NpyIter_ResetBasePointers(NpyIter *iter, char **baseptrs, char
                            **errmsg)

Resets the iterator to its initial state, with new base data pointers.
This function requires great caution.

If errmsg is non-NULL, it should point to a variable which will
receive the error message, and no Python exception will be set.
This is so that the function can be called from code not holding
the GIL.

::

  int
  NpyIter_ResetToIterIndexRange(NpyIter *iter, npy_intp istart, npy_intp
                                iend, char **errmsg)

Resets the iterator to a new iterator index range

If errmsg is non-NULL, it should point to a variable which will
receive the error message, and no Python exception will be set.
This is so that the function can be called from code not holding
the GIL.

::

  int
  NpyIter_GetNDim(NpyIter *iter)

Gets the number of dimensions being iterated

::

  int
  NpyIter_GetNOp(NpyIter *iter)

Gets the number of operands being iterated

::

  NpyIter_IterNextFunc *
  NpyIter_GetIterNext(NpyIter *iter, char **errmsg)

Compute the specialized iteration function for an iterator

If errmsg is non-NULL, it should point to a variable which will
receive the error message, and no Python exception will be set.
This is so that the function can be called from code not holding
the GIL.

::

  npy_intp
  NpyIter_GetIterSize(NpyIter *iter)

Gets the number of elements being iterated

::

  void
  NpyIter_GetIterIndexRange(NpyIter *iter, npy_intp *istart, npy_intp
                            *iend)

Gets the range of iteration indices being iterated

::

  npy_intp
  NpyIter_GetIterIndex(NpyIter *iter)

Gets the current iteration index

::

  int
  NpyIter_GotoIterIndex(NpyIter *iter, npy_intp iterindex)

Sets the iterator position to the specified iterindex,
which matches the iteration order of the iterator.

Returns NPY_SUCCEED on success, NPY_FAIL on failure.

::

  npy_bool
  NpyIter_HasMultiIndex(NpyIter *iter)

Whether the iterator is tracking a multi-index

::

  int
  NpyIter_GetShape(NpyIter *iter, npy_intp *outshape)

Gets the broadcast shape if a multi-index is being tracked by the iterator,
otherwise gets the shape of the iteration as Fortran-order
(fastest-changing index first).

The reason Fortran-order is returned when a multi-index
is not enabled is that this is providing a direct view into how
the iterator traverses the n-dimensional space. The iterator organizes
its memory from fastest index to slowest index, and when
a multi-index is enabled, it uses a permutation to recover the original
order.

Returns NPY_SUCCEED or NPY_FAIL.

::

  NpyIter_GetMultiIndexFunc *
  NpyIter_GetGetMultiIndex(NpyIter *iter, char **errmsg)

Compute a specialized get_multi_index function for the iterator

If errmsg is non-NULL, it should point to a variable which will
receive the error message, and no Python exception will be set.
This is so that the function can be called from code not holding
the GIL.

::

  int
  NpyIter_GotoMultiIndex(NpyIter *iter, npy_intp *multi_index)

Sets the iterator to the specified multi-index, which must have the
correct number of entries for 'ndim'.  It is only valid
when NPY_ITER_MULTI_INDEX was passed to the constructor.  This operation
fails if the multi-index is out of bounds.

Returns NPY_SUCCEED on success, NPY_FAIL on failure.

::

  int
  NpyIter_RemoveMultiIndex(NpyIter *iter)

Removes multi-index support from an iterator.

Returns NPY_SUCCEED or NPY_FAIL.

::

  npy_bool
  NpyIter_HasIndex(NpyIter *iter)

Whether the iterator is tracking an index

::

  npy_bool
  NpyIter_IsBuffered(NpyIter *iter)

Whether the iterator is buffered

::

  npy_bool
  NpyIter_IsGrowInner(NpyIter *iter)

Whether the inner loop can grow if buffering is unneeded

::

  npy_intp
  NpyIter_GetBufferSize(NpyIter *iter)

Gets the size of the buffer, or 0 if buffering is not enabled

::

  npy_intp *
  NpyIter_GetIndexPtr(NpyIter *iter)

Get a pointer to the index, if it is being tracked

::

  int
  NpyIter_GotoIndex(NpyIter *iter, npy_intp flat_index)

If the iterator is tracking an index, sets the iterator
to the specified index.

Returns NPY_SUCCEED on success, NPY_FAIL on failure.

::

  char **
  NpyIter_GetDataPtrArray(NpyIter *iter)

Get the array of data pointers (1 per object being iterated)

This function may be safely called without holding the Python GIL.

::

  PyArray_Descr **
  NpyIter_GetDescrArray(NpyIter *iter)

Get the array of data type pointers (1 per object being iterated)

::

  PyArrayObject **
  NpyIter_GetOperandArray(NpyIter *iter)

Get the array of objects being iterated

::

  PyArrayObject *
  NpyIter_GetIterView(NpyIter *iter, npy_intp i)

Returns a view to the i-th object with the iterator's internal axes

::

  void
  NpyIter_GetReadFlags(NpyIter *iter, char *outreadflags)

Gets an array of read flags (1 per object being iterated)

::

  void
  NpyIter_GetWriteFlags(NpyIter *iter, char *outwriteflags)

Gets an array of write flags (1 per object being iterated)

::

  void
  NpyIter_DebugPrint(NpyIter *iter)

For debugging

::

  npy_bool
  NpyIter_IterationNeedsAPI(NpyIter *iter)

Whether the iteration loop, and in particular the iternext()
function, needs API access.  If this is true, the GIL must
be retained while iterating.

::

  void
  NpyIter_GetInnerFixedStrideArray(NpyIter *iter, npy_intp *out_strides)

Get an array of strides which are fixed.  Any strides which may
change during iteration receive the value NPY_MAX_INTP.  Once
the iterator is ready to iterate, call this to get the strides
which will always be fixed in the inner loop, then choose optimized
inner loop functions which take advantage of those fixed strides.

This function may be safely called without holding the Python GIL.

::

  int
  NpyIter_RemoveAxis(NpyIter *iter, int axis)

Removes an axis from iteration. This requires that NPY_ITER_MULTI_INDEX
was set for iterator creation, and does not work if buffering is
enabled. This function also resets the iterator to its initial state.

Returns NPY_SUCCEED or NPY_FAIL.

::

  npy_intp *
  NpyIter_GetAxisStrideArray(NpyIter *iter, int axis)

Gets the array of strides for the specified axis.
If the iterator is tracking a multi-index, gets the strides
for the axis specified, otherwise gets the strides for
the iteration axis as Fortran order (fastest-changing axis first).

Returns NULL if an error occurs.

::

  npy_bool
  NpyIter_RequiresBuffering(NpyIter *iter)

Whether the iteration could be done with no buffering.

::

  char **
  NpyIter_GetInitialDataPtrArray(NpyIter *iter)

Get the array of data pointers (1 per object being iterated),
directly into the arrays (never pointing to a buffer), for starting
unbuffered iteration. This always returns the addresses for the
iterator position as reset to iterator index 0.

These pointers are different from the pointers accepted by
NpyIter_ResetBasePointers, because the direction along some
axes may have been reversed, requiring base offsets.

This function may be safely called without holding the Python GIL.

::

  int
  NpyIter_CreateCompatibleStrides(NpyIter *iter, npy_intp
                                  itemsize, npy_intp *outstrides)

Builds a set of strides which are the same as the strides of an
output array created using the NPY_ITER_ALLOCATE flag, where NULL
was passed for op_axes.  This is for data packed contiguously,
but not necessarily in C or Fortran order. This should be used
together with NpyIter_GetShape and NpyIter_GetNDim.

A use case for this function is to match the shape and layout of
the iterator and tack on one or more dimensions.  For example,
in order to generate a vector per input value for a numerical gradient,
you pass in ndim*itemsize for itemsize, then add another dimension to
the end with size ndim and stride itemsize.  To do the Hessian matrix,
you do the same thing but add two dimensions, or take advantage of
the symmetry and pack it into 1 dimension with a particular encoding.

This function may only be called if the iterator is tracking a multi-index
and if NPY_ITER_DONT_NEGATE_STRIDES was used to prevent an axis from
being iterated in reverse order.

If an array is created with this method, simply adding 'itemsize'
for each iteration will traverse the new array matching the
iterator.

Returns NPY_SUCCEED or NPY_FAIL.

::

  int
  PyArray_CastingConverter(PyObject *obj, NPY_CASTING *casting)

Convert any Python object, *obj*, to an NPY_CASTING enum.

::

  npy_intp
  PyArray_CountNonzero(PyArrayObject *self)

Counts the number of non-zero elements in the array.

Returns -1 on error.

::

  PyArray_Descr *
  PyArray_PromoteTypes(PyArray_Descr *type1, PyArray_Descr *type2)

Produces the smallest size and lowest kind type to which both
input types can be cast.

::

  PyArray_Descr *
  PyArray_MinScalarType(PyArrayObject *arr)

If arr is a scalar (has 0 dimensions) with a built-in number data type,
finds the smallest type size/kind which can still represent its data.
Otherwise, returns the array's data type.


::

  PyArray_Descr *
  PyArray_ResultType(npy_intp narrs, PyArrayObject **arr, npy_intp
                     ndtypes, PyArray_Descr **dtypes)

Produces the result type of a bunch of inputs, using the UFunc
type promotion rules. Use this function when you have a set of
input arrays, and need to determine an output array dtype.

If all the inputs are scalars (have 0 dimensions) or the maximum "kind"
of the scalars is greater than the maximum "kind" of the arrays, does
a regular type promotion.

Otherwise, does a type promotion on the MinScalarType
of all the inputs.  Data types passed directly are treated as array
types.


::

  npy_bool
  PyArray_CanCastArrayTo(PyArrayObject *arr, PyArray_Descr
                         *to, NPY_CASTING casting)

Returns 1 if the array object may be cast to the given data type using
the casting rule, 0 otherwise.  This differs from PyArray_CanCastTo in
that it handles scalar arrays (0 dimensions) specially, by checking
their value.

::

  npy_bool
  PyArray_CanCastTypeTo(PyArray_Descr *from, PyArray_Descr
                        *to, NPY_CASTING casting)

Returns true if data of type 'from' may be cast to data of type
'to' according to the rule 'casting'.

::

  PyArrayObject *
  PyArray_EinsteinSum(char *subscripts, npy_intp nop, PyArrayObject
                      **op_in, PyArray_Descr *dtype, NPY_ORDER
                      order, NPY_CASTING casting, PyArrayObject *out)

This function provides summation of array elements according to
the Einstein summation convention.  For example:
- trace(a)        -> einsum("ii", a)
- transpose(a)    -> einsum("ji", a)
- multiply(a,b)   -> einsum(",", a, b)
- inner(a,b)      -> einsum("i,i", a, b)
- outer(a,b)      -> einsum("i,j", a, b)
- matvec(a,b)     -> einsum("ij,j", a, b)
- matmat(a,b)     -> einsum("ij,jk", a, b)

subscripts: The string of subscripts for einstein summation.
nop:        The number of operands
op_in:      The array of operands
dtype:      Either NULL, or the data type to force the calculation as.
order:      The order for the calculation/the output axes.
casting:    What kind of casts should be permitted.
out:        Either NULL, or an array into which the output should be placed.

By default, the labels get placed in alphabetical order
at the end of the output. So, if c = einsum("i,j", a, b)
then c[i,j] == a[i]*b[j], but if c = einsum("j,i", a, b)
then c[i,j] = a[j]*b[i].

Alternatively, you can control the output order or prevent
an axis from being summed/force an axis to be summed by providing
indices for the output. This allows us to turn 'trace' into
'diag', for example.
- diag(a)         -> einsum("ii->i", a)
- sum(a, axis=0)  -> einsum("i...->", a)

Subscripts at the beginning and end may be specified by
putting an ellipsis "..." in the middle.  For example,
the function einsum("i...i", a) takes the diagonal of
the first and last dimensions of the operand, and
einsum("ij...,jk...->ik...") takes the matrix product using
the first two indices of each operand instead of the last two.

When there is only one operand, no axes being summed, and
no output parameter, this function returns a view
into the operand instead of making a copy.

::

  PyObject *
  PyArray_NewLikeArray(PyArrayObject *prototype, NPY_ORDER
                       order, PyArray_Descr *dtype, int subok)

Creates a new array with the same shape as the provided one,
with possible memory layout order and data type changes.

prototype - The array the new one should be like.
order     - NPY_CORDER - C-contiguous result.
NPY_FORTRANORDER - Fortran-contiguous result.
NPY_ANYORDER - Fortran if prototype is Fortran, C otherwise.
NPY_KEEPORDER - Keeps the axis ordering of prototype.
dtype     - If not NULL, overrides the data type of the result.
subok     - If 1, use the prototype's array subtype, otherwise
always create a base-class array.

NOTE: If dtype is not NULL, steals the dtype reference.  On failure or when
dtype->subarray is true, dtype will be decrefed.

::

  int
  PyArray_GetArrayParamsFromObject(PyObject *op, PyArray_Descr
                                   *requested_dtype, npy_bool
                                   writeable, PyArray_Descr
                                   **out_dtype, int *out_ndim, npy_intp
                                   *out_dims, PyArrayObject
                                   **out_arr, PyObject *context)

Retrieves the array parameters for viewing/converting an arbitrary
PyObject* to a NumPy array. This allows the "innate type and shape"
of Python list-of-lists to be discovered without
actually converting to an array.

In some cases, such as structured arrays and the __array__ interface,
a data type needs to be used to make sense of the object.  When
this is needed, provide a Descr for 'requested_dtype', otherwise
provide NULL. This reference is not stolen. Also, if the requested
dtype doesn't modify the interpretation of the input, out_dtype will
still get the "innate" dtype of the object, not the dtype passed
in 'requested_dtype'.

If writing to the value in 'op' is desired, set the boolean
'writeable' to 1.  This raises an error when 'op' is a scalar, list
of lists, or other non-writeable 'op'.

Result: When success (0 return value) is returned, either out_arr
is filled with a non-NULL PyArrayObject and
the rest of the parameters are untouched, or out_arr is
filled with NULL, and the rest of the parameters are
filled.

Typical usage:

PyArrayObject *arr = NULL;
PyArray_Descr *dtype = NULL;
int ndim = 0;
npy_intp dims[NPY_MAXDIMS];

if (PyArray_GetArrayParamsFromObject(op, NULL, 1, &dtype,
&ndim, dims, &arr, NULL) < 0) {
return NULL;
}
if (arr == NULL) {
... validate/change dtype, validate flags, ndim, etc ...
// Could make custom strides here too
arr = PyArray_NewFromDescr(&PyArray_Type, dtype, ndim,
dims, NULL,
is_f_order ? NPY_ARRAY_F_CONTIGUOUS : 0,
NULL);
if (arr == NULL) {
return NULL;
}
if (PyArray_CopyObject(arr, op) < 0) {
Py_DECREF(arr);
return NULL;
}
}
else {
... in this case the other parameters weren't filled, just
validate and possibly copy arr itself ...
}
... use arr ...

::

  int
  PyArray_ConvertClipmodeSequence(PyObject *object, NPY_CLIPMODE
                                  *modes, int n)

Convert an object to an array of n NPY_CLIPMODE values.
This is intended to be used in functions where a different mode
could be applied to each axis, like in ravel_multi_index.

::

  PyObject *
  PyArray_MatrixProduct2(PyObject *op1, PyObject
                         *op2, PyArrayObject*out)

Numeric.matrixproduct2(a,v,out)
just like inner product but does the swapaxes stuff on the fly

::

  npy_bool
  NpyIter_IsFirstVisit(NpyIter *iter, int iop)

Checks to see whether this is the first time the elements
of the specified reduction operand which the iterator points at are
being seen for the first time. The function returns
a reasonable answer for reduction operands and when buffering is
disabled. The answer may be incorrect for buffered non-reduction
operands.

This function is intended to be used in EXTERNAL_LOOP mode only,
and will produce some wrong answers when that mode is not enabled.

If this function returns true, the caller should also
check the inner loop stride of the operand, because if
that stride is 0, then only the first element of the innermost
external loop is being visited for the first time.

WARNING: For performance reasons, 'iop' is not bounds-checked,
it is not confirmed that 'iop' is actually a reduction
operand, and it is not confirmed that EXTERNAL_LOOP
mode is enabled. These checks are the responsibility of
the caller, and should be done outside of any inner loops.

::

  int
  PyArray_SetBaseObject(PyArrayObject *arr, PyObject *obj)

Sets the 'base' attribute of the array. This steals a reference
to 'obj'.

Returns 0 on success, -1 on failure.

::

  void
  PyArray_CreateSortedStridePerm(int ndim, npy_intp
                                 *strides, npy_stride_sort_item
                                 *out_strideperm)


This function populates the first ndim elements
of strideperm with sorted descending by their absolute values.
For example, the stride array (4, -2, 12) becomes
[(2, 12), (0, 4), (1, -2)].

::

  void
  PyArray_RemoveAxesInPlace(PyArrayObject *arr, npy_bool *flags)


Removes the axes flagged as True from the array,
modifying it in place. If an axis flagged for removal
has a shape entry bigger than one, this effectively selects
index zero for that axis.

WARNING: If an axis flagged for removal has a shape equal to zero,
the array will point to invalid memory. The caller must
validate this!
If an axis flagged for removal has a shape larger then one,
the aligned flag (and in the future the contiguous flags),
may need explicit update.
(check also NPY_RELAXED_STRIDES_CHECKING)

For example, this can be used to remove the reduction axes
from a reduction result once its computation is complete.

::

  void
  PyArray_DebugPrint(PyArrayObject *obj)

Prints the raw data of the ndarray in a form useful for debugging
low-level C issues.

::

  int
  PyArray_FailUnlessWriteable(PyArrayObject *obj, const char *name)


This function does nothing if obj is writeable, and raises an exception
(and returns -1) if obj is not writeable. It may also do other
house-keeping, such as issuing warnings on arrays which are transitioning
to become views. Always call this function at some point before writing to
an array.

'name' is a name for the array, used to give better error
messages. Something like "assignment destination", "output array", or even
just "array".

::

  int
  PyArray_SetUpdateIfCopyBase(PyArrayObject *arr, PyArrayObject *base)


Precondition: 'arr' is a copy of 'base' (though possibly with different
strides, ordering, etc.). This function sets the UPDATEIFCOPY flag and the
->base pointer on 'arr', so that when 'arr' is destructed, it will copy any
changes back to 'base'.

Steals a reference to 'base'.

Returns 0 on success, -1 on failure.

::

  void *
  PyDataMem_NEW(size_t size)

Allocates memory for array data.

::

  void
  PyDataMem_FREE(void *ptr)

Free memory for array data.

::

  void *
  PyDataMem_RENEW(void *ptr, size_t size)

Reallocate/resize memory for array data.

::

  PyDataMem_EventHookFunc *
  PyDataMem_SetEventHook(PyDataMem_EventHookFunc *newhook, void
                         *user_data, void **old_data)

Sets the allocation event hook for numpy array data.
Takes a PyDataMem_EventHookFunc *, which has the signature:
void hook(void *old, void *new, size_t size, void *user_data).
Also takes a void *user_data, and void **old_data.

Returns a pointer to the previous hook or NULL.  If old_data is
non-NULL, the previous user_data pointer will be copied to it.

If not NULL, hook will be called at the end of each PyDataMem_NEW/FREE/RENEW:
result = PyDataMem_NEW(size)        -> (*hook)(NULL, result, size, user_data)
PyDataMem_FREE(ptr)                 -> (*hook)(ptr, NULL, 0, user_data)
result = PyDataMem_RENEW(ptr, size) -> (*hook)(ptr, result, size, user_data)

When the hook is called, the GIL will be held by the calling
thread.  The hook should be written to be reentrant, if it performs
operations that might cause new allocation events (such as the
creation/destruction numpy objects, or creating/destroying Python
objects which might cause a gc)

::

  void
  PyArray_MapIterSwapAxes(PyArrayMapIterObject *mit, PyArrayObject
                          **ret, int getmap)


::

  PyObject *
  PyArray_MapIterArray(PyArrayObject *a, PyObject *index)


Use advanced indexing to iterate an array. Please note
that most of this public API is currently not guaranteed
to stay the same between versions. If you plan on using
it, please consider adding more utility functions here
to accommodate new features.

::

  void
  PyArray_MapIterNext(PyArrayMapIterObject *mit)

This function needs to update the state of the map iterator
and point mit->dataptr to the memory-location of the next object

Note that this function never handles an extra operand but provides
compatibility for an old (exposed) API.

::

  int
  PyArray_Partition(PyArrayObject *op, PyArrayObject *ktharray, int
                    axis, NPY_SELECTKIND which)

Partition an array in-place

::

  PyObject *
  PyArray_ArgPartition(PyArrayObject *op, PyArrayObject *ktharray, int
                       axis, NPY_SELECTKIND which)

ArgPartition an array

::

  int
  PyArray_SelectkindConverter(PyObject *obj, NPY_SELECTKIND *selectkind)

Convert object to select kind

::

  void *
  PyDataMem_NEW_ZEROED(size_t size, size_t elsize)

Allocates zeroed memory for array data.

::

  int
  PyArray_CheckAnyScalarExact(PyObject *obj)

return true an object is exactly a numpy scalar