inoryQwQ commited on
Commit
90f0b29
·
1 Parent(s): 3399058

Shorten kv cache

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitignore +4 -0
  2. axmodel/decoder_loop.axmodel +2 -2
  3. axmodel/decoder_loop_u8.axmodel +3 -0
  4. axmodel/decoder_main.axmodel +2 -2
  5. axmodel/decoder_main_u8.axmodel +3 -0
  6. cpp/CMakeLists.txt +35 -0
  7. cpp/build.sh +8 -0
  8. cpp/cmake/msp_dependencies.cmake +24 -0
  9. cpp/download_bsp.sh +7 -0
  10. cpp/install/fireredasr +0 -0
  11. cpp/main.cpp +141 -0
  12. cpp/src/AudioFile.h +1293 -0
  13. cpp/src/DecoderLoop.hpp +39 -0
  14. cpp/src/DecoderMain.hpp +19 -0
  15. cpp/src/Encoder.hpp +20 -0
  16. cpp/src/EngineWrapper.cpp +351 -0
  17. cpp/src/EngineWrapper.hpp +53 -0
  18. cpp/src/base64.cpp +120 -0
  19. cpp/src/base64.h +11 -0
  20. cpp/src/cmdline.hpp +732 -0
  21. cpp/src/librosa/eigen3/.hgeol +11 -0
  22. cpp/src/librosa/eigen3/.hgignore +34 -0
  23. cpp/src/librosa/eigen3/CMakeLists.txt +616 -0
  24. cpp/src/librosa/eigen3/COPYING.BSD +26 -0
  25. cpp/src/librosa/eigen3/COPYING.GPL +674 -0
  26. cpp/src/librosa/eigen3/COPYING.LGPL +502 -0
  27. cpp/src/librosa/eigen3/COPYING.MINPACK +52 -0
  28. cpp/src/librosa/eigen3/COPYING.MPL2 +373 -0
  29. cpp/src/librosa/eigen3/COPYING.README +18 -0
  30. cpp/src/librosa/eigen3/CTestConfig.cmake +13 -0
  31. cpp/src/librosa/eigen3/CTestCustom.cmake.in +4 -0
  32. cpp/src/librosa/eigen3/Eigen/CMakeLists.txt +19 -0
  33. cpp/src/librosa/eigen3/Eigen/Cholesky +46 -0
  34. cpp/src/librosa/eigen3/Eigen/CholmodSupport +48 -0
  35. cpp/src/librosa/eigen3/Eigen/Core +537 -0
  36. cpp/src/librosa/eigen3/Eigen/Dense +7 -0
  37. cpp/src/librosa/eigen3/Eigen/Eigen +2 -0
  38. cpp/src/librosa/eigen3/Eigen/Eigenvalues +61 -0
  39. cpp/src/librosa/eigen3/Eigen/Geometry +62 -0
  40. cpp/src/librosa/eigen3/Eigen/Householder +30 -0
  41. cpp/src/librosa/eigen3/Eigen/IterativeLinearSolvers +48 -0
  42. cpp/src/librosa/eigen3/Eigen/Jacobi +33 -0
  43. cpp/src/librosa/eigen3/Eigen/LU +50 -0
  44. cpp/src/librosa/eigen3/Eigen/MetisSupport +35 -0
  45. cpp/src/librosa/eigen3/Eigen/OrderingMethods +73 -0
  46. cpp/src/librosa/eigen3/Eigen/PaStiXSupport +48 -0
  47. cpp/src/librosa/eigen3/Eigen/PardisoSupport +35 -0
  48. cpp/src/librosa/eigen3/Eigen/QR +51 -0
  49. cpp/src/librosa/eigen3/Eigen/QtAlignedMalloc +40 -0
  50. cpp/src/librosa/eigen3/Eigen/SPQRSupport +34 -0
.gitignore ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ .vscode
2
+ __pycache__
3
+ cpp/build
4
+ cpp/ax650n_bsp_sdk
axmodel/decoder_loop.axmodel CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:c34f5617f86ad6759bcef16df3b8c2be74660e33b05f1447c52d6c6cf3dcc1e1
3
- size 447207512
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6b109e1281135a673b613c1fd92f5d12d64e02d1f3da47561c142bbc57295d5d
3
+ size 446759232
axmodel/decoder_loop_u8.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c34f5617f86ad6759bcef16df3b8c2be74660e33b05f1447c52d6c6cf3dcc1e1
3
+ size 447207512
axmodel/decoder_main.axmodel CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:ebf1de8db552335580fba7e83d2d89e9479518a99bdc7728b04b6975b3eb2b88
3
- size 511355470
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dc95af79976bd25aa2b13fe62d99ff5e9b03a3d9ce1ea26bfc8b7c7502a4b9b0
3
+ size 506408654
axmodel/decoder_main_u8.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ebf1de8db552335580fba7e83d2d89e9479518a99bdc7728b04b6975b3eb2b88
3
+ size 511355470
cpp/CMakeLists.txt ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
2
+ project(fireredasr)
3
+
4
+ set(CMAKE_CXX_STANDARD 17)
5
+
6
+ if (CMAKE_BUILD_TYPE MATCHES Debug)
7
+ set(CMAKE_CXX_FLAGS "-fvisibility=hidden -g -O0")
8
+ add_definitions(-D__AX_SKEL_DEBUG__)
9
+ elseif (CMAKE_BUILD_TYPE MATCHES Release)
10
+ set(CMAKE_CXX_FLAGS "-fvisibility=hidden -O2")
11
+ endif()
12
+
13
+ include(cmake/msp_dependencies.cmake)
14
+ add_definitions(-DENV_HAS_STD_FILESYSTEM)
15
+ add_definitions(-DENV_HAS_POSIX_FILE_STAT)
16
+
17
+ # OpenCC for 简繁转换
18
+ # include_directories(opencc/include/opencc)
19
+ # link_directories(opencc/lib)
20
+
21
+ include_directories(${MSP_INC_DIR})
22
+ link_directories(${MSP_LIB_DIR})
23
+
24
+ include_directories(src)
25
+ aux_source_directory(src SRC)
26
+ add_executable(fireredasr main.cpp ${SRC})
27
+ target_link_libraries(fireredasr ${MSP_LIBS})
28
+
29
+ # file(COPY ${CMAKE_SOURCE_DIR}/opencc/share/opencc/t2s.json DESTINATION ${CMAKE_INSTALL_PREFIX})
30
+ # file(COPY ${CMAKE_SOURCE_DIR}/opencc/share/opencc/TSPhrases.ocd2 DESTINATION ${CMAKE_INSTALL_PREFIX})
31
+ # file(COPY ${CMAKE_SOURCE_DIR}/opencc/share/opencc/TSCharacters.ocd2 DESTINATION ${CMAKE_INSTALL_PREFIX})
32
+
33
+ install(TARGETS fireredasr
34
+ RUNTIME
35
+ DESTINATION .)
cpp/build.sh ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ mkdir -p build && cd build
2
+ cmake .. \
3
+ -DCHIP_AX650=ON \
4
+ -DCMAKE_TOOLCHAIN_FILE=../toolchains/aarch64-none-linux-gnu.toolchain.cmake \
5
+ -DCMAKE_INSTALL_PREFIX=../install \
6
+ -DCMAKE_BUILD_TYPE=Release
7
+ make -j4
8
+ make install
cpp/cmake/msp_dependencies.cmake ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # bsp
2
+ if(NOT BSP_MSP_DIR)
3
+ if (CHIP_AX650)
4
+ add_definitions(-DCHIP_AX650)
5
+ set(BSP_MSP_DIR ${CMAKE_SOURCE_DIR}/ax650n_bsp_sdk/msp/out)
6
+ else()
7
+ add_definitions(-DCHIP_AX630C)
8
+ set(BSP_MSP_DIR ${CMAKE_SOURCE_DIR}/ax620e_bsp_sdk/msp/out/arm64_glibc)
9
+ endif()
10
+ endif()
11
+ message(STATUS "BSP_MSP_DIR = ${BSP_MSP_DIR}")
12
+
13
+ # check bsp exist
14
+ if(NOT EXISTS ${BSP_MSP_DIR})
15
+ message(FATAL_ERROR "FATAL: BSP_MSP_DIR ${BSP_MSP_DIR} not exist")
16
+ endif()
17
+
18
+ set(MSP_INC_DIR ${BSP_MSP_DIR}/include)
19
+ set(MSP_LIB_DIR ${BSP_MSP_DIR}/lib)
20
+
21
+ list(APPEND MSP_LIBS
22
+ ax_sys
23
+ ax_engine
24
+ ax_interpreter)
cpp/download_bsp.sh ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ if [ ! -d ax650n_bsp_sdk ]; then
3
+ echo "\e[32mTips: \n follow docs/how_to_speed_up_submodule_init.md if you this process too slow\e[0m\n"
4
+
5
+ echo "clone ax650 bsp to ax650n_bsp_sdk, please wait..."
6
+ git clone https://github.com/AXERA-TECH/ax650n_bsp_sdk.git
7
+ fi
cpp/install/fireredasr ADDED
Binary file (37.4 kB). View file
 
cpp/main.cpp ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #include "Encoder.hpp"
2
+ #include "DecoderMain.hpp"
3
+ #include "DecoderLoop.hpp"
4
+
5
+ #include <stdio.h>
6
+ #include <ctime>
7
+ #include <sys/time.h>
8
+
9
+ #include <ax_sys_api.h>
10
+
11
+ static double get_current_time()
12
+ {
13
+ struct timeval tv;
14
+ gettimeofday(&tv, NULL);
15
+
16
+ return tv.tv_sec * 1000.0 + tv.tv_usec / 1000.0;
17
+ }
18
+
19
+ int main(int argc, char** argv) {
20
+ int ret = AX_SYS_Init();
21
+ if (0 != ret) {
22
+ fprintf(stderr, "AX_SYS_Init failed! ret = 0x%x\n", ret);
23
+ return -1;
24
+ }
25
+
26
+ AX_ENGINE_NPU_ATTR_T npu_attr;
27
+ memset(&npu_attr, 0, sizeof(npu_attr));
28
+ npu_attr.eHardMode = static_cast<AX_ENGINE_NPU_MODE_T>(0);
29
+ ret = AX_ENGINE_Init(&npu_attr);
30
+ if (0 != ret) {
31
+ fprintf(stderr, "Init ax-engine failed{0x%8x}.\n", ret);
32
+ return -1;
33
+ }
34
+
35
+ Encoder encoder;
36
+ DecoderMain decoder_main;
37
+ DecoderLoop decoder_loop;
38
+
39
+ double start, end;
40
+ double whole_start, whole_end;
41
+
42
+ start = get_current_time();
43
+ if (0 != encoder.Init("../axmodel/encoder.axmodel")) {
44
+ printf("Init encoder failed!\n");
45
+ return -1;
46
+ }
47
+ end = get_current_time();
48
+ printf("Load encoder take %.2fms\n", end - start);
49
+
50
+ start = get_current_time();
51
+ if (0 != decoder_main.Init("../axmodel/decoder_main.axmodel")) {
52
+ printf("Init decoder_main failed!\n");
53
+ return -1;
54
+ }
55
+ end = get_current_time();
56
+ printf("Load decoder_main take %.2fms\n", end - start);
57
+
58
+ start = get_current_time();
59
+ if (0 != decoder_loop.Init("../axmodel/decoder_loop.axmodel")) {
60
+ printf("Init decoder_loop failed!\n");
61
+ return -1;
62
+ }
63
+ end = get_current_time();
64
+ printf("Load decoder_loop take %.2fms\n", end - start);
65
+
66
+ std::vector<float> encoder_inputs(encoder.GetInputSize(0) / sizeof(float));
67
+ std::vector<float> encoder_input_lengths(encoder.GetInputSize(1) / sizeof(float));
68
+ encoder_input_lengths[0] = 100;
69
+
70
+ std::vector<float> n_layer_cross_k(encoder.GetOutputSize(0) / sizeof(float));
71
+ std::vector<float> n_layer_cross_v(encoder.GetOutputSize(1) / sizeof(float));
72
+ std::vector<float> cross_attn_mask(encoder.GetOutputSize(2) / sizeof(float));
73
+
74
+ start = get_current_time();
75
+ whole_start = start;
76
+ encoder.SetInput(encoder_inputs.data(), 0);
77
+ encoder.SetInput(encoder_input_lengths.data(), 1);
78
+ encoder.Run();
79
+ // encoder.GetOutput(n_layer_cross_k.data(), 0);
80
+ // encoder.GetOutput(n_layer_cross_v.data(), 1);
81
+ // encoder.GetOutput(cross_attn_mask.data(), 2);
82
+ end = get_current_time();
83
+ printf("Run encoder take %.2fms\n", end - start);
84
+
85
+ std::vector<int> tokens(decoder_main.GetInputSize(0) / sizeof(int));
86
+
87
+ std::vector<int> logits(decoder_main.GetOutputSize(0) / sizeof(int));
88
+ std::vector<float> n_layer_self_k_cache(decoder_main.GetOutputSize(1) / sizeof(float));
89
+ std::vector<float> n_layer_self_v_cache(decoder_main.GetOutputSize(2) / sizeof(float));
90
+
91
+ start = get_current_time();
92
+ decoder_main.SetInput(tokens.data(), 0);
93
+ // decoder_main.SetInput(encoder.GetOutputPtr(0), 1);
94
+ // decoder_main.SetInput(encoder.GetOutputPtr(1), 2);
95
+ // decoder_main.SetInput(encoder.GetOutputPtr(2), 3);
96
+ decoder_main.SetInput(n_layer_cross_k.data(), 1);
97
+ decoder_main.SetInput(n_layer_cross_v.data(), 2);
98
+ decoder_main.SetInput(cross_attn_mask.data(), 3);
99
+ decoder_main.Run();
100
+ decoder_main.GetOutput(logits.data(), 0);
101
+ // decoder_main.GetOutput(n_layer_self_k_cache.data(), 1);
102
+ // decoder_main.GetOutput(n_layer_self_v_cache.data(), 2);
103
+ end = get_current_time();
104
+ printf("Run decoder_main take %.2fms\n", end - start);
105
+
106
+ std::vector<float> pe(decoder_loop.GetOutputSize(5) / sizeof(float));
107
+ std::vector<float> self_attn_mask(decoder_loop.GetOutputSize(6) / sizeof(float));
108
+
109
+ decoder_loop.SetInput(n_layer_cross_k.data(), 3);
110
+ decoder_loop.SetInput(n_layer_cross_v.data(), 4);
111
+ for (int i = 0; i < 14; i++) {
112
+ // "tokens": tokens,
113
+ // "in_n_layer_self_k_cache": n_layer_self_k_cache,
114
+ // "in_n_layer_self_v_cache": n_layer_self_v_cache,
115
+ // "n_layer_cross_k": n_layer_cross_k_cache,
116
+ // "n_layer_cross_v": n_layer_cross_v_cache,
117
+ // "pe": pe,
118
+ // "self_attn_mask": self_attn_mask,
119
+ // "cross_attn_mask": cross_attn_mask,
120
+
121
+ start = get_current_time();
122
+ decoder_loop.SetInput(tokens.data(), 0);
123
+ decoder_loop.SetInput(decoder_loop.GetOutputPtr(1), 1);
124
+ decoder_loop.SetInput(decoder_loop.GetOutputPtr(2), 2);
125
+ // decoder_loop.SetInput(encoder.GetOutputPtr(0), 3);
126
+ // decoder_loop.SetInput(encoder.GetOutputPtr(1), 4);
127
+
128
+ decoder_loop.Run();
129
+ decoder_loop.GetOutput(logits.data(), 0);
130
+ // decoder_main.GetOutput(n_layer_self_k_cache.data(), 1);
131
+ // decoder_main.GetOutput(n_layer_self_v_cache.data(), 2);
132
+ end = get_current_time();
133
+ printf("Run decoder_loop take %.2fms\n", end - start);
134
+ }
135
+
136
+ whole_end = get_current_time();
137
+ printf("Whole duration %.2fms\n", whole_end - whole_start);
138
+ printf("RTF: %.4f\n", (whole_end - whole_start) / 4000.0);
139
+
140
+ return 0;
141
+ }
cpp/src/AudioFile.h ADDED
@@ -0,0 +1,1293 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //=======================================================================
2
+ /** @file AudioFile.h
3
+ * @author Adam Stark
4
+ * @copyright Copyright (C) 2017 Adam Stark
5
+ *
6
+ * This file is part of the 'AudioFile' library
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+ //=======================================================================
22
+
23
+ #ifndef _AS_AudioFile_h
24
+ #define _AS_AudioFile_h
25
+
26
+ #include <iostream>
27
+ #include <vector>
28
+ #include <cassert>
29
+ #include <string>
30
+ #include <cstring>
31
+ #include <fstream>
32
+ #include <unordered_map>
33
+ #include <iterator>
34
+ #include <algorithm>
35
+
36
+ // disable some warnings on Windows
37
+ #if defined (_MSC_VER)
38
+ __pragma(warning (push))
39
+ __pragma(warning (disable : 4244))
40
+ __pragma(warning (disable : 4457))
41
+ __pragma(warning (disable : 4458))
42
+ __pragma(warning (disable : 4389))
43
+ __pragma(warning (disable : 4996))
44
+ #elif defined (__GNUC__)
45
+ _Pragma("GCC diagnostic push")
46
+ _Pragma("GCC diagnostic ignored \"-Wconversion\"")
47
+ _Pragma("GCC diagnostic ignored \"-Wsign-compare\"")
48
+ _Pragma("GCC diagnostic ignored \"-Wshadow\"")
49
+ #endif
50
+
51
+ //=============================================================
52
+ /** The different types of audio file, plus some other types to
53
+ * indicate a failure to load a file, or that one hasn't been
54
+ * loaded yet
55
+ */
56
+ enum class AudioFileFormat
57
+ {
58
+ Error,
59
+ NotLoaded,
60
+ Wave,
61
+ Aiff
62
+ };
63
+
64
+ //=============================================================
65
+ template <class T>
66
+ class AudioFile
67
+ {
68
+ public:
69
+
70
+ //=============================================================
71
+ typedef std::vector<std::vector<T> > AudioBuffer;
72
+
73
+ //=============================================================
74
+ /** Constructor */
75
+ AudioFile();
76
+
77
+ /** Constructor, using a given file path to load a file */
78
+ AudioFile (std::string filePath);
79
+
80
+ //=============================================================
81
+ /** Loads an audio file from a given file path.
82
+ * @Returns true if the file was successfully loaded
83
+ */
84
+ bool load (std::string filePath);
85
+
86
+ /** Saves an audio file to a given file path.
87
+ * @Returns true if the file was successfully saved
88
+ */
89
+ bool save (std::string filePath, AudioFileFormat format = AudioFileFormat::Wave);
90
+
91
+ //=============================================================
92
+ /** @Returns the sample rate */
93
+ uint32_t getSampleRate() const;
94
+
95
+ /** @Returns the number of audio channels in the buffer */
96
+ int getNumChannels() const;
97
+
98
+ /** @Returns true if the audio file is mono */
99
+ bool isMono() const;
100
+
101
+ /** @Returns true if the audio file is stereo */
102
+ bool isStereo() const;
103
+
104
+ /** @Returns the bit depth of each sample */
105
+ int getBitDepth() const;
106
+
107
+ /** @Returns the number of samples per channel */
108
+ int getNumSamplesPerChannel() const;
109
+
110
+ /** @Returns the length in seconds of the audio file based on the number of samples and sample rate */
111
+ double getLengthInSeconds() const;
112
+
113
+ /** Prints a summary of the audio file to the console */
114
+ void printSummary() const;
115
+
116
+ //=============================================================
117
+
118
+ /** Set the audio buffer for this AudioFile by copying samples from another buffer.
119
+ * @Returns true if the buffer was copied successfully.
120
+ */
121
+ bool setAudioBuffer (AudioBuffer& newBuffer);
122
+
123
+ /** Sets the audio buffer to a given number of channels and number of samples per channel. This will try to preserve
124
+ * the existing audio, adding zeros to any new channels or new samples in a given channel.
125
+ */
126
+ void setAudioBufferSize (int numChannels, int numSamples);
127
+
128
+ /** Sets the number of samples per channel in the audio buffer. This will try to preserve
129
+ * the existing audio, adding zeros to new samples in a given channel if the number of samples is increased.
130
+ */
131
+ void setNumSamplesPerChannel (int numSamples);
132
+
133
+ /** Sets the number of channels. New channels will have the correct number of samples and be initialised to zero */
134
+ void setNumChannels (int numChannels);
135
+
136
+ /** Sets the bit depth for the audio file. If you use the save() function, this bit depth rate will be used */
137
+ void setBitDepth (int numBitsPerSample);
138
+
139
+ /** Sets the sample rate for the audio file. If you use the save() function, this sample rate will be used */
140
+ void setSampleRate (uint32_t newSampleRate);
141
+
142
+ //=============================================================
143
+ /** Sets whether the library should log error messages to the console. By default this is true */
144
+ void shouldLogErrorsToConsole (bool logErrors);
145
+
146
+ //=============================================================
147
+ /** A vector of vectors holding the audio samples for the AudioFile. You can
148
+ * access the samples by channel and then by sample index, i.e:
149
+ *
150
+ * samples[channel][sampleIndex]
151
+ */
152
+ AudioBuffer samples;
153
+
154
+ //=============================================================
155
+ /** An optional iXML chunk that can be added to the AudioFile.
156
+ */
157
+ std::string iXMLChunk;
158
+
159
+ private:
160
+
161
+ //=============================================================
162
+ enum class Endianness
163
+ {
164
+ LittleEndian,
165
+ BigEndian
166
+ };
167
+
168
+ //=============================================================
169
+ AudioFileFormat determineAudioFileFormat (std::vector<uint8_t>& fileData);
170
+ bool decodeWaveFile (std::vector<uint8_t>& fileData);
171
+ bool decodeAiffFile (std::vector<uint8_t>& fileData);
172
+
173
+ //=============================================================
174
+ bool saveToWaveFile (std::string filePath);
175
+ bool saveToAiffFile (std::string filePath);
176
+
177
+ //=============================================================
178
+ void clearAudioBuffer();
179
+
180
+ //=============================================================
181
+ int32_t fourBytesToInt (std::vector<uint8_t>& source, int startIndex, Endianness endianness = Endianness::LittleEndian);
182
+ int16_t twoBytesToInt (std::vector<uint8_t>& source, int startIndex, Endianness endianness = Endianness::LittleEndian);
183
+ int getIndexOfString (std::vector<uint8_t>& source, std::string s);
184
+ int getIndexOfChunk (std::vector<uint8_t>& source, const std::string& chunkHeaderID, int startIndex, Endianness endianness = Endianness::LittleEndian);
185
+
186
+ //=============================================================
187
+ T sixteenBitIntToSample (int16_t sample);
188
+ int16_t sampleToSixteenBitInt (T sample);
189
+
190
+ //=============================================================
191
+ uint8_t sampleToSingleByte (T sample);
192
+ T singleByteToSample (uint8_t sample);
193
+
194
+ uint32_t getAiffSampleRate (std::vector<uint8_t>& fileData, int sampleRateStartIndex);
195
+ bool tenByteMatch (std::vector<uint8_t>& v1, int startIndex1, std::vector<uint8_t>& v2, int startIndex2);
196
+ void addSampleRateToAiffData (std::vector<uint8_t>& fileData, uint32_t sampleRate);
197
+ T clamp (T v1, T minValue, T maxValue);
198
+
199
+ //=============================================================
200
+ void addStringToFileData (std::vector<uint8_t>& fileData, std::string s);
201
+ void addInt32ToFileData (std::vector<uint8_t>& fileData, int32_t i, Endianness endianness = Endianness::LittleEndian);
202
+ void addInt16ToFileData (std::vector<uint8_t>& fileData, int16_t i, Endianness endianness = Endianness::LittleEndian);
203
+
204
+ //=============================================================
205
+ bool writeDataToFile (std::vector<uint8_t>& fileData, std::string filePath);
206
+
207
+ //=============================================================
208
+ void reportError (std::string errorMessage);
209
+
210
+ //=============================================================
211
+ AudioFileFormat audioFileFormat;
212
+ uint32_t sampleRate;
213
+ int bitDepth;
214
+ bool logErrorsToConsole {true};
215
+ };
216
+
217
+
218
+ //=============================================================
219
+ // Pre-defined 10-byte representations of common sample rates
220
+ static std::unordered_map <uint32_t, std::vector<uint8_t>> aiffSampleRateTable = {
221
+ {8000, {64, 11, 250, 0, 0, 0, 0, 0, 0, 0}},
222
+ {11025, {64, 12, 172, 68, 0, 0, 0, 0, 0, 0}},
223
+ {16000, {64, 12, 250, 0, 0, 0, 0, 0, 0, 0}},
224
+ {22050, {64, 13, 172, 68, 0, 0, 0, 0, 0, 0}},
225
+ {32000, {64, 13, 250, 0, 0, 0, 0, 0, 0, 0}},
226
+ {37800, {64, 14, 147, 168, 0, 0, 0, 0, 0, 0}},
227
+ {44056, {64, 14, 172, 24, 0, 0, 0, 0, 0, 0}},
228
+ {44100, {64, 14, 172, 68, 0, 0, 0, 0, 0, 0}},
229
+ {47250, {64, 14, 184, 146, 0, 0, 0, 0, 0, 0}},
230
+ {48000, {64, 14, 187, 128, 0, 0, 0, 0, 0, 0}},
231
+ {50000, {64, 14, 195, 80, 0, 0, 0, 0, 0, 0}},
232
+ {50400, {64, 14, 196, 224, 0, 0, 0, 0, 0, 0}},
233
+ {88200, {64, 15, 172, 68, 0, 0, 0, 0, 0, 0}},
234
+ {96000, {64, 15, 187, 128, 0, 0, 0, 0, 0, 0}},
235
+ {176400, {64, 16, 172, 68, 0, 0, 0, 0, 0, 0}},
236
+ {192000, {64, 16, 187, 128, 0, 0, 0, 0, 0, 0}},
237
+ {352800, {64, 17, 172, 68, 0, 0, 0, 0, 0, 0}},
238
+ {2822400, {64, 20, 172, 68, 0, 0, 0, 0, 0, 0}},
239
+ {5644800, {64, 21, 172, 68, 0, 0, 0, 0, 0, 0}}
240
+ };
241
+
242
+ //=============================================================
243
+ enum WavAudioFormat
244
+ {
245
+ PCM = 0x0001,
246
+ IEEEFloat = 0x0003,
247
+ ALaw = 0x0006,
248
+ MULaw = 0x0007,
249
+ Extensible = 0xFFFE
250
+ };
251
+
252
+ //=============================================================
253
+ enum AIFFAudioFormat
254
+ {
255
+ Uncompressed,
256
+ Compressed,
257
+ Error
258
+ };
259
+
260
+ //=============================================================
261
+ /* IMPLEMENTATION */
262
+ //=============================================================
263
+
264
+ //=============================================================
265
+ template <class T>
266
+ AudioFile<T>::AudioFile()
267
+ {
268
+ static_assert(std::is_floating_point<T>::value, "ERROR: This version of AudioFile only supports floating point sample formats");
269
+
270
+ bitDepth = 16;
271
+ sampleRate = 44100;
272
+ samples.resize (1);
273
+ samples[0].resize (0);
274
+ audioFileFormat = AudioFileFormat::NotLoaded;
275
+ }
276
+
277
+ //=============================================================
278
+ template <class T>
279
+ AudioFile<T>::AudioFile (std::string filePath)
280
+ : AudioFile<T>()
281
+ {
282
+ load (filePath);
283
+ }
284
+
285
+ //=============================================================
286
+ template <class T>
287
+ uint32_t AudioFile<T>::getSampleRate() const
288
+ {
289
+ return sampleRate;
290
+ }
291
+
292
+ //=============================================================
293
+ template <class T>
294
+ int AudioFile<T>::getNumChannels() const
295
+ {
296
+ return (int)samples.size();
297
+ }
298
+
299
+ //=============================================================
300
+ template <class T>
301
+ bool AudioFile<T>::isMono() const
302
+ {
303
+ return getNumChannels() == 1;
304
+ }
305
+
306
+ //=============================================================
307
+ template <class T>
308
+ bool AudioFile<T>::isStereo() const
309
+ {
310
+ return getNumChannels() == 2;
311
+ }
312
+
313
+ //=============================================================
314
+ template <class T>
315
+ int AudioFile<T>::getBitDepth() const
316
+ {
317
+ return bitDepth;
318
+ }
319
+
320
+ //=============================================================
321
+ template <class T>
322
+ int AudioFile<T>::getNumSamplesPerChannel() const
323
+ {
324
+ if (samples.size() > 0)
325
+ return (int) samples[0].size();
326
+ else
327
+ return 0;
328
+ }
329
+
330
+ //=============================================================
331
+ template <class T>
332
+ double AudioFile<T>::getLengthInSeconds() const
333
+ {
334
+ return (double)getNumSamplesPerChannel() / (double)sampleRate;
335
+ }
336
+
337
+ //=============================================================
338
+ template <class T>
339
+ void AudioFile<T>::printSummary() const
340
+ {
341
+ std::cout << "|======================================|" << std::endl;
342
+ std::cout << "Num Channels: " << getNumChannels() << std::endl;
343
+ std::cout << "Num Samples Per Channel: " << getNumSamplesPerChannel() << std::endl;
344
+ std::cout << "Sample Rate: " << sampleRate << std::endl;
345
+ std::cout << "Bit Depth: " << bitDepth << std::endl;
346
+ std::cout << "Length in Seconds: " << getLengthInSeconds() << std::endl;
347
+ std::cout << "|======================================|" << std::endl;
348
+ }
349
+
350
+ //=============================================================
351
+ template <class T>
352
+ bool AudioFile<T>::setAudioBuffer (AudioBuffer& newBuffer)
353
+ {
354
+ int numChannels = (int)newBuffer.size();
355
+
356
+ if (numChannels <= 0)
357
+ {
358
+ assert (false && "The buffer your are trying to use has no channels");
359
+ return false;
360
+ }
361
+
362
+ size_t numSamples = newBuffer[0].size();
363
+
364
+ // set the number of channels
365
+ samples.resize (newBuffer.size());
366
+
367
+ for (int k = 0; k < getNumChannels(); k++)
368
+ {
369
+ assert (newBuffer[k].size() == numSamples);
370
+
371
+ samples[k].resize (numSamples);
372
+
373
+ for (size_t i = 0; i < numSamples; i++)
374
+ {
375
+ samples[k][i] = newBuffer[k][i];
376
+ }
377
+ }
378
+
379
+ return true;
380
+ }
381
+
382
+ //=============================================================
383
+ template <class T>
384
+ void AudioFile<T>::setAudioBufferSize (int numChannels, int numSamples)
385
+ {
386
+ samples.resize (numChannels);
387
+ setNumSamplesPerChannel (numSamples);
388
+ }
389
+
390
+ //=============================================================
391
+ template <class T>
392
+ void AudioFile<T>::setNumSamplesPerChannel (int numSamples)
393
+ {
394
+ int originalSize = getNumSamplesPerChannel();
395
+
396
+ for (int i = 0; i < getNumChannels();i++)
397
+ {
398
+ samples[i].resize (numSamples);
399
+
400
+ // set any new samples to zero
401
+ if (numSamples > originalSize)
402
+ std::fill (samples[i].begin() + originalSize, samples[i].end(), (T)0.);
403
+ }
404
+ }
405
+
406
+ //=============================================================
407
+ template <class T>
408
+ void AudioFile<T>::setNumChannels (int numChannels)
409
+ {
410
+ int originalNumChannels = getNumChannels();
411
+ int originalNumSamplesPerChannel = getNumSamplesPerChannel();
412
+
413
+ samples.resize (numChannels);
414
+
415
+ // make sure any new channels are set to the right size
416
+ // and filled with zeros
417
+ if (numChannels > originalNumChannels)
418
+ {
419
+ for (int i = originalNumChannels; i < numChannels; i++)
420
+ {
421
+ samples[i].resize (originalNumSamplesPerChannel);
422
+ std::fill (samples[i].begin(), samples[i].end(), (T)0.);
423
+ }
424
+ }
425
+ }
426
+
427
+ //=============================================================
428
+ template <class T>
429
+ void AudioFile<T>::setBitDepth (int numBitsPerSample)
430
+ {
431
+ bitDepth = numBitsPerSample;
432
+ }
433
+
434
+ //=============================================================
435
+ template <class T>
436
+ void AudioFile<T>::setSampleRate (uint32_t newSampleRate)
437
+ {
438
+ sampleRate = newSampleRate;
439
+ }
440
+
441
+ //=============================================================
442
+ template <class T>
443
+ void AudioFile<T>::shouldLogErrorsToConsole (bool logErrors)
444
+ {
445
+ logErrorsToConsole = logErrors;
446
+ }
447
+
448
+ //=============================================================
449
+ template <class T>
450
+ bool AudioFile<T>::load (std::string filePath)
451
+ {
452
+ std::ifstream file (filePath, std::ios::binary);
453
+
454
+ // check the file exists
455
+ if (! file.good())
456
+ {
457
+ reportError ("ERROR: File doesn't exist or otherwise can't load file\n" + filePath);
458
+ return false;
459
+ }
460
+
461
+ std::vector<uint8_t> fileData;
462
+
463
+ file.unsetf (std::ios::skipws);
464
+
465
+ file.seekg (0, std::ios::end);
466
+ size_t length = file.tellg();
467
+ file.seekg (0, std::ios::beg);
468
+
469
+ // allocate
470
+ fileData.resize (length);
471
+
472
+ file.read(reinterpret_cast<char*> (fileData.data()), length);
473
+ file.close();
474
+
475
+ if (file.gcount() != length)
476
+ {
477
+ reportError ("ERROR: Couldn't read entire file\n" + filePath);
478
+ return false;
479
+ }
480
+
481
+ // get audio file format
482
+ audioFileFormat = determineAudioFileFormat (fileData);
483
+
484
+ if (audioFileFormat == AudioFileFormat::Wave)
485
+ {
486
+ return decodeWaveFile (fileData);
487
+ }
488
+ else if (audioFileFormat == AudioFileFormat::Aiff)
489
+ {
490
+ return decodeAiffFile (fileData);
491
+ }
492
+ else
493
+ {
494
+ reportError ("Audio File Type: Error");
495
+ return false;
496
+ }
497
+ }
498
+
499
+ //=============================================================
500
+ template <class T>
501
+ bool AudioFile<T>::decodeWaveFile (std::vector<uint8_t>& fileData)
502
+ {
503
+ // -----------------------------------------------------------
504
+ // HEADER CHUNK
505
+ std::string headerChunkID (fileData.begin(), fileData.begin() + 4);
506
+ //int32_t fileSizeInBytes = fourBytesToInt (fileData, 4) + 8;
507
+ std::string format (fileData.begin() + 8, fileData.begin() + 12);
508
+
509
+ // -----------------------------------------------------------
510
+ // try and find the start points of key chunks
511
+ int indexOfDataChunk = getIndexOfChunk (fileData, "data", 12);
512
+ int indexOfFormatChunk = getIndexOfChunk (fileData, "fmt ", 12);
513
+ int indexOfXMLChunk = getIndexOfChunk (fileData, "iXML", 12);
514
+
515
+ // if we can't find the data or format chunks, or the IDs/formats don't seem to be as expected
516
+ // then it is unlikely we'll able to read this file, so abort
517
+ if (indexOfDataChunk == -1 || indexOfFormatChunk == -1 || headerChunkID != "RIFF" || format != "WAVE")
518
+ {
519
+ reportError ("ERROR: this doesn't seem to be a valid .WAV file");
520
+ return false;
521
+ }
522
+
523
+ // -----------------------------------------------------------
524
+ // FORMAT CHUNK
525
+ int f = indexOfFormatChunk;
526
+ std::string formatChunkID (fileData.begin() + f, fileData.begin() + f + 4);
527
+ //int32_t formatChunkSize = fourBytesToInt (fileData, f + 4);
528
+ uint16_t audioFormat = twoBytesToInt (fileData, f + 8);
529
+ uint16_t numChannels = twoBytesToInt (fileData, f + 10);
530
+ sampleRate = (uint32_t) fourBytesToInt (fileData, f + 12);
531
+ uint32_t numBytesPerSecond = fourBytesToInt (fileData, f + 16);
532
+ uint16_t numBytesPerBlock = twoBytesToInt (fileData, f + 20);
533
+ bitDepth = (int) twoBytesToInt (fileData, f + 22);
534
+
535
+ uint16_t numBytesPerSample = static_cast<uint16_t> (bitDepth) / 8;
536
+
537
+ // check that the audio format is PCM or Float or extensible
538
+ if (audioFormat != WavAudioFormat::PCM && audioFormat != WavAudioFormat::IEEEFloat && audioFormat != WavAudioFormat::Extensible)
539
+ {
540
+ reportError ("ERROR: this .WAV file is encoded in a format that this library does not support at present");
541
+ return false;
542
+ }
543
+
544
+ // check the number of channels is mono or stereo
545
+ if (numChannels < 1 || numChannels > 128)
546
+ {
547
+ reportError ("ERROR: this WAV file seems to be an invalid number of channels (or corrupted?)");
548
+ return false;
549
+ }
550
+
551
+ // check header data is consistent
552
+ if (numBytesPerSecond != static_cast<uint32_t> ((numChannels * sampleRate * bitDepth) / 8) || numBytesPerBlock != (numChannels * numBytesPerSample))
553
+ {
554
+ reportError ("ERROR: the header data in this WAV file seems to be inconsistent");
555
+ return false;
556
+ }
557
+
558
+ // check bit depth is either 8, 16, 24 or 32 bit
559
+ if (bitDepth != 8 && bitDepth != 16 && bitDepth != 24 && bitDepth != 32)
560
+ {
561
+ reportError ("ERROR: this file has a bit depth that is not 8, 16, 24 or 32 bits");
562
+ return false;
563
+ }
564
+
565
+ // -----------------------------------------------------------
566
+ // DATA CHUNK
567
+ int d = indexOfDataChunk;
568
+ std::string dataChunkID (fileData.begin() + d, fileData.begin() + d + 4);
569
+ int32_t dataChunkSize = fourBytesToInt (fileData, d + 4);
570
+
571
+ int numSamples = dataChunkSize / (numChannels * bitDepth / 8);
572
+ int samplesStartIndex = indexOfDataChunk + 8;
573
+
574
+ clearAudioBuffer();
575
+ samples.resize (numChannels);
576
+
577
+ for (int i = 0; i < numSamples; i++)
578
+ {
579
+ for (int channel = 0; channel < numChannels; channel++)
580
+ {
581
+ int sampleIndex = samplesStartIndex + (numBytesPerBlock * i) + channel * numBytesPerSample;
582
+
583
+ if ((sampleIndex + (bitDepth / 8) - 1) >= fileData.size())
584
+ {
585
+ reportError ("ERROR: read file error as the metadata indicates more samples than there are in the file data");
586
+ return false;
587
+ }
588
+
589
+ if (bitDepth == 8)
590
+ {
591
+ T sample = singleByteToSample (fileData[sampleIndex]);
592
+ samples[channel].push_back (sample);
593
+ }
594
+ else if (bitDepth == 16)
595
+ {
596
+ int16_t sampleAsInt = twoBytesToInt (fileData, sampleIndex);
597
+ T sample = sixteenBitIntToSample (sampleAsInt);
598
+ samples[channel].push_back (sample);
599
+ }
600
+ else if (bitDepth == 24)
601
+ {
602
+ int32_t sampleAsInt = 0;
603
+ sampleAsInt = (fileData[sampleIndex + 2] << 16) | (fileData[sampleIndex + 1] << 8) | fileData[sampleIndex];
604
+
605
+ if (sampleAsInt & 0x800000) // if the 24th bit is set, this is a negative number in 24-bit world
606
+ sampleAsInt = sampleAsInt | ~0xFFFFFF; // so make sure sign is extended to the 32 bit float
607
+
608
+ T sample = (T)sampleAsInt / (T)8388608.;
609
+ samples[channel].push_back (sample);
610
+ }
611
+ else if (bitDepth == 32)
612
+ {
613
+ int32_t sampleAsInt = fourBytesToInt (fileData, sampleIndex);
614
+ T sample;
615
+
616
+ if (audioFormat == WavAudioFormat::IEEEFloat)
617
+ sample = (T)reinterpret_cast<float&> (sampleAsInt);
618
+ else // assume PCM
619
+ sample = (T) sampleAsInt / static_cast<float> (std::numeric_limits<std::int32_t>::max());
620
+
621
+ samples[channel].push_back (sample);
622
+ }
623
+ else
624
+ {
625
+ assert (false);
626
+ }
627
+ }
628
+ }
629
+
630
+ // -----------------------------------------------------------
631
+ // iXML CHUNK
632
+ if (indexOfXMLChunk != -1)
633
+ {
634
+ int32_t chunkSize = fourBytesToInt (fileData, indexOfXMLChunk + 4);
635
+ iXMLChunk = std::string ((const char*) &fileData[indexOfXMLChunk + 8], chunkSize);
636
+ }
637
+
638
+ return true;
639
+ }
640
+
641
+ //=============================================================
642
+ template <class T>
643
+ bool AudioFile<T>::decodeAiffFile (std::vector<uint8_t>& fileData)
644
+ {
645
+ // -----------------------------------------------------------
646
+ // HEADER CHUNK
647
+ std::string headerChunkID (fileData.begin(), fileData.begin() + 4);
648
+ //int32_t fileSizeInBytes = fourBytesToInt (fileData, 4, Endianness::BigEndian) + 8;
649
+ std::string format (fileData.begin() + 8, fileData.begin() + 12);
650
+
651
+ int audioFormat = format == "AIFF" ? AIFFAudioFormat::Uncompressed : format == "AIFC" ? AIFFAudioFormat::Compressed : AIFFAudioFormat::Error;
652
+
653
+ // -----------------------------------------------------------
654
+ // try and find the start points of key chunks
655
+ int indexOfCommChunk = getIndexOfChunk (fileData, "COMM", 12, Endianness::BigEndian);
656
+ int indexOfSoundDataChunk = getIndexOfChunk (fileData, "SSND", 12, Endianness::BigEndian);
657
+ int indexOfXMLChunk = getIndexOfChunk (fileData, "iXML", 12, Endianness::BigEndian);
658
+
659
+ // if we can't find the data or format chunks, or the IDs/formats don't seem to be as expected
660
+ // then it is unlikely we'll able to read this file, so abort
661
+ if (indexOfSoundDataChunk == -1 || indexOfCommChunk == -1 || headerChunkID != "FORM" || audioFormat == AIFFAudioFormat::Error)
662
+ {
663
+ reportError ("ERROR: this doesn't seem to be a valid AIFF file");
664
+ return false;
665
+ }
666
+
667
+ // -----------------------------------------------------------
668
+ // COMM CHUNK
669
+ int p = indexOfCommChunk;
670
+ std::string commChunkID (fileData.begin() + p, fileData.begin() + p + 4);
671
+ //int32_t commChunkSize = fourBytesToInt (fileData, p + 4, Endianness::BigEndian);
672
+ int16_t numChannels = twoBytesToInt (fileData, p + 8, Endianness::BigEndian);
673
+ int32_t numSamplesPerChannel = fourBytesToInt (fileData, p + 10, Endianness::BigEndian);
674
+ bitDepth = (int) twoBytesToInt (fileData, p + 14, Endianness::BigEndian);
675
+ sampleRate = getAiffSampleRate (fileData, p + 16);
676
+
677
+ // check the sample rate was properly decoded
678
+ if (sampleRate == 0)
679
+ {
680
+ reportError ("ERROR: this AIFF file has an unsupported sample rate");
681
+ return false;
682
+ }
683
+
684
+ // check the number of channels is mono or stereo
685
+ if (numChannels < 1 ||numChannels > 2)
686
+ {
687
+ reportError ("ERROR: this AIFF file seems to be neither mono nor stereo (perhaps multi-track, or corrupted?)");
688
+ return false;
689
+ }
690
+
691
+ // check bit depth is either 8, 16, 24 or 32-bit
692
+ if (bitDepth != 8 && bitDepth != 16 && bitDepth != 24 && bitDepth != 32)
693
+ {
694
+ reportError ("ERROR: this file has a bit depth that is not 8, 16, 24 or 32 bits");
695
+ return false;
696
+ }
697
+
698
+ // -----------------------------------------------------------
699
+ // SSND CHUNK
700
+ int s = indexOfSoundDataChunk;
701
+ std::string soundDataChunkID (fileData.begin() + s, fileData.begin() + s + 4);
702
+ int32_t soundDataChunkSize = fourBytesToInt (fileData, s + 4, Endianness::BigEndian);
703
+ int32_t offset = fourBytesToInt (fileData, s + 8, Endianness::BigEndian);
704
+ //int32_t blockSize = fourBytesToInt (fileData, s + 12, Endianness::BigEndian);
705
+
706
+ int numBytesPerSample = bitDepth / 8;
707
+ int numBytesPerFrame = numBytesPerSample * numChannels;
708
+ int totalNumAudioSampleBytes = numSamplesPerChannel * numBytesPerFrame;
709
+ int samplesStartIndex = s + 16 + (int)offset;
710
+
711
+ // sanity check the data
712
+ if ((soundDataChunkSize - 8) != totalNumAudioSampleBytes || totalNumAudioSampleBytes > static_cast<long>(fileData.size() - samplesStartIndex))
713
+ {
714
+ reportError ("ERROR: the metadatafor this file doesn't seem right");
715
+ return false;
716
+ }
717
+
718
+ clearAudioBuffer();
719
+ samples.resize (numChannels);
720
+
721
+ for (int i = 0; i < numSamplesPerChannel; i++)
722
+ {
723
+ for (int channel = 0; channel < numChannels; channel++)
724
+ {
725
+ int sampleIndex = samplesStartIndex + (numBytesPerFrame * i) + channel * numBytesPerSample;
726
+
727
+ if ((sampleIndex + (bitDepth / 8) - 1) >= fileData.size())
728
+ {
729
+ reportError ("ERROR: read file error as the metadata indicates more samples than there are in the file data");
730
+ return false;
731
+ }
732
+
733
+ if (bitDepth == 8)
734
+ {
735
+ int8_t sampleAsSigned8Bit = (int8_t)fileData[sampleIndex];
736
+ T sample = (T)sampleAsSigned8Bit / (T)128.;
737
+ samples[channel].push_back (sample);
738
+ }
739
+ else if (bitDepth == 16)
740
+ {
741
+ int16_t sampleAsInt = twoBytesToInt (fileData, sampleIndex, Endianness::BigEndian);
742
+ T sample = sixteenBitIntToSample (sampleAsInt);
743
+ samples[channel].push_back (sample);
744
+ }
745
+ else if (bitDepth == 24)
746
+ {
747
+ int32_t sampleAsInt = 0;
748
+ sampleAsInt = (fileData[sampleIndex] << 16) | (fileData[sampleIndex + 1] << 8) | fileData[sampleIndex + 2];
749
+
750
+ if (sampleAsInt & 0x800000) // if the 24th bit is set, this is a negative number in 24-bit world
751
+ sampleAsInt = sampleAsInt | ~0xFFFFFF; // so make sure sign is extended to the 32 bit float
752
+
753
+ T sample = (T)sampleAsInt / (T)8388608.;
754
+ samples[channel].push_back (sample);
755
+ }
756
+ else if (bitDepth == 32)
757
+ {
758
+ int32_t sampleAsInt = fourBytesToInt (fileData, sampleIndex, Endianness::BigEndian);
759
+ T sample;
760
+
761
+ if (audioFormat == AIFFAudioFormat::Compressed)
762
+ sample = (T)reinterpret_cast<float&> (sampleAsInt);
763
+ else // assume uncompressed
764
+ sample = (T) sampleAsInt / static_cast<float> (std::numeric_limits<std::int32_t>::max());
765
+
766
+ samples[channel].push_back (sample);
767
+ }
768
+ else
769
+ {
770
+ assert (false);
771
+ }
772
+ }
773
+ }
774
+
775
+ // -----------------------------------------------------------
776
+ // iXML CHUNK
777
+ if (indexOfXMLChunk != -1)
778
+ {
779
+ int32_t chunkSize = fourBytesToInt (fileData, indexOfXMLChunk + 4);
780
+ iXMLChunk = std::string ((const char*) &fileData[indexOfXMLChunk + 8], chunkSize);
781
+ }
782
+
783
+ return true;
784
+ }
785
+
786
+ //=============================================================
787
+ template <class T>
788
+ uint32_t AudioFile<T>::getAiffSampleRate (std::vector<uint8_t>& fileData, int sampleRateStartIndex)
789
+ {
790
+ for (auto it : aiffSampleRateTable)
791
+ {
792
+ if (tenByteMatch (fileData, sampleRateStartIndex, it.second, 0))
793
+ return it.first;
794
+ }
795
+
796
+ return 0;
797
+ }
798
+
799
+ //=============================================================
800
+ template <class T>
801
+ bool AudioFile<T>::tenByteMatch (std::vector<uint8_t>& v1, int startIndex1, std::vector<uint8_t>& v2, int startIndex2)
802
+ {
803
+ for (int i = 0; i < 10; i++)
804
+ {
805
+ if (v1[startIndex1 + i] != v2[startIndex2 + i])
806
+ return false;
807
+ }
808
+
809
+ return true;
810
+ }
811
+
812
+ //=============================================================
813
+ template <class T>
814
+ void AudioFile<T>::addSampleRateToAiffData (std::vector<uint8_t>& fileData, uint32_t sampleRate)
815
+ {
816
+ if (aiffSampleRateTable.count (sampleRate) > 0)
817
+ {
818
+ for (int i = 0; i < 10; i++)
819
+ fileData.push_back (aiffSampleRateTable[sampleRate][i]);
820
+ }
821
+ }
822
+
823
+ //=============================================================
824
+ template <class T>
825
+ bool AudioFile<T>::save (std::string filePath, AudioFileFormat format)
826
+ {
827
+ if (format == AudioFileFormat::Wave)
828
+ {
829
+ return saveToWaveFile (filePath);
830
+ }
831
+ else if (format == AudioFileFormat::Aiff)
832
+ {
833
+ return saveToAiffFile (filePath);
834
+ }
835
+
836
+ return false;
837
+ }
838
+
839
+ //=============================================================
840
+ template <class T>
841
+ bool AudioFile<T>::saveToWaveFile (std::string filePath)
842
+ {
843
+ std::vector<uint8_t> fileData;
844
+
845
+ int32_t dataChunkSize = getNumSamplesPerChannel() * (getNumChannels() * bitDepth / 8);
846
+ int16_t audioFormat = bitDepth == 32 ? WavAudioFormat::IEEEFloat : WavAudioFormat::PCM;
847
+ int32_t formatChunkSize = audioFormat == WavAudioFormat::PCM ? 16 : 18;
848
+ int32_t iXMLChunkSize = static_cast<int32_t> (iXMLChunk.size());
849
+
850
+ // -----------------------------------------------------------
851
+ // HEADER CHUNK
852
+ addStringToFileData (fileData, "RIFF");
853
+
854
+ // The file size in bytes is the header chunk size (4, not counting RIFF and WAVE) + the format
855
+ // chunk size (24) + the metadata part of the data chunk plus the actual data chunk size
856
+ int32_t fileSizeInBytes = 4 + formatChunkSize + 8 + 8 + dataChunkSize;
857
+ if (iXMLChunkSize > 0)
858
+ {
859
+ fileSizeInBytes += (8 + iXMLChunkSize);
860
+ }
861
+
862
+ addInt32ToFileData (fileData, fileSizeInBytes);
863
+
864
+ addStringToFileData (fileData, "WAVE");
865
+
866
+ // -----------------------------------------------------------
867
+ // FORMAT CHUNK
868
+ addStringToFileData (fileData, "fmt ");
869
+ addInt32ToFileData (fileData, formatChunkSize); // format chunk size (16 for PCM)
870
+ addInt16ToFileData (fileData, audioFormat); // audio format
871
+ addInt16ToFileData (fileData, (int16_t)getNumChannels()); // num channels
872
+ addInt32ToFileData (fileData, (int32_t)sampleRate); // sample rate
873
+
874
+ int32_t numBytesPerSecond = (int32_t) ((getNumChannels() * sampleRate * bitDepth) / 8);
875
+ addInt32ToFileData (fileData, numBytesPerSecond);
876
+
877
+ int16_t numBytesPerBlock = getNumChannels() * (bitDepth / 8);
878
+ addInt16ToFileData (fileData, numBytesPerBlock);
879
+
880
+ addInt16ToFileData (fileData, (int16_t)bitDepth);
881
+
882
+ if (audioFormat == WavAudioFormat::IEEEFloat)
883
+ addInt16ToFileData (fileData, 0); // extension size
884
+
885
+ // -----------------------------------------------------------
886
+ // DATA CHUNK
887
+ addStringToFileData (fileData, "data");
888
+ addInt32ToFileData (fileData, dataChunkSize);
889
+
890
+ for (int i = 0; i < getNumSamplesPerChannel(); i++)
891
+ {
892
+ for (int channel = 0; channel < getNumChannels(); channel++)
893
+ {
894
+ if (bitDepth == 8)
895
+ {
896
+ uint8_t byte = sampleToSingleByte (samples[channel][i]);
897
+ fileData.push_back (byte);
898
+ }
899
+ else if (bitDepth == 16)
900
+ {
901
+ int16_t sampleAsInt = sampleToSixteenBitInt (samples[channel][i]);
902
+ addInt16ToFileData (fileData, sampleAsInt);
903
+ }
904
+ else if (bitDepth == 24)
905
+ {
906
+ int32_t sampleAsIntAgain = (int32_t) (samples[channel][i] * (T)8388608.);
907
+
908
+ uint8_t bytes[3];
909
+ bytes[2] = (uint8_t) (sampleAsIntAgain >> 16) & 0xFF;
910
+ bytes[1] = (uint8_t) (sampleAsIntAgain >> 8) & 0xFF;
911
+ bytes[0] = (uint8_t) sampleAsIntAgain & 0xFF;
912
+
913
+ fileData.push_back (bytes[0]);
914
+ fileData.push_back (bytes[1]);
915
+ fileData.push_back (bytes[2]);
916
+ }
917
+ else if (bitDepth == 32)
918
+ {
919
+ int32_t sampleAsInt;
920
+
921
+ if (audioFormat == WavAudioFormat::IEEEFloat)
922
+ sampleAsInt = (int32_t) reinterpret_cast<int32_t&> (samples[channel][i]);
923
+ else // assume PCM
924
+ sampleAsInt = (int32_t) (samples[channel][i] * std::numeric_limits<int32_t>::max());
925
+
926
+ addInt32ToFileData (fileData, sampleAsInt, Endianness::LittleEndian);
927
+ }
928
+ else
929
+ {
930
+ assert (false && "Trying to write a file with unsupported bit depth");
931
+ return false;
932
+ }
933
+ }
934
+ }
935
+
936
+ // -----------------------------------------------------------
937
+ // iXML CHUNK
938
+ if (iXMLChunkSize > 0)
939
+ {
940
+ addStringToFileData (fileData, "iXML");
941
+ addInt32ToFileData (fileData, iXMLChunkSize);
942
+ addStringToFileData (fileData, iXMLChunk);
943
+ }
944
+
945
+ // check that the various sizes we put in the metadata are correct
946
+ if (fileSizeInBytes != static_cast<int32_t> (fileData.size() - 8) || dataChunkSize != (getNumSamplesPerChannel() * getNumChannels() * (bitDepth / 8)))
947
+ {
948
+ reportError ("ERROR: couldn't save file to " + filePath);
949
+ return false;
950
+ }
951
+
952
+ // try to write the file
953
+ return writeDataToFile (fileData, filePath);
954
+ }
955
+
956
+ //=============================================================
957
+ template <class T>
958
+ bool AudioFile<T>::saveToAiffFile (std::string filePath)
959
+ {
960
+ std::vector<uint8_t> fileData;
961
+
962
+ int32_t numBytesPerSample = bitDepth / 8;
963
+ int32_t numBytesPerFrame = numBytesPerSample * getNumChannels();
964
+ int32_t totalNumAudioSampleBytes = getNumSamplesPerChannel() * numBytesPerFrame;
965
+ int32_t soundDataChunkSize = totalNumAudioSampleBytes + 8;
966
+ int32_t iXMLChunkSize = static_cast<int32_t> (iXMLChunk.size());
967
+
968
+ // -----------------------------------------------------------
969
+ // HEADER CHUNK
970
+ addStringToFileData (fileData, "FORM");
971
+
972
+ // The file size in bytes is the header chunk size (4, not counting FORM and AIFF) + the COMM
973
+ // chunk size (26) + the metadata part of the SSND chunk plus the actual data chunk size
974
+ int32_t fileSizeInBytes = 4 + 26 + 16 + totalNumAudioSampleBytes;
975
+ if (iXMLChunkSize > 0)
976
+ {
977
+ fileSizeInBytes += (8 + iXMLChunkSize);
978
+ }
979
+
980
+ addInt32ToFileData (fileData, fileSizeInBytes, Endianness::BigEndian);
981
+
982
+ addStringToFileData (fileData, "AIFF");
983
+
984
+ // -----------------------------------------------------------
985
+ // COMM CHUNK
986
+ addStringToFileData (fileData, "COMM");
987
+ addInt32ToFileData (fileData, 18, Endianness::BigEndian); // commChunkSize
988
+ addInt16ToFileData (fileData, getNumChannels(), Endianness::BigEndian); // num channels
989
+ addInt32ToFileData (fileData, getNumSamplesPerChannel(), Endianness::BigEndian); // num samples per channel
990
+ addInt16ToFileData (fileData, bitDepth, Endianness::BigEndian); // bit depth
991
+ addSampleRateToAiffData (fileData, sampleRate);
992
+
993
+ // -----------------------------------------------------------
994
+ // SSND CHUNK
995
+ addStringToFileData (fileData, "SSND");
996
+ addInt32ToFileData (fileData, soundDataChunkSize, Endianness::BigEndian);
997
+ addInt32ToFileData (fileData, 0, Endianness::BigEndian); // offset
998
+ addInt32ToFileData (fileData, 0, Endianness::BigEndian); // block size
999
+
1000
+ for (int i = 0; i < getNumSamplesPerChannel(); i++)
1001
+ {
1002
+ for (int channel = 0; channel < getNumChannels(); channel++)
1003
+ {
1004
+ if (bitDepth == 8)
1005
+ {
1006
+ uint8_t byte = sampleToSingleByte (samples[channel][i]);
1007
+ fileData.push_back (byte);
1008
+ }
1009
+ else if (bitDepth == 16)
1010
+ {
1011
+ int16_t sampleAsInt = sampleToSixteenBitInt (samples[channel][i]);
1012
+ addInt16ToFileData (fileData, sampleAsInt, Endianness::BigEndian);
1013
+ }
1014
+ else if (bitDepth == 24)
1015
+ {
1016
+ int32_t sampleAsIntAgain = (int32_t) (samples[channel][i] * (T)8388608.);
1017
+
1018
+ uint8_t bytes[3];
1019
+ bytes[0] = (uint8_t) (sampleAsIntAgain >> 16) & 0xFF;
1020
+ bytes[1] = (uint8_t) (sampleAsIntAgain >> 8) & 0xFF;
1021
+ bytes[2] = (uint8_t) sampleAsIntAgain & 0xFF;
1022
+
1023
+ fileData.push_back (bytes[0]);
1024
+ fileData.push_back (bytes[1]);
1025
+ fileData.push_back (bytes[2]);
1026
+ }
1027
+ else if (bitDepth == 32)
1028
+ {
1029
+ // write samples as signed integers (no implementation yet for floating point, but looking at WAV implementation should help)
1030
+ int32_t sampleAsInt = (int32_t) (samples[channel][i] * std::numeric_limits<int32_t>::max());
1031
+ addInt32ToFileData (fileData, sampleAsInt, Endianness::BigEndian);
1032
+ }
1033
+ else
1034
+ {
1035
+ assert (false && "Trying to write a file with unsupported bit depth");
1036
+ return false;
1037
+ }
1038
+ }
1039
+ }
1040
+
1041
+ // -----------------------------------------------------------
1042
+ // iXML CHUNK
1043
+ if (iXMLChunkSize > 0)
1044
+ {
1045
+ addStringToFileData (fileData, "iXML");
1046
+ addInt32ToFileData (fileData, iXMLChunkSize, Endianness::BigEndian);
1047
+ addStringToFileData (fileData, iXMLChunk);
1048
+ }
1049
+
1050
+ // check that the various sizes we put in the metadata are correct
1051
+ if (fileSizeInBytes != static_cast<int32_t> (fileData.size() - 8) || soundDataChunkSize != getNumSamplesPerChannel() * numBytesPerFrame + 8)
1052
+ {
1053
+ reportError ("ERROR: couldn't save file to " + filePath);
1054
+ return false;
1055
+ }
1056
+
1057
+ // try to write the file
1058
+ return writeDataToFile (fileData, filePath);
1059
+ }
1060
+
1061
+ //=============================================================
1062
+ template <class T>
1063
+ bool AudioFile<T>::writeDataToFile (std::vector<uint8_t>& fileData, std::string filePath)
1064
+ {
1065
+ std::ofstream outputFile (filePath, std::ios::binary);
1066
+
1067
+ if (outputFile.is_open())
1068
+ {
1069
+ for (size_t i = 0; i < fileData.size(); i++)
1070
+ {
1071
+ char value = (char) fileData[i];
1072
+ outputFile.write (&value, sizeof (char));
1073
+ }
1074
+
1075
+ outputFile.close();
1076
+
1077
+ return true;
1078
+ }
1079
+
1080
+ return false;
1081
+ }
1082
+
1083
+ //=============================================================
1084
+ template <class T>
1085
+ void AudioFile<T>::addStringToFileData (std::vector<uint8_t>& fileData, std::string s)
1086
+ {
1087
+ for (size_t i = 0; i < s.length();i++)
1088
+ fileData.push_back ((uint8_t) s[i]);
1089
+ }
1090
+
1091
+ //=============================================================
1092
+ template <class T>
1093
+ void AudioFile<T>::addInt32ToFileData (std::vector<uint8_t>& fileData, int32_t i, Endianness endianness)
1094
+ {
1095
+ uint8_t bytes[4];
1096
+
1097
+ if (endianness == Endianness::LittleEndian)
1098
+ {
1099
+ bytes[3] = (i >> 24) & 0xFF;
1100
+ bytes[2] = (i >> 16) & 0xFF;
1101
+ bytes[1] = (i >> 8) & 0xFF;
1102
+ bytes[0] = i & 0xFF;
1103
+ }
1104
+ else
1105
+ {
1106
+ bytes[0] = (i >> 24) & 0xFF;
1107
+ bytes[1] = (i >> 16) & 0xFF;
1108
+ bytes[2] = (i >> 8) & 0xFF;
1109
+ bytes[3] = i & 0xFF;
1110
+ }
1111
+
1112
+ for (int i = 0; i < 4; i++)
1113
+ fileData.push_back (bytes[i]);
1114
+ }
1115
+
1116
+ //=============================================================
1117
+ template <class T>
1118
+ void AudioFile<T>::addInt16ToFileData (std::vector<uint8_t>& fileData, int16_t i, Endianness endianness)
1119
+ {
1120
+ uint8_t bytes[2];
1121
+
1122
+ if (endianness == Endianness::LittleEndian)
1123
+ {
1124
+ bytes[1] = (i >> 8) & 0xFF;
1125
+ bytes[0] = i & 0xFF;
1126
+ }
1127
+ else
1128
+ {
1129
+ bytes[0] = (i >> 8) & 0xFF;
1130
+ bytes[1] = i & 0xFF;
1131
+ }
1132
+
1133
+ fileData.push_back (bytes[0]);
1134
+ fileData.push_back (bytes[1]);
1135
+ }
1136
+
1137
+ //=============================================================
1138
+ template <class T>
1139
+ void AudioFile<T>::clearAudioBuffer()
1140
+ {
1141
+ for (size_t i = 0; i < samples.size();i++)
1142
+ {
1143
+ samples[i].clear();
1144
+ }
1145
+
1146
+ samples.clear();
1147
+ }
1148
+
1149
+ //=============================================================
1150
+ template <class T>
1151
+ AudioFileFormat AudioFile<T>::determineAudioFileFormat (std::vector<uint8_t>& fileData)
1152
+ {
1153
+ std::string header (fileData.begin(), fileData.begin() + 4);
1154
+
1155
+ if (header == "RIFF")
1156
+ return AudioFileFormat::Wave;
1157
+ else if (header == "FORM")
1158
+ return AudioFileFormat::Aiff;
1159
+ else
1160
+ return AudioFileFormat::Error;
1161
+ }
1162
+
1163
+ //=============================================================
1164
+ template <class T>
1165
+ int32_t AudioFile<T>::fourBytesToInt (std::vector<uint8_t>& source, int startIndex, Endianness endianness)
1166
+ {
1167
+ int32_t result;
1168
+
1169
+ if (endianness == Endianness::LittleEndian)
1170
+ result = (source[startIndex + 3] << 24) | (source[startIndex + 2] << 16) | (source[startIndex + 1] << 8) | source[startIndex];
1171
+ else
1172
+ result = (source[startIndex] << 24) | (source[startIndex + 1] << 16) | (source[startIndex + 2] << 8) | source[startIndex + 3];
1173
+
1174
+ return result;
1175
+ }
1176
+
1177
+ //=============================================================
1178
+ template <class T>
1179
+ int16_t AudioFile<T>::twoBytesToInt (std::vector<uint8_t>& source, int startIndex, Endianness endianness)
1180
+ {
1181
+ int16_t result;
1182
+
1183
+ if (endianness == Endianness::LittleEndian)
1184
+ result = (source[startIndex + 1] << 8) | source[startIndex];
1185
+ else
1186
+ result = (source[startIndex] << 8) | source[startIndex + 1];
1187
+
1188
+ return result;
1189
+ }
1190
+
1191
+ //=============================================================
1192
+ template <class T>
1193
+ int AudioFile<T>::getIndexOfString (std::vector<uint8_t>& source, std::string stringToSearchFor)
1194
+ {
1195
+ int index = -1;
1196
+ int stringLength = (int)stringToSearchFor.length();
1197
+
1198
+ for (size_t i = 0; i < source.size() - stringLength;i++)
1199
+ {
1200
+ std::string section (source.begin() + i, source.begin() + i + stringLength);
1201
+
1202
+ if (section == stringToSearchFor)
1203
+ {
1204
+ index = static_cast<int> (i);
1205
+ break;
1206
+ }
1207
+ }
1208
+
1209
+ return index;
1210
+ }
1211
+
1212
+ //=============================================================
1213
+ template <class T>
1214
+ int AudioFile<T>::getIndexOfChunk (std::vector<uint8_t>& source, const std::string& chunkHeaderID, int startIndex, Endianness endianness)
1215
+ {
1216
+ constexpr int dataLen = 4;
1217
+ if (chunkHeaderID.size() != dataLen)
1218
+ {
1219
+ assert (false && "Invalid chunk header ID string");
1220
+ return -1;
1221
+ }
1222
+
1223
+ int i = startIndex;
1224
+ while (i < source.size() - dataLen)
1225
+ {
1226
+ if (memcmp (&source[i], chunkHeaderID.data(), dataLen) == 0)
1227
+ {
1228
+ return i;
1229
+ }
1230
+
1231
+ i += dataLen;
1232
+ auto chunkSize = fourBytesToInt (source, i, endianness);
1233
+ i += (dataLen + chunkSize);
1234
+ }
1235
+
1236
+ return -1;
1237
+ }
1238
+
1239
+ //=============================================================
1240
+ template <class T>
1241
+ T AudioFile<T>::sixteenBitIntToSample (int16_t sample)
1242
+ {
1243
+ return static_cast<T> (sample) / static_cast<T> (32768.);
1244
+ }
1245
+
1246
+ //=============================================================
1247
+ template <class T>
1248
+ int16_t AudioFile<T>::sampleToSixteenBitInt (T sample)
1249
+ {
1250
+ sample = clamp (sample, -1., 1.);
1251
+ return static_cast<int16_t> (sample * 32767.);
1252
+ }
1253
+
1254
+ //=============================================================
1255
+ template <class T>
1256
+ uint8_t AudioFile<T>::sampleToSingleByte (T sample)
1257
+ {
1258
+ sample = clamp (sample, -1., 1.);
1259
+ sample = (sample + 1.) / 2.;
1260
+ return static_cast<uint8_t> (sample * 255.);
1261
+ }
1262
+
1263
+ //=============================================================
1264
+ template <class T>
1265
+ T AudioFile<T>::singleByteToSample (uint8_t sample)
1266
+ {
1267
+ return static_cast<T> (sample - 128) / static_cast<T> (128.);
1268
+ }
1269
+
1270
+ //=============================================================
1271
+ template <class T>
1272
+ T AudioFile<T>::clamp (T value, T minValue, T maxValue)
1273
+ {
1274
+ value = std::min (value, maxValue);
1275
+ value = std::max (value, minValue);
1276
+ return value;
1277
+ }
1278
+
1279
+ //=============================================================
1280
+ template <class T>
1281
+ void AudioFile<T>::reportError (std::string errorMessage)
1282
+ {
1283
+ if (logErrorsToConsole)
1284
+ std::cout << errorMessage << std::endl;
1285
+ }
1286
+
1287
+ #if defined (_MSC_VER)
1288
+ __pragma(warning (pop))
1289
+ #elif defined (__GNUC__)
1290
+ _Pragma("GCC diagnostic pop")
1291
+ #endif
1292
+
1293
+ #endif /* AudioFile_h */
cpp/src/DecoderLoop.hpp ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**************************************************************************************************
2
+ *
3
+ * Copyright (c) 2019-2023 Axera Semiconductor (Ningbo) Co., Ltd. All Rights Reserved.
4
+ *
5
+ * This source file is the property of Axera Semiconductor (Ningbo) Co., Ltd. and
6
+ * may not be copied or distributed in any isomorphic form without the prior
7
+ * written consent of Axera Semiconductor (Ningbo) Co., Ltd.
8
+ *
9
+ **************************************************************************************************/
10
+
11
+ #pragma once
12
+
13
+ #include "EngineWrapper.hpp"
14
+
15
+ class DecoderLoop : public EngineWrapper {
16
+ public:
17
+ DecoderLoop() = default;
18
+ ~DecoderLoop() = default;
19
+
20
+ // int Run() {
21
+ // int ret = 0;
22
+ // ret = this->Run();
23
+ // if (ret) {
24
+ // return ret;
25
+ // }
26
+
27
+ // // ret = SetInput(GetOutputPtr(1), 1);
28
+ // // if (ret) {
29
+ // // return ret;
30
+ // // }
31
+
32
+ // // ret = SetInput(GetOutputPtr(2), 2);
33
+ // // if (ret) {
34
+ // // return ret;
35
+ // // }
36
+
37
+ // return ret;
38
+ // }
39
+ };
cpp/src/DecoderMain.hpp ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**************************************************************************************************
2
+ *
3
+ * Copyright (c) 2019-2023 Axera Semiconductor (Ningbo) Co., Ltd. All Rights Reserved.
4
+ *
5
+ * This source file is the property of Axera Semiconductor (Ningbo) Co., Ltd. and
6
+ * may not be copied or distributed in any isomorphic form without the prior
7
+ * written consent of Axera Semiconductor (Ningbo) Co., Ltd.
8
+ *
9
+ **************************************************************************************************/
10
+
11
+ #pragma once
12
+
13
+ #include "EngineWrapper.hpp"
14
+
15
+ class DecoderMain : public EngineWrapper {
16
+ public:
17
+ DecoderMain() = default;
18
+ ~DecoderMain() = default;
19
+ };
cpp/src/Encoder.hpp ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**************************************************************************************************
2
+ *
3
+ * Copyright (c) 2019-2023 Axera Semiconductor (Ningbo) Co., Ltd. All Rights Reserved.
4
+ *
5
+ * This source file is the property of Axera Semiconductor (Ningbo) Co., Ltd. and
6
+ * may not be copied or distributed in any isomorphic form without the prior
7
+ * written consent of Axera Semiconductor (Ningbo) Co., Ltd.
8
+ *
9
+ **************************************************************************************************/
10
+
11
+ #pragma once
12
+
13
+ #include <vector>
14
+ #include "EngineWrapper.hpp"
15
+
16
+ class Encoder : public EngineWrapper {
17
+ public:
18
+ Encoder() = default;
19
+ ~Encoder() = default;
20
+ };
cpp/src/EngineWrapper.cpp ADDED
@@ -0,0 +1,351 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**************************************************************************************************
2
+ *
3
+ * Copyright (c) 2019-2023 Axera Semiconductor (Ningbo) Co., Ltd. All Rights Reserved.
4
+ *
5
+ * This source file is the property of Axera Semiconductor (Ningbo) Co., Ltd. and
6
+ * may not be copied or distributed in any isomorphic form without the prior
7
+ * written consent of Axera Semiconductor (Ningbo) Co., Ltd.
8
+ *
9
+ **************************************************************************************************/
10
+ #include "EngineWrapper.hpp"
11
+ #include "utils/io.hpp"
12
+
13
+ #include <cstdlib>
14
+
15
+ #if defined(CHIP_AX650)
16
+ static const char *strAlgoModelType[AX_ENGINE_MODEL_TYPE_BUTT] = {"3.6T", "7.2T", "18T"};
17
+ #endif
18
+
19
+ #if defined(CHIP_AX630C) || defined(CHIP_AX620Q)
20
+ static const char *strAlgoModelType[AX_ENGINE_MODEL_TYPE_BUTT] = {"HalfOCM", "FullOCM"};
21
+ #endif
22
+
23
+
24
+ /// @brief npu type
25
+ typedef enum axNPU_TYPE_E {
26
+ AX_NPU_DEFAULT = 0, /* running under default NPU according to system */
27
+ AX_STD_VNPU_1 = (1 << 0), /* running under STD VNPU1 */
28
+ AX_STD_VNPU_2 = (1 << 1), /* running under STD VNPU2 */
29
+ AX_STD_VNPU_3 = (1 << 2), /* running under STD VNPU3 */
30
+ AX_BL_VNPU_1 = (1 << 3), /* running under BIG-LITTLE VNPU1 */
31
+ AX_BL_VNPU_2 = (1 << 4) /* running under BIG-LITTLE VNPU2 */
32
+ } AX_NPU_TYPE_E;
33
+
34
+ #if defined(CHIP_AX650)
35
+ static AX_S32 CheckModelVNpu(const std::string &strModel, const AX_ENGINE_MODEL_TYPE_T &eModelType, const AX_S32 &nNpuType, AX_U32 &nNpuSet) {
36
+ AX_ENGINE_NPU_ATTR_T stNpuAttr;
37
+ memset(&stNpuAttr, 0x00, sizeof(stNpuAttr));
38
+
39
+ auto ret = AX_ENGINE_GetVNPUAttr(&stNpuAttr);
40
+ if (ret == 0) {
41
+ // VNPU DISABLE
42
+ if (stNpuAttr.eHardMode == AX_ENGINE_VIRTUAL_NPU_DISABLE) {
43
+ nNpuSet = 0x01; // NON-VNPU (0b111)
44
+ // printf("%s will run under VNPU-DISABLE [%s]\n", strModel.c_str(), strAlgoModelType[eModelType]);
45
+ }
46
+ // STD VNPU
47
+ else if (stNpuAttr.eHardMode == AX_ENGINE_VIRTUAL_NPU_STD) {
48
+ // 7.2T & 10.8T no allow
49
+ if (eModelType == AX_ENGINE_MODEL_TYPE1
50
+ || eModelType == AX_ENGINE_MODEL_TYPE2) {
51
+ // printf("%s model type%d: [%s], no allow run under STD VNPU\n", strModel.c_str(), eModelType, strAlgoModelType[eModelType]);
52
+ return -1;
53
+ }
54
+
55
+ // default STD VNPU2
56
+ if (nNpuType == 0) {
57
+ nNpuSet = 0x02; // VNPU2 (0b010)
58
+ // printf("%s will run under default STD-VNPU2 [%s]\n", strModel.c_str(), strAlgoModelType[eModelType]);
59
+ }
60
+ else {
61
+ if (nNpuType & AX_STD_VNPU_1) {
62
+ nNpuSet |= 0x01; // VNPU1 (0b001)
63
+ // printf("%s will run under STD-VNPU1 [%s]\n", strModel.c_str(), strAlgoModelType[eModelType]);
64
+ }
65
+ if (nNpuType & AX_STD_VNPU_2) {
66
+ nNpuSet |= 0x02; // VNPU2 (0b010)
67
+ // printf("%s will run under STD-VNPU2 [%s]\n", strModel.c_str(), strAlgoModelType[eModelType]);
68
+ }
69
+ if (nNpuType & AX_STD_VNPU_3) {
70
+ nNpuSet |= 0x04; // VNPU3 (0b100)
71
+ // printf("%s will run under STD-VNPU3 [%s]\n", strModel.c_str(), strAlgoModelType[eModelType]);
72
+ }
73
+ }
74
+ }
75
+ // BL VNPU
76
+ else if (stNpuAttr.eHardMode == AX_ENGINE_VIRTUAL_NPU_BIG_LITTLE) {
77
+ // 10.8T no allow
78
+ if (eModelType == AX_ENGINE_MODEL_TYPE2) {
79
+ // printf("%s model type%d: [%s], no allow run under BL VNPU\n", strModel.c_str(), eModelType, strAlgoModelType[eModelType]);
80
+ return -1;
81
+ }
82
+
83
+ // default BL VNPU
84
+ if (nNpuType == 0) {
85
+ // 7.2T default BL VNPU1
86
+ if (eModelType == AX_ENGINE_MODEL_TYPE1) {
87
+ nNpuSet = 0x01; // VNPU1 (0b001)
88
+ // printf("%s will run under default BL-VNPU1 [%s]\n", strModel.c_str(), strAlgoModelType[eModelType]);
89
+ }
90
+ // 3.6T default BL VNPU2
91
+ else {
92
+ nNpuSet = 0x02; // VNPU2 (0b010)
93
+ // printf("%s will run under default BL-VNPU2 [%s]\n", strModel.c_str(), strAlgoModelType[eModelType]);
94
+ }
95
+ }
96
+ else {
97
+ // 7.2T
98
+ if (eModelType == AX_ENGINE_MODEL_TYPE1) {
99
+ // no allow set to BL VNPU2
100
+ if (nNpuType & AX_BL_VNPU_2) {
101
+ // printf("%s model type%d: [%s], no allow run under BL VNPU2\n", strModel.c_str(), eModelType, strAlgoModelType[eModelType]);
102
+ return -1;
103
+ }
104
+ if (nNpuType & AX_BL_VNPU_1) {
105
+ nNpuSet |= 0x01; // VNPU1 (0b001)
106
+ // printf("%s will run under BL-VNPU1 [%s]\n", strModel.c_str(), strAlgoModelType[eModelType]);
107
+ }
108
+ }
109
+ // 3.6T
110
+ else {
111
+ if (nNpuType & AX_BL_VNPU_1) {
112
+ nNpuSet |= 0x01; // VNPU1 (0b001)
113
+ // printf("%s will run under BL-VNPU1 [%s]\n", strModel.c_str(), strAlgoModelType[eModelType]);
114
+ }
115
+ if (nNpuType & AX_BL_VNPU_2) {
116
+ nNpuSet |= 0x02; // VNPU2 (0b010)
117
+ // printf("%s will run under BL-VNPU2 [%s]\n", strModel.c_str(), strAlgoModelType[eModelType]);
118
+ }
119
+ }
120
+ }
121
+ }
122
+ }
123
+ else {
124
+ printf("AX_ENGINE_GetVNPUAttr fail ret = %x\n", ret);
125
+ }
126
+
127
+ return ret;
128
+ }
129
+ #endif
130
+
131
+ #if defined(CHIP_AX630C) || defined(CHIP_AX620Q)
132
+ static AX_S32 CheckModelVNpu(const std::string &strModel, const AX_ENGINE_MODEL_TYPE_T &eModelType, const AX_S32 &nNpuType, AX_U32 &nNpuSet) {
133
+ AX_ENGINE_NPU_ATTR_T stNpuAttr;
134
+ memset(&stNpuAttr, 0x00, sizeof(stNpuAttr));
135
+
136
+ auto ret = AX_ENGINE_GetVNPUAttr(&stNpuAttr);
137
+ if (ret == 0) {
138
+ // VNPU DISABLE
139
+ if (stNpuAttr.eHardMode == AX_ENGINE_VIRTUAL_NPU_DISABLE) {
140
+ nNpuSet = 0x01; // NON-VNPU (0b111)
141
+ // ALOGN("%s will run under VNPU-DISABLE [%s]", strModel.c_str(), strAlgoModelType[eModelType]);
142
+ }
143
+ // STD VNPU
144
+ else if (stNpuAttr.eHardMode == AX_ENGINE_VIRTUAL_NPU_ENABLE) {
145
+ // full ocm model was no allowned
146
+ if (eModelType == AX_ENGINE_MODEL_TYPE1) {
147
+ // printf("%s model type%d: [%s], no allow run under STD VNPU", strModel.c_str(), eModelType, strAlgoModelType[eModelType]);
148
+ return -1;
149
+ }
150
+
151
+ // default STD VNPU2
152
+ if (nNpuType == 0) {
153
+ nNpuSet = 0x02; // VNPU2 (0b010)
154
+ // printf("%s will run under default STD-VNPU2 [%s]", strModel.c_str(), strAlgoModelType[eModelType]);
155
+ }
156
+ else {
157
+ if (nNpuType & AX_STD_VNPU_1) {
158
+ nNpuSet |= 0x01; // VNPU1 (0b001)
159
+ // printf("%s will run under STD-VNPU1 [%s]", strModel.c_str(), strAlgoModelType[eModelType]);
160
+ }
161
+ if (nNpuType & AX_STD_VNPU_2) {
162
+ nNpuSet |= 0x02; // VNPU2 (0b010)
163
+ // printf("%s will run under STD-VNPU2 [%s]", strModel.c_str(), strAlgoModelType[eModelType]);
164
+ }
165
+ }
166
+ }
167
+ }
168
+ else {
169
+ printf("AX_ENGINE_GetVNPUAttr fail ret = %x", ret);
170
+ }
171
+
172
+ return ret;
173
+ }
174
+ #endif
175
+
176
+
177
+ int EngineWrapper::Init(const char* strModelPath, uint32_t nNpuType)
178
+ {
179
+ AX_S32 ret = 0;
180
+
181
+ // 1. load model
182
+ AX_BOOL bLoadModelUseCmm = AX_TRUE;
183
+ AX_CHAR *pModelBufferVirAddr = nullptr;
184
+ AX_U64 u64ModelBufferPhyAddr = 0;
185
+ AX_U32 nModelBufferSize = 0;
186
+
187
+ std::vector<char> model_buffer;
188
+
189
+ if (bLoadModelUseCmm) {
190
+ if (!utils::read_file(strModelPath, (AX_VOID **)&pModelBufferVirAddr, u64ModelBufferPhyAddr, nModelBufferSize)) {
191
+ printf("read model(%s) use cmm fail\n", strModelPath);
192
+ return -1;
193
+ }
194
+ }
195
+ else {
196
+ if (!utils::read_file(strModelPath, model_buffer)) {
197
+ printf("read model(%s) fail\n", strModelPath);
198
+ return -1;
199
+ }
200
+
201
+ pModelBufferVirAddr = model_buffer.data();
202
+ nModelBufferSize = model_buffer.size();
203
+ }
204
+
205
+ auto freeModelBuffer = [&]() {
206
+ if (bLoadModelUseCmm) {
207
+ if (u64ModelBufferPhyAddr != 0) {
208
+ AX_SYS_MemFree(u64ModelBufferPhyAddr, &pModelBufferVirAddr);
209
+ }
210
+ }
211
+ else {
212
+ std::vector<char>().swap(model_buffer);
213
+ }
214
+ return;
215
+ };
216
+
217
+ // 1.1 Get Model Type
218
+ AX_ENGINE_MODEL_TYPE_T eModelType = AX_ENGINE_MODEL_TYPE2;
219
+ ret = AX_ENGINE_GetModelType(pModelBufferVirAddr, nModelBufferSize, &eModelType);
220
+ if (0 != ret) {
221
+ printf("%s AX_ENGINE_GetModelType fail ret=%d, eModelType=%d\n", strModelPath, ret, eModelType);
222
+ freeModelBuffer();
223
+ return -1;
224
+ }
225
+
226
+ // 1.2 Check VNPU
227
+ AX_ENGINE_NPU_SET_T nNpuSet = 0;
228
+ ret = CheckModelVNpu(strModelPath, eModelType, nNpuType, nNpuSet);
229
+ if (0 != ret) {
230
+ printf("CheckModelVNpu fail\n");
231
+ freeModelBuffer();
232
+ return -1;
233
+ }
234
+
235
+ // 2. create handle
236
+ AX_ENGINE_HANDLE handle = nullptr;
237
+ ret = AX_ENGINE_CreateHandle(&handle, pModelBufferVirAddr, nModelBufferSize);
238
+ auto deinit_handle = [&handle]() {
239
+ if (handle) {
240
+ AX_ENGINE_DestroyHandle(handle);
241
+ }
242
+ return -1;
243
+ };
244
+
245
+ freeModelBuffer();
246
+
247
+ if (0 != ret || !handle) {
248
+ printf("Create model(%s) handle fail\n", strModelPath);
249
+
250
+ return deinit_handle();
251
+ }
252
+
253
+ // 3. create context
254
+ ret = AX_ENGINE_CreateContext(handle);
255
+ if (0 != ret) {
256
+ return deinit_handle();
257
+ }
258
+
259
+ // 4. set io
260
+ m_io_info = nullptr;
261
+ ret = AX_ENGINE_GetIOInfo(handle, &m_io_info);
262
+ if (0 != ret) {
263
+ return deinit_handle();
264
+ }
265
+ m_input_num = m_io_info->nInputSize;
266
+ m_output_num = m_io_info->nOutputSize;
267
+
268
+ // 4.1 query io
269
+ // AX_IMG_FORMAT_E eDtype;
270
+ // ret = utils::query_model_input_size(m_io_info, m_input_size, eDtype);//FIXME.
271
+ // if (0 != ret) {
272
+ // printf("model(%s) query model input size fail\n", strModelPath.c_str());
273
+ // return deinit_handle();
274
+ // }
275
+
276
+ // if (!(eDtype == AX_FORMAT_YUV420_SEMIPLANAR || eDtype == AX_FORMAT_YUV420_SEMIPLANAR_VU ||
277
+ // eDtype == AX_FORMAT_RGB888 || eDtype == AX_FORMAT_BGR888)) {
278
+ // printf("model(%s) data type is: 0x%02X, unsupport\n", strModelPath, eDtype);
279
+ // return deinit_handle();
280
+ // }
281
+
282
+ // 4.2 brief io
283
+ #ifdef __DEBUG__
284
+ printf("brief_io_info\n");
285
+ utils::brief_io_info(strModelPath, m_io_info);
286
+ #endif
287
+
288
+ //5. Config VNPU
289
+ // printf("model(%s) nNpuSet: 0x%08X\n", strModelPath.c_str(), nNpuSet);
290
+ // will do nothing for using create handle v2 api
291
+
292
+ // 6. prepare io
293
+ // AX_U32 nIoDepth = (stCtx.vecOutputBufferFlag.size() == 0) ? 1 : stCtx.vecOutputBufferFlag.size();
294
+ ret = utils::prepare_io(strModelPath, m_io_info, m_io, utils::IO_BUFFER_STRATEGY_CACHED);
295
+ if (0 != ret) {
296
+ printf("prepare io failed!\n");
297
+ utils::free_io(m_io);
298
+ return deinit_handle();
299
+ }
300
+
301
+ m_handle = handle;
302
+ m_hasInit = true;
303
+
304
+ return 0;
305
+ }
306
+
307
+ int EngineWrapper::SetInput(void* pInput, int index) {
308
+ return utils::push_io_input(pInput, index, m_io);
309
+ }
310
+
311
+ int EngineWrapper::Run()
312
+ {
313
+ if (!m_hasInit)
314
+ return -1;
315
+
316
+ // 7.3 run & benchmark
317
+ auto ret = AX_ENGINE_RunSync(m_handle, &m_io);
318
+ if (0 != ret) {
319
+ printf("AX_ENGINE_RunSync failed. ret=0x%x\n", ret);
320
+ return ret;
321
+ }
322
+
323
+ return 0;
324
+ }
325
+
326
+ int EngineWrapper::GetOutput(void* pOutput, int index) {
327
+ return utils::push_io_output(pOutput, index, m_io);
328
+ }
329
+
330
+ int EngineWrapper::GetInputSize(int index) {
331
+ return m_io.pInputs[index].nSize;
332
+ }
333
+
334
+ int EngineWrapper::GetOutputSize(int index) {
335
+ return m_io.pOutputs[index].nSize;
336
+ }
337
+
338
+ void* EngineWrapper::GetOutputPtr(int index) {
339
+ utils::cache_io_flush(&m_io.pOutputs[index]);
340
+ return m_io.pOutputs[index].pVirAddr;
341
+ }
342
+
343
+ int EngineWrapper::Release()
344
+ {
345
+ if (m_handle) {
346
+ utils::free_io(m_io);
347
+ AX_ENGINE_DestroyHandle(m_handle);
348
+ m_handle = nullptr;
349
+ }
350
+ return 0;
351
+ }
cpp/src/EngineWrapper.hpp ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**************************************************************************************************
2
+ *
3
+ * Copyright (c) 2019-2023 Axera Semiconductor (Ningbo) Co., Ltd. All Rights Reserved.
4
+ *
5
+ * This source file is the property of Axera Semiconductor (Ningbo) Co., Ltd. and
6
+ * may not be copied or distributed in any isomorphic form without the prior
7
+ * written consent of Axera Semiconductor (Ningbo) Co., Ltd.
8
+ *
9
+ **************************************************************************************************/
10
+
11
+ #pragma once
12
+
13
+ #include <string>
14
+ #include <vector>
15
+ #include <cstring>
16
+ #include <array>
17
+ #include <cstdint>
18
+
19
+ #include "ax_engine_api.h"
20
+
21
+
22
+ class EngineWrapper {
23
+ public:
24
+ EngineWrapper() :
25
+ m_hasInit(false),
26
+ m_handle(nullptr) {}
27
+
28
+ virtual ~EngineWrapper() {
29
+ Release();
30
+ }
31
+
32
+ int Init(const char* strModelPath, uint32_t nNpuType = 0);
33
+
34
+ int SetInput(void* pInput, int index);
35
+
36
+ int Run();
37
+
38
+ int GetOutput(void* pOutput, int index);
39
+
40
+ int GetInputSize(int index);
41
+ int GetOutputSize(int index);
42
+
43
+ void* GetOutputPtr(int index);
44
+
45
+ int Release();
46
+
47
+ protected:
48
+ bool m_hasInit;
49
+ AX_ENGINE_HANDLE m_handle;
50
+ AX_ENGINE_IO_INFO_T *m_io_info{};
51
+ AX_ENGINE_IO_T m_io{};
52
+ int m_input_num{}, m_output_num{};
53
+ };
cpp/src/base64.cpp ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #include "base64.h"
2
+
3
+ static uint8 alphabet_map[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
4
+ static uint8 reverse_map[] =
5
+ {
6
+ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
7
+ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
8
+ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 255, 255, 255, 63,
9
+ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, 255, 255, 255, 255,
10
+ 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
11
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 255, 255, 255, 255, 255,
12
+ 255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
13
+ 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 255, 255, 255, 255, 255
14
+ };
15
+
16
+ // //GB2312到UTF-8的转换
17
+ // char* G2U(const char* gb2312)
18
+ // {
19
+ // int len = MultiByteToWideChar(CP_ACP, 0, gb2312, -1, NULL, 0);
20
+ // wchar_t* wstr = new wchar_t[len + 1];
21
+ // memset(wstr, 0, len + 1);
22
+ // MultiByteToWideChar(CP_ACP, 0, gb2312, -1, wstr, len);
23
+ // len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL);
24
+ // char* str = new char[len + 1];
25
+ // memset(str, 0, len + 1);
26
+ // WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, len, NULL, NULL);
27
+ // if (wstr) delete[] wstr;
28
+ // return str;
29
+ // }
30
+ // //UTF-8到GB2312的转换
31
+ // char* U2G(const char* utf8)
32
+ // {
33
+ // int len = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, NULL, 0);
34
+ // wchar_t* wstr = new wchar_t[len + 1];
35
+ // memset(wstr, 0, len + 1);
36
+ // MultiByteToWideChar(CP_UTF8, 0, utf8, -1, wstr, len);
37
+ // len = WideCharToMultiByte(CP_ACP, 0, wstr, -1, NULL, 0, NULL, NULL);
38
+ // char* str = new char[len + 1];
39
+ // memset(str, 0, len + 1);
40
+ // WideCharToMultiByte(CP_ACP, 0, wstr, -1, str, len, NULL, NULL);
41
+ // if (wstr) delete[] wstr;
42
+ // return str;
43
+ // }
44
+
45
+ // uint32 base64_encode(char* input, uint8* encode)
46
+ // {
47
+ // //1、包含中文的字符串 字符编码(windows默认是gbk)转换成unicode
48
+
49
+ // //2、字符编码方式是utf-8的二进制
50
+ // // uint8* text = (uint8*)G2U(input);
51
+ // uint32 text_len = (uint32)strlen((char*)input);
52
+
53
+ // uint32 i, j;
54
+ // for (i = 0, j = 0; i + 3 <= text_len; i += 3)
55
+ // {
56
+ // encode[j++] = alphabet_map[text[i] >> 2]; //取出第一个字符的前6位并找出对应的结果字符
57
+ // encode[j++] = alphabet_map[((text[i] << 4) & 0x30) | (text[i + 1] >> 4)]; //将第一个字符的后2位与第二个字符的前4位进行组合并找到对应的结果字符
58
+ // encode[j++] = alphabet_map[((text[i + 1] << 2) & 0x3c) | (text[i + 2] >> 6)]; //将第二个字符的后4位与第三个字符的前2位组合并找出对应的结果字符
59
+ // encode[j++] = alphabet_map[text[i + 2] & 0x3f]; //取出第三个字符的后6位并找出结果字符
60
+ // }
61
+
62
+ // if (i < text_len)
63
+ // {
64
+ // uint32 tail = text_len - i;
65
+ // if (tail == 1)
66
+ // {
67
+ // encode[j++] = alphabet_map[text[i] >> 2];
68
+ // encode[j++] = alphabet_map[(text[i] << 4) & 0x30];
69
+ // encode[j++] = '=';
70
+ // encode[j++] = '=';
71
+ // }
72
+ // else //tail==2
73
+ // {
74
+ // encode[j++] = alphabet_map[text[i] >> 2];
75
+ // encode[j++] = alphabet_map[((text[i] << 4) & 0x30) | (text[i + 1] >> 4)];
76
+ // encode[j++] = alphabet_map[(text[i + 1] << 2) & 0x3c];
77
+ // encode[j++] = '=';
78
+ // }
79
+ // }
80
+ // encode[j] = 0;
81
+ // return j;
82
+ // }
83
+
84
+ int base64_decode(const uint8* code, uint32 code_len, char* str)
85
+ {
86
+ uint8 plain[1024];
87
+ assert((code_len & 0x03) == 0); //如果它的条件返回错误,则终止程序执行。4的倍数。
88
+
89
+ uint32 i, j = 0;
90
+ uint8 quad[4];
91
+ for (i = 0; i < code_len; i += 4)
92
+ {
93
+ for (uint32 k = 0; k < 4; k++)
94
+ {
95
+ quad[k] = reverse_map[code[i + k]];//分组,每组四个分别依次转换为base64表内的十进制数
96
+ }
97
+
98
+ assert(quad[0] < 64 && quad[1] < 64);
99
+
100
+ plain[j++] = (quad[0] << 2) | (quad[1] >> 4); //取出第一个字符对应base64表的十进制数的前6位与第二个字符对应base64表的十进制数的前2位进行组合
101
+
102
+ if (quad[2] >= 64)
103
+ break;
104
+ else if (quad[3] >= 64)
105
+ {
106
+ plain[j++] = (quad[1] << 4) | (quad[2] >> 2); //取出第二个字符对应base64表的十进制数的后4位与第三个字符对应base64表的十进制数的前4位进行组合
107
+ break;
108
+ }
109
+ else
110
+ {
111
+ plain[j++] = (quad[1] << 4) | (quad[2] >> 2);
112
+ plain[j++] = (quad[2] << 6) | quad[3];//取出第三个字符对应base64表的十进制数的后2位与第4个字符进行组合
113
+ }
114
+ }
115
+ plain[j] = 0;
116
+ // char str[1024] = "";
117
+ strcpy(str, (char*)plain);
118
+ // strcpy_s(str, sizeof(plain), U2G(str));
119
+ return j;
120
+ }
cpp/src/base64.h ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pragma once
2
+
3
+ #include <string.h>
4
+ #include <stdlib.h>
5
+ #include <wchar.h>
6
+ #include <assert.h>
7
+ #include <iostream>
8
+ typedef unsigned char uint8;
9
+ typedef unsigned long uint32;
10
+ // uint32 base64_encode(char* input, uint8* encode);
11
+ int base64_decode(const uint8* code, uint32 code_len, char* str);
cpp/src/cmdline.hpp ADDED
@@ -0,0 +1,732 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright (c) 2009, Hideyuki Tanaka
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+ * Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+ * Neither the name of the <organization> nor the
13
+ names of its contributors may be used to endorse or promote products
14
+ derived from this software without specific prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY <copyright holder> ''AS IS'' AND ANY
17
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
20
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
+ */
27
+
28
+ #pragma once
29
+
30
+ #include <cxxabi.h>
31
+
32
+ #include <algorithm>
33
+ #include <cstdlib>
34
+ #include <cstring>
35
+ #include <iostream>
36
+ #include <map>
37
+ #include <sstream>
38
+ #include <stdexcept>
39
+ #include <string>
40
+ #include <typeinfo>
41
+ #include <vector>
42
+
43
+ namespace cmdline {
44
+
45
+ namespace detail {
46
+
47
+ template <typename Target, typename Source, bool Same>
48
+ class lexical_cast_t {
49
+ public:
50
+ static Target cast(const Source &arg) {
51
+ Target ret;
52
+ std::stringstream ss;
53
+ if (!(ss << arg && ss >> ret && ss.eof())) throw std::bad_cast();
54
+
55
+ return ret;
56
+ }
57
+ };
58
+
59
+ template <typename Target, typename Source>
60
+ class lexical_cast_t<Target, Source, true> {
61
+ public:
62
+ static Target cast(const Source &arg) { return arg; }
63
+ };
64
+
65
+ template <typename Source>
66
+ class lexical_cast_t<std::string, Source, false> {
67
+ public:
68
+ static std::string cast(const Source &arg) {
69
+ std::ostringstream ss;
70
+ ss << arg;
71
+ return ss.str();
72
+ }
73
+ };
74
+
75
+ template <typename Target>
76
+ class lexical_cast_t<Target, std::string, false> {
77
+ public:
78
+ static Target cast(const std::string &arg) {
79
+ Target ret;
80
+ std::istringstream ss(arg);
81
+ if (!(ss >> ret && ss.eof())) throw std::bad_cast();
82
+ return ret;
83
+ }
84
+ };
85
+
86
+ template <typename T1, typename T2>
87
+ struct is_same {
88
+ static const bool value = false;
89
+ };
90
+
91
+ template <typename T>
92
+ struct is_same<T, T> {
93
+ static const bool value = true;
94
+ };
95
+
96
+ template <typename Target, typename Source>
97
+ Target lexical_cast(const Source &arg) {
98
+ return lexical_cast_t<Target, Source,
99
+ detail::is_same<Target, Source>::value>::cast(arg);
100
+ }
101
+
102
+ static inline std::string demangle(const std::string &name) {
103
+ int status = 0;
104
+ char *p = abi::__cxa_demangle(name.c_str(), 0, 0, &status);
105
+ std::string ret(p);
106
+ free(p);
107
+ return ret;
108
+ }
109
+
110
+ template <class T>
111
+ std::string readable_typename() {
112
+ return demangle(typeid(T).name());
113
+ }
114
+
115
+ template <class T>
116
+ std::string default_value(T def) {
117
+ return detail::lexical_cast<std::string>(def);
118
+ }
119
+
120
+ template <>
121
+ inline std::string readable_typename<std::string>() {
122
+ return "string";
123
+ }
124
+
125
+ } // namespace detail
126
+
127
+ //-----
128
+
129
+ class cmdline_error : public std::exception {
130
+ public:
131
+ cmdline_error(const std::string &msg) : msg(msg) {}
132
+ ~cmdline_error() throw() {}
133
+ const char *what() const throw() { return msg.c_str(); }
134
+
135
+ private:
136
+ std::string msg;
137
+ };
138
+
139
+ template <class T>
140
+ struct default_reader {
141
+ T operator()(const std::string &str) { return detail::lexical_cast<T>(str); }
142
+ };
143
+
144
+ template <class T>
145
+ struct range_reader {
146
+ range_reader(const T &low, const T &high) : low(low), high(high) {}
147
+ T operator()(const std::string &s) const {
148
+ T ret = default_reader<T>()(s);
149
+ if (!(ret >= low && ret <= high))
150
+ throw cmdline::cmdline_error("range_error");
151
+ return ret;
152
+ }
153
+
154
+ private:
155
+ T low, high;
156
+ };
157
+
158
+ template <class T>
159
+ range_reader<T> range(const T &low, const T &high) {
160
+ return range_reader<T>(low, high);
161
+ }
162
+
163
+ template <class T>
164
+ struct oneof_reader {
165
+ T operator()(const std::string &s) {
166
+ T ret = default_reader<T>()(s);
167
+ if (std::find(alt.begin(), alt.end(), ret) == alt.end())
168
+ throw cmdline_error("");
169
+ return ret;
170
+ }
171
+ void add(const T &v) { alt.push_back(v); }
172
+
173
+ private:
174
+ std::vector<T> alt;
175
+ };
176
+
177
+ template <class T>
178
+ oneof_reader<T> oneof(T a1) {
179
+ oneof_reader<T> ret;
180
+ ret.add(a1);
181
+ return ret;
182
+ }
183
+
184
+ template <class T>
185
+ oneof_reader<T> oneof(T a1, T a2) {
186
+ oneof_reader<T> ret;
187
+ ret.add(a1);
188
+ ret.add(a2);
189
+ return ret;
190
+ }
191
+
192
+ template <class T>
193
+ oneof_reader<T> oneof(T a1, T a2, T a3) {
194
+ oneof_reader<T> ret;
195
+ ret.add(a1);
196
+ ret.add(a2);
197
+ ret.add(a3);
198
+ return ret;
199
+ }
200
+
201
+ template <class T>
202
+ oneof_reader<T> oneof(T a1, T a2, T a3, T a4) {
203
+ oneof_reader<T> ret;
204
+ ret.add(a1);
205
+ ret.add(a2);
206
+ ret.add(a3);
207
+ ret.add(a4);
208
+ return ret;
209
+ }
210
+
211
+ template <class T>
212
+ oneof_reader<T> oneof(T a1, T a2, T a3, T a4, T a5) {
213
+ oneof_reader<T> ret;
214
+ ret.add(a1);
215
+ ret.add(a2);
216
+ ret.add(a3);
217
+ ret.add(a4);
218
+ ret.add(a5);
219
+ return ret;
220
+ }
221
+
222
+ template <class T>
223
+ oneof_reader<T> oneof(T a1, T a2, T a3, T a4, T a5, T a6) {
224
+ oneof_reader<T> ret;
225
+ ret.add(a1);
226
+ ret.add(a2);
227
+ ret.add(a3);
228
+ ret.add(a4);
229
+ ret.add(a5);
230
+ ret.add(a6);
231
+ return ret;
232
+ }
233
+
234
+ template <class T>
235
+ oneof_reader<T> oneof(T a1, T a2, T a3, T a4, T a5, T a6, T a7) {
236
+ oneof_reader<T> ret;
237
+ ret.add(a1);
238
+ ret.add(a2);
239
+ ret.add(a3);
240
+ ret.add(a4);
241
+ ret.add(a5);
242
+ ret.add(a6);
243
+ ret.add(a7);
244
+ return ret;
245
+ }
246
+
247
+ template <class T>
248
+ oneof_reader<T> oneof(T a1, T a2, T a3, T a4, T a5, T a6, T a7, T a8) {
249
+ oneof_reader<T> ret;
250
+ ret.add(a1);
251
+ ret.add(a2);
252
+ ret.add(a3);
253
+ ret.add(a4);
254
+ ret.add(a5);
255
+ ret.add(a6);
256
+ ret.add(a7);
257
+ ret.add(a8);
258
+ return ret;
259
+ }
260
+
261
+ template <class T>
262
+ oneof_reader<T> oneof(T a1, T a2, T a3, T a4, T a5, T a6, T a7, T a8, T a9) {
263
+ oneof_reader<T> ret;
264
+ ret.add(a1);
265
+ ret.add(a2);
266
+ ret.add(a3);
267
+ ret.add(a4);
268
+ ret.add(a5);
269
+ ret.add(a6);
270
+ ret.add(a7);
271
+ ret.add(a8);
272
+ ret.add(a9);
273
+ return ret;
274
+ }
275
+
276
+ template <class T>
277
+ oneof_reader<T> oneof(T a1, T a2, T a3, T a4, T a5, T a6, T a7, T a8, T a9,
278
+ T a10) {
279
+ oneof_reader<T> ret;
280
+ ret.add(a1);
281
+ ret.add(a2);
282
+ ret.add(a3);
283
+ ret.add(a4);
284
+ ret.add(a5);
285
+ ret.add(a6);
286
+ ret.add(a7);
287
+ ret.add(a8);
288
+ ret.add(a9);
289
+ ret.add(a10);
290
+ return ret;
291
+ }
292
+
293
+ //-----
294
+
295
+ class parser {
296
+ public:
297
+ parser() {}
298
+ ~parser() {
299
+ for (std::map<std::string, option_base *>::iterator p = options.begin();
300
+ p != options.end(); p++)
301
+ delete p->second;
302
+ }
303
+
304
+ void add(const std::string &name, char short_name = 0,
305
+ const std::string &desc = "") {
306
+ if (options.count(name))
307
+ throw cmdline_error("multiple definition: " + name);
308
+ options[name] = new option_without_value(name, short_name, desc);
309
+ ordered.push_back(options[name]);
310
+ }
311
+
312
+ template <class T>
313
+ void add(const std::string &name, char short_name = 0,
314
+ const std::string &desc = "", bool need = true, const T def = T()) {
315
+ add(name, short_name, desc, need, def, default_reader<T>());
316
+ }
317
+
318
+ template <class T, class F>
319
+ void add(const std::string &name, char short_name = 0,
320
+ const std::string &desc = "", bool need = true, const T def = T(),
321
+ F reader = F()) {
322
+ if (options.count(name))
323
+ throw cmdline_error("multiple definition: " + name);
324
+ options[name] = new option_with_value_with_reader<T, F>(
325
+ name, short_name, need, def, desc, reader);
326
+ ordered.push_back(options[name]);
327
+ }
328
+
329
+ void footer(const std::string &f) { ftr = f; }
330
+
331
+ void set_program_name(const std::string &name) { prog_name = name; }
332
+
333
+ bool exist(const std::string &name) const {
334
+ if (options.count(name) == 0)
335
+ throw cmdline_error("there is no flag: --" + name);
336
+ return options.find(name)->second->has_set();
337
+ }
338
+
339
+ template <class T>
340
+ const T &get(const std::string &name) const {
341
+ if (options.count(name) == 0)
342
+ throw cmdline_error("there is no flag: --" + name);
343
+ const option_with_value<T> *p =
344
+ dynamic_cast<const option_with_value<T> *>(options.find(name)->second);
345
+ if (p == NULL) throw cmdline_error("type mismatch flag '" + name + "'");
346
+ return p->get();
347
+ }
348
+
349
+ const std::vector<std::string> &rest() const { return others; }
350
+
351
+ bool parse(const std::string &arg) {
352
+ std::vector<std::string> args;
353
+
354
+ std::string buf;
355
+ bool in_quote = false;
356
+ for (std::string::size_type i = 0; i < arg.length(); i++) {
357
+ if (arg[i] == '\"') {
358
+ in_quote = !in_quote;
359
+ continue;
360
+ }
361
+
362
+ if (arg[i] == ' ' && !in_quote) {
363
+ args.push_back(buf);
364
+ buf = "";
365
+ continue;
366
+ }
367
+
368
+ if (arg[i] == '\\') {
369
+ i++;
370
+ if (i >= arg.length()) {
371
+ errors.push_back("unexpected occurrence of '\\' at end of string");
372
+ return false;
373
+ }
374
+ }
375
+
376
+ buf += arg[i];
377
+ }
378
+
379
+ if (in_quote) {
380
+ errors.push_back("quote is not closed");
381
+ return false;
382
+ }
383
+
384
+ if (buf.length() > 0) args.push_back(buf);
385
+
386
+ for (size_t i = 0; i < args.size(); i++)
387
+ std::cout << "\"" << args[i] << "\"" << std::endl;
388
+
389
+ return parse(args);
390
+ }
391
+
392
+ bool parse(const std::vector<std::string> &args) {
393
+ int argc = static_cast<int>(args.size());
394
+ std::vector<const char *> argv(argc);
395
+
396
+ for (int i = 0; i < argc; i++) argv[i] = args[i].c_str();
397
+
398
+ return parse(argc, &argv[0]);
399
+ }
400
+
401
+ bool parse(int argc, const char *const argv[]) {
402
+ errors.clear();
403
+ others.clear();
404
+
405
+ if (argc < 1) {
406
+ errors.push_back("argument number must be longer than 0");
407
+ return false;
408
+ }
409
+ if (prog_name == "") prog_name = argv[0];
410
+
411
+ std::map<char, std::string> lookup;
412
+ for (std::map<std::string, option_base *>::iterator p = options.begin();
413
+ p != options.end(); p++) {
414
+ if (p->first.length() == 0) continue;
415
+ char initial = p->second->short_name();
416
+ if (initial) {
417
+ if (lookup.count(initial) > 0) {
418
+ lookup[initial] = "";
419
+ errors.push_back(std::string("short option '") + initial +
420
+ "' is ambiguous");
421
+ return false;
422
+ } else
423
+ lookup[initial] = p->first;
424
+ }
425
+ }
426
+
427
+ for (int i = 1; i < argc; i++) {
428
+ if (strncmp(argv[i], "--", 2) == 0) {
429
+ const char *p = strchr(argv[i] + 2, '=');
430
+ if (p) {
431
+ std::string name(argv[i] + 2, p);
432
+ std::string val(p + 1);
433
+ set_option(name, val);
434
+ } else {
435
+ std::string name(argv[i] + 2);
436
+ if (options.count(name) == 0) {
437
+ errors.push_back("undefined option: --" + name);
438
+ continue;
439
+ }
440
+ if (options[name]->has_value()) {
441
+ if (i + 1 >= argc) {
442
+ errors.push_back("option needs value: --" + name);
443
+ continue;
444
+ } else {
445
+ i++;
446
+ set_option(name, argv[i]);
447
+ }
448
+ } else {
449
+ set_option(name);
450
+ }
451
+ }
452
+ } else if (strncmp(argv[i], "-", 1) == 0) {
453
+ if (!argv[i][1]) continue;
454
+ char last = argv[i][1];
455
+ for (int j = 2; argv[i][j]; j++) {
456
+ last = argv[i][j];
457
+ if (lookup.count(argv[i][j - 1]) == 0) {
458
+ errors.push_back(std::string("undefined short option: -") +
459
+ argv[i][j - 1]);
460
+ continue;
461
+ }
462
+ if (lookup[argv[i][j - 1]] == "") {
463
+ errors.push_back(std::string("ambiguous short option: -") +
464
+ argv[i][j - 1]);
465
+ continue;
466
+ }
467
+ set_option(lookup[argv[i][j - 1]]);
468
+ }
469
+
470
+ if (lookup.count(last) == 0) {
471
+ errors.push_back(std::string("undefined short option: -") + last);
472
+ continue;
473
+ }
474
+ if (lookup[last] == "") {
475
+ errors.push_back(std::string("ambiguous short option: -") + last);
476
+ continue;
477
+ }
478
+
479
+ if (i + 1 < argc && options[lookup[last]]->has_value()) {
480
+ set_option(lookup[last], argv[i + 1]);
481
+ i++;
482
+ } else {
483
+ set_option(lookup[last]);
484
+ }
485
+ } else {
486
+ others.push_back(argv[i]);
487
+ }
488
+ }
489
+
490
+ for (std::map<std::string, option_base *>::iterator p = options.begin();
491
+ p != options.end(); p++)
492
+ if (!p->second->valid())
493
+ errors.push_back("need option: --" + std::string(p->first));
494
+
495
+ return errors.size() == 0;
496
+ }
497
+
498
+ void parse_check(const std::string &arg) {
499
+ if (!options.count("help")) add("help", '?', "print this message");
500
+ check(0, parse(arg));
501
+ }
502
+
503
+ void parse_check(const std::vector<std::string> &args) {
504
+ if (!options.count("help")) add("help", '?', "print this message");
505
+ check(args.size(), parse(args));
506
+ }
507
+
508
+ void parse_check(int argc, char *argv[]) {
509
+ if (!options.count("help")) add("help", '?', "print this message");
510
+ check(argc, parse(argc, argv));
511
+ }
512
+
513
+ std::string error() const { return errors.size() > 0 ? errors[0] : ""; }
514
+
515
+ std::string error_full() const {
516
+ std::ostringstream oss;
517
+ for (size_t i = 0; i < errors.size(); i++) oss << errors[i] << std::endl;
518
+ return oss.str();
519
+ }
520
+
521
+ std::string usage() const {
522
+ std::ostringstream oss;
523
+ oss << "usage: " << prog_name << " ";
524
+ for (size_t i = 0; i < ordered.size(); i++) {
525
+ if (ordered[i]->must()) oss << ordered[i]->short_description() << " ";
526
+ }
527
+
528
+ oss << "[options] ... " << ftr << std::endl;
529
+ oss << "options:" << std::endl;
530
+
531
+ size_t max_width = 0;
532
+ for (size_t i = 0; i < ordered.size(); i++) {
533
+ max_width = std::max(max_width, ordered[i]->name().length());
534
+ }
535
+ for (size_t i = 0; i < ordered.size(); i++) {
536
+ if (ordered[i]->short_name()) {
537
+ oss << " -" << ordered[i]->short_name() << ", ";
538
+ } else {
539
+ oss << " ";
540
+ }
541
+
542
+ oss << "--" << ordered[i]->name();
543
+ for (size_t j = ordered[i]->name().length(); j < max_width + 4; j++)
544
+ oss << ' ';
545
+ oss << ordered[i]->description() << std::endl;
546
+ }
547
+ return oss.str();
548
+ }
549
+
550
+ private:
551
+ void check(int argc, bool ok) {
552
+ if ((argc == 1 && !ok) || exist("help")) {
553
+ std::cerr << usage();
554
+ exit(0);
555
+ }
556
+
557
+ if (!ok) {
558
+ std::cerr << error() << std::endl << usage();
559
+ exit(1);
560
+ }
561
+ }
562
+
563
+ void set_option(const std::string &name) {
564
+ if (options.count(name) == 0) {
565
+ errors.push_back("undefined option: --" + name);
566
+ return;
567
+ }
568
+ if (!options[name]->set()) {
569
+ errors.push_back("option needs value: --" + name);
570
+ return;
571
+ }
572
+ }
573
+
574
+ void set_option(const std::string &name, const std::string &value) {
575
+ if (options.count(name) == 0) {
576
+ errors.push_back("undefined option: --" + name);
577
+ return;
578
+ }
579
+ if (!options[name]->set(value)) {
580
+ errors.push_back("option value is invalid: --" + name + "=" + value);
581
+ return;
582
+ }
583
+ }
584
+
585
+ class option_base {
586
+ public:
587
+ virtual ~option_base() {}
588
+
589
+ virtual bool has_value() const = 0;
590
+ virtual bool set() = 0;
591
+ virtual bool set(const std::string &value) = 0;
592
+ virtual bool has_set() const = 0;
593
+ virtual bool valid() const = 0;
594
+ virtual bool must() const = 0;
595
+
596
+ virtual const std::string &name() const = 0;
597
+ virtual char short_name() const = 0;
598
+ virtual const std::string &description() const = 0;
599
+ virtual std::string short_description() const = 0;
600
+ };
601
+
602
+ class option_without_value : public option_base {
603
+ public:
604
+ option_without_value(const std::string &name, char short_name,
605
+ const std::string &desc)
606
+ : nam(name), snam(short_name), desc(desc), has(false) {}
607
+ ~option_without_value() {}
608
+
609
+ bool has_value() const { return false; }
610
+
611
+ bool set() {
612
+ has = true;
613
+ return true;
614
+ }
615
+
616
+ bool set(const std::string &) { return false; }
617
+
618
+ bool has_set() const { return has; }
619
+
620
+ bool valid() const { return true; }
621
+
622
+ bool must() const { return false; }
623
+
624
+ const std::string &name() const { return nam; }
625
+
626
+ char short_name() const { return snam; }
627
+
628
+ const std::string &description() const { return desc; }
629
+
630
+ std::string short_description() const { return "--" + nam; }
631
+
632
+ private:
633
+ std::string nam;
634
+ char snam;
635
+ std::string desc;
636
+ bool has;
637
+ };
638
+
639
+ template <class T>
640
+ class option_with_value : public option_base {
641
+ public:
642
+ option_with_value(const std::string &name, char short_name, bool need,
643
+ const T &def, const std::string &desc)
644
+ : nam(name),
645
+ snam(short_name),
646
+ need(need),
647
+ has(false),
648
+ def(def),
649
+ actual(def) {
650
+ this->desc = full_description(desc);
651
+ }
652
+ ~option_with_value() {}
653
+
654
+ const T &get() const { return actual; }
655
+
656
+ bool has_value() const { return true; }
657
+
658
+ bool set() { return false; }
659
+
660
+ bool set(const std::string &value) {
661
+ try {
662
+ actual = read(value);
663
+ has = true;
664
+ } catch (const std::exception &e) {
665
+ return false;
666
+ }
667
+ return true;
668
+ }
669
+
670
+ bool has_set() const { return has; }
671
+
672
+ bool valid() const {
673
+ if (need && !has) return false;
674
+ return true;
675
+ }
676
+
677
+ bool must() const { return need; }
678
+
679
+ const std::string &name() const { return nam; }
680
+
681
+ char short_name() const { return snam; }
682
+
683
+ const std::string &description() const { return desc; }
684
+
685
+ std::string short_description() const {
686
+ return "--" + nam + "=" + detail::readable_typename<T>();
687
+ }
688
+
689
+ protected:
690
+ std::string full_description(const std::string &desc) {
691
+ return desc + " (" + detail::readable_typename<T>() +
692
+ (need ? "" : " [=" + detail::default_value<T>(def) + "]") + ")";
693
+ }
694
+
695
+ virtual T read(const std::string &s) = 0;
696
+
697
+ std::string nam;
698
+ char snam;
699
+ bool need;
700
+ std::string desc;
701
+
702
+ bool has;
703
+ T def;
704
+ T actual;
705
+ };
706
+
707
+ template <class T, class F>
708
+ class option_with_value_with_reader : public option_with_value<T> {
709
+ public:
710
+ option_with_value_with_reader(const std::string &name, char short_name,
711
+ bool need, const T def,
712
+ const std::string &desc, F reader)
713
+ : option_with_value<T>(name, short_name, need, def, desc),
714
+ reader(reader) {}
715
+
716
+ private:
717
+ T read(const std::string &s) { return reader(s); }
718
+
719
+ F reader;
720
+ };
721
+
722
+ std::map<std::string, option_base *> options;
723
+ std::vector<option_base *> ordered;
724
+ std::string ftr;
725
+
726
+ std::string prog_name;
727
+ std::vector<std::string> others;
728
+
729
+ std::vector<std::string> errors;
730
+ };
731
+
732
+ } // namespace cmdline
cpp/src/librosa/eigen3/.hgeol ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [patterns]
2
+ *.sh = LF
3
+ *.MINPACK = CRLF
4
+ scripts/*.in = LF
5
+ debug/msvc/*.dat = CRLF
6
+ debug/msvc/*.natvis = CRLF
7
+ unsupported/test/mpreal/*.* = CRLF
8
+ ** = native
9
+
10
+ [repository]
11
+ native = LF
cpp/src/librosa/eigen3/.hgignore ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ syntax: glob
2
+ qrc_*cxx
3
+ *.orig
4
+ *.pyc
5
+ *.diff
6
+ diff
7
+ *.save
8
+ save
9
+ *.old
10
+ *.gmo
11
+ *.qm
12
+ core
13
+ core.*
14
+ *.bak
15
+ *~
16
+ *build*
17
+ *.moc.*
18
+ *.moc
19
+ ui_*
20
+ CMakeCache.txt
21
+ tags
22
+ .*.swp
23
+ activity.png
24
+ *.out
25
+ *.php*
26
+ *.log
27
+ *.orig
28
+ *.rej
29
+ log
30
+ patch
31
+ a
32
+ a.*
33
+ lapack/testing
34
+ lapack/reference
cpp/src/librosa/eigen3/CMakeLists.txt ADDED
@@ -0,0 +1,616 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ project(Eigen3)
2
+
3
+ cmake_minimum_required(VERSION 2.8.5)
4
+
5
+ # guard against in-source builds
6
+
7
+ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
8
+ message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there. You may need to remove CMakeCache.txt. ")
9
+ endif()
10
+
11
+ # Alias Eigen_*_DIR to Eigen3_*_DIR:
12
+
13
+ set(Eigen_SOURCE_DIR ${Eigen3_SOURCE_DIR})
14
+ set(Eigen_BINARY_DIR ${Eigen3_BINARY_DIR})
15
+
16
+ # guard against bad build-type strings
17
+
18
+ if (NOT CMAKE_BUILD_TYPE)
19
+ set(CMAKE_BUILD_TYPE "Release")
20
+ endif()
21
+
22
+ string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_tolower)
23
+ if( NOT cmake_build_type_tolower STREQUAL "debug"
24
+ AND NOT cmake_build_type_tolower STREQUAL "release"
25
+ AND NOT cmake_build_type_tolower STREQUAL "relwithdebinfo")
26
+ message(FATAL_ERROR "Unknown build type \"${CMAKE_BUILD_TYPE}\". Allowed values are Debug, Release, RelWithDebInfo (case-insensitive).")
27
+ endif()
28
+
29
+
30
+ #############################################################################
31
+ # retrieve version infomation #
32
+ #############################################################################
33
+
34
+ # automatically parse the version number
35
+ file(READ "${PROJECT_SOURCE_DIR}/Eigen/src/Core/util/Macros.h" _eigen_version_header)
36
+ string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen_world_version_match "${_eigen_version_header}")
37
+ set(EIGEN_WORLD_VERSION "${CMAKE_MATCH_1}")
38
+ string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen_major_version_match "${_eigen_version_header}")
39
+ set(EIGEN_MAJOR_VERSION "${CMAKE_MATCH_1}")
40
+ string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen_minor_version_match "${_eigen_version_header}")
41
+ set(EIGEN_MINOR_VERSION "${CMAKE_MATCH_1}")
42
+ set(EIGEN_VERSION_NUMBER ${EIGEN_WORLD_VERSION}.${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION})
43
+
44
+ # if we are not in a mercurial clone
45
+ if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.hg)
46
+ # if the mercurial program is absent or this will leave the EIGEN_HG_CHANGESET string empty,
47
+ # but won't stop CMake.
48
+ execute_process(COMMAND hg tip -R ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE EIGEN_HGTIP_OUTPUT)
49
+ execute_process(COMMAND hg branch -R ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE EIGEN_BRANCH_OUTPUT)
50
+ endif()
51
+
52
+ # if this is the default (aka development) branch, extract the mercurial changeset number from the hg tip output...
53
+ if(EIGEN_BRANCH_OUTPUT MATCHES "default")
54
+ string(REGEX MATCH "^changeset: *[0-9]*:([0-9;a-f]+).*" EIGEN_HG_CHANGESET_MATCH "${EIGEN_HGTIP_OUTPUT}")
55
+ set(EIGEN_HG_CHANGESET "${CMAKE_MATCH_1}")
56
+ endif(EIGEN_BRANCH_OUTPUT MATCHES "default")
57
+ #...and show it next to the version number
58
+ if(EIGEN_HG_CHANGESET)
59
+ set(EIGEN_VERSION "${EIGEN_VERSION_NUMBER} (mercurial changeset ${EIGEN_HG_CHANGESET})")
60
+ else(EIGEN_HG_CHANGESET)
61
+ set(EIGEN_VERSION "${EIGEN_VERSION_NUMBER}")
62
+ endif(EIGEN_HG_CHANGESET)
63
+
64
+
65
+ include(CheckCXXCompilerFlag)
66
+ include(GNUInstallDirs)
67
+
68
+ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
69
+
70
+
71
+ option(EIGEN_TEST_CXX11 "Enable testing with C++11 and C++11 features (e.g. Tensor module)." OFF)
72
+
73
+
74
+ macro(ei_add_cxx_compiler_flag FLAG)
75
+ string(REGEX REPLACE "-" "" SFLAG1 ${FLAG})
76
+ string(REGEX REPLACE "\\+" "p" SFLAG ${SFLAG1})
77
+ check_cxx_compiler_flag(${FLAG} COMPILER_SUPPORT_${SFLAG})
78
+ if(COMPILER_SUPPORT_${SFLAG})
79
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAG}")
80
+ endif()
81
+ endmacro(ei_add_cxx_compiler_flag)
82
+
83
+ check_cxx_compiler_flag("-std=c++11" EIGEN_COMPILER_SUPPORT_CPP11)
84
+
85
+ if(EIGEN_TEST_CXX11)
86
+ set(CMAKE_CXX_STANDARD 11)
87
+ set(CMAKE_CXX_EXTENSIONS OFF)
88
+ if(EIGEN_COMPILER_SUPPORT_CPP11)
89
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
90
+ endif()
91
+ else()
92
+ #set(CMAKE_CXX_STANDARD 03)
93
+ #set(CMAKE_CXX_EXTENSIONS OFF)
94
+ ei_add_cxx_compiler_flag("-std=c++03")
95
+ endif()
96
+
97
+ #############################################################################
98
+ # find how to link to the standard libraries #
99
+ #############################################################################
100
+
101
+ find_package(StandardMathLibrary)
102
+
103
+
104
+ set(EIGEN_TEST_CUSTOM_LINKER_FLAGS "" CACHE STRING "Additional linker flags when linking unit tests.")
105
+ set(EIGEN_TEST_CUSTOM_CXX_FLAGS "" CACHE STRING "Additional compiler flags when compiling unit tests.")
106
+
107
+ set(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO "")
108
+
109
+ if(NOT STANDARD_MATH_LIBRARY_FOUND)
110
+
111
+ message(FATAL_ERROR
112
+ "Can't link to the standard math library. Please report to the Eigen developers, telling them about your platform.")
113
+
114
+ else()
115
+
116
+ if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
117
+ set(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO "${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO} ${STANDARD_MATH_LIBRARY}")
118
+ else()
119
+ set(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO "${STANDARD_MATH_LIBRARY}")
120
+ endif()
121
+
122
+ endif()
123
+
124
+ if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
125
+ message(STATUS "Standard libraries to link to explicitly: ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO}")
126
+ else()
127
+ message(STATUS "Standard libraries to link to explicitly: none")
128
+ endif()
129
+
130
+ option(EIGEN_BUILD_BTL "Build benchmark suite" OFF)
131
+
132
+ # Disable pkgconfig only for native Windows builds
133
+ if(NOT WIN32 OR NOT CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
134
+ option(EIGEN_BUILD_PKGCONFIG "Build pkg-config .pc file for Eigen" ON)
135
+ endif()
136
+
137
+ set(CMAKE_INCLUDE_CURRENT_DIR ON)
138
+
139
+ option(EIGEN_SPLIT_LARGE_TESTS "Split large tests into smaller executables" ON)
140
+
141
+ option(EIGEN_DEFAULT_TO_ROW_MAJOR "Use row-major as default matrix storage order" OFF)
142
+ if(EIGEN_DEFAULT_TO_ROW_MAJOR)
143
+ add_definitions("-DEIGEN_DEFAULT_TO_ROW_MAJOR")
144
+ endif()
145
+
146
+ set(EIGEN_TEST_MAX_SIZE "320" CACHE STRING "Maximal matrix/vector size, default is 320")
147
+
148
+ if(NOT MSVC)
149
+ # We assume that other compilers are partly compatible with GNUCC
150
+
151
+ # clang outputs some warnings for unknown flags that are not caught by check_cxx_compiler_flag
152
+ # adding -Werror turns such warnings into errors
153
+ check_cxx_compiler_flag("-Werror" COMPILER_SUPPORT_WERROR)
154
+ if(COMPILER_SUPPORT_WERROR)
155
+ set(CMAKE_REQUIRED_FLAGS "-Werror")
156
+ endif()
157
+ ei_add_cxx_compiler_flag("-pedantic")
158
+ ei_add_cxx_compiler_flag("-Wall")
159
+ ei_add_cxx_compiler_flag("-Wextra")
160
+ #ei_add_cxx_compiler_flag("-Weverything") # clang
161
+
162
+ ei_add_cxx_compiler_flag("-Wundef")
163
+ ei_add_cxx_compiler_flag("-Wcast-align")
164
+ ei_add_cxx_compiler_flag("-Wchar-subscripts")
165
+ ei_add_cxx_compiler_flag("-Wnon-virtual-dtor")
166
+ ei_add_cxx_compiler_flag("-Wunused-local-typedefs")
167
+ ei_add_cxx_compiler_flag("-Wpointer-arith")
168
+ ei_add_cxx_compiler_flag("-Wwrite-strings")
169
+ ei_add_cxx_compiler_flag("-Wformat-security")
170
+ ei_add_cxx_compiler_flag("-Wshorten-64-to-32")
171
+ ei_add_cxx_compiler_flag("-Wlogical-op")
172
+ ei_add_cxx_compiler_flag("-Wenum-conversion")
173
+ ei_add_cxx_compiler_flag("-Wc++11-extensions")
174
+ ei_add_cxx_compiler_flag("-Wdouble-promotion")
175
+ # ei_add_cxx_compiler_flag("-Wconversion")
176
+
177
+ # -Wshadow is insanely too strict with gcc, hopefully it will become usable with gcc 6
178
+ # if(NOT CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "5.0.0"))
179
+ if(NOT CMAKE_COMPILER_IS_GNUCXX)
180
+ ei_add_cxx_compiler_flag("-Wshadow")
181
+ endif()
182
+
183
+ ei_add_cxx_compiler_flag("-Wno-psabi")
184
+ ei_add_cxx_compiler_flag("-Wno-variadic-macros")
185
+ ei_add_cxx_compiler_flag("-Wno-long-long")
186
+
187
+ ei_add_cxx_compiler_flag("-fno-check-new")
188
+ ei_add_cxx_compiler_flag("-fno-common")
189
+ ei_add_cxx_compiler_flag("-fstrict-aliasing")
190
+ ei_add_cxx_compiler_flag("-wd981") # disable ICC's "operands are evaluated in unspecified order" remark
191
+ ei_add_cxx_compiler_flag("-wd2304") # disable ICC's "warning #2304: non-explicit constructor with single argument may cause implicit type conversion" produced by -Wnon-virtual-dtor
192
+
193
+
194
+ # The -ansi flag must be added last, otherwise it is also used as a linker flag by check_cxx_compiler_flag making it fails
195
+ # Moreover we should not set both -strict-ansi and -ansi
196
+ check_cxx_compiler_flag("-strict-ansi" COMPILER_SUPPORT_STRICTANSI)
197
+ ei_add_cxx_compiler_flag("-Qunused-arguments") # disable clang warning: argument unused during compilation: '-ansi'
198
+
199
+ if(COMPILER_SUPPORT_STRICTANSI)
200
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -strict-ansi")
201
+ else()
202
+ ei_add_cxx_compiler_flag("-ansi")
203
+ endif()
204
+
205
+ if(ANDROID_NDK)
206
+ ei_add_cxx_compiler_flag("-pie")
207
+ ei_add_cxx_compiler_flag("-fPIE")
208
+ endif()
209
+
210
+ set(CMAKE_REQUIRED_FLAGS "")
211
+
212
+ option(EIGEN_TEST_SSE2 "Enable/Disable SSE2 in tests/examples" OFF)
213
+ if(EIGEN_TEST_SSE2)
214
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2")
215
+ message(STATUS "Enabling SSE2 in tests/examples")
216
+ endif()
217
+
218
+ option(EIGEN_TEST_SSE3 "Enable/Disable SSE3 in tests/examples" OFF)
219
+ if(EIGEN_TEST_SSE3)
220
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse3")
221
+ message(STATUS "Enabling SSE3 in tests/examples")
222
+ endif()
223
+
224
+ option(EIGEN_TEST_SSSE3 "Enable/Disable SSSE3 in tests/examples" OFF)
225
+ if(EIGEN_TEST_SSSE3)
226
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mssse3")
227
+ message(STATUS "Enabling SSSE3 in tests/examples")
228
+ endif()
229
+
230
+ option(EIGEN_TEST_SSE4_1 "Enable/Disable SSE4.1 in tests/examples" OFF)
231
+ if(EIGEN_TEST_SSE4_1)
232
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
233
+ message(STATUS "Enabling SSE4.1 in tests/examples")
234
+ endif()
235
+
236
+ option(EIGEN_TEST_SSE4_2 "Enable/Disable SSE4.2 in tests/examples" OFF)
237
+ if(EIGEN_TEST_SSE4_2)
238
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
239
+ message(STATUS "Enabling SSE4.2 in tests/examples")
240
+ endif()
241
+
242
+ option(EIGEN_TEST_AVX "Enable/Disable AVX in tests/examples" OFF)
243
+ if(EIGEN_TEST_AVX)
244
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
245
+ message(STATUS "Enabling AVX in tests/examples")
246
+ endif()
247
+
248
+ option(EIGEN_TEST_FMA "Enable/Disable FMA in tests/examples" OFF)
249
+ if(EIGEN_TEST_FMA AND NOT EIGEN_TEST_NEON)
250
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfma")
251
+ message(STATUS "Enabling FMA in tests/examples")
252
+ endif()
253
+
254
+ option(EIGEN_TEST_AVX512 "Enable/Disable AVX512 in tests/examples" OFF)
255
+ if(EIGEN_TEST_AVX512)
256
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx512f -fabi-version=6 -DEIGEN_ENABLE_AVX512")
257
+ message(STATUS "Enabling AVX512 in tests/examples")
258
+ endif()
259
+
260
+ option(EIGEN_TEST_F16C "Enable/Disable F16C in tests/examples" OFF)
261
+ if(EIGEN_TEST_F16C)
262
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mf16c")
263
+ message(STATUS "Enabling F16C in tests/examples")
264
+ endif()
265
+
266
+ option(EIGEN_TEST_ALTIVEC "Enable/Disable AltiVec in tests/examples" OFF)
267
+ if(EIGEN_TEST_ALTIVEC)
268
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maltivec -mabi=altivec")
269
+ message(STATUS "Enabling AltiVec in tests/examples")
270
+ endif()
271
+
272
+ option(EIGEN_TEST_VSX "Enable/Disable VSX in tests/examples" OFF)
273
+ if(EIGEN_TEST_VSX)
274
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -mvsx")
275
+ message(STATUS "Enabling VSX in tests/examples")
276
+ endif()
277
+
278
+ option(EIGEN_TEST_NEON "Enable/Disable Neon in tests/examples" OFF)
279
+ if(EIGEN_TEST_NEON)
280
+ if(EIGEN_TEST_FMA)
281
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=neon-vfpv4")
282
+ else()
283
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=neon")
284
+ endif()
285
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfloat-abi=hard")
286
+ message(STATUS "Enabling NEON in tests/examples")
287
+ endif()
288
+
289
+ option(EIGEN_TEST_NEON64 "Enable/Disable Neon in tests/examples" OFF)
290
+ if(EIGEN_TEST_NEON64)
291
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
292
+ message(STATUS "Enabling NEON in tests/examples")
293
+ endif()
294
+
295
+ option(EIGEN_TEST_ZVECTOR "Enable/Disable S390X(zEC13) ZVECTOR in tests/examples" OFF)
296
+ if(EIGEN_TEST_ZVECTOR)
297
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=z13 -mzvector")
298
+ message(STATUS "Enabling S390X(zEC13) ZVECTOR in tests/examples")
299
+ endif()
300
+
301
+ check_cxx_compiler_flag("-fopenmp" COMPILER_SUPPORT_OPENMP)
302
+ if(COMPILER_SUPPORT_OPENMP)
303
+ option(EIGEN_TEST_OPENMP "Enable/Disable OpenMP in tests/examples" OFF)
304
+ if(EIGEN_TEST_OPENMP)
305
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
306
+ message(STATUS "Enabling OpenMP in tests/examples")
307
+ endif()
308
+ endif()
309
+
310
+ else(NOT MSVC)
311
+
312
+ # C4127 - conditional expression is constant
313
+ # C4714 - marked as __forceinline not inlined (I failed to deactivate it selectively)
314
+ # We can disable this warning in the unit tests since it is clear that it occurs
315
+ # because we are oftentimes returning objects that have a destructor or may
316
+ # throw exceptions - in particular in the unit tests we are throwing extra many
317
+ # exceptions to cover indexing errors.
318
+ # C4505 - unreferenced local function has been removed (impossible to deactive selectively)
319
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /wd4127 /wd4505 /wd4714")
320
+
321
+ # replace all /Wx by /W4
322
+ string(REGEX REPLACE "/W[0-9]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
323
+
324
+ check_cxx_compiler_flag("/openmp" COMPILER_SUPPORT_OPENMP)
325
+ if(COMPILER_SUPPORT_OPENMP)
326
+ option(EIGEN_TEST_OPENMP "Enable/Disable OpenMP in tests/examples" OFF)
327
+ if(EIGEN_TEST_OPENMP)
328
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp")
329
+ message(STATUS "Enabling OpenMP in tests/examples")
330
+ endif()
331
+ endif()
332
+
333
+ option(EIGEN_TEST_SSE2 "Enable/Disable SSE2 in tests/examples" OFF)
334
+ if(EIGEN_TEST_SSE2)
335
+ if(NOT CMAKE_CL_64)
336
+ # arch is not supported on 64 bit systems, SSE is enabled automatically.
337
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE2")
338
+ endif(NOT CMAKE_CL_64)
339
+ message(STATUS "Enabling SSE2 in tests/examples")
340
+ endif(EIGEN_TEST_SSE2)
341
+ endif(NOT MSVC)
342
+
343
+ option(EIGEN_TEST_NO_EXPLICIT_VECTORIZATION "Disable explicit vectorization in tests/examples" OFF)
344
+ option(EIGEN_TEST_X87 "Force using X87 instructions. Implies no vectorization." OFF)
345
+ option(EIGEN_TEST_32BIT "Force generating 32bit code." OFF)
346
+
347
+ if(EIGEN_TEST_X87)
348
+ set(EIGEN_TEST_NO_EXPLICIT_VECTORIZATION ON)
349
+ if(CMAKE_COMPILER_IS_GNUCXX)
350
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpmath=387")
351
+ message(STATUS "Forcing use of x87 instructions in tests/examples")
352
+ else()
353
+ message(STATUS "EIGEN_TEST_X87 ignored on your compiler")
354
+ endif()
355
+ endif()
356
+
357
+ if(EIGEN_TEST_32BIT)
358
+ if(CMAKE_COMPILER_IS_GNUCXX)
359
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
360
+ message(STATUS "Forcing generation of 32-bit code in tests/examples")
361
+ else()
362
+ message(STATUS "EIGEN_TEST_32BIT ignored on your compiler")
363
+ endif()
364
+ endif()
365
+
366
+ if(EIGEN_TEST_NO_EXPLICIT_VECTORIZATION)
367
+ add_definitions(-DEIGEN_DONT_VECTORIZE=1)
368
+ message(STATUS "Disabling vectorization in tests/examples")
369
+ endif()
370
+
371
+ option(EIGEN_TEST_NO_EXPLICIT_ALIGNMENT "Disable explicit alignment (hence vectorization) in tests/examples" OFF)
372
+ if(EIGEN_TEST_NO_EXPLICIT_ALIGNMENT)
373
+ add_definitions(-DEIGEN_DONT_ALIGN=1)
374
+ message(STATUS "Disabling alignment in tests/examples")
375
+ endif()
376
+
377
+ option(EIGEN_TEST_NO_EXCEPTIONS "Disables C++ exceptions" OFF)
378
+ if(EIGEN_TEST_NO_EXCEPTIONS)
379
+ ei_add_cxx_compiler_flag("-fno-exceptions")
380
+ message(STATUS "Disabling exceptions in tests/examples")
381
+ endif()
382
+
383
+ set(EIGEN_CUDA_COMPUTE_ARCH 30 CACHE STRING "The CUDA compute architecture level to target when compiling CUDA code")
384
+
385
+ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
386
+
387
+ # Backward compatibility support for EIGEN_INCLUDE_INSTALL_DIR
388
+ if(EIGEN_INCLUDE_INSTALL_DIR)
389
+ message(WARNING "EIGEN_INCLUDE_INSTALL_DIR is deprecated. Use INCLUDE_INSTALL_DIR instead.")
390
+ endif()
391
+
392
+ if(EIGEN_INCLUDE_INSTALL_DIR AND NOT INCLUDE_INSTALL_DIR)
393
+ set(INCLUDE_INSTALL_DIR ${EIGEN_INCLUDE_INSTALL_DIR}
394
+ CACHE PATH "The directory relative to CMAKE_PREFIX_PATH where Eigen header files are installed")
395
+ else()
396
+ set(INCLUDE_INSTALL_DIR
397
+ "${CMAKE_INSTALL_INCLUDEDIR}/eigen3"
398
+ CACHE PATH "The directory relative to CMAKE_PREFIX_PATH where Eigen header files are installed"
399
+ )
400
+ endif()
401
+ set(CMAKEPACKAGE_INSTALL_DIR
402
+ "${CMAKE_INSTALL_DATADIR}/eigen3/cmake"
403
+ CACHE PATH "The directory relative to CMAKE_PREFIX_PATH where Eigen3Config.cmake is installed"
404
+ )
405
+ set(PKGCONFIG_INSTALL_DIR
406
+ "${CMAKE_INSTALL_DATADIR}/pkgconfig"
407
+ CACHE PATH "The directory relative to CMAKE_PREFIX_PATH where eigen3.pc is installed"
408
+ )
409
+
410
+
411
+ # similar to set_target_properties but append the property instead of overwriting it
412
+ macro(ei_add_target_property target prop value)
413
+
414
+ get_target_property(previous ${target} ${prop})
415
+ # if the property wasn't previously set, ${previous} is now "previous-NOTFOUND" which cmake allows catching with plain if()
416
+ if(NOT previous)
417
+ set(previous "")
418
+ endif(NOT previous)
419
+ set_target_properties(${target} PROPERTIES ${prop} "${previous} ${value}")
420
+ endmacro(ei_add_target_property)
421
+
422
+ install(FILES
423
+ signature_of_eigen3_matrix_library
424
+ DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel
425
+ )
426
+
427
+ if(EIGEN_BUILD_PKGCONFIG)
428
+ configure_file(eigen3.pc.in eigen3.pc @ONLY)
429
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/eigen3.pc
430
+ DESTINATION ${PKGCONFIG_INSTALL_DIR}
431
+ )
432
+ endif()
433
+
434
+ add_subdirectory(Eigen)
435
+
436
+ add_subdirectory(doc EXCLUDE_FROM_ALL)
437
+
438
+ option(BUILD_TESTING "Enable creation of Eigen tests." ON)
439
+ if(BUILD_TESTING)
440
+ include(EigenConfigureTesting)
441
+
442
+ if(EIGEN_LEAVE_TEST_IN_ALL_TARGET)
443
+ add_subdirectory(test) # can't do EXCLUDE_FROM_ALL here, breaks CTest
444
+ else()
445
+ add_subdirectory(test EXCLUDE_FROM_ALL)
446
+ endif()
447
+ endif()
448
+
449
+ if(EIGEN_LEAVE_TEST_IN_ALL_TARGET)
450
+ add_subdirectory(blas)
451
+ add_subdirectory(lapack)
452
+ else()
453
+ add_subdirectory(blas EXCLUDE_FROM_ALL)
454
+ add_subdirectory(lapack EXCLUDE_FROM_ALL)
455
+ endif()
456
+
457
+ # add SYCL
458
+ option(EIGEN_TEST_SYCL "Add Sycl support." OFF)
459
+ if(EIGEN_TEST_SYCL)
460
+ set (CMAKE_MODULE_PATH "${CMAKE_ROOT}/Modules" "cmake/Modules/" "${CMAKE_MODULE_PATH}")
461
+ include(FindComputeCpp)
462
+ endif()
463
+
464
+ add_subdirectory(unsupported)
465
+
466
+ add_subdirectory(demos EXCLUDE_FROM_ALL)
467
+
468
+ # must be after test and unsupported, for configuring buildtests.in
469
+ add_subdirectory(scripts EXCLUDE_FROM_ALL)
470
+
471
+ # TODO: consider also replacing EIGEN_BUILD_BTL by a custom target "make btl"?
472
+ if(EIGEN_BUILD_BTL)
473
+ add_subdirectory(bench/btl EXCLUDE_FROM_ALL)
474
+ endif(EIGEN_BUILD_BTL)
475
+
476
+ if(NOT WIN32)
477
+ add_subdirectory(bench/spbench EXCLUDE_FROM_ALL)
478
+ endif(NOT WIN32)
479
+
480
+ configure_file(scripts/cdashtesting.cmake.in cdashtesting.cmake @ONLY)
481
+
482
+ if(BUILD_TESTING)
483
+ ei_testing_print_summary()
484
+ endif()
485
+
486
+ message(STATUS "")
487
+ message(STATUS "Configured Eigen ${EIGEN_VERSION_NUMBER}")
488
+ message(STATUS "")
489
+
490
+ option(EIGEN_FAILTEST "Enable failtests." OFF)
491
+ if(EIGEN_FAILTEST)
492
+ add_subdirectory(failtest)
493
+ endif()
494
+
495
+ string(TOLOWER "${CMAKE_GENERATOR}" cmake_generator_tolower)
496
+ if(cmake_generator_tolower MATCHES "makefile")
497
+ message(STATUS "Some things you can do now:")
498
+ message(STATUS "--------------+--------------------------------------------------------------")
499
+ message(STATUS "Command | Description")
500
+ message(STATUS "--------------+--------------------------------------------------------------")
501
+ message(STATUS "make install | Install Eigen. Headers will be installed to:")
502
+ message(STATUS " | <CMAKE_INSTALL_PREFIX>/<INCLUDE_INSTALL_DIR>")
503
+ message(STATUS " | Using the following values:")
504
+ message(STATUS " | CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
505
+ message(STATUS " | INCLUDE_INSTALL_DIR: ${INCLUDE_INSTALL_DIR}")
506
+ message(STATUS " | Change the install location of Eigen headers using:")
507
+ message(STATUS " | cmake . -DCMAKE_INSTALL_PREFIX=yourprefix")
508
+ message(STATUS " | Or:")
509
+ message(STATUS " | cmake . -DINCLUDE_INSTALL_DIR=yourdir")
510
+ message(STATUS "make doc | Generate the API documentation, requires Doxygen & LaTeX")
511
+ message(STATUS "make check | Build and run the unit-tests. Read this page:")
512
+ message(STATUS " | http://eigen.tuxfamily.org/index.php?title=Tests")
513
+ message(STATUS "make blas | Build BLAS library (not the same thing as Eigen)")
514
+ message(STATUS "make uninstall| Removes files installed by make install")
515
+ message(STATUS "--------------+--------------------------------------------------------------")
516
+ else()
517
+ message(STATUS "To build/run the unit tests, read this page:")
518
+ message(STATUS " http://eigen.tuxfamily.org/index.php?title=Tests")
519
+ endif()
520
+
521
+ message(STATUS "")
522
+
523
+
524
+ set ( EIGEN_VERSION_STRING ${EIGEN_VERSION_NUMBER} )
525
+ set ( EIGEN_VERSION_MAJOR ${EIGEN_WORLD_VERSION} )
526
+ set ( EIGEN_VERSION_MINOR ${EIGEN_MAJOR_VERSION} )
527
+ set ( EIGEN_VERSION_PATCH ${EIGEN_MINOR_VERSION} )
528
+ set ( EIGEN_DEFINITIONS "")
529
+ set ( EIGEN_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/${INCLUDE_INSTALL_DIR}" )
530
+ set ( EIGEN_ROOT_DIR ${CMAKE_INSTALL_PREFIX} )
531
+
532
+ # Interface libraries require at least CMake 3.0
533
+ if (NOT CMAKE_VERSION VERSION_LESS 3.0)
534
+ include (CMakePackageConfigHelpers)
535
+
536
+ # Imported target support
537
+ add_library (eigen INTERFACE)
538
+
539
+ target_compile_definitions (eigen INTERFACE ${EIGEN_DEFINITIONS})
540
+ target_include_directories (eigen INTERFACE
541
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
542
+ $<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}>
543
+ )
544
+
545
+ # Export as title case Eigen
546
+ set_target_properties (eigen PROPERTIES EXPORT_NAME Eigen)
547
+
548
+ install (TARGETS eigen EXPORT Eigen3Targets)
549
+
550
+ configure_package_config_file (
551
+ ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Eigen3Config.cmake.in
552
+ ${CMAKE_CURRENT_BINARY_DIR}/Eigen3Config.cmake
553
+ PATH_VARS EIGEN_INCLUDE_DIR EIGEN_ROOT_DIR
554
+ INSTALL_DESTINATION ${CMAKEPACKAGE_INSTALL_DIR}
555
+ NO_CHECK_REQUIRED_COMPONENTS_MACRO # Eigen does not provide components
556
+ )
557
+ # Remove CMAKE_SIZEOF_VOID_P from Eigen3ConfigVersion.cmake since Eigen does
558
+ # not depend on architecture specific settings or libraries. More
559
+ # specifically, an Eigen3Config.cmake generated from a 64 bit target can be
560
+ # used for 32 bit targets as well (and vice versa).
561
+ set (_Eigen3_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
562
+ unset (CMAKE_SIZEOF_VOID_P)
563
+ write_basic_package_version_file (Eigen3ConfigVersion.cmake
564
+ VERSION ${EIGEN_VERSION_NUMBER}
565
+ COMPATIBILITY SameMajorVersion)
566
+ set (CMAKE_SIZEOF_VOID_P ${_Eigen3_CMAKE_SIZEOF_VOID_P})
567
+
568
+ # The Eigen target will be located in the Eigen3 namespace. Other CMake
569
+ # targets can refer to it using Eigen3::Eigen.
570
+ export (TARGETS eigen NAMESPACE Eigen3:: FILE Eigen3Targets.cmake)
571
+ # Export Eigen3 package to CMake registry such that it can be easily found by
572
+ # CMake even if it has not been installed to a standard directory.
573
+ export (PACKAGE Eigen3)
574
+
575
+ install (EXPORT Eigen3Targets NAMESPACE Eigen3:: DESTINATION ${CMAKEPACKAGE_INSTALL_DIR})
576
+
577
+ else (NOT CMAKE_VERSION VERSION_LESS 3.0)
578
+ # Fallback to legacy Eigen3Config.cmake without the imported target
579
+
580
+ # If CMakePackageConfigHelpers module is available (CMake >= 2.8.8)
581
+ # create a relocatable Config file, otherwise leave the hardcoded paths
582
+ include(CMakePackageConfigHelpers OPTIONAL RESULT_VARIABLE CPCH_PATH)
583
+
584
+ if(CPCH_PATH)
585
+ configure_package_config_file (
586
+ ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Eigen3ConfigLegacy.cmake.in
587
+ ${CMAKE_CURRENT_BINARY_DIR}/Eigen3Config.cmake
588
+ PATH_VARS EIGEN_INCLUDE_DIR EIGEN_ROOT_DIR
589
+ INSTALL_DESTINATION ${CMAKEPACKAGE_INSTALL_DIR}
590
+ NO_CHECK_REQUIRED_COMPONENTS_MACRO # Eigen does not provide components
591
+ )
592
+ else()
593
+ # The PACKAGE_* variables are defined by the configure_package_config_file
594
+ # but without it we define them manually to the hardcoded paths
595
+ set(PACKAGE_INIT "")
596
+ set(PACKAGE_EIGEN_INCLUDE_DIR ${EIGEN_INCLUDE_DIR})
597
+ set(PACKAGE_EIGEN_ROOT_DIR ${EIGEN_ROOT_DIR})
598
+ configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Eigen3ConfigLegacy.cmake.in
599
+ ${CMAKE_CURRENT_BINARY_DIR}/Eigen3Config.cmake
600
+ @ONLY ESCAPE_QUOTES )
601
+ endif()
602
+
603
+ write_basic_package_version_file( Eigen3ConfigVersion.cmake
604
+ VERSION ${EIGEN_VERSION_NUMBER}
605
+ COMPATIBILITY SameMajorVersion )
606
+
607
+ endif (NOT CMAKE_VERSION VERSION_LESS 3.0)
608
+
609
+ install ( FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/UseEigen3.cmake
610
+ ${CMAKE_CURRENT_BINARY_DIR}/Eigen3Config.cmake
611
+ ${CMAKE_CURRENT_BINARY_DIR}/Eigen3ConfigVersion.cmake
612
+ DESTINATION ${CMAKEPACKAGE_INSTALL_DIR} )
613
+
614
+ # Add uninstall target
615
+ add_custom_target ( uninstall
616
+ COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/EigenUninstall.cmake)
cpp/src/librosa/eigen3/COPYING.BSD ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright (c) 2011, Intel Corporation. All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name of Intel Corporation nor the names of its contributors may
13
+ be used to endorse or promote products derived from this software without
14
+ specific prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
+ */
cpp/src/librosa/eigen3/COPYING.GPL ADDED
@@ -0,0 +1,674 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU General Public License is a free, copyleft license for
11
+ software and other kinds of works.
12
+
13
+ The licenses for most software and other practical works are designed
14
+ to take away your freedom to share and change the works. By contrast,
15
+ the GNU General Public License is intended to guarantee your freedom to
16
+ share and change all versions of a program--to make sure it remains free
17
+ software for all its users. We, the Free Software Foundation, use the
18
+ GNU General Public License for most of our software; it applies also to
19
+ any other work released this way by its authors. You can apply it to
20
+ your programs, too.
21
+
22
+ When we speak of free software, we are referring to freedom, not
23
+ price. Our General Public Licenses are designed to make sure that you
24
+ have the freedom to distribute copies of free software (and charge for
25
+ them if you wish), that you receive source code or can get it if you
26
+ want it, that you can change the software or use pieces of it in new
27
+ free programs, and that you know you can do these things.
28
+
29
+ To protect your rights, we need to prevent others from denying you
30
+ these rights or asking you to surrender the rights. Therefore, you have
31
+ certain responsibilities if you distribute copies of the software, or if
32
+ you modify it: responsibilities to respect the freedom of others.
33
+
34
+ For example, if you distribute copies of such a program, whether
35
+ gratis or for a fee, you must pass on to the recipients the same
36
+ freedoms that you received. You must make sure that they, too, receive
37
+ or can get the source code. And you must show them these terms so they
38
+ know their rights.
39
+
40
+ Developers that use the GNU GPL protect your rights with two steps:
41
+ (1) assert copyright on the software, and (2) offer you this License
42
+ giving you legal permission to copy, distribute and/or modify it.
43
+
44
+ For the developers' and authors' protection, the GPL clearly explains
45
+ that there is no warranty for this free software. For both users' and
46
+ authors' sake, the GPL requires that modified versions be marked as
47
+ changed, so that their problems will not be attributed erroneously to
48
+ authors of previous versions.
49
+
50
+ Some devices are designed to deny users access to install or run
51
+ modified versions of the software inside them, although the manufacturer
52
+ can do so. This is fundamentally incompatible with the aim of
53
+ protecting users' freedom to change the software. The systematic
54
+ pattern of such abuse occurs in the area of products for individuals to
55
+ use, which is precisely where it is most unacceptable. Therefore, we
56
+ have designed this version of the GPL to prohibit the practice for those
57
+ products. If such problems arise substantially in other domains, we
58
+ stand ready to extend this provision to those domains in future versions
59
+ of the GPL, as needed to protect the freedom of users.
60
+
61
+ Finally, every program is threatened constantly by software patents.
62
+ States should not allow patents to restrict development and use of
63
+ software on general-purpose computers, but in those that do, we wish to
64
+ avoid the special danger that patents applied to a free program could
65
+ make it effectively proprietary. To prevent this, the GPL assures that
66
+ patents cannot be used to render the program non-free.
67
+
68
+ The precise terms and conditions for copying, distribution and
69
+ modification follow.
70
+
71
+ TERMS AND CONDITIONS
72
+
73
+ 0. Definitions.
74
+
75
+ "This License" refers to version 3 of the GNU General Public License.
76
+
77
+ "Copyright" also means copyright-like laws that apply to other kinds of
78
+ works, such as semiconductor masks.
79
+
80
+ "The Program" refers to any copyrightable work licensed under this
81
+ License. Each licensee is addressed as "you". "Licensees" and
82
+ "recipients" may be individuals or organizations.
83
+
84
+ To "modify" a work means to copy from or adapt all or part of the work
85
+ in a fashion requiring copyright permission, other than the making of an
86
+ exact copy. The resulting work is called a "modified version" of the
87
+ earlier work or a work "based on" the earlier work.
88
+
89
+ A "covered work" means either the unmodified Program or a work based
90
+ on the Program.
91
+
92
+ To "propagate" a work means to do anything with it that, without
93
+ permission, would make you directly or secondarily liable for
94
+ infringement under applicable copyright law, except executing it on a
95
+ computer or modifying a private copy. Propagation includes copying,
96
+ distribution (with or without modification), making available to the
97
+ public, and in some countries other activities as well.
98
+
99
+ To "convey" a work means any kind of propagation that enables other
100
+ parties to make or receive copies. Mere interaction with a user through
101
+ a computer network, with no transfer of a copy, is not conveying.
102
+
103
+ An interactive user interface displays "Appropriate Legal Notices"
104
+ to the extent that it includes a convenient and prominently visible
105
+ feature that (1) displays an appropriate copyright notice, and (2)
106
+ tells the user that there is no warranty for the work (except to the
107
+ extent that warranties are provided), that licensees may convey the
108
+ work under this License, and how to view a copy of this License. If
109
+ the interface presents a list of user commands or options, such as a
110
+ menu, a prominent item in the list meets this criterion.
111
+
112
+ 1. Source Code.
113
+
114
+ The "source code" for a work means the preferred form of the work
115
+ for making modifications to it. "Object code" means any non-source
116
+ form of a work.
117
+
118
+ A "Standard Interface" means an interface that either is an official
119
+ standard defined by a recognized standards body, or, in the case of
120
+ interfaces specified for a particular programming language, one that
121
+ is widely used among developers working in that language.
122
+
123
+ The "System Libraries" of an executable work include anything, other
124
+ than the work as a whole, that (a) is included in the normal form of
125
+ packaging a Major Component, but which is not part of that Major
126
+ Component, and (b) serves only to enable use of the work with that
127
+ Major Component, or to implement a Standard Interface for which an
128
+ implementation is available to the public in source code form. A
129
+ "Major Component", in this context, means a major essential component
130
+ (kernel, window system, and so on) of the specific operating system
131
+ (if any) on which the executable work runs, or a compiler used to
132
+ produce the work, or an object code interpreter used to run it.
133
+
134
+ The "Corresponding Source" for a work in object code form means all
135
+ the source code needed to generate, install, and (for an executable
136
+ work) run the object code and to modify the work, including scripts to
137
+ control those activities. However, it does not include the work's
138
+ System Libraries, or general-purpose tools or generally available free
139
+ programs which are used unmodified in performing those activities but
140
+ which are not part of the work. For example, Corresponding Source
141
+ includes interface definition files associated with source files for
142
+ the work, and the source code for shared libraries and dynamically
143
+ linked subprograms that the work is specifically designed to require,
144
+ such as by intimate data communication or control flow between those
145
+ subprograms and other parts of the work.
146
+
147
+ The Corresponding Source need not include anything that users
148
+ can regenerate automatically from other parts of the Corresponding
149
+ Source.
150
+
151
+ The Corresponding Source for a work in source code form is that
152
+ same work.
153
+
154
+ 2. Basic Permissions.
155
+
156
+ All rights granted under this License are granted for the term of
157
+ copyright on the Program, and are irrevocable provided the stated
158
+ conditions are met. This License explicitly affirms your unlimited
159
+ permission to run the unmodified Program. The output from running a
160
+ covered work is covered by this License only if the output, given its
161
+ content, constitutes a covered work. This License acknowledges your
162
+ rights of fair use or other equivalent, as provided by copyright law.
163
+
164
+ You may make, run and propagate covered works that you do not
165
+ convey, without conditions so long as your license otherwise remains
166
+ in force. You may convey covered works to others for the sole purpose
167
+ of having them make modifications exclusively for you, or provide you
168
+ with facilities for running those works, provided that you comply with
169
+ the terms of this License in conveying all material for which you do
170
+ not control copyright. Those thus making or running the covered works
171
+ for you must do so exclusively on your behalf, under your direction
172
+ and control, on terms that prohibit them from making any copies of
173
+ your copyrighted material outside their relationship with you.
174
+
175
+ Conveying under any other circumstances is permitted solely under
176
+ the conditions stated below. Sublicensing is not allowed; section 10
177
+ makes it unnecessary.
178
+
179
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
+
181
+ No covered work shall be deemed part of an effective technological
182
+ measure under any applicable law fulfilling obligations under article
183
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184
+ similar laws prohibiting or restricting circumvention of such
185
+ measures.
186
+
187
+ When you convey a covered work, you waive any legal power to forbid
188
+ circumvention of technological measures to the extent such circumvention
189
+ is effected by exercising rights under this License with respect to
190
+ the covered work, and you disclaim any intention to limit operation or
191
+ modification of the work as a means of enforcing, against the work's
192
+ users, your or third parties' legal rights to forbid circumvention of
193
+ technological measures.
194
+
195
+ 4. Conveying Verbatim Copies.
196
+
197
+ You may convey verbatim copies of the Program's source code as you
198
+ receive it, in any medium, provided that you conspicuously and
199
+ appropriately publish on each copy an appropriate copyright notice;
200
+ keep intact all notices stating that this License and any
201
+ non-permissive terms added in accord with section 7 apply to the code;
202
+ keep intact all notices of the absence of any warranty; and give all
203
+ recipients a copy of this License along with the Program.
204
+
205
+ You may charge any price or no price for each copy that you convey,
206
+ and you may offer support or warranty protection for a fee.
207
+
208
+ 5. Conveying Modified Source Versions.
209
+
210
+ You may convey a work based on the Program, or the modifications to
211
+ produce it from the Program, in the form of source code under the
212
+ terms of section 4, provided that you also meet all of these conditions:
213
+
214
+ a) The work must carry prominent notices stating that you modified
215
+ it, and giving a relevant date.
216
+
217
+ b) The work must carry prominent notices stating that it is
218
+ released under this License and any conditions added under section
219
+ 7. This requirement modifies the requirement in section 4 to
220
+ "keep intact all notices".
221
+
222
+ c) You must license the entire work, as a whole, under this
223
+ License to anyone who comes into possession of a copy. This
224
+ License will therefore apply, along with any applicable section 7
225
+ additional terms, to the whole of the work, and all its parts,
226
+ regardless of how they are packaged. This License gives no
227
+ permission to license the work in any other way, but it does not
228
+ invalidate such permission if you have separately received it.
229
+
230
+ d) If the work has interactive user interfaces, each must display
231
+ Appropriate Legal Notices; however, if the Program has interactive
232
+ interfaces that do not display Appropriate Legal Notices, your
233
+ work need not make them do so.
234
+
235
+ A compilation of a covered work with other separate and independent
236
+ works, which are not by their nature extensions of the covered work,
237
+ and which are not combined with it such as to form a larger program,
238
+ in or on a volume of a storage or distribution medium, is called an
239
+ "aggregate" if the compilation and its resulting copyright are not
240
+ used to limit the access or legal rights of the compilation's users
241
+ beyond what the individual works permit. Inclusion of a covered work
242
+ in an aggregate does not cause this License to apply to the other
243
+ parts of the aggregate.
244
+
245
+ 6. Conveying Non-Source Forms.
246
+
247
+ You may convey a covered work in object code form under the terms
248
+ of sections 4 and 5, provided that you also convey the
249
+ machine-readable Corresponding Source under the terms of this License,
250
+ in one of these ways:
251
+
252
+ a) Convey the object code in, or embodied in, a physical product
253
+ (including a physical distribution medium), accompanied by the
254
+ Corresponding Source fixed on a durable physical medium
255
+ customarily used for software interchange.
256
+
257
+ b) Convey the object code in, or embodied in, a physical product
258
+ (including a physical distribution medium), accompanied by a
259
+ written offer, valid for at least three years and valid for as
260
+ long as you offer spare parts or customer support for that product
261
+ model, to give anyone who possesses the object code either (1) a
262
+ copy of the Corresponding Source for all the software in the
263
+ product that is covered by this License, on a durable physical
264
+ medium customarily used for software interchange, for a price no
265
+ more than your reasonable cost of physically performing this
266
+ conveying of source, or (2) access to copy the
267
+ Corresponding Source from a network server at no charge.
268
+
269
+ c) Convey individual copies of the object code with a copy of the
270
+ written offer to provide the Corresponding Source. This
271
+ alternative is allowed only occasionally and noncommercially, and
272
+ only if you received the object code with such an offer, in accord
273
+ with subsection 6b.
274
+
275
+ d) Convey the object code by offering access from a designated
276
+ place (gratis or for a charge), and offer equivalent access to the
277
+ Corresponding Source in the same way through the same place at no
278
+ further charge. You need not require recipients to copy the
279
+ Corresponding Source along with the object code. If the place to
280
+ copy the object code is a network server, the Corresponding Source
281
+ may be on a different server (operated by you or a third party)
282
+ that supports equivalent copying facilities, provided you maintain
283
+ clear directions next to the object code saying where to find the
284
+ Corresponding Source. Regardless of what server hosts the
285
+ Corresponding Source, you remain obligated to ensure that it is
286
+ available for as long as needed to satisfy these requirements.
287
+
288
+ e) Convey the object code using peer-to-peer transmission, provided
289
+ you inform other peers where the object code and Corresponding
290
+ Source of the work are being offered to the general public at no
291
+ charge under subsection 6d.
292
+
293
+ A separable portion of the object code, whose source code is excluded
294
+ from the Corresponding Source as a System Library, need not be
295
+ included in conveying the object code work.
296
+
297
+ A "User Product" is either (1) a "consumer product", which means any
298
+ tangible personal property which is normally used for personal, family,
299
+ or household purposes, or (2) anything designed or sold for incorporation
300
+ into a dwelling. In determining whether a product is a consumer product,
301
+ doubtful cases shall be resolved in favor of coverage. For a particular
302
+ product received by a particular user, "normally used" refers to a
303
+ typical or common use of that class of product, regardless of the status
304
+ of the particular user or of the way in which the particular user
305
+ actually uses, or expects or is expected to use, the product. A product
306
+ is a consumer product regardless of whether the product has substantial
307
+ commercial, industrial or non-consumer uses, unless such uses represent
308
+ the only significant mode of use of the product.
309
+
310
+ "Installation Information" for a User Product means any methods,
311
+ procedures, authorization keys, or other information required to install
312
+ and execute modified versions of a covered work in that User Product from
313
+ a modified version of its Corresponding Source. The information must
314
+ suffice to ensure that the continued functioning of the modified object
315
+ code is in no case prevented or interfered with solely because
316
+ modification has been made.
317
+
318
+ If you convey an object code work under this section in, or with, or
319
+ specifically for use in, a User Product, and the conveying occurs as
320
+ part of a transaction in which the right of possession and use of the
321
+ User Product is transferred to the recipient in perpetuity or for a
322
+ fixed term (regardless of how the transaction is characterized), the
323
+ Corresponding Source conveyed under this section must be accompanied
324
+ by the Installation Information. But this requirement does not apply
325
+ if neither you nor any third party retains the ability to install
326
+ modified object code on the User Product (for example, the work has
327
+ been installed in ROM).
328
+
329
+ The requirement to provide Installation Information does not include a
330
+ requirement to continue to provide support service, warranty, or updates
331
+ for a work that has been modified or installed by the recipient, or for
332
+ the User Product in which it has been modified or installed. Access to a
333
+ network may be denied when the modification itself materially and
334
+ adversely affects the operation of the network or violates the rules and
335
+ protocols for communication across the network.
336
+
337
+ Corresponding Source conveyed, and Installation Information provided,
338
+ in accord with this section must be in a format that is publicly
339
+ documented (and with an implementation available to the public in
340
+ source code form), and must require no special password or key for
341
+ unpacking, reading or copying.
342
+
343
+ 7. Additional Terms.
344
+
345
+ "Additional permissions" are terms that supplement the terms of this
346
+ License by making exceptions from one or more of its conditions.
347
+ Additional permissions that are applicable to the entire Program shall
348
+ be treated as though they were included in this License, to the extent
349
+ that they are valid under applicable law. If additional permissions
350
+ apply only to part of the Program, that part may be used separately
351
+ under those permissions, but the entire Program remains governed by
352
+ this License without regard to the additional permissions.
353
+
354
+ When you convey a copy of a covered work, you may at your option
355
+ remove any additional permissions from that copy, or from any part of
356
+ it. (Additional permissions may be written to require their own
357
+ removal in certain cases when you modify the work.) You may place
358
+ additional permissions on material, added by you to a covered work,
359
+ for which you have or can give appropriate copyright permission.
360
+
361
+ Notwithstanding any other provision of this License, for material you
362
+ add to a covered work, you may (if authorized by the copyright holders of
363
+ that material) supplement the terms of this License with terms:
364
+
365
+ a) Disclaiming warranty or limiting liability differently from the
366
+ terms of sections 15 and 16 of this License; or
367
+
368
+ b) Requiring preservation of specified reasonable legal notices or
369
+ author attributions in that material or in the Appropriate Legal
370
+ Notices displayed by works containing it; or
371
+
372
+ c) Prohibiting misrepresentation of the origin of that material, or
373
+ requiring that modified versions of such material be marked in
374
+ reasonable ways as different from the original version; or
375
+
376
+ d) Limiting the use for publicity purposes of names of licensors or
377
+ authors of the material; or
378
+
379
+ e) Declining to grant rights under trademark law for use of some
380
+ trade names, trademarks, or service marks; or
381
+
382
+ f) Requiring indemnification of licensors and authors of that
383
+ material by anyone who conveys the material (or modified versions of
384
+ it) with contractual assumptions of liability to the recipient, for
385
+ any liability that these contractual assumptions directly impose on
386
+ those licensors and authors.
387
+
388
+ All other non-permissive additional terms are considered "further
389
+ restrictions" within the meaning of section 10. If the Program as you
390
+ received it, or any part of it, contains a notice stating that it is
391
+ governed by this License along with a term that is a further
392
+ restriction, you may remove that term. If a license document contains
393
+ a further restriction but permits relicensing or conveying under this
394
+ License, you may add to a covered work material governed by the terms
395
+ of that license document, provided that the further restriction does
396
+ not survive such relicensing or conveying.
397
+
398
+ If you add terms to a covered work in accord with this section, you
399
+ must place, in the relevant source files, a statement of the
400
+ additional terms that apply to those files, or a notice indicating
401
+ where to find the applicable terms.
402
+
403
+ Additional terms, permissive or non-permissive, may be stated in the
404
+ form of a separately written license, or stated as exceptions;
405
+ the above requirements apply either way.
406
+
407
+ 8. Termination.
408
+
409
+ You may not propagate or modify a covered work except as expressly
410
+ provided under this License. Any attempt otherwise to propagate or
411
+ modify it is void, and will automatically terminate your rights under
412
+ this License (including any patent licenses granted under the third
413
+ paragraph of section 11).
414
+
415
+ However, if you cease all violation of this License, then your
416
+ license from a particular copyright holder is reinstated (a)
417
+ provisionally, unless and until the copyright holder explicitly and
418
+ finally terminates your license, and (b) permanently, if the copyright
419
+ holder fails to notify you of the violation by some reasonable means
420
+ prior to 60 days after the cessation.
421
+
422
+ Moreover, your license from a particular copyright holder is
423
+ reinstated permanently if the copyright holder notifies you of the
424
+ violation by some reasonable means, this is the first time you have
425
+ received notice of violation of this License (for any work) from that
426
+ copyright holder, and you cure the violation prior to 30 days after
427
+ your receipt of the notice.
428
+
429
+ Termination of your rights under this section does not terminate the
430
+ licenses of parties who have received copies or rights from you under
431
+ this License. If your rights have been terminated and not permanently
432
+ reinstated, you do not qualify to receive new licenses for the same
433
+ material under section 10.
434
+
435
+ 9. Acceptance Not Required for Having Copies.
436
+
437
+ You are not required to accept this License in order to receive or
438
+ run a copy of the Program. Ancillary propagation of a covered work
439
+ occurring solely as a consequence of using peer-to-peer transmission
440
+ to receive a copy likewise does not require acceptance. However,
441
+ nothing other than this License grants you permission to propagate or
442
+ modify any covered work. These actions infringe copyright if you do
443
+ not accept this License. Therefore, by modifying or propagating a
444
+ covered work, you indicate your acceptance of this License to do so.
445
+
446
+ 10. Automatic Licensing of Downstream Recipients.
447
+
448
+ Each time you convey a covered work, the recipient automatically
449
+ receives a license from the original licensors, to run, modify and
450
+ propagate that work, subject to this License. You are not responsible
451
+ for enforcing compliance by third parties with this License.
452
+
453
+ An "entity transaction" is a transaction transferring control of an
454
+ organization, or substantially all assets of one, or subdividing an
455
+ organization, or merging organizations. If propagation of a covered
456
+ work results from an entity transaction, each party to that
457
+ transaction who receives a copy of the work also receives whatever
458
+ licenses to the work the party's predecessor in interest had or could
459
+ give under the previous paragraph, plus a right to possession of the
460
+ Corresponding Source of the work from the predecessor in interest, if
461
+ the predecessor has it or can get it with reasonable efforts.
462
+
463
+ You may not impose any further restrictions on the exercise of the
464
+ rights granted or affirmed under this License. For example, you may
465
+ not impose a license fee, royalty, or other charge for exercise of
466
+ rights granted under this License, and you may not initiate litigation
467
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
468
+ any patent claim is infringed by making, using, selling, offering for
469
+ sale, or importing the Program or any portion of it.
470
+
471
+ 11. Patents.
472
+
473
+ A "contributor" is a copyright holder who authorizes use under this
474
+ License of the Program or a work on which the Program is based. The
475
+ work thus licensed is called the contributor's "contributor version".
476
+
477
+ A contributor's "essential patent claims" are all patent claims
478
+ owned or controlled by the contributor, whether already acquired or
479
+ hereafter acquired, that would be infringed by some manner, permitted
480
+ by this License, of making, using, or selling its contributor version,
481
+ but do not include claims that would be infringed only as a
482
+ consequence of further modification of the contributor version. For
483
+ purposes of this definition, "control" includes the right to grant
484
+ patent sublicenses in a manner consistent with the requirements of
485
+ this License.
486
+
487
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
488
+ patent license under the contributor's essential patent claims, to
489
+ make, use, sell, offer for sale, import and otherwise run, modify and
490
+ propagate the contents of its contributor version.
491
+
492
+ In the following three paragraphs, a "patent license" is any express
493
+ agreement or commitment, however denominated, not to enforce a patent
494
+ (such as an express permission to practice a patent or covenant not to
495
+ sue for patent infringement). To "grant" such a patent license to a
496
+ party means to make such an agreement or commitment not to enforce a
497
+ patent against the party.
498
+
499
+ If you convey a covered work, knowingly relying on a patent license,
500
+ and the Corresponding Source of the work is not available for anyone
501
+ to copy, free of charge and under the terms of this License, through a
502
+ publicly available network server or other readily accessible means,
503
+ then you must either (1) cause the Corresponding Source to be so
504
+ available, or (2) arrange to deprive yourself of the benefit of the
505
+ patent license for this particular work, or (3) arrange, in a manner
506
+ consistent with the requirements of this License, to extend the patent
507
+ license to downstream recipients. "Knowingly relying" means you have
508
+ actual knowledge that, but for the patent license, your conveying the
509
+ covered work in a country, or your recipient's use of the covered work
510
+ in a country, would infringe one or more identifiable patents in that
511
+ country that you have reason to believe are valid.
512
+
513
+ If, pursuant to or in connection with a single transaction or
514
+ arrangement, you convey, or propagate by procuring conveyance of, a
515
+ covered work, and grant a patent license to some of the parties
516
+ receiving the covered work authorizing them to use, propagate, modify
517
+ or convey a specific copy of the covered work, then the patent license
518
+ you grant is automatically extended to all recipients of the covered
519
+ work and works based on it.
520
+
521
+ A patent license is "discriminatory" if it does not include within
522
+ the scope of its coverage, prohibits the exercise of, or is
523
+ conditioned on the non-exercise of one or more of the rights that are
524
+ specifically granted under this License. You may not convey a covered
525
+ work if you are a party to an arrangement with a third party that is
526
+ in the business of distributing software, under which you make payment
527
+ to the third party based on the extent of your activity of conveying
528
+ the work, and under which the third party grants, to any of the
529
+ parties who would receive the covered work from you, a discriminatory
530
+ patent license (a) in connection with copies of the covered work
531
+ conveyed by you (or copies made from those copies), or (b) primarily
532
+ for and in connection with specific products or compilations that
533
+ contain the covered work, unless you entered into that arrangement,
534
+ or that patent license was granted, prior to 28 March 2007.
535
+
536
+ Nothing in this License shall be construed as excluding or limiting
537
+ any implied license or other defenses to infringement that may
538
+ otherwise be available to you under applicable patent law.
539
+
540
+ 12. No Surrender of Others' Freedom.
541
+
542
+ If conditions are imposed on you (whether by court order, agreement or
543
+ otherwise) that contradict the conditions of this License, they do not
544
+ excuse you from the conditions of this License. If you cannot convey a
545
+ covered work so as to satisfy simultaneously your obligations under this
546
+ License and any other pertinent obligations, then as a consequence you may
547
+ not convey it at all. For example, if you agree to terms that obligate you
548
+ to collect a royalty for further conveying from those to whom you convey
549
+ the Program, the only way you could satisfy both those terms and this
550
+ License would be to refrain entirely from conveying the Program.
551
+
552
+ 13. Use with the GNU Affero General Public License.
553
+
554
+ Notwithstanding any other provision of this License, you have
555
+ permission to link or combine any covered work with a work licensed
556
+ under version 3 of the GNU Affero General Public License into a single
557
+ combined work, and to convey the resulting work. The terms of this
558
+ License will continue to apply to the part which is the covered work,
559
+ but the special requirements of the GNU Affero General Public License,
560
+ section 13, concerning interaction through a network will apply to the
561
+ combination as such.
562
+
563
+ 14. Revised Versions of this License.
564
+
565
+ The Free Software Foundation may publish revised and/or new versions of
566
+ the GNU General Public License from time to time. Such new versions will
567
+ be similar in spirit to the present version, but may differ in detail to
568
+ address new problems or concerns.
569
+
570
+ Each version is given a distinguishing version number. If the
571
+ Program specifies that a certain numbered version of the GNU General
572
+ Public License "or any later version" applies to it, you have the
573
+ option of following the terms and conditions either of that numbered
574
+ version or of any later version published by the Free Software
575
+ Foundation. If the Program does not specify a version number of the
576
+ GNU General Public License, you may choose any version ever published
577
+ by the Free Software Foundation.
578
+
579
+ If the Program specifies that a proxy can decide which future
580
+ versions of the GNU General Public License can be used, that proxy's
581
+ public statement of acceptance of a version permanently authorizes you
582
+ to choose that version for the Program.
583
+
584
+ Later license versions may give you additional or different
585
+ permissions. However, no additional obligations are imposed on any
586
+ author or copyright holder as a result of your choosing to follow a
587
+ later version.
588
+
589
+ 15. Disclaimer of Warranty.
590
+
591
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
+
600
+ 16. Limitation of Liability.
601
+
602
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610
+ SUCH DAMAGES.
611
+
612
+ 17. Interpretation of Sections 15 and 16.
613
+
614
+ If the disclaimer of warranty and limitation of liability provided
615
+ above cannot be given local legal effect according to their terms,
616
+ reviewing courts shall apply local law that most closely approximates
617
+ an absolute waiver of all civil liability in connection with the
618
+ Program, unless a warranty or assumption of liability accompanies a
619
+ copy of the Program in return for a fee.
620
+
621
+ END OF TERMS AND CONDITIONS
622
+
623
+ How to Apply These Terms to Your New Programs
624
+
625
+ If you develop a new program, and you want it to be of the greatest
626
+ possible use to the public, the best way to achieve this is to make it
627
+ free software which everyone can redistribute and change under these terms.
628
+
629
+ To do so, attach the following notices to the program. It is safest
630
+ to attach them to the start of each source file to most effectively
631
+ state the exclusion of warranty; and each file should have at least
632
+ the "copyright" line and a pointer to where the full notice is found.
633
+
634
+ <one line to give the program's name and a brief idea of what it does.>
635
+ Copyright (C) <year> <name of author>
636
+
637
+ This program is free software: you can redistribute it and/or modify
638
+ it under the terms of the GNU General Public License as published by
639
+ the Free Software Foundation, either version 3 of the License, or
640
+ (at your option) any later version.
641
+
642
+ This program is distributed in the hope that it will be useful,
643
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
644
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645
+ GNU General Public License for more details.
646
+
647
+ You should have received a copy of the GNU General Public License
648
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
649
+
650
+ Also add information on how to contact you by electronic and paper mail.
651
+
652
+ If the program does terminal interaction, make it output a short
653
+ notice like this when it starts in an interactive mode:
654
+
655
+ <program> Copyright (C) <year> <name of author>
656
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657
+ This is free software, and you are welcome to redistribute it
658
+ under certain conditions; type `show c' for details.
659
+
660
+ The hypothetical commands `show w' and `show c' should show the appropriate
661
+ parts of the General Public License. Of course, your program's commands
662
+ might be different; for a GUI interface, you would use an "about box".
663
+
664
+ You should also get your employer (if you work as a programmer) or school,
665
+ if any, to sign a "copyright disclaimer" for the program, if necessary.
666
+ For more information on this, and how to apply and follow the GNU GPL, see
667
+ <http://www.gnu.org/licenses/>.
668
+
669
+ The GNU General Public License does not permit incorporating your program
670
+ into proprietary programs. If your program is a subroutine library, you
671
+ may consider it more useful to permit linking proprietary applications with
672
+ the library. If this is what you want to do, use the GNU Lesser General
673
+ Public License instead of this License. But first, please read
674
+ <http://www.gnu.org/philosophy/why-not-lgpl.html>.
cpp/src/librosa/eigen3/COPYING.LGPL ADDED
@@ -0,0 +1,502 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 2.1, February 1999
3
+
4
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ [This is the first released version of the Lesser GPL. It also counts
10
+ as the successor of the GNU Library Public License, version 2, hence
11
+ the version number 2.1.]
12
+
13
+ Preamble
14
+
15
+ The licenses for most software are designed to take away your
16
+ freedom to share and change it. By contrast, the GNU General Public
17
+ Licenses are intended to guarantee your freedom to share and change
18
+ free software--to make sure the software is free for all its users.
19
+
20
+ This license, the Lesser General Public License, applies to some
21
+ specially designated software packages--typically libraries--of the
22
+ Free Software Foundation and other authors who decide to use it. You
23
+ can use it too, but we suggest you first think carefully about whether
24
+ this license or the ordinary General Public License is the better
25
+ strategy to use in any particular case, based on the explanations below.
26
+
27
+ When we speak of free software, we are referring to freedom of use,
28
+ not price. Our General Public Licenses are designed to make sure that
29
+ you have the freedom to distribute copies of free software (and charge
30
+ for this service if you wish); that you receive source code or can get
31
+ it if you want it; that you can change the software and use pieces of
32
+ it in new free programs; and that you are informed that you can do
33
+ these things.
34
+
35
+ To protect your rights, we need to make restrictions that forbid
36
+ distributors to deny you these rights or to ask you to surrender these
37
+ rights. These restrictions translate to certain responsibilities for
38
+ you if you distribute copies of the library or if you modify it.
39
+
40
+ For example, if you distribute copies of the library, whether gratis
41
+ or for a fee, you must give the recipients all the rights that we gave
42
+ you. You must make sure that they, too, receive or can get the source
43
+ code. If you link other code with the library, you must provide
44
+ complete object files to the recipients, so that they can relink them
45
+ with the library after making changes to the library and recompiling
46
+ it. And you must show them these terms so they know their rights.
47
+
48
+ We protect your rights with a two-step method: (1) we copyright the
49
+ library, and (2) we offer you this license, which gives you legal
50
+ permission to copy, distribute and/or modify the library.
51
+
52
+ To protect each distributor, we want to make it very clear that
53
+ there is no warranty for the free library. Also, if the library is
54
+ modified by someone else and passed on, the recipients should know
55
+ that what they have is not the original version, so that the original
56
+ author's reputation will not be affected by problems that might be
57
+ introduced by others.
58
+
59
+ Finally, software patents pose a constant threat to the existence of
60
+ any free program. We wish to make sure that a company cannot
61
+ effectively restrict the users of a free program by obtaining a
62
+ restrictive license from a patent holder. Therefore, we insist that
63
+ any patent license obtained for a version of the library must be
64
+ consistent with the full freedom of use specified in this license.
65
+
66
+ Most GNU software, including some libraries, is covered by the
67
+ ordinary GNU General Public License. This license, the GNU Lesser
68
+ General Public License, applies to certain designated libraries, and
69
+ is quite different from the ordinary General Public License. We use
70
+ this license for certain libraries in order to permit linking those
71
+ libraries into non-free programs.
72
+
73
+ When a program is linked with a library, whether statically or using
74
+ a shared library, the combination of the two is legally speaking a
75
+ combined work, a derivative of the original library. The ordinary
76
+ General Public License therefore permits such linking only if the
77
+ entire combination fits its criteria of freedom. The Lesser General
78
+ Public License permits more lax criteria for linking other code with
79
+ the library.
80
+
81
+ We call this license the "Lesser" General Public License because it
82
+ does Less to protect the user's freedom than the ordinary General
83
+ Public License. It also provides other free software developers Less
84
+ of an advantage over competing non-free programs. These disadvantages
85
+ are the reason we use the ordinary General Public License for many
86
+ libraries. However, the Lesser license provides advantages in certain
87
+ special circumstances.
88
+
89
+ For example, on rare occasions, there may be a special need to
90
+ encourage the widest possible use of a certain library, so that it becomes
91
+ a de-facto standard. To achieve this, non-free programs must be
92
+ allowed to use the library. A more frequent case is that a free
93
+ library does the same job as widely used non-free libraries. In this
94
+ case, there is little to gain by limiting the free library to free
95
+ software only, so we use the Lesser General Public License.
96
+
97
+ In other cases, permission to use a particular library in non-free
98
+ programs enables a greater number of people to use a large body of
99
+ free software. For example, permission to use the GNU C Library in
100
+ non-free programs enables many more people to use the whole GNU
101
+ operating system, as well as its variant, the GNU/Linux operating
102
+ system.
103
+
104
+ Although the Lesser General Public License is Less protective of the
105
+ users' freedom, it does ensure that the user of a program that is
106
+ linked with the Library has the freedom and the wherewithal to run
107
+ that program using a modified version of the Library.
108
+
109
+ The precise terms and conditions for copying, distribution and
110
+ modification follow. Pay close attention to the difference between a
111
+ "work based on the library" and a "work that uses the library". The
112
+ former contains code derived from the library, whereas the latter must
113
+ be combined with the library in order to run.
114
+
115
+ GNU LESSER GENERAL PUBLIC LICENSE
116
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
117
+
118
+ 0. This License Agreement applies to any software library or other
119
+ program which contains a notice placed by the copyright holder or
120
+ other authorized party saying it may be distributed under the terms of
121
+ this Lesser General Public License (also called "this License").
122
+ Each licensee is addressed as "you".
123
+
124
+ A "library" means a collection of software functions and/or data
125
+ prepared so as to be conveniently linked with application programs
126
+ (which use some of those functions and data) to form executables.
127
+
128
+ The "Library", below, refers to any such software library or work
129
+ which has been distributed under these terms. A "work based on the
130
+ Library" means either the Library or any derivative work under
131
+ copyright law: that is to say, a work containing the Library or a
132
+ portion of it, either verbatim or with modifications and/or translated
133
+ straightforwardly into another language. (Hereinafter, translation is
134
+ included without limitation in the term "modification".)
135
+
136
+ "Source code" for a work means the preferred form of the work for
137
+ making modifications to it. For a library, complete source code means
138
+ all the source code for all modules it contains, plus any associated
139
+ interface definition files, plus the scripts used to control compilation
140
+ and installation of the library.
141
+
142
+ Activities other than copying, distribution and modification are not
143
+ covered by this License; they are outside its scope. The act of
144
+ running a program using the Library is not restricted, and output from
145
+ such a program is covered only if its contents constitute a work based
146
+ on the Library (independent of the use of the Library in a tool for
147
+ writing it). Whether that is true depends on what the Library does
148
+ and what the program that uses the Library does.
149
+
150
+ 1. You may copy and distribute verbatim copies of the Library's
151
+ complete source code as you receive it, in any medium, provided that
152
+ you conspicuously and appropriately publish on each copy an
153
+ appropriate copyright notice and disclaimer of warranty; keep intact
154
+ all the notices that refer to this License and to the absence of any
155
+ warranty; and distribute a copy of this License along with the
156
+ Library.
157
+
158
+ You may charge a fee for the physical act of transferring a copy,
159
+ and you may at your option offer warranty protection in exchange for a
160
+ fee.
161
+
162
+ 2. You may modify your copy or copies of the Library or any portion
163
+ of it, thus forming a work based on the Library, and copy and
164
+ distribute such modifications or work under the terms of Section 1
165
+ above, provided that you also meet all of these conditions:
166
+
167
+ a) The modified work must itself be a software library.
168
+
169
+ b) You must cause the files modified to carry prominent notices
170
+ stating that you changed the files and the date of any change.
171
+
172
+ c) You must cause the whole of the work to be licensed at no
173
+ charge to all third parties under the terms of this License.
174
+
175
+ d) If a facility in the modified Library refers to a function or a
176
+ table of data to be supplied by an application program that uses
177
+ the facility, other than as an argument passed when the facility
178
+ is invoked, then you must make a good faith effort to ensure that,
179
+ in the event an application does not supply such function or
180
+ table, the facility still operates, and performs whatever part of
181
+ its purpose remains meaningful.
182
+
183
+ (For example, a function in a library to compute square roots has
184
+ a purpose that is entirely well-defined independent of the
185
+ application. Therefore, Subsection 2d requires that any
186
+ application-supplied function or table used by this function must
187
+ be optional: if the application does not supply it, the square
188
+ root function must still compute square roots.)
189
+
190
+ These requirements apply to the modified work as a whole. If
191
+ identifiable sections of that work are not derived from the Library,
192
+ and can be reasonably considered independent and separate works in
193
+ themselves, then this License, and its terms, do not apply to those
194
+ sections when you distribute them as separate works. But when you
195
+ distribute the same sections as part of a whole which is a work based
196
+ on the Library, the distribution of the whole must be on the terms of
197
+ this License, whose permissions for other licensees extend to the
198
+ entire whole, and thus to each and every part regardless of who wrote
199
+ it.
200
+
201
+ Thus, it is not the intent of this section to claim rights or contest
202
+ your rights to work written entirely by you; rather, the intent is to
203
+ exercise the right to control the distribution of derivative or
204
+ collective works based on the Library.
205
+
206
+ In addition, mere aggregation of another work not based on the Library
207
+ with the Library (or with a work based on the Library) on a volume of
208
+ a storage or distribution medium does not bring the other work under
209
+ the scope of this License.
210
+
211
+ 3. You may opt to apply the terms of the ordinary GNU General Public
212
+ License instead of this License to a given copy of the Library. To do
213
+ this, you must alter all the notices that refer to this License, so
214
+ that they refer to the ordinary GNU General Public License, version 2,
215
+ instead of to this License. (If a newer version than version 2 of the
216
+ ordinary GNU General Public License has appeared, then you can specify
217
+ that version instead if you wish.) Do not make any other change in
218
+ these notices.
219
+
220
+ Once this change is made in a given copy, it is irreversible for
221
+ that copy, so the ordinary GNU General Public License applies to all
222
+ subsequent copies and derivative works made from that copy.
223
+
224
+ This option is useful when you wish to copy part of the code of
225
+ the Library into a program that is not a library.
226
+
227
+ 4. You may copy and distribute the Library (or a portion or
228
+ derivative of it, under Section 2) in object code or executable form
229
+ under the terms of Sections 1 and 2 above provided that you accompany
230
+ it with the complete corresponding machine-readable source code, which
231
+ must be distributed under the terms of Sections 1 and 2 above on a
232
+ medium customarily used for software interchange.
233
+
234
+ If distribution of object code is made by offering access to copy
235
+ from a designated place, then offering equivalent access to copy the
236
+ source code from the same place satisfies the requirement to
237
+ distribute the source code, even though third parties are not
238
+ compelled to copy the source along with the object code.
239
+
240
+ 5. A program that contains no derivative of any portion of the
241
+ Library, but is designed to work with the Library by being compiled or
242
+ linked with it, is called a "work that uses the Library". Such a
243
+ work, in isolation, is not a derivative work of the Library, and
244
+ therefore falls outside the scope of this License.
245
+
246
+ However, linking a "work that uses the Library" with the Library
247
+ creates an executable that is a derivative of the Library (because it
248
+ contains portions of the Library), rather than a "work that uses the
249
+ library". The executable is therefore covered by this License.
250
+ Section 6 states terms for distribution of such executables.
251
+
252
+ When a "work that uses the Library" uses material from a header file
253
+ that is part of the Library, the object code for the work may be a
254
+ derivative work of the Library even though the source code is not.
255
+ Whether this is true is especially significant if the work can be
256
+ linked without the Library, or if the work is itself a library. The
257
+ threshold for this to be true is not precisely defined by law.
258
+
259
+ If such an object file uses only numerical parameters, data
260
+ structure layouts and accessors, and small macros and small inline
261
+ functions (ten lines or less in length), then the use of the object
262
+ file is unrestricted, regardless of whether it is legally a derivative
263
+ work. (Executables containing this object code plus portions of the
264
+ Library will still fall under Section 6.)
265
+
266
+ Otherwise, if the work is a derivative of the Library, you may
267
+ distribute the object code for the work under the terms of Section 6.
268
+ Any executables containing that work also fall under Section 6,
269
+ whether or not they are linked directly with the Library itself.
270
+
271
+ 6. As an exception to the Sections above, you may also combine or
272
+ link a "work that uses the Library" with the Library to produce a
273
+ work containing portions of the Library, and distribute that work
274
+ under terms of your choice, provided that the terms permit
275
+ modification of the work for the customer's own use and reverse
276
+ engineering for debugging such modifications.
277
+
278
+ You must give prominent notice with each copy of the work that the
279
+ Library is used in it and that the Library and its use are covered by
280
+ this License. You must supply a copy of this License. If the work
281
+ during execution displays copyright notices, you must include the
282
+ copyright notice for the Library among them, as well as a reference
283
+ directing the user to the copy of this License. Also, you must do one
284
+ of these things:
285
+
286
+ a) Accompany the work with the complete corresponding
287
+ machine-readable source code for the Library including whatever
288
+ changes were used in the work (which must be distributed under
289
+ Sections 1 and 2 above); and, if the work is an executable linked
290
+ with the Library, with the complete machine-readable "work that
291
+ uses the Library", as object code and/or source code, so that the
292
+ user can modify the Library and then relink to produce a modified
293
+ executable containing the modified Library. (It is understood
294
+ that the user who changes the contents of definitions files in the
295
+ Library will not necessarily be able to recompile the application
296
+ to use the modified definitions.)
297
+
298
+ b) Use a suitable shared library mechanism for linking with the
299
+ Library. A suitable mechanism is one that (1) uses at run time a
300
+ copy of the library already present on the user's computer system,
301
+ rather than copying library functions into the executable, and (2)
302
+ will operate properly with a modified version of the library, if
303
+ the user installs one, as long as the modified version is
304
+ interface-compatible with the version that the work was made with.
305
+
306
+ c) Accompany the work with a written offer, valid for at
307
+ least three years, to give the same user the materials
308
+ specified in Subsection 6a, above, for a charge no more
309
+ than the cost of performing this distribution.
310
+
311
+ d) If distribution of the work is made by offering access to copy
312
+ from a designated place, offer equivalent access to copy the above
313
+ specified materials from the same place.
314
+
315
+ e) Verify that the user has already received a copy of these
316
+ materials or that you have already sent this user a copy.
317
+
318
+ For an executable, the required form of the "work that uses the
319
+ Library" must include any data and utility programs needed for
320
+ reproducing the executable from it. However, as a special exception,
321
+ the materials to be distributed need not include anything that is
322
+ normally distributed (in either source or binary form) with the major
323
+ components (compiler, kernel, and so on) of the operating system on
324
+ which the executable runs, unless that component itself accompanies
325
+ the executable.
326
+
327
+ It may happen that this requirement contradicts the license
328
+ restrictions of other proprietary libraries that do not normally
329
+ accompany the operating system. Such a contradiction means you cannot
330
+ use both them and the Library together in an executable that you
331
+ distribute.
332
+
333
+ 7. You may place library facilities that are a work based on the
334
+ Library side-by-side in a single library together with other library
335
+ facilities not covered by this License, and distribute such a combined
336
+ library, provided that the separate distribution of the work based on
337
+ the Library and of the other library facilities is otherwise
338
+ permitted, and provided that you do these two things:
339
+
340
+ a) Accompany the combined library with a copy of the same work
341
+ based on the Library, uncombined with any other library
342
+ facilities. This must be distributed under the terms of the
343
+ Sections above.
344
+
345
+ b) Give prominent notice with the combined library of the fact
346
+ that part of it is a work based on the Library, and explaining
347
+ where to find the accompanying uncombined form of the same work.
348
+
349
+ 8. You may not copy, modify, sublicense, link with, or distribute
350
+ the Library except as expressly provided under this License. Any
351
+ attempt otherwise to copy, modify, sublicense, link with, or
352
+ distribute the Library is void, and will automatically terminate your
353
+ rights under this License. However, parties who have received copies,
354
+ or rights, from you under this License will not have their licenses
355
+ terminated so long as such parties remain in full compliance.
356
+
357
+ 9. You are not required to accept this License, since you have not
358
+ signed it. However, nothing else grants you permission to modify or
359
+ distribute the Library or its derivative works. These actions are
360
+ prohibited by law if you do not accept this License. Therefore, by
361
+ modifying or distributing the Library (or any work based on the
362
+ Library), you indicate your acceptance of this License to do so, and
363
+ all its terms and conditions for copying, distributing or modifying
364
+ the Library or works based on it.
365
+
366
+ 10. Each time you redistribute the Library (or any work based on the
367
+ Library), the recipient automatically receives a license from the
368
+ original licensor to copy, distribute, link with or modify the Library
369
+ subject to these terms and conditions. You may not impose any further
370
+ restrictions on the recipients' exercise of the rights granted herein.
371
+ You are not responsible for enforcing compliance by third parties with
372
+ this License.
373
+
374
+ 11. If, as a consequence of a court judgment or allegation of patent
375
+ infringement or for any other reason (not limited to patent issues),
376
+ conditions are imposed on you (whether by court order, agreement or
377
+ otherwise) that contradict the conditions of this License, they do not
378
+ excuse you from the conditions of this License. If you cannot
379
+ distribute so as to satisfy simultaneously your obligations under this
380
+ License and any other pertinent obligations, then as a consequence you
381
+ may not distribute the Library at all. For example, if a patent
382
+ license would not permit royalty-free redistribution of the Library by
383
+ all those who receive copies directly or indirectly through you, then
384
+ the only way you could satisfy both it and this License would be to
385
+ refrain entirely from distribution of the Library.
386
+
387
+ If any portion of this section is held invalid or unenforceable under any
388
+ particular circumstance, the balance of the section is intended to apply,
389
+ and the section as a whole is intended to apply in other circumstances.
390
+
391
+ It is not the purpose of this section to induce you to infringe any
392
+ patents or other property right claims or to contest validity of any
393
+ such claims; this section has the sole purpose of protecting the
394
+ integrity of the free software distribution system which is
395
+ implemented by public license practices. Many people have made
396
+ generous contributions to the wide range of software distributed
397
+ through that system in reliance on consistent application of that
398
+ system; it is up to the author/donor to decide if he or she is willing
399
+ to distribute software through any other system and a licensee cannot
400
+ impose that choice.
401
+
402
+ This section is intended to make thoroughly clear what is believed to
403
+ be a consequence of the rest of this License.
404
+
405
+ 12. If the distribution and/or use of the Library is restricted in
406
+ certain countries either by patents or by copyrighted interfaces, the
407
+ original copyright holder who places the Library under this License may add
408
+ an explicit geographical distribution limitation excluding those countries,
409
+ so that distribution is permitted only in or among countries not thus
410
+ excluded. In such case, this License incorporates the limitation as if
411
+ written in the body of this License.
412
+
413
+ 13. The Free Software Foundation may publish revised and/or new
414
+ versions of the Lesser General Public License from time to time.
415
+ Such new versions will be similar in spirit to the present version,
416
+ but may differ in detail to address new problems or concerns.
417
+
418
+ Each version is given a distinguishing version number. If the Library
419
+ specifies a version number of this License which applies to it and
420
+ "any later version", you have the option of following the terms and
421
+ conditions either of that version or of any later version published by
422
+ the Free Software Foundation. If the Library does not specify a
423
+ license version number, you may choose any version ever published by
424
+ the Free Software Foundation.
425
+
426
+ 14. If you wish to incorporate parts of the Library into other free
427
+ programs whose distribution conditions are incompatible with these,
428
+ write to the author to ask for permission. For software which is
429
+ copyrighted by the Free Software Foundation, write to the Free
430
+ Software Foundation; we sometimes make exceptions for this. Our
431
+ decision will be guided by the two goals of preserving the free status
432
+ of all derivatives of our free software and of promoting the sharing
433
+ and reuse of software generally.
434
+
435
+ NO WARRANTY
436
+
437
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
438
+ WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
439
+ EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
440
+ OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
441
+ KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
442
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
443
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
444
+ LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
445
+ THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
446
+
447
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
448
+ WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
449
+ AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
450
+ FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
451
+ CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
452
+ LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
453
+ RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
454
+ FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
455
+ SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
456
+ DAMAGES.
457
+
458
+ END OF TERMS AND CONDITIONS
459
+
460
+ How to Apply These Terms to Your New Libraries
461
+
462
+ If you develop a new library, and you want it to be of the greatest
463
+ possible use to the public, we recommend making it free software that
464
+ everyone can redistribute and change. You can do so by permitting
465
+ redistribution under these terms (or, alternatively, under the terms of the
466
+ ordinary General Public License).
467
+
468
+ To apply these terms, attach the following notices to the library. It is
469
+ safest to attach them to the start of each source file to most effectively
470
+ convey the exclusion of warranty; and each file should have at least the
471
+ "copyright" line and a pointer to where the full notice is found.
472
+
473
+ <one line to give the library's name and a brief idea of what it does.>
474
+ Copyright (C) <year> <name of author>
475
+
476
+ This library is free software; you can redistribute it and/or
477
+ modify it under the terms of the GNU Lesser General Public
478
+ License as published by the Free Software Foundation; either
479
+ version 2.1 of the License, or (at your option) any later version.
480
+
481
+ This library is distributed in the hope that it will be useful,
482
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
483
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
484
+ Lesser General Public License for more details.
485
+
486
+ You should have received a copy of the GNU Lesser General Public
487
+ License along with this library; if not, write to the Free Software
488
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
489
+
490
+ Also add information on how to contact you by electronic and paper mail.
491
+
492
+ You should also get your employer (if you work as a programmer) or your
493
+ school, if any, to sign a "copyright disclaimer" for the library, if
494
+ necessary. Here is a sample; alter the names:
495
+
496
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
497
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
498
+
499
+ <signature of Ty Coon>, 1 April 1990
500
+ Ty Coon, President of Vice
501
+
502
+ That's all there is to it!
cpp/src/librosa/eigen3/COPYING.MINPACK ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Minpack Copyright Notice (1999) University of Chicago. All rights reserved
2
+
3
+ Redistribution and use in source and binary forms, with or
4
+ without modification, are permitted provided that the
5
+ following conditions are met:
6
+
7
+ 1. Redistributions of source code must retain the above
8
+ copyright notice, this list of conditions and the following
9
+ disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above
12
+ copyright notice, this list of conditions and the following
13
+ disclaimer in the documentation and/or other materials
14
+ provided with the distribution.
15
+
16
+ 3. The end-user documentation included with the
17
+ redistribution, if any, must include the following
18
+ acknowledgment:
19
+
20
+ "This product includes software developed by the
21
+ University of Chicago, as Operator of Argonne National
22
+ Laboratory.
23
+
24
+ Alternately, this acknowledgment may appear in the software
25
+ itself, if and wherever such third-party acknowledgments
26
+ normally appear.
27
+
28
+ 4. WARRANTY DISCLAIMER. THE SOFTWARE IS SUPPLIED "AS IS"
29
+ WITHOUT WARRANTY OF ANY KIND. THE COPYRIGHT HOLDER, THE
30
+ UNITED STATES, THE UNITED STATES DEPARTMENT OF ENERGY, AND
31
+ THEIR EMPLOYEES: (1) DISCLAIM ANY WARRANTIES, EXPRESS OR
32
+ IMPLIED, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES
33
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE
34
+ OR NON-INFRINGEMENT, (2) DO NOT ASSUME ANY LEGAL LIABILITY
35
+ OR RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR
36
+ USEFULNESS OF THE SOFTWARE, (3) DO NOT REPRESENT THAT USE OF
37
+ THE SOFTWARE WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS, (4)
38
+ DO NOT WARRANT THAT THE SOFTWARE WILL FUNCTION
39
+ UNINTERRUPTED, THAT IT IS ERROR-FREE OR THAT ANY ERRORS WILL
40
+ BE CORRECTED.
41
+
42
+ 5. LIMITATION OF LIABILITY. IN NO EVENT WILL THE COPYRIGHT
43
+ HOLDER, THE UNITED STATES, THE UNITED STATES DEPARTMENT OF
44
+ ENERGY, OR THEIR EMPLOYEES: BE LIABLE FOR ANY INDIRECT,
45
+ INCIDENTAL, CONSEQUENTIAL, SPECIAL OR PUNITIVE DAMAGES OF
46
+ ANY KIND OR NATURE, INCLUDING BUT NOT LIMITED TO LOSS OF
47
+ PROFITS OR LOSS OF DATA, FOR ANY REASON WHATSOEVER, WHETHER
48
+ SUCH LIABILITY IS ASSERTED ON THE BASIS OF CONTRACT, TORT
49
+ (INCLUDING NEGLIGENCE OR STRICT LIABILITY), OR OTHERWISE,
50
+ EVEN IF ANY OF SAID PARTIES HAS BEEN WARNED OF THE
51
+ POSSIBILITY OF SUCH LOSS OR DAMAGES.
52
+
cpp/src/librosa/eigen3/COPYING.MPL2 ADDED
@@ -0,0 +1,373 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Mozilla Public License Version 2.0
2
+ ==================================
3
+
4
+ 1. Definitions
5
+ --------------
6
+
7
+ 1.1. "Contributor"
8
+ means each individual or legal entity that creates, contributes to
9
+ the creation of, or owns Covered Software.
10
+
11
+ 1.2. "Contributor Version"
12
+ means the combination of the Contributions of others (if any) used
13
+ by a Contributor and that particular Contributor's Contribution.
14
+
15
+ 1.3. "Contribution"
16
+ means Covered Software of a particular Contributor.
17
+
18
+ 1.4. "Covered Software"
19
+ means Source Code Form to which the initial Contributor has attached
20
+ the notice in Exhibit A, the Executable Form of such Source Code
21
+ Form, and Modifications of such Source Code Form, in each case
22
+ including portions thereof.
23
+
24
+ 1.5. "Incompatible With Secondary Licenses"
25
+ means
26
+
27
+ (a) that the initial Contributor has attached the notice described
28
+ in Exhibit B to the Covered Software; or
29
+
30
+ (b) that the Covered Software was made available under the terms of
31
+ version 1.1 or earlier of the License, but not also under the
32
+ terms of a Secondary License.
33
+
34
+ 1.6. "Executable Form"
35
+ means any form of the work other than Source Code Form.
36
+
37
+ 1.7. "Larger Work"
38
+ means a work that combines Covered Software with other material, in
39
+ a separate file or files, that is not Covered Software.
40
+
41
+ 1.8. "License"
42
+ means this document.
43
+
44
+ 1.9. "Licensable"
45
+ means having the right to grant, to the maximum extent possible,
46
+ whether at the time of the initial grant or subsequently, any and
47
+ all of the rights conveyed by this License.
48
+
49
+ 1.10. "Modifications"
50
+ means any of the following:
51
+
52
+ (a) any file in Source Code Form that results from an addition to,
53
+ deletion from, or modification of the contents of Covered
54
+ Software; or
55
+
56
+ (b) any new file in Source Code Form that contains any Covered
57
+ Software.
58
+
59
+ 1.11. "Patent Claims" of a Contributor
60
+ means any patent claim(s), including without limitation, method,
61
+ process, and apparatus claims, in any patent Licensable by such
62
+ Contributor that would be infringed, but for the grant of the
63
+ License, by the making, using, selling, offering for sale, having
64
+ made, import, or transfer of either its Contributions or its
65
+ Contributor Version.
66
+
67
+ 1.12. "Secondary License"
68
+ means either the GNU General Public License, Version 2.0, the GNU
69
+ Lesser General Public License, Version 2.1, the GNU Affero General
70
+ Public License, Version 3.0, or any later versions of those
71
+ licenses.
72
+
73
+ 1.13. "Source Code Form"
74
+ means the form of the work preferred for making modifications.
75
+
76
+ 1.14. "You" (or "Your")
77
+ means an individual or a legal entity exercising rights under this
78
+ License. For legal entities, "You" includes any entity that
79
+ controls, is controlled by, or is under common control with You. For
80
+ purposes of this definition, "control" means (a) the power, direct
81
+ or indirect, to cause the direction or management of such entity,
82
+ whether by contract or otherwise, or (b) ownership of more than
83
+ fifty percent (50%) of the outstanding shares or beneficial
84
+ ownership of such entity.
85
+
86
+ 2. License Grants and Conditions
87
+ --------------------------------
88
+
89
+ 2.1. Grants
90
+
91
+ Each Contributor hereby grants You a world-wide, royalty-free,
92
+ non-exclusive license:
93
+
94
+ (a) under intellectual property rights (other than patent or trademark)
95
+ Licensable by such Contributor to use, reproduce, make available,
96
+ modify, display, perform, distribute, and otherwise exploit its
97
+ Contributions, either on an unmodified basis, with Modifications, or
98
+ as part of a Larger Work; and
99
+
100
+ (b) under Patent Claims of such Contributor to make, use, sell, offer
101
+ for sale, have made, import, and otherwise transfer either its
102
+ Contributions or its Contributor Version.
103
+
104
+ 2.2. Effective Date
105
+
106
+ The licenses granted in Section 2.1 with respect to any Contribution
107
+ become effective for each Contribution on the date the Contributor first
108
+ distributes such Contribution.
109
+
110
+ 2.3. Limitations on Grant Scope
111
+
112
+ The licenses granted in this Section 2 are the only rights granted under
113
+ this License. No additional rights or licenses will be implied from the
114
+ distribution or licensing of Covered Software under this License.
115
+ Notwithstanding Section 2.1(b) above, no patent license is granted by a
116
+ Contributor:
117
+
118
+ (a) for any code that a Contributor has removed from Covered Software;
119
+ or
120
+
121
+ (b) for infringements caused by: (i) Your and any other third party's
122
+ modifications of Covered Software, or (ii) the combination of its
123
+ Contributions with other software (except as part of its Contributor
124
+ Version); or
125
+
126
+ (c) under Patent Claims infringed by Covered Software in the absence of
127
+ its Contributions.
128
+
129
+ This License does not grant any rights in the trademarks, service marks,
130
+ or logos of any Contributor (except as may be necessary to comply with
131
+ the notice requirements in Section 3.4).
132
+
133
+ 2.4. Subsequent Licenses
134
+
135
+ No Contributor makes additional grants as a result of Your choice to
136
+ distribute the Covered Software under a subsequent version of this
137
+ License (see Section 10.2) or under the terms of a Secondary License (if
138
+ permitted under the terms of Section 3.3).
139
+
140
+ 2.5. Representation
141
+
142
+ Each Contributor represents that the Contributor believes its
143
+ Contributions are its original creation(s) or it has sufficient rights
144
+ to grant the rights to its Contributions conveyed by this License.
145
+
146
+ 2.6. Fair Use
147
+
148
+ This License is not intended to limit any rights You have under
149
+ applicable copyright doctrines of fair use, fair dealing, or other
150
+ equivalents.
151
+
152
+ 2.7. Conditions
153
+
154
+ Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
155
+ in Section 2.1.
156
+
157
+ 3. Responsibilities
158
+ -------------------
159
+
160
+ 3.1. Distribution of Source Form
161
+
162
+ All distribution of Covered Software in Source Code Form, including any
163
+ Modifications that You create or to which You contribute, must be under
164
+ the terms of this License. You must inform recipients that the Source
165
+ Code Form of the Covered Software is governed by the terms of this
166
+ License, and how they can obtain a copy of this License. You may not
167
+ attempt to alter or restrict the recipients' rights in the Source Code
168
+ Form.
169
+
170
+ 3.2. Distribution of Executable Form
171
+
172
+ If You distribute Covered Software in Executable Form then:
173
+
174
+ (a) such Covered Software must also be made available in Source Code
175
+ Form, as described in Section 3.1, and You must inform recipients of
176
+ the Executable Form how they can obtain a copy of such Source Code
177
+ Form by reasonable means in a timely manner, at a charge no more
178
+ than the cost of distribution to the recipient; and
179
+
180
+ (b) You may distribute such Executable Form under the terms of this
181
+ License, or sublicense it under different terms, provided that the
182
+ license for the Executable Form does not attempt to limit or alter
183
+ the recipients' rights in the Source Code Form under this License.
184
+
185
+ 3.3. Distribution of a Larger Work
186
+
187
+ You may create and distribute a Larger Work under terms of Your choice,
188
+ provided that You also comply with the requirements of this License for
189
+ the Covered Software. If the Larger Work is a combination of Covered
190
+ Software with a work governed by one or more Secondary Licenses, and the
191
+ Covered Software is not Incompatible With Secondary Licenses, this
192
+ License permits You to additionally distribute such Covered Software
193
+ under the terms of such Secondary License(s), so that the recipient of
194
+ the Larger Work may, at their option, further distribute the Covered
195
+ Software under the terms of either this License or such Secondary
196
+ License(s).
197
+
198
+ 3.4. Notices
199
+
200
+ You may not remove or alter the substance of any license notices
201
+ (including copyright notices, patent notices, disclaimers of warranty,
202
+ or limitations of liability) contained within the Source Code Form of
203
+ the Covered Software, except that You may alter any license notices to
204
+ the extent required to remedy known factual inaccuracies.
205
+
206
+ 3.5. Application of Additional Terms
207
+
208
+ You may choose to offer, and to charge a fee for, warranty, support,
209
+ indemnity or liability obligations to one or more recipients of Covered
210
+ Software. However, You may do so only on Your own behalf, and not on
211
+ behalf of any Contributor. You must make it absolutely clear that any
212
+ such warranty, support, indemnity, or liability obligation is offered by
213
+ You alone, and You hereby agree to indemnify every Contributor for any
214
+ liability incurred by such Contributor as a result of warranty, support,
215
+ indemnity or liability terms You offer. You may include additional
216
+ disclaimers of warranty and limitations of liability specific to any
217
+ jurisdiction.
218
+
219
+ 4. Inability to Comply Due to Statute or Regulation
220
+ ---------------------------------------------------
221
+
222
+ If it is impossible for You to comply with any of the terms of this
223
+ License with respect to some or all of the Covered Software due to
224
+ statute, judicial order, or regulation then You must: (a) comply with
225
+ the terms of this License to the maximum extent possible; and (b)
226
+ describe the limitations and the code they affect. Such description must
227
+ be placed in a text file included with all distributions of the Covered
228
+ Software under this License. Except to the extent prohibited by statute
229
+ or regulation, such description must be sufficiently detailed for a
230
+ recipient of ordinary skill to be able to understand it.
231
+
232
+ 5. Termination
233
+ --------------
234
+
235
+ 5.1. The rights granted under this License will terminate automatically
236
+ if You fail to comply with any of its terms. However, if You become
237
+ compliant, then the rights granted under this License from a particular
238
+ Contributor are reinstated (a) provisionally, unless and until such
239
+ Contributor explicitly and finally terminates Your grants, and (b) on an
240
+ ongoing basis, if such Contributor fails to notify You of the
241
+ non-compliance by some reasonable means prior to 60 days after You have
242
+ come back into compliance. Moreover, Your grants from a particular
243
+ Contributor are reinstated on an ongoing basis if such Contributor
244
+ notifies You of the non-compliance by some reasonable means, this is the
245
+ first time You have received notice of non-compliance with this License
246
+ from such Contributor, and You become compliant prior to 30 days after
247
+ Your receipt of the notice.
248
+
249
+ 5.2. If You initiate litigation against any entity by asserting a patent
250
+ infringement claim (excluding declaratory judgment actions,
251
+ counter-claims, and cross-claims) alleging that a Contributor Version
252
+ directly or indirectly infringes any patent, then the rights granted to
253
+ You by any and all Contributors for the Covered Software under Section
254
+ 2.1 of this License shall terminate.
255
+
256
+ 5.3. In the event of termination under Sections 5.1 or 5.2 above, all
257
+ end user license agreements (excluding distributors and resellers) which
258
+ have been validly granted by You or Your distributors under this License
259
+ prior to termination shall survive termination.
260
+
261
+ ************************************************************************
262
+ * *
263
+ * 6. Disclaimer of Warranty *
264
+ * ------------------------- *
265
+ * *
266
+ * Covered Software is provided under this License on an "as is" *
267
+ * basis, without warranty of any kind, either expressed, implied, or *
268
+ * statutory, including, without limitation, warranties that the *
269
+ * Covered Software is free of defects, merchantable, fit for a *
270
+ * particular purpose or non-infringing. The entire risk as to the *
271
+ * quality and performance of the Covered Software is with You. *
272
+ * Should any Covered Software prove defective in any respect, You *
273
+ * (not any Contributor) assume the cost of any necessary servicing, *
274
+ * repair, or correction. This disclaimer of warranty constitutes an *
275
+ * essential part of this License. No use of any Covered Software is *
276
+ * authorized under this License except under this disclaimer. *
277
+ * *
278
+ ************************************************************************
279
+
280
+ ************************************************************************
281
+ * *
282
+ * 7. Limitation of Liability *
283
+ * -------------------------- *
284
+ * *
285
+ * Under no circumstances and under no legal theory, whether tort *
286
+ * (including negligence), contract, or otherwise, shall any *
287
+ * Contributor, or anyone who distributes Covered Software as *
288
+ * permitted above, be liable to You for any direct, indirect, *
289
+ * special, incidental, or consequential damages of any character *
290
+ * including, without limitation, damages for lost profits, loss of *
291
+ * goodwill, work stoppage, computer failure or malfunction, or any *
292
+ * and all other commercial damages or losses, even if such party *
293
+ * shall have been informed of the possibility of such damages. This *
294
+ * limitation of liability shall not apply to liability for death or *
295
+ * personal injury resulting from such party's negligence to the *
296
+ * extent applicable law prohibits such limitation. Some *
297
+ * jurisdictions do not allow the exclusion or limitation of *
298
+ * incidental or consequential damages, so this exclusion and *
299
+ * limitation may not apply to You. *
300
+ * *
301
+ ************************************************************************
302
+
303
+ 8. Litigation
304
+ -------------
305
+
306
+ Any litigation relating to this License may be brought only in the
307
+ courts of a jurisdiction where the defendant maintains its principal
308
+ place of business and such litigation shall be governed by laws of that
309
+ jurisdiction, without reference to its conflict-of-law provisions.
310
+ Nothing in this Section shall prevent a party's ability to bring
311
+ cross-claims or counter-claims.
312
+
313
+ 9. Miscellaneous
314
+ ----------------
315
+
316
+ This License represents the complete agreement concerning the subject
317
+ matter hereof. If any provision of this License is held to be
318
+ unenforceable, such provision shall be reformed only to the extent
319
+ necessary to make it enforceable. Any law or regulation which provides
320
+ that the language of a contract shall be construed against the drafter
321
+ shall not be used to construe this License against a Contributor.
322
+
323
+ 10. Versions of the License
324
+ ---------------------------
325
+
326
+ 10.1. New Versions
327
+
328
+ Mozilla Foundation is the license steward. Except as provided in Section
329
+ 10.3, no one other than the license steward has the right to modify or
330
+ publish new versions of this License. Each version will be given a
331
+ distinguishing version number.
332
+
333
+ 10.2. Effect of New Versions
334
+
335
+ You may distribute the Covered Software under the terms of the version
336
+ of the License under which You originally received the Covered Software,
337
+ or under the terms of any subsequent version published by the license
338
+ steward.
339
+
340
+ 10.3. Modified Versions
341
+
342
+ If you create software not governed by this License, and you want to
343
+ create a new license for such software, you may create and use a
344
+ modified version of this License if you rename the license and remove
345
+ any references to the name of the license steward (except to note that
346
+ such modified license differs from this License).
347
+
348
+ 10.4. Distributing Source Code Form that is Incompatible With Secondary
349
+ Licenses
350
+
351
+ If You choose to distribute Source Code Form that is Incompatible With
352
+ Secondary Licenses under the terms of this version of the License, the
353
+ notice described in Exhibit B of this License must be attached.
354
+
355
+ Exhibit A - Source Code Form License Notice
356
+ -------------------------------------------
357
+
358
+ This Source Code Form is subject to the terms of the Mozilla Public
359
+ License, v. 2.0. If a copy of the MPL was not distributed with this
360
+ file, You can obtain one at http://mozilla.org/MPL/2.0/.
361
+
362
+ If it is not possible or desirable to put the notice in a particular
363
+ file, then You may include the notice in a location (such as a LICENSE
364
+ file in a relevant directory) where a recipient would be likely to look
365
+ for such a notice.
366
+
367
+ You may add additional accurate notices of copyright ownership.
368
+
369
+ Exhibit B - "Incompatible With Secondary Licenses" Notice
370
+ ---------------------------------------------------------
371
+
372
+ This Source Code Form is "Incompatible With Secondary Licenses", as
373
+ defined by the Mozilla Public License, v. 2.0.
cpp/src/librosa/eigen3/COPYING.README ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Eigen is primarily MPL2 licensed. See COPYING.MPL2 and these links:
2
+ http://www.mozilla.org/MPL/2.0/
3
+ http://www.mozilla.org/MPL/2.0/FAQ.html
4
+
5
+ Some files contain third-party code under BSD or LGPL licenses, whence the other
6
+ COPYING.* files here.
7
+
8
+ All the LGPL code is either LGPL 2.1-only, or LGPL 2.1-or-later.
9
+ For this reason, the COPYING.LGPL file contains the LGPL 2.1 text.
10
+
11
+ If you want to guarantee that the Eigen code that you are #including is licensed
12
+ under the MPL2 and possibly more permissive licenses (like BSD), #define this
13
+ preprocessor symbol:
14
+ EIGEN_MPL2_ONLY
15
+ For example, with most compilers, you could add this to your project CXXFLAGS:
16
+ -DEIGEN_MPL2_ONLY
17
+ This will cause a compilation error to be generated if you #include any code that is
18
+ LGPL licensed.
cpp/src/librosa/eigen3/CTestConfig.cmake ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## This file should be placed in the root directory of your project.
2
+ ## Then modify the CMakeLists.txt file in the root directory of your
3
+ ## project to incorporate the testing dashboard.
4
+ ## # The following are required to uses Dart and the Cdash dashboard
5
+ ## ENABLE_TESTING()
6
+ ## INCLUDE(CTest)
7
+ set(CTEST_PROJECT_NAME "Eigen 3.3")
8
+ set(CTEST_NIGHTLY_START_TIME "00:00:00 UTC")
9
+
10
+ set(CTEST_DROP_METHOD "http")
11
+ set(CTEST_DROP_SITE "manao.inria.fr")
12
+ set(CTEST_DROP_LOCATION "/CDash/submit.php?project=Eigen+3.3")
13
+ set(CTEST_DROP_SITE_CDASH TRUE)
cpp/src/librosa/eigen3/CTestCustom.cmake.in ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+
2
+ set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS "2000")
3
+ set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS "2000")
4
+ list(APPEND CTEST_CUSTOM_ERROR_EXCEPTION @EIGEN_CTEST_ERROR_EXCEPTION@)
cpp/src/librosa/eigen3/Eigen/CMakeLists.txt ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ include(RegexUtils)
2
+ test_escape_string_as_regex()
3
+
4
+ file(GLOB Eigen_directory_files "*")
5
+
6
+ escape_string_as_regex(ESCAPED_CMAKE_CURRENT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
7
+
8
+ foreach(f ${Eigen_directory_files})
9
+ if(NOT f MATCHES "\\.txt" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/[.].+" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/src")
10
+ list(APPEND Eigen_directory_files_to_install ${f})
11
+ endif()
12
+ endforeach(f ${Eigen_directory_files})
13
+
14
+ install(FILES
15
+ ${Eigen_directory_files_to_install}
16
+ DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen COMPONENT Devel
17
+ )
18
+
19
+ install(DIRECTORY src DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen COMPONENT Devel FILES_MATCHING PATTERN "*.h")
cpp/src/librosa/eigen3/Eigen/Cholesky ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // This Source Code Form is subject to the terms of the Mozilla
5
+ // Public License v. 2.0. If a copy of the MPL was not distributed
6
+ // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
+
8
+ #ifndef EIGEN_CHOLESKY_MODULE_H
9
+ #define EIGEN_CHOLESKY_MODULE_H
10
+
11
+ #include "Core"
12
+ #include "Jacobi"
13
+
14
+ #include "src/Core/util/DisableStupidWarnings.h"
15
+
16
+ /** \defgroup Cholesky_Module Cholesky module
17
+ *
18
+ *
19
+ *
20
+ * This module provides two variants of the Cholesky decomposition for selfadjoint (hermitian) matrices.
21
+ * Those decompositions are also accessible via the following methods:
22
+ * - MatrixBase::llt()
23
+ * - MatrixBase::ldlt()
24
+ * - SelfAdjointView::llt()
25
+ * - SelfAdjointView::ldlt()
26
+ *
27
+ * \code
28
+ * #include <Eigen/Cholesky>
29
+ * \endcode
30
+ */
31
+
32
+ #include "src/Cholesky/LLT.h"
33
+ #include "src/Cholesky/LDLT.h"
34
+ #ifdef EIGEN_USE_LAPACKE
35
+ #ifdef EIGEN_USE_MKL
36
+ #include "mkl_lapacke.h"
37
+ #else
38
+ #include "src/misc/lapacke.h"
39
+ #endif
40
+ #include "src/Cholesky/LLT_LAPACKE.h"
41
+ #endif
42
+
43
+ #include "src/Core/util/ReenableStupidWarnings.h"
44
+
45
+ #endif // EIGEN_CHOLESKY_MODULE_H
46
+ /* vim: set filetype=cpp et sw=2 ts=2 ai: */
cpp/src/librosa/eigen3/Eigen/CholmodSupport ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // This Source Code Form is subject to the terms of the Mozilla
5
+ // Public License v. 2.0. If a copy of the MPL was not distributed
6
+ // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
+
8
+ #ifndef EIGEN_CHOLMODSUPPORT_MODULE_H
9
+ #define EIGEN_CHOLMODSUPPORT_MODULE_H
10
+
11
+ #include "SparseCore"
12
+
13
+ #include "src/Core/util/DisableStupidWarnings.h"
14
+
15
+ extern "C" {
16
+ #include <cholmod.h>
17
+ }
18
+
19
+ /** \ingroup Support_modules
20
+ * \defgroup CholmodSupport_Module CholmodSupport module
21
+ *
22
+ * This module provides an interface to the Cholmod library which is part of the <a href="http://www.suitesparse.com">suitesparse</a> package.
23
+ * It provides the two following main factorization classes:
24
+ * - class CholmodSupernodalLLT: a supernodal LLT Cholesky factorization.
25
+ * - class CholmodDecomposiiton: a general L(D)LT Cholesky factorization with automatic or explicit runtime selection of the underlying factorization method (supernodal or simplicial).
26
+ *
27
+ * For the sake of completeness, this module also propose the two following classes:
28
+ * - class CholmodSimplicialLLT
29
+ * - class CholmodSimplicialLDLT
30
+ * Note that these classes does not bring any particular advantage compared to the built-in
31
+ * SimplicialLLT and SimplicialLDLT factorization classes.
32
+ *
33
+ * \code
34
+ * #include <Eigen/CholmodSupport>
35
+ * \endcode
36
+ *
37
+ * In order to use this module, the cholmod headers must be accessible from the include paths, and your binary must be linked to the cholmod library and its dependencies.
38
+ * The dependencies depend on how cholmod has been compiled.
39
+ * For a cmake based project, you can use our FindCholmod.cmake module to help you in this task.
40
+ *
41
+ */
42
+
43
+ #include "src/CholmodSupport/CholmodSupport.h"
44
+
45
+ #include "src/Core/util/ReenableStupidWarnings.h"
46
+
47
+ #endif // EIGEN_CHOLMODSUPPORT_MODULE_H
48
+
cpp/src/librosa/eigen3/Eigen/Core ADDED
@@ -0,0 +1,537 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
5
+ // Copyright (C) 2007-2011 Benoit Jacob <jacob.benoit.1@gmail.com>
6
+ //
7
+ // This Source Code Form is subject to the terms of the Mozilla
8
+ // Public License v. 2.0. If a copy of the MPL was not distributed
9
+ // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10
+
11
+ #ifndef EIGEN_CORE_H
12
+ #define EIGEN_CORE_H
13
+
14
+ // first thing Eigen does: stop the compiler from committing suicide
15
+ #include "src/Core/util/DisableStupidWarnings.h"
16
+
17
+ #if defined(__CUDACC__) && !defined(EIGEN_NO_CUDA)
18
+ #define EIGEN_CUDACC __CUDACC__
19
+ #endif
20
+
21
+ #if defined(__CUDA_ARCH__) && !defined(EIGEN_NO_CUDA)
22
+ #define EIGEN_CUDA_ARCH __CUDA_ARCH__
23
+ #endif
24
+
25
+ #if defined(__CUDACC_VER_MAJOR__) && (__CUDACC_VER_MAJOR__ >= 9)
26
+ #define EIGEN_CUDACC_VER ((__CUDACC_VER_MAJOR__ * 10000) + (__CUDACC_VER_MINOR__ * 100))
27
+ #elif defined(__CUDACC_VER__)
28
+ #define EIGEN_CUDACC_VER __CUDACC_VER__
29
+ #else
30
+ #define EIGEN_CUDACC_VER 0
31
+ #endif
32
+
33
+ // Handle NVCC/CUDA/SYCL
34
+ #if defined(__CUDACC__) || defined(__SYCL_DEVICE_ONLY__)
35
+ // Do not try asserts on CUDA and SYCL!
36
+ #ifndef EIGEN_NO_DEBUG
37
+ #define EIGEN_NO_DEBUG
38
+ #endif
39
+
40
+ #ifdef EIGEN_INTERNAL_DEBUGGING
41
+ #undef EIGEN_INTERNAL_DEBUGGING
42
+ #endif
43
+
44
+ #ifdef EIGEN_EXCEPTIONS
45
+ #undef EIGEN_EXCEPTIONS
46
+ #endif
47
+
48
+ // All functions callable from CUDA code must be qualified with __device__
49
+ #ifdef __CUDACC__
50
+ // Do not try to vectorize on CUDA and SYCL!
51
+ #ifndef EIGEN_DONT_VECTORIZE
52
+ #define EIGEN_DONT_VECTORIZE
53
+ #endif
54
+
55
+ #define EIGEN_DEVICE_FUNC __host__ __device__
56
+ // We need cuda_runtime.h to ensure that that EIGEN_USING_STD_MATH macro
57
+ // works properly on the device side
58
+ #include <cuda_runtime.h>
59
+ #else
60
+ #define EIGEN_DEVICE_FUNC
61
+ #endif
62
+
63
+ #else
64
+ #define EIGEN_DEVICE_FUNC
65
+
66
+ #endif
67
+
68
+ // When compiling CUDA device code with NVCC, pull in math functions from the
69
+ // global namespace. In host mode, and when device doee with clang, use the
70
+ // std versions.
71
+ #if defined(__CUDA_ARCH__) && defined(__NVCC__)
72
+ #define EIGEN_USING_STD_MATH(FUNC) using ::FUNC;
73
+ #else
74
+ #define EIGEN_USING_STD_MATH(FUNC) using std::FUNC;
75
+ #endif
76
+
77
+ #if (defined(_CPPUNWIND) || defined(__EXCEPTIONS)) && !defined(__CUDA_ARCH__) && !defined(EIGEN_EXCEPTIONS) && !defined(EIGEN_USE_SYCL)
78
+ #define EIGEN_EXCEPTIONS
79
+ #endif
80
+
81
+ #ifdef EIGEN_EXCEPTIONS
82
+ #include <new>
83
+ #endif
84
+
85
+ // then include this file where all our macros are defined. It's really important to do it first because
86
+ // it's where we do all the alignment settings (platform detection and honoring the user's will if he
87
+ // defined e.g. EIGEN_DONT_ALIGN) so it needs to be done before we do anything with vectorization.
88
+ #include "src/Core/util/Macros.h"
89
+
90
+ // Disable the ipa-cp-clone optimization flag with MinGW 6.x or newer (enabled by default with -O3)
91
+ // See http://eigen.tuxfamily.org/bz/show_bug.cgi?id=556 for details.
92
+ #if EIGEN_COMP_MINGW && EIGEN_GNUC_AT_LEAST(4,6)
93
+ #pragma GCC optimize ("-fno-ipa-cp-clone")
94
+ #endif
95
+
96
+ #include <complex>
97
+
98
+ // this include file manages BLAS and MKL related macros
99
+ // and inclusion of their respective header files
100
+ #include "src/Core/util/MKL_support.h"
101
+
102
+ // if alignment is disabled, then disable vectorization. Note: EIGEN_MAX_ALIGN_BYTES is the proper check, it takes into
103
+ // account both the user's will (EIGEN_MAX_ALIGN_BYTES,EIGEN_DONT_ALIGN) and our own platform checks
104
+ #if EIGEN_MAX_ALIGN_BYTES==0
105
+ #ifndef EIGEN_DONT_VECTORIZE
106
+ #define EIGEN_DONT_VECTORIZE
107
+ #endif
108
+ #endif
109
+
110
+ #if EIGEN_COMP_MSVC
111
+ #include <malloc.h> // for _aligned_malloc -- need it regardless of whether vectorization is enabled
112
+ #if (EIGEN_COMP_MSVC >= 1500) // 2008 or later
113
+ // Remember that usage of defined() in a #define is undefined by the standard.
114
+ // a user reported that in 64-bit mode, MSVC doesn't care to define _M_IX86_FP.
115
+ #if (defined(_M_IX86_FP) && (_M_IX86_FP >= 2)) || EIGEN_ARCH_x86_64
116
+ #define EIGEN_SSE2_ON_MSVC_2008_OR_LATER
117
+ #endif
118
+ #endif
119
+ #else
120
+ // Remember that usage of defined() in a #define is undefined by the standard
121
+ #if (defined __SSE2__) && ( (!EIGEN_COMP_GNUC) || EIGEN_COMP_ICC || EIGEN_GNUC_AT_LEAST(4,2) )
122
+ #define EIGEN_SSE2_ON_NON_MSVC_BUT_NOT_OLD_GCC
123
+ #endif
124
+ #endif
125
+
126
+ #ifndef EIGEN_DONT_VECTORIZE
127
+
128
+ #if defined (EIGEN_SSE2_ON_NON_MSVC_BUT_NOT_OLD_GCC) || defined(EIGEN_SSE2_ON_MSVC_2008_OR_LATER)
129
+
130
+ // Defines symbols for compile-time detection of which instructions are
131
+ // used.
132
+ // EIGEN_VECTORIZE_YY is defined if and only if the instruction set YY is used
133
+ #define EIGEN_VECTORIZE
134
+ #define EIGEN_VECTORIZE_SSE
135
+ #define EIGEN_VECTORIZE_SSE2
136
+
137
+ // Detect sse3/ssse3/sse4:
138
+ // gcc and icc defines __SSE3__, ...
139
+ // there is no way to know about this on msvc. You can define EIGEN_VECTORIZE_SSE* if you
140
+ // want to force the use of those instructions with msvc.
141
+ #ifdef __SSE3__
142
+ #define EIGEN_VECTORIZE_SSE3
143
+ #endif
144
+ #ifdef __SSSE3__
145
+ #define EIGEN_VECTORIZE_SSSE3
146
+ #endif
147
+ #ifdef __SSE4_1__
148
+ #define EIGEN_VECTORIZE_SSE4_1
149
+ #endif
150
+ #ifdef __SSE4_2__
151
+ #define EIGEN_VECTORIZE_SSE4_2
152
+ #endif
153
+ #ifdef __AVX__
154
+ #define EIGEN_VECTORIZE_AVX
155
+ #define EIGEN_VECTORIZE_SSE3
156
+ #define EIGEN_VECTORIZE_SSSE3
157
+ #define EIGEN_VECTORIZE_SSE4_1
158
+ #define EIGEN_VECTORIZE_SSE4_2
159
+ #endif
160
+ #ifdef __AVX2__
161
+ #define EIGEN_VECTORIZE_AVX2
162
+ #endif
163
+ #ifdef __FMA__
164
+ #define EIGEN_VECTORIZE_FMA
165
+ #endif
166
+ #if defined(__AVX512F__) && defined(EIGEN_ENABLE_AVX512)
167
+ #define EIGEN_VECTORIZE_AVX512
168
+ #define EIGEN_VECTORIZE_AVX2
169
+ #define EIGEN_VECTORIZE_AVX
170
+ #define EIGEN_VECTORIZE_FMA
171
+ #ifdef __AVX512DQ__
172
+ #define EIGEN_VECTORIZE_AVX512DQ
173
+ #endif
174
+ #ifdef __AVX512ER__
175
+ #define EIGEN_VECTORIZE_AVX512ER
176
+ #endif
177
+ #endif
178
+
179
+ // include files
180
+
181
+ // This extern "C" works around a MINGW-w64 compilation issue
182
+ // https://sourceforge.net/tracker/index.php?func=detail&aid=3018394&group_id=202880&atid=983354
183
+ // In essence, intrin.h is included by windows.h and also declares intrinsics (just as emmintrin.h etc. below do).
184
+ // However, intrin.h uses an extern "C" declaration, and g++ thus complains of duplicate declarations
185
+ // with conflicting linkage. The linkage for intrinsics doesn't matter, but at that stage the compiler doesn't know;
186
+ // so, to avoid compile errors when windows.h is included after Eigen/Core, ensure intrinsics are extern "C" here too.
187
+ // notice that since these are C headers, the extern "C" is theoretically needed anyways.
188
+ extern "C" {
189
+ // In theory we should only include immintrin.h and not the other *mmintrin.h header files directly.
190
+ // Doing so triggers some issues with ICC. However old gcc versions seems to not have this file, thus:
191
+ #if EIGEN_COMP_ICC >= 1110
192
+ #include <immintrin.h>
193
+ #else
194
+ #include <mmintrin.h>
195
+ #include <emmintrin.h>
196
+ #include <xmmintrin.h>
197
+ #ifdef EIGEN_VECTORIZE_SSE3
198
+ #include <pmmintrin.h>
199
+ #endif
200
+ #ifdef EIGEN_VECTORIZE_SSSE3
201
+ #include <tmmintrin.h>
202
+ #endif
203
+ #ifdef EIGEN_VECTORIZE_SSE4_1
204
+ #include <smmintrin.h>
205
+ #endif
206
+ #ifdef EIGEN_VECTORIZE_SSE4_2
207
+ #include <nmmintrin.h>
208
+ #endif
209
+ #if defined(EIGEN_VECTORIZE_AVX) || defined(EIGEN_VECTORIZE_AVX512)
210
+ #include <immintrin.h>
211
+ #endif
212
+ #endif
213
+ } // end extern "C"
214
+ #elif defined __VSX__
215
+ #define EIGEN_VECTORIZE
216
+ #define EIGEN_VECTORIZE_VSX
217
+ #include <altivec.h>
218
+ // We need to #undef all these ugly tokens defined in <altivec.h>
219
+ // => use __vector instead of vector
220
+ #undef bool
221
+ #undef vector
222
+ #undef pixel
223
+ #elif defined __ALTIVEC__
224
+ #define EIGEN_VECTORIZE
225
+ #define EIGEN_VECTORIZE_ALTIVEC
226
+ #include <altivec.h>
227
+ // We need to #undef all these ugly tokens defined in <altivec.h>
228
+ // => use __vector instead of vector
229
+ #undef bool
230
+ #undef vector
231
+ #undef pixel
232
+ #elif (defined __ARM_NEON) || (defined __ARM_NEON__)
233
+ #define EIGEN_VECTORIZE
234
+ #define EIGEN_VECTORIZE_NEON
235
+ #include <arm_neon.h>
236
+ #elif (defined __s390x__ && defined __VEC__)
237
+ #define EIGEN_VECTORIZE
238
+ #define EIGEN_VECTORIZE_ZVECTOR
239
+ #include <vecintrin.h>
240
+ #endif
241
+ #endif
242
+
243
+ #if defined(__F16C__) && !defined(EIGEN_COMP_CLANG)
244
+ // We can use the optimized fp16 to float and float to fp16 conversion routines
245
+ #define EIGEN_HAS_FP16_C
246
+ #endif
247
+
248
+ #if defined __CUDACC__
249
+ #define EIGEN_VECTORIZE_CUDA
250
+ #include <vector_types.h>
251
+ #if EIGEN_CUDACC_VER >= 70500
252
+ #define EIGEN_HAS_CUDA_FP16
253
+ #endif
254
+ #endif
255
+
256
+ #if defined EIGEN_HAS_CUDA_FP16
257
+ #include <host_defines.h>
258
+ #include <cuda_fp16.h>
259
+ #endif
260
+
261
+ #if (defined _OPENMP) && (!defined EIGEN_DONT_PARALLELIZE)
262
+ #define EIGEN_HAS_OPENMP
263
+ #endif
264
+
265
+ #ifdef EIGEN_HAS_OPENMP
266
+ #include <omp.h>
267
+ #endif
268
+
269
+ // MSVC for windows mobile does not have the errno.h file
270
+ #if !(EIGEN_COMP_MSVC && EIGEN_OS_WINCE) && !EIGEN_COMP_ARM
271
+ #define EIGEN_HAS_ERRNO
272
+ #endif
273
+
274
+ #ifdef EIGEN_HAS_ERRNO
275
+ #include <cerrno>
276
+ #endif
277
+ #include <cstddef>
278
+ #include <cstdlib>
279
+ #include <cmath>
280
+ #include <cassert>
281
+ #include <functional>
282
+ #include <iosfwd>
283
+ #include <cstring>
284
+ #include <string>
285
+ #include <limits>
286
+ #include <climits> // for CHAR_BIT
287
+ // for min/max:
288
+ #include <algorithm>
289
+
290
+ // for std::is_nothrow_move_assignable
291
+ #ifdef EIGEN_INCLUDE_TYPE_TRAITS
292
+ #include <type_traits>
293
+ #endif
294
+
295
+ // for outputting debug info
296
+ #ifdef EIGEN_DEBUG_ASSIGN
297
+ #include <iostream>
298
+ #endif
299
+
300
+ // required for __cpuid, needs to be included after cmath
301
+ #if EIGEN_COMP_MSVC && EIGEN_ARCH_i386_OR_x86_64 && !EIGEN_OS_WINCE
302
+ #include <intrin.h>
303
+ #endif
304
+
305
+ /** \brief Namespace containing all symbols from the %Eigen library. */
306
+ namespace Eigen {
307
+
308
+ inline static const char *SimdInstructionSetsInUse(void) {
309
+ #if defined(EIGEN_VECTORIZE_AVX512)
310
+ return "AVX512, FMA, AVX2, AVX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2";
311
+ #elif defined(EIGEN_VECTORIZE_AVX)
312
+ return "AVX SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2";
313
+ #elif defined(EIGEN_VECTORIZE_SSE4_2)
314
+ return "SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2";
315
+ #elif defined(EIGEN_VECTORIZE_SSE4_1)
316
+ return "SSE, SSE2, SSE3, SSSE3, SSE4.1";
317
+ #elif defined(EIGEN_VECTORIZE_SSSE3)
318
+ return "SSE, SSE2, SSE3, SSSE3";
319
+ #elif defined(EIGEN_VECTORIZE_SSE3)
320
+ return "SSE, SSE2, SSE3";
321
+ #elif defined(EIGEN_VECTORIZE_SSE2)
322
+ return "SSE, SSE2";
323
+ #elif defined(EIGEN_VECTORIZE_ALTIVEC)
324
+ return "AltiVec";
325
+ #elif defined(EIGEN_VECTORIZE_VSX)
326
+ return "VSX";
327
+ #elif defined(EIGEN_VECTORIZE_NEON)
328
+ return "ARM NEON";
329
+ #elif defined(EIGEN_VECTORIZE_ZVECTOR)
330
+ return "S390X ZVECTOR";
331
+ #else
332
+ return "None";
333
+ #endif
334
+ }
335
+
336
+ } // end namespace Eigen
337
+
338
+ #if defined EIGEN2_SUPPORT_STAGE40_FULL_EIGEN3_STRICTNESS || defined EIGEN2_SUPPORT_STAGE30_FULL_EIGEN3_API || defined EIGEN2_SUPPORT_STAGE20_RESOLVE_API_CONFLICTS || defined EIGEN2_SUPPORT_STAGE10_FULL_EIGEN2_API || defined EIGEN2_SUPPORT
339
+ // This will generate an error message:
340
+ #error Eigen2-support is only available up to version 3.2. Please go to "http://eigen.tuxfamily.org/index.php?title=Eigen2" for further information
341
+ #endif
342
+
343
+ namespace Eigen {
344
+
345
+ // we use size_t frequently and we'll never remember to prepend it with std:: everytime just to
346
+ // ensure QNX/QCC support
347
+ using std::size_t;
348
+ // gcc 4.6.0 wants std:: for ptrdiff_t
349
+ using std::ptrdiff_t;
350
+
351
+ }
352
+
353
+ /** \defgroup Core_Module Core module
354
+ * This is the main module of Eigen providing dense matrix and vector support
355
+ * (both fixed and dynamic size) with all the features corresponding to a BLAS library
356
+ * and much more...
357
+ *
358
+ * \code
359
+ * #include <Eigen/Core>
360
+ * \endcode
361
+ */
362
+
363
+ #include "src/Core/util/Constants.h"
364
+ #include "src/Core/util/Meta.h"
365
+ #include "src/Core/util/ForwardDeclarations.h"
366
+ #include "src/Core/util/StaticAssert.h"
367
+ #include "src/Core/util/XprHelper.h"
368
+ #include "src/Core/util/Memory.h"
369
+
370
+ #include "src/Core/NumTraits.h"
371
+ #include "src/Core/MathFunctions.h"
372
+ #include "src/Core/GenericPacketMath.h"
373
+ #include "src/Core/MathFunctionsImpl.h"
374
+ #include "src/Core/arch/Default/ConjHelper.h"
375
+
376
+ #if defined EIGEN_VECTORIZE_AVX512
377
+ #include "src/Core/arch/SSE/PacketMath.h"
378
+ #include "src/Core/arch/AVX/PacketMath.h"
379
+ #include "src/Core/arch/AVX512/PacketMath.h"
380
+ #include "src/Core/arch/AVX512/MathFunctions.h"
381
+ #elif defined EIGEN_VECTORIZE_AVX
382
+ // Use AVX for floats and doubles, SSE for integers
383
+ #include "src/Core/arch/SSE/PacketMath.h"
384
+ #include "src/Core/arch/SSE/Complex.h"
385
+ #include "src/Core/arch/SSE/MathFunctions.h"
386
+ #include "src/Core/arch/AVX/PacketMath.h"
387
+ #include "src/Core/arch/AVX/MathFunctions.h"
388
+ #include "src/Core/arch/AVX/Complex.h"
389
+ #include "src/Core/arch/AVX/TypeCasting.h"
390
+ #include "src/Core/arch/SSE/TypeCasting.h"
391
+ #elif defined EIGEN_VECTORIZE_SSE
392
+ #include "src/Core/arch/SSE/PacketMath.h"
393
+ #include "src/Core/arch/SSE/MathFunctions.h"
394
+ #include "src/Core/arch/SSE/Complex.h"
395
+ #include "src/Core/arch/SSE/TypeCasting.h"
396
+ #elif defined(EIGEN_VECTORIZE_ALTIVEC) || defined(EIGEN_VECTORIZE_VSX)
397
+ #include "src/Core/arch/AltiVec/PacketMath.h"
398
+ #include "src/Core/arch/AltiVec/MathFunctions.h"
399
+ #include "src/Core/arch/AltiVec/Complex.h"
400
+ #elif defined EIGEN_VECTORIZE_NEON
401
+ #include "src/Core/arch/NEON/PacketMath.h"
402
+ #include "src/Core/arch/NEON/MathFunctions.h"
403
+ #include "src/Core/arch/NEON/Complex.h"
404
+ #elif defined EIGEN_VECTORIZE_ZVECTOR
405
+ #include "src/Core/arch/ZVector/PacketMath.h"
406
+ #include "src/Core/arch/ZVector/MathFunctions.h"
407
+ #include "src/Core/arch/ZVector/Complex.h"
408
+ #endif
409
+
410
+ // Half float support
411
+ #include "src/Core/arch/CUDA/Half.h"
412
+ #include "src/Core/arch/CUDA/PacketMathHalf.h"
413
+ #include "src/Core/arch/CUDA/TypeCasting.h"
414
+
415
+ #if defined EIGEN_VECTORIZE_CUDA
416
+ #include "src/Core/arch/CUDA/PacketMath.h"
417
+ #include "src/Core/arch/CUDA/MathFunctions.h"
418
+ #endif
419
+
420
+ #include "src/Core/arch/Default/Settings.h"
421
+
422
+ #include "src/Core/functors/TernaryFunctors.h"
423
+ #include "src/Core/functors/BinaryFunctors.h"
424
+ #include "src/Core/functors/UnaryFunctors.h"
425
+ #include "src/Core/functors/NullaryFunctors.h"
426
+ #include "src/Core/functors/StlFunctors.h"
427
+ #include "src/Core/functors/AssignmentFunctors.h"
428
+
429
+ // Specialized functors to enable the processing of complex numbers
430
+ // on CUDA devices
431
+ #include "src/Core/arch/CUDA/Complex.h"
432
+
433
+ #include "src/Core/IO.h"
434
+ #include "src/Core/DenseCoeffsBase.h"
435
+ #include "src/Core/DenseBase.h"
436
+ #include "src/Core/MatrixBase.h"
437
+ #include "src/Core/EigenBase.h"
438
+
439
+ #include "src/Core/Product.h"
440
+ #include "src/Core/CoreEvaluators.h"
441
+ #include "src/Core/AssignEvaluator.h"
442
+
443
+ #ifndef EIGEN_PARSED_BY_DOXYGEN // work around Doxygen bug triggered by Assign.h r814874
444
+ // at least confirmed with Doxygen 1.5.5 and 1.5.6
445
+ #include "src/Core/Assign.h"
446
+ #endif
447
+
448
+ #include "src/Core/ArrayBase.h"
449
+ #include "src/Core/util/BlasUtil.h"
450
+ #include "src/Core/DenseStorage.h"
451
+ #include "src/Core/NestByValue.h"
452
+
453
+ // #include "src/Core/ForceAlignedAccess.h"
454
+
455
+ #include "src/Core/ReturnByValue.h"
456
+ #include "src/Core/NoAlias.h"
457
+ #include "src/Core/PlainObjectBase.h"
458
+ #include "src/Core/Matrix.h"
459
+ #include "src/Core/Array.h"
460
+ #include "src/Core/CwiseTernaryOp.h"
461
+ #include "src/Core/CwiseBinaryOp.h"
462
+ #include "src/Core/CwiseUnaryOp.h"
463
+ #include "src/Core/CwiseNullaryOp.h"
464
+ #include "src/Core/CwiseUnaryView.h"
465
+ #include "src/Core/SelfCwiseBinaryOp.h"
466
+ #include "src/Core/Dot.h"
467
+ #include "src/Core/StableNorm.h"
468
+ #include "src/Core/Stride.h"
469
+ #include "src/Core/MapBase.h"
470
+ #include "src/Core/Map.h"
471
+ #include "src/Core/Ref.h"
472
+ #include "src/Core/Block.h"
473
+ #include "src/Core/VectorBlock.h"
474
+ #include "src/Core/Transpose.h"
475
+ #include "src/Core/DiagonalMatrix.h"
476
+ #include "src/Core/Diagonal.h"
477
+ #include "src/Core/DiagonalProduct.h"
478
+ #include "src/Core/Redux.h"
479
+ #include "src/Core/Visitor.h"
480
+ #include "src/Core/Fuzzy.h"
481
+ #include "src/Core/Swap.h"
482
+ #include "src/Core/CommaInitializer.h"
483
+ #include "src/Core/GeneralProduct.h"
484
+ #include "src/Core/Solve.h"
485
+ #include "src/Core/Inverse.h"
486
+ #include "src/Core/SolverBase.h"
487
+ #include "src/Core/PermutationMatrix.h"
488
+ #include "src/Core/Transpositions.h"
489
+ #include "src/Core/TriangularMatrix.h"
490
+ #include "src/Core/SelfAdjointView.h"
491
+ #include "src/Core/products/GeneralBlockPanelKernel.h"
492
+ #include "src/Core/products/Parallelizer.h"
493
+ #include "src/Core/ProductEvaluators.h"
494
+ #include "src/Core/products/GeneralMatrixVector.h"
495
+ #include "src/Core/products/GeneralMatrixMatrix.h"
496
+ #include "src/Core/SolveTriangular.h"
497
+ #include "src/Core/products/GeneralMatrixMatrixTriangular.h"
498
+ #include "src/Core/products/SelfadjointMatrixVector.h"
499
+ #include "src/Core/products/SelfadjointMatrixMatrix.h"
500
+ #include "src/Core/products/SelfadjointProduct.h"
501
+ #include "src/Core/products/SelfadjointRank2Update.h"
502
+ #include "src/Core/products/TriangularMatrixVector.h"
503
+ #include "src/Core/products/TriangularMatrixMatrix.h"
504
+ #include "src/Core/products/TriangularSolverMatrix.h"
505
+ #include "src/Core/products/TriangularSolverVector.h"
506
+ #include "src/Core/BandMatrix.h"
507
+ #include "src/Core/CoreIterators.h"
508
+ #include "src/Core/ConditionEstimator.h"
509
+
510
+ #include "src/Core/BooleanRedux.h"
511
+ #include "src/Core/Select.h"
512
+ #include "src/Core/VectorwiseOp.h"
513
+ #include "src/Core/Random.h"
514
+ #include "src/Core/Replicate.h"
515
+ #include "src/Core/Reverse.h"
516
+ #include "src/Core/ArrayWrapper.h"
517
+
518
+ #ifdef EIGEN_USE_BLAS
519
+ #include "src/Core/products/GeneralMatrixMatrix_BLAS.h"
520
+ #include "src/Core/products/GeneralMatrixVector_BLAS.h"
521
+ #include "src/Core/products/GeneralMatrixMatrixTriangular_BLAS.h"
522
+ #include "src/Core/products/SelfadjointMatrixMatrix_BLAS.h"
523
+ #include "src/Core/products/SelfadjointMatrixVector_BLAS.h"
524
+ #include "src/Core/products/TriangularMatrixMatrix_BLAS.h"
525
+ #include "src/Core/products/TriangularMatrixVector_BLAS.h"
526
+ #include "src/Core/products/TriangularSolverMatrix_BLAS.h"
527
+ #endif // EIGEN_USE_BLAS
528
+
529
+ #ifdef EIGEN_USE_MKL_VML
530
+ #include "src/Core/Assign_MKL.h"
531
+ #endif
532
+
533
+ #include "src/Core/GlobalFunctions.h"
534
+
535
+ #include "src/Core/util/ReenableStupidWarnings.h"
536
+
537
+ #endif // EIGEN_CORE_H
cpp/src/librosa/eigen3/Eigen/Dense ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ #include "Core"
2
+ #include "LU"
3
+ #include "Cholesky"
4
+ #include "QR"
5
+ #include "SVD"
6
+ #include "Geometry"
7
+ #include "Eigenvalues"
cpp/src/librosa/eigen3/Eigen/Eigen ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ #include "Dense"
2
+ #include "Sparse"
cpp/src/librosa/eigen3/Eigen/Eigenvalues ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // This Source Code Form is subject to the terms of the Mozilla
5
+ // Public License v. 2.0. If a copy of the MPL was not distributed
6
+ // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
+
8
+ #ifndef EIGEN_EIGENVALUES_MODULE_H
9
+ #define EIGEN_EIGENVALUES_MODULE_H
10
+
11
+ #include "Core"
12
+
13
+ #include "src/Core/util/DisableStupidWarnings.h"
14
+
15
+ #include "Cholesky"
16
+ #include "Jacobi"
17
+ #include "Householder"
18
+ #include "LU"
19
+ #include "Geometry"
20
+
21
+ /** \defgroup Eigenvalues_Module Eigenvalues module
22
+ *
23
+ *
24
+ *
25
+ * This module mainly provides various eigenvalue solvers.
26
+ * This module also provides some MatrixBase methods, including:
27
+ * - MatrixBase::eigenvalues(),
28
+ * - MatrixBase::operatorNorm()
29
+ *
30
+ * \code
31
+ * #include <Eigen/Eigenvalues>
32
+ * \endcode
33
+ */
34
+
35
+ #include "src/misc/RealSvd2x2.h"
36
+ #include "src/Eigenvalues/Tridiagonalization.h"
37
+ #include "src/Eigenvalues/RealSchur.h"
38
+ #include "src/Eigenvalues/EigenSolver.h"
39
+ #include "src/Eigenvalues/SelfAdjointEigenSolver.h"
40
+ #include "src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h"
41
+ #include "src/Eigenvalues/HessenbergDecomposition.h"
42
+ #include "src/Eigenvalues/ComplexSchur.h"
43
+ #include "src/Eigenvalues/ComplexEigenSolver.h"
44
+ #include "src/Eigenvalues/RealQZ.h"
45
+ #include "src/Eigenvalues/GeneralizedEigenSolver.h"
46
+ #include "src/Eigenvalues/MatrixBaseEigenvalues.h"
47
+ #ifdef EIGEN_USE_LAPACKE
48
+ #ifdef EIGEN_USE_MKL
49
+ #include "mkl_lapacke.h"
50
+ #else
51
+ #include "src/misc/lapacke.h"
52
+ #endif
53
+ #include "src/Eigenvalues/RealSchur_LAPACKE.h"
54
+ #include "src/Eigenvalues/ComplexSchur_LAPACKE.h"
55
+ #include "src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h"
56
+ #endif
57
+
58
+ #include "src/Core/util/ReenableStupidWarnings.h"
59
+
60
+ #endif // EIGEN_EIGENVALUES_MODULE_H
61
+ /* vim: set filetype=cpp et sw=2 ts=2 ai: */
cpp/src/librosa/eigen3/Eigen/Geometry ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // This Source Code Form is subject to the terms of the Mozilla
5
+ // Public License v. 2.0. If a copy of the MPL was not distributed
6
+ // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
+
8
+ #ifndef EIGEN_GEOMETRY_MODULE_H
9
+ #define EIGEN_GEOMETRY_MODULE_H
10
+
11
+ #include "Core"
12
+
13
+ #include "src/Core/util/DisableStupidWarnings.h"
14
+
15
+ #include "SVD"
16
+ #include "LU"
17
+ #include <limits>
18
+
19
+ /** \defgroup Geometry_Module Geometry module
20
+ *
21
+ * This module provides support for:
22
+ * - fixed-size homogeneous transformations
23
+ * - translation, scaling, 2D and 3D rotations
24
+ * - \link Quaternion quaternions \endlink
25
+ * - cross products (\ref MatrixBase::cross, \ref MatrixBase::cross3)
26
+ * - orthognal vector generation (\ref MatrixBase::unitOrthogonal)
27
+ * - some linear components: \link ParametrizedLine parametrized-lines \endlink and \link Hyperplane hyperplanes \endlink
28
+ * - \link AlignedBox axis aligned bounding boxes \endlink
29
+ * - \link umeyama least-square transformation fitting \endlink
30
+ *
31
+ * \code
32
+ * #include <Eigen/Geometry>
33
+ * \endcode
34
+ */
35
+
36
+ #include "src/Geometry/OrthoMethods.h"
37
+ #include "src/Geometry/EulerAngles.h"
38
+
39
+ #include "src/Geometry/Homogeneous.h"
40
+ #include "src/Geometry/RotationBase.h"
41
+ #include "src/Geometry/Rotation2D.h"
42
+ #include "src/Geometry/Quaternion.h"
43
+ #include "src/Geometry/AngleAxis.h"
44
+ #include "src/Geometry/Transform.h"
45
+ #include "src/Geometry/Translation.h"
46
+ #include "src/Geometry/Scaling.h"
47
+ #include "src/Geometry/Hyperplane.h"
48
+ #include "src/Geometry/ParametrizedLine.h"
49
+ #include "src/Geometry/AlignedBox.h"
50
+ #include "src/Geometry/Umeyama.h"
51
+
52
+ // Use the SSE optimized version whenever possible. At the moment the
53
+ // SSE version doesn't compile when AVX is enabled
54
+ #if defined EIGEN_VECTORIZE_SSE && !defined EIGEN_VECTORIZE_AVX
55
+ #include "src/Geometry/arch/Geometry_SSE.h"
56
+ #endif
57
+
58
+ #include "src/Core/util/ReenableStupidWarnings.h"
59
+
60
+ #endif // EIGEN_GEOMETRY_MODULE_H
61
+ /* vim: set filetype=cpp et sw=2 ts=2 ai: */
62
+
cpp/src/librosa/eigen3/Eigen/Householder ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // This Source Code Form is subject to the terms of the Mozilla
5
+ // Public License v. 2.0. If a copy of the MPL was not distributed
6
+ // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
+
8
+ #ifndef EIGEN_HOUSEHOLDER_MODULE_H
9
+ #define EIGEN_HOUSEHOLDER_MODULE_H
10
+
11
+ #include "Core"
12
+
13
+ #include "src/Core/util/DisableStupidWarnings.h"
14
+
15
+ /** \defgroup Householder_Module Householder module
16
+ * This module provides Householder transformations.
17
+ *
18
+ * \code
19
+ * #include <Eigen/Householder>
20
+ * \endcode
21
+ */
22
+
23
+ #include "src/Householder/Householder.h"
24
+ #include "src/Householder/HouseholderSequence.h"
25
+ #include "src/Householder/BlockHouseholder.h"
26
+
27
+ #include "src/Core/util/ReenableStupidWarnings.h"
28
+
29
+ #endif // EIGEN_HOUSEHOLDER_MODULE_H
30
+ /* vim: set filetype=cpp et sw=2 ts=2 ai: */
cpp/src/librosa/eigen3/Eigen/IterativeLinearSolvers ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // This Source Code Form is subject to the terms of the Mozilla
5
+ // Public License v. 2.0. If a copy of the MPL was not distributed
6
+ // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
+
8
+ #ifndef EIGEN_ITERATIVELINEARSOLVERS_MODULE_H
9
+ #define EIGEN_ITERATIVELINEARSOLVERS_MODULE_H
10
+
11
+ #include "SparseCore"
12
+ #include "OrderingMethods"
13
+
14
+ #include "src/Core/util/DisableStupidWarnings.h"
15
+
16
+ /**
17
+ * \defgroup IterativeLinearSolvers_Module IterativeLinearSolvers module
18
+ *
19
+ * This module currently provides iterative methods to solve problems of the form \c A \c x = \c b, where \c A is a squared matrix, usually very large and sparse.
20
+ * Those solvers are accessible via the following classes:
21
+ * - ConjugateGradient for selfadjoint (hermitian) matrices,
22
+ * - LeastSquaresConjugateGradient for rectangular least-square problems,
23
+ * - BiCGSTAB for general square matrices.
24
+ *
25
+ * These iterative solvers are associated with some preconditioners:
26
+ * - IdentityPreconditioner - not really useful
27
+ * - DiagonalPreconditioner - also called Jacobi preconditioner, work very well on diagonal dominant matrices.
28
+ * - IncompleteLUT - incomplete LU factorization with dual thresholding
29
+ *
30
+ * Such problems can also be solved using the direct sparse decomposition modules: SparseCholesky, CholmodSupport, UmfPackSupport, SuperLUSupport.
31
+ *
32
+ \code
33
+ #include <Eigen/IterativeLinearSolvers>
34
+ \endcode
35
+ */
36
+
37
+ #include "src/IterativeLinearSolvers/SolveWithGuess.h"
38
+ #include "src/IterativeLinearSolvers/IterativeSolverBase.h"
39
+ #include "src/IterativeLinearSolvers/BasicPreconditioners.h"
40
+ #include "src/IterativeLinearSolvers/ConjugateGradient.h"
41
+ #include "src/IterativeLinearSolvers/LeastSquareConjugateGradient.h"
42
+ #include "src/IterativeLinearSolvers/BiCGSTAB.h"
43
+ #include "src/IterativeLinearSolvers/IncompleteLUT.h"
44
+ #include "src/IterativeLinearSolvers/IncompleteCholesky.h"
45
+
46
+ #include "src/Core/util/ReenableStupidWarnings.h"
47
+
48
+ #endif // EIGEN_ITERATIVELINEARSOLVERS_MODULE_H
cpp/src/librosa/eigen3/Eigen/Jacobi ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // This Source Code Form is subject to the terms of the Mozilla
5
+ // Public License v. 2.0. If a copy of the MPL was not distributed
6
+ // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
+
8
+ #ifndef EIGEN_JACOBI_MODULE_H
9
+ #define EIGEN_JACOBI_MODULE_H
10
+
11
+ #include "Core"
12
+
13
+ #include "src/Core/util/DisableStupidWarnings.h"
14
+
15
+ /** \defgroup Jacobi_Module Jacobi module
16
+ * This module provides Jacobi and Givens rotations.
17
+ *
18
+ * \code
19
+ * #include <Eigen/Jacobi>
20
+ * \endcode
21
+ *
22
+ * In addition to listed classes, it defines the two following MatrixBase methods to apply a Jacobi or Givens rotation:
23
+ * - MatrixBase::applyOnTheLeft()
24
+ * - MatrixBase::applyOnTheRight().
25
+ */
26
+
27
+ #include "src/Jacobi/Jacobi.h"
28
+
29
+ #include "src/Core/util/ReenableStupidWarnings.h"
30
+
31
+ #endif // EIGEN_JACOBI_MODULE_H
32
+ /* vim: set filetype=cpp et sw=2 ts=2 ai: */
33
+
cpp/src/librosa/eigen3/Eigen/LU ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // This Source Code Form is subject to the terms of the Mozilla
5
+ // Public License v. 2.0. If a copy of the MPL was not distributed
6
+ // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
+
8
+ #ifndef EIGEN_LU_MODULE_H
9
+ #define EIGEN_LU_MODULE_H
10
+
11
+ #include "Core"
12
+
13
+ #include "src/Core/util/DisableStupidWarnings.h"
14
+
15
+ /** \defgroup LU_Module LU module
16
+ * This module includes %LU decomposition and related notions such as matrix inversion and determinant.
17
+ * This module defines the following MatrixBase methods:
18
+ * - MatrixBase::inverse()
19
+ * - MatrixBase::determinant()
20
+ *
21
+ * \code
22
+ * #include <Eigen/LU>
23
+ * \endcode
24
+ */
25
+
26
+ #include "src/misc/Kernel.h"
27
+ #include "src/misc/Image.h"
28
+ #include "src/LU/FullPivLU.h"
29
+ #include "src/LU/PartialPivLU.h"
30
+ #ifdef EIGEN_USE_LAPACKE
31
+ #ifdef EIGEN_USE_MKL
32
+ #include "mkl_lapacke.h"
33
+ #else
34
+ #include "src/misc/lapacke.h"
35
+ #endif
36
+ #include "src/LU/PartialPivLU_LAPACKE.h"
37
+ #endif
38
+ #include "src/LU/Determinant.h"
39
+ #include "src/LU/InverseImpl.h"
40
+
41
+ // Use the SSE optimized version whenever possible. At the moment the
42
+ // SSE version doesn't compile when AVX is enabled
43
+ #if defined EIGEN_VECTORIZE_SSE && !defined EIGEN_VECTORIZE_AVX
44
+ #include "src/LU/arch/Inverse_SSE.h"
45
+ #endif
46
+
47
+ #include "src/Core/util/ReenableStupidWarnings.h"
48
+
49
+ #endif // EIGEN_LU_MODULE_H
50
+ /* vim: set filetype=cpp et sw=2 ts=2 ai: */
cpp/src/librosa/eigen3/Eigen/MetisSupport ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // This Source Code Form is subject to the terms of the Mozilla
5
+ // Public License v. 2.0. If a copy of the MPL was not distributed
6
+ // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
+
8
+ #ifndef EIGEN_METISSUPPORT_MODULE_H
9
+ #define EIGEN_METISSUPPORT_MODULE_H
10
+
11
+ #include "SparseCore"
12
+
13
+ #include "src/Core/util/DisableStupidWarnings.h"
14
+
15
+ extern "C" {
16
+ #include <metis.h>
17
+ }
18
+
19
+
20
+ /** \ingroup Support_modules
21
+ * \defgroup MetisSupport_Module MetisSupport module
22
+ *
23
+ * \code
24
+ * #include <Eigen/MetisSupport>
25
+ * \endcode
26
+ * This module defines an interface to the METIS reordering package (http://glaros.dtc.umn.edu/gkhome/views/metis).
27
+ * It can be used just as any other built-in method as explained in \link OrderingMethods_Module here. \endlink
28
+ */
29
+
30
+
31
+ #include "src/MetisSupport/MetisSupport.h"
32
+
33
+ #include "src/Core/util/ReenableStupidWarnings.h"
34
+
35
+ #endif // EIGEN_METISSUPPORT_MODULE_H
cpp/src/librosa/eigen3/Eigen/OrderingMethods ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // This Source Code Form is subject to the terms of the Mozilla
5
+ // Public License v. 2.0. If a copy of the MPL was not distributed
6
+ // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
+
8
+ #ifndef EIGEN_ORDERINGMETHODS_MODULE_H
9
+ #define EIGEN_ORDERINGMETHODS_MODULE_H
10
+
11
+ #include "SparseCore"
12
+
13
+ #include "src/Core/util/DisableStupidWarnings.h"
14
+
15
+ /**
16
+ * \defgroup OrderingMethods_Module OrderingMethods module
17
+ *
18
+ * This module is currently for internal use only
19
+ *
20
+ * It defines various built-in and external ordering methods for sparse matrices.
21
+ * They are typically used to reduce the number of elements during
22
+ * the sparse matrix decomposition (LLT, LU, QR).
23
+ * Precisely, in a preprocessing step, a permutation matrix P is computed using
24
+ * those ordering methods and applied to the columns of the matrix.
25
+ * Using for instance the sparse Cholesky decomposition, it is expected that
26
+ * the nonzeros elements in LLT(A*P) will be much smaller than that in LLT(A).
27
+ *
28
+ *
29
+ * Usage :
30
+ * \code
31
+ * #include <Eigen/OrderingMethods>
32
+ * \endcode
33
+ *
34
+ * A simple usage is as a template parameter in the sparse decomposition classes :
35
+ *
36
+ * \code
37
+ * SparseLU<MatrixType, COLAMDOrdering<int> > solver;
38
+ * \endcode
39
+ *
40
+ * \code
41
+ * SparseQR<MatrixType, COLAMDOrdering<int> > solver;
42
+ * \endcode
43
+ *
44
+ * It is possible as well to call directly a particular ordering method for your own purpose,
45
+ * \code
46
+ * AMDOrdering<int> ordering;
47
+ * PermutationMatrix<Dynamic, Dynamic, int> perm;
48
+ * SparseMatrix<double> A;
49
+ * //Fill the matrix ...
50
+ *
51
+ * ordering(A, perm); // Call AMD
52
+ * \endcode
53
+ *
54
+ * \note Some of these methods (like AMD or METIS), need the sparsity pattern
55
+ * of the input matrix to be symmetric. When the matrix is structurally unsymmetric,
56
+ * Eigen computes internally the pattern of \f$A^T*A\f$ before calling the method.
57
+ * If your matrix is already symmetric (at leat in structure), you can avoid that
58
+ * by calling the method with a SelfAdjointView type.
59
+ *
60
+ * \code
61
+ * // Call the ordering on the pattern of the lower triangular matrix A
62
+ * ordering(A.selfadjointView<Lower>(), perm);
63
+ * \endcode
64
+ */
65
+
66
+ #ifndef EIGEN_MPL2_ONLY
67
+ #include "src/OrderingMethods/Amd.h"
68
+ #endif
69
+
70
+ #include "src/OrderingMethods/Ordering.h"
71
+ #include "src/Core/util/ReenableStupidWarnings.h"
72
+
73
+ #endif // EIGEN_ORDERINGMETHODS_MODULE_H
cpp/src/librosa/eigen3/Eigen/PaStiXSupport ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // This Source Code Form is subject to the terms of the Mozilla
5
+ // Public License v. 2.0. If a copy of the MPL was not distributed
6
+ // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
+
8
+ #ifndef EIGEN_PASTIXSUPPORT_MODULE_H
9
+ #define EIGEN_PASTIXSUPPORT_MODULE_H
10
+
11
+ #include "SparseCore"
12
+
13
+ #include "src/Core/util/DisableStupidWarnings.h"
14
+
15
+ extern "C" {
16
+ #include <pastix_nompi.h>
17
+ #include <pastix.h>
18
+ }
19
+
20
+ #ifdef complex
21
+ #undef complex
22
+ #endif
23
+
24
+ /** \ingroup Support_modules
25
+ * \defgroup PaStiXSupport_Module PaStiXSupport module
26
+ *
27
+ * This module provides an interface to the <a href="http://pastix.gforge.inria.fr/">PaSTiX</a> library.
28
+ * PaSTiX is a general \b supernodal, \b parallel and \b opensource sparse solver.
29
+ * It provides the two following main factorization classes:
30
+ * - class PastixLLT : a supernodal, parallel LLt Cholesky factorization.
31
+ * - class PastixLDLT: a supernodal, parallel LDLt Cholesky factorization.
32
+ * - class PastixLU : a supernodal, parallel LU factorization (optimized for a symmetric pattern).
33
+ *
34
+ * \code
35
+ * #include <Eigen/PaStiXSupport>
36
+ * \endcode
37
+ *
38
+ * In order to use this module, the PaSTiX headers must be accessible from the include paths, and your binary must be linked to the PaSTiX library and its dependencies.
39
+ * The dependencies depend on how PaSTiX has been compiled.
40
+ * For a cmake based project, you can use our FindPaSTiX.cmake module to help you in this task.
41
+ *
42
+ */
43
+
44
+ #include "src/PaStiXSupport/PaStiXSupport.h"
45
+
46
+ #include "src/Core/util/ReenableStupidWarnings.h"
47
+
48
+ #endif // EIGEN_PASTIXSUPPORT_MODULE_H
cpp/src/librosa/eigen3/Eigen/PardisoSupport ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // This Source Code Form is subject to the terms of the Mozilla
5
+ // Public License v. 2.0. If a copy of the MPL was not distributed
6
+ // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
+
8
+ #ifndef EIGEN_PARDISOSUPPORT_MODULE_H
9
+ #define EIGEN_PARDISOSUPPORT_MODULE_H
10
+
11
+ #include "SparseCore"
12
+
13
+ #include "src/Core/util/DisableStupidWarnings.h"
14
+
15
+ #include <mkl_pardiso.h>
16
+
17
+ /** \ingroup Support_modules
18
+ * \defgroup PardisoSupport_Module PardisoSupport module
19
+ *
20
+ * This module brings support for the Intel(R) MKL PARDISO direct sparse solvers.
21
+ *
22
+ * \code
23
+ * #include <Eigen/PardisoSupport>
24
+ * \endcode
25
+ *
26
+ * In order to use this module, the MKL headers must be accessible from the include paths, and your binary must be linked to the MKL library and its dependencies.
27
+ * See this \ref TopicUsingIntelMKL "page" for more information on MKL-Eigen integration.
28
+ *
29
+ */
30
+
31
+ #include "src/PardisoSupport/PardisoSupport.h"
32
+
33
+ #include "src/Core/util/ReenableStupidWarnings.h"
34
+
35
+ #endif // EIGEN_PARDISOSUPPORT_MODULE_H
cpp/src/librosa/eigen3/Eigen/QR ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // This Source Code Form is subject to the terms of the Mozilla
5
+ // Public License v. 2.0. If a copy of the MPL was not distributed
6
+ // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
+
8
+ #ifndef EIGEN_QR_MODULE_H
9
+ #define EIGEN_QR_MODULE_H
10
+
11
+ #include "Core"
12
+
13
+ #include "src/Core/util/DisableStupidWarnings.h"
14
+
15
+ #include "Cholesky"
16
+ #include "Jacobi"
17
+ #include "Householder"
18
+
19
+ /** \defgroup QR_Module QR module
20
+ *
21
+ *
22
+ *
23
+ * This module provides various QR decompositions
24
+ * This module also provides some MatrixBase methods, including:
25
+ * - MatrixBase::householderQr()
26
+ * - MatrixBase::colPivHouseholderQr()
27
+ * - MatrixBase::fullPivHouseholderQr()
28
+ *
29
+ * \code
30
+ * #include <Eigen/QR>
31
+ * \endcode
32
+ */
33
+
34
+ #include "src/QR/HouseholderQR.h"
35
+ #include "src/QR/FullPivHouseholderQR.h"
36
+ #include "src/QR/ColPivHouseholderQR.h"
37
+ #include "src/QR/CompleteOrthogonalDecomposition.h"
38
+ #ifdef EIGEN_USE_LAPACKE
39
+ #ifdef EIGEN_USE_MKL
40
+ #include "mkl_lapacke.h"
41
+ #else
42
+ #include "src/misc/lapacke.h"
43
+ #endif
44
+ #include "src/QR/HouseholderQR_LAPACKE.h"
45
+ #include "src/QR/ColPivHouseholderQR_LAPACKE.h"
46
+ #endif
47
+
48
+ #include "src/Core/util/ReenableStupidWarnings.h"
49
+
50
+ #endif // EIGEN_QR_MODULE_H
51
+ /* vim: set filetype=cpp et sw=2 ts=2 ai: */
cpp/src/librosa/eigen3/Eigen/QtAlignedMalloc ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // This Source Code Form is subject to the terms of the Mozilla
5
+ // Public License v. 2.0. If a copy of the MPL was not distributed
6
+ // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
+
8
+ #ifndef EIGEN_QTMALLOC_MODULE_H
9
+ #define EIGEN_QTMALLOC_MODULE_H
10
+
11
+ #include "Core"
12
+
13
+ #if (!EIGEN_MALLOC_ALREADY_ALIGNED)
14
+
15
+ #include "src/Core/util/DisableStupidWarnings.h"
16
+
17
+ void *qMalloc(std::size_t size)
18
+ {
19
+ return Eigen::internal::aligned_malloc(size);
20
+ }
21
+
22
+ void qFree(void *ptr)
23
+ {
24
+ Eigen::internal::aligned_free(ptr);
25
+ }
26
+
27
+ void *qRealloc(void *ptr, std::size_t size)
28
+ {
29
+ void* newPtr = Eigen::internal::aligned_malloc(size);
30
+ std::memcpy(newPtr, ptr, size);
31
+ Eigen::internal::aligned_free(ptr);
32
+ return newPtr;
33
+ }
34
+
35
+ #include "src/Core/util/ReenableStupidWarnings.h"
36
+
37
+ #endif
38
+
39
+ #endif // EIGEN_QTMALLOC_MODULE_H
40
+ /* vim: set filetype=cpp et sw=2 ts=2 ai: */
cpp/src/librosa/eigen3/Eigen/SPQRSupport ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // This Source Code Form is subject to the terms of the Mozilla
5
+ // Public License v. 2.0. If a copy of the MPL was not distributed
6
+ // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
+
8
+ #ifndef EIGEN_SPQRSUPPORT_MODULE_H
9
+ #define EIGEN_SPQRSUPPORT_MODULE_H
10
+
11
+ #include "SparseCore"
12
+
13
+ #include "src/Core/util/DisableStupidWarnings.h"
14
+
15
+ #include "SuiteSparseQR.hpp"
16
+
17
+ /** \ingroup Support_modules
18
+ * \defgroup SPQRSupport_Module SuiteSparseQR module
19
+ *
20
+ * This module provides an interface to the SPQR library, which is part of the <a href="http://www.suitesparse.com">suitesparse</a> package.
21
+ *
22
+ * \code
23
+ * #include <Eigen/SPQRSupport>
24
+ * \endcode
25
+ *
26
+ * In order to use this module, the SPQR headers must be accessible from the include paths, and your binary must be linked to the SPQR library and its dependencies (Cholmod, AMD, COLAMD,...).
27
+ * For a cmake based project, you can use our FindSPQR.cmake and FindCholmod.Cmake modules
28
+ *
29
+ */
30
+
31
+ #include "src/CholmodSupport/CholmodSupport.h"
32
+ #include "src/SPQRSupport/SuiteSparseQRSupport.h"
33
+
34
+ #endif