From f7de49afe77ff25c85946294b889f9865ebbcf34 Mon Sep 17 00:00:00 2001 From: Yu Kun Date: Thu, 8 Aug 2019 15:46:18 +0800 Subject: [PATCH] remove knowhere_build Former-commit-id: 0a8468cb0f2247c81e39bf1215210470a277ba0a --- .../inc/Aggregator/AggregatorContext.h | 67 - .../Aggregator/AggregatorExecutionContext.h | 53 - .../inc/Aggregator/AggregatorService.h | 88 - .../inc/Aggregator/AggregatorSettings.h | 39 - .../AnnService/inc/Client/ClientWrapper.h | 80 - .../SPTAG/AnnService/inc/Client/Options.h | 42 - .../SPTAG/AnnService/inc/Core/BKT/Index.h | 112 - .../inc/Core/BKT/ParameterDefinitionList.h | 36 - .../SPTAG/AnnService/inc/Core/Common.h | 166 - .../SPTAG/AnnService/inc/Core/Common/BKTree.h | 492 - .../AnnService/inc/Core/Common/CommonUtils.h | 178 - .../AnnService/inc/Core/Common/DataUtils.h | 290 - .../AnnService/inc/Core/Common/Dataset.h | 216 - .../inc/Core/Common/DistanceUtils.h | 610 - .../inc/Core/Common/FineGrainedLock.h | 51 - .../SPTAG/AnnService/inc/Core/Common/Heap.h | 105 - .../SPTAG/AnnService/inc/Core/Common/KDTree.h | 358 - .../inc/Core/Common/NeighborhoodGraph.h | 436 - .../inc/Core/Common/QueryResultSet.h | 96 - .../Core/Common/RelativeNeighborhoodGraph.h | 123 - .../AnnService/inc/Core/Common/WorkSpace.h | 185 - .../inc/Core/Common/WorkSpacePool.h | 43 - .../AnnService/inc/Core/CommonDataStructure.h | 56 - .../AnnService/inc/Core/DefinitionList.h | 57 - .../SPTAG/AnnService/inc/Core/KDT/Index.h | 112 - .../inc/Core/KDT/ParameterDefinitionList.h | 34 - .../SPTAG/AnnService/inc/Core/MetadataSet.h | 114 - .../SPTAG/AnnService/inc/Core/SearchQuery.h | 239 - .../SPTAG/AnnService/inc/Core/VectorIndex.h | 94 - .../SPTAG/AnnService/inc/Core/VectorSet.h | 73 - .../AnnService/inc/Helper/ArgumentsParser.h | 253 - .../AnnService/inc/Helper/Base64Encode.h | 33 - .../AnnService/inc/Helper/CommonHelper.h | 40 - .../SPTAG/AnnService/inc/Helper/Concurrent.h | 97 - .../AnnService/inc/Helper/SimpleIniReader.h | 97 - .../AnnService/inc/Helper/StringConvert.h | 374 - .../AnnService/inc/IndexBuilder/Options.h | 47 - .../AnnService/inc/IndexBuilder/ThreadPool.h | 27 - .../inc/IndexBuilder/VectorSetReader.h | 43 - .../VectorSetReaders/DefaultReader.h | 108 - .../SPTAG/AnnService/inc/Server/QueryParser.h | 56 - .../inc/Server/SearchExecutionContext.h | 80 - .../AnnService/inc/Server/SearchExecutor.h | 56 - .../AnnService/inc/Server/SearchService.h | 73 - .../AnnService/inc/Server/ServiceContext.h | 44 - .../AnnService/inc/Server/ServiceSettings.h | 41 - .../SPTAG/AnnService/inc/Socket/Client.h | 68 - .../SPTAG/AnnService/inc/Socket/Common.h | 25 - .../SPTAG/AnnService/inc/Socket/Connection.h | 100 - .../AnnService/inc/Socket/ConnectionManager.h | 73 - .../SPTAG/AnnService/inc/Socket/Packet.h | 142 - .../AnnService/inc/Socket/RemoteSearchQuery.h | 99 - .../AnnService/inc/Socket/ResourceManager.h | 190 - .../SPTAG/AnnService/inc/Socket/Server.h | 55 - .../inc/Socket/SimpleSerialization.h | 174 - .../knowhere_build/include/arrow/allocator.h | 151 - .../knowhere_build/include/arrow/api.h | 43 - .../knowhere_build/include/arrow/array.h | 1149 - .../include/arrow/array/builder_adaptive.h | 175 - .../include/arrow/array/builder_base.h | 219 - .../include/arrow/array/builder_binary.h | 395 - .../include/arrow/array/builder_decimal.h | 53 - .../include/arrow/array/builder_dict.h | 369 - .../include/arrow/array/builder_nested.h | 260 - .../include/arrow/array/builder_primitive.h | 429 - .../include/arrow/array/builder_time.h | 70 - .../include/arrow/array/builder_union.h | 106 - .../include/arrow/array/concatenate.h | 39 - .../include/arrow/buffer-builder.h | 379 - .../knowhere_build/include/arrow/buffer.h | 444 - .../knowhere_build/include/arrow/builder.h | 58 - .../knowhere_build/include/arrow/compare.h | 101 - .../include/arrow/compute/api.h | 33 - .../include/arrow/compute/benchmark-util.h | 97 - .../include/arrow/compute/context.h | 82 - .../include/arrow/compute/expression.h | 261 - .../include/arrow/compute/kernel.h | 289 - .../include/arrow/compute/kernels/aggregate.h | 115 - .../include/arrow/compute/kernels/boolean.h | 76 - .../include/arrow/compute/kernels/cast.h | 98 - .../include/arrow/compute/kernels/compare.h | 176 - .../include/arrow/compute/kernels/count.h | 88 - .../include/arrow/compute/kernels/filter.h | 93 - .../include/arrow/compute/kernels/hash.h | 105 - .../include/arrow/compute/kernels/mean.h | 66 - .../include/arrow/compute/kernels/sum.h | 70 - .../include/arrow/compute/kernels/take.h | 101 - .../include/arrow/compute/logical_type.h | 308 - .../include/arrow/compute/operation.h | 52 - .../include/arrow/compute/test-util.h | 110 - .../include/arrow/compute/type_fwd.h | 38 - .../knowhere_build/include/arrow/csv/api.h | 24 - .../include/arrow/csv/chunker.h | 69 - .../include/arrow/csv/column-builder.h | 87 - .../include/arrow/csv/converter.h | 68 - .../include/arrow/csv/options.h | 98 - .../knowhere_build/include/arrow/csv/parser.h | 149 - .../knowhere_build/include/arrow/csv/reader.h | 53 - .../include/arrow/csv/test-common.h | 71 - .../include/arrow/dataset/api.h | 26 - .../include/arrow/dataset/dataset.h | 114 - .../include/arrow/dataset/discovery.h | 45 - .../include/arrow/dataset/disk_store.h | 56 - .../include/arrow/dataset/file_base.h | 144 - .../include/arrow/dataset/file_csv.h | 69 - .../include/arrow/dataset/file_feather.h | 56 - .../include/arrow/dataset/file_json.h | 61 - .../include/arrow/dataset/file_parquet.h | 60 - .../include/arrow/dataset/filter.h | 40 - .../include/arrow/dataset/partition.h | 217 - .../include/arrow/dataset/scanner.h | 94 - .../include/arrow/dataset/transaction.h | 25 - .../include/arrow/dataset/type_fwd.h | 71 - .../include/arrow/dataset/visibility.h | 48 - .../include/arrow/dataset/writer.h | 36 - .../include/arrow/extension_type.h | 128 - .../include/arrow/filesystem/filesystem.h | 247 - .../include/arrow/filesystem/localfs.h | 67 - .../include/arrow/filesystem/mockfs.h | 104 - .../include/arrow/filesystem/path-util.h | 70 - .../include/arrow/filesystem/test-util.h | 132 - .../knowhere_build/include/arrow/io/api.h | 28 - .../include/arrow/io/buffered.h | 160 - .../include/arrow/io/compressed.h | 115 - .../knowhere_build/include/arrow/io/file.h | 246 - .../knowhere_build/include/arrow/io/hdfs.h | 258 - .../include/arrow/io/interfaces.h | 206 - .../knowhere_build/include/arrow/io/memory.h | 172 - .../knowhere_build/include/arrow/io/mman.h | 181 - .../include/arrow/io/readahead.h | 98 - .../include/arrow/io/test-common.h | 61 - .../knowhere_build/include/arrow/ipc/api.h | 28 - .../include/arrow/ipc/dictionary.h | 106 - .../include/arrow/ipc/feather.h | 173 - .../include/arrow/ipc/json-integration.h | 133 - .../include/arrow/ipc/json-simple.h | 56 - .../include/arrow/ipc/message.h | 241 - .../knowhere_build/include/arrow/ipc/reader.h | 291 - .../include/arrow/ipc/test-common.h | 139 - .../knowhere_build/include/arrow/ipc/util.h | 48 - .../knowhere_build/include/arrow/ipc/writer.h | 393 - .../knowhere_build/include/arrow/json/api.h | 21 - .../include/arrow/json/chunked-builder.h | 76 - .../include/arrow/json/chunker.h | 69 - .../include/arrow/json/converter.h | 94 - .../include/arrow/json/options.h | 63 - .../include/arrow/json/parser.h | 96 - .../include/arrow/json/rapidjson-defs.h | 44 - .../include/arrow/json/reader.h | 62 - .../include/arrow/json/test-common.h | 183 - .../include/arrow/memory_pool-test.h | 90 - .../include/arrow/memory_pool.h | 155 - .../include/arrow/pretty_print.h | 112 - .../include/arrow/record_batch.h | 188 - .../knowhere_build/include/arrow/result.h | 344 - .../knowhere_build/include/arrow/scalar.h | 210 - .../include/arrow/sparse_tensor.h | 271 - .../knowhere_build/include/arrow/status.h | 423 - .../knowhere_build/include/arrow/stl.h | 373 - .../knowhere_build/include/arrow/table.h | 396 - .../include/arrow/table_builder.h | 113 - .../knowhere_build/include/arrow/tensor.h | 167 - .../include/arrow/testing/gtest_common.h | 133 - .../include/arrow/testing/gtest_util.h | 330 - .../include/arrow/testing/random.h | 272 - .../include/arrow/testing/util.h | 126 - .../knowhere_build/include/arrow/type.h | 1219 - .../knowhere_build/include/arrow/type_fwd.h | 233 - .../include/arrow/type_traits.h | 598 - .../include/arrow/util/basic_decimal.h | 175 - .../include/arrow/util/bit-stream-utils.h | 416 - .../include/arrow/util/bit-util.h | 923 - .../include/arrow/util/bpacking.h | 3308 --- .../include/arrow/util/checked_cast.h | 63 - .../include/arrow/util/compiler-util.h | 25 - .../include/arrow/util/compression.h | 153 - .../include/arrow/util/compression_brotli.h | 55 - .../include/arrow/util/compression_bz2.h | 55 - .../include/arrow/util/compression_lz4.h | 55 - .../include/arrow/util/compression_snappy.h | 54 - .../include/arrow/util/compression_zlib.h | 70 - .../include/arrow/util/compression_zstd.h | 55 - .../include/arrow/util/config.h | 24 - .../include/arrow/util/cpu-info.h | 101 - .../include/arrow/util/decimal.h | 133 - .../include/arrow/util/hash-util.h | 310 - .../include/arrow/util/hashing.h | 963 - .../include/arrow/util/int-util.h | 105 - .../include/arrow/util/interfaces.h | 32 - .../include/arrow/util/io-util.h | 263 - .../include/arrow/util/iterator.h | 35 - .../include/arrow/util/key_value_metadata.h | 81 - .../knowhere_build/include/arrow/util/lazy.h | 128 - .../include/arrow/util/logging.h | 253 - .../include/arrow/util/macros.h | 166 - .../include/arrow/util/memory.h | 46 - .../include/arrow/util/neon-util.h | 59 - .../include/arrow/util/parallel.h | 95 - .../include/arrow/util/parsing.h | 512 - .../include/arrow/util/rle-encoding.h | 604 - .../include/arrow/util/sse-util.h | 122 - .../knowhere_build/include/arrow/util/stl.h | 95 - .../include/arrow/util/stopwatch.h | 48 - .../include/arrow/util/string.h | 68 - .../include/arrow/util/string_builder.h | 69 - .../include/arrow/util/string_view.h | 33 - .../include/arrow/util/task-group.h | 91 - .../include/arrow/util/thread-pool.h | 169 - .../knowhere_build/include/arrow/util/trie.h | 245 - .../include/arrow/util/type_traits.h | 48 - .../knowhere_build/include/arrow/util/ubsan.h | 53 - .../knowhere_build/include/arrow/util/uri.h | 70 - .../knowhere_build/include/arrow/util/utf8.h | 184 - .../include/arrow/util/variant.h | 36 - .../include/arrow/util/visibility.h | 46 - .../arrow/util/windows_compatibility.h | 40 - .../include/arrow/vendored/datetime.h | 21 - .../include/arrow/vendored/datetime/date.h | 7944 ------- .../include/arrow/vendored/datetime/ios.h | 53 - .../include/arrow/vendored/datetime/tz.h | 2775 --- .../arrow/vendored/datetime/tz_private.h | 319 - .../arrow/vendored/datetime/visibility.h | 26 - .../include/arrow/vendored/string_view.hpp | 1330 -- .../include/arrow/vendored/variant.hpp | 2815 --- .../knowhere_build/include/arrow/visitor.h | 141 - .../include/arrow/visitor_inline.h | 289 - cpp/thirdparty/knowhere_build/include/cblas.h | 385 - .../knowhere_build/include/f77blas.h | 779 - .../knowhere_build/include/faiss/AutoTune.h | 261 - .../include/faiss/AuxIndexStructures.h | 286 - .../knowhere_build/include/faiss/Clustering.h | 101 - .../include/faiss/FaissAssert.h | 95 - .../include/faiss/FaissException.h | 71 - .../knowhere_build/include/faiss/HNSW.h | 274 - .../knowhere_build/include/faiss/Heap.h | 495 - .../knowhere_build/include/faiss/IVFlib.h | 129 - .../knowhere_build/include/faiss/Index.h | 221 - .../include/faiss/IndexBinary.h | 163 - .../include/faiss/IndexBinaryFlat.h | 54 - .../include/faiss/IndexBinaryFromFloat.h | 52 - .../include/faiss/IndexBinaryHNSW.h | 56 - .../include/faiss/IndexBinaryIVF.h | 211 - .../knowhere_build/include/faiss/IndexFlat.h | 165 - .../knowhere_build/include/faiss/IndexHNSW.h | 170 - .../knowhere_build/include/faiss/IndexIVF.h | 336 - .../include/faiss/IndexIVFFlat.h | 114 - .../knowhere_build/include/faiss/IndexIVFPQ.h | 258 - .../include/faiss/IndexIVFSpectralHash.h | 74 - .../knowhere_build/include/faiss/IndexLSH.h | 77 - .../knowhere_build/include/faiss/IndexPQ.h | 189 - .../include/faiss/IndexReplicas.h | 76 - .../include/faiss/IndexScalarQuantizer.h | 172 - .../include/faiss/IndexShards.h | 100 - .../include/faiss/InvertedLists.h | 334 - .../include/faiss/MetaIndexes.h | 126 - .../include/faiss/OnDiskInvertedLists.h | 127 - .../include/faiss/PolysemousTraining.h | 158 - .../include/faiss/ProductQuantizer.h | 242 - .../include/faiss/ThreadedIndex-inl.h | 192 - .../include/faiss/ThreadedIndex.h | 80 - .../include/faiss/VectorTransform.h | 337 - .../include/faiss/WorkerThread.h | 61 - .../knowhere_build/include/faiss/distances.h | 54 - .../include/faiss/gpu/GpuAutoTune.h | 48 - .../include/faiss/gpu/GpuClonerOptions.h | 53 - .../include/faiss/gpu/GpuDistance.h | 52 - .../include/faiss/gpu/GpuFaissAssert.h | 29 - .../include/faiss/gpu/GpuIndex.h | 135 - .../include/faiss/gpu/GpuIndexBinaryFlat.h | 89 - .../include/faiss/gpu/GpuIndexFlat.h | 180 - .../include/faiss/gpu/GpuIndexIVF.h | 90 - .../include/faiss/gpu/GpuIndexIVFFlat.h | 92 - .../include/faiss/gpu/GpuIndexIVFPQ.h | 143 - .../include/faiss/gpu/GpuIndicesOptions.h | 30 - .../include/faiss/gpu/GpuResources.h | 73 - .../include/faiss/gpu/StandardGpuResources.h | 114 - .../include/faiss/gpu/impl/RemapIndices.h | 24 - .../include/faiss/gpu/utils/DeviceMemory.h | 71 - .../include/faiss/gpu/utils/DeviceUtils.h | 179 - .../include/faiss/gpu/utils/MemorySpace.h | 44 - .../faiss/gpu/utils/StackDeviceMemory.h | 129 - .../include/faiss/gpu/utils/StaticUtils.h | 78 - .../include/faiss/gpu/utils/Timer.h | 52 - .../knowhere_build/include/faiss/hamming.h | 572 - .../knowhere_build/include/faiss/index_io.h | 90 - .../knowhere_build/include/faiss/utils.h | 418 - .../include/jsoncons/basic_json.hpp | 4984 ---- .../include/jsoncons/bignum.hpp | 1604 -- .../include/jsoncons/byte_string.hpp | 710 - .../include/jsoncons/config/binary_detail.hpp | 547 - .../jsoncons/config/jsoncons_config.hpp | 114 - .../include/jsoncons/config/version.hpp | 40 - .../include/jsoncons/detail/grisu3.hpp | 405 - .../jsoncons/detail/heap_only_string.hpp | 156 - .../include/jsoncons/detail/parse_number.hpp | 526 - .../include/jsoncons/detail/print_number.hpp | 344 - .../include/jsoncons/detail/string_view.hpp | 525 - .../include/jsoncons/detail/type_traits.hpp | 228 - .../include/jsoncons/encode_decode_json.hpp | 280 - .../knowhere_build/include/jsoncons/json.hpp | 14 - .../include/jsoncons/json_container_types.hpp | 1962 -- .../include/jsoncons/json_content_handler.hpp | 431 - .../jsoncons/json_conversion_traits.hpp | 196 - .../include/jsoncons/json_cursor.hpp | 680 - .../include/jsoncons/json_decoder.hpp | 357 - .../include/jsoncons/json_encoder.hpp | 1470 -- .../include/jsoncons/json_error.hpp | 154 - .../include/jsoncons/json_exception.hpp | 183 - .../include/jsoncons/json_filter.hpp | 382 - .../include/jsoncons/json_fwd.hpp | 23 - .../include/jsoncons/json_options.hpp | 837 - .../include/jsoncons/json_parser.hpp | 2841 --- .../include/jsoncons/json_pull_reader.hpp | 13 - .../include/jsoncons/json_reader.hpp | 514 - .../include/jsoncons/json_serializer.hpp | 12 - .../include/jsoncons/json_type_traits.hpp | 1047 - .../jsoncons/json_type_traits_macros.hpp | 181 - .../include/jsoncons/parse_error_handler.hpp | 74 - .../include/jsoncons/pretty_print.hpp | 89 - .../include/jsoncons/result.hpp | 284 - .../include/jsoncons/ser_context.hpp | 50 - .../include/jsoncons/source.hpp | 746 - .../include/jsoncons/staj_iterator.hpp | 354 - .../include/jsoncons/staj_reader.hpp | 434 - .../include/jsoncons/unicode_traits.hpp | 1492 -- .../include/jsoncons_ext/bson/bson.hpp | 106 - .../include/jsoncons_ext/bson/bson_detail.hpp | 42 - .../jsoncons_ext/bson/bson_encoder.hpp | 342 - .../include/jsoncons_ext/bson/bson_error.hpp | 70 - .../include/jsoncons_ext/bson/bson_reader.hpp | 297 - .../include/jsoncons_ext/cbor/cbor.hpp | 130 - .../include/jsoncons_ext/cbor/cbor_detail.hpp | 72 - .../jsoncons_ext/cbor/cbor_encoder.hpp | 1062 - .../include/jsoncons_ext/cbor/cbor_error.hpp | 96 - .../jsoncons_ext/cbor/cbor_options.hpp | 66 - .../include/jsoncons_ext/cbor/cbor_reader.hpp | 1491 -- .../include/jsoncons_ext/csv/csv.hpp | 14 - .../include/jsoncons_ext/csv/csv_encoder.hpp | 619 - .../include/jsoncons_ext/csv/csv_error.hpp | 77 - .../include/jsoncons_ext/csv/csv_options.hpp | 771 - .../include/jsoncons_ext/csv/csv_parser.hpp | 1357 -- .../include/jsoncons_ext/csv/csv_reader.hpp | 328 - .../jsoncons_ext/csv/csv_serializer.hpp | 12 - .../jsoncons_ext/jsonpatch/jsonpatch.hpp | 492 - .../jsonpatch/jsonpatch_error.hpp | 114 - .../jsoncons_ext/jsonpath/json_query.hpp | 1808 -- .../jsoncons_ext/jsonpath/jsonpath_error.hpp | 206 - .../jsoncons_ext/jsonpath/jsonpath_filter.hpp | 1953 -- .../jsonpath/jsonpath_function.hpp | 225 - .../jsoncons_ext/jsonpointer/jsonpointer.hpp | 959 - .../jsonpointer/jsonpointer.hpp.orig | 1060 - .../jsonpointer/jsonpointer_error.hpp | 109 - .../include/jsoncons_ext/msgpack/msgpack.hpp | 126 - .../jsoncons_ext/msgpack/msgpack_detail.hpp | 50 - .../jsoncons_ext/msgpack/msgpack_encoder.hpp | 459 - .../jsoncons_ext/msgpack/msgpack_error.hpp | 82 - .../jsoncons_ext/msgpack/msgpack_reader.hpp | 757 - .../include/jsoncons_ext/ubjson/ubjson.hpp | 106 - .../jsoncons_ext/ubjson/ubjson_detail.hpp | 42 - .../jsoncons_ext/ubjson/ubjson_encoder.hpp | 433 - .../jsoncons_ext/ubjson/ubjson_error.hpp | 89 - .../jsoncons_ext/ubjson/ubjson_reader.hpp | 589 - .../include/knowhere/adapter/arrow.h | 18 - .../include/knowhere/adapter/faiss_adopt.h | 20 - .../include/knowhere/adapter/sptag.h | 24 - .../include/knowhere/adapter/structure.h | 42 - .../include/knowhere/common/array.h | 35 - .../include/knowhere/common/binary_set.h | 62 - .../include/knowhere/common/buffer.h | 45 - .../include/knowhere/common/config.h | 14 - .../include/knowhere/common/dataset.h | 122 - .../include/knowhere/common/device_type.h | 10 - .../include/knowhere/common/error.h | 40 - .../include/knowhere/common/exception.h | 45 - .../include/knowhere/common/id.h | 42 - .../include/knowhere/common/schema.h | 21 - .../include/knowhere/common/tensor.h | 16 - .../include/knowhere/common/timer.h | 41 - .../include/knowhere/index/index.h | 49 - .../include/knowhere/index/index_model.h | 24 - .../include/knowhere/index/index_type.h | 17 - .../knowhere/index/preprocessor/normalize.h | 26 - .../index/preprocessor/preprocessor.h | 22 - .../knowhere/index/vector_index/cpu_kdt_rng.h | 70 - .../knowhere/index/vector_index/definitions.h | 14 - .../knowhere/index/vector_index/gpu_ivf.h | 54 - .../knowhere/index/vector_index/idmap.h | 36 - .../include/knowhere/index/vector_index/ivf.h | 123 - .../index/vector_index/kdt_parameters.h | 34 - .../index/vector_index/nsg/neighbor.h | 51 - .../knowhere/index/vector_index/nsg/nsg.h | 147 - .../knowhere/index/vector_index/nsg/nsg.i | 15 - .../knowhere/index/vector_index/nsg/nsg_io.h | 22 - .../knowhere/index/vector_index/nsg_index.h | 40 - .../index/vector_index/vector_index.h | 38 - .../knowhere_build/include/lapacke.h | 19463 ---------------- .../knowhere_build/include/lapacke_config.h | 126 - .../knowhere_build/include/lapacke_mangling.h | 17 - .../knowhere_build/include/lapacke_utils.h | 579 - .../knowhere_build/include/openblas_config.h | 141 - 400 files changed, 125767 deletions(-) delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Aggregator/AggregatorContext.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Aggregator/AggregatorExecutionContext.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Aggregator/AggregatorService.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Aggregator/AggregatorSettings.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Client/ClientWrapper.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Client/Options.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/BKT/Index.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/BKT/ParameterDefinitionList.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/BKTree.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/CommonUtils.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/DataUtils.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/Dataset.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/DistanceUtils.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/FineGrainedLock.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/Heap.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/KDTree.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/NeighborhoodGraph.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/QueryResultSet.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/RelativeNeighborhoodGraph.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/WorkSpace.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/WorkSpacePool.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/CommonDataStructure.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/DefinitionList.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/KDT/Index.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/KDT/ParameterDefinitionList.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/MetadataSet.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/SearchQuery.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/VectorIndex.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/VectorSet.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Helper/ArgumentsParser.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Helper/Base64Encode.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Helper/CommonHelper.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Helper/Concurrent.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Helper/SimpleIniReader.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Helper/StringConvert.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/IndexBuilder/Options.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/IndexBuilder/ThreadPool.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/IndexBuilder/VectorSetReader.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/IndexBuilder/VectorSetReaders/DefaultReader.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Server/QueryParser.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Server/SearchExecutionContext.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Server/SearchExecutor.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Server/SearchService.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Server/ServiceContext.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Server/ServiceSettings.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/Client.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/Common.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/Connection.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/ConnectionManager.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/Packet.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/RemoteSearchQuery.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/ResourceManager.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/Server.h delete mode 100644 cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/SimpleSerialization.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/allocator.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/api.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/array.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/array/builder_adaptive.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/array/builder_base.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/array/builder_binary.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/array/builder_decimal.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/array/builder_dict.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/array/builder_nested.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/array/builder_primitive.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/array/builder_time.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/array/builder_union.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/array/concatenate.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/buffer-builder.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/buffer.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/builder.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/compare.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/compute/api.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/compute/benchmark-util.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/compute/context.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/compute/expression.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/compute/kernel.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/aggregate.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/boolean.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/cast.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/compare.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/count.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/filter.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/hash.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/mean.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/sum.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/take.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/compute/logical_type.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/compute/operation.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/compute/test-util.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/compute/type_fwd.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/csv/api.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/csv/chunker.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/csv/column-builder.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/csv/converter.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/csv/options.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/csv/parser.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/csv/reader.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/csv/test-common.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/dataset/api.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/dataset/dataset.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/dataset/discovery.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/dataset/disk_store.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/dataset/file_base.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/dataset/file_csv.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/dataset/file_feather.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/dataset/file_json.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/dataset/file_parquet.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/dataset/filter.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/dataset/partition.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/dataset/scanner.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/dataset/transaction.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/dataset/type_fwd.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/dataset/visibility.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/dataset/writer.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/extension_type.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/filesystem/filesystem.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/filesystem/localfs.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/filesystem/mockfs.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/filesystem/path-util.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/filesystem/test-util.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/io/api.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/io/buffered.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/io/compressed.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/io/file.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/io/hdfs.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/io/interfaces.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/io/memory.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/io/mman.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/io/readahead.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/io/test-common.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/ipc/api.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/ipc/dictionary.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/ipc/feather.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/ipc/json-integration.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/ipc/json-simple.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/ipc/message.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/ipc/reader.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/ipc/test-common.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/ipc/util.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/ipc/writer.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/json/api.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/json/chunked-builder.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/json/chunker.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/json/converter.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/json/options.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/json/parser.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/json/rapidjson-defs.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/json/reader.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/json/test-common.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/memory_pool-test.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/memory_pool.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/pretty_print.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/record_batch.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/result.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/scalar.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/sparse_tensor.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/status.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/stl.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/table.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/table_builder.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/tensor.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/testing/gtest_common.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/testing/gtest_util.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/testing/random.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/testing/util.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/type.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/type_fwd.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/type_traits.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/basic_decimal.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/bit-stream-utils.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/bit-util.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/bpacking.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/checked_cast.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/compiler-util.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/compression.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/compression_brotli.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/compression_bz2.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/compression_lz4.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/compression_snappy.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/compression_zlib.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/compression_zstd.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/config.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/cpu-info.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/decimal.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/hash-util.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/hashing.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/int-util.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/interfaces.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/io-util.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/iterator.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/key_value_metadata.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/lazy.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/logging.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/macros.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/memory.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/neon-util.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/parallel.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/parsing.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/rle-encoding.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/sse-util.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/stl.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/stopwatch.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/string.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/string_builder.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/string_view.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/task-group.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/thread-pool.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/trie.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/type_traits.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/ubsan.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/uri.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/utf8.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/variant.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/visibility.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/util/windows_compatibility.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/vendored/datetime.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/vendored/datetime/date.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/vendored/datetime/ios.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/vendored/datetime/tz.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/vendored/datetime/tz_private.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/vendored/datetime/visibility.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/vendored/string_view.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/vendored/variant.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/visitor.h delete mode 100644 cpp/thirdparty/knowhere_build/include/arrow/visitor_inline.h delete mode 100644 cpp/thirdparty/knowhere_build/include/cblas.h delete mode 100644 cpp/thirdparty/knowhere_build/include/f77blas.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/AutoTune.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/AuxIndexStructures.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/Clustering.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/FaissAssert.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/FaissException.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/HNSW.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/Heap.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/IVFlib.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/Index.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/IndexBinary.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/IndexBinaryFlat.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/IndexBinaryFromFloat.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/IndexBinaryHNSW.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/IndexBinaryIVF.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/IndexFlat.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/IndexHNSW.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/IndexIVF.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/IndexIVFFlat.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/IndexIVFPQ.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/IndexIVFSpectralHash.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/IndexLSH.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/IndexPQ.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/IndexReplicas.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/IndexScalarQuantizer.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/IndexShards.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/InvertedLists.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/MetaIndexes.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/OnDiskInvertedLists.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/PolysemousTraining.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/ProductQuantizer.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/ThreadedIndex-inl.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/ThreadedIndex.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/VectorTransform.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/WorkerThread.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/distances.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuAutoTune.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuClonerOptions.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuDistance.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuFaissAssert.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuIndex.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuIndexBinaryFlat.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuIndexFlat.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuIndexIVF.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuIndexIVFFlat.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuIndexIVFPQ.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuIndicesOptions.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuResources.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/gpu/StandardGpuResources.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/gpu/impl/RemapIndices.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/gpu/utils/DeviceMemory.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/gpu/utils/DeviceUtils.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/gpu/utils/MemorySpace.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/gpu/utils/StackDeviceMemory.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/gpu/utils/StaticUtils.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/gpu/utils/Timer.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/hamming.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/index_io.h delete mode 100644 cpp/thirdparty/knowhere_build/include/faiss/utils.h delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/basic_json.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/bignum.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/byte_string.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/config/binary_detail.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/config/jsoncons_config.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/config/version.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/detail/grisu3.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/detail/heap_only_string.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/detail/parse_number.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/detail/print_number.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/detail/string_view.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/detail/type_traits.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/encode_decode_json.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/json.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/json_container_types.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/json_content_handler.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/json_conversion_traits.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/json_cursor.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/json_decoder.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/json_encoder.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/json_error.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/json_exception.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/json_filter.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/json_fwd.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/json_options.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/json_parser.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/json_pull_reader.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/json_reader.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/json_serializer.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/json_type_traits.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/json_type_traits_macros.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/parse_error_handler.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/pretty_print.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/result.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/ser_context.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/source.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/staj_iterator.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/staj_reader.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons/unicode_traits.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/bson/bson.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/bson/bson_detail.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/bson/bson_encoder.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/bson/bson_error.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/bson/bson_reader.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/cbor/cbor.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/cbor/cbor_detail.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/cbor/cbor_encoder.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/cbor/cbor_error.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/cbor/cbor_options.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/cbor/cbor_reader.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/csv/csv.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/csv/csv_encoder.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/csv/csv_error.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/csv/csv_options.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/csv/csv_parser.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/csv/csv_reader.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/csv/csv_serializer.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpatch/jsonpatch.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpatch/jsonpatch_error.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpath/json_query.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpath/jsonpath_error.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpath/jsonpath_filter.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpath/jsonpath_function.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpointer/jsonpointer.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpointer/jsonpointer.hpp.orig delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpointer/jsonpointer_error.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/msgpack/msgpack.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/msgpack/msgpack_detail.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/msgpack/msgpack_encoder.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/msgpack/msgpack_error.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/msgpack/msgpack_reader.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/ubjson/ubjson.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/ubjson/ubjson_detail.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/ubjson/ubjson_encoder.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/ubjson/ubjson_error.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/jsoncons_ext/ubjson/ubjson_reader.hpp delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/adapter/arrow.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/adapter/faiss_adopt.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/adapter/sptag.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/adapter/structure.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/common/array.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/common/binary_set.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/common/buffer.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/common/config.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/common/dataset.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/common/device_type.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/common/error.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/common/exception.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/common/id.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/common/schema.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/common/tensor.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/common/timer.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/index/index.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/index/index_model.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/index/index_type.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/index/preprocessor/normalize.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/index/preprocessor/preprocessor.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/cpu_kdt_rng.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/definitions.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/gpu_ivf.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/idmap.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/ivf.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/kdt_parameters.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/nsg/neighbor.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/nsg/nsg.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/nsg/nsg.i delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/nsg/nsg_io.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/nsg_index.h delete mode 100644 cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/vector_index.h delete mode 100644 cpp/thirdparty/knowhere_build/include/lapacke.h delete mode 100644 cpp/thirdparty/knowhere_build/include/lapacke_config.h delete mode 100644 cpp/thirdparty/knowhere_build/include/lapacke_mangling.h delete mode 100644 cpp/thirdparty/knowhere_build/include/lapacke_utils.h delete mode 100644 cpp/thirdparty/knowhere_build/include/openblas_config.h diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Aggregator/AggregatorContext.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Aggregator/AggregatorContext.h deleted file mode 100644 index 60c86137be..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Aggregator/AggregatorContext.h +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_AGGREGATOR_AGGREGATORCONTEXT_H_ -#define _SPTAG_AGGREGATOR_AGGREGATORCONTEXT_H_ - -#include "inc/Socket/Common.h" -#include "AggregatorSettings.h" - -#include -#include -#include - -namespace SPTAG -{ -namespace Aggregator -{ - -enum RemoteMachineStatus : uint8_t -{ - Disconnected = 0, - - Connecting, - - Connected -}; - - -struct RemoteMachine -{ - RemoteMachine(); - - std::string m_address; - - std::string m_port; - - Socket::ConnectionID m_connectionID; - - std::atomic m_status; -}; - -class AggregatorContext -{ -public: - AggregatorContext(const std::string& p_filePath); - - ~AggregatorContext(); - - bool IsInitialized() const; - - const std::vector>& GetRemoteServers() const; - - const std::shared_ptr& GetSettings() const; - -private: - std::vector> m_remoteServers; - - std::shared_ptr m_settings; - - bool m_initialized; -}; - -} // namespace Aggregator -} // namespace AnnService - - -#endif // _SPTAG_AGGREGATOR_AGGREGATORCONTEXT_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Aggregator/AggregatorExecutionContext.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Aggregator/AggregatorExecutionContext.h deleted file mode 100644 index 12948a218a..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Aggregator/AggregatorExecutionContext.h +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_AGGREGATOR_AGGREGATOREXECUTIONCONTEXT_H_ -#define _SPTAG_AGGREGATOR_AGGREGATOREXECUTIONCONTEXT_H_ - -#include "inc/Socket/RemoteSearchQuery.h" -#include "inc/Socket/Packet.h" - -#include -#include - -namespace SPTAG -{ -namespace Aggregator -{ - -typedef std::shared_ptr AggregatorResult; - -class AggregatorExecutionContext -{ -public: - AggregatorExecutionContext(std::size_t p_totalServerNumber, - Socket::PacketHeader p_requestHeader); - - ~AggregatorExecutionContext(); - - std::size_t GetServerNumber() const; - - AggregatorResult& GetResult(std::size_t p_num); - - const Socket::PacketHeader& GetRequestHeader() const; - - bool IsCompletedAfterFinsh(std::uint32_t p_finishedCount); - -private: - std::atomic m_unfinishedCount; - - std::vector m_results; - - Socket::PacketHeader m_requestHeader; - -}; - - - - -} // namespace Aggregator -} // namespace AnnService - - -#endif // _SPTAG_AGGREGATOR_AGGREGATOREXECUTIONCONTEXT_H_ - diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Aggregator/AggregatorService.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Aggregator/AggregatorService.h deleted file mode 100644 index 4d864aa5f0..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Aggregator/AggregatorService.h +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_AGGREGATOR_AGGREGATORSERVICE_H_ -#define _SPTAG_AGGREGATOR_AGGREGATORSERVICE_H_ - -#include "AggregatorContext.h" -#include "AggregatorExecutionContext.h" -#include "inc/Socket/Server.h" -#include "inc/Socket/Client.h" -#include "inc/Socket/ResourceManager.h" - -#include - -#include -#include -#include -#include - -namespace SPTAG -{ -namespace Aggregator -{ - -class AggregatorService -{ -public: - AggregatorService(); - - ~AggregatorService(); - - bool Initialize(); - - void Run(); - -private: - - void StartClient(); - - void StartListen(); - - void WaitForShutdown(); - - void ConnectToPendingServers(); - - void AddToPendingServers(std::shared_ptr p_remoteServer); - - void SearchRequestHanlder(Socket::ConnectionID p_localConnectionID, Socket::Packet p_packet); - - void SearchResponseHanlder(Socket::ConnectionID p_localConnectionID, Socket::Packet p_packet); - - void AggregateResults(std::shared_ptr p_exectionContext); - - std::shared_ptr GetContext(); - -private: - typedef std::function AggregatorCallback; - - std::shared_ptr m_aggregatorContext; - - std::shared_ptr m_socketServer; - - std::shared_ptr m_socketClient; - - bool m_initalized; - - std::unique_ptr m_threadPool; - - boost::asio::io_context m_ioContext; - - boost::asio::signal_set m_shutdownSignals; - - std::vector> m_pendingConnectServers; - - std::mutex m_pendingConnectServersMutex; - - boost::asio::deadline_timer m_pendingConnectServersTimer; - - Socket::ResourceManager m_aggregatorCallbackManager; -}; - - - -} // namespace Aggregator -} // namespace AnnService - - -#endif // _SPTAG_AGGREGATOR_AGGREGATORSERVICE_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Aggregator/AggregatorSettings.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Aggregator/AggregatorSettings.h deleted file mode 100644 index cb1e9fe7f7..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Aggregator/AggregatorSettings.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_AGGREGATOR_AGGREGATORSETTINGS_H_ -#define _SPTAG_AGGREGATOR_AGGREGATORSETTINGS_H_ - -#include "../Core/Common.h" - -#include - -namespace SPTAG -{ -namespace Aggregator -{ - -struct AggregatorSettings -{ - AggregatorSettings(); - - std::string m_listenAddr; - - std::string m_listenPort; - - std::uint32_t m_searchTimeout; - - SizeType m_threadNum; - - SizeType m_socketThreadNum; -}; - - - - -} // namespace Aggregator -} // namespace AnnService - - -#endif // _SPTAG_AGGREGATOR_AGGREGATORSETTINGS_H_ - diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Client/ClientWrapper.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Client/ClientWrapper.h deleted file mode 100644 index d96a67061e..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Client/ClientWrapper.h +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_CLIENT_CLIENTWRAPPER_H_ -#define _SPTAG_CLIENT_CLIENTWRAPPER_H_ - -#include "inc/Socket/Client.h" -#include "inc/Socket/RemoteSearchQuery.h" -#include "inc/Socket/ResourceManager.h" -#include "Options.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace SPTAG -{ -namespace Client -{ - -class ClientWrapper -{ -public: - typedef std::function Callback; - - ClientWrapper(const ClientOptions& p_options); - - ~ClientWrapper(); - - void SendQueryAsync(const Socket::RemoteQuery& p_query, - Callback p_callback, - const ClientOptions& p_options); - - void WaitAllFinished(); - - bool IsAvailable() const; - -private: - typedef std::pair ConnectionPair; - - Socket::PacketHandlerMapPtr GetHandlerMap(); - - void DecreaseUnfnishedJobCount(); - - const ConnectionPair& GetConnection(); - - void SearchResponseHanlder(Socket::ConnectionID p_localConnectionID, Socket::Packet p_packet); - - void HandleDeadConnection(Socket::ConnectionID p_cid); - -private: - ClientOptions m_options; - - std::unique_ptr m_client; - - std::atomic m_unfinishedJobCount; - - std::atomic_bool m_isWaitingFinish; - - std::condition_variable m_waitingQueue; - - std::mutex m_waitingMutex; - - std::vector m_connections; - - std::atomic m_spinCountOfConnection; - - Socket::ResourceManager m_callbackManager; -}; - - -} // namespace Socket -} // namespace SPTAG - -#endif // _SPTAG_CLIENT_OPTIONS_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Client/Options.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Client/Options.h deleted file mode 100644 index 062061f042..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Client/Options.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_CLIENT_OPTIONS_H_ -#define _SPTAG_CLIENT_OPTIONS_H_ - -#include "inc/Helper/ArgumentsParser.h" - -#include -#include -#include - -namespace SPTAG -{ -namespace Client -{ - -class ClientOptions : public Helper::ArgumentsParser -{ -public: - ClientOptions(); - - virtual ~ClientOptions(); - - std::string m_serverAddr; - - std::string m_serverPort; - - // in milliseconds. - std::uint32_t m_searchTimeout; - - std::uint32_t m_threadNum; - - std::uint32_t m_socketThreadNum; - -}; - - -} // namespace Socket -} // namespace SPTAG - -#endif // _SPTAG_CLIENT_OPTIONS_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/BKT/Index.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/BKT/Index.h deleted file mode 100644 index fde5b8ec88..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/BKT/Index.h +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_BKT_INDEX_H_ -#define _SPTAG_BKT_INDEX_H_ - -#include "../Common.h" -#include "../VectorIndex.h" - -#include "../Common/CommonUtils.h" -#include "../Common/DistanceUtils.h" -#include "../Common/QueryResultSet.h" -#include "../Common/Dataset.h" -#include "../Common/WorkSpace.h" -#include "../Common/WorkSpacePool.h" -#include "../Common/RelativeNeighborhoodGraph.h" -#include "../Common/BKTree.h" -#include "inc/Helper/SimpleIniReader.h" -#include "inc/Helper/StringConvert.h" - -#include -#include -#include - -namespace SPTAG -{ - - namespace Helper - { - class IniReader; - } - - namespace BKT - { - template - class Index : public VectorIndex - { - private: - // data points - COMMON::Dataset m_pSamples; - - // BKT structures. - COMMON::BKTree m_pTrees; - - // Graph structure - COMMON::RelativeNeighborhoodGraph m_pGraph; - - std::string m_sBKTFilename; - std::string m_sGraphFilename; - std::string m_sDataPointsFilename; - - std::mutex m_dataLock; // protect data and graph - tbb::concurrent_unordered_set m_deletedID; - std::unique_ptr m_workSpacePool; - - int m_iNumberOfThreads; - DistCalcMethod m_iDistCalcMethod; - float(*m_fComputeDistance)(const T* pX, const T* pY, int length); - - int m_iMaxCheck; - int m_iThresholdOfNumberOfContinuousNoBetterPropagation; - int m_iNumberOfInitialDynamicPivots; - int m_iNumberOfOtherDynamicPivots; - public: - Index() - { -#define DefineBKTParameter(VarName, VarType, DefaultValue, RepresentStr) \ - VarName = DefaultValue; \ - -#include "inc/Core/BKT/ParameterDefinitionList.h" -#undef DefineBKTParameter - - m_fComputeDistance = COMMON::DistanceCalcSelector(m_iDistCalcMethod); - } - - ~Index() {} - - inline int GetNumSamples() const { return m_pSamples.R(); } - inline int GetFeatureDim() const { return m_pSamples.C(); } - - inline int GetCurrMaxCheck() const { return m_iMaxCheck; } - inline int GetNumThreads() const { return m_iNumberOfThreads; } - inline DistCalcMethod GetDistCalcMethod() const { return m_iDistCalcMethod; } - inline IndexAlgoType GetIndexAlgoType() const { return IndexAlgoType::BKT; } - inline VectorValueType GetVectorValueType() const { return GetEnumValueType(); } - - inline float ComputeDistance(const void* pX, const void* pY) const { return m_fComputeDistance((const T*)pX, (const T*)pY, m_pSamples.C()); } - inline const void* GetSample(const int idx) const { return (void*)m_pSamples[idx]; } - - ErrorCode BuildIndex(const void* p_data, int p_vectorNum, int p_dimension); - - ErrorCode SaveIndexToMemory(std::vector& p_indexBlobs, std::vector& p_indexBlobsLen); - ErrorCode LoadIndexFromMemory(const std::vector& p_indexBlobs); - - ErrorCode SaveIndex(const std::string& p_folderPath, std::ofstream& p_configout); - ErrorCode LoadIndex(const std::string& p_folderPath, Helper::IniReader& p_reader); - ErrorCode SearchIndex(QueryResult &p_query) const; - ErrorCode AddIndex(const void* p_vectors, int p_vectorNum, int p_dimension); - ErrorCode DeleteIndex(const void* p_vectors, int p_vectorNum); - - ErrorCode SetParameter(const char* p_param, const char* p_value); - std::string GetParameter(const char* p_param) const; - - private: - ErrorCode RefineIndex(const std::string& p_folderPath); - void SearchIndexWithDeleted(COMMON::QueryResultSet &p_query, COMMON::WorkSpace &p_space, const tbb::concurrent_unordered_set &p_deleted) const; - void SearchIndexWithoutDeleted(COMMON::QueryResultSet &p_query, COMMON::WorkSpace &p_space) const; - }; - } // namespace BKT -} // namespace SPTAG - -#endif // _SPTAG_BKT_INDEX_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/BKT/ParameterDefinitionList.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/BKT/ParameterDefinitionList.h deleted file mode 100644 index 7ad17fcbb1..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/BKT/ParameterDefinitionList.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifdef DefineBKTParameter - -// DefineBKTParameter(VarName, VarType, DefaultValue, RepresentStr) -DefineBKTParameter(m_sBKTFilename, std::string, std::string("tree.bin"), "TreeFilePath") -DefineBKTParameter(m_sGraphFilename, std::string, std::string("graph.bin"), "GraphFilePath") -DefineBKTParameter(m_sDataPointsFilename, std::string, std::string("vectors.bin"), "VectorFilePath") - -DefineBKTParameter(m_pTrees.m_iTreeNumber, int, 1L, "BKTNumber") -DefineBKTParameter(m_pTrees.m_iBKTKmeansK, int, 32L, "BKTKmeansK") -DefineBKTParameter(m_pTrees.m_iBKTLeafSize, int, 8L, "BKTLeafSize") -DefineBKTParameter(m_pTrees.m_iSamples, int, 1000L, "Samples") - - -DefineBKTParameter(m_pGraph.m_iTPTNumber, int, 32L, "TpTreeNumber") -DefineBKTParameter(m_pGraph.m_iTPTLeafSize, int, 2000L, "TPTLeafSize") -DefineBKTParameter(m_pGraph.m_numTopDimensionTPTSplit, int, 5L, "NumTopDimensionTpTreeSplit") - -DefineBKTParameter(m_pGraph.m_iNeighborhoodSize, int, 32L, "NeighborhoodSize") -DefineBKTParameter(m_pGraph.m_iNeighborhoodScale, int, 2L, "GraphNeighborhoodScale") -DefineBKTParameter(m_pGraph.m_iCEFScale, int, 2L, "GraphCEFScale") -DefineBKTParameter(m_pGraph.m_iRefineIter, int, 0L, "RefineIterations") -DefineBKTParameter(m_pGraph.m_iCEF, int, 1000L, "CEF") -DefineBKTParameter(m_pGraph.m_iMaxCheckForRefineGraph, int, 10000L, "MaxCheckForRefineGraph") - -DefineBKTParameter(m_iNumberOfThreads, int, 1L, "NumberOfThreads") -DefineBKTParameter(m_iDistCalcMethod, SPTAG::DistCalcMethod, SPTAG::DistCalcMethod::Cosine, "DistCalcMethod") - -DefineBKTParameter(m_iMaxCheck, int, 8192L, "MaxCheck") -DefineBKTParameter(m_iThresholdOfNumberOfContinuousNoBetterPropagation, int, 3L, "ThresholdOfNumberOfContinuousNoBetterPropagation") -DefineBKTParameter(m_iNumberOfInitialDynamicPivots, int, 50L, "NumberOfInitialDynamicPivots") -DefineBKTParameter(m_iNumberOfOtherDynamicPivots, int, 4L, "NumberOfOtherDynamicPivots") - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common.h deleted file mode 100644 index 91c6239b32..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common.h +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_CORE_COMMONDEFS_H_ -#define _SPTAG_CORE_COMMONDEFS_H_ - -#include -#include -#include -#include -#include -#include -#include - -#ifndef _MSC_VER -#include -#include -#define FolderSep '/' -#define mkdir(a) mkdir(a, ACCESSPERMS) -inline bool direxists(const char* path) { - struct stat info; - return stat(path, &info) == 0 && (info.st_mode & S_IFDIR); -} -inline bool fileexists(const char* path) { - struct stat info; - return stat(path, &info) == 0 && (info.st_mode & S_IFDIR) == 0; -} -template -inline T min(T a, T b) { - return a < b ? a : b; -} -template -inline T max(T a, T b) { - return a > b ? a : b; -} - -#ifndef _rotl -#define _rotl(x, n) (((x) << (n)) | ((x) >> (32-(n)))) -#endif - -#else -#define WIN32_LEAN_AND_MEAN -#include -#include -#define FolderSep '\\' -#define mkdir(a) CreateDirectory(a, NULL) -inline bool direxists(const char* path) { - auto dwAttr = GetFileAttributes((LPCSTR)path); - return (dwAttr != INVALID_FILE_ATTRIBUTES) && (dwAttr & FILE_ATTRIBUTE_DIRECTORY); -} -inline bool fileexists(const char* path) { - auto dwAttr = GetFileAttributes((LPCSTR)path); - return (dwAttr != INVALID_FILE_ATTRIBUTES) && (dwAttr & FILE_ATTRIBUTE_DIRECTORY) == 0; -} -#endif - -namespace SPTAG -{ - -typedef std::uint32_t SizeType; - -const float MinDist = (std::numeric_limits::min)(); -const float MaxDist = (std::numeric_limits::max)(); -const float Epsilon = 0.000000001f; - -class MyException : public std::exception -{ -private: - std::string Exp; -public: - MyException(std::string e) { Exp = e; } -#ifdef _MSC_VER - const char* what() const { return Exp.c_str(); } -#else - const char* what() const noexcept { return Exp.c_str(); } -#endif -}; - -// Type of number index. -typedef std::int32_t IndexType; -static_assert(std::is_integral::value, "IndexType must be integral type."); - - -enum class ErrorCode : std::uint16_t -{ -#define DefineErrorCode(Name, Value) Name = Value, -#include "DefinitionList.h" -#undef DefineErrorCode - - Undefined -}; -static_assert(static_cast(ErrorCode::Undefined) != 0, "Empty ErrorCode!"); - - -enum class DistCalcMethod : std::uint8_t -{ -#define DefineDistCalcMethod(Name) Name, -#include "DefinitionList.h" -#undef DefineDistCalcMethod - - Undefined -}; -static_assert(static_cast(DistCalcMethod::Undefined) != 0, "Empty DistCalcMethod!"); - - -enum class VectorValueType : std::uint8_t -{ -#define DefineVectorValueType(Name, Type) Name, -#include "DefinitionList.h" -#undef DefineVectorValueType - - Undefined -}; -static_assert(static_cast(VectorValueType::Undefined) != 0, "Empty VectorValueType!"); - - -enum class IndexAlgoType : std::uint8_t -{ -#define DefineIndexAlgo(Name) Name, -#include "DefinitionList.h" -#undef DefineIndexAlgo - - Undefined -}; -static_assert(static_cast(IndexAlgoType::Undefined) != 0, "Empty IndexAlgoType!"); - - -template -constexpr VectorValueType GetEnumValueType() -{ - return VectorValueType::Undefined; -} - - -#define DefineVectorValueType(Name, Type) \ -template<> \ -constexpr VectorValueType GetEnumValueType() \ -{ \ - return VectorValueType::Name; \ -} \ - -#include "DefinitionList.h" -#undef DefineVectorValueType - - -inline std::size_t GetValueTypeSize(VectorValueType p_valueType) -{ - switch (p_valueType) - { -#define DefineVectorValueType(Name, Type) \ - case VectorValueType::Name: \ - return sizeof(Type); \ - -#include "DefinitionList.h" -#undef DefineVectorValueType - - default: - break; - } - - return 0; -} - -} // namespace SPTAG - -#endif // _SPTAG_CORE_COMMONDEFS_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/BKTree.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/BKTree.h deleted file mode 100644 index 366ca08499..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/BKTree.h +++ /dev/null @@ -1,492 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_COMMON_BKTREE_H_ -#define _SPTAG_COMMON_BKTREE_H_ - -#include -#include -#include -#include - -#include "../VectorIndex.h" - -#include "CommonUtils.h" -#include "QueryResultSet.h" -#include "WorkSpace.h" - -#pragma warning(disable:4996) // 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. - -namespace SPTAG -{ - namespace COMMON - { - // node type for storing BKT - struct BKTNode - { - int centerid; - int childStart; - int childEnd; - - BKTNode(int cid = -1) : centerid(cid), childStart(-1), childEnd(-1) {} - }; - - template - struct KmeansArgs { - int _K; - int _D; - int _T; - T* centers; - int* counts; - float* newCenters; - int* newCounts; - char* label; - int* clusterIdx; - float* clusterDist; - T* newTCenters; - - KmeansArgs(int k, int dim, int datasize, int threadnum) : _K(k), _D(dim), _T(threadnum) { - centers = new T[k * dim]; - counts = new int[k]; - newCenters = new float[threadnum * k * dim]; - newCounts = new int[threadnum * k]; - label = new char[datasize]; - clusterIdx = new int[threadnum * k]; - clusterDist = new float[threadnum * k]; - newTCenters = new T[k * dim]; - } - - ~KmeansArgs() { - delete[] centers; - delete[] counts; - delete[] newCenters; - delete[] newCounts; - delete[] label; - delete[] clusterIdx; - delete[] clusterDist; - delete[] newTCenters; - } - - inline void ClearCounts() { - memset(newCounts, 0, sizeof(int) * _T * _K); - } - - inline void ClearCenters() { - memset(newCenters, 0, sizeof(float) * _T * _K * _D); - } - - inline void ClearDists(float dist) { - for (int i = 0; i < _T * _K; i++) { - clusterIdx[i] = -1; - clusterDist[i] = dist; - } - } - - void Shuffle(std::vector& indices, int first, int last) { - int* pos = new int[_K]; - pos[0] = first; - for (int k = 1; k < _K; k++) pos[k] = pos[k - 1] + newCounts[k - 1]; - - for (int k = 0; k < _K; k++) { - if (newCounts[k] == 0) continue; - int i = pos[k]; - while (newCounts[k] > 0) { - int swapid = pos[(int)(label[i])] + newCounts[(int)(label[i])] - 1; - newCounts[(int)(label[i])]--; - std::swap(indices[i], indices[swapid]); - std::swap(label[i], label[swapid]); - } - while (indices[i] != clusterIdx[k]) i++; - std::swap(indices[i], indices[pos[k] + counts[k] - 1]); - } - delete[] pos; - } - }; - - class BKTree - { - public: - BKTree(): m_iTreeNumber(1), m_iBKTKmeansK(32), m_iBKTLeafSize(8), m_iSamples(1000) {} - - BKTree(BKTree& other): m_iTreeNumber(other.m_iTreeNumber), - m_iBKTKmeansK(other.m_iBKTKmeansK), - m_iBKTLeafSize(other.m_iBKTLeafSize), - m_iSamples(other.m_iSamples) {} - ~BKTree() {} - - inline const BKTNode& operator[](int index) const { return m_pTreeRoots[index]; } - inline BKTNode& operator[](int index) { return m_pTreeRoots[index]; } - - inline int size() const { return (int)m_pTreeRoots.size(); } - - inline const std::unordered_map& GetSampleMap() const { return m_pSampleCenterMap; } - - template - void BuildTrees(VectorIndex* index, std::vector* indices = nullptr) - { - struct BKTStackItem { - int index, first, last; - BKTStackItem(int index_, int first_, int last_) : index(index_), first(first_), last(last_) {} - }; - std::stack ss; - - std::vector localindices; - if (indices == nullptr) { - localindices.resize(index->GetNumSamples()); - for (int i = 0; i < index->GetNumSamples(); i++) localindices[i] = i; - } - else { - localindices.assign(indices->begin(), indices->end()); - } - KmeansArgs args(m_iBKTKmeansK, index->GetFeatureDim(), (int)localindices.size(), omp_get_num_threads()); - - m_pSampleCenterMap.clear(); - for (char i = 0; i < m_iTreeNumber; i++) - { - std::random_shuffle(localindices.begin(), localindices.end()); - - m_pTreeStart.push_back((int)m_pTreeRoots.size()); - m_pTreeRoots.push_back(BKTNode((int)localindices.size())); - std::cout << "Start to build BKTree " << i + 1 << std::endl; - - ss.push(BKTStackItem(m_pTreeStart[i], 0, (int)localindices.size())); - while (!ss.empty()) { - BKTStackItem item = ss.top(); ss.pop(); - int newBKTid = (int)m_pTreeRoots.size(); - m_pTreeRoots[item.index].childStart = newBKTid; - if (item.last - item.first <= m_iBKTLeafSize) { - for (int j = item.first; j < item.last; j++) { - m_pTreeRoots.push_back(BKTNode(localindices[j])); - } - } - else { // clustering the data into BKTKmeansK clusters - int numClusters = KmeansClustering(index, localindices, item.first, item.last, args); - if (numClusters <= 1) { - int end = min(item.last + 1, (int)localindices.size()); - std::sort(localindices.begin() + item.first, localindices.begin() + end); - m_pTreeRoots[item.index].centerid = localindices[item.first]; - m_pTreeRoots[item.index].childStart = -m_pTreeRoots[item.index].childStart; - for (int j = item.first + 1; j < end; j++) { - m_pTreeRoots.push_back(BKTNode(localindices[j])); - m_pSampleCenterMap[localindices[j]] = m_pTreeRoots[item.index].centerid; - } - m_pSampleCenterMap[-1 - m_pTreeRoots[item.index].centerid] = item.index; - } - else { - for (int k = 0; k < m_iBKTKmeansK; k++) { - if (args.counts[k] == 0) continue; - m_pTreeRoots.push_back(BKTNode(localindices[item.first + args.counts[k] - 1])); - if (args.counts[k] > 1) ss.push(BKTStackItem(newBKTid++, item.first, item.first + args.counts[k] - 1)); - item.first += args.counts[k]; - } - } - } - m_pTreeRoots[item.index].childEnd = (int)m_pTreeRoots.size(); - } - std::cout << i + 1 << " BKTree built, " << m_pTreeRoots.size() - m_pTreeStart[i] << " " << localindices.size() << std::endl; - } - } - - bool SaveTrees(void **pKDTMemFile, int64_t &len) const - { - int treeNodeSize = (int)m_pTreeRoots.size(); - - size_t size = sizeof(int) + - sizeof(int) * m_iTreeNumber + - sizeof(int) + - sizeof(BKTNode) * treeNodeSize; - char *mem = (char*)malloc(size); - if (mem == NULL) return false; - - auto ptr = mem; - *(int*)ptr = m_iTreeNumber; - ptr += sizeof(int); - - memcpy(ptr, m_pTreeStart.data(), sizeof(int) * m_iTreeNumber); - ptr += sizeof(int) * m_iTreeNumber; - - *(int*)ptr = treeNodeSize; - ptr += sizeof(int); - - memcpy(ptr, m_pTreeRoots.data(), sizeof(BKTNode) * treeNodeSize); - *pKDTMemFile = mem; - len = size; - - return true; - } - - bool SaveTrees(std::string sTreeFileName) const - { - std::cout << "Save BKT to " << sTreeFileName << std::endl; - FILE *fp = fopen(sTreeFileName.c_str(), "wb"); - if (fp == NULL) return false; - - fwrite(&m_iTreeNumber, sizeof(int), 1, fp); - fwrite(m_pTreeStart.data(), sizeof(int), m_iTreeNumber, fp); - int treeNodeSize = (int)m_pTreeRoots.size(); - fwrite(&treeNodeSize, sizeof(int), 1, fp); - fwrite(m_pTreeRoots.data(), sizeof(BKTNode), treeNodeSize, fp); - fclose(fp); - std::cout << "Save BKT (" << m_iTreeNumber << "," << treeNodeSize << ") Finish!" << std::endl; - return true; - } - - bool LoadTrees(char* pBKTMemFile) - { - m_iTreeNumber = *((int*)pBKTMemFile); - pBKTMemFile += sizeof(int); - m_pTreeStart.resize(m_iTreeNumber); - memcpy(m_pTreeStart.data(), pBKTMemFile, sizeof(int) * m_iTreeNumber); - pBKTMemFile += sizeof(int)*m_iTreeNumber; - - int treeNodeSize = *((int*)pBKTMemFile); - pBKTMemFile += sizeof(int); - m_pTreeRoots.resize(treeNodeSize); - memcpy(m_pTreeRoots.data(), pBKTMemFile, sizeof(BKTNode) * treeNodeSize); - return true; - } - - bool LoadTrees(std::string sTreeFileName) - { - std::cout << "Load BKT From " << sTreeFileName << std::endl; - FILE *fp = fopen(sTreeFileName.c_str(), "rb"); - if (fp == NULL) return false; - - fread(&m_iTreeNumber, sizeof(int), 1, fp); - m_pTreeStart.resize(m_iTreeNumber); - fread(m_pTreeStart.data(), sizeof(int), m_iTreeNumber, fp); - - int treeNodeSize; - fread(&treeNodeSize, sizeof(int), 1, fp); - m_pTreeRoots.resize(treeNodeSize); - fread(m_pTreeRoots.data(), sizeof(BKTNode), treeNodeSize, fp); - fclose(fp); - std::cout << "Load BKT (" << m_iTreeNumber << "," << treeNodeSize << ") Finish!" << std::endl; - return true; - } - - template - void InitSearchTrees(const VectorIndex* p_index, const COMMON::QueryResultSet &p_query, COMMON::WorkSpace &p_space) const - { - for (char i = 0; i < m_iTreeNumber; i++) { - const BKTNode& node = m_pTreeRoots[m_pTreeStart[i]]; - if (node.childStart < 0) { - p_space.m_SPTQueue.insert(COMMON::HeapCell(m_pTreeStart[i], p_index->ComputeDistance((const void*)p_query.GetTarget(), p_index->GetSample(node.centerid)))); - } - else { - for (int begin = node.childStart; begin < node.childEnd; begin++) { - int index = m_pTreeRoots[begin].centerid; - p_space.m_SPTQueue.insert(COMMON::HeapCell(begin, p_index->ComputeDistance((const void*)p_query.GetTarget(), p_index->GetSample(index)))); - } - } - } - } - - template - void SearchTrees(const VectorIndex* p_index, const COMMON::QueryResultSet &p_query, - COMMON::WorkSpace &p_space, const int p_limits) const - { - do - { - COMMON::HeapCell bcell = p_space.m_SPTQueue.pop(); - const BKTNode& tnode = m_pTreeRoots[bcell.node]; - if (tnode.childStart < 0) { - if (!p_space.CheckAndSet(tnode.centerid)) { - p_space.m_iNumberOfCheckedLeaves++; - p_space.m_NGQueue.insert(COMMON::HeapCell(tnode.centerid, bcell.distance)); - } - if (p_space.m_iNumberOfCheckedLeaves >= p_limits) break; - } - else { - if (!p_space.CheckAndSet(tnode.centerid)) { - p_space.m_NGQueue.insert(COMMON::HeapCell(tnode.centerid, bcell.distance)); - } - for (int begin = tnode.childStart; begin < tnode.childEnd; begin++) { - int index = m_pTreeRoots[begin].centerid; - p_space.m_SPTQueue.insert(COMMON::HeapCell(begin, p_index->ComputeDistance((const void*)p_query.GetTarget(), p_index->GetSample(index)))); - } - } - } while (!p_space.m_SPTQueue.empty()); - } - - private: - - template - float KmeansAssign(VectorIndex* p_index, - std::vector& indices, - const int first, const int last, KmeansArgs& args, const bool updateCenters) const { - float currDist = 0; - int threads = omp_get_num_threads(); - float lambda = (updateCenters) ? COMMON::Utils::GetBase() * COMMON::Utils::GetBase() / (100.0f * (last - first)) : 0.0f; - int subsize = (last - first - 1) / threads + 1; - -#pragma omp parallel for - for (int tid = 0; tid < threads; tid++) - { - int istart = first + tid * subsize; - int iend = min(first + (tid + 1) * subsize, last); - int *inewCounts = args.newCounts + tid * m_iBKTKmeansK; - float *inewCenters = args.newCenters + tid * m_iBKTKmeansK * p_index->GetFeatureDim(); - int * iclusterIdx = args.clusterIdx + tid * m_iBKTKmeansK; - float * iclusterDist = args.clusterDist + tid * m_iBKTKmeansK; - float idist = 0; - for (int i = istart; i < iend; i++) { - int clusterid = 0; - float smallestDist = MaxDist; - for (int k = 0; k < m_iBKTKmeansK; k++) { - float dist = p_index->ComputeDistance(p_index->GetSample(indices[i]), (const void*)(args.centers + k*p_index->GetFeatureDim())) + lambda*args.counts[k]; - if (dist > -MaxDist && dist < smallestDist) { - clusterid = k; smallestDist = dist; - } - } - args.label[i] = clusterid; - inewCounts[clusterid]++; - idist += smallestDist; - if (updateCenters) { - const T* v = (const T*)p_index->GetSample(indices[i]); - float* center = inewCenters + clusterid*p_index->GetFeatureDim(); - for (int j = 0; j < p_index->GetFeatureDim(); j++) center[j] += v[j]; - if (smallestDist > iclusterDist[clusterid]) { - iclusterDist[clusterid] = smallestDist; - iclusterIdx[clusterid] = indices[i]; - } - } - else { - if (smallestDist <= iclusterDist[clusterid]) { - iclusterDist[clusterid] = smallestDist; - iclusterIdx[clusterid] = indices[i]; - } - } - } - COMMON::Utils::atomic_float_add(&currDist, idist); - } - - for (int i = 1; i < threads; i++) { - for (int k = 0; k < m_iBKTKmeansK; k++) - args.newCounts[k] += args.newCounts[i*m_iBKTKmeansK + k]; - } - - if (updateCenters) { - for (int i = 1; i < threads; i++) { - float* currCenter = args.newCenters + i*m_iBKTKmeansK*p_index->GetFeatureDim(); - for (int j = 0; j < m_iBKTKmeansK * p_index->GetFeatureDim(); j++) args.newCenters[j] += currCenter[j]; - } - - int maxcluster = 0; - for (int k = 1; k < m_iBKTKmeansK; k++) if (args.newCounts[maxcluster] < args.newCounts[k]) maxcluster = k; - - int maxid = maxcluster; - for (int tid = 1; tid < threads; tid++) { - if (args.clusterDist[maxid] < args.clusterDist[tid * m_iBKTKmeansK + maxcluster]) maxid = tid * m_iBKTKmeansK + maxcluster; - } - if (args.clusterIdx[maxid] < 0 || args.clusterIdx[maxid] >= p_index->GetNumSamples()) - std::cout << "first:" << first << " last:" << last << " maxcluster:" << maxcluster << "(" << args.newCounts[maxcluster] << ") Error maxid:" << maxid << " dist:" << args.clusterDist[maxid] << std::endl; - maxid = args.clusterIdx[maxid]; - - for (int k = 0; k < m_iBKTKmeansK; k++) { - T* TCenter = args.newTCenters + k * p_index->GetFeatureDim(); - if (args.newCounts[k] == 0) { - //int nextid = Utils::rand_int(last, first); - //while (args.label[nextid] != maxcluster) nextid = Utils::rand_int(last, first); - int nextid = maxid; - std::memcpy(TCenter, p_index->GetSample(nextid), sizeof(T)*p_index->GetFeatureDim()); - } - else { - float* currCenters = args.newCenters + k * p_index->GetFeatureDim(); - for (int j = 0; j < p_index->GetFeatureDim(); j++) currCenters[j] /= args.newCounts[k]; - - if (p_index->GetDistCalcMethod() == DistCalcMethod::Cosine) { - COMMON::Utils::Normalize(currCenters, p_index->GetFeatureDim(), COMMON::Utils::GetBase()); - } - for (int j = 0; j < p_index->GetFeatureDim(); j++) TCenter[j] = (T)(currCenters[j]); - } - } - } - else { - for (int i = 1; i < threads; i++) { - for (int k = 0; k < m_iBKTKmeansK; k++) { - if (args.clusterIdx[i*m_iBKTKmeansK + k] != -1 && args.clusterDist[i*m_iBKTKmeansK + k] <= args.clusterDist[k]) { - args.clusterDist[k] = args.clusterDist[i*m_iBKTKmeansK + k]; - args.clusterIdx[k] = args.clusterIdx[i*m_iBKTKmeansK + k]; - } - } - } - } - return currDist; - } - - template - int KmeansClustering(VectorIndex* p_index, - std::vector& indices, const int first, const int last, KmeansArgs& args) const { - int iterLimit = 100; - - int batchEnd = min(first + m_iSamples, last); - float currDiff, currDist, minClusterDist = MaxDist; - for (int numKmeans = 0; numKmeans < 3; numKmeans++) { - for (int k = 0; k < m_iBKTKmeansK; k++) { - int randid = COMMON::Utils::rand_int(last, first); - std::memcpy(args.centers + k*p_index->GetFeatureDim(), p_index->GetSample(indices[randid]), sizeof(T)*p_index->GetFeatureDim()); - } - args.ClearCounts(); - currDist = KmeansAssign(p_index, indices, first, batchEnd, args, false); - if (currDist < minClusterDist) { - minClusterDist = currDist; - memcpy(args.newTCenters, args.centers, sizeof(T)*m_iBKTKmeansK*p_index->GetFeatureDim()); - memcpy(args.counts, args.newCounts, sizeof(int) * m_iBKTKmeansK); - } - } - - minClusterDist = MaxDist; - int noImprovement = 0; - for (int iter = 0; iter < iterLimit; iter++) { - std::memcpy(args.centers, args.newTCenters, sizeof(T)*m_iBKTKmeansK*p_index->GetFeatureDim()); - std::random_shuffle(indices.begin() + first, indices.begin() + last); - - args.ClearCenters(); - args.ClearCounts(); - args.ClearDists(-MaxDist); - currDist = KmeansAssign(p_index, indices, first, batchEnd, args, true); - memcpy(args.counts, args.newCounts, sizeof(int)*m_iBKTKmeansK); - - currDiff = 0; - for (int k = 0; k < m_iBKTKmeansK; k++) { - currDiff += p_index->ComputeDistance((const void*)(args.centers + k*p_index->GetFeatureDim()), (const void*)(args.newTCenters + k*p_index->GetFeatureDim())); - } - - if (currDist < minClusterDist) { - noImprovement = 0; - minClusterDist = currDist; - } - else { - noImprovement++; - } - if (currDiff < 1e-3 || noImprovement >= 5) break; - } - - args.ClearCounts(); - args.ClearDists(MaxDist); - currDist = KmeansAssign(p_index, indices, first, last, args, false); - memcpy(args.counts, args.newCounts, sizeof(int)*m_iBKTKmeansK); - - int numClusters = 0; - for (int i = 0; i < m_iBKTKmeansK; i++) if (args.counts[i] > 0) numClusters++; - - if (numClusters <= 1) { - //if (last - first > 1) std::cout << "large cluster:" << last - first << " dist:" << currDist << std::endl; - return numClusters; - } - args.Shuffle(indices, first, last); - return numClusters; - } - - private: - std::vector m_pTreeStart; - std::vector m_pTreeRoots; - std::unordered_map m_pSampleCenterMap; - - public: - int m_iTreeNumber, m_iBKTKmeansK, m_iBKTLeafSize, m_iSamples; - }; - } -} -#endif diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/CommonUtils.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/CommonUtils.h deleted file mode 100644 index ca5ed83fca..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/CommonUtils.h +++ /dev/null @@ -1,178 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_COMMON_COMMONUTILS_H_ -#define _SPTAG_COMMON_COMMONUTILS_H_ - -#include "../Common.h" - -#include - -#include -#include -#include -#include - -#include -#include -#include - -#define PREFETCH - -#ifndef _MSC_VER -#include -#include -#include -#include - -#define InterlockedCompareExchange(a,b,c) __sync_val_compare_and_swap(a, c, b) -#define Sleep(a) usleep(a * 1000) -#define strtok_s(a, b, c) strtok_r(a, b, c) -#endif - -namespace SPTAG -{ - namespace COMMON - { - class Utils { - public: - static int rand_int(int high = RAND_MAX, int low = 0) // Generates a random int value. - { - return low + (int)(float(high - low)*(std::rand() / (RAND_MAX + 1.0))); - } - - static inline float atomic_float_add(volatile float* ptr, const float operand) - { - union { - volatile long iOld; - float fOld; - }; - union { - long iNew; - float fNew; - }; - - while (true) { - iOld = *(volatile long *)ptr; - fNew = fOld + operand; - if (InterlockedCompareExchange((long *)ptr, iNew, iOld) == iOld) { - return fNew; - } - } - } - - static double GetVector(char* cstr, const char* sep, std::vector& arr, int& NumDim) { - char* current; - char* context = NULL; - - int i = 0; - double sum = 0; - arr.clear(); - current = strtok_s(cstr, sep, &context); - while (current != NULL && (i < NumDim || NumDim < 0)) { - try { - float val = (float)atof(current); - arr.push_back(val); - } - catch (std::exception e) { - std::cout << "Exception:" << e.what() << std::endl; - return -2; - } - - sum += arr[i] * arr[i]; - current = strtok_s(NULL, sep, &context); - i++; - } - - if (NumDim < 0) NumDim = i; - if (i < NumDim) return -2; - return std::sqrt(sum); - } - - template - static void Normalize(T* arr, int col, int base) { - double vecLen = 0; - for (int j = 0; j < col; j++) { - double val = arr[j]; - vecLen += val * val; - } - vecLen = std::sqrt(vecLen); - if (vecLen < 1e-6) { - T val = (T)(1.0 / std::sqrt((double)col) * base); - for (int j = 0; j < col; j++) arr[j] = val; - } - else { - for (int j = 0; j < col; j++) arr[j] = (T)(arr[j] / vecLen * base); - } - } - - static size_t ProcessLine(std::string& currentLine, std::vector& arr, int& D, int base, DistCalcMethod distCalcMethod) { - size_t index; - double vecLen; - if (currentLine.length() == 0 || (index = currentLine.find_last_of("\t")) == std::string::npos || (vecLen = GetVector(const_cast(currentLine.c_str() + index + 1), "|", arr, D)) < -1) { - std::cout << "Parse vector error: " + currentLine << std::endl; - //throw MyException("Error in parsing data " + currentLine); - return -1; - } - if (distCalcMethod == DistCalcMethod::Cosine) { - Normalize(arr.data(), D, base); - } - return index; - } - - template - static void PrepareQuerys(std::ifstream& inStream, std::vector& qString, std::vector>& Query, int& NumQuery, int& NumDim, DistCalcMethod distCalcMethod, int base) { - std::string currentLine; - std::vector arr; - int i = 0; - size_t index; - while ((NumQuery < 0 || i < NumQuery) && !inStream.eof()) { - std::getline(inStream, currentLine); - if (currentLine.length() <= 1 || (index = ProcessLine(currentLine, arr, NumDim, base, distCalcMethod)) < 0) { - continue; - } - qString.push_back(currentLine.substr(0, index)); - if (Query.size() < i + 1) Query.push_back(std::vector(NumDim, 0)); - - for (int j = 0; j < NumDim; j++) Query[i][j] = (T)arr[j]; - i++; - } - NumQuery = i; - std::cout << "Load data: (" << NumQuery << ", " << NumDim << ")" << std::endl; - } - - template - static inline int GetBase() { - if (GetEnumValueType() != VectorValueType::Float) { - return (int)(std::numeric_limits::max)(); - } - return 1; - } - - static inline void AddNeighbor(int idx, float dist, int *neighbors, float *dists, int size) - { - size--; - if (dist < dists[size] || (dist == dists[size] && idx < neighbors[size])) - { - int nb; - for (nb = 0; nb <= size && neighbors[nb] != idx; nb++); - - if (nb > size) - { - nb = size; - while (nb > 0 && (dist < dists[nb - 1] || (dist == dists[nb - 1] && idx < neighbors[nb - 1]))) - { - dists[nb] = dists[nb - 1]; - neighbors[nb] = neighbors[nb - 1]; - nb--; - } - dists[nb] = dist; - neighbors[nb] = idx; - } - } - } - }; - } -} - -#endif // _SPTAG_COMMON_COMMONUTILS_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/DataUtils.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/DataUtils.h deleted file mode 100644 index affc4687da..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/DataUtils.h +++ /dev/null @@ -1,290 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_COMMON_DATAUTILS_H_ -#define _SPTAG_COMMON_DATAUTILS_H_ - -#include -#include -#include "CommonUtils.h" -#include "../../Helper/CommonHelper.h" - -namespace SPTAG -{ - namespace COMMON - { - const int bufsize = 1024 * 1024 * 1024; - - class DataUtils { - public: - template - static void ProcessTSVData(int id, int threadbase, std::uint64_t blocksize, - std::string filename, std::string outfile, std::string outmetafile, std::string outmetaindexfile, - std::atomic_int& numSamples, int& D, DistCalcMethod distCalcMethod) { - std::ifstream inputStream(filename); - if (!inputStream.is_open()) { - std::cerr << "unable to open file " + filename << std::endl; - throw MyException("unable to open file " + filename); - exit(1); - } - std::ofstream outputStream, metaStream_out, metaStream_index; - outputStream.open(outfile + std::to_string(id + threadbase), std::ofstream::binary); - metaStream_out.open(outmetafile + std::to_string(id + threadbase), std::ofstream::binary); - metaStream_index.open(outmetaindexfile + std::to_string(id + threadbase), std::ofstream::binary); - if (!outputStream.is_open() || !metaStream_out.is_open() || !metaStream_index.is_open()) { - std::cerr << "unable to open output file " << outfile << " " << outmetafile << " " << outmetaindexfile << std::endl; - throw MyException("unable to open output files"); - exit(1); - } - - std::vector arr; - std::vector sample; - - int base = 1; - if (distCalcMethod == DistCalcMethod::Cosine) { - base = Utils::GetBase(); - } - std::uint64_t writepos = 0; - int sampleSize = 0; - std::uint64_t totalread = 0; - std::streamoff startpos = id * blocksize; - -#ifndef _MSC_VER - int enter_size = 1; -#else - int enter_size = 1; -#endif - std::string currentLine; - size_t index; - inputStream.seekg(startpos, std::ifstream::beg); - if (id != 0) { - std::getline(inputStream, currentLine); - totalread += currentLine.length() + enter_size; - } - std::cout << "Begin thread " << id << " begin at:" << (startpos + totalread) << std::endl; - while (!inputStream.eof() && totalread <= blocksize) { - std::getline(inputStream, currentLine); - if (currentLine.length() <= enter_size || (index = Utils::ProcessLine(currentLine, arr, D, base, distCalcMethod)) < 0) { - totalread += currentLine.length() + enter_size; - continue; - } - sample.resize(D); - for (int j = 0; j < D; j++) sample[j] = (T)arr[j]; - - outputStream.write((char *)(sample.data()), sizeof(T)*D); - metaStream_index.write((char *)&writepos, sizeof(std::uint64_t)); - metaStream_out.write(currentLine.c_str(), index); - - writepos += index; - sampleSize += 1; - totalread += currentLine.length() + enter_size; - } - metaStream_index.write((char *)&writepos, sizeof(std::uint64_t)); - metaStream_index.write((char *)&sampleSize, sizeof(int)); - inputStream.close(); - outputStream.close(); - metaStream_out.close(); - metaStream_index.close(); - - numSamples.fetch_add(sampleSize); - - std::cout << "Finish Thread[" << id << ", " << sampleSize << "] at:" << (startpos + totalread) << std::endl; - } - - static void MergeData(int threadbase, std::string outfile, std::string outmetafile, std::string outmetaindexfile, - std::atomic_int& numSamples, int D) { - std::ifstream inputStream; - std::ofstream outputStream; - char * buf = new char[bufsize]; - std::uint64_t * offsets; - int partSamples; - int metaSamples = 0; - std::uint64_t lastoff = 0; - - outputStream.open(outfile, std::ofstream::binary); - outputStream.write((char *)&numSamples, sizeof(int)); - outputStream.write((char *)&D, sizeof(int)); - for (int i = 0; i < threadbase; i++) { - std::string file = outfile + std::to_string(i); - inputStream.open(file, std::ifstream::binary); - while (!inputStream.eof()) { - inputStream.read(buf, bufsize); - outputStream.write(buf, inputStream.gcount()); - } - inputStream.close(); - remove(file.c_str()); - } - outputStream.close(); - - outputStream.open(outmetafile, std::ofstream::binary); - for (int i = 0; i < threadbase; i++) { - std::string file = outmetafile + std::to_string(i); - inputStream.open(file, std::ifstream::binary); - while (!inputStream.eof()) { - inputStream.read(buf, bufsize); - outputStream.write(buf, inputStream.gcount()); - } - inputStream.close(); - remove(file.c_str()); - } - outputStream.close(); - delete[] buf; - - outputStream.open(outmetaindexfile, std::ofstream::binary); - outputStream.write((char *)&numSamples, sizeof(int)); - for (int i = 0; i < threadbase; i++) { - std::string file = outmetaindexfile + std::to_string(i); - inputStream.open(file, std::ifstream::binary); - - inputStream.seekg(-((long long)sizeof(int)), inputStream.end); - inputStream.read((char *)&partSamples, sizeof(int)); - offsets = new std::uint64_t[partSamples + 1]; - - inputStream.seekg(0, inputStream.beg); - inputStream.read((char *)offsets, sizeof(std::uint64_t)*(partSamples + 1)); - inputStream.close(); - remove(file.c_str()); - - for (int j = 0; j < partSamples + 1; j++) - offsets[j] += lastoff; - outputStream.write((char *)offsets, sizeof(std::uint64_t)*partSamples); - - lastoff = offsets[partSamples]; - metaSamples += partSamples; - delete[] offsets; - } - outputStream.write((char *)&lastoff, sizeof(std::uint64_t)); - outputStream.close(); - - std::cout << "numSamples:" << numSamples << " metaSamples:" << metaSamples << " D:" << D << std::endl; - } - - static bool MergeIndex(const std::string& p_vectorfile1, const std::string& p_metafile1, const std::string& p_metaindexfile1, - const std::string& p_vectorfile2, const std::string& p_metafile2, const std::string& p_metaindexfile2) { - std::ifstream inputStream1, inputStream2; - std::ofstream outputStream; - char * buf = new char[bufsize]; - int R1, R2, C1, C2; - -#define MergeVector(inputStream, vectorFile, R, C) \ - inputStream.open(vectorFile, std::ifstream::binary); \ - if (!inputStream.is_open()) { \ - std::cout << "Cannot open vector file: " << vectorFile <<"!" << std::endl; \ - return false; \ - } \ - inputStream.read((char *)&(R), sizeof(int)); \ - inputStream.read((char *)&(C), sizeof(int)); \ - - MergeVector(inputStream1, p_vectorfile1, R1, C1) - MergeVector(inputStream2, p_vectorfile2, R2, C2) -#undef MergeVector - if (C1 != C2) { - inputStream1.close(); inputStream2.close(); - std::cout << "Vector dimensions are not the same!" << std::endl; - return false; - } - R1 += R2; - outputStream.open(p_vectorfile1 + "_tmp", std::ofstream::binary); - outputStream.write((char *)&R1, sizeof(int)); - outputStream.write((char *)&C1, sizeof(int)); - while (!inputStream1.eof()) { - inputStream1.read(buf, bufsize); - outputStream.write(buf, inputStream1.gcount()); - } - while (!inputStream2.eof()) { - inputStream2.read(buf, bufsize); - outputStream.write(buf, inputStream2.gcount()); - } - inputStream1.close(); inputStream2.close(); - outputStream.close(); - - if (p_metafile1 != "" && p_metafile2 != "") { - outputStream.open(p_metafile1 + "_tmp", std::ofstream::binary); -#define MergeMeta(inputStream, metaFile) \ - inputStream.open(metaFile, std::ifstream::binary); \ - if (!inputStream.is_open()) { \ - std::cout << "Cannot open meta file: " << metaFile << "!" << std::endl; \ - return false; \ - } \ - while (!inputStream.eof()) { \ - inputStream.read(buf, bufsize); \ - outputStream.write(buf, inputStream.gcount()); \ - } \ - inputStream.close(); \ - - MergeMeta(inputStream1, p_metafile1) - MergeMeta(inputStream2, p_metafile2) -#undef MergeMeta - outputStream.close(); - delete[] buf; - - - std::uint64_t * offsets; - int partSamples; - std::uint64_t lastoff = 0; - outputStream.open(p_metaindexfile1 + "_tmp", std::ofstream::binary); - outputStream.write((char *)&R1, sizeof(int)); -#define MergeMetaIndex(inputStream, metaIndexFile) \ - inputStream.open(metaIndexFile, std::ifstream::binary); \ - if (!inputStream.is_open()) { \ - std::cout << "Cannot open meta index file: " << metaIndexFile << "!" << std::endl; \ - return false; \ - } \ - inputStream.read((char *)&partSamples, sizeof(int)); \ - offsets = new std::uint64_t[partSamples + 1]; \ - inputStream.read((char *)offsets, sizeof(std::uint64_t)*(partSamples + 1)); \ - inputStream.close(); \ - for (int j = 0; j < partSamples + 1; j++) offsets[j] += lastoff; \ - outputStream.write((char *)offsets, sizeof(std::uint64_t)*partSamples); \ - lastoff = offsets[partSamples]; \ - delete[] offsets; \ - - MergeMetaIndex(inputStream1, p_metaindexfile1) - MergeMetaIndex(inputStream2, p_metaindexfile2) -#undef MergeMetaIndex - outputStream.write((char *)&lastoff, sizeof(std::uint64_t)); - outputStream.close(); - - rename((p_metafile1 + "_tmp").c_str(), p_metafile1.c_str()); - rename((p_metaindexfile1 + "_tmp").c_str(), p_metaindexfile1.c_str()); - } - rename((p_vectorfile1 + "_tmp").c_str(), p_vectorfile1.c_str()); - - std::cout << "Merged -> numSamples:" << R1 << " D:" << C1 << std::endl; - return true; - } - - template - static void ParseData(std::string filenames, std::string outfile, std::string outmetafile, std::string outmetaindexfile, - int threadnum, DistCalcMethod distCalcMethod) { - omp_set_num_threads(threadnum); - - std::atomic_int numSamples = { 0 }; - int D = -1; - - int threadbase = 0; - std::vector inputFileNames = Helper::StrUtils::SplitString(filenames, ","); - for (std::string inputFileName : inputFileNames) - { -#ifndef _MSC_VER - struct stat stat_buf; - stat(inputFileName.c_str(), &stat_buf); -#else - struct _stat64 stat_buf; - int res = _stat64(inputFileName.c_str(), &stat_buf); -#endif - std::uint64_t blocksize = (stat_buf.st_size + threadnum - 1) / threadnum; - -#pragma omp parallel for - for (int i = 0; i < threadnum; i++) { - ProcessTSVData(i, threadbase, blocksize, inputFileName, outfile, outmetafile, outmetaindexfile, numSamples, D, distCalcMethod); - } - threadbase += threadnum; - } - MergeData(threadbase, outfile, outmetafile, outmetaindexfile, numSamples, D); - } - }; - } -} - -#endif // _SPTAG_COMMON_DATAUTILS_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/Dataset.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/Dataset.h deleted file mode 100644 index b47d521d81..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/Dataset.h +++ /dev/null @@ -1,216 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_COMMON_DATASET_H_ -#define _SPTAG_COMMON_DATASET_H_ - -#include - -#if defined(_MSC_VER) || defined(__INTEL_COMPILER) -#include -#else -#include -#endif // defined(__GNUC__) - -#define ALIGN 32 - -#define aligned_malloc(a, b) _mm_malloc(a, b) -#define aligned_free(a) _mm_free(a) - -#pragma warning(disable:4996) // 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. - -namespace SPTAG -{ - namespace COMMON - { - // structure to save Data and Graph - template - class Dataset - { - private: - int rows; - int cols; - bool ownData = false; - T* data = nullptr; - std::vector dataIncremental; - - public: - Dataset(): rows(0), cols(1) {} - Dataset(int rows_, int cols_, T* data_ = nullptr, bool transferOnwership_ = true) - { - Initialize(rows_, cols_, data_, transferOnwership_); - } - ~Dataset() - { - if (ownData) aligned_free(data); - } - void Initialize(int rows_, int cols_, T* data_ = nullptr, bool transferOnwership_ = true) - { - rows = rows_; - cols = cols_; - data = data_; - if (data_ == nullptr || !transferOnwership_) - { - ownData = true; - data = (T*)aligned_malloc(sizeof(T) * rows * cols, ALIGN); - if (data_ != nullptr) memcpy(data, data_, rows * cols * sizeof(T)); - else std::memset(data, -1, rows * cols * sizeof(T)); - } - } - void SetR(int R_) - { - if (R_ >= rows) - dataIncremental.resize((R_ - rows) * cols); - else - { - rows = R_; - dataIncremental.clear(); - } - } - inline int R() const { return (int)(rows + dataIncremental.size() / cols); } - inline int C() const { return cols; } - T* operator[](int index) - { - if (index >= rows) { - return dataIncremental.data() + (size_t)(index - rows)*cols; - } - return data + (size_t)index*cols; - } - - const T* operator[](int index) const - { - if (index >= rows) { - return dataIncremental.data() + (size_t)(index - rows)*cols; - } - return data + (size_t)index*cols; - } - - void AddBatch(const T* pData, int num) - { - dataIncremental.insert(dataIncremental.end(), pData, pData + num*cols); - } - - void AddBatch(int num) - { - dataIncremental.insert(dataIncremental.end(), (size_t)num*cols, T(-1)); - } - - bool Save(std::string sDataPointsFileName) - { - std::cout << "Save Data To " << sDataPointsFileName << std::endl; - FILE * fp = fopen(sDataPointsFileName.c_str(), "wb"); - if (fp == NULL) return false; - - int CR = R(); - fwrite(&CR, sizeof(int), 1, fp); - fwrite(&cols, sizeof(int), 1, fp); - - T* ptr = data; - int toWrite = rows; - while (toWrite > 0) - { - size_t write = fwrite(ptr, sizeof(T) * cols, toWrite, fp); - ptr += write * cols; - toWrite -= (int)write; - } - ptr = dataIncremental.data(); - toWrite = CR - rows; - while (toWrite > 0) - { - size_t write = fwrite(ptr, sizeof(T) * cols, toWrite, fp); - ptr += write * cols; - toWrite -= (int)write; - } - fclose(fp); - - std::cout << "Save Data (" << CR << ", " << cols << ") Finish!" << std::endl; - return true; - } - - bool Save(void **pDataPointsMemFile, int64_t &len) - { - size_t size = sizeof(int) + sizeof(int) + sizeof(T) * R() *cols; - char *mem = (char*)malloc(size); - if (mem == NULL) return false; - - int CR = R(); - - auto header = (int*)mem; - header[0] = CR; - header[1] = cols; - auto body = &mem[8]; - - memcpy(body, data, sizeof(T) * cols * rows); - body += sizeof(T) * cols * rows; - memcpy(body, dataIncremental.data(), sizeof(T) * cols * (CR - rows)); - body += sizeof(T) * cols * (CR - rows); - - *pDataPointsMemFile = mem; - len = size; - - return true; - } - - bool Load(std::string sDataPointsFileName) - { - std::cout << "Load Data From " << sDataPointsFileName << std::endl; - FILE * fp = fopen(sDataPointsFileName.c_str(), "rb"); - if (fp == NULL) return false; - - int R, C; - fread(&R, sizeof(int), 1, fp); - fread(&C, sizeof(int), 1, fp); - - Initialize(R, C); - T* ptr = data; - while (R > 0) { - size_t read = fread(ptr, sizeof(T) * C, R, fp); - ptr += read * C; - R -= (int)read; - } - fclose(fp); - std::cout << "Load Data (" << rows << ", " << cols << ") Finish!" << std::endl; - return true; - } - - // Functions for loading models from memory mapped files - bool Load(char* pDataPointsMemFile) - { - int R, C; - R = *((int*)pDataPointsMemFile); - pDataPointsMemFile += sizeof(int); - - C = *((int*)pDataPointsMemFile); - pDataPointsMemFile += sizeof(int); - - Initialize(R, C, (T*)pDataPointsMemFile); - return true; - } - - bool Refine(const std::vector& indices, std::string sDataPointsFileName) - { - std::cout << "Save Refine Data To " << sDataPointsFileName << std::endl; - FILE * fp = fopen(sDataPointsFileName.c_str(), "wb"); - if (fp == NULL) return false; - - int R = (int)(indices.size()); - fwrite(&R, sizeof(int), 1, fp); - fwrite(&cols, sizeof(int), 1, fp); - - // write point one by one in case for cache miss - for (int i = 0; i < R; i++) { - if (indices[i] < rows) - fwrite(data + (size_t)indices[i] * cols, sizeof(T) * cols, 1, fp); - else - fwrite(dataIncremental.data() + (size_t)(indices[i] - rows) * cols, sizeof(T) * cols, 1, fp); - } - fclose(fp); - - std::cout << "Save Refine Data (" << R << ", " << cols << ") Finish!" << std::endl; - return true; - } - }; - } -} - -#endif // _SPTAG_COMMON_DATASET_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/DistanceUtils.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/DistanceUtils.h deleted file mode 100644 index 828eead752..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/DistanceUtils.h +++ /dev/null @@ -1,610 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_COMMON_DISTANCEUTILS_H_ -#define _SPTAG_COMMON_DISTANCEUTILS_H_ - -#include -#include - -#include "CommonUtils.h" - -#define SSE - -#ifndef _MSC_VER -#define DIFF128 diff128 -#define DIFF256 diff256 -#else -#define DIFF128 diff128.m128_f32 -#define DIFF256 diff256.m256_f32 -#endif - -namespace SPTAG -{ - namespace COMMON - { - class DistanceUtils - { - public: - static inline __m128 _mm_mul_epi8(__m128i X, __m128i Y) - { - __m128i zero = _mm_setzero_si128(); - - __m128i sign_x = _mm_cmplt_epi8(X, zero); - __m128i sign_y = _mm_cmplt_epi8(Y, zero); - - __m128i xlo = _mm_unpacklo_epi8(X, sign_x); - __m128i xhi = _mm_unpackhi_epi8(X, sign_x); - __m128i ylo = _mm_unpacklo_epi8(Y, sign_y); - __m128i yhi = _mm_unpackhi_epi8(Y, sign_y); - - return _mm_cvtepi32_ps(_mm_add_epi32(_mm_madd_epi16(xlo, ylo), _mm_madd_epi16(xhi, yhi))); - } - - static inline __m128 _mm_sqdf_epi8(__m128i X, __m128i Y) - { - __m128i zero = _mm_setzero_si128(); - - __m128i sign_x = _mm_cmplt_epi8(X, zero); - __m128i sign_y = _mm_cmplt_epi8(Y, zero); - - __m128i xlo = _mm_unpacklo_epi8(X, sign_x); - __m128i xhi = _mm_unpackhi_epi8(X, sign_x); - __m128i ylo = _mm_unpacklo_epi8(Y, sign_y); - __m128i yhi = _mm_unpackhi_epi8(Y, sign_y); - - __m128i dlo = _mm_sub_epi16(xlo, ylo); - __m128i dhi = _mm_sub_epi16(xhi, yhi); - - return _mm_cvtepi32_ps(_mm_add_epi32(_mm_madd_epi16(dlo, dlo), _mm_madd_epi16(dhi, dhi))); - } - - static inline __m128 _mm_mul_epu8(__m128i X, __m128i Y) - { - __m128i zero = _mm_setzero_si128(); - - __m128i xlo = _mm_unpacklo_epi8(X, zero); - __m128i xhi = _mm_unpackhi_epi8(X, zero); - __m128i ylo = _mm_unpacklo_epi8(Y, zero); - __m128i yhi = _mm_unpackhi_epi8(Y, zero); - - return _mm_cvtepi32_ps(_mm_add_epi32(_mm_madd_epi16(xlo, ylo), _mm_madd_epi16(xhi, yhi))); - } - - static inline __m128 _mm_sqdf_epu8(__m128i X, __m128i Y) - { - __m128i zero = _mm_setzero_si128(); - - __m128i xlo = _mm_unpacklo_epi8(X, zero); - __m128i xhi = _mm_unpackhi_epi8(X, zero); - __m128i ylo = _mm_unpacklo_epi8(Y, zero); - __m128i yhi = _mm_unpackhi_epi8(Y, zero); - - __m128i dlo = _mm_sub_epi16(xlo, ylo); - __m128i dhi = _mm_sub_epi16(xhi, yhi); - - return _mm_cvtepi32_ps(_mm_add_epi32(_mm_madd_epi16(dlo, dlo), _mm_madd_epi16(dhi, dhi))); - } - - static inline __m128 _mm_mul_epi16(__m128i X, __m128i Y) - { - return _mm_cvtepi32_ps(_mm_madd_epi16(X, Y)); - } - - static inline __m128 _mm_sqdf_epi16(__m128i X, __m128i Y) - { - __m128i zero = _mm_setzero_si128(); - - __m128i sign_x = _mm_cmplt_epi16(X, zero); - __m128i sign_y = _mm_cmplt_epi16(Y, zero); - - __m128i xlo = _mm_unpacklo_epi16(X, sign_x); - __m128i xhi = _mm_unpackhi_epi16(X, sign_x); - __m128i ylo = _mm_unpacklo_epi16(Y, sign_y); - __m128i yhi = _mm_unpackhi_epi16(Y, sign_y); - - __m128 dlo = _mm_cvtepi32_ps(_mm_sub_epi32(xlo, ylo)); - __m128 dhi = _mm_cvtepi32_ps(_mm_sub_epi32(xhi, yhi)); - - return _mm_add_ps(_mm_mul_ps(dlo, dlo), _mm_mul_ps(dhi, dhi)); - } - static inline __m128 _mm_sqdf_ps(__m128 X, __m128 Y) - { - __m128 d = _mm_sub_ps(X, Y); - return _mm_mul_ps(d, d); - } -#if defined(AVX) - static inline __m256 _mm256_mul_epi8(__m256i X, __m256i Y) - { - __m256i zero = _mm256_setzero_si256(); - - __m256i sign_x = _mm256_cmpgt_epi8(zero, X); - __m256i sign_y = _mm256_cmpgt_epi8(zero, Y); - - __m256i xlo = _mm256_unpacklo_epi8(X, sign_x); - __m256i xhi = _mm256_unpackhi_epi8(X, sign_x); - __m256i ylo = _mm256_unpacklo_epi8(Y, sign_y); - __m256i yhi = _mm256_unpackhi_epi8(Y, sign_y); - - return _mm256_cvtepi32_ps(_mm256_add_epi32(_mm256_madd_epi16(xlo, ylo), _mm256_madd_epi16(xhi, yhi))); - } - static inline __m256 _mm256_sqdf_epi8(__m256i X, __m256i Y) - { - __m256i zero = _mm256_setzero_si256(); - - __m256i sign_x = _mm256_cmpgt_epi8(zero, X); - __m256i sign_y = _mm256_cmpgt_epi8(zero, Y); - - __m256i xlo = _mm256_unpacklo_epi8(X, sign_x); - __m256i xhi = _mm256_unpackhi_epi8(X, sign_x); - __m256i ylo = _mm256_unpacklo_epi8(Y, sign_y); - __m256i yhi = _mm256_unpackhi_epi8(Y, sign_y); - - __m256i dlo = _mm256_sub_epi16(xlo, ylo); - __m256i dhi = _mm256_sub_epi16(xhi, yhi); - - return _mm256_cvtepi32_ps(_mm256_add_epi32(_mm256_madd_epi16(dlo, dlo), _mm256_madd_epi16(dhi, dhi))); - } - static inline __m256 _mm256_mul_epu8(__m256i X, __m256i Y) - { - __m256i zero = _mm256_setzero_si256(); - - __m256i xlo = _mm256_unpacklo_epi8(X, zero); - __m256i xhi = _mm256_unpackhi_epi8(X, zero); - __m256i ylo = _mm256_unpacklo_epi8(Y, zero); - __m256i yhi = _mm256_unpackhi_epi8(Y, zero); - - return _mm256_cvtepi32_ps(_mm256_add_epi32(_mm256_madd_epi16(xlo, ylo), _mm256_madd_epi16(xhi, yhi))); - } - static inline __m256 _mm256_sqdf_epu8(__m256i X, __m256i Y) - { - __m256i zero = _mm256_setzero_si256(); - - __m256i xlo = _mm256_unpacklo_epi8(X, zero); - __m256i xhi = _mm256_unpackhi_epi8(X, zero); - __m256i ylo = _mm256_unpacklo_epi8(Y, zero); - __m256i yhi = _mm256_unpackhi_epi8(Y, zero); - - __m256i dlo = _mm256_sub_epi16(xlo, ylo); - __m256i dhi = _mm256_sub_epi16(xhi, yhi); - - return _mm256_cvtepi32_ps(_mm256_add_epi32(_mm256_madd_epi16(dlo, dlo), _mm256_madd_epi16(dhi, dhi))); - } - static inline __m256 _mm256_mul_epi16(__m256i X, __m256i Y) - { - return _mm256_cvtepi32_ps(_mm256_madd_epi16(X, Y)); - } - static inline __m256 _mm256_sqdf_epi16(__m256i X, __m256i Y) - { - __m256i zero = _mm256_setzero_si256(); - - __m256i sign_x = _mm256_cmpgt_epi16(zero, X); - __m256i sign_y = _mm256_cmpgt_epi16(zero, Y); - - __m256i xlo = _mm256_unpacklo_epi16(X, sign_x); - __m256i xhi = _mm256_unpackhi_epi16(X, sign_x); - __m256i ylo = _mm256_unpacklo_epi16(Y, sign_y); - __m256i yhi = _mm256_unpackhi_epi16(Y, sign_y); - - __m256 dlo = _mm256_cvtepi32_ps(_mm256_sub_epi32(xlo, ylo)); - __m256 dhi = _mm256_cvtepi32_ps(_mm256_sub_epi32(xhi, yhi)); - - return _mm256_add_ps(_mm256_mul_ps(dlo, dlo), _mm256_mul_ps(dhi, dhi)); - } - static inline __m256 _mm256_sqdf_ps(__m256 X, __m256 Y) - { - __m256 d = _mm256_sub_ps(X, Y); - return _mm256_mul_ps(d, d); - } -#endif -/* - template - static float ComputeL2Distance(const T *pX, const T *pY, int length) - { - float diff = 0; - const T* pEnd1 = pX + length; - while (pX < pEnd1) { - float c1 = ((float)(*pX++) - (float)(*pY++)); diff += c1 * c1; - } - return diff; - } -*/ -#define REPEAT(type, ctype, delta, load, exec, acc, result) \ - { \ - type c1 = load((ctype *)(pX)); \ - type c2 = load((ctype *)(pY)); \ - pX += delta; pY += delta; \ - result = acc(result, exec(c1, c2)); \ - } \ - - static float ComputeL2Distance(const std::int8_t *pX, const std::int8_t *pY, int length) - { - const std::int8_t* pEnd32 = pX + ((length >> 5) << 5); - const std::int8_t* pEnd16 = pX + ((length >> 4) << 4); - const std::int8_t* pEnd4 = pX + ((length >> 2) << 2); - const std::int8_t* pEnd1 = pX + length; -#if defined(SSE) - __m128 diff128 = _mm_setzero_ps(); - while (pX < pEnd32) { - REPEAT(__m128i, __m128i, 16, _mm_loadu_si128, _mm_sqdf_epi8, _mm_add_ps, diff128) - REPEAT(__m128i, __m128i, 16, _mm_loadu_si128, _mm_sqdf_epi8, _mm_add_ps, diff128) - } - while (pX < pEnd16) { - REPEAT(__m128i, __m128i, 16, _mm_loadu_si128, _mm_sqdf_epi8, _mm_add_ps, diff128) - } - float diff = DIFF128[0] + DIFF128[1] + DIFF128[2] + DIFF128[3]; -#elif defined(AVX) - __m256 diff256 = _mm256_setzero_ps(); - while (pX < pEnd32) { - REPEAT(__m256i, __m256i, 32, _mm256_loadu_si256, _mm256_sqdf_epi8, _mm256_add_ps, diff256) - } - __m128 diff128 = _mm_add_ps(_mm256_castps256_ps128(diff256), _mm256_extractf128_ps(diff256, 1)); - while (pX < pEnd16) { - REPEAT(__m128i, __m128i, 16, _mm_loadu_si128, _mm_sqdf_epi8, _mm_add_ps, diff128) - } - float diff = DIFF128[0] + DIFF128[1] + DIFF128[2] + DIFF128[3]; -#else - float diff = 0; -#endif - while (pX < pEnd4) { - float c1 = ((float)(*pX++) - (float)(*pY++)); diff += c1 * c1; - c1 = ((float)(*pX++) - (float)(*pY++)); diff += c1 * c1; - c1 = ((float)(*pX++) - (float)(*pY++)); diff += c1 * c1; - c1 = ((float)(*pX++) - (float)(*pY++)); diff += c1 * c1; - } - while (pX < pEnd1) { - float c1 = ((float)(*pX++) - (float)(*pY++)); diff += c1 * c1; - } - return diff; - } - - static float ComputeL2Distance(const std::uint8_t *pX, const std::uint8_t *pY, int length) - { - const std::uint8_t* pEnd32 = pX + ((length >> 5) << 5); - const std::uint8_t* pEnd16 = pX + ((length >> 4) << 4); - const std::uint8_t* pEnd4 = pX + ((length >> 2) << 2); - const std::uint8_t* pEnd1 = pX + length; -#if defined(SSE) - __m128 diff128 = _mm_setzero_ps(); - while (pX < pEnd32) { - REPEAT(__m128i, __m128i, 16, _mm_loadu_si128, _mm_sqdf_epu8, _mm_add_ps, diff128) - REPEAT(__m128i, __m128i, 16, _mm_loadu_si128, _mm_sqdf_epu8, _mm_add_ps, diff128) - } - while (pX < pEnd16) { - REPEAT(__m128i, __m128i, 16, _mm_loadu_si128, _mm_sqdf_epu8, _mm_add_ps, diff128) - } - float diff = DIFF128[0] + DIFF128[1] + DIFF128[2] + DIFF128[3]; -#elif defined(AVX) - __m256 diff256 = _mm256_setzero_ps(); - while (pX < pEnd32) { - REPEAT(__m256i, __m256i, 32, _mm256_loadu_si256, _mm256_sqdf_epu8, _mm256_add_ps, diff256) - } - __m128 diff128 = _mm_add_ps(_mm256_castps256_ps128(diff256), _mm256_extractf128_ps(diff256, 1)); - while (pX < pEnd16) { - REPEAT(__m128i, __m128i, 16, _mm_loadu_si128, _mm_sqdf_epu8, _mm_add_ps, diff128) - } - float diff = DIFF128[0] + DIFF128[1] + DIFF128[2] + DIFF128[3]; -#else - float diff = 0; -#endif - while (pX < pEnd4) { - float c1 = ((float)(*pX++) - (float)(*pY++)); diff += c1 * c1; - c1 = ((float)(*pX++) - (float)(*pY++)); diff += c1 * c1; - c1 = ((float)(*pX++) - (float)(*pY++)); diff += c1 * c1; - c1 = ((float)(*pX++) - (float)(*pY++)); diff += c1 * c1; - } - while (pX < pEnd1) { - float c1 = ((float)(*pX++) - (float)(*pY++)); diff += c1 * c1; - } - return diff; - } - - static float ComputeL2Distance(const std::int16_t *pX, const std::int16_t *pY, int length) - { - const std::int16_t* pEnd16 = pX + ((length >> 4) << 4); - const std::int16_t* pEnd8 = pX + ((length >> 3) << 3); - const std::int16_t* pEnd4 = pX + ((length >> 2) << 2); - const std::int16_t* pEnd1 = pX + length; -#if defined(SSE) - __m128 diff128 = _mm_setzero_ps(); - while (pX < pEnd16) { - REPEAT(__m128i, __m128i, 8, _mm_loadu_si128, _mm_sqdf_epi16, _mm_add_ps, diff128) - REPEAT(__m128i, __m128i, 8, _mm_loadu_si128, _mm_sqdf_epi16, _mm_add_ps, diff128) - } - while (pX < pEnd8) { - REPEAT(__m128i, __m128i, 8, _mm_loadu_si128, _mm_sqdf_epi16, _mm_add_ps, diff128) - } - float diff = DIFF128[0] + DIFF128[1] + DIFF128[2] + DIFF128[3]; -#elif defined(AVX) - __m256 diff256 = _mm256_setzero_ps(); - while (pX < pEnd16) { - REPEAT(__m256i, __m256i, 16, _mm256_loadu_si256, _mm256_sqdf_epi16, _mm256_add_ps, diff256) - } - __m128 diff128 = _mm_add_ps(_mm256_castps256_ps128(diff256), _mm256_extractf128_ps(diff256, 1)); - while (pX < pEnd8) { - REPEAT(__m128i, __m128i, 8, _mm_loadu_si128, _mm_sqdf_epi16, _mm_add_ps, diff128) - } - float diff = DIFF128[0] + DIFF128[1] + DIFF128[2] + DIFF128[3]; -#else - float diff = 0; -#endif - while (pX < pEnd4) { - float c1 = ((float)(*pX++) - (float)(*pY++)); diff += c1 * c1; - c1 = ((float)(*pX++) - (float)(*pY++)); diff += c1 * c1; - c1 = ((float)(*pX++) - (float)(*pY++)); diff += c1 * c1; - c1 = ((float)(*pX++) - (float)(*pY++)); diff += c1 * c1; - } - - while (pX < pEnd1) { - float c1 = ((float)(*pX++) - (float)(*pY++)); diff += c1 * c1; - } - return diff; - } - - static float ComputeL2Distance(const float *pX, const float *pY, int length) - { - const float* pEnd16 = pX + ((length >> 4) << 4); - const float* pEnd4 = pX + ((length >> 2) << 2); - const float* pEnd1 = pX + length; -#if defined(SSE) - __m128 diff128 = _mm_setzero_ps(); - while (pX < pEnd16) - { - REPEAT(__m128, const float, 4, _mm_loadu_ps, _mm_sqdf_ps, _mm_add_ps, diff128) - REPEAT(__m128, const float, 4, _mm_loadu_ps, _mm_sqdf_ps, _mm_add_ps, diff128) - REPEAT(__m128, const float, 4, _mm_loadu_ps, _mm_sqdf_ps, _mm_add_ps, diff128) - REPEAT(__m128, const float, 4, _mm_loadu_ps, _mm_sqdf_ps, _mm_add_ps, diff128) - } - while (pX < pEnd4) - { - REPEAT(__m128, const float, 4, _mm_loadu_ps, _mm_sqdf_ps, _mm_add_ps, diff128) - } - float diff = DIFF128[0] + DIFF128[1] + DIFF128[2] + DIFF128[3]; -#elif defined(AVX) - __m256 diff256 = _mm256_setzero_ps(); - while (pX < pEnd16) - { - REPEAT(__m256, const float, 8, _mm256_loadu_ps, _mm256_sqdf_ps, _mm256_add_ps, diff256) - REPEAT(__m256, const float, 8, _mm256_loadu_ps, _mm256_sqdf_ps, _mm256_add_ps, diff256) - } - __m128 diff128 = _mm_add_ps(_mm256_castps256_ps128(diff256), _mm256_extractf128_ps(diff256, 1)); - while (pX < pEnd4) - { - REPEAT(__m128, const float, 4, _mm_loadu_ps, _mm_sqdf_ps, _mm_add_ps, diff128) - } - float diff = DIFF128[0] + DIFF128[1] + DIFF128[2] + DIFF128[3]; -#else - float diff = 0; - while (pX < pEnd4) { - float c1 = (*pX++) - (*pY++); diff += c1 * c1; - c1 = (*pX++) - (*pY++); diff += c1 * c1; - c1 = (*pX++) - (*pY++); diff += c1 * c1; - c1 = (*pX++) - (*pY++); diff += c1 * c1; - } -#endif - while (pX < pEnd1) { - float c1 = (*pX++) - (*pY++); diff += c1 * c1; - } - return diff; - } -/* - template - static float ComputeCosineDistance(const T *pX, const T *pY, int length) { - float diff = 0; - const T* pEnd1 = pX + length; - while (pX < pEnd1) diff += (*pX++) * (*pY++); - return 1 - diff; - } -*/ - static float ComputeCosineDistance(const std::int8_t *pX, const std::int8_t *pY, int length) { - const std::int8_t* pEnd32 = pX + ((length >> 5) << 5); - const std::int8_t* pEnd16 = pX + ((length >> 4) << 4); - const std::int8_t* pEnd4 = pX + ((length >> 2) << 2); - const std::int8_t* pEnd1 = pX + length; -#if defined(SSE) - - __m128 diff128 = _mm_setzero_ps(); - while (pX < pEnd32) { - REPEAT(__m128i, __m128i, 16, _mm_loadu_si128, _mm_mul_epi8, _mm_add_ps, diff128) - REPEAT(__m128i, __m128i, 16, _mm_loadu_si128, _mm_mul_epi8, _mm_add_ps, diff128) - } - while (pX < pEnd16) { - REPEAT(__m128i, __m128i, 16, _mm_loadu_si128, _mm_mul_epi8, _mm_add_ps, diff128) - } - float diff = DIFF128[0] + DIFF128[1] + DIFF128[2] + DIFF128[3]; -#elif defined(AVX) - __m256 diff256 = _mm256_setzero_ps(); - while (pX < pEnd32) { - REPEAT(__m256i, __m256i, 32, _mm256_loadu_si256, _mm256_mul_epi8, _mm256_add_ps, diff256) - } - __m128 diff128 = _mm_add_ps(_mm256_castps256_ps128(diff256), _mm256_extractf128_ps(diff256, 1)); - while (pX < pEnd16) { - REPEAT(__m128i, __m128i, 16, _mm_loadu_si128, _mm_mul_epi8, _mm_add_ps, diff128) - } - float diff = DIFF128[0] + DIFF128[1] + DIFF128[2] + DIFF128[3]; -#else - float diff = 0; -#endif - while (pX < pEnd4) - { - float c1 = ((float)(*pX++) * (float)(*pY++)); diff += c1; - c1 = ((float)(*pX++) * (float)(*pY++)); diff += c1; - c1 = ((float)(*pX++) * (float)(*pY++)); diff += c1; - c1 = ((float)(*pX++) * (float)(*pY++)); diff += c1; - } - while (pX < pEnd1) diff += ((float)(*pX++) * (float)(*pY++)); - return 16129 - diff; - } - - static float ComputeCosineDistance(const std::uint8_t *pX, const std::uint8_t *pY, int length) { - const std::uint8_t* pEnd32 = pX + ((length >> 5) << 5); - const std::uint8_t* pEnd16 = pX + ((length >> 4) << 4); - const std::uint8_t* pEnd4 = pX + ((length >> 2) << 2); - const std::uint8_t* pEnd1 = pX + length; -#if defined(SSE) - - __m128 diff128 = _mm_setzero_ps(); - while (pX < pEnd32) { - REPEAT(__m128i, __m128i, 16, _mm_loadu_si128, _mm_mul_epu8, _mm_add_ps, diff128) - REPEAT(__m128i, __m128i, 16, _mm_loadu_si128, _mm_mul_epu8, _mm_add_ps, diff128) - } - while (pX < pEnd16) { - REPEAT(__m128i, __m128i, 16, _mm_loadu_si128, _mm_mul_epu8, _mm_add_ps, diff128) - } - float diff = DIFF128[0] + DIFF128[1] + DIFF128[2] + DIFF128[3]; -#elif defined(AVX) - __m256 diff256 = _mm256_setzero_ps(); - while (pX < pEnd32) { - REPEAT(__m256i, __m256i, 32, _mm256_loadu_si256, _mm256_mul_epu8, _mm256_add_ps, diff256) - } - __m128 diff128 = _mm_add_ps(_mm256_castps256_ps128(diff256), _mm256_extractf128_ps(diff256, 1)); - while (pX < pEnd16) { - REPEAT(__m128i, __m128i, 16, _mm_loadu_si128, _mm_mul_epu8, _mm_add_ps, diff128) - } - float diff = DIFF128[0] + DIFF128[1] + DIFF128[2] + DIFF128[3]; -#else - float diff = 0; -#endif - while (pX < pEnd4) - { - float c1 = ((float)(*pX++) * (float)(*pY++)); diff += c1; - c1 = ((float)(*pX++) * (float)(*pY++)); diff += c1; - c1 = ((float)(*pX++) * (float)(*pY++)); diff += c1; - c1 = ((float)(*pX++) * (float)(*pY++)); diff += c1; - } - while (pX < pEnd1) diff += ((float)(*pX++) * (float)(*pY++)); - return 65025 - diff; - } - - static float ComputeCosineDistance(const std::int16_t *pX, const std::int16_t *pY, int length) { - const std::int16_t* pEnd16 = pX + ((length >> 4) << 4); - const std::int16_t* pEnd8 = pX + ((length >> 3) << 3); - const std::int16_t* pEnd4 = pX + ((length >> 2) << 2); - const std::int16_t* pEnd1 = pX + length; -#if defined(SSE) - __m128 diff128 = _mm_setzero_ps(); - while (pX < pEnd16) { - REPEAT(__m128i, __m128i, 8, _mm_loadu_si128, _mm_mul_epi16, _mm_add_ps, diff128) - REPEAT(__m128i, __m128i, 8, _mm_loadu_si128, _mm_mul_epi16, _mm_add_ps, diff128) - } - while (pX < pEnd8) { - REPEAT(__m128i, __m128i, 8, _mm_loadu_si128, _mm_mul_epi16, _mm_add_ps, diff128) - } - float diff = DIFF128[0] + DIFF128[1] + DIFF128[2] + DIFF128[3]; - -#elif defined(AVX) - __m256 diff256 = _mm256_setzero_ps(); - while (pX < pEnd16) { - REPEAT(__m256i, __m256i, 16, _mm256_loadu_si256, _mm256_mul_epi16, _mm256_add_ps, diff256) - } - __m128 diff128 = _mm_add_ps(_mm256_castps256_ps128(diff256), _mm256_extractf128_ps(diff256, 1)); - while (pX < pEnd8) { - REPEAT(__m128i, __m128i, 8, _mm_loadu_si128, _mm_mul_epi16, _mm_add_ps, diff128) - } - float diff = DIFF128[0] + DIFF128[1] + DIFF128[2] + DIFF128[3]; -#else - float diff = 0; -#endif - while (pX < pEnd4) - { - float c1 = ((float)(*pX++) * (float)(*pY++)); diff += c1; - c1 = ((float)(*pX++) * (float)(*pY++)); diff += c1; - c1 = ((float)(*pX++) * (float)(*pY++)); diff += c1; - c1 = ((float)(*pX++) * (float)(*pY++)); diff += c1; - } - - while (pX < pEnd1) diff += ((float)(*pX++) * (float)(*pY++)); - return 1073676289 - diff; - } - - static float ComputeCosineDistance(const float *pX, const float *pY, int length) { - const float* pEnd16 = pX + ((length >> 4) << 4); - const float* pEnd4 = pX + ((length >> 2) << 2); - const float* pEnd1 = pX + length; -#if defined(SSE) - __m128 diff128 = _mm_setzero_ps(); - while (pX < pEnd16) - { - REPEAT(__m128, const float, 4, _mm_loadu_ps, _mm_mul_ps, _mm_add_ps, diff128) - REPEAT(__m128, const float, 4, _mm_loadu_ps, _mm_mul_ps, _mm_add_ps, diff128) - REPEAT(__m128, const float, 4, _mm_loadu_ps, _mm_mul_ps, _mm_add_ps, diff128) - REPEAT(__m128, const float, 4, _mm_loadu_ps, _mm_mul_ps, _mm_add_ps, diff128) - } - while (pX < pEnd4) - { - REPEAT(__m128, const float, 4, _mm_loadu_ps, _mm_mul_ps, _mm_add_ps, diff128) - } - float diff = DIFF128[0] + DIFF128[1] + DIFF128[2] + DIFF128[3]; - -#elif defined(AVX) - __m256 diff256 = _mm256_setzero_ps(); - while (pX < pEnd16) - { - REPEAT(__m256, const float, 8, _mm256_loadu_ps, _mm256_mul_ps, _mm256_add_ps, diff256) - REPEAT(__m256, const float, 8, _mm256_loadu_ps, _mm256_mul_ps, _mm256_add_ps, diff256) - } - __m128 diff128 = _mm_add_ps(_mm256_castps256_ps128(diff256), _mm256_extractf128_ps(diff256, 1)); - while (pX < pEnd4) - { - REPEAT(__m128, const float, 4, _mm_loadu_ps, _mm_mul_ps, _mm_add_ps, diff128) - } - float diff = DIFF128[0] + DIFF128[1] + DIFF128[2] + DIFF128[3]; -#else - float diff = 0; - while (pX < pEnd4) - { - float c1 = (*pX++) * (*pY++); diff += c1; - c1 = (*pX++) * (*pY++); diff += c1; - c1 = (*pX++) * (*pY++); diff += c1; - c1 = (*pX++) * (*pY++); diff += c1; - } -#endif - while (pX < pEnd1) diff += (*pX++) * (*pY++); - return 1 - diff; - } - - template - static inline float ComputeDistance(const T *p1, const T *p2, int length, SPTAG::DistCalcMethod distCalcMethod) - { - if (distCalcMethod == SPTAG::DistCalcMethod::L2) - return ComputeL2Distance(p1, p2, length); - - return ComputeCosineDistance(p1, p2, length); - } - - static inline float ConvertCosineSimilarityToDistance(float cs) - { - // Cosine similarity is in [-1, 1], the higher the value, the closer are the two vectors. - // However, the tree is built and searched based on "distance" between two vectors, that's >=0. The smaller the value, the closer are the two vectors. - // So we do a linear conversion from a cosine similarity to a distance value. - return 1 - cs; //[1, 3] - } - - static inline float ConvertDistanceBackToCosineSimilarity(float d) - { - return 1 - d; - } - }; - - - template - float (*DistanceCalcSelector(SPTAG::DistCalcMethod p_method)) (const T*, const T*, int) - { - switch (p_method) - { - case SPTAG::DistCalcMethod::Cosine: - return &(DistanceUtils::ComputeCosineDistance); - - case SPTAG::DistCalcMethod::L2: - return &(DistanceUtils::ComputeL2Distance); - - default: - break; - } - - return nullptr; - } - } -} - -#endif // _SPTAG_COMMON_DISTANCEUTILS_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/FineGrainedLock.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/FineGrainedLock.h deleted file mode 100644 index d8bfbaa9fe..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/FineGrainedLock.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_COMMON_FINEGRAINEDLOCK_H_ -#define _SPTAG_COMMON_FINEGRAINEDLOCK_H_ - -#include -#include -#include - -namespace SPTAG -{ - namespace COMMON - { - class FineGrainedLock { - public: - FineGrainedLock() {} - ~FineGrainedLock() { - for (int i = 0; i < locks.size(); i++) - locks[i].reset(); - locks.clear(); - } - - void resize(int n) { - int current = (int)locks.size(); - if (current <= n) { - locks.resize(n); - for (int i = current; i < n; i++) - locks[i].reset(new std::mutex); - } - else { - for (int i = n; i < current; i++) - locks[i].reset(); - locks.resize(n); - } - } - - std::mutex& operator[](int idx) { - return *locks[idx]; - } - - const std::mutex& operator[](int idx) const { - return *locks[idx]; - } - private: - std::vector> locks; - }; - } -} - -#endif // _SPTAG_COMMON_FINEGRAINEDLOCK_H_ \ No newline at end of file diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/Heap.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/Heap.h deleted file mode 100644 index 261aa498a6..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/Heap.h +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_COMMON_HEAP_H_ -#define _SPTAG_COMMON_HEAP_H_ - -namespace SPTAG -{ - namespace COMMON - { - - // priority queue - template - class Heap { - public: - Heap() : heap(nullptr), length(0), count(0) {} - - Heap(int size) { Resize(size); } - - void Resize(int size) - { - length = size; - heap.reset(new T[length + 1]); // heap uses 1-based indexing - count = 0; - lastlevel = int(pow(2.0, floor(log2(size)))); - } - ~Heap() {} - inline int size() { return count; } - inline bool empty() { return count == 0; } - inline void clear() { count = 0; } - inline T& Top() { if (count == 0) return heap[0]; else return heap[1]; } - - // Insert a new element in the heap. - void insert(T value) - { - /* If heap is full, then return without adding this element. */ - int loc; - if (count == length) { - int maxi = lastlevel; - for (int i = lastlevel + 1; i <= length; i++) - if (heap[maxi] < heap[i]) maxi = i; - if (value > heap[maxi]) return; - loc = maxi; - } - else { - loc = ++(count); /* Remember 1-based indexing. */ - } - /* Keep moving parents down until a place is found for this node. */ - int par = (loc >> 1); /* Location of parent. */ - while (par > 0 && value < heap[par]) { - heap[loc] = heap[par]; /* Move parent down to loc. */ - loc = par; - par >>= 1; - } - /* Insert the element at the determined location. */ - heap[loc] = value; - } - // Returns the node of minimum value from the heap (top of the heap). - bool pop(T& value) - { - if (count == 0) return false; - /* Switch first node with last. */ - value = heap[1]; - std::swap(heap[1], heap[count]); - count--; - heapify(); /* Move new node 1 to right position. */ - return true; /* Return old last node. */ - } - T& pop() - { - if (count == 0) return heap[0]; - /* Switch first node with last. */ - std::swap(heap[1], heap[count]); - count--; - heapify(); /* Move new node 1 to right position. */ - return heap[count + 1]; /* Return old last node. */ - } - private: - // Storage array for the heap. - // Type T must be comparable. - std::unique_ptr heap; - int length; - int count; // Number of element in the heap - int lastlevel; - // Reorganizes the heap (a parent is smaller than its children) starting with a node. - - void heapify() - { - int parent = 1, next = 2; - while (next < count) { - if (heap[next] > heap[next + 1]) next++; - if (heap[next] < heap[parent]) { - std::swap(heap[parent], heap[next]); - parent = next; - next <<= 1; - } - else break; - } - if (next == count && heap[next] < heap[parent]) std::swap(heap[parent], heap[next]); - } - }; - } -} - -#endif // _SPTAG_COMMON_HEAP_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/KDTree.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/KDTree.h deleted file mode 100644 index 95d4ae36e4..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/KDTree.h +++ /dev/null @@ -1,358 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_COMMON_KDTREE_H_ -#define _SPTAG_COMMON_KDTREE_H_ - -#include -#include -#include - -#include "../VectorIndex.h" - -#include "CommonUtils.h" -#include "QueryResultSet.h" -#include "WorkSpace.h" - -#pragma warning(disable:4996) // 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. - -namespace SPTAG -{ - namespace COMMON - { - // node type for storing KDT - struct KDTNode - { - int left; - int right; - short split_dim; - float split_value; - }; - - class KDTree - { - public: - KDTree() : m_iTreeNumber(2), m_numTopDimensionKDTSplit(5), m_iSamples(1000) {} - - KDTree(KDTree& other) : m_iTreeNumber(other.m_iTreeNumber), - m_numTopDimensionKDTSplit(other.m_numTopDimensionKDTSplit), - m_iSamples(other.m_iSamples) {} - ~KDTree() {} - - inline const KDTNode& operator[](int index) const { return m_pTreeRoots[index]; } - inline KDTNode& operator[](int index) { return m_pTreeRoots[index]; } - - inline int size() const { return (int)m_pTreeRoots.size(); } - - template - void BuildTrees(VectorIndex* p_index, std::vector* indices = nullptr) - { - std::vector localindices; - if (indices == nullptr) { - localindices.resize(p_index->GetNumSamples()); - for (int i = 0; i < p_index->GetNumSamples(); i++) localindices[i] = i; - } - else { - localindices.assign(indices->begin(), indices->end()); - } - - m_pTreeRoots.resize(m_iTreeNumber * localindices.size()); - m_pTreeStart.resize(m_iTreeNumber, 0); -#pragma omp parallel for - for (int i = 0; i < m_iTreeNumber; i++) - { - Sleep(i * 100); std::srand(clock()); - - std::vector pindices(localindices.begin(), localindices.end()); - std::random_shuffle(pindices.begin(), pindices.end()); - - m_pTreeStart[i] = i * (int)pindices.size(); - std::cout << "Start to build KDTree " << i + 1 << std::endl; - int iTreeSize = m_pTreeStart[i]; - DivideTree(p_index, pindices, 0, (int)pindices.size() - 1, m_pTreeStart[i], iTreeSize); - std::cout << i + 1 << " KDTree built, " << iTreeSize - m_pTreeStart[i] << " " << pindices.size() << std::endl; - } - } - - bool SaveTrees(void **pKDTMemFile, int64_t &len) const - { - int treeNodeSize = (int)m_pTreeRoots.size(); - - size_t size = sizeof(int) + - sizeof(int) * m_iTreeNumber + - sizeof(int) + - sizeof(KDTNode) * treeNodeSize; - char *mem = (char*)malloc(size); - if (mem == NULL) return false; - - auto ptr = mem; - *(int*)ptr = m_iTreeNumber; - ptr += sizeof(int); - - memcpy(ptr, m_pTreeStart.data(), sizeof(int) * m_iTreeNumber); - ptr += sizeof(int) * m_iTreeNumber; - - *(int*)ptr = treeNodeSize; - ptr += sizeof(int); - - memcpy(ptr, m_pTreeRoots.data(), sizeof(KDTNode) * treeNodeSize); - *pKDTMemFile = mem; - len = size; - - return true; - } - - bool SaveTrees(std::string sTreeFileName) const - { - std::cout << "Save KDT to " << sTreeFileName << std::endl; - FILE *fp = fopen(sTreeFileName.c_str(), "wb"); - if (fp == NULL) return false; - - fwrite(&m_iTreeNumber, sizeof(int), 1, fp); - fwrite(m_pTreeStart.data(), sizeof(int), m_iTreeNumber, fp); - int treeNodeSize = (int)m_pTreeRoots.size(); - fwrite(&treeNodeSize, sizeof(int), 1, fp); - fwrite(m_pTreeRoots.data(), sizeof(KDTNode), treeNodeSize, fp); - fclose(fp); - std::cout << "Save KDT (" << m_iTreeNumber << "," << treeNodeSize << ") Finish!" << std::endl; - return true; - } - - bool LoadTrees(char* pKDTMemFile) - { - m_iTreeNumber = *((int*)pKDTMemFile); - pKDTMemFile += sizeof(int); - m_pTreeStart.resize(m_iTreeNumber); - memcpy(m_pTreeStart.data(), pKDTMemFile, sizeof(int) * m_iTreeNumber); - pKDTMemFile += sizeof(int)*m_iTreeNumber; - - int treeNodeSize = *((int*)pKDTMemFile); - pKDTMemFile += sizeof(int); - m_pTreeRoots.resize(treeNodeSize); - memcpy(m_pTreeRoots.data(), pKDTMemFile, sizeof(KDTNode) * treeNodeSize); - return true; - } - - bool LoadTrees(std::string sTreeFileName) - { - std::cout << "Load KDT From " << sTreeFileName << std::endl; - FILE *fp = fopen(sTreeFileName.c_str(), "rb"); - if (fp == NULL) return false; - - fread(&m_iTreeNumber, sizeof(int), 1, fp); - m_pTreeStart.resize(m_iTreeNumber); - fread(m_pTreeStart.data(), sizeof(int), m_iTreeNumber, fp); - - int treeNodeSize; - fread(&treeNodeSize, sizeof(int), 1, fp); - m_pTreeRoots.resize(treeNodeSize); - fread(m_pTreeRoots.data(), sizeof(KDTNode), treeNodeSize, fp); - fclose(fp); - std::cout << "Load KDT (" << m_iTreeNumber << "," << treeNodeSize << ") Finish!" << std::endl; - return true; - } - - template - void InitSearchTrees(const VectorIndex* p_index, const COMMON::QueryResultSet &p_query, COMMON::WorkSpace &p_space, const int p_limits) const - { - for (char i = 0; i < m_iTreeNumber; i++) { - KDTSearch(p_index, p_query, p_space, m_pTreeStart[i], true, 0); - } - - while (!p_space.m_SPTQueue.empty() && p_space.m_iNumberOfCheckedLeaves < p_limits) - { - auto& tcell = p_space.m_SPTQueue.pop(); - if (p_query.worstDist() < tcell.distance) break; - KDTSearch(p_index, p_query, p_space, tcell.node, true, tcell.distance); - } - } - - template - void SearchTrees(const VectorIndex* p_index, const COMMON::QueryResultSet &p_query, COMMON::WorkSpace &p_space, const int p_limits) const - { - while (!p_space.m_SPTQueue.empty() && p_space.m_iNumberOfCheckedLeaves < p_limits) - { - auto& tcell = p_space.m_SPTQueue.pop(); - KDTSearch(p_index, p_query, p_space, tcell.node, false, tcell.distance); - } - } - - private: - - template - void KDTSearch(const VectorIndex* p_index, const COMMON::QueryResultSet &p_query, - COMMON::WorkSpace& p_space, const int node, const bool isInit, const float distBound) const { - if (node < 0) - { - int index = -node - 1; - if (index >= p_index->GetNumSamples()) return; -#ifdef PREFETCH - const char* data = (const char *)(p_index->GetSample(index)); - _mm_prefetch(data, _MM_HINT_T0); - _mm_prefetch(data + 64, _MM_HINT_T0); -#endif - if (p_space.CheckAndSet(index)) return; - - ++p_space.m_iNumberOfTreeCheckedLeaves; - ++p_space.m_iNumberOfCheckedLeaves; - p_space.m_NGQueue.insert(COMMON::HeapCell(index, p_index->ComputeDistance((const void*)p_query.GetTarget(), (const void*)data))); - return; - } - - auto& tnode = m_pTreeRoots[node]; - - float diff = (p_query.GetTarget())[tnode.split_dim] - tnode.split_value; - float distanceBound = distBound + diff * diff; - int otherChild, bestChild; - if (diff < 0) - { - bestChild = tnode.left; - otherChild = tnode.right; - } - else - { - otherChild = tnode.left; - bestChild = tnode.right; - } - - if (!isInit || distanceBound < p_query.worstDist()) - { - p_space.m_SPTQueue.insert(COMMON::HeapCell(otherChild, distanceBound)); - } - KDTSearch(p_index, p_query, p_space, bestChild, isInit, distBound); - } - - - template - void DivideTree(VectorIndex* p_index, std::vector& indices, int first, int last, - int index, int &iTreeSize) { - ChooseDivision(p_index, m_pTreeRoots[index], indices, first, last); - int i = Subdivide(p_index, m_pTreeRoots[index], indices, first, last); - if (i - 1 <= first) - { - m_pTreeRoots[index].left = -indices[first] - 1; - } - else - { - iTreeSize++; - m_pTreeRoots[index].left = iTreeSize; - DivideTree(p_index, indices, first, i - 1, iTreeSize, iTreeSize); - } - if (last == i) - { - m_pTreeRoots[index].right = -indices[last] - 1; - } - else - { - iTreeSize++; - m_pTreeRoots[index].right = iTreeSize; - DivideTree(p_index, indices, i, last, iTreeSize, iTreeSize); - } - } - - template - void ChooseDivision(VectorIndex* p_index, KDTNode& node, const std::vector& indices, const int first, const int last) - { - std::vector meanValues(p_index->GetFeatureDim(), 0); - std::vector varianceValues(p_index->GetFeatureDim(), 0); - int end = min(first + m_iSamples, last); - int count = end - first + 1; - // calculate the mean of each dimension - for (int j = first; j <= end; j++) - { - const T* v = (const T*)p_index->GetSample(indices[j]); - for (int k = 0; k < p_index->GetFeatureDim(); k++) - { - meanValues[k] += v[k]; - } - } - for (int k = 0; k < p_index->GetFeatureDim(); k++) - { - meanValues[k] /= count; - } - // calculate the variance of each dimension - for (int j = first; j <= end; j++) - { - const T* v = (const T*)p_index->GetSample(indices[j]); - for (int k = 0; k < p_index->GetFeatureDim(); k++) - { - float dist = v[k] - meanValues[k]; - varianceValues[k] += dist*dist; - } - } - // choose the split dimension as one of the dimension inside TOP_DIM maximum variance - node.split_dim = SelectDivisionDimension(varianceValues); - // determine the threshold - node.split_value = meanValues[node.split_dim]; - } - - int SelectDivisionDimension(const std::vector& varianceValues) const - { - // Record the top maximum variances - std::vector topind(m_numTopDimensionKDTSplit); - int num = 0; - // order the variances - for (int i = 0; i < varianceValues.size(); i++) - { - if (num < m_numTopDimensionKDTSplit || varianceValues[i] > varianceValues[topind[num - 1]]) - { - if (num < m_numTopDimensionKDTSplit) - { - topind[num++] = i; - } - else - { - topind[num - 1] = i; - } - int j = num - 1; - // order the TOP_DIM variances - while (j > 0 && varianceValues[topind[j]] > varianceValues[topind[j - 1]]) - { - std::swap(topind[j], topind[j - 1]); - j--; - } - } - } - // randomly choose a dimension from TOP_DIM - return topind[COMMON::Utils::rand_int(num)]; - } - - template - int Subdivide(VectorIndex* p_index, const KDTNode& node, std::vector& indices, const int first, const int last) const - { - int i = first; - int j = last; - // decide which child one point belongs - while (i <= j) - { - int ind = indices[i]; - const T* v = (const T*)p_index->GetSample(ind); - float val = v[node.split_dim]; - if (val < node.split_value) - { - i++; - } - else - { - std::swap(indices[i], indices[j]); - j--; - } - } - // if all the points in the node are equal,equally split the node into 2 - if ((i == first) || (i == last + 1)) - { - i = (first + last + 1) / 2; - } - return i; - } - - private: - std::vector m_pTreeStart; - std::vector m_pTreeRoots; - - public: - int m_iTreeNumber, m_numTopDimensionKDTSplit, m_iSamples; - }; - } -} -#endif diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/NeighborhoodGraph.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/NeighborhoodGraph.h deleted file mode 100644 index 02d2541754..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/NeighborhoodGraph.h +++ /dev/null @@ -1,436 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_COMMON_NG_H_ -#define _SPTAG_COMMON_NG_H_ - -#include "../VectorIndex.h" - -#include "CommonUtils.h" -#include "Dataset.h" -#include "FineGrainedLock.h" -#include "QueryResultSet.h" - -namespace SPTAG -{ - namespace COMMON - { - class NeighborhoodGraph - { - public: - NeighborhoodGraph(): m_iTPTNumber(32), - m_iTPTLeafSize(2000), - m_iSamples(1000), - m_numTopDimensionTPTSplit(5), - m_iNeighborhoodSize(32), - m_iNeighborhoodScale(2), - m_iCEFScale(2), - m_iRefineIter(0), - m_iCEF(1000), - m_iMaxCheckForRefineGraph(10000) {} - - ~NeighborhoodGraph() {} - - virtual void InsertNeighbors(VectorIndex* index, const int node, int insertNode, float insertDist) = 0; - - virtual void RebuildNeighbors(VectorIndex* index, const int node, int* nodes, const BasicResult* queryResults, const int numResults) = 0; - - virtual float GraphAccuracyEstimation(VectorIndex* index, const int samples, const std::unordered_map* idmap = nullptr) = 0; - - template - void BuildGraph(VectorIndex* index, const std::unordered_map* idmap = nullptr) - { - std::cout << "build RNG graph!" << std::endl; - - m_iGraphSize = index->GetNumSamples(); - m_iNeighborhoodSize = m_iNeighborhoodSize * m_iNeighborhoodScale; - m_pNeighborhoodGraph.Initialize(m_iGraphSize, m_iNeighborhoodSize); - m_dataUpdateLock.resize(m_iGraphSize); - - if (m_iGraphSize < 1000) { - RefineGraph(index, idmap); - std::cout << "Build RNG Graph end!" << std::endl; - return; - } - - { - COMMON::Dataset NeighborhoodDists(m_iGraphSize, m_iNeighborhoodSize); - std::vector> TptreeDataIndices(m_iTPTNumber, std::vector(m_iGraphSize)); - std::vector>> TptreeLeafNodes(m_iTPTNumber, std::vector>()); - - for (int i = 0; i < m_iGraphSize; i++) - for (int j = 0; j < m_iNeighborhoodSize; j++) - (NeighborhoodDists)[i][j] = MaxDist; - - std::cout << "Parallel TpTree Partition begin " << std::endl; -#pragma omp parallel for schedule(dynamic) - for (int i = 0; i < m_iTPTNumber; i++) - { - Sleep(i * 100); std::srand(clock()); - for (int j = 0; j < m_iGraphSize; j++) TptreeDataIndices[i][j] = j; - std::random_shuffle(TptreeDataIndices[i].begin(), TptreeDataIndices[i].end()); - PartitionByTptree(index, TptreeDataIndices[i], 0, m_iGraphSize - 1, TptreeLeafNodes[i]); - std::cout << "Finish Getting Leaves for Tree " << i << std::endl; - } - std::cout << "Parallel TpTree Partition done" << std::endl; - - for (int i = 0; i < m_iTPTNumber; i++) - { -#pragma omp parallel for schedule(dynamic) - for (int j = 0; j < TptreeLeafNodes[i].size(); j++) - { - int start_index = TptreeLeafNodes[i][j].first; - int end_index = TptreeLeafNodes[i][j].second; - if (omp_get_thread_num() == 0) std::cout << "\rProcessing Tree " << i << ' ' << j * 100 / TptreeLeafNodes[i].size() << '%'; - for (int x = start_index; x < end_index; x++) - { - for (int y = x + 1; y <= end_index; y++) - { - int p1 = TptreeDataIndices[i][x]; - int p2 = TptreeDataIndices[i][y]; - float dist = index->ComputeDistance(index->GetSample(p1), index->GetSample(p2)); - if (idmap != nullptr) { - p1 = (idmap->find(p1) == idmap->end()) ? p1 : idmap->at(p1); - p2 = (idmap->find(p2) == idmap->end()) ? p2 : idmap->at(p2); - } - COMMON::Utils::AddNeighbor(p2, dist, (m_pNeighborhoodGraph)[p1], (NeighborhoodDists)[p1], m_iNeighborhoodSize); - COMMON::Utils::AddNeighbor(p1, dist, (m_pNeighborhoodGraph)[p2], (NeighborhoodDists)[p2], m_iNeighborhoodSize); - } - } - } - TptreeDataIndices[i].clear(); - TptreeLeafNodes[i].clear(); - std::cout << std::endl; - } - TptreeDataIndices.clear(); - TptreeLeafNodes.clear(); - } - - if (m_iMaxCheckForRefineGraph > 0) { - RefineGraph(index, idmap); - } - } - - template - void RefineGraph(VectorIndex* index, const std::unordered_map* idmap = nullptr) - { - m_iCEF *= m_iCEFScale; - m_iMaxCheckForRefineGraph *= m_iCEFScale; - -#pragma omp parallel for schedule(dynamic) - for (int i = 0; i < m_iGraphSize; i++) - { - RefineNode(index, i, false); - if (i % 1000 == 0) std::cout << "\rRefine 1 " << (i * 100 / m_iGraphSize) << "%"; - } - std::cout << "Refine RNG, graph acc:" << GraphAccuracyEstimation(index, 100, idmap) << std::endl; - - m_iCEF /= m_iCEFScale; - m_iMaxCheckForRefineGraph /= m_iCEFScale; - m_iNeighborhoodSize /= m_iNeighborhoodScale; - -#pragma omp parallel for schedule(dynamic) - for (int i = 0; i < m_iGraphSize; i++) - { - RefineNode(index, i, false); - if (i % 1000 == 0) std::cout << "\rRefine 2 " << (i * 100 / m_iGraphSize) << "%"; - } - std::cout << "Refine RNG, graph acc:" << GraphAccuracyEstimation(index, 100, idmap) << std::endl; - - if (idmap != nullptr) { - for (auto iter = idmap->begin(); iter != idmap->end(); iter++) - if (iter->first < 0) - { - m_pNeighborhoodGraph[-1 - iter->first][m_iNeighborhoodSize - 1] = -2 - iter->second; - } - } - } - - template - ErrorCode RefineGraph(VectorIndex* index, std::vector& indices, std::vector& reverseIndices, - std::string graphFileName, const std::unordered_map* idmap = nullptr) - { - int R = (int)indices.size(); - -#pragma omp parallel for schedule(dynamic) - for (int i = 0; i < R; i++) - { - RefineNode(index, indices[i], false); - int* nodes = m_pNeighborhoodGraph[indices[i]]; - for (int j = 0; j < m_iNeighborhoodSize; j++) - { - if (nodes[j] < 0) nodes[j] = -1; - else nodes[j] = reverseIndices[nodes[j]]; - } - if (idmap == nullptr || idmap->find(-1 - indices[i]) == idmap->end()) continue; - nodes[m_iNeighborhoodSize - 1] = -2 - idmap->at(-1 - indices[i]); - } - - std::ofstream graphOut(graphFileName, std::ios::binary); - if (!graphOut.is_open()) return ErrorCode::FailedCreateFile; - graphOut.write((char*)&R, sizeof(int)); - graphOut.write((char*)&m_iNeighborhoodSize, sizeof(int)); - for (int i = 0; i < R; i++) { - graphOut.write((char*)m_pNeighborhoodGraph[indices[i]], sizeof(int) * m_iNeighborhoodSize); - } - graphOut.close(); - return ErrorCode::Success; - } - - - template - void RefineNode(VectorIndex* index, const int node, bool updateNeighbors) - { - COMMON::QueryResultSet query((const T*)index->GetSample(node), m_iCEF + 1); - index->SearchIndex(query); - RebuildNeighbors(index, node, m_pNeighborhoodGraph[node], query.GetResults(), m_iCEF + 1); - - if (updateNeighbors) { - // update neighbors - for (int j = 0; j <= m_iCEF; j++) - { - BasicResult* item = query.GetResult(j); - if (item->VID < 0) break; - if (item->VID == node) continue; - - std::lock_guard lock(m_dataUpdateLock[item->VID]); - InsertNeighbors(index, item->VID, node, item->Dist); - } - } - } - - template - void PartitionByTptree(VectorIndex* index, std::vector& indices, const int first, const int last, - std::vector> & leaves) - { - if (last - first <= m_iTPTLeafSize) - { - leaves.push_back(std::make_pair(first, last)); - } - else - { - std::vector Mean(index->GetFeatureDim(), 0); - - int iIteration = 100; - int end = min(first + m_iSamples, last); - int count = end - first + 1; - // calculate the mean of each dimension - for (int j = first; j <= end; j++) - { - const T* v = (const T*)index->GetSample(indices[j]); - for (int k = 0; k < index->GetFeatureDim(); k++) - { - Mean[k] += v[k]; - } - } - for (int k = 0; k < index->GetFeatureDim(); k++) - { - Mean[k] /= count; - } - std::vector Variance; - Variance.reserve(index->GetFeatureDim()); - for (int j = 0; j < index->GetFeatureDim(); j++) - { - Variance.push_back(BasicResult(j, 0)); - } - // calculate the variance of each dimension - for (int j = first; j <= end; j++) - { - const T* v = (const T*)index->GetSample(indices[j]); - for (int k = 0; k < index->GetFeatureDim(); k++) - { - float dist = v[k] - Mean[k]; - Variance[k].Dist += dist*dist; - } - } - std::sort(Variance.begin(), Variance.end(), COMMON::Compare); - std::vector indexs(m_numTopDimensionTPTSplit); - std::vector weight(m_numTopDimensionTPTSplit), bestweight(m_numTopDimensionTPTSplit); - float bestvariance = Variance[index->GetFeatureDim() - 1].Dist; - for (int i = 0; i < m_numTopDimensionTPTSplit; i++) - { - indexs[i] = Variance[index->GetFeatureDim() - 1 - i].VID; - bestweight[i] = 0; - } - bestweight[0] = 1; - float bestmean = Mean[indexs[0]]; - - std::vector Val(count); - for (int i = 0; i < iIteration; i++) - { - float sumweight = 0; - for (int j = 0; j < m_numTopDimensionTPTSplit; j++) - { - weight[j] = float(rand() % 10000) / 5000.0f - 1.0f; - sumweight += weight[j] * weight[j]; - } - sumweight = sqrt(sumweight); - for (int j = 0; j < m_numTopDimensionTPTSplit; j++) - { - weight[j] /= sumweight; - } - float mean = 0; - for (int j = 0; j < count; j++) - { - Val[j] = 0; - const T* v = (const T*)index->GetSample(indices[first + j]); - for (int k = 0; k < m_numTopDimensionTPTSplit; k++) - { - Val[j] += weight[k] * v[indexs[k]]; - } - mean += Val[j]; - } - mean /= count; - float var = 0; - for (int j = 0; j < count; j++) - { - float dist = Val[j] - mean; - var += dist * dist; - } - if (var > bestvariance) - { - bestvariance = var; - bestmean = mean; - for (int j = 0; j < m_numTopDimensionTPTSplit; j++) - { - bestweight[j] = weight[j]; - } - } - } - int i = first; - int j = last; - // decide which child one point belongs - while (i <= j) - { - float val = 0; - const T* v = (const T*)index->GetSample(indices[i]); - for (int k = 0; k < m_numTopDimensionTPTSplit; k++) - { - val += bestweight[k] * v[indexs[k]]; - } - if (val < bestmean) - { - i++; - } - else - { - std::swap(indices[i], indices[j]); - j--; - } - } - // if all the points in the node are equal,equally split the node into 2 - if ((i == first) || (i == last + 1)) - { - i = (first + last + 1) / 2; - } - - Mean.clear(); - Variance.clear(); - Val.clear(); - indexs.clear(); - weight.clear(); - bestweight.clear(); - - PartitionByTptree(index, indices, first, i - 1, leaves); - PartitionByTptree(index, indices, i, last, leaves); - } - } - - bool LoadGraph(std::string sGraphFilename) - { - std::cout << "Load Graph From " << sGraphFilename << std::endl; - FILE * fp = fopen(sGraphFilename.c_str(), "rb"); - if (fp == NULL) return false; - - fread(&m_iGraphSize, sizeof(int), 1, fp); - fread(&m_iNeighborhoodSize, sizeof(int), 1, fp); - m_pNeighborhoodGraph.Initialize(m_iGraphSize, m_iNeighborhoodSize); - m_dataUpdateLock.resize(m_iGraphSize); - - for (int i = 0; i < m_iGraphSize; i++) - { - fread((m_pNeighborhoodGraph)[i], sizeof(int), m_iNeighborhoodSize, fp); - } - fclose(fp); - std::cout << "Load Graph (" << m_iGraphSize << "," << m_iNeighborhoodSize << ") Finish!" << std::endl; - return true; - } - - bool LoadGraphFromMemory(char* pGraphMemFile) - { - m_iGraphSize = *((int*)pGraphMemFile); - pGraphMemFile += sizeof(int); - - m_iNeighborhoodSize = *((int*)pGraphMemFile); - pGraphMemFile += sizeof(int); - - m_pNeighborhoodGraph.Initialize(m_iGraphSize, m_iNeighborhoodSize, (int*)pGraphMemFile); - m_dataUpdateLock.resize(m_iGraphSize); - return true; - } - - bool SaveGraph(std::string sGraphFilename) const - { - std::cout << "Save Graph To " << sGraphFilename << std::endl; - FILE *fp = fopen(sGraphFilename.c_str(), "wb"); - if (fp == NULL) return false; - - fwrite(&m_iGraphSize, sizeof(int), 1, fp); - fwrite(&m_iNeighborhoodSize, sizeof(int), 1, fp); - for (int i = 0; i < m_iGraphSize; i++) - { - fwrite((m_pNeighborhoodGraph)[i], sizeof(int), m_iNeighborhoodSize, fp); - } - fclose(fp); - std::cout << "Save Graph (" << m_iGraphSize << "," << m_iNeighborhoodSize << ") Finish!" << std::endl; - return true; - } - - bool SaveGraphToMemory(void **pGraphMemFile, int64_t &len) { - size_t size = sizeof(int) + sizeof(int) + sizeof(int) * m_iNeighborhoodSize * m_iGraphSize; - char *mem = (char*)malloc(size); - if (mem == NULL) return false; - - auto ptr = mem; - *(int*)ptr = m_iGraphSize; - ptr += sizeof(int); - - *(int*)ptr = m_iNeighborhoodSize; - ptr += sizeof(int); - - for (int i = 0; i < m_iGraphSize; i++) - { - memcpy(ptr, (m_pNeighborhoodGraph)[i], sizeof(int) * m_iNeighborhoodSize); - ptr += sizeof(int) * m_iNeighborhoodSize; - } - *pGraphMemFile = mem; - len = size; - - return true; - } - - inline void AddBatch(int num) { m_pNeighborhoodGraph.AddBatch(num); m_iGraphSize += num; m_dataUpdateLock.resize(m_iGraphSize); } - - inline int* operator[](int index) { return m_pNeighborhoodGraph[index]; } - - inline const int* operator[](int index) const { return m_pNeighborhoodGraph[index]; } - - inline void SetR(int rows) { m_pNeighborhoodGraph.SetR(rows); m_iGraphSize = rows; m_dataUpdateLock.resize(m_iGraphSize); } - - inline int R() const { return m_iGraphSize; } - - static std::shared_ptr CreateInstance(std::string type); - - protected: - // Graph structure - int m_iGraphSize; - COMMON::Dataset m_pNeighborhoodGraph; - COMMON::FineGrainedLock m_dataUpdateLock; // protect one row of the graph - - public: - int m_iTPTNumber, m_iTPTLeafSize, m_iSamples, m_numTopDimensionTPTSplit; - int m_iNeighborhoodSize, m_iNeighborhoodScale, m_iCEFScale, m_iRefineIter, m_iCEF, m_iMaxCheckForRefineGraph; - }; - } -} -#endif diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/QueryResultSet.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/QueryResultSet.h deleted file mode 100644 index 1e66287892..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/QueryResultSet.h +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_COMMON_QUERYRESULTSET_H_ -#define _SPTAG_COMMON_QUERYRESULTSET_H_ - -#include "../SearchQuery.h" - -namespace SPTAG -{ -namespace COMMON -{ - -inline bool operator < (const BasicResult& lhs, const BasicResult& rhs) -{ - return ((lhs.Dist < rhs.Dist) || ((lhs.Dist == rhs.Dist) && (lhs.VID < rhs.VID))); -} - - -inline bool Compare(const BasicResult& lhs, const BasicResult& rhs) -{ - return ((lhs.Dist < rhs.Dist) || ((lhs.Dist == rhs.Dist) && (lhs.VID < rhs.VID))); -} - - -// Space to save temporary answer, similar with TopKCache -template -class QueryResultSet : public QueryResult -{ -public: - QueryResultSet(const T* _target, int _K) : QueryResult(_target, _K, false) - { - } - - QueryResultSet(const QueryResultSet& other) : QueryResult(other) - { - } - - inline void SetTarget(const T *p_target) - { - m_target = p_target; - } - - inline const T* GetTarget() const - { - return reinterpret_cast(m_target); - } - - inline float worstDist() const - { - return m_results[0].Dist; - } - - bool AddPoint(const int index, float dist) - { - if (dist < m_results[0].Dist || (dist == m_results[0].Dist && index < m_results[0].VID)) - { - m_results[0].VID = index; - m_results[0].Dist = dist; - Heapify(m_resultNum); - return true; - } - return false; - } - - inline void SortResult() - { - for (int i = m_resultNum - 1; i >= 0; i--) - { - std::swap(m_results[0], m_results[i]); - Heapify(i); - } - } - -private: - void Heapify(int count) - { - int parent = 0, next = 1, maxidx = count - 1; - while (next < maxidx) - { - if (m_results[next] < m_results[next + 1]) next++; - if (m_results[parent] < m_results[next]) - { - std::swap(m_results[next], m_results[parent]); - parent = next; - next = (parent << 1) + 1; - } - else break; - } - if (next == maxidx && m_results[parent] < m_results[next]) std::swap(m_results[parent], m_results[next]); - } -}; -} -} - -#endif // _SPTAG_COMMON_QUERYRESULTSET_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/RelativeNeighborhoodGraph.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/RelativeNeighborhoodGraph.h deleted file mode 100644 index 4992508644..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/RelativeNeighborhoodGraph.h +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_COMMON_RNG_H_ -#define _SPTAG_COMMON_RNG_H_ - -#include "NeighborhoodGraph.h" - -namespace SPTAG -{ - namespace COMMON - { - class RelativeNeighborhoodGraph: public NeighborhoodGraph - { - public: - void RebuildNeighbors(VectorIndex* index, const int node, int* nodes, const BasicResult* queryResults, const int numResults) { - int count = 0; - for (int j = 0; j < numResults && count < m_iNeighborhoodSize; j++) { - const BasicResult& item = queryResults[j]; - if (item.VID < 0) break; - if (item.VID == node) continue; - - bool good = true; - for (int k = 0; k < count; k++) { - if (index->ComputeDistance(index->GetSample(nodes[k]), index->GetSample(item.VID)) <= item.Dist) { - good = false; - break; - } - } - if (good) nodes[count++] = item.VID; - } - for (int j = count; j < m_iNeighborhoodSize; j++) nodes[j] = -1; - } - - void InsertNeighbors(VectorIndex* index, const int node, int insertNode, float insertDist) - { - int* nodes = m_pNeighborhoodGraph[node]; - for (int k = 0; k < m_iNeighborhoodSize; k++) - { - int tmpNode = nodes[k]; - if (tmpNode < -1) continue; - - if (tmpNode < 0) - { - bool good = true; - for (int t = 0; t < k; t++) { - if (index->ComputeDistance(index->GetSample(insertNode), index->GetSample(nodes[t])) < insertDist) { - good = false; - break; - } - } - if (good) { - nodes[k] = insertNode; - } - break; - } - float tmpDist = index->ComputeDistance(index->GetSample(node), index->GetSample(tmpNode)); - if (insertDist < tmpDist || (insertDist == tmpDist && insertNode < tmpNode)) - { - bool good = true; - for (int t = 0; t < k; t++) { - if (index->ComputeDistance(index->GetSample(insertNode), index->GetSample(nodes[t])) < insertDist) { - good = false; - break; - } - } - if (good) { - nodes[k] = insertNode; - insertNode = tmpNode; - insertDist = tmpDist; - } - else { - break; - } - } - } - } - - float GraphAccuracyEstimation(VectorIndex* index, const int samples, const std::unordered_map* idmap = nullptr) - { - int* correct = new int[samples]; - -#pragma omp parallel for schedule(dynamic) - for (int i = 0; i < samples; i++) - { - int x = COMMON::Utils::rand_int(m_iGraphSize); - //int x = i; - COMMON::QueryResultSet query(nullptr, m_iCEF); - for (int y = 0; y < m_iGraphSize; y++) - { - if ((idmap != nullptr && idmap->find(y) != idmap->end())) continue; - float dist = index->ComputeDistance(index->GetSample(x), index->GetSample(y)); - query.AddPoint(y, dist); - } - query.SortResult(); - int * exact_rng = new int[m_iNeighborhoodSize]; - RebuildNeighbors(index, x, exact_rng, query.GetResults(), m_iCEF); - - correct[i] = 0; - for (int j = 0; j < m_iNeighborhoodSize; j++) { - if (exact_rng[j] == -1) { - correct[i] += m_iNeighborhoodSize - j; - break; - } - for (int k = 0; k < m_iNeighborhoodSize; k++) - if ((m_pNeighborhoodGraph)[x][k] == exact_rng[j]) { - correct[i]++; - break; - } - } - delete[] exact_rng; - } - float acc = 0; - for (int i = 0; i < samples; i++) acc += float(correct[i]); - acc = acc / samples / m_iNeighborhoodSize; - delete[] correct; - return acc; - } - - }; - } -} -#endif \ No newline at end of file diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/WorkSpace.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/WorkSpace.h deleted file mode 100644 index 74d0a5039b..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/WorkSpace.h +++ /dev/null @@ -1,185 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_COMMON_WORKSPACE_H_ -#define _SPTAG_COMMON_WORKSPACE_H_ - -#include "CommonUtils.h" -#include "Heap.h" - -namespace SPTAG -{ - namespace COMMON - { - // node type in the priority queue - struct HeapCell - { - int node; - float distance; - - HeapCell(int _node = -1, float _distance = MaxDist) : node(_node), distance(_distance) {} - - inline bool operator < (const HeapCell& rhs) - { - return distance < rhs.distance; - } - - inline bool operator > (const HeapCell& rhs) - { - return distance > rhs.distance; - } - }; - - class OptHashPosVector - { - protected: - // Max loop number in one hash block. - static const int m_maxLoop = 8; - - // Max pool size. - static const int m_poolSize = 8191; - - // Could we use the second hash block. - bool m_secondHash; - - // Record 2 hash tables. - // [0~m_poolSize + 1) is the first block. - // [m_poolSize + 1, 2*(m_poolSize + 1)) is the second block; - int m_hashTable[(m_poolSize + 1) * 2]; - - - inline unsigned hash_func2(int idx, int loop) - { - return ((unsigned)idx + loop) & m_poolSize; - } - - - inline unsigned hash_func(unsigned idx) - { - return ((unsigned)(idx * 99991) + _rotl(idx, 2) + 101) & m_poolSize; - } - - public: - OptHashPosVector() {} - - ~OptHashPosVector() {} - - - void Init(int size) - { - m_secondHash = true; - clear(); - } - - void clear() - { - if (!m_secondHash) - { - // Clear first block. - memset(&m_hashTable[0], 0, sizeof(int)*(m_poolSize + 1)); - } - else - { - // Clear all blocks. - memset(&m_hashTable[0], 0, 2 * sizeof(int) * (m_poolSize + 1)); - m_secondHash = false; - } - } - - - inline bool CheckAndSet(int idx) - { - // Inner Index is begin from 1 - return _CheckAndSet(&m_hashTable[0], idx + 1) == 0; - } - - - inline int _CheckAndSet(int* hashTable, int idx) - { - unsigned index, loop; - - // Get first hash position. - index = hash_func(idx); - for (loop = 0; loop < m_maxLoop; ++loop) - { - if (!hashTable[index]) - { - // index first match and record it. - hashTable[index] = idx; - return 1; - } - if (hashTable[index] == idx) - { - // Hit this item in hash table. - return 0; - } - // Get next hash position. - index = hash_func2(index, loop); - } - - if (hashTable == &m_hashTable[0]) - { - // Use second hash block. - m_secondHash = true; - return _CheckAndSet(&m_hashTable[m_poolSize + 1], idx); - } - - // Do not include this item. - return -1; - } - }; - - // Variables for each single NN search - struct WorkSpace - { - void Initialize(int maxCheck, int dataSize) - { - nodeCheckStatus.Init(dataSize); - m_SPTQueue.Resize(maxCheck * 10); - m_NGQueue.Resize(maxCheck * 30); - - m_iNumberOfTreeCheckedLeaves = 0; - m_iNumberOfCheckedLeaves = 0; - m_iContinuousLimit = maxCheck / 64; - m_iMaxCheck = maxCheck; - m_iNumOfContinuousNoBetterPropagation = 0; - } - - void Reset(int maxCheck) - { - nodeCheckStatus.clear(); - m_SPTQueue.clear(); - m_NGQueue.clear(); - - m_iNumberOfTreeCheckedLeaves = 0; - m_iNumberOfCheckedLeaves = 0; - m_iContinuousLimit = maxCheck / 64; - m_iMaxCheck = maxCheck; - m_iNumOfContinuousNoBetterPropagation = 0; - } - - inline bool CheckAndSet(int idx) - { - return nodeCheckStatus.CheckAndSet(idx); - } - - OptHashPosVector nodeCheckStatus; - //OptHashPosVector nodeCheckStatus; - - // counter for dynamic pivoting - int m_iNumOfContinuousNoBetterPropagation; - int m_iContinuousLimit; - int m_iNumberOfTreeCheckedLeaves; - int m_iNumberOfCheckedLeaves; - int m_iMaxCheck; - - // Prioriy queue used for neighborhood graph - Heap m_NGQueue; - - // Priority queue Used for BKT-Tree - Heap m_SPTQueue; - }; - } -} - -#endif // _SPTAG_COMMON_WORKSPACE_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/WorkSpacePool.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/WorkSpacePool.h deleted file mode 100644 index 9a7154e693..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/Common/WorkSpacePool.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_COMMON_WORKSPACEPOOL_H_ -#define _SPTAG_COMMON_WORKSPACEPOOL_H_ - -#include "WorkSpace.h" - -#include -#include - -namespace SPTAG -{ -namespace COMMON -{ - -class WorkSpacePool -{ -public: - WorkSpacePool(int p_maxCheck, int p_vectorCount); - - virtual ~WorkSpacePool(); - - std::shared_ptr Rent(); - - void Return(const std::shared_ptr& p_workSpace); - - void Init(int size); - -private: - std::list> m_workSpacePool; - - std::mutex m_workSpacePoolMutex; - - int m_maxCheck; - - int m_vectorCount; -}; - -} -} - -#endif // _SPTAG_COMMON_WORKSPACEPOOL_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/CommonDataStructure.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/CommonDataStructure.h deleted file mode 100644 index 74d7980f4b..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/CommonDataStructure.h +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_COMMONDATASTRUCTURE_H_ -#define _SPTAG_COMMONDATASTRUCTURE_H_ - -#include "Common.h" - -namespace SPTAG -{ - -class ByteArray -{ -public: - ByteArray(); - - ByteArray(ByteArray&& p_right); - - ByteArray(std::uint8_t* p_array, std::size_t p_length, bool p_transferOnwership); - - ByteArray(std::uint8_t* p_array, std::size_t p_length, std::shared_ptr p_dataHolder); - - ByteArray(const ByteArray& p_right); - - ByteArray& operator= (const ByteArray& p_right); - - ByteArray& operator= (ByteArray&& p_right); - - ~ByteArray(); - - static ByteArray Alloc(std::size_t p_length); - - std::uint8_t* Data() const; - - std::size_t Length() const; - - void SetData(std::uint8_t* p_array, std::size_t p_length); - - std::shared_ptr DataHolder() const; - - void Clear(); - - const static ByteArray c_empty; - -private: - std::uint8_t* m_data; - - std::size_t m_length; - - // Notice this is holding an array. Set correct deleter for this. - std::shared_ptr m_dataHolder; -}; - -} // namespace SPTAG - -#endif // _SPTAG_COMMONDATASTRUCTURE_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/DefinitionList.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/DefinitionList.h deleted file mode 100644 index f5b66422d7..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/DefinitionList.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifdef DefineVectorValueType - -DefineVectorValueType(Int8, std::int8_t) -DefineVectorValueType(UInt8, std::uint8_t) -DefineVectorValueType(Int16, std::int16_t) -DefineVectorValueType(Float, float) - -#endif // DefineVectorValueType - - -#ifdef DefineDistCalcMethod - -DefineDistCalcMethod(L2) -DefineDistCalcMethod(Cosine) - -#endif // DefineDistCalcMethod - - -#ifdef DefineErrorCode - -// 0x0000 ~ 0x0FFF General Status -DefineErrorCode(Success, 0x0000) -DefineErrorCode(Fail, 0x0001) -DefineErrorCode(FailedOpenFile, 0x0002) -DefineErrorCode(FailedCreateFile, 0x0003) -DefineErrorCode(ParamNotFound, 0x0010) -DefineErrorCode(FailedParseValue, 0x0011) - -// 0x1000 ~ 0x1FFF Index Build Status - -// 0x2000 ~ 0x2FFF Index Serve Status - -// 0x3000 ~ 0x3FFF Helper Function Status -DefineErrorCode(ReadIni_FailedParseSection, 0x3000) -DefineErrorCode(ReadIni_FailedParseParam, 0x3001) -DefineErrorCode(ReadIni_DuplicatedSection, 0x3002) -DefineErrorCode(ReadIni_DuplicatedParam, 0x3003) - - -// 0x4000 ~ 0x4FFF Socket Library Status -DefineErrorCode(Socket_FailedResolveEndPoint, 0x4000) -DefineErrorCode(Socket_FailedConnectToEndPoint, 0x4001) - - -#endif // DefineErrorCode - - - -#ifdef DefineIndexAlgo - -DefineIndexAlgo(BKT) -DefineIndexAlgo(KDT) - -#endif // DefineIndexAlgo diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/KDT/Index.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/KDT/Index.h deleted file mode 100644 index 7ab4b8daec..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/KDT/Index.h +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_KDT_INDEX_H_ -#define _SPTAG_KDT_INDEX_H_ - -#include "../Common.h" -#include "../VectorIndex.h" - -#include "../Common/CommonUtils.h" -#include "../Common/DistanceUtils.h" -#include "../Common/QueryResultSet.h" -#include "../Common/Dataset.h" -#include "../Common/WorkSpace.h" -#include "../Common/WorkSpacePool.h" -#include "../Common/RelativeNeighborhoodGraph.h" -#include "../Common/KDTree.h" -#include "inc/Helper/StringConvert.h" -#include "inc/Helper/SimpleIniReader.h" - -#include -#include -#include - -namespace SPTAG -{ - - namespace Helper - { - class IniReader; - } - - namespace KDT - { - template - class Index : public VectorIndex - { - private: - // data points - COMMON::Dataset m_pSamples; - - // KDT structures. - COMMON::KDTree m_pTrees; - - // Graph structure - COMMON::RelativeNeighborhoodGraph m_pGraph; - - std::string m_sKDTFilename; - std::string m_sGraphFilename; - std::string m_sDataPointsFilename; - - std::mutex m_dataLock; // protect data and graph - tbb::concurrent_unordered_set m_deletedID; - std::unique_ptr m_workSpacePool; - - int m_iNumberOfThreads; - DistCalcMethod m_iDistCalcMethod; - float(*m_fComputeDistance)(const T* pX, const T* pY, int length); - - int m_iMaxCheck; - int m_iThresholdOfNumberOfContinuousNoBetterPropagation; - int m_iNumberOfInitialDynamicPivots; - int m_iNumberOfOtherDynamicPivots; - public: - Index() - { -#define DefineKDTParameter(VarName, VarType, DefaultValue, RepresentStr) \ - VarName = DefaultValue; \ - -#include "inc/Core/KDT/ParameterDefinitionList.h" -#undef DefineKDTParameter - - m_fComputeDistance = COMMON::DistanceCalcSelector(m_iDistCalcMethod); - } - - ~Index() {} - - inline int GetNumSamples() const { return m_pSamples.R(); } - inline int GetFeatureDim() const { return m_pSamples.C(); } - - inline int GetCurrMaxCheck() const { return m_iMaxCheck; } - inline int GetNumThreads() const { return m_iNumberOfThreads; } - inline DistCalcMethod GetDistCalcMethod() const { return m_iDistCalcMethod; } - inline IndexAlgoType GetIndexAlgoType() const { return IndexAlgoType::KDT; } - inline VectorValueType GetVectorValueType() const { return GetEnumValueType(); } - - inline float ComputeDistance(const void* pX, const void* pY) const { return m_fComputeDistance((const T*)pX, (const T*)pY, m_pSamples.C()); } - inline const void* GetSample(const int idx) const { return (void*)m_pSamples[idx]; } - - ErrorCode BuildIndex(const void* p_data, int p_vectorNum, int p_dimension); - - ErrorCode SaveIndexToMemory(std::vector& p_indexBlobs, std::vector& p_indexBlobsLen); - ErrorCode LoadIndexFromMemory(const std::vector& p_indexBlobs); - - ErrorCode SaveIndex(const std::string& p_folderPath, std::ofstream& p_configout); - ErrorCode LoadIndex(const std::string& p_folderPath, Helper::IniReader& p_reader); - ErrorCode SearchIndex(QueryResult &p_query) const; - ErrorCode AddIndex(const void* p_vectors, int p_vectorNum, int p_dimension); - ErrorCode DeleteIndex(const void* p_vectors, int p_vectorNum); - - ErrorCode SetParameter(const char* p_param, const char* p_value); - std::string GetParameter(const char* p_param) const; - - private: - ErrorCode RefineIndex(const std::string& p_folderPath); - void SearchIndexWithDeleted(COMMON::QueryResultSet &p_query, COMMON::WorkSpace &p_space, const tbb::concurrent_unordered_set &p_deleted) const; - void SearchIndexWithoutDeleted(COMMON::QueryResultSet &p_query, COMMON::WorkSpace &p_space) const; - }; - } // namespace KDT -} // namespace SPTAG - -#endif // _SPTAG_KDT_INDEX_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/KDT/ParameterDefinitionList.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/KDT/ParameterDefinitionList.h deleted file mode 100644 index 70d70ccbe7..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/KDT/ParameterDefinitionList.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifdef DefineKDTParameter - -// DefineKDTParameter(VarName, VarType, DefaultValue, RepresentStr) -DefineKDTParameter(m_sKDTFilename, std::string, std::string("tree.bin"), "TreeFilePath") -DefineKDTParameter(m_sGraphFilename, std::string, std::string("graph.bin"), "GraphFilePath") -DefineKDTParameter(m_sDataPointsFilename, std::string, std::string("vectors.bin"), "VectorFilePath") - -DefineKDTParameter(m_pTrees.m_iTreeNumber, int, 1L, "KDTNumber") -DefineKDTParameter(m_pTrees.m_numTopDimensionKDTSplit, int, 5L, "NumTopDimensionKDTSplit") -DefineKDTParameter(m_pTrees.m_iSamples, int, 100L, "NumSamplesKDTSplitConsideration") - -DefineKDTParameter(m_pGraph.m_iTPTNumber, int, 32L, "TPTNumber") -DefineKDTParameter(m_pGraph.m_iTPTLeafSize, int, 2000L, "TPTLeafSize") -DefineKDTParameter(m_pGraph.m_numTopDimensionTPTSplit, int, 5L, "NumTopDimensionTPTSplit") - -DefineKDTParameter(m_pGraph.m_iNeighborhoodSize, int, 32L, "NeighborhoodSize") -DefineKDTParameter(m_pGraph.m_iNeighborhoodScale, int, 2L, "GraphNeighborhoodScale") -DefineKDTParameter(m_pGraph.m_iCEFScale, int, 2L, "GraphCEFScale") -DefineKDTParameter(m_pGraph.m_iRefineIter, int, 0L, "RefineIterations") -DefineKDTParameter(m_pGraph.m_iCEF, int, 1000L, "CEF") -DefineKDTParameter(m_pGraph.m_iMaxCheckForRefineGraph, int, 10000L, "MaxCheckForRefineGraph") - -DefineKDTParameter(m_iNumberOfThreads, int, 1L, "NumberOfThreads") -DefineKDTParameter(m_iDistCalcMethod, SPTAG::DistCalcMethod, SPTAG::DistCalcMethod::Cosine, "DistCalcMethod") - -DefineKDTParameter(m_iMaxCheck, int, 8192L, "MaxCheck") -DefineKDTParameter(m_iThresholdOfNumberOfContinuousNoBetterPropagation, int, 3L, "ThresholdOfNumberOfContinuousNoBetterPropagation") -DefineKDTParameter(m_iNumberOfInitialDynamicPivots, int, 50L, "NumberOfInitialDynamicPivots") -DefineKDTParameter(m_iNumberOfOtherDynamicPivots, int, 4L, "NumberOfOtherDynamicPivots") - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/MetadataSet.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/MetadataSet.h deleted file mode 100644 index 7b7baed50d..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/MetadataSet.h +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_METADATASET_H_ -#define _SPTAG_METADATASET_H_ - -#include "CommonDataStructure.h" - -#include -#include - -namespace SPTAG -{ - -class MetadataSet -{ -public: - MetadataSet(); - - virtual ~MetadataSet(); - - virtual ByteArray GetMetadata(IndexType p_vectorID) const = 0; - - virtual SizeType Count() const = 0; - - virtual bool Available() const = 0; - - virtual void AddBatch(MetadataSet& data) = 0; - - virtual ErrorCode SaveMetadata(const std::string& p_metaFile, const std::string& p_metaindexFile) = 0; - - virtual ErrorCode SaveMetadataToMemory(void **pGraphMemFile, int64_t &len) = 0; - - virtual ErrorCode LoadMetadataFromMemory(void *pGraphMemFile) = 0; - - virtual ErrorCode RefineMetadata(std::vector& indices, const std::string& p_folderPath); - - static ErrorCode MetaCopy(const std::string& p_src, const std::string& p_dst); -}; - - -class FileMetadataSet : public MetadataSet -{ -public: - FileMetadataSet(const std::string& p_metaFile, const std::string& p_metaindexFile); - - ~FileMetadataSet(); - - ByteArray GetMetadata(IndexType p_vectorID) const; - - SizeType Count() const; - - bool Available() const; - - void AddBatch(MetadataSet& data); - - ErrorCode SaveMetadata(const std::string& p_metaFile, const std::string& p_metaindexFile); - - ErrorCode SaveMetadataToMemory(void **pGraphMemFile, int64_t &len); - - ErrorCode LoadMetadataFromMemory(void *pGraphMemFile); -private: - std::ifstream* m_fp = nullptr; - - std::vector m_pOffsets; - - SizeType m_count; - - std::string m_metaFile; - - std::string m_metaindexFile; - - std::vector m_newdata; -}; - - -class MemMetadataSet : public MetadataSet -{ -public: - MemMetadataSet() = default; - - MemMetadataSet(ByteArray p_metadata, ByteArray p_offsets, SizeType p_count); - - ~MemMetadataSet(); - - ByteArray GetMetadata(IndexType p_vectorID) const; - - SizeType Count() const; - - bool Available() const; - - void AddBatch(MetadataSet& data); - - ErrorCode SaveMetadata(const std::string& p_metaFile, const std::string& p_metaindexFile); - - ErrorCode SaveMetadataToMemory(void **pGraphMemFile, int64_t &len); - - ErrorCode LoadMetadataFromMemory(void *pGraphMemFile); -private: - std::vector m_offsets; - - SizeType m_count; - - ByteArray m_metadataHolder; - - ByteArray m_offsetHolder; - - std::vector m_newdata; -}; - - -} // namespace SPTAG - -#endif // _SPTAG_METADATASET_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/SearchQuery.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/SearchQuery.h deleted file mode 100644 index ede82cc938..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/SearchQuery.h +++ /dev/null @@ -1,239 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_SEARCHQUERY_H_ -#define _SPTAG_SEARCHQUERY_H_ - -#include "CommonDataStructure.h" - -#include - -namespace SPTAG -{ - - struct BasicResult - { - int VID; - float Dist; - - BasicResult() : VID(-1), Dist(MaxDist) {} - - BasicResult(int p_vid, float p_dist) : VID(p_vid), Dist(p_dist) {} - }; - - -// Space to save temporary answer, similar with TopKCache -class QueryResult -{ -public: - typedef BasicResult* iterator; - typedef const BasicResult* const_iterator; - - QueryResult() - : m_target(nullptr), - m_resultNum(0), - m_withMeta(false) - { - } - - - QueryResult(const void* p_target, int p_resultNum, bool p_withMeta) - : m_target(nullptr), - m_resultNum(0), - m_withMeta(false) - { - Init(p_target, p_resultNum, p_withMeta); - } - - - QueryResult(const void* p_target, int p_resultNum, std::vector& p_results) - : m_target(p_target), - m_resultNum(p_resultNum), - m_withMeta(false) - { - p_results.resize(p_resultNum); - m_results.reset(p_results.data()); - } - - - QueryResult(const QueryResult& p_other) - : m_target(p_other.m_target), - m_resultNum(p_other.m_resultNum), - m_withMeta(p_other.m_withMeta) - { - if (m_resultNum > 0) - { - m_results.reset(new BasicResult[m_resultNum]); - std::memcpy(m_results.get(), p_other.m_results.get(), sizeof(BasicResult) * m_resultNum); - - if (m_withMeta) - { - m_metadatas.reset(new ByteArray[m_resultNum]); - std::copy(p_other.m_metadatas.get(), p_other.m_metadatas.get() + m_resultNum, m_metadatas.get()); - } - } - } - - - QueryResult& operator=(const QueryResult& p_other) - { - Init(p_other.m_target, p_other.m_resultNum, p_other.m_withMeta); - - if (m_resultNum > 0) - { - std::memcpy(m_results.get(), p_other.m_results.get(), sizeof(BasicResult) * m_resultNum); - if (m_withMeta) - { - std::copy(p_other.m_metadatas.get(), p_other.m_metadatas.get() + m_resultNum, m_metadatas.get()); - } - } - - return *this; - } - - - ~QueryResult() - { - } - - - inline void Init(const void* p_target, int p_resultNum, bool p_withMeta) - { - m_target = p_target; - if (p_resultNum > m_resultNum) - { - m_results.reset(new BasicResult[p_resultNum]); - } - - if (p_withMeta && (!m_withMeta || p_resultNum > m_resultNum)) - { - m_metadatas.reset(new ByteArray[p_resultNum]); - } - - m_resultNum = p_resultNum; - m_withMeta = p_withMeta; - } - - - inline int GetResultNum() const - { - return m_resultNum; - } - - - inline const void* GetTarget() - { - return m_target; - } - - - inline void SetTarget(const void* p_target) - { - m_target = p_target; - } - - - inline BasicResult* GetResult(int i) const - { - return i < m_resultNum ? m_results.get() + i : nullptr; - } - - - inline void SetResult(int p_index, int p_VID, float p_dist) - { - if (p_index < m_resultNum) - { - m_results[p_index].VID = p_VID; - m_results[p_index].Dist = p_dist; - } - } - - - inline BasicResult* GetResults() const - { - return m_results.get(); - } - - - inline bool WithMeta() const - { - return m_withMeta; - } - - - inline const ByteArray& GetMetadata(int p_index) const - { - if (p_index < m_resultNum && m_withMeta) - { - return m_metadatas[p_index]; - } - - return ByteArray::c_empty; - } - - - inline void SetMetadata(int p_index, ByteArray p_metadata) - { - if (p_index < m_resultNum && m_withMeta) - { - m_metadatas[p_index] = std::move(p_metadata); - } - } - - - inline void Reset() - { - for (int i = 0; i < m_resultNum; i++) - { - m_results[i].VID = -1; - m_results[i].Dist = MaxDist; - } - - if (m_withMeta) - { - for (int i = 0; i < m_resultNum; i++) - { - m_metadatas[i].Clear(); - } - } - } - - - iterator begin() - { - return m_results.get(); - } - - - iterator end() - { - return m_results.get() + m_resultNum; - } - - - const_iterator begin() const - { - return m_results.get(); - } - - - const_iterator end() const - { - return m_results.get() + m_resultNum; - } - - -protected: - const void* m_target; - - int m_resultNum; - - bool m_withMeta; - - std::unique_ptr m_results; - - std::unique_ptr m_metadatas; -}; -} // namespace SPTAG - -#endif // _SPTAG_SEARCHQUERY_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/VectorIndex.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/VectorIndex.h deleted file mode 100644 index 5fc508e3ad..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/VectorIndex.h +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_VECTORINDEX_H_ -#define _SPTAG_VECTORINDEX_H_ - -#include "Common.h" -#include "SearchQuery.h" -#include "VectorSet.h" -#include "MetadataSet.h" -#include "inc/Helper/SimpleIniReader.h" - -namespace SPTAG -{ - -class VectorIndex -{ -public: - VectorIndex(); - - virtual ~VectorIndex(); - - virtual ErrorCode SaveIndex(const std::string& p_folderPath, std::ofstream& p_configout) = 0; - - virtual ErrorCode LoadIndex(const std::string& p_folderPath, Helper::IniReader& p_reader) = 0; - - virtual ErrorCode SaveIndexToMemory(std::vector& p_indexBlobs, std::vector& p_indexBlobsLen) = 0; - - virtual ErrorCode LoadIndexFromMemory(const std::vector& p_indexBlobs) = 0; - - virtual ErrorCode BuildIndex(const void* p_data, int p_vectorNum, int p_dimension) = 0; - - virtual ErrorCode SearchIndex(QueryResult& p_results) const = 0; - - virtual ErrorCode AddIndex(const void* p_vectors, int p_vectorNum, int p_dimension) = 0; - - virtual ErrorCode DeleteIndex(const void* p_vectors, int p_vectorNum) = 0; - - //virtual ErrorCode AddIndexWithID(const void* p_vector, const int& p_id) = 0; - - //virtual ErrorCode DeleteIndexWithID(const void* p_vector, const int& p_id) = 0; - - virtual float ComputeDistance(const void* pX, const void* pY) const = 0; - virtual const void* GetSample(const int idx) const = 0; - virtual int GetFeatureDim() const = 0; - virtual int GetNumSamples() const = 0; - - virtual DistCalcMethod GetDistCalcMethod() const = 0; - virtual IndexAlgoType GetIndexAlgoType() const = 0; - virtual VectorValueType GetVectorValueType() const = 0; - virtual int GetNumThreads() const = 0; - - virtual std::string GetParameter(const char* p_param) const = 0; - virtual ErrorCode SetParameter(const char* p_param, const char* p_value) = 0; - - virtual ErrorCode LoadIndex(const std::string& p_folderPath); - - virtual ErrorCode SaveIndex(const std::string& p_folderPath); - - virtual ErrorCode BuildIndex(std::shared_ptr p_vectorSet, std::shared_ptr p_metadataSet); - - virtual ErrorCode SearchIndex(const void* p_vector, int p_neighborCount, std::vector& p_results) const; - - virtual ErrorCode AddIndex(std::shared_ptr p_vectorSet, std::shared_ptr p_metadataSet); - - virtual std::string GetParameter(const std::string& p_param) const; - virtual ErrorCode SetParameter(const std::string& p_param, const std::string& p_value); - - virtual ByteArray GetMetadata(IndexType p_vectorID) const; - virtual void SetMetadata(const std::string& p_metadataFilePath, const std::string& p_metadataIndexPath); - - virtual std::string GetIndexName() const - { - if (m_sIndexName == "") - return Helper::Convert::ConvertToString(GetIndexAlgoType()); - return m_sIndexName; - } - virtual void SetIndexName(std::string p_name) { m_sIndexName = p_name; } - - static std::shared_ptr CreateInstance(IndexAlgoType p_algo, VectorValueType p_valuetype); - - static ErrorCode MergeIndex(const char* p_indexFilePath1, const char* p_indexFilePath2); - - static ErrorCode LoadIndex(const std::string& p_loaderFilePath, std::shared_ptr& p_vectorIndex); - -protected: - std::string m_sIndexName; - std::shared_ptr m_pMetadata; -}; - - -} // namespace SPTAG - -#endif // _SPTAG_VECTORINDEX_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/VectorSet.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/VectorSet.h deleted file mode 100644 index 4d0727aa81..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Core/VectorSet.h +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_VECTORSET_H_ -#define _SPTAG_VECTORSET_H_ - -#include "CommonDataStructure.h" - -namespace SPTAG -{ - -class VectorSet -{ -public: - VectorSet(); - - virtual ~VectorSet(); - - virtual VectorValueType GetValueType() const = 0; - - virtual void* GetVector(IndexType p_vectorID) const = 0; - - virtual void* GetData() const = 0; - - virtual SizeType Dimension() const = 0; - - virtual SizeType Count() const = 0; - - virtual bool Available() const = 0; - - virtual ErrorCode Save(const std::string& p_vectorFile) const = 0; -}; - - -class BasicVectorSet : public VectorSet -{ -public: - BasicVectorSet(const ByteArray& p_bytesArray, - VectorValueType p_valueType, - SizeType p_dimension, - SizeType p_vectorCount); - - virtual ~BasicVectorSet(); - - virtual VectorValueType GetValueType() const; - - virtual void* GetVector(IndexType p_vectorID) const; - - virtual void* GetData() const; - - virtual SizeType Dimension() const; - - virtual SizeType Count() const; - - virtual bool Available() const; - - virtual ErrorCode Save(const std::string& p_vectorFile) const; - -private: - ByteArray m_data; - - VectorValueType m_valueType; - - SizeType m_dimension; - - SizeType m_vectorCount; - - SizeType m_perVectorDataSize; -}; - -} // namespace SPTAG - -#endif // _SPTAG_VECTORSET_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Helper/ArgumentsParser.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Helper/ArgumentsParser.h deleted file mode 100644 index 0ae19b8e8f..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Helper/ArgumentsParser.h +++ /dev/null @@ -1,253 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_HELPER_ARGUMENTSPARSER_H_ -#define _SPTAG_HELPER_ARGUMENTSPARSER_H_ - -#include "inc/Helper/StringConvert.h" - -#include -#include -#include -#include -#include - -namespace SPTAG -{ -namespace Helper -{ - -class ArgumentsParser -{ -public: - ArgumentsParser(); - - virtual ~ArgumentsParser(); - - virtual bool Parse(int p_argc, char** p_args); - - virtual void PrintHelp(); - -protected: - class IArgument - { - public: - IArgument(); - - virtual ~IArgument(); - - virtual bool ParseValue(int& p_restArgc, char** (&p_args)) = 0; - - virtual void PrintDescription(FILE* p_output) = 0; - - virtual bool IsRequiredButNotSet() const = 0; - }; - - - template - class ArgumentT : public IArgument - { - public: - ArgumentT(DataType& p_target, - const std::string& p_representStringShort, - const std::string& p_representString, - const std::string& p_description, - bool p_followedValue, - const DataType& p_switchAsValue, - bool p_isRequired) - : m_value(p_target), - m_representStringShort(p_representStringShort), - m_representString(p_representString), - m_description(p_description), - m_followedValue(p_followedValue), - c_switchAsValue(p_switchAsValue), - m_isRequired(p_isRequired), - m_isSet(false) - { - } - - virtual ~ArgumentT() - { - } - - - virtual bool ParseValue(int& p_restArgc, char** (&p_args)) - { - if (0 == p_restArgc) - { - return true; - } - - if (0 != strcmp(*p_args, m_representString.c_str()) - && 0 != strcmp(*p_args, m_representStringShort.c_str())) - { - return true; - } - - if (!m_followedValue) - { - m_value = c_switchAsValue; - --p_restArgc; - ++p_args; - m_isSet = true; - return true; - } - - if (p_restArgc < 2) - { - return false; - } - - DataType tmp; - if (!Helper::Convert::ConvertStringTo(p_args[1], tmp)) - { - return false; - } - - m_value = std::move(tmp); - - p_restArgc -= 2; - p_args += 2; - m_isSet = true; - return true; - } - - - virtual void PrintDescription(FILE* p_output) - { - std::size_t padding = 30; - if (!m_representStringShort.empty()) - { - fprintf(p_output, "%s", m_representStringShort.c_str()); - padding -= m_representStringShort.size(); - } - - if (!m_representString.empty()) - { - if (!m_representStringShort.empty()) - { - fprintf(p_output, ", "); - padding -= 2; - } - - fprintf(p_output, "%s", m_representString.c_str()); - padding -= m_representString.size(); - } - - if (m_followedValue) - { - fprintf(p_output, " "); - padding -= 8; - } - - while (padding-- > 0) - { - fputc(' ', p_output); - } - - fprintf(p_output, "%s", m_description.c_str()); - } - - - virtual bool IsRequiredButNotSet() const - { - return m_isRequired && !m_isSet; - } - - private: - DataType & m_value; - - std::string m_representStringShort; - - std::string m_representString; - - std::string m_description; - - bool m_followedValue; - - const DataType c_switchAsValue; - - bool m_isRequired; - - bool m_isSet; - }; - - - template - void AddRequiredOption(DataType& p_target, - const std::string& p_representStringShort, - const std::string& p_representString, - const std::string& p_description) - { - m_arguments.emplace_back(std::shared_ptr( - new ArgumentT(p_target, - p_representStringShort, - p_representString, - p_description, - true, - DataType(), - true))); - } - - - template - void AddOptionalOption(DataType& p_target, - const std::string& p_representStringShort, - const std::string& p_representString, - const std::string& p_description) - { - m_arguments.emplace_back(std::shared_ptr( - new ArgumentT(p_target, - p_representStringShort, - p_representString, - p_description, - true, - DataType(), - false))); - } - - - template - void AddRequiredSwitch(DataType& p_target, - const std::string& p_representStringShort, - const std::string& p_representString, - const std::string& p_description, - const DataType& p_switchAsValue) - { - m_arguments.emplace_back(std::shared_ptr( - new ArgumentT(p_target, - p_representStringShort, - p_representString, - p_description, - false, - p_switchAsValue, - true))); - } - - - template - void AddOptionalSwitch(DataType& p_target, - const std::string& p_representStringShort, - const std::string& p_representString, - const std::string& p_description, - const DataType& p_switchAsValue) - { - m_arguments.emplace_back(std::shared_ptr( - new ArgumentT(p_target, - p_representStringShort, - p_representString, - p_description, - false, - p_switchAsValue, - false))); - } - -private: - std::vector> m_arguments; -}; - - -} // namespace Helper -} // namespace SPTAG - -#endif // _SPTAG_HELPER_ARGUMENTSPARSER_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Helper/Base64Encode.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Helper/Base64Encode.h deleted file mode 100644 index 8e7919345d..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Helper/Base64Encode.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_HELPER_BASE64ENCODE_H_ -#define _SPTAG_HELPER_BASE64ENCODE_H_ - -#include -#include -#include - -namespace SPTAG -{ -namespace Helper -{ -namespace Base64 -{ - -bool Encode(const std::uint8_t* p_in, std::size_t p_inLen, char* p_out, std::size_t& p_outLen); - -bool Encode(const std::uint8_t* p_in, std::size_t p_inLen, std::ostream& p_out, std::size_t& p_outLen); - -bool Decode(const char* p_in, std::size_t p_inLen, std::uint8_t* p_out, std::size_t& p_outLen); - -std::size_t CapacityForEncode(std::size_t p_inLen); - -std::size_t CapacityForDecode(std::size_t p_inLen); - - -} // namespace Base64 -} // namespace Helper -} // namespace SPTAG - -#endif // _SPTAG_HELPER_BASE64ENCODE_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Helper/CommonHelper.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Helper/CommonHelper.h deleted file mode 100644 index 7f14784707..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Helper/CommonHelper.h +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_HELPER_COMMONHELPER_H_ -#define _SPTAG_HELPER_COMMONHELPER_H_ - -#include "../Core/Common.h" - -#include -#include -#include -#include -#include -#include - - -namespace SPTAG -{ -namespace Helper -{ -namespace StrUtils -{ - -void ToLowerInPlace(std::string& p_str); - -std::vector SplitString(const std::string& p_str, const std::string& p_separator); - -std::pair FindTrimmedSegment(const char* p_begin, - const char* p_end, - const std::function& p_isSkippedChar); - -bool StartsWith(const char* p_str, const char* p_prefix); - -bool StrEqualIgnoreCase(const char* p_left, const char* p_right); - -} // namespace StrUtils -} // namespace Helper -} // namespace SPTAG - -#endif // _SPTAG_HELPER_COMMONHELPER_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Helper/Concurrent.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Helper/Concurrent.h deleted file mode 100644 index 35c7cc93e4..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Helper/Concurrent.h +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_HELPER_CONCURRENT_H_ -#define _SPTAG_HELPER_CONCURRENT_H_ - - -#include -#include -#include - - -namespace SPTAG -{ -namespace Helper -{ -namespace Concurrent -{ - -class SpinLock -{ -public: - SpinLock() = default; - - void Lock() noexcept - { - while (m_lock.test_and_set(std::memory_order_acquire)) - { - } - } - - void Unlock() noexcept - { - m_lock.clear(std::memory_order_release); - } - - SpinLock(const SpinLock&) = delete; - SpinLock& operator = (const SpinLock&) = delete; - -private: - std::atomic_flag m_lock = ATOMIC_FLAG_INIT; -}; - -template -class LockGuard { -public: - LockGuard(Lock& lock) noexcept - : m_lock(lock) { - lock.Lock(); - } - - LockGuard(Lock& lock, std::adopt_lock_t) noexcept - : m_lock(lock) {} - - ~LockGuard() { - m_lock.Unlock(); - } - - LockGuard(const LockGuard&) = delete; - LockGuard& operator=(const LockGuard&) = delete; - -private: - Lock& m_lock; -}; - - -class WaitSignal -{ -public: - WaitSignal(); - - WaitSignal(std::uint32_t p_unfinished); - - ~WaitSignal(); - - void Reset(std::uint32_t p_unfinished); - - void Wait(); - - void FinishOne(); - -private: - std::atomic m_unfinished; - - std::atomic_bool m_isWaiting; - - std::mutex m_mutex; - - std::condition_variable m_cv; -}; - - -} // namespace Base64 -} // namespace Helper -} // namespace SPTAG - -#endif // _SPTAG_HELPER_CONCURRENT_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Helper/SimpleIniReader.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Helper/SimpleIniReader.h deleted file mode 100644 index 31b797aba9..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Helper/SimpleIniReader.h +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_HELPER_INIREADER_H_ -#define _SPTAG_HELPER_INIREADER_H_ - -#include "../Core/Common.h" -#include "StringConvert.h" - -#include -#include -#include -#include -#include - - -namespace SPTAG -{ -namespace Helper -{ - -// Simple INI Reader with basic functions. Case insensitive. -class IniReader -{ -public: - typedef std::map ParameterValueMap; - - IniReader(); - - ~IniReader(); - - ErrorCode LoadIniFile(const std::string& p_iniFilePath); - - bool DoesSectionExist(const std::string& p_section) const; - - bool DoesParameterExist(const std::string& p_section, const std::string& p_param) const; - - const ParameterValueMap& GetParameters(const std::string& p_section) const; - - template - DataType GetParameter(const std::string& p_section, const std::string& p_param, const DataType& p_defaultVal) const; - - void SetParameter(const std::string& p_section, const std::string& p_param, const std::string& p_val); - -private: - bool GetRawValue(const std::string& p_section, const std::string& p_param, std::string& p_value) const; - - template - static inline DataType ConvertStringTo(std::string&& p_str, const DataType& p_defaultVal); - -private: - const static ParameterValueMap c_emptyParameters; - - std::map> m_parameters; -}; - - -template -DataType -IniReader::GetParameter(const std::string& p_section, const std::string& p_param, const DataType& p_defaultVal) const -{ - std::string value; - if (!GetRawValue(p_section, p_param, value)) - { - return p_defaultVal; - } - - return ConvertStringTo(std::move(value), p_defaultVal); -} - - -template -inline DataType -IniReader::ConvertStringTo(std::string&& p_str, const DataType& p_defaultVal) -{ - DataType value; - if (Convert::ConvertStringTo(p_str.c_str(), value)) - { - return value; - } - - return p_defaultVal; -} - - -template <> -inline std::string -IniReader::ConvertStringTo(std::string&& p_str, const std::string& p_defaultVal) -{ - return std::move(p_str); -} - - -} // namespace Helper -} // namespace SPTAG - -#endif // _SPTAG_HELPER_INIREADER_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Helper/StringConvert.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Helper/StringConvert.h deleted file mode 100644 index b6e53df785..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Helper/StringConvert.h +++ /dev/null @@ -1,374 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_HELPER_STRINGCONVERTHELPER_H_ -#define _SPTAG_HELPER_STRINGCONVERTHELPER_H_ - -#include "inc/Core/Common.h" -#include "CommonHelper.h" - -#include -#include -#include -#include -#include -#include - -namespace SPTAG -{ -namespace Helper -{ -namespace Convert -{ - -template -inline bool ConvertStringTo(const char* p_str, DataType& p_value) -{ - if (nullptr == p_str) - { - return false; - } - - std::istringstream sstream; - sstream.str(p_str); - if (p_str >> p_value) - { - return true; - } - - return false; -} - - -template -inline std::string ConvertToString(const DataType& p_value) -{ - return std::to_string(p_value); -} - - -// Specialization of ConvertStringTo<>(). - -template -inline bool ConvertStringToSignedInt(const char* p_str, DataType& p_value) -{ - static_assert(std::is_integral::value && std::is_signed::value, "type check"); - - if (nullptr == p_str) - { - return false; - } - - char* end = nullptr; - errno = 0; - auto val = std::strtoll(p_str, &end, 10); - if (errno == ERANGE || end == p_str || *end != '\0') - { - return false; - } - - if (val < (std::numeric_limits::min)() || val >(std::numeric_limits::max)()) - { - return false; - } - - p_value = static_cast(val); - return true; -} - - -template -inline bool ConvertStringToUnsignedInt(const char* p_str, DataType& p_value) -{ - static_assert(std::is_integral::value && std::is_unsigned::value, "type check"); - - if (nullptr == p_str) - { - return false; - } - - char* end = nullptr; - errno = 0; - auto val = std::strtoull(p_str, &end, 10); - if (errno == ERANGE || end == p_str || *end != '\0') - { - return false; - } - - if (val < (std::numeric_limits::min)() || val >(std::numeric_limits::max)()) - { - return false; - } - - p_value = static_cast(val); - return true; -} - - -template <> -inline bool ConvertStringTo(const char* p_str, std::string& p_value) -{ - if (nullptr == p_str) - { - return false; - } - - p_value = p_str; - return true; -} - - -template <> -inline bool ConvertStringTo(const char* p_str, float& p_value) -{ - if (nullptr == p_str) - { - return false; - } - - char* end = nullptr; - errno = 0; - p_value = std::strtof(p_str, &end); - return (errno != ERANGE && end != p_str && *end == '\0'); -} - - -template <> -inline bool ConvertStringTo(const char* p_str, double& p_value) -{ - if (nullptr == p_str) - { - return false; - } - - char* end = nullptr; - errno = 0; - p_value = std::strtod(p_str, &end); - return (errno != ERANGE && end != p_str && *end == '\0'); -} - - -template <> -inline bool ConvertStringTo(const char* p_str, std::int8_t& p_value) -{ - return ConvertStringToSignedInt(p_str, p_value); -} - - -template <> -inline bool ConvertStringTo(const char* p_str, std::int16_t& p_value) -{ - return ConvertStringToSignedInt(p_str, p_value); -} - - -template <> -inline bool ConvertStringTo(const char* p_str, std::int32_t& p_value) -{ - return ConvertStringToSignedInt(p_str, p_value); -} - - -template <> -inline bool ConvertStringTo(const char* p_str, std::int64_t& p_value) -{ - return ConvertStringToSignedInt(p_str, p_value); -} - - -template <> -inline bool ConvertStringTo(const char* p_str, std::uint8_t& p_value) -{ - return ConvertStringToUnsignedInt(p_str, p_value); -} - - -template <> -inline bool ConvertStringTo(const char* p_str, std::uint16_t& p_value) -{ - return ConvertStringToUnsignedInt(p_str, p_value); -} - - -template <> -inline bool ConvertStringTo(const char* p_str, std::uint32_t& p_value) -{ - return ConvertStringToUnsignedInt(p_str, p_value); -} - - -template <> -inline bool ConvertStringTo(const char* p_str, std::uint64_t& p_value) -{ - return ConvertStringToUnsignedInt(p_str, p_value); -} - - -template <> -inline bool ConvertStringTo(const char* p_str, bool& p_value) -{ - if (StrUtils::StrEqualIgnoreCase(p_str, "true")) - { - p_value = true; - - } - else if (StrUtils::StrEqualIgnoreCase(p_str, "false")) - { - p_value = false; - } - else - { - return false; - } - - return true; -} - - -template <> -inline bool ConvertStringTo(const char* p_str, IndexAlgoType& p_value) -{ - if (nullptr == p_str) - { - return false; - } - -#define DefineIndexAlgo(Name) \ - else if (StrUtils::StrEqualIgnoreCase(p_str, #Name)) \ - { \ - p_value = IndexAlgoType::Name; \ - return true; \ - } \ - -#include "inc/Core/DefinitionList.h" -#undef DefineIndexAlgo - - return false; -} - - -template <> -inline bool ConvertStringTo(const char* p_str, DistCalcMethod& p_value) -{ - if (nullptr == p_str) - { - return false; - } - -#define DefineDistCalcMethod(Name) \ - else if (StrUtils::StrEqualIgnoreCase(p_str, #Name)) \ - { \ - p_value = DistCalcMethod::Name; \ - return true; \ - } \ - -#include "inc/Core/DefinitionList.h" -#undef DefineDistCalcMethod - - return false; -} - - -template <> -inline bool ConvertStringTo(const char* p_str, VectorValueType& p_value) -{ - if (nullptr == p_str) - { - return false; - } - -#define DefineVectorValueType(Name, Type) \ - else if (StrUtils::StrEqualIgnoreCase(p_str, #Name)) \ - { \ - p_value = VectorValueType::Name; \ - return true; \ - } \ - -#include "inc/Core/DefinitionList.h" -#undef DefineVectorValueType - - return false; -} - - -// Specialization of ConvertToString<>(). - -template<> -inline std::string ConvertToString(const std::string& p_value) -{ - return p_value; -} - - -template<> -inline std::string ConvertToString(const bool& p_value) -{ - return p_value ? "true" : "false"; -} - - -template <> -inline std::string ConvertToString(const IndexAlgoType& p_value) -{ - switch (p_value) - { -#define DefineIndexAlgo(Name) \ - case IndexAlgoType::Name: \ - return #Name; \ - -#include "inc/Core/DefinitionList.h" -#undef DefineIndexAlgo - - default: - break; - } - - return "Undefined"; -} - - -template <> -inline std::string ConvertToString(const DistCalcMethod& p_value) -{ - switch (p_value) - { -#define DefineDistCalcMethod(Name) \ - case DistCalcMethod::Name: \ - return #Name; \ - -#include "inc/Core/DefinitionList.h" -#undef DefineDistCalcMethod - - default: - break; - } - - return "Undefined"; -} - - -template <> -inline std::string ConvertToString(const VectorValueType& p_value) -{ - switch (p_value) - { -#define DefineVectorValueType(Name, Type) \ - case VectorValueType::Name: \ - return #Name; \ - -#include "inc/Core/DefinitionList.h" -#undef DefineVectorValueType - - default: - break; - } - - return "Undefined"; -} - - -} // namespace Convert -} // namespace Helper -} // namespace SPTAG - -#endif // _SPTAG_HELPER_STRINGCONVERTHELPER_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/IndexBuilder/Options.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/IndexBuilder/Options.h deleted file mode 100644 index 7c939efae5..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/IndexBuilder/Options.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_INDEXBUILDER_OPTIONS_H_ -#define _SPTAG_INDEXBUILDER_OPTIONS_H_ - -#include "inc/Core/Common.h" -#include "inc/Helper/ArgumentsParser.h" - -#include -#include -#include - -namespace SPTAG -{ -namespace IndexBuilder -{ - -class BuilderOptions : public Helper::ArgumentsParser -{ -public: - BuilderOptions(); - - ~BuilderOptions(); - - std::uint32_t m_threadNum; - - std::uint32_t m_dimension; - - std::string m_vectorDelimiter; - - SPTAG::VectorValueType m_inputValueType; - - std::string m_inputFiles; - - std::string m_outputFolder; - - SPTAG::IndexAlgoType m_indexAlgoType; - - std::string m_builderConfigFile; -}; - - -} // namespace IndexBuilder -} // namespace SPTAG - -#endif // _SPTAG_INDEXBUILDER_OPTIONS_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/IndexBuilder/ThreadPool.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/IndexBuilder/ThreadPool.h deleted file mode 100644 index 7256f71ae5..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/IndexBuilder/ThreadPool.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_INDEXBUILDER_THREADPOOL_H_ -#define _SPTAG_INDEXBUILDER_THREADPOOL_H_ - -#include -#include - -namespace SPTAG -{ -namespace IndexBuilder -{ -namespace ThreadPool -{ - -void Init(std::uint32_t p_threadNum); - -bool Queue(std::function p_workItem); - -std::uint32_t CurrentThreadNum(); - -} -} // namespace IndexBuilder -} // namespace SPTAG - -#endif // _SPTAG_INDEXBUILDER_THREADPOOL_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/IndexBuilder/VectorSetReader.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/IndexBuilder/VectorSetReader.h deleted file mode 100644 index 6bb3026aa0..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/IndexBuilder/VectorSetReader.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_INDEXBUILDER_VECTORSETREADER_H_ -#define _SPTAG_INDEXBUILDER_VECTORSETREADER_H_ - -#include "inc/Core/Common.h" -#include "inc/Core/VectorSet.h" -#include "inc/Core/MetadataSet.h" -#include "Options.h" - -#include - -namespace SPTAG -{ -namespace IndexBuilder -{ - -class VectorSetReader -{ -public: - VectorSetReader(std::shared_ptr p_options); - - virtual ~VectorSetReader(); - - virtual ErrorCode LoadFile(const std::string& p_filePath) = 0; - - virtual std::shared_ptr GetVectorSet() const = 0; - - virtual std::shared_ptr GetMetadataSet() const = 0; - - static std::shared_ptr CreateInstance(std::shared_ptr p_options); - -protected: - std::shared_ptr m_options; -}; - - - -} // namespace IndexBuilder -} // namespace SPTAG - -#endif // _SPTAG_INDEXBUILDER_VECTORSETREADER_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/IndexBuilder/VectorSetReaders/DefaultReader.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/IndexBuilder/VectorSetReaders/DefaultReader.h deleted file mode 100644 index e3e1911a9d..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/IndexBuilder/VectorSetReaders/DefaultReader.h +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_INDEXBUILDER_VECTORSETREADERS_DEFAULTREADER_H_ -#define _SPTAG_INDEXBUILDER_VECTORSETREADERS_DEFAULTREADER_H_ - -#include "../VectorSetReader.h" -#include "inc/Helper/Concurrent.h" - -#include -#include -#include - -namespace SPTAG -{ -namespace IndexBuilder -{ - -class DefaultReader : public VectorSetReader -{ -public: - DefaultReader(std::shared_ptr p_options); - - virtual ~DefaultReader(); - - virtual ErrorCode LoadFile(const std::string& p_filePaths); - - virtual std::shared_ptr GetVectorSet() const; - - virtual std::shared_ptr GetMetadataSet() const; - -private: - typedef std::pair FileInfoPair; - - static std::vector GetFileSizes(const std::string& p_filePaths); - - void LoadFileInternal(const std::string& p_filePath, - std::uint32_t p_subtaskID, - std::uint32_t p_fileBlockID, - std::size_t p_fileBlockSize); - - void MergeData(); - - template - bool TranslateVector(char* p_str, DataType* p_vector) - { - std::uint32_t eleCount = 0; - char* next = p_str; - while ((*next) != '\0') - { - while ((*next) != '\0' && m_options->m_vectorDelimiter.find(*next) == std::string::npos) - { - ++next; - } - - bool reachEnd = ('\0' == (*next)); - *next = '\0'; - if (p_str != next) - { - if (eleCount >= m_options->m_dimension) - { - return false; - } - - if (!Helper::Convert::ConvertStringTo(p_str, p_vector[eleCount++])) - { - return false; - } - } - - if (reachEnd) - { - break; - } - - ++next; - p_str = next; - } - - return eleCount == m_options->m_dimension; - } - -private: - std::uint32_t m_subTaskCount; - - std::size_t m_subTaskBlocksize; - - std::atomic m_totalRecordCount; - - std::atomic m_totalRecordVectorBytes; - - std::vector m_subTaskRecordCount; - - std::string m_vectorOutput; - - std::string m_metadataConentOutput; - - std::string m_metadataIndexOutput; - - Helper::Concurrent::WaitSignal m_waitSignal; -}; - - - -} // namespace IndexBuilder -} // namespace SPTAG - -#endif // _SPTAG_INDEXBUILDER_VECTORSETREADERS_DEFAULT_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Server/QueryParser.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Server/QueryParser.h deleted file mode 100644 index 9444e40862..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Server/QueryParser.h +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_SERVER_QUERYPARSER_H_ -#define _SPTAG_SERVER_QUERYPARSER_H_ - -#include "../Core/Common.h" -#include "../Core/CommonDataStructure.h" - -#include - -namespace SPTAG -{ -namespace Service -{ - - -class QueryParser -{ -public: - typedef std::pair OptionPair; - - QueryParser(); - - ~QueryParser(); - - ErrorCode Parse(const std::string& p_query, const char* p_vectorSeparator); - - const std::vector& GetVectorElements() const; - - const std::vector& GetOptions() const; - - const char* GetVectorBase64() const; - - SizeType GetVectorBase64Length() const; - -private: - std::vector m_options; - - std::vector m_vectorElements; - - const char* m_vectorBase64; - - SizeType m_vectorBase64Length; - - ByteArray m_dataHolder; - - static const char* c_defaultVectorSeparator; -}; - - -} // namespace Server -} // namespace AnnService - - -#endif // _SPTAG_SERVER_QUERYPARSER_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Server/SearchExecutionContext.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Server/SearchExecutionContext.h deleted file mode 100644 index cba4df4651..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Server/SearchExecutionContext.h +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_SERVER_SEARCHEXECUTIONCONTEXT_H_ -#define _SPTAG_SERVER_SEARCHEXECUTIONCONTEXT_H_ - -#include "inc/Core/VectorIndex.h" -#include "inc/Core/SearchQuery.h" -#include "inc/Socket/RemoteSearchQuery.h" -#include "ServiceSettings.h" -#include "QueryParser.h" - -#include -#include -#include - - -namespace SPTAG -{ -namespace Service -{ - -typedef Socket::IndexSearchResult SearchResult; - -class SearchExecutionContext -{ -public: - SearchExecutionContext(const std::shared_ptr& p_serviceSettings); - - ~SearchExecutionContext(); - - ErrorCode ParseQuery(const std::string& p_query); - - ErrorCode ExtractOption(); - - ErrorCode ExtractVector(VectorValueType p_targetType); - - void AddResults(std::string p_indexName, QueryResult& p_results); - - std::vector& GetResults(); - - const std::vector& GetResults() const; - - const ByteArray& GetVector() const; - - const std::vector& GetSelectedIndexNames() const; - - const SizeType GetVectorDimension() const; - - const std::vector& GetOptions() const; - - const SizeType GetResultNum() const; - - const bool GetExtractMetadata() const; - -private: - const std::shared_ptr c_serviceSettings; - - QueryParser m_queryParser; - - std::vector m_indexNames; - - ByteArray m_vector; - - SizeType m_vectorDimension; - - std::vector m_results; - - VectorValueType m_inputValueType; - - bool m_extractMetadata; - - SizeType m_resultNum; -}; - -} // namespace Server -} // namespace AnnService - - -#endif // _SPTAG_SERVER_SEARCHEXECUTIONCONTEXT_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Server/SearchExecutor.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Server/SearchExecutor.h deleted file mode 100644 index 201832651b..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Server/SearchExecutor.h +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_SERVER_SEARCHEXECUTOR_H_ -#define _SPTAG_SERVER_SEARCHEXECUTOR_H_ - -#include "ServiceContext.h" -#include "ServiceSettings.h" -#include "SearchExecutionContext.h" -#include "QueryParser.h" - -#include -#include -#include - -namespace SPTAG -{ -namespace Service -{ - -class SearchExecutor -{ -public: - typedef std::function)> CallBack; - - SearchExecutor(std::string p_queryString, - std::shared_ptr p_serviceContext, - const CallBack& p_callback); - - ~SearchExecutor(); - - void Execute(); - -private: - void ExecuteInternal(); - - void SelectIndex(); - -private: - CallBack m_callback; - - const std::shared_ptr c_serviceContext; - - std::shared_ptr m_executionContext; - - std::string m_queryString; - - std::vector> m_selectedIndex; -}; - - -} // namespace Server -} // namespace AnnService - - -#endif // _SPTAG_SERVER_SEARCHEXECUTOR_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Server/SearchService.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Server/SearchService.h deleted file mode 100644 index 34d0c6064c..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Server/SearchService.h +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_SERVER_SERVICE_H_ -#define _SPTAG_SERVER_SERVICE_H_ - -#include "ServiceContext.h" -#include "../Socket/Server.h" - -#include - -#include -#include -#include -#include - -namespace SPTAG -{ -namespace Service -{ - -class SearchExecutionContext; - -class SearchService -{ -public: - SearchService(); - - ~SearchService(); - - bool Initialize(int p_argNum, char* p_args[]); - - void Run(); - -private: - void RunSocketMode(); - - void RunInteractiveMode(); - - void SearchHanlder(Socket::ConnectionID p_localConnectionID, Socket::Packet p_packet); - - void SearchHanlderCallback(std::shared_ptr p_exeContext, - Socket::Packet p_srcPacket); - -private: - enum class ServeMode : std::uint8_t - { - Interactive, - - Socket - }; - - std::shared_ptr m_serviceContext; - - std::shared_ptr m_socketServer; - - bool m_initialized; - - ServeMode m_serveMode; - - std::unique_ptr m_threadPool; - - boost::asio::io_context m_ioContext; - - boost::asio::signal_set m_shutdownSignals; -}; - - -} // namespace Server -} // namespace AnnService - - -#endif // _SPTAG_SERVER_SERVICE_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Server/ServiceContext.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Server/ServiceContext.h deleted file mode 100644 index b1a7b84045..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Server/ServiceContext.h +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_SERVER_SERVICECONTEX_H_ -#define _SPTAG_SERVER_SERVICECONTEX_H_ - -#include "inc/Core/VectorIndex.h" -#include "ServiceSettings.h" - -#include -#include - -namespace SPTAG -{ -namespace Service -{ - -class ServiceContext -{ -public: - ServiceContext(const std::string& p_configFilePath); - - ~ServiceContext(); - - const std::map>& GetIndexMap() const; - - const std::shared_ptr& GetServiceSettings() const; - - bool IsInitialized() const; - -private: - bool m_initialized; - - std::shared_ptr m_settings; - - std::map> m_fullIndexList; -}; - - -} // namespace Server -} // namespace AnnService - -#endif // _SPTAG_SERVER_SERVICECONTEX_H_ - diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Server/ServiceSettings.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Server/ServiceSettings.h deleted file mode 100644 index 9077487355..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Server/ServiceSettings.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_SERVER_SERVICESTTINGS_H_ -#define _SPTAG_SERVER_SERVICESTTINGS_H_ - -#include "../Core/Common.h" - -#include - -namespace SPTAG -{ -namespace Service -{ - -struct ServiceSettings -{ - ServiceSettings(); - - std::string m_vectorSeparator; - - std::string m_listenAddr; - - std::string m_listenPort; - - SizeType m_defaultMaxResultNumber; - - SizeType m_threadNum; - - SizeType m_socketThreadNum; -}; - - - - -} // namespace Server -} // namespace AnnService - - -#endif // _SPTAG_SERVER_SERVICESTTINGS_H_ - diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/Client.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/Client.h deleted file mode 100644 index a57465dfd7..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/Client.h +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_SOCKET_CLIENT_H_ -#define _SPTAG_SOCKET_CLIENT_H_ - -#include "inc/Core/Common.h" -#include "Connection.h" -#include "ConnectionManager.h" -#include "Packet.h" - -#include -#include -#include -#include - -namespace SPTAG -{ -namespace Socket -{ - -class Client -{ -public: - typedef std::function ConnectCallback; - - Client(const PacketHandlerMapPtr& p_handlerMap, - std::size_t p_threadNum, - std::uint32_t p_heartbeatIntervalSeconds); - - ~Client(); - - ConnectionID ConnectToServer(const std::string& p_address, - const std::string& p_port, - SPTAG::ErrorCode& p_ec); - - void AsyncConnectToServer(const std::string& p_address, - const std::string& p_port, - ConnectCallback p_callback); - - void SendPacket(ConnectionID p_connection, Packet p_packet, std::function p_callback); - - void SetEventOnConnectionClose(std::function p_event); - -private: - void KeepIoContext(); - -private: - std::atomic_bool m_stopped; - - std::uint32_t m_heartbeatIntervalSeconds; - - boost::asio::io_context m_ioContext; - - boost::asio::deadline_timer m_deadlineTimer; - - std::shared_ptr m_connectionManager; - - std::vector m_threadPool; - - const PacketHandlerMapPtr c_requestHandlerMap; -}; - - -} // namespace Socket -} // namespace SPTAG - -#endif // _SPTAG_SOCKET_CLIENT_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/Common.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/Common.h deleted file mode 100644 index dc06af1bb4..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/Common.h +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_SOCKET_COMMON_H_ -#define _SPTAG_SOCKET_COMMON_H_ - -#include - -namespace SPTAG -{ -namespace Socket -{ - -typedef std::uint32_t ConnectionID; - -typedef std::uint32_t ResourceID; - -extern const ConnectionID c_invalidConnectionID; - -extern const ResourceID c_invalidResourceID; - -} // namespace Socket -} // namespace SPTAG - -#endif // _SPTAG_SOCKET_COMMON_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/Connection.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/Connection.h deleted file mode 100644 index 1d75d093b3..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/Connection.h +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_SOCKET_CONNECTION_H_ -#define _SPTAG_SOCKET_CONNECTION_H_ - -#include "Packet.h" - -#include -#include -#include - -#include -#include -#include - -namespace SPTAG -{ -namespace Socket -{ - -class ConnectionManager; - -class Connection : public std::enable_shared_from_this -{ -public: - typedef std::shared_ptr Ptr; - - Connection(ConnectionID p_connectionID, - boost::asio::ip::tcp::socket&& p_socket, - const PacketHandlerMapPtr& p_handlerMap, - std::weak_ptr p_connectionManager); - - void Start(); - - void Stop(); - - void StartHeartbeat(std::size_t p_intervalSeconds); - - void AsyncSend(Packet p_packet, std::function p_callback); - - ConnectionID GetConnectionID() const; - - ConnectionID GetRemoteConnectionID() const; - - Connection(const Connection&) = delete; - Connection& operator=(const Connection&) = delete; - -private: - void AsyncReadHeader(); - - void AsyncReadBody(); - - void HandleReadHeader(boost::system::error_code p_ec, std::size_t p_bytesTransferred); - - void HandleReadBody(boost::system::error_code p_ec, std::size_t p_bytesTransferred); - - void SendHeartbeat(std::size_t p_intervalSeconds); - - void SendRegister(); - - void HandleHeartbeatRequest(); - - void HandleRegisterRequest(); - - void HandleRegisterResponse(); - - void HandleNoHandlerResponse(); - - void OnConnectionFail(const boost::system::error_code& p_ec); - -private: - const ConnectionID c_connectionID; - - ConnectionID m_remoteConnectionID; - - const std::weak_ptr c_connectionManager; - - const PacketHandlerMapPtr c_handlerMap; - - boost::asio::ip::tcp::socket m_socket; - - boost::asio::io_context::strand m_strand; - - boost::asio::deadline_timer m_heartbeatTimer; - - std::uint8_t m_packetHeaderReadBuffer[PacketHeader::c_bufferSize]; - - Packet m_packetRead; - - std::atomic_bool m_stopped; - - std::atomic_bool m_heartbeatStarted; -}; - - -} // namespace Socket -} // namespace SPTAG - -#endif // _SPTAG_SOCKET_CONNECTION_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/ConnectionManager.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/ConnectionManager.h deleted file mode 100644 index e487c61053..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/ConnectionManager.h +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_SOCKET_CONNECTIONMANAGER_H_ -#define _SPTAG_SOCKET_CONNECTIONMANAGER_H_ - -#include "Connection.h" -#include "inc/Helper/Concurrent.h" - -#include -#include -#include -#include -#include - -#include - -namespace SPTAG -{ -namespace Socket -{ - -class ConnectionManager : public std::enable_shared_from_this -{ -public: - ConnectionManager(); - - ConnectionID AddConnection(boost::asio::ip::tcp::socket&& p_socket, - const PacketHandlerMapPtr& p_handlerMap, - std::uint32_t p_heartbeatIntervalSeconds); - - void RemoveConnection(ConnectionID p_connectionID); - - Connection::Ptr GetConnection(ConnectionID p_connectionID); - - void SetEventOnRemoving(std::function p_event); - - void StopAll(); - -private: - inline static std::uint32_t GetPosition(ConnectionID p_connectionID); - -private: - static constexpr std::uint32_t c_connectionPoolSize = 1 << 8; - - static constexpr std::uint32_t c_connectionPoolMask = c_connectionPoolSize - 1; - - struct ConnectionItem - { - ConnectionItem(); - - std::atomic_bool m_isEmpty; - - Connection::Ptr m_connection; - }; - - // Start from 1. 0 means not assigned. - std::atomic m_nextConnectionID; - - std::atomic m_connectionCount; - - std::array m_connections; - - Helper::Concurrent::SpinLock m_spinLock; - - std::function m_eventOnRemoving; -}; - - -} // namespace Socket -} // namespace SPTAG - -#endif // _SPTAG_SOCKET_CONNECTIONMANAGER_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/Packet.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/Packet.h deleted file mode 100644 index 8c99b09fed..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/Packet.h +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_SOCKET_PACKET_H_ -#define _SPTAG_SOCKET_PACKET_H_ - -#include "Common.h" - -#include -#include -#include -#include -#include - -namespace SPTAG -{ -namespace Socket -{ - -enum class PacketType : std::uint8_t -{ - Undefined = 0x00, - - HeartbeatRequest = 0x01, - - RegisterRequest = 0x02, - - SearchRequest = 0x03, - - ResponseMask = 0x80, - - HeartbeatResponse = ResponseMask | HeartbeatRequest, - - RegisterResponse = ResponseMask | RegisterRequest, - - SearchResponse = ResponseMask | SearchRequest -}; - - -enum class PacketProcessStatus : std::uint8_t -{ - Ok = 0x00, - - Timeout = 0x01, - - Dropped = 0x02, - - Failed = 0x03 -}; - - -struct PacketHeader -{ - static constexpr std::size_t c_bufferSize = 16; - - PacketHeader(); - PacketHeader(PacketHeader&& p_right); - PacketHeader(const PacketHeader& p_right); - - std::size_t WriteBuffer(std::uint8_t* p_buffer); - - void ReadBuffer(const std::uint8_t* p_buffer); - - PacketType m_packetType; - - PacketProcessStatus m_processStatus; - - std::uint32_t m_bodyLength; - - // Meaning of this is different with different PacketType. - // In most request case, it means connection expeced for response. - // In most response case, it means connection which handled request. - ConnectionID m_connectionID; - - ResourceID m_resourceID; -}; - - -static_assert(sizeof(PacketHeader) <= PacketHeader::c_bufferSize, ""); - - -class Packet -{ -public: - Packet(); - Packet(Packet&& p_right); - Packet(const Packet& p_right); - - PacketHeader& Header(); - - std::uint8_t* HeaderBuffer() const; - - std::uint8_t* Body() const; - - std::uint8_t* Buffer() const; - - std::uint32_t BufferLength() const; - - std::uint32_t BufferCapacity() const; - - void AllocateBuffer(std::uint32_t p_bodyCapacity); - -private: - PacketHeader m_header; - - std::shared_ptr m_buffer; - - std::uint32_t m_bufferCapacity; -}; - - -struct PacketTypeHash -{ - std::size_t operator()(const PacketType& p_val) const - { - return static_cast(p_val); - } -}; - - -typedef std::function PacketHandler; - -typedef std::unordered_map PacketHandlerMap; -typedef std::shared_ptr PacketHandlerMapPtr; - - -namespace PacketTypeHelper -{ - -bool IsRequestPacket(PacketType p_type); - -bool IsResponsePacket(PacketType p_type); - -PacketType GetCrosspondingResponseType(PacketType p_type); - -} - - -} // namespace SPTAG -} // namespace Socket - -#endif // _SPTAG_SOCKET_SOCKETSERVER_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/RemoteSearchQuery.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/RemoteSearchQuery.h deleted file mode 100644 index 900aa6cb16..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/RemoteSearchQuery.h +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_SOCKET_REMOTESEARCHQUERY_H_ -#define _SPTAG_SOCKET_REMOTESEARCHQUERY_H_ - -#include "inc/Core/CommonDataStructure.h" -#include "inc/Core/SearchQuery.h" - -#include -#include -#include -#include -#include - -namespace SPTAG -{ -namespace Socket -{ - -// TODO: use Bond replace below structures. - -struct RemoteQuery -{ - static constexpr std::uint16_t MajorVersion() { return 1; } - static constexpr std::uint16_t MirrorVersion() { return 0; } - - enum class QueryType : std::uint8_t - { - String = 0 - }; - - RemoteQuery(); - - std::size_t EstimateBufferSize() const; - - std::uint8_t* Write(std::uint8_t* p_buffer) const; - - const std::uint8_t* Read(const std::uint8_t* p_buffer); - - - QueryType m_type; - - std::string m_queryString; -}; - - -struct IndexSearchResult -{ - std::string m_indexName; - - QueryResult m_results; -}; - - -struct RemoteSearchResult -{ - static constexpr std::uint16_t MajorVersion() { return 1; } - static constexpr std::uint16_t MirrorVersion() { return 0; } - - enum class ResultStatus : std::uint8_t - { - Success = 0, - - Timeout = 1, - - FailedNetwork = 2, - - FailedExecute = 3, - - Dropped = 4 - }; - - RemoteSearchResult(); - - RemoteSearchResult(const RemoteSearchResult& p_right); - - RemoteSearchResult(RemoteSearchResult&& p_right); - - RemoteSearchResult& operator=(RemoteSearchResult&& p_right); - - std::size_t EstimateBufferSize() const; - - std::uint8_t* Write(std::uint8_t* p_buffer) const; - - const std::uint8_t* Read(const std::uint8_t* p_buffer); - - - ResultStatus m_status; - - std::vector m_allIndexResults; -}; - - - -} // namespace SPTAG -} // namespace Socket - -#endif // _SPTAG_SOCKET_REMOTESEARCHQUERY_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/ResourceManager.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/ResourceManager.h deleted file mode 100644 index 404cac830f..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/ResourceManager.h +++ /dev/null @@ -1,190 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_SOCKET_RESOURCEMANAGER_H_ -#define _SPTAG_SOCKET_RESOURCEMANAGER_H_ - -#include "Common.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace std -{ -typedef atomic atomic_uint32_t; -} - -namespace SPTAG -{ -namespace Socket -{ - -template -class ResourceManager : public std::enable_shared_from_this> -{ -public: - typedef std::function)> TimeoutCallback; - - ResourceManager() - : m_nextResourceID(1), - m_isStopped(false), - m_timeoutItemCount(0) - { - m_timeoutChecker = std::thread(&ResourceManager::StartCheckTimeout, this); - } - - - ~ResourceManager() - { - m_isStopped = true; - m_timeoutChecker.join(); - } - - - ResourceID Add(const std::shared_ptr& p_resource, - std::uint32_t p_timeoutMilliseconds, - TimeoutCallback p_timeoutCallback) - { - ResourceID rid = m_nextResourceID.fetch_add(1); - while (c_invalidResourceID == rid) - { - rid = m_nextResourceID.fetch_add(1); - } - - { - std::lock_guard guard(m_resourcesMutex); - m_resources.emplace(rid, p_resource); - } - - if (p_timeoutMilliseconds > 0) - { - std::unique_ptr item(new ResourceItem); - - item->m_resourceID = rid; - item->m_callback = std::move(p_timeoutCallback); - item->m_expireTime = m_clock.now() + std::chrono::milliseconds(p_timeoutMilliseconds); - - { - std::lock_guard guard(m_timeoutListMutex); - m_timeoutList.emplace_back(std::move(item)); - } - - ++m_timeoutItemCount; - } - - return rid; - } - - - std::shared_ptr GetAndRemove(ResourceID p_resourceID) - { - std::shared_ptr ret; - std::lock_guard guard(m_resourcesMutex); - auto iter = m_resources.find(p_resourceID); - if (iter != m_resources.end()) - { - ret = iter->second; - m_resources.erase(iter); - } - - return ret; - } - - - void Remove(ResourceID p_resourceID) - { - std::lock_guard guard(m_resourcesMutex); - auto iter = m_resources.find(p_resourceID); - if (iter != m_resources.end()) - { - m_resources.erase(iter); - } - } - -private: - void StartCheckTimeout() - { - std::vector> timeouted; - timeouted.reserve(1024); - while (!m_isStopped) - { - if (m_timeoutItemCount > 0) - { - std::lock_guard guard(m_timeoutListMutex); - while (!m_timeoutList.empty() - && m_timeoutList.front()->m_expireTime <= m_clock.now()) - { - timeouted.emplace_back(std::move(m_timeoutList.front())); - m_timeoutList.pop_front(); - --m_timeoutItemCount; - } - } - - if (timeouted.empty()) - { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } - else - { - for (auto& item : timeouted) - { - auto resource = GetAndRemove(item->m_resourceID); - if (nullptr != resource) - { - item->m_callback(std::move(resource)); - } - } - - timeouted.clear(); - } - } - } - - -private: - struct ResourceItem - { - ResourceItem() - : m_resourceID(c_invalidResourceID) - { - } - - ResourceID m_resourceID; - - TimeoutCallback m_callback; - - std::chrono::time_point m_expireTime; - }; - - std::deque> m_timeoutList; - - std::atomic m_timeoutItemCount; - - std::mutex m_timeoutListMutex; - - std::unordered_map> m_resources; - - std::atomic m_nextResourceID; - - std::mutex m_resourcesMutex; - - std::chrono::high_resolution_clock m_clock; - - std::thread m_timeoutChecker; - - bool m_isStopped; -}; - - -} // namespace Socket -} // namespace SPTAG - -#endif // _SPTAG_SOCKET_RESOURCEMANAGER_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/Server.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/Server.h deleted file mode 100644 index aac97bf84b..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/Server.h +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_SOCKET_SERVER_H_ -#define _SPTAG_SOCKET_SERVER_H_ - -#include "Connection.h" -#include "ConnectionManager.h" -#include "Packet.h" - -#include -#include -#include - -namespace SPTAG -{ -namespace Socket -{ - -class Server -{ -public: - Server(const std::string& p_address, - const std::string& p_port, - const PacketHandlerMapPtr& p_handlerMap, - std::size_t p_threadNum); - - ~Server(); - - void StartListen(); - - void SendPacket(ConnectionID p_connection, Packet p_packet, std::function p_callback); - - void SetEventOnConnectionClose(std::function p_event); - -private: - void StartAccept(); - -private: - boost::asio::io_context m_ioContext; - - boost::asio::ip::tcp::acceptor m_acceptor; - - std::shared_ptr m_connectionManager; - - std::vector m_threadPool; - - const PacketHandlerMapPtr m_requestHandlerMap; -}; - - -} // namespace Socket -} // namespace SPTAG - -#endif // _SPTAG_SOCKET_SERVER_H_ diff --git a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/SimpleSerialization.h b/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/SimpleSerialization.h deleted file mode 100644 index 6da925625b..0000000000 --- a/cpp/thirdparty/knowhere_build/include/SPTAG/AnnService/inc/Socket/SimpleSerialization.h +++ /dev/null @@ -1,174 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _SPTAG_SOCKET_SIMPLESERIALIZATION_H_ -#define _SPTAG_SOCKET_SIMPLESERIALIZATION_H_ - -#include "inc/Core/CommonDataStructure.h" - -#include -#include -#include -#include - -namespace SPTAG -{ -namespace Socket -{ -namespace SimpleSerialization -{ - - template - inline std::uint8_t* - SimpleWriteBuffer(const T& p_val, std::uint8_t* p_buffer) - { - static_assert(std::is_fundamental::value || std::is_enum::value, - "Only applied for fundanmental type."); - - *(reinterpret_cast(p_buffer)) = p_val; - return p_buffer + sizeof(T); - } - - - template - inline const std::uint8_t* - SimpleReadBuffer(const std::uint8_t* p_buffer, T& p_val) - { - static_assert(std::is_fundamental::value || std::is_enum::value, - "Only applied for fundanmental type."); - - p_val = *(reinterpret_cast(p_buffer)); - return p_buffer + sizeof(T); - } - - - template - inline std::size_t - EstimateBufferSize(const T& p_val) - { - static_assert(std::is_fundamental::value || std::is_enum::value, - "Only applied for fundanmental type."); - - return sizeof(T); - } - - - template<> - inline std::uint8_t* - SimpleWriteBuffer(const std::string& p_val, std::uint8_t* p_buffer) - { - p_buffer = SimpleWriteBuffer(static_cast(p_val.size()), p_buffer); - - std::memcpy(p_buffer, p_val.c_str(), p_val.size()); - return p_buffer + p_val.size(); - } - - - template<> - inline const std::uint8_t* - SimpleReadBuffer(const std::uint8_t* p_buffer, std::string& p_val) - { - p_val.clear(); - std::uint32_t len = 0; - p_buffer = SimpleReadBuffer(p_buffer, len); - - if (len > 0) - { - p_val.reserve(len); - p_val.assign(reinterpret_cast(p_buffer), len); - } - - return p_buffer + len; - } - - - template<> - inline std::size_t - EstimateBufferSize(const std::string& p_val) - { - return sizeof(std::uint32_t) + p_val.size(); - } - - - template<> - inline std::uint8_t* - SimpleWriteBuffer(const ByteArray& p_val, std::uint8_t* p_buffer) - { - p_buffer = SimpleWriteBuffer(static_cast(p_val.Length()), p_buffer); - - std::memcpy(p_buffer, p_val.Data(), p_val.Length()); - return p_buffer + p_val.Length(); - } - - - template<> - inline const std::uint8_t* - SimpleReadBuffer(const std::uint8_t* p_buffer, ByteArray& p_val) - { - p_val.Clear(); - std::uint32_t len = 0; - p_buffer = SimpleReadBuffer(p_buffer, len); - - if (len > 0) - { - p_val = ByteArray::Alloc(len); - std::memcpy(p_val.Data(), p_buffer, len); - } - - return p_buffer + len; - } - - - template<> - inline std::size_t - EstimateBufferSize(const ByteArray& p_val) - { - return sizeof(std::uint32_t) + p_val.Length(); - } - - - template - inline std::uint8_t* - SimpleWriteSharedPtrBuffer(const std::shared_ptr& p_val, std::uint8_t* p_buffer) - { - if (nullptr == p_val) - { - return SimpleWriteBuffer(false, p_buffer); - } - - p_buffer = SimpleWriteBuffer(true, p_buffer); - p_buffer = SimpleWriteBuffer(*p_val, p_buffer); - return p_buffer; - } - - - template - inline const std::uint8_t* - SimpleReadSharedPtrBuffer(const std::uint8_t* p_buffer, std::shared_ptr& p_val) - { - p_val.reset(); - bool isNotNull = false; - p_buffer = SimpleReadBuffer(p_buffer, isNotNull); - - if (isNotNull) - { - p_val.reset(new T); - p_buffer = SimpleReadBuffer(p_buffer, *p_val); - } - - return p_buffer; - } - - - template - inline std::size_t - EstimateSharedPtrBufferSize(const std::shared_ptr& p_val) - { - return sizeof(bool) + (nullptr == p_val ? 0 : EstimateBufferSize(*p_val)); - } - -} // namespace SimpleSerialization -} // namespace SPTAG -} // namespace Socket - -#endif // _SPTAG_SOCKET_SIMPLESERIALIZATION_H_ diff --git a/cpp/thirdparty/knowhere_build/include/arrow/allocator.h b/cpp/thirdparty/knowhere_build/include/arrow/allocator.h deleted file mode 100644 index a02b8e64bb..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/allocator.h +++ /dev/null @@ -1,151 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_ALLOCATOR_H -#define ARROW_ALLOCATOR_H - -#include -#include -#include -#include - -#include "arrow/memory_pool.h" -#include "arrow/status.h" -#include "arrow/util/macros.h" - -namespace arrow { - -/// \brief A STL allocator delegating allocations to a Arrow MemoryPool -template -class stl_allocator { - public: - using value_type = T; - using pointer = T*; - using const_pointer = const T*; - using reference = T&; - using const_reference = const T&; - using size_type = std::size_t; - using difference_type = std::ptrdiff_t; - - template - struct rebind { - using other = stl_allocator; - }; - - /// \brief Construct an allocator from the default MemoryPool - stl_allocator() noexcept : pool_(default_memory_pool()) {} - /// \brief Construct an allocator from the given MemoryPool - explicit stl_allocator(MemoryPool* pool) noexcept : pool_(pool) {} - - template - stl_allocator(const stl_allocator& rhs) noexcept : pool_(rhs.pool_) {} - - ~stl_allocator() { pool_ = NULLPTR; } - - pointer address(reference r) const noexcept { return std::addressof(r); } - - const_pointer address(const_reference r) const noexcept { return std::addressof(r); } - - pointer allocate(size_type n, const void* /*hint*/ = NULLPTR) { - uint8_t* data; - Status s = pool_->Allocate(n * sizeof(T), &data); - if (!s.ok()) throw std::bad_alloc(); - return reinterpret_cast(data); - } - - void deallocate(pointer p, size_type n) { - pool_->Free(reinterpret_cast(p), n * sizeof(T)); - } - - size_type size_max() const noexcept { return size_type(-1) / sizeof(T); } - - template - void construct(U* p, Args&&... args) { - new (reinterpret_cast(p)) U(std::forward(args)...); - } - - template - void destroy(U* p) { - p->~U(); - } - - MemoryPool* pool() const noexcept { return pool_; } - - private: - MemoryPool* pool_; -}; - -/// \brief A MemoryPool implementation delegating allocations to a STL allocator -/// -/// Note that STL allocators don't provide a resizing operation, and therefore -/// any buffer resizes will do a full reallocation and copy. -template > -class STLMemoryPool : public MemoryPool { - public: - /// \brief Construct a memory pool from the given allocator - explicit STLMemoryPool(const Allocator& alloc) : alloc_(alloc) {} - - Status Allocate(int64_t size, uint8_t** out) override { - try { - *out = alloc_.allocate(size); - } catch (std::bad_alloc& e) { - return Status::OutOfMemory(e.what()); - } - stats_.UpdateAllocatedBytes(size); - return Status::OK(); - } - - Status Reallocate(int64_t old_size, int64_t new_size, uint8_t** ptr) override { - uint8_t* old_ptr = *ptr; - try { - *ptr = alloc_.allocate(new_size); - } catch (std::bad_alloc& e) { - return Status::OutOfMemory(e.what()); - } - memcpy(*ptr, old_ptr, std::min(old_size, new_size)); - alloc_.deallocate(old_ptr, old_size); - stats_.UpdateAllocatedBytes(new_size - old_size); - return Status::OK(); - } - - void Free(uint8_t* buffer, int64_t size) override { - alloc_.deallocate(buffer, size); - stats_.UpdateAllocatedBytes(-size); - } - - int64_t bytes_allocated() const override { return stats_.bytes_allocated(); } - - int64_t max_memory() const override { return stats_.max_memory(); } - - private: - Allocator alloc_; - internal::MemoryPoolStats stats_; -}; - -template -bool operator==(const stl_allocator& lhs, const stl_allocator& rhs) noexcept { - return lhs.pool() == rhs.pool(); -} - -template -bool operator!=(const stl_allocator& lhs, const stl_allocator& rhs) noexcept { - return !(lhs == rhs); -} - -} // namespace arrow - -#endif // ARROW_ALLOCATOR_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/api.h b/cpp/thirdparty/knowhere_build/include/arrow/api.h deleted file mode 100644 index 3d6a17961b..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/api.h +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// Coarse public API while the library is in development - -#ifndef ARROW_API_H -#define ARROW_API_H - -#include "arrow/array.h" // IYWU pragma: export -#include "arrow/buffer.h" // IYWU pragma: export -#include "arrow/builder.h" // IYWU pragma: export -#include "arrow/compare.h" // IYWU pragma: export -#include "arrow/extension_type.h" // IYWU pragma: export -#include "arrow/memory_pool.h" // IYWU pragma: export -#include "arrow/pretty_print.h" // IYWU pragma: export -#include "arrow/record_batch.h" // IYWU pragma: export -#include "arrow/status.h" // IYWU pragma: export -#include "arrow/table.h" // IYWU pragma: export -#include "arrow/table_builder.h" // IYWU pragma: export -#include "arrow/tensor.h" // IYWU pragma: export -#include "arrow/type.h" // IYWU pragma: export -#include "arrow/util/config.h" // IYWU pragma: export -#include "arrow/util/key_value_metadata.h" // IWYU pragma: export -#include "arrow/visitor.h" // IYWU pragma: export - -/// \brief Top-level namespace for Apache Arrow C++ API -namespace arrow {} - -#endif // ARROW_API_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/array.h b/cpp/thirdparty/knowhere_build/include/arrow/array.h deleted file mode 100644 index 2a1ce7aae6..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/array.h +++ /dev/null @@ -1,1149 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_ARRAY_H -#define ARROW_ARRAY_H - -#include -#include -#include -#include -#include -#include -#include - -#include "arrow/buffer.h" -#include "arrow/compare.h" -#include "arrow/result.h" -#include "arrow/type.h" -#include "arrow/type_traits.h" -#include "arrow/util/bit-util.h" -#include "arrow/util/checked_cast.h" -#include "arrow/util/macros.h" -#include "arrow/util/string_view.h" // IWYU pragma: export -#include "arrow/util/visibility.h" - -namespace arrow { - -class Array; -class ArrayVisitor; - -// When slicing, we do not know the null count of the sliced range without -// doing some computation. To avoid doing this eagerly, we set the null count -// to -1 (any negative number will do). When Array::null_count is called the -// first time, the null count will be computed. See ARROW-33 -constexpr int64_t kUnknownNullCount = -1; - -class MemoryPool; -class Status; - -// ---------------------------------------------------------------------- -// Generic array data container - -/// \class ArrayData -/// \brief Mutable container for generic Arrow array data -/// -/// This data structure is a self-contained representation of the memory and -/// metadata inside an Arrow array data structure (called vectors in Java). The -/// classes arrow::Array and its subclasses provide strongly-typed accessors -/// with support for the visitor pattern and other affordances. -/// -/// This class is designed for easy internal data manipulation, analytical data -/// processing, and data transport to and from IPC messages. For example, we -/// could cast from int64 to float64 like so: -/// -/// Int64Array arr = GetMyData(); -/// auto new_data = arr.data()->Copy(); -/// new_data->type = arrow::float64(); -/// DoubleArray double_arr(new_data); -/// -/// This object is also useful in an analytics setting where memory may be -/// reused. For example, if we had a group of operations all returning doubles, -/// say: -/// -/// Log(Sqrt(Expr(arr))) -/// -/// Then the low-level implementations of each of these functions could have -/// the signatures -/// -/// void Log(const ArrayData& values, ArrayData* out); -/// -/// As another example a function may consume one or more memory buffers in an -/// input array and replace them with newly-allocated data, changing the output -/// data type as well. -struct ARROW_EXPORT ArrayData { - ArrayData() : length(0), null_count(0), offset(0) {} - - ArrayData(const std::shared_ptr& type, int64_t length, - int64_t null_count = kUnknownNullCount, int64_t offset = 0) - : type(type), length(length), null_count(null_count), offset(offset) {} - - ArrayData(const std::shared_ptr& type, int64_t length, - const std::vector>& buffers, - int64_t null_count = kUnknownNullCount, int64_t offset = 0) - : ArrayData(type, length, null_count, offset) { - this->buffers = buffers; - } - - ArrayData(const std::shared_ptr& type, int64_t length, - const std::vector>& buffers, - const std::vector>& child_data, - int64_t null_count = kUnknownNullCount, int64_t offset = 0) - : ArrayData(type, length, null_count, offset) { - this->buffers = buffers; - this->child_data = child_data; - } - - ArrayData(const std::shared_ptr& type, int64_t length, - std::vector>&& buffers, - int64_t null_count = kUnknownNullCount, int64_t offset = 0) - : ArrayData(type, length, null_count, offset) { - this->buffers = std::move(buffers); - } - - static std::shared_ptr Make(const std::shared_ptr& type, - int64_t length, - std::vector>&& buffers, - int64_t null_count = kUnknownNullCount, - int64_t offset = 0); - - static std::shared_ptr Make( - const std::shared_ptr& type, int64_t length, - const std::vector>& buffers, - int64_t null_count = kUnknownNullCount, int64_t offset = 0); - - static std::shared_ptr Make( - const std::shared_ptr& type, int64_t length, - const std::vector>& buffers, - const std::vector>& child_data, - int64_t null_count = kUnknownNullCount, int64_t offset = 0); - - static std::shared_ptr Make(const std::shared_ptr& type, - int64_t length, - int64_t null_count = kUnknownNullCount, - int64_t offset = 0); - - // Move constructor - ArrayData(ArrayData&& other) noexcept - : type(std::move(other.type)), - length(other.length), - null_count(other.null_count), - offset(other.offset), - buffers(std::move(other.buffers)), - child_data(std::move(other.child_data)), - dictionary(std::move(other.dictionary)) {} - - // Copy constructor - ArrayData(const ArrayData& other) noexcept - : type(other.type), - length(other.length), - null_count(other.null_count), - offset(other.offset), - buffers(other.buffers), - child_data(other.child_data), - dictionary(other.dictionary) {} - - // Move assignment - ArrayData& operator=(ArrayData&& other) = default; - - // Copy assignment - ArrayData& operator=(const ArrayData& other) = default; - - std::shared_ptr Copy() const { return std::make_shared(*this); } - - // Access a buffer's data as a typed C pointer - template - inline const T* GetValues(int i, int64_t absolute_offset) const { - if (buffers[i]) { - return reinterpret_cast(buffers[i]->data()) + absolute_offset; - } else { - return NULLPTR; - } - } - - template - inline const T* GetValues(int i) const { - return GetValues(i, offset); - } - - // Access a buffer's data as a typed C pointer - template - inline T* GetMutableValues(int i, int64_t absolute_offset) { - if (buffers[i]) { - return reinterpret_cast(buffers[i]->mutable_data()) + absolute_offset; - } else { - return NULLPTR; - } - } - - template - inline T* GetMutableValues(int i) { - return GetMutableValues(i, offset); - } - - // Construct a zero-copy slice of the data with the indicated offset and length - ArrayData Slice(int64_t offset, int64_t length) const; - - /// \brief Return null count, or compute and set it if it's not known - int64_t GetNullCount() const; - - std::shared_ptr type; - int64_t length; - mutable int64_t null_count; - // The logical start point into the physical buffers (in values, not bytes). - // Note that, for child data, this must be *added* to the child data's own offset. - int64_t offset; - std::vector> buffers; - std::vector> child_data; - - // The dictionary for this Array, if any. Only used for dictionary - // type - std::shared_ptr dictionary; -}; - -/// \brief Create a strongly-typed Array instance from generic ArrayData -/// \param[in] data the array contents -/// \return the resulting Array instance -ARROW_EXPORT -std::shared_ptr MakeArray(const std::shared_ptr& data); - -/// \brief Create a strongly-typed Array instance with all elements null -/// \param[in] type the array type -/// \param[in] length the array length -/// \param[out] out resulting Array instance -ARROW_EXPORT -Status MakeArrayOfNull(const std::shared_ptr& type, int64_t length, - std::shared_ptr* out); - -// ---------------------------------------------------------------------- -// User array accessor types - -/// \brief Array base type -/// Immutable data array with some logical type and some length. -/// -/// Any memory is owned by the respective Buffer instance (or its parents). -/// -/// The base class is only required to have a null bitmap buffer if the null -/// count is greater than 0 -/// -/// If known, the null count can be provided in the base Array constructor. If -/// the null count is not known, pass -1 to indicate that the null count is to -/// be computed on the first call to null_count() -class ARROW_EXPORT Array { - public: - virtual ~Array() = default; - - /// \brief Return true if value at index is null. Does not boundscheck - bool IsNull(int64_t i) const { - return null_bitmap_data_ != NULLPTR && - !BitUtil::GetBit(null_bitmap_data_, i + data_->offset); - } - - /// \brief Return true if value at index is valid (not null). Does not - /// boundscheck - bool IsValid(int64_t i) const { - return null_bitmap_data_ == NULLPTR || - BitUtil::GetBit(null_bitmap_data_, i + data_->offset); - } - - /// Size in the number of elements this array contains. - int64_t length() const { return data_->length; } - - /// A relative position into another array's data, to enable zero-copy - /// slicing. This value defaults to zero - int64_t offset() const { return data_->offset; } - - /// The number of null entries in the array. If the null count was not known - /// at time of construction (and set to a negative value), then the null - /// count will be computed and cached on the first invocation of this - /// function - int64_t null_count() const; - - std::shared_ptr type() const { return data_->type; } - Type::type type_id() const { return data_->type->id(); } - - /// Buffer for the null bitmap. - /// - /// Note that for `null_count == 0`, this can be null. - /// This buffer does not account for any slice offset - std::shared_ptr null_bitmap() const { return data_->buffers[0]; } - - /// Raw pointer to the null bitmap. - /// - /// Note that for `null_count == 0`, this can be null. - /// This buffer does not account for any slice offset - const uint8_t* null_bitmap_data() const { return null_bitmap_data_; } - - /// Equality comparison with another array - bool Equals(const Array& arr, const EqualOptions& = EqualOptions::Defaults()) const; - bool Equals(const std::shared_ptr& arr, - const EqualOptions& = EqualOptions::Defaults()) const; - - /// Approximate equality comparison with another array - /// - /// epsilon is only used if this is FloatArray or DoubleArray - bool ApproxEquals(const std::shared_ptr& arr, - const EqualOptions& = EqualOptions::Defaults()) const; - bool ApproxEquals(const Array& arr, - const EqualOptions& = EqualOptions::Defaults()) const; - - /// Compare if the range of slots specified are equal for the given array and - /// this array. end_idx exclusive. This methods does not bounds check. - bool RangeEquals(int64_t start_idx, int64_t end_idx, int64_t other_start_idx, - const Array& other) const; - bool RangeEquals(int64_t start_idx, int64_t end_idx, int64_t other_start_idx, - const std::shared_ptr& other) const; - bool RangeEquals(const Array& other, int64_t start_idx, int64_t end_idx, - int64_t other_start_idx) const; - bool RangeEquals(const std::shared_ptr& other, int64_t start_idx, - int64_t end_idx, int64_t other_start_idx) const; - - Status Accept(ArrayVisitor* visitor) const; - - /// Construct a zero-copy view of this array with the given type. - /// - /// This method checks if the types are layout-compatible. - /// Nested types are traversed in depth-first order. Data buffers must have - /// the same item sizes, even though the logical types may be different. - /// An error is returned if the types are not layout-compatible. - Status View(const std::shared_ptr& type, std::shared_ptr* out); - - /// Construct a zero-copy slice of the array with the indicated offset and - /// length - /// - /// \param[in] offset the position of the first element in the constructed - /// slice - /// \param[in] length the length of the slice. If there are not enough - /// elements in the array, the length will be adjusted accordingly - /// - /// \return a new object wrapped in std::shared_ptr - std::shared_ptr Slice(int64_t offset, int64_t length) const; - - /// Slice from offset until end of the array - std::shared_ptr Slice(int64_t offset) const; - - std::shared_ptr data() const { return data_; } - - int num_fields() const { return static_cast(data_->child_data.size()); } - - /// \return PrettyPrint representation of array suitable for debugging - std::string ToString() const; - - protected: - Array() : null_bitmap_data_(NULLPTR) {} - - std::shared_ptr data_; - const uint8_t* null_bitmap_data_; - - /// Protected method for constructors - inline void SetData(const std::shared_ptr& data) { - if (data->buffers.size() > 0 && data->buffers[0]) { - null_bitmap_data_ = data->buffers[0]->data(); - } else { - null_bitmap_data_ = NULLPTR; - } - data_ = data; - } - - private: - ARROW_DISALLOW_COPY_AND_ASSIGN(Array); -}; - -using ArrayVector = std::vector>; - -namespace internal { - -/// Given a number of ArrayVectors, treat each ArrayVector as the -/// chunks of a chunked array. Then rechunk each ArrayVector such that -/// all ArrayVectors are chunked identically. It is mandatory that -/// all ArrayVectors contain the same total number of elements. -ARROW_EXPORT -std::vector RechunkArraysConsistently(const std::vector&); - -} // namespace internal - -static inline std::ostream& operator<<(std::ostream& os, const Array& x) { - os << x.ToString(); - return os; -} - -/// Base class for non-nested arrays -class ARROW_EXPORT FlatArray : public Array { - protected: - using Array::Array; -}; - -/// Degenerate null type Array -class ARROW_EXPORT NullArray : public FlatArray { - public: - using TypeClass = NullType; - - explicit NullArray(const std::shared_ptr& data) { SetData(data); } - explicit NullArray(int64_t length); - - private: - inline void SetData(const std::shared_ptr& data) { - null_bitmap_data_ = NULLPTR; - data->null_count = data->length; - data_ = data; - } -}; - -/// Base class for arrays of fixed-size logical types -class ARROW_EXPORT PrimitiveArray : public FlatArray { - public: - PrimitiveArray(const std::shared_ptr& type, int64_t length, - const std::shared_ptr& data, - const std::shared_ptr& null_bitmap = NULLPTR, - int64_t null_count = kUnknownNullCount, int64_t offset = 0); - - /// Does not account for any slice offset - std::shared_ptr values() const { return data_->buffers[1]; } - - protected: - PrimitiveArray() : raw_values_(NULLPTR) {} - - inline void SetData(const std::shared_ptr& data) { - auto values = data->buffers[1]; - this->Array::SetData(data); - raw_values_ = values == NULLPTR ? NULLPTR : values->data(); - } - - explicit inline PrimitiveArray(const std::shared_ptr& data) { - SetData(data); - } - - const uint8_t* raw_values_; -}; - -/// Concrete Array class for numeric data. -template -class NumericArray : public PrimitiveArray { - public: - using TypeClass = TYPE; - using value_type = typename TypeClass::c_type; - - explicit NumericArray(const std::shared_ptr& data) : PrimitiveArray(data) {} - - // Only enable this constructor without a type argument for types without additional - // metadata - template - NumericArray( - typename std::enable_if::is_parameter_free, int64_t>::type length, - const std::shared_ptr& data, - const std::shared_ptr& null_bitmap = NULLPTR, - int64_t null_count = kUnknownNullCount, int64_t offset = 0) - : PrimitiveArray(TypeTraits::type_singleton(), length, data, null_bitmap, - null_count, offset) {} - - const value_type* raw_values() const { - return reinterpret_cast(raw_values_) + data_->offset; - } - - value_type Value(int64_t i) const { return raw_values()[i]; } - - // For API compatibility with BinaryArray etc. - value_type GetView(int64_t i) const { return Value(i); } - - protected: - using PrimitiveArray::PrimitiveArray; -}; - -/// Concrete Array class for boolean data -class ARROW_EXPORT BooleanArray : public PrimitiveArray { - public: - using TypeClass = BooleanType; - - explicit BooleanArray(const std::shared_ptr& data); - - BooleanArray(int64_t length, const std::shared_ptr& data, - const std::shared_ptr& null_bitmap = NULLPTR, - int64_t null_count = kUnknownNullCount, int64_t offset = 0); - - bool Value(int64_t i) const { - return BitUtil::GetBit(reinterpret_cast(raw_values_), - i + data_->offset); - } - - bool GetView(int64_t i) const { return Value(i); } - - protected: - using PrimitiveArray::PrimitiveArray; -}; - -// ---------------------------------------------------------------------- -// ListArray - -/// Concrete Array class for list data -class ARROW_EXPORT ListArray : public Array { - public: - using TypeClass = ListType; - - explicit ListArray(const std::shared_ptr& data); - - ListArray(const std::shared_ptr& type, int64_t length, - const std::shared_ptr& value_offsets, - const std::shared_ptr& values, - const std::shared_ptr& null_bitmap = NULLPTR, - int64_t null_count = kUnknownNullCount, int64_t offset = 0); - - /// \brief Construct ListArray from array of offsets and child value array - /// - /// This function does the bare minimum of validation of the offsets and - /// input types, and will allocate a new offsets array if necessary (i.e. if - /// the offsets contain any nulls). If the offsets do not have nulls, they - /// are assumed to be well-formed - /// - /// \param[in] offsets Array containing n + 1 offsets encoding length and - /// size. Must be of int32 type - /// \param[in] values Array containing - /// \param[in] pool MemoryPool in case new offsets array needs to be - /// allocated because of null values - /// \param[out] out Will have length equal to offsets.length() - 1 - static Status FromArrays(const Array& offsets, const Array& values, MemoryPool* pool, - std::shared_ptr* out); - - const ListType* list_type() const { return list_type_; } - - /// \brief Return array object containing the list's values - std::shared_ptr values() const; - - /// Note that this buffer does not account for any slice offset - std::shared_ptr value_offsets() const { return data_->buffers[1]; } - - std::shared_ptr value_type() const; - - /// Return pointer to raw value offsets accounting for any slice offset - const int32_t* raw_value_offsets() const { return raw_value_offsets_ + data_->offset; } - - // The following functions will not perform boundschecking - int32_t value_offset(int64_t i) const { return raw_value_offsets_[i + data_->offset]; } - int32_t value_length(int64_t i) const { - i += data_->offset; - return raw_value_offsets_[i + 1] - raw_value_offsets_[i]; - } - std::shared_ptr value_slice(int64_t i) const { - return values_->Slice(value_offset(i), value_length(i)); - } - - protected: - // This constructor defers SetData to a derived array class - ListArray() = default; - void SetData(const std::shared_ptr& data); - - const int32_t* raw_value_offsets_ = NULLPTR; - - private: - const ListType* list_type_ = NULLPTR; - std::shared_ptr values_; -}; - -// ---------------------------------------------------------------------- -// MapArray - -/// Concrete Array class for map data -/// -/// NB: "value" in this context refers to a pair of a key and the correspondint item -class ARROW_EXPORT MapArray : public ListArray { - public: - using TypeClass = MapType; - - explicit MapArray(const std::shared_ptr& data); - - MapArray(const std::shared_ptr& type, int64_t length, - const std::shared_ptr& value_offsets, - const std::shared_ptr& keys, const std::shared_ptr& items, - const std::shared_ptr& null_bitmap = NULLPTR, - int64_t null_count = kUnknownNullCount, int64_t offset = 0); - - MapArray(const std::shared_ptr& type, int64_t length, - const std::shared_ptr& value_offsets, - const std::shared_ptr& values, - const std::shared_ptr& null_bitmap = NULLPTR, - int64_t null_count = kUnknownNullCount, int64_t offset = 0); - - const MapType* map_type() const { return map_type_; } - - /// \brief Return array object containing all map keys - std::shared_ptr keys() const { return keys_; } - - /// \brief Return array object containing all mapped items - std::shared_ptr items() const { return items_; } - - protected: - void SetData(const std::shared_ptr& data); - - private: - const MapType* map_type_; - std::shared_ptr keys_, items_; -}; - -// ---------------------------------------------------------------------- -// FixedSizeListArray - -/// Concrete Array class for fixed size list data -class ARROW_EXPORT FixedSizeListArray : public Array { - public: - using TypeClass = FixedSizeListType; - - explicit FixedSizeListArray(const std::shared_ptr& data); - - FixedSizeListArray(const std::shared_ptr& type, int64_t length, - const std::shared_ptr& values, - const std::shared_ptr& null_bitmap = NULLPTR, - int64_t null_count = kUnknownNullCount, int64_t offset = 0); - - const FixedSizeListType* list_type() const; - - /// \brief Return array object containing the list's values - std::shared_ptr values() const; - - std::shared_ptr value_type() const; - - // The following functions will not perform boundschecking - int32_t value_offset(int64_t i) const { - i += data_->offset; - return static_cast(list_size_ * i); - } - int32_t value_length(int64_t i = 0) const { return list_size_; } - std::shared_ptr value_slice(int64_t i) const { - return values_->Slice(value_offset(i), value_length(i)); - } - - protected: - void SetData(const std::shared_ptr& data); - int32_t list_size_; - - private: - std::shared_ptr values_; -}; - -// ---------------------------------------------------------------------- -// Binary and String - -/// Concrete Array class for variable-size binary data -class ARROW_EXPORT BinaryArray : public FlatArray { - public: - using TypeClass = BinaryType; - - explicit BinaryArray(const std::shared_ptr& data); - - BinaryArray(int64_t length, const std::shared_ptr& value_offsets, - const std::shared_ptr& data, - const std::shared_ptr& null_bitmap = NULLPTR, - int64_t null_count = kUnknownNullCount, int64_t offset = 0); - - /// Return the pointer to the given elements bytes - // XXX should GetValue(int64_t i) return a string_view? - const uint8_t* GetValue(int64_t i, int32_t* out_length) const { - // Account for base offset - i += data_->offset; - const int32_t pos = raw_value_offsets_[i]; - *out_length = raw_value_offsets_[i + 1] - pos; - return raw_data_ + pos; - } - - /// \brief Get binary value as a string_view - /// - /// \param i the value index - /// \return the view over the selected value - util::string_view GetView(int64_t i) const { - // Account for base offset - i += data_->offset; - const int32_t pos = raw_value_offsets_[i]; - return util::string_view(reinterpret_cast(raw_data_ + pos), - raw_value_offsets_[i + 1] - pos); - } - - /// \brief Get binary value as a std::string - /// - /// \param i the value index - /// \return the value copied into a std::string - std::string GetString(int64_t i) const { return std::string(GetView(i)); } - - /// Note that this buffer does not account for any slice offset - std::shared_ptr value_offsets() const { return data_->buffers[1]; } - - /// Note that this buffer does not account for any slice offset - std::shared_ptr value_data() const { return data_->buffers[2]; } - - const int32_t* raw_value_offsets() const { return raw_value_offsets_ + data_->offset; } - - // Neither of these functions will perform boundschecking - int32_t value_offset(int64_t i) const { return raw_value_offsets_[i + data_->offset]; } - int32_t value_length(int64_t i) const { - i += data_->offset; - return raw_value_offsets_[i + 1] - raw_value_offsets_[i]; - } - - protected: - // For subclasses - BinaryArray() : raw_value_offsets_(NULLPTR), raw_data_(NULLPTR) {} - - /// Protected method for constructors - void SetData(const std::shared_ptr& data); - - // Constructor to allow sub-classes/builders to substitute their own logical type - BinaryArray(const std::shared_ptr& type, int64_t length, - const std::shared_ptr& value_offsets, - const std::shared_ptr& data, - const std::shared_ptr& null_bitmap = NULLPTR, - int64_t null_count = kUnknownNullCount, int64_t offset = 0); - - const int32_t* raw_value_offsets_; - const uint8_t* raw_data_; -}; - -/// Concrete Array class for variable-size string (utf-8) data -class ARROW_EXPORT StringArray : public BinaryArray { - public: - using TypeClass = StringType; - - explicit StringArray(const std::shared_ptr& data); - - StringArray(int64_t length, const std::shared_ptr& value_offsets, - const std::shared_ptr& data, - const std::shared_ptr& null_bitmap = NULLPTR, - int64_t null_count = kUnknownNullCount, int64_t offset = 0); -}; - -// ---------------------------------------------------------------------- -// Fixed width binary - -/// Concrete Array class for fixed-size binary data -class ARROW_EXPORT FixedSizeBinaryArray : public PrimitiveArray { - public: - using TypeClass = FixedSizeBinaryType; - - explicit FixedSizeBinaryArray(const std::shared_ptr& data); - - FixedSizeBinaryArray(const std::shared_ptr& type, int64_t length, - const std::shared_ptr& data, - const std::shared_ptr& null_bitmap = NULLPTR, - int64_t null_count = kUnknownNullCount, int64_t offset = 0); - - const uint8_t* GetValue(int64_t i) const; - const uint8_t* Value(int64_t i) const { return GetValue(i); } - - util::string_view GetView(int64_t i) const { - return util::string_view(reinterpret_cast(GetValue(i)), byte_width()); - } - - std::string GetString(int64_t i) const { return std::string(GetView(i)); } - - int32_t byte_width() const { return byte_width_; } - - const uint8_t* raw_values() const { return raw_values_ + data_->offset * byte_width_; } - - protected: - inline void SetData(const std::shared_ptr& data) { - this->PrimitiveArray::SetData(data); - byte_width_ = - internal::checked_cast(*type()).byte_width(); - } - - int32_t byte_width_; -}; - -/// DayTimeArray -/// --------------------- -/// \brief Array of Day and Millisecond values. -class ARROW_EXPORT DayTimeIntervalArray : public PrimitiveArray { - public: - using TypeClass = DayTimeIntervalType; - - explicit DayTimeIntervalArray(const std::shared_ptr& data); - - DayTimeIntervalArray(const std::shared_ptr& type, int64_t length, - const std::shared_ptr& data, - const std::shared_ptr& null_bitmap = NULLPTR, - int64_t null_count = kUnknownNullCount, int64_t offset = 0); - - TypeClass::DayMilliseconds GetValue(int64_t i) const; - TypeClass::DayMilliseconds Value(int64_t i) const { return GetValue(i); } - - // For compatibility with Take kernel. - TypeClass::DayMilliseconds GetView(int64_t i) const { return GetValue(i); } - - int32_t byte_width() const { return sizeof(TypeClass::DayMilliseconds); } - - const uint8_t* raw_values() const { return raw_values_ + data_->offset * byte_width(); } - - protected: - inline void SetData(const std::shared_ptr& data) { - this->PrimitiveArray::SetData(data); - } -}; - -// ---------------------------------------------------------------------- -// Decimal128Array - -/// Concrete Array class for 128-bit decimal data -class ARROW_EXPORT Decimal128Array : public FixedSizeBinaryArray { - public: - using TypeClass = Decimal128Type; - - using FixedSizeBinaryArray::FixedSizeBinaryArray; - - /// \brief Construct Decimal128Array from ArrayData instance - explicit Decimal128Array(const std::shared_ptr& data); - - std::string FormatValue(int64_t i) const; -}; - -// Backward compatibility -using DecimalArray = Decimal128Array; - -// ---------------------------------------------------------------------- -// Struct - -/// Concrete Array class for struct data -class ARROW_EXPORT StructArray : public Array { - public: - using TypeClass = StructType; - - explicit StructArray(const std::shared_ptr& data); - - StructArray(const std::shared_ptr& type, int64_t length, - const std::vector>& children, - std::shared_ptr null_bitmap = NULLPTR, - int64_t null_count = kUnknownNullCount, int64_t offset = 0); - - /// \brief Return a StructArray from child arrays and field names. - /// - /// The length and data type are automatically inferred from the arguments. - /// There should be at least one child array. - static Result> Make( - const std::vector>& children, - const std::vector& field_names, - std::shared_ptr null_bitmap = NULLPTR, - int64_t null_count = kUnknownNullCount, int64_t offset = 0); - - const StructType* struct_type() const; - - // Return a shared pointer in case the requestor desires to share ownership - // with this array. The returned array has its offset, length and null - // count adjusted. - std::shared_ptr field(int pos) const; - - /// Returns null if name not found - std::shared_ptr GetFieldByName(const std::string& name) const; - - /// \brief Flatten this array as a vector of arrays, one for each field - /// - /// \param[in] pool The pool to allocate null bitmaps from, if necessary - /// \param[out] out The resulting vector of arrays - Status Flatten(MemoryPool* pool, ArrayVector* out) const; - - private: - // For caching boxed child data - // XXX This is not handled in a thread-safe manner. - mutable std::vector> boxed_fields_; -}; - -// ---------------------------------------------------------------------- -// Union - -/// Concrete Array class for union data -class ARROW_EXPORT UnionArray : public Array { - public: - using TypeClass = UnionType; - using type_id_t = uint8_t; - - explicit UnionArray(const std::shared_ptr& data); - - UnionArray(const std::shared_ptr& type, int64_t length, - const std::vector>& children, - const std::shared_ptr& type_ids, - const std::shared_ptr& value_offsets = NULLPTR, - const std::shared_ptr& null_bitmap = NULLPTR, - int64_t null_count = kUnknownNullCount, int64_t offset = 0); - - /// \brief Construct Dense UnionArray from types_ids, value_offsets and children - /// - /// This function does the bare minimum of validation of the offsets and - /// input types. The value_offsets are assumed to be well-formed. - /// - /// \param[in] type_ids An array of 8-bit signed integers, enumerated from - /// 0 corresponding to each type. - /// \param[in] value_offsets An array of signed int32 values indicating the - /// relative offset into the respective child array for the type in a given slot. - /// The respective offsets for each child value array must be in order / increasing. - /// \param[in] children Vector of children Arrays containing the data for each type. - /// \param[in] field_names Vector of strings containing the name of each field. - /// \param[in] type_codes Vector of type codes. - /// \param[out] out Will have length equal to value_offsets.length() - static Status MakeDense(const Array& type_ids, const Array& value_offsets, - const std::vector>& children, - const std::vector& field_names, - const std::vector& type_codes, - std::shared_ptr* out); - - /// \brief Construct Dense UnionArray from types_ids, value_offsets and children - /// - /// This function does the bare minimum of validation of the offsets and - /// input types. The value_offsets are assumed to be well-formed. - /// - /// \param[in] type_ids An array of 8-bit signed integers, enumerated from - /// 0 corresponding to each type. - /// \param[in] value_offsets An array of signed int32 values indicating the - /// relative offset into the respective child array for the type in a given slot. - /// The respective offsets for each child value array must be in order / increasing. - /// \param[in] children Vector of children Arrays containing the data for each type. - /// \param[in] field_names Vector of strings containing the name of each field. - /// \param[out] out Will have length equal to value_offsets.length() - static Status MakeDense(const Array& type_ids, const Array& value_offsets, - const std::vector>& children, - const std::vector& field_names, - std::shared_ptr* out) { - return MakeDense(type_ids, value_offsets, children, field_names, {}, out); - } - - /// \brief Construct Dense UnionArray from types_ids, value_offsets and children - /// - /// This function does the bare minimum of validation of the offsets and - /// input types. The value_offsets are assumed to be well-formed. - /// - /// \param[in] type_ids An array of 8-bit signed integers, enumerated from - /// 0 corresponding to each type. - /// \param[in] value_offsets An array of signed int32 values indicating the - /// relative offset into the respective child array for the type in a given slot. - /// The respective offsets for each child value array must be in order / increasing. - /// \param[in] children Vector of children Arrays containing the data for each type. - /// \param[in] type_codes Vector of type codes. - /// \param[out] out Will have length equal to value_offsets.length() - static Status MakeDense(const Array& type_ids, const Array& value_offsets, - const std::vector>& children, - const std::vector& type_codes, - std::shared_ptr* out) { - return MakeDense(type_ids, value_offsets, children, {}, type_codes, out); - } - - /// \brief Construct Dense UnionArray from types_ids, value_offsets and children - /// - /// This function does the bare minimum of validation of the offsets and - /// input types. The value_offsets are assumed to be well-formed. - /// - /// The name of each field is filled by the index of the field. - /// - /// \param[in] type_ids An array of 8-bit signed integers, enumerated from - /// 0 corresponding to each type. - /// \param[in] value_offsets An array of signed int32 values indicating the - /// relative offset into the respective child array for the type in a given slot. - /// The respective offsets for each child value array must be in order / increasing. - /// \param[in] children Vector of children Arrays containing the data for each type. - /// \param[out] out Will have length equal to value_offsets.length() - static Status MakeDense(const Array& type_ids, const Array& value_offsets, - const std::vector>& children, - std::shared_ptr* out) { - return MakeDense(type_ids, value_offsets, children, {}, {}, out); - } - - /// \brief Construct Sparse UnionArray from type_ids and children - /// - /// This function does the bare minimum of validation of the offsets and - /// input types. - /// - /// \param[in] type_ids An array of 8-bit signed integers, enumerated from - /// 0 corresponding to each type. - /// \param[in] children Vector of children Arrays containing the data for each type. - /// \param[in] field_names Vector of strings containing the name of each field. - /// \param[in] type_codes Vector of type codes. - /// \param[out] out Will have length equal to type_ids.length() - static Status MakeSparse(const Array& type_ids, - const std::vector>& children, - const std::vector& field_names, - const std::vector& type_codes, - std::shared_ptr* out); - - /// \brief Construct Sparse UnionArray from type_ids and children - /// - /// This function does the bare minimum of validation of the offsets and - /// input types. - /// - /// \param[in] type_ids An array of 8-bit signed integers, enumerated from - /// 0 corresponding to each type. - /// \param[in] children Vector of children Arrays containing the data for each type. - /// \param[in] field_names Vector of strings containing the name of each field. - /// \param[out] out Will have length equal to type_ids.length() - static Status MakeSparse(const Array& type_ids, - const std::vector>& children, - const std::vector& field_names, - std::shared_ptr* out) { - return MakeSparse(type_ids, children, field_names, {}, out); - } - - /// \brief Construct Sparse UnionArray from type_ids and children - /// - /// This function does the bare minimum of validation of the offsets and - /// input types. - /// - /// \param[in] type_ids An array of 8-bit signed integers, enumerated from - /// 0 corresponding to each type. - /// \param[in] children Vector of children Arrays containing the data for each type. - /// \param[in] type_codes Vector of type codes. - /// \param[out] out Will have length equal to type_ids.length() - static Status MakeSparse(const Array& type_ids, - const std::vector>& children, - const std::vector& type_codes, - std::shared_ptr* out) { - return MakeSparse(type_ids, children, {}, type_codes, out); - } - - /// \brief Construct Sparse UnionArray from type_ids and children - /// - /// This function does the bare minimum of validation of the offsets and - /// input types. - /// - /// The name of each field is filled by the index of the field. - /// - /// \param[in] type_ids An array of 8-bit signed integers, enumerated from - /// 0 corresponding to each type. - /// \param[in] children Vector of children Arrays containing the data for each type. - /// \param[out] out Will have length equal to type_ids.length() - static Status MakeSparse(const Array& type_ids, - const std::vector>& children, - std::shared_ptr* out) { - return MakeSparse(type_ids, children, {}, {}, out); - } - - /// Note that this buffer does not account for any slice offset - std::shared_ptr type_ids() const { return data_->buffers[1]; } - - /// Note that this buffer does not account for any slice offset - std::shared_ptr value_offsets() const { return data_->buffers[2]; } - - int32_t value_offset(int64_t i) const { return raw_value_offsets_[i + data_->offset]; } - - const type_id_t* raw_type_ids() const { return raw_type_ids_ + data_->offset; } - const int32_t* raw_value_offsets() const { return raw_value_offsets_ + data_->offset; } - - UnionMode::type mode() const { - return internal::checked_cast(*type()).mode(); - } - - // Return the given field as an individual array. - // For sparse unions, the returned array has its offset, length and null - // count adjusted. - // For dense unions, the returned array is unchanged. - std::shared_ptr child(int pos) const; - - /// Only use this while the UnionArray is in scope - const Array* UnsafeChild(int pos) const; - - protected: - void SetData(const std::shared_ptr& data); - - const type_id_t* raw_type_ids_; - const int32_t* raw_value_offsets_; - - // For caching boxed child data - mutable std::vector> boxed_fields_; -}; - -// ---------------------------------------------------------------------- -// DictionaryArray - -/// \brief Array type for dictionary-encoded data with a -/// data-dependent dictionary -/// -/// A dictionary array contains an array of non-negative integers (the -/// "dictionary indices") along with a data type containing a "dictionary" -/// corresponding to the distinct values represented in the data. -/// -/// For example, the array -/// -/// ["foo", "bar", "foo", "bar", "foo", "bar"] -/// -/// with dictionary ["bar", "foo"], would have dictionary array representation -/// -/// indices: [1, 0, 1, 0, 1, 0] -/// dictionary: ["bar", "foo"] -/// -/// The indices in principle may have any integer type (signed or unsigned), -/// though presently data in IPC exchanges must be signed int32. -class ARROW_EXPORT DictionaryArray : public Array { - public: - using TypeClass = DictionaryType; - - explicit DictionaryArray(const std::shared_ptr& data); - - DictionaryArray(const std::shared_ptr& type, - const std::shared_ptr& indices, - const std::shared_ptr& dictionary); - - /// \brief Construct DictionaryArray from dictionary and indices - /// array and validate - /// - /// This function does the validation of the indices and input type. It checks if - /// all indices are non-negative and smaller than the size of the dictionary - /// - /// \param[in] type a dictionary type - /// \param[in] dictionary the dictionary with same value type as the - /// type object - /// \param[in] indices an array of non-negative signed - /// integers smaller than the size of the dictionary - /// \param[out] out the resulting DictionaryArray instance - static Status FromArrays(const std::shared_ptr& type, - const std::shared_ptr& indices, - const std::shared_ptr& dictionary, - std::shared_ptr* out); - - /// \brief Transpose this DictionaryArray - /// - /// This method constructs a new dictionary array with the given dictionary type, - /// transposing indices using the transpose map. - /// The type and the transpose map are typically computed using - /// DictionaryType::Unify. - /// - /// \param[in] pool a pool to allocate the array data from - /// \param[in] type the new type object - /// \param[in] dictionary the new dictionary - /// \param[in] transpose_map a vector transposing this array's indices - /// into the target array's indices - /// \param[out] out the resulting DictionaryArray instance - Status Transpose(MemoryPool* pool, const std::shared_ptr& type, - const std::shared_ptr& dictionary, - const std::vector& transpose_map, - std::shared_ptr* out) const; - - /// \brief Return the dictionary for this array, which is stored as - /// a member of the ArrayData internal structure - std::shared_ptr dictionary() const; - std::shared_ptr indices() const; - - const DictionaryType* dict_type() const { return dict_type_; } - - private: - void SetData(const std::shared_ptr& data); - const DictionaryType* dict_type_; - std::shared_ptr indices_; -}; - -/// \brief Perform any validation checks to determine obvious inconsistencies -/// with the array's internal data -/// -/// This can be an expensive check. -/// -/// \param array an Array instance -/// \return Status -ARROW_EXPORT -Status ValidateArray(const Array& array); - -} // namespace arrow - -#endif // ARROW_ARRAY_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/array/builder_adaptive.h b/cpp/thirdparty/knowhere_build/include/arrow/array/builder_adaptive.h deleted file mode 100644 index 7f24109526..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/array/builder_adaptive.h +++ /dev/null @@ -1,175 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include - -#include "arrow/array/builder_base.h" - -namespace arrow { - -namespace internal { - -class ARROW_EXPORT AdaptiveIntBuilderBase : public ArrayBuilder { - public: - explicit AdaptiveIntBuilderBase(MemoryPool* pool); - - /// \brief Append multiple nulls - /// \param[in] length the number of nulls to append - Status AppendNulls(int64_t length) final { - ARROW_RETURN_NOT_OK(CommitPendingData()); - ARROW_RETURN_NOT_OK(Reserve(length)); - memset(data_->mutable_data() + length_ * int_size_, 0, int_size_ * length); - UnsafeSetNull(length); - return Status::OK(); - } - - Status AppendNull() final { - pending_data_[pending_pos_] = 0; - pending_valid_[pending_pos_] = 0; - pending_has_nulls_ = true; - ++pending_pos_; - - if (ARROW_PREDICT_FALSE(pending_pos_ >= pending_size_)) { - return CommitPendingData(); - } - return Status::OK(); - } - - void Reset() override; - Status Resize(int64_t capacity) override; - - protected: - virtual Status CommitPendingData() = 0; - - std::shared_ptr data_; - uint8_t* raw_data_; - uint8_t int_size_; - - static constexpr int32_t pending_size_ = 1024; - uint8_t pending_valid_[pending_size_]; - uint64_t pending_data_[pending_size_]; - int32_t pending_pos_; - bool pending_has_nulls_; -}; - -} // namespace internal - -class ARROW_EXPORT AdaptiveUIntBuilder : public internal::AdaptiveIntBuilderBase { - public: - explicit AdaptiveUIntBuilder(MemoryPool* pool ARROW_MEMORY_POOL_DEFAULT); - - using ArrayBuilder::Advance; - using internal::AdaptiveIntBuilderBase::Reset; - - /// Scalar append - Status Append(const uint64_t val) { - pending_data_[pending_pos_] = val; - pending_valid_[pending_pos_] = 1; - ++pending_pos_; - - if (ARROW_PREDICT_FALSE(pending_pos_ >= pending_size_)) { - return CommitPendingData(); - } - return Status::OK(); - } - - /// \brief Append a sequence of elements in one shot - /// \param[in] values a contiguous C array of values - /// \param[in] length the number of values to append - /// \param[in] valid_bytes an optional sequence of bytes where non-zero - /// indicates a valid (non-null) value - /// \return Status - Status AppendValues(const uint64_t* values, int64_t length, - const uint8_t* valid_bytes = NULLPTR); - - Status FinishInternal(std::shared_ptr* out) override; - - protected: - Status CommitPendingData() override; - Status ExpandIntSize(uint8_t new_int_size); - - Status AppendValuesInternal(const uint64_t* values, int64_t length, - const uint8_t* valid_bytes); - - template - typename std::enable_if= sizeof(new_type), Status>::type - ExpandIntSizeInternal(); -#define __LESS(a, b) (a) < (b) - template - typename std::enable_if<__LESS(sizeof(old_type), sizeof(new_type)), Status>::type - ExpandIntSizeInternal(); -#undef __LESS - - template - Status ExpandIntSizeN(); -}; - -class ARROW_EXPORT AdaptiveIntBuilder : public internal::AdaptiveIntBuilderBase { - public: - explicit AdaptiveIntBuilder(MemoryPool* pool ARROW_MEMORY_POOL_DEFAULT); - - using ArrayBuilder::Advance; - using internal::AdaptiveIntBuilderBase::Reset; - - /// Scalar append - Status Append(const int64_t val) { - auto v = static_cast(val); - - pending_data_[pending_pos_] = v; - pending_valid_[pending_pos_] = 1; - ++pending_pos_; - - if (ARROW_PREDICT_FALSE(pending_pos_ >= pending_size_)) { - return CommitPendingData(); - } - return Status::OK(); - } - - /// \brief Append a sequence of elements in one shot - /// \param[in] values a contiguous C array of values - /// \param[in] length the number of values to append - /// \param[in] valid_bytes an optional sequence of bytes where non-zero - /// indicates a valid (non-null) value - /// \return Status - Status AppendValues(const int64_t* values, int64_t length, - const uint8_t* valid_bytes = NULLPTR); - - Status FinishInternal(std::shared_ptr* out) override; - - protected: - Status CommitPendingData() override; - Status ExpandIntSize(uint8_t new_int_size); - - Status AppendValuesInternal(const int64_t* values, int64_t length, - const uint8_t* valid_bytes); - - template - typename std::enable_if= sizeof(new_type), Status>::type - ExpandIntSizeInternal(); -#define __LESS(a, b) (a) < (b) - template - typename std::enable_if<__LESS(sizeof(old_type), sizeof(new_type)), Status>::type - ExpandIntSizeInternal(); -#undef __LESS - - template - Status ExpandIntSizeN(); -}; - -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/array/builder_base.h b/cpp/thirdparty/knowhere_build/include/arrow/array/builder_base.h deleted file mode 100644 index 36f6c7a2a4..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/array/builder_base.h +++ /dev/null @@ -1,219 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include // IWYU pragma: keep -#include -#include -#include -#include -#include -#include -#include - -#include "arrow/buffer-builder.h" -#include "arrow/status.h" -#include "arrow/type.h" -#include "arrow/type_traits.h" -#include "arrow/util/macros.h" -#include "arrow/util/type_traits.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Array; -struct ArrayData; -class MemoryPool; - -constexpr int64_t kMinBuilderCapacity = 1 << 5; -constexpr int64_t kListMaximumElements = std::numeric_limits::max() - 1; - -/// Base class for all data array builders. -/// -/// This class provides a facilities for incrementally building the null bitmap -/// (see Append methods) and as a side effect the current number of slots and -/// the null count. -/// -/// \note Users are expected to use builders as one of the concrete types below. -/// For example, ArrayBuilder* pointing to BinaryBuilder should be downcast before use. -class ARROW_EXPORT ArrayBuilder { - public: - explicit ArrayBuilder(const std::shared_ptr& type, MemoryPool* pool) - : type_(type), pool_(pool), null_bitmap_builder_(pool) {} - - virtual ~ArrayBuilder() = default; - - /// For nested types. Since the objects are owned by this class instance, we - /// skip shared pointers and just return a raw pointer - ArrayBuilder* child(int i) { return children_[i].get(); } - - int num_children() const { return static_cast(children_.size()); } - - int64_t length() const { return length_; } - int64_t null_count() const { return null_count_; } - int64_t capacity() const { return capacity_; } - - /// \brief Ensure that enough memory has been allocated to fit the indicated - /// number of total elements in the builder, including any that have already - /// been appended. Does not account for reallocations that may be due to - /// variable size data, like binary values. To make space for incremental - /// appends, use Reserve instead. - /// - /// \param[in] capacity the minimum number of total array values to - /// accommodate. Must be greater than the current capacity. - /// \return Status - virtual Status Resize(int64_t capacity); - - /// \brief Ensure that there is enough space allocated to add the indicated - /// number of elements without any further calls to Resize. Overallocation is - /// used in order to minimize the impact of incremental Reserve() calls. - /// - /// \param[in] additional_capacity the number of additional array values - /// \return Status - Status Reserve(int64_t additional_capacity) { - auto current_capacity = capacity(); - auto min_capacity = length() + additional_capacity; - if (min_capacity <= current_capacity) return Status::OK(); - - // leave growth factor up to BufferBuilder - auto new_capacity = BufferBuilder::GrowByFactor(current_capacity, min_capacity); - return Resize(new_capacity); - } - - /// Reset the builder. - virtual void Reset(); - - virtual Status AppendNull() = 0; - virtual Status AppendNulls(int64_t length) = 0; - - /// For cases where raw data was memcpy'd into the internal buffers, allows us - /// to advance the length of the builder. It is your responsibility to use - /// this function responsibly. - Status Advance(int64_t elements); - - /// \brief Return result of builder as an internal generic ArrayData - /// object. Resets builder except for dictionary builder - /// - /// \param[out] out the finalized ArrayData object - /// \return Status - virtual Status FinishInternal(std::shared_ptr* out) = 0; - - /// \brief Return result of builder as an Array object. - /// - /// The builder is reset except for DictionaryBuilder. - /// - /// \param[out] out the finalized Array object - /// \return Status - Status Finish(std::shared_ptr* out); - - std::shared_ptr type() const { return type_; } - - protected: - /// Append to null bitmap - Status AppendToBitmap(bool is_valid); - - /// Vector append. Treat each zero byte as a null. If valid_bytes is null - /// assume all of length bits are valid. - Status AppendToBitmap(const uint8_t* valid_bytes, int64_t length); - - /// Uniform append. Append N times the same validity bit. - Status AppendToBitmap(int64_t num_bits, bool value); - - /// Set the next length bits to not null (i.e. valid). - Status SetNotNull(int64_t length); - - // Unsafe operations (don't check capacity/don't resize) - - void UnsafeAppendNull() { UnsafeAppendToBitmap(false); } - - // Append to null bitmap, update the length - void UnsafeAppendToBitmap(bool is_valid) { - null_bitmap_builder_.UnsafeAppend(is_valid); - ++length_; - if (!is_valid) ++null_count_; - } - - // Vector append. Treat each zero byte as a nullzero. If valid_bytes is null - // assume all of length bits are valid. - void UnsafeAppendToBitmap(const uint8_t* valid_bytes, int64_t length) { - if (valid_bytes == NULLPTR) { - return UnsafeSetNotNull(length); - } - null_bitmap_builder_.UnsafeAppend(valid_bytes, length); - length_ += length; - null_count_ = null_bitmap_builder_.false_count(); - } - - // Append the same validity value a given number of times. - void UnsafeAppendToBitmap(const int64_t num_bits, bool value) { - if (value) { - UnsafeSetNotNull(num_bits); - } else { - UnsafeSetNull(num_bits); - } - } - - void UnsafeAppendToBitmap(const std::vector& is_valid); - - // Set the next validity bits to not null (i.e. valid). - void UnsafeSetNotNull(int64_t length); - - // Set the next validity bits to null (i.e. invalid). - void UnsafeSetNull(int64_t length); - - static Status TrimBuffer(const int64_t bytes_filled, ResizableBuffer* buffer); - - /// \brief Finish to an array of the specified ArrayType - template - Status FinishTyped(std::shared_ptr* out) { - std::shared_ptr out_untyped; - ARROW_RETURN_NOT_OK(Finish(&out_untyped)); - *out = std::static_pointer_cast(std::move(out_untyped)); - return Status::OK(); - } - - static Status CheckCapacity(int64_t new_capacity, int64_t old_capacity) { - if (new_capacity < 0) { - return Status::Invalid("Resize capacity must be positive"); - } - - if (new_capacity < old_capacity) { - return Status::Invalid("Resize cannot downsize"); - } - - return Status::OK(); - } - - std::shared_ptr type_; - MemoryPool* pool_; - - TypedBufferBuilder null_bitmap_builder_; - int64_t null_count_ = 0; - - // Array length, so far. Also, the index of the next element to be added - int64_t length_ = 0; - int64_t capacity_ = 0; - - // Child value array builders. These are owned by this class - std::vector> children_; - - private: - ARROW_DISALLOW_COPY_AND_ASSIGN(ArrayBuilder); -}; - -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/array/builder_binary.h b/cpp/thirdparty/knowhere_build/include/arrow/array/builder_binary.h deleted file mode 100644 index 47d3bae4b8..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/array/builder_binary.h +++ /dev/null @@ -1,395 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include -#include -#include - -#include "arrow/array.h" -#include "arrow/array/builder_base.h" -#include "arrow/buffer-builder.h" -#include "arrow/status.h" -#include "arrow/type_traits.h" -#include "arrow/util/macros.h" -#include "arrow/util/string_view.h" // IWYU pragma: export - -namespace arrow { - -constexpr int64_t kBinaryMemoryLimit = std::numeric_limits::max() - 1; - -// ---------------------------------------------------------------------- -// Binary and String - -/// \class BinaryBuilder -/// \brief Builder class for variable-length binary data -class ARROW_EXPORT BinaryBuilder : public ArrayBuilder { - public: - explicit BinaryBuilder(MemoryPool* pool ARROW_MEMORY_POOL_DEFAULT); - - BinaryBuilder(const std::shared_ptr& type, MemoryPool* pool); - - Status Append(const uint8_t* value, int32_t length) { - ARROW_RETURN_NOT_OK(Reserve(1)); - ARROW_RETURN_NOT_OK(AppendNextOffset()); - // Safety check for UBSAN. - if (ARROW_PREDICT_TRUE(length > 0)) { - ARROW_RETURN_NOT_OK(value_data_builder_.Append(value, length)); - } - - UnsafeAppendToBitmap(true); - return Status::OK(); - } - - Status AppendNulls(int64_t length) final { - const int64_t num_bytes = value_data_builder_.length(); - if (ARROW_PREDICT_FALSE(num_bytes > kBinaryMemoryLimit)) { - return AppendOverflow(num_bytes); - } - ARROW_RETURN_NOT_OK(Reserve(length)); - for (int64_t i = 0; i < length; ++i) { - offsets_builder_.UnsafeAppend(static_cast(num_bytes)); - } - UnsafeAppendToBitmap(length, false); - return Status::OK(); - } - - Status AppendNull() final { - ARROW_RETURN_NOT_OK(AppendNextOffset()); - ARROW_RETURN_NOT_OK(Reserve(1)); - UnsafeAppendToBitmap(false); - return Status::OK(); - } - - Status Append(const char* value, int32_t length) { - return Append(reinterpret_cast(value), length); - } - - Status Append(util::string_view value) { - return Append(value.data(), static_cast(value.size())); - } - - /// \brief Append without checking capacity - /// - /// Offsets and data should have been presized using Reserve() and - /// ReserveData(), respectively. - void UnsafeAppend(const uint8_t* value, int32_t length) { - UnsafeAppendNextOffset(); - value_data_builder_.UnsafeAppend(value, length); - UnsafeAppendToBitmap(true); - } - - void UnsafeAppend(const char* value, int32_t length) { - UnsafeAppend(reinterpret_cast(value), length); - } - - void UnsafeAppend(const std::string& value) { - UnsafeAppend(value.c_str(), static_cast(value.size())); - } - - void UnsafeAppend(util::string_view value) { - UnsafeAppend(value.data(), static_cast(value.size())); - } - - void UnsafeAppendNull() { - const int64_t num_bytes = value_data_builder_.length(); - offsets_builder_.UnsafeAppend(static_cast(num_bytes)); - UnsafeAppendToBitmap(false); - } - - void Reset() override; - Status Resize(int64_t capacity) override; - - /// \brief Ensures there is enough allocated capacity to append the indicated - /// number of bytes to the value data buffer without additional allocations - Status ReserveData(int64_t elements); - - Status FinishInternal(std::shared_ptr* out) override; - - /// \cond FALSE - using ArrayBuilder::Finish; - /// \endcond - - Status Finish(std::shared_ptr* out) { return FinishTyped(out); } - - /// \return size of values buffer so far - int64_t value_data_length() const { return value_data_builder_.length(); } - /// \return capacity of values buffer - int64_t value_data_capacity() const { return value_data_builder_.capacity(); } - - /// Temporary access to a value. - /// - /// This pointer becomes invalid on the next modifying operation. - const uint8_t* GetValue(int64_t i, int32_t* out_length) const; - - /// Temporary access to a value. - /// - /// This view becomes invalid on the next modifying operation. - util::string_view GetView(int64_t i) const; - - protected: - TypedBufferBuilder offsets_builder_; - TypedBufferBuilder value_data_builder_; - - Status AppendOverflow(int64_t num_bytes); - - Status AppendNextOffset() { - const int64_t num_bytes = value_data_builder_.length(); - if (ARROW_PREDICT_FALSE(num_bytes > kBinaryMemoryLimit)) { - return AppendOverflow(num_bytes); - } - return offsets_builder_.Append(static_cast(num_bytes)); - } - - void UnsafeAppendNextOffset() { - const int64_t num_bytes = value_data_builder_.length(); - offsets_builder_.UnsafeAppend(static_cast(num_bytes)); - } -}; - -/// \class StringBuilder -/// \brief Builder class for UTF8 strings -class ARROW_EXPORT StringBuilder : public BinaryBuilder { - public: - using BinaryBuilder::BinaryBuilder; - explicit StringBuilder(MemoryPool* pool ARROW_MEMORY_POOL_DEFAULT); - - using BinaryBuilder::Append; - using BinaryBuilder::Reset; - using BinaryBuilder::UnsafeAppend; - - /// \brief Append a sequence of strings in one shot. - /// - /// \param[in] values a vector of strings - /// \param[in] valid_bytes an optional sequence of bytes where non-zero - /// indicates a valid (non-null) value - /// \return Status - Status AppendValues(const std::vector& values, - const uint8_t* valid_bytes = NULLPTR); - - /// \brief Append a sequence of nul-terminated strings in one shot. - /// If one of the values is NULL, it is processed as a null - /// value even if the corresponding valid_bytes entry is 1. - /// - /// \param[in] values a contiguous C array of nul-terminated char * - /// \param[in] length the number of values to append - /// \param[in] valid_bytes an optional sequence of bytes where non-zero - /// indicates a valid (non-null) value - /// \return Status - Status AppendValues(const char** values, int64_t length, - const uint8_t* valid_bytes = NULLPTR); - - /// \cond FALSE - using ArrayBuilder::Finish; - /// \endcond - - Status Finish(std::shared_ptr* out) { return FinishTyped(out); } -}; - -// ---------------------------------------------------------------------- -// FixedSizeBinaryBuilder - -class ARROW_EXPORT FixedSizeBinaryBuilder : public ArrayBuilder { - public: - FixedSizeBinaryBuilder(const std::shared_ptr& type, - MemoryPool* pool ARROW_MEMORY_POOL_DEFAULT); - - Status Append(const uint8_t* value) { - ARROW_RETURN_NOT_OK(Reserve(1)); - UnsafeAppend(value); - return Status::OK(); - } - - Status Append(const char* value) { - return Append(reinterpret_cast(value)); - } - - Status Append(const util::string_view& view) { - ARROW_RETURN_NOT_OK(Reserve(1)); - UnsafeAppend(view); - return Status::OK(); - } - - Status Append(const std::string& s) { - ARROW_RETURN_NOT_OK(Reserve(1)); - UnsafeAppend(s); - return Status::OK(); - } - - template - Status Append(const std::array& value) { - ARROW_RETURN_NOT_OK(Reserve(1)); - UnsafeAppend( - util::string_view(reinterpret_cast(value.data()), value.size())); - return Status::OK(); - } - - Status AppendValues(const uint8_t* data, int64_t length, - const uint8_t* valid_bytes = NULLPTR); - - Status AppendNull() final; - - Status AppendNulls(int64_t length) final; - - void UnsafeAppend(const uint8_t* value) { - UnsafeAppendToBitmap(true); - if (ARROW_PREDICT_TRUE(byte_width_ > 0)) { - byte_builder_.UnsafeAppend(value, byte_width_); - } - } - - void UnsafeAppend(util::string_view value) { -#ifndef NDEBUG - CheckValueSize(static_cast(value.size())); -#endif - UnsafeAppend(reinterpret_cast(value.data())); - } - - void UnsafeAppendNull() { - UnsafeAppendToBitmap(false); - byte_builder_.UnsafeAdvance(byte_width_); - } - - void Reset() override; - Status Resize(int64_t capacity) override; - Status FinishInternal(std::shared_ptr* out) override; - - /// \cond FALSE - using ArrayBuilder::Finish; - /// \endcond - - Status Finish(std::shared_ptr* out) { return FinishTyped(out); } - - /// \return size of values buffer so far - int64_t value_data_length() const { return byte_builder_.length(); } - - int32_t byte_width() const { return byte_width_; } - - /// Temporary access to a value. - /// - /// This pointer becomes invalid on the next modifying operation. - const uint8_t* GetValue(int64_t i) const; - - /// Temporary access to a value. - /// - /// This view becomes invalid on the next modifying operation. - util::string_view GetView(int64_t i) const; - - protected: - int32_t byte_width_; - BufferBuilder byte_builder_; - - /// Temporary access to a value. - /// - /// This pointer becomes invalid on the next modifying operation. - uint8_t* GetMutableValue(int64_t i) { - uint8_t* data_ptr = byte_builder_.mutable_data(); - return data_ptr + i * byte_width_; - } - -#ifndef NDEBUG - void CheckValueSize(int64_t size); -#endif -}; - -// ---------------------------------------------------------------------- -// Chunked builders: build a sequence of BinaryArray or StringArray that are -// limited to a particular size (to the upper limit of 2GB) - -namespace internal { - -class ARROW_EXPORT ChunkedBinaryBuilder { - public: - ChunkedBinaryBuilder(int32_t max_chunk_value_length, - MemoryPool* pool ARROW_MEMORY_POOL_DEFAULT); - - ChunkedBinaryBuilder(int32_t max_chunk_value_length, int32_t max_chunk_length, - MemoryPool* pool ARROW_MEMORY_POOL_DEFAULT); - - virtual ~ChunkedBinaryBuilder() = default; - - Status Append(const uint8_t* value, int32_t length) { - if (ARROW_PREDICT_FALSE(length + builder_->value_data_length() > - max_chunk_value_length_)) { - if (builder_->value_data_length() == 0) { - // The current item is larger than max_chunk_size_; - // this chunk will be oversize and hold *only* this item - ARROW_RETURN_NOT_OK(builder_->Append(value, length)); - return NextChunk(); - } - // The current item would cause builder_->value_data_length() to exceed - // max_chunk_size_, so finish this chunk and append the current item to the next - // chunk - ARROW_RETURN_NOT_OK(NextChunk()); - return Append(value, length); - } - - if (ARROW_PREDICT_FALSE(builder_->length() == max_chunk_length_)) { - // The current item would cause builder_->value_data_length() to exceed - // max_chunk_size_, so finish this chunk and append the current item to the next - // chunk - ARROW_RETURN_NOT_OK(NextChunk()); - } - - return builder_->Append(value, length); - } - - Status Append(const util::string_view& value) { - return Append(reinterpret_cast(value.data()), - static_cast(value.size())); - } - - Status AppendNull() { - if (ARROW_PREDICT_FALSE(builder_->length() == max_chunk_length_)) { - ARROW_RETURN_NOT_OK(NextChunk()); - } - return builder_->AppendNull(); - } - - Status Reserve(int64_t values); - - virtual Status Finish(ArrayVector* out); - - protected: - Status NextChunk(); - - // maximum total character data size per chunk - int64_t max_chunk_value_length_; - - // maximum elements allowed per chunk - int64_t max_chunk_length_ = kListMaximumElements; - - // when Reserve() would cause builder_ to exceed its max_chunk_length_, - // add to extra_capacity_ instead and wait to reserve until the next chunk - int64_t extra_capacity_ = 0; - - std::unique_ptr builder_; - std::vector> chunks_; -}; - -class ARROW_EXPORT ChunkedStringBuilder : public ChunkedBinaryBuilder { - public: - using ChunkedBinaryBuilder::ChunkedBinaryBuilder; - - Status Finish(ArrayVector* out) override; -}; - -} // namespace internal - -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/array/builder_decimal.h b/cpp/thirdparty/knowhere_build/include/arrow/array/builder_decimal.h deleted file mode 100644 index e64d16528d..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/array/builder_decimal.h +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include - -#include "arrow/array/builder_base.h" -#include "arrow/array/builder_binary.h" - -namespace arrow { - -class Decimal128; - -class ARROW_EXPORT Decimal128Builder : public FixedSizeBinaryBuilder { - public: - explicit Decimal128Builder(const std::shared_ptr& type, - MemoryPool* pool ARROW_MEMORY_POOL_DEFAULT); - - using FixedSizeBinaryBuilder::Append; - using FixedSizeBinaryBuilder::AppendValues; - using FixedSizeBinaryBuilder::Reset; - - Status Append(Decimal128 val); - void UnsafeAppend(Decimal128 val); - void UnsafeAppend(util::string_view val); - - Status FinishInternal(std::shared_ptr* out) override; - - /// \cond FALSE - using ArrayBuilder::Finish; - /// \endcond - - Status Finish(std::shared_ptr* out) { return FinishTyped(out); } -}; - -using DecimalBuilder = Decimal128Builder; - -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/array/builder_dict.h b/cpp/thirdparty/knowhere_build/include/arrow/array/builder_dict.h deleted file mode 100644 index 93cad2975a..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/array/builder_dict.h +++ /dev/null @@ -1,369 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include - -#include "arrow/array/builder_adaptive.h" // IWYU pragma: export -#include "arrow/array/builder_base.h" // IWYU pragma: export - -#include "arrow/array.h" - -namespace arrow { - -// ---------------------------------------------------------------------- -// Dictionary builder - -namespace internal { - -template -struct DictionaryScalar { - using type = typename T::c_type; -}; - -template <> -struct DictionaryScalar { - using type = util::string_view; -}; - -template <> -struct DictionaryScalar { - using type = util::string_view; -}; - -template <> -struct DictionaryScalar { - using type = util::string_view; -}; - -class ARROW_EXPORT DictionaryMemoTable { - public: - explicit DictionaryMemoTable(const std::shared_ptr& type); - explicit DictionaryMemoTable(const std::shared_ptr& dictionary); - ~DictionaryMemoTable(); - - int32_t GetOrInsert(const bool& value); - int32_t GetOrInsert(const int8_t& value); - int32_t GetOrInsert(const int16_t& value); - int32_t GetOrInsert(const int32_t& value); - int32_t GetOrInsert(const int64_t& value); - int32_t GetOrInsert(const uint8_t& value); - int32_t GetOrInsert(const uint16_t& value); - int32_t GetOrInsert(const uint32_t& value); - int32_t GetOrInsert(const uint64_t& value); - int32_t GetOrInsert(const float& value); - int32_t GetOrInsert(const double& value); - int32_t GetOrInsert(const util::string_view& value); - - Status GetArrayData(MemoryPool* pool, int64_t start_offset, - std::shared_ptr* out); - - int32_t size() const; - - private: - class DictionaryMemoTableImpl; - std::unique_ptr impl_; -}; - -} // namespace internal - -/// \brief Array builder for created encoded DictionaryArray from -/// dense array -/// -/// Unlike other builders, dictionary builder does not completely -/// reset the state on Finish calls. The arrays built after the -/// initial Finish call will reuse the previously created encoding and -/// build a delta dictionary when new terms occur. -/// -/// data -template -class DictionaryBuilder : public ArrayBuilder { - public: - using Scalar = typename internal::DictionaryScalar::type; - - // WARNING: the type given below is the value type, not the DictionaryType. - // The DictionaryType is instantiated on the Finish() call. - template - DictionaryBuilder( - typename std::enable_if::value, - const std::shared_ptr&>::type type, - MemoryPool* pool) - : ArrayBuilder(type, pool), - memo_table_(new internal::DictionaryMemoTable(type)), - delta_offset_(0), - byte_width_(-1), - values_builder_(pool) {} - - template - explicit DictionaryBuilder( - typename std::enable_if::value, - const std::shared_ptr&>::type type, - MemoryPool* pool) - : ArrayBuilder(type, pool), - memo_table_(new internal::DictionaryMemoTable(type)), - delta_offset_(0), - byte_width_(static_cast(*type).byte_width()), - values_builder_(pool) {} - - template - explicit DictionaryBuilder( - typename std::enable_if::is_parameter_free, MemoryPool*>::type pool) - : DictionaryBuilder(TypeTraits::type_singleton(), pool) {} - - DictionaryBuilder(const std::shared_ptr& dictionary, MemoryPool* pool) - : ArrayBuilder(dictionary->type(), pool), - memo_table_(new internal::DictionaryMemoTable(dictionary)), - delta_offset_(0), - byte_width_(-1), - values_builder_(pool) {} - - ~DictionaryBuilder() override = default; - - /// \brief Append a scalar value - Status Append(const Scalar& value) { - ARROW_RETURN_NOT_OK(Reserve(1)); - - auto memo_index = memo_table_->GetOrInsert(value); - ARROW_RETURN_NOT_OK(values_builder_.Append(memo_index)); - length_ += 1; - - return Status::OK(); - } - - /// \brief Append a fixed-width string (only for FixedSizeBinaryType) - template - Status Append(typename std::enable_if::value, - const uint8_t*>::type value) { - return Append(util::string_view(reinterpret_cast(value), byte_width_)); - } - - /// \brief Append a fixed-width string (only for FixedSizeBinaryType) - template - Status Append(typename std::enable_if::value, - const char*>::type value) { - return Append(util::string_view(value, byte_width_)); - } - - /// \brief Append a scalar null value - Status AppendNull() final { - length_ += 1; - null_count_ += 1; - - return values_builder_.AppendNull(); - } - - Status AppendNulls(int64_t length) final { - length_ += length; - null_count_ += length; - - return values_builder_.AppendNulls(length); - } - - /// \brief Append a whole dense array to the builder - template - Status AppendArray( - typename std::enable_if::value, - const Array&>::type array) { - using ArrayType = typename TypeTraits::ArrayType; - - const auto& concrete_array = static_cast(array); - for (int64_t i = 0; i < array.length(); i++) { - if (array.IsNull(i)) { - ARROW_RETURN_NOT_OK(AppendNull()); - } else { - ARROW_RETURN_NOT_OK(Append(concrete_array.GetView(i))); - } - } - return Status::OK(); - } - - template - Status AppendArray( - typename std::enable_if::value, - const Array&>::type array) { - if (!type_->Equals(*array.type())) { - return Status::Invalid( - "Cannot append FixedSizeBinary array with non-matching type"); - } - - const auto& concrete_array = static_cast(array); - for (int64_t i = 0; i < array.length(); i++) { - if (array.IsNull(i)) { - ARROW_RETURN_NOT_OK(AppendNull()); - } else { - ARROW_RETURN_NOT_OK(Append(concrete_array.GetValue(i))); - } - } - return Status::OK(); - } - - void Reset() override { - ArrayBuilder::Reset(); - values_builder_.Reset(); - memo_table_.reset(new internal::DictionaryMemoTable(type_)); - delta_offset_ = 0; - } - - Status Resize(int64_t capacity) override { - ARROW_RETURN_NOT_OK(CheckCapacity(capacity, capacity_)); - capacity = std::max(capacity, kMinBuilderCapacity); - - if (capacity_ == 0) { - // Initialize hash table - // XXX should we let the user pass additional size heuristics? - delta_offset_ = 0; - } - ARROW_RETURN_NOT_OK(values_builder_.Resize(capacity)); - capacity_ = values_builder_.capacity(); - return Status::OK(); - } - - Status FinishInternal(std::shared_ptr* out) override { - // Finalize indices array - ARROW_RETURN_NOT_OK(values_builder_.FinishInternal(out)); - - // Generate dictionary array from hash table contents - std::shared_ptr dictionary_data; - - ARROW_RETURN_NOT_OK( - memo_table_->GetArrayData(pool_, delta_offset_, &dictionary_data)); - - // Set type of array data to the right dictionary type - (*out)->type = dictionary((*out)->type, type_); - (*out)->dictionary = MakeArray(dictionary_data); - - // Update internals for further uses of this DictionaryBuilder - delta_offset_ = memo_table_->size(); - values_builder_.Reset(); - - return Status::OK(); - } - - /// \cond FALSE - using ArrayBuilder::Finish; - /// \endcond - - Status Finish(std::shared_ptr* out) { return FinishTyped(out); } - - /// is the dictionary builder in the delta building mode - bool is_building_delta() { return delta_offset_ > 0; } - - protected: - std::unique_ptr memo_table_; - - int32_t delta_offset_; - // Only used for FixedSizeBinaryType - int32_t byte_width_; - - AdaptiveIntBuilder values_builder_; -}; - -template <> -class DictionaryBuilder : public ArrayBuilder { - public: - DictionaryBuilder(const std::shared_ptr& type, MemoryPool* pool) - : ArrayBuilder(type, pool), values_builder_(pool) {} - explicit DictionaryBuilder(MemoryPool* pool) - : ArrayBuilder(null(), pool), values_builder_(pool) {} - - DictionaryBuilder(const std::shared_ptr& dictionary, MemoryPool* pool) - : ArrayBuilder(dictionary->type(), pool), values_builder_(pool) {} - - /// \brief Append a scalar null value - Status AppendNull() final { - length_ += 1; - null_count_ += 1; - - return values_builder_.AppendNull(); - } - - Status AppendNulls(int64_t length) final { - length_ += length; - null_count_ += length; - - return values_builder_.AppendNulls(length); - } - - /// \brief Append a whole dense array to the builder - Status AppendArray(const Array& array) { - for (int64_t i = 0; i < array.length(); i++) { - ARROW_RETURN_NOT_OK(AppendNull()); - } - return Status::OK(); - } - - Status Resize(int64_t capacity) override { - ARROW_RETURN_NOT_OK(CheckCapacity(capacity, capacity_)); - capacity = std::max(capacity, kMinBuilderCapacity); - - ARROW_RETURN_NOT_OK(values_builder_.Resize(capacity)); - capacity_ = values_builder_.capacity(); - return Status::OK(); - } - - Status FinishInternal(std::shared_ptr* out) override { - std::shared_ptr dictionary = std::make_shared(0); - - ARROW_RETURN_NOT_OK(values_builder_.FinishInternal(out)); - (*out)->type = std::make_shared((*out)->type, type_); - (*out)->dictionary = dictionary; - - return Status::OK(); - } - - /// \cond FALSE - using ArrayBuilder::Finish; - /// \endcond - - Status Finish(std::shared_ptr* out) { return FinishTyped(out); } - - protected: - AdaptiveIntBuilder values_builder_; -}; - -class ARROW_EXPORT BinaryDictionaryBuilder : public DictionaryBuilder { - public: - using DictionaryBuilder::Append; - using DictionaryBuilder::DictionaryBuilder; - - Status Append(const uint8_t* value, int32_t length) { - return Append(reinterpret_cast(value), length); - } - - Status Append(const char* value, int32_t length) { - return Append(util::string_view(value, length)); - } -}; - -/// \brief Dictionary array builder with convenience methods for strings -class ARROW_EXPORT StringDictionaryBuilder : public DictionaryBuilder { - public: - using DictionaryBuilder::Append; - using DictionaryBuilder::DictionaryBuilder; - - Status Append(const uint8_t* value, int32_t length) { - return Append(reinterpret_cast(value), length); - } - - Status Append(const char* value, int32_t length) { - return Append(util::string_view(value, length)); - } -}; - -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/array/builder_nested.h b/cpp/thirdparty/knowhere_build/include/arrow/array/builder_nested.h deleted file mode 100644 index de03145918..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/array/builder_nested.h +++ /dev/null @@ -1,260 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include - -#include "arrow/array/builder_base.h" -#include "arrow/buffer-builder.h" - -namespace arrow { - -// ---------------------------------------------------------------------- -// List builder - -/// \class ListBuilder -/// \brief Builder class for variable-length list array value types -/// -/// To use this class, you must append values to the child array builder and use -/// the Append function to delimit each distinct list value (once the values -/// have been appended to the child array) or use the bulk API to append -/// a sequence of offests and null values. -/// -/// A note on types. Per arrow/type.h all types in the c++ implementation are -/// logical so even though this class always builds list array, this can -/// represent multiple different logical types. If no logical type is provided -/// at construction time, the class defaults to List where t is taken from the -/// value_builder/values that the object is constructed with. -class ARROW_EXPORT ListBuilder : public ArrayBuilder { - public: - /// Use this constructor to incrementally build the value array along with offsets and - /// null bitmap. - ListBuilder(MemoryPool* pool, const std::shared_ptr& value_builder, - const std::shared_ptr& type = NULLPTR); - - Status Resize(int64_t capacity) override; - void Reset() override; - Status FinishInternal(std::shared_ptr* out) override; - - /// \cond FALSE - using ArrayBuilder::Finish; - /// \endcond - - Status Finish(std::shared_ptr* out) { return FinishTyped(out); } - - /// \brief Vector append - /// - /// If passed, valid_bytes is of equal length to values, and any zero byte - /// will be considered as a null for that slot - Status AppendValues(const int32_t* offsets, int64_t length, - const uint8_t* valid_bytes = NULLPTR); - - /// \brief Start a new variable-length list slot - /// - /// This function should be called before beginning to append elements to the - /// value builder - Status Append(bool is_valid = true); - - Status AppendNull() final { return Append(false); } - - Status AppendNulls(int64_t length) final; - - ArrayBuilder* value_builder() const; - - protected: - TypedBufferBuilder offsets_builder_; - std::shared_ptr value_builder_; - std::shared_ptr values_; - - Status CheckNextOffset() const; - Status AppendNextOffset(); - Status AppendNextOffset(int64_t num_repeats); -}; - -// ---------------------------------------------------------------------- -// Map builder - -/// \class MapBuilder -/// \brief Builder class for arrays of variable-size maps -/// -/// To use this class, you must append values to the key and item array builders -/// and use the Append function to delimit each distinct map (once the keys and items -/// have been appended) or use the bulk API to append a sequence of offests and null -/// maps. -/// -/// Key uniqueness and ordering are not validated. -class ARROW_EXPORT MapBuilder : public ArrayBuilder { - public: - /// Use this constructor to incrementally build the key and item arrays along with - /// offsets and null bitmap. - MapBuilder(MemoryPool* pool, const std::shared_ptr& key_builder, - const std::shared_ptr& item_builder, - const std::shared_ptr& type); - - /// Derive built type from key and item builders' types - MapBuilder(MemoryPool* pool, const std::shared_ptr& key_builder, - const std::shared_ptr& item_builder, bool keys_sorted = false); - - Status Resize(int64_t capacity) override; - void Reset() override; - Status FinishInternal(std::shared_ptr* out) override; - - /// \cond FALSE - using ArrayBuilder::Finish; - /// \endcond - - Status Finish(std::shared_ptr* out) { return FinishTyped(out); } - - /// \brief Vector append - /// - /// If passed, valid_bytes is of equal length to values, and any zero byte - /// will be considered as a null for that slot - Status AppendValues(const int32_t* offsets, int64_t length, - const uint8_t* valid_bytes = NULLPTR); - - /// \brief Start a new variable-length map slot - /// - /// This function should be called before beginning to append elements to the - /// key and value builders - Status Append(); - - Status AppendNull() final; - - Status AppendNulls(int64_t length) final; - - ArrayBuilder* key_builder() const { return key_builder_.get(); } - ArrayBuilder* item_builder() const { return item_builder_.get(); } - - protected: - std::shared_ptr list_builder_; - std::shared_ptr key_builder_; - std::shared_ptr item_builder_; -}; - -// ---------------------------------------------------------------------- -// FixedSizeList builder - -/// \class FixedSizeListBuilder -/// \brief Builder class for fixed-length list array value types -class ARROW_EXPORT FixedSizeListBuilder : public ArrayBuilder { - public: - FixedSizeListBuilder(MemoryPool* pool, - std::shared_ptr const& value_builder, - int32_t list_size); - - FixedSizeListBuilder(MemoryPool* pool, - std::shared_ptr const& value_builder, - const std::shared_ptr& type); - - Status Resize(int64_t capacity) override; - void Reset() override; - Status FinishInternal(std::shared_ptr* out) override; - - /// \cond FALSE - using ArrayBuilder::Finish; - /// \endcond - - Status Finish(std::shared_ptr* out) { return FinishTyped(out); } - - /// \brief Append a valid fixed length list. - /// - /// This function affects only the validity bitmap; the child values must be appended - /// using the child array builder. - Status Append(); - - /// \brief Vector append - /// - /// If passed, valid_bytes wil be read and any zero byte - /// will cause the corresponding slot to be null - /// - /// This function affects only the validity bitmap; the child values must be appended - /// using the child array builder. This includes appending nulls for null lists. - /// XXX this restriction is confusing, should this method be omitted? - Status AppendValues(int64_t length, const uint8_t* valid_bytes = NULLPTR); - - /// \brief Append a null fixed length list. - /// - /// The child array builder will have the approriate number of nulls appended - /// automatically. - Status AppendNull() final; - - /// \brief Append length null fixed length lists. - /// - /// The child array builder will have the approriate number of nulls appended - /// automatically. - Status AppendNulls(int64_t length) final; - - ArrayBuilder* value_builder() const { return value_builder_.get(); } - - protected: - const int32_t list_size_; - std::shared_ptr value_builder_; -}; - -// ---------------------------------------------------------------------- -// Struct - -// --------------------------------------------------------------------------------- -// StructArray builder -/// Append, Resize and Reserve methods are acting on StructBuilder. -/// Please make sure all these methods of all child-builders' are consistently -/// called to maintain data-structure consistency. -class ARROW_EXPORT StructBuilder : public ArrayBuilder { - public: - StructBuilder(const std::shared_ptr& type, MemoryPool* pool, - std::vector>&& field_builders); - - Status FinishInternal(std::shared_ptr* out) override; - - /// \cond FALSE - using ArrayBuilder::Finish; - /// \endcond - - Status Finish(std::shared_ptr* out) { return FinishTyped(out); } - - /// Null bitmap is of equal length to every child field, and any zero byte - /// will be considered as a null for that field, but users must using app- - /// end methods or advance methods of the child builders' independently to - /// insert data. - Status AppendValues(int64_t length, const uint8_t* valid_bytes) { - ARROW_RETURN_NOT_OK(Reserve(length)); - UnsafeAppendToBitmap(valid_bytes, length); - return Status::OK(); - } - - /// Append an element to the Struct. All child-builders' Append method must - /// be called independently to maintain data-structure consistency. - Status Append(bool is_valid = true) { - ARROW_RETURN_NOT_OK(Reserve(1)); - UnsafeAppendToBitmap(is_valid); - return Status::OK(); - } - - Status AppendNull() final { return Append(false); } - - Status AppendNulls(int64_t length) final; - - void Reset() override; - - ArrayBuilder* field_builder(int i) const { return children_[i].get(); } - - int num_fields() const { return static_cast(children_.size()); } -}; - -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/array/builder_primitive.h b/cpp/thirdparty/knowhere_build/include/arrow/array/builder_primitive.h deleted file mode 100644 index 8abbe029e1..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/array/builder_primitive.h +++ /dev/null @@ -1,429 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include -#include - -#include "arrow/array.h" -#include "arrow/array/builder_base.h" -#include "arrow/type.h" - -namespace arrow { - -class ARROW_EXPORT NullBuilder : public ArrayBuilder { - public: - explicit NullBuilder(MemoryPool* pool ARROW_MEMORY_POOL_DEFAULT) - : ArrayBuilder(null(), pool) {} - - /// \brief Append the specified number of null elements - Status AppendNulls(int64_t length) final { - if (length < 0) return Status::Invalid("length must be positive"); - null_count_ += length; - length_ += length; - return Status::OK(); - } - - /// \brief Append a single null element - Status AppendNull() final { return AppendNulls(1); } - - Status Append(std::nullptr_t) { return AppendNull(); } - - Status FinishInternal(std::shared_ptr* out) override; - - /// \cond FALSE - using ArrayBuilder::Finish; - /// \endcond - - Status Finish(std::shared_ptr* out) { return FinishTyped(out); } -}; - -/// Base class for all Builders that emit an Array of a scalar numerical type. -template -class NumericBuilder : public ArrayBuilder { - public: - using value_type = typename T::c_type; - using ArrayType = typename TypeTraits::ArrayType; - using ArrayBuilder::ArrayBuilder; - - template - explicit NumericBuilder( - typename std::enable_if::is_parameter_free, MemoryPool*>::type pool - ARROW_MEMORY_POOL_DEFAULT) - : ArrayBuilder(TypeTraits::type_singleton(), pool) {} - - /// Append a single scalar and increase the size if necessary. - Status Append(const value_type val) { - ARROW_RETURN_NOT_OK(ArrayBuilder::Reserve(1)); - UnsafeAppend(val); - return Status::OK(); - } - - /// Write nulls as uint8_t* (0 value indicates null) into pre-allocated memory - /// The memory at the corresponding data slot is set to 0 to prevent - /// uninitialized memory access - Status AppendNulls(int64_t length) final { - ARROW_RETURN_NOT_OK(Reserve(length)); - data_builder_.UnsafeAppend(length, static_cast(0)); - UnsafeSetNull(length); - return Status::OK(); - } - - /// \brief Append a single null element - Status AppendNull() final { - ARROW_RETURN_NOT_OK(Reserve(1)); - data_builder_.UnsafeAppend(static_cast(0)); - UnsafeAppendToBitmap(false); - return Status::OK(); - } - - value_type GetValue(int64_t index) const { return data_builder_.data()[index]; } - - void Reset() override { data_builder_.Reset(); } - - Status Resize(int64_t capacity) override { - ARROW_RETURN_NOT_OK(CheckCapacity(capacity, capacity_)); - capacity = std::max(capacity, kMinBuilderCapacity); - ARROW_RETURN_NOT_OK(data_builder_.Resize(capacity)); - return ArrayBuilder::Resize(capacity); - } - - value_type operator[](int64_t index) const { return GetValue(index); } - - value_type& operator[](int64_t index) { - return reinterpret_cast(data_builder_.mutable_data())[index]; - } - - /// \brief Append a sequence of elements in one shot - /// \param[in] values a contiguous C array of values - /// \param[in] length the number of values to append - /// \param[in] valid_bytes an optional sequence of bytes where non-zero - /// indicates a valid (non-null) value - /// \return Status - Status AppendValues(const value_type* values, int64_t length, - const uint8_t* valid_bytes = NULLPTR) { - ARROW_RETURN_NOT_OK(Reserve(length)); - data_builder_.UnsafeAppend(values, length); - // length_ is update by these - ArrayBuilder::UnsafeAppendToBitmap(valid_bytes, length); - return Status::OK(); - } - - /// \brief Append a sequence of elements in one shot - /// \param[in] values a contiguous C array of values - /// \param[in] length the number of values to append - /// \param[in] is_valid an std::vector indicating valid (1) or null - /// (0). Equal in length to values - /// \return Status - Status AppendValues(const value_type* values, int64_t length, - const std::vector& is_valid) { - ARROW_RETURN_NOT_OK(Reserve(length)); - data_builder_.UnsafeAppend(values, length); - // length_ is update by these - ArrayBuilder::UnsafeAppendToBitmap(is_valid); - return Status::OK(); - } - - /// \brief Append a sequence of elements in one shot - /// \param[in] values a std::vector of values - /// \param[in] is_valid an std::vector indicating valid (1) or null - /// (0). Equal in length to values - /// \return Status - Status AppendValues(const std::vector& values, - const std::vector& is_valid) { - return AppendValues(values.data(), static_cast(values.size()), is_valid); - } - - /// \brief Append a sequence of elements in one shot - /// \param[in] values a std::vector of values - /// \return Status - Status AppendValues(const std::vector& values) { - return AppendValues(values.data(), static_cast(values.size())); - } - - Status FinishInternal(std::shared_ptr* out) override { - std::shared_ptr data, null_bitmap; - ARROW_RETURN_NOT_OK(null_bitmap_builder_.Finish(&null_bitmap)); - ARROW_RETURN_NOT_OK(data_builder_.Finish(&data)); - *out = ArrayData::Make(type_, length_, {null_bitmap, data}, null_count_); - capacity_ = length_ = null_count_ = 0; - return Status::OK(); - } - - /// \cond FALSE - using ArrayBuilder::Finish; - /// \endcond - - Status Finish(std::shared_ptr* out) { return FinishTyped(out); } - - /// \brief Append a sequence of elements in one shot - /// \param[in] values_begin InputIterator to the beginning of the values - /// \param[in] values_end InputIterator pointing to the end of the values - /// \return Status - template - Status AppendValues(ValuesIter values_begin, ValuesIter values_end) { - int64_t length = static_cast(std::distance(values_begin, values_end)); - ARROW_RETURN_NOT_OK(Reserve(length)); - data_builder_.UnsafeAppend(values_begin, values_end); - // this updates the length_ - UnsafeSetNotNull(length); - return Status::OK(); - } - - /// \brief Append a sequence of elements in one shot, with a specified nullmap - /// \param[in] values_begin InputIterator to the beginning of the values - /// \param[in] values_end InputIterator pointing to the end of the values - /// \param[in] valid_begin InputIterator with elements indication valid(1) - /// or null(0) values. - /// \return Status - template - typename std::enable_if::value, Status>::type AppendValues( - ValuesIter values_begin, ValuesIter values_end, ValidIter valid_begin) { - static_assert(!internal::is_null_pointer::value, - "Don't pass a NULLPTR directly as valid_begin, use the 2-argument " - "version instead"); - int64_t length = static_cast(std::distance(values_begin, values_end)); - ARROW_RETURN_NOT_OK(Reserve(length)); - data_builder_.UnsafeAppend(values_begin, values_end); - null_bitmap_builder_.UnsafeAppend( - length, [&valid_begin]() -> bool { return *valid_begin++; }); - length_ = null_bitmap_builder_.length(); - null_count_ = null_bitmap_builder_.false_count(); - return Status::OK(); - } - - // Same as above, with a pointer type ValidIter - template - typename std::enable_if::value, Status>::type AppendValues( - ValuesIter values_begin, ValuesIter values_end, ValidIter valid_begin) { - int64_t length = static_cast(std::distance(values_begin, values_end)); - ARROW_RETURN_NOT_OK(Reserve(length)); - data_builder_.UnsafeAppend(values_begin, values_end); - // this updates the length_ - if (valid_begin == NULLPTR) { - UnsafeSetNotNull(length); - } else { - null_bitmap_builder_.UnsafeAppend( - length, [&valid_begin]() -> bool { return *valid_begin++; }); - length_ = null_bitmap_builder_.length(); - null_count_ = null_bitmap_builder_.false_count(); - } - - return Status::OK(); - } - - /// Append a single scalar under the assumption that the underlying Buffer is - /// large enough. - /// - /// This method does not capacity-check; make sure to call Reserve - /// beforehand. - void UnsafeAppend(const value_type val) { - ArrayBuilder::UnsafeAppendToBitmap(true); - data_builder_.UnsafeAppend(val); - } - - void UnsafeAppendNull() { - ArrayBuilder::UnsafeAppendToBitmap(false); - data_builder_.UnsafeAppend(0); - } - - protected: - TypedBufferBuilder data_builder_; -}; - -// Builders - -using UInt8Builder = NumericBuilder; -using UInt16Builder = NumericBuilder; -using UInt32Builder = NumericBuilder; -using UInt64Builder = NumericBuilder; - -using Int8Builder = NumericBuilder; -using Int16Builder = NumericBuilder; -using Int32Builder = NumericBuilder; -using Int64Builder = NumericBuilder; - -using HalfFloatBuilder = NumericBuilder; -using FloatBuilder = NumericBuilder; -using DoubleBuilder = NumericBuilder; - -class ARROW_EXPORT BooleanBuilder : public ArrayBuilder { - public: - using value_type = bool; - explicit BooleanBuilder(MemoryPool* pool ARROW_MEMORY_POOL_DEFAULT); - - explicit BooleanBuilder(const std::shared_ptr& type, MemoryPool* pool); - - /// Write nulls as uint8_t* (0 value indicates null) into pre-allocated memory - Status AppendNulls(int64_t length) final { - ARROW_RETURN_NOT_OK(Reserve(length)); - data_builder_.UnsafeAppend(length, false); - UnsafeSetNull(length); - return Status::OK(); - } - - Status AppendNull() final { - ARROW_RETURN_NOT_OK(Reserve(1)); - UnsafeAppendNull(); - return Status::OK(); - } - - /// Scalar append - Status Append(const bool val) { - ARROW_RETURN_NOT_OK(Reserve(1)); - UnsafeAppend(val); - return Status::OK(); - } - - Status Append(const uint8_t val) { return Append(val != 0); } - - /// Scalar append, without checking for capacity - void UnsafeAppend(const bool val) { - data_builder_.UnsafeAppend(val); - UnsafeAppendToBitmap(true); - } - - void UnsafeAppendNull() { - data_builder_.UnsafeAppend(false); - UnsafeAppendToBitmap(false); - } - - void UnsafeAppend(const uint8_t val) { UnsafeAppend(val != 0); } - - /// \brief Append a sequence of elements in one shot - /// \param[in] values a contiguous array of bytes (non-zero is 1) - /// \param[in] length the number of values to append - /// \param[in] valid_bytes an optional sequence of bytes where non-zero - /// indicates a valid (non-null) value - /// \return Status - Status AppendValues(const uint8_t* values, int64_t length, - const uint8_t* valid_bytes = NULLPTR); - - /// \brief Append a sequence of elements in one shot - /// \param[in] values a contiguous C array of values - /// \param[in] length the number of values to append - /// \param[in] is_valid an std::vector indicating valid (1) or null - /// (0). Equal in length to values - /// \return Status - Status AppendValues(const uint8_t* values, int64_t length, - const std::vector& is_valid); - - /// \brief Append a sequence of elements in one shot - /// \param[in] values a std::vector of bytes - /// \param[in] is_valid an std::vector indicating valid (1) or null - /// (0). Equal in length to values - /// \return Status - Status AppendValues(const std::vector& values, - const std::vector& is_valid); - - /// \brief Append a sequence of elements in one shot - /// \param[in] values a std::vector of bytes - /// \return Status - Status AppendValues(const std::vector& values); - - /// \brief Append a sequence of elements in one shot - /// \param[in] values an std::vector indicating true (1) or false - /// \param[in] is_valid an std::vector indicating valid (1) or null - /// (0). Equal in length to values - /// \return Status - Status AppendValues(const std::vector& values, const std::vector& is_valid); - - /// \brief Append a sequence of elements in one shot - /// \param[in] values an std::vector indicating true (1) or false - /// \return Status - Status AppendValues(const std::vector& values); - - /// \brief Append a sequence of elements in one shot - /// \param[in] values_begin InputIterator to the beginning of the values - /// \param[in] values_end InputIterator pointing to the end of the values - /// or null(0) values - /// \return Status - template - Status AppendValues(ValuesIter values_begin, ValuesIter values_end) { - int64_t length = static_cast(std::distance(values_begin, values_end)); - ARROW_RETURN_NOT_OK(Reserve(length)); - data_builder_.UnsafeAppend( - length, [&values_begin]() -> bool { return *values_begin++; }); - // this updates length_ - UnsafeSetNotNull(length); - return Status::OK(); - } - - /// \brief Append a sequence of elements in one shot, with a specified nullmap - /// \param[in] values_begin InputIterator to the beginning of the values - /// \param[in] values_end InputIterator pointing to the end of the values - /// \param[in] valid_begin InputIterator with elements indication valid(1) - /// or null(0) values - /// \return Status - template - typename std::enable_if::value, Status>::type AppendValues( - ValuesIter values_begin, ValuesIter values_end, ValidIter valid_begin) { - static_assert(!internal::is_null_pointer::value, - "Don't pass a NULLPTR directly as valid_begin, use the 2-argument " - "version instead"); - int64_t length = static_cast(std::distance(values_begin, values_end)); - ARROW_RETURN_NOT_OK(Reserve(length)); - - data_builder_.UnsafeAppend( - length, [&values_begin]() -> bool { return *values_begin++; }); - null_bitmap_builder_.UnsafeAppend( - length, [&valid_begin]() -> bool { return *valid_begin++; }); - length_ = null_bitmap_builder_.length(); - null_count_ = null_bitmap_builder_.false_count(); - return Status::OK(); - } - - // Same as above, for a pointer type ValidIter - template - typename std::enable_if::value, Status>::type AppendValues( - ValuesIter values_begin, ValuesIter values_end, ValidIter valid_begin) { - int64_t length = static_cast(std::distance(values_begin, values_end)); - ARROW_RETURN_NOT_OK(Reserve(length)); - data_builder_.UnsafeAppend( - length, [&values_begin]() -> bool { return *values_begin++; }); - - if (valid_begin == NULLPTR) { - UnsafeSetNotNull(length); - } else { - null_bitmap_builder_.UnsafeAppend( - length, [&valid_begin]() -> bool { return *valid_begin++; }); - } - length_ = null_bitmap_builder_.length(); - null_count_ = null_bitmap_builder_.false_count(); - return Status::OK(); - } - - Status AppendValues(int64_t length, bool value); - - Status FinishInternal(std::shared_ptr* out) override; - - /// \cond FALSE - using ArrayBuilder::Finish; - /// \endcond - - Status Finish(std::shared_ptr* out) { return FinishTyped(out); } - - void Reset() override; - Status Resize(int64_t capacity) override; - - protected: - TypedBufferBuilder data_builder_; -}; - -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/array/builder_time.h b/cpp/thirdparty/knowhere_build/include/arrow/array/builder_time.h deleted file mode 100644 index 3ff783b1b1..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/array/builder_time.h +++ /dev/null @@ -1,70 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// Contains declarations of time related Arrow builder types. - -#pragma once - -#include - -#include "arrow/array.h" -#include "arrow/array/builder_base.h" -#include "arrow/array/builder_binary.h" -#include "arrow/array/builder_primitive.h" -#include "arrow/buffer-builder.h" -#include "arrow/status.h" -#include "arrow/type_traits.h" -#include "arrow/util/macros.h" - -namespace arrow { - -class ARROW_EXPORT DayTimeIntervalBuilder : public ArrayBuilder { - public: - using DayMilliseconds = DayTimeIntervalType::DayMilliseconds; - - explicit DayTimeIntervalBuilder(MemoryPool* pool ARROW_MEMORY_POOL_DEFAULT) - : DayTimeIntervalBuilder(day_time_interval(), pool) {} - - DayTimeIntervalBuilder(std::shared_ptr type, - MemoryPool* pool ARROW_MEMORY_POOL_DEFAULT) - : ArrayBuilder(type, pool), - builder_(fixed_size_binary(sizeof(DayMilliseconds)), pool) {} - - void Reset() override { builder_.Reset(); } - Status Resize(int64_t capacity) override { return builder_.Resize(capacity); } - Status Append(DayMilliseconds day_millis) { - return builder_.Append(reinterpret_cast(&day_millis)); - } - void UnsafeAppend(DayMilliseconds day_millis) { - builder_.UnsafeAppend(reinterpret_cast(&day_millis)); - } - using ArrayBuilder::UnsafeAppendNull; - Status AppendNull() override { return builder_.AppendNull(); } - Status AppendNulls(int64_t length) override { return builder_.AppendNulls(length); } - Status FinishInternal(std::shared_ptr* out) override { - auto result = builder_.FinishInternal(out); - if (*out != NULLPTR) { - (*out)->type = type(); - } - return result; - } - - private: - FixedSizeBinaryBuilder builder_; -}; - -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/array/builder_union.h b/cpp/thirdparty/knowhere_build/include/arrow/array/builder_union.h deleted file mode 100644 index aac2e54f9a..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/array/builder_union.h +++ /dev/null @@ -1,106 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include -#include - -#include "arrow/array.h" -#include "arrow/array/builder_base.h" -#include "arrow/buffer-builder.h" - -namespace arrow { - -/// \class DenseUnionBuilder -/// -/// You need to call AppendChild for each of the children builders you want -/// to use. The function will return an int8_t, which is the type tag -/// associated with that child. You can then call Append with that tag -/// (followed by an append on the child builder) to add elements to -/// the union array. -/// -/// You can either specify the type when the UnionBuilder is constructed -/// or let the UnionBuilder infer the type at runtime (by omitting the -/// type argument from the constructor). -/// -/// This API is EXPERIMENTAL. -class ARROW_EXPORT DenseUnionBuilder : public ArrayBuilder { - public: - /// Use this constructor to incrementally build the union array along - /// with types, offsets, and null bitmap. - explicit DenseUnionBuilder(MemoryPool* pool, - const std::shared_ptr& type = NULLPTR); - - Status AppendNull() final { - ARROW_RETURN_NOT_OK(types_builder_.Append(0)); - ARROW_RETURN_NOT_OK(offsets_builder_.Append(0)); - return AppendToBitmap(false); - } - - Status AppendNulls(int64_t length) final { - ARROW_RETURN_NOT_OK(types_builder_.Reserve(length)); - ARROW_RETURN_NOT_OK(offsets_builder_.Reserve(length)); - ARROW_RETURN_NOT_OK(Reserve(length)); - for (int64_t i = 0; i < length; ++i) { - types_builder_.UnsafeAppend(0); - offsets_builder_.UnsafeAppend(0); - } - return AppendToBitmap(length, false); - } - - /// \brief Append an element to the UnionArray. This must be followed - /// by an append to the appropriate child builder. - /// \param[in] type index of the child the value will be appended - /// \param[in] offset offset of the value in that child - Status Append(int8_t type, int32_t offset) { - ARROW_RETURN_NOT_OK(types_builder_.Append(type)); - ARROW_RETURN_NOT_OK(offsets_builder_.Append(offset)); - return AppendToBitmap(true); - } - - Status FinishInternal(std::shared_ptr* out) override; - - /// \cond FALSE - using ArrayBuilder::Finish; - /// \endcond - - Status Finish(std::shared_ptr* out) { return FinishTyped(out); } - - /// \brief Make a new child builder available to the UnionArray - /// - /// \param[in] child the child builder - /// \param[in] field_name the name of the field in the union array type - /// if type inference is used - /// \return child index, which is the "type" argument that needs - /// to be passed to the "Append" method to add a new element to - /// the union array. - int8_t AppendChild(const std::shared_ptr& child, - const std::string& field_name = "") { - children_.push_back(child); - field_names_.push_back(field_name); - return static_cast(children_.size() - 1); - } - - private: - TypedBufferBuilder types_builder_; - TypedBufferBuilder offsets_builder_; - std::vector field_names_; -}; - -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/array/concatenate.h b/cpp/thirdparty/knowhere_build/include/arrow/array/concatenate.h deleted file mode 100644 index 67738d547f..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/array/concatenate.h +++ /dev/null @@ -1,39 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include - -#include "arrow/array.h" -#include "arrow/memory_pool.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -/// \brief Concatenate arrays -/// -/// \param[in] arrays a vector of arrays to be concatenated -/// \param[in] pool memory to store the result will be allocated from this memory pool -/// \param[out] out the resulting concatenated array -/// \return Status -ARROW_EXPORT -Status Concatenate(const ArrayVector& arrays, MemoryPool* pool, - std::shared_ptr* out); - -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/buffer-builder.h b/cpp/thirdparty/knowhere_build/include/arrow/buffer-builder.h deleted file mode 100644 index 85f36ee3f5..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/buffer-builder.h +++ /dev/null @@ -1,379 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_BUFFER_BUILDER_H -#define ARROW_BUFFER_BUILDER_H - -#include -#include -#include -#include -#include -#include - -#include "arrow/buffer.h" -#include "arrow/status.h" -#include "arrow/util/bit-util.h" -#include "arrow/util/macros.h" -#include "arrow/util/ubsan.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -// ---------------------------------------------------------------------- -// Buffer builder classes - -/// \class BufferBuilder -/// \brief A class for incrementally building a contiguous chunk of in-memory -/// data -class ARROW_EXPORT BufferBuilder { - public: - explicit BufferBuilder(MemoryPool* pool ARROW_MEMORY_POOL_DEFAULT) - : pool_(pool), - data_(/*ensure never null to make ubsan happy and avoid check penalties below*/ - &util::internal::non_null_filler), - - capacity_(0), - size_(0) {} - - /// \brief Resize the buffer to the nearest multiple of 64 bytes - /// - /// \param new_capacity the new capacity of the of the builder. Will be - /// rounded up to a multiple of 64 bytes for padding \param shrink_to_fit if - /// new capacity is smaller than the existing size, reallocate internal - /// buffer. Set to false to avoid reallocations when shrinking the builder. - /// \return Status - Status Resize(const int64_t new_capacity, bool shrink_to_fit = true) { - // Resize(0) is a no-op - if (new_capacity == 0) { - return Status::OK(); - } - if (buffer_ == NULLPTR) { - ARROW_RETURN_NOT_OK(AllocateResizableBuffer(pool_, new_capacity, &buffer_)); - } else { - ARROW_RETURN_NOT_OK(buffer_->Resize(new_capacity, shrink_to_fit)); - } - capacity_ = buffer_->capacity(); - data_ = buffer_->mutable_data(); - return Status::OK(); - } - - /// \brief Ensure that builder can accommodate the additional number of bytes - /// without the need to perform allocations - /// - /// \param[in] additional_bytes number of additional bytes to make space for - /// \return Status - Status Reserve(const int64_t additional_bytes) { - auto min_capacity = size_ + additional_bytes; - if (min_capacity <= capacity_) { - return Status::OK(); - } - return Resize(GrowByFactor(capacity_, min_capacity), false); - } - - /// \brief Return a capacity expanded by an unspecified growth factor - static int64_t GrowByFactor(int64_t current_capacity, int64_t new_capacity) { - // NOTE: Doubling isn't a great overallocation practice - // see https://github.com/facebook/folly/blob/master/folly/docs/FBVector.md - // for discussion. - // Grow exactly if a large upsize (the caller might know the exact final size). - // Otherwise overallocate by 1.5 to keep a linear amortized cost. - return std::max(new_capacity, current_capacity * 3 / 2); - } - - /// \brief Append the given data to the buffer - /// - /// The buffer is automatically expanded if necessary. - Status Append(const void* data, const int64_t length) { - if (ARROW_PREDICT_FALSE(size_ + length > capacity_)) { - ARROW_RETURN_NOT_OK(Resize(GrowByFactor(capacity_, size_ + length), false)); - } - UnsafeAppend(data, length); - return Status::OK(); - } - - /// \brief Append copies of a value to the buffer - /// - /// The buffer is automatically expanded if necessary. - Status Append(const int64_t num_copies, uint8_t value) { - ARROW_RETURN_NOT_OK(Reserve(num_copies)); - UnsafeAppend(num_copies, value); - return Status::OK(); - } - - // Advance pointer and zero out memory - Status Advance(const int64_t length) { return Append(length, 0); } - - // Advance pointer, but don't allocate or zero memory - void UnsafeAdvance(const int64_t length) { size_ += length; } - - // Unsafe methods don't check existing size - void UnsafeAppend(const void* data, const int64_t length) { - memcpy(data_ + size_, data, static_cast(length)); - size_ += length; - } - - void UnsafeAppend(const int64_t num_copies, uint8_t value) { - memset(data_ + size_, value, static_cast(num_copies)); - size_ += num_copies; - } - - /// \brief Return result of builder as a Buffer object. - /// - /// The builder is reset and can be reused afterwards. - /// - /// \param[out] out the finalized Buffer object - /// \param shrink_to_fit if the buffer size is smaller than its capacity, - /// reallocate to fit more tightly in memory. Set to false to avoid - /// a reallocation, at the expense of potentially more memory consumption. - /// \return Status - Status Finish(std::shared_ptr* out, bool shrink_to_fit = true) { - ARROW_RETURN_NOT_OK(Resize(size_, shrink_to_fit)); - if (size_ != 0) buffer_->ZeroPadding(); - *out = buffer_; - if (*out == NULLPTR) { - ARROW_RETURN_NOT_OK(AllocateBuffer(pool_, 0, out)); - } - Reset(); - return Status::OK(); - } - - void Reset() { - buffer_ = NULLPTR; - capacity_ = size_ = 0; - } - - /// \brief Set size to a smaller value without modifying builder - /// contents. For reusable BufferBuilder classes - /// \param[in] position must be non-negative and less than or equal - /// to the current length() - void Rewind(int64_t position) { size_ = position; } - - int64_t capacity() const { return capacity_; } - int64_t length() const { return size_; } - const uint8_t* data() const { return data_; } - uint8_t* mutable_data() { return data_; } - - private: - std::shared_ptr buffer_; - MemoryPool* pool_; - uint8_t* data_; - int64_t capacity_; - int64_t size_; -}; - -template -class TypedBufferBuilder; - -/// \brief A BufferBuilder for building a buffer of arithmetic elements -template -class TypedBufferBuilder::value>::type> { - public: - explicit TypedBufferBuilder(MemoryPool* pool ARROW_MEMORY_POOL_DEFAULT) - : bytes_builder_(pool) {} - - Status Append(T value) { - return bytes_builder_.Append(reinterpret_cast(&value), sizeof(T)); - } - - Status Append(const T* values, int64_t num_elements) { - return bytes_builder_.Append(reinterpret_cast(values), - num_elements * sizeof(T)); - } - - Status Append(const int64_t num_copies, T value) { - ARROW_RETURN_NOT_OK(Reserve(num_copies + length())); - UnsafeAppend(num_copies, value); - return Status::OK(); - } - - void UnsafeAppend(T value) { - bytes_builder_.UnsafeAppend(reinterpret_cast(&value), sizeof(T)); - } - - void UnsafeAppend(const T* values, int64_t num_elements) { - bytes_builder_.UnsafeAppend(reinterpret_cast(values), - num_elements * sizeof(T)); - } - - template - void UnsafeAppend(Iter values_begin, Iter values_end) { - int64_t num_elements = static_cast(std::distance(values_begin, values_end)); - auto data = mutable_data() + length(); - bytes_builder_.UnsafeAdvance(num_elements * sizeof(T)); - std::copy(values_begin, values_end, data); - } - - void UnsafeAppend(const int64_t num_copies, T value) { - auto data = mutable_data() + length(); - bytes_builder_.UnsafeAppend(num_copies * sizeof(T), 0); - for (const auto end = data + num_copies; data != end; ++data) { - *data = value; - } - } - - Status Resize(const int64_t new_capacity, bool shrink_to_fit = true) { - return bytes_builder_.Resize(new_capacity * sizeof(T), shrink_to_fit); - } - - Status Reserve(const int64_t additional_elements) { - return bytes_builder_.Reserve(additional_elements * sizeof(T)); - } - - Status Advance(const int64_t length) { - return bytes_builder_.Advance(length * sizeof(T)); - } - - Status Finish(std::shared_ptr* out, bool shrink_to_fit = true) { - return bytes_builder_.Finish(out, shrink_to_fit); - } - - void Reset() { bytes_builder_.Reset(); } - - int64_t length() const { return bytes_builder_.length() / sizeof(T); } - int64_t capacity() const { return bytes_builder_.capacity() / sizeof(T); } - const T* data() const { return reinterpret_cast(bytes_builder_.data()); } - T* mutable_data() { return reinterpret_cast(bytes_builder_.mutable_data()); } - - private: - BufferBuilder bytes_builder_; -}; - -/// \brief A BufferBuilder for building a buffer containing a bitmap -template <> -class TypedBufferBuilder { - public: - explicit TypedBufferBuilder(MemoryPool* pool ARROW_MEMORY_POOL_DEFAULT) - : bytes_builder_(pool) {} - - Status Append(bool value) { - ARROW_RETURN_NOT_OK(Reserve(1)); - UnsafeAppend(value); - return Status::OK(); - } - - Status Append(const uint8_t* valid_bytes, int64_t num_elements) { - ARROW_RETURN_NOT_OK(Reserve(num_elements)); - UnsafeAppend(valid_bytes, num_elements); - return Status::OK(); - } - - Status Append(const int64_t num_copies, bool value) { - ARROW_RETURN_NOT_OK(Reserve(num_copies)); - UnsafeAppend(num_copies, value); - return Status::OK(); - } - - void UnsafeAppend(bool value) { - BitUtil::SetBitTo(mutable_data(), bit_length_, value); - if (!value) { - ++false_count_; - } - ++bit_length_; - } - - void UnsafeAppend(const uint8_t* bytes, int64_t num_elements) { - if (num_elements == 0) return; - int64_t i = 0; - internal::GenerateBitsUnrolled(mutable_data(), bit_length_, num_elements, [&] { - bool value = bytes[i++]; - false_count_ += !value; - return value; - }); - bit_length_ += num_elements; - } - - void UnsafeAppend(const int64_t num_copies, bool value) { - BitUtil::SetBitsTo(mutable_data(), bit_length_, num_copies, value); - false_count_ += num_copies * !value; - bit_length_ += num_copies; - } - - template - void UnsafeAppend(const int64_t num_elements, Generator&& gen) { - if (num_elements == 0) return; - - if (count_falses) { - internal::GenerateBitsUnrolled(mutable_data(), bit_length_, num_elements, [&] { - bool value = gen(); - false_count_ += !value; - return value; - }); - } else { - internal::GenerateBitsUnrolled(mutable_data(), bit_length_, num_elements, - std::forward(gen)); - } - bit_length_ += num_elements; - } - - Status Resize(const int64_t new_capacity, bool shrink_to_fit = true) { - const int64_t old_byte_capacity = bytes_builder_.capacity(); - ARROW_RETURN_NOT_OK( - bytes_builder_.Resize(BitUtil::BytesForBits(new_capacity), shrink_to_fit)); - // Resize() may have chosen a larger capacity (e.g. for padding), - // so ask it again before calling memset(). - const int64_t new_byte_capacity = bytes_builder_.capacity(); - if (new_byte_capacity > old_byte_capacity) { - // The additional buffer space is 0-initialized for convenience, - // so that other methods can simply bump the length. - memset(mutable_data() + old_byte_capacity, 0, - static_cast(new_byte_capacity - old_byte_capacity)); - } - return Status::OK(); - } - - Status Reserve(const int64_t additional_elements) { - return Resize( - BufferBuilder::GrowByFactor(bit_length_, bit_length_ + additional_elements), - false); - } - - Status Advance(const int64_t length) { - ARROW_RETURN_NOT_OK(Reserve(length)); - bit_length_ += length; - false_count_ += length; - return Status::OK(); - } - - Status Finish(std::shared_ptr* out, bool shrink_to_fit = true) { - // set bytes_builder_.size_ == byte size of data - bytes_builder_.UnsafeAdvance(BitUtil::BytesForBits(bit_length_) - - bytes_builder_.length()); - bit_length_ = false_count_ = 0; - return bytes_builder_.Finish(out, shrink_to_fit); - } - - void Reset() { - bytes_builder_.Reset(); - bit_length_ = false_count_ = 0; - } - - int64_t length() const { return bit_length_; } - int64_t capacity() const { return bytes_builder_.capacity() * 8; } - const uint8_t* data() const { return bytes_builder_.data(); } - uint8_t* mutable_data() { return bytes_builder_.mutable_data(); } - int64_t false_count() const { return false_count_; } - - private: - BufferBuilder bytes_builder_; - int64_t bit_length_ = 0; - int64_t false_count_ = 0; -}; - -} // namespace arrow - -#endif // ARROW_BUFFER_BUILDER_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/buffer.h b/cpp/thirdparty/knowhere_build/include/arrow/buffer.h deleted file mode 100644 index 3eb9b033b9..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/buffer.h +++ /dev/null @@ -1,444 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_BUFFER_H -#define ARROW_BUFFER_H - -#include -#include -#include -#include -#include -#include - -#include "arrow/memory_pool.h" -#include "arrow/status.h" -#include "arrow/util/macros.h" -#include "arrow/util/string_view.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -// ---------------------------------------------------------------------- -// Buffer classes - -/// \class Buffer -/// \brief Object containing a pointer to a piece of contiguous memory with a -/// particular size. -/// -/// Buffers have two related notions of length: size and capacity. Size is -/// the number of bytes that might have valid data. Capacity is the number -/// of bytes that were allocated for the buffer in total. -/// -/// The Buffer base class does not own its memory, but subclasses often do. -/// -/// The following invariant is always true: Size <= Capacity -class ARROW_EXPORT Buffer { - public: - /// \brief Construct from buffer and size without copying memory - /// - /// \param[in] data a memory buffer - /// \param[in] size buffer size - /// - /// \note The passed memory must be kept alive through some other means - Buffer(const uint8_t* data, int64_t size) - : is_mutable_(false), - data_(data), - mutable_data_(NULLPTR), - size_(size), - capacity_(size) {} - - /// \brief Construct from string_view without copying memory - /// - /// \param[in] data a string_view object - /// - /// \note The memory viewed by data must not be deallocated in the lifetime of the - /// Buffer; temporary rvalue strings must be stored in an lvalue somewhere - explicit Buffer(util::string_view data) - : Buffer(reinterpret_cast(data.data()), - static_cast(data.size())) {} - - virtual ~Buffer() = default; - - /// An offset into data that is owned by another buffer, but we want to be - /// able to retain a valid pointer to it even after other shared_ptr's to the - /// parent buffer have been destroyed - /// - /// This method makes no assertions about alignment or padding of the buffer but - /// in general we expected buffers to be aligned and padded to 64 bytes. In the future - /// we might add utility methods to help determine if a buffer satisfies this contract. - Buffer(const std::shared_ptr& parent, const int64_t offset, const int64_t size) - : Buffer(parent->data() + offset, size) { - parent_ = parent; - } - - uint8_t operator[](std::size_t i) const { return data_[i]; } - - bool is_mutable() const { return is_mutable_; } - - /// \brief Construct a new std::string with a hexadecimal representation of the buffer. - /// \return std::string - std::string ToHexString(); - - /// Return true if both buffers are the same size and contain the same bytes - /// up to the number of compared bytes - bool Equals(const Buffer& other, int64_t nbytes) const; - - /// Return true if both buffers are the same size and contain the same bytes - bool Equals(const Buffer& other) const; - - /// Copy a section of the buffer into a new Buffer. - Status Copy(const int64_t start, const int64_t nbytes, MemoryPool* pool, - std::shared_ptr* out) const; - - /// Copy a section of the buffer using the default memory pool into a new Buffer. - Status Copy(const int64_t start, const int64_t nbytes, - std::shared_ptr* out) const; - - /// Zero bytes in padding, i.e. bytes between size_ and capacity_. - void ZeroPadding() { -#ifndef NDEBUG - CheckMutable(); -#endif - // A zero-capacity buffer can have a null data pointer - if (capacity_ != 0) { - memset(mutable_data_ + size_, 0, static_cast(capacity_ - size_)); - } - } - - /// \brief Construct a new buffer that owns its memory from a std::string - /// - /// \param[in] data a std::string object - /// \param[in] pool a memory pool - /// \param[out] out the created buffer - /// - /// \return Status message - static Status FromString(const std::string& data, MemoryPool* pool, - std::shared_ptr* out); - - /// \brief Construct a new buffer that owns its memory from a std::string - /// using the default memory pool - static Status FromString(const std::string& data, std::shared_ptr* out); - - /// \brief Construct an immutable buffer that takes ownership of the contents - /// of an std::string - /// \param[in] data an rvalue-reference of a string - /// \return a new Buffer instance - static std::shared_ptr FromString(std::string&& data); - - /// \brief Create buffer referencing typed memory with some length without - /// copying - /// \param[in] data the typed memory as C array - /// \param[in] length the number of values in the array - /// \return a new shared_ptr - template - static std::shared_ptr Wrap(const T* data, SizeType length) { - return std::make_shared(reinterpret_cast(data), - static_cast(sizeof(T) * length)); - } - - /// \brief Create buffer referencing std::vector with some length without - /// copying - /// \param[in] data the vector to be referenced. If this vector is changed, - /// the buffer may become invalid - /// \return a new shared_ptr - template - static std::shared_ptr Wrap(const std::vector& data) { - return std::make_shared(reinterpret_cast(data.data()), - static_cast(sizeof(T) * data.size())); - } - - /// \brief Copy buffer contents into a new std::string - /// \return std::string - /// \note Can throw std::bad_alloc if buffer is large - std::string ToString() const; - - /// \brief View buffer contents as a util::string_view - /// \return util::string_view - explicit operator util::string_view() const { - return util::string_view(reinterpret_cast(data_), size_); - } - - /// \brief Return a pointer to the buffer's data - const uint8_t* data() const { return data_; } - /// \brief Return a writable pointer to the buffer's data - /// - /// The buffer has to be mutable. Otherwise, an assertion may be thrown - /// or a null pointer may be returned. - uint8_t* mutable_data() { -#ifndef NDEBUG - CheckMutable(); -#endif - return mutable_data_; - } - - /// \brief Return the buffer's size in bytes - int64_t size() const { return size_; } - - /// \brief Return the buffer's capacity (number of allocated bytes) - int64_t capacity() const { return capacity_; } - - std::shared_ptr parent() const { return parent_; } - - protected: - bool is_mutable_; - const uint8_t* data_; - uint8_t* mutable_data_; - int64_t size_; - int64_t capacity_; - - // null by default, but may be set - std::shared_ptr parent_; - - void CheckMutable() const; - - private: - ARROW_DISALLOW_COPY_AND_ASSIGN(Buffer); -}; - -using BufferVector = std::vector>; - -/// \defgroup buffer-slicing-functions Functions for slicing buffers -/// -/// @{ - -/// \brief Construct a view on a buffer at the given offset and length. -/// -/// This function cannot fail and does not check for errors (except in debug builds) -static inline std::shared_ptr SliceBuffer(const std::shared_ptr& buffer, - const int64_t offset, - const int64_t length) { - return std::make_shared(buffer, offset, length); -} - -/// \brief Construct a view on a buffer at the given offset, up to the buffer's end. -/// -/// This function cannot fail and does not check for errors (except in debug builds) -static inline std::shared_ptr SliceBuffer(const std::shared_ptr& buffer, - const int64_t offset) { - int64_t length = buffer->size() - offset; - return SliceBuffer(buffer, offset, length); -} - -/// \brief Like SliceBuffer, but construct a mutable buffer slice. -/// -/// If the parent buffer is not mutable, behavior is undefined (it may abort -/// in debug builds). -ARROW_EXPORT -std::shared_ptr SliceMutableBuffer(const std::shared_ptr& buffer, - const int64_t offset, const int64_t length); - -/// \brief Like SliceBuffer, but construct a mutable buffer slice. -/// -/// If the parent buffer is not mutable, behavior is undefined (it may abort -/// in debug builds). -static inline std::shared_ptr SliceMutableBuffer( - const std::shared_ptr& buffer, const int64_t offset) { - int64_t length = buffer->size() - offset; - return SliceMutableBuffer(buffer, offset, length); -} - -/// @} - -/// \class MutableBuffer -/// \brief A Buffer whose contents can be mutated. May or may not own its data. -class ARROW_EXPORT MutableBuffer : public Buffer { - public: - MutableBuffer(uint8_t* data, const int64_t size) : Buffer(data, size) { - mutable_data_ = data; - is_mutable_ = true; - } - - MutableBuffer(const std::shared_ptr& parent, const int64_t offset, - const int64_t size); - - /// \brief Create buffer referencing typed memory with some length - /// \param[in] data the typed memory as C array - /// \param[in] length the number of values in the array - /// \return a new shared_ptr - template - static std::shared_ptr Wrap(T* data, SizeType length) { - return std::make_shared(reinterpret_cast(data), - static_cast(sizeof(T) * length)); - } - - protected: - MutableBuffer() : Buffer(NULLPTR, 0) {} -}; - -/// \class ResizableBuffer -/// \brief A mutable buffer that can be resized -class ARROW_EXPORT ResizableBuffer : public MutableBuffer { - public: - /// Change buffer reported size to indicated size, allocating memory if - /// necessary. This will ensure that the capacity of the buffer is a multiple - /// of 64 bytes as defined in Layout.md. - /// Consider using ZeroPadding afterwards, to conform to the Arrow layout - /// specification. - /// - /// @param new_size The new size for the buffer. - /// @param shrink_to_fit Whether to shrink the capacity if new size < current size - virtual Status Resize(const int64_t new_size, bool shrink_to_fit = true) = 0; - - /// Ensure that buffer has enough memory allocated to fit the indicated - /// capacity (and meets the 64 byte padding requirement in Layout.md). - /// It does not change buffer's reported size and doesn't zero the padding. - virtual Status Reserve(const int64_t new_capacity) = 0; - - template - Status TypedResize(const int64_t new_nb_elements, bool shrink_to_fit = true) { - return Resize(sizeof(T) * new_nb_elements, shrink_to_fit); - } - - template - Status TypedReserve(const int64_t new_nb_elements) { - return Reserve(sizeof(T) * new_nb_elements); - } - - protected: - ResizableBuffer(uint8_t* data, int64_t size) : MutableBuffer(data, size) {} -}; - -/// \defgroup buffer-allocation-functions Functions for allocating buffers -/// -/// @{ - -/// \brief Allocate a fixed size mutable buffer from a memory pool, zero its padding. -/// -/// \param[in] pool a memory pool -/// \param[in] size size of buffer to allocate -/// \param[out] out the allocated buffer (contains padding) -/// -/// \return Status message -ARROW_EXPORT -Status AllocateBuffer(MemoryPool* pool, const int64_t size, std::shared_ptr* out); - -/// \brief Allocate a fixed size mutable buffer from a memory pool, zero its padding. -/// -/// \param[in] pool a memory pool -/// \param[in] size size of buffer to allocate -/// \param[out] out the allocated buffer (contains padding) -/// -/// \return Status message -ARROW_EXPORT -Status AllocateBuffer(MemoryPool* pool, const int64_t size, std::unique_ptr* out); - -/// \brief Allocate a fixed-size mutable buffer from the default memory pool -/// -/// \param[in] size size of buffer to allocate -/// \param[out] out the allocated buffer (contains padding) -/// -/// \return Status message -ARROW_EXPORT -Status AllocateBuffer(const int64_t size, std::shared_ptr* out); - -/// \brief Allocate a fixed-size mutable buffer from the default memory pool -/// -/// \param[in] size size of buffer to allocate -/// \param[out] out the allocated buffer (contains padding) -/// -/// \return Status message -ARROW_EXPORT -Status AllocateBuffer(const int64_t size, std::unique_ptr* out); - -/// \brief Allocate a resizeable buffer from a memory pool, zero its padding. -/// -/// \param[in] pool a memory pool -/// \param[in] size size of buffer to allocate -/// \param[out] out the allocated buffer -/// -/// \return Status message -ARROW_EXPORT -Status AllocateResizableBuffer(MemoryPool* pool, const int64_t size, - std::shared_ptr* out); - -/// \brief Allocate a resizeable buffer from a memory pool, zero its padding. -/// -/// \param[in] pool a memory pool -/// \param[in] size size of buffer to allocate -/// \param[out] out the allocated buffer -/// -/// \return Status message -ARROW_EXPORT -Status AllocateResizableBuffer(MemoryPool* pool, const int64_t size, - std::unique_ptr* out); - -/// \brief Allocate a resizeable buffer from the default memory pool -/// -/// \param[in] size size of buffer to allocate -/// \param[out] out the allocated buffer -/// -/// \return Status message -ARROW_EXPORT -Status AllocateResizableBuffer(const int64_t size, std::shared_ptr* out); - -/// \brief Allocate a resizeable buffer from the default memory pool -/// -/// \param[in] size size of buffer to allocate -/// \param[out] out the allocated buffer -/// -/// \return Status message -ARROW_EXPORT -Status AllocateResizableBuffer(const int64_t size, std::unique_ptr* out); - -/// \brief Allocate a bitmap buffer from a memory pool -/// no guarantee on values is provided. -/// -/// \param[in] pool memory pool to allocate memory from -/// \param[in] length size in bits of bitmap to allocate -/// \param[out] out the resulting buffer -/// -/// \return Status message -ARROW_EXPORT -Status AllocateBitmap(MemoryPool* pool, int64_t length, std::shared_ptr* out); - -/// \brief Allocate a zero-initialized bitmap buffer from a memory pool -/// -/// \param[in] pool memory pool to allocate memory from -/// \param[in] length size in bits of bitmap to allocate -/// \param[out] out the resulting buffer (zero-initialized). -/// -/// \return Status message -ARROW_EXPORT -Status AllocateEmptyBitmap(MemoryPool* pool, int64_t length, - std::shared_ptr* out); - -/// \brief Allocate a zero-initialized bitmap buffer from the default memory pool -/// -/// \param[in] length size in bits of bitmap to allocate -/// \param[out] out the resulting buffer -/// -/// \return Status message -ARROW_EXPORT -Status AllocateEmptyBitmap(int64_t length, std::shared_ptr* out); - -/// \brief Concatenate multiple buffers into a single buffer -/// -/// \param[in] buffers to be concatenated -/// \param[in] pool memory pool to allocate the new buffer from -/// \param[out] out the concatenated buffer -/// -/// \return Status -ARROW_EXPORT -Status ConcatenateBuffers(const BufferVector& buffers, MemoryPool* pool, - std::shared_ptr* out); - -/// @} - -} // namespace arrow - -#endif // ARROW_BUFFER_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/builder.h b/cpp/thirdparty/knowhere_build/include/arrow/builder.h deleted file mode 100644 index 56c3e2b371..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/builder.h +++ /dev/null @@ -1,58 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include - -#include "arrow/array/builder_adaptive.h" // IWYU pragma: export -#include "arrow/array/builder_base.h" // IWYU pragma: export -#include "arrow/array/builder_binary.h" // IWYU pragma: export -#include "arrow/array/builder_decimal.h" // IWYU pragma: export -#include "arrow/array/builder_dict.h" // IWYU pragma: export -#include "arrow/array/builder_nested.h" // IWYU pragma: export -#include "arrow/array/builder_primitive.h" // IWYU pragma: export -#include "arrow/array/builder_time.h" // IWYU pragma: export -#include "arrow/status.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class DataType; -class MemoryPool; - -/// \brief Construct an empty ArrayBuilder corresponding to the data -/// type -/// \param[in] pool the MemoryPool to use for allocations -/// \param[in] type an instance of DictionaryType -/// \param[out] out the created ArrayBuilder -ARROW_EXPORT -Status MakeBuilder(MemoryPool* pool, const std::shared_ptr& type, - std::unique_ptr* out); - -/// \brief Construct an empty DictionaryBuilder initialized optionally -/// with a pre-existing dictionary -/// \param[in] pool the MemoryPool to use for allocations -/// \param[in] type an instance of DictionaryType -/// \param[in] dictionary the initial dictionary, if any. May be nullptr -/// \param[out] out the created ArrayBuilder -ARROW_EXPORT -Status MakeDictionaryBuilder(MemoryPool* pool, const std::shared_ptr& type, - const std::shared_ptr& dictionary, - std::unique_ptr* out); - -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/compare.h b/cpp/thirdparty/knowhere_build/include/arrow/compare.h deleted file mode 100644 index 21da16b79e..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/compare.h +++ /dev/null @@ -1,101 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// Functions for comparing Arrow data structures - -#ifndef ARROW_COMPARE_H -#define ARROW_COMPARE_H - -#include - -#include "arrow/util/visibility.h" - -namespace arrow { - -class Array; -class DataType; -class Tensor; -class SparseTensor; -struct Scalar; - -static constexpr double kDefaultAbsoluteTolerance = 1E-5; - -/// A container of options for equality comparisons -class EqualOptions { - public: - /// Whether or not NaNs are considered equal. - bool nans_equal() const { return nans_equal_; } - - /// Return a new EqualOptions object with the "nans_equal" property changed. - EqualOptions nans_equal(bool v) const { - auto res = EqualOptions(*this); - res.nans_equal_ = v; - return res; - } - - /// The absolute tolerance for approximate comparisons of floating-point values. - double atol() const { return atol_; } - - /// Return a new EqualOptions object with the "atol" property changed. - EqualOptions atol(double v) const { - auto res = EqualOptions(*this); - res.atol_ = v; - return res; - } - - static EqualOptions Defaults() { return EqualOptions(); } - - protected: - double atol_ = kDefaultAbsoluteTolerance; - bool nans_equal_ = false; -}; - -/// Returns true if the arrays are exactly equal -bool ARROW_EXPORT ArrayEquals(const Array& left, const Array& right, - const EqualOptions& = EqualOptions::Defaults()); - -bool ARROW_EXPORT TensorEquals(const Tensor& left, const Tensor& right); - -/// EXPERIMENTAL: Returns true if the given sparse tensors are exactly equal -bool ARROW_EXPORT SparseTensorEquals(const SparseTensor& left, const SparseTensor& right); - -/// Returns true if the arrays are approximately equal. For non-floating point -/// types, this is equivalent to ArrayEquals(left, right) -bool ARROW_EXPORT ArrayApproxEquals(const Array& left, const Array& right, - const EqualOptions& = EqualOptions::Defaults()); - -/// Returns true if indicated equal-length segment of arrays is exactly equal -bool ARROW_EXPORT ArrayRangeEquals(const Array& left, const Array& right, - int64_t start_idx, int64_t end_idx, - int64_t other_start_idx); - -/// Returns true if the type metadata are exactly equal -/// \param[in] left a DataType -/// \param[in] right a DataType -/// \param[in] check_metadata whether to compare KeyValueMetadata for child -/// fields -bool ARROW_EXPORT TypeEquals(const DataType& left, const DataType& right, - bool check_metadata = true); - -/// Returns true if scalars are equal -/// \param[in] left a Scalar -/// \param[in] right a Scalar -bool ARROW_EXPORT ScalarEquals(const Scalar& left, const Scalar& right); - -} // namespace arrow - -#endif // ARROW_COMPARE_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/compute/api.h b/cpp/thirdparty/knowhere_build/include/arrow/compute/api.h deleted file mode 100644 index 2a2e79f1a4..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/compute/api.h +++ /dev/null @@ -1,33 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_COMPUTE_API_H -#define ARROW_COMPUTE_API_H - -#include "arrow/compute/context.h" // IWYU pragma: export -#include "arrow/compute/kernel.h" // IWYU pragma: export - -#include "arrow/compute/kernels/boolean.h" // IWYU pragma: export -#include "arrow/compute/kernels/cast.h" // IWYU pragma: export -#include "arrow/compute/kernels/compare.h" // IWYU pragma: export -#include "arrow/compute/kernels/count.h" // IWYU pragma: export -#include "arrow/compute/kernels/hash.h" // IWYU pragma: export -#include "arrow/compute/kernels/mean.h" // IWYU pragma: export -#include "arrow/compute/kernels/sum.h" // IWYU pragma: export -#include "arrow/compute/kernels/take.h" // IWYU pragma: export - -#endif // ARROW_COMPUTE_API_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/compute/benchmark-util.h b/cpp/thirdparty/knowhere_build/include/arrow/compute/benchmark-util.h deleted file mode 100644 index 113fdd7031..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/compute/benchmark-util.h +++ /dev/null @@ -1,97 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include - -#include "arrow/testing/gtest_util.h" -#include "arrow/util/cpu-info.h" - -namespace arrow { -namespace compute { - -using internal::CpuInfo; -static CpuInfo* cpu_info = CpuInfo::GetInstance(); - -static const int64_t kL1Size = cpu_info->CacheSize(CpuInfo::L1_CACHE); -static const int64_t kL2Size = cpu_info->CacheSize(CpuInfo::L2_CACHE); -static const int64_t kL3Size = cpu_info->CacheSize(CpuInfo::L3_CACHE); -static const int64_t kCantFitInL3Size = kL3Size * 4; -static const std::vector kMemorySizes = {kL1Size, kL2Size, kL3Size, - kCantFitInL3Size}; - -template -struct BenchmarkArgsType; - -// Pattern matching that extracts the vector element type of Benchmark::Args() -template -struct BenchmarkArgsType&)> { - using type = Values; -}; - -// Benchmark changed its parameter type between releases from -// int to int64_t. As it doesn't have version macros, we need -// to apply C++ template magic. -using ArgsType = - typename BenchmarkArgsType::type; - -void BenchmarkSetArgsWithSizes(benchmark::internal::Benchmark* bench, - const std::vector& sizes = kMemorySizes) { - bench->Unit(benchmark::kMicrosecond); - - for (auto size : sizes) - for (auto nulls : std::vector({0, 1, 10, 50})) - bench->Args({static_cast(size), nulls}); -} - -void BenchmarkSetArgs(benchmark::internal::Benchmark* bench) { - BenchmarkSetArgsWithSizes(bench, kMemorySizes); -} - -void RegressionSetArgs(benchmark::internal::Benchmark* bench) { - // Regression do not need to account for cache hierarchy, thus optimize for - // the best case. - BenchmarkSetArgsWithSizes(bench, {kL1Size}); -} - -// RAII struct to handle some of the boilerplate in regression benchmarks -struct RegressionArgs { - // size of memory tested (per iteration) in bytes - const int64_t size; - - // proportion of nulls in generated arrays - const double null_proportion; - - explicit RegressionArgs(benchmark::State& state) - : size(state.range(0)), - null_proportion(static_cast(state.range(1)) / 100.0), - state_(state) {} - - ~RegressionArgs() { - state_.counters["size"] = static_cast(size); - state_.counters["null_percent"] = static_cast(state_.range(1)); - state_.SetBytesProcessed(state_.iterations() * size); - } - - private: - benchmark::State& state_; -}; - -} // namespace compute -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/compute/context.h b/cpp/thirdparty/knowhere_build/include/arrow/compute/context.h deleted file mode 100644 index 8ac4700b91..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/compute/context.h +++ /dev/null @@ -1,82 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_COMPUTE_CONTEXT_H -#define ARROW_COMPUTE_CONTEXT_H - -#include -#include - -#include "arrow/memory_pool.h" -#include "arrow/status.h" -#include "arrow/util/macros.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Buffer; - -namespace internal { -class CpuInfo; -} // namespace internal - -namespace compute { - -#define RETURN_IF_ERROR(ctx) \ - if (ARROW_PREDICT_FALSE(ctx->HasError())) { \ - Status s = ctx->status(); \ - ctx->ResetStatus(); \ - return s; \ - } - -/// \brief Container for variables and options used by function evaluation -class ARROW_EXPORT FunctionContext { - public: - explicit FunctionContext(MemoryPool* pool ARROW_MEMORY_POOL_DEFAULT); - MemoryPool* memory_pool() const; - - /// \brief Allocate buffer from the context's memory pool - Status Allocate(const int64_t nbytes, std::shared_ptr* out); - - /// \brief Indicate that an error has occurred, to be checked by a parent caller - /// \param[in] status a Status instance - /// - /// \note Will not overwrite a prior set Status, so we will have the first - /// error that occurred until FunctionContext::ResetStatus is called - void SetStatus(const Status& status); - - /// \brief Clear any error status - void ResetStatus(); - - /// \brief Return true if an error has occurred - bool HasError() const { return !status_.ok(); } - - /// \brief Return the current status of the context - const Status& status() const { return status_; } - - internal::CpuInfo* cpu_info() const { return cpu_info_; } - - private: - Status status_; - MemoryPool* pool_; - internal::CpuInfo* cpu_info_; -}; - -} // namespace compute -} // namespace arrow - -#endif // ARROW_COMPUTE_CONTEXT_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/compute/expression.h b/cpp/thirdparty/knowhere_build/include/arrow/compute/expression.h deleted file mode 100644 index cc55814154..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/compute/expression.h +++ /dev/null @@ -1,261 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include - -#include "arrow/compute/type_fwd.h" -#include "arrow/status.h" -#include "arrow/util/macros.h" -#include "arrow/util/visibility.h" - -namespace arrow { -namespace compute { - -class LogicalType; -class ExprVisitor; -class Operation; - -/// \brief Base class for all analytic expressions. Expressions may represent -/// data values (scalars, arrays, tables) -class ARROW_EXPORT Expr { - public: - /// \brief Instantiate expression from an abstract operation - /// \param[in] op the operation that generates the expression - explicit Expr(ConstOpPtr op); - - virtual ~Expr() = default; - - /// \brief A unique string identifier for the kind of expression - virtual std::string kind() const = 0; - - /// \brief Accept expression visitor - /// TODO(wesm) - // virtual Status Accept(ExprVisitor* visitor) const = 0; - - /// \brief The underlying operation - ConstOpPtr op() const { return op_; } - - protected: - ConstOpPtr op_; -}; - -/// The value cardinality: one or many. These correspond to the arrow::Scalar -/// and arrow::Array types -enum class ValueRank { SCALAR, ARRAY }; - -/// \brief Base class for a data-generated expression with a fixed and known -/// type. This includes arrays and scalars -class ARROW_EXPORT ValueExpr : public Expr { - public: - /// \brief The name of the expression, if any. The default is unnamed - // virtual const ExprName& name() const; - LogicalTypePtr type() const; - - /// \brief The value cardinality (scalar or array) of the expression - virtual ValueRank rank() const = 0; - - protected: - ValueExpr(ConstOpPtr op, LogicalTypePtr type); - - /// \brief The semantic data type of the expression - LogicalTypePtr type_; -}; - -class ARROW_EXPORT ArrayExpr : public ValueExpr { - protected: - using ValueExpr::ValueExpr; - std::string kind() const override; - ValueRank rank() const override; -}; - -class ARROW_EXPORT ScalarExpr : public ValueExpr { - protected: - using ValueExpr::ValueExpr; - std::string kind() const override; - ValueRank rank() const override; -}; - -namespace value { - -// These are mixin classes to provide a type hierarchy for values identify -class ValueMixin {}; -class Null : public ValueMixin {}; -class Bool : public ValueMixin {}; -class Number : public ValueMixin {}; -class Integer : public Number {}; -class SignedInteger : public Integer {}; -class Int8 : public SignedInteger {}; -class Int16 : public SignedInteger {}; -class Int32 : public SignedInteger {}; -class Int64 : public SignedInteger {}; -class UnsignedInteger : public Integer {}; -class UInt8 : public UnsignedInteger {}; -class UInt16 : public UnsignedInteger {}; -class UInt32 : public UnsignedInteger {}; -class UInt64 : public UnsignedInteger {}; -class Floating : public Number {}; -class Float16 : public Floating {}; -class Float32 : public Floating {}; -class Float64 : public Floating {}; -class Binary : public ValueMixin {}; -class Utf8 : public Binary {}; -class List : public ValueMixin {}; -class Struct : public ValueMixin {}; - -} // namespace value - -#define SIMPLE_EXPR_FACTORY(NAME) ARROW_EXPORT ExprPtr NAME(ConstOpPtr op); - -namespace scalar { - -#define DECLARE_SCALAR_EXPR(TYPE) \ - class ARROW_EXPORT TYPE : public ScalarExpr, public value::TYPE { \ - public: \ - explicit TYPE(ConstOpPtr op); \ - using ScalarExpr::kind; \ - }; - -DECLARE_SCALAR_EXPR(Null) -DECLARE_SCALAR_EXPR(Bool) -DECLARE_SCALAR_EXPR(Int8) -DECLARE_SCALAR_EXPR(Int16) -DECLARE_SCALAR_EXPR(Int32) -DECLARE_SCALAR_EXPR(Int64) -DECLARE_SCALAR_EXPR(UInt8) -DECLARE_SCALAR_EXPR(UInt16) -DECLARE_SCALAR_EXPR(UInt32) -DECLARE_SCALAR_EXPR(UInt64) -DECLARE_SCALAR_EXPR(Float16) -DECLARE_SCALAR_EXPR(Float32) -DECLARE_SCALAR_EXPR(Float64) -DECLARE_SCALAR_EXPR(Binary) -DECLARE_SCALAR_EXPR(Utf8) - -#undef DECLARE_SCALAR_EXPR - -SIMPLE_EXPR_FACTORY(null); -SIMPLE_EXPR_FACTORY(boolean); -SIMPLE_EXPR_FACTORY(int8); -SIMPLE_EXPR_FACTORY(int16); -SIMPLE_EXPR_FACTORY(int32); -SIMPLE_EXPR_FACTORY(int64); -SIMPLE_EXPR_FACTORY(uint8); -SIMPLE_EXPR_FACTORY(uint16); -SIMPLE_EXPR_FACTORY(uint32); -SIMPLE_EXPR_FACTORY(uint64); -SIMPLE_EXPR_FACTORY(float16); -SIMPLE_EXPR_FACTORY(float32); -SIMPLE_EXPR_FACTORY(float64); -SIMPLE_EXPR_FACTORY(binary); -SIMPLE_EXPR_FACTORY(utf8); - -class ARROW_EXPORT List : public ScalarExpr, public value::List { - public: - List(ConstOpPtr op, LogicalTypePtr type); - using ScalarExpr::kind; -}; - -class ARROW_EXPORT Struct : public ScalarExpr, public value::Struct { - public: - Struct(ConstOpPtr op, LogicalTypePtr type); - using ScalarExpr::kind; -}; - -} // namespace scalar - -namespace array { - -#define DECLARE_ARRAY_EXPR(TYPE) \ - class ARROW_EXPORT TYPE : public ArrayExpr, public value::TYPE { \ - public: \ - explicit TYPE(ConstOpPtr op); \ - using ArrayExpr::kind; \ - }; - -DECLARE_ARRAY_EXPR(Null) -DECLARE_ARRAY_EXPR(Bool) -DECLARE_ARRAY_EXPR(Int8) -DECLARE_ARRAY_EXPR(Int16) -DECLARE_ARRAY_EXPR(Int32) -DECLARE_ARRAY_EXPR(Int64) -DECLARE_ARRAY_EXPR(UInt8) -DECLARE_ARRAY_EXPR(UInt16) -DECLARE_ARRAY_EXPR(UInt32) -DECLARE_ARRAY_EXPR(UInt64) -DECLARE_ARRAY_EXPR(Float16) -DECLARE_ARRAY_EXPR(Float32) -DECLARE_ARRAY_EXPR(Float64) -DECLARE_ARRAY_EXPR(Binary) -DECLARE_ARRAY_EXPR(Utf8) - -#undef DECLARE_ARRAY_EXPR - -SIMPLE_EXPR_FACTORY(null); -SIMPLE_EXPR_FACTORY(boolean); -SIMPLE_EXPR_FACTORY(int8); -SIMPLE_EXPR_FACTORY(int16); -SIMPLE_EXPR_FACTORY(int32); -SIMPLE_EXPR_FACTORY(int64); -SIMPLE_EXPR_FACTORY(uint8); -SIMPLE_EXPR_FACTORY(uint16); -SIMPLE_EXPR_FACTORY(uint32); -SIMPLE_EXPR_FACTORY(uint64); -SIMPLE_EXPR_FACTORY(float16); -SIMPLE_EXPR_FACTORY(float32); -SIMPLE_EXPR_FACTORY(float64); -SIMPLE_EXPR_FACTORY(binary); -SIMPLE_EXPR_FACTORY(utf8); - -class ARROW_EXPORT List : public ArrayExpr, public value::List { - public: - List(ConstOpPtr op, LogicalTypePtr type); - using ArrayExpr::kind; -}; - -class ARROW_EXPORT Struct : public ArrayExpr, public value::Struct { - public: - Struct(ConstOpPtr op, LogicalTypePtr type); - using ArrayExpr::kind; -}; - -} // namespace array - -#undef SIMPLE_EXPR_FACTORY - -template -inline bool InheritsFrom(const ObjectType* obj) { - return dynamic_cast(obj) != NULLPTR; -} - -template -inline bool InheritsFrom(const ObjectType& obj) { - return dynamic_cast(&obj) != NULLPTR; -} - -/// \brief Construct a ScalarExpr containing an Operation given a logical type -ARROW_EXPORT -Status GetScalarExpr(ConstOpPtr op, LogicalTypePtr ty, ExprPtr* out); - -/// \brief Construct an ArrayExpr containing an Operation given a logical type -ARROW_EXPORT -Status GetArrayExpr(ConstOpPtr op, LogicalTypePtr ty, ExprPtr* out); - -} // namespace compute -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/compute/kernel.h b/cpp/thirdparty/knowhere_build/include/arrow/compute/kernel.h deleted file mode 100644 index c8f2e94ae0..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/compute/kernel.h +++ /dev/null @@ -1,289 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_COMPUTE_KERNEL_H -#define ARROW_COMPUTE_KERNEL_H - -#include -#include -#include - -#include "arrow/array.h" -#include "arrow/record_batch.h" -#include "arrow/scalar.h" -#include "arrow/table.h" -#include "arrow/util/macros.h" -#include "arrow/util/memory.h" -#include "arrow/util/variant.h" // IWYU pragma: export -#include "arrow/util/visibility.h" - -namespace arrow { -namespace compute { - -class FunctionContext; - -/// \class OpKernel -/// \brief Base class for operator kernels -/// -/// Note to implementors: -/// Operator kernels are intended to be the lowest level of an analytics/compute -/// engine. They will generally not be exposed directly to end-users. Instead -/// they will be wrapped by higher level constructs (e.g. top-level functions -/// or physical execution plan nodes). These higher level constructs are -/// responsible for user input validation and returning the appropriate -/// error Status. -/// -/// Due to this design, implementations of Call (the execution -/// method on subclasses) should use assertions (i.e. DCHECK) to double-check -/// parameter arguments when in higher level components returning an -/// InvalidArgument error might be more appropriate. -/// -class ARROW_EXPORT OpKernel { - public: - virtual ~OpKernel() = default; - /// \brief EXPERIMENTAL The output data type of the kernel - /// \return the output type - virtual std::shared_ptr out_type() const = 0; -}; - -struct Datum; -static inline bool CollectionEquals(const std::vector& left, - const std::vector& right); - -// Datums variants may have a length. This special value indicate that the -// current variant does not have a length. -constexpr int64_t kUnknownLength = -1; - -/// \class Datum -/// \brief Variant type for various Arrow C++ data structures -struct ARROW_EXPORT Datum { - enum type { NONE, SCALAR, ARRAY, CHUNKED_ARRAY, RECORD_BATCH, TABLE, COLLECTION }; - - util::variant, std::shared_ptr, - std::shared_ptr, std::shared_ptr, - std::shared_ptr, std::vector> - value; - - /// \brief Empty datum, to be populated elsewhere - Datum() : value(NULLPTR) {} - - Datum(const std::shared_ptr& value) // NOLINT implicit conversion - : value(value) {} - Datum(const std::shared_ptr& value) // NOLINT implicit conversion - : value(value) {} - - Datum(const std::shared_ptr& value) // NOLINT implicit conversion - : Datum(value ? value->data() : NULLPTR) {} - - Datum(const std::shared_ptr& value) // NOLINT implicit conversion - : value(value) {} - Datum(const std::shared_ptr& value) // NOLINT implicit conversion - : value(value) {} - Datum(const std::shared_ptr
& value) // NOLINT implicit conversion - : value(value) {} - Datum(const std::vector& value) // NOLINT implicit conversion - : value(value) {} - - // Cast from subtypes of Array to Datum - template ::value>::type> - Datum(const std::shared_ptr& value) // NOLINT implicit conversion - : Datum(std::shared_ptr(value)) {} - - // Convenience constructors - explicit Datum(bool value) : value(std::make_shared(value)) {} - explicit Datum(int8_t value) : value(std::make_shared(value)) {} - explicit Datum(uint8_t value) : value(std::make_shared(value)) {} - explicit Datum(int16_t value) : value(std::make_shared(value)) {} - explicit Datum(uint16_t value) : value(std::make_shared(value)) {} - explicit Datum(int32_t value) : value(std::make_shared(value)) {} - explicit Datum(uint32_t value) : value(std::make_shared(value)) {} - explicit Datum(int64_t value) : value(std::make_shared(value)) {} - explicit Datum(uint64_t value) : value(std::make_shared(value)) {} - explicit Datum(float value) : value(std::make_shared(value)) {} - explicit Datum(double value) : value(std::make_shared(value)) {} - - ~Datum() {} - - Datum(const Datum& other) noexcept { this->value = other.value; } - - Datum& operator=(const Datum& other) noexcept { - value = other.value; - return *this; - } - - // Define move constructor and move assignment, for better performance - Datum(Datum&& other) noexcept : value(std::move(other.value)) {} - - Datum& operator=(Datum&& other) noexcept { - value = std::move(other.value); - return *this; - } - - Datum::type kind() const { - switch (this->value.index()) { - case 0: - return Datum::NONE; - case 1: - return Datum::SCALAR; - case 2: - return Datum::ARRAY; - case 3: - return Datum::CHUNKED_ARRAY; - case 4: - return Datum::RECORD_BATCH; - case 5: - return Datum::TABLE; - case 6: - return Datum::COLLECTION; - default: - return Datum::NONE; - } - } - - std::shared_ptr array() const { - return util::get>(this->value); - } - - std::shared_ptr make_array() const { - return MakeArray(util::get>(this->value)); - } - - std::shared_ptr chunked_array() const { - return util::get>(this->value); - } - - std::shared_ptr record_batch() const { - return util::get>(this->value); - } - - std::shared_ptr
table() const { - return util::get>(this->value); - } - - const std::vector collection() const { - return util::get>(this->value); - } - - std::shared_ptr scalar() const { - return util::get>(this->value); - } - - bool is_array() const { return this->kind() == Datum::ARRAY; } - - bool is_arraylike() const { - return this->kind() == Datum::ARRAY || this->kind() == Datum::CHUNKED_ARRAY; - } - - bool is_scalar() const { return this->kind() == Datum::SCALAR; } - - /// \brief The value type of the variant, if any - /// - /// \return nullptr if no type - std::shared_ptr type() const { - if (this->kind() == Datum::ARRAY) { - return util::get>(this->value)->type; - } else if (this->kind() == Datum::CHUNKED_ARRAY) { - return util::get>(this->value)->type(); - } else if (this->kind() == Datum::SCALAR) { - return util::get>(this->value)->type; - } - return NULLPTR; - } - - /// \brief The value length of the variant, if any - /// - /// \return kUnknownLength if no type - int64_t length() const { - if (this->kind() == Datum::ARRAY) { - return util::get>(this->value)->length; - } else if (this->kind() == Datum::CHUNKED_ARRAY) { - return util::get>(this->value)->length(); - } else if (this->kind() == Datum::SCALAR) { - return 1; - } - return kUnknownLength; - } - - bool Equals(const Datum& other) const { - if (this->kind() != other.kind()) return false; - - switch (this->kind()) { - case Datum::NONE: - return true; - case Datum::SCALAR: - return internal::SharedPtrEquals(this->scalar(), other.scalar()); - case Datum::ARRAY: - return internal::SharedPtrEquals(this->make_array(), other.make_array()); - case Datum::CHUNKED_ARRAY: - return internal::SharedPtrEquals(this->chunked_array(), other.chunked_array()); - case Datum::RECORD_BATCH: - return internal::SharedPtrEquals(this->record_batch(), other.record_batch()); - case Datum::TABLE: - return internal::SharedPtrEquals(this->table(), other.table()); - case Datum::COLLECTION: - return CollectionEquals(this->collection(), other.collection()); - default: - return false; - } - } -}; - -/// \class UnaryKernel -/// \brief An array-valued function of a single input argument. -/// -/// Note to implementors: Try to avoid making kernels that allocate memory if -/// the output size is a deterministic function of the Input Datum's metadata. -/// Instead separate the logic of the kernel and allocations necessary into -/// two different kernels. Some reusable kernels that allocate buffers -/// and delegate computation to another kernel are available in util-internal.h. -class ARROW_EXPORT UnaryKernel : public OpKernel { - public: - /// \brief Executes the kernel. - /// - /// \param[in] ctx The function context for the kernel - /// \param[in] input The kernel input data - /// \param[out] out The output of the function. Each implementation of this - /// function might assume different things about the existing contents of out - /// (e.g. which buffers are preallocated). In the future it is expected that - /// there will be a more generic mechansim for understanding the necessary - /// contracts. - virtual Status Call(FunctionContext* ctx, const Datum& input, Datum* out) = 0; -}; - -/// \class BinaryKernel -/// \brief An array-valued function of a two input arguments -class ARROW_EXPORT BinaryKernel : public OpKernel { - public: - virtual Status Call(FunctionContext* ctx, const Datum& left, const Datum& right, - Datum* out) = 0; -}; - -static inline bool CollectionEquals(const std::vector& left, - const std::vector& right) { - if (left.size() != right.size()) return false; - - for (size_t i = 0; i < left.size(); i++) - if (!left[i].Equals(right[i])) return false; - - return true; -} - -} // namespace compute -} // namespace arrow - -#endif // ARROW_COMPUTE_KERNEL_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/aggregate.h b/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/aggregate.h deleted file mode 100644 index 2fe82636f8..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/aggregate.h +++ /dev/null @@ -1,115 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include - -#include "arrow/compute/kernel.h" - -namespace arrow { - -class Array; -class Status; - -namespace compute { - -class FunctionContext; -struct Datum; - -/// AggregateFunction is an interface for Aggregates -/// -/// An aggregates transforms an array into single result called a state via the -/// Consume method.. State supports the merge operation via the Merge method. -/// State can be sealed into a final result via the Finalize method. -// -/// State ownership is handled by callers, thus the interface exposes 3 methods -/// for the caller to manage memory: -/// - Size -/// - New (placement new constructor invocation) -/// - Delete (state desctructor) -/// -/// Design inspired by ClickHouse aggregate functions. -class AggregateFunction { - public: - /// \brief Consume an array into a state. - virtual Status Consume(const Array& input, void* state) const = 0; - - /// \brief Merge states. - virtual Status Merge(const void* src, void* dst) const = 0; - - /// \brief Convert state into a final result. - virtual Status Finalize(const void* src, Datum* output) const = 0; - - virtual ~AggregateFunction() {} - - virtual std::shared_ptr out_type() const = 0; - - /// State management methods. - virtual int64_t Size() const = 0; - virtual void New(void* ptr) const = 0; - virtual void Delete(void* ptr) const = 0; -}; - -/// AggregateFunction partial implementation for static type state -template -class AggregateFunctionStaticState : public AggregateFunction { - virtual Status Consume(const Array& input, State* state) const = 0; - virtual Status Merge(const State& src, State* dst) const = 0; - virtual Status Finalize(const State& src, Datum* output) const = 0; - - Status Consume(const Array& input, void* state) const final { - return Consume(input, static_cast(state)); - } - - Status Merge(const void* src, void* dst) const final { - return Merge(*static_cast(src), static_cast(dst)); - } - - /// \brief Convert state into a final result. - Status Finalize(const void* src, Datum* output) const final { - return Finalize(*static_cast(src), output); - } - - int64_t Size() const final { return sizeof(State); } - - void New(void* ptr) const final { - // By using placement-new syntax, the constructor of the State is invoked - // in the memory location defined by the caller. This only supports State - // with a parameter-less constructor. - new (ptr) State; - } - - void Delete(void* ptr) const final { static_cast(ptr)->~State(); } -}; - -/// \brief UnaryKernel implemented by an AggregateState -class ARROW_EXPORT AggregateUnaryKernel : public UnaryKernel { - public: - explicit AggregateUnaryKernel(std::shared_ptr& aggregate) - : aggregate_function_(aggregate) {} - - Status Call(FunctionContext* ctx, const Datum& input, Datum* out) override; - - std::shared_ptr out_type() const override; - - private: - std::shared_ptr aggregate_function_; -}; - -} // namespace compute -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/boolean.h b/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/boolean.h deleted file mode 100644 index fb88659dbc..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/boolean.h +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_COMPUTE_KERNELS_BOOLEAN_H -#define ARROW_COMPUTE_KERNELS_BOOLEAN_H - -#include "arrow/status.h" -#include "arrow/util/visibility.h" - -namespace arrow { -namespace compute { - -struct Datum; -class FunctionContext; - -/// \brief Invert the values of a boolean datum -/// \param[in] context the FunctionContext -/// \param[in] value datum to invert -/// \param[out] out resulting datum -/// -/// \since 0.11.0 -/// \note API not yet finalized -ARROW_EXPORT -Status Invert(FunctionContext* context, const Datum& value, Datum* out); - -/// \brief Element-wise AND of two boolean datums -/// \param[in] context the FunctionContext -/// \param[in] left left operand (array) -/// \param[in] right right operand (array) -/// \param[out] out resulting datum -/// -/// \since 0.11.0 -/// \note API not yet finalized -ARROW_EXPORT -Status And(FunctionContext* context, const Datum& left, const Datum& right, Datum* out); - -/// \brief Element-wise OR of two boolean datums -/// \param[in] context the FunctionContext -/// \param[in] left left operand (array) -/// \param[in] right right operand (array) -/// \param[out] out resulting datum -/// -/// \since 0.11.0 -/// \note API not yet finalized -ARROW_EXPORT -Status Or(FunctionContext* context, const Datum& left, const Datum& right, Datum* out); - -/// \brief Element-wise XOR of two boolean datums -/// \param[in] context the FunctionContext -/// \param[in] left left operand (array) -/// \param[in] right right operand (array) -/// \param[out] out resulting datum -/// -/// \since 0.11.0 -/// \note API not yet finalized -ARROW_EXPORT -Status Xor(FunctionContext* context, const Datum& left, const Datum& right, Datum* out); - -} // namespace compute -} // namespace arrow - -#endif // ARROW_COMPUTE_KERNELS_CAST_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/cast.h b/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/cast.h deleted file mode 100644 index 5a7c5be93b..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/cast.h +++ /dev/null @@ -1,98 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_COMPUTE_KERNELS_CAST_H -#define ARROW_COMPUTE_KERNELS_CAST_H - -#include - -#include "arrow/status.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Array; -class DataType; - -namespace compute { - -struct Datum; -class FunctionContext; -class UnaryKernel; - -struct ARROW_EXPORT CastOptions { - CastOptions() - : allow_int_overflow(false), - allow_time_truncate(false), - allow_float_truncate(false), - allow_invalid_utf8(false) {} - - explicit CastOptions(bool safe) - : allow_int_overflow(!safe), - allow_time_truncate(!safe), - allow_float_truncate(!safe), - allow_invalid_utf8(!safe) {} - - static CastOptions Safe() { return CastOptions(true); } - - static CastOptions Unsafe() { return CastOptions(false); } - - bool allow_int_overflow; - bool allow_time_truncate; - bool allow_float_truncate; - // Indicate if conversions from Binary/FixedSizeBinary to string must - // validate the utf8 payload. - bool allow_invalid_utf8; -}; - -/// \since 0.7.0 -/// \note API not yet finalized -ARROW_EXPORT -Status GetCastFunction(const DataType& in_type, std::shared_ptr to_type, - const CastOptions& options, std::unique_ptr* kernel); - -/// \brief Cast from one array type to another -/// \param[in] context the FunctionContext -/// \param[in] value array to cast -/// \param[in] to_type type to cast to -/// \param[in] options casting options -/// \param[out] out resulting array -/// -/// \since 0.7.0 -/// \note API not yet finalized -ARROW_EXPORT -Status Cast(FunctionContext* context, const Array& value, - std::shared_ptr to_type, const CastOptions& options, - std::shared_ptr* out); - -/// \brief Cast from one value to another -/// \param[in] context the FunctionContext -/// \param[in] value datum to cast -/// \param[in] to_type type to cast to -/// \param[in] options casting options -/// \param[out] out resulting datum -/// -/// \since 0.8.0 -/// \note API not yet finalized -ARROW_EXPORT -Status Cast(FunctionContext* context, const Datum& value, - std::shared_ptr to_type, const CastOptions& options, Datum* out); - -} // namespace compute -} // namespace arrow - -#endif // ARROW_COMPUTE_KERNELS_CAST_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/compare.h b/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/compare.h deleted file mode 100644 index b4c9612ae8..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/compare.h +++ /dev/null @@ -1,176 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include - -#include "arrow/compute/kernel.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Array; -class DataType; -struct Scalar; -class Status; - -namespace compute { - -struct Datum; -class FunctionContext; - -/// CompareFunction is an interface for Comparisons -/// -/// Comparisons take an array and emits a selection vector. The selection vector -/// is given in the form of a bitmask as a BooleanArray result. -class ARROW_EXPORT CompareFunction { - public: - /// Compare an array with a scalar argument. - virtual Status Compare(const ArrayData& array, const Scalar& scalar, - ArrayData* output) const = 0; - - Status Compare(const ArrayData& array, const Scalar& scalar, - std::shared_ptr* output) { - return Compare(array, scalar, output->get()); - } - - virtual Status Compare(const Scalar& scalar, const ArrayData& array, - ArrayData* output) const = 0; - - Status Compare(const Scalar& scalar, const ArrayData& array, - std::shared_ptr* output) { - return Compare(scalar, array, output->get()); - } - - /// Compare an array with an array argument. - virtual Status Compare(const ArrayData& lhs, const ArrayData& rhs, - ArrayData* output) const = 0; - - Status Compare(const ArrayData& lhs, const ArrayData& rhs, - std::shared_ptr* output) { - return Compare(lhs, rhs, output->get()); - } - - /// By default, CompareFunction emits a result bitmap. - virtual std::shared_ptr out_type() const { return boolean(); } - - virtual ~CompareFunction() {} -}; - -/// \brief BinaryKernel bound to a select function -class ARROW_EXPORT CompareBinaryKernel : public BinaryKernel { - public: - explicit CompareBinaryKernel(std::shared_ptr& select) - : compare_function_(select) {} - - Status Call(FunctionContext* ctx, const Datum& left, const Datum& right, - Datum* out) override; - - static int64_t out_length(const Datum& left, const Datum& right) { - if (left.kind() == Datum::ARRAY) return left.length(); - if (right.kind() == Datum::ARRAY) return right.length(); - - return 0; - } - - std::shared_ptr out_type() const override; - - private: - std::shared_ptr compare_function_; -}; - -enum CompareOperator { - EQUAL, - NOT_EQUAL, - GREATER, - GREATER_EQUAL, - LESS, - LESS_EQUAL, -}; - -template -struct Comparator; - -template -struct Comparator { - constexpr static bool Compare(const T& lhs, const T& rhs) { return lhs == rhs; } -}; - -template -struct Comparator { - constexpr static bool Compare(const T& lhs, const T& rhs) { return lhs != rhs; } -}; - -template -struct Comparator { - constexpr static bool Compare(const T& lhs, const T& rhs) { return lhs > rhs; } -}; - -template -struct Comparator { - constexpr static bool Compare(const T& lhs, const T& rhs) { return lhs >= rhs; } -}; - -template -struct Comparator { - constexpr static bool Compare(const T& lhs, const T& rhs) { return lhs < rhs; } -}; - -template -struct Comparator { - constexpr static bool Compare(const T& lhs, const T& rhs) { return lhs <= rhs; } -}; - -struct CompareOptions { - explicit CompareOptions(CompareOperator op) : op(op) {} - - enum CompareOperator op; -}; - -/// \brief Return a Compare CompareFunction -/// -/// \param[in] context FunctionContext passing context information -/// \param[in] type required to specialize the kernel -/// \param[in] options required to specify the compare operator -/// -/// \since 0.14.0 -/// \note API not yet finalized -ARROW_EXPORT -std::shared_ptr MakeCompareFunction(FunctionContext* context, - const DataType& type, - struct CompareOptions options); - -/// \brief Compare a numeric array with a scalar. -/// -/// \param[in] context the FunctionContext -/// \param[in] left datum to compare, must be an Array -/// \param[in] right datum to compare, must be a Scalar of the same type than -/// left Datum. -/// \param[in] options compare options -/// \param[out] out resulting datum -/// -/// Note on floating point arrays, this uses ieee-754 compare semantics. -/// -/// \since 0.14.0 -/// \note API not yet finalized -ARROW_EXPORT -Status Compare(FunctionContext* context, const Datum& left, const Datum& right, - struct CompareOptions options, Datum* out); - -} // namespace compute -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/count.h b/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/count.h deleted file mode 100644 index c33ac48665..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/count.h +++ /dev/null @@ -1,88 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include - -#include "arrow/status.h" -#include "arrow/type.h" -#include "arrow/type_traits.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Array; -class DataType; - -namespace compute { - -struct Datum; -class FunctionContext; -class AggregateFunction; - -/// \class CountOptions -/// -/// The user control the Count kernel behavior with this class. By default, the -/// it will count all non-null values. -struct ARROW_EXPORT CountOptions { - enum mode { - // Count all non-null values. - COUNT_ALL = 0, - // Count all null values. - COUNT_NULL, - }; - - explicit CountOptions(enum mode count_mode) : count_mode(count_mode) {} - - enum mode count_mode = COUNT_ALL; -}; - -/// \brief Return Count function aggregate -ARROW_EXPORT -std::shared_ptr MakeCount(FunctionContext* context, - const CountOptions& options); - -/// \brief Count non-null (or null) values in an array. -/// -/// \param[in] context the FunctionContext -/// \param[in] options counting options, see CountOptions for more information -/// \param[in] datum to count -/// \param[out] out resulting datum -/// -/// \since 0.13.0 -/// \note API not yet finalized -ARROW_EXPORT -Status Count(FunctionContext* context, const CountOptions& options, const Datum& datum, - Datum* out); - -/// \brief Count non-null (or null) values in an array. -/// -/// \param[in] context the FunctionContext -/// \param[in] options counting options, see CountOptions for more information -/// \param[in] array to count -/// \param[out] out resulting datum -/// -/// \since 0.13.0 -/// \note API not yet finalized -ARROW_EXPORT -Status Count(FunctionContext* context, const CountOptions& options, const Array& array, - Datum* out); - -} // namespace compute -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/filter.h b/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/filter.h deleted file mode 100644 index 401daa8c80..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/filter.h +++ /dev/null @@ -1,93 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include - -#include "arrow/compute/kernel.h" -#include "arrow/status.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Array; - -namespace compute { - -class FunctionContext; - -/// \brief Filter an array with a boolean selection filter -/// -/// The output array will be populated with values from the input at positions -/// where the selection filter is not 0. Nulls in the filter will result in nulls -/// in the output. -/// -/// For example given values = ["a", "b", "c", null, "e", "f"] and -/// filter = [0, 1, 1, 0, null, 1], the output will be -/// = ["b", "c", null, "f"] -/// -/// \param[in] ctx the FunctionContext -/// \param[in] values array to filter -/// \param[in] filter indicates which values should be filtered out -/// \param[out] out resulting array -ARROW_EXPORT -Status Filter(FunctionContext* ctx, const Array& values, const Array& filter, - std::shared_ptr* out); - -/// \brief Filter an array with a boolean selection filter -/// -/// \param[in] ctx the FunctionContext -/// \param[in] values datum to filter -/// \param[in] filter indicates which values should be filtered out -/// \param[out] out resulting datum -ARROW_EXPORT -Status Filter(FunctionContext* ctx, const Datum& values, const Datum& filter, Datum* out); - -/// \brief BinaryKernel implementing Filter operation -class ARROW_EXPORT FilterKernel : public BinaryKernel { - public: - explicit FilterKernel(const std::shared_ptr& type) : type_(type) {} - - /// \brief BinaryKernel interface - /// - /// delegates to subclasses via Filter() - Status Call(FunctionContext* ctx, const Datum& values, const Datum& filter, - Datum* out) override; - - /// \brief output type of this kernel (identical to type of values filtered) - std::shared_ptr out_type() const override { return type_; } - - /// \brief factory for FilterKernels - /// - /// \param[in] value_type constructed FilterKernel will support filtering - /// values of this type - /// \param[out] out created kernel - static Status Make(const std::shared_ptr& value_type, - std::unique_ptr* out); - - /// \brief single-array implementation - virtual Status Filter(FunctionContext* ctx, const Array& values, - const BooleanArray& filter, int64_t length, - std::shared_ptr* out) = 0; - - protected: - std::shared_ptr type_; -}; - -} // namespace compute -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/hash.h b/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/hash.h deleted file mode 100644 index edc7c493e4..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/hash.h +++ /dev/null @@ -1,105 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_COMPUTE_KERNELS_HASH_H -#define ARROW_COMPUTE_KERNELS_HASH_H - -#include - -#include "arrow/compute/kernel.h" -#include "arrow/status.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Array; -class DataType; -struct ArrayData; - -namespace compute { - -class FunctionContext; - -/// \brief Compute unique elements from an array-like object -/// -/// Note if a null occurs in the input it will NOT be included in the output. -/// -/// \param[in] context the FunctionContext -/// \param[in] datum array-like input -/// \param[out] out result as Array -/// -/// \since 0.8.0 -/// \note API not yet finalized -ARROW_EXPORT -Status Unique(FunctionContext* context, const Datum& datum, std::shared_ptr* out); - -// Constants for accessing the output of ValueCounts -ARROW_EXPORT extern const char kValuesFieldName[]; -ARROW_EXPORT extern const char kCountsFieldName[]; -ARROW_EXPORT extern const int32_t kValuesFieldIndex; -ARROW_EXPORT extern const int32_t kCountsFieldIndex; -/// \brief Return counts of unique elements from an array-like object. -/// -/// Note that the counts do not include counts for nulls in the array. These can be -/// obtained separately from metadata. -/// -/// For floating point arrays there is no attempt to normalize -0.0, 0.0 and NaN values -/// which can lead to unexpected results if the input Array has these values. -/// -/// \param[in] context the FunctionContext -/// \param[in] value array-like input -/// \param[out] counts An array of structs. -/// -/// \since 0.13.0 -/// \note API not yet finalized -ARROW_EXPORT -Status ValueCounts(FunctionContext* context, const Datum& value, - std::shared_ptr* counts); - -/// \brief Dictionary-encode values in an array-like object -/// \param[in] context the FunctionContext -/// \param[in] data array-like input -/// \param[out] out result with same shape and type as input -/// -/// \since 0.8.0 -/// \note API not yet finalized -ARROW_EXPORT -Status DictionaryEncode(FunctionContext* context, const Datum& data, Datum* out); - -// TODO(wesm): Define API for incremental dictionary encoding - -// TODO(wesm): Define API for regularizing DictionaryArray objects with -// different dictionaries - -// -// ARROW_EXPORT -// Status DictionaryEncode(FunctionContext* context, const Datum& data, -// const Array& prior_dictionary, Datum* out); - -// TODO(wesm): Implement these next -// ARROW_EXPORT -// Status Match(FunctionContext* context, const Datum& values, const Datum& member_set, -// Datum* out); - -// ARROW_EXPORT -// Status IsIn(FunctionContext* context, const Datum& values, const Datum& member_set, -// Datum* out); - -} // namespace compute -} // namespace arrow - -#endif // ARROW_COMPUTE_KERNELS_HASH_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/mean.h b/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/mean.h deleted file mode 100644 index 5074d4e7b7..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/mean.h +++ /dev/null @@ -1,66 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include - -#include "arrow/status.h" -#include "arrow/type.h" -#include "arrow/type_traits.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Array; -class DataType; - -namespace compute { - -struct Datum; -class FunctionContext; -class AggregateFunction; - -ARROW_EXPORT -std::shared_ptr MakeMeanAggregateFunction(const DataType& type, - FunctionContext* context); - -/// \brief Compute the mean of a numeric array. -/// -/// \param[in] context the FunctionContext -/// \param[in] value datum to compute the mean, expecting Array -/// \param[out] mean datum of the computed mean as a DoubleScalar -/// -/// \since 0.13.0 -/// \note API not yet finalized -ARROW_EXPORT -Status Mean(FunctionContext* context, const Datum& value, Datum* mean); - -/// \brief Compute the mean of a numeric array. -/// -/// \param[in] context the FunctionContext -/// \param[in] array to compute the mean -/// \param[out] mean datum of the computed mean as a DoubleScalar -/// -/// \since 0.13.0 -/// \note API not yet finalized -ARROW_EXPORT -Status Mean(FunctionContext* context, const Array& array, Datum* mean); - -} // namespace compute -}; // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/sum.h b/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/sum.h deleted file mode 100644 index e6f95490d7..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/sum.h +++ /dev/null @@ -1,70 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include - -#include "arrow/util/visibility.h" - -namespace arrow { - -class Array; -class DataType; -class Status; - -namespace compute { - -struct Datum; -class FunctionContext; -class AggregateFunction; - -/// \brief Return a Sum Kernel -/// -/// \param[in] type required to specialize the kernel -/// \param[in] context the FunctionContext -/// -/// \since 0.13.0 -/// \note API not yet finalized -ARROW_EXPORT -std::shared_ptr MakeSumAggregateFunction(const DataType& type, - FunctionContext* context); - -/// \brief Sum values of a numeric array. -/// -/// \param[in] context the FunctionContext -/// \param[in] value datum to sum, expecting Array or ChunkedArray -/// \param[out] out resulting datum -/// -/// \since 0.13.0 -/// \note API not yet finalized -ARROW_EXPORT -Status Sum(FunctionContext* context, const Datum& value, Datum* out); - -/// \brief Sum values of a numeric array. -/// -/// \param[in] context the FunctionContext -/// \param[in] array to sum -/// \param[out] out resulting datum -/// -/// \since 0.13.0 -/// \note API not yet finalized -ARROW_EXPORT -Status Sum(FunctionContext* context, const Array& array, Datum* out); - -} // namespace compute -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/take.h b/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/take.h deleted file mode 100644 index f064b7265e..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/compute/kernels/take.h +++ /dev/null @@ -1,101 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include - -#include "arrow/compute/kernel.h" -#include "arrow/status.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Array; - -namespace compute { - -class FunctionContext; - -struct ARROW_EXPORT TakeOptions {}; - -/// \brief Take from an array of values at indices in another array -/// -/// The output array will be of the same type as the input values -/// array, with elements taken from the values array at the given -/// indices. If an index is null then the taken element will be null. -/// -/// For example given values = ["a", "b", "c", null, "e", "f"] and -/// indices = [2, 1, null, 3], the output will be -/// = [values[2], values[1], null, values[3]] -/// = ["c", "b", null, null] -/// -/// \param[in] ctx the FunctionContext -/// \param[in] values array from which to take -/// \param[in] indices which values to take -/// \param[in] options options -/// \param[out] out resulting array -ARROW_EXPORT -Status Take(FunctionContext* ctx, const Array& values, const Array& indices, - const TakeOptions& options, std::shared_ptr* out); - -/// \brief Take from an array of values at indices in another array -/// -/// \param[in] ctx the FunctionContext -/// \param[in] values datum from which to take -/// \param[in] indices which values to take -/// \param[in] options options -/// \param[out] out resulting datum -ARROW_EXPORT -Status Take(FunctionContext* ctx, const Datum& values, const Datum& indices, - const TakeOptions& options, Datum* out); - -/// \brief BinaryKernel implementing Take operation -class ARROW_EXPORT TakeKernel : public BinaryKernel { - public: - explicit TakeKernel(const std::shared_ptr& type, TakeOptions options = {}) - : type_(type) {} - - /// \brief BinaryKernel interface - /// - /// delegates to subclasses via Take() - Status Call(FunctionContext* ctx, const Datum& values, const Datum& indices, - Datum* out) override; - - /// \brief output type of this kernel (identical to type of values taken) - std::shared_ptr out_type() const override { return type_; } - - /// \brief factory for TakeKernels - /// - /// \param[in] value_type constructed TakeKernel will support taking - /// values of this type - /// \param[in] index_type constructed TakeKernel will support taking - /// with indices of this type - /// \param[out] out created kernel - static Status Make(const std::shared_ptr& value_type, - const std::shared_ptr& index_type, - std::unique_ptr* out); - - /// \brief single-array implementation - virtual Status Take(FunctionContext* ctx, const Array& values, const Array& indices, - std::shared_ptr* out) = 0; - - protected: - std::shared_ptr type_; -}; -} // namespace compute -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/compute/logical_type.h b/cpp/thirdparty/knowhere_build/include/arrow/compute/logical_type.h deleted file mode 100644 index 7acbeefe4a..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/compute/logical_type.h +++ /dev/null @@ -1,308 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// Metadata objects for creating well-typed expressions. These are distinct -// from (and higher level than) arrow::DataType as some type parameters (like -// decimal scale and precision) may not be known at expression build time, and -// these are resolved later on evaluation - -#pragma once - -#include -#include - -#include "arrow/compute/type_fwd.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Status; - -namespace compute { - -class Expr; - -/// \brief An object that represents either a single concrete value type or a -/// group of related types, to help with expression type validation and other -/// purposes -class ARROW_EXPORT LogicalType { - public: - enum Id { - ANY, - NUMBER, - INTEGER, - SIGNED_INTEGER, - UNSIGNED_INTEGER, - FLOATING, - NULL_, - BOOL, - UINT8, - INT8, - UINT16, - INT16, - UINT32, - INT32, - UINT64, - INT64, - FLOAT16, - FLOAT32, - FLOAT64, - BINARY, - UTF8, - DATE, - TIME, - TIMESTAMP, - DECIMAL, - LIST, - STRUCT - }; - - Id id() const { return id_; } - - virtual ~LogicalType() = default; - - virtual std::string ToString() const = 0; - - /// \brief Check if expression is an instance of this type class - virtual bool IsInstance(const Expr& expr) const = 0; - - /// \brief Get a logical expression type from a concrete Arrow in-memory - /// array type - static Status FromArrow(const ::arrow::DataType& type, LogicalTypePtr* out); - - protected: - explicit LogicalType(Id id) : id_(id) {} - Id id_; -}; - -namespace type { - -/// \brief Logical type for any value type -class ARROW_EXPORT Any : public LogicalType { - public: - Any() : LogicalType(LogicalType::ANY) {} - bool IsInstance(const Expr& expr) const override; - std::string ToString() const override; -}; - -/// \brief Logical type for null -class ARROW_EXPORT Null : public LogicalType { - public: - Null() : LogicalType(LogicalType::NULL_) {} - bool IsInstance(const Expr& expr) const override; - std::string ToString() const override; -}; - -/// \brief Logical type for concrete boolean -class ARROW_EXPORT Bool : public LogicalType { - public: - Bool() : LogicalType(LogicalType::BOOL) {} - bool IsInstance(const Expr& expr) const override; - std::string ToString() const override; -}; - -/// \brief Logical type for any number (integer or floating point) -class ARROW_EXPORT Number : public LogicalType { - public: - Number() : Number(LogicalType::NUMBER) {} - bool IsInstance(const Expr& expr) const override; - std::string ToString() const override; - - protected: - explicit Number(Id type_id) : LogicalType(type_id) {} -}; - -/// \brief Logical type for any integer -class ARROW_EXPORT Integer : public Number { - public: - Integer() : Integer(LogicalType::INTEGER) {} - bool IsInstance(const Expr& expr) const override; - std::string ToString() const override; - - protected: - explicit Integer(Id type_id) : Number(type_id) {} -}; - -/// \brief Logical type for any floating point number -class ARROW_EXPORT Floating : public Number { - public: - Floating() : Floating(LogicalType::FLOATING) {} - bool IsInstance(const Expr& expr) const override; - std::string ToString() const override; - - protected: - explicit Floating(Id type_id) : Number(type_id) {} -}; - -/// \brief Logical type for any signed integer -class ARROW_EXPORT SignedInteger : public Integer { - public: - SignedInteger() : SignedInteger(LogicalType::SIGNED_INTEGER) {} - bool IsInstance(const Expr& expr) const override; - std::string ToString() const override; - - protected: - explicit SignedInteger(Id type_id) : Integer(type_id) {} -}; - -/// \brief Logical type for any unsigned integer -class ARROW_EXPORT UnsignedInteger : public Integer { - public: - UnsignedInteger() : UnsignedInteger(LogicalType::UNSIGNED_INTEGER) {} - bool IsInstance(const Expr& expr) const override; - std::string ToString() const override; - - protected: - explicit UnsignedInteger(Id type_id) : Integer(type_id) {} -}; - -/// \brief Logical type for int8 -class ARROW_EXPORT Int8 : public SignedInteger { - public: - Int8() : SignedInteger(LogicalType::INT8) {} - bool IsInstance(const Expr& expr) const override; - std::string ToString() const override; -}; - -/// \brief Logical type for int16 -class ARROW_EXPORT Int16 : public SignedInteger { - public: - Int16() : SignedInteger(LogicalType::INT16) {} - bool IsInstance(const Expr& expr) const override; - std::string ToString() const override; -}; - -/// \brief Logical type for int32 -class ARROW_EXPORT Int32 : public SignedInteger { - public: - Int32() : SignedInteger(LogicalType::INT32) {} - bool IsInstance(const Expr& expr) const override; - std::string ToString() const override; -}; - -/// \brief Logical type for int64 -class ARROW_EXPORT Int64 : public SignedInteger { - public: - Int64() : SignedInteger(LogicalType::INT64) {} - bool IsInstance(const Expr& expr) const override; - std::string ToString() const override; -}; - -/// \brief Logical type for uint8 -class ARROW_EXPORT UInt8 : public UnsignedInteger { - public: - UInt8() : UnsignedInteger(LogicalType::UINT8) {} - bool IsInstance(const Expr& expr) const override; - std::string ToString() const override; -}; - -/// \brief Logical type for uint16 -class ARROW_EXPORT UInt16 : public UnsignedInteger { - public: - UInt16() : UnsignedInteger(LogicalType::UINT16) {} - bool IsInstance(const Expr& expr) const override; - std::string ToString() const override; -}; - -/// \brief Logical type for uint32 -class ARROW_EXPORT UInt32 : public UnsignedInteger { - public: - UInt32() : UnsignedInteger(LogicalType::UINT32) {} - bool IsInstance(const Expr& expr) const override; - std::string ToString() const override; -}; - -/// \brief Logical type for uint64 -class ARROW_EXPORT UInt64 : public UnsignedInteger { - public: - UInt64() : UnsignedInteger(LogicalType::UINT64) {} - bool IsInstance(const Expr& expr) const override; - std::string ToString() const override; -}; - -/// \brief Logical type for 16-bit floating point -class ARROW_EXPORT Float16 : public Floating { - public: - Float16() : Floating(LogicalType::FLOAT16) {} - bool IsInstance(const Expr& expr) const override; - std::string ToString() const override; -}; - -/// \brief Logical type for 32-bit floating point -class ARROW_EXPORT Float32 : public Floating { - public: - Float32() : Floating(LogicalType::FLOAT32) {} - bool IsInstance(const Expr& expr) const override; - std::string ToString() const override; -}; - -/// \brief Logical type for 64-bit floating point -class ARROW_EXPORT Float64 : public Floating { - public: - Float64() : Floating(LogicalType::FLOAT64) {} - bool IsInstance(const Expr& expr) const override; - std::string ToString() const override; -}; - -/// \brief Logical type for variable-size binary -class ARROW_EXPORT Binary : public LogicalType { - public: - Binary() : Binary(LogicalType::BINARY) {} - bool IsInstance(const Expr& expr) const override; - std::string ToString() const override; - - protected: - explicit Binary(Id type_id) : LogicalType(type_id) {} -}; - -/// \brief Logical type for variable-size binary -class ARROW_EXPORT Utf8 : public Binary { - public: - Utf8() : Binary(LogicalType::UTF8) {} - bool IsInstance(const Expr& expr) const override; - std::string ToString() const override; -}; - -#define SIMPLE_TYPE_FACTORY(NAME) ARROW_EXPORT LogicalTypePtr NAME(); - -SIMPLE_TYPE_FACTORY(any); -SIMPLE_TYPE_FACTORY(null); -SIMPLE_TYPE_FACTORY(boolean); -SIMPLE_TYPE_FACTORY(number); -SIMPLE_TYPE_FACTORY(integer); -SIMPLE_TYPE_FACTORY(signed_integer); -SIMPLE_TYPE_FACTORY(unsigned_integer); -SIMPLE_TYPE_FACTORY(floating); -SIMPLE_TYPE_FACTORY(int8); -SIMPLE_TYPE_FACTORY(int16); -SIMPLE_TYPE_FACTORY(int32); -SIMPLE_TYPE_FACTORY(int64); -SIMPLE_TYPE_FACTORY(uint8); -SIMPLE_TYPE_FACTORY(uint16); -SIMPLE_TYPE_FACTORY(uint32); -SIMPLE_TYPE_FACTORY(uint64); -SIMPLE_TYPE_FACTORY(float16); -SIMPLE_TYPE_FACTORY(float32); -SIMPLE_TYPE_FACTORY(float64); -SIMPLE_TYPE_FACTORY(binary); -SIMPLE_TYPE_FACTORY(utf8); - -#undef SIMPLE_TYPE_FACTORY - -} // namespace type -} // namespace compute -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/compute/operation.h b/cpp/thirdparty/knowhere_build/include/arrow/compute/operation.h deleted file mode 100644 index c06f8c311c..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/compute/operation.h +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include - -#include "arrow/compute/type_fwd.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Status; - -namespace compute { - -/// \brief An operation is a node in a computation graph, taking input data -/// expression dependencies and emitting an output expression -class ARROW_EXPORT Operation : public std::enable_shared_from_this { - public: - virtual ~Operation() = default; - - /// \brief Check input expression arguments and output the type of resulting - /// expression that this operation produces. If the input arguments are - /// invalid, error Status is returned - /// \param[out] out the returned well-typed expression - /// \return success or failure - virtual Status ToExpr(ExprPtr* out) const = 0; - - /// \brief Return the input expressions used to instantiate the - /// operation. The default implementation returns an empty vector - /// \return a vector of expressions - virtual std::vector input_args() const; -}; - -} // namespace compute -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/compute/test-util.h b/cpp/thirdparty/knowhere_build/include/arrow/compute/test-util.h deleted file mode 100644 index bec54cc361..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/compute/test-util.h +++ /dev/null @@ -1,110 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_COMPUTE_TEST_UTIL_H -#define ARROW_COMPUTE_TEST_UTIL_H - -#include -#include - -#include - -#include "arrow/array.h" -#include "arrow/memory_pool.h" -#include "arrow/testing/gtest_util.h" -#include "arrow/testing/util.h" -#include "arrow/type.h" - -#include "arrow/compute/context.h" -#include "arrow/compute/kernel.h" - -namespace arrow { -namespace compute { - -class ComputeFixture { - public: - ComputeFixture() : ctx_(default_memory_pool()) {} - - protected: - FunctionContext ctx_; -}; - -class MockUnaryKernel : public UnaryKernel { - public: - MOCK_METHOD3(Call, Status(FunctionContext* ctx, const Datum& input, Datum* out)); - MOCK_CONST_METHOD0(out_type, std::shared_ptr()); -}; - -class MockBinaryKernel : public BinaryKernel { - public: - MOCK_METHOD4(Call, Status(FunctionContext* ctx, const Datum& left, const Datum& right, - Datum* out)); - MOCK_CONST_METHOD0(out_type, std::shared_ptr()); -}; - -template -std::shared_ptr _MakeArray(const std::shared_ptr& type, - const std::vector& values, - const std::vector& is_valid) { - std::shared_ptr result; - if (is_valid.size() > 0) { - ArrayFromVector(type, is_valid, values, &result); - } else { - ArrayFromVector(type, values, &result); - } - return result; -} - -template -struct DatumEqual {}; - -template -struct DatumEqual::value>::type> { - static constexpr double kArbitraryDoubleErrorBound = 1.0; - using ScalarType = typename TypeTraits::ScalarType; - - static void EnsureEqual(const Datum& lhs, const Datum& rhs) { - ASSERT_EQ(lhs.kind(), rhs.kind()); - if (lhs.kind() == Datum::SCALAR) { - auto left = internal::checked_cast(lhs.scalar().get()); - auto right = internal::checked_cast(rhs.scalar().get()); - ASSERT_EQ(left->is_valid, right->is_valid); - ASSERT_EQ(left->type->id(), right->type->id()); - ASSERT_NEAR(left->value, right->value, kArbitraryDoubleErrorBound); - } - } -}; - -template -struct DatumEqual::value>::type> { - using ScalarType = typename TypeTraits::ScalarType; - static void EnsureEqual(const Datum& lhs, const Datum& rhs) { - ASSERT_EQ(lhs.kind(), rhs.kind()); - if (lhs.kind() == Datum::SCALAR) { - auto left = internal::checked_cast(lhs.scalar().get()); - auto right = internal::checked_cast(rhs.scalar().get()); - ASSERT_EQ(left->is_valid, right->is_valid); - ASSERT_EQ(left->type->id(), right->type->id()); - ASSERT_EQ(left->value, right->value); - } - } -}; - -} // namespace compute -} // namespace arrow - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/arrow/compute/type_fwd.h b/cpp/thirdparty/knowhere_build/include/arrow/compute/type_fwd.h deleted file mode 100644 index 48d45ecd11..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/compute/type_fwd.h +++ /dev/null @@ -1,38 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include - -#include "arrow/type_fwd.h" - -namespace arrow { -namespace compute { - -class Expr; -class LogicalType; -class Operation; - -using ArrowTypePtr = std::shared_ptr<::arrow::DataType>; -using ExprPtr = std::shared_ptr; -using ConstOpPtr = std::shared_ptr; -using OpPtr = std::shared_ptr; -using LogicalTypePtr = std::shared_ptr; - -} // namespace compute -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/csv/api.h b/cpp/thirdparty/knowhere_build/include/arrow/csv/api.h deleted file mode 100644 index 8e311844c5..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/csv/api.h +++ /dev/null @@ -1,24 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_CSV_API_H -#define ARROW_CSV_API_H - -#include "arrow/csv/options.h" -#include "arrow/csv/reader.h" - -#endif // ARROW_CSV_API_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/csv/chunker.h b/cpp/thirdparty/knowhere_build/include/arrow/csv/chunker.h deleted file mode 100644 index 6c61632614..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/csv/chunker.h +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_CSV_CHUNKER_H -#define ARROW_CSV_CHUNKER_H - -#include - -#include "arrow/csv/options.h" -#include "arrow/status.h" -#include "arrow/util/macros.h" -#include "arrow/util/visibility.h" - -namespace arrow { -namespace csv { - -/// \class Chunker -/// \brief A reusable block-based chunker for CSV data -/// -/// The chunker takes a block of CSV data and finds a suitable place -/// to cut it up without splitting a row. -/// If the block is truncated (i.e. not all data can be chunked), it is up -/// to the caller to arrange the next block to start with the trailing data. -/// -/// Note: if the previous block ends with CR (0x0d) and a new block starts -/// with LF (0x0a), the chunker will consider the leading newline as an empty line. -class ARROW_EXPORT Chunker { - public: - explicit Chunker(ParseOptions options); - - /// \brief Carve up a chunk in a block of data - /// - /// Process a block of CSV data, reading up to size bytes. - /// The number of bytes in the chunk is returned in out_size. - Status Process(const char* data, uint32_t size, uint32_t* out_size); - - protected: - ARROW_DISALLOW_COPY_AND_ASSIGN(Chunker); - - // Like Process(), but specialized for some parsing options - template - Status ProcessSpecialized(const char* data, uint32_t size, uint32_t* out_size); - - // Detect a single line from the data pointer. Return the line end, - // or nullptr if the remaining line is truncated. - template - inline const char* ReadLine(const char* data, const char* data_end); - - ParseOptions options_; -}; - -} // namespace csv -} // namespace arrow - -#endif // ARROW_CSV_CHUNKER_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/csv/column-builder.h b/cpp/thirdparty/knowhere_build/include/arrow/csv/column-builder.h deleted file mode 100644 index 054a642295..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/csv/column-builder.h +++ /dev/null @@ -1,87 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_CSV_COLUMN_BUILDER_H -#define ARROW_CSV_COLUMN_BUILDER_H - -#include -#include - -#include "arrow/array.h" -#include "arrow/status.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class ChunkedArray; -class DataType; - -namespace internal { - -class TaskGroup; - -} // namespace internal - -namespace csv { - -class BlockParser; -struct ConvertOptions; - -class ARROW_EXPORT ColumnBuilder { - public: - virtual ~ColumnBuilder() = default; - - /// Spawn a task that will try to convert and append the given CSV block. - /// All calls to Append() should happen on the same thread, otherwise - /// call Insert() instead. - virtual void Append(const std::shared_ptr& parser); - - /// Spawn a task that will try to convert and insert the given CSV block - virtual void Insert(int64_t block_index, - const std::shared_ptr& parser) = 0; - - /// Return the final chunked array. The TaskGroup _must_ have finished! - virtual Status Finish(std::shared_ptr* out) = 0; - - /// Change the task group. The previous TaskGroup _must_ have finished! - void SetTaskGroup(const std::shared_ptr& task_group); - - std::shared_ptr task_group() { return task_group_; } - - /// Construct a strictly-typed ColumnBuilder. - static Status Make(const std::shared_ptr& type, int32_t col_index, - const ConvertOptions& options, - const std::shared_ptr& task_group, - std::shared_ptr* out); - - /// Construct a type-inferring ColumnBuilder. - static Status Make(int32_t col_index, const ConvertOptions& options, - const std::shared_ptr& task_group, - std::shared_ptr* out); - - protected: - explicit ColumnBuilder(const std::shared_ptr& task_group) - : task_group_(task_group) {} - - std::shared_ptr task_group_; - ArrayVector chunks_; -}; - -} // namespace csv -} // namespace arrow - -#endif // ARROW_CSV_COLUMN_BUILDER_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/csv/converter.h b/cpp/thirdparty/knowhere_build/include/arrow/csv/converter.h deleted file mode 100644 index d64fe695d0..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/csv/converter.h +++ /dev/null @@ -1,68 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_CSV_CONVERTER_H -#define ARROW_CSV_CONVERTER_H - -#include -#include - -#include "arrow/csv/options.h" -#include "arrow/util/macros.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Array; -class DataType; -class MemoryPool; -class Status; - -namespace csv { - -class BlockParser; - -class ARROW_EXPORT Converter { - public: - Converter(const std::shared_ptr& type, const ConvertOptions& options, - MemoryPool* pool); - virtual ~Converter() = default; - - virtual Status Convert(const BlockParser& parser, int32_t col_index, - std::shared_ptr* out) = 0; - - std::shared_ptr type() const { return type_; } - - static Status Make(const std::shared_ptr& type, const ConvertOptions& options, - std::shared_ptr* out); - static Status Make(const std::shared_ptr& type, const ConvertOptions& options, - MemoryPool* pool, std::shared_ptr* out); - - protected: - ARROW_DISALLOW_COPY_AND_ASSIGN(Converter); - - virtual Status Initialize() = 0; - - const ConvertOptions options_; - MemoryPool* pool_; - std::shared_ptr type_; -}; - -} // namespace csv -} // namespace arrow - -#endif // ARROW_CSV_CONVERTER_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/csv/options.h b/cpp/thirdparty/knowhere_build/include/arrow/csv/options.h deleted file mode 100644 index 9cd312ac07..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/csv/options.h +++ /dev/null @@ -1,98 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_CSV_OPTIONS_H -#define ARROW_CSV_OPTIONS_H - -#include -#include -#include -#include -#include - -#include "arrow/util/visibility.h" - -namespace arrow { - -class DataType; - -namespace csv { - -struct ARROW_EXPORT ParseOptions { - // Parsing options - - // Field delimiter - char delimiter = ','; - // Whether quoting is used - bool quoting = true; - // Quoting character (if `quoting` is true) - char quote_char = '"'; - // Whether a quote inside a value is double-quoted - bool double_quote = true; - // Whether escaping is used - bool escaping = false; - // Escaping character (if `escaping` is true) - char escape_char = '\\'; - // Whether values are allowed to contain CR (0x0d) and LF (0x0a) characters - bool newlines_in_values = false; - // Whether empty lines are ignored. If false, an empty line represents - // a single empty value (assuming a one-column CSV file). - bool ignore_empty_lines = true; - - // XXX Should this be in ReadOptions? - // Number of header rows to skip (including the first row containing column names) - int32_t header_rows = 1; - - static ParseOptions Defaults(); -}; - -struct ARROW_EXPORT ConvertOptions { - // Conversion options - - // Whether to check UTF8 validity of string columns - bool check_utf8 = true; - // Optional per-column types (disabling type inference on those columns) - std::unordered_map> column_types; - // Recognized spellings for null values - std::vector null_values; - // Recognized spellings for boolean values - std::vector true_values; - std::vector false_values; - // Whether string / binary columns can have null values. - // If true, then strings in "null_values" are considered null for string columns. - // If false, then all strings are valid string values. - bool strings_can_be_null = false; - - static ConvertOptions Defaults(); -}; - -struct ARROW_EXPORT ReadOptions { - // Reader options - - // Whether to use the global CPU thread pool - bool use_threads = true; - // Block size we request from the IO layer; also determines the size of - // chunks when use_threads is true - int32_t block_size = 1 << 20; // 1 MB - - static ReadOptions Defaults(); -}; - -} // namespace csv -} // namespace arrow - -#endif // ARROW_CSV_OPTIONS_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/csv/parser.h b/cpp/thirdparty/knowhere_build/include/arrow/csv/parser.h deleted file mode 100644 index fdddc37a2c..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/csv/parser.h +++ /dev/null @@ -1,149 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_CSV_PARSER_H -#define ARROW_CSV_PARSER_H - -#include -#include -#include -#include - -#include "arrow/buffer.h" -#include "arrow/csv/options.h" -#include "arrow/status.h" -#include "arrow/util/macros.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class MemoryPool; - -namespace csv { - -constexpr int32_t kMaxParserNumRows = 100000; - -/// \class BlockParser -/// \brief A reusable block-based parser for CSV data -/// -/// The parser takes a block of CSV data and delimits rows and fields, -/// unquoting and unescaping them on the fly. Parsed data is own by the -/// parser, so the original buffer can be discarded after Parse() returns. -/// -/// If the block is truncated (i.e. not all data can be parsed), it is up -/// to the caller to arrange the next block to start with the trailing data. -/// Also, if the previous block ends with CR (0x0d) and a new block starts -/// with LF (0x0a), the parser will consider the leading newline as an empty -/// line; the caller should therefore strip it. -class ARROW_EXPORT BlockParser { - public: - explicit BlockParser(ParseOptions options, int32_t num_cols = -1, - int32_t max_num_rows = kMaxParserNumRows); - explicit BlockParser(MemoryPool* pool, ParseOptions options, int32_t num_cols = -1, - int32_t max_num_rows = kMaxParserNumRows); - - /// \brief Parse a block of data - /// - /// Parse a block of CSV data, ingesting up to max_num_rows rows. - /// The number of bytes actually parsed is returned in out_size. - Status Parse(const char* data, uint32_t size, uint32_t* out_size); - - /// \brief Parse the final block of data - /// - /// Like Parse(), but called with the final block in a file. - /// The last row may lack a trailing line separator. - Status ParseFinal(const char* data, uint32_t size, uint32_t* out_size); - - /// \brief Return the number of parsed rows - int32_t num_rows() const { return num_rows_; } - /// \brief Return the number of parsed columns - int32_t num_cols() const { return num_cols_; } - /// \brief Return the total size in bytes of parsed data - uint32_t num_bytes() const { return parsed_size_; } - - /// \brief Visit parsed values in a column - /// - /// The signature of the visitor is - /// Status(const uint8_t* data, uint32_t size, bool quoted) - template - Status VisitColumn(int32_t col_index, Visitor&& visit) const { - for (size_t buf_index = 0; buf_index < values_buffers_.size(); ++buf_index) { - const auto& values_buffer = values_buffers_[buf_index]; - const auto values = reinterpret_cast(values_buffer->data()); - const auto max_pos = - static_cast(values_buffer->size() / sizeof(ValueDesc)) - 1; - for (int32_t pos = col_index; pos < max_pos; pos += num_cols_) { - auto start = values[pos].offset; - auto stop = values[pos + 1].offset; - auto quoted = values[pos + 1].quoted; - ARROW_RETURN_NOT_OK(visit(parsed_ + start, stop - start, quoted)); - } - } - return Status::OK(); - } - - protected: - ARROW_DISALLOW_COPY_AND_ASSIGN(BlockParser); - - Status DoParse(const char* data, uint32_t size, bool is_final, uint32_t* out_size); - template - Status DoParseSpecialized(const char* data, uint32_t size, bool is_final, - uint32_t* out_size); - - template - Status ParseChunk(ValuesWriter* values_writer, ParsedWriter* parsed_writer, - const char* data, const char* data_end, bool is_final, - int32_t rows_in_chunk, const char** out_data, bool* finished_parsing); - - // Parse a single line from the data pointer - template - Status ParseLine(ValuesWriter* values_writer, ParsedWriter* parsed_writer, - const char* data, const char* data_end, bool is_final, - const char** out_data); - - MemoryPool* pool_; - const ParseOptions options_; - // The number of rows parsed from the block - int32_t num_rows_; - // The number of columns (can be -1 at start) - int32_t num_cols_; - // The maximum number of rows to parse from this block - int32_t max_num_rows_; - - // Linear scratchpad for parsed values - struct ValueDesc { - uint32_t offset : 31; - bool quoted : 1; - }; - - // XXX should we ensure the parsed buffer is padded with 8 or 16 excess zero bytes? - // It may help with null parsing... - std::vector> values_buffers_; - std::shared_ptr parsed_buffer_; - const uint8_t* parsed_; - int32_t values_size_; - int32_t parsed_size_; - - class ResizableValuesWriter; - class PresizedValuesWriter; - class PresizedParsedWriter; -}; - -} // namespace csv -} // namespace arrow - -#endif // ARROW_CSV_PARSER_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/csv/reader.h b/cpp/thirdparty/knowhere_build/include/arrow/csv/reader.h deleted file mode 100644 index edf6f11098..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/csv/reader.h +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_CSV_READER_H -#define ARROW_CSV_READER_H - -#include - -#include "arrow/csv/options.h" // IWYU pragma: keep -#include "arrow/status.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class MemoryPool; -class Table; - -namespace io { -class InputStream; -} // namespace io - -namespace csv { - -class ARROW_EXPORT TableReader { - public: - virtual ~TableReader() = default; - - virtual Status Read(std::shared_ptr
* out) = 0; - - // XXX pass optional schema? - static Status Make(MemoryPool* pool, std::shared_ptr input, - const ReadOptions&, const ParseOptions&, const ConvertOptions&, - std::shared_ptr* out); -}; - -} // namespace csv -} // namespace arrow - -#endif // ARROW_CSV_READER_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/csv/test-common.h b/cpp/thirdparty/knowhere_build/include/arrow/csv/test-common.h deleted file mode 100644 index 624023f603..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/csv/test-common.h +++ /dev/null @@ -1,71 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_CSV_TEST_COMMON_H -#define ARROW_CSV_TEST_COMMON_H - -#include -#include -#include - -#include "arrow/csv/parser.h" -#include "arrow/testing/gtest_util.h" - -namespace arrow { -namespace csv { - -std::string MakeCSVData(std::vector lines) { - std::string s; - for (const auto& line : lines) { - s += line; - } - return s; -} - -// Make a BlockParser from a vector of lines representing a CSV file -void MakeCSVParser(std::vector lines, ParseOptions options, - std::shared_ptr* out) { - auto csv = MakeCSVData(lines); - auto parser = std::make_shared(options); - uint32_t out_size; - ASSERT_OK(parser->Parse(csv.data(), static_cast(csv.size()), &out_size)); - ASSERT_EQ(out_size, csv.size()) << "trailing CSV data not parsed"; - *out = parser; -} - -void MakeCSVParser(std::vector lines, std::shared_ptr* out) { - MakeCSVParser(lines, ParseOptions::Defaults(), out); -} - -// Make a BlockParser from a vector of strings representing a single CSV column -void MakeColumnParser(std::vector items, std::shared_ptr* out) { - auto options = ParseOptions::Defaults(); - // Need this to test for null (empty) values - options.ignore_empty_lines = false; - std::vector lines; - for (const auto& item : items) { - lines.push_back(item + '\n'); - } - MakeCSVParser(lines, options, out); - ASSERT_EQ((*out)->num_cols(), 1) << "Should have seen only 1 CSV column"; - ASSERT_EQ((*out)->num_rows(), items.size()); -} - -} // namespace csv -} // namespace arrow - -#endif // ARROW_CSV_TEST_COMMON_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/dataset/api.h b/cpp/thirdparty/knowhere_build/include/arrow/dataset/api.h deleted file mode 100644 index 9ded93a7fd..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/dataset/api.h +++ /dev/null @@ -1,26 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include "arrow/dataset/dataset.h" -#include "arrow/dataset/discovery.h" -#include "arrow/dataset/file_base.h" -#include "arrow/dataset/file_csv.h" -#include "arrow/dataset/file_feather.h" -#include "arrow/dataset/file_parquet.h" -#include "arrow/dataset/scanner.h" diff --git a/cpp/thirdparty/knowhere_build/include/arrow/dataset/dataset.h b/cpp/thirdparty/knowhere_build/include/arrow/dataset/dataset.h deleted file mode 100644 index 4aba8945b2..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/dataset/dataset.h +++ /dev/null @@ -1,114 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include -#include - -#include "arrow/dataset/type_fwd.h" -#include "arrow/dataset/visibility.h" - -namespace arrow { -namespace dataset { - -/// \brief A granular piece of a Dataset, such as an individual file, -/// which can be read/scanned separately from other fragments -class ARROW_DS_EXPORT DataFragment { - public: - virtual ~DataFragment() = default; - - /// \brief Return true if the fragment can benefit from parallel - /// scanning - virtual bool splittable() const = 0; - - /// \brief Partition options to use when scanning this fragment. May be - /// nullptr - virtual std::shared_ptr scan_options() const = 0; -}; - -/// \brief Conditions to apply to a dataset when reading to include or -/// exclude fragments, filter out rows, etc. -struct DataSelector { - std::vector> filters; - - // TODO(wesm): Select specific partition keys, file path globs, or - // other common desirable selections -}; - -/// \brief A basic component of a Dataset which yields zero or more -/// DataFragments -class ARROW_DS_EXPORT DataSource { - public: - virtual ~DataSource() = default; - - virtual std::string type() const = 0; - - virtual std::unique_ptr GetFragments( - const DataSelector& selector) = 0; -}; - -/// \brief A DataSource consisting of a flat sequence of DataFragments -class ARROW_DS_EXPORT SimpleDataSource : public DataSource { - public: - std::unique_ptr GetFragments( - const DataSelector& selector) override; - - private: - DataFragmentVector fragments_; -}; - -/// \brief Top-level interface for a Dataset with fragments coming -/// from possibly multiple sources -class ARROW_DS_EXPORT Dataset : public std::enable_shared_from_this { - public: - /// \param[in] source a single input data source - /// \param[in] schema a known schema to conform to, may be nullptr - explicit Dataset(std::shared_ptr source, - std::shared_ptr schema = NULLPTR); - - /// \param[in] sources one or more input data sources - /// \param[in] schema a known schema to conform to, may be nullptr - explicit Dataset(const std::vector>& sources, - std::shared_ptr schema = NULLPTR); - - virtual ~Dataset() = default; - - /// \brief Begin to build a new Scan operation against this Dataset - ScannerBuilder NewScan() const; - - const std::vector>& sources() const { return sources_; } - - std::shared_ptr schema() const { return schema_; } - - /// \brief Compute consensus schema from input data sources - Status InferSchema(std::shared_ptr* out); - - /// \brief Return a copy of Dataset with a new target schema - Status ReplaceSchema(std::shared_ptr schema, std::unique_ptr* out); - - protected: - // The data sources must conform their output to this schema (with - // projections and filters taken into account) - std::shared_ptr schema_; - - std::vector> sources_; -}; - -} // namespace dataset -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/dataset/discovery.h b/cpp/thirdparty/knowhere_build/include/arrow/dataset/discovery.h deleted file mode 100644 index 18242250f3..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/dataset/discovery.h +++ /dev/null @@ -1,45 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -/// Logic for automatically determining the structure of multi-file -/// dataset with possible partitioning according to available -/// partition schemes - -#pragma once - -#include -#include - -#include "arrow/dataset/type_fwd.h" -#include "arrow/dataset/visibility.h" -#include "arrow/util/macros.h" - -namespace arrow { -namespace dataset { - -struct ARROW_DS_EXPORT DiscoveryOptions { - std::shared_ptr format = NULLPTR; - std::shared_ptr partition_scheme = NULLPTR; -}; - -/// \brief Using a root directory -ARROW_DS_EXPORT -Status DiscoverSource(const std::string& path, fs::FileSystem* filesystem, - const DiscoveryOptions& options, std::shared_ptr* out); - -} // namespace dataset -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/dataset/disk_store.h b/cpp/thirdparty/knowhere_build/include/arrow/dataset/disk_store.h deleted file mode 100644 index a405aa2b41..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/dataset/disk_store.h +++ /dev/null @@ -1,56 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include - -#include "arrow/dataset/type_fwd.h" -#include "arrow/type_fwd.h" - -namespace arrow { -namespace dataset { - -/// \brief Loads a previously-written collection of Arrow protocol -/// files and exposes them in a way that can be consumed as a Dataset -/// source -class ARROW_DS_EXPORT DiskStoreReader : public DatasetSource { - public: - DiskStoreReader(const std::string& path, fs::FileSystem* filesystem); - - private: - class DiskStoreReaderImpl; - std::unique_ptr impl_; - - std::string path_; - fs::FileSystem* filesystem_; - - DiskStoreReader() {} -}; - -/// \brief -class ARROW_DS_EXPORT DiskStoreWriter { - public: - Status Write(const RecordBatch& batch); - - private: - DiskStoreWriter() {} -}; - -} // namespace dataset -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/dataset/file_base.h b/cpp/thirdparty/knowhere_build/include/arrow/dataset/file_base.h deleted file mode 100644 index 295a918103..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/dataset/file_base.h +++ /dev/null @@ -1,144 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include -#include - -#include "arrow/dataset/scanner.h" -#include "arrow/dataset/type_fwd.h" -#include "arrow/dataset/visibility.h" -#include "arrow/dataset/writer.h" -#include "arrow/util/compression.h" - -namespace arrow { -namespace dataset { - -/// \brief Contains the location of a file to be read -class ARROW_DS_EXPORT FileSource { - public: - enum SourceType { PATH, BUFFER }; - - FileSource(std::string path, fs::FileSystem* filesystem, - Compression::type compression = Compression::UNCOMPRESSED) - : FileSource(FileSource::PATH, compression) { - path_ = std::move(path); - filesystem_ = filesystem; - } - - FileSource(std::shared_ptr buffer, - Compression::type compression = Compression::UNCOMPRESSED) - : FileSource(FileSource::BUFFER, compression) { - buffer_ = std::move(buffer); - } - - bool operator==(const FileSource& other) const { - if (type_ != other.type_) { - return false; - } else if (type_ == FileSource::PATH) { - return path_ == other.path_ && filesystem_ == other.filesystem_; - } else { - return buffer_->Equals(*other.buffer_); - } - } - - /// \brief The kind of file, whether stored in a filesystem, memory - /// resident, or other - SourceType type() const { return type_; } - - /// \brief Return the type of raw compression on the file, if any - Compression::type compression() const { return compression_; } - - /// \brief Return the file path, if any. Only valid when file source - /// type is PATH - std::string path() const { return path_; } - - /// \brief Return the filesystem, if any. Only valid when file - /// source type is PATH - fs::FileSystem* filesystem() const { return filesystem_; } - - /// \brief Return the buffer containing the file, if any. Only value - /// when file source type is BUFFER - std::shared_ptr buffer() const { return buffer_; } - - private: - explicit FileSource(SourceType type, - Compression::type compression = Compression::UNCOMPRESSED) - : type_(type), compression_(compression) {} - SourceType type_; - Compression::type compression_; - - // PATH-based source - std::string path_; - fs::FileSystem* filesystem_; - - // BUFFER-based source - std::shared_ptr buffer_; -}; - -/// \brief Base class for file scanning options -class ARROW_DS_EXPORT FileScanOptions : public ScanOptions { - public: - /// \brief The name of the file format this options corresponds to - virtual std::string file_type() const = 0; -}; - -/// \brief Base class for file writing options -class ARROW_DS_EXPORT FileWriteOptions : public WriteOptions { - public: - virtual ~FileWriteOptions() = default; - - /// \brief The name of the file format this options corresponds to - virtual std::string file_type() const = 0; -}; - -/// \brief Base class for file format implementation -class ARROW_DS_EXPORT FileFormat { - public: - virtual ~FileFormat() = default; - - virtual std::string name() const = 0; - - /// \brief Return true if the given file extension - virtual bool IsKnownExtension(const std::string& ext) const = 0; - - /// \brief Open a file for scanning - virtual Status ScanFile(const FileSource& location, - std::shared_ptr scan_options, - std::shared_ptr scan_context, - std::unique_ptr* out) const = 0; -}; - -/// \brief A DataFragment that is stored in a file with a known format -class ARROW_DS_EXPORT FileBasedDataFragment : public DataFragment { - public: - FileBasedDataFragment(const FileSource& location, std::shared_ptr format, - std::shared_ptr); - - const FileSource& location() const { return location_; } - std::shared_ptr format() const { return format_; } - - protected: - FileSource location_; - std::shared_ptr format_; - std::shared_ptr scan_options_; -}; - -} // namespace dataset -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/dataset/file_csv.h b/cpp/thirdparty/knowhere_build/include/arrow/dataset/file_csv.h deleted file mode 100644 index 1b46145575..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/dataset/file_csv.h +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include - -#include "arrow/csv/options.h" -#include "arrow/dataset/file_base.h" -#include "arrow/dataset/type_fwd.h" -#include "arrow/dataset/visibility.h" -#include "arrow/util/iterator.h" - -namespace arrow { - -namespace fs { - -class FileSystem; - -} // namespace fs - -namespace dataset { - -class ARROW_DS_EXPORT CsvScanOptions : public FileScanOptions { - public: - std::string file_type() const override; - - private: - csv::ParseOptions parse_options_; - csv::ConvertOptions convert_options_; - csv::ReadOptions read_options_; -}; - -class ARROW_DS_EXPORT CsvWriteOptions : public FileWriteOptions { - public: - std::string file_type() const override; -}; - -/// \brief A FileFormat implementation that reads from CSV files -class ARROW_DS_EXPORT CsvFileFormat : public FileFormat { - public: - std::string name() const override; - - /// \brief Return true if the given file extension - bool IsKnownExtension(const std::string& ext) const override; - - /// \brief Open a file for scanning - Status ScanFile(const FileSource& location, std::shared_ptr scan_options, - std::shared_ptr scan_context, - std::unique_ptr* out) const override; -}; - -} // namespace dataset -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/dataset/file_feather.h b/cpp/thirdparty/knowhere_build/include/arrow/dataset/file_feather.h deleted file mode 100644 index d92cf82b9f..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/dataset/file_feather.h +++ /dev/null @@ -1,56 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include - -#include "arrow/dataset/file_base.h" -#include "arrow/dataset/type_fwd.h" -#include "arrow/dataset/visibility.h" - -namespace arrow { -namespace dataset { - -class ARROW_DS_EXPORT FeatherScanOptions : public FileScanOptions { - public: - std::string file_type() const override; -}; - -class ARROW_DS_EXPORT FeatherWriterOptions : public FileWriteOptions { - public: - std::string file_type() const override; -}; - -/// \brief A FileFormat implementation that reads from Feather (Arrow -/// IPC protocol) files -class ARROW_DS_EXPORT FeatherFileFormat : public FileFormat { - public: - std::string name() const override; - - /// \brief Return true if the given file extension - bool IsKnownExtension(const std::string& ext) const override; - - /// \brief Open a file for scanning - Status ScanFile(const FileSource& location, std::shared_ptr scan_options, - std::shared_ptr scan_context, - std::unique_ptr* out) const override; -}; - -} // namespace dataset -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/dataset/file_json.h b/cpp/thirdparty/knowhere_build/include/arrow/dataset/file_json.h deleted file mode 100644 index 11e6bbe6ad..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/dataset/file_json.h +++ /dev/null @@ -1,61 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include - -#include "arrow/dataset/file_base.h" -#include "arrow/dataset/type_fwd.h" -#include "arrow/dataset/visibility.h" -#include "arrow/json/options.h" - -namespace arrow { -namespace dataset { - -class ARROW_DS_EXPORT JsonScanOptions : public FileScanOptions { - public: - /// - std::string file_type() const override; - - private: - json::ParseOptions parse_options_; - json::ReadOptions read_options_; -}; - -class ARROW_DS_EXPORT JsonWriteOptions : public FileWriteOptions { - public: - std::string file_type() const override; -}; - -/// \brief A FileFormat implementation that reads from JSON files -class ARROW_DS_EXPORT JsonFileFormat : public FileFormat { - public: - std::string name() const override; - - /// \brief Return true if the given file extension - bool IsKnownExtension(const std::string& ext) const override; - - /// \brief Open a file for scanning - Status ScanFile(const FileSource& location, std::shared_ptr scan_options, - std::shared_ptr scan_context, - std::unique_ptr* out) const override; -}; - -} // namespace dataset -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/dataset/file_parquet.h b/cpp/thirdparty/knowhere_build/include/arrow/dataset/file_parquet.h deleted file mode 100644 index d88c6f889b..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/dataset/file_parquet.h +++ /dev/null @@ -1,60 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include - -#include "arrow/dataset/file_base.h" -#include "arrow/dataset/type_fwd.h" -#include "arrow/dataset/visibility.h" - -namespace arrow { -namespace dataset { - -class ARROW_DS_EXPORT ParquetScanOptions : public FileScanOptions { - public: - std::string file_type() const override; -}; - -class ARROW_DS_EXPORT ParquetWriteOptions : public FileWriteOptions { - public: - std::string file_type() const override; -}; - -class ARROW_DS_EXPORT ParquetFragment : public FileBasedDataFragment { - public: - bool splittable() const override { return true; } -}; - -/// \brief A FileFormat implementation that reads from Parquet files -class ARROW_DS_EXPORT ParquetFileFormat : public FileFormat { - public: - std::string name() const override; - - /// \brief Return true if the given file extension - bool IsKnownExtension(const std::string& ext) const override; - - /// \brief Open a file for scanning - Status ScanFile(const FileSource& location, std::shared_ptr scan_options, - std::shared_ptr scan_context, - std::unique_ptr* out) const override; -}; - -} // namespace dataset -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/dataset/filter.h b/cpp/thirdparty/knowhere_build/include/arrow/dataset/filter.h deleted file mode 100644 index a727b1ce4b..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/dataset/filter.h +++ /dev/null @@ -1,40 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include - -#include "arrow/dataset/visibility.h" - -namespace arrow { -namespace dataset { - -class ARROW_DS_EXPORT Filter { - public: - enum type { - /// Simple boolean predicate consisting of comparisons and boolean - /// logic (AND, OR, NOT) involving Schema fields - EXPRESSION, - - /// - GENERIC - }; -}; - -} // namespace dataset -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/dataset/partition.h b/cpp/thirdparty/knowhere_build/include/arrow/dataset/partition.h deleted file mode 100644 index 28c55adcc1..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/dataset/partition.h +++ /dev/null @@ -1,217 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include -#include -#include - -#include "arrow/dataset/dataset.h" -#include "arrow/dataset/type_fwd.h" -#include "arrow/dataset/visibility.h" - -namespace arrow { -namespace dataset { - -// ---------------------------------------------------------------------- -// Computing partition values - -// TODO(wesm): API for computing partition keys derived from raw -// values. For example, year(value) or hash_function(value) instead of -// simply value, so a dataset with a timestamp column might group all -// data with year 2009 in the same partition - -// /// \brief -// class ScalarTransform { -// public: -// virtual Status Transform(const std::shared_ptr& input, -// std::shared_ptr* output) const = 0; -// }; - -// class PartitionField { -// public: - -// private: -// std::string field_name_; -// }; - -// ---------------------------------------------------------------------- -// Partition identifiers - -/// \brief A partition level identifier which can be used -/// -/// TODO(wesm): Is this general enough? What other kinds of partition -/// keys exist and do we need to support them? -class PartitionKey { - public: - const std::vector& fields() const { return fields_; } - const std::vector>& values() const { return values_; } - - private: - std::vector fields_; - std::vector> values_; -}; - -/// \brief Intermediate data structure for data parsed from a string -/// partition identifier. -/// -/// For example, the identifier "foo=5" might be parsed with a single -/// "foo" field and the value 5. A more complex identifier might be -/// written as "foo=5,bar=2", which would yield two fields and two -/// values. -/// -/// Some partition schemes may store the field names in a metadata -/// store instead of in file paths, for example -/// dataset_root/2009/11/... could be used when the partition fields -/// are "year" and "month" -struct PartitionKeyData { - std::vector fields; - std::vector> values; -}; - -// ---------------------------------------------------------------------- -// Partition schemes - -/// \brief -class ARROW_DS_EXPORT PartitionScheme { - public: - virtual ~PartitionScheme() = default; - - /// \brief The name identifying the kind of partition scheme - virtual std::string name() const = 0; - - virtual bool PathMatchesScheme(const std::string& path) const = 0; - - virtual Status ParseKey(const std::string& path, PartitionKeyData* out) const = 0; -}; - -/// \brief Multi-level, directory based partitioning scheme -/// originating from Apache Hive with all data files stored in the -/// leaf directories. Data is partitioned by static values of a -/// particular column in the schema. Partition keys are represented in -/// the form $key=$value in directory names -class ARROW_DS_EXPORT HivePartitionScheme : public PartitionScheme { - public: - /// \brief Return true if path - bool PathMatchesScheme(const std::string& path) const override; - - virtual Status ParseKey(const std::string& path, PartitionKeyData* out) const = 0; -}; - -// ---------------------------------------------------------------------- -// - -// Partitioned datasets come in different forms. Here is an example of -// a Hive-style partitioned dataset: -// -// dataset_root/ -// key1=$k1_v1/ -// key2=$k2_v1/ -// 0.parquet -// 1.parquet -// 2.parquet -// 3.parquet -// key2=$k2_v2/ -// 0.parquet -// 1.parquet -// key1=$k1_v2/ -// key2=$k2_v1/ -// 0.parquet -// 1.parquet -// key2=$k2_v2/ -// 0.parquet -// 1.parquet -// 2.parquet -// -// In this case, the dataset has 11 fragments (11 files) to be -// scanned, or potentially more if it is configured to split Parquet -// files at the row group level - -class ARROW_DS_EXPORT Partition : public DataSource { - public: - std::string type() const override; - - /// \brief The key for this partition source, may be nullptr, - /// e.g. for the top-level partitioned source container - virtual const PartitionKey* key() const = 0; - - virtual std::unique_ptr GetFragments( - const Selector& selector) = 0; -}; - -/// \brief Simple implementation of Partition, which consists of a -/// partition identifier, subpartitions, and some data fragments -class ARROW_DS_EXPORT SimplePartition : public Partition { - public: - SimplePartition(std::unique_ptr partition_key, - DataFragmentVector&& data_fragments, PartitionVector&& subpartitions, - std::shared_ptr scan_options = NULLPTR) - : key_(std::move(partition_key)), - data_fragments_(std::move(data_fragments)), - subpartitions_(std::move(subpartitions)), - scan_options_(scan_options) {} - - const PartitionKey* key() const override { return key_.get(); } - - int num_subpartitions() const { return static_cast(subpartitions_.size()); } - - int num_data_fragments() const { return static_cast(data_fragments__.size()); } - - const PartitionVector& subpartitions() const { return subpartitions_; } - const DataFragmentVector& data_fragments() const { return data_fragments_; } - - std::unique_ptr GetFragments( - const FilterVector& filters) override; - - private: - std::unique_ptr key_; - - /// \brief Data fragments belonging to this partition level. In some - /// partition schemes such as Hive-style, this member is - /// mutually-exclusive with subpartitions, where data fragments - /// occur only in the partition leaves - std::vector> data_fragments_; - - /// \brief Child partitions of this partition - std::vector> subpartitions_; - - /// \brief Default scan options to use for data fragments - std::shared_ptr scan_options_; -}; - -/// \brief A PartitionSource that returns fragments as the result of input iterators -class ARROW_DS_EXPORT LazyPartition : public Partition { - public: - const PartitionKey* key() const override; - - std::unique_ptr GetFragments( - const& DataSelector selector) override; - - // TODO(wesm): Iterate over subpartitions - - protected: - std::unique_ptr partition_iter_; - - // By default, once this source is consumed using GetFragments, it - // cannot be consumed again. By setting this to true, we cache - bool cache_manifest_ = false; -}; - -} // namespace dataset -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/dataset/scanner.h b/cpp/thirdparty/knowhere_build/include/arrow/dataset/scanner.h deleted file mode 100644 index 36d3b84cf8..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/dataset/scanner.h +++ /dev/null @@ -1,94 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include -#include - -#include "arrow/dataset/type_fwd.h" -#include "arrow/dataset/visibility.h" - -namespace arrow { -namespace dataset { - -/// \brief Shared state for a Scan operation -struct ARROW_DS_EXPORT ScanContext {}; - -// TODO(wesm): API for handling of post-materialization filters. For -// example, if the user requests [$col1 > 0, $col2 > 0] and $col1 is a -// partition key, but $col2 is not, then the filter "$col2 > 0" must -// be evaluated in-memory against the RecordBatch objects resulting -// from the Scan - -class ARROW_DS_EXPORT ScanOptions { - public: - virtual ~ScanOptions() = default; -}; - -/// \brief Read record batches from a range of a single data fragment -class ARROW_DS_EXPORT ScanTask { - public: - virtual ~ScanTask() = default; - - /// \brief Iterate through sequence of materialized record batches - /// resulting from the Scan. Execution semantics encapsulated in the - /// particular ScanTask implementation - virtual std::unique_ptr Scan() = 0; -}; - -/// \brief Main interface for -class ARROW_DS_EXPORT Scanner { - public: - virtual ~Scanner() = default; - - /// \brief Return iterator yielding ScanTask instances to enable - /// serial or parallel execution of units of scanning work - virtual std::unique_ptr GetTasks() = 0; -}; - -class ARROW_DS_EXPORT ScannerBuilder { - public: - ScannerBuilder(std::shared_ptr dataset, - std::shared_ptr scan_context); - - /// \brief Set - ScannerBuilder* Project(const std::vector& columns); - - ScannerBuilder* AddFilter(const std::shared_ptr& filter); - - ScannerBuilder* SetGlobalFileOptions(std::shared_ptr options); - - /// \brief If true (default), add partition keys to the - /// RecordBatches that the scan produces if they are not in the data - /// otherwise - ScannerBuilder* IncludePartitionKeys(bool include = true); - - /// \brief Return the constructed now-immutable Scanner object - std::unique_ptr Finish() const; - - private: - std::shared_ptr dataset_; - std::shared_ptr scan_context_; - std::vector project_columns_; - FilterVector filters_; - bool include_partition_keys_; -}; - -} // namespace dataset -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/dataset/transaction.h b/cpp/thirdparty/knowhere_build/include/arrow/dataset/transaction.h deleted file mode 100644 index d5c94b27cf..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/dataset/transaction.h +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include "arrow/dataset/type_fwd.h" -#include "arrow/dataset/visibility.h" - -namespace arrow { -namespace dataset {} // namespace dataset -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/dataset/type_fwd.h b/cpp/thirdparty/knowhere_build/include/arrow/dataset/type_fwd.h deleted file mode 100644 index 8e3824625e..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/dataset/type_fwd.h +++ /dev/null @@ -1,71 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include - -#include "arrow/dataset/visibility.h" -#include "arrow/type_fwd.h" // IWYU pragma: export - -namespace arrow { - -namespace fs { - -class FileSystem; - -} // namespace fs - -namespace dataset { - -class Dataset; -class DataFragment; -class DataSource; -struct DataSelector; -using DataFragmentIterator = Iterator>; -using DataFragmentVector = std::vector>; - -struct DiscoveryOptions; - -class FileBasedDataFragment; -class FileFormat; -class FileScanOptions; -class FileWriteOptions; - -class Filter; -using FilterVector = std::vector>; - -class Partition; -class PartitionKey; -class PartitionScheme; -using PartitionVector = std::vector>; -using PartitionIterator = Iterator>; - -struct ScanContext; -class ScanOptions; -class Scanner; -class ScannerBuilder; -class ScanTask; -using ScanTaskIterator = Iterator>; - -class DatasetWriter; -class WriteContext; -class WriteOptions; - -} // namespace dataset -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/dataset/visibility.h b/cpp/thirdparty/knowhere_build/include/arrow/dataset/visibility.h deleted file mode 100644 index 324b1b269d..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/dataset/visibility.h +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#if defined(_WIN32) || defined(__CYGWIN__) -#if defined(_MSC_VER) -#pragma warning(push) -#pragma warning(disable : 4251) -#else -#pragma GCC diagnostic ignored "-Wattributes" -#endif - -#ifdef ARROW_DS_STATIC -#define ARROW_DS_EXPORT -#elif defined(ARROW_DS_EXPORTING) -#define ARROW_DS_EXPORT __declspec(dllexport) -#else -#define ARROW_DS_EXPORT __declspec(dllimport) -#endif - -#define ARROW_DS_NO_EXPORT -#else // Not Windows -#ifndef ARROW_DS_EXPORT -#define ARROW_DS_EXPORT __attribute__((visibility("default"))) -#endif -#ifndef ARROW_DS_NO_EXPORT -#define ARROW_DS_NO_EXPORT __attribute__((visibility("hidden"))) -#endif -#endif // Non-Windows - -#if defined(_MSC_VER) -#pragma warning(pop) -#endif diff --git a/cpp/thirdparty/knowhere_build/include/arrow/dataset/writer.h b/cpp/thirdparty/knowhere_build/include/arrow/dataset/writer.h deleted file mode 100644 index 048a0e54d7..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/dataset/writer.h +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include -#include - -#include "arrow/dataset/type_fwd.h" -#include "arrow/dataset/visibility.h" - -namespace arrow { -namespace dataset { - -class ARROW_DS_EXPORT WriteOptions { - public: - virtual ~WriteOptions() = default; -}; - -} // namespace dataset -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/extension_type.h b/cpp/thirdparty/knowhere_build/include/arrow/extension_type.h deleted file mode 100644 index 8bf4639bd1..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/extension_type.h +++ /dev/null @@ -1,128 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -/// User-defined extension types. EXPERIMENTAL in 0.13.0 -/// \since 0.13.0 - -#pragma once - -#include -#include - -#include "arrow/array.h" -#include "arrow/type.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -/// \brief The base class for custom / user-defined types. -class ARROW_EXPORT ExtensionType : public DataType { - public: - static constexpr Type::type type_id = Type::EXTENSION; - - /// \brief The type of array used to represent this extension type's data - std::shared_ptr storage_type() const { return storage_type_; } - - DataTypeLayout layout() const override; - - std::string ToString() const override; - std::string name() const override; - - /// \brief Unique name of extension type used to identify type for - /// serialization - /// \return the string name of the extension - virtual std::string extension_name() const = 0; - - /// \brief Determine if two instances of the same extension types are - /// equal. Invoked from ExtensionType::Equals - /// \param[in] other the type to compare this type with - /// \return bool true if type instances are equal - virtual bool ExtensionEquals(const ExtensionType& other) const = 0; - - /// \brief Wrap built-in Array type in a user-defined ExtensionArray instance - /// \param[in] data the physical storage for the extension type - virtual std::shared_ptr MakeArray(std::shared_ptr data) const = 0; - - /// \brief Create an instance of the ExtensionType given the actual storage - /// type and the serialized representation - /// \param[in] storage_type the physical storage type of the extension - /// \param[in] serialized_data the serialized representation produced by - /// Serialize - /// \param[out] out the reconstructed extension type - /// \return Status - virtual Status Deserialize(std::shared_ptr storage_type, - const std::string& serialized_data, - std::shared_ptr* out) const = 0; - - /// \brief Create a serialized representation of the extension type's - /// metadata. The storage type will be handled automatically in IPC code - /// paths - /// \return the serialized representation - virtual std::string Serialize() const = 0; - - protected: - explicit ExtensionType(std::shared_ptr storage_type) - : DataType(Type::EXTENSION), storage_type_(storage_type) {} - - std::shared_ptr storage_type_; -}; - -/// \brief Base array class for user-defined extension types -class ARROW_EXPORT ExtensionArray : public Array { - public: - /// \brief Construct an ExtensionArray from an ArrayData. - /// - /// The ArrayData must have the right ExtensionType. - explicit ExtensionArray(const std::shared_ptr& data); - - /// \brief Construct an ExtensionArray from a type and the underlying storage. - ExtensionArray(const std::shared_ptr& type, - const std::shared_ptr& storage); - - const ExtensionType* extension_type() const { - return internal::checked_cast(data_->type.get()); - } - - /// \brief The physical storage for the extension array - std::shared_ptr storage() const { return storage_; } - - protected: - void SetData(const std::shared_ptr& data); - std::shared_ptr storage_; -}; - -/// \brief Register an extension type globally. The name returned by the type's -/// extension_name() method should be unique. This method is thread-safe -/// \param[in] type an instance of the extension type -/// \return Status -ARROW_EXPORT -Status RegisterExtensionType(std::shared_ptr type); - -/// \brief Delete an extension type from the global registry. This method is -/// thread-safe -/// \param[in] type_name the unique name of a registered extension type -/// \return Status error if the type name is unknown -ARROW_EXPORT -Status UnregisterExtensionType(const std::string& type_name); - -/// \brief Retrieve an extension type from the global registry. Returns nullptr -/// if not found. This method is thread-safe -/// \return the globally-registered extension type -ARROW_EXPORT -std::shared_ptr GetExtensionType(const std::string& type_name); - -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/filesystem/filesystem.h b/cpp/thirdparty/knowhere_build/include/arrow/filesystem/filesystem.h deleted file mode 100644 index 9a3e5a0dd5..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/filesystem/filesystem.h +++ /dev/null @@ -1,247 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include -#include -#include -#include - -#include "arrow/status.h" -#include "arrow/util/compression.h" -#include "arrow/util/visibility.h" - -// The Windows API defines macros from *File resolving to either -// *FileA or *FileW. Need to undo them. -#ifdef _WIN32 -#ifdef DeleteFile -#undef DeleteFile -#endif -#ifdef CopyFile -#undef CopyFile -#endif -#endif - -namespace arrow { - -namespace io { - -class InputStream; -class OutputStream; -class RandomAccessFile; - -} // namespace io - -namespace fs { - -// A system clock time point expressed as a 64-bit (or more) number of -// nanoseconds since the epoch. -using TimePoint = - std::chrono::time_point; - -/// \brief EXPERIMENTAL: FileSystem entry type -enum class ARROW_EXPORT FileType { - // Target does not exist - NonExistent, - // Target exists but its type is unknown (could be a special file such - // as a Unix socket or character device, or Windows NUL / CON / ...) - Unknown, - // Target is a regular file - File, - // Target is a directory - Directory -}; - -ARROW_EXPORT std::string ToString(FileType); - -static const int64_t kNoSize = -1; -static const TimePoint kNoTime = TimePoint(TimePoint::duration(-1)); - -/// \brief EXPERIMENTAL: FileSystem entry stats -struct ARROW_EXPORT FileStats { - FileStats() = default; - FileStats(FileStats&&) = default; - FileStats& operator=(FileStats&&) = default; - FileStats(const FileStats&) = default; - FileStats& operator=(const FileStats&) = default; - - // The file type. - FileType type() const { return type_; } - void set_type(FileType type) { type_ = type; } - - // The full file path in the filesystem. - std::string path() const { return path_; } - void set_path(const std::string& path) { path_ = path; } - - // The file base name (component after the last directory separator). - std::string base_name() const; - - // The size in bytes, if available. Only regular files are guaranteed - // to have a size. - int64_t size() const { return size_; } - void set_size(int64_t size) { size_ = size; } - - // The time of last modification, if available. - TimePoint mtime() const { return mtime_; } - void set_mtime(TimePoint mtime) { mtime_ = mtime; } - - protected: - FileType type_ = FileType::Unknown; - std::string path_; - int64_t size_ = kNoSize; - TimePoint mtime_ = kNoTime; -}; - -/// \brief EXPERIMENTAL: file selector -struct ARROW_EXPORT Selector { - // The directory in which to select files. - // If the path exists but doesn't point to a directory, this should be an error. - std::string base_dir; - // The behavior if `base_dir` doesn't exist in the filesystem. If false, - // an error is returned. If true, an empty selection is returned. - bool allow_non_existent = false; - // Whether to recurse into subdirectories. - bool recursive = false; - - Selector() {} -}; - -/// \brief EXPERIMENTAL: abstract file system API -class ARROW_EXPORT FileSystem { - public: - virtual ~FileSystem(); - - /// Get statistics for the given target. - /// - /// Any symlink is automatically dereferenced, recursively. - /// A non-existing or unreachable file returns an Ok status and - /// has a FileType of value NonExistent. An error status indicates - /// a truly exceptional condition (low-level I/O error, etc.). - virtual Status GetTargetStats(const std::string& path, FileStats* out) = 0; - /// Same, for many targets at once. - virtual Status GetTargetStats(const std::vector& paths, - std::vector* out); - /// Same, according to a selector. - /// - /// The selector's base directory will not be part of the results, even if - /// it exists. - /// If it doesn't exist, see `Selector::allow_non_existent`. - virtual Status GetTargetStats(const Selector& select, std::vector* out) = 0; - - /// Create a directory and subdirectories. - /// - /// This function succeeds if the directory already exists. - virtual Status CreateDir(const std::string& path, bool recursive = true) = 0; - - /// Delete a directory and its contents, recursively. - virtual Status DeleteDir(const std::string& path) = 0; - - /// Delete a file. - virtual Status DeleteFile(const std::string& path) = 0; - /// Delete many files. - /// - /// The default implementation issues individual delete operations in sequence. - virtual Status DeleteFiles(const std::vector& paths); - - /// Move / rename a file or directory. - /// - /// If the destination exists: - /// - if it is a non-empty directory, an error is returned - /// - otherwise, if it has the same type as the source, it is replaced - /// - otherwise, behavior is unspecified (implementation-dependent). - virtual Status Move(const std::string& src, const std::string& dest) = 0; - - /// Copy a file. - /// - /// If the destination exists and is a directory, an error is returned. - /// Otherwise, it is replaced. - virtual Status CopyFile(const std::string& src, const std::string& dest) = 0; - - /// Open an input stream for sequential reading. - virtual Status OpenInputStream(const std::string& path, - std::shared_ptr* out) = 0; - - /// Open an input file for random access reading. - virtual Status OpenInputFile(const std::string& path, - std::shared_ptr* out) = 0; - - /// Open an output stream for sequential writing. - /// - /// If the target already exists, existing data is truncated. - virtual Status OpenOutputStream(const std::string& path, - std::shared_ptr* out) = 0; - - /// Open an output stream for appending. - /// - /// If the target doesn't exist, a new empty file is created. - virtual Status OpenAppendStream(const std::string& path, - std::shared_ptr* out) = 0; -}; - -/// \brief EXPERIMENTAL: a FileSystem implementation that delegates to another -/// implementation after prepending a fixed base path. -/// -/// This is useful to expose a logical view of a subtree of a filesystem, -/// for example a directory in a LocalFileSystem. -/// This makes no security guarantee. For example, symlinks may allow to -/// "escape" the subtree and access other parts of the underlying filesystem. -class ARROW_EXPORT SubTreeFileSystem : public FileSystem { - public: - explicit SubTreeFileSystem(const std::string& base_path, - std::shared_ptr base_fs); - ~SubTreeFileSystem() override; - - using FileSystem::GetTargetStats; - Status GetTargetStats(const std::string& path, FileStats* out) override; - Status GetTargetStats(const Selector& select, std::vector* out) override; - - Status CreateDir(const std::string& path, bool recursive = true) override; - - Status DeleteDir(const std::string& path) override; - - Status DeleteFile(const std::string& path) override; - - Status Move(const std::string& src, const std::string& dest) override; - - Status CopyFile(const std::string& src, const std::string& dest) override; - - Status OpenInputStream(const std::string& path, - std::shared_ptr* out) override; - - Status OpenInputFile(const std::string& path, - std::shared_ptr* out) override; - - Status OpenOutputStream(const std::string& path, - std::shared_ptr* out) override; - - Status OpenAppendStream(const std::string& path, - std::shared_ptr* out) override; - - protected: - const std::string base_path_; - std::shared_ptr base_fs_; - - std::string PrependBase(const std::string& s) const; - Status PrependBaseNonEmpty(std::string* s) const; - Status StripBase(const std::string& s, std::string* out) const; - Status FixStats(FileStats* st) const; -}; - -} // namespace fs -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/filesystem/localfs.h b/cpp/thirdparty/knowhere_build/include/arrow/filesystem/localfs.h deleted file mode 100644 index c720ac2b93..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/filesystem/localfs.h +++ /dev/null @@ -1,67 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include -#include - -#include "arrow/filesystem/filesystem.h" - -namespace arrow { -namespace fs { - -/// \brief EXPERIMENTAL: a FileSystem implementation accessing files -/// on the local machine. -/// -/// Details such as symlinks are abstracted away (symlinks are always followed, -/// except when deleting an entry). -class ARROW_EXPORT LocalFileSystem : public FileSystem { - public: - LocalFileSystem(); - ~LocalFileSystem() override; - - using FileSystem::GetTargetStats; - Status GetTargetStats(const std::string& path, FileStats* out) override; - Status GetTargetStats(const Selector& select, std::vector* out) override; - - Status CreateDir(const std::string& path, bool recursive = true) override; - - Status DeleteDir(const std::string& path) override; - - Status DeleteFile(const std::string& path) override; - - Status Move(const std::string& src, const std::string& dest) override; - - Status CopyFile(const std::string& src, const std::string& dest) override; - - Status OpenInputStream(const std::string& path, - std::shared_ptr* out) override; - - Status OpenInputFile(const std::string& path, - std::shared_ptr* out) override; - - Status OpenOutputStream(const std::string& path, - std::shared_ptr* out) override; - - Status OpenAppendStream(const std::string& path, - std::shared_ptr* out) override; -}; - -} // namespace fs -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/filesystem/mockfs.h b/cpp/thirdparty/knowhere_build/include/arrow/filesystem/mockfs.h deleted file mode 100644 index ba7b57636d..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/filesystem/mockfs.h +++ /dev/null @@ -1,104 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include -#include -#include - -#include "arrow/filesystem/filesystem.h" - -namespace arrow { -namespace fs { -namespace internal { - -struct DirInfo { - std::string full_path; - TimePoint mtime; - - bool operator==(const DirInfo& other) const { - return mtime == other.mtime && full_path == other.full_path; - } - - friend ARROW_EXPORT std::ostream& operator<<(std::ostream&, const DirInfo&); -}; - -struct FileInfo { - std::string full_path; - TimePoint mtime; - std::string data; - - bool operator==(const FileInfo& other) const { - return mtime == other.mtime && full_path == other.full_path && data == other.data; - } - - friend ARROW_EXPORT std::ostream& operator<<(std::ostream&, const FileInfo&); -}; - -/// A mock FileSystem implementation that holds its contents in memory. -/// -/// Useful for validating the FileSystem API, writing conformance suite, -/// and bootstrapping FileSystem-based APIs. -class ARROW_EXPORT MockFileSystem : public FileSystem { - public: - explicit MockFileSystem(TimePoint current_time); - ~MockFileSystem() override; - - // XXX It's not very practical to have to explicitly declare inheritance - // of default overrides. - using FileSystem::GetTargetStats; - Status GetTargetStats(const std::string& path, FileStats* out) override; - Status GetTargetStats(const Selector& select, std::vector* out) override; - - Status CreateDir(const std::string& path, bool recursive = true) override; - - Status DeleteDir(const std::string& path) override; - - Status DeleteFile(const std::string& path) override; - - Status Move(const std::string& src, const std::string& dest) override; - - Status CopyFile(const std::string& src, const std::string& dest) override; - - Status OpenInputStream(const std::string& path, - std::shared_ptr* out) override; - - Status OpenInputFile(const std::string& path, - std::shared_ptr* out) override; - - Status OpenOutputStream(const std::string& path, - std::shared_ptr* out) override; - - Status OpenAppendStream(const std::string& path, - std::shared_ptr* out) override; - - // Contents-dumping helpers to ease testing. - // Output is lexicographically-ordered by full path. - std::vector AllDirs(); - std::vector AllFiles(); - - class Impl; - - protected: - std::unique_ptr impl_; -}; - -} // namespace internal -} // namespace fs -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/filesystem/path-util.h b/cpp/thirdparty/knowhere_build/include/arrow/filesystem/path-util.h deleted file mode 100644 index 444451d32a..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/filesystem/path-util.h +++ /dev/null @@ -1,70 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include -#include - -#include "arrow/status.h" - -namespace arrow { -namespace fs { -namespace internal { - -constexpr char kSep = '/'; - -// Computations on abstract paths (not local paths with system-dependent behaviour). -// Abstract paths are typically used in URIs. - -// Split an abstract path into its individual components. -ARROW_EXPORT -std::vector SplitAbstractPath(const std::string& s); - -// Return the parent directory and basename of an abstract path. Both values may be -// empty. -ARROW_EXPORT -std::pair GetAbstractPathParent(const std::string& s); - -// Validate the components of an abstract path. -ARROW_EXPORT -Status ValidateAbstractPathParts(const std::vector& parts); - -// Append a non-empty stem to an abstract path. -ARROW_EXPORT -std::string ConcatAbstractPath(const std::string& base, const std::string& stem); - -ARROW_EXPORT -std::string EnsureTrailingSlash(const std::string& s); - -// Join the components of an abstract path. -template -std::string JoinAbstractPath(StringIt it, StringIt end) { - std::string path; - for (; it != end; ++it) { - if (!path.empty()) { - path += kSep; - } - path += *it; - } - return path; -} - -} // namespace internal -} // namespace fs -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/filesystem/test-util.h b/cpp/thirdparty/knowhere_build/include/arrow/filesystem/test-util.h deleted file mode 100644 index ee2e67dd5b..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/filesystem/test-util.h +++ /dev/null @@ -1,132 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include -#include -#include - -#include "arrow/filesystem/filesystem.h" - -namespace arrow { -namespace fs { - -static constexpr double kTimeSlack = 2.0; // In seconds - -ARROW_EXPORT -void AssertFileStats(const FileStats& st, const std::string& path, FileType type); - -ARROW_EXPORT -void AssertFileStats(const FileStats& st, const std::string& path, FileType type, - TimePoint mtime); - -ARROW_EXPORT -void AssertFileStats(const FileStats& st, const std::string& path, FileType type, - TimePoint mtime, int64_t size); - -ARROW_EXPORT -void AssertFileStats(const FileStats& st, const std::string& path, FileType type, - int64_t size); - -ARROW_EXPORT -void CreateFile(FileSystem* fs, const std::string& path, const std::string& data); - -// Sort of vector of FileStats by lexicographic path order -ARROW_EXPORT -void SortStats(std::vector* stats); - -template -void AssertDurationBetween(Duration d, double min_secs, double max_secs) { - auto seconds = std::chrono::duration_cast>(d); - ASSERT_GE(seconds.count(), min_secs); - ASSERT_LE(seconds.count(), max_secs); -} - -// Generic tests for FileSystem implementations. -// To use this class, subclass both from it and ::testing::Test, -// implement GetEmptyFileSystem(), and use GENERIC_FS_TEST_FUNCTIONS() -// to define the various tests. -class ARROW_EXPORT GenericFileSystemTest { - public: - virtual ~GenericFileSystemTest(); - - void TestEmpty(); - void TestCreateDir(); - void TestDeleteDir(); - void TestDeleteFile(); - void TestDeleteFiles(); - void TestMoveFile(); - void TestMoveDir(); - void TestCopyFile(); - void TestGetTargetStatsSingle(); - void TestGetTargetStatsVector(); - void TestGetTargetStatsSelector(); - void TestOpenOutputStream(); - void TestOpenAppendStream(); - void TestOpenInputStream(); - void TestOpenInputFile(); - - protected: - virtual std::shared_ptr GetEmptyFileSystem() = 0; - - void TestEmpty(FileSystem* fs); - void TestCreateDir(FileSystem* fs); - void TestDeleteDir(FileSystem* fs); - void TestDeleteFile(FileSystem* fs); - void TestDeleteFiles(FileSystem* fs); - void TestMoveFile(FileSystem* fs); - void TestMoveDir(FileSystem* fs); - void TestCopyFile(FileSystem* fs); - void TestGetTargetStatsSingle(FileSystem* fs); - void TestGetTargetStatsVector(FileSystem* fs); - void TestGetTargetStatsSelector(FileSystem* fs); - void TestOpenOutputStream(FileSystem* fs); - void TestOpenAppendStream(FileSystem* fs); - void TestOpenInputStream(FileSystem* fs); - void TestOpenInputFile(FileSystem* fs); -}; - -#define GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, NAME) \ - TEST_MACRO(TEST_CLASS, NAME) { this->Test##NAME(); } - -#define GENERIC_FS_TEST_FUNCTIONS_MACROS(TEST_MACRO, TEST_CLASS) \ - GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, Empty) \ - GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, CreateDir) \ - GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, DeleteDir) \ - GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, DeleteFile) \ - GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, DeleteFiles) \ - GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, MoveFile) \ - GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, MoveDir) \ - GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, CopyFile) \ - GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, GetTargetStatsSingle) \ - GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, GetTargetStatsVector) \ - GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, GetTargetStatsSelector) \ - GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, OpenOutputStream) \ - GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, OpenAppendStream) \ - GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, OpenInputStream) \ - GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, OpenInputFile) - -#define GENERIC_FS_TEST_FUNCTIONS(TEST_CLASS) \ - GENERIC_FS_TEST_FUNCTIONS_MACROS(TEST_F, TEST_CLASS) - -#define GENERIC_FS_TYPED_TEST_FUNCTIONS(TEST_CLASS) \ - GENERIC_FS_TEST_FUNCTIONS_MACROS(TYPED_TEST, TEST_CLASS) - -} // namespace fs -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/io/api.h b/cpp/thirdparty/knowhere_build/include/arrow/io/api.h deleted file mode 100644 index cf1be337fd..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/io/api.h +++ /dev/null @@ -1,28 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_IO_API_H -#define ARROW_IO_API_H - -#include "arrow/io/buffered.h" -#include "arrow/io/compressed.h" -#include "arrow/io/file.h" -#include "arrow/io/hdfs.h" -#include "arrow/io/interfaces.h" -#include "arrow/io/memory.h" - -#endif // ARROW_IO_API_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/io/buffered.h b/cpp/thirdparty/knowhere_build/include/arrow/io/buffered.h deleted file mode 100644 index 03ea1c7f75..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/io/buffered.h +++ /dev/null @@ -1,160 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// Buffered stream implementations - -#ifndef ARROW_IO_BUFFERED_H -#define ARROW_IO_BUFFERED_H - -#include -#include - -#include "arrow/io/interfaces.h" -#include "arrow/util/string_view.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Buffer; -class MemoryPool; -class Status; - -namespace io { - -class ARROW_EXPORT BufferedOutputStream : public OutputStream { - public: - ~BufferedOutputStream() override; - - /// \brief Create a buffered output stream wrapping the given output stream. - /// \param[in] buffer_size the size of the temporary write buffer - /// \param[in] pool a MemoryPool to use for allocations - /// \param[in] raw another OutputStream - /// \param[out] out the created BufferedOutputStream - /// \return Status - static Status Create(int64_t buffer_size, MemoryPool* pool, - std::shared_ptr raw, - std::shared_ptr* out); - - /// \brief Resize internal buffer - /// \param[in] new_buffer_size the new buffer size - /// \return Status - Status SetBufferSize(int64_t new_buffer_size); - - /// \brief Return the current size of the internal buffer - int64_t buffer_size() const; - - /// \brief Flush any buffered writes and release the raw - /// OutputStream. Further operations on this object are invalid - /// \param[out] raw the underlying OutputStream - /// \return Status - Status Detach(std::shared_ptr* raw); - - // OutputStream interface - - /// \brief Close the buffered output stream. This implicitly closes the - /// underlying raw output stream. - Status Close() override; - bool closed() const override; - - Status Tell(int64_t* position) const override; - // Write bytes to the stream. Thread-safe - Status Write(const void* data, int64_t nbytes) override; - - Status Flush() override; - - /// \brief Return the underlying raw output stream. - std::shared_ptr raw() const; - - private: - explicit BufferedOutputStream(std::shared_ptr raw, MemoryPool* pool); - - class ARROW_NO_EXPORT Impl; - std::unique_ptr impl_; -}; - -/// \class BufferedInputStream -/// \brief An InputStream that performs buffered reads from an unbuffered -/// InputStream, which can mitigate the overhead of many small reads in some -/// cases -class ARROW_EXPORT BufferedInputStream : public InputStream { - public: - ~BufferedInputStream() override; - - /// \brief Create a BufferedInputStream from a raw InputStream - /// \param[in] buffer_size the size of the temporary read buffer - /// \param[in] pool a MemoryPool to use for allocations - /// \param[in] raw a raw InputStream - /// \param[out] out the created BufferedInputStream - /// \param[in] raw_read_bound a bound on the maximum number of bytes - /// to read from the raw input stream. The default -1 indicates that - /// it is unbounded - static Status Create(int64_t buffer_size, MemoryPool* pool, - std::shared_ptr raw, - std::shared_ptr* out, - int64_t raw_read_bound = -1); - - /// \brief Resize internal read buffer; calls to Read(...) will read at least - /// \param[in] new_buffer_size the new read buffer size - /// \return Status - Status SetBufferSize(int64_t new_buffer_size); - - /// \brief Return the number of remaining bytes in the read buffer - int64_t bytes_buffered() const; - - /// \brief Return the current size of the internal buffer - int64_t buffer_size() const; - - /// \brief Release the raw InputStream. Any data buffered will be - /// discarded. Further operations on this object are invalid - /// \return raw the underlying InputStream - std::shared_ptr Detach(); - - /// \brief Return the unbuffered InputStream - std::shared_ptr raw() const; - - // InputStream APIs - - /// \brief Return a zero-copy string view referencing buffered data, - /// but do not advance the position of the stream. Buffers data and - /// expands the buffer size if necessary - Status Peek(int64_t nbytes, util::string_view* out) override; - - Status Close() override; - bool closed() const override; - - /// \brief Returns the position of the buffered stream, though the position - /// of the unbuffered stream may be further advanced - Status Tell(int64_t* position) const override; - - Status Read(int64_t nbytes, int64_t* bytes_read, void* out) override; - - /// \brief Read into buffer. If the read is already buffered, then this will - /// return a slice into the buffer - Status Read(int64_t nbytes, std::shared_ptr* out) override; - - private: - explicit BufferedInputStream(std::shared_ptr raw, MemoryPool* pool, - int64_t raw_total_bytes_bound); - - class ARROW_NO_EXPORT Impl; - std::unique_ptr impl_; -}; - -} // namespace io -} // namespace arrow - -#endif // ARROW_IO_BUFFERED_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/io/compressed.h b/cpp/thirdparty/knowhere_build/include/arrow/io/compressed.h deleted file mode 100644 index ffb18d929a..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/io/compressed.h +++ /dev/null @@ -1,115 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// Compressed stream implementations - -#ifndef ARROW_IO_COMPRESSED_H -#define ARROW_IO_COMPRESSED_H - -#include -#include - -#include "arrow/io/interfaces.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class MemoryPool; -class Status; - -namespace util { - -class Codec; - -} // namespace util - -namespace io { - -class ARROW_EXPORT CompressedOutputStream : public OutputStream { - public: - ~CompressedOutputStream() override; - - /// \brief Create a compressed output stream wrapping the given output stream. - static Status Make(util::Codec* codec, const std::shared_ptr& raw, - std::shared_ptr* out); - static Status Make(MemoryPool* pool, util::Codec* codec, - const std::shared_ptr& raw, - std::shared_ptr* out); - - // OutputStream interface - - /// \brief Close the compressed output stream. This implicitly closes the - /// underlying raw output stream. - Status Close() override; - bool closed() const override; - - Status Tell(int64_t* position) const override; - - Status Write(const void* data, int64_t nbytes) override; - Status Flush() override; - - /// \brief Return the underlying raw output stream. - std::shared_ptr raw() const; - - private: - ARROW_DISALLOW_COPY_AND_ASSIGN(CompressedOutputStream); - - CompressedOutputStream() = default; - - class ARROW_NO_EXPORT Impl; - std::unique_ptr impl_; -}; - -class ARROW_EXPORT CompressedInputStream : public InputStream { - public: - ~CompressedInputStream() override; - - /// \brief Create a compressed input stream wrapping the given input stream. - static Status Make(util::Codec* codec, const std::shared_ptr& raw, - std::shared_ptr* out); - static Status Make(MemoryPool* pool, util::Codec* codec, - const std::shared_ptr& raw, - std::shared_ptr* out); - - // InputStream interface - - /// \brief Close the compressed input stream. This implicitly closes the - /// underlying raw input stream. - Status Close() override; - bool closed() const override; - - Status Tell(int64_t* position) const override; - - Status Read(int64_t nbytes, int64_t* bytes_read, void* out) override; - Status Read(int64_t nbytes, std::shared_ptr* out) override; - - /// \brief Return the underlying raw input stream. - std::shared_ptr raw() const; - - private: - ARROW_DISALLOW_COPY_AND_ASSIGN(CompressedInputStream); - - CompressedInputStream() = default; - - class ARROW_NO_EXPORT Impl; - std::unique_ptr impl_; -}; - -} // namespace io -} // namespace arrow - -#endif // ARROW_IO_COMPRESSED_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/io/file.h b/cpp/thirdparty/knowhere_build/include/arrow/io/file.h deleted file mode 100644 index e9ac13f4c6..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/io/file.h +++ /dev/null @@ -1,246 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// IO interface implementations for OS files - -#ifndef ARROW_IO_FILE_H -#define ARROW_IO_FILE_H - -#include -#include -#include - -#include "arrow/io/interfaces.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Buffer; -class MemoryPool; -class Status; - -namespace io { - -class ARROW_EXPORT FileOutputStream : public OutputStream { - public: - ~FileOutputStream() override; - - /// \brief Open a local file for writing, truncating any existing file - /// \param[in] path with UTF8 encoding - /// \param[out] out a base interface OutputStream instance - /// - /// When opening a new file, any existing file with the indicated path is - /// truncated to 0 bytes, deleting any existing data - static Status Open(const std::string& path, std::shared_ptr* out); - - /// \brief Open a local file for writing - /// \param[in] path with UTF8 encoding - /// \param[in] append append to existing file, otherwise truncate to 0 bytes - /// \param[out] out a base interface OutputStream instance - static Status Open(const std::string& path, bool append, - std::shared_ptr* out); - - /// \brief Open a file descriptor for writing. The underlying file isn't - /// truncated. - /// \param[in] fd file descriptor - /// \param[out] out a base interface OutputStream instance - /// - /// The file descriptor becomes owned by the OutputStream, and will be closed - /// on Close() or destruction. - static Status Open(int fd, std::shared_ptr* out); - - /// \brief Open a local file for writing, truncating any existing file - /// \param[in] path with UTF8 encoding - /// \param[out] file a FileOutputStream instance - /// - /// When opening a new file, any existing file with the indicated path is - /// truncated to 0 bytes, deleting any existing data - static Status Open(const std::string& path, std::shared_ptr* file); - - /// \brief Open a local file for writing - /// \param[in] path with UTF8 encoding - /// \param[in] append append to existing file, otherwise truncate to 0 bytes - /// \param[out] file a FileOutputStream instance - static Status Open(const std::string& path, bool append, - std::shared_ptr* file); - - /// \brief Open a file descriptor for writing. The underlying file isn't - /// truncated. - /// \param[in] fd file descriptor - /// \param[out] out a FileOutputStream instance - /// - /// The file descriptor becomes owned by the OutputStream, and will be closed - /// on Close() or destruction. - static Status Open(int fd, std::shared_ptr* out); - - // OutputStream interface - Status Close() override; - bool closed() const override; - Status Tell(int64_t* position) const override; - - // Write bytes to the stream. Thread-safe - Status Write(const void* data, int64_t nbytes) override; - - using Writable::Write; - - int file_descriptor() const; - - private: - FileOutputStream(); - - class ARROW_NO_EXPORT FileOutputStreamImpl; - std::unique_ptr impl_; -}; - -// Operating system file -class ARROW_EXPORT ReadableFile : public RandomAccessFile { - public: - ~ReadableFile() override; - - /// \brief Open a local file for reading - /// \param[in] path with UTF8 encoding - /// \param[out] file ReadableFile instance - /// Open file, allocate memory (if needed) from default memory pool - static Status Open(const std::string& path, std::shared_ptr* file); - - /// \brief Open a local file for reading - /// \param[in] path with UTF8 encoding - /// \param[in] pool a MemoryPool for memory allocations - /// \param[out] file ReadableFile instance - /// Open file with one's own memory pool for memory allocations - static Status Open(const std::string& path, MemoryPool* pool, - std::shared_ptr* file); - - /// \brief Open a local file for reading - /// \param[in] fd file descriptor - /// \param[out] file ReadableFile instance - /// Open file with one's own memory pool for memory allocations - /// - /// The file descriptor becomes owned by the ReadableFile, and will be closed - /// on Close() or destruction. - static Status Open(int fd, std::shared_ptr* file); - - /// \brief Open a local file for reading - /// \param[in] fd file descriptor - /// \param[in] pool a MemoryPool for memory allocations - /// \param[out] file ReadableFile instance - /// Open file with one's own memory pool for memory allocations - /// - /// The file descriptor becomes owned by the ReadableFile, and will be closed - /// on Close() or destruction. - static Status Open(int fd, MemoryPool* pool, std::shared_ptr* file); - - Status Close() override; - bool closed() const override; - Status Tell(int64_t* position) const override; - - // Read bytes from the file. Thread-safe - Status Read(int64_t nbytes, int64_t* bytes_read, void* buffer) override; - Status Read(int64_t nbytes, std::shared_ptr* out) override; - - /// \brief Thread-safe implementation of ReadAt - Status ReadAt(int64_t position, int64_t nbytes, int64_t* bytes_read, - void* out) override; - - /// \brief Thread-safe implementation of ReadAt - Status ReadAt(int64_t position, int64_t nbytes, std::shared_ptr* out) override; - - Status GetSize(int64_t* size) override; - Status Seek(int64_t position) override; - - int file_descriptor() const; - - private: - explicit ReadableFile(MemoryPool* pool); - - class ARROW_NO_EXPORT ReadableFileImpl; - std::unique_ptr impl_; -}; - -// A file interface that uses memory-mapped files for memory interactions, -// supporting zero copy reads. The same class is used for both reading and -// writing. -// -// If opening a file in a writable mode, it is not truncated first as with -// FileOutputStream -class ARROW_EXPORT MemoryMappedFile : public ReadWriteFileInterface { - public: - ~MemoryMappedFile() override; - - /// Create new file with indicated size, return in read/write mode - static Status Create(const std::string& path, int64_t size, - std::shared_ptr* out); - - static Status Open(const std::string& path, FileMode::type mode, - std::shared_ptr* out); - - Status Close() override; - - bool closed() const override; - - Status Tell(int64_t* position) const override; - - Status Seek(int64_t position) override; - - // Required by RandomAccessFile, copies memory into out. Not thread-safe - Status Read(int64_t nbytes, int64_t* bytes_read, void* out) override; - - // Zero copy read, moves position pointer. Not thread-safe - Status Read(int64_t nbytes, std::shared_ptr* out) override; - - // Zero-copy read, leaves position unchanged. Acquires a reader lock - // for the duration of slice creation (typically very short). Is thread-safe. - Status ReadAt(int64_t position, int64_t nbytes, std::shared_ptr* out) override; - - // Raw copy of the memory at specified position. Thread-safe, but - // locks out other readers for the duration of memcpy. Prefer the - // zero copy method - Status ReadAt(int64_t position, int64_t nbytes, int64_t* bytes_read, - void* out) override; - - bool supports_zero_copy() const override; - - /// Write data at the current position in the file. Thread-safe - Status Write(const void* data, int64_t nbytes) override; - - /// Set the size of the map to new_size. - Status Resize(int64_t new_size); - - /// Write data at a particular position in the file. Thread-safe - Status WriteAt(int64_t position, const void* data, int64_t nbytes) override; - - // @return: the size in bytes of the memory source - Status GetSize(int64_t* size) const; - - // @return: the size in bytes of the memory source - Status GetSize(int64_t* size) override; - - int file_descriptor() const; - - private: - MemoryMappedFile(); - - Status WriteInternal(const void* data, int64_t nbytes); - - class ARROW_NO_EXPORT MemoryMap; - std::shared_ptr memory_map_; -}; - -} // namespace io -} // namespace arrow - -#endif // ARROW_IO_FILE_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/io/hdfs.h b/cpp/thirdparty/knowhere_build/include/arrow/io/hdfs.h deleted file mode 100644 index 45a47ddeda..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/io/hdfs.h +++ /dev/null @@ -1,258 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_IO_HDFS -#define ARROW_IO_HDFS - -#include -#include -#include -#include -#include - -#include "arrow/io/interfaces.h" -#include "arrow/util/macros.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Buffer; -class MemoryPool; -class Status; - -namespace io { - -class HdfsReadableFile; -class HdfsOutputStream; - -struct HdfsPathInfo { - ObjectType::type kind; - - std::string name; - std::string owner; - std::string group; - - // Access times in UNIX timestamps (seconds) - int64_t size; - int64_t block_size; - - int32_t last_modified_time; - int32_t last_access_time; - - int16_t replication; - int16_t permissions; -}; - -enum class HdfsDriver : char { LIBHDFS, LIBHDFS3 }; - -struct HdfsConnectionConfig { - std::string host; - int port; - std::string user; - std::string kerb_ticket; - std::unordered_map extra_conf; - HdfsDriver driver; -}; - -class ARROW_EXPORT HadoopFileSystem : public FileSystem { - public: - ~HadoopFileSystem() override; - - // Connect to an HDFS cluster given a configuration - // - // @param config (in): configuration for connecting - // @param fs (out): the created client - // @returns Status - static Status Connect(const HdfsConnectionConfig* config, - std::shared_ptr* fs); - - // Create directory and all parents - // - // @param path (in): absolute HDFS path - // @returns Status - Status MakeDirectory(const std::string& path) override; - - // Delete file or directory - // @param path: absolute path to data - // @param recursive: if path is a directory, delete contents as well - // @returns error status on failure - Status Delete(const std::string& path, bool recursive = false); - - Status DeleteDirectory(const std::string& path) override; - - // Disconnect from cluster - // - // @returns Status - Status Disconnect(); - - // @param path (in): absolute HDFS path - // @returns bool, true if the path exists, false if not (or on error) - bool Exists(const std::string& path); - - // @param path (in): absolute HDFS path - // @param info (out) - // @returns Status - Status GetPathInfo(const std::string& path, HdfsPathInfo* info); - - // @param nbytes (out): total capacity of the filesystem - // @returns Status - Status GetCapacity(int64_t* nbytes); - - // @param nbytes (out): total bytes used of the filesystem - // @returns Status - Status GetUsed(int64_t* nbytes); - - Status GetChildren(const std::string& path, std::vector* listing) override; - - Status ListDirectory(const std::string& path, std::vector* listing); - - /// Change - /// - /// @param path file path to change - /// @param owner pass null for no change - /// @param group pass null for no change - Status Chown(const std::string& path, const char* owner, const char* group); - - /// Change path permissions - /// - /// \param path Absolute path in file system - /// \param mode Mode bitset - /// \return Status - Status Chmod(const std::string& path, int mode); - - // Move file or directory from source path to destination path within the - // current filesystem - Status Rename(const std::string& src, const std::string& dst) override; - - Status Stat(const std::string& path, FileStatistics* stat) override; - - // TODO(wesm): GetWorkingDirectory, SetWorkingDirectory - - // Open an HDFS file in READ mode. Returns error - // status if the file is not found. - // - // @param path complete file path - Status OpenReadable(const std::string& path, int32_t buffer_size, - std::shared_ptr* file); - - Status OpenReadable(const std::string& path, std::shared_ptr* file); - - // FileMode::WRITE options - // @param path complete file path - // @param buffer_size, 0 for default - // @param replication, 0 for default - // @param default_block_size, 0 for default - Status OpenWritable(const std::string& path, bool append, int32_t buffer_size, - int16_t replication, int64_t default_block_size, - std::shared_ptr* file); - - Status OpenWritable(const std::string& path, bool append, - std::shared_ptr* file); - - ARROW_DEPRECATED("Use OpenWritable") - Status OpenWriteable(const std::string& path, bool append, int32_t buffer_size, - int16_t replication, int64_t default_block_size, - std::shared_ptr* file); - - ARROW_DEPRECATED("Use OpenWritable") - Status OpenWriteable(const std::string& path, bool append, - std::shared_ptr* file); - - private: - friend class HdfsReadableFile; - friend class HdfsOutputStream; - - class ARROW_NO_EXPORT HadoopFileSystemImpl; - std::unique_ptr impl_; - - HadoopFileSystem(); - ARROW_DISALLOW_COPY_AND_ASSIGN(HadoopFileSystem); -}; - -class ARROW_EXPORT HdfsReadableFile : public RandomAccessFile { - public: - ~HdfsReadableFile() override; - - Status Close() override; - - bool closed() const override; - - Status GetSize(int64_t* size) override; - - // NOTE: If you wish to read a particular range of a file in a multithreaded - // context, you may prefer to use ReadAt to avoid locking issues - Status Read(int64_t nbytes, int64_t* bytes_read, void* buffer) override; - - Status Read(int64_t nbytes, std::shared_ptr* out) override; - - Status ReadAt(int64_t position, int64_t nbytes, int64_t* bytes_read, - void* buffer) override; - - Status ReadAt(int64_t position, int64_t nbytes, std::shared_ptr* out) override; - - Status Seek(int64_t position) override; - Status Tell(int64_t* position) const override; - - void set_memory_pool(MemoryPool* pool); - - private: - explicit HdfsReadableFile(MemoryPool* pool = NULLPTR); - - class ARROW_NO_EXPORT HdfsReadableFileImpl; - std::unique_ptr impl_; - - friend class HadoopFileSystem::HadoopFileSystemImpl; - - ARROW_DISALLOW_COPY_AND_ASSIGN(HdfsReadableFile); -}; - -// Naming this file OutputStream because it does not support seeking (like the -// WritableFile interface) -class ARROW_EXPORT HdfsOutputStream : public OutputStream { - public: - ~HdfsOutputStream() override; - - Status Close() override; - - bool closed() const override; - - Status Write(const void* buffer, int64_t nbytes) override; - - Status Write(const void* buffer, int64_t nbytes, int64_t* bytes_written); - - Status Flush() override; - - Status Tell(int64_t* position) const override; - - private: - class ARROW_NO_EXPORT HdfsOutputStreamImpl; - std::unique_ptr impl_; - - friend class HadoopFileSystem::HadoopFileSystemImpl; - - HdfsOutputStream(); - - ARROW_DISALLOW_COPY_AND_ASSIGN(HdfsOutputStream); -}; - -Status ARROW_EXPORT HaveLibHdfs(); -Status ARROW_EXPORT HaveLibHdfs3(); - -} // namespace io -} // namespace arrow - -#endif // ARROW_IO_HDFS diff --git a/cpp/thirdparty/knowhere_build/include/arrow/io/interfaces.h b/cpp/thirdparty/knowhere_build/include/arrow/io/interfaces.h deleted file mode 100644 index 3a5cfe3d77..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/io/interfaces.h +++ /dev/null @@ -1,206 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_IO_INTERFACES_H -#define ARROW_IO_INTERFACES_H - -#include -#include -#include -#include - -#include "arrow/util/macros.h" -#include "arrow/util/string_view.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Buffer; -class Status; - -namespace io { - -struct FileMode { - enum type { READ, WRITE, READWRITE }; -}; - -struct ObjectType { - enum type { FILE, DIRECTORY }; -}; - -struct ARROW_EXPORT FileStatistics { - /// Size of file, -1 if finding length is unsupported - int64_t size; - ObjectType::type kind; -}; - -class ARROW_EXPORT FileSystem { - public: - virtual ~FileSystem() = default; - - virtual Status MakeDirectory(const std::string& path) = 0; - - virtual Status DeleteDirectory(const std::string& path) = 0; - - virtual Status GetChildren(const std::string& path, - std::vector* listing) = 0; - - virtual Status Rename(const std::string& src, const std::string& dst) = 0; - - virtual Status Stat(const std::string& path, FileStatistics* stat) = 0; -}; - -class ARROW_EXPORT FileInterface { - public: - virtual ~FileInterface() = 0; - virtual Status Close() = 0; - virtual Status Tell(int64_t* position) const = 0; - virtual bool closed() const = 0; - - FileMode::type mode() const { return mode_; } - - protected: - FileInterface() : mode_(FileMode::READ) {} - FileMode::type mode_; - void set_mode(FileMode::type mode) { mode_ = mode; } - - private: - ARROW_DISALLOW_COPY_AND_ASSIGN(FileInterface); -}; - -class ARROW_EXPORT Seekable { - public: - virtual ~Seekable() = default; - virtual Status Seek(int64_t position) = 0; -}; - -class ARROW_EXPORT Writable { - public: - virtual ~Writable() = default; - - virtual Status Write(const void* data, int64_t nbytes) = 0; - - /// \brief Flush buffered bytes, if any - virtual Status Flush(); - - Status Write(const std::string& data); -}; - -class ARROW_EXPORT Readable { - public: - virtual ~Readable() = default; - - virtual Status Read(int64_t nbytes, int64_t* bytes_read, void* out) = 0; - - // Does not copy if not necessary - virtual Status Read(int64_t nbytes, std::shared_ptr* out) = 0; -}; - -class ARROW_EXPORT OutputStream : virtual public FileInterface, public Writable { - protected: - OutputStream() = default; -}; - -class ARROW_EXPORT InputStream : virtual public FileInterface, virtual public Readable { - public: - /// \brief Advance or skip stream indicated number of bytes - /// \param[in] nbytes the number to move forward - /// \return Status - Status Advance(int64_t nbytes); - - /// \brief Return zero-copy string_view to upcoming bytes in the - /// stream but do not modify stream position. View becomes invalid - /// after any operation on file. If the InputStream is unbuffered, - /// returns 0-length string_view. May trigger buffering if the - /// requested size is larger than the number of buffered bytes - /// \param[in] nbytes the maximum number of bytes to see - /// \param[out] out the returned arrow::util::string_view - /// \return Status - virtual Status Peek(int64_t nbytes, util::string_view* out); - - /// \brief Return true if InputStream is capable of zero copy Buffer reads - virtual bool supports_zero_copy() const; - - protected: - InputStream() = default; -}; - -class ARROW_EXPORT RandomAccessFile : public InputStream, public Seekable { - public: - /// Necessary because we hold a std::unique_ptr - ~RandomAccessFile() override; - - virtual Status GetSize(int64_t* size) = 0; - - /// \brief Read nbytes at position, provide default implementations using - /// Read(...), but can be overridden. The default implementation is - /// thread-safe. It is unspecified whether this method updates the file - /// position or not. - /// - /// \param[in] position Where to read bytes from - /// \param[in] nbytes The number of bytes to read - /// \param[out] bytes_read The number of bytes read - /// \param[out] out The buffer to read bytes into - /// \return Status - virtual Status ReadAt(int64_t position, int64_t nbytes, int64_t* bytes_read, void* out); - - /// \brief Read nbytes at position, provide default implementations using - /// Read(...), but can be overridden. The default implementation is - /// thread-safe. It is unspecified whether this method updates the file - /// position or not. - /// - /// \param[in] position Where to read bytes from - /// \param[in] nbytes The number of bytes to read - /// \param[out] out The buffer to read bytes into. The number of bytes read can be - /// retrieved by calling Buffer::size(). - virtual Status ReadAt(int64_t position, int64_t nbytes, std::shared_ptr* out); - - protected: - RandomAccessFile(); - - private: - struct ARROW_NO_EXPORT RandomAccessFileImpl; - std::unique_ptr interface_impl_; -}; - -class ARROW_EXPORT WritableFile : public OutputStream, public Seekable { - public: - virtual Status WriteAt(int64_t position, const void* data, int64_t nbytes) = 0; - - protected: - WritableFile() = default; -}; - -class ARROW_EXPORT ReadWriteFileInterface : public RandomAccessFile, public WritableFile { - protected: - ReadWriteFileInterface() { RandomAccessFile::set_mode(FileMode::READWRITE); } -}; - -// TODO(kszucs): remove this after 0.13 -#ifndef _MSC_VER -using WriteableFile ARROW_DEPRECATED("Use WritableFile") = WritableFile; -using ReadableFileInterface ARROW_DEPRECATED("Use RandomAccessFile") = RandomAccessFile; -#else -// MSVC does not like using ARROW_DEPRECATED with using declarations -using WriteableFile = WritableFile; -using ReadableFileInterface = RandomAccessFile; -#endif - -} // namespace io -} // namespace arrow - -#endif // ARROW_IO_INTERFACES_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/io/memory.h b/cpp/thirdparty/knowhere_build/include/arrow/io/memory.h deleted file mode 100644 index d820d46552..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/io/memory.h +++ /dev/null @@ -1,172 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// Public API for different memory sharing / IO mechanisms - -#pragma once - -#include -#include - -#include "arrow/buffer.h" -#include "arrow/io/interfaces.h" -#include "arrow/memory_pool.h" -#include "arrow/util/string_view.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Buffer; -class ResizableBuffer; -class Status; - -namespace io { - -// \brief An output stream that writes to a resizable buffer -class ARROW_EXPORT BufferOutputStream : public OutputStream { - public: - explicit BufferOutputStream(const std::shared_ptr& buffer); - - /// \brief Create in-memory output stream with indicated capacity using a - /// memory pool - /// \param[in] initial_capacity the initial allocated internal capacity of - /// the OutputStream - /// \param[in,out] pool a MemoryPool to use for allocations - /// \param[out] out the created stream - static Status Create(int64_t initial_capacity, MemoryPool* pool, - std::shared_ptr* out); - - ~BufferOutputStream() override; - - // Implement the OutputStream interface - Status Close() override; - bool closed() const override; - Status Tell(int64_t* position) const override; - Status Write(const void* data, int64_t nbytes) override; - - using OutputStream::Write; - - /// Close the stream and return the buffer - Status Finish(std::shared_ptr* result); - - /// \brief Initialize state of OutputStream with newly allocated memory and - /// set position to 0 - /// \param[in] initial_capacity the starting allocated capacity - /// \param[in,out] pool the memory pool to use for allocations - /// \return Status - Status Reset(int64_t initial_capacity = 1024, MemoryPool* pool = default_memory_pool()); - - int64_t capacity() const { return capacity_; } - - private: - BufferOutputStream(); - - // Ensures there is sufficient space available to write nbytes - Status Reserve(int64_t nbytes); - - std::shared_ptr buffer_; - bool is_open_; - int64_t capacity_; - int64_t position_; - uint8_t* mutable_data_; -}; - -// \brief A helper class to tracks the size of allocations -class ARROW_EXPORT MockOutputStream : public OutputStream { - public: - MockOutputStream() : extent_bytes_written_(0), is_open_(true) {} - - // Implement the OutputStream interface - Status Close() override; - bool closed() const override; - Status Tell(int64_t* position) const override; - Status Write(const void* data, int64_t nbytes) override; - - int64_t GetExtentBytesWritten() const { return extent_bytes_written_; } - - private: - int64_t extent_bytes_written_; - bool is_open_; -}; - -/// \brief Enables random writes into a fixed-size mutable buffer -class ARROW_EXPORT FixedSizeBufferWriter : public WritableFile { - public: - /// Input buffer must be mutable, will abort if not - explicit FixedSizeBufferWriter(const std::shared_ptr& buffer); - ~FixedSizeBufferWriter() override; - - Status Close() override; - bool closed() const override; - Status Seek(int64_t position) override; - Status Tell(int64_t* position) const override; - Status Write(const void* data, int64_t nbytes) override; - Status WriteAt(int64_t position, const void* data, int64_t nbytes) override; - - void set_memcopy_threads(int num_threads); - void set_memcopy_blocksize(int64_t blocksize); - void set_memcopy_threshold(int64_t threshold); - - protected: - class FixedSizeBufferWriterImpl; - std::unique_ptr impl_; -}; - -/// \class BufferReader -/// \brief Random access zero-copy reads on an arrow::Buffer -class ARROW_EXPORT BufferReader : public RandomAccessFile { - public: - explicit BufferReader(const std::shared_ptr& buffer); - explicit BufferReader(const Buffer& buffer); - BufferReader(const uint8_t* data, int64_t size); - - /// \brief Instantiate from std::string or arrow::util::string_view. Does not - /// own data - explicit BufferReader(const util::string_view& data); - - Status Close() override; - bool closed() const override; - Status Tell(int64_t* position) const override; - Status Read(int64_t nbytes, int64_t* bytes_read, void* buffer) override; - // Zero copy read - Status Read(int64_t nbytes, std::shared_ptr* out) override; - - Status Peek(int64_t nbytes, util::string_view* out) override; - - bool supports_zero_copy() const override; - - Status ReadAt(int64_t position, int64_t nbytes, int64_t* bytes_read, - void* out) override; - Status ReadAt(int64_t position, int64_t nbytes, std::shared_ptr* out) override; - - Status GetSize(int64_t* size) override; - Status Seek(int64_t position) override; - - std::shared_ptr buffer() const { return buffer_; } - - protected: - inline Status CheckClosed() const; - - std::shared_ptr buffer_; - const uint8_t* data_; - int64_t size_; - int64_t position_; - bool is_open_; -}; - -} // namespace io -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/io/mman.h b/cpp/thirdparty/knowhere_build/include/arrow/io/mman.h deleted file mode 100644 index 6125492560..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/io/mman.h +++ /dev/null @@ -1,181 +0,0 @@ -// Copyright https://code.google.com/p/mman-win32/ -// -// Licensed under the MIT License; -// You may obtain a copy of the License at -// -// https://opensource.org/licenses/MIT - -#ifndef _MMAN_WIN32_H -#define _MMAN_WIN32_H - -#include "arrow/util/windows_compatibility.h" - -#include -#include -#include - -#define PROT_NONE 0 -#define PROT_READ 1 -#define PROT_WRITE 2 -#define PROT_EXEC 4 - -#define MAP_FILE 0 -#define MAP_SHARED 1 -#define MAP_PRIVATE 2 -#define MAP_TYPE 0xf -#define MAP_FIXED 0x10 -#define MAP_ANONYMOUS 0x20 -#define MAP_ANON MAP_ANONYMOUS - -#define MAP_FAILED ((void*)-1) - -/* Flags for msync. */ -#define MS_ASYNC 1 -#define MS_SYNC 2 -#define MS_INVALIDATE 4 - -#ifndef FILE_MAP_EXECUTE -#define FILE_MAP_EXECUTE 0x0020 -#endif - -static inline int __map_mman_error(const DWORD err, const int deferr) { - if (err == 0) return 0; - // TODO: implement - return err; -} - -static inline DWORD __map_mmap_prot_page(const int prot) { - DWORD protect = 0; - - if (prot == PROT_NONE) return protect; - - if ((prot & PROT_EXEC) != 0) { - protect = ((prot & PROT_WRITE) != 0) ? PAGE_EXECUTE_READWRITE : PAGE_EXECUTE_READ; - } else { - protect = ((prot & PROT_WRITE) != 0) ? PAGE_READWRITE : PAGE_READONLY; - } - - return protect; -} - -static inline DWORD __map_mmap_prot_file(const int prot) { - DWORD desiredAccess = 0; - - if (prot == PROT_NONE) return desiredAccess; - - if ((prot & PROT_READ) != 0) desiredAccess |= FILE_MAP_READ; - if ((prot & PROT_WRITE) != 0) desiredAccess |= FILE_MAP_WRITE; - if ((prot & PROT_EXEC) != 0) desiredAccess |= FILE_MAP_EXECUTE; - - return desiredAccess; -} - -static inline void* mmap(void* addr, size_t len, int prot, int flags, int fildes, - off_t off) { - HANDLE fm, h; - - void* map = MAP_FAILED; - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4293) -#endif - - const DWORD dwFileOffsetLow = - (sizeof(off_t) <= sizeof(DWORD)) ? (DWORD)off : (DWORD)(off & 0xFFFFFFFFL); - const DWORD dwFileOffsetHigh = - (sizeof(off_t) <= sizeof(DWORD)) ? (DWORD)0 : (DWORD)((off >> 32) & 0xFFFFFFFFL); - const DWORD protect = __map_mmap_prot_page(prot); - const DWORD desiredAccess = __map_mmap_prot_file(prot); - - const size_t maxSize = off + len; - - const DWORD dwMaxSizeLow = static_cast(maxSize & 0xFFFFFFFFL); - const DWORD dwMaxSizeHigh = static_cast((maxSize >> 32) & 0xFFFFFFFFL); - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - - errno = 0; - - if (len == 0 - /* Unsupported flag combinations */ - || (flags & MAP_FIXED) != 0 - /* Usupported protection combinations */ - || prot == PROT_EXEC) { - errno = EINVAL; - return MAP_FAILED; - } - - h = ((flags & MAP_ANONYMOUS) == 0) ? (HANDLE)_get_osfhandle(fildes) - : INVALID_HANDLE_VALUE; - - if ((flags & MAP_ANONYMOUS) == 0 && h == INVALID_HANDLE_VALUE) { - errno = EBADF; - return MAP_FAILED; - } - - fm = CreateFileMapping(h, NULL, protect, dwMaxSizeHigh, dwMaxSizeLow, NULL); - - if (fm == NULL) { - errno = __map_mman_error(GetLastError(), EPERM); - return MAP_FAILED; - } - - map = MapViewOfFile(fm, desiredAccess, dwFileOffsetHigh, dwFileOffsetLow, len); - - CloseHandle(fm); - - if (map == NULL) { - errno = __map_mman_error(GetLastError(), EPERM); - return MAP_FAILED; - } - - return map; -} - -static inline int munmap(void* addr, size_t len) { - if (UnmapViewOfFile(addr)) return 0; - - errno = __map_mman_error(GetLastError(), EPERM); - - return -1; -} - -static inline int mprotect(void* addr, size_t len, int prot) { - DWORD newProtect = __map_mmap_prot_page(prot); - DWORD oldProtect = 0; - - if (VirtualProtect(addr, len, newProtect, &oldProtect)) return 0; - - errno = __map_mman_error(GetLastError(), EPERM); - - return -1; -} - -static inline int msync(void* addr, size_t len, int flags) { - if (FlushViewOfFile(addr, len)) return 0; - - errno = __map_mman_error(GetLastError(), EPERM); - - return -1; -} - -static inline int mlock(const void* addr, size_t len) { - if (VirtualLock((LPVOID)addr, len)) return 0; - - errno = __map_mman_error(GetLastError(), EPERM); - - return -1; -} - -static inline int munlock(const void* addr, size_t len) { - if (VirtualUnlock((LPVOID)addr, len)) return 0; - - errno = __map_mman_error(GetLastError(), EPERM); - - return -1; -} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/arrow/io/readahead.h b/cpp/thirdparty/knowhere_build/include/arrow/io/readahead.h deleted file mode 100644 index 950520ba59..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/io/readahead.h +++ /dev/null @@ -1,98 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_IO_READAHEAD_H -#define ARROW_IO_READAHEAD_H - -#include -#include - -#include "arrow/util/visibility.h" - -namespace arrow { - -class MemoryPool; -class ResizableBuffer; -class Status; - -namespace io { - -class InputStream; - -namespace internal { - -struct ARROW_EXPORT ReadaheadBuffer { - std::shared_ptr buffer; - int64_t left_padding; - int64_t right_padding; -}; - -class ARROW_EXPORT ReadaheadSpooler { - public: - /// \brief EXPERIMENTAL: Create a readahead spooler wrapping the given input stream. - /// - /// The spooler launches a background thread that reads up to a given number - /// of fixed-size blocks in advance from the underlying stream. - /// The buffers returned by Read() will be padded at the beginning and the end - /// with the configured amount of (zeroed) bytes. - ReadaheadSpooler(MemoryPool* pool, std::shared_ptr raw, - int64_t read_size = kDefaultReadSize, int32_t readahead_queue_size = 1, - int64_t left_padding = 0, int64_t right_padding = 0); - - explicit ReadaheadSpooler(std::shared_ptr raw, - int64_t read_size = kDefaultReadSize, - int32_t readahead_queue_size = 1, int64_t left_padding = 0, - int64_t right_padding = 0); - - ~ReadaheadSpooler(); - - /// Configure zero-padding at beginning and end of buffers (default 0 bytes). - /// The buffers returned by Read() will be padded at the beginning and the end - /// with the configured amount of (zeroed) bytes. - /// Note that, as reading happens in background and in advance, changing the - /// configured values might not affect Read() results immediately. - int64_t GetLeftPadding(); - void SetLeftPadding(int64_t size); - - int64_t GetRightPadding(); - void SetRightPadding(int64_t size); - - /// \brief Close the spooler. This implicitly closes the underlying input stream. - Status Close(); - - /// \brief Read a buffer from the queue. - /// - /// If the buffer pointer in the ReadaheadBuffer is null, then EOF was - /// reached and/or the spooler was explicitly closed. - /// Otherwise, the buffer will contain at most read_size bytes in addition - /// to the configured padding (short reads are possible at the end of a file). - // How do we allow reusing the buffer in ReadaheadBuffer? perhaps by using - // a caching memory pool? - Status Read(ReadaheadBuffer* out); - - private: - static constexpr int64_t kDefaultReadSize = 1 << 20; // 1 MB - - class ARROW_NO_EXPORT Impl; - std::unique_ptr impl_; -}; - -} // namespace internal -} // namespace io -} // namespace arrow - -#endif // ARROW_IO_READAHEAD_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/io/test-common.h b/cpp/thirdparty/knowhere_build/include/arrow/io/test-common.h deleted file mode 100644 index 75e134732e..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/io/test-common.h +++ /dev/null @@ -1,61 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_IO_TEST_COMMON_H -#define ARROW_IO_TEST_COMMON_H - -#include -#include -#include - -#include "arrow/status.h" -#include "arrow/util/visibility.h" - -namespace arrow { -namespace io { - -class MemoryMappedFile; - -ARROW_EXPORT -void AssertFileContents(const std::string& path, const std::string& contents); - -ARROW_EXPORT bool FileExists(const std::string& path); - -ARROW_EXPORT bool FileIsClosed(int fd); - -ARROW_EXPORT -Status ZeroMemoryMap(MemoryMappedFile* file); - -class ARROW_EXPORT MemoryMapFixture { - public: - void TearDown(); - - void CreateFile(const std::string& path, int64_t size); - - Status InitMemoryMap(int64_t size, const std::string& path, - std::shared_ptr* mmap); - - void AppendFile(const std::string& path); - - private: - std::vector tmp_files_; -}; - -} // namespace io -} // namespace arrow - -#endif // ARROW_IO_TEST_COMMON_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/ipc/api.h b/cpp/thirdparty/knowhere_build/include/arrow/ipc/api.h deleted file mode 100644 index 1895c31319..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/ipc/api.h +++ /dev/null @@ -1,28 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_IPC_API_H -#define ARROW_IPC_API_H - -#include "arrow/ipc/dictionary.h" -#include "arrow/ipc/feather.h" -#include "arrow/ipc/json-simple.h" -#include "arrow/ipc/message.h" -#include "arrow/ipc/reader.h" -#include "arrow/ipc/writer.h" - -#endif // ARROW_IPC_API_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/ipc/dictionary.h b/cpp/thirdparty/knowhere_build/include/arrow/ipc/dictionary.h deleted file mode 100644 index 787cd0ddd5..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/ipc/dictionary.h +++ /dev/null @@ -1,106 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// Tools for dictionaries in IPC context - -#ifndef ARROW_IPC_DICTIONARY_H -#define ARROW_IPC_DICTIONARY_H - -#include -#include -#include - -#include "arrow/status.h" -#include "arrow/util/macros.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Array; -class DataType; -class Field; -class RecordBatch; - -namespace ipc { - -using DictionaryMap = std::unordered_map>; - -/// \brief Memoization data structure for assigning id numbers to -/// dictionaries and tracking their current state through possible -/// deltas in an IPC stream -class ARROW_EXPORT DictionaryMemo { - public: - DictionaryMemo(); - DictionaryMemo(DictionaryMemo&&) = default; - DictionaryMemo& operator=(DictionaryMemo&&) = default; - - /// \brief Return current dictionary corresponding to a particular - /// id. Returns KeyError if id not found - Status GetDictionary(int64_t id, std::shared_ptr* dictionary) const; - - /// \brief Return dictionary value type corresponding to a - /// particular dictionary id. This permits multiple fields to - /// reference the same dictionary in IPC and JSON - Status GetDictionaryType(int64_t id, std::shared_ptr* type) const; - - /// \brief Return id for dictionary, computing new id if necessary - Status GetOrAssignId(const std::shared_ptr& field, int64_t* out); - - /// \brief Return id for dictionary if it exists, otherwise return - /// KeyError - Status GetId(const Field& type, int64_t* id) const; - - /// \brief Return true if dictionary for type is in this memo - bool HasDictionary(const Field& type) const; - - /// \brief Return true if we have a dictionary for the input id - bool HasDictionary(int64_t id) const; - - /// \brief Add field to the memo, return KeyError if already present - Status AddField(int64_t id, const std::shared_ptr& field); - - /// \brief Add a dictionary to the memo with a particular id. Returns - /// KeyError if that dictionary already exists - Status AddDictionary(int64_t id, const std::shared_ptr& dictionary); - - const DictionaryMap& id_to_dictionary() const { return id_to_dictionary_; } - - /// \brief The number of fields tracked in the memo - int num_fields() const { return static_cast(field_to_id_.size()); } - int num_dictionaries() const { return static_cast(id_to_dictionary_.size()); } - - private: - Status AddFieldInternal(int64_t id, const std::shared_ptr& field); - - // Dictionary memory addresses, to track whether a particular - // dictionary-encoded field has been seen before - std::unordered_map field_to_id_; - - // Map of dictionary id to dictionary array - DictionaryMap id_to_dictionary_; - std::unordered_map> id_to_type_; - - ARROW_DISALLOW_COPY_AND_ASSIGN(DictionaryMemo); -}; - -ARROW_EXPORT -Status CollectDictionaries(const RecordBatch& batch, DictionaryMemo* memo); - -} // namespace ipc -} // namespace arrow - -#endif // ARROW_IPC_DICTIONARY_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/ipc/feather.h b/cpp/thirdparty/knowhere_build/include/arrow/ipc/feather.h deleted file mode 100644 index b6bd4ff5e5..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/ipc/feather.h +++ /dev/null @@ -1,173 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// Public API for the "Feather" file format, originally created at -// http://github.com/wesm/feather - -#ifndef ARROW_IPC_FEATHER_H -#define ARROW_IPC_FEATHER_H - -#include -#include -#include -#include - -#include "arrow/util/visibility.h" - -namespace arrow { - -class Array; -class Column; -class Status; -class Table; - -namespace io { - -class OutputStream; -class RandomAccessFile; - -} // namespace io - -namespace ipc { -namespace feather { - -static constexpr const int kFeatherVersion = 2; - -// ---------------------------------------------------------------------- -// Metadata accessor classes - -/// \class TableReader -/// \brief An interface for reading columns from Feather files -class ARROW_EXPORT TableReader { - public: - TableReader(); - ~TableReader(); - - /// \brief Open a Feather file from a RandomAccessFile interface - /// - /// \param[in] source a RandomAccessFile instance - /// \param[out] out the table reader - static Status Open(const std::shared_ptr& source, - std::unique_ptr* out); - - /// \brief Optional table description - /// - /// This does not return a const std::string& because a string has to be - /// copied from the flatbuffer to be able to return a non-flatbuffer type - std::string GetDescription() const; - - /// \brief Return true if the table has a description field populated - bool HasDescription() const; - - /// \brief Return the version number of the Feather file - int version() const; - - /// \brief Return the number of rows in the file - int64_t num_rows() const; - - /// \brief Return the number of columns in the file - int64_t num_columns() const; - - std::string GetColumnName(int i) const; - - /// \brief Read a column from the file as an arrow::Column. - /// - /// \param[in] i the column index to read - /// \param[out] out the returned column - /// \return Status - /// - /// This function is zero-copy if the file source supports zero-copy reads - Status GetColumn(int i, std::shared_ptr* out); - - /// \brief Read all columns from the file as an arrow::Table. - /// - /// \param[out] out the returned table - /// \return Status - /// - /// This function is zero-copy if the file source supports zero-copy reads - Status Read(std::shared_ptr
* out); - - /// \brief Read only the specified columns from the file as an arrow::Table. - /// - /// \param[in] indices the column indices to read - /// \param[out] out the returned table - /// \return Status - /// - /// This function is zero-copy if the file source supports zero-copy reads - Status Read(const std::vector& indices, std::shared_ptr
* out); - - /// \brief Read only the specified columns from the file as an arrow::Table. - /// - /// \param[in] names the column names to read - /// \param[out] out the returned table - /// \return Status - /// - /// This function is zero-copy if the file source supports zero-copy reads - Status Read(const std::vector& names, std::shared_ptr
* out); - - private: - class ARROW_NO_EXPORT TableReaderImpl; - std::unique_ptr impl_; -}; - -/// \class TableWriter -/// \brief Interface for writing Feather files -class ARROW_EXPORT TableWriter { - public: - ~TableWriter(); - - /// \brief Create a new TableWriter that writes to an OutputStream - /// \param[in] stream an output stream - /// \param[out] out the returned table writer - /// \return Status - static Status Open(const std::shared_ptr& stream, - std::unique_ptr* out); - - /// \brief Set the description field in the file metadata - void SetDescription(const std::string& desc); - - /// \brief Set the number of rows in the file - void SetNumRows(int64_t num_rows); - - /// \brief Append a column to the file - /// - /// \param[in] name the column name - /// \param[in] values the column values as a contiguous arrow::Array - /// \return Status - Status Append(const std::string& name, const Array& values); - - /// \brief Write a table to the file - /// - /// \param[in] table the table to be written - /// \return Status - Status Write(const Table& table); - - /// \brief Finalize the file by writing the file metadata and footer - /// \return Status - Status Finalize(); - - private: - TableWriter(); - class ARROW_NO_EXPORT TableWriterImpl; - std::unique_ptr impl_; -}; - -} // namespace feather -} // namespace ipc -} // namespace arrow - -#endif // ARROW_IPC_FEATHER_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/ipc/json-integration.h b/cpp/thirdparty/knowhere_build/include/arrow/ipc/json-integration.h deleted file mode 100644 index 0256532a4a..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/ipc/json-integration.h +++ /dev/null @@ -1,133 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// Implement Arrow JSON serialization format - -#pragma once - -#include -#include - -#include "arrow/status.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Buffer; -class MemoryPool; -class RecordBatch; -class Schema; - -namespace io { -class ReadableFile; -} // namespace io - -namespace ipc { -namespace internal { -namespace json { - -/// \class JsonWriter -/// \brief Write the JSON representation of an Arrow record batch file or stream -/// -/// This is used for integration testing -class ARROW_EXPORT JsonWriter { - public: - ~JsonWriter(); - - /// \brief Create a new JSON writer that writes to memory - /// - /// \param[in] schema the schema of record batches - /// \param[out] out the returned writer object - /// \return Status - static Status Open(const std::shared_ptr& schema, - std::unique_ptr* out); - - /// \brief Append a record batch - Status WriteRecordBatch(const RecordBatch& batch); - - /// \brief Finish the JSON payload and return as a std::string - /// - /// \param[out] result the JSON as as a std::string - /// \return Status - Status Finish(std::string* result); - - private: - explicit JsonWriter(const std::shared_ptr& schema); - - // Hide RapidJSON details from public API - class JsonWriterImpl; - std::unique_ptr impl_; -}; - -/// \class JsonReader -/// \brief Read the JSON representation of an Arrow record batch file or stream -/// -/// This is used for integration testing -class ARROW_EXPORT JsonReader { - public: - ~JsonReader(); - - /// \brief Create a new JSON reader - /// - /// \param[in] pool a MemoryPool to use for buffer allocations - /// \param[in] data a Buffer containing the JSON data - /// \param[out] reader the returned reader object - /// \return Status - static Status Open(MemoryPool* pool, const std::shared_ptr& data, - std::unique_ptr* reader); - - /// \brief Create a new JSON reader that uses the default memory pool - /// - /// \param[in] data a Buffer containing the JSON data - /// \param[out] reader the returned reader object - /// \return Status - static Status Open(const std::shared_ptr& data, - std::unique_ptr* reader); - - /// \brief Create a new JSON reader from a file - /// - /// \param[in] pool a MemoryPool to use for buffer allocations - /// \param[in] in_file a ReadableFile containing JSON data - /// \param[out] reader the returned reader object - /// \return Status - static Status Open(MemoryPool* pool, const std::shared_ptr& in_file, - std::unique_ptr* reader); - - /// \brief Return the schema read from the JSON - std::shared_ptr schema() const; - - /// \brief Return the number of record batches - int num_record_batches() const; - - /// \brief Read a particular record batch from the file - /// - /// \param[in] i the record batch index, does not boundscheck - /// \param[out] batch the read record batch - Status ReadRecordBatch(int i, std::shared_ptr* batch) const; - - private: - JsonReader(MemoryPool* pool, const std::shared_ptr& data); - - // Hide RapidJSON details from public API - class JsonReaderImpl; - std::unique_ptr impl_; -}; - -} // namespace json -} // namespace internal -} // namespace ipc -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/ipc/json-simple.h b/cpp/thirdparty/knowhere_build/include/arrow/ipc/json-simple.h deleted file mode 100644 index da6483ff15..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/ipc/json-simple.h +++ /dev/null @@ -1,56 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// Implement a simple JSON representation format for arrays - -#ifndef ARROW_IPC_JSON_SIMPLE_H -#define ARROW_IPC_JSON_SIMPLE_H - -#include -#include - -#include "arrow/status.h" -#include "arrow/util/string_view.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Array; -class DataType; - -namespace ipc { -namespace internal { -namespace json { - -ARROW_EXPORT -Status ArrayFromJSON(const std::shared_ptr&, const std::string& json, - std::shared_ptr* out); - -ARROW_EXPORT -Status ArrayFromJSON(const std::shared_ptr&, const util::string_view& json, - std::shared_ptr* out); - -ARROW_EXPORT -Status ArrayFromJSON(const std::shared_ptr&, const char* json, - std::shared_ptr* out); - -} // namespace json -} // namespace internal -} // namespace ipc -} // namespace arrow - -#endif // ARROW_IPC_JSON_SIMPLE_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/ipc/message.h b/cpp/thirdparty/knowhere_build/include/arrow/ipc/message.h deleted file mode 100644 index fcc7e77837..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/ipc/message.h +++ /dev/null @@ -1,241 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// C++ object model and user API for interprocess schema messaging - -#ifndef ARROW_IPC_MESSAGE_H -#define ARROW_IPC_MESSAGE_H - -#include -#include -#include - -#include "arrow/status.h" -#include "arrow/util/macros.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Buffer; - -namespace io { - -class FileInterface; -class InputStream; -class OutputStream; -class RandomAccessFile; - -} // namespace io - -namespace ipc { - -enum class MetadataVersion : char { - /// 0.1.0 - V1, - - /// 0.2.0 - V2, - - /// 0.3.0 to 0.7.1 - V3, - - /// >= 0.8.0 - V4 -}; - -// ARROW-109: We set this number arbitrarily to help catch user mistakes. For -// deeply nested schemas, it is expected the user will indicate explicitly the -// maximum allowed recursion depth -constexpr int kMaxNestingDepth = 64; - -// Read interface classes. We do not fully deserialize the flatbuffers so that -// individual fields metadata can be retrieved from very large schema without -// - -/// \class Message -/// \brief An IPC message including metadata and body -class ARROW_EXPORT Message { - public: - enum Type { NONE, SCHEMA, DICTIONARY_BATCH, RECORD_BATCH, TENSOR, SPARSE_TENSOR }; - - /// \brief Construct message, but do not validate - /// - /// Use at your own risk; Message::Open has more metadata validation - Message(const std::shared_ptr& metadata, const std::shared_ptr& body); - - ~Message(); - - /// \brief Create and validate a Message instance from two buffers - /// - /// \param[in] metadata a buffer containing the Flatbuffer metadata - /// \param[in] body a buffer containing the message body, which may be null - /// \param[out] out the created message - /// \return Status - static Status Open(const std::shared_ptr& metadata, - const std::shared_ptr& body, std::unique_ptr* out); - - /// \brief Read message body and create Message given Flatbuffer metadata - /// \param[in] metadata containing a serialized Message flatbuffer - /// \param[in] stream an InputStream - /// \param[out] out the created Message - /// \return Status - /// - /// \note If stream supports zero-copy, this is zero-copy - static Status ReadFrom(const std::shared_ptr& metadata, io::InputStream* stream, - std::unique_ptr* out); - - /// \brief Read message body from position in file, and create Message given - /// the Flatbuffer metadata - /// \param[in] offset the position in the file where the message body starts. - /// \param[in] metadata containing a serialized Message flatbuffer - /// \param[in] file the seekable file interface to read from - /// \param[out] out the created Message - /// \return Status - /// - /// \note If file supports zero-copy, this is zero-copy - static Status ReadFrom(const int64_t offset, const std::shared_ptr& metadata, - io::RandomAccessFile* file, std::unique_ptr* out); - - /// \brief Return true if message type and contents are equal - /// - /// \param other another message - /// \return true if contents equal - bool Equals(const Message& other) const; - - /// \brief the Message metadata - /// - /// \return buffer - std::shared_ptr metadata() const; - - /// \brief the Message body, if any - /// - /// \return buffer is null if no body - std::shared_ptr body() const; - - /// \brief The expected body length according to the metadata, for - /// verification purposes - int64_t body_length() const; - - /// \brief The Message type - Type type() const; - - /// \brief The Message metadata version - MetadataVersion metadata_version() const; - - const void* header() const; - - /// \brief Write length-prefixed metadata and body to output stream - /// - /// \param[in] file output stream to write to - /// \param[in] alignment byte alignment for metadata, usually 8 or - /// 64. Whether the body is padded depends on the metadata; if the body - /// buffer is smaller than the size indicated in the metadata, then extra - /// padding bytes will be written - /// \param[out] output_length the number of bytes written - /// \return Status - Status SerializeTo(io::OutputStream* file, int32_t alignment, - int64_t* output_length) const; - - /// \brief Return true if the Message metadata passes Flatbuffer validation - bool Verify() const; - - /// \brief Whether a given message type needs a body. - static bool HasBody(Type type) { return type != NONE && type != SCHEMA; } - - private: - // Hide serialization details from user API - class MessageImpl; - std::unique_ptr impl_; - - ARROW_DISALLOW_COPY_AND_ASSIGN(Message); -}; - -ARROW_EXPORT std::string FormatMessageType(Message::Type type); - -/// \brief Abstract interface for a sequence of messages -/// \since 0.5.0 -class ARROW_EXPORT MessageReader { - public: - virtual ~MessageReader() = default; - - /// \brief Create MessageReader that reads from InputStream - static std::unique_ptr Open(io::InputStream* stream); - - /// \brief Create MessageReader that reads from owned InputStream - static std::unique_ptr Open( - const std::shared_ptr& owned_stream); - - /// \brief Read next Message from the interface - /// - /// \param[out] message an arrow::ipc::Message instance - /// \return Status - virtual Status ReadNextMessage(std::unique_ptr* message) = 0; -}; - -/// \brief Read encapsulated RPC message from position in file -/// -/// Read a length-prefixed message flatbuffer starting at the indicated file -/// offset. If the message has a body with non-zero length, it will also be -/// read -/// -/// The metadata_length includes at least the length prefix and the flatbuffer -/// -/// \param[in] offset the position in the file where the message starts. The -/// first 4 bytes after the offset are the message length -/// \param[in] metadata_length the total number of bytes to read from file -/// \param[in] file the seekable file interface to read from -/// \param[out] message the message read -/// \return Status success or failure -ARROW_EXPORT -Status ReadMessage(const int64_t offset, const int32_t metadata_length, - io::RandomAccessFile* file, std::unique_ptr* message); - -/// \brief Advance stream to an 8-byte offset if its position is not a multiple -/// of 8 already -/// \param[in] stream an input stream -/// \param[in] alignment the byte multiple for the metadata prefix, usually 8 -/// or 64, to ensure the body starts on a multiple of that alignment -/// \return Status -ARROW_EXPORT -Status AlignStream(io::InputStream* stream, int32_t alignment = 8); - -/// \brief Advance stream to an 8-byte offset if its position is not a multiple -/// of 8 already -/// \param[in] stream an output stream -/// \param[in] alignment the byte multiple for the metadata prefix, usually 8 -/// or 64, to ensure the body starts on a multiple of that alignment -/// \return Status -ARROW_EXPORT -Status AlignStream(io::OutputStream* stream, int32_t alignment = 8); - -/// \brief Return error Status if file position is not a multiple of the -/// indicated alignment -ARROW_EXPORT -Status CheckAligned(io::FileInterface* stream, int32_t alignment = 8); - -/// \brief Read encapsulated RPC message (metadata and body) from InputStream -/// -/// Read length-prefixed message with as-yet unknown length. Returns null if -/// there are not enough bytes available or the message length is 0 (e.g. EOS -/// in a stream) -ARROW_EXPORT -Status ReadMessage(io::InputStream* stream, std::unique_ptr* message); - -} // namespace ipc -} // namespace arrow - -#endif // ARROW_IPC_MESSAGE_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/ipc/reader.h b/cpp/thirdparty/knowhere_build/include/arrow/ipc/reader.h deleted file mode 100644 index 34a0eefbbb..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/ipc/reader.h +++ /dev/null @@ -1,291 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// Read Arrow files and streams - -#ifndef ARROW_IPC_READER_H -#define ARROW_IPC_READER_H - -#include -#include - -#include "arrow/ipc/dictionary.h" -#include "arrow/ipc/message.h" -#include "arrow/record_batch.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Buffer; -class Schema; -class Status; -class Tensor; -class SparseTensor; - -namespace io { - -class InputStream; -class RandomAccessFile; - -} // namespace io - -namespace ipc { - -using RecordBatchReader = ::arrow::RecordBatchReader; - -/// \class RecordBatchStreamReader -/// \brief Synchronous batch stream reader that reads from io::InputStream -/// -/// This class reads the schema (plus any dictionaries) as the first messages -/// in the stream, followed by record batches. For more granular zero-copy -/// reads see the ReadRecordBatch functions -class ARROW_EXPORT RecordBatchStreamReader : public RecordBatchReader { - public: - ~RecordBatchStreamReader() override; - - /// Create batch reader from generic MessageReader. - /// This will take ownership of the given MessageReader. - /// - /// \param[in] message_reader a MessageReader implementation - /// \param[out] out the created RecordBatchReader object - /// \return Status - static Status Open(std::unique_ptr message_reader, - std::shared_ptr* out); - static Status Open(std::unique_ptr message_reader, - std::unique_ptr* out); - - /// \brief Record batch stream reader from InputStream - /// - /// \param[in] stream an input stream instance. Must stay alive throughout - /// lifetime of stream reader - /// \param[out] out the created RecordBatchStreamReader object - /// \return Status - static Status Open(io::InputStream* stream, std::shared_ptr* out); - - /// \brief Open stream and retain ownership of stream object - /// \param[in] stream the input stream - /// \param[out] out the batch reader - /// \return Status - static Status Open(const std::shared_ptr& stream, - std::shared_ptr* out); - - /// \brief Returns the schema read from the stream - std::shared_ptr schema() const override; - - Status ReadNext(std::shared_ptr* batch) override; - - private: - RecordBatchStreamReader(); - - class ARROW_NO_EXPORT RecordBatchStreamReaderImpl; - std::unique_ptr impl_; -}; - -/// \brief Reads the record batch file format -class ARROW_EXPORT RecordBatchFileReader { - public: - ~RecordBatchFileReader(); - - /// \brief Open a RecordBatchFileReader - /// - /// Open a file-like object that is assumed to be self-contained; i.e., the - /// end of the file interface is the end of the Arrow file. Note that there - /// can be any amount of data preceding the Arrow-formatted data, because we - /// need only locate the end of the Arrow file stream to discover the metadata - /// and then proceed to read the data into memory. - static Status Open(io::RandomAccessFile* file, - std::shared_ptr* reader); - - /// \brief Open a RecordBatchFileReader - /// If the file is embedded within some larger file or memory region, you can - /// pass the absolute memory offset to the end of the file (which contains the - /// metadata footer). The metadata must have been written with memory offsets - /// relative to the start of the containing file - /// - /// \param[in] file the data source - /// \param[in] footer_offset the position of the end of the Arrow file - /// \param[out] reader the returned reader - /// \return Status - static Status Open(io::RandomAccessFile* file, int64_t footer_offset, - std::shared_ptr* reader); - - /// \brief Version of Open that retains ownership of file - /// - /// \param[in] file the data source - /// \param[out] reader the returned reader - /// \return Status - static Status Open(const std::shared_ptr& file, - std::shared_ptr* reader); - - /// \brief Version of Open that retains ownership of file - /// - /// \param[in] file the data source - /// \param[in] footer_offset the position of the end of the Arrow file - /// \param[out] reader the returned reader - /// \return Status - static Status Open(const std::shared_ptr& file, - int64_t footer_offset, - std::shared_ptr* reader); - - /// \brief The schema read from the file - std::shared_ptr schema() const; - - /// \brief Returns the number of record batches in the file - int num_record_batches() const; - - /// \brief Return the metadata version from the file metadata - MetadataVersion version() const; - - /// \brief Read a particular record batch from the file. Does not copy memory - /// if the input source supports zero-copy. - /// - /// \param[in] i the index of the record batch to return - /// \param[out] batch the read batch - /// \return Status - Status ReadRecordBatch(int i, std::shared_ptr* batch); - - private: - RecordBatchFileReader(); - - class ARROW_NO_EXPORT RecordBatchFileReaderImpl; - std::unique_ptr impl_; -}; - -// Generic read functions; does not copy data if the input supports zero copy reads - -/// \brief Read Schema from stream serialized as a single IPC message -/// and populate any dictionary-encoded fields into a DictionaryMemo -/// -/// \param[in] stream an InputStream -/// \param[in] dictionary_memo for recording dictionary-encoded fields -/// \param[out] out the output Schema -/// \return Status -/// -/// If record batches follow the schema, it is better to use -/// RecordBatchStreamReader -ARROW_EXPORT -Status ReadSchema(io::InputStream* stream, DictionaryMemo* dictionary_memo, - std::shared_ptr* out); - -/// \brief Read Schema from encapsulated Message -/// -/// \param[in] message a message instance containing metadata -/// \param[in] dictionary_memo DictionaryMemo for recording dictionary-encoded -/// fields. Can be nullptr if you are sure there are no -/// dictionary-encoded fields -/// \param[out] out the resulting Schema -/// \return Status -ARROW_EXPORT -Status ReadSchema(const Message& message, DictionaryMemo* dictionary_memo, - std::shared_ptr* out); - -/// Read record batch as encapsulated IPC message with metadata size prefix and -/// header -/// -/// \param[in] schema the record batch schema -/// \param[in] dictionary_memo DictionaryMemo which has any -/// dictionaries. Can be nullptr if you are sure there are no -/// dictionary-encoded fields -/// \param[in] stream the file where the batch is located -/// \param[out] out the read record batch -/// \return Status -ARROW_EXPORT -Status ReadRecordBatch(const std::shared_ptr& schema, - const DictionaryMemo* dictionary_memo, io::InputStream* stream, - std::shared_ptr* out); - -/// \brief Read record batch from file given metadata and schema -/// -/// \param[in] metadata a Message containing the record batch metadata -/// \param[in] schema the record batch schema -/// \param[in] dictionary_memo DictionaryMemo which has any -/// dictionaries. Can be nullptr if you are sure there are no -/// dictionary-encoded fields -/// \param[in] file a random access file -/// \param[out] out the read record batch -/// \return Status -ARROW_EXPORT -Status ReadRecordBatch(const Buffer& metadata, const std::shared_ptr& schema, - const DictionaryMemo* dictionary_memo, io::RandomAccessFile* file, - std::shared_ptr* out); - -/// \brief Read record batch from encapsulated Message -/// -/// \param[in] message a message instance containing metadata and body -/// \param[in] schema the record batch schema -/// \param[in] dictionary_memo DictionaryMemo which has any -/// dictionaries. Can be nullptr if you are sure there are no -/// dictionary-encoded fields -/// \param[out] out the resulting RecordBatch -/// \return Status -ARROW_EXPORT -Status ReadRecordBatch(const Message& message, const std::shared_ptr& schema, - const DictionaryMemo* dictionary_memo, - std::shared_ptr* out); - -/// Read record batch from file given metadata and schema -/// -/// \param[in] metadata a Message containing the record batch metadata -/// \param[in] schema the record batch schema -/// \param[in] dictionary_memo DictionaryMemo which has any -/// dictionaries. Can be nullptr if you are sure there are no -/// dictionary-encoded fields -/// \param[in] file a random access file -/// \param[in] max_recursion_depth the maximum permitted nesting depth -/// \param[out] out the read record batch -/// \return Status -ARROW_EXPORT -Status ReadRecordBatch(const Buffer& metadata, const std::shared_ptr& schema, - const DictionaryMemo* dictionary_memo, int max_recursion_depth, - io::RandomAccessFile* file, std::shared_ptr* out); - -/// \brief Read arrow::Tensor as encapsulated IPC message in file -/// -/// \param[in] file an InputStream pointed at the start of the message -/// \param[out] out the read tensor -/// \return Status -ARROW_EXPORT -Status ReadTensor(io::InputStream* file, std::shared_ptr* out); - -/// \brief EXPERIMENTAL: Read arrow::Tensor from IPC message -/// -/// \param[in] message a Message containing the tensor metadata and body -/// \param[out] out the read tensor -/// \return Status -ARROW_EXPORT -Status ReadTensor(const Message& message, std::shared_ptr* out); - -/// \brief EXPERIMETNAL: Read arrow::SparseTensor as encapsulated IPC message in file -/// -/// \param[in] file an InputStream pointed at the start of the message -/// \param[out] out the read sparse tensor -/// \return Status -ARROW_EXPORT -Status ReadSparseTensor(io::InputStream* file, std::shared_ptr* out); - -/// \brief EXPERIMENTAL: Read arrow::SparseTensor from IPC message -/// -/// \param[in] message a Message containing the tensor metadata and body -/// \param[out] out the read sparse tensor -/// \return Status -ARROW_EXPORT -Status ReadSparseTensor(const Message& message, std::shared_ptr* out); - -} // namespace ipc -} // namespace arrow - -#endif // ARROW_IPC_READER_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/ipc/test-common.h b/cpp/thirdparty/knowhere_build/include/arrow/ipc/test-common.h deleted file mode 100644 index 0ec98349c7..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/ipc/test-common.h +++ /dev/null @@ -1,139 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_IPC_TEST_COMMON_H -#define ARROW_IPC_TEST_COMMON_H - -#include -#include - -#include "arrow/array.h" -#include "arrow/record_batch.h" -#include "arrow/status.h" -#include "arrow/type.h" - -namespace arrow { -namespace ipc { -namespace test { - -// A typedef used for test parameterization -typedef Status MakeRecordBatch(std::shared_ptr* out); - -ARROW_EXPORT -void CompareArraysDetailed(int index, const Array& result, const Array& expected); - -ARROW_EXPORT -void CompareBatchColumnsDetailed(const RecordBatch& result, const RecordBatch& expected); - -ARROW_EXPORT -Status MakeRandomInt32Array(int64_t length, bool include_nulls, MemoryPool* pool, - std::shared_ptr* out, uint32_t seed = 0); - -ARROW_EXPORT -Status MakeRandomListArray(const std::shared_ptr& child_array, int num_lists, - bool include_nulls, MemoryPool* pool, - std::shared_ptr* out); - -ARROW_EXPORT -Status MakeRandomMapArray(const std::shared_ptr& child_array, int num_lists, - bool include_nulls, MemoryPool* pool, - std::shared_ptr* out); - -ARROW_EXPORT -Status MakeRandomBooleanArray(const int length, bool include_nulls, - std::shared_ptr* out); - -ARROW_EXPORT -Status MakeBooleanBatchSized(const int length, std::shared_ptr* out); - -ARROW_EXPORT -Status MakeBooleanBatch(std::shared_ptr* out); - -ARROW_EXPORT -Status MakeIntBatchSized(int length, std::shared_ptr* out, - uint32_t seed = 0); - -ARROW_EXPORT -Status MakeIntRecordBatch(std::shared_ptr* out); - -ARROW_EXPORT -Status MakeRandomStringArray(int64_t length, bool include_nulls, MemoryPool* pool, - std::shared_ptr* out); - -ARROW_EXPORT -Status MakeStringTypesRecordBatch(std::shared_ptr* out, - bool with_nulls = true); - -ARROW_EXPORT -Status MakeStringTypesRecordBatchWithNulls(std::shared_ptr* out); - -ARROW_EXPORT -Status MakeNullRecordBatch(std::shared_ptr* out); - -ARROW_EXPORT -Status MakeListRecordBatch(std::shared_ptr* out); - -ARROW_EXPORT -Status MakeFixedSizeListRecordBatch(std::shared_ptr* out); - -ARROW_EXPORT -Status MakeZeroLengthRecordBatch(std::shared_ptr* out); - -ARROW_EXPORT -Status MakeNonNullRecordBatch(std::shared_ptr* out); - -ARROW_EXPORT -Status MakeDeeplyNestedList(std::shared_ptr* out); - -ARROW_EXPORT -Status MakeStruct(std::shared_ptr* out); - -ARROW_EXPORT -Status MakeUnion(std::shared_ptr* out); - -ARROW_EXPORT -Status MakeDictionary(std::shared_ptr* out); - -ARROW_EXPORT -Status MakeDictionaryFlat(std::shared_ptr* out); - -ARROW_EXPORT -Status MakeDates(std::shared_ptr* out); - -ARROW_EXPORT -Status MakeTimestamps(std::shared_ptr* out); - -ARROW_EXPORT -Status MakeIntervals(std::shared_ptr* out); - -ARROW_EXPORT -Status MakeTimes(std::shared_ptr* out); - -ARROW_EXPORT -Status MakeFWBinary(std::shared_ptr* out); - -ARROW_EXPORT -Status MakeDecimal(std::shared_ptr* out); - -ARROW_EXPORT -Status MakeNull(std::shared_ptr* out); - -} // namespace test -} // namespace ipc -} // namespace arrow - -#endif // ARROW_IPC_TEST_COMMON_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/ipc/util.h b/cpp/thirdparty/knowhere_build/include/arrow/ipc/util.h deleted file mode 100644 index 80f9f3c510..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/ipc/util.h +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_IPC_UTIL_H -#define ARROW_IPC_UTIL_H - -#include - -#include "arrow/array.h" -#include "arrow/io/interfaces.h" -#include "arrow/status.h" - -namespace arrow { -namespace ipc { - -// Buffers are padded to 64-byte boundaries (for SIMD) -static constexpr int32_t kArrowAlignment = 64; - -// Tensors are padded to 64-byte boundaries -static constexpr int32_t kTensorAlignment = 64; - -// Align on 8-byte boundaries in IPC -static constexpr int32_t kArrowIpcAlignment = 8; - -static constexpr uint8_t kPaddingBytes[kArrowAlignment] = {0}; - -static inline int64_t PaddedLength(int64_t nbytes, int32_t alignment = kArrowAlignment) { - return ((nbytes + alignment - 1) / alignment) * alignment; -} - -} // namespace ipc -} // namespace arrow - -#endif // ARROW_IPC_UTIL_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/ipc/writer.h b/cpp/thirdparty/knowhere_build/include/arrow/ipc/writer.h deleted file mode 100644 index d2b9faafae..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/ipc/writer.h +++ /dev/null @@ -1,393 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// Implement Arrow streaming binary format - -#ifndef ARROW_IPC_WRITER_H -#define ARROW_IPC_WRITER_H - -#include -#include -#include - -#include "arrow/ipc/message.h" -#include "arrow/result.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Array; -class Buffer; -class MemoryPool; -class RecordBatch; -class Schema; -class Status; -class Table; -class Tensor; -class SparseTensor; - -namespace io { - -class OutputStream; - -} // namespace io - -namespace ipc { - -class DictionaryMemo; - -/// \class RecordBatchWriter -/// \brief Abstract interface for writing a stream of record batches -class ARROW_EXPORT RecordBatchWriter { - public: - virtual ~RecordBatchWriter(); - - /// \brief Write a record batch to the stream - /// - /// \param[in] batch the record batch to write to the stream - /// \param[in] allow_64bit if true, allow field lengths that don't fit - /// in a signed 32-bit int - /// \return Status - virtual Status WriteRecordBatch(const RecordBatch& batch, bool allow_64bit = false) = 0; - - /// \brief Write possibly-chunked table by creating sequence of record batches - /// \param[in] table table to write - /// \return Status - Status WriteTable(const Table& table); - - /// \brief Write Table with a particular chunksize - /// \param[in] table table to write - /// \param[in] max_chunksize maximum chunk size for table chunks - /// \return Status - Status WriteTable(const Table& table, int64_t max_chunksize); - - /// \brief Perform any logic necessary to finish the stream - /// - /// \return Status - virtual Status Close() = 0; - - /// In some cases, writing may require memory allocation. We use the default - /// memory pool, but provide the option to override - /// - /// \param pool the memory pool to use for required allocations - virtual void set_memory_pool(MemoryPool* pool) = 0; -}; - -/// \class RecordBatchStreamWriter -/// \brief Synchronous batch stream writer that writes the Arrow streaming -/// format -class ARROW_EXPORT RecordBatchStreamWriter : public RecordBatchWriter { - public: - ~RecordBatchStreamWriter() override; - - /// Create a new writer from stream sink and schema. User is responsible for - /// closing the actual OutputStream. - /// - /// \param[in] sink output stream to write to - /// \param[in] schema the schema of the record batches to be written - /// \param[out] out the created stream writer - /// \return Status - static Status Open(io::OutputStream* sink, const std::shared_ptr& schema, - std::shared_ptr* out); - - /// Create a new writer from stream sink and schema. User is responsible for - /// closing the actual OutputStream. - /// - /// \param[in] sink output stream to write to - /// \param[in] schema the schema of the record batches to be written - /// \return Result> - static Result> Open( - io::OutputStream* sink, const std::shared_ptr& schema); - - /// \brief Write a record batch to the stream - /// - /// \param[in] batch the record batch to write - /// \param[in] allow_64bit allow array lengths over INT32_MAX - 1 - /// \return Status - Status WriteRecordBatch(const RecordBatch& batch, bool allow_64bit = false) override; - - /// \brief Close the stream by writing a 4-byte int32 0 EOS market - /// \return Status - Status Close() override; - - void set_memory_pool(MemoryPool* pool) override; - - protected: - RecordBatchStreamWriter(); - class ARROW_NO_EXPORT RecordBatchStreamWriterImpl; - std::unique_ptr impl_; -}; - -/// \brief Creates the Arrow record batch file format -/// -/// Implements the random access file format, which structurally is a record -/// batch stream followed by a metadata footer at the end of the file. Magic -/// numbers are written at the start and end of the file -class ARROW_EXPORT RecordBatchFileWriter : public RecordBatchStreamWriter { - public: - ~RecordBatchFileWriter() override; - - /// Create a new writer from stream sink and schema - /// - /// \param[in] sink output stream to write to - /// \param[in] schema the schema of the record batches to be written - /// \param[out] out the created stream writer - /// \return Status - static Status Open(io::OutputStream* sink, const std::shared_ptr& schema, - std::shared_ptr* out); - - /// Create a new writer from stream sink and schema - /// - /// \param[in] sink output stream to write to - /// \param[in] schema the schema of the record batches to be written - /// \return Status - static Result> Open( - io::OutputStream* sink, const std::shared_ptr& schema); - - /// \brief Write a record batch to the file - /// - /// \param[in] batch the record batch to write - /// \param[in] allow_64bit allow array lengths over INT32_MAX - 1 - /// \return Status - Status WriteRecordBatch(const RecordBatch& batch, bool allow_64bit = false) override; - - /// \brief Close the file stream by writing the file footer and magic number - /// \return Status - Status Close() override; - - private: - RecordBatchFileWriter(); - class ARROW_NO_EXPORT RecordBatchFileWriterImpl; - std::unique_ptr file_impl_; -}; - -/// \brief Low-level API for writing a record batch (without schema) to an OutputStream -/// -/// \param[in] batch the record batch to write -/// \param[in] buffer_start_offset the start offset to use in the buffer metadata, -/// generally should be 0 -/// \param[in] dst an OutputStream -/// \param[out] metadata_length the size of the length-prefixed flatbuffer -/// including padding to a 64-byte boundary -/// \param[out] body_length the size of the contiguous buffer block plus -/// \param[in] pool the memory pool to allocate memory from -/// \param[in] max_recursion_depth the maximum permitted nesting schema depth -/// \param[in] allow_64bit permit field lengths exceeding INT32_MAX. May not be -/// readable by other Arrow implementations -/// padding bytes -/// \return Status -/// -/// Write the RecordBatch (collection of equal-length Arrow arrays) to the -/// output stream in a contiguous block. The record batch metadata is written as -/// a flatbuffer (see format/Message.fbs -- the RecordBatch message type) -/// prefixed by its size, followed by each of the memory buffers in the batch -/// written end to end (with appropriate alignment and padding): -/// -/// \code -/// -/// \endcode -/// -/// Finally, the absolute offsets (relative to the start of the output stream) -/// to the end of the body and end of the metadata / data header (suffixed by -/// the header size) is returned in out-variables -ARROW_EXPORT -Status WriteRecordBatch(const RecordBatch& batch, int64_t buffer_start_offset, - io::OutputStream* dst, int32_t* metadata_length, - int64_t* body_length, MemoryPool* pool, - int max_recursion_depth = kMaxNestingDepth, - bool allow_64bit = false); - -/// \brief Serialize record batch as encapsulated IPC message in a new buffer -/// -/// \param[in] batch the record batch -/// \param[in] pool a MemoryPool to allocate memory from -/// \param[out] out the serialized message -/// \return Status -ARROW_EXPORT -Status SerializeRecordBatch(const RecordBatch& batch, MemoryPool* pool, - std::shared_ptr* out); - -/// \brief Write record batch to OutputStream -/// -/// \param[in] batch the record batch to write -/// \param[in] pool a MemoryPool to use for temporary allocations, if needed -/// \param[in] out the OutputStream to write the output to -/// \return Status -/// -/// If writing to pre-allocated memory, you can use -/// arrow::ipc::GetRecordBatchSize to compute how much space is required -ARROW_EXPORT -Status SerializeRecordBatch(const RecordBatch& batch, MemoryPool* pool, - io::OutputStream* out); - -/// \brief Serialize schema as encapsulated IPC message -/// -/// \param[in] schema the schema to write -/// \param[in] dictionary_memo a DictionaryMemo for recording dictionary ids -/// \param[in] pool a MemoryPool to allocate memory from -/// \param[out] out the serialized schema -/// \return Status -ARROW_EXPORT -Status SerializeSchema(const Schema& schema, DictionaryMemo* dictionary_memo, - MemoryPool* pool, std::shared_ptr* out); - -/// \brief Write multiple record batches to OutputStream, including schema -/// \param[in] batches a vector of batches. Must all have same schema -/// \param[out] dst an OutputStream -/// \return Status -ARROW_EXPORT -Status WriteRecordBatchStream(const std::vector>& batches, - io::OutputStream* dst); - -/// \brief Compute the number of bytes needed to write a record batch including metadata -/// -/// \param[in] batch the record batch to write -/// \param[out] size the size of the complete encapsulated message -/// \return Status -ARROW_EXPORT -Status GetRecordBatchSize(const RecordBatch& batch, int64_t* size); - -/// \brief Compute the number of bytes needed to write a tensor including metadata -/// -/// \param[in] tensor the tenseor to write -/// \param[out] size the size of the complete encapsulated message -/// \return Status -ARROW_EXPORT -Status GetTensorSize(const Tensor& tensor, int64_t* size); - -/// \brief EXPERIMENTAL: Convert arrow::Tensor to a Message with minimal memory -/// allocation -/// -/// \param[in] tensor the Tensor to write -/// \param[in] pool MemoryPool to allocate space for metadata -/// \param[out] out the resulting Message -/// \return Status -ARROW_EXPORT -Status GetTensorMessage(const Tensor& tensor, MemoryPool* pool, - std::unique_ptr* out); - -/// \brief Write arrow::Tensor as a contiguous message. -/// -/// The metadata and body are written assuming 64-byte alignment. It is the -/// user's responsibility to ensure that the OutputStream has been aligned -/// to a 64-byte multiple before writing the message. -/// -/// The message is written out as followed: -/// \code -/// -/// \endcode -/// -/// \param[in] tensor the Tensor to write -/// \param[in] dst the OutputStream to write to -/// \param[out] metadata_length the actual metadata length, including padding -/// \param[out] body_length the acutal message body length -/// \return Status -ARROW_EXPORT -Status WriteTensor(const Tensor& tensor, io::OutputStream* dst, int32_t* metadata_length, - int64_t* body_length); - -// \brief EXPERIMENTAL: Write arrow::SparseTensor as a contiguous mesasge. The metadata, -// sparse index, and body are written assuming 64-byte alignment. It is the -// user's responsibility to ensure that the OutputStream has been aligned -// to a 64-byte multiple before writing the message. -// -// \param[in] tensor the SparseTensor to write -// \param[in] dst the OutputStream to write to -// \param[out] metadata_length the actual metadata length, including padding -// \param[out] body_length the actual message body length -ARROW_EXPORT -Status WriteSparseTensor(const SparseTensor& sparse_tensor, io::OutputStream* dst, - int32_t* metadata_length, int64_t* body_length, - MemoryPool* pool); - -namespace internal { - -// These internal APIs may change without warning or deprecation - -// Intermediate data structure with metadata header, and zero or more buffers -// for the message body. -struct IpcPayload { - Message::Type type = Message::NONE; - std::shared_ptr metadata; - std::vector> body_buffers; - int64_t body_length = 0; -}; - -class ARROW_EXPORT IpcPayloadWriter { - public: - virtual ~IpcPayloadWriter(); - - // Default implementation is a no-op - virtual Status Start(); - - virtual Status WritePayload(const IpcPayload& payload) = 0; - - virtual Status Close() = 0; -}; - -/// Create a new RecordBatchWriter from IpcPayloadWriter and schema. -/// -/// \param[in] sink the IpcPayloadWriter to write to -/// \param[in] schema the schema of the record batches to be written -/// \param[out] out the created RecordBatchWriter -/// \return Status -ARROW_EXPORT -Status OpenRecordBatchWriter(std::unique_ptr sink, - const std::shared_ptr& schema, - std::unique_ptr* out); - -/// Create a new RecordBatchWriter from IpcPayloadWriter and schema. -/// -/// \param[in] sink the IpcPayloadWriter to write to -/// \param[in] schema the schema of the record batches to be written -/// \return Result> -ARROW_EXPORT -Result> OpenRecordBatchWriter( - std::unique_ptr sink, const std::shared_ptr& schema); - -/// \brief Compute IpcPayload for the given schema -/// \param[in] schema the Schema that is being serialized -/// \param[in,out] dictionary_memo class to populate with assigned dictionary ids -/// \param[out] out the returned vector of IpcPayloads -/// \return Status -ARROW_EXPORT -Status GetSchemaPayload(const Schema& schema, DictionaryMemo* dictionary_memo, - IpcPayload* out); - -/// \brief Compute IpcPayload for a dictionary -/// \param[in] id the dictionary id -/// \param[in] dictionary the dictionary values -/// \param[out] payload the output IpcPayload -/// \return Status -ARROW_EXPORT -Status GetDictionaryPayload(int64_t id, const std::shared_ptr& dictionary, - MemoryPool* pool, IpcPayload* payload); - -/// \brief Compute IpcPayload for the given record batch -/// \param[in] batch the RecordBatch that is being serialized -/// \param[in,out] pool for any required temporary memory allocations -/// \param[out] out the returned IpcPayload -/// \return Status -ARROW_EXPORT -Status GetRecordBatchPayload(const RecordBatch& batch, MemoryPool* pool, IpcPayload* out); - -} // namespace internal - -} // namespace ipc -} // namespace arrow - -#endif // ARROW_IPC_WRITER_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/json/api.h b/cpp/thirdparty/knowhere_build/include/arrow/json/api.h deleted file mode 100644 index 47b56684b5..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/json/api.h +++ /dev/null @@ -1,21 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include "arrow/json/options.h" -#include "arrow/json/reader.h" diff --git a/cpp/thirdparty/knowhere_build/include/arrow/json/chunked-builder.h b/cpp/thirdparty/knowhere_build/include/arrow/json/chunked-builder.h deleted file mode 100644 index b2cfbefdf4..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/json/chunked-builder.h +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include - -#include "arrow/status.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -namespace internal { -class TaskGroup; -} // namespace internal - -class Array; -class MemoryPool; -class DataType; -class Field; -class ChunkedArray; - -namespace json { - -class PromotionGraph; - -class ARROW_EXPORT ChunkedArrayBuilder { - public: - virtual ~ChunkedArrayBuilder() = default; - - /// Spawn a task that will try to convert and insert the given JSON block - virtual void Insert(int64_t block_index, - const std::shared_ptr& unconverted_field, - const std::shared_ptr& unconverted) = 0; - - /// Return the final chunked array. - /// Every chunk must be inserted before this is called! - virtual Status Finish(std::shared_ptr* out) = 0; - - /// Finish current task group and substitute a new one - virtual Status ReplaceTaskGroup( - const std::shared_ptr& task_group) = 0; - - protected: - explicit ChunkedArrayBuilder(const std::shared_ptr& task_group) - : task_group_(task_group) {} - - std::shared_ptr task_group_; -}; - -/// create a chunked builder -/// -/// if unexpected fields and promotion need to be handled, promotion_graph must be -/// non-null -ARROW_EXPORT Status MakeChunkedArrayBuilder( - const std::shared_ptr& task_group, MemoryPool* pool, - const PromotionGraph* promotion_graph, const std::shared_ptr& type, - std::unique_ptr* out); - -} // namespace json -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/json/chunker.h b/cpp/thirdparty/knowhere_build/include/arrow/json/chunker.h deleted file mode 100644 index 0f94d81afd..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/json/chunker.h +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include - -#include "arrow/status.h" -#include "arrow/util/macros.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Buffer; - -namespace json { - -struct ParseOptions; - -/// \class Chunker -/// \brief A reusable block-based chunker for JSON data -/// -/// The chunker takes a block of JSON data and finds a suitable place -/// to cut it up without splitting an object. -class ARROW_EXPORT Chunker { - public: - virtual ~Chunker() = default; - - /// \brief Carve up a chunk in a block of data to contain only whole objects - /// \param[in] block json data to be chunked - /// \param[out] whole subrange of block containing whole json objects - /// \param[out] partial subrange of block a partial json object - virtual Status Process(const std::shared_ptr& block, - std::shared_ptr* whole, - std::shared_ptr* partial) = 0; - - /// \brief Carve the completion of a partial object out of a block - /// \param[in] partial incomplete json object - /// \param[in] block json data - /// \param[out] completion subrange of block containing the completion of partial - /// \param[out] rest subrange of block containing what completion does not cover - virtual Status ProcessWithPartial(const std::shared_ptr& partial, - const std::shared_ptr& block, - std::shared_ptr* completion, - std::shared_ptr* rest) = 0; - - static std::unique_ptr Make(const ParseOptions& options); - - protected: - Chunker() = default; - ARROW_DISALLOW_COPY_AND_ASSIGN(Chunker); -}; - -} // namespace json -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/json/converter.h b/cpp/thirdparty/knowhere_build/include/arrow/json/converter.h deleted file mode 100644 index 9a812dd3c3..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/json/converter.h +++ /dev/null @@ -1,94 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include - -#include "arrow/status.h" -#include "arrow/util/macros.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Array; -class DataType; -class Field; -class MemoryPool; - -namespace json { - -/// \brief interface for conversion of Arrays -/// -/// Converters are not required to be correct for arbitrary input- only -/// for unconverted arrays emitted by a corresponding parser. -class ARROW_EXPORT Converter { - public: - virtual ~Converter() = default; - - /// convert an array - /// on failure, this converter may be promoted to another converter which - /// *can* convert the given input. - virtual Status Convert(const std::shared_ptr& in, - std::shared_ptr* out) = 0; - - std::shared_ptr out_type() const { return out_type_; } - - MemoryPool* pool() { return pool_; } - - protected: - ARROW_DISALLOW_COPY_AND_ASSIGN(Converter); - - Converter(MemoryPool* pool, const std::shared_ptr& out_type) - : pool_(pool), out_type_(out_type) {} - - MemoryPool* pool_; - std::shared_ptr out_type_; -}; - -/// \brief produce a single converter to the specified out_type -ARROW_EXPORT Status MakeConverter(const std::shared_ptr& out_type, - MemoryPool* pool, std::shared_ptr* out); - -class ARROW_EXPORT PromotionGraph { - public: - virtual ~PromotionGraph() = default; - - /// \brief produce a valid field which will be inferred as null - virtual std::shared_ptr Null(const std::string& name) const = 0; - - /// \brief given an unexpected field encountered during parsing, return a type to which - /// it may be convertible (may return null if none is available) - virtual std::shared_ptr Infer( - const std::shared_ptr& unexpected_field) const = 0; - - /// \brief given a type to which conversion failed, return a promoted type to which - /// conversion may succeed (may return null if none is available) - virtual std::shared_ptr Promote( - const std::shared_ptr& failed, - const std::shared_ptr& unexpected_field) const = 0; - - protected: - ARROW_DISALLOW_COPY_AND_ASSIGN(PromotionGraph); - PromotionGraph() = default; -}; - -ARROW_EXPORT const PromotionGraph* GetPromotionGraph(); - -} // namespace json -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/json/options.h b/cpp/thirdparty/knowhere_build/include/arrow/json/options.h deleted file mode 100644 index 8d27faabea..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/json/options.h +++ /dev/null @@ -1,63 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include - -#include "arrow/util/visibility.h" - -namespace arrow { - -class DataType; -class Schema; - -namespace json { - -enum class UnexpectedFieldBehavior : char { Ignore, Error, InferType }; - -struct ARROW_EXPORT ParseOptions { - // Parsing options - - // Optional explicit schema (no type inference, ignores other fields) - std::shared_ptr explicit_schema; - - // Whether objects may be printed across multiple lines (for example pretty printed) - // NB: if false, input must end with an empty line - bool newlines_in_values = false; - - // How should parse handle fields outside the explicit_schema? - UnexpectedFieldBehavior unexpected_field_behavior = UnexpectedFieldBehavior::InferType; - - static ParseOptions Defaults(); -}; - -struct ARROW_EXPORT ReadOptions { - // Reader options - - // Whether to use the global CPU thread pool - bool use_threads = true; - // Block size we request from the IO layer; also determines the size of - // chunks when use_threads is true - int32_t block_size = 1 << 20; // 1 MB - - static ReadOptions Defaults(); -}; - -} // namespace json -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/json/parser.h b/cpp/thirdparty/knowhere_build/include/arrow/json/parser.h deleted file mode 100644 index ec12eeec37..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/json/parser.h +++ /dev/null @@ -1,96 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include - -#include "arrow/json/options.h" -#include "arrow/status.h" -#include "arrow/util/key_value_metadata.h" -#include "arrow/util/macros.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Array; -class Buffer; -class MemoryPool; -class KeyValueMetadata; -class ResizableBuffer; - -namespace json { - -struct Kind { - enum type : uint8_t { kNull, kBoolean, kNumber, kString, kArray, kObject }; - - static const std::string& Name(Kind::type); - - static const std::shared_ptr& Tag(Kind::type); - - static Kind::type FromTag(const std::shared_ptr& tag); - - static Status ForType(const DataType& type, Kind::type* kind); -}; - -constexpr int32_t kMaxParserNumRows = 100000; - -/// \class BlockParser -/// \brief A reusable block-based parser for JSON data -/// -/// The parser takes a block of newline delimited JSON data and extracts Arrays -/// of unconverted strings which can be fed to a Converter to obtain a usable Array. -/// -/// Note that in addition to parse errors (such as malformed JSON) some conversion -/// errors are caught at parse time: -/// - A null value in non-nullable column -/// - Change in the JSON kind of a column. For example, if an explicit schema is provided -/// which stipulates that field "a" is integral, a row of {"a": "not a number"} will -/// result in an error. This also applies to fields outside an explicit schema. -class ARROW_EXPORT BlockParser { - public: - virtual ~BlockParser() = default; - - /// \brief Reserve storage for scalars parsed from a block of json - virtual Status ReserveScalarStorage(int64_t nbytes) = 0; - - /// \brief Parse a block of data - virtual Status Parse(const std::shared_ptr& json) = 0; - - /// \brief Extract parsed data - virtual Status Finish(std::shared_ptr* parsed) = 0; - - /// \brief Return the number of parsed rows - int32_t num_rows() const { return num_rows_; } - - static Status Make(MemoryPool* pool, const ParseOptions& options, - std::unique_ptr* out); - - static Status Make(const ParseOptions& options, std::unique_ptr* out); - - protected: - ARROW_DISALLOW_COPY_AND_ASSIGN(BlockParser); - - explicit BlockParser(MemoryPool* pool) : pool_(pool) {} - - MemoryPool* pool_; - int32_t num_rows_ = 0; -}; - -} // namespace json -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/json/rapidjson-defs.h b/cpp/thirdparty/knowhere_build/include/arrow/json/rapidjson-defs.h deleted file mode 100644 index 68dd0be638..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/json/rapidjson-defs.h +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// Include this file before including any RapidJSON headers. - -#define RAPIDJSON_HAS_STDSTRING 1 -#define RAPIDJSON_HAS_CXX11_RVALUE_REFS 1 -#define RAPIDJSON_HAS_CXX11_RANGE_FOR 1 - -// rapidjson will be defined in namespace arrow::rapidjson -#define RAPIDJSON_NAMESPACE arrow::rapidjson -#define RAPIDJSON_NAMESPACE_BEGIN \ - namespace arrow { \ - namespace rapidjson { -#define RAPIDJSON_NAMESPACE_END \ - } \ - } - -#include "arrow/util/sse-util.h" - -// enable SIMD whitespace skipping, if available -#if defined(ARROW_HAVE_SSE2) -#define RAPIDJSON_SSE2 1 -#define ARROW_RAPIDJSON_SKIP_WHITESPACE_SIMD 1 -#endif - -#if defined(ARROW_HAVE_SSE4_2) -#define RAPIDJSON_SSE42 1 -#define ARROW_RAPIDJSON_SKIP_WHITESPACE_SIMD 1 -#endif diff --git a/cpp/thirdparty/knowhere_build/include/arrow/json/reader.h b/cpp/thirdparty/knowhere_build/include/arrow/json/reader.h deleted file mode 100644 index 51a3473a04..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/json/reader.h +++ /dev/null @@ -1,62 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include - -#include "arrow/json/options.h" -#include "arrow/status.h" -#include "arrow/util/macros.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Buffer; -class MemoryPool; -class Table; -class RecordBatch; -class Array; -class DataType; - -namespace io { -class InputStream; -} // namespace io - -namespace json { - -class ARROW_EXPORT TableReader { - public: - virtual ~TableReader() = default; - - virtual Status Read(std::shared_ptr
* out) = 0; - - static Status Make(MemoryPool* pool, std::shared_ptr input, - const ReadOptions&, const ParseOptions&, - std::shared_ptr* out); -}; - -ARROW_EXPORT Status ParseOne(ParseOptions options, std::shared_ptr json, - std::shared_ptr* out); - -/// \brief convert an Array produced by BlockParser into an Array of out_type -ARROW_EXPORT Status Convert(const std::shared_ptr& out_type, - const std::shared_ptr& in, - std::shared_ptr* out); - -} // namespace json -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/json/test-common.h b/cpp/thirdparty/knowhere_build/include/arrow/json/test-common.h deleted file mode 100644 index 2905ae9556..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/json/test-common.h +++ /dev/null @@ -1,183 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#include -#include -#include -#include - -#include "arrow/json/rapidjson-defs.h" -#include "rapidjson/document.h" -#include "rapidjson/prettywriter.h" -#include "rapidjson/reader.h" -#include "rapidjson/writer.h" - -#include "arrow/io/memory.h" -#include "arrow/json/converter.h" -#include "arrow/json/options.h" -#include "arrow/json/parser.h" -#include "arrow/testing/gtest_util.h" -#include "arrow/type.h" -#include "arrow/util/string_view.h" -#include "arrow/visitor_inline.h" - -namespace arrow { -namespace json { - -namespace rj = arrow::rapidjson; - -using rj::StringBuffer; -using util::string_view; -using Writer = rj::Writer; - -inline static Status OK(bool ok) { return ok ? Status::OK() : Status::Invalid(""); } - -template -inline static Status Generate(const std::shared_ptr& type, Engine& e, - Writer* writer); - -template -inline static Status Generate(const std::vector>& fields, - Engine& e, Writer* writer); - -template -inline static Status Generate(const std::shared_ptr& schm, Engine& e, - Writer* writer) { - return Generate(schm->fields(), e, writer); -} - -template -struct GenerateImpl { - Status Visit(const BooleanType&) { - return OK(writer.Bool(std::uniform_int_distribution{}(e)&1)); - } - template - Status Visit(T const&, enable_if_unsigned_integer* = nullptr) { - auto val = std::uniform_int_distribution<>{}(e); - return OK(writer.Uint64(static_cast(val))); - } - template - Status Visit(T const&, enable_if_signed_integer* = nullptr) { - auto val = std::uniform_int_distribution<>{}(e); - return OK(writer.Int64(static_cast(val))); - } - template - Status Visit(T const&, enable_if_floating_point* = nullptr) { - auto val = std::normal_distribution{0, 1 << 10}(e); - return OK(writer.Double(val)); - } - Status Visit(HalfFloatType const&) { - auto val = std::normal_distribution{0, 1 << 10}(e); - return OK(writer.Double(val)); - } - template - Status Visit(T const&, enable_if_binary* = nullptr) { - auto size = std::poisson_distribution<>{4}(e); - std::uniform_int_distribution gen_char(32, 127); // FIXME generate UTF8 - std::string s(size, '\0'); - for (char& ch : s) ch = static_cast(gen_char(e)); - return OK(writer.String(s.c_str())); - } - template - Status Visit( - T const& t, typename std::enable_if::value>::type* = nullptr, - typename std::enable_if::value>::type* = nullptr) { - return Status::Invalid("can't generate a value of type " + t.name()); - } - Status Visit(const ListType& t) { - auto size = std::poisson_distribution<>{4}(e); - writer.StartArray(); - for (int i = 0; i < size; ++i) RETURN_NOT_OK(Generate(t.value_type(), e, &writer)); - return OK(writer.EndArray(size)); - } - Status Visit(const StructType& t) { return Generate(t.children(), e, &writer); } - Engine& e; - rj::Writer& writer; -}; - -template -inline static Status Generate(const std::shared_ptr& type, Engine& e, - Writer* writer) { - if (std::uniform_real_distribution<>{0, 1}(e) < .2) { - // one out of 5 chance of null, anywhere - writer->Null(); - return Status::OK(); - } - GenerateImpl visitor = {e, *writer}; - return VisitTypeInline(*type, &visitor); -} - -template -inline static Status Generate(const std::vector>& fields, - Engine& e, Writer* writer) { - RETURN_NOT_OK(OK(writer->StartObject())); - for (const auto& f : fields) { - writer->Key(f->name().c_str()); - RETURN_NOT_OK(Generate(f->type(), e, writer)); - } - return OK(writer->EndObject(static_cast(fields.size()))); -} - -inline static Status MakeStream(string_view src_str, - std::shared_ptr* out) { - auto src = std::make_shared(src_str); - *out = std::make_shared(src); - return Status::OK(); -} - -// scalar values (numbers and strings) are parsed into a -// dictionary. This can be decoded for ease of comparison -inline static Status DecodeStringDictionary(const DictionaryArray& dict_array, - std::shared_ptr* decoded) { - const StringArray& dict = static_cast(*dict_array.dictionary()); - const Int32Array& indices = static_cast(*dict_array.indices()); - StringBuilder builder; - RETURN_NOT_OK(builder.Resize(indices.length())); - for (int64_t i = 0; i < indices.length(); ++i) { - if (indices.IsNull(i)) { - builder.UnsafeAppendNull(); - continue; - } - auto value = dict.GetView(indices.GetView(i)); - RETURN_NOT_OK(builder.ReserveData(value.size())); - builder.UnsafeAppend(value); - } - return builder.Finish(decoded); -} - -inline static Status ParseFromString(ParseOptions options, string_view src_str, - std::shared_ptr* parsed) { - auto src = std::make_shared(src_str); - std::unique_ptr parser; - RETURN_NOT_OK(BlockParser::Make(options, &parser)); - RETURN_NOT_OK(parser->Parse(src)); - return parser->Finish(parsed); -} - -static inline std::string PrettyPrint(string_view one_line) { - rj::Document document; - - // Must pass size to avoid ASAN issues. - document.Parse(one_line.data(), one_line.size()); - rj::StringBuffer sb; - rj::PrettyWriter writer(sb); - document.Accept(writer); - return sb.GetString(); -} - -} // namespace json -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/memory_pool-test.h b/cpp/thirdparty/knowhere_build/include/arrow/memory_pool-test.h deleted file mode 100644 index 3eca585a1b..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/memory_pool-test.h +++ /dev/null @@ -1,90 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#include -#include -#include -#include - -#include - -#include "arrow/memory_pool.h" -#include "arrow/status.h" -#include "arrow/testing/gtest_util.h" - -namespace arrow { - -class TestMemoryPoolBase : public ::testing::Test { - public: - virtual ::arrow::MemoryPool* memory_pool() = 0; - - void TestMemoryTracking() { - auto pool = memory_pool(); - - uint8_t* data; - ASSERT_OK(pool->Allocate(100, &data)); - EXPECT_EQ(static_cast(0), reinterpret_cast(data) % 64); - ASSERT_EQ(100, pool->bytes_allocated()); - - uint8_t* data2; - ASSERT_OK(pool->Allocate(27, &data2)); - EXPECT_EQ(static_cast(0), reinterpret_cast(data2) % 64); - ASSERT_EQ(127, pool->bytes_allocated()); - - pool->Free(data, 100); - ASSERT_EQ(27, pool->bytes_allocated()); - pool->Free(data2, 27); - ASSERT_EQ(0, pool->bytes_allocated()); - } - - void TestOOM() { - auto pool = memory_pool(); - - uint8_t* data; - int64_t to_alloc = std::min(std::numeric_limits::max(), - std::numeric_limits::max()); - // subtract 63 to prevent overflow after the size is aligned - to_alloc -= 63; - ASSERT_RAISES(OutOfMemory, pool->Allocate(to_alloc, &data)); - } - - void TestReallocate() { - auto pool = memory_pool(); - - uint8_t* data; - ASSERT_OK(pool->Allocate(10, &data)); - ASSERT_EQ(10, pool->bytes_allocated()); - data[0] = 35; - data[9] = 12; - - // Expand - ASSERT_OK(pool->Reallocate(10, 20, &data)); - ASSERT_EQ(data[9], 12); - ASSERT_EQ(20, pool->bytes_allocated()); - - // Shrink - ASSERT_OK(pool->Reallocate(20, 5, &data)); - ASSERT_EQ(data[0], 35); - ASSERT_EQ(5, pool->bytes_allocated()); - - // Free - pool->Free(data, 5); - ASSERT_EQ(0, pool->bytes_allocated()); - } -}; - -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/memory_pool.h b/cpp/thirdparty/knowhere_build/include/arrow/memory_pool.h deleted file mode 100644 index 60643c387f..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/memory_pool.h +++ /dev/null @@ -1,155 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_MEMORY_POOL_H -#define ARROW_MEMORY_POOL_H - -#include -#include -#include - -#include "arrow/status.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -namespace internal { - -/////////////////////////////////////////////////////////////////////// -// Helper tracking memory statistics - -class MemoryPoolStats { - public: - MemoryPoolStats() : bytes_allocated_(0), max_memory_(0) {} - - int64_t max_memory() const { return max_memory_.load(); } - - int64_t bytes_allocated() const { return bytes_allocated_.load(); } - - inline void UpdateAllocatedBytes(int64_t diff) { - auto allocated = bytes_allocated_.fetch_add(diff) + diff; - // "maximum" allocated memory is ill-defined in multi-threaded code, - // so don't try to be too rigorous here - if (diff > 0 && allocated > max_memory_) { - max_memory_ = allocated; - } - } - - protected: - std::atomic bytes_allocated_; - std::atomic max_memory_; -}; - -} // namespace internal - -/// Base class for memory allocation. -/// -/// Besides tracking the number of allocated bytes, the allocator also should -/// take care of the required 64-byte alignment. -class ARROW_EXPORT MemoryPool { - public: - virtual ~MemoryPool(); - - /// \brief EXPERIMENTAL. Create a new instance of the default MemoryPool - static std::unique_ptr CreateDefault(); - - /// Allocate a new memory region of at least size bytes. - /// - /// The allocated region shall be 64-byte aligned. - virtual Status Allocate(int64_t size, uint8_t** out) = 0; - - /// Resize an already allocated memory section. - /// - /// As by default most default allocators on a platform don't support aligned - /// reallocation, this function can involve a copy of the underlying data. - virtual Status Reallocate(int64_t old_size, int64_t new_size, uint8_t** ptr) = 0; - - /// Free an allocated region. - /// - /// @param buffer Pointer to the start of the allocated memory region - /// @param size Allocated size located at buffer. An allocator implementation - /// may use this for tracking the amount of allocated bytes as well as for - /// faster deallocation if supported by its backend. - virtual void Free(uint8_t* buffer, int64_t size) = 0; - - /// The number of bytes that were allocated and not yet free'd through - /// this allocator. - virtual int64_t bytes_allocated() const = 0; - - /// Return peak memory allocation in this memory pool - /// - /// \return Maximum bytes allocated. If not known (or not implemented), - /// returns -1 - virtual int64_t max_memory() const; - - protected: - MemoryPool(); -}; - -class ARROW_EXPORT LoggingMemoryPool : public MemoryPool { - public: - explicit LoggingMemoryPool(MemoryPool* pool); - ~LoggingMemoryPool() override = default; - - Status Allocate(int64_t size, uint8_t** out) override; - Status Reallocate(int64_t old_size, int64_t new_size, uint8_t** ptr) override; - - void Free(uint8_t* buffer, int64_t size) override; - - int64_t bytes_allocated() const override; - - int64_t max_memory() const override; - - private: - MemoryPool* pool_; -}; - -/// Derived class for memory allocation. -/// -/// Tracks the number of bytes and maximum memory allocated through its direct -/// calls. Actual allocation is delegated to MemoryPool class. -class ARROW_EXPORT ProxyMemoryPool : public MemoryPool { - public: - explicit ProxyMemoryPool(MemoryPool* pool); - ~ProxyMemoryPool() override; - - Status Allocate(int64_t size, uint8_t** out) override; - Status Reallocate(int64_t old_size, int64_t new_size, uint8_t** ptr) override; - - void Free(uint8_t* buffer, int64_t size) override; - - int64_t bytes_allocated() const override; - - int64_t max_memory() const override; - - private: - class ProxyMemoryPoolImpl; - std::unique_ptr impl_; -}; - -/// Return the process-wide default memory pool. -ARROW_EXPORT MemoryPool* default_memory_pool(); - -#ifdef ARROW_NO_DEFAULT_MEMORY_POOL -#define ARROW_MEMORY_POOL_DEFAULT -#else -#define ARROW_MEMORY_POOL_DEFAULT = default_memory_pool() -#endif - -} // namespace arrow - -#endif // ARROW_MEMORY_POOL_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/pretty_print.h b/cpp/thirdparty/knowhere_build/include/arrow/pretty_print.h deleted file mode 100644 index 9c2708f16e..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/pretty_print.h +++ /dev/null @@ -1,112 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_PRETTY_PRINT_H -#define ARROW_PRETTY_PRINT_H - -#include -#include - -#include "arrow/util/visibility.h" - -namespace arrow { - -class Array; -class Column; -class ChunkedArray; -class RecordBatch; -class Schema; -class Status; -class Table; - -struct PrettyPrintOptions { - PrettyPrintOptions(int indent_arg, int window_arg = 10, int indent_size_arg = 2, - std::string null_rep_arg = "null", bool skip_new_lines_arg = false) - : indent(indent_arg), - indent_size(indent_size_arg), - window(window_arg), - null_rep(null_rep_arg), - skip_new_lines(skip_new_lines_arg) {} - - /// Number of spaces to shift entire formatted object to the right - int indent; - - /// Size of internal indents - int indent_size; - - /// Maximum number of elements to show at the beginning and at the end. - int window; - - /// String to use for representing a null value, defaults to "null" - std::string null_rep; - - /// Skip new lines between elements, defaults to false - bool skip_new_lines; -}; - -/// \brief Print human-readable representation of RecordBatch -ARROW_EXPORT -Status PrettyPrint(const RecordBatch& batch, int indent, std::ostream* sink); - -/// \brief Print human-readable representation of Table -ARROW_EXPORT -Status PrettyPrint(const Table& table, const PrettyPrintOptions& options, - std::ostream* sink); - -/// \brief Print human-readable representation of Array -ARROW_EXPORT -Status PrettyPrint(const Array& arr, int indent, std::ostream* sink); - -/// \brief Print human-readable representation of Array -ARROW_EXPORT -Status PrettyPrint(const Array& arr, const PrettyPrintOptions& options, - std::ostream* sink); - -/// \brief Print human-readable representation of Array -ARROW_EXPORT -Status PrettyPrint(const Array& arr, const PrettyPrintOptions& options, - std::string* result); - -/// \brief Print human-readable representation of ChunkedArray -ARROW_EXPORT -Status PrettyPrint(const ChunkedArray& chunked_arr, const PrettyPrintOptions& options, - std::ostream* sink); - -/// \brief Print human-readable representation of ChunkedArray -ARROW_EXPORT -Status PrettyPrint(const ChunkedArray& chunked_arr, const PrettyPrintOptions& options, - std::string* result); - -/// \brief Print human-readable representation of Column -ARROW_EXPORT -Status PrettyPrint(const Column& column, const PrettyPrintOptions& options, - std::ostream* sink); - -ARROW_EXPORT -Status PrettyPrint(const Schema& schema, const PrettyPrintOptions& options, - std::ostream* sink); - -ARROW_EXPORT -Status PrettyPrint(const Schema& schema, const PrettyPrintOptions& options, - std::string* result); - -ARROW_EXPORT -Status DebugPrint(const Array& arr, int indent); - -} // namespace arrow - -#endif // ARROW_PRETTY_PRINT_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/record_batch.h b/cpp/thirdparty/knowhere_build/include/arrow/record_batch.h deleted file mode 100644 index 2d0538db4a..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/record_batch.h +++ /dev/null @@ -1,188 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include -#include -#include - -#include "arrow/type_fwd.h" -#include "arrow/util/iterator.h" -#include "arrow/util/macros.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -/// \class RecordBatch -/// \brief Collection of equal-length arrays matching a particular Schema -/// -/// A record batch is table-like data structure that is semantically a sequence -/// of fields, each a contiguous Arrow array -class ARROW_EXPORT RecordBatch { - public: - virtual ~RecordBatch() = default; - - /// \param[in] schema The record batch schema - /// \param[in] num_rows length of fields in the record batch. Each array - /// should have the same length as num_rows - /// \param[in] columns the record batch fields as vector of arrays - static std::shared_ptr Make( - const std::shared_ptr& schema, int64_t num_rows, - const std::vector>& columns); - - /// \brief Move-based constructor for a vector of Array instances - static std::shared_ptr Make(const std::shared_ptr& schema, - int64_t num_rows, - std::vector>&& columns); - - /// \brief Construct record batch from vector of internal data structures - /// \since 0.5.0 - /// - /// This class is only provided with an rvalue-reference for the input data, - /// and is intended for internal use, or advanced users. - /// - /// \param schema the record batch schema - /// \param num_rows the number of semantic rows in the record batch. This - /// should be equal to the length of each field - /// \param columns the data for the batch's columns - static std::shared_ptr Make( - const std::shared_ptr& schema, int64_t num_rows, - std::vector>&& columns); - - /// \brief Construct record batch by copying vector of array data - /// \since 0.5.0 - static std::shared_ptr Make( - const std::shared_ptr& schema, int64_t num_rows, - const std::vector>& columns); - - /// \brief Determine if two record batches are exactly equal - /// \return true if batches are equal - bool Equals(const RecordBatch& other) const; - - /// \brief Determine if two record batches are approximately equal - bool ApproxEquals(const RecordBatch& other) const; - - // \return the table's schema - /// \return true if batches are equal - std::shared_ptr schema() const { return schema_; } - - /// \brief Retrieve an array from the record batch - /// \param[in] i field index, does not boundscheck - /// \return an Array object - virtual std::shared_ptr column(int i) const = 0; - - /// \brief Retrieve an array from the record batch - /// \param[in] name field name - /// \return an Array or null if no field was found - std::shared_ptr GetColumnByName(const std::string& name) const; - - /// \brief Retrieve an array's internaldata from the record batch - /// \param[in] i field index, does not boundscheck - /// \return an internal ArrayData object - virtual std::shared_ptr column_data(int i) const = 0; - - /// \brief Add column to the record batch, producing a new RecordBatch - /// - /// \param[in] i field index, which will be boundschecked - /// \param[in] field field to be added - /// \param[in] column column to be added - /// \param[out] out record batch with column added - virtual Status AddColumn(int i, const std::shared_ptr& field, - const std::shared_ptr& column, - std::shared_ptr* out) const = 0; - - /// \brief Add new nullable column to the record batch, producing a new - /// RecordBatch. - /// - /// For non-nullable columns, use the Field-based version of this method. - /// - /// \param[in] i field index, which will be boundschecked - /// \param[in] field_name name of field to be added - /// \param[in] column column to be added - /// \param[out] out record batch with column added - virtual Status AddColumn(int i, const std::string& field_name, - const std::shared_ptr& column, - std::shared_ptr* out) const; - - /// \brief Remove column from the record batch, producing a new RecordBatch - /// - /// \param[in] i field index, does boundscheck - /// \param[out] out record batch with column removed - virtual Status RemoveColumn(int i, std::shared_ptr* out) const = 0; - - virtual std::shared_ptr ReplaceSchemaMetadata( - const std::shared_ptr& metadata) const = 0; - - /// \brief Name in i-th column - const std::string& column_name(int i) const; - - /// \return the number of columns in the table - int num_columns() const; - - /// \return the number of rows (the corresponding length of each column) - int64_t num_rows() const { return num_rows_; } - - /// \brief Slice each of the arrays in the record batch - /// \param[in] offset the starting offset to slice, through end of batch - /// \return new record batch - virtual std::shared_ptr Slice(int64_t offset) const; - - /// \brief Slice each of the arrays in the record batch - /// \param[in] offset the starting offset to slice - /// \param[in] length the number of elements to slice from offset - /// \return new record batch - virtual std::shared_ptr Slice(int64_t offset, int64_t length) const = 0; - - /// \brief Check for schema or length inconsistencies - /// \return Status - virtual Status Validate() const; - - protected: - RecordBatch(const std::shared_ptr& schema, int64_t num_rows); - - std::shared_ptr schema_; - int64_t num_rows_; - - private: - ARROW_DISALLOW_COPY_AND_ASSIGN(RecordBatch); -}; - -/// \brief Abstract interface for reading stream of record batches -class ARROW_EXPORT RecordBatchReader { - public: - virtual ~RecordBatchReader(); - - /// \return the shared schema of the record batches in the stream - virtual std::shared_ptr schema() const = 0; - - /// \brief Read the next record batch in the stream. Return null for batch - /// when reaching end of stream - /// - /// \param[out] batch the next loaded batch, null at end of stream - /// \return Status - virtual Status ReadNext(std::shared_ptr* batch) = 0; - - /// \brief Consume entire stream as a vector of record batches - Status ReadAll(std::vector>* batches); - - /// \brief Read all batches and concatenate as arrow::Table - Status ReadAll(std::shared_ptr
* table); -}; - -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/result.h b/cpp/thirdparty/knowhere_build/include/arrow/result.h deleted file mode 100644 index 36e6ef79ab..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/result.h +++ /dev/null @@ -1,344 +0,0 @@ -// -// Copyright 2017 Asylo authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -// Adapted from Asylo - -#pragma once - -#include -#include - -#include "arrow/status.h" -#include "arrow/util/macros.h" -#include "arrow/util/variant.h" - -namespace arrow { - -namespace internal { - -ARROW_EXPORT void DieWithMessage(const std::string& msg); - -} // namespace internal - -// A class for representing either a usable value, or an error. -/// -/// A Result object either contains a value of type `T` or a Status object -/// explaining why such a value is not present. The type `T` must be -/// copy-constructible and/or move-constructible. -/// -/// The state of a Result object may be determined by calling ok() or -/// status(). The ok() method returns true if the object contains a valid value. -/// The status() method returns the internal Status object. A Result object -/// that contains a valid value will return an OK Status for a call to status(). -/// -/// A value of type `T` may be extracted from a Result object through a call -/// to ValueOrDie(). This function should only be called if a call to ok() -/// returns true. Sample usage: -/// -/// ``` -/// arrow::Result result = CalculateFoo(); -/// if (result.ok()) { -/// Foo foo = result.ValueOrDie(); -/// foo.DoSomethingCool(); -/// } else { -/// ARROW_LOG(ERROR) << result.status(); -/// } -/// ``` -/// -/// If `T` is a move-only type, like `std::unique_ptr<>`, then the value should -/// only be extracted after invoking `std::move()` on the Result object. -/// Sample usage: -/// -/// ``` -/// arrow::Result> result = CalculateFoo(); -/// if (result.ok()) { -/// std::unique_ptr foo = std::move(result).ValueOrDie(); -/// foo->DoSomethingCool(); -/// } else { -/// ARROW_LOG(ERROR) << result.status(); -/// } -/// ``` -/// -/// Result is provided for the convenience of implementing functions that -/// return some value but may fail during execution. For instance, consider a -/// function with the following signature: -/// -/// ``` -/// arrow::Status CalculateFoo(int *output); -/// ``` -/// -/// This function may instead be written as: -/// -/// ``` -/// arrow::Result CalculateFoo(); -/// ``` -template -class Result { - template - friend class Result; - using VariantType = arrow::util::variant; - static_assert(!std::is_same::value, - "this assert indicates you have probably made a metaprogramming error"); - - public: - /// Constructs a Result object that contains a non-OK status. - /// - /// This constructor is marked `explicit` to prevent attempts to `return {}` - /// from a function with a return type of, for example, - /// `Result>`. While `return {}` seems like it would return - /// an empty vector, it will actually invoke the default constructor of - /// Result. - explicit Result() // NOLINT(runtime/explicit) - : variant_(Status::UnknownError("Unknown error")) {} - - ~Result() = default; - - /// Constructs a Result object with the given non-OK Status object. All - /// calls to ValueOrDie() on this object will abort. The given `status` must - /// not be an OK status, otherwise this constructor will abort. - /// - /// This constructor is not declared explicit so that a function with a return - /// type of `Result` can return a Status object, and the status will be - /// implicitly converted to the appropriate return type as a matter of - /// convenience. - /// - /// \param status The non-OK Status object to initalize to. - Result(const Status& status) // NOLINT(runtime/explicit) - : variant_(status) { - if (ARROW_PREDICT_FALSE(status.ok())) { - internal::DieWithMessage(std::string("Constructed with a non-error status: ") + - status.ToString()); - } - } - - /// Constructs a Result object that contains `value`. The resulting object - /// is considered to have an OK status. The wrapped element can be accessed - /// with ValueOrDie(). - /// - /// This constructor is made implicit so that a function with a return type of - /// `Result` can return an object of type `U &&`, implicitly converting - /// it to a `Result` object. - /// - /// Note that `T` must be implicitly constructible from `U`, and `U` must not - /// be a (cv-qualified) Status or Status-reference type. Due to C++ - /// reference-collapsing rules and perfect-forwarding semantics, this - /// constructor matches invocations that pass `value` either as a const - /// reference or as an rvalue reference. Since Result needs to work for both - /// reference and rvalue-reference types, the constructor uses perfect - /// forwarding to avoid invalidating arguments that were passed by reference. - /// See http://thbecker.net/articles/rvalue_references/section_08.html for - /// additional details. - /// - /// \param value The value to initialize to. - template ::value && std::is_convertible::value && - !std::is_same::type>::type, - Status>::value>::type> - Result(U&& value) // NOLINT(runtime/explicit) - : variant_(std::forward(value)) {} - - /// Copy constructor. - /// - /// This constructor needs to be explicitly defined because the presence of - /// the move-assignment operator deletes the default copy constructor. In such - /// a scenario, since the deleted copy constructor has stricter binding rules - /// than the templated copy constructor, the templated constructor cannot act - /// as a copy constructor, and any attempt to copy-construct a `Result` - /// object results in a compilation error. - /// - /// \param other The value to copy from. - Result(const Result& other) = default; - - /// Templatized constructor that constructs a `Result` from a const - /// reference to a `Result`. - /// - /// `T` must be implicitly constructible from `const U &`. - /// - /// \param other The value to copy from. - template ::value && - std::is_convertible::value>::type> - Result(const Result& other) : variant_("unitialized") { - AssignVariant(other.variant_); - } - - /// Copy-assignment operator. - /// - /// \param other The Result object to copy. - Result& operator=(const Result& other) = default; - - /// Templatized constructor which constructs a `Result` by moving the - /// contents of a `Result`. `T` must be implicitly constructible from `U - /// &&`. - /// - /// Sets `other` to contain a non-OK status with a`StatusError::Invalid` - /// error code. - /// - /// \param other The Result object to move from and set to a non-OK status. - template ::value && - std::is_convertible::value>::type> - Result(Result&& other) : variant_("unitialized") { - AssignVariant(std::move(other.variant_)); - other.variant_ = "Value was moved to another Result."; - } - - /// Move-assignment operator. - /// - /// Sets `other` to an invalid state.. - /// - /// \param other The Result object to assign from and set to a non-OK - /// status. - Result& operator=(Result&& other) { - // Check for self-assignment. - if (this == &other) { - return *this; - } - AssignVariant(std::move(other.variant_)); - other.variant_ = "Value was moved to another Result."; - - return *this; - } - - /// Indicates whether the object contains a `T` value. Generally instead - /// of accessing this directly you will want to use ASSIGN_OR_RAISE defined - /// below. - /// - /// \return True if this Result object's status is OK (i.e. a call to ok() - /// returns true). If this function returns true, then it is safe to access - /// the wrapped element through a call to ValueOrDie(). - bool ok() const { return arrow::util::holds_alternative(variant_); } - - /// \brief Equivelant to ok(). - // operator bool() const { return ok(); } - - /// Gets the stored status object, or an OK status if a `T` value is stored. - /// - /// \return The stored non-OK status object, or an OK status if this object - /// has a value. - Status status() const { - return ok() ? Status::OK() : arrow::util::get(variant_); - } - - /// Gets the stored `T` value. - /// - /// This method should only be called if this Result object's status is OK - /// (i.e. a call to ok() returns true), otherwise this call will abort. - /// - /// \return The stored `T` value. - const T& ValueOrDie() const& { - if (ARROW_PREDICT_FALSE(!ok())) { - internal::DieWithMessage(std::string("ValueOrDie called on an error: ") + - status().ToString()); - } - return arrow::util::get(variant_); - } - const T& operator*() const& { return ValueOrDie(); } - - /// Gets a mutable reference to the stored `T` value. - /// - /// This method should only be called if this Result object's status is OK - /// (i.e. a call to ok() returns true), otherwise this call will abort. - /// - /// \return The stored `T` value. - T& ValueOrDie() & { - if (ARROW_PREDICT_FALSE(!ok())) { - internal::DieWithMessage(std::string("ValueOrDie called on an error: ") + - status().ToString()); - } - return arrow::util::get(variant_); - } - T& operator*() & { return ValueOrDie(); } - - /// Moves and returns the internally-stored `T` value. - /// - /// This method should only be called if this Result object's status is OK - /// (i.e. a call to ok() returns true), otherwise this call will abort. The - /// Result object is invalidated after this call and will be updated to - /// contain a non-OK status. - /// - /// \return The stored `T` value. - T ValueOrDie() && { - if (ARROW_PREDICT_FALSE(!ok())) { - internal::DieWithMessage(std::string("ValueOrDie called on an error: ") + - status().ToString()); - } - T tmp(std::move(arrow::util::get(variant_))); - variant_ = "Object already returned with ValueOrDie"; - return tmp; - } - T operator*() && { return ValueOrDie(); } - - private: - // Assignment is disabled by default so we need to destruct/reconstruct - // the value. - template - void AssignVariant(arrow::util::variant&& other) { - variant_.~variant(); - if (arrow::util::holds_alternative(other)) { - // Reuse memory of variant_ for construction - new (&variant_) VariantType(arrow::util::get(std::move(other))); - } else { - new (&variant_) VariantType(arrow::util::get(std::move(other))); - } - } - - // Assignment is disabled by default so we need to destruct/reconstruct - // the value. - template - void AssignVariant(const arrow::util::variant& other) { - variant_.~variant(); - if (arrow::util::holds_alternative(other)) { - // Reuse memory of variant_ for construction - new (&variant_) VariantType(arrow::util::get(other)); - } else { - new (&variant_) VariantType(arrow::util::get(other)); - } - } - - arrow::util::variant variant_; -}; - -#define ARROW_ASSIGN_OR_RAISE_IMPL(status_name, lhs, rexpr) \ - auto status_name = (rexpr); \ - ARROW_RETURN_NOT_OK(status_name.status()); \ - lhs = std::move(status_name).ValueOrDie(); - -#define ARROW_ASSIGN_OR_RAISE_NAME(x, y) ARROW_CONCAT(x, y) - -// Executes an expression that returns a Result, extracting its value -// into the variable defined by lhs (or returning on error). -// -// Example: Assigning to an existing value -// ValueType value; -// ARROW_ASSIGN_OR_RAISE(value, MaybeGetValue(arg)); -// -// WARNING: ASSIGN_OR_RAISE expands into multiple statements; it cannot be used -// in a single statement (e.g. as the body of an if statement without {})! -#define ARROW_ASSIGN_OR_RAISE(lhs, rexpr) \ - ARROW_ASSIGN_OR_RAISE_IMPL(ARROW_ASSIGN_OR_RAISE_NAME(_error_or_value, __COUNTER__), \ - lhs, rexpr); - -namespace internal { - -// For Cython, because of https://github.com/cython/cython/issues/3018 -template -using CResult = Result; - -} // namespace internal -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/scalar.h b/cpp/thirdparty/knowhere_build/include/arrow/scalar.h deleted file mode 100644 index 4f0589a2f5..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/scalar.h +++ /dev/null @@ -1,210 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// Object model for scalar (non-Array) values. Not intended for use with large -// amounts of data -// -// NOTE: This API is experimental as of the 0.13 version and subject to change -// without deprecation warnings - -#pragma once - -#include -#include - -#include "arrow/type.h" -#include "arrow/type_fwd.h" -#include "arrow/type_traits.h" -#include "arrow/util/decimal.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Array; - -/// \brief Base class for scalar values, representing a single value occupying -/// an array "slot" -struct ARROW_EXPORT Scalar { - virtual ~Scalar() = default; - - /// \brief The type of the scalar value - std::shared_ptr type; - - /// \brief Whether the value is valid (not null) or not - bool is_valid; - - bool Equals(const Scalar& other) const; - bool Equals(const std::shared_ptr& other) const { - if (other) return Equals(*other); - return false; - } - - protected: - Scalar(const std::shared_ptr& type, bool is_valid) - : type(type), is_valid(is_valid) {} -}; - -/// \brief A scalar value for NullType. Never valid -struct ARROW_EXPORT NullScalar : public Scalar { - public: - NullScalar() : Scalar{null(), false} {} -}; - -namespace internal { - -struct ARROW_EXPORT PrimitiveScalar : public Scalar { - using Scalar::Scalar; -}; - -} // namespace internal - -struct ARROW_EXPORT BooleanScalar : public internal::PrimitiveScalar { - bool value; - explicit BooleanScalar(bool value, bool is_valid = true) - : internal::PrimitiveScalar{boolean(), is_valid}, value(value) {} -}; - -template -struct NumericScalar : public internal::PrimitiveScalar { - using T = typename Type::c_type; - T value; - - explicit NumericScalar(T value, bool is_valid = true) - : NumericScalar(value, TypeTraits::type_singleton(), is_valid) {} - - protected: - explicit NumericScalar(T value, const std::shared_ptr& type, bool is_valid) - : internal::PrimitiveScalar{type, is_valid}, value(value) {} -}; - -struct ARROW_EXPORT BinaryScalar : public Scalar { - std::shared_ptr value; - explicit BinaryScalar(const std::shared_ptr& value, bool is_valid = true) - : BinaryScalar(value, binary(), is_valid) {} - - protected: - BinaryScalar(const std::shared_ptr& value, - const std::shared_ptr& type, bool is_valid = true) - : Scalar{type, is_valid}, value(value) {} -}; - -struct ARROW_EXPORT FixedSizeBinaryScalar : public BinaryScalar { - FixedSizeBinaryScalar(const std::shared_ptr& value, - const std::shared_ptr& type, bool is_valid = true); -}; - -struct ARROW_EXPORT StringScalar : public BinaryScalar { - explicit StringScalar(const std::shared_ptr& value, bool is_valid = true) - : BinaryScalar(value, utf8(), is_valid) {} -}; - -class ARROW_EXPORT Date32Scalar : public NumericScalar { - public: - using NumericScalar::NumericScalar; -}; - -class ARROW_EXPORT Date64Scalar : public NumericScalar { - public: - using NumericScalar::NumericScalar; -}; - -class ARROW_EXPORT Time32Scalar : public internal::PrimitiveScalar { - public: - int32_t value; - Time32Scalar(int32_t value, const std::shared_ptr& type, - bool is_valid = true); -}; - -class ARROW_EXPORT Time64Scalar : public internal::PrimitiveScalar { - public: - int64_t value; - Time64Scalar(int64_t value, const std::shared_ptr& type, - bool is_valid = true); -}; - -class ARROW_EXPORT TimestampScalar : public internal::PrimitiveScalar { - public: - int64_t value; - TimestampScalar(int64_t value, const std::shared_ptr& type, - bool is_valid = true); -}; - -class ARROW_EXPORT DurationScalar : public internal::PrimitiveScalar { - public: - int64_t value; - DurationScalar(int64_t value, const std::shared_ptr& type, - bool is_valid = true); -}; - -class ARROW_EXPORT MonthIntervalScalar : public internal::PrimitiveScalar { - public: - int32_t value; - MonthIntervalScalar(int32_t value, const std::shared_ptr& type, - bool is_valid = true); -}; - -class ARROW_EXPORT DayTimeIntervalScalar : public internal::PrimitiveScalar { - public: - DayTimeIntervalType::DayMilliseconds value; - DayTimeIntervalScalar(DayTimeIntervalType::DayMilliseconds value, - const std::shared_ptr& type, bool is_valid = true); -}; - -struct ARROW_EXPORT Decimal128Scalar : public Scalar { - Decimal128 value; - Decimal128Scalar(const Decimal128& value, const std::shared_ptr& type, - bool is_valid = true); -}; - -struct ARROW_EXPORT ListScalar : public Scalar { - std::shared_ptr value; - - ListScalar(const std::shared_ptr& value, const std::shared_ptr& type, - bool is_valid = true); - - explicit ListScalar(const std::shared_ptr& value, bool is_valid = true); -}; - -struct ARROW_EXPORT MapScalar : public Scalar { - std::shared_ptr keys; - std::shared_ptr items; - - MapScalar(const std::shared_ptr& keys, const std::shared_ptr& values, - const std::shared_ptr& type, bool is_valid = true); - - MapScalar(const std::shared_ptr& keys, const std::shared_ptr& values, - bool is_valid = true); -}; - -struct ARROW_EXPORT FixedSizeListScalar : public Scalar { - std::shared_ptr value; - - FixedSizeListScalar(const std::shared_ptr& value, - const std::shared_ptr& type, bool is_valid = true); - - explicit FixedSizeListScalar(const std::shared_ptr& value, bool is_valid = true); -}; - -struct ARROW_EXPORT StructScalar : public Scalar { - std::vector> value; -}; - -class ARROW_EXPORT UnionScalar : public Scalar {}; -class ARROW_EXPORT DictionaryScalar : public Scalar {}; -class ARROW_EXPORT ExtensionScalar : public Scalar {}; - -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/sparse_tensor.h b/cpp/thirdparty/knowhere_build/include/arrow/sparse_tensor.h deleted file mode 100644 index b6fe4b2059..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/sparse_tensor.h +++ /dev/null @@ -1,271 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_SPARSE_TENSOR_H -#define ARROW_SPARSE_TENSOR_H - -#include -#include -#include - -#include "arrow/tensor.h" - -namespace arrow { - -// ---------------------------------------------------------------------- -// SparseIndex class - -struct SparseTensorFormat { - /// EXPERIMENTAL: The index format type of SparseTensor - enum type { COO, CSR }; -}; - -/// \brief EXPERIMENTAL: The base class for the index of a sparse tensor -/// -/// SparseIndex describes where the non-zero elements are within a SparseTensor. -/// -/// There are several ways to represent this. The format_id is used to -/// distinguish what kind of representation is used. Each possible value of -/// format_id must have only one corresponding concrete subclass of SparseIndex. -class ARROW_EXPORT SparseIndex { - public: - explicit SparseIndex(SparseTensorFormat::type format_id, int64_t non_zero_length) - : format_id_(format_id), non_zero_length_(non_zero_length) {} - - virtual ~SparseIndex() = default; - - /// \brief Return the identifier of the format type - SparseTensorFormat::type format_id() const { return format_id_; } - - /// \brief Return the number of non zero values in the sparse tensor related - /// to this sparse index - int64_t non_zero_length() const { return non_zero_length_; } - - /// \brief Return the string representation of the sparse index - virtual std::string ToString() const = 0; - - protected: - SparseTensorFormat::type format_id_; - int64_t non_zero_length_; -}; - -namespace internal { -template -class SparseIndexBase : public SparseIndex { - public: - explicit SparseIndexBase(int64_t non_zero_length) - : SparseIndex(SparseIndexType::format_id, non_zero_length) {} -}; -} // namespace internal - -// ---------------------------------------------------------------------- -// SparseCOOIndex class - -/// \brief EXPERIMENTAL: The index data for a COO sparse tensor -/// -/// A COO sparse index manages the location of its non-zero values by their -/// coordinates. -class ARROW_EXPORT SparseCOOIndex : public internal::SparseIndexBase { - public: - using CoordsTensor = NumericTensor; - - static constexpr SparseTensorFormat::type format_id = SparseTensorFormat::COO; - - // Constructor with a column-major NumericTensor - explicit SparseCOOIndex(const std::shared_ptr& coords); - - /// \brief Return a tensor that has the coordinates of the non-zero values - const std::shared_ptr& indices() const { return coords_; } - - /// \brief Return a string representation of the sparse index - std::string ToString() const override; - - /// \brief Return whether the COO indices are equal - bool Equals(const SparseCOOIndex& other) const { - return indices()->Equals(*other.indices()); - } - - protected: - std::shared_ptr coords_; -}; - -// ---------------------------------------------------------------------- -// SparseCSRIndex class - -/// \brief EXPERIMENTAL: The index data for a CSR sparse matrix -/// -/// A CSR sparse index manages the location of its non-zero values by two -/// vectors. -/// -/// The first vector, called indptr, represents the range of the rows; the i-th -/// row spans from indptr[i] to indptr[i+1] in the corresponding value vector. -/// So the length of an indptr vector is the number of rows + 1. -/// -/// The other vector, called indices, represents the column indices of the -/// corresponding non-zero values. So the length of an indices vector is same -/// as the number of non-zero-values. -class ARROW_EXPORT SparseCSRIndex : public internal::SparseIndexBase { - public: - using IndexTensor = NumericTensor; - - static constexpr SparseTensorFormat::type format_id = SparseTensorFormat::CSR; - - // Constructor with two index vectors - explicit SparseCSRIndex(const std::shared_ptr& indptr, - const std::shared_ptr& indices); - - /// \brief Return a 1D tensor of indptr vector - const std::shared_ptr& indptr() const { return indptr_; } - - /// \brief Return a 1D tensor of indices vector - const std::shared_ptr& indices() const { return indices_; } - - /// \brief Return a string representation of the sparse index - std::string ToString() const override; - - /// \brief Return whether the CSR indices are equal - bool Equals(const SparseCSRIndex& other) const { - return indptr()->Equals(*other.indptr()) && indices()->Equals(*other.indices()); - } - - protected: - std::shared_ptr indptr_; - std::shared_ptr indices_; -}; - -// ---------------------------------------------------------------------- -// SparseTensor class - -/// \brief EXPERIMENTAL: The base class of sparse tensor container -class ARROW_EXPORT SparseTensor { - public: - virtual ~SparseTensor() = default; - - SparseTensorFormat::type format_id() const { return sparse_index_->format_id(); } - - /// \brief Return a value type of the sparse tensor - std::shared_ptr type() const { return type_; } - - /// \brief Return a buffer that contains the value vector of the sparse tensor - std::shared_ptr data() const { return data_; } - - /// \brief Return an immutable raw data pointer - const uint8_t* raw_data() const { return data_->data(); } - - /// \brief Return a mutable raw data pointer - uint8_t* raw_mutable_data() const { return data_->mutable_data(); } - - /// \brief Return a shape vector of the sparse tensor - const std::vector& shape() const { return shape_; } - - /// \brief Return a sparse index of the sparse tensor - const std::shared_ptr& sparse_index() const { return sparse_index_; } - - /// \brief Return a number of dimensions of the sparse tensor - int ndim() const { return static_cast(shape_.size()); } - - /// \brief Return a vector of dimension names - const std::vector& dim_names() const { return dim_names_; } - - /// \brief Return the name of the i-th dimension - const std::string& dim_name(int i) const; - - /// \brief Total number of value cells in the sparse tensor - int64_t size() const; - - /// \brief Return true if the underlying data buffer is mutable - bool is_mutable() const { return data_->is_mutable(); } - - /// \brief Total number of non-zero cells in the sparse tensor - int64_t non_zero_length() const { - return sparse_index_ ? sparse_index_->non_zero_length() : 0; - } - - /// \brief Return whether sparse tensors are equal - bool Equals(const SparseTensor& other) const; - - protected: - // Constructor with all attributes - SparseTensor(const std::shared_ptr& type, const std::shared_ptr& data, - const std::vector& shape, - const std::shared_ptr& sparse_index, - const std::vector& dim_names); - - std::shared_ptr type_; - std::shared_ptr data_; - std::vector shape_; - std::shared_ptr sparse_index_; - - // These names are optional - std::vector dim_names_; -}; - -// ---------------------------------------------------------------------- -// SparseTensorImpl class - -namespace internal { - -ARROW_EXPORT -void MakeSparseTensorFromTensor(const Tensor& tensor, - SparseTensorFormat::type sparse_format_id, - std::shared_ptr* sparse_index, - std::shared_ptr* data); - -} // namespace internal - -/// \brief EXPERIMENTAL: Concrete sparse tensor implementation classes with sparse index -/// type -template -class SparseTensorImpl : public SparseTensor { - public: - virtual ~SparseTensorImpl() = default; - - // Constructor with all attributes - SparseTensorImpl(const std::shared_ptr& sparse_index, - const std::shared_ptr& type, - const std::shared_ptr& data, const std::vector& shape, - const std::vector& dim_names) - : SparseTensor(type, data, shape, sparse_index, dim_names) {} - - // Constructor for empty sparse tensor - SparseTensorImpl(const std::shared_ptr& type, - const std::vector& shape, - const std::vector& dim_names = {}) - : SparseTensorImpl(NULLPTR, type, NULLPTR, shape, dim_names) {} - - // Constructor with a dense tensor - explicit SparseTensorImpl(const Tensor& tensor) - : SparseTensorImpl(NULLPTR, tensor.type(), NULLPTR, tensor.shape(), - tensor.dim_names_) { - internal::MakeSparseTensorFromTensor(tensor, SparseIndexType::format_id, - &sparse_index_, &data_); - } - - private: - ARROW_DISALLOW_COPY_AND_ASSIGN(SparseTensorImpl); -}; - -/// \brief EXPERIMENTAL: Type alias for COO sparse tensor -using SparseTensorCOO = SparseTensorImpl; - -/// \brief EXPERIMENTAL: Type alias for CSR sparse matrix -using SparseTensorCSR = SparseTensorImpl; -using SparseMatrixCSR = SparseTensorImpl; - -} // namespace arrow - -#endif // ARROW_SPARSE_TENSOR_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/status.h b/cpp/thirdparty/knowhere_build/include/arrow/status.h deleted file mode 100644 index 1ed0da65fc..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/status.h +++ /dev/null @@ -1,423 +0,0 @@ -// Copyright (c) 2011 The LevelDB Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. See the AUTHORS file for names of contributors. -// -// A Status encapsulates the result of an operation. It may indicate success, -// or it may indicate an error with an associated error message. -// -// Multiple threads can invoke const methods on a Status without -// external synchronization, but if any of the threads may call a -// non-const method, all threads accessing the same Status must use -// external synchronization. - -// Adapted from Apache Kudu, TensorFlow - -#ifndef ARROW_STATUS_H_ -#define ARROW_STATUS_H_ - -#include -#include -#include -#include - -#include "arrow/util/macros.h" -#include "arrow/util/string_builder.h" -#include "arrow/util/visibility.h" - -#ifdef ARROW_EXTRA_ERROR_CONTEXT - -/// \brief Return with given status if condition is met. -#define ARROW_RETURN_IF_(condition, status, expr) \ - do { \ - if (ARROW_PREDICT_FALSE(condition)) { \ - ::arrow::Status _st = (status); \ - _st.AddContextLine(__FILE__, __LINE__, expr); \ - return _st; \ - } \ - } while (0) - -#else - -#define ARROW_RETURN_IF_(condition, status, _) \ - do { \ - if (ARROW_PREDICT_FALSE(condition)) { \ - return (status); \ - } \ - } while (0) - -#endif // ARROW_EXTRA_ERROR_CONTEXT - -#define ARROW_RETURN_IF(condition, status) \ - ARROW_RETURN_IF_(condition, status, ARROW_STRINGIFY(status)) - -/// \brief Propagate any non-successful Status to the caller -#define ARROW_RETURN_NOT_OK(status) \ - do { \ - ::arrow::Status __s = (status); \ - ARROW_RETURN_IF_(!__s.ok(), __s, ARROW_STRINGIFY(status)); \ - } while (false) - -#define RETURN_NOT_OK_ELSE(s, else_) \ - do { \ - ::arrow::Status _s = (s); \ - if (!_s.ok()) { \ - else_; \ - return _s; \ - } \ - } while (false) - -// This is an internal-use macro and should not be used in public headers. -#ifndef RETURN_NOT_OK -#define RETURN_NOT_OK(s) ARROW_RETURN_NOT_OK(s) -#endif - -namespace arrow { - -enum class StatusCode : char { - OK = 0, - OutOfMemory = 1, - KeyError = 2, - TypeError = 3, - Invalid = 4, - IOError = 5, - CapacityError = 6, - IndexError = 7, - UnknownError = 9, - NotImplemented = 10, - SerializationError = 11, - PythonError = 12, - RError = 13, - PlasmaObjectExists = 20, - PlasmaObjectNonexistent = 21, - PlasmaStoreFull = 22, - PlasmaObjectAlreadySealed = 23, - StillExecuting = 24, - // Gandiva range of errors - CodeGenError = 40, - ExpressionValidationError = 41, - ExecutionError = 42 -}; - -#if defined(__clang__) -// Only clang supports warn_unused_result as a type annotation. -class ARROW_MUST_USE_RESULT ARROW_EXPORT Status; -#endif - -/// \brief Status outcome object (success or error) -/// -/// The Status object is an object holding the outcome of an operation. -/// The outcome is represented as a StatusCode, either success -/// (StatusCode::OK) or an error (any other of the StatusCode enumeration values). -/// -/// Additionally, if an error occurred, a specific error message is generally -/// attached. -class ARROW_EXPORT Status { - public: - // Create a success status. - Status() noexcept : state_(NULLPTR) {} - ~Status() noexcept { - // ARROW-2400: On certain compilers, splitting off the slow path improves - // performance significantly. - if (ARROW_PREDICT_FALSE(state_ != NULL)) { - DeleteState(); - } - } - - Status(StatusCode code, const std::string& msg); - - // Copy the specified status. - inline Status(const Status& s); - inline Status& operator=(const Status& s); - - // Move the specified status. - inline Status(Status&& s) noexcept; - inline Status& operator=(Status&& s) noexcept; - - // AND the statuses. - inline Status operator&(const Status& s) const noexcept; - inline Status operator&(Status&& s) const noexcept; - inline Status& operator&=(const Status& s) noexcept; - inline Status& operator&=(Status&& s) noexcept; - - /// Return a success status - static Status OK() { return Status(); } - - /// Return a success status with a specific message - template - static Status OK(Args&&... args) { - return Status(StatusCode::OK, util::StringBuilder(std::forward(args)...)); - } - - /// Return an error status for out-of-memory conditions - template - static Status OutOfMemory(Args&&... args) { - return Status(StatusCode::OutOfMemory, - util::StringBuilder(std::forward(args)...)); - } - - /// Return an error status for failed key lookups (e.g. column name in a table) - template - static Status KeyError(Args&&... args) { - return Status(StatusCode::KeyError, util::StringBuilder(std::forward(args)...)); - } - - /// Return an error status for type errors (such as mismatching data types) - template - static Status TypeError(Args&&... args) { - return Status(StatusCode::TypeError, - util::StringBuilder(std::forward(args)...)); - } - - /// Return an error status for unknown errors - template - static Status UnknownError(Args&&... args) { - return Status(StatusCode::UnknownError, - util::StringBuilder(std::forward(args)...)); - } - - /// Return an error status when an operation or a combination of operation and - /// data types is unimplemented - template - static Status NotImplemented(Args&&... args) { - return Status(StatusCode::NotImplemented, - util::StringBuilder(std::forward(args)...)); - } - - /// Return an error status for invalid data (for example a string that fails parsing) - template - static Status Invalid(Args&&... args) { - return Status(StatusCode::Invalid, util::StringBuilder(std::forward(args)...)); - } - - /// Return an error status when an index is out of bounds - template - static Status IndexError(Args&&... args) { - return Status(StatusCode::IndexError, - util::StringBuilder(std::forward(args)...)); - } - - /// Return an error status when a container's capacity would exceed its limits - template - static Status CapacityError(Args&&... args) { - return Status(StatusCode::CapacityError, - util::StringBuilder(std::forward(args)...)); - } - - /// Return an error status when some IO-related operation failed - template - static Status IOError(Args&&... args) { - return Status(StatusCode::IOError, util::StringBuilder(std::forward(args)...)); - } - - /// Return an error status when some (de)serialization operation failed - template - static Status SerializationError(Args&&... args) { - return Status(StatusCode::SerializationError, - util::StringBuilder(std::forward(args)...)); - } - - template - static Status RError(Args&&... args) { - return Status(StatusCode::RError, util::StringBuilder(std::forward(args)...)); - } - - template - static Status PlasmaObjectExists(Args&&... args) { - return Status(StatusCode::PlasmaObjectExists, - util::StringBuilder(std::forward(args)...)); - } - - template - static Status PlasmaObjectNonexistent(Args&&... args) { - return Status(StatusCode::PlasmaObjectNonexistent, - util::StringBuilder(std::forward(args)...)); - } - - template - static Status PlasmaObjectAlreadySealed(Args&&... args) { - return Status(StatusCode::PlasmaObjectAlreadySealed, - util::StringBuilder(std::forward(args)...)); - } - - template - static Status PlasmaStoreFull(Args&&... args) { - return Status(StatusCode::PlasmaStoreFull, - util::StringBuilder(std::forward(args)...)); - } - - static Status StillExecuting() { return Status(StatusCode::StillExecuting, ""); } - - template - static Status CodeGenError(Args&&... args) { - return Status(StatusCode::CodeGenError, - util::StringBuilder(std::forward(args)...)); - } - - template - static Status ExpressionValidationError(Args&&... args) { - return Status(StatusCode::ExpressionValidationError, - util::StringBuilder(std::forward(args)...)); - } - - template - static Status ExecutionError(Args&&... args) { - return Status(StatusCode::ExecutionError, - util::StringBuilder(std::forward(args)...)); - } - - /// Return true iff the status indicates success. - bool ok() const { return (state_ == NULLPTR); } - - /// Return true iff the status indicates an out-of-memory error. - bool IsOutOfMemory() const { return code() == StatusCode::OutOfMemory; } - /// Return true iff the status indicates a key lookup error. - bool IsKeyError() const { return code() == StatusCode::KeyError; } - /// Return true iff the status indicates invalid data. - bool IsInvalid() const { return code() == StatusCode::Invalid; } - /// Return true iff the status indicates an IO-related failure. - bool IsIOError() const { return code() == StatusCode::IOError; } - /// Return true iff the status indicates a container reaching capacity limits. - bool IsCapacityError() const { return code() == StatusCode::CapacityError; } - /// Return true iff the status indicates an out of bounds index. - bool IsIndexError() const { return code() == StatusCode::IndexError; } - /// Return true iff the status indicates a type error. - bool IsTypeError() const { return code() == StatusCode::TypeError; } - /// Return true iff the status indicates an unknown error. - bool IsUnknownError() const { return code() == StatusCode::UnknownError; } - /// Return true iff the status indicates an unimplemented operation. - bool IsNotImplemented() const { return code() == StatusCode::NotImplemented; } - /// Return true iff the status indicates a (de)serialization failure - bool IsSerializationError() const { return code() == StatusCode::SerializationError; } - /// Return true iff the status indicates a R-originated error. - bool IsRError() const { return code() == StatusCode::RError; } - /// Return true iff the status indicates a Python-originated error. - bool IsPythonError() const { return code() == StatusCode::PythonError; } - /// Return true iff the status indicates an already existing Plasma object. - bool IsPlasmaObjectExists() const { return code() == StatusCode::PlasmaObjectExists; } - /// Return true iff the status indicates a non-existent Plasma object. - bool IsPlasmaObjectNonexistent() const { - return code() == StatusCode::PlasmaObjectNonexistent; - } - /// Return true iff the status indicates an already sealed Plasma object. - bool IsPlasmaObjectAlreadySealed() const { - return code() == StatusCode::PlasmaObjectAlreadySealed; - } - /// Return true iff the status indicates the Plasma store reached its capacity limit. - bool IsPlasmaStoreFull() const { return code() == StatusCode::PlasmaStoreFull; } - - bool IsStillExecuting() const { return code() == StatusCode::StillExecuting; } - - bool IsCodeGenError() const { return code() == StatusCode::CodeGenError; } - - bool IsExpressionValidationError() const { - return code() == StatusCode::ExpressionValidationError; - } - - bool IsExecutionError() const { return code() == StatusCode::ExecutionError; } - - /// \brief Return a string representation of this status suitable for printing. - /// - /// The string "OK" is returned for success. - std::string ToString() const; - - /// \brief Return a string representation of the status code, without the message - /// text or POSIX code information. - std::string CodeAsString() const; - - /// \brief Return the StatusCode value attached to this status. - StatusCode code() const { return ok() ? StatusCode::OK : state_->code; } - - /// \brief Return the specific error message attached to this status. - std::string message() const { return ok() ? "" : state_->msg; } - - [[noreturn]] void Abort() const; - [[noreturn]] void Abort(const std::string& message) const; - -#ifdef ARROW_EXTRA_ERROR_CONTEXT - void AddContextLine(const char* filename, int line, const char* expr); -#endif - - private: - struct State { - StatusCode code; - std::string msg; - }; - // OK status has a `NULL` state_. Otherwise, `state_` points to - // a `State` structure containing the error code and message(s) - State* state_; - - void DeleteState() { - delete state_; - state_ = NULLPTR; - } - void CopyFrom(const Status& s); - inline void MoveFrom(Status& s); -}; - -static inline std::ostream& operator<<(std::ostream& os, const Status& x) { - os << x.ToString(); - return os; -} - -void Status::MoveFrom(Status& s) { - delete state_; - state_ = s.state_; - s.state_ = NULLPTR; -} - -Status::Status(const Status& s) - : state_((s.state_ == NULLPTR) ? NULLPTR : new State(*s.state_)) {} - -Status& Status::operator=(const Status& s) { - // The following condition catches both aliasing (when this == &s), - // and the common case where both s and *this are ok. - if (state_ != s.state_) { - CopyFrom(s); - } - return *this; -} - -Status::Status(Status&& s) noexcept : state_(s.state_) { s.state_ = NULLPTR; } - -Status& Status::operator=(Status&& s) noexcept { - MoveFrom(s); - return *this; -} - -/// \cond FALSE -// (note: emits warnings on Doxygen < 1.8.15, -// see https://github.com/doxygen/doxygen/issues/6295) -Status Status::operator&(const Status& s) const noexcept { - if (ok()) { - return s; - } else { - return *this; - } -} - -Status Status::operator&(Status&& s) const noexcept { - if (ok()) { - return std::move(s); - } else { - return *this; - } -} - -Status& Status::operator&=(const Status& s) noexcept { - if (ok() && !s.ok()) { - CopyFrom(s); - } - return *this; -} - -Status& Status::operator&=(Status&& s) noexcept { - if (ok() && !s.ok()) { - MoveFrom(s); - } - return *this; -} -/// \endcond - -} // namespace arrow - -#endif // ARROW_STATUS_H_ diff --git a/cpp/thirdparty/knowhere_build/include/arrow/stl.h b/cpp/thirdparty/knowhere_build/include/arrow/stl.h deleted file mode 100644 index d641e39955..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/stl.h +++ /dev/null @@ -1,373 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_STL_H -#define ARROW_STL_H - -#include -#include -#include -#include - -#include "arrow/builder.h" -#include "arrow/compute/api.h" -#include "arrow/table.h" -#include "arrow/type.h" -#include "arrow/type_traits.h" -#include "arrow/util/checked_cast.h" - -namespace arrow { - -class Schema; - -namespace stl { - -/// Traits meta class to map standard C/C++ types to equivalent Arrow types. -template -struct ConversionTraits {}; - -#define ARROW_STL_CONVERSION(c_type, ArrowType_) \ - template <> \ - struct ConversionTraits : public CTypeTraits { \ - static Status AppendRow(typename TypeTraits::BuilderType& builder, \ - c_type cell) { \ - return builder.Append(cell); \ - } \ - static c_type GetEntry(const typename TypeTraits::ArrayType& array, \ - size_t j) { \ - return array.Value(j); \ - } \ - constexpr static bool nullable = false; \ - }; - -ARROW_STL_CONVERSION(bool, BooleanType) -ARROW_STL_CONVERSION(int8_t, Int8Type) -ARROW_STL_CONVERSION(int16_t, Int16Type) -ARROW_STL_CONVERSION(int32_t, Int32Type) -ARROW_STL_CONVERSION(int64_t, Int64Type) -ARROW_STL_CONVERSION(uint8_t, UInt8Type) -ARROW_STL_CONVERSION(uint16_t, UInt16Type) -ARROW_STL_CONVERSION(uint32_t, UInt32Type) -ARROW_STL_CONVERSION(uint64_t, UInt64Type) -ARROW_STL_CONVERSION(float, FloatType) -ARROW_STL_CONVERSION(double, DoubleType) - -template <> -struct ConversionTraits : public CTypeTraits { - static Status AppendRow(StringBuilder& builder, const std::string& cell) { - return builder.Append(cell); - } - static std::string GetEntry(const StringArray& array, size_t j) { - return array.GetString(j); - } - constexpr static bool nullable = false; -}; - -template -struct ConversionTraits> - : public CTypeTraits> { - static Status AppendRow(ListBuilder& builder, std::vector cell) { - using ElementBuilderType = typename TypeTraits< - typename ConversionTraits::ArrowType>::BuilderType; - ARROW_RETURN_NOT_OK(builder.Append()); - ElementBuilderType& value_builder = - ::arrow::internal::checked_cast(*builder.value_builder()); - for (auto const& value : cell) { - ARROW_RETURN_NOT_OK( - ConversionTraits::AppendRow(value_builder, value)); - } - return Status::OK(); - } - - static std::vector GetEntry(const ListArray& array, size_t j) { - using ElementArrayType = typename TypeTraits< - typename ConversionTraits::ArrowType>::ArrayType; - - const ElementArrayType& value_array = - ::arrow::internal::checked_cast(*array.values()); - - std::vector vec(array.value_length(j)); - for (int64_t i = 0; i < array.value_length(j); i++) { - vec[i] = ConversionTraits::GetEntry(value_array, - array.value_offset(j) + i); - } - return vec; - } - - constexpr static bool nullable = false; -}; - -/// Build an arrow::Schema based upon the types defined in a std::tuple-like structure. -/// -/// While the type information is available at compile-time, we still need to add the -/// column names at runtime, thus these methods are not constexpr. -template ::value> -struct SchemaFromTuple { - using Element = typename std::tuple_element::type; - - // Implementations that take a vector-like object for the column names. - - /// Recursively build a vector of arrow::Field from the defined types. - /// - /// In most cases MakeSchema is the better entrypoint for the Schema creation. - static std::vector> MakeSchemaRecursion( - const std::vector& names) { - std::vector> ret = - SchemaFromTuple::MakeSchemaRecursion(names); - std::shared_ptr type = CTypeTraits::type_singleton(); - ret.push_back(field(names[N - 1], type, false /* nullable */)); - return ret; - } - - /// Build a Schema from the types of the tuple-like structure passed in as template - /// parameter assign the column names at runtime. - /// - /// An example usage of this API can look like the following: - /// - /// \code{.cpp} - /// using TupleType = std::tuple>; - /// std::shared_ptr schema = - /// SchemaFromTuple::MakeSchema({"int_column", "list_of_strings_column"}); - /// \endcode - static std::shared_ptr MakeSchema(const std::vector& names) { - return std::make_shared(MakeSchemaRecursion(names)); - } - - // Implementations that take a tuple-like object for the column names. - - /// Recursively build a vector of arrow::Field from the defined types. - /// - /// In most cases MakeSchema is the better entrypoint for the Schema creation. - template - static std::vector> MakeSchemaRecursionT( - const NamesTuple& names) { - using std::get; - - std::vector> ret = - SchemaFromTuple::MakeSchemaRecursionT(names); - std::shared_ptr type = ConversionTraits::type_singleton(); - ret.push_back(field(get(names), type, ConversionTraits::nullable)); - return ret; - } - - /// Build a Schema from the types of the tuple-like structure passed in as template - /// parameter assign the column names at runtime. - /// - /// An example usage of this API can look like the following: - /// - /// \code{.cpp} - /// using TupleType = std::tuple>; - /// std::shared_ptr schema = - /// SchemaFromTuple::MakeSchema({"int_column", "list_of_strings_column"}); - /// \endcode - template - static std::shared_ptr MakeSchema(const NamesTuple& names) { - return std::make_shared(MakeSchemaRecursionT(names)); - } -}; - -template -struct SchemaFromTuple { - static std::vector> MakeSchemaRecursion( - const std::vector& names) { - std::vector> ret; - ret.reserve(names.size()); - return ret; - } - - template - static std::vector> MakeSchemaRecursionT( - const NamesTuple& names) { - std::vector> ret; - ret.reserve(std::tuple_size::value); - return ret; - } -}; - -namespace internal { -template ::value> -struct CreateBuildersRecursive { - static Status Make(MemoryPool* pool, - std::vector>* builders) { - using Element = typename std::tuple_element::type; - std::shared_ptr type = ConversionTraits::type_singleton(); - ARROW_RETURN_NOT_OK(MakeBuilder(pool, type, &builders->at(N - 1))); - - return CreateBuildersRecursive::Make(pool, builders); - } -}; - -template -struct CreateBuildersRecursive { - static Status Make(MemoryPool*, std::vector>*) { - return Status::OK(); - } -}; - -template ::value> -struct RowIterator { - static Status Append(const std::vector>& builders, - const Tuple& row) { - using std::get; - using Element = typename std::tuple_element::type; - using BuilderType = - typename TypeTraits::ArrowType>::BuilderType; - - BuilderType& builder = - ::arrow::internal::checked_cast(*builders[N - 1]); - ARROW_RETURN_NOT_OK(ConversionTraits::AppendRow(builder, get(row))); - - return RowIterator::Append(builders, row); - } -}; - -template -struct RowIterator { - static Status Append(const std::vector>& builders, - const Tuple& row) { - return Status::OK(); - } -}; - -template ::value> -struct EnsureColumnTypes { - static Status Cast(const Table& table, std::shared_ptr
* table_owner, - const compute::CastOptions& cast_options, - compute::FunctionContext* ctx, - std::reference_wrapper* result) { - using Element = typename std::tuple_element::type; - std::shared_ptr expected_type = ConversionTraits::type_singleton(); - - if (!table.schema()->field(N - 1)->type()->Equals(*expected_type)) { - compute::Datum casted; - ARROW_RETURN_NOT_OK(compute::Cast(ctx, compute::Datum(table.column(N - 1)->data()), - expected_type, cast_options, &casted)); - std::shared_ptr new_column = std::make_shared( - table.schema()->field(N - 1)->WithType(expected_type), casted.chunked_array()); - ARROW_RETURN_NOT_OK(table.SetColumn(N - 1, new_column, table_owner)); - *result = **table_owner; - } - - return EnsureColumnTypes::Cast(result->get(), table_owner, cast_options, - ctx, result); - } -}; - -template -struct EnsureColumnTypes { - static Status Cast(const Table& table, std::shared_ptr
* table_ownder, - const compute::CastOptions& cast_options, - compute::FunctionContext* ctx, - std::reference_wrapper* result) { - return Status::OK(); - } -}; - -template ::value> -struct TupleSetter { - static void Fill(const Table& table, Range* rows) { - using std::get; - using Element = typename std::tuple_element::type; - using ArrayType = - typename TypeTraits::ArrowType>::ArrayType; - - auto iter = rows->begin(); - const ChunkedArray& chunked_array = *table.column(N - 1)->data(); - for (int i = 0; i < chunked_array.num_chunks(); i++) { - const ArrayType& array = - ::arrow::internal::checked_cast(*chunked_array.chunk(i)); - for (int64_t j = 0; j < array.length(); j++) { - get(*iter++) = ConversionTraits::GetEntry(array, j); - } - } - - return TupleSetter::Fill(table, rows); - } -}; - -template -struct TupleSetter { - static void Fill(const Table& table, Range* rows) {} -}; - -} // namespace internal - -template -Status TableFromTupleRange(MemoryPool* pool, const Range& rows, - const std::vector& names, - std::shared_ptr
* table) { - using row_type = typename std::iterator_traits::value_type; - constexpr std::size_t n_columns = std::tuple_size::value; - - std::shared_ptr schema = SchemaFromTuple::MakeSchema(names); - - std::vector> builders(n_columns); - ARROW_RETURN_NOT_OK(internal::CreateBuildersRecursive::Make(pool, &builders)); - - for (auto const& row : rows) { - ARROW_RETURN_NOT_OK(internal::RowIterator::Append(builders, row)); - } - - std::vector> arrays; - for (auto const& builder : builders) { - std::shared_ptr array; - ARROW_RETURN_NOT_OK(builder->Finish(&array)); - arrays.emplace_back(array); - } - - *table = Table::Make(schema, arrays); - - return Status::OK(); -} - -template -Status TupleRangeFromTable(const Table& table, const compute::CastOptions& cast_options, - compute::FunctionContext* ctx, Range* rows) { - using row_type = typename std::decay::type; - constexpr std::size_t n_columns = std::tuple_size::value; - - if (table.schema()->num_fields() != n_columns) { - std::stringstream ss; - ss << "Number of columns in the table does not match the width of the target: "; - ss << table.schema()->num_fields() << " != " << n_columns; - return Status::Invalid(ss.str()); - } - - // TODO: Use std::size with C++17 - if (rows->size() != static_cast(table.num_rows())) { - std::stringstream ss; - ss << "Number of rows in the table does not match the size of the target: "; - ss << table.num_rows() << " != " << rows->size(); - return Status::Invalid(ss.str()); - } - - // Check that all columns have the correct type, otherwise cast them. - std::shared_ptr
table_owner; - std::reference_wrapper current_table(table); - - ARROW_RETURN_NOT_OK(internal::EnsureColumnTypes::Cast( - table, &table_owner, cast_options, ctx, ¤t_table)); - - internal::TupleSetter::Fill(current_table.get(), rows); - - return Status::OK(); -} - -} // namespace stl -} // namespace arrow - -#endif // ARROW_STL_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/table.h b/cpp/thirdparty/knowhere_build/include/arrow/table.h deleted file mode 100644 index 2e7dcee904..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/table.h +++ /dev/null @@ -1,396 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_TABLE_H -#define ARROW_TABLE_H - -#include -#include -#include -#include - -#include "arrow/array.h" -#include "arrow/record_batch.h" -#include "arrow/type.h" -#include "arrow/util/macros.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class MemoryPool; -class Status; - -/// \class ChunkedArray -/// \brief A data structure managing a list of primitive Arrow arrays logically -/// as one large array -class ARROW_EXPORT ChunkedArray { - public: - /// \brief Construct a chunked array from a vector of arrays - /// - /// The vector should be non-empty and all its elements should have the same - /// data type. - explicit ChunkedArray(const ArrayVector& chunks); - - /// \brief Construct a chunked array from a single Array - explicit ChunkedArray(const std::shared_ptr& chunk) - : ChunkedArray(ArrayVector({chunk})) {} - - /// \brief Construct a chunked array from a vector of arrays and a data type - /// - /// As the data type is passed explicitly, the vector may be empty. - ChunkedArray(const ArrayVector& chunks, const std::shared_ptr& type); - - /// \return the total length of the chunked array; computed on construction - int64_t length() const { return length_; } - - /// \return the total number of nulls among all chunks - int64_t null_count() const { return null_count_; } - - int num_chunks() const { return static_cast(chunks_.size()); } - - /// \return chunk a particular chunk from the chunked array - std::shared_ptr chunk(int i) const { return chunks_[i]; } - - const ArrayVector& chunks() const { return chunks_; } - - /// \brief Construct a zero-copy slice of the chunked array with the - /// indicated offset and length - /// - /// \param[in] offset the position of the first element in the constructed - /// slice - /// \param[in] length the length of the slice. If there are not enough - /// elements in the chunked array, the length will be adjusted accordingly - /// - /// \return a new object wrapped in std::shared_ptr - std::shared_ptr Slice(int64_t offset, int64_t length) const; - - /// \brief Slice from offset until end of the chunked array - std::shared_ptr Slice(int64_t offset) const; - - /// \brief Flatten this chunked array as a vector of chunked arrays, one - /// for each struct field - /// - /// \param[in] pool The pool for buffer allocations, if any - /// \param[out] out The resulting vector of arrays - Status Flatten(MemoryPool* pool, std::vector>* out) const; - - std::shared_ptr type() const { return type_; } - - /// \brief Determine if two chunked arrays are equal. - /// - /// Two chunked arrays can be equal only if they have equal datatypes. - /// However, they may be equal even if they have different chunkings. - bool Equals(const ChunkedArray& other) const; - /// \brief Determine if two chunked arrays are equal. - bool Equals(const std::shared_ptr& other) const; - - /// \brief Check that all chunks have the same data type - Status Validate() const; - - protected: - ArrayVector chunks_; - int64_t length_; - int64_t null_count_; - std::shared_ptr type_; - - private: - ARROW_DISALLOW_COPY_AND_ASSIGN(ChunkedArray); -}; - -/// \class Column -/// \brief An immutable column data structure consisting of a field (type -/// metadata) and a chunked data array -class ARROW_EXPORT Column { - public: - /// \brief Construct a column from a vector of arrays - /// - /// The array chunks' datatype must match the field's datatype. - Column(const std::shared_ptr& field, const ArrayVector& chunks); - /// \brief Construct a column from a chunked array - /// - /// The chunked array's datatype must match the field's datatype. - Column(const std::shared_ptr& field, const std::shared_ptr& data); - /// \brief Construct a column from a single array - /// - /// The array's datatype must match the field's datatype. - Column(const std::shared_ptr& field, const std::shared_ptr& data); - - /// \brief Construct a column from a name and an array - /// - /// A field with the given name and the array's datatype is automatically created. - Column(const std::string& name, const std::shared_ptr& data); - /// \brief Construct a column from a name and a chunked array - /// - /// A field with the given name and the array's datatype is automatically created. - Column(const std::string& name, const std::shared_ptr& data); - - int64_t length() const { return data_->length(); } - - int64_t null_count() const { return data_->null_count(); } - - std::shared_ptr field() const { return field_; } - - /// \brief The column name - /// \return the column's name in the passed metadata - const std::string& name() const { return field_->name(); } - - /// \brief The column type - /// \return the column's type according to the metadata - std::shared_ptr type() const { return field_->type(); } - - /// \brief The column data as a chunked array - /// \return the column's data as a chunked logical array - std::shared_ptr data() const { return data_; } - - /// \brief Construct a zero-copy slice of the column with the indicated - /// offset and length - /// - /// \param[in] offset the position of the first element in the constructed - /// slice - /// \param[in] length the length of the slice. If there are not enough - /// elements in the column, the length will be adjusted accordingly - /// - /// \return a new object wrapped in std::shared_ptr - std::shared_ptr Slice(int64_t offset, int64_t length) const { - return std::make_shared(field_, data_->Slice(offset, length)); - } - - /// \brief Slice from offset until end of the column - std::shared_ptr Slice(int64_t offset) const { - return std::make_shared(field_, data_->Slice(offset)); - } - - /// \brief Flatten this column as a vector of columns - /// - /// \param[in] pool The pool for buffer allocations, if any - /// \param[out] out The resulting vector of arrays - Status Flatten(MemoryPool* pool, std::vector>* out) const; - - /// \brief Determine if two columns are equal. - /// - /// Two columns can be equal only if they have equal datatypes. - /// However, they may be equal even if they have different chunkings. - bool Equals(const Column& other) const; - /// \brief Determine if the two columns are equal. - bool Equals(const std::shared_ptr& other) const; - - /// \brief Verify that the column's array data is consistent with the passed - /// field's metadata - Status ValidateData(); - - protected: - std::shared_ptr field_; - std::shared_ptr data_; - - private: - ARROW_DISALLOW_COPY_AND_ASSIGN(Column); -}; - -/// \class Table -/// \brief Logical table as sequence of chunked arrays -class ARROW_EXPORT Table { - public: - virtual ~Table() = default; - - /// \brief Construct a Table from schema and columns - /// If columns is zero-length, the table's number of rows is zero - /// \param schema The table schema (column types) - /// \param columns The table's columns - /// \param num_rows number of rows in table, -1 (default) to infer from columns - static std::shared_ptr
Make(const std::shared_ptr& schema, - const std::vector>& columns, - int64_t num_rows = -1); - - /// \brief Construct a Table from columns, schema is assembled from column fields - /// If columns is zero-length, the table's number of rows is zero - /// \param columns The table's columns - /// \param num_rows number of rows in table, -1 (default) to infer from columns - static std::shared_ptr
Make(const std::vector>& columns, - int64_t num_rows = -1); - - /// \brief Construct a Table from schema and arrays - /// \param schema The table schema (column types) - /// \param arrays The table's columns as arrays - /// \param num_rows number of rows in table, -1 (default) to infer from columns - static std::shared_ptr
Make(const std::shared_ptr& schema, - const std::vector>& arrays, - int64_t num_rows = -1); - - /// \brief Construct a Table from RecordBatches, using schema supplied by the first - /// RecordBatch. - /// - /// \param[in] batches a std::vector of record batches - /// \param[out] table the returned table - /// \return Status Returns Status::Invalid if there is some problem - static Status FromRecordBatches( - const std::vector>& batches, - std::shared_ptr
* table); - - /// \brief Construct a Table from RecordBatches, using supplied schema. There may be - /// zero record batches - /// - /// \param[in] schema the arrow::Schema for each batch - /// \param[in] batches a std::vector of record batches - /// \param[out] table the returned table - /// \return Status - static Status FromRecordBatches( - const std::shared_ptr& schema, - const std::vector>& batches, - std::shared_ptr
* table); - - /// \brief Construct a Table from a chunked StructArray. One column will be produced - /// for each field of the StructArray. - /// - /// \param[in] array a chunked StructArray - /// \param[out] table the returned table - /// \return Status - static Status FromChunkedStructArray(const std::shared_ptr& array, - std::shared_ptr
* table); - - /// Return the table schema - std::shared_ptr schema() const { return schema_; } - - /// Return a column by index - virtual std::shared_ptr column(int i) const = 0; - - /// \brief Construct a zero-copy slice of the table with the - /// indicated offset and length - /// - /// \param[in] offset the index of the first row in the constructed - /// slice - /// \param[in] length the number of rows of the slice. If there are not enough - /// rows in the table, the length will be adjusted accordingly - /// - /// \return a new object wrapped in std::shared_ptr
- virtual std::shared_ptr
Slice(int64_t offset, int64_t length) const = 0; - - /// \brief Slice from first row at offset until end of the table - std::shared_ptr
Slice(int64_t offset) const { return Slice(offset, num_rows_); } - - /// \brief Return a column by name - /// \param[in] name field name - /// \return an Array or null if no field was found - std::shared_ptr GetColumnByName(const std::string& name) const { - auto i = schema_->GetFieldIndex(name); - return i == -1 ? NULLPTR : column(i); - } - - /// \brief Remove column from the table, producing a new Table - virtual Status RemoveColumn(int i, std::shared_ptr
* out) const = 0; - - /// \brief Add column to the table, producing a new Table - virtual Status AddColumn(int i, const std::shared_ptr& column, - std::shared_ptr
* out) const = 0; - - /// \brief Replace a column in the table, producing a new Table - virtual Status SetColumn(int i, const std::shared_ptr& column, - std::shared_ptr
* out) const = 0; - - /// \brief Return names of all columns - std::vector ColumnNames() const; - - /// \brief Rename columns with provided names - Status RenameColumns(const std::vector& names, - std::shared_ptr
* out) const; - - /// \brief Replace schema key-value metadata with new metadata (EXPERIMENTAL) - /// \since 0.5.0 - /// - /// \param[in] metadata new KeyValueMetadata - /// \return new Table - virtual std::shared_ptr
ReplaceSchemaMetadata( - const std::shared_ptr& metadata) const = 0; - - /// \brief Flatten the table, producing a new Table. Any column with a - /// struct type will be flattened into multiple columns - /// - /// \param[in] pool The pool for buffer allocations, if any - /// \param[out] out The returned table - virtual Status Flatten(MemoryPool* pool, std::shared_ptr
* out) const = 0; - - /// \brief Perform any checks to validate the input arguments - virtual Status Validate() const = 0; - - /// \brief Return the number of columns in the table - int num_columns() const { return schema_->num_fields(); } - - /// \brief Return the number of rows (equal to each column's logical length) - int64_t num_rows() const { return num_rows_; } - - /// \brief Determine if tables are equal - /// - /// Two tables can be equal only if they have equal schemas. - /// However, they may be equal even if they have different chunkings. - bool Equals(const Table& other) const; - - /// \brief Make a new table by combining the chunks this table has. - /// - /// All the underlying chunks in the ChunkedArray of each column are - /// concatenated into zero or one chunk. - /// - /// \param[in] pool The pool for buffer allocations - /// \param[out] out The table with chunks combined - Status CombineChunks(MemoryPool* pool, std::shared_ptr
* out) const; - - protected: - Table(); - - std::shared_ptr schema_; - int64_t num_rows_; - - private: - ARROW_DISALLOW_COPY_AND_ASSIGN(Table); -}; - -/// \brief Compute a stream of record batches from a (possibly chunked) Table -/// -/// The conversion is zero-copy: each record batch is a view over a slice -/// of the table's columns. -class ARROW_EXPORT TableBatchReader : public RecordBatchReader { - public: - ~TableBatchReader() override; - - /// \brief Construct a TableBatchReader for the given table - explicit TableBatchReader(const Table& table); - - std::shared_ptr schema() const override; - - Status ReadNext(std::shared_ptr* out) override; - - /// \brief Set the desired maximum chunk size of record batches - /// - /// The actual chunk size of each record batch may be smaller, depending - /// on actual chunking characteristics of each table column. - void set_chunksize(int64_t chunksize); - - private: - class TableBatchReaderImpl; - std::unique_ptr impl_; -}; - -/// \brief Construct table from multiple input tables. -/// -/// The tables are concatenated vertically. Therefore, all tables should -/// have the same schema. Each column in the output table is the result -/// of concatenating the corresponding columns in all input tables. -ARROW_EXPORT -Status ConcatenateTables(const std::vector>& tables, - std::shared_ptr
* table); - -} // namespace arrow - -#endif // ARROW_TABLE_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/table_builder.h b/cpp/thirdparty/knowhere_build/include/arrow/table_builder.h deleted file mode 100644 index 8e7dfc1e5b..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/table_builder.h +++ /dev/null @@ -1,113 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_TABLE_BUILDER_H -#define ARROW_TABLE_BUILDER_H - -#include -#include -#include - -#include "arrow/builder.h" -#include "arrow/status.h" -#include "arrow/type.h" -#include "arrow/util/checked_cast.h" -#include "arrow/util/macros.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class MemoryPool; -class RecordBatch; - -/// \class RecordBatchBuilder -/// \brief Helper class for creating record batches iteratively given a known -/// schema -class ARROW_EXPORT RecordBatchBuilder { - public: - /// \brief Create an initialize a RecordBatchBuilder - /// \param[in] schema The schema for the record batch - /// \param[in] pool A MemoryPool to use for allocations - /// \param[in] builder the created builder instance - static Status Make(const std::shared_ptr& schema, MemoryPool* pool, - std::unique_ptr* builder); - - /// \brief Create an initialize a RecordBatchBuilder - /// \param[in] schema The schema for the record batch - /// \param[in] pool A MemoryPool to use for allocations - /// \param[in] initial_capacity The initial capacity for the builders - /// \param[in] builder the created builder instance - static Status Make(const std::shared_ptr& schema, MemoryPool* pool, - int64_t initial_capacity, - std::unique_ptr* builder); - - /// \brief Get base pointer to field builder - /// \param i the field index - /// \return pointer to ArrayBuilder - ArrayBuilder* GetField(int i) { return raw_field_builders_[i]; } - - /// \brief Return field builder casted to indicated specific builder type - /// \param i the field index - /// \return pointer to template type - template - T* GetFieldAs(int i) { - return internal::checked_cast(raw_field_builders_[i]); - } - - /// \brief Finish current batch and optionally reset - /// \param[in] reset_builders the resulting RecordBatch - /// \param[out] batch the resulting RecordBatch - /// \return Status - Status Flush(bool reset_builders, std::shared_ptr* batch); - - /// \brief Finish current batch and reset - /// \param[out] batch the resulting RecordBatch - /// \return Status - Status Flush(std::shared_ptr* batch); - - /// \brief Set the initial capacity for new builders - void SetInitialCapacity(int64_t capacity); - - /// \brief The initial capacity for builders - int64_t initial_capacity() const { return initial_capacity_; } - - /// \brief The number of fields in the schema - int num_fields() const { return schema_->num_fields(); } - - /// \brief The number of fields in the schema - std::shared_ptr schema() const { return schema_; } - - private: - ARROW_DISALLOW_COPY_AND_ASSIGN(RecordBatchBuilder); - - RecordBatchBuilder(const std::shared_ptr& schema, MemoryPool* pool, - int64_t initial_capacity); - - Status CreateBuilders(); - Status InitBuilders(); - - std::shared_ptr schema_; - int64_t initial_capacity_; - MemoryPool* pool_; - - std::vector> field_builders_; - std::vector raw_field_builders_; -}; - -} // namespace arrow - -#endif // ARROW_TABLE_BUILDER_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/tensor.h b/cpp/thirdparty/knowhere_build/include/arrow/tensor.h deleted file mode 100644 index 317150234e..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/tensor.h +++ /dev/null @@ -1,167 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_TENSOR_H -#define ARROW_TENSOR_H - -#include -#include -#include -#include - -#include "arrow/buffer.h" -#include "arrow/type.h" -#include "arrow/type_traits.h" -#include "arrow/util/macros.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -static inline bool is_tensor_supported(Type::type type_id) { - switch (type_id) { - case Type::UINT8: - case Type::INT8: - case Type::UINT16: - case Type::INT16: - case Type::UINT32: - case Type::INT32: - case Type::UINT64: - case Type::INT64: - case Type::HALF_FLOAT: - case Type::FLOAT: - case Type::DOUBLE: - return true; - default: - break; - } - return false; -} - -template -class SparseTensorImpl; - -class ARROW_EXPORT Tensor { - public: - virtual ~Tensor() = default; - - /// Constructor with no dimension names or strides, data assumed to be row-major - Tensor(const std::shared_ptr& type, const std::shared_ptr& data, - const std::vector& shape); - - /// Constructor with non-negative strides - Tensor(const std::shared_ptr& type, const std::shared_ptr& data, - const std::vector& shape, const std::vector& strides); - - /// Constructor with non-negative strides and dimension names - Tensor(const std::shared_ptr& type, const std::shared_ptr& data, - const std::vector& shape, const std::vector& strides, - const std::vector& dim_names); - - std::shared_ptr type() const { return type_; } - std::shared_ptr data() const { return data_; } - - const uint8_t* raw_data() const { return data_->data(); } - uint8_t* raw_mutable_data() { return data_->mutable_data(); } - - const std::vector& shape() const { return shape_; } - const std::vector& strides() const { return strides_; } - - int ndim() const { return static_cast(shape_.size()); } - - const std::vector& dim_names() const { return dim_names_; } - const std::string& dim_name(int i) const; - - /// Total number of value cells in the tensor - int64_t size() const; - - /// Return true if the underlying data buffer is mutable - bool is_mutable() const { return data_->is_mutable(); } - - /// Either row major or column major - bool is_contiguous() const; - - /// AKA "C order" - bool is_row_major() const; - - /// AKA "Fortran order" - bool is_column_major() const; - - Type::type type_id() const; - - bool Equals(const Tensor& other) const; - - /// Compute the number of non-zero values in the tensor - Status CountNonZero(int64_t* result) const; - - protected: - Tensor() {} - - std::shared_ptr type_; - std::shared_ptr data_; - std::vector shape_; - std::vector strides_; - - /// These names are optional - std::vector dim_names_; - - template - friend class SparseTensorImpl; - - private: - ARROW_DISALLOW_COPY_AND_ASSIGN(Tensor); -}; - -template -class NumericTensor : public Tensor { - public: - using TypeClass = TYPE; - using value_type = typename TypeClass::c_type; - - /// Constructor with non-negative strides and dimension names - NumericTensor(const std::shared_ptr& data, const std::vector& shape, - const std::vector& strides, - const std::vector& dim_names) - : Tensor(TypeTraits::type_singleton(), data, shape, strides, dim_names) {} - - /// Constructor with no dimension names or strides, data assumed to be row-major - NumericTensor(const std::shared_ptr& data, const std::vector& shape) - : NumericTensor(data, shape, {}, {}) {} - - /// Constructor with non-negative strides - NumericTensor(const std::shared_ptr& data, const std::vector& shape, - const std::vector& strides) - : NumericTensor(data, shape, strides, {}) {} - - const value_type& Value(const std::vector& index) const { - int64_t offset = CalculateValueOffset(index); - const value_type* ptr = reinterpret_cast(raw_data() + offset); - return *ptr; - } - - protected: - int64_t CalculateValueOffset(const std::vector& index) const { - int64_t offset = 0; - for (size_t i = 0; i < index.size(); ++i) { - offset += index[i] * strides_[i]; - } - return offset; - } -}; - -} // namespace arrow - -#endif // ARROW_TENSOR_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/testing/gtest_common.h b/cpp/thirdparty/knowhere_build/include/arrow/testing/gtest_common.h deleted file mode 100644 index d0221de4b4..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/testing/gtest_common.h +++ /dev/null @@ -1,133 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_TEST_COMMON_H -#define ARROW_TEST_COMMON_H - -#include -#include -#include -#include -#include - -#include - -#include "arrow/array.h" -#include "arrow/buffer.h" -#include "arrow/builder.h" -#include "arrow/memory_pool.h" -#include "arrow/testing/gtest_util.h" -#include "arrow/testing/util.h" - -namespace arrow { - -class TestBase : public ::testing::Test { - public: - void SetUp() { - pool_ = default_memory_pool(); - random_seed_ = 0; - } - - std::shared_ptr MakeRandomNullBitmap(int64_t length, int64_t null_count) { - const int64_t null_nbytes = BitUtil::BytesForBits(length); - - std::shared_ptr null_bitmap; - ARROW_EXPECT_OK(AllocateBuffer(pool_, null_nbytes, &null_bitmap)); - memset(null_bitmap->mutable_data(), 255, null_nbytes); - for (int64_t i = 0; i < null_count; i++) { - BitUtil::ClearBit(null_bitmap->mutable_data(), i * (length / null_count)); - } - return null_bitmap; - } - - template - inline std::shared_ptr MakeRandomArray(int64_t length, int64_t null_count = 0); - - protected: - uint32_t random_seed_; - MemoryPool* pool_; -}; - -template -std::shared_ptr TestBase::MakeRandomArray(int64_t length, int64_t null_count) { - const int64_t data_nbytes = length * sizeof(typename ArrayType::value_type); - std::shared_ptr data; - ARROW_EXPECT_OK(AllocateBuffer(pool_, data_nbytes, &data)); - - // Fill with random data - random_bytes(data_nbytes, random_seed_++, data->mutable_data()); - std::shared_ptr null_bitmap = MakeRandomNullBitmap(length, null_count); - - return std::make_shared(length, data, null_bitmap, null_count); -} - -template <> -inline std::shared_ptr TestBase::MakeRandomArray(int64_t length, - int64_t null_count) { - return std::make_shared(length); -} - -template <> -inline std::shared_ptr TestBase::MakeRandomArray( - int64_t length, int64_t null_count) { - const int byte_width = 10; - std::shared_ptr null_bitmap = MakeRandomNullBitmap(length, null_count); - std::shared_ptr data; - ARROW_EXPECT_OK(AllocateBuffer(pool_, byte_width * length, &data)); - - ::arrow::random_bytes(data->size(), 0, data->mutable_data()); - return std::make_shared(fixed_size_binary(byte_width), length, - data, null_bitmap, null_count); -} - -template <> -inline std::shared_ptr TestBase::MakeRandomArray(int64_t length, - int64_t null_count) { - std::vector valid_bytes(length, 1); - for (int64_t i = 0; i < null_count; i++) { - valid_bytes[i * 2] = 0; - } - BinaryBuilder builder(pool_); - - const int kBufferSize = 10; - uint8_t buffer[kBufferSize]; - for (int64_t i = 0; i < length; i++) { - if (!valid_bytes[i]) { - ARROW_EXPECT_OK(builder.AppendNull()); - } else { - ::arrow::random_bytes(kBufferSize, static_cast(i), buffer); - ARROW_EXPECT_OK(builder.Append(buffer, kBufferSize)); - } - } - - std::shared_ptr out; - ARROW_EXPECT_OK(builder.Finish(&out)); - return out; -} - -class TestBuilder : public ::testing::Test { - public: - void SetUp() { pool_ = default_memory_pool(); } - - protected: - MemoryPool* pool_; - std::shared_ptr type_; -}; - -} // namespace arrow - -#endif // ARROW_TEST_COMMON_H_ diff --git a/cpp/thirdparty/knowhere_build/include/arrow/testing/gtest_util.h b/cpp/thirdparty/knowhere_build/include/arrow/testing/gtest_util.h deleted file mode 100644 index 914aeb011c..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/testing/gtest_util.h +++ /dev/null @@ -1,330 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "arrow/buffer.h" -#include "arrow/builder.h" -#include "arrow/status.h" -#include "arrow/type_fwd.h" -#include "arrow/type_traits.h" -#include "arrow/util/bit-util.h" -#include "arrow/util/macros.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -template -class Result; - -namespace internal { - -// Helpers for the ASSERT* macros below - -inline Status GenericToStatus(const Status& st) { return st; } - -template -inline Status GenericToStatus(const Result& res) { - return res.status(); -} - -} // namespace internal -} // namespace arrow - -// NOTE: failing must be inline in the macros below, to get correct file / line number -// reporting on test failures. - -#define ASSERT_RAISES(ENUM, expr) \ - do { \ - auto _res = (expr); \ - ::arrow::Status _st = ::arrow::internal::GenericToStatus(_res); \ - if (!_st.Is##ENUM()) { \ - FAIL() << "Expected '" ARROW_STRINGIFY(expr) "' to fail with " ARROW_STRINGIFY( \ - ENUM) ", but got " \ - << _st.ToString(); \ - } \ - } while (false) - -#define ASSERT_RAISES_WITH_MESSAGE(ENUM, message, expr) \ - do { \ - auto _res = (expr); \ - ::arrow::Status _st = ::arrow::internal::GenericToStatus(_res); \ - if (!_st.Is##ENUM()) { \ - FAIL() << "Expected '" ARROW_STRINGIFY(expr) "' to fail with " ARROW_STRINGIFY( \ - ENUM) ", but got " \ - << _st.ToString(); \ - } \ - ASSERT_EQ((message), _st.ToString()); \ - } while (false) - -#define ASSERT_OK(expr) \ - do { \ - auto _res = (expr); \ - ::arrow::Status _st = ::arrow::internal::GenericToStatus(_res); \ - if (!_st.ok()) { \ - FAIL() << "'" ARROW_STRINGIFY(expr) "' failed with " << _st.ToString(); \ - } \ - } while (false) - -#define ASSERT_OK_NO_THROW(expr) ASSERT_NO_THROW(ASSERT_OK(expr)) - -#define ARROW_EXPECT_OK(expr) \ - do { \ - auto _res = (expr); \ - ::arrow::Status _st = ::arrow::internal::GenericToStatus(_res); \ - EXPECT_TRUE(_st.ok()); \ - } while (false) - -#define ABORT_NOT_OK(expr) \ - do { \ - auto _res = (expr); \ - ::arrow::Status _st = ::arrow::internal::GenericToStatus(_res); \ - if (ARROW_PREDICT_FALSE(!_st.ok())) { \ - _st.Abort(); \ - } \ - } while (false); - -namespace arrow { - -// ---------------------------------------------------------------------- -// Useful testing::Types declarations - -typedef ::testing::Types - NumericArrowTypes; - -class Array; -class ChunkedArray; -class Column; -class RecordBatch; -class Table; - -namespace compute { -struct Datum; -} - -using Datum = compute::Datum; - -using ArrayVector = std::vector>; - -#define ASSERT_ARRAYS_EQUAL(lhs, rhs) AssertArraysEqual((lhs), (rhs)) -#define ASSERT_BATCHES_EQUAL(lhs, rhs) AssertBatchesEqual((lhs), (rhs)) - -ARROW_EXPORT void AssertArraysEqual(const Array& expected, const Array& actual); -ARROW_EXPORT void AssertBatchesEqual(const RecordBatch& expected, - const RecordBatch& actual); -ARROW_EXPORT void AssertChunkedEqual(const ChunkedArray& expected, - const ChunkedArray& actual); -ARROW_EXPORT void AssertChunkedEqual(const ChunkedArray& actual, - const ArrayVector& expected); -ARROW_EXPORT void AssertBufferEqual(const Buffer& buffer, - const std::vector& expected); -ARROW_EXPORT void AssertBufferEqual(const Buffer& buffer, const std::string& expected); -ARROW_EXPORT void AssertBufferEqual(const Buffer& buffer, const Buffer& expected); -ARROW_EXPORT void AssertSchemaEqual(const Schema& lhs, const Schema& rhs); - -ARROW_EXPORT void AssertTablesEqual(const Table& expected, const Table& actual, - bool same_chunk_layout = true); - -ARROW_EXPORT void AssertDatumsEqual(const Datum& expected, const Datum& actual); - -template -void AssertNumericDataEqual(const C_TYPE* raw_data, - const std::vector& expected_values) { - for (auto expected : expected_values) { - ASSERT_EQ(expected, *raw_data); - ++raw_data; - } -} - -ARROW_EXPORT void CompareBatch(const RecordBatch& left, const RecordBatch& right, - bool compare_metadata = true); - -// Check if the padding of the buffers of the array is zero. -// Also cause valgrind warnings if the padding bytes are uninitialized. -ARROW_EXPORT void AssertZeroPadded(const Array& array); - -// Check if the valid buffer bytes are initialized -// and cause valgrind warnings otherwise. -ARROW_EXPORT void TestInitialized(const Array& array); - -template -void FinishAndCheckPadding(BuilderType* builder, std::shared_ptr* out) { - ASSERT_OK(builder->Finish(out)); - AssertZeroPadded(**out); - TestInitialized(**out); -} - -#define DECL_T() typedef typename TestFixture::T T; - -#define DECL_TYPE() typedef typename TestFixture::Type Type; - -// ArrayFromJSON: construct an Array from a simple JSON representation - -ARROW_EXPORT -std::shared_ptr ArrayFromJSON(const std::shared_ptr&, - const std::string& json); - -// ArrayFromVector: construct an Array from vectors of C values - -template -void ArrayFromVector(const std::shared_ptr& type, - const std::vector& is_valid, const std::vector& values, - std::shared_ptr* out) { - auto type_id = TYPE::type_id; - ASSERT_EQ(type_id, type->id()) - << "template parameter and concrete DataType instance don't agree"; - - std::unique_ptr builder_ptr; - ASSERT_OK(MakeBuilder(default_memory_pool(), type, &builder_ptr)); - // Get the concrete builder class to access its Append() specializations - auto& builder = dynamic_cast::BuilderType&>(*builder_ptr); - - for (size_t i = 0; i < values.size(); ++i) { - if (is_valid[i]) { - ASSERT_OK(builder.Append(values[i])); - } else { - ASSERT_OK(builder.AppendNull()); - } - } - ASSERT_OK(builder.Finish(out)); -} - -template -void ArrayFromVector(const std::shared_ptr& type, - const std::vector& values, std::shared_ptr* out) { - auto type_id = TYPE::type_id; - ASSERT_EQ(type_id, type->id()) - << "template parameter and concrete DataType instance don't agree"; - - std::unique_ptr builder_ptr; - ASSERT_OK(MakeBuilder(default_memory_pool(), type, &builder_ptr)); - // Get the concrete builder class to access its Append() specializations - auto& builder = dynamic_cast::BuilderType&>(*builder_ptr); - - for (size_t i = 0; i < values.size(); ++i) { - ASSERT_OK(builder.Append(values[i])); - } - ASSERT_OK(builder.Finish(out)); -} - -// Overloads without a DataType argument, for parameterless types - -template -void ArrayFromVector(const std::vector& is_valid, const std::vector& values, - std::shared_ptr* out) { - auto type = TypeTraits::type_singleton(); - ArrayFromVector(type, is_valid, values, out); -} - -template -void ArrayFromVector(const std::vector& values, std::shared_ptr* out) { - auto type = TypeTraits::type_singleton(); - ArrayFromVector(type, values, out); -} - -// ChunkedArrayFromVector: construct a ChunkedArray from vectors of C values - -template -void ChunkedArrayFromVector(const std::shared_ptr& type, - const std::vector>& is_valid, - const std::vector>& values, - std::shared_ptr* out) { - ArrayVector chunks; - ASSERT_EQ(is_valid.size(), values.size()); - for (size_t i = 0; i < values.size(); ++i) { - std::shared_ptr array; - ArrayFromVector(type, is_valid[i], values[i], &array); - chunks.push_back(array); - } - *out = std::make_shared(chunks); -} - -template -void ChunkedArrayFromVector(const std::shared_ptr& type, - const std::vector>& values, - std::shared_ptr* out) { - ArrayVector chunks; - for (size_t i = 0; i < values.size(); ++i) { - std::shared_ptr array; - ArrayFromVector(type, values[i], &array); - chunks.push_back(array); - } - *out = std::make_shared(chunks); -} - -// Overloads without a DataType argument, for parameterless types - -template -void ChunkedArrayFromVector(const std::vector>& is_valid, - const std::vector>& values, - std::shared_ptr* out) { - auto type = TypeTraits::type_singleton(); - ChunkedArrayFromVector(type, is_valid, values, out); -} - -template -void ChunkedArrayFromVector(const std::vector>& values, - std::shared_ptr* out) { - auto type = TypeTraits::type_singleton(); - ChunkedArrayFromVector(type, values, out); -} - -template -static inline Status GetBitmapFromVector(const std::vector& is_valid, - std::shared_ptr* result) { - size_t length = is_valid.size(); - - std::shared_ptr buffer; - RETURN_NOT_OK(AllocateEmptyBitmap(length, &buffer)); - - uint8_t* bitmap = buffer->mutable_data(); - for (size_t i = 0; i < static_cast(length); ++i) { - if (is_valid[i]) { - BitUtil::SetBit(bitmap, i); - } - } - - *result = buffer; - return Status::OK(); -} - -template -inline void BitmapFromVector(const std::vector& is_valid, - std::shared_ptr* out) { - ASSERT_OK(GetBitmapFromVector(is_valid, out)); -} - -template -void AssertSortedEquals(std::vector u, std::vector v) { - std::sort(u.begin(), u.end()); - std::sort(v.begin(), v.end()); - ASSERT_EQ(u, v); -} - -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/testing/random.h b/cpp/thirdparty/knowhere_build/include/arrow/testing/random.h deleted file mode 100644 index 6b188fd573..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/testing/random.h +++ /dev/null @@ -1,272 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include -#include -#include -#include -#include -#include - -#include "arrow/type.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Array; - -namespace random { - -using SeedType = std::random_device::result_type; -constexpr SeedType kSeedMax = std::numeric_limits::max(); - -class ARROW_EXPORT RandomArrayGenerator { - public: - explicit RandomArrayGenerator(SeedType seed) - : seed_distribution_(static_cast(1), kSeedMax), seed_rng_(seed) {} - - /// \brief Generates a random BooleanArray - /// - /// \param[in] size the size of the array to generate - /// \param[in] probability the estimated number of active bits - /// \param[in] null_probability the probability of a row being null - /// - /// \return a generated Array - std::shared_ptr Boolean(int64_t size, double probability, - double null_probability); - - /// \brief Generates a random UInt8Array - /// - /// \param[in] size the size of the array to generate - /// \param[in] min the lower bound of the uniform distribution - /// \param[in] max the upper bound of the uniform distribution - /// \param[in] null_probability the probability of a row being null - /// - /// \return a generated Array - std::shared_ptr UInt8(int64_t size, uint8_t min, uint8_t max, - double null_probability); - - /// \brief Generates a random Int8Array - /// - /// \param[in] size the size of the array to generate - /// \param[in] min the lower bound of the uniform distribution - /// \param[in] max the upper bound of the uniform distribution - /// \param[in] null_probability the probability of a row being null - /// - /// \return a generated Array - std::shared_ptr Int8(int64_t size, int8_t min, int8_t max, - double null_probability); - - /// \brief Generates a random UInt16Array - /// - /// \param[in] size the size of the array to generate - /// \param[in] min the lower bound of the uniform distribution - /// \param[in] max the upper bound of the uniform distribution - /// \param[in] null_probability the probability of a row being null - /// - /// \return a generated Array - std::shared_ptr UInt16(int64_t size, uint16_t min, uint16_t max, - double null_probability); - - /// \brief Generates a random Int16Array - /// - /// \param[in] size the size of the array to generate - /// \param[in] min the lower bound of the uniform distribution - /// \param[in] max the upper bound of the uniform distribution - /// \param[in] null_probability the probability of a row being null - /// - /// \return a generated Array - std::shared_ptr Int16(int64_t size, int16_t min, int16_t max, - double null_probability); - - /// \brief Generates a random UInt32Array - /// - /// \param[in] size the size of the array to generate - /// \param[in] min the lower bound of the uniform distribution - /// \param[in] max the upper bound of the uniform distribution - /// \param[in] null_probability the probability of a row being null - /// - /// \return a generated Array - std::shared_ptr UInt32(int64_t size, uint32_t min, uint32_t max, - double null_probability); - - /// \brief Generates a random Int32Array - /// - /// \param[in] size the size of the array to generate - /// \param[in] min the lower bound of the uniform distribution - /// \param[in] max the upper bound of the uniform distribution - /// \param[in] null_probability the probability of a row being null - /// - /// \return a generated Array - std::shared_ptr Int32(int64_t size, int32_t min, int32_t max, - double null_probability); - - /// \brief Generates a random UInt64Array - /// - /// \param[in] size the size of the array to generate - /// \param[in] min the lower bound of the uniform distribution - /// \param[in] max the upper bound of the uniform distribution - /// \param[in] null_probability the probability of a row being null - /// - /// \return a generated Array - std::shared_ptr UInt64(int64_t size, uint64_t min, uint64_t max, - double null_probability); - - /// \brief Generates a random Int64Array - /// - /// \param[in] size the size of the array to generate - /// \param[in] min the lower bound of the uniform distribution - /// \param[in] max the upper bound of the uniform distribution - /// \param[in] null_probability the probability of a row being null - /// - /// \return a generated Array - std::shared_ptr Int64(int64_t size, int64_t min, int64_t max, - double null_probability); - - /// \brief Generates a random FloatArray - /// - /// \param[in] size the size of the array to generate - /// \param[in] min the lower bound of the uniform distribution - /// \param[in] max the upper bound of the uniform distribution - /// \param[in] null_probability the probability of a row being null - /// - /// \return a generated Array - std::shared_ptr Float32(int64_t size, float min, float max, - double null_probability); - - /// \brief Generates a random DoubleArray - /// - /// \param[in] size the size of the array to generate - /// \param[in] min the lower bound of the uniform distribution - /// \param[in] max the upper bound of the uniform distribution - /// \param[in] null_probability the probability of a row being null - /// - /// \return a generated Array - std::shared_ptr Float64(int64_t size, double min, double max, - double null_probability); - - template - std::shared_ptr Numeric(int64_t size, CType min, CType max, - double null_probability) { - switch (ArrowType::type_id) { - case Type::UINT8: - return UInt8(size, static_cast(min), static_cast(max), - null_probability); - case Type::INT8: - return Int8(size, static_cast(min), static_cast(max), - null_probability); - case Type::UINT16: - return UInt16(size, static_cast(min), static_cast(max), - null_probability); - case Type::INT16: - return Int16(size, static_cast(min), static_cast(max), - null_probability); - case Type::UINT32: - return UInt32(size, static_cast(min), static_cast(max), - null_probability); - case Type::INT32: - return Int32(size, static_cast(min), static_cast(max), - null_probability); - case Type::UINT64: - return UInt64(size, static_cast(min), static_cast(max), - null_probability); - case Type::INT64: - return Int64(size, static_cast(min), static_cast(max), - null_probability); - case Type::FLOAT: - return Float32(size, static_cast(min), static_cast(max), - null_probability); - case Type::DOUBLE: - return Float64(size, static_cast(min), static_cast(max), - null_probability); - default: - return nullptr; - } - } - - /// \brief Generates a random StringArray - /// - /// \param[in] size the size of the array to generate - /// \param[in] min_length the lower bound of the string length - /// determined by the uniform distribution - /// \param[in] max_length the upper bound of the string length - /// determined by the uniform distribution - /// \param[in] null_probability the probability of a row being null - /// - /// \return a generated Array - std::shared_ptr String(int64_t size, int32_t min_length, - int32_t max_length, double null_probability); - - /// \brief Generates a random StringArray with repeated values - /// - /// \param[in] size the size of the array to generate - /// \param[in] unique the number of unique string values used - /// to populate the array - /// \param[in] min_length the lower bound of the string length - /// determined by the uniform distribution - /// \param[in] max_length the upper bound of the string length - /// determined by the uniform distribution - /// \param[in] null_probability the probability of a row being null - /// - /// \return a generated Array - std::shared_ptr StringWithRepeats(int64_t size, int64_t unique, - int32_t min_length, int32_t max_length, - double null_probability); - - private: - SeedType seed() { return seed_distribution_(seed_rng_); } - - std::uniform_int_distribution seed_distribution_; - std::default_random_engine seed_rng_; -}; - -} // namespace random - -// -// Assorted functions -// - -template -void randint(int64_t N, T lower, T upper, std::vector* out) { - const int random_seed = 0; - std::default_random_engine gen(random_seed); - std::uniform_int_distribution d(lower, upper); - out->resize(N, static_cast(0)); - std::generate(out->begin(), out->end(), [&d, &gen] { return static_cast(d(gen)); }); -} - -template -void random_real(int64_t n, uint32_t seed, T min_value, T max_value, - std::vector* out) { - std::default_random_engine gen(seed); - std::uniform_real_distribution d(min_value, max_value); - out->resize(n, static_cast(0)); - std::generate(out->begin(), out->end(), [&d, &gen] { return static_cast(d(gen)); }); -} - -template -void rand_uniform_int(int64_t n, uint32_t seed, T min_value, T max_value, U* out) { - assert(out || (n == 0)); - std::default_random_engine gen(seed); - std::uniform_int_distribution d(min_value, max_value); - std::generate(out, out + n, [&d, &gen] { return static_cast(d(gen)); }); -} - -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/testing/util.h b/cpp/thirdparty/knowhere_build/include/arrow/testing/util.h deleted file mode 100644 index d12f57e3b7..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/testing/util.h +++ /dev/null @@ -1,126 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "arrow/buffer.h" -#include "arrow/record_batch.h" -#include "arrow/status.h" -#include "arrow/type_fwd.h" -#include "arrow/util/macros.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Array; -class ChunkedArray; -class Column; -class MemoryPool; -class RecordBatch; -class Table; - -using ArrayVector = std::vector>; - -template -Status CopyBufferFromVector(const std::vector& values, MemoryPool* pool, - std::shared_ptr* result) { - int64_t nbytes = static_cast(values.size()) * sizeof(T); - - std::shared_ptr buffer; - RETURN_NOT_OK(AllocateBuffer(pool, nbytes, &buffer)); - auto immutable_data = reinterpret_cast(values.data()); - std::copy(immutable_data, immutable_data + nbytes, buffer->mutable_data()); - memset(buffer->mutable_data() + nbytes, 0, - static_cast(buffer->capacity() - nbytes)); - - *result = buffer; - return Status::OK(); -} - -// Sets approximately pct_null of the first n bytes in null_bytes to zero -// and the rest to non-zero (true) values. -ARROW_EXPORT void random_null_bytes(int64_t n, double pct_null, uint8_t* null_bytes); -ARROW_EXPORT void random_is_valid(int64_t n, double pct_null, std::vector* is_valid, - int random_seed = 0); -ARROW_EXPORT void random_bytes(int64_t n, uint32_t seed, uint8_t* out); -ARROW_EXPORT int32_t DecimalSize(int32_t precision); -ARROW_EXPORT void random_decimals(int64_t n, uint32_t seed, int32_t precision, - uint8_t* out); -ARROW_EXPORT void random_ascii(int64_t n, uint32_t seed, uint8_t* out); -ARROW_EXPORT int64_t CountNulls(const std::vector& valid_bytes); - -ARROW_EXPORT Status MakeRandomByteBuffer(int64_t length, MemoryPool* pool, - std::shared_ptr* out, - uint32_t seed = 0); - -ARROW_EXPORT uint64_t random_seed(); - -template -Status MakeArray(const std::vector& valid_bytes, const std::vector& values, - int64_t size, Builder* builder, std::shared_ptr* out) { - // Append the first 1000 - for (int64_t i = 0; i < size; ++i) { - if (valid_bytes[i] > 0) { - RETURN_NOT_OK(builder->Append(values[i])); - } else { - RETURN_NOT_OK(builder->AppendNull()); - } - } - return builder->Finish(out); -} - -#define DECL_T() typedef typename TestFixture::T T; - -#define DECL_TYPE() typedef typename TestFixture::Type Type; - -// ---------------------------------------------------------------------- -// A RecordBatchReader for serving a sequence of in-memory record batches - -class BatchIterator : public RecordBatchReader { - public: - BatchIterator(const std::shared_ptr& schema, - const std::vector>& batches) - : schema_(schema), batches_(batches), position_(0) {} - - std::shared_ptr schema() const override { return schema_; } - - Status ReadNext(std::shared_ptr* out) override { - if (position_ >= batches_.size()) { - *out = nullptr; - } else { - *out = batches_[position_++]; - } - return Status::OK(); - } - - private: - std::shared_ptr schema_; - std::vector> batches_; - size_t position_; -}; - -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/type.h b/cpp/thirdparty/knowhere_build/include/arrow/type.h deleted file mode 100644 index 16f486f45f..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/type.h +++ /dev/null @@ -1,1219 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_TYPE_H -#define ARROW_TYPE_H - -#include -#include -#include -#include -#include -#include - -#include "arrow/status.h" -#include "arrow/type_fwd.h" // IWYU pragma: export -#include "arrow/util/checked_cast.h" -#include "arrow/util/macros.h" -#include "arrow/util/visibility.h" -#include "arrow/visitor.h" // IWYU pragma: keep - -namespace arrow { - -class Array; -class Field; -class MemoryPool; - -struct Type { - /// \brief Main data type enumeration - /// - /// This enumeration provides a quick way to interrogate the category - /// of a DataType instance. - enum type { - /// A NULL type having no physical storage - NA, - - /// Boolean as 1 bit, LSB bit-packed ordering - BOOL, - - /// Unsigned 8-bit little-endian integer - UINT8, - - /// Signed 8-bit little-endian integer - INT8, - - /// Unsigned 16-bit little-endian integer - UINT16, - - /// Signed 16-bit little-endian integer - INT16, - - /// Unsigned 32-bit little-endian integer - UINT32, - - /// Signed 32-bit little-endian integer - INT32, - - /// Unsigned 64-bit little-endian integer - UINT64, - - /// Signed 64-bit little-endian integer - INT64, - - /// 2-byte floating point value - HALF_FLOAT, - - /// 4-byte floating point value - FLOAT, - - /// 8-byte floating point value - DOUBLE, - - /// UTF8 variable-length string as List - STRING, - - /// Variable-length bytes (no guarantee of UTF8-ness) - BINARY, - - /// Fixed-size binary. Each value occupies the same number of bytes - FIXED_SIZE_BINARY, - - /// int32_t days since the UNIX epoch - DATE32, - - /// int64_t milliseconds since the UNIX epoch - DATE64, - - /// Exact timestamp encoded with int64 since UNIX epoch - /// Default unit millisecond - TIMESTAMP, - - /// Time as signed 32-bit integer, representing either seconds or - /// milliseconds since midnight - TIME32, - - /// Time as signed 64-bit integer, representing either microseconds or - /// nanoseconds since midnight - TIME64, - - /// YEAR_MONTH or DAY_TIME interval in SQL style - INTERVAL, - - /// Precision- and scale-based decimal type. Storage type depends on the - /// parameters. - DECIMAL, - - /// A list of some logical data type - LIST, - - /// Struct of logical types - STRUCT, - - /// Unions of logical types - UNION, - - /// Dictionary-encoded type, also called "categorical" or "factor" - /// in other programming languages. Holds the dictionary value - /// type but not the dictionary itself, which is part of the - /// ArrayData struct - DICTIONARY, - - /// Map, a repeated struct logical type - MAP, - - /// Custom data type, implemented by user - EXTENSION, - - /// Fixed size list of some logical type - FIXED_SIZE_LIST, - - /// Measure of elapsed time in either seconds, milliseconds, microseconds - /// or nanoseconds. - DURATION - }; -}; - -struct ARROW_EXPORT DataTypeLayout { - // The bit width for each buffer in this DataType's representation - // (kVariableSizeBuffer if the item size for a given buffer is unknown or variable, - // kAlwaysNullBuffer if the buffer is always null). - // Child types are not included, they should be inspected separately. - std::vector bit_widths; - bool has_dictionary; - - static constexpr int64_t kAlwaysNullBuffer = 0; - static constexpr int64_t kVariableSizeBuffer = -1; -}; - -/// \brief Base class for all data types -/// -/// Data types in this library are all *logical*. They can be expressed as -/// either a primitive physical type (bytes or bits of some fixed size), a -/// nested type consisting of other data types, or another data type (e.g. a -/// timestamp encoded as an int64). -/// -/// Simple datatypes may be entirely described by their Type::type id, but -/// complex datatypes are usually parametric. -class ARROW_EXPORT DataType { - public: - explicit DataType(Type::type id) : id_(id) {} - virtual ~DataType(); - - /// \brief Return whether the types are equal - /// - /// Types that are logically convertible from one to another (e.g. List - /// and Binary) are NOT equal. - bool Equals(const DataType& other, bool check_metadata = true) const; - - /// \brief Return whether the types are equal - bool Equals(const std::shared_ptr& other) const; - - std::shared_ptr child(int i) const { return children_[i]; } - - const std::vector>& children() const { return children_; } - - int num_children() const { return static_cast(children_.size()); } - - Status Accept(TypeVisitor* visitor) const; - - /// \brief A string representation of the type, including any children - virtual std::string ToString() const = 0; - - /// \brief A string name of the type, omitting any child fields - /// - /// \note Experimental API - /// \since 0.7.0 - virtual std::string name() const = 0; - - /// \brief Return the data type layout. Children are not included. - /// - /// \note Experimental API - virtual DataTypeLayout layout() const = 0; - - /// \brief Return the type category - Type::type id() const { return id_; } - - protected: - Type::type id_; - std::vector> children_; - - private: - ARROW_DISALLOW_COPY_AND_ASSIGN(DataType); -}; - -std::ostream& operator<<(std::ostream& os, const DataType& type); - -/// \brief Base class for all fixed-width data types -class ARROW_EXPORT FixedWidthType : public DataType { - public: - using DataType::DataType; - - virtual int bit_width() const = 0; -}; - -/// \brief Base class for all data types representing primitive values -class ARROW_EXPORT PrimitiveCType : public FixedWidthType { - public: - using FixedWidthType::FixedWidthType; -}; - -/// \brief Base class for all numeric data types -class ARROW_EXPORT NumberType : public PrimitiveCType { - public: - using PrimitiveCType::PrimitiveCType; -}; - -/// \brief Base class for all integral data types -class ARROW_EXPORT IntegerType : public NumberType { - public: - using NumberType::NumberType; - virtual bool is_signed() const = 0; -}; - -/// \brief Base class for all floating-point data types -class ARROW_EXPORT FloatingPointType : public NumberType { - public: - using NumberType::NumberType; - enum Precision { HALF, SINGLE, DOUBLE }; - virtual Precision precision() const = 0; -}; - -/// \brief Base class for all parametric data types -class ParametricType {}; - -class ARROW_EXPORT NestedType : public DataType, public ParametricType { - public: - using DataType::DataType; -}; - -class NoExtraMeta {}; - -/// \brief The combination of a field name and data type, with optional metadata -/// -/// Fields are used to describe the individual constituents of a -/// nested DataType or a Schema. -/// -/// A field's metadata is represented by a KeyValueMetadata instance, -/// which holds arbitrary key-value pairs. -class ARROW_EXPORT Field { - public: - Field(const std::string& name, const std::shared_ptr& type, - bool nullable = true, - const std::shared_ptr& metadata = NULLPTR) - : name_(name), type_(type), nullable_(nullable), metadata_(metadata) {} - - /// \brief Return the field's attached metadata - std::shared_ptr metadata() const { return metadata_; } - - /// \brief Return whether the field has non-empty metadata - bool HasMetadata() const; - - /// \brief Return a copy of this field with the given metadata attached to it - std::shared_ptr AddMetadata( - const std::shared_ptr& metadata) const; - /// \brief Return a copy of this field without any metadata attached to it - std::shared_ptr RemoveMetadata() const; - - /// \brief Return a copy of this field with the replaced type. - std::shared_ptr WithType(const std::shared_ptr& type) const; - - /// \brief Return a copy of this field with the replaced name. - std::shared_ptr WithName(const std::string& name) const; - - std::vector> Flatten() const; - - bool Equals(const Field& other, bool check_metadata = true) const; - bool Equals(const std::shared_ptr& other, bool check_metadata = true) const; - - /// \brief Return a string representation ot the field - std::string ToString() const; - - /// \brief Return the field name - const std::string& name() const { return name_; } - /// \brief Return the field data type - std::shared_ptr type() const { return type_; } - /// \brief Return whether the field is nullable - bool nullable() const { return nullable_; } - - std::shared_ptr Copy() const; - - private: - // Field name - std::string name_; - - // The field's data type - std::shared_ptr type_; - - // Fields can be nullable - bool nullable_; - - // The field's metadata, if any - std::shared_ptr metadata_; - - ARROW_DISALLOW_COPY_AND_ASSIGN(Field); -}; - -namespace detail { - -template -class ARROW_EXPORT CTypeImpl : public BASE { - public: - using c_type = C_TYPE; - static constexpr Type::type type_id = TYPE_ID; - - CTypeImpl() : BASE(TYPE_ID) {} - - int bit_width() const override { return static_cast(sizeof(C_TYPE) * CHAR_BIT); } - - DataTypeLayout layout() const override { return {{1, bit_width()}, false}; } - - std::string ToString() const override { return this->name(); } -}; - -template -class IntegerTypeImpl : public detail::CTypeImpl { - bool is_signed() const override { return std::is_signed::value; } -}; - -} // namespace detail - -/// Concrete type class for always-null data -class ARROW_EXPORT NullType : public DataType, public NoExtraMeta { - public: - static constexpr Type::type type_id = Type::NA; - - NullType() : DataType(Type::NA) {} - - std::string ToString() const override; - - DataTypeLayout layout() const override { - return {{DataTypeLayout::kAlwaysNullBuffer}, false}; - } - - std::string name() const override { return "null"; } -}; - -/// Concrete type class for boolean data -class ARROW_EXPORT BooleanType : public FixedWidthType, public NoExtraMeta { - public: - static constexpr Type::type type_id = Type::BOOL; - - BooleanType() : FixedWidthType(Type::BOOL) {} - - std::string ToString() const override; - - DataTypeLayout layout() const override { return {{1, 1}, false}; } - - int bit_width() const override { return 1; } - std::string name() const override { return "bool"; } -}; - -/// Concrete type class for unsigned 8-bit integer data -class ARROW_EXPORT UInt8Type - : public detail::IntegerTypeImpl { - public: - std::string name() const override { return "uint8"; } -}; - -/// Concrete type class for signed 8-bit integer data -class ARROW_EXPORT Int8Type - : public detail::IntegerTypeImpl { - public: - std::string name() const override { return "int8"; } -}; - -/// Concrete type class for unsigned 16-bit integer data -class ARROW_EXPORT UInt16Type - : public detail::IntegerTypeImpl { - public: - std::string name() const override { return "uint16"; } -}; - -/// Concrete type class for signed 16-bit integer data -class ARROW_EXPORT Int16Type - : public detail::IntegerTypeImpl { - public: - std::string name() const override { return "int16"; } -}; - -/// Concrete type class for unsigned 32-bit integer data -class ARROW_EXPORT UInt32Type - : public detail::IntegerTypeImpl { - public: - std::string name() const override { return "uint32"; } -}; - -/// Concrete type class for signed 32-bit integer data -class ARROW_EXPORT Int32Type - : public detail::IntegerTypeImpl { - public: - std::string name() const override { return "int32"; } -}; - -/// Concrete type class for unsigned 64-bit integer data -class ARROW_EXPORT UInt64Type - : public detail::IntegerTypeImpl { - public: - std::string name() const override { return "uint64"; } -}; - -/// Concrete type class for signed 64-bit integer data -class ARROW_EXPORT Int64Type - : public detail::IntegerTypeImpl { - public: - std::string name() const override { return "int64"; } -}; - -/// Concrete type class for 16-bit floating-point data -class ARROW_EXPORT HalfFloatType - : public detail::CTypeImpl { - public: - Precision precision() const override; - std::string name() const override { return "halffloat"; } -}; - -/// Concrete type class for 32-bit floating-point data (C "float") -class ARROW_EXPORT FloatType - : public detail::CTypeImpl { - public: - Precision precision() const override; - std::string name() const override { return "float"; } -}; - -/// Concrete type class for 64-bit floating-point data (C "double") -class ARROW_EXPORT DoubleType - : public detail::CTypeImpl { - public: - Precision precision() const override; - std::string name() const override { return "double"; } -}; - -/// \brief Concrete type class for list data -/// -/// List data is nested data where each value is a variable number of -/// child items. Lists can be recursively nested, for example -/// list(list(int32)). -class ARROW_EXPORT ListType : public NestedType { - public: - static constexpr Type::type type_id = Type::LIST; - - // List can contain any other logical value type - explicit ListType(const std::shared_ptr& value_type) - : ListType(std::make_shared("item", value_type)) {} - - explicit ListType(const std::shared_ptr& value_field) : NestedType(Type::LIST) { - children_ = {value_field}; - } - - std::shared_ptr value_field() const { return children_[0]; } - - std::shared_ptr value_type() const { return children_[0]->type(); } - - DataTypeLayout layout() const override { - return {{1, CHAR_BIT * sizeof(int32_t)}, false}; - } - - std::string ToString() const override; - - std::string name() const override { return "list"; } -}; - -/// \brief Concrete type class for map data -/// -/// Map data is nested data where each value is a variable number of -/// key-item pairs. Maps can be recursively nested, for example -/// map(utf8, map(utf8, int32)). -class ARROW_EXPORT MapType : public ListType { - public: - static constexpr Type::type type_id = Type::MAP; - - MapType(const std::shared_ptr& key_type, - const std::shared_ptr& item_type, bool keys_sorted = false); - - std::shared_ptr key_type() const { return value_type()->child(0)->type(); } - - std::shared_ptr item_type() const { return value_type()->child(1)->type(); } - - std::string ToString() const override; - - std::string name() const override { return "map"; } - - bool keys_sorted() const { return keys_sorted_; } - - private: - bool keys_sorted_; -}; - -/// \brief Concrete type class for fixed size list data -class ARROW_EXPORT FixedSizeListType : public NestedType { - public: - static constexpr Type::type type_id = Type::FIXED_SIZE_LIST; - - // List can contain any other logical value type - FixedSizeListType(const std::shared_ptr& value_type, int32_t list_size) - : FixedSizeListType(std::make_shared("item", value_type), list_size) {} - - FixedSizeListType(const std::shared_ptr& value_field, int32_t list_size) - : NestedType(type_id), list_size_(list_size) { - children_ = {value_field}; - } - - std::shared_ptr value_field() const { return children_[0]; } - - std::shared_ptr value_type() const { return children_[0]->type(); } - - DataTypeLayout layout() const override { return {{1}, false}; } - - std::string ToString() const override; - - std::string name() const override { return "fixed_size_list"; } - - int32_t list_size() const { return list_size_; } - - protected: - int32_t list_size_; -}; - -/// \brief Concrete type class for variable-size binary data -class ARROW_EXPORT BinaryType : public DataType, public NoExtraMeta { - public: - static constexpr Type::type type_id = Type::BINARY; - - BinaryType() : BinaryType(Type::BINARY) {} - - DataTypeLayout layout() const override { - return {{1, CHAR_BIT * sizeof(int32_t), DataTypeLayout::kVariableSizeBuffer}, false}; - } - - std::string ToString() const override; - std::string name() const override { return "binary"; } - - protected: - // Allow subclasses to change the logical type. - explicit BinaryType(Type::type logical_type) : DataType(logical_type) {} -}; - -/// \brief Concrete type class for fixed-size binary data -class ARROW_EXPORT FixedSizeBinaryType : public FixedWidthType, public ParametricType { - public: - static constexpr Type::type type_id = Type::FIXED_SIZE_BINARY; - - explicit FixedSizeBinaryType(int32_t byte_width) - : FixedWidthType(Type::FIXED_SIZE_BINARY), byte_width_(byte_width) {} - explicit FixedSizeBinaryType(int32_t byte_width, Type::type override_type_id) - : FixedWidthType(override_type_id), byte_width_(byte_width) {} - - std::string ToString() const override; - std::string name() const override { return "fixed_size_binary"; } - - DataTypeLayout layout() const override { return {{1, bit_width()}, false}; } - - int32_t byte_width() const { return byte_width_; } - int bit_width() const override; - - protected: - int32_t byte_width_; -}; - -/// \brief Concrete type class for variable-size string data, utf8-encoded -class ARROW_EXPORT StringType : public BinaryType { - public: - static constexpr Type::type type_id = Type::STRING; - - StringType() : BinaryType(Type::STRING) {} - - std::string ToString() const override; - std::string name() const override { return "utf8"; } -}; - -/// \brief Concrete type class for struct data -class ARROW_EXPORT StructType : public NestedType { - public: - static constexpr Type::type type_id = Type::STRUCT; - - explicit StructType(const std::vector>& fields); - - ~StructType() override; - - DataTypeLayout layout() const override { return {{1}, false}; } - - std::string ToString() const override; - std::string name() const override { return "struct"; } - - /// Returns null if name not found - std::shared_ptr GetFieldByName(const std::string& name) const; - - /// Return all fields having this name - std::vector> GetAllFieldsByName(const std::string& name) const; - - /// Returns -1 if name not found or if there are multiple fields having the - /// same name - int GetFieldIndex(const std::string& name) const; - - /// Return the indices of all fields having this name - std::vector GetAllFieldIndices(const std::string& name) const; - - ARROW_DEPRECATED("Use GetFieldByName") - std::shared_ptr GetChildByName(const std::string& name) const; - - ARROW_DEPRECATED("Use GetFieldIndex") - int GetChildIndex(const std::string& name) const; - - private: - class Impl; - std::unique_ptr impl_; -}; - -/// \brief Base type class for (fixed-size) decimal data -class ARROW_EXPORT DecimalType : public FixedSizeBinaryType { - public: - explicit DecimalType(int32_t byte_width, int32_t precision, int32_t scale) - : FixedSizeBinaryType(byte_width, Type::DECIMAL), - precision_(precision), - scale_(scale) {} - - int32_t precision() const { return precision_; } - int32_t scale() const { return scale_; } - - protected: - int32_t precision_; - int32_t scale_; -}; - -/// \brief Concrete type class for 128-bit decimal data -class ARROW_EXPORT Decimal128Type : public DecimalType { - public: - static constexpr Type::type type_id = Type::DECIMAL; - - explicit Decimal128Type(int32_t precision, int32_t scale); - - std::string ToString() const override; - std::string name() const override { return "decimal"; } -}; - -struct UnionMode { - enum type { SPARSE, DENSE }; -}; - -/// \brief Concrete type class for union data -class ARROW_EXPORT UnionType : public NestedType { - public: - static constexpr Type::type type_id = Type::UNION; - - UnionType(const std::vector>& fields, - const std::vector& type_codes, - UnionMode::type mode = UnionMode::SPARSE); - - DataTypeLayout layout() const override; - - std::string ToString() const override; - std::string name() const override { return "union"; } - - const std::vector& type_codes() const { return type_codes_; } - - UnionMode::type mode() const { return mode_; } - - private: - UnionMode::type mode_; - - // The type id used in the data to indicate each data type in the union. For - // example, the first type in the union might be denoted by the id 5 (instead - // of 0). - std::vector type_codes_; -}; - -// ---------------------------------------------------------------------- -// Date and time types - -enum class DateUnit : char { DAY = 0, MILLI = 1 }; - -/// \brief Base type for all date and time types -class ARROW_EXPORT TemporalType : public FixedWidthType { - public: - using FixedWidthType::FixedWidthType; - - DataTypeLayout layout() const override { return {{1, bit_width()}, false}; } -}; - -/// \brief Base type class for date data -class ARROW_EXPORT DateType : public TemporalType { - public: - virtual DateUnit unit() const = 0; - - protected: - explicit DateType(Type::type type_id); -}; - -/// Concrete type class for 32-bit date data (as number of days since UNIX epoch) -class ARROW_EXPORT Date32Type : public DateType { - public: - static constexpr Type::type type_id = Type::DATE32; - static constexpr DateUnit UNIT = DateUnit::DAY; - - using c_type = int32_t; - - Date32Type(); - - int bit_width() const override { return static_cast(sizeof(c_type) * CHAR_BIT); } - - std::string ToString() const override; - - std::string name() const override { return "date32"; } - DateUnit unit() const override { return UNIT; } -}; - -/// Concrete type class for 64-bit date data (as number of milliseconds since UNIX epoch) -class ARROW_EXPORT Date64Type : public DateType { - public: - static constexpr Type::type type_id = Type::DATE64; - static constexpr DateUnit UNIT = DateUnit::MILLI; - - using c_type = int64_t; - - Date64Type(); - - int bit_width() const override { return static_cast(sizeof(c_type) * CHAR_BIT); } - - std::string ToString() const override; - - std::string name() const override { return "date64"; } - DateUnit unit() const override { return UNIT; } -}; - -struct TimeUnit { - /// The unit for a time or timestamp DataType - enum type { SECOND = 0, MILLI = 1, MICRO = 2, NANO = 3 }; -}; - -std::ostream& operator<<(std::ostream& os, TimeUnit::type unit); - -/// Base type class for time data -class ARROW_EXPORT TimeType : public TemporalType, public ParametricType { - public: - TimeUnit::type unit() const { return unit_; } - - protected: - TimeType(Type::type type_id, TimeUnit::type unit); - TimeUnit::type unit_; -}; - -/// Concrete type class for 32-bit time data (as number of seconds or milliseconds -/// since midnight) -class ARROW_EXPORT Time32Type : public TimeType { - public: - static constexpr Type::type type_id = Type::TIME32; - using c_type = int32_t; - - int bit_width() const override { return static_cast(sizeof(c_type) * CHAR_BIT); } - - explicit Time32Type(TimeUnit::type unit = TimeUnit::MILLI); - - std::string ToString() const override; - - std::string name() const override { return "time32"; } -}; - -/// Concrete type class for 64-bit time data (as number of microseconds or nanoseconds -/// since midnight) -class ARROW_EXPORT Time64Type : public TimeType { - public: - static constexpr Type::type type_id = Type::TIME64; - using c_type = int64_t; - - int bit_width() const override { return static_cast(sizeof(c_type) * CHAR_BIT); } - - explicit Time64Type(TimeUnit::type unit = TimeUnit::NANO); - - std::string ToString() const override; - - std::string name() const override { return "time64"; } -}; - -/// \brief Concrete type class for datetime data (as number of seconds, milliseconds, -/// microseconds or nanoseconds since UNIX epoch) -/// -/// If supplied, the timezone string should take either the form (i) "Area/Location", -/// with values drawn from the names in the IANA Time Zone Database (such as -/// "Europe/Zurich"); or (ii) "(+|-)HH:MM" indicating an absolute offset from GMT -/// (such as "-08:00"). To indicate a native UTC timestamp, one of the strings "UTC", -/// "Etc/UTC" or "+00:00" should be used. -/// -/// If any non-empty string is supplied as the timezone for a TimestampType, then the -/// Arrow field containing that timestamp type (and by extension the column associated -/// with such a field) is considered "timezone-aware". The integer arrays that comprise -/// a timezone-aware column must contain UTC normalized datetime values, regardless of -/// the contents of their timezone string. More precisely, (i) the producer of a -/// timezone-aware column must populate its constituent arrays with valid UTC values -/// (performing offset conversions from non-UTC values if necessary); and (ii) the -/// consumer of a timezone-aware column may assume that the column's values are directly -/// comparable (that is, with no offset adjustment required) to the values of any other -/// timezone-aware column or to any other valid UTC datetime value (provided all values -/// are expressed in the same units). -/// -/// If a TimestampType is constructed without a timezone (or, equivalently, if the -/// timezone supplied is an empty string) then the resulting Arrow field (column) is -/// considered "timezone-naive". The producer of a timezone-naive column may populate -/// its constituent integer arrays with datetime values from any timezone; the consumer -/// of a timezone-naive column should make no assumptions about the interoperability or -/// comparability of the values of such a column with those of any other timestamp -/// column or datetime value. -/// -/// If a timezone-aware field contains a recognized timezone, its values may be -/// localized to that locale upon display; the values of timezone-naive fields must -/// always be displayed "as is", with no localization performed on them. -class ARROW_EXPORT TimestampType : public TemporalType, public ParametricType { - public: - using Unit = TimeUnit; - - typedef int64_t c_type; - static constexpr Type::type type_id = Type::TIMESTAMP; - - int bit_width() const override { return static_cast(sizeof(int64_t) * CHAR_BIT); } - - explicit TimestampType(TimeUnit::type unit = TimeUnit::MILLI) - : TemporalType(Type::TIMESTAMP), unit_(unit) {} - - explicit TimestampType(TimeUnit::type unit, const std::string& timezone) - : TemporalType(Type::TIMESTAMP), unit_(unit), timezone_(timezone) {} - - std::string ToString() const override; - std::string name() const override { return "timestamp"; } - - TimeUnit::type unit() const { return unit_; } - const std::string& timezone() const { return timezone_; } - - private: - TimeUnit::type unit_; - std::string timezone_; -}; - -// Base class for the different kinds of intervals. -class ARROW_EXPORT IntervalType : public TemporalType, public ParametricType { - public: - enum type { MONTHS, DAY_TIME }; - IntervalType() : TemporalType(Type::INTERVAL) {} - - virtual type interval_type() const = 0; - virtual ~IntervalType() = default; -}; - -/// \brief Represents a some number of months. -/// -/// Type representing a number of months. Corresponeds to YearMonth type -/// in Schema.fbs (Years are defined as 12 months). -class ARROW_EXPORT MonthIntervalType : public IntervalType { - public: - using c_type = int32_t; - static constexpr Type::type type_id = Type::INTERVAL; - - IntervalType::type interval_type() const override { return IntervalType::MONTHS; } - - int bit_width() const override { return static_cast(sizeof(c_type) * CHAR_BIT); } - - MonthIntervalType() : IntervalType() {} - - std::string ToString() const override { return name(); } - std::string name() const override { return "month_interval"; } -}; - -/// \brief Represents a number of days and milliseconds (fraction of day). -class ARROW_EXPORT DayTimeIntervalType : public IntervalType { - public: - struct DayMilliseconds { - int32_t days; - int32_t milliseconds; - bool operator==(DayMilliseconds other) const { - return this->days == other.days && this->milliseconds == other.milliseconds; - } - bool operator!=(DayMilliseconds other) const { return !(*this == other); } - }; - using c_type = DayMilliseconds; - static_assert(sizeof(DayMilliseconds) == 8, - "DayMilliseconds struct assumed to be of size 8 bytes"); - static constexpr Type::type type_id = Type::INTERVAL; - IntervalType::type interval_type() const override { return IntervalType::DAY_TIME; } - - DayTimeIntervalType() : IntervalType() {} - - int bit_width() const override { return static_cast(sizeof(c_type) * CHAR_BIT); } - - std::string ToString() const override { return name(); } - std::string name() const override { return "day_time_interval"; } -}; - -// \brief Represents an amount of elapsed time without any relation to a calendar -// artifact. -class ARROW_EXPORT DurationType : public TemporalType, public ParametricType { - public: - using Unit = TimeUnit; - - static constexpr Type::type type_id = Type::DURATION; - using c_type = int64_t; - - int bit_width() const override { return static_cast(sizeof(int64_t) * CHAR_BIT); } - - explicit DurationType(TimeUnit::type unit = TimeUnit::MILLI) - : TemporalType(Type::DURATION), unit_(unit) {} - - std::string ToString() const override; - std::string name() const override { return "duration"; } - - TimeUnit::type unit() const { return unit_; } - - private: - TimeUnit::type unit_; -}; - -// ---------------------------------------------------------------------- -// Dictionary type (for representing categorical or dictionary-encoded -// in memory) - -/// \brief Dictionary-encoded value type with data-dependent -/// dictionary -class ARROW_EXPORT DictionaryType : public FixedWidthType { - public: - static constexpr Type::type type_id = Type::DICTIONARY; - - DictionaryType(const std::shared_ptr& index_type, - const std::shared_ptr& value_type, bool ordered = false); - - std::string ToString() const override; - std::string name() const override { return "dictionary"; } - - int bit_width() const override; - - DataTypeLayout layout() const override; - - std::shared_ptr index_type() const { return index_type_; } - std::shared_ptr value_type() const { return value_type_; } - - bool ordered() const { return ordered_; } - - /// \brief Unify dictionaries types - /// - /// Compute a resulting dictionary that will allow the union of values - /// of all input dictionary types. The input types must all have the - /// same value type. - /// \param[in] pool Memory pool to allocate dictionary values from - /// \param[in] types A sequence of input dictionary types - /// \param[in] dictionaries A sequence of input dictionaries - /// corresponding to each type - /// \param[out] out_type The unified dictionary type - /// \param[out] out_dictionary The unified dictionary - /// \param[out] out_transpose_maps (optionally) A sequence of integer vectors, - /// one per input type. Each integer vector represents the transposition - /// of input type indices into unified type indices. - // XXX Should we return something special (an empty transpose map?) when - // the transposition is the identity function? - static Status Unify(MemoryPool* pool, const std::vector& types, - const std::vector& dictionaries, - std::shared_ptr* out_type, - std::shared_ptr* out_dictionary, - std::vector>* out_transpose_maps = NULLPTR); - - protected: - // Must be an integer type (not currently checked) - std::shared_ptr index_type_; - std::shared_ptr value_type_; - bool ordered_; -}; - -// ---------------------------------------------------------------------- -// Schema - -/// \class Schema -/// \brief Sequence of arrow::Field objects describing the columns of a record -/// batch or table data structure -class ARROW_EXPORT Schema { - public: - explicit Schema(const std::vector>& fields, - const std::shared_ptr& metadata = NULLPTR); - - explicit Schema(std::vector>&& fields, - const std::shared_ptr& metadata = NULLPTR); - - Schema(const Schema&); - - virtual ~Schema(); - - /// Returns true if all of the schema fields are equal - bool Equals(const Schema& other, bool check_metadata = true) const; - - /// \brief Return the number of fields (columns) in the schema - int num_fields() const; - - /// Return the ith schema element. Does not boundscheck - std::shared_ptr field(int i) const; - - const std::vector>& fields() const; - - std::vector field_names() const; - - /// Returns null if name not found - std::shared_ptr GetFieldByName(const std::string& name) const; - - /// Return all fields having this name - std::vector> GetAllFieldsByName(const std::string& name) const; - - /// Returns -1 if name not found - int GetFieldIndex(const std::string& name) const; - - /// Return the indices of all fields having this name - std::vector GetAllFieldIndices(const std::string& name) const; - - /// \brief The custom key-value metadata, if any - /// - /// \return metadata may be null - std::shared_ptr metadata() const; - - /// \brief Render a string representation of the schema suitable for debugging - std::string ToString() const; - - Status AddField(int i, const std::shared_ptr& field, - std::shared_ptr* out) const; - Status RemoveField(int i, std::shared_ptr* out) const; - Status SetField(int i, const std::shared_ptr& field, - std::shared_ptr* out) const; - - /// \brief Replace key-value metadata with new metadata - /// - /// \param[in] metadata new KeyValueMetadata - /// \return new Schema - std::shared_ptr AddMetadata( - const std::shared_ptr& metadata) const; - - /// \brief Return copy of Schema without the KeyValueMetadata - std::shared_ptr RemoveMetadata() const; - - /// \brief Indicates that Schema has non-empty KevValueMetadata - bool HasMetadata() const; - - private: - class Impl; - std::unique_ptr impl_; -}; - -// ---------------------------------------------------------------------- -// Parametric factory functions -// Other factory functions are in type_fwd.h - -/// \addtogroup type-factories -/// @{ - -/// \brief Create a FixedSizeBinaryType instance. -ARROW_EXPORT -std::shared_ptr fixed_size_binary(int32_t byte_width); - -/// \brief Create a Decimal128Type instance -ARROW_EXPORT -std::shared_ptr decimal(int32_t precision, int32_t scale); - -/// \brief Create a ListType instance from its child Field type -ARROW_EXPORT -std::shared_ptr list(const std::shared_ptr& value_type); - -/// \brief Create a ListType instance from its child DataType -ARROW_EXPORT -std::shared_ptr list(const std::shared_ptr& value_type); - -/// \brief Create a MapType instance from its key and value DataTypes -ARROW_EXPORT -std::shared_ptr map(const std::shared_ptr& key_type, - const std::shared_ptr& value_type, - bool keys_sorted = false); - -/// \brief Create a FixedSizeListType instance from its child Field type -ARROW_EXPORT -std::shared_ptr fixed_size_list(const std::shared_ptr& value_type, - int32_t list_size); - -/// \brief Create a FixedSizeListType instance from its child DataType -ARROW_EXPORT -std::shared_ptr fixed_size_list(const std::shared_ptr& value_type, - int32_t list_size); -/// \brief Return an Duration instance (naming use _type to avoid namespace conflict with -/// built in time clases). -std::shared_ptr ARROW_EXPORT duration(TimeUnit::type unit); - -/// \brief Return an DayTimeIntervalType instance -std::shared_ptr ARROW_EXPORT day_time_interval(); - -/// \brief Return an MonthIntervalType instance -std::shared_ptr ARROW_EXPORT month_interval(); - -/// \brief Create a TimestampType instance from its unit -ARROW_EXPORT -std::shared_ptr timestamp(TimeUnit::type unit); - -/// \brief Create a TimestampType instance from its unit and timezone -ARROW_EXPORT -std::shared_ptr timestamp(TimeUnit::type unit, const std::string& timezone); - -/// \brief Create a 32-bit time type instance -/// -/// Unit can be either SECOND or MILLI -std::shared_ptr ARROW_EXPORT time32(TimeUnit::type unit); - -/// \brief Create a 64-bit time type instance -/// -/// Unit can be either MICRO or NANO -std::shared_ptr ARROW_EXPORT time64(TimeUnit::type unit); - -/// \brief Create a StructType instance -std::shared_ptr ARROW_EXPORT -struct_(const std::vector>& fields); - -/// \brief Create a UnionType instance -std::shared_ptr ARROW_EXPORT -union_(const std::vector>& child_fields, - const std::vector& type_codes, UnionMode::type mode = UnionMode::SPARSE); - -/// \brief Create a UnionType instance -std::shared_ptr ARROW_EXPORT -union_(const std::vector>& children, - const std::vector& field_names, - const std::vector& type_codes, UnionMode::type mode = UnionMode::SPARSE); - -/// \brief Create a UnionType instance -inline std::shared_ptr ARROW_EXPORT -union_(const std::vector>& children, - const std::vector& field_names, - UnionMode::type mode = UnionMode::SPARSE) { - return union_(children, field_names, {}, mode); -} - -/// \brief Create a UnionType instance -inline std::shared_ptr ARROW_EXPORT -union_(const std::vector>& children, - UnionMode::type mode = UnionMode::SPARSE) { - return union_(children, {}, {}, mode); -} - -/// \brief Create a DictionaryType instance -/// \param[in] index_type the type of the dictionary indices (must be -/// a signed integer) -/// \param[in] dict_type the type of the values in the variable dictionary -/// \param[in] ordered true if the order of the dictionary values has -/// semantic meaning and should be preserved where possible -ARROW_EXPORT -std::shared_ptr dictionary(const std::shared_ptr& index_type, - const std::shared_ptr& dict_type, - bool ordered = false); - -/// @} - -/// \defgroup schema-factories Factory functions for fields and schemas -/// -/// Factory functions for fields and schemas -/// @{ - -/// \brief Create a Field instance -/// -/// \param name the field name -/// \param type the field value type -/// \param nullable whether the values are nullable, default true -/// \param metadata any custom key-value metadata, default null -std::shared_ptr ARROW_EXPORT field( - const std::string& name, const std::shared_ptr& type, bool nullable = true, - const std::shared_ptr& metadata = NULLPTR); - -/// \brief Create a Schema instance -/// -/// \param fields the schema's fields -/// \param metadata any custom key-value metadata, default null -/// \return schema shared_ptr to Schema -ARROW_EXPORT -std::shared_ptr schema( - const std::vector>& fields, - const std::shared_ptr& metadata = NULLPTR); - -/// \brief Create a Schema instance -/// -/// \param fields the schema's fields (rvalue reference) -/// \param metadata any custom key-value metadata, default null -/// \return schema shared_ptr to Schema -ARROW_EXPORT -std::shared_ptr schema( - std::vector>&& fields, - const std::shared_ptr& metadata = NULLPTR); - -/// @} - -} // namespace arrow - -#endif // ARROW_TYPE_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/type_fwd.h b/cpp/thirdparty/knowhere_build/include/arrow/type_fwd.h deleted file mode 100644 index ea32b49d16..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/type_fwd.h +++ /dev/null @@ -1,233 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_TYPE_FWD_H -#define ARROW_TYPE_FWD_H - -#include - -#include "arrow/util/iterator.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Status; - -class DataType; -class KeyValueMetadata; -class Array; -struct ArrayData; -class ArrayBuilder; -class Field; -class Tensor; - -class ChunkedArray; -class Column; -class RecordBatch; -class Table; - -using RecordBatchIterator = Iterator>; - -class Buffer; -class MemoryPool; -class RecordBatch; -class Schema; - -class DictionaryType; -class DictionaryArray; -class DictionaryScalar; - -class NullType; -class NullArray; -class NullBuilder; -struct NullScalar; - -class BooleanType; -class BooleanArray; -class BooleanBuilder; -struct BooleanScalar; - -class BinaryType; -class BinaryArray; -class BinaryBuilder; -struct BinaryScalar; - -class FixedSizeBinaryType; -class FixedSizeBinaryArray; -class FixedSizeBinaryBuilder; -struct FixedSizeBinaryScalar; - -class StringType; -class StringArray; -class StringBuilder; -struct StringScalar; - -class ListType; -class ListArray; -class ListBuilder; -struct ListScalar; - -class MapType; -class MapArray; -class MapBuilder; -struct MapScalar; - -class FixedSizeListType; -class FixedSizeListArray; -class FixedSizeListBuilder; -struct FixedSizeListScalar; - -class StructType; -class StructArray; -class StructBuilder; -struct StructScalar; - -class Decimal128Type; -class Decimal128Array; -class Decimal128Builder; -struct Decimal128Scalar; - -class UnionType; -class UnionArray; -class UnionScalar; - -template -class NumericArray; - -template -class NumericBuilder; - -template -class NumericTensor; - -template -struct NumericScalar; - -#define _NUMERIC_TYPE_DECL(KLASS) \ - class KLASS##Type; \ - using KLASS##Array = NumericArray; \ - using KLASS##Builder = NumericBuilder; \ - using KLASS##Scalar = NumericScalar; \ - using KLASS##Tensor = NumericTensor; - -_NUMERIC_TYPE_DECL(Int8) -_NUMERIC_TYPE_DECL(Int16) -_NUMERIC_TYPE_DECL(Int32) -_NUMERIC_TYPE_DECL(Int64) -_NUMERIC_TYPE_DECL(UInt8) -_NUMERIC_TYPE_DECL(UInt16) -_NUMERIC_TYPE_DECL(UInt32) -_NUMERIC_TYPE_DECL(UInt64) -_NUMERIC_TYPE_DECL(HalfFloat) -_NUMERIC_TYPE_DECL(Float) -_NUMERIC_TYPE_DECL(Double) - -#undef _NUMERIC_TYPE_DECL - -class Date64Type; -using Date64Array = NumericArray; -using Date64Builder = NumericBuilder; -class Date64Scalar; - -class Date32Type; -using Date32Array = NumericArray; -using Date32Builder = NumericBuilder; -class Date32Scalar; - -class Time32Type; -using Time32Array = NumericArray; -using Time32Builder = NumericBuilder; -class Time32Scalar; - -class Time64Type; -using Time64Array = NumericArray; -using Time64Builder = NumericBuilder; -class Time64Scalar; - -class TimestampType; -using TimestampArray = NumericArray; -using TimestampBuilder = NumericBuilder; -class TimestampScalar; - -class MonthIntervalType; -using MonthIntervalArray = NumericArray; -using MonthIntervalBuilder = NumericBuilder; -class MonthIntervalScalar; - -class DayTimeIntervalType; -class DayTimeIntervalArray; -class DayTimeIntervalBuilder; -class DayTimeIntervalScalar; - -class DurationType; -using DurationArray = NumericArray; -using DurationBuilder = NumericBuilder; -class DurationScalar; - -class ExtensionType; -class ExtensionArray; -class ExtensionScalar; - -// ---------------------------------------------------------------------- -// (parameter-free) Factory functions -// Other factory functions are in type.h - -/// \defgroup type-factories Factory functions for creating data types -/// -/// Factory functions for creating data types -/// @{ - -/// \brief Return a NullType instance -std::shared_ptr ARROW_EXPORT null(); -/// \brief Return a BooleanType instance -std::shared_ptr ARROW_EXPORT boolean(); -/// \brief Return a Int8Type instance -std::shared_ptr ARROW_EXPORT int8(); -/// \brief Return a Int16Type instance -std::shared_ptr ARROW_EXPORT int16(); -/// \brief Return a Int32Type instance -std::shared_ptr ARROW_EXPORT int32(); -/// \brief Return a Int64Type instance -std::shared_ptr ARROW_EXPORT int64(); -/// \brief Return a UInt8Type instance -std::shared_ptr ARROW_EXPORT uint8(); -/// \brief Return a UInt16Type instance -std::shared_ptr ARROW_EXPORT uint16(); -/// \brief Return a UInt32Type instance -std::shared_ptr ARROW_EXPORT uint32(); -/// \brief Return a UInt64Type instance -std::shared_ptr ARROW_EXPORT uint64(); -/// \brief Return a HalfFloatType instance -std::shared_ptr ARROW_EXPORT float16(); -/// \brief Return a FloatType instance -std::shared_ptr ARROW_EXPORT float32(); -/// \brief Return a DoubleType instance -std::shared_ptr ARROW_EXPORT float64(); -/// \brief Return a StringType instance -std::shared_ptr ARROW_EXPORT utf8(); -/// \brief Return a BinaryType instance -std::shared_ptr ARROW_EXPORT binary(); -/// \brief Return a Date32Type instance -std::shared_ptr ARROW_EXPORT date32(); -/// \brief Return a Date64Type instance -std::shared_ptr ARROW_EXPORT date64(); - -/// @} - -} // namespace arrow - -#endif // ARROW_TYPE_FWD_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/type_traits.h b/cpp/thirdparty/knowhere_build/include/arrow/type_traits.h deleted file mode 100644 index 4902f5c633..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/type_traits.h +++ /dev/null @@ -1,598 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_TYPE_TRAITS_H -#define ARROW_TYPE_TRAITS_H - -#include -#include -#include -#include - -#include "arrow/type_fwd.h" -#include "arrow/util/bit-util.h" - -namespace arrow { - -// -// Per-type type traits -// - -template -struct TypeTraits {}; - -template -struct CTypeTraits {}; - -template <> -struct TypeTraits { - using ArrayType = NullArray; - using BuilderType = NullBuilder; - using ScalarType = NullScalar; - - static constexpr int64_t bytes_required(int64_t) { return 0; } - constexpr static bool is_parameter_free = true; - static inline std::shared_ptr type_singleton() { return null(); } -}; - -template <> -struct TypeTraits { - using ArrayType = BooleanArray; - using BuilderType = BooleanBuilder; - using ScalarType = BooleanScalar; - using CType = bool; - - static constexpr int64_t bytes_required(int64_t elements) { - return BitUtil::BytesForBits(elements); - } - constexpr static bool is_parameter_free = true; - static inline std::shared_ptr type_singleton() { return boolean(); } -}; - -template <> -struct CTypeTraits : public TypeTraits { - using ArrowType = BooleanType; -}; - -#define PRIMITIVE_TYPE_TRAITS_DEF_(CType_, ArrowType_, ArrowArrayType, ArrowBuilderType, \ - ArrowScalarType, ArrowTensorType, SingletonFn) \ - template <> \ - struct TypeTraits { \ - using ArrayType = ArrowArrayType; \ - using BuilderType = ArrowBuilderType; \ - using ScalarType = ArrowScalarType; \ - using TensorType = ArrowTensorType; \ - using CType = ArrowType_::c_type; \ - static constexpr int64_t bytes_required(int64_t elements) { \ - return elements * static_cast(sizeof(CType)); \ - } \ - constexpr static bool is_parameter_free = true; \ - static inline std::shared_ptr type_singleton() { return SingletonFn(); } \ - }; \ - \ - template <> \ - struct CTypeTraits : public TypeTraits { \ - using ArrowType = ArrowType_; \ - }; - -#define PRIMITIVE_TYPE_TRAITS_DEF(CType, ArrowShort, SingletonFn) \ - PRIMITIVE_TYPE_TRAITS_DEF_( \ - CType, ARROW_CONCAT(ArrowShort, Type), ARROW_CONCAT(ArrowShort, Array), \ - ARROW_CONCAT(ArrowShort, Builder), ARROW_CONCAT(ArrowShort, Scalar), \ - ARROW_CONCAT(ArrowShort, Tensor), SingletonFn) - -PRIMITIVE_TYPE_TRAITS_DEF(uint8_t, UInt8, uint8) -PRIMITIVE_TYPE_TRAITS_DEF(int8_t, Int8, int8) -PRIMITIVE_TYPE_TRAITS_DEF(uint16_t, UInt16, uint16) -PRIMITIVE_TYPE_TRAITS_DEF(int16_t, Int16, int16) -PRIMITIVE_TYPE_TRAITS_DEF(uint32_t, UInt32, uint32) -PRIMITIVE_TYPE_TRAITS_DEF(int32_t, Int32, int32) -PRIMITIVE_TYPE_TRAITS_DEF(uint64_t, UInt64, uint64) -PRIMITIVE_TYPE_TRAITS_DEF(int64_t, Int64, int64) -PRIMITIVE_TYPE_TRAITS_DEF(float, Float, float32) -PRIMITIVE_TYPE_TRAITS_DEF(double, Double, float64) - -#undef PRIMITIVE_TYPE_TRAITS_DEF -#undef PRIMITIVE_TYPE_TRAITS_DEF_ - -template <> -struct TypeTraits { - using ArrayType = Date64Array; - using BuilderType = Date64Builder; - using ScalarType = Date64Scalar; - using CType = Date64Type::c_type; - - static constexpr int64_t bytes_required(int64_t elements) { - return elements * static_cast(sizeof(int64_t)); - } - constexpr static bool is_parameter_free = true; - static inline std::shared_ptr type_singleton() { return date64(); } -}; - -template <> -struct TypeTraits { - using ArrayType = Date32Array; - using BuilderType = Date32Builder; - using ScalarType = Date32Scalar; - using CType = Date32Type::c_type; - - static constexpr int64_t bytes_required(int64_t elements) { - return elements * static_cast(sizeof(int32_t)); - } - constexpr static bool is_parameter_free = true; - static inline std::shared_ptr type_singleton() { return date32(); } -}; - -template <> -struct TypeTraits { - using ArrayType = TimestampArray; - using BuilderType = TimestampBuilder; - using ScalarType = TimestampScalar; - using CType = TimestampType::c_type; - - static constexpr int64_t bytes_required(int64_t elements) { - return elements * static_cast(sizeof(int64_t)); - } - constexpr static bool is_parameter_free = false; -}; - -template <> -struct TypeTraits { - using ArrayType = DurationArray; - using BuilderType = DurationBuilder; - using ScalarType = DurationScalar; - - static constexpr int64_t bytes_required(int64_t elements) { - return elements * static_cast(sizeof(int64_t)); - } - constexpr static bool is_parameter_free = false; -}; - -template <> -struct TypeTraits { - using ArrayType = DayTimeIntervalArray; - using BuilderType = DayTimeIntervalBuilder; - using ScalarType = DayTimeIntervalScalar; - - static constexpr int64_t bytes_required(int64_t elements) { - return elements * static_cast(sizeof(DayTimeIntervalType::DayMilliseconds)); - } - constexpr static bool is_parameter_free = true; -}; - -template <> -struct TypeTraits { - using ArrayType = MonthIntervalArray; - using BuilderType = MonthIntervalBuilder; - using ScalarType = MonthIntervalScalar; - - static constexpr int64_t bytes_required(int64_t elements) { - return elements * static_cast(sizeof(int32_t)); - } - constexpr static bool is_parameter_free = true; -}; - -template <> -struct TypeTraits { - using ArrayType = Time32Array; - using BuilderType = Time32Builder; - using ScalarType = Time32Scalar; - using CType = Time32Type::c_type; - - static constexpr int64_t bytes_required(int64_t elements) { - return elements * static_cast(sizeof(int32_t)); - } - constexpr static bool is_parameter_free = false; -}; - -template <> -struct TypeTraits { - using ArrayType = Time64Array; - using BuilderType = Time64Builder; - using ScalarType = Time64Scalar; - using CType = Time64Type::c_type; - - static constexpr int64_t bytes_required(int64_t elements) { - return elements * static_cast(sizeof(int64_t)); - } - constexpr static bool is_parameter_free = false; -}; - -template <> -struct TypeTraits { - using ArrayType = HalfFloatArray; - using BuilderType = HalfFloatBuilder; - using ScalarType = HalfFloatScalar; - using TensorType = HalfFloatTensor; - - static constexpr int64_t bytes_required(int64_t elements) { - return elements * static_cast(sizeof(uint16_t)); - } - constexpr static bool is_parameter_free = true; - static inline std::shared_ptr type_singleton() { return float16(); } -}; - -template <> -struct TypeTraits { - using ArrayType = Decimal128Array; - using BuilderType = Decimal128Builder; - using ScalarType = Decimal128Scalar; - constexpr static bool is_parameter_free = false; -}; - -template <> -struct TypeTraits { - using ArrayType = BinaryArray; - using BuilderType = BinaryBuilder; - using ScalarType = BinaryScalar; - constexpr static bool is_parameter_free = true; - static inline std::shared_ptr type_singleton() { return binary(); } -}; - -template <> -struct TypeTraits { - using ArrayType = FixedSizeBinaryArray; - using BuilderType = FixedSizeBinaryBuilder; - using ScalarType = FixedSizeBinaryScalar; - constexpr static bool is_parameter_free = false; -}; - -template <> -struct TypeTraits { - using ArrayType = StringArray; - using BuilderType = StringBuilder; - using ScalarType = StringScalar; - constexpr static bool is_parameter_free = true; - static inline std::shared_ptr type_singleton() { return utf8(); } -}; - -template <> -struct CTypeTraits : public TypeTraits { - using ArrowType = StringType; -}; - -template <> -struct CTypeTraits : public TypeTraits { - using ArrowType = StringType; -}; - -template <> -struct TypeTraits { - using ArrayType = ListArray; - using BuilderType = ListBuilder; - using ScalarType = ListScalar; - constexpr static bool is_parameter_free = false; -}; - -template <> -struct TypeTraits { - using ArrayType = MapArray; - using BuilderType = MapBuilder; - using ScalarType = MapScalar; - constexpr static bool is_parameter_free = false; -}; - -template <> -struct TypeTraits { - using ArrayType = FixedSizeListArray; - using BuilderType = FixedSizeListBuilder; - using ScalarType = FixedSizeListScalar; - constexpr static bool is_parameter_free = false; -}; - -template -struct CTypeTraits> : public TypeTraits { - using ArrowType = ListType; - - static inline std::shared_ptr type_singleton() { - return list(CTypeTraits::type_singleton()); - } -}; - -template <> -struct TypeTraits { - using ArrayType = StructArray; - using BuilderType = StructBuilder; - using ScalarType = StructScalar; - constexpr static bool is_parameter_free = false; -}; - -template <> -struct TypeTraits { - using ArrayType = UnionArray; - constexpr static bool is_parameter_free = false; -}; - -template <> -struct TypeTraits { - using ArrayType = DictionaryArray; - using ScalarType = DictionaryScalar; - constexpr static bool is_parameter_free = false; -}; - -template <> -struct TypeTraits { - using ArrayType = ExtensionArray; - constexpr static bool is_parameter_free = false; -}; - -// -// Useful type predicates -// - -template -using is_number_type = std::is_base_of; - -template -using is_integer_type = std::is_base_of; - -template -using is_floating_type = std::is_base_of; - -template -using is_temporal_type = std::is_base_of; - -template -struct has_c_type { - static constexpr bool value = - (std::is_base_of::value || std::is_base_of::value || - std::is_base_of::value || std::is_base_of::value || - std::is_base_of::value || - std::is_base_of::value); -}; - -template -struct is_8bit_int { - static constexpr bool value = - (std::is_same::value || std::is_same::value); -}; - -template -using enable_if_8bit_int = typename std::enable_if::value, R>::type; - -template -using enable_if_primitive_ctype = - typename std::enable_if::value, R>::type; - -template -using enable_if_integer = typename std::enable_if::value, R>::type; - -template -using is_signed_integer = - std::integral_constant::value && - std::is_signed::value>; - -template -using enable_if_signed_integer = - typename std::enable_if::value, R>::type; - -template -using enable_if_unsigned_integer = typename std::enable_if< - is_integer_type::value && std::is_unsigned::value, R>::type; - -template -using enable_if_floating_point = - typename std::enable_if::value, R>::type; - -template -using is_date = std::is_base_of; - -template -using enable_if_date = typename std::enable_if::value, R>::type; - -template -using is_time = std::is_base_of; - -template -using enable_if_time = typename std::enable_if::value, R>::type; - -template -using is_timestamp = std::is_base_of; - -template -using enable_if_timestamp = typename std::enable_if::value, R>::type; - -template -using enable_if_has_c_type = typename std::enable_if::value, R>::type; - -template -using enable_if_null = typename std::enable_if::value, R>::type; - -template -using enable_if_binary = - typename std::enable_if::value, R>::type; - -template -using enable_if_boolean = - typename std::enable_if::value, R>::type; - -template -using enable_if_binary_like = - typename std::enable_if::value || - std::is_base_of::value, - R>::type; - -template -using enable_if_fixed_size_binary = - typename std::enable_if::value, R>::type; - -template -using enable_if_list = - typename std::enable_if::value, R>::type; - -template -using enable_if_fixed_size_list = - typename std::enable_if::value, R>::type; - -template -using enable_if_number = typename std::enable_if::value, R>::type; - -namespace detail { - -// Not all type classes have a c_type -template -struct as_void { - using type = void; -}; - -// The partial specialization will match if T has the ATTR_NAME member -#define GET_ATTR(ATTR_NAME, DEFAULT) \ - template \ - struct GetAttr_##ATTR_NAME { \ - using type = DEFAULT; \ - }; \ - \ - template \ - struct GetAttr_##ATTR_NAME::type> { \ - using type = typename T::ATTR_NAME; \ - }; - -GET_ATTR(c_type, void) -GET_ATTR(TypeClass, void) - -#undef GET_ATTR - -} // namespace detail - -#define PRIMITIVE_TRAITS(T) \ - using TypeClass = \ - typename std::conditional::value, T, \ - typename detail::GetAttr_TypeClass::type>::type; \ - using c_type = typename detail::GetAttr_c_type::type - -template -struct IsUnsignedInt { - PRIMITIVE_TRAITS(T); - static constexpr bool value = - std::is_integral::value && std::is_unsigned::value; -}; - -template -struct IsSignedInt { - PRIMITIVE_TRAITS(T); - static constexpr bool value = - std::is_integral::value && std::is_signed::value; -}; - -template -struct IsInteger { - PRIMITIVE_TRAITS(T); - static constexpr bool value = std::is_integral::value; -}; - -template -struct IsFloatingPoint { - PRIMITIVE_TRAITS(T); - static constexpr bool value = std::is_floating_point::value; -}; - -template -struct IsNumeric { - PRIMITIVE_TRAITS(T); - static constexpr bool value = std::is_arithmetic::value; -}; - -static inline bool is_integer(Type::type type_id) { - switch (type_id) { - case Type::UINT8: - case Type::INT8: - case Type::UINT16: - case Type::INT16: - case Type::UINT32: - case Type::INT32: - case Type::UINT64: - case Type::INT64: - return true; - default: - break; - } - return false; -} - -static inline bool is_floating(Type::type type_id) { - switch (type_id) { - case Type::HALF_FLOAT: - case Type::FLOAT: - case Type::DOUBLE: - return true; - default: - break; - } - return false; -} - -static inline bool is_primitive(Type::type type_id) { - switch (type_id) { - case Type::NA: - case Type::BOOL: - case Type::UINT8: - case Type::INT8: - case Type::UINT16: - case Type::INT16: - case Type::UINT32: - case Type::INT32: - case Type::UINT64: - case Type::INT64: - case Type::HALF_FLOAT: - case Type::FLOAT: - case Type::DOUBLE: - case Type::DATE32: - case Type::DATE64: - case Type::TIME32: - case Type::TIME64: - case Type::TIMESTAMP: - case Type::INTERVAL: - return true; - default: - break; - } - return false; -} - -static inline bool is_binary_like(Type::type type_id) { - switch (type_id) { - case Type::BINARY: - case Type::STRING: - return true; - default: - break; - } - return false; -} - -static inline bool is_dictionary(Type::type type_id) { - return type_id == Type::DICTIONARY; -} - -static inline bool is_fixed_size_binary(Type::type type_id) { - switch (type_id) { - case Type::DECIMAL: - case Type::FIXED_SIZE_BINARY: - return true; - default: - break; - } - return false; -} - -static inline bool is_fixed_width(Type::type type_id) { - return is_primitive(type_id) || is_dictionary(type_id) || is_fixed_size_binary(type_id); -} - -} // namespace arrow - -#endif // ARROW_TYPE_TRAITS_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/basic_decimal.h b/cpp/thirdparty/knowhere_build/include/arrow/util/basic_decimal.h deleted file mode 100644 index 2e5857c301..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/basic_decimal.h +++ /dev/null @@ -1,175 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include -#include -#include -#include - -#include "arrow/util/macros.h" -#include "arrow/util/type_traits.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -enum class DecimalStatus { - kSuccess, - kDivideByZero, - kOverflow, - kRescaleDataLoss, -}; - -/// Represents a signed 128-bit integer in two's complement. -/// -/// This class is also compiled into LLVM IR - so, it should not have cpp references like -/// streams and boost. -class ARROW_EXPORT BasicDecimal128 { - public: - /// \brief Create a BasicDecimal128 from the two's complement representation. - constexpr BasicDecimal128(int64_t high, uint64_t low) noexcept - : low_bits_(low), high_bits_(high) {} - - /// \brief Empty constructor creates a BasicDecimal128 with a value of 0. - constexpr BasicDecimal128() noexcept : BasicDecimal128(0, 0) {} - - /// \brief Convert any integer value into a BasicDecimal128. - template ::value, T>::type> - constexpr BasicDecimal128(T value) noexcept - : BasicDecimal128(static_cast(value) >= 0 ? 0 : -1, - static_cast(value)) {} - - /// \brief Create a BasicDecimal128 from an array of bytes. Bytes are assumed to be in - /// little-endian byte order. - explicit BasicDecimal128(const uint8_t* bytes); - - /// \brief Negate the current value (in-place) - BasicDecimal128& Negate(); - - /// \brief Absolute value (in-place) - BasicDecimal128& Abs(); - - /// \brief Absolute value - static BasicDecimal128 Abs(const BasicDecimal128& left); - - /// \brief Add a number to this one. The result is truncated to 128 bits. - BasicDecimal128& operator+=(const BasicDecimal128& right); - - /// \brief Subtract a number from this one. The result is truncated to 128 bits. - BasicDecimal128& operator-=(const BasicDecimal128& right); - - /// \brief Multiply this number by another number. The result is truncated to 128 bits. - BasicDecimal128& operator*=(const BasicDecimal128& right); - - /// Divide this number by right and return the result. - /// - /// This operation is not destructive. - /// The answer rounds to zero. Signs work like: - /// 21 / 5 -> 4, 1 - /// -21 / 5 -> -4, -1 - /// 21 / -5 -> -4, 1 - /// -21 / -5 -> 4, -1 - /// \param[in] divisor the number to divide by - /// \param[out] result the quotient - /// \param[out] remainder the remainder after the division - DecimalStatus Divide(const BasicDecimal128& divisor, BasicDecimal128* result, - BasicDecimal128* remainder) const; - - /// \brief In-place division. - BasicDecimal128& operator/=(const BasicDecimal128& right); - - /// \brief Bitwise "or" between two BasicDecimal128. - BasicDecimal128& operator|=(const BasicDecimal128& right); - - /// \brief Bitwise "and" between two BasicDecimal128. - BasicDecimal128& operator&=(const BasicDecimal128& right); - - /// \brief Shift left by the given number of bits. - BasicDecimal128& operator<<=(uint32_t bits); - - /// \brief Shift right by the given number of bits. Negative values will - BasicDecimal128& operator>>=(uint32_t bits); - - /// \brief Get the high bits of the two's complement representation of the number. - inline int64_t high_bits() const { return high_bits_; } - - /// \brief Get the low bits of the two's complement representation of the number. - inline uint64_t low_bits() const { return low_bits_; } - - /// \brief Return the raw bytes of the value in little-endian byte order. - std::array ToBytes() const; - void ToBytes(uint8_t* out) const; - - /// \brief seperate the integer and fractional parts for the given scale. - void GetWholeAndFraction(int32_t scale, BasicDecimal128* whole, - BasicDecimal128* fraction) const; - - /// \brief Scale multiplier for given scale value. - static const BasicDecimal128& GetScaleMultiplier(int32_t scale); - - /// \brief Convert BasicDecimal128 from one scale to another - DecimalStatus Rescale(int32_t original_scale, int32_t new_scale, - BasicDecimal128* out) const; - - /// \brief Scale up. - BasicDecimal128 IncreaseScaleBy(int32_t increase_by) const; - - /// \brief Scale down. - /// - If 'round' is true, the right-most digits are dropped and the result value is - /// rounded up (+1 for +ve, -1 for -ve) based on the value of the dropped digits - /// (>= 10^reduce_by / 2). - /// - If 'round' is false, the right-most digits are simply dropped. - BasicDecimal128 ReduceScaleBy(int32_t reduce_by, bool round = true) const; - - // returns 1 for positive and zero decimal values, -1 for negative decimal values. - inline int64_t Sign() const { return 1 | (high_bits_ >> 63); } - - /// \brief count the number of leading binary zeroes. - int32_t CountLeadingBinaryZeros() const; - - /// \brief Get the maximum valid unscaled decimal value. - static const BasicDecimal128& GetMaxValue(); - - private: - uint64_t low_bits_; - int64_t high_bits_; -}; - -ARROW_EXPORT bool operator==(const BasicDecimal128& left, const BasicDecimal128& right); -ARROW_EXPORT bool operator!=(const BasicDecimal128& left, const BasicDecimal128& right); -ARROW_EXPORT bool operator<(const BasicDecimal128& left, const BasicDecimal128& right); -ARROW_EXPORT bool operator<=(const BasicDecimal128& left, const BasicDecimal128& right); -ARROW_EXPORT bool operator>(const BasicDecimal128& left, const BasicDecimal128& right); -ARROW_EXPORT bool operator>=(const BasicDecimal128& left, const BasicDecimal128& right); - -ARROW_EXPORT BasicDecimal128 operator-(const BasicDecimal128& operand); -ARROW_EXPORT BasicDecimal128 operator~(const BasicDecimal128& operand); -ARROW_EXPORT BasicDecimal128 operator+(const BasicDecimal128& left, - const BasicDecimal128& right); -ARROW_EXPORT BasicDecimal128 operator-(const BasicDecimal128& left, - const BasicDecimal128& right); -ARROW_EXPORT BasicDecimal128 operator*(const BasicDecimal128& left, - const BasicDecimal128& right); -ARROW_EXPORT BasicDecimal128 operator/(const BasicDecimal128& left, - const BasicDecimal128& right); -ARROW_EXPORT BasicDecimal128 operator%(const BasicDecimal128& left, - const BasicDecimal128& right); - -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/bit-stream-utils.h b/cpp/thirdparty/knowhere_build/include/arrow/util/bit-stream-utils.h deleted file mode 100644 index ad86ee87c9..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/bit-stream-utils.h +++ /dev/null @@ -1,416 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// From Apache Impala (incubating) as of 2016-01-29 - -#ifndef ARROW_UTIL_BIT_STREAM_UTILS_H -#define ARROW_UTIL_BIT_STREAM_UTILS_H - -#include -#include -#include - -#include "arrow/util/bit-util.h" -#include "arrow/util/bpacking.h" -#include "arrow/util/logging.h" -#include "arrow/util/macros.h" - -namespace arrow { -namespace BitUtil { - -/// Utility class to write bit/byte streams. This class can write data to either be -/// bit packed or byte aligned (and a single stream that has a mix of both). -/// This class does not allocate memory. -class BitWriter { - public: - /// buffer: buffer to write bits to. Buffer should be preallocated with - /// 'buffer_len' bytes. - BitWriter(uint8_t* buffer, int buffer_len) : buffer_(buffer), max_bytes_(buffer_len) { - Clear(); - } - - void Clear() { - buffered_values_ = 0; - byte_offset_ = 0; - bit_offset_ = 0; - } - - /// The number of current bytes written, including the current byte (i.e. may include a - /// fraction of a byte). Includes buffered values. - int bytes_written() const { - return byte_offset_ + static_cast(BitUtil::BytesForBits(bit_offset_)); - } - uint8_t* buffer() const { return buffer_; } - int buffer_len() const { return max_bytes_; } - - /// Writes a value to buffered_values_, flushing to buffer_ if necessary. This is bit - /// packed. Returns false if there was not enough space. num_bits must be <= 32. - bool PutValue(uint64_t v, int num_bits); - - /// Writes v to the next aligned byte using num_bytes. If T is larger than - /// num_bytes, the extra high-order bytes will be ignored. Returns false if - /// there was not enough space. - template - bool PutAligned(T v, int num_bytes); - - /// Write a Vlq encoded int to the buffer. Returns false if there was not enough - /// room. The value is written byte aligned. - /// For more details on vlq: - /// en.wikipedia.org/wiki/Variable-length_quantity - bool PutVlqInt(uint32_t v); - - // Writes an int zigzag encoded. - bool PutZigZagVlqInt(int32_t v); - - /// Get a pointer to the next aligned byte and advance the underlying buffer - /// by num_bytes. - /// Returns NULL if there was not enough space. - uint8_t* GetNextBytePtr(int num_bytes = 1); - - /// Flushes all buffered values to the buffer. Call this when done writing to - /// the buffer. If 'align' is true, buffered_values_ is reset and any future - /// writes will be written to the next byte boundary. - void Flush(bool align = false); - - private: - uint8_t* buffer_; - int max_bytes_; - - /// Bit-packed values are initially written to this variable before being memcpy'd to - /// buffer_. This is faster than writing values byte by byte directly to buffer_. - uint64_t buffered_values_; - - int byte_offset_; // Offset in buffer_ - int bit_offset_; // Offset in buffered_values_ -}; - -/// Utility class to read bit/byte stream. This class can read bits or bytes -/// that are either byte aligned or not. It also has utilities to read multiple -/// bytes in one read (e.g. encoded int). -class BitReader { - public: - /// 'buffer' is the buffer to read from. The buffer's length is 'buffer_len'. - BitReader(const uint8_t* buffer, int buffer_len) - : buffer_(buffer), max_bytes_(buffer_len), byte_offset_(0), bit_offset_(0) { - int num_bytes = std::min(8, max_bytes_ - byte_offset_); - memcpy(&buffered_values_, buffer_ + byte_offset_, num_bytes); - } - - BitReader() - : buffer_(NULL), - max_bytes_(0), - buffered_values_(0), - byte_offset_(0), - bit_offset_(0) {} - - void Reset(const uint8_t* buffer, int buffer_len) { - buffer_ = buffer; - max_bytes_ = buffer_len; - byte_offset_ = 0; - bit_offset_ = 0; - int num_bytes = std::min(8, max_bytes_ - byte_offset_); - memcpy(&buffered_values_, buffer_ + byte_offset_, num_bytes); - } - - /// Gets the next value from the buffer. Returns true if 'v' could be read or false if - /// there are not enough bytes left. num_bits must be <= 32. - template - bool GetValue(int num_bits, T* v); - - /// Get a number of values from the buffer. Return the number of values actually read. - template - int GetBatch(int num_bits, T* v, int batch_size); - - /// Reads a 'num_bytes'-sized value from the buffer and stores it in 'v'. T - /// needs to be a little-endian native type and big enough to store - /// 'num_bytes'. The value is assumed to be byte-aligned so the stream will - /// be advanced to the start of the next byte before 'v' is read. Returns - /// false if there are not enough bytes left. - template - bool GetAligned(int num_bytes, T* v); - - /// Reads a vlq encoded int from the stream. The encoded int must start at - /// the beginning of a byte. Return false if there were not enough bytes in - /// the buffer. - bool GetVlqInt(int32_t* v); - - // Reads a zigzag encoded int `into` v. - bool GetZigZagVlqInt(int32_t* v); - - /// Returns the number of bytes left in the stream, not including the current - /// byte (i.e., there may be an additional fraction of a byte). - int bytes_left() { - return max_bytes_ - - (byte_offset_ + static_cast(BitUtil::BytesForBits(bit_offset_))); - } - - /// Maximum byte length of a vlq encoded int - static const int MAX_VLQ_BYTE_LEN = 5; - - private: - const uint8_t* buffer_; - int max_bytes_; - - /// Bytes are memcpy'd from buffer_ and values are read from this variable. This is - /// faster than reading values byte by byte directly from buffer_. - uint64_t buffered_values_; - - int byte_offset_; // Offset in buffer_ - int bit_offset_; // Offset in buffered_values_ -}; - -inline bool BitWriter::PutValue(uint64_t v, int num_bits) { - // TODO: revisit this limit if necessary (can be raised to 64 by fixing some edge cases) - DCHECK_LE(num_bits, 32); - DCHECK_EQ(v >> num_bits, 0) << "v = " << v << ", num_bits = " << num_bits; - - if (ARROW_PREDICT_FALSE(byte_offset_ * 8 + bit_offset_ + num_bits > max_bytes_ * 8)) - return false; - - buffered_values_ |= v << bit_offset_; - bit_offset_ += num_bits; - - if (ARROW_PREDICT_FALSE(bit_offset_ >= 64)) { - // Flush buffered_values_ and write out bits of v that did not fit - memcpy(buffer_ + byte_offset_, &buffered_values_, 8); - buffered_values_ = 0; - byte_offset_ += 8; - bit_offset_ -= 64; - buffered_values_ = v >> (num_bits - bit_offset_); - } - DCHECK_LT(bit_offset_, 64); - return true; -} - -inline void BitWriter::Flush(bool align) { - int num_bytes = static_cast(BitUtil::BytesForBits(bit_offset_)); - DCHECK_LE(byte_offset_ + num_bytes, max_bytes_); - memcpy(buffer_ + byte_offset_, &buffered_values_, num_bytes); - - if (align) { - buffered_values_ = 0; - byte_offset_ += num_bytes; - bit_offset_ = 0; - } -} - -inline uint8_t* BitWriter::GetNextBytePtr(int num_bytes) { - Flush(/* align */ true); - DCHECK_LE(byte_offset_, max_bytes_); - if (byte_offset_ + num_bytes > max_bytes_) return NULL; - uint8_t* ptr = buffer_ + byte_offset_; - byte_offset_ += num_bytes; - return ptr; -} - -template -inline bool BitWriter::PutAligned(T val, int num_bytes) { - uint8_t* ptr = GetNextBytePtr(num_bytes); - if (ptr == NULL) return false; - memcpy(ptr, &val, num_bytes); - return true; -} - -inline bool BitWriter::PutVlqInt(uint32_t v) { - bool result = true; - while ((v & 0xFFFFFF80) != 0L) { - result &= PutAligned(static_cast((v & 0x7F) | 0x80), 1); - v >>= 7; - } - result &= PutAligned(static_cast(v & 0x7F), 1); - return result; -} - -namespace detail { - -template -inline void GetValue_(int num_bits, T* v, int max_bytes, const uint8_t* buffer, - int* bit_offset, int* byte_offset, uint64_t* buffered_values) { -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4800) -#endif - *v = static_cast(BitUtil::TrailingBits(*buffered_values, *bit_offset + num_bits) >> - *bit_offset); -#ifdef _MSC_VER -#pragma warning(pop) -#endif - *bit_offset += num_bits; - if (*bit_offset >= 64) { - *byte_offset += 8; - *bit_offset -= 64; - - int bytes_remaining = max_bytes - *byte_offset; - if (ARROW_PREDICT_TRUE(bytes_remaining >= 8)) { - memcpy(buffered_values, buffer + *byte_offset, 8); - } else { - memcpy(buffered_values, buffer + *byte_offset, bytes_remaining); - } -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4800 4805) -#endif - // Read bits of v that crossed into new buffered_values_ - *v = *v | static_cast(BitUtil::TrailingBits(*buffered_values, *bit_offset) - << (num_bits - *bit_offset)); -#ifdef _MSC_VER -#pragma warning(pop) -#endif - DCHECK_LE(*bit_offset, 64); - } -} - -} // namespace detail - -template -inline bool BitReader::GetValue(int num_bits, T* v) { - return GetBatch(num_bits, v, 1) == 1; -} - -template -inline int BitReader::GetBatch(int num_bits, T* v, int batch_size) { - DCHECK(buffer_ != NULL); - // TODO: revisit this limit if necessary - DCHECK_LE(num_bits, 32); - DCHECK_LE(num_bits, static_cast(sizeof(T) * 8)); - - int bit_offset = bit_offset_; - int byte_offset = byte_offset_; - uint64_t buffered_values = buffered_values_; - int max_bytes = max_bytes_; - const uint8_t* buffer = buffer_; - - uint64_t needed_bits = num_bits * batch_size; - uint64_t remaining_bits = (max_bytes - byte_offset) * 8 - bit_offset; - if (remaining_bits < needed_bits) { - batch_size = static_cast(remaining_bits) / num_bits; - } - - int i = 0; - if (ARROW_PREDICT_FALSE(bit_offset != 0)) { - for (; i < batch_size && bit_offset != 0; ++i) { - detail::GetValue_(num_bits, &v[i], max_bytes, buffer, &bit_offset, &byte_offset, - &buffered_values); - } - } - - if (sizeof(T) == 4) { - int num_unpacked = - internal::unpack32(reinterpret_cast(buffer + byte_offset), - reinterpret_cast(v + i), batch_size - i, num_bits); - i += num_unpacked; - byte_offset += num_unpacked * num_bits / 8; - } else { - const int buffer_size = 1024; - uint32_t unpack_buffer[buffer_size]; - while (i < batch_size) { - int unpack_size = std::min(buffer_size, batch_size - i); - int num_unpacked = - internal::unpack32(reinterpret_cast(buffer + byte_offset), - unpack_buffer, unpack_size, num_bits); - if (num_unpacked == 0) { - break; - } - for (int k = 0; k < num_unpacked; ++k) { -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4800) -#endif - v[i + k] = static_cast(unpack_buffer[k]); -#ifdef _MSC_VER -#pragma warning(pop) -#endif - } - i += num_unpacked; - byte_offset += num_unpacked * num_bits / 8; - } - } - - int bytes_remaining = max_bytes - byte_offset; - if (bytes_remaining >= 8) { - memcpy(&buffered_values, buffer + byte_offset, 8); - } else { - memcpy(&buffered_values, buffer + byte_offset, bytes_remaining); - } - - for (; i < batch_size; ++i) { - detail::GetValue_(num_bits, &v[i], max_bytes, buffer, &bit_offset, &byte_offset, - &buffered_values); - } - - bit_offset_ = bit_offset; - byte_offset_ = byte_offset; - buffered_values_ = buffered_values; - - return batch_size; -} - -template -inline bool BitReader::GetAligned(int num_bytes, T* v) { - DCHECK_LE(num_bytes, static_cast(sizeof(T))); - int bytes_read = static_cast(BitUtil::BytesForBits(bit_offset_)); - if (ARROW_PREDICT_FALSE(byte_offset_ + bytes_read + num_bytes > max_bytes_)) - return false; - - // Advance byte_offset to next unread byte and read num_bytes - byte_offset_ += bytes_read; - memcpy(v, buffer_ + byte_offset_, num_bytes); - byte_offset_ += num_bytes; - - // Reset buffered_values_ - bit_offset_ = 0; - int bytes_remaining = max_bytes_ - byte_offset_; - if (ARROW_PREDICT_TRUE(bytes_remaining >= 8)) { - memcpy(&buffered_values_, buffer_ + byte_offset_, 8); - } else { - memcpy(&buffered_values_, buffer_ + byte_offset_, bytes_remaining); - } - return true; -} - -inline bool BitReader::GetVlqInt(int32_t* v) { - *v = 0; - int shift = 0; - int num_bytes = 0; - uint8_t byte = 0; - do { - if (!GetAligned(1, &byte)) return false; - *v |= (byte & 0x7F) << shift; - shift += 7; - DCHECK_LE(++num_bytes, MAX_VLQ_BYTE_LEN); - } while ((byte & 0x80) != 0); - return true; -} - -inline bool BitWriter::PutZigZagVlqInt(int32_t v) { - // Note negative left shift is undefined - uint32_t u = (static_cast(v) << 1) ^ (v >> 31); - return PutVlqInt(u); -} - -inline bool BitReader::GetZigZagVlqInt(int32_t* v) { - int32_t u_signed; - if (!GetVlqInt(&u_signed)) return false; - uint32_t u = static_cast(u_signed); - *reinterpret_cast(v) = (u >> 1) ^ -(static_cast(u & 1)); - return true; -} - -} // namespace BitUtil -} // namespace arrow - -#endif // ARROW_UTIL_BIT_STREAM_UTILS_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/bit-util.h b/cpp/thirdparty/knowhere_build/include/arrow/util/bit-util.h deleted file mode 100644 index 576990e0d5..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/bit-util.h +++ /dev/null @@ -1,923 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -#ifndef ARROW_UTIL_BIT_UTIL_H -#define ARROW_UTIL_BIT_UTIL_H - -#ifdef _WIN32 -#define ARROW_LITTLE_ENDIAN 1 -#else -#ifdef __APPLE__ -#include -#else -#include -#endif -# -#ifndef __BYTE_ORDER__ -#error "__BYTE_ORDER__ not defined" -#endif -# -#ifndef __ORDER_LITTLE_ENDIAN__ -#error "__ORDER_LITTLE_ENDIAN__ not defined" -#endif -# -#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ -#define ARROW_LITTLE_ENDIAN 1 -#else -#define ARROW_LITTLE_ENDIAN 0 -#endif -#endif - -#if defined(_MSC_VER) -#include -#pragma intrinsic(_BitScanReverse) -#pragma intrinsic(_BitScanForward) -#define ARROW_BYTE_SWAP64 _byteswap_uint64 -#define ARROW_BYTE_SWAP32 _byteswap_ulong -#else -#define ARROW_BYTE_SWAP64 __builtin_bswap64 -#define ARROW_BYTE_SWAP32 __builtin_bswap32 -#endif - -#include -#include -#include -#include -#include -#include -#include - -#include "arrow/util/macros.h" -#include "arrow/util/type_traits.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class Buffer; -class MemoryPool; -class Status; - -namespace detail { - -template -typename std::make_unsigned::type as_unsigned(Integer x) { - return static_cast::type>(x); -} - -} // namespace detail - -namespace BitUtil { - -// The number of set bits in a given unsigned byte value, pre-computed -// -// Generated with the following Python code -// output = 'static constexpr uint8_t kBytePopcount[] = {{{0}}};' -// popcounts = [str(bin(i).count('1')) for i in range(0, 256)] -// print(output.format(', '.join(popcounts))) -static constexpr uint8_t kBytePopcount[] = { - 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, - 4, 4, 5, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, - 4, 5, 4, 5, 5, 6, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, - 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, - 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, - 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, - 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, - 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 3, 4, 4, 5, 4, 5, 5, 6, - 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8}; - -// -// Bit-related computations on integer values -// - -// Returns the ceil of value/divisor -constexpr int64_t CeilDiv(int64_t value, int64_t divisor) { - return value / divisor + (value % divisor != 0); -} - -constexpr int64_t BytesForBits(int64_t bits) { return (bits + 7) >> 3; } - -// Returns the smallest power of two that contains v. If v is already a -// power of two, it is returned as is. -static inline int64_t NextPower2(int64_t n) { - // Taken from - // http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 - n--; - n |= n >> 1; - n |= n >> 2; - n |= n >> 4; - n |= n >> 8; - n |= n >> 16; - n |= n >> 32; - n++; - return n; -} - -constexpr bool IsMultipleOf64(int64_t n) { return (n & 63) == 0; } - -constexpr bool IsMultipleOf8(int64_t n) { return (n & 7) == 0; } - -// Returns 'value' rounded up to the nearest multiple of 'factor' -constexpr int64_t RoundUp(int64_t value, int64_t factor) { - return (value + (factor - 1)) / factor * factor; -} - -// Returns 'value' rounded down to the nearest multiple of 'factor' -constexpr int64_t RoundDown(int64_t value, int64_t factor) { - return (value / factor) * factor; -} - -// Returns 'value' rounded up to the nearest multiple of 'factor' when factor -// is a power of two. -// The result is undefined on overflow, i.e. if `value > 2**64 - factor`, -// since we cannot return the correct result which would be 2**64. -constexpr int64_t RoundUpToPowerOf2(int64_t value, int64_t factor) { - // DCHECK((factor > 0) && ((factor & (factor - 1)) == 0)); - return (value + (factor - 1)) & ~(factor - 1); -} - -constexpr int64_t RoundUpToMultipleOf8(int64_t num) { return RoundUpToPowerOf2(num, 8); } - -constexpr int64_t RoundUpToMultipleOf64(int64_t num) { - return RoundUpToPowerOf2(num, 64); -} - -// Returns the number of bytes covering a sliced bitmap. Find the length -// rounded to cover full bytes on both extremities. -// -// The following example represents a slice (offset=10, length=9) -// -// 0 8 16 24 -// |-------|-------|------| -// [ ] (slice) -// [ ] (same slice aligned to bytes bounds, length=16) -// -// The covering bytes is the length (in bytes) of this new aligned slice. -constexpr int64_t CoveringBytes(int64_t offset, int64_t length) { - return (BitUtil::RoundUp(length + offset, 8) - BitUtil::RoundDown(offset, 8)) / 8; -} - -// Returns the 'num_bits' least-significant bits of 'v'. -static inline uint64_t TrailingBits(uint64_t v, int num_bits) { - if (ARROW_PREDICT_FALSE(num_bits == 0)) return 0; - if (ARROW_PREDICT_FALSE(num_bits >= 64)) return v; - int n = 64 - num_bits; - return (v << n) >> n; -} - -/// \brief Count the number of leading zeros in an unsigned integer. -static inline int CountLeadingZeros(uint32_t value) { -#if defined(__clang__) || defined(__GNUC__) - if (value == 0) return 32; - return static_cast(__builtin_clz(value)); -#elif defined(_MSC_VER) - unsigned long index; // NOLINT - if (_BitScanReverse(&index, static_cast(value))) { // NOLINT - return 31 - static_cast(index); - } else { - return 32; - } -#else - int bitpos = 0; - while (value != 0) { - value >>= 1; - ++bitpos; - } - return 32 - bitpos; -#endif -} - -static inline int CountLeadingZeros(uint64_t value) { -#if defined(__clang__) || defined(__GNUC__) - if (value == 0) return 64; - return static_cast(__builtin_clzll(value)); -#elif defined(_MSC_VER) - unsigned long index; // NOLINT - if (_BitScanReverse64(&index, value)) { // NOLINT - return 63 - static_cast(index); - } else { - return 64; - } -#else - int bitpos = 0; - while (value != 0) { - value >>= 1; - ++bitpos; - } - return 64 - bitpos; -#endif -} - -static inline int CountTrailingZeros(uint32_t value) { -#if defined(__clang__) || defined(__GNUC__) - if (value == 0) return 32; - return static_cast(__builtin_ctzl(value)); -#elif defined(_MSC_VER) - unsigned long index; // NOLINT - if (_BitScanForward(&index, value)) { - return static_cast(index); - } else { - return 32; - } -#else - int bitpos = 0; - if (value) { - while (value & 1 == 0) { - value >>= 1; - ++bitpos; - } - } else { - bitpos = 32; - } - return bitpos; -#endif -} - -static inline int CountTrailingZeros(uint64_t value) { -#if defined(__clang__) || defined(__GNUC__) - if (value == 0) return 64; - return static_cast(__builtin_ctzll(value)); -#elif defined(_MSC_VER) - unsigned long index; // NOLINT - if (_BitScanForward64(&index, value)) { - return static_cast(index); - } else { - return 64; - } -#else - int bitpos = 0; - if (value) { - while (value & 1 == 0) { - value >>= 1; - ++bitpos; - } - } else { - bitpos = 64; - } - return bitpos; -#endif -} - -// Returns the minimum number of bits needed to represent an unsigned value -static inline int NumRequiredBits(uint64_t x) { return 64 - CountLeadingZeros(x); } - -// Returns ceil(log2(x)). -static inline int Log2(uint64_t x) { - // DCHECK_GT(x, 0); - return NumRequiredBits(x - 1); -} - -// -// Byte-swap 16-bit, 32-bit and 64-bit values -// - -// Swap the byte order (i.e. endianess) -static inline int64_t ByteSwap(int64_t value) { return ARROW_BYTE_SWAP64(value); } -static inline uint64_t ByteSwap(uint64_t value) { - return static_cast(ARROW_BYTE_SWAP64(value)); -} -static inline int32_t ByteSwap(int32_t value) { return ARROW_BYTE_SWAP32(value); } -static inline uint32_t ByteSwap(uint32_t value) { - return static_cast(ARROW_BYTE_SWAP32(value)); -} -static inline int16_t ByteSwap(int16_t value) { - constexpr auto m = static_cast(0xff); - return static_cast(((value >> 8) & m) | ((value & m) << 8)); -} -static inline uint16_t ByteSwap(uint16_t value) { - return static_cast(ByteSwap(static_cast(value))); -} - -// Write the swapped bytes into dst. Src and dst cannot overlap. -static inline void ByteSwap(void* dst, const void* src, int len) { - switch (len) { - case 1: - *reinterpret_cast(dst) = *reinterpret_cast(src); - return; - case 2: - *reinterpret_cast(dst) = ByteSwap(*reinterpret_cast(src)); - return; - case 4: - *reinterpret_cast(dst) = ByteSwap(*reinterpret_cast(src)); - return; - case 8: - *reinterpret_cast(dst) = ByteSwap(*reinterpret_cast(src)); - return; - default: - break; - } - - auto d = reinterpret_cast(dst); - auto s = reinterpret_cast(src); - for (int i = 0; i < len; ++i) { - d[i] = s[len - i - 1]; - } -} - -// Convert to little/big endian format from the machine's native endian format. -#if ARROW_LITTLE_ENDIAN -template > -static inline T ToBigEndian(T value) { - return ByteSwap(value); -} - -template > -static inline T ToLittleEndian(T value) { - return value; -} -#else -template > -static inline T ToBigEndian(T value) { - return value; -} - -template > -static inline T ToLittleEndian(T value) { - return ByteSwap(value); -} -#endif - -// Convert from big/little endian format to the machine's native endian format. -#if ARROW_LITTLE_ENDIAN -template > -static inline T FromBigEndian(T value) { - return ByteSwap(value); -} - -template > -static inline T FromLittleEndian(T value) { - return value; -} -#else -template > -static inline T FromBigEndian(T value) { - return value; -} - -template > -static inline T FromLittleEndian(T value) { - return ByteSwap(value); -} -#endif - -// -// Utilities for reading and writing individual bits by their index -// in a memory area. -// - -// Bitmask selecting the k-th bit in a byte -static constexpr uint8_t kBitmask[] = {1, 2, 4, 8, 16, 32, 64, 128}; - -// the bitwise complement version of kBitmask -static constexpr uint8_t kFlippedBitmask[] = {254, 253, 251, 247, 239, 223, 191, 127}; - -// Bitmask selecting the (k - 1) preceding bits in a byte -static constexpr uint8_t kPrecedingBitmask[] = {0, 1, 3, 7, 15, 31, 63, 127}; -static constexpr uint8_t kPrecedingWrappingBitmask[] = {255, 1, 3, 7, 15, 31, 63, 127}; - -// the bitwise complement version of kPrecedingBitmask -static constexpr uint8_t kTrailingBitmask[] = {255, 254, 252, 248, 240, 224, 192, 128}; - -static inline bool GetBit(const uint8_t* bits, uint64_t i) { - return (bits[i >> 3] >> (i & 0x07)) & 1; -} - -// Gets the i-th bit from a byte. Should only be used with i <= 7. -static inline bool GetBitFromByte(uint8_t byte, uint8_t i) { return byte & kBitmask[i]; } - -static inline void ClearBit(uint8_t* bits, int64_t i) { - bits[i / 8] &= kFlippedBitmask[i % 8]; -} - -static inline void SetBit(uint8_t* bits, int64_t i) { bits[i / 8] |= kBitmask[i % 8]; } - -static inline void SetBitTo(uint8_t* bits, int64_t i, bool bit_is_set) { - // https://graphics.stanford.edu/~seander/bithacks.html - // "Conditionally set or clear bits without branching" - // NOTE: this seems to confuse Valgrind as it reads from potentially - // uninitialized memory - bits[i / 8] ^= static_cast(-static_cast(bit_is_set) ^ bits[i / 8]) & - kBitmask[i % 8]; -} - -/// \brief set or clear a range of bits quickly -static inline void SetBitsTo(uint8_t* bits, int64_t start_offset, int64_t length, - bool bits_are_set) { - if (length == 0) return; - - const auto i_begin = start_offset; - const auto i_end = start_offset + length; - const uint8_t fill_byte = static_cast(-static_cast(bits_are_set)); - - const auto bytes_begin = i_begin / 8; - const auto bytes_end = i_end / 8 + 1; - - const auto first_byte_mask = kPrecedingBitmask[i_begin % 8]; - const auto last_byte_mask = kTrailingBitmask[i_end % 8]; - - if (bytes_end == bytes_begin + 1) { - // set bits within a single byte - const auto only_byte_mask = - i_end % 8 == 0 ? first_byte_mask - : static_cast(first_byte_mask | last_byte_mask); - bits[bytes_begin] &= only_byte_mask; - bits[bytes_begin] |= static_cast(fill_byte & ~only_byte_mask); - return; - } - - // set/clear trailing bits of first byte - bits[bytes_begin] &= first_byte_mask; - bits[bytes_begin] |= static_cast(fill_byte & ~first_byte_mask); - - if (bytes_end - bytes_begin > 2) { - // set/clear whole bytes - std::memset(bits + bytes_begin + 1, fill_byte, - static_cast(bytes_end - bytes_begin - 2)); - } - - if (i_end % 8 == 0) return; - - // set/clear leading bits of last byte - bits[bytes_end - 1] &= last_byte_mask; - bits[bytes_end - 1] |= static_cast(fill_byte & ~last_byte_mask); -} - -/// \brief Convert vector of bytes to bitmap buffer -ARROW_EXPORT -Status BytesToBits(const std::vector&, MemoryPool*, std::shared_ptr*); - -} // namespace BitUtil - -namespace internal { - -class BitmapReader { - public: - BitmapReader(const uint8_t* bitmap, int64_t start_offset, int64_t length) - : bitmap_(bitmap), position_(0), length_(length) { - current_byte_ = 0; - byte_offset_ = start_offset / 8; - bit_offset_ = start_offset % 8; - if (length > 0) { - current_byte_ = bitmap[byte_offset_]; - } - } - - bool IsSet() const { return (current_byte_ & (1 << bit_offset_)) != 0; } - - bool IsNotSet() const { return (current_byte_ & (1 << bit_offset_)) == 0; } - - void Next() { - ++bit_offset_; - ++position_; - if (ARROW_PREDICT_FALSE(bit_offset_ == 8)) { - bit_offset_ = 0; - ++byte_offset_; - if (ARROW_PREDICT_TRUE(position_ < length_)) { - current_byte_ = bitmap_[byte_offset_]; - } - } - } - - private: - const uint8_t* bitmap_; - int64_t position_; - int64_t length_; - - uint8_t current_byte_; - int64_t byte_offset_; - int64_t bit_offset_; -}; - -class BitmapWriter { - // A sequential bitwise writer that preserves surrounding bit values. - - public: - BitmapWriter(uint8_t* bitmap, int64_t start_offset, int64_t length) - : bitmap_(bitmap), position_(0), length_(length) { - byte_offset_ = start_offset / 8; - bit_mask_ = BitUtil::kBitmask[start_offset % 8]; - if (length > 0) { - current_byte_ = bitmap[byte_offset_]; - } else { - current_byte_ = 0; - } - } - - void Set() { current_byte_ |= bit_mask_; } - - void Clear() { current_byte_ &= bit_mask_ ^ 0xFF; } - - void Next() { - bit_mask_ = static_cast(bit_mask_ << 1); - ++position_; - if (bit_mask_ == 0) { - // Finished this byte, need advancing - bit_mask_ = 0x01; - bitmap_[byte_offset_++] = current_byte_; - if (ARROW_PREDICT_TRUE(position_ < length_)) { - current_byte_ = bitmap_[byte_offset_]; - } - } - } - - void Finish() { - // Store current byte if we didn't went past bitmap storage - if (length_ > 0 && (bit_mask_ != 0x01 || position_ < length_)) { - bitmap_[byte_offset_] = current_byte_; - } - } - - int64_t position() const { return position_; } - - private: - uint8_t* bitmap_; - int64_t position_; - int64_t length_; - - uint8_t current_byte_; - uint8_t bit_mask_; - int64_t byte_offset_; -}; - -class FirstTimeBitmapWriter { - // Like BitmapWriter, but any bit values *following* the bits written - // might be clobbered. It is hence faster than BitmapWriter, and can - // also avoid false positives with Valgrind. - - public: - FirstTimeBitmapWriter(uint8_t* bitmap, int64_t start_offset, int64_t length) - : bitmap_(bitmap), position_(0), length_(length) { - current_byte_ = 0; - byte_offset_ = start_offset / 8; - bit_mask_ = BitUtil::kBitmask[start_offset % 8]; - if (length > 0) { - current_byte_ = bitmap[byte_offset_] & BitUtil::kPrecedingBitmask[start_offset % 8]; - } else { - current_byte_ = 0; - } - } - - void Set() { current_byte_ |= bit_mask_; } - - void Clear() {} - - void Next() { - bit_mask_ = static_cast(bit_mask_ << 1); - ++position_; - if (bit_mask_ == 0) { - // Finished this byte, need advancing - bit_mask_ = 0x01; - bitmap_[byte_offset_++] = current_byte_; - current_byte_ = 0; - } - } - - void Finish() { - // Store current byte if we didn't went past bitmap storage - if (length_ > 0 && (bit_mask_ != 0x01 || position_ < length_)) { - bitmap_[byte_offset_] = current_byte_; - } - } - - int64_t position() const { return position_; } - - private: - uint8_t* bitmap_; - int64_t position_; - int64_t length_; - - uint8_t current_byte_; - uint8_t bit_mask_; - int64_t byte_offset_; -}; - -// A std::generate() like function to write sequential bits into a bitmap area. -// Bits preceding the bitmap area are preserved, bits following the bitmap -// area may be clobbered. - -template -void GenerateBits(uint8_t* bitmap, int64_t start_offset, int64_t length, Generator&& g) { - if (length == 0) { - return; - } - uint8_t* cur = bitmap + start_offset / 8; - uint8_t bit_mask = BitUtil::kBitmask[start_offset % 8]; - uint8_t current_byte = *cur & BitUtil::kPrecedingBitmask[start_offset % 8]; - - for (int64_t index = 0; index < length; ++index) { - const bool bit = g(); - current_byte = bit ? (current_byte | bit_mask) : current_byte; - bit_mask = static_cast(bit_mask << 1); - if (bit_mask == 0) { - bit_mask = 1; - *cur++ = current_byte; - current_byte = 0; - } - } - if (bit_mask != 1) { - *cur++ = current_byte; - } -} - -// Like GenerateBits(), but unrolls its main loop for higher performance. - -template -void GenerateBitsUnrolled(uint8_t* bitmap, int64_t start_offset, int64_t length, - Generator&& g) { - if (length == 0) { - return; - } - uint8_t current_byte; - uint8_t* cur = bitmap + start_offset / 8; - const uint64_t start_bit_offset = start_offset % 8; - uint8_t bit_mask = BitUtil::kBitmask[start_bit_offset]; - int64_t remaining = length; - - if (bit_mask != 0x01) { - current_byte = *cur & BitUtil::kPrecedingBitmask[start_bit_offset]; - while (bit_mask != 0 && remaining > 0) { - current_byte = g() ? (current_byte | bit_mask) : current_byte; - bit_mask = static_cast(bit_mask << 1); - --remaining; - } - *cur++ = current_byte; - } - - int64_t remaining_bytes = remaining / 8; - while (remaining_bytes-- > 0) { - current_byte = 0; - current_byte = g() ? current_byte | 0x01 : current_byte; - current_byte = g() ? current_byte | 0x02 : current_byte; - current_byte = g() ? current_byte | 0x04 : current_byte; - current_byte = g() ? current_byte | 0x08 : current_byte; - current_byte = g() ? current_byte | 0x10 : current_byte; - current_byte = g() ? current_byte | 0x20 : current_byte; - current_byte = g() ? current_byte | 0x40 : current_byte; - current_byte = g() ? current_byte | 0x80 : current_byte; - *cur++ = current_byte; - } - - int64_t remaining_bits = remaining % 8; - if (remaining_bits) { - current_byte = 0; - bit_mask = 0x01; - while (remaining_bits-- > 0) { - current_byte = g() ? (current_byte | bit_mask) : current_byte; - bit_mask = static_cast(bit_mask << 1); - } - *cur++ = current_byte; - } -} - -// A function that visits each bit in a bitmap and calls a visitor function with a -// boolean representation of that bit. This is intended to be analogous to -// GenerateBits. -template -void VisitBits(const uint8_t* bitmap, int64_t start_offset, int64_t length, - Visitor&& visit) { - BitmapReader reader(bitmap, start_offset, length); - for (int64_t index = 0; index < length; ++index) { - visit(reader.IsSet()); - reader.Next(); - } -} - -// Like VisitBits(), but unrolls its main loop for better performance. -template -void VisitBitsUnrolled(const uint8_t* bitmap, int64_t start_offset, int64_t length, - Visitor&& visit) { - if (length == 0) { - return; - } - - // Start by visiting any bits preceding the first full byte. - int64_t num_bits_before_full_bytes = - BitUtil::RoundUpToMultipleOf8(start_offset) - start_offset; - // Truncate num_bits_before_full_bytes if it is greater than length. - if (num_bits_before_full_bytes > length) { - num_bits_before_full_bytes = length; - } - // Use the non loop-unrolled VisitBits since we don't want to add branches - VisitBits(bitmap, start_offset, num_bits_before_full_bytes, visit); - - // Shift the start pointer to the first full byte and compute the - // number of full bytes to be read. - const uint8_t* first_full_byte = bitmap + BitUtil::CeilDiv(start_offset, 8); - const int64_t num_full_bytes = (length - num_bits_before_full_bytes) / 8; - - // Iterate over each full byte of the input bitmap and call the visitor in - // a loop-unrolled manner. - for (int64_t byte_index = 0; byte_index < num_full_bytes; ++byte_index) { - // Get the current bit-packed byte value from the bitmap. - const uint8_t byte = *(first_full_byte + byte_index); - - // Execute the visitor function on each bit of the current byte. - visit(BitUtil::GetBitFromByte(byte, 0)); - visit(BitUtil::GetBitFromByte(byte, 1)); - visit(BitUtil::GetBitFromByte(byte, 2)); - visit(BitUtil::GetBitFromByte(byte, 3)); - visit(BitUtil::GetBitFromByte(byte, 4)); - visit(BitUtil::GetBitFromByte(byte, 5)); - visit(BitUtil::GetBitFromByte(byte, 6)); - visit(BitUtil::GetBitFromByte(byte, 7)); - } - - // Write any leftover bits in the last byte. - const int64_t num_bits_after_full_bytes = (length - num_bits_before_full_bytes) % 8; - VisitBits(first_full_byte + num_full_bytes, 0, num_bits_after_full_bytes, - visit); -} - -// ---------------------------------------------------------------------- -// Bitmap utilities - -/// Copy a bit range of an existing bitmap -/// -/// \param[in] pool memory pool to allocate memory from -/// \param[in] bitmap source data -/// \param[in] offset bit offset into the source data -/// \param[in] length number of bits to copy -/// \param[out] out the resulting copy -/// -/// \return Status message -ARROW_EXPORT -Status CopyBitmap(MemoryPool* pool, const uint8_t* bitmap, int64_t offset, int64_t length, - std::shared_ptr* out); - -/// Copy a bit range of an existing bitmap into an existing bitmap -/// -/// \param[in] bitmap source data -/// \param[in] offset bit offset into the source data -/// \param[in] length number of bits to copy -/// \param[in] dest_offset bit offset into the destination -/// \param[in] restore_trailing_bits don't clobber bits outside the destination range -/// \param[out] dest the destination buffer, must have at least space for -/// (offset + length) bits -ARROW_EXPORT -void CopyBitmap(const uint8_t* bitmap, int64_t offset, int64_t length, uint8_t* dest, - int64_t dest_offset, bool restore_trailing_bits = true); - -/// Invert a bit range of an existing bitmap into an existing bitmap -/// -/// \param[in] bitmap source data -/// \param[in] offset bit offset into the source data -/// \param[in] length number of bits to copy -/// \param[in] dest_offset bit offset into the destination -/// \param[out] dest the destination buffer, must have at least space for -/// (offset + length) bits -ARROW_EXPORT -void InvertBitmap(const uint8_t* bitmap, int64_t offset, int64_t length, uint8_t* dest, - int64_t dest_offset); - -/// Invert a bit range of an existing bitmap -/// -/// \param[in] pool memory pool to allocate memory from -/// \param[in] bitmap source data -/// \param[in] offset bit offset into the source data -/// \param[in] length number of bits to copy -/// \param[out] out the resulting copy -/// -/// \return Status message -ARROW_EXPORT -Status InvertBitmap(MemoryPool* pool, const uint8_t* bitmap, int64_t offset, - int64_t length, std::shared_ptr* out); - -/// Compute the number of 1's in the given data array -/// -/// \param[in] data a packed LSB-ordered bitmap as a byte array -/// \param[in] bit_offset a bitwise offset into the bitmap -/// \param[in] length the number of bits to inspect in the bitmap relative to -/// the offset -/// -/// \return The number of set (1) bits in the range -ARROW_EXPORT -int64_t CountSetBits(const uint8_t* data, int64_t bit_offset, int64_t length); - -ARROW_EXPORT -bool BitmapEquals(const uint8_t* left, int64_t left_offset, const uint8_t* right, - int64_t right_offset, int64_t bit_length); - -/// \brief Do a "bitmap and" on right and left buffers starting at -/// their respective bit-offsets for the given bit-length and put -/// the results in out_buffer starting at the given bit-offset. -/// -/// out_buffer will be allocated and initialized to zeros using pool before -/// the operation. -ARROW_EXPORT -Status BitmapAnd(MemoryPool* pool, const uint8_t* left, int64_t left_offset, - const uint8_t* right, int64_t right_offset, int64_t length, - int64_t out_offset, std::shared_ptr* out_buffer); - -/// \brief Do a "bitmap and" on right and left buffers starting at -/// their respective bit-offsets for the given bit-length and put -/// the results in out starting at the given bit-offset. -ARROW_EXPORT -void BitmapAnd(const uint8_t* left, int64_t left_offset, const uint8_t* right, - int64_t right_offset, int64_t length, int64_t out_offset, uint8_t* out); - -/// \brief Do a "bitmap or" for the given bit length on right and left buffers -/// starting at their respective bit-offsets and put the results in out_buffer -/// starting at the given bit-offset. -/// -/// out_buffer will be allocated and initialized to zeros using pool before -/// the operation. -ARROW_EXPORT -Status BitmapOr(MemoryPool* pool, const uint8_t* left, int64_t left_offset, - const uint8_t* right, int64_t right_offset, int64_t length, - int64_t out_offset, std::shared_ptr* out_buffer); - -/// \brief Do a "bitmap or" for the given bit length on right and left buffers -/// starting at their respective bit-offsets and put the results in out -/// starting at the given bit-offset. -ARROW_EXPORT -void BitmapOr(const uint8_t* left, int64_t left_offset, const uint8_t* right, - int64_t right_offset, int64_t length, int64_t out_offset, uint8_t* out); - -/// \brief Do a "bitmap xor" for the given bit-length on right and left -/// buffers starting at their respective bit-offsets and put the results in -/// out_buffer starting at the given bit offset. -/// -/// out_buffer will be allocated and initialized to zeros using pool before -/// the operation. -ARROW_EXPORT -Status BitmapXor(MemoryPool* pool, const uint8_t* left, int64_t left_offset, - const uint8_t* right, int64_t right_offset, int64_t length, - int64_t out_offset, std::shared_ptr* out_buffer); - -/// \brief Do a "bitmap xor" for the given bit-length on right and left -/// buffers starting at their respective bit-offsets and put the results in -/// out starting at the given bit offset. -ARROW_EXPORT -void BitmapXor(const uint8_t* left, int64_t left_offset, const uint8_t* right, - int64_t right_offset, int64_t length, int64_t out_offset, uint8_t* out); - -/// \brief Generate Bitmap with all position to `value` except for one found -/// at `straggler_pos`. -ARROW_EXPORT -Status BitmapAllButOne(MemoryPool* pool, int64_t length, int64_t straggler_pos, - std::shared_ptr* output, bool value = true); - -/// \brief Store a stack of bitsets efficiently. The top bitset may be -/// accessed and its bits may be modified, but it may not be resized. -class BitsetStack { - public: - using reference = typename std::vector::reference; - - /// \brief push a bitset onto the stack - /// \param size number of bits in the next bitset - /// \param value initial value for bits in the pushed bitset - void Push(int size, bool value) { - offsets_.push_back(bit_count()); - bits_.resize(bit_count() + size, value); - } - - /// \brief number of bits in the bitset at the top of the stack - int TopSize() const { - if (offsets_.size() == 0) return 0; - return bit_count() - offsets_.back(); - } - - /// \brief pop a bitset off the stack - void Pop() { - bits_.resize(offsets_.back()); - offsets_.pop_back(); - } - - /// \brief get the value of a bit in the top bitset - /// \param i index of the bit to access - bool operator[](int i) const { return bits_[offsets_.back() + i]; } - - /// \brief get a mutable reference to a bit in the top bitset - /// \param i index of the bit to access - reference operator[](int i) { return bits_[offsets_.back() + i]; } - - private: - int bit_count() const { return static_cast(bits_.size()); } - std::vector bits_; - std::vector offsets_; -}; - -} // namespace internal -} // namespace arrow - -#endif // ARROW_UTIL_BIT_UTIL_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/bpacking.h b/cpp/thirdparty/knowhere_build/include/arrow/util/bpacking.h deleted file mode 100644 index 14258cff6e..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/bpacking.h +++ /dev/null @@ -1,3308 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// This file was modified from its original version for inclusion in parquet-cpp. -// Original source: -// https://github.com/lemire/FrameOfReference/blob/6ccaf9e97160f9a3b299e23a8ef739e711ef0c71/src/bpacking.cpp -// The original copyright notice follows. - -// This code is released under the -// Apache License Version 2.0 http://www.apache.org/licenses/. -// (c) Daniel Lemire 2013 - -#ifndef ARROW_UTIL_BPACKING_H -#define ARROW_UTIL_BPACKING_H - -#include "arrow/util/logging.h" - -namespace arrow { -namespace internal { - -inline const uint32_t* unpack1_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) & 1; - out++; - *out = ((*in) >> 1) & 1; - out++; - *out = ((*in) >> 2) & 1; - out++; - *out = ((*in) >> 3) & 1; - out++; - *out = ((*in) >> 4) & 1; - out++; - *out = ((*in) >> 5) & 1; - out++; - *out = ((*in) >> 6) & 1; - out++; - *out = ((*in) >> 7) & 1; - out++; - *out = ((*in) >> 8) & 1; - out++; - *out = ((*in) >> 9) & 1; - out++; - *out = ((*in) >> 10) & 1; - out++; - *out = ((*in) >> 11) & 1; - out++; - *out = ((*in) >> 12) & 1; - out++; - *out = ((*in) >> 13) & 1; - out++; - *out = ((*in) >> 14) & 1; - out++; - *out = ((*in) >> 15) & 1; - out++; - *out = ((*in) >> 16) & 1; - out++; - *out = ((*in) >> 17) & 1; - out++; - *out = ((*in) >> 18) & 1; - out++; - *out = ((*in) >> 19) & 1; - out++; - *out = ((*in) >> 20) & 1; - out++; - *out = ((*in) >> 21) & 1; - out++; - *out = ((*in) >> 22) & 1; - out++; - *out = ((*in) >> 23) & 1; - out++; - *out = ((*in) >> 24) & 1; - out++; - *out = ((*in) >> 25) & 1; - out++; - *out = ((*in) >> 26) & 1; - out++; - *out = ((*in) >> 27) & 1; - out++; - *out = ((*in) >> 28) & 1; - out++; - *out = ((*in) >> 29) & 1; - out++; - *out = ((*in) >> 30) & 1; - out++; - *out = ((*in) >> 31); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack2_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 2); - out++; - *out = ((*in) >> 2) % (1U << 2); - out++; - *out = ((*in) >> 4) % (1U << 2); - out++; - *out = ((*in) >> 6) % (1U << 2); - out++; - *out = ((*in) >> 8) % (1U << 2); - out++; - *out = ((*in) >> 10) % (1U << 2); - out++; - *out = ((*in) >> 12) % (1U << 2); - out++; - *out = ((*in) >> 14) % (1U << 2); - out++; - *out = ((*in) >> 16) % (1U << 2); - out++; - *out = ((*in) >> 18) % (1U << 2); - out++; - *out = ((*in) >> 20) % (1U << 2); - out++; - *out = ((*in) >> 22) % (1U << 2); - out++; - *out = ((*in) >> 24) % (1U << 2); - out++; - *out = ((*in) >> 26) % (1U << 2); - out++; - *out = ((*in) >> 28) % (1U << 2); - out++; - *out = ((*in) >> 30); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 2); - out++; - *out = ((*in) >> 2) % (1U << 2); - out++; - *out = ((*in) >> 4) % (1U << 2); - out++; - *out = ((*in) >> 6) % (1U << 2); - out++; - *out = ((*in) >> 8) % (1U << 2); - out++; - *out = ((*in) >> 10) % (1U << 2); - out++; - *out = ((*in) >> 12) % (1U << 2); - out++; - *out = ((*in) >> 14) % (1U << 2); - out++; - *out = ((*in) >> 16) % (1U << 2); - out++; - *out = ((*in) >> 18) % (1U << 2); - out++; - *out = ((*in) >> 20) % (1U << 2); - out++; - *out = ((*in) >> 22) % (1U << 2); - out++; - *out = ((*in) >> 24) % (1U << 2); - out++; - *out = ((*in) >> 26) % (1U << 2); - out++; - *out = ((*in) >> 28) % (1U << 2); - out++; - *out = ((*in) >> 30); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack3_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 3); - out++; - *out = ((*in) >> 3) % (1U << 3); - out++; - *out = ((*in) >> 6) % (1U << 3); - out++; - *out = ((*in) >> 9) % (1U << 3); - out++; - *out = ((*in) >> 12) % (1U << 3); - out++; - *out = ((*in) >> 15) % (1U << 3); - out++; - *out = ((*in) >> 18) % (1U << 3); - out++; - *out = ((*in) >> 21) % (1U << 3); - out++; - *out = ((*in) >> 24) % (1U << 3); - out++; - *out = ((*in) >> 27) % (1U << 3); - out++; - *out = ((*in) >> 30); - ++in; - *out |= ((*in) % (1U << 1)) << (3 - 1); - out++; - *out = ((*in) >> 1) % (1U << 3); - out++; - *out = ((*in) >> 4) % (1U << 3); - out++; - *out = ((*in) >> 7) % (1U << 3); - out++; - *out = ((*in) >> 10) % (1U << 3); - out++; - *out = ((*in) >> 13) % (1U << 3); - out++; - *out = ((*in) >> 16) % (1U << 3); - out++; - *out = ((*in) >> 19) % (1U << 3); - out++; - *out = ((*in) >> 22) % (1U << 3); - out++; - *out = ((*in) >> 25) % (1U << 3); - out++; - *out = ((*in) >> 28) % (1U << 3); - out++; - *out = ((*in) >> 31); - ++in; - *out |= ((*in) % (1U << 2)) << (3 - 2); - out++; - *out = ((*in) >> 2) % (1U << 3); - out++; - *out = ((*in) >> 5) % (1U << 3); - out++; - *out = ((*in) >> 8) % (1U << 3); - out++; - *out = ((*in) >> 11) % (1U << 3); - out++; - *out = ((*in) >> 14) % (1U << 3); - out++; - *out = ((*in) >> 17) % (1U << 3); - out++; - *out = ((*in) >> 20) % (1U << 3); - out++; - *out = ((*in) >> 23) % (1U << 3); - out++; - *out = ((*in) >> 26) % (1U << 3); - out++; - *out = ((*in) >> 29); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack4_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 4); - out++; - *out = ((*in) >> 4) % (1U << 4); - out++; - *out = ((*in) >> 8) % (1U << 4); - out++; - *out = ((*in) >> 12) % (1U << 4); - out++; - *out = ((*in) >> 16) % (1U << 4); - out++; - *out = ((*in) >> 20) % (1U << 4); - out++; - *out = ((*in) >> 24) % (1U << 4); - out++; - *out = ((*in) >> 28); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 4); - out++; - *out = ((*in) >> 4) % (1U << 4); - out++; - *out = ((*in) >> 8) % (1U << 4); - out++; - *out = ((*in) >> 12) % (1U << 4); - out++; - *out = ((*in) >> 16) % (1U << 4); - out++; - *out = ((*in) >> 20) % (1U << 4); - out++; - *out = ((*in) >> 24) % (1U << 4); - out++; - *out = ((*in) >> 28); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 4); - out++; - *out = ((*in) >> 4) % (1U << 4); - out++; - *out = ((*in) >> 8) % (1U << 4); - out++; - *out = ((*in) >> 12) % (1U << 4); - out++; - *out = ((*in) >> 16) % (1U << 4); - out++; - *out = ((*in) >> 20) % (1U << 4); - out++; - *out = ((*in) >> 24) % (1U << 4); - out++; - *out = ((*in) >> 28); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 4); - out++; - *out = ((*in) >> 4) % (1U << 4); - out++; - *out = ((*in) >> 8) % (1U << 4); - out++; - *out = ((*in) >> 12) % (1U << 4); - out++; - *out = ((*in) >> 16) % (1U << 4); - out++; - *out = ((*in) >> 20) % (1U << 4); - out++; - *out = ((*in) >> 24) % (1U << 4); - out++; - *out = ((*in) >> 28); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack5_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 5); - out++; - *out = ((*in) >> 5) % (1U << 5); - out++; - *out = ((*in) >> 10) % (1U << 5); - out++; - *out = ((*in) >> 15) % (1U << 5); - out++; - *out = ((*in) >> 20) % (1U << 5); - out++; - *out = ((*in) >> 25) % (1U << 5); - out++; - *out = ((*in) >> 30); - ++in; - *out |= ((*in) % (1U << 3)) << (5 - 3); - out++; - *out = ((*in) >> 3) % (1U << 5); - out++; - *out = ((*in) >> 8) % (1U << 5); - out++; - *out = ((*in) >> 13) % (1U << 5); - out++; - *out = ((*in) >> 18) % (1U << 5); - out++; - *out = ((*in) >> 23) % (1U << 5); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 1)) << (5 - 1); - out++; - *out = ((*in) >> 1) % (1U << 5); - out++; - *out = ((*in) >> 6) % (1U << 5); - out++; - *out = ((*in) >> 11) % (1U << 5); - out++; - *out = ((*in) >> 16) % (1U << 5); - out++; - *out = ((*in) >> 21) % (1U << 5); - out++; - *out = ((*in) >> 26) % (1U << 5); - out++; - *out = ((*in) >> 31); - ++in; - *out |= ((*in) % (1U << 4)) << (5 - 4); - out++; - *out = ((*in) >> 4) % (1U << 5); - out++; - *out = ((*in) >> 9) % (1U << 5); - out++; - *out = ((*in) >> 14) % (1U << 5); - out++; - *out = ((*in) >> 19) % (1U << 5); - out++; - *out = ((*in) >> 24) % (1U << 5); - out++; - *out = ((*in) >> 29); - ++in; - *out |= ((*in) % (1U << 2)) << (5 - 2); - out++; - *out = ((*in) >> 2) % (1U << 5); - out++; - *out = ((*in) >> 7) % (1U << 5); - out++; - *out = ((*in) >> 12) % (1U << 5); - out++; - *out = ((*in) >> 17) % (1U << 5); - out++; - *out = ((*in) >> 22) % (1U << 5); - out++; - *out = ((*in) >> 27); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack6_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 6); - out++; - *out = ((*in) >> 6) % (1U << 6); - out++; - *out = ((*in) >> 12) % (1U << 6); - out++; - *out = ((*in) >> 18) % (1U << 6); - out++; - *out = ((*in) >> 24) % (1U << 6); - out++; - *out = ((*in) >> 30); - ++in; - *out |= ((*in) % (1U << 4)) << (6 - 4); - out++; - *out = ((*in) >> 4) % (1U << 6); - out++; - *out = ((*in) >> 10) % (1U << 6); - out++; - *out = ((*in) >> 16) % (1U << 6); - out++; - *out = ((*in) >> 22) % (1U << 6); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 2)) << (6 - 2); - out++; - *out = ((*in) >> 2) % (1U << 6); - out++; - *out = ((*in) >> 8) % (1U << 6); - out++; - *out = ((*in) >> 14) % (1U << 6); - out++; - *out = ((*in) >> 20) % (1U << 6); - out++; - *out = ((*in) >> 26); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 6); - out++; - *out = ((*in) >> 6) % (1U << 6); - out++; - *out = ((*in) >> 12) % (1U << 6); - out++; - *out = ((*in) >> 18) % (1U << 6); - out++; - *out = ((*in) >> 24) % (1U << 6); - out++; - *out = ((*in) >> 30); - ++in; - *out |= ((*in) % (1U << 4)) << (6 - 4); - out++; - *out = ((*in) >> 4) % (1U << 6); - out++; - *out = ((*in) >> 10) % (1U << 6); - out++; - *out = ((*in) >> 16) % (1U << 6); - out++; - *out = ((*in) >> 22) % (1U << 6); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 2)) << (6 - 2); - out++; - *out = ((*in) >> 2) % (1U << 6); - out++; - *out = ((*in) >> 8) % (1U << 6); - out++; - *out = ((*in) >> 14) % (1U << 6); - out++; - *out = ((*in) >> 20) % (1U << 6); - out++; - *out = ((*in) >> 26); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack7_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 7); - out++; - *out = ((*in) >> 7) % (1U << 7); - out++; - *out = ((*in) >> 14) % (1U << 7); - out++; - *out = ((*in) >> 21) % (1U << 7); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 3)) << (7 - 3); - out++; - *out = ((*in) >> 3) % (1U << 7); - out++; - *out = ((*in) >> 10) % (1U << 7); - out++; - *out = ((*in) >> 17) % (1U << 7); - out++; - *out = ((*in) >> 24) % (1U << 7); - out++; - *out = ((*in) >> 31); - ++in; - *out |= ((*in) % (1U << 6)) << (7 - 6); - out++; - *out = ((*in) >> 6) % (1U << 7); - out++; - *out = ((*in) >> 13) % (1U << 7); - out++; - *out = ((*in) >> 20) % (1U << 7); - out++; - *out = ((*in) >> 27); - ++in; - *out |= ((*in) % (1U << 2)) << (7 - 2); - out++; - *out = ((*in) >> 2) % (1U << 7); - out++; - *out = ((*in) >> 9) % (1U << 7); - out++; - *out = ((*in) >> 16) % (1U << 7); - out++; - *out = ((*in) >> 23) % (1U << 7); - out++; - *out = ((*in) >> 30); - ++in; - *out |= ((*in) % (1U << 5)) << (7 - 5); - out++; - *out = ((*in) >> 5) % (1U << 7); - out++; - *out = ((*in) >> 12) % (1U << 7); - out++; - *out = ((*in) >> 19) % (1U << 7); - out++; - *out = ((*in) >> 26); - ++in; - *out |= ((*in) % (1U << 1)) << (7 - 1); - out++; - *out = ((*in) >> 1) % (1U << 7); - out++; - *out = ((*in) >> 8) % (1U << 7); - out++; - *out = ((*in) >> 15) % (1U << 7); - out++; - *out = ((*in) >> 22) % (1U << 7); - out++; - *out = ((*in) >> 29); - ++in; - *out |= ((*in) % (1U << 4)) << (7 - 4); - out++; - *out = ((*in) >> 4) % (1U << 7); - out++; - *out = ((*in) >> 11) % (1U << 7); - out++; - *out = ((*in) >> 18) % (1U << 7); - out++; - *out = ((*in) >> 25); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack8_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 8); - out++; - *out = ((*in) >> 8) % (1U << 8); - out++; - *out = ((*in) >> 16) % (1U << 8); - out++; - *out = ((*in) >> 24); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 8); - out++; - *out = ((*in) >> 8) % (1U << 8); - out++; - *out = ((*in) >> 16) % (1U << 8); - out++; - *out = ((*in) >> 24); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 8); - out++; - *out = ((*in) >> 8) % (1U << 8); - out++; - *out = ((*in) >> 16) % (1U << 8); - out++; - *out = ((*in) >> 24); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 8); - out++; - *out = ((*in) >> 8) % (1U << 8); - out++; - *out = ((*in) >> 16) % (1U << 8); - out++; - *out = ((*in) >> 24); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 8); - out++; - *out = ((*in) >> 8) % (1U << 8); - out++; - *out = ((*in) >> 16) % (1U << 8); - out++; - *out = ((*in) >> 24); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 8); - out++; - *out = ((*in) >> 8) % (1U << 8); - out++; - *out = ((*in) >> 16) % (1U << 8); - out++; - *out = ((*in) >> 24); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 8); - out++; - *out = ((*in) >> 8) % (1U << 8); - out++; - *out = ((*in) >> 16) % (1U << 8); - out++; - *out = ((*in) >> 24); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 8); - out++; - *out = ((*in) >> 8) % (1U << 8); - out++; - *out = ((*in) >> 16) % (1U << 8); - out++; - *out = ((*in) >> 24); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack9_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 9); - out++; - *out = ((*in) >> 9) % (1U << 9); - out++; - *out = ((*in) >> 18) % (1U << 9); - out++; - *out = ((*in) >> 27); - ++in; - *out |= ((*in) % (1U << 4)) << (9 - 4); - out++; - *out = ((*in) >> 4) % (1U << 9); - out++; - *out = ((*in) >> 13) % (1U << 9); - out++; - *out = ((*in) >> 22) % (1U << 9); - out++; - *out = ((*in) >> 31); - ++in; - *out |= ((*in) % (1U << 8)) << (9 - 8); - out++; - *out = ((*in) >> 8) % (1U << 9); - out++; - *out = ((*in) >> 17) % (1U << 9); - out++; - *out = ((*in) >> 26); - ++in; - *out |= ((*in) % (1U << 3)) << (9 - 3); - out++; - *out = ((*in) >> 3) % (1U << 9); - out++; - *out = ((*in) >> 12) % (1U << 9); - out++; - *out = ((*in) >> 21) % (1U << 9); - out++; - *out = ((*in) >> 30); - ++in; - *out |= ((*in) % (1U << 7)) << (9 - 7); - out++; - *out = ((*in) >> 7) % (1U << 9); - out++; - *out = ((*in) >> 16) % (1U << 9); - out++; - *out = ((*in) >> 25); - ++in; - *out |= ((*in) % (1U << 2)) << (9 - 2); - out++; - *out = ((*in) >> 2) % (1U << 9); - out++; - *out = ((*in) >> 11) % (1U << 9); - out++; - *out = ((*in) >> 20) % (1U << 9); - out++; - *out = ((*in) >> 29); - ++in; - *out |= ((*in) % (1U << 6)) << (9 - 6); - out++; - *out = ((*in) >> 6) % (1U << 9); - out++; - *out = ((*in) >> 15) % (1U << 9); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 1)) << (9 - 1); - out++; - *out = ((*in) >> 1) % (1U << 9); - out++; - *out = ((*in) >> 10) % (1U << 9); - out++; - *out = ((*in) >> 19) % (1U << 9); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 5)) << (9 - 5); - out++; - *out = ((*in) >> 5) % (1U << 9); - out++; - *out = ((*in) >> 14) % (1U << 9); - out++; - *out = ((*in) >> 23); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack10_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 10); - out++; - *out = ((*in) >> 10) % (1U << 10); - out++; - *out = ((*in) >> 20) % (1U << 10); - out++; - *out = ((*in) >> 30); - ++in; - *out |= ((*in) % (1U << 8)) << (10 - 8); - out++; - *out = ((*in) >> 8) % (1U << 10); - out++; - *out = ((*in) >> 18) % (1U << 10); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 6)) << (10 - 6); - out++; - *out = ((*in) >> 6) % (1U << 10); - out++; - *out = ((*in) >> 16) % (1U << 10); - out++; - *out = ((*in) >> 26); - ++in; - *out |= ((*in) % (1U << 4)) << (10 - 4); - out++; - *out = ((*in) >> 4) % (1U << 10); - out++; - *out = ((*in) >> 14) % (1U << 10); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 2)) << (10 - 2); - out++; - *out = ((*in) >> 2) % (1U << 10); - out++; - *out = ((*in) >> 12) % (1U << 10); - out++; - *out = ((*in) >> 22); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 10); - out++; - *out = ((*in) >> 10) % (1U << 10); - out++; - *out = ((*in) >> 20) % (1U << 10); - out++; - *out = ((*in) >> 30); - ++in; - *out |= ((*in) % (1U << 8)) << (10 - 8); - out++; - *out = ((*in) >> 8) % (1U << 10); - out++; - *out = ((*in) >> 18) % (1U << 10); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 6)) << (10 - 6); - out++; - *out = ((*in) >> 6) % (1U << 10); - out++; - *out = ((*in) >> 16) % (1U << 10); - out++; - *out = ((*in) >> 26); - ++in; - *out |= ((*in) % (1U << 4)) << (10 - 4); - out++; - *out = ((*in) >> 4) % (1U << 10); - out++; - *out = ((*in) >> 14) % (1U << 10); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 2)) << (10 - 2); - out++; - *out = ((*in) >> 2) % (1U << 10); - out++; - *out = ((*in) >> 12) % (1U << 10); - out++; - *out = ((*in) >> 22); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack11_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 11); - out++; - *out = ((*in) >> 11) % (1U << 11); - out++; - *out = ((*in) >> 22); - ++in; - *out |= ((*in) % (1U << 1)) << (11 - 1); - out++; - *out = ((*in) >> 1) % (1U << 11); - out++; - *out = ((*in) >> 12) % (1U << 11); - out++; - *out = ((*in) >> 23); - ++in; - *out |= ((*in) % (1U << 2)) << (11 - 2); - out++; - *out = ((*in) >> 2) % (1U << 11); - out++; - *out = ((*in) >> 13) % (1U << 11); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 3)) << (11 - 3); - out++; - *out = ((*in) >> 3) % (1U << 11); - out++; - *out = ((*in) >> 14) % (1U << 11); - out++; - *out = ((*in) >> 25); - ++in; - *out |= ((*in) % (1U << 4)) << (11 - 4); - out++; - *out = ((*in) >> 4) % (1U << 11); - out++; - *out = ((*in) >> 15) % (1U << 11); - out++; - *out = ((*in) >> 26); - ++in; - *out |= ((*in) % (1U << 5)) << (11 - 5); - out++; - *out = ((*in) >> 5) % (1U << 11); - out++; - *out = ((*in) >> 16) % (1U << 11); - out++; - *out = ((*in) >> 27); - ++in; - *out |= ((*in) % (1U << 6)) << (11 - 6); - out++; - *out = ((*in) >> 6) % (1U << 11); - out++; - *out = ((*in) >> 17) % (1U << 11); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 7)) << (11 - 7); - out++; - *out = ((*in) >> 7) % (1U << 11); - out++; - *out = ((*in) >> 18) % (1U << 11); - out++; - *out = ((*in) >> 29); - ++in; - *out |= ((*in) % (1U << 8)) << (11 - 8); - out++; - *out = ((*in) >> 8) % (1U << 11); - out++; - *out = ((*in) >> 19) % (1U << 11); - out++; - *out = ((*in) >> 30); - ++in; - *out |= ((*in) % (1U << 9)) << (11 - 9); - out++; - *out = ((*in) >> 9) % (1U << 11); - out++; - *out = ((*in) >> 20) % (1U << 11); - out++; - *out = ((*in) >> 31); - ++in; - *out |= ((*in) % (1U << 10)) << (11 - 10); - out++; - *out = ((*in) >> 10) % (1U << 11); - out++; - *out = ((*in) >> 21); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack12_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 12); - out++; - *out = ((*in) >> 12) % (1U << 12); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 4)) << (12 - 4); - out++; - *out = ((*in) >> 4) % (1U << 12); - out++; - *out = ((*in) >> 16) % (1U << 12); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 8)) << (12 - 8); - out++; - *out = ((*in) >> 8) % (1U << 12); - out++; - *out = ((*in) >> 20); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 12); - out++; - *out = ((*in) >> 12) % (1U << 12); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 4)) << (12 - 4); - out++; - *out = ((*in) >> 4) % (1U << 12); - out++; - *out = ((*in) >> 16) % (1U << 12); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 8)) << (12 - 8); - out++; - *out = ((*in) >> 8) % (1U << 12); - out++; - *out = ((*in) >> 20); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 12); - out++; - *out = ((*in) >> 12) % (1U << 12); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 4)) << (12 - 4); - out++; - *out = ((*in) >> 4) % (1U << 12); - out++; - *out = ((*in) >> 16) % (1U << 12); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 8)) << (12 - 8); - out++; - *out = ((*in) >> 8) % (1U << 12); - out++; - *out = ((*in) >> 20); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 12); - out++; - *out = ((*in) >> 12) % (1U << 12); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 4)) << (12 - 4); - out++; - *out = ((*in) >> 4) % (1U << 12); - out++; - *out = ((*in) >> 16) % (1U << 12); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 8)) << (12 - 8); - out++; - *out = ((*in) >> 8) % (1U << 12); - out++; - *out = ((*in) >> 20); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack13_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 13); - out++; - *out = ((*in) >> 13) % (1U << 13); - out++; - *out = ((*in) >> 26); - ++in; - *out |= ((*in) % (1U << 7)) << (13 - 7); - out++; - *out = ((*in) >> 7) % (1U << 13); - out++; - *out = ((*in) >> 20); - ++in; - *out |= ((*in) % (1U << 1)) << (13 - 1); - out++; - *out = ((*in) >> 1) % (1U << 13); - out++; - *out = ((*in) >> 14) % (1U << 13); - out++; - *out = ((*in) >> 27); - ++in; - *out |= ((*in) % (1U << 8)) << (13 - 8); - out++; - *out = ((*in) >> 8) % (1U << 13); - out++; - *out = ((*in) >> 21); - ++in; - *out |= ((*in) % (1U << 2)) << (13 - 2); - out++; - *out = ((*in) >> 2) % (1U << 13); - out++; - *out = ((*in) >> 15) % (1U << 13); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 9)) << (13 - 9); - out++; - *out = ((*in) >> 9) % (1U << 13); - out++; - *out = ((*in) >> 22); - ++in; - *out |= ((*in) % (1U << 3)) << (13 - 3); - out++; - *out = ((*in) >> 3) % (1U << 13); - out++; - *out = ((*in) >> 16) % (1U << 13); - out++; - *out = ((*in) >> 29); - ++in; - *out |= ((*in) % (1U << 10)) << (13 - 10); - out++; - *out = ((*in) >> 10) % (1U << 13); - out++; - *out = ((*in) >> 23); - ++in; - *out |= ((*in) % (1U << 4)) << (13 - 4); - out++; - *out = ((*in) >> 4) % (1U << 13); - out++; - *out = ((*in) >> 17) % (1U << 13); - out++; - *out = ((*in) >> 30); - ++in; - *out |= ((*in) % (1U << 11)) << (13 - 11); - out++; - *out = ((*in) >> 11) % (1U << 13); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 5)) << (13 - 5); - out++; - *out = ((*in) >> 5) % (1U << 13); - out++; - *out = ((*in) >> 18) % (1U << 13); - out++; - *out = ((*in) >> 31); - ++in; - *out |= ((*in) % (1U << 12)) << (13 - 12); - out++; - *out = ((*in) >> 12) % (1U << 13); - out++; - *out = ((*in) >> 25); - ++in; - *out |= ((*in) % (1U << 6)) << (13 - 6); - out++; - *out = ((*in) >> 6) % (1U << 13); - out++; - *out = ((*in) >> 19); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack14_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 14); - out++; - *out = ((*in) >> 14) % (1U << 14); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 10)) << (14 - 10); - out++; - *out = ((*in) >> 10) % (1U << 14); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 6)) << (14 - 6); - out++; - *out = ((*in) >> 6) % (1U << 14); - out++; - *out = ((*in) >> 20); - ++in; - *out |= ((*in) % (1U << 2)) << (14 - 2); - out++; - *out = ((*in) >> 2) % (1U << 14); - out++; - *out = ((*in) >> 16) % (1U << 14); - out++; - *out = ((*in) >> 30); - ++in; - *out |= ((*in) % (1U << 12)) << (14 - 12); - out++; - *out = ((*in) >> 12) % (1U << 14); - out++; - *out = ((*in) >> 26); - ++in; - *out |= ((*in) % (1U << 8)) << (14 - 8); - out++; - *out = ((*in) >> 8) % (1U << 14); - out++; - *out = ((*in) >> 22); - ++in; - *out |= ((*in) % (1U << 4)) << (14 - 4); - out++; - *out = ((*in) >> 4) % (1U << 14); - out++; - *out = ((*in) >> 18); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 14); - out++; - *out = ((*in) >> 14) % (1U << 14); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 10)) << (14 - 10); - out++; - *out = ((*in) >> 10) % (1U << 14); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 6)) << (14 - 6); - out++; - *out = ((*in) >> 6) % (1U << 14); - out++; - *out = ((*in) >> 20); - ++in; - *out |= ((*in) % (1U << 2)) << (14 - 2); - out++; - *out = ((*in) >> 2) % (1U << 14); - out++; - *out = ((*in) >> 16) % (1U << 14); - out++; - *out = ((*in) >> 30); - ++in; - *out |= ((*in) % (1U << 12)) << (14 - 12); - out++; - *out = ((*in) >> 12) % (1U << 14); - out++; - *out = ((*in) >> 26); - ++in; - *out |= ((*in) % (1U << 8)) << (14 - 8); - out++; - *out = ((*in) >> 8) % (1U << 14); - out++; - *out = ((*in) >> 22); - ++in; - *out |= ((*in) % (1U << 4)) << (14 - 4); - out++; - *out = ((*in) >> 4) % (1U << 14); - out++; - *out = ((*in) >> 18); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack15_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 15); - out++; - *out = ((*in) >> 15) % (1U << 15); - out++; - *out = ((*in) >> 30); - ++in; - *out |= ((*in) % (1U << 13)) << (15 - 13); - out++; - *out = ((*in) >> 13) % (1U << 15); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 11)) << (15 - 11); - out++; - *out = ((*in) >> 11) % (1U << 15); - out++; - *out = ((*in) >> 26); - ++in; - *out |= ((*in) % (1U << 9)) << (15 - 9); - out++; - *out = ((*in) >> 9) % (1U << 15); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 7)) << (15 - 7); - out++; - *out = ((*in) >> 7) % (1U << 15); - out++; - *out = ((*in) >> 22); - ++in; - *out |= ((*in) % (1U << 5)) << (15 - 5); - out++; - *out = ((*in) >> 5) % (1U << 15); - out++; - *out = ((*in) >> 20); - ++in; - *out |= ((*in) % (1U << 3)) << (15 - 3); - out++; - *out = ((*in) >> 3) % (1U << 15); - out++; - *out = ((*in) >> 18); - ++in; - *out |= ((*in) % (1U << 1)) << (15 - 1); - out++; - *out = ((*in) >> 1) % (1U << 15); - out++; - *out = ((*in) >> 16) % (1U << 15); - out++; - *out = ((*in) >> 31); - ++in; - *out |= ((*in) % (1U << 14)) << (15 - 14); - out++; - *out = ((*in) >> 14) % (1U << 15); - out++; - *out = ((*in) >> 29); - ++in; - *out |= ((*in) % (1U << 12)) << (15 - 12); - out++; - *out = ((*in) >> 12) % (1U << 15); - out++; - *out = ((*in) >> 27); - ++in; - *out |= ((*in) % (1U << 10)) << (15 - 10); - out++; - *out = ((*in) >> 10) % (1U << 15); - out++; - *out = ((*in) >> 25); - ++in; - *out |= ((*in) % (1U << 8)) << (15 - 8); - out++; - *out = ((*in) >> 8) % (1U << 15); - out++; - *out = ((*in) >> 23); - ++in; - *out |= ((*in) % (1U << 6)) << (15 - 6); - out++; - *out = ((*in) >> 6) % (1U << 15); - out++; - *out = ((*in) >> 21); - ++in; - *out |= ((*in) % (1U << 4)) << (15 - 4); - out++; - *out = ((*in) >> 4) % (1U << 15); - out++; - *out = ((*in) >> 19); - ++in; - *out |= ((*in) % (1U << 2)) << (15 - 2); - out++; - *out = ((*in) >> 2) % (1U << 15); - out++; - *out = ((*in) >> 17); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack16_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 16); - out++; - *out = ((*in) >> 16); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 16); - out++; - *out = ((*in) >> 16); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 16); - out++; - *out = ((*in) >> 16); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 16); - out++; - *out = ((*in) >> 16); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 16); - out++; - *out = ((*in) >> 16); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 16); - out++; - *out = ((*in) >> 16); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 16); - out++; - *out = ((*in) >> 16); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 16); - out++; - *out = ((*in) >> 16); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 16); - out++; - *out = ((*in) >> 16); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 16); - out++; - *out = ((*in) >> 16); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 16); - out++; - *out = ((*in) >> 16); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 16); - out++; - *out = ((*in) >> 16); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 16); - out++; - *out = ((*in) >> 16); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 16); - out++; - *out = ((*in) >> 16); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 16); - out++; - *out = ((*in) >> 16); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 16); - out++; - *out = ((*in) >> 16); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack17_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 17); - out++; - *out = ((*in) >> 17); - ++in; - *out |= ((*in) % (1U << 2)) << (17 - 2); - out++; - *out = ((*in) >> 2) % (1U << 17); - out++; - *out = ((*in) >> 19); - ++in; - *out |= ((*in) % (1U << 4)) << (17 - 4); - out++; - *out = ((*in) >> 4) % (1U << 17); - out++; - *out = ((*in) >> 21); - ++in; - *out |= ((*in) % (1U << 6)) << (17 - 6); - out++; - *out = ((*in) >> 6) % (1U << 17); - out++; - *out = ((*in) >> 23); - ++in; - *out |= ((*in) % (1U << 8)) << (17 - 8); - out++; - *out = ((*in) >> 8) % (1U << 17); - out++; - *out = ((*in) >> 25); - ++in; - *out |= ((*in) % (1U << 10)) << (17 - 10); - out++; - *out = ((*in) >> 10) % (1U << 17); - out++; - *out = ((*in) >> 27); - ++in; - *out |= ((*in) % (1U << 12)) << (17 - 12); - out++; - *out = ((*in) >> 12) % (1U << 17); - out++; - *out = ((*in) >> 29); - ++in; - *out |= ((*in) % (1U << 14)) << (17 - 14); - out++; - *out = ((*in) >> 14) % (1U << 17); - out++; - *out = ((*in) >> 31); - ++in; - *out |= ((*in) % (1U << 16)) << (17 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 1)) << (17 - 1); - out++; - *out = ((*in) >> 1) % (1U << 17); - out++; - *out = ((*in) >> 18); - ++in; - *out |= ((*in) % (1U << 3)) << (17 - 3); - out++; - *out = ((*in) >> 3) % (1U << 17); - out++; - *out = ((*in) >> 20); - ++in; - *out |= ((*in) % (1U << 5)) << (17 - 5); - out++; - *out = ((*in) >> 5) % (1U << 17); - out++; - *out = ((*in) >> 22); - ++in; - *out |= ((*in) % (1U << 7)) << (17 - 7); - out++; - *out = ((*in) >> 7) % (1U << 17); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 9)) << (17 - 9); - out++; - *out = ((*in) >> 9) % (1U << 17); - out++; - *out = ((*in) >> 26); - ++in; - *out |= ((*in) % (1U << 11)) << (17 - 11); - out++; - *out = ((*in) >> 11) % (1U << 17); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 13)) << (17 - 13); - out++; - *out = ((*in) >> 13) % (1U << 17); - out++; - *out = ((*in) >> 30); - ++in; - *out |= ((*in) % (1U << 15)) << (17 - 15); - out++; - *out = ((*in) >> 15); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack18_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 18); - out++; - *out = ((*in) >> 18); - ++in; - *out |= ((*in) % (1U << 4)) << (18 - 4); - out++; - *out = ((*in) >> 4) % (1U << 18); - out++; - *out = ((*in) >> 22); - ++in; - *out |= ((*in) % (1U << 8)) << (18 - 8); - out++; - *out = ((*in) >> 8) % (1U << 18); - out++; - *out = ((*in) >> 26); - ++in; - *out |= ((*in) % (1U << 12)) << (18 - 12); - out++; - *out = ((*in) >> 12) % (1U << 18); - out++; - *out = ((*in) >> 30); - ++in; - *out |= ((*in) % (1U << 16)) << (18 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 2)) << (18 - 2); - out++; - *out = ((*in) >> 2) % (1U << 18); - out++; - *out = ((*in) >> 20); - ++in; - *out |= ((*in) % (1U << 6)) << (18 - 6); - out++; - *out = ((*in) >> 6) % (1U << 18); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 10)) << (18 - 10); - out++; - *out = ((*in) >> 10) % (1U << 18); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 14)) << (18 - 14); - out++; - *out = ((*in) >> 14); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 18); - out++; - *out = ((*in) >> 18); - ++in; - *out |= ((*in) % (1U << 4)) << (18 - 4); - out++; - *out = ((*in) >> 4) % (1U << 18); - out++; - *out = ((*in) >> 22); - ++in; - *out |= ((*in) % (1U << 8)) << (18 - 8); - out++; - *out = ((*in) >> 8) % (1U << 18); - out++; - *out = ((*in) >> 26); - ++in; - *out |= ((*in) % (1U << 12)) << (18 - 12); - out++; - *out = ((*in) >> 12) % (1U << 18); - out++; - *out = ((*in) >> 30); - ++in; - *out |= ((*in) % (1U << 16)) << (18 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 2)) << (18 - 2); - out++; - *out = ((*in) >> 2) % (1U << 18); - out++; - *out = ((*in) >> 20); - ++in; - *out |= ((*in) % (1U << 6)) << (18 - 6); - out++; - *out = ((*in) >> 6) % (1U << 18); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 10)) << (18 - 10); - out++; - *out = ((*in) >> 10) % (1U << 18); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 14)) << (18 - 14); - out++; - *out = ((*in) >> 14); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack19_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 19); - out++; - *out = ((*in) >> 19); - ++in; - *out |= ((*in) % (1U << 6)) << (19 - 6); - out++; - *out = ((*in) >> 6) % (1U << 19); - out++; - *out = ((*in) >> 25); - ++in; - *out |= ((*in) % (1U << 12)) << (19 - 12); - out++; - *out = ((*in) >> 12) % (1U << 19); - out++; - *out = ((*in) >> 31); - ++in; - *out |= ((*in) % (1U << 18)) << (19 - 18); - out++; - *out = ((*in) >> 18); - ++in; - *out |= ((*in) % (1U << 5)) << (19 - 5); - out++; - *out = ((*in) >> 5) % (1U << 19); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 11)) << (19 - 11); - out++; - *out = ((*in) >> 11) % (1U << 19); - out++; - *out = ((*in) >> 30); - ++in; - *out |= ((*in) % (1U << 17)) << (19 - 17); - out++; - *out = ((*in) >> 17); - ++in; - *out |= ((*in) % (1U << 4)) << (19 - 4); - out++; - *out = ((*in) >> 4) % (1U << 19); - out++; - *out = ((*in) >> 23); - ++in; - *out |= ((*in) % (1U << 10)) << (19 - 10); - out++; - *out = ((*in) >> 10) % (1U << 19); - out++; - *out = ((*in) >> 29); - ++in; - *out |= ((*in) % (1U << 16)) << (19 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 3)) << (19 - 3); - out++; - *out = ((*in) >> 3) % (1U << 19); - out++; - *out = ((*in) >> 22); - ++in; - *out |= ((*in) % (1U << 9)) << (19 - 9); - out++; - *out = ((*in) >> 9) % (1U << 19); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 15)) << (19 - 15); - out++; - *out = ((*in) >> 15); - ++in; - *out |= ((*in) % (1U << 2)) << (19 - 2); - out++; - *out = ((*in) >> 2) % (1U << 19); - out++; - *out = ((*in) >> 21); - ++in; - *out |= ((*in) % (1U << 8)) << (19 - 8); - out++; - *out = ((*in) >> 8) % (1U << 19); - out++; - *out = ((*in) >> 27); - ++in; - *out |= ((*in) % (1U << 14)) << (19 - 14); - out++; - *out = ((*in) >> 14); - ++in; - *out |= ((*in) % (1U << 1)) << (19 - 1); - out++; - *out = ((*in) >> 1) % (1U << 19); - out++; - *out = ((*in) >> 20); - ++in; - *out |= ((*in) % (1U << 7)) << (19 - 7); - out++; - *out = ((*in) >> 7) % (1U << 19); - out++; - *out = ((*in) >> 26); - ++in; - *out |= ((*in) % (1U << 13)) << (19 - 13); - out++; - *out = ((*in) >> 13); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack20_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 20); - out++; - *out = ((*in) >> 20); - ++in; - *out |= ((*in) % (1U << 8)) << (20 - 8); - out++; - *out = ((*in) >> 8) % (1U << 20); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 16)) << (20 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 4)) << (20 - 4); - out++; - *out = ((*in) >> 4) % (1U << 20); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 12)) << (20 - 12); - out++; - *out = ((*in) >> 12); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 20); - out++; - *out = ((*in) >> 20); - ++in; - *out |= ((*in) % (1U << 8)) << (20 - 8); - out++; - *out = ((*in) >> 8) % (1U << 20); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 16)) << (20 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 4)) << (20 - 4); - out++; - *out = ((*in) >> 4) % (1U << 20); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 12)) << (20 - 12); - out++; - *out = ((*in) >> 12); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 20); - out++; - *out = ((*in) >> 20); - ++in; - *out |= ((*in) % (1U << 8)) << (20 - 8); - out++; - *out = ((*in) >> 8) % (1U << 20); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 16)) << (20 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 4)) << (20 - 4); - out++; - *out = ((*in) >> 4) % (1U << 20); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 12)) << (20 - 12); - out++; - *out = ((*in) >> 12); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 20); - out++; - *out = ((*in) >> 20); - ++in; - *out |= ((*in) % (1U << 8)) << (20 - 8); - out++; - *out = ((*in) >> 8) % (1U << 20); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 16)) << (20 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 4)) << (20 - 4); - out++; - *out = ((*in) >> 4) % (1U << 20); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 12)) << (20 - 12); - out++; - *out = ((*in) >> 12); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack21_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 21); - out++; - *out = ((*in) >> 21); - ++in; - *out |= ((*in) % (1U << 10)) << (21 - 10); - out++; - *out = ((*in) >> 10) % (1U << 21); - out++; - *out = ((*in) >> 31); - ++in; - *out |= ((*in) % (1U << 20)) << (21 - 20); - out++; - *out = ((*in) >> 20); - ++in; - *out |= ((*in) % (1U << 9)) << (21 - 9); - out++; - *out = ((*in) >> 9) % (1U << 21); - out++; - *out = ((*in) >> 30); - ++in; - *out |= ((*in) % (1U << 19)) << (21 - 19); - out++; - *out = ((*in) >> 19); - ++in; - *out |= ((*in) % (1U << 8)) << (21 - 8); - out++; - *out = ((*in) >> 8) % (1U << 21); - out++; - *out = ((*in) >> 29); - ++in; - *out |= ((*in) % (1U << 18)) << (21 - 18); - out++; - *out = ((*in) >> 18); - ++in; - *out |= ((*in) % (1U << 7)) << (21 - 7); - out++; - *out = ((*in) >> 7) % (1U << 21); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 17)) << (21 - 17); - out++; - *out = ((*in) >> 17); - ++in; - *out |= ((*in) % (1U << 6)) << (21 - 6); - out++; - *out = ((*in) >> 6) % (1U << 21); - out++; - *out = ((*in) >> 27); - ++in; - *out |= ((*in) % (1U << 16)) << (21 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 5)) << (21 - 5); - out++; - *out = ((*in) >> 5) % (1U << 21); - out++; - *out = ((*in) >> 26); - ++in; - *out |= ((*in) % (1U << 15)) << (21 - 15); - out++; - *out = ((*in) >> 15); - ++in; - *out |= ((*in) % (1U << 4)) << (21 - 4); - out++; - *out = ((*in) >> 4) % (1U << 21); - out++; - *out = ((*in) >> 25); - ++in; - *out |= ((*in) % (1U << 14)) << (21 - 14); - out++; - *out = ((*in) >> 14); - ++in; - *out |= ((*in) % (1U << 3)) << (21 - 3); - out++; - *out = ((*in) >> 3) % (1U << 21); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 13)) << (21 - 13); - out++; - *out = ((*in) >> 13); - ++in; - *out |= ((*in) % (1U << 2)) << (21 - 2); - out++; - *out = ((*in) >> 2) % (1U << 21); - out++; - *out = ((*in) >> 23); - ++in; - *out |= ((*in) % (1U << 12)) << (21 - 12); - out++; - *out = ((*in) >> 12); - ++in; - *out |= ((*in) % (1U << 1)) << (21 - 1); - out++; - *out = ((*in) >> 1) % (1U << 21); - out++; - *out = ((*in) >> 22); - ++in; - *out |= ((*in) % (1U << 11)) << (21 - 11); - out++; - *out = ((*in) >> 11); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack22_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 22); - out++; - *out = ((*in) >> 22); - ++in; - *out |= ((*in) % (1U << 12)) << (22 - 12); - out++; - *out = ((*in) >> 12); - ++in; - *out |= ((*in) % (1U << 2)) << (22 - 2); - out++; - *out = ((*in) >> 2) % (1U << 22); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 14)) << (22 - 14); - out++; - *out = ((*in) >> 14); - ++in; - *out |= ((*in) % (1U << 4)) << (22 - 4); - out++; - *out = ((*in) >> 4) % (1U << 22); - out++; - *out = ((*in) >> 26); - ++in; - *out |= ((*in) % (1U << 16)) << (22 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 6)) << (22 - 6); - out++; - *out = ((*in) >> 6) % (1U << 22); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 18)) << (22 - 18); - out++; - *out = ((*in) >> 18); - ++in; - *out |= ((*in) % (1U << 8)) << (22 - 8); - out++; - *out = ((*in) >> 8) % (1U << 22); - out++; - *out = ((*in) >> 30); - ++in; - *out |= ((*in) % (1U << 20)) << (22 - 20); - out++; - *out = ((*in) >> 20); - ++in; - *out |= ((*in) % (1U << 10)) << (22 - 10); - out++; - *out = ((*in) >> 10); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 22); - out++; - *out = ((*in) >> 22); - ++in; - *out |= ((*in) % (1U << 12)) << (22 - 12); - out++; - *out = ((*in) >> 12); - ++in; - *out |= ((*in) % (1U << 2)) << (22 - 2); - out++; - *out = ((*in) >> 2) % (1U << 22); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 14)) << (22 - 14); - out++; - *out = ((*in) >> 14); - ++in; - *out |= ((*in) % (1U << 4)) << (22 - 4); - out++; - *out = ((*in) >> 4) % (1U << 22); - out++; - *out = ((*in) >> 26); - ++in; - *out |= ((*in) % (1U << 16)) << (22 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 6)) << (22 - 6); - out++; - *out = ((*in) >> 6) % (1U << 22); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 18)) << (22 - 18); - out++; - *out = ((*in) >> 18); - ++in; - *out |= ((*in) % (1U << 8)) << (22 - 8); - out++; - *out = ((*in) >> 8) % (1U << 22); - out++; - *out = ((*in) >> 30); - ++in; - *out |= ((*in) % (1U << 20)) << (22 - 20); - out++; - *out = ((*in) >> 20); - ++in; - *out |= ((*in) % (1U << 10)) << (22 - 10); - out++; - *out = ((*in) >> 10); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack23_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 23); - out++; - *out = ((*in) >> 23); - ++in; - *out |= ((*in) % (1U << 14)) << (23 - 14); - out++; - *out = ((*in) >> 14); - ++in; - *out |= ((*in) % (1U << 5)) << (23 - 5); - out++; - *out = ((*in) >> 5) % (1U << 23); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 19)) << (23 - 19); - out++; - *out = ((*in) >> 19); - ++in; - *out |= ((*in) % (1U << 10)) << (23 - 10); - out++; - *out = ((*in) >> 10); - ++in; - *out |= ((*in) % (1U << 1)) << (23 - 1); - out++; - *out = ((*in) >> 1) % (1U << 23); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 15)) << (23 - 15); - out++; - *out = ((*in) >> 15); - ++in; - *out |= ((*in) % (1U << 6)) << (23 - 6); - out++; - *out = ((*in) >> 6) % (1U << 23); - out++; - *out = ((*in) >> 29); - ++in; - *out |= ((*in) % (1U << 20)) << (23 - 20); - out++; - *out = ((*in) >> 20); - ++in; - *out |= ((*in) % (1U << 11)) << (23 - 11); - out++; - *out = ((*in) >> 11); - ++in; - *out |= ((*in) % (1U << 2)) << (23 - 2); - out++; - *out = ((*in) >> 2) % (1U << 23); - out++; - *out = ((*in) >> 25); - ++in; - *out |= ((*in) % (1U << 16)) << (23 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 7)) << (23 - 7); - out++; - *out = ((*in) >> 7) % (1U << 23); - out++; - *out = ((*in) >> 30); - ++in; - *out |= ((*in) % (1U << 21)) << (23 - 21); - out++; - *out = ((*in) >> 21); - ++in; - *out |= ((*in) % (1U << 12)) << (23 - 12); - out++; - *out = ((*in) >> 12); - ++in; - *out |= ((*in) % (1U << 3)) << (23 - 3); - out++; - *out = ((*in) >> 3) % (1U << 23); - out++; - *out = ((*in) >> 26); - ++in; - *out |= ((*in) % (1U << 17)) << (23 - 17); - out++; - *out = ((*in) >> 17); - ++in; - *out |= ((*in) % (1U << 8)) << (23 - 8); - out++; - *out = ((*in) >> 8) % (1U << 23); - out++; - *out = ((*in) >> 31); - ++in; - *out |= ((*in) % (1U << 22)) << (23 - 22); - out++; - *out = ((*in) >> 22); - ++in; - *out |= ((*in) % (1U << 13)) << (23 - 13); - out++; - *out = ((*in) >> 13); - ++in; - *out |= ((*in) % (1U << 4)) << (23 - 4); - out++; - *out = ((*in) >> 4) % (1U << 23); - out++; - *out = ((*in) >> 27); - ++in; - *out |= ((*in) % (1U << 18)) << (23 - 18); - out++; - *out = ((*in) >> 18); - ++in; - *out |= ((*in) % (1U << 9)) << (23 - 9); - out++; - *out = ((*in) >> 9); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack24_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 24); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 16)) << (24 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 8)) << (24 - 8); - out++; - *out = ((*in) >> 8); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 24); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 16)) << (24 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 8)) << (24 - 8); - out++; - *out = ((*in) >> 8); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 24); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 16)) << (24 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 8)) << (24 - 8); - out++; - *out = ((*in) >> 8); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 24); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 16)) << (24 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 8)) << (24 - 8); - out++; - *out = ((*in) >> 8); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 24); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 16)) << (24 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 8)) << (24 - 8); - out++; - *out = ((*in) >> 8); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 24); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 16)) << (24 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 8)) << (24 - 8); - out++; - *out = ((*in) >> 8); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 24); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 16)) << (24 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 8)) << (24 - 8); - out++; - *out = ((*in) >> 8); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 24); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 16)) << (24 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 8)) << (24 - 8); - out++; - *out = ((*in) >> 8); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack25_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 25); - out++; - *out = ((*in) >> 25); - ++in; - *out |= ((*in) % (1U << 18)) << (25 - 18); - out++; - *out = ((*in) >> 18); - ++in; - *out |= ((*in) % (1U << 11)) << (25 - 11); - out++; - *out = ((*in) >> 11); - ++in; - *out |= ((*in) % (1U << 4)) << (25 - 4); - out++; - *out = ((*in) >> 4) % (1U << 25); - out++; - *out = ((*in) >> 29); - ++in; - *out |= ((*in) % (1U << 22)) << (25 - 22); - out++; - *out = ((*in) >> 22); - ++in; - *out |= ((*in) % (1U << 15)) << (25 - 15); - out++; - *out = ((*in) >> 15); - ++in; - *out |= ((*in) % (1U << 8)) << (25 - 8); - out++; - *out = ((*in) >> 8); - ++in; - *out |= ((*in) % (1U << 1)) << (25 - 1); - out++; - *out = ((*in) >> 1) % (1U << 25); - out++; - *out = ((*in) >> 26); - ++in; - *out |= ((*in) % (1U << 19)) << (25 - 19); - out++; - *out = ((*in) >> 19); - ++in; - *out |= ((*in) % (1U << 12)) << (25 - 12); - out++; - *out = ((*in) >> 12); - ++in; - *out |= ((*in) % (1U << 5)) << (25 - 5); - out++; - *out = ((*in) >> 5) % (1U << 25); - out++; - *out = ((*in) >> 30); - ++in; - *out |= ((*in) % (1U << 23)) << (25 - 23); - out++; - *out = ((*in) >> 23); - ++in; - *out |= ((*in) % (1U << 16)) << (25 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 9)) << (25 - 9); - out++; - *out = ((*in) >> 9); - ++in; - *out |= ((*in) % (1U << 2)) << (25 - 2); - out++; - *out = ((*in) >> 2) % (1U << 25); - out++; - *out = ((*in) >> 27); - ++in; - *out |= ((*in) % (1U << 20)) << (25 - 20); - out++; - *out = ((*in) >> 20); - ++in; - *out |= ((*in) % (1U << 13)) << (25 - 13); - out++; - *out = ((*in) >> 13); - ++in; - *out |= ((*in) % (1U << 6)) << (25 - 6); - out++; - *out = ((*in) >> 6) % (1U << 25); - out++; - *out = ((*in) >> 31); - ++in; - *out |= ((*in) % (1U << 24)) << (25 - 24); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 17)) << (25 - 17); - out++; - *out = ((*in) >> 17); - ++in; - *out |= ((*in) % (1U << 10)) << (25 - 10); - out++; - *out = ((*in) >> 10); - ++in; - *out |= ((*in) % (1U << 3)) << (25 - 3); - out++; - *out = ((*in) >> 3) % (1U << 25); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 21)) << (25 - 21); - out++; - *out = ((*in) >> 21); - ++in; - *out |= ((*in) % (1U << 14)) << (25 - 14); - out++; - *out = ((*in) >> 14); - ++in; - *out |= ((*in) % (1U << 7)) << (25 - 7); - out++; - *out = ((*in) >> 7); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack26_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 26); - out++; - *out = ((*in) >> 26); - ++in; - *out |= ((*in) % (1U << 20)) << (26 - 20); - out++; - *out = ((*in) >> 20); - ++in; - *out |= ((*in) % (1U << 14)) << (26 - 14); - out++; - *out = ((*in) >> 14); - ++in; - *out |= ((*in) % (1U << 8)) << (26 - 8); - out++; - *out = ((*in) >> 8); - ++in; - *out |= ((*in) % (1U << 2)) << (26 - 2); - out++; - *out = ((*in) >> 2) % (1U << 26); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 22)) << (26 - 22); - out++; - *out = ((*in) >> 22); - ++in; - *out |= ((*in) % (1U << 16)) << (26 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 10)) << (26 - 10); - out++; - *out = ((*in) >> 10); - ++in; - *out |= ((*in) % (1U << 4)) << (26 - 4); - out++; - *out = ((*in) >> 4) % (1U << 26); - out++; - *out = ((*in) >> 30); - ++in; - *out |= ((*in) % (1U << 24)) << (26 - 24); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 18)) << (26 - 18); - out++; - *out = ((*in) >> 18); - ++in; - *out |= ((*in) % (1U << 12)) << (26 - 12); - out++; - *out = ((*in) >> 12); - ++in; - *out |= ((*in) % (1U << 6)) << (26 - 6); - out++; - *out = ((*in) >> 6); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 26); - out++; - *out = ((*in) >> 26); - ++in; - *out |= ((*in) % (1U << 20)) << (26 - 20); - out++; - *out = ((*in) >> 20); - ++in; - *out |= ((*in) % (1U << 14)) << (26 - 14); - out++; - *out = ((*in) >> 14); - ++in; - *out |= ((*in) % (1U << 8)) << (26 - 8); - out++; - *out = ((*in) >> 8); - ++in; - *out |= ((*in) % (1U << 2)) << (26 - 2); - out++; - *out = ((*in) >> 2) % (1U << 26); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 22)) << (26 - 22); - out++; - *out = ((*in) >> 22); - ++in; - *out |= ((*in) % (1U << 16)) << (26 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 10)) << (26 - 10); - out++; - *out = ((*in) >> 10); - ++in; - *out |= ((*in) % (1U << 4)) << (26 - 4); - out++; - *out = ((*in) >> 4) % (1U << 26); - out++; - *out = ((*in) >> 30); - ++in; - *out |= ((*in) % (1U << 24)) << (26 - 24); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 18)) << (26 - 18); - out++; - *out = ((*in) >> 18); - ++in; - *out |= ((*in) % (1U << 12)) << (26 - 12); - out++; - *out = ((*in) >> 12); - ++in; - *out |= ((*in) % (1U << 6)) << (26 - 6); - out++; - *out = ((*in) >> 6); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack27_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 27); - out++; - *out = ((*in) >> 27); - ++in; - *out |= ((*in) % (1U << 22)) << (27 - 22); - out++; - *out = ((*in) >> 22); - ++in; - *out |= ((*in) % (1U << 17)) << (27 - 17); - out++; - *out = ((*in) >> 17); - ++in; - *out |= ((*in) % (1U << 12)) << (27 - 12); - out++; - *out = ((*in) >> 12); - ++in; - *out |= ((*in) % (1U << 7)) << (27 - 7); - out++; - *out = ((*in) >> 7); - ++in; - *out |= ((*in) % (1U << 2)) << (27 - 2); - out++; - *out = ((*in) >> 2) % (1U << 27); - out++; - *out = ((*in) >> 29); - ++in; - *out |= ((*in) % (1U << 24)) << (27 - 24); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 19)) << (27 - 19); - out++; - *out = ((*in) >> 19); - ++in; - *out |= ((*in) % (1U << 14)) << (27 - 14); - out++; - *out = ((*in) >> 14); - ++in; - *out |= ((*in) % (1U << 9)) << (27 - 9); - out++; - *out = ((*in) >> 9); - ++in; - *out |= ((*in) % (1U << 4)) << (27 - 4); - out++; - *out = ((*in) >> 4) % (1U << 27); - out++; - *out = ((*in) >> 31); - ++in; - *out |= ((*in) % (1U << 26)) << (27 - 26); - out++; - *out = ((*in) >> 26); - ++in; - *out |= ((*in) % (1U << 21)) << (27 - 21); - out++; - *out = ((*in) >> 21); - ++in; - *out |= ((*in) % (1U << 16)) << (27 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 11)) << (27 - 11); - out++; - *out = ((*in) >> 11); - ++in; - *out |= ((*in) % (1U << 6)) << (27 - 6); - out++; - *out = ((*in) >> 6); - ++in; - *out |= ((*in) % (1U << 1)) << (27 - 1); - out++; - *out = ((*in) >> 1) % (1U << 27); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 23)) << (27 - 23); - out++; - *out = ((*in) >> 23); - ++in; - *out |= ((*in) % (1U << 18)) << (27 - 18); - out++; - *out = ((*in) >> 18); - ++in; - *out |= ((*in) % (1U << 13)) << (27 - 13); - out++; - *out = ((*in) >> 13); - ++in; - *out |= ((*in) % (1U << 8)) << (27 - 8); - out++; - *out = ((*in) >> 8); - ++in; - *out |= ((*in) % (1U << 3)) << (27 - 3); - out++; - *out = ((*in) >> 3) % (1U << 27); - out++; - *out = ((*in) >> 30); - ++in; - *out |= ((*in) % (1U << 25)) << (27 - 25); - out++; - *out = ((*in) >> 25); - ++in; - *out |= ((*in) % (1U << 20)) << (27 - 20); - out++; - *out = ((*in) >> 20); - ++in; - *out |= ((*in) % (1U << 15)) << (27 - 15); - out++; - *out = ((*in) >> 15); - ++in; - *out |= ((*in) % (1U << 10)) << (27 - 10); - out++; - *out = ((*in) >> 10); - ++in; - *out |= ((*in) % (1U << 5)) << (27 - 5); - out++; - *out = ((*in) >> 5); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack28_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 28); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 24)) << (28 - 24); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 20)) << (28 - 20); - out++; - *out = ((*in) >> 20); - ++in; - *out |= ((*in) % (1U << 16)) << (28 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 12)) << (28 - 12); - out++; - *out = ((*in) >> 12); - ++in; - *out |= ((*in) % (1U << 8)) << (28 - 8); - out++; - *out = ((*in) >> 8); - ++in; - *out |= ((*in) % (1U << 4)) << (28 - 4); - out++; - *out = ((*in) >> 4); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 28); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 24)) << (28 - 24); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 20)) << (28 - 20); - out++; - *out = ((*in) >> 20); - ++in; - *out |= ((*in) % (1U << 16)) << (28 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 12)) << (28 - 12); - out++; - *out = ((*in) >> 12); - ++in; - *out |= ((*in) % (1U << 8)) << (28 - 8); - out++; - *out = ((*in) >> 8); - ++in; - *out |= ((*in) % (1U << 4)) << (28 - 4); - out++; - *out = ((*in) >> 4); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 28); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 24)) << (28 - 24); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 20)) << (28 - 20); - out++; - *out = ((*in) >> 20); - ++in; - *out |= ((*in) % (1U << 16)) << (28 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 12)) << (28 - 12); - out++; - *out = ((*in) >> 12); - ++in; - *out |= ((*in) % (1U << 8)) << (28 - 8); - out++; - *out = ((*in) >> 8); - ++in; - *out |= ((*in) % (1U << 4)) << (28 - 4); - out++; - *out = ((*in) >> 4); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 28); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 24)) << (28 - 24); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 20)) << (28 - 20); - out++; - *out = ((*in) >> 20); - ++in; - *out |= ((*in) % (1U << 16)) << (28 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 12)) << (28 - 12); - out++; - *out = ((*in) >> 12); - ++in; - *out |= ((*in) % (1U << 8)) << (28 - 8); - out++; - *out = ((*in) >> 8); - ++in; - *out |= ((*in) % (1U << 4)) << (28 - 4); - out++; - *out = ((*in) >> 4); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack29_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 29); - out++; - *out = ((*in) >> 29); - ++in; - *out |= ((*in) % (1U << 26)) << (29 - 26); - out++; - *out = ((*in) >> 26); - ++in; - *out |= ((*in) % (1U << 23)) << (29 - 23); - out++; - *out = ((*in) >> 23); - ++in; - *out |= ((*in) % (1U << 20)) << (29 - 20); - out++; - *out = ((*in) >> 20); - ++in; - *out |= ((*in) % (1U << 17)) << (29 - 17); - out++; - *out = ((*in) >> 17); - ++in; - *out |= ((*in) % (1U << 14)) << (29 - 14); - out++; - *out = ((*in) >> 14); - ++in; - *out |= ((*in) % (1U << 11)) << (29 - 11); - out++; - *out = ((*in) >> 11); - ++in; - *out |= ((*in) % (1U << 8)) << (29 - 8); - out++; - *out = ((*in) >> 8); - ++in; - *out |= ((*in) % (1U << 5)) << (29 - 5); - out++; - *out = ((*in) >> 5); - ++in; - *out |= ((*in) % (1U << 2)) << (29 - 2); - out++; - *out = ((*in) >> 2) % (1U << 29); - out++; - *out = ((*in) >> 31); - ++in; - *out |= ((*in) % (1U << 28)) << (29 - 28); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 25)) << (29 - 25); - out++; - *out = ((*in) >> 25); - ++in; - *out |= ((*in) % (1U << 22)) << (29 - 22); - out++; - *out = ((*in) >> 22); - ++in; - *out |= ((*in) % (1U << 19)) << (29 - 19); - out++; - *out = ((*in) >> 19); - ++in; - *out |= ((*in) % (1U << 16)) << (29 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 13)) << (29 - 13); - out++; - *out = ((*in) >> 13); - ++in; - *out |= ((*in) % (1U << 10)) << (29 - 10); - out++; - *out = ((*in) >> 10); - ++in; - *out |= ((*in) % (1U << 7)) << (29 - 7); - out++; - *out = ((*in) >> 7); - ++in; - *out |= ((*in) % (1U << 4)) << (29 - 4); - out++; - *out = ((*in) >> 4); - ++in; - *out |= ((*in) % (1U << 1)) << (29 - 1); - out++; - *out = ((*in) >> 1) % (1U << 29); - out++; - *out = ((*in) >> 30); - ++in; - *out |= ((*in) % (1U << 27)) << (29 - 27); - out++; - *out = ((*in) >> 27); - ++in; - *out |= ((*in) % (1U << 24)) << (29 - 24); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 21)) << (29 - 21); - out++; - *out = ((*in) >> 21); - ++in; - *out |= ((*in) % (1U << 18)) << (29 - 18); - out++; - *out = ((*in) >> 18); - ++in; - *out |= ((*in) % (1U << 15)) << (29 - 15); - out++; - *out = ((*in) >> 15); - ++in; - *out |= ((*in) % (1U << 12)) << (29 - 12); - out++; - *out = ((*in) >> 12); - ++in; - *out |= ((*in) % (1U << 9)) << (29 - 9); - out++; - *out = ((*in) >> 9); - ++in; - *out |= ((*in) % (1U << 6)) << (29 - 6); - out++; - *out = ((*in) >> 6); - ++in; - *out |= ((*in) % (1U << 3)) << (29 - 3); - out++; - *out = ((*in) >> 3); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack30_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 30); - out++; - *out = ((*in) >> 30); - ++in; - *out |= ((*in) % (1U << 28)) << (30 - 28); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 26)) << (30 - 26); - out++; - *out = ((*in) >> 26); - ++in; - *out |= ((*in) % (1U << 24)) << (30 - 24); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 22)) << (30 - 22); - out++; - *out = ((*in) >> 22); - ++in; - *out |= ((*in) % (1U << 20)) << (30 - 20); - out++; - *out = ((*in) >> 20); - ++in; - *out |= ((*in) % (1U << 18)) << (30 - 18); - out++; - *out = ((*in) >> 18); - ++in; - *out |= ((*in) % (1U << 16)) << (30 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 14)) << (30 - 14); - out++; - *out = ((*in) >> 14); - ++in; - *out |= ((*in) % (1U << 12)) << (30 - 12); - out++; - *out = ((*in) >> 12); - ++in; - *out |= ((*in) % (1U << 10)) << (30 - 10); - out++; - *out = ((*in) >> 10); - ++in; - *out |= ((*in) % (1U << 8)) << (30 - 8); - out++; - *out = ((*in) >> 8); - ++in; - *out |= ((*in) % (1U << 6)) << (30 - 6); - out++; - *out = ((*in) >> 6); - ++in; - *out |= ((*in) % (1U << 4)) << (30 - 4); - out++; - *out = ((*in) >> 4); - ++in; - *out |= ((*in) % (1U << 2)) << (30 - 2); - out++; - *out = ((*in) >> 2); - ++in; - out++; - *out = ((*in) >> 0) % (1U << 30); - out++; - *out = ((*in) >> 30); - ++in; - *out |= ((*in) % (1U << 28)) << (30 - 28); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 26)) << (30 - 26); - out++; - *out = ((*in) >> 26); - ++in; - *out |= ((*in) % (1U << 24)) << (30 - 24); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 22)) << (30 - 22); - out++; - *out = ((*in) >> 22); - ++in; - *out |= ((*in) % (1U << 20)) << (30 - 20); - out++; - *out = ((*in) >> 20); - ++in; - *out |= ((*in) % (1U << 18)) << (30 - 18); - out++; - *out = ((*in) >> 18); - ++in; - *out |= ((*in) % (1U << 16)) << (30 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 14)) << (30 - 14); - out++; - *out = ((*in) >> 14); - ++in; - *out |= ((*in) % (1U << 12)) << (30 - 12); - out++; - *out = ((*in) >> 12); - ++in; - *out |= ((*in) % (1U << 10)) << (30 - 10); - out++; - *out = ((*in) >> 10); - ++in; - *out |= ((*in) % (1U << 8)) << (30 - 8); - out++; - *out = ((*in) >> 8); - ++in; - *out |= ((*in) % (1U << 6)) << (30 - 6); - out++; - *out = ((*in) >> 6); - ++in; - *out |= ((*in) % (1U << 4)) << (30 - 4); - out++; - *out = ((*in) >> 4); - ++in; - *out |= ((*in) % (1U << 2)) << (30 - 2); - out++; - *out = ((*in) >> 2); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack31_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0) % (1U << 31); - out++; - *out = ((*in) >> 31); - ++in; - *out |= ((*in) % (1U << 30)) << (31 - 30); - out++; - *out = ((*in) >> 30); - ++in; - *out |= ((*in) % (1U << 29)) << (31 - 29); - out++; - *out = ((*in) >> 29); - ++in; - *out |= ((*in) % (1U << 28)) << (31 - 28); - out++; - *out = ((*in) >> 28); - ++in; - *out |= ((*in) % (1U << 27)) << (31 - 27); - out++; - *out = ((*in) >> 27); - ++in; - *out |= ((*in) % (1U << 26)) << (31 - 26); - out++; - *out = ((*in) >> 26); - ++in; - *out |= ((*in) % (1U << 25)) << (31 - 25); - out++; - *out = ((*in) >> 25); - ++in; - *out |= ((*in) % (1U << 24)) << (31 - 24); - out++; - *out = ((*in) >> 24); - ++in; - *out |= ((*in) % (1U << 23)) << (31 - 23); - out++; - *out = ((*in) >> 23); - ++in; - *out |= ((*in) % (1U << 22)) << (31 - 22); - out++; - *out = ((*in) >> 22); - ++in; - *out |= ((*in) % (1U << 21)) << (31 - 21); - out++; - *out = ((*in) >> 21); - ++in; - *out |= ((*in) % (1U << 20)) << (31 - 20); - out++; - *out = ((*in) >> 20); - ++in; - *out |= ((*in) % (1U << 19)) << (31 - 19); - out++; - *out = ((*in) >> 19); - ++in; - *out |= ((*in) % (1U << 18)) << (31 - 18); - out++; - *out = ((*in) >> 18); - ++in; - *out |= ((*in) % (1U << 17)) << (31 - 17); - out++; - *out = ((*in) >> 17); - ++in; - *out |= ((*in) % (1U << 16)) << (31 - 16); - out++; - *out = ((*in) >> 16); - ++in; - *out |= ((*in) % (1U << 15)) << (31 - 15); - out++; - *out = ((*in) >> 15); - ++in; - *out |= ((*in) % (1U << 14)) << (31 - 14); - out++; - *out = ((*in) >> 14); - ++in; - *out |= ((*in) % (1U << 13)) << (31 - 13); - out++; - *out = ((*in) >> 13); - ++in; - *out |= ((*in) % (1U << 12)) << (31 - 12); - out++; - *out = ((*in) >> 12); - ++in; - *out |= ((*in) % (1U << 11)) << (31 - 11); - out++; - *out = ((*in) >> 11); - ++in; - *out |= ((*in) % (1U << 10)) << (31 - 10); - out++; - *out = ((*in) >> 10); - ++in; - *out |= ((*in) % (1U << 9)) << (31 - 9); - out++; - *out = ((*in) >> 9); - ++in; - *out |= ((*in) % (1U << 8)) << (31 - 8); - out++; - *out = ((*in) >> 8); - ++in; - *out |= ((*in) % (1U << 7)) << (31 - 7); - out++; - *out = ((*in) >> 7); - ++in; - *out |= ((*in) % (1U << 6)) << (31 - 6); - out++; - *out = ((*in) >> 6); - ++in; - *out |= ((*in) % (1U << 5)) << (31 - 5); - out++; - *out = ((*in) >> 5); - ++in; - *out |= ((*in) % (1U << 4)) << (31 - 4); - out++; - *out = ((*in) >> 4); - ++in; - *out |= ((*in) % (1U << 3)) << (31 - 3); - out++; - *out = ((*in) >> 3); - ++in; - *out |= ((*in) % (1U << 2)) << (31 - 2); - out++; - *out = ((*in) >> 2); - ++in; - *out |= ((*in) % (1U << 1)) << (31 - 1); - out++; - *out = ((*in) >> 1); - ++in; - out++; - - return in; -} - -inline const uint32_t* unpack32_32(const uint32_t* in, uint32_t* out) { - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - *out = ((*in) >> 0); - ++in; - out++; - - return in; -} - -inline const uint32_t* nullunpacker32(const uint32_t* in, uint32_t* out) { - for (int k = 0; k < 32; ++k) { - out[k] = 0; - } - return in; -} - -inline int unpack32(const uint32_t* in, uint32_t* out, int batch_size, int num_bits) { - batch_size = batch_size / 32 * 32; - int num_loops = batch_size / 32; - - switch (num_bits) { - case 0: - for (int i = 0; i < num_loops; ++i) in = nullunpacker32(in, out + i * 32); - break; - case 1: - for (int i = 0; i < num_loops; ++i) in = unpack1_32(in, out + i * 32); - break; - case 2: - for (int i = 0; i < num_loops; ++i) in = unpack2_32(in, out + i * 32); - break; - case 3: - for (int i = 0; i < num_loops; ++i) in = unpack3_32(in, out + i * 32); - break; - case 4: - for (int i = 0; i < num_loops; ++i) in = unpack4_32(in, out + i * 32); - break; - case 5: - for (int i = 0; i < num_loops; ++i) in = unpack5_32(in, out + i * 32); - break; - case 6: - for (int i = 0; i < num_loops; ++i) in = unpack6_32(in, out + i * 32); - break; - case 7: - for (int i = 0; i < num_loops; ++i) in = unpack7_32(in, out + i * 32); - break; - case 8: - for (int i = 0; i < num_loops; ++i) in = unpack8_32(in, out + i * 32); - break; - case 9: - for (int i = 0; i < num_loops; ++i) in = unpack9_32(in, out + i * 32); - break; - case 10: - for (int i = 0; i < num_loops; ++i) in = unpack10_32(in, out + i * 32); - break; - case 11: - for (int i = 0; i < num_loops; ++i) in = unpack11_32(in, out + i * 32); - break; - case 12: - for (int i = 0; i < num_loops; ++i) in = unpack12_32(in, out + i * 32); - break; - case 13: - for (int i = 0; i < num_loops; ++i) in = unpack13_32(in, out + i * 32); - break; - case 14: - for (int i = 0; i < num_loops; ++i) in = unpack14_32(in, out + i * 32); - break; - case 15: - for (int i = 0; i < num_loops; ++i) in = unpack15_32(in, out + i * 32); - break; - case 16: - for (int i = 0; i < num_loops; ++i) in = unpack16_32(in, out + i * 32); - break; - case 17: - for (int i = 0; i < num_loops; ++i) in = unpack17_32(in, out + i * 32); - break; - case 18: - for (int i = 0; i < num_loops; ++i) in = unpack18_32(in, out + i * 32); - break; - case 19: - for (int i = 0; i < num_loops; ++i) in = unpack19_32(in, out + i * 32); - break; - case 20: - for (int i = 0; i < num_loops; ++i) in = unpack20_32(in, out + i * 32); - break; - case 21: - for (int i = 0; i < num_loops; ++i) in = unpack21_32(in, out + i * 32); - break; - case 22: - for (int i = 0; i < num_loops; ++i) in = unpack22_32(in, out + i * 32); - break; - case 23: - for (int i = 0; i < num_loops; ++i) in = unpack23_32(in, out + i * 32); - break; - case 24: - for (int i = 0; i < num_loops; ++i) in = unpack24_32(in, out + i * 32); - break; - case 25: - for (int i = 0; i < num_loops; ++i) in = unpack25_32(in, out + i * 32); - break; - case 26: - for (int i = 0; i < num_loops; ++i) in = unpack26_32(in, out + i * 32); - break; - case 27: - for (int i = 0; i < num_loops; ++i) in = unpack27_32(in, out + i * 32); - break; - case 28: - for (int i = 0; i < num_loops; ++i) in = unpack28_32(in, out + i * 32); - break; - case 29: - for (int i = 0; i < num_loops; ++i) in = unpack29_32(in, out + i * 32); - break; - case 30: - for (int i = 0; i < num_loops; ++i) in = unpack30_32(in, out + i * 32); - break; - case 31: - for (int i = 0; i < num_loops; ++i) in = unpack31_32(in, out + i * 32); - break; - case 32: - for (int i = 0; i < num_loops; ++i) in = unpack32_32(in, out + i * 32); - break; - default: - DCHECK(false) << "Unsupported num_bits"; - } - - return batch_size; -} - -} // namespace internal -} // namespace arrow - -#endif // ARROW_UTIL_BPACKING_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/checked_cast.h b/cpp/thirdparty/knowhere_build/include/arrow/util/checked_cast.h deleted file mode 100644 index d75a6a360e..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/checked_cast.h +++ /dev/null @@ -1,63 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_CAST_H -#define ARROW_CAST_H - -#include -#include - -namespace arrow { -namespace internal { - -template -inline OutputType checked_cast(InputType&& value) { - static_assert(std::is_class::type>::type>::value, - "checked_cast input type must be a class"); - static_assert(std::is_class::type>::type>::value, - "checked_cast output type must be a class"); -#ifdef NDEBUG - return static_cast(value); -#else - return dynamic_cast(value); -#endif -} - -template -std::shared_ptr checked_pointer_cast(const std::shared_ptr& r) noexcept { -#ifndef NDEBUG - return std::static_pointer_cast(r); -#else - return std::dynamic_pointer_cast(r); -#endif -} - -template -std::unique_ptr checked_pointer_cast(std::unique_ptr r) noexcept { -#ifndef NDEBUG - return std::unique_ptr(static_cast(r.release())); -#else - return std::unique_ptr(dynamic_cast(r.release())); -#endif -} - -} // namespace internal -} // namespace arrow - -#endif // ARROW_CAST_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/compiler-util.h b/cpp/thirdparty/knowhere_build/include/arrow/util/compiler-util.h deleted file mode 100644 index 820a9b0c11..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/compiler-util.h +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// Deprecated header, here for backwards compatibility in parquet-cpp - -#ifndef ARROW_UTIL_COMPILER_UTIL_H -#define ARROW_UTIL_COMPILER_UTIL_H - -#include "arrow/util/macros.h" - -#endif // ARROW_UTIL_COMPILER_UTIL_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/compression.h b/cpp/thirdparty/knowhere_build/include/arrow/util/compression.h deleted file mode 100644 index 43174f4dba..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/compression.h +++ /dev/null @@ -1,153 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_UTIL_COMPRESSION_H -#define ARROW_UTIL_COMPRESSION_H - -#include -#include - -#include "arrow/util/visibility.h" - -namespace arrow { - -class Status; - -struct Compression { - enum type { UNCOMPRESSED, SNAPPY, GZIP, BROTLI, ZSTD, LZ4, LZO, BZ2 }; -}; - -namespace util { - -/// \brief Streaming compressor interface -/// -class ARROW_EXPORT Compressor { - public: - virtual ~Compressor(); - - /// \brief Compress some input. - /// - /// If bytes_read is 0 on return, then a larger output buffer should be supplied. - virtual Status Compress(int64_t input_len, const uint8_t* input, int64_t output_len, - uint8_t* output, int64_t* bytes_read, - int64_t* bytes_written) = 0; - - /// \brief Flush part of the compressed output. - /// - /// If should_retry is true on return, Flush() should be called again - /// with a larger buffer. - virtual Status Flush(int64_t output_len, uint8_t* output, int64_t* bytes_written, - bool* should_retry) = 0; - - /// \brief End compressing, doing whatever is necessary to end the stream. - /// - /// If should_retry is true on return, End() should be called again - /// with a larger buffer. Otherwise, the Compressor should not be used anymore. - /// - /// End() implies Flush(). - virtual Status End(int64_t output_len, uint8_t* output, int64_t* bytes_written, - bool* should_retry) = 0; - - // XXX add methods for buffer size heuristics? -}; - -/// \brief Streaming decompressor interface -/// -class ARROW_EXPORT Decompressor { - public: - virtual ~Decompressor(); - - /// \brief Decompress some input. - /// - /// If need_more_output is true on return, a larger output buffer needs - /// to be supplied. - /// XXX is need_more_output necessary? (Brotli?) - virtual Status Decompress(int64_t input_len, const uint8_t* input, int64_t output_len, - uint8_t* output, int64_t* bytes_read, int64_t* bytes_written, - bool* need_more_output) = 0; - - /// \brief Return whether the compressed stream is finished. - /// - /// This is a heuristic. If true is returned, then it is guaranteed - /// that the stream is finished. If false is returned, however, it may - /// simply be that the underlying library isn't able to provide the information. - virtual bool IsFinished() = 0; - - // XXX add methods for buffer size heuristics? -}; - -class ARROW_EXPORT Codec { - public: - virtual ~Codec(); - - static Status Create(Compression::type codec, std::unique_ptr* out); - - /// \brief One-shot decompression function - /// - /// output_buffer_len must be correct and therefore be obtained in advance. - /// - /// \note One-shot decompression is not always compatible with streaming - /// compression. Depending on the codec (e.g. LZ4), different formats may - /// be used. - virtual Status Decompress(int64_t input_len, const uint8_t* input, - int64_t output_buffer_len, uint8_t* output_buffer) = 0; - - /// \brief One-shot decompression function that also returns the - /// actual decompressed size. - /// - /// \param[in] input_len the number of bytes of compressed data. - /// \param[in] input the compressed data. - /// \param[in] output_buffer_len the number of bytes of buffer for - /// decompressed data. - /// \param[in] output_buffer the buffer for decompressed data. - /// \param[out] output_len the actual decompressed size. - /// - /// \note One-shot decompression is not always compatible with streaming - /// compression. Depending on the codec (e.g. LZ4), different formats may - /// be used. - virtual Status Decompress(int64_t input_len, const uint8_t* input, - int64_t output_buffer_len, uint8_t* output_buffer, - int64_t* output_len) = 0; - - /// \brief One-shot compression function - /// - /// output_buffer_len must first have been computed using MaxCompressedLen(). - /// - /// \note One-shot compression is not always compatible with streaming - /// decompression. Depending on the codec (e.g. LZ4), different formats may - /// be used. - virtual Status Compress(int64_t input_len, const uint8_t* input, - int64_t output_buffer_len, uint8_t* output_buffer, - int64_t* output_len) = 0; - - virtual int64_t MaxCompressedLen(int64_t input_len, const uint8_t* input) = 0; - - // XXX Should be able to choose compression level, or presets? ("fast", etc.) - - /// \brief Create a streaming compressor instance - virtual Status MakeCompressor(std::shared_ptr* out) = 0; - - /// \brief Create a streaming decompressor instance - virtual Status MakeDecompressor(std::shared_ptr* out) = 0; - - virtual const char* name() const = 0; -}; - -} // namespace util -} // namespace arrow - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/compression_brotli.h b/cpp/thirdparty/knowhere_build/include/arrow/util/compression_brotli.h deleted file mode 100644 index 59f97cda6b..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/compression_brotli.h +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_UTIL_COMPRESSION_BROTLI_H -#define ARROW_UTIL_COMPRESSION_BROTLI_H - -#include -#include - -#include "arrow/status.h" -#include "arrow/util/compression.h" -#include "arrow/util/visibility.h" - -namespace arrow { -namespace util { - -// Brotli codec. -class ARROW_EXPORT BrotliCodec : public Codec { - public: - Status Decompress(int64_t input_len, const uint8_t* input, int64_t output_buffer_len, - uint8_t* output_buffer) override; - - Status Decompress(int64_t input_len, const uint8_t* input, int64_t output_buffer_len, - uint8_t* output_buffer, int64_t* output_len) override; - - Status Compress(int64_t input_len, const uint8_t* input, int64_t output_buffer_len, - uint8_t* output_buffer, int64_t* output_len) override; - - int64_t MaxCompressedLen(int64_t input_len, const uint8_t* input) override; - - Status MakeCompressor(std::shared_ptr* out) override; - - Status MakeDecompressor(std::shared_ptr* out) override; - - const char* name() const override { return "brotli"; } -}; - -} // namespace util -} // namespace arrow - -#endif // ARROW_UTIL_COMPRESSION_BROTLI_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/compression_bz2.h b/cpp/thirdparty/knowhere_build/include/arrow/util/compression_bz2.h deleted file mode 100644 index 2146158825..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/compression_bz2.h +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_UTIL_COMPRESSION_BZ2_H -#define ARROW_UTIL_COMPRESSION_BZ2_H - -#include -#include - -#include "arrow/status.h" -#include "arrow/util/compression.h" -#include "arrow/util/visibility.h" - -namespace arrow { -namespace util { - -// BZ2 codec. -class ARROW_EXPORT BZ2Codec : public Codec { - public: - Status Decompress(int64_t input_len, const uint8_t* input, int64_t output_buffer_len, - uint8_t* output_buffer) override; - - Status Decompress(int64_t input_len, const uint8_t* input, int64_t output_buffer_len, - uint8_t* output_buffer, int64_t* output_len) override; - - Status Compress(int64_t input_len, const uint8_t* input, int64_t output_buffer_len, - uint8_t* output_buffer, int64_t* output_len) override; - - int64_t MaxCompressedLen(int64_t input_len, const uint8_t* input) override; - - Status MakeCompressor(std::shared_ptr* out) override; - - Status MakeDecompressor(std::shared_ptr* out) override; - - const char* name() const override { return "bz2"; } -}; - -} // namespace util -} // namespace arrow - -#endif // ARROW_UTIL_COMPRESSION_BZ2_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/compression_lz4.h b/cpp/thirdparty/knowhere_build/include/arrow/util/compression_lz4.h deleted file mode 100644 index 4d06f03c2c..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/compression_lz4.h +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_UTIL_COMPRESSION_LZ4_H -#define ARROW_UTIL_COMPRESSION_LZ4_H - -#include -#include - -#include "arrow/status.h" -#include "arrow/util/compression.h" -#include "arrow/util/visibility.h" - -namespace arrow { -namespace util { - -// Lz4 codec. -class ARROW_EXPORT Lz4Codec : public Codec { - public: - Status Decompress(int64_t input_len, const uint8_t* input, int64_t output_buffer_len, - uint8_t* output_buffer) override; - - Status Decompress(int64_t input_len, const uint8_t* input, int64_t output_buffer_len, - uint8_t* output_buffer, int64_t* output_len) override; - - Status Compress(int64_t input_len, const uint8_t* input, int64_t output_buffer_len, - uint8_t* output_buffer, int64_t* output_len) override; - - int64_t MaxCompressedLen(int64_t input_len, const uint8_t* input) override; - - Status MakeCompressor(std::shared_ptr* out) override; - - Status MakeDecompressor(std::shared_ptr* out) override; - - const char* name() const override { return "lz4"; } -}; - -} // namespace util -} // namespace arrow - -#endif // ARROW_UTIL_COMPRESSION_LZ4_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/compression_snappy.h b/cpp/thirdparty/knowhere_build/include/arrow/util/compression_snappy.h deleted file mode 100644 index 7029400ab2..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/compression_snappy.h +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_UTIL_COMPRESSION_SNAPPY_H -#define ARROW_UTIL_COMPRESSION_SNAPPY_H - -#include -#include - -#include "arrow/status.h" -#include "arrow/util/compression.h" -#include "arrow/util/visibility.h" - -namespace arrow { -namespace util { - -class ARROW_EXPORT SnappyCodec : public Codec { - public: - Status Decompress(int64_t input_len, const uint8_t* input, int64_t output_buffer_len, - uint8_t* output_buffer) override; - - Status Decompress(int64_t input_len, const uint8_t* input, int64_t output_buffer_len, - uint8_t* output_buffer, int64_t* output_len) override; - - Status Compress(int64_t input_len, const uint8_t* input, int64_t output_buffer_len, - uint8_t* output_buffer, int64_t* output_len) override; - - int64_t MaxCompressedLen(int64_t input_len, const uint8_t* input) override; - - Status MakeCompressor(std::shared_ptr* out) override; - - Status MakeDecompressor(std::shared_ptr* out) override; - - const char* name() const override { return "snappy"; } -}; - -} // namespace util -} // namespace arrow - -#endif // ARROW_UTIL_COMPRESSION_SNAPPY_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/compression_zlib.h b/cpp/thirdparty/knowhere_build/include/arrow/util/compression_zlib.h deleted file mode 100644 index 9a5feaa290..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/compression_zlib.h +++ /dev/null @@ -1,70 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_UTIL_COMPRESSION_ZLIB_H -#define ARROW_UTIL_COMPRESSION_ZLIB_H - -#include -#include - -#include "arrow/status.h" -#include "arrow/util/compression.h" -#include "arrow/util/visibility.h" - -namespace arrow { -namespace util { - -// GZip codec. -class ARROW_EXPORT GZipCodec : public Codec { - public: - /// Compression formats supported by the zlib library - enum Format { - ZLIB, - DEFLATE, - GZIP, - }; - - explicit GZipCodec(Format format = GZIP); - ~GZipCodec() override; - - Status Decompress(int64_t input_len, const uint8_t* input, int64_t output_buffer_len, - uint8_t* output_buffer) override; - - Status Decompress(int64_t input_len, const uint8_t* input, int64_t output_buffer_len, - uint8_t* output_buffer, int64_t* output_len) override; - - Status Compress(int64_t input_len, const uint8_t* input, int64_t output_buffer_len, - uint8_t* output_buffer, int64_t* output_len) override; - - int64_t MaxCompressedLen(int64_t input_len, const uint8_t* input) override; - - Status MakeCompressor(std::shared_ptr* out) override; - - Status MakeDecompressor(std::shared_ptr* out) override; - - const char* name() const override; - - private: - // The gzip compressor is stateful - class GZipCodecImpl; - std::unique_ptr impl_; -}; - -} // namespace util -} // namespace arrow - -#endif // ARROW_UTIL_COMPRESSION_ZLIB_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/compression_zstd.h b/cpp/thirdparty/knowhere_build/include/arrow/util/compression_zstd.h deleted file mode 100644 index 8b05d8c80a..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/compression_zstd.h +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_UTIL_COMPRESSION_ZSTD_H -#define ARROW_UTIL_COMPRESSION_ZSTD_H - -#include -#include - -#include "arrow/status.h" -#include "arrow/util/compression.h" -#include "arrow/util/visibility.h" - -namespace arrow { -namespace util { - -// ZSTD codec. -class ARROW_EXPORT ZSTDCodec : public Codec { - public: - Status Decompress(int64_t input_len, const uint8_t* input, int64_t output_buffer_len, - uint8_t* output_buffer) override; - - Status Decompress(int64_t input_len, const uint8_t* input, int64_t output_buffer_len, - uint8_t* output_buffer, int64_t* output_len) override; - - Status Compress(int64_t input_len, const uint8_t* input, int64_t output_buffer_len, - uint8_t* output_buffer, int64_t* output_len) override; - - int64_t MaxCompressedLen(int64_t input_len, const uint8_t* input) override; - - Status MakeCompressor(std::shared_ptr* out) override; - - Status MakeDecompressor(std::shared_ptr* out) override; - - const char* name() const override { return "zstd"; } -}; - -} // namespace util -} // namespace arrow - -#endif // ARROW_UTIL_COMPRESSION_ZSTD_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/config.h b/cpp/thirdparty/knowhere_build/include/arrow/util/config.h deleted file mode 100644 index 8c7ec98ddc..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/config.h +++ /dev/null @@ -1,24 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#define ARROW_VERSION_MAJOR 0 -#define ARROW_VERSION_MINOR 14 -#define ARROW_VERSION_PATCH 0 -#define ARROW_VERSION ((ARROW_VERSION_MAJOR * 1000) + ARROW_VERSION_MINOR) * 1000 + ARROW_VERSION_PATCH - -/* #undef DOUBLE_CONVERSION_HAS_CASE_INSENSIBILITY */ -/* #undef GRPCPP_PP_INCLUDE */ diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/cpu-info.h b/cpp/thirdparty/knowhere_build/include/arrow/util/cpu-info.h deleted file mode 100644 index 714d7ac5bc..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/cpu-info.h +++ /dev/null @@ -1,101 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// From Apache Impala (incubating) as of 2016-01-29. Pared down to a minimal -// set of functions needed for Apache Arrow / Apache parquet-cpp - -#ifndef ARROW_UTIL_CPU_INFO_H -#define ARROW_UTIL_CPU_INFO_H - -#include -#include - -#include "arrow/util/visibility.h" - -namespace arrow { -namespace internal { - -/// CpuInfo is an interface to query for cpu information at runtime. The caller can -/// ask for the sizes of the caches and what hardware features are supported. -/// On Linux, this information is pulled from a couple of sys files (/proc/cpuinfo and -/// /sys/devices) -class ARROW_EXPORT CpuInfo { - public: - static constexpr int64_t SSSE3 = (1 << 1); - static constexpr int64_t SSE4_1 = (1 << 2); - static constexpr int64_t SSE4_2 = (1 << 3); - static constexpr int64_t POPCNT = (1 << 4); - - /// Cache enums for L1 (data), L2 and L3 - enum CacheLevel { - L1_CACHE = 0, - L2_CACHE = 1, - L3_CACHE = 2, - }; - - static CpuInfo* GetInstance(); - - /// Determine if the CPU meets the minimum CPU requirements and if not, issue an error - /// and terminate. - void VerifyCpuRequirements(); - - /// Returns all the flags for this cpu - int64_t hardware_flags(); - - /// Returns whether of not the cpu supports this flag - bool IsSupported(int64_t flag) const { return (hardware_flags_ & flag) != 0; } - - /// \brief The processor supports SSE4.2 and the Arrow libraries are built - /// with support for it - bool CanUseSSE4_2() const; - - /// Toggle a hardware feature on and off. It is not valid to turn on a feature - /// that the underlying hardware cannot support. This is useful for testing. - void EnableFeature(int64_t flag, bool enable); - - /// Returns the size of the cache in KB at this cache level - int64_t CacheSize(CacheLevel level); - - /// Returns the number of cpu cycles per millisecond - int64_t cycles_per_ms(); - - /// Returns the number of cores (including hyper-threaded) on this machine. - int num_cores(); - - /// Returns the model name of the cpu (e.g. Intel i7-2600) - std::string model_name(); - - private: - CpuInfo(); - - void Init(); - - /// Inits CPU cache size variables with default values - void SetDefaultCacheSize(); - - int64_t hardware_flags_; - int64_t original_hardware_flags_; - int64_t cache_sizes_[L3_CACHE + 1]; - int64_t cycles_per_ms_; - int num_cores_; - std::string model_name_; -}; - -} // namespace internal -} // namespace arrow - -#endif // ARROW_UTIL_CPU_INFO_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/decimal.h b/cpp/thirdparty/knowhere_build/include/arrow/util/decimal.h deleted file mode 100644 index 3a576d085a..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/decimal.h +++ /dev/null @@ -1,133 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include -#include -#include -#include - -#include "arrow/status.h" -#include "arrow/util/basic_decimal.h" -#include "arrow/util/string_view.h" - -namespace arrow { - -/// Represents a signed 128-bit integer in two's complement. -/// Calculations wrap around and overflow is ignored. -/// -/// For a discussion of the algorithms, look at Knuth's volume 2, -/// Semi-numerical Algorithms section 4.3.1. -/// -/// Adapted from the Apache ORC C++ implementation -/// -/// The implementation is split into two parts : -/// -/// 1. BasicDecimal128 -/// - can be safely compiled to IR without references to libstdc++. -/// 2. Decimal128 -/// - has additional functionality on top of BasicDecimal128 to deal with -/// strings and streams. -class ARROW_EXPORT Decimal128 : public BasicDecimal128 { - public: - /// \cond FALSE - // (need to avoid a duplicate definition in Sphinx) - using BasicDecimal128::BasicDecimal128; - /// \endcond - - /// \brief constructor creates a Decimal128 from a BasicDecimal128. - constexpr Decimal128(const BasicDecimal128& value) noexcept : BasicDecimal128(value) {} - - /// \brief Parse the number from a base 10 string representation. - explicit Decimal128(const std::string& value); - - /// \brief Empty constructor creates a Decimal128 with a value of 0. - // This is required on some older compilers. - constexpr Decimal128() noexcept : BasicDecimal128() {} - - /// Divide this number by right and return the result. - /// - /// This operation is not destructive. - /// The answer rounds to zero. Signs work like: - /// 21 / 5 -> 4, 1 - /// -21 / 5 -> -4, -1 - /// 21 / -5 -> -4, 1 - /// -21 / -5 -> 4, -1 - /// \param[in] divisor the number to divide by - /// \param[out] result the quotient - /// \param[out] remainder the remainder after the division - Status Divide(const Decimal128& divisor, Decimal128* result, - Decimal128* remainder) const { - auto dstatus = BasicDecimal128::Divide(divisor, result, remainder); - return ToArrowStatus(dstatus); - } - - /// \brief Convert the Decimal128 value to a base 10 decimal string with the given - /// scale. - std::string ToString(int32_t scale) const; - - /// \brief Convert the value to an integer string - std::string ToIntegerString() const; - - /// \brief Cast this value to an int64_t. - explicit operator int64_t() const; - - /// \brief Convert a decimal string to a Decimal128 value, optionally including - /// precision and scale if they're passed in and not null. - static Status FromString(const util::string_view& s, Decimal128* out, - int32_t* precision = NULLPTR, int32_t* scale = NULLPTR); - static Status FromString(const std::string& s, Decimal128* out, - int32_t* precision = NULLPTR, int32_t* scale = NULLPTR); - static Status FromString(const char* s, Decimal128* out, int32_t* precision = NULLPTR, - int32_t* scale = NULLPTR); - - /// \brief Convert from a big-endian byte representation. The length must be - /// between 1 and 16. - /// \return error status if the length is an invalid value - static Status FromBigEndian(const uint8_t* data, int32_t length, Decimal128* out); - - /// \brief Convert Decimal128 from one scale to another - Status Rescale(int32_t original_scale, int32_t new_scale, Decimal128* out) const { - auto dstatus = BasicDecimal128::Rescale(original_scale, new_scale, out); - return ToArrowStatus(dstatus); - } - - /// \brief Convert to a signed integer - template > - Status ToInteger(T* out) const { - constexpr auto min_value = std::numeric_limits::min(); - constexpr auto max_value = std::numeric_limits::max(); - const auto& self = *this; - if (self < min_value || self > max_value) { - return Status::Invalid("Invalid cast from Decimal128 to ", sizeof(T), - " byte integer"); - } - *out = static_cast(low_bits()); - return Status::OK(); - } - - friend ARROW_EXPORT std::ostream& operator<<(std::ostream& os, - const Decimal128& decimal); - - private: - /// Converts internal error code to Status - Status ToArrowStatus(DecimalStatus dstatus) const; -}; - -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/hash-util.h b/cpp/thirdparty/knowhere_build/include/arrow/util/hash-util.h deleted file mode 100644 index 7aed3c171d..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/hash-util.h +++ /dev/null @@ -1,310 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// From Apache Impala (incubating) as of 2016-02-22 - -#ifndef ARROW_UTIL_HASH_UTIL_H -#define ARROW_UTIL_HASH_UTIL_H - -#include -#include - -#include "arrow/util/logging.h" -#include "arrow/util/macros.h" -#include "arrow/util/neon-util.h" -#include "arrow/util/sse-util.h" - -static inline uint32_t HW_crc32_u8(uint32_t crc, uint8_t v) { - DCHECK(false) << "Hardware CRC support is not enabled"; - return 0; -} - -static inline uint32_t HW_crc32_u16(uint32_t crc, uint16_t v) { - DCHECK(false) << "Hardware CRC support is not enabled"; - return 0; -} - -static inline uint32_t HW_crc32_u32(uint32_t crc, uint32_t v) { - DCHECK(false) << "Hardware CRC support is not enabled"; - return 0; -} - -static inline uint32_t HW_crc32_u64(uint32_t crc, uint64_t v) { - DCHECK(false) << "Hardware CRC support is not enabled"; - return 0; -} - -#ifdef ARROW_HAVE_SSE4_2 -#define HW_crc32_u8 SSE4_crc32_u8 -#define HW_crc32_u16 SSE4_crc32_u16 -#define HW_crc32_u32 SSE4_crc32_u32 -#define HW_crc32_u64 SSE4_crc32_u64 -#elif defined(ARROW_HAVE_ARM_CRC) -#define HW_crc32_u8 ARMCE_crc32_u8 -#define HW_crc32_u16 ARMCE_crc32_u16 -#define HW_crc32_u32 ARMCE_crc32_u32 -#define HW_crc32_u64 ARMCE_crc32_u64 -#endif - -namespace arrow { - -/// Utility class to compute hash values. -class HashUtil { - public: -#if defined(ARROW_HAVE_SSE4_2) || defined(ARROW_HAVE_ARM_CRC) - static constexpr bool have_hardware_crc32 = true; -#else - static constexpr bool have_hardware_crc32 = false; -#endif - - /// Compute the Crc32 hash for data using SSE4/ArmCRC instructions. The input hash - /// parameter is the current hash/seed value. - /// This should only be called if SSE/ArmCRC is supported. - /// This is ~4x faster than Fnv/Boost Hash. - /// TODO: crc32 hashes with different seeds do not result in different hash functions. - /// The resulting hashes are correlated. - static uint32_t CrcHash(const void* data, int32_t nbytes, uint32_t hash) { - const uint8_t* p = reinterpret_cast(data); - const uint8_t* end = p + nbytes; - -#if ARROW_BITNESS >= 64 - while (p <= end - 8) { - hash = HW_crc32_u64(hash, *reinterpret_cast(p)); - p += 8; - } -#endif - - while (p <= end - 4) { - hash = HW_crc32_u32(hash, *reinterpret_cast(p)); - p += 4; - } - while (p < end) { - hash = HW_crc32_u8(hash, *p); - ++p; - } - - // The lower half of the CRC hash has has poor uniformity, so swap the halves - // for anyone who only uses the first several bits of the hash. - hash = (hash << 16) | (hash >> 16); - return hash; - } - - /// A variant of CRC32 hashing that computes two independent running CRCs - /// over interleaved halves of the input, giving out a 64-bit integer. - /// The result's quality should be improved by a finalization step. - /// - /// In addition to producing more bits of output, this should be twice - /// faster than CrcHash on CPUs that can overlap several independent - /// CRC computations. - static uint64_t DoubleCrcHash(const void* data, int32_t nbytes, uint64_t hash) { - const uint8_t* p = reinterpret_cast(data); - - uint32_t h1 = static_cast(hash >> 32); - uint32_t h2 = static_cast(hash); - -#if ARROW_BITNESS >= 64 - while (nbytes >= 16) { - h1 = HW_crc32_u64(h1, *reinterpret_cast(p)); - h2 = HW_crc32_u64(h2, *reinterpret_cast(p + 8)); - nbytes -= 16; - p += 16; - } - if (nbytes >= 8) { - h1 = HW_crc32_u32(h1, *reinterpret_cast(p)); - h2 = HW_crc32_u32(h2, *reinterpret_cast(p + 4)); - nbytes -= 8; - p += 8; - } -#else - while (nbytes >= 8) { - h1 = HW_crc32_u32(h1, *reinterpret_cast(p)); - h2 = HW_crc32_u32(h2, *reinterpret_cast(p + 4)); - nbytes -= 8; - p += 8; - } -#endif - - if (nbytes >= 4) { - h1 = HW_crc32_u16(h1, *reinterpret_cast(p)); - h2 = HW_crc32_u16(h2, *reinterpret_cast(p + 2)); - nbytes -= 4; - p += 4; - } - switch (nbytes) { - case 3: - h1 = HW_crc32_u8(h1, p[2]); - // fallthrough - case 2: - h2 = HW_crc32_u8(h2, p[1]); - // fallthrough - case 1: - h1 = HW_crc32_u8(h1, p[0]); - // fallthrough - case 0: - break; - default: - assert(0); - } - - // A finalization step is recommended to mix up the result's bits - return (static_cast(h1) << 32) + h2; - } - - static const uint64_t MURMUR_PRIME = 0xc6a4a7935bd1e995; - static const int MURMUR_R = 47; - - /// Murmur2 hash implementation returning 64-bit hashes. - static uint64_t MurmurHash2_64(const void* input, int len, uint64_t seed) { - uint64_t h = seed ^ (len * MURMUR_PRIME); - - const uint64_t* data = reinterpret_cast(input); - const uint64_t* end = data + (len / sizeof(uint64_t)); - - while (data != end) { - uint64_t k = *data++; - k *= MURMUR_PRIME; - k ^= k >> MURMUR_R; - k *= MURMUR_PRIME; - h ^= k; - h *= MURMUR_PRIME; - } - - const uint8_t* data2 = reinterpret_cast(data); - switch (len & 7) { - case 7: - h ^= uint64_t(data2[6]) << 48; - case 6: - h ^= uint64_t(data2[5]) << 40; - case 5: - h ^= uint64_t(data2[4]) << 32; - case 4: - h ^= uint64_t(data2[3]) << 24; - case 3: - h ^= uint64_t(data2[2]) << 16; - case 2: - h ^= uint64_t(data2[1]) << 8; - case 1: - h ^= uint64_t(data2[0]); - h *= MURMUR_PRIME; - } - - h ^= h >> MURMUR_R; - h *= MURMUR_PRIME; - h ^= h >> MURMUR_R; - return h; - } - - /// default values recommended by http://isthe.com/chongo/tech/comp/fnv/ - static const uint32_t FNV_PRIME = 0x01000193; // 16777619 - static const uint32_t FNV_SEED = 0x811C9DC5; // 2166136261 - static const uint64_t FNV64_PRIME = 1099511628211UL; - static const uint64_t FNV64_SEED = 14695981039346656037UL; - - /// Implementation of the Fowler-Noll-Vo hash function. This is not as performant - /// as boost's hash on int types (2x slower) but has bit entropy. - /// For ints, boost just returns the value of the int which can be pathological. - /// For example, if the data is <1000, 2000, 3000, 4000, ..> and then the mod of 1000 - /// is taken on the hash, all values will collide to the same bucket. - /// For string values, Fnv is slightly faster than boost. - /// IMPORTANT: FNV hash suffers from poor diffusion of the least significant bit, - /// which can lead to poor results when input bytes are duplicated. - /// See FnvHash64to32() for how this can be mitigated. - static uint64_t FnvHash64(const void* data, int32_t bytes, uint64_t hash) { - const uint8_t* ptr = reinterpret_cast(data); - while (bytes--) { - hash = (*ptr ^ hash) * FNV64_PRIME; - ++ptr; - } - return hash; - } - - /// Return a 32-bit hash computed by invoking FNV-64 and folding the result to 32-bits. - /// This technique is recommended instead of FNV-32 since the LSB of an FNV hash is the - /// XOR of the LSBs of its input bytes, leading to poor results for duplicate inputs. - /// The input seed 'hash' is duplicated so the top half of the seed is not all zero. - /// Data length must be at least 1 byte: zero-length data should be handled separately, - /// for example using CombineHash with a unique constant value to avoid returning the - /// hash argument. Zero-length data gives terrible results: the initial hash value is - /// xored with itself cancelling all bits. - static uint32_t FnvHash64to32(const void* data, int32_t bytes, uint32_t hash) { - // IMPALA-2270: this function should never be used for zero-byte inputs. - DCHECK_GT(bytes, 0); - uint64_t hash_u64 = hash | (static_cast(hash) << 32); - hash_u64 = FnvHash64(data, bytes, hash_u64); - return static_cast((hash_u64 >> 32) ^ (hash_u64 & 0xFFFFFFFF)); - } - - // Hash template - template - static inline int Hash(const void* data, int32_t bytes, uint32_t seed); - - /// The magic number (used in hash_combine()) 0x9e3779b9 = 2^32 / (golden ratio). - static const uint32_t HASH_COMBINE_SEED = 0x9e3779b9; - - /// Combine hashes 'value' and 'seed' to get a new hash value. Similar to - /// boost::hash_combine(), but for uint32_t. This function should be used with a - /// constant first argument to update the hash value for zero-length values such as - /// NULL, boolean, and empty strings. - static inline uint32_t HashCombine32(uint32_t value, uint32_t seed) { - return seed ^ (HASH_COMBINE_SEED + value + (seed << 6) + (seed >> 2)); - } - - // Get 32 more bits of randomness from a 32-bit hash: - static inline uint32_t Rehash32to32(const uint32_t hash) { - // Constants generated by uuidgen(1) with the -r flag - static const uint64_t m = 0x7850f11ec6d14889ull, a = 0x6773610597ca4c63ull; - // This is strongly universal hashing following Dietzfelbinger's "Universal hashing - // and k-wise independent random variables via integer arithmetic without primes". As - // such, for any two distinct uint32_t's hash1 and hash2, the probability (over the - // randomness of the constants) that any subset of bit positions of - // Rehash32to32(hash1) is equal to the same subset of bit positions - // Rehash32to32(hash2) is minimal. - return static_cast((static_cast(hash) * m + a) >> 32); - } - - static inline uint64_t Rehash32to64(const uint32_t hash) { - static const uint64_t m1 = 0x47b6137a44974d91ull, m2 = 0x8824ad5ba2b7289cull, - a1 = 0x705495c62df1424aull, a2 = 0x9efc49475c6bfb31ull; - const uint64_t hash1 = (static_cast(hash) * m1 + a1) >> 32; - const uint64_t hash2 = (static_cast(hash) * m2 + a2) >> 32; - return hash1 | (hash2 << 32); - } -}; - -// HW Hash -template <> -inline int HashUtil::Hash(const void* data, int32_t bytes, uint32_t seed) { -#ifdef ARROW_HAVE_ARM_CRC - // Need run time check for Arm - // if not support, fall back to Murmur - if (!crc32c_runtime_check()) - return static_cast(HashUtil::MurmurHash2_64(data, bytes, seed)); - else -#endif - // Double CRC - return static_cast(HashUtil::DoubleCrcHash(data, bytes, seed)); -} - -// Murmur Hash -template <> -inline int HashUtil::Hash(const void* data, int32_t bytes, uint32_t seed) { - return static_cast(HashUtil::MurmurHash2_64(data, bytes, seed)); -} - -} // namespace arrow - -#endif // ARROW_UTIL_HASH_UTIL_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/hashing.h b/cpp/thirdparty/knowhere_build/include/arrow/util/hashing.h deleted file mode 100644 index 49641d81c0..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/hashing.h +++ /dev/null @@ -1,963 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// Private header, not to be exported - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "arrow/array.h" -#include "arrow/buffer.h" -#include "arrow/builder.h" -#include "arrow/type.h" -#include "arrow/type_traits.h" -#include "arrow/util/bit-util.h" -#include "arrow/util/checked_cast.h" -#include "arrow/util/hash-util.h" -#include "arrow/util/macros.h" -#include "arrow/util/string_view.h" - -namespace arrow { -namespace internal { - -// XXX would it help to have a 32-bit hash value on large datasets? -typedef uint64_t hash_t; - -// Notes about the choice of a hash function. -// - xxHash64 is extremely fast on large enough data -// - for small- to medium-sized data, there are better choices -// (see comprehensive benchmarks results at -// https://aras-p.info/blog/2016/08/09/More-Hash-Function-Tests/) -// - for very small fixed-size data (<= 16 bytes, e.g. Decimal128), it is -// beneficial to define specialized hash functions -// - while xxHash and others have good statistical properties, we can relax those -// a bit if it helps performance (especially if the hash table implementation -// has a good collision resolution strategy) - -template -inline hash_t ComputeStringHash(const void* data, int64_t length); - -template -struct ScalarHelperBase { - static bool CompareScalars(Scalar u, Scalar v) { return u == v; } - - static hash_t ComputeHash(const Scalar& value) { - // Generic hash computation for scalars. Simply apply the string hash - // to the bit representation of the value. - - // XXX in the case of FP values, we'd like equal values to have the same hash, - // even if they have different bit representations... - return ComputeStringHash(&value, sizeof(value)); - } -}; - -template -struct ScalarHelper : public ScalarHelperBase {}; - -template -struct ScalarHelper::value>::type> - : public ScalarHelperBase { - // ScalarHelper specialization for integers - - static hash_t ComputeHash(const Scalar& value) { - // Faster hash computation for integers. - - // Two of xxhash's prime multipliers (which are chosen for their - // bit dispersion properties) - static constexpr uint64_t multipliers[] = {11400714785074694791ULL, - 14029467366897019727ULL}; - - // Multiplying by the prime number mixes the low bits into the high bits, - // then byte-swapping (which is a single CPU instruction) allows the - // combined high and low bits to participate in the initial hash table index. - auto h = static_cast(value); - return BitUtil::ByteSwap(multipliers[AlgNum] * h); - } -}; - -template -struct ScalarHelper< - Scalar, AlgNum, - typename std::enable_if::value>::type> - : public ScalarHelperBase { - // ScalarHelper specialization for util::string_view - - static hash_t ComputeHash(const util::string_view& value) { - return ComputeStringHash(value.data(), static_cast(value.size())); - } -}; - -template -struct ScalarHelper::value>::type> - : public ScalarHelperBase { - // ScalarHelper specialization for reals - - static bool CompareScalars(Scalar u, Scalar v) { - if (std::isnan(u)) { - // XXX should we do a bit-precise comparison? - return std::isnan(v); - } - return u == v; - } -}; - -template -hash_t ComputeStringHash(const void* data, int64_t length) { - if (ARROW_PREDICT_TRUE(length <= 16)) { - // Specialize for small hash strings, as they are quite common as - // hash table keys. - auto p = reinterpret_cast(data); - auto n = static_cast(length); - if (n <= 8) { - if (n <= 3) { - if (n == 0) { - return 1U; - } - uint32_t x = (n << 24) ^ (p[0] << 16) ^ (p[n / 2] << 8) ^ p[n - 1]; - return ScalarHelper::ComputeHash(x); - } - // 4 <= length <= 8 - // We can read the string as two overlapping 32-bit ints, apply - // different hash functions to each of them in parallel, then XOR - // the results - uint32_t x, y; - hash_t hx, hy; - // XXX those are unaligned accesses. Should we have a facility for that? - x = *reinterpret_cast(p + n - 4); - y = *reinterpret_cast(p); - hx = ScalarHelper::ComputeHash(x); - hy = ScalarHelper::ComputeHash(y); - return n ^ hx ^ hy; - } - // 8 <= length <= 16 - // Apply the same principle as above - uint64_t x, y; - hash_t hx, hy; - x = *reinterpret_cast(p + n - 8); - y = *reinterpret_cast(p); - hx = ScalarHelper::ComputeHash(x); - hy = ScalarHelper::ComputeHash(y); - return n ^ hx ^ hy; - } - - if (HashUtil::have_hardware_crc32) { - // DoubleCrcHash is faster that Murmur2. - auto h = HashUtil::DoubleCrcHash(data, static_cast(length), AlgNum); - return ScalarHelper::ComputeHash(h); - } else { - // Fall back on 64-bit Murmur2 for longer strings. - // It has decent speed for medium-sized strings. There may be faster - // hashes on long strings such as xxHash, but that may not matter much - // for the typical length distribution of hash keys. - return HashUtil::MurmurHash2_64(data, static_cast(length), AlgNum); - } -} - -// XXX add a HashEq struct with both hash and compare functions? - -// ---------------------------------------------------------------------- -// An open-addressing insert-only hash table (no deletes) - -template -class HashTable { - public: - static constexpr hash_t kSentinel = 0ULL; - - struct Entry { - hash_t h; - Payload payload; - - // An entry is valid if the hash is different from the sentinel value - operator bool() const { return h != kSentinel; } - }; - - explicit HashTable(uint64_t capacity) { - // Presize for at least 8 elements - capacity = std::max(capacity, static_cast(8U)); - size_ = BitUtil::NextPower2(capacity * 4U); - size_mask_ = size_ - 1; - n_filled_ = 0; - // This will zero out hash entries, marking them empty - entries_.resize(size_); - } - - // Lookup with non-linear probing - // cmp_func should have signature bool(const Payload*). - // Return a (Entry*, found) pair. - template - std::pair Lookup(hash_t h, CmpFunc&& cmp_func) { - auto p = Lookup(h, entries_.data(), size_mask_, - std::forward(cmp_func)); - return {&entries_[p.first], p.second}; - } - - template - std::pair Lookup(hash_t h, CmpFunc&& cmp_func) const { - auto p = Lookup(h, entries_.data(), size_mask_, - std::forward(cmp_func)); - return {&entries_[p.first], p.second}; - } - - void Insert(Entry* entry, hash_t h, const Payload& payload) { - // Ensure entry is empty before inserting - assert(!*entry); - entry->h = FixHash(h); - entry->payload = payload; - ++n_filled_; - if (NeedUpsizing()) { - // Resizing is expensive, avoid doing it too often - Upsize(size_ * 4); - } - } - - uint64_t size() const { return n_filled_; } - - // Visit all non-empty entries in the table - // The visit_func should have signature void(const Entry*) - template - void VisitEntries(VisitFunc&& visit_func) const { - for (const auto& entry : entries_) { - if (entry) { - visit_func(&entry); - } - } - } - - protected: - // NoCompare is for when the value is known not to exist in the table - enum CompareKind { DoCompare, NoCompare }; - - // The workhorse lookup function - template - std::pair Lookup(hash_t h, const Entry* entries, uint64_t size_mask, - CmpFunc&& cmp_func) const { - static constexpr uint8_t perturb_shift = 5; - - uint64_t index, perturb; - const Entry* entry; - - h = FixHash(h); - index = h & size_mask; - perturb = (h >> perturb_shift) + 1U; - - while (true) { - entry = &entries[index]; - if (CompareEntry(h, entry, std::forward(cmp_func))) { - // Found - return {index, true}; - } - if (entry->h == 0U) { - // Empty slot - return {index, false}; - } - - // Perturbation logic inspired from CPython's set / dict object. - // The goal is that all 64 bits of the unmasked hash value eventually - // participate in the probing sequence, to minimize clustering. - index = (index + perturb) & size_mask; - perturb = (perturb >> perturb_shift) + 1U; - } - } - - template - bool CompareEntry(hash_t h, const Entry* entry, CmpFunc&& cmp_func) const { - if (CKind == NoCompare) { - return false; - } else { - return entry->h == h && cmp_func(&entry->payload); - } - } - - bool NeedUpsizing() const { - // Keep the load factor <= 1/2 - return n_filled_ * 2U >= size_; - } - - void Upsize(uint64_t new_size) { - assert(new_size > size_); - uint64_t new_mask = new_size - 1; - assert((new_size & new_mask) == 0); // it's a power of two - - std::vector new_entries(new_size); - for (auto& entry : entries_) { - if (entry) { - // Dummy compare function (will not be called) - auto cmp_func = [](const Payload*) { return false; }; - // Non-empty slot, move into new - auto p = Lookup(entry.h, new_entries.data(), new_mask, cmp_func); - assert(!p.second); // shouldn't have found a matching entry - new_entries[p.first] = entry; - } - } - std::swap(entries_, new_entries); - size_ = new_size; - size_mask_ = new_mask; - } - - hash_t FixHash(hash_t h) const { return (h == kSentinel) ? 42U : h; } - - uint64_t size_; - uint64_t size_mask_; - uint64_t n_filled_; - std::vector entries_; -}; - -// XXX typedef memo_index_t int32_t ? - -constexpr int32_t kKeyNotFound = -1; - -// ---------------------------------------------------------------------- -// A base class for memoization table. - -class MemoTable { - public: - virtual ~MemoTable() = default; - - virtual int32_t size() const = 0; -}; - -// ---------------------------------------------------------------------- -// A memoization table for memory-cheap scalar values. - -// The memoization table remembers and allows to look up the insertion -// index for each key. - -template class HashTableTemplateType = HashTable> -class ScalarMemoTable : public MemoTable { - public: - explicit ScalarMemoTable(int64_t entries = 0) - : hash_table_(static_cast(entries)) {} - - int32_t Get(const Scalar& value) const { - auto cmp_func = [value](const Payload* payload) -> bool { - return ScalarHelper::CompareScalars(payload->value, value); - }; - hash_t h = ComputeHash(value); - auto p = hash_table_.Lookup(h, cmp_func); - if (p.second) { - return p.first->payload.memo_index; - } else { - return kKeyNotFound; - } - } - - template - int32_t GetOrInsert(const Scalar& value, Func1&& on_found, Func2&& on_not_found) { - auto cmp_func = [value](const Payload* payload) -> bool { - return ScalarHelper::CompareScalars(value, payload->value); - }; - hash_t h = ComputeHash(value); - auto p = hash_table_.Lookup(h, cmp_func); - int32_t memo_index; - if (p.second) { - memo_index = p.first->payload.memo_index; - on_found(memo_index); - } else { - memo_index = size(); - hash_table_.Insert(p.first, h, {value, memo_index}); - on_not_found(memo_index); - } - return memo_index; - } - - int32_t GetOrInsert(const Scalar& value) { - return GetOrInsert(value, [](int32_t i) {}, [](int32_t i) {}); - } - - int32_t GetNull() const { return null_index_; } - - template - int32_t GetOrInsertNull(Func1&& on_found, Func2&& on_not_found) { - int32_t memo_index = GetNull(); - if (memo_index != kKeyNotFound) { - on_found(memo_index); - } else { - null_index_ = memo_index = size(); - on_not_found(memo_index); - } - return memo_index; - } - - int32_t GetOrInsertNull() { - return GetOrInsertNull([](int32_t i) {}, [](int32_t i) {}); - } - - // The number of entries in the memo table +1 if null was added. - // (which is also 1 + the largest memo index) - int32_t size() const override { - return static_cast(hash_table_.size()) + (GetNull() != kKeyNotFound); - } - - // Copy values starting from index `start` into `out_data` - void CopyValues(int32_t start, Scalar* out_data) const { - hash_table_.VisitEntries([=](const HashTableEntry* entry) { - int32_t index = entry->payload.memo_index - start; - if (index >= 0) { - out_data[index] = entry->payload.value; - } - }); - } - - void CopyValues(Scalar* out_data) const { CopyValues(0, out_data); } - - protected: - struct Payload { - Scalar value; - int32_t memo_index; - }; - - using HashTableType = HashTableTemplateType; - using HashTableEntry = typename HashTableType::Entry; - HashTableType hash_table_; - int32_t null_index_ = kKeyNotFound; - - hash_t ComputeHash(const Scalar& value) const { - return ScalarHelper::ComputeHash(value); - } -}; - -// ---------------------------------------------------------------------- -// A memoization table for small scalar values, using direct indexing - -template -struct SmallScalarTraits {}; - -template <> -struct SmallScalarTraits { - static constexpr int32_t cardinality = 2; - - static uint32_t AsIndex(bool value) { return value ? 1 : 0; } -}; - -template -struct SmallScalarTraits::value>::type> { - using Unsigned = typename std::make_unsigned::type; - - static constexpr int32_t cardinality = 1U + std::numeric_limits::max(); - - static uint32_t AsIndex(Scalar value) { return static_cast(value); } -}; - -template class HashTableTemplateType = HashTable> -class SmallScalarMemoTable : public MemoTable { - public: - explicit SmallScalarMemoTable(int64_t entries = 0) { - std::fill(value_to_index_, value_to_index_ + cardinality + 1, kKeyNotFound); - index_to_value_.reserve(cardinality); - } - - int32_t Get(const Scalar value) const { - auto value_index = AsIndex(value); - return value_to_index_[value_index]; - } - - template - int32_t GetOrInsert(const Scalar value, Func1&& on_found, Func2&& on_not_found) { - auto value_index = AsIndex(value); - auto memo_index = value_to_index_[value_index]; - if (memo_index == kKeyNotFound) { - memo_index = static_cast(index_to_value_.size()); - index_to_value_.push_back(value); - value_to_index_[value_index] = memo_index; - assert(memo_index < cardinality + 1); - on_not_found(memo_index); - } else { - on_found(memo_index); - } - return memo_index; - } - - int32_t GetOrInsert(const Scalar value) { - return GetOrInsert(value, [](int32_t i) {}, [](int32_t i) {}); - } - - int32_t GetNull() const { return value_to_index_[cardinality]; } - - template - int32_t GetOrInsertNull(Func1&& on_found, Func2&& on_not_found) { - auto memo_index = GetNull(); - if (memo_index == kKeyNotFound) { - memo_index = value_to_index_[cardinality] = size(); - index_to_value_.push_back(0); - on_not_found(memo_index); - } else { - on_found(memo_index); - } - return memo_index; - } - - int32_t GetOrInsertNull() { - return GetOrInsertNull([](int32_t i) {}, [](int32_t i) {}); - } - - // The number of entries in the memo table - // (which is also 1 + the largest memo index) - int32_t size() const override { return static_cast(index_to_value_.size()); } - - // Copy values starting from index `start` into `out_data` - void CopyValues(int32_t start, Scalar* out_data) const { - DCHECK_GE(start, 0); - DCHECK_LE(static_cast(start), index_to_value_.size()); - int64_t offset = start * static_cast(sizeof(Scalar)); - memcpy(out_data, index_to_value_.data() + offset, (size() - start) * sizeof(Scalar)); - } - - void CopyValues(Scalar* out_data) const { CopyValues(0, out_data); } - - const std::vector& values() const { return index_to_value_; } - - protected: - static constexpr auto cardinality = SmallScalarTraits::cardinality; - static_assert(cardinality <= 256, "cardinality too large for direct-addressed table"); - - uint32_t AsIndex(Scalar value) const { - return SmallScalarTraits::AsIndex(value); - } - - // The last index is reserved for the null element. - int32_t value_to_index_[cardinality + 1]; - std::vector index_to_value_; -}; - -// ---------------------------------------------------------------------- -// A memoization table for variable-sized binary data. - -class BinaryMemoTable : public MemoTable { - public: - explicit BinaryMemoTable(int64_t entries = 0, int64_t values_size = -1) - : hash_table_(static_cast(entries)) { - offsets_.reserve(entries + 1); - offsets_.push_back(0); - if (values_size == -1) { - values_.reserve(entries * 4); // A conservative heuristic - } else { - values_.reserve(values_size); - } - } - - int32_t Get(const void* data, int32_t length) const { - hash_t h = ComputeStringHash<0>(data, length); - auto p = Lookup(h, data, length); - if (p.second) { - return p.first->payload.memo_index; - } else { - return kKeyNotFound; - } - } - - int32_t Get(const std::string& value) const { - return Get(value.data(), static_cast(value.length())); - } - - int32_t Get(const util::string_view& value) const { - return Get(value.data(), static_cast(value.length())); - } - - template - int32_t GetOrInsert(const void* data, int32_t length, Func1&& on_found, - Func2&& on_not_found) { - hash_t h = ComputeStringHash<0>(data, length); - auto p = Lookup(h, data, length); - int32_t memo_index; - if (p.second) { - memo_index = p.first->payload.memo_index; - on_found(memo_index); - } else { - memo_index = size(); - // Insert offset - auto offset = static_cast(values_.size()); - assert(offsets_.size() == static_cast(memo_index + 1)); - assert(offsets_[memo_index] == offset); - offsets_.push_back(offset + length); - // Insert string value - values_.append(static_cast(data), length); - // Insert hash entry - hash_table_.Insert(const_cast(p.first), h, {memo_index}); - - on_not_found(memo_index); - } - return memo_index; - } - - template - int32_t GetOrInsert(const util::string_view& value, Func1&& on_found, - Func2&& on_not_found) { - return GetOrInsert(value.data(), static_cast(value.length()), - std::forward(on_found), std::forward(on_not_found)); - } - - int32_t GetOrInsert(const void* data, int32_t length) { - return GetOrInsert(data, length, [](int32_t i) {}, [](int32_t i) {}); - } - - int32_t GetOrInsert(const util::string_view& value) { - return GetOrInsert(value.data(), static_cast(value.length())); - } - - int32_t GetOrInsert(const std::string& value) { - return GetOrInsert(value.data(), static_cast(value.length())); - } - - int32_t GetNull() const { return null_index_; } - - template - int32_t GetOrInsertNull(Func1&& on_found, Func2&& on_not_found) { - auto memo_index = GetNull(); - if (memo_index == kKeyNotFound) { - memo_index = null_index_ = size(); - auto offset = static_cast(values_.size()); - // Only the offset array needs to be updated. - offsets_.push_back(offset); - - on_not_found(memo_index); - } else { - on_found(memo_index); - } - return memo_index; - } - - int32_t GetOrInsertNull() { - return GetOrInsertNull([](int32_t i) {}, [](int32_t i) {}); - } - - // The number of entries in the memo table - // (which is also 1 + the largest memo index) - int32_t size() const override { - return static_cast(hash_table_.size() + (GetNull() != kKeyNotFound)); - } - - int32_t values_size() const { return static_cast(values_.size()); } - - const uint8_t* values_data() const { - return reinterpret_cast(values_.data()); - } - - // Copy (n + 1) offsets starting from index `start` into `out_data` - template - void CopyOffsets(int32_t start, Offset* out_data) const { - auto delta = offsets_[start]; - for (uint32_t i = start; i < offsets_.size(); ++i) { - auto adjusted_offset = offsets_[i] - delta; - auto cast_offset = static_cast(adjusted_offset); - assert(static_cast(cast_offset) == adjusted_offset); // avoid truncation - *out_data++ = cast_offset; - } - } - - template - void CopyOffsets(Offset* out_data) const { - CopyOffsets(0, out_data); - } - - // Copy values starting from index `start` into `out_data` - void CopyValues(int32_t start, uint8_t* out_data) const { - CopyValues(start, -1, out_data); - } - - // Same as above, but check output size in debug mode - void CopyValues(int32_t start, int64_t out_size, uint8_t* out_data) const { - int32_t offset = offsets_[start]; - auto length = values_.size() - static_cast(offset); - if (out_size != -1) { - assert(static_cast(length) == out_size); - } - memcpy(out_data, values_.data() + offset, length); - } - - void CopyValues(uint8_t* out_data) const { CopyValues(0, -1, out_data); } - - void CopyValues(int64_t out_size, uint8_t* out_data) const { - CopyValues(0, out_size, out_data); - } - - void CopyFixedWidthValues(int32_t start, int32_t width_size, int64_t out_size, - uint8_t* out_data) const { - // This method exists to cope with the fact that the BinaryMemoTable does - // not know the fixed width when inserting the null value. The data - // buffer hold a zero length string for the null value (if found). - // - // Thus, the method will properly inject an empty value of the proper width - // in the output buffer. - - int32_t null_index = GetNull(); - if (null_index < start) { - // Nothing to skip, proceed as usual. - CopyValues(start, out_size, out_data); - return; - } - - int32_t left_offset = offsets_[start]; - - // Ensure that the data length is exactly missing width_size bytes to fit - // in the expected output (n_values * width_size). -#ifndef NDEBUG - int64_t data_length = values_.size() - static_cast(left_offset); - assert(data_length + width_size == out_size); -#endif - - auto in_data = values_.data() + left_offset; - // The null use 0-length in the data, slice the data in 2 and skip by - // width_size in out_data. [part_1][width_size][part_2] - auto null_data_offset = offsets_[null_index]; - auto left_size = null_data_offset - left_offset; - if (left_size > 0) { - memcpy(out_data, in_data + left_offset, left_size); - } - - auto right_size = values_.size() - static_cast(null_data_offset); - if (right_size > 0) { - // skip the null fixed size value. - auto out_offset = left_size + width_size; - assert(out_data + out_offset + right_size == out_data + out_size); - memcpy(out_data + out_offset, in_data + null_data_offset, right_size); - } - } - - // Visit the stored values in insertion order. - // The visitor function should have the signature `void(util::string_view)` - // or `void(const util::string_view&)`. - template - void VisitValues(int32_t start, VisitFunc&& visit) const { - for (uint32_t i = start; i < offsets_.size() - 1; ++i) { - visit( - util::string_view(values_.data() + offsets_[i], offsets_[i + 1] - offsets_[i])); - } - } - - protected: - struct Payload { - int32_t memo_index; - }; - - using HashTableType = HashTable; - using HashTableEntry = typename HashTable::Entry; - HashTableType hash_table_; - - std::vector offsets_; - std::string values_; - - int32_t null_index_ = kKeyNotFound; - - std::pair Lookup(hash_t h, const void* data, - int32_t length) const { - auto cmp_func = [=](const Payload* payload) { - int32_t start, stop; - start = offsets_[payload->memo_index]; - stop = offsets_[payload->memo_index + 1]; - return length == stop - start && memcmp(data, values_.data() + start, length) == 0; - }; - return hash_table_.Lookup(h, cmp_func); - } -}; - -template -struct HashTraits {}; - -template <> -struct HashTraits { - using MemoTableType = SmallScalarMemoTable; -}; - -template -struct HashTraits> { - using c_type = typename T::c_type; - using MemoTableType = SmallScalarMemoTable; -}; - -template -struct HashTraits< - T, typename std::enable_if::value && !is_8bit_int::value>::type> { - using c_type = typename T::c_type; - using MemoTableType = ScalarMemoTable; -}; - -template -struct HashTraits> { - using MemoTableType = BinaryMemoTable; -}; - -template -struct HashTraits> { - using MemoTableType = BinaryMemoTable; -}; - -template -static inline Status ComputeNullBitmap(MemoryPool* pool, const MemoTableType& memo_table, - int64_t start_offset, int64_t* null_count, - std::shared_ptr* null_bitmap) { - int64_t dict_length = static_cast(memo_table.size()) - start_offset; - int64_t null_index = memo_table.GetNull(); - - *null_count = 0; - *null_bitmap = nullptr; - - if (null_index != kKeyNotFound && null_index >= start_offset) { - null_index -= start_offset; - *null_count = 1; - RETURN_NOT_OK(internal::BitmapAllButOne(pool, dict_length, null_index, null_bitmap)); - } - - return Status::OK(); -} - -template -struct DictionaryTraits {}; - -template <> -struct DictionaryTraits { - using T = BooleanType; - using MemoTableType = typename HashTraits::MemoTableType; - - static Status GetDictionaryArrayData(MemoryPool* pool, - const std::shared_ptr& type, - const MemoTableType& memo_table, - int64_t start_offset, - std::shared_ptr* out) { - if (start_offset < 0) { - return Status::Invalid("invalid start_offset ", start_offset); - } - - BooleanBuilder builder(pool); - const auto& bool_values = memo_table.values(); - const auto null_index = memo_table.GetNull(); - - // Will iterate up to 3 times. - for (int64_t i = start_offset; i < memo_table.size(); i++) { - RETURN_NOT_OK(i == null_index ? builder.AppendNull() - : builder.Append(bool_values[i])); - } - - return builder.FinishInternal(out); - } -}; // namespace internal - -template -struct DictionaryTraits> { - using c_type = typename T::c_type; - using MemoTableType = typename HashTraits::MemoTableType; - - static Status GetDictionaryArrayData(MemoryPool* pool, - const std::shared_ptr& type, - const MemoTableType& memo_table, - int64_t start_offset, - std::shared_ptr* out) { - std::shared_ptr dict_buffer; - auto dict_length = static_cast(memo_table.size()) - start_offset; - // This makes a copy, but we assume a dictionary array is usually small - // compared to the size of the dictionary-using array. - // (also, copying the dictionary values is cheap compared to the cost - // of building the memo table) - RETURN_NOT_OK( - AllocateBuffer(pool, TypeTraits::bytes_required(dict_length), &dict_buffer)); - memo_table.CopyValues(static_cast(start_offset), - reinterpret_cast(dict_buffer->mutable_data())); - - int64_t null_count = 0; - std::shared_ptr null_bitmap = nullptr; - RETURN_NOT_OK( - ComputeNullBitmap(pool, memo_table, start_offset, &null_count, &null_bitmap)); - - *out = ArrayData::Make(type, dict_length, {null_bitmap, dict_buffer}, null_count); - return Status::OK(); - } -}; - -template -struct DictionaryTraits> { - using MemoTableType = typename HashTraits::MemoTableType; - - static Status GetDictionaryArrayData(MemoryPool* pool, - const std::shared_ptr& type, - const MemoTableType& memo_table, - int64_t start_offset, - std::shared_ptr* out) { - std::shared_ptr dict_offsets; - std::shared_ptr dict_data; - - // Create the offsets buffer - auto dict_length = static_cast(memo_table.size() - start_offset); - RETURN_NOT_OK(AllocateBuffer( - pool, TypeTraits::bytes_required(dict_length + 1), &dict_offsets)); - auto raw_offsets = reinterpret_cast(dict_offsets->mutable_data()); - memo_table.CopyOffsets(static_cast(start_offset), raw_offsets); - - // Create the data buffer - DCHECK_EQ(raw_offsets[0], 0); - RETURN_NOT_OK(AllocateBuffer(pool, raw_offsets[dict_length], &dict_data)); - memo_table.CopyValues(static_cast(start_offset), dict_data->size(), - dict_data->mutable_data()); - - int64_t null_count = 0; - std::shared_ptr null_bitmap = nullptr; - RETURN_NOT_OK( - ComputeNullBitmap(pool, memo_table, start_offset, &null_count, &null_bitmap)); - - *out = ArrayData::Make(type, dict_length, {null_bitmap, dict_offsets, dict_data}, - null_count); - - return Status::OK(); - } -}; - -template -struct DictionaryTraits> { - using MemoTableType = typename HashTraits::MemoTableType; - - static Status GetDictionaryArrayData(MemoryPool* pool, - const std::shared_ptr& type, - const MemoTableType& memo_table, - int64_t start_offset, - std::shared_ptr* out) { - const T& concrete_type = internal::checked_cast(*type); - std::shared_ptr dict_data; - - // Create the data buffer - auto dict_length = static_cast(memo_table.size() - start_offset); - auto width_length = concrete_type.byte_width(); - auto data_length = dict_length * width_length; - RETURN_NOT_OK(AllocateBuffer(pool, data_length, &dict_data)); - auto data = dict_data->mutable_data(); - - memo_table.CopyFixedWidthValues(static_cast(start_offset), width_length, - data_length, data); - - int64_t null_count = 0; - std::shared_ptr null_bitmap = nullptr; - RETURN_NOT_OK( - ComputeNullBitmap(pool, memo_table, start_offset, &null_count, &null_bitmap)); - - *out = ArrayData::Make(type, dict_length, {null_bitmap, dict_data}, null_count); - return Status::OK(); - } -}; - -} // namespace internal -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/int-util.h b/cpp/thirdparty/knowhere_build/include/arrow/util/int-util.h deleted file mode 100644 index da45473794..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/int-util.h +++ /dev/null @@ -1,105 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_UTIL_INT_UTIL_H -#define ARROW_UTIL_INT_UTIL_H - -#include -#include - -#include "arrow/util/visibility.h" - -namespace arrow { -namespace internal { - -ARROW_EXPORT -uint8_t DetectUIntWidth(const uint64_t* values, int64_t length, uint8_t min_width = 1); - -ARROW_EXPORT -uint8_t DetectUIntWidth(const uint64_t* values, const uint8_t* valid_bytes, - int64_t length, uint8_t min_width = 1); - -ARROW_EXPORT -uint8_t DetectIntWidth(const int64_t* values, int64_t length, uint8_t min_width = 1); - -ARROW_EXPORT -uint8_t DetectIntWidth(const int64_t* values, const uint8_t* valid_bytes, int64_t length, - uint8_t min_width = 1); - -ARROW_EXPORT -void DowncastInts(const int64_t* source, int8_t* dest, int64_t length); - -ARROW_EXPORT -void DowncastInts(const int64_t* source, int16_t* dest, int64_t length); - -ARROW_EXPORT -void DowncastInts(const int64_t* source, int32_t* dest, int64_t length); - -ARROW_EXPORT -void DowncastInts(const int64_t* source, int64_t* dest, int64_t length); - -ARROW_EXPORT -void DowncastUInts(const uint64_t* source, uint8_t* dest, int64_t length); - -ARROW_EXPORT -void DowncastUInts(const uint64_t* source, uint16_t* dest, int64_t length); - -ARROW_EXPORT -void DowncastUInts(const uint64_t* source, uint32_t* dest, int64_t length); - -ARROW_EXPORT -void DowncastUInts(const uint64_t* source, uint64_t* dest, int64_t length); - -template -ARROW_EXPORT void TransposeInts(const InputInt* source, OutputInt* dest, int64_t length, - const int32_t* transpose_map); - -/// Signed addition with well-defined behaviour on overflow (as unsigned) -template -SignedInt SafeSignedAdd(SignedInt u, SignedInt v) { - using UnsignedInt = typename std::make_unsigned::type; - return static_cast(static_cast(u) + - static_cast(v)); -} - -/// Signed left shift with well-defined behaviour on negative numbers or overflow -template -SignedInt SafeLeftShift(SignedInt u, Shift shift) { - using UnsignedInt = typename std::make_unsigned::type; - return static_cast(static_cast(u) << shift); -} - -/// Upcast an integer to the largest possible width (currently 64 bits) - -template -typename std::enable_if< - std::is_integral::value && std::is_signed::value, int64_t>::type -UpcastInt(Integer v) { - return v; -} - -template -typename std::enable_if< - std::is_integral::value && std::is_unsigned::value, uint64_t>::type -UpcastInt(Integer v) { - return v; -} - -} // namespace internal -} // namespace arrow - -#endif // ARROW_UTIL_INT_UTIL_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/interfaces.h b/cpp/thirdparty/knowhere_build/include/arrow/util/interfaces.h deleted file mode 100644 index 3ebe2207f7..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/interfaces.h +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include "arrow/dataset/visibility.h" - -namespace arrow { - -class Status; - -template -class Iterator { - public: - virtual Status Next(T* out) = 0; -} - -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/io-util.h b/cpp/thirdparty/knowhere_build/include/arrow/util/io-util.h deleted file mode 100644 index dd6ff570f0..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/io-util.h +++ /dev/null @@ -1,263 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_UTIL_IO_UTIL_H -#define ARROW_UTIL_IO_UTIL_H - -#ifndef _WIN32 -#define ARROW_HAVE_SIGACTION 1 -#endif - -#include -#include - -#if ARROW_HAVE_SIGACTION -#include // Needed for struct sigaction -#endif - -#include "arrow/io/interfaces.h" -#include "arrow/status.h" -#include "arrow/util/macros.h" - -// The Windows API defines DeleteFile as a macro resolving to either -// DeleteFileA or DeleteFileW. Need to undo it. -#if defined(_WIN32) && defined(DeleteFile) -#undef DeleteFile -#endif - -namespace arrow { - -class Buffer; - -namespace io { - -// Output stream that just writes to stdout. -class ARROW_EXPORT StdoutStream : public OutputStream { - public: - StdoutStream(); - ~StdoutStream() override {} - - Status Close() override; - bool closed() const override; - - Status Tell(int64_t* position) const override; - - Status Write(const void* data, int64_t nbytes) override; - - private: - int64_t pos_; -}; - -// Output stream that just writes to stderr. -class ARROW_EXPORT StderrStream : public OutputStream { - public: - StderrStream(); - ~StderrStream() override {} - - Status Close() override; - bool closed() const override; - - Status Tell(int64_t* position) const override; - - Status Write(const void* data, int64_t nbytes) override; - - private: - int64_t pos_; -}; - -// Input stream that just reads from stdin. -class ARROW_EXPORT StdinStream : public InputStream { - public: - StdinStream(); - ~StdinStream() override {} - - Status Close() override; - bool closed() const override; - - Status Tell(int64_t* position) const override; - - Status Read(int64_t nbytes, int64_t* bytes_read, void* out) override; - - Status Read(int64_t nbytes, std::shared_ptr* out) override; - - private: - int64_t pos_; -}; - -} // namespace io - -namespace internal { - -// NOTE: 8-bit path strings on Windows are encoded using UTF-8. -// Using MBCS would fail encoding some paths. - -#if defined(_WIN32) -using NativePathString = std::wstring; -#else -using NativePathString = std::string; -#endif - -class ARROW_EXPORT PlatformFilename { - public: - ~PlatformFilename(); - PlatformFilename(); - PlatformFilename(const PlatformFilename&); - PlatformFilename(PlatformFilename&&); - PlatformFilename& operator=(const PlatformFilename&); - PlatformFilename& operator=(PlatformFilename&&); - explicit PlatformFilename(const NativePathString& path); - - const NativePathString& ToNative() const; - std::string ToString() const; - - // These functions can fail for character encoding reasons. - static Status FromString(const std::string& file_name, PlatformFilename* out); - Status Join(const std::string& child_name, PlatformFilename* out) const; - - private: - struct Impl; - std::unique_ptr impl_; - - explicit PlatformFilename(const Impl& impl); - explicit PlatformFilename(Impl&& impl); - - // Those functions need access to the embedded path object - friend ARROW_EXPORT Status CreateDir(const PlatformFilename&, bool*); - friend ARROW_EXPORT Status CreateDirTree(const PlatformFilename&, bool*); - friend ARROW_EXPORT Status DeleteDirTree(const PlatformFilename&, bool*); - friend ARROW_EXPORT Status DeleteFile(const PlatformFilename&, bool*); - friend ARROW_EXPORT Status FileExists(const PlatformFilename&, bool*); -}; - -ARROW_EXPORT -Status CreateDir(const PlatformFilename& dir_path, bool* created = NULLPTR); -ARROW_EXPORT -Status CreateDirTree(const PlatformFilename& dir_path, bool* created = NULLPTR); -ARROW_EXPORT -Status DeleteDirTree(const PlatformFilename& dir_path, bool* deleted = NULLPTR); -ARROW_EXPORT -Status DeleteFile(const PlatformFilename& file_path, bool* deleted = NULLPTR); -ARROW_EXPORT -Status FileExists(const PlatformFilename& path, bool* out); - -ARROW_EXPORT -Status FileNameFromString(const std::string& file_name, PlatformFilename* out); - -ARROW_EXPORT -Status FileOpenReadable(const PlatformFilename& file_name, int* fd); -ARROW_EXPORT -Status FileOpenWritable(const PlatformFilename& file_name, bool write_only, bool truncate, - bool append, int* fd); - -ARROW_EXPORT -Status FileRead(int fd, uint8_t* buffer, const int64_t nbytes, int64_t* bytes_read); -ARROW_EXPORT -Status FileReadAt(int fd, uint8_t* buffer, int64_t position, int64_t nbytes, - int64_t* bytes_read); -ARROW_EXPORT -Status FileWrite(int fd, const uint8_t* buffer, const int64_t nbytes); -ARROW_EXPORT -Status FileTruncate(int fd, const int64_t size); - -ARROW_EXPORT -Status FileTell(int fd, int64_t* pos); -ARROW_EXPORT -Status FileSeek(int fd, int64_t pos); -ARROW_EXPORT -Status FileSeek(int fd, int64_t pos, int whence); -ARROW_EXPORT -Status FileGetSize(int fd, int64_t* size); - -ARROW_EXPORT -Status FileClose(int fd); - -ARROW_EXPORT -Status CreatePipe(int fd[2]); - -ARROW_EXPORT -Status MemoryMapRemap(void* addr, size_t old_size, size_t new_size, int fildes, - void** new_addr); - -ARROW_EXPORT -Status GetEnvVar(const char* name, std::string* out); -ARROW_EXPORT -Status GetEnvVar(const std::string& name, std::string* out); -ARROW_EXPORT -Status SetEnvVar(const char* name, const char* value); -ARROW_EXPORT -Status SetEnvVar(const std::string& name, const std::string& value); -ARROW_EXPORT -Status DelEnvVar(const char* name); -ARROW_EXPORT -Status DelEnvVar(const std::string& name); - -ARROW_EXPORT -std::string ErrnoMessage(int errnum); -#if _WIN32 -ARROW_EXPORT -std::string WinErrorMessage(int errnum); -#endif - -class ARROW_EXPORT TemporaryDir { - public: - ~TemporaryDir(); - - const PlatformFilename& path() { return path_; } - - static Status Make(const std::string& prefix, std::unique_ptr* out); - - private: - PlatformFilename path_; - - explicit TemporaryDir(PlatformFilename&&); -}; - -class ARROW_EXPORT SignalHandler { - public: - typedef void (*Callback)(int); - - SignalHandler(); - explicit SignalHandler(Callback cb); -#if ARROW_HAVE_SIGACTION - explicit SignalHandler(const struct sigaction& sa); -#endif - - Callback callback() const; -#if ARROW_HAVE_SIGACTION - const struct sigaction& action() const; -#endif - - protected: -#if ARROW_HAVE_SIGACTION - // Storing the full sigaction allows to restore the entire signal handling - // configuration. - struct sigaction sa_; -#else - Callback cb_; -#endif -}; - -ARROW_EXPORT -Status GetSignalHandler(int signum, SignalHandler* out); -ARROW_EXPORT -Status SetSignalHandler(int signum, const SignalHandler& handler, - SignalHandler* old_handler = NULLPTR); - -} // namespace internal -} // namespace arrow - -#endif // ARROW_UTIL_IO_UTIL_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/iterator.h b/cpp/thirdparty/knowhere_build/include/arrow/util/iterator.h deleted file mode 100644 index 52fb10b09a..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/iterator.h +++ /dev/null @@ -1,35 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include "arrow/dataset/visibility.h" - -namespace arrow { - -class Status; - -/// \brief A generic Iterator that can return errors -template -class Iterator { - public: - /// \brief Return the next element of the sequence, nullptr when the - /// iteration is completed - virtual Status Next(T* out) = 0; -}; - -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/key_value_metadata.h b/cpp/thirdparty/knowhere_build/include/arrow/util/key_value_metadata.h deleted file mode 100644 index 2820c98200..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/key_value_metadata.h +++ /dev/null @@ -1,81 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_UTIL_KEY_VALUE_METADATA_H -#define ARROW_UTIL_KEY_VALUE_METADATA_H - -#include -#include -#include -#include -#include - -#include "arrow/util/macros.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -/// \brief A container for key-value pair type metadata. Not thread-safe -class ARROW_EXPORT KeyValueMetadata { - public: - KeyValueMetadata(); - KeyValueMetadata(const std::vector& keys, - const std::vector& values); - explicit KeyValueMetadata(const std::unordered_map& map); - virtual ~KeyValueMetadata() = default; - - void ToUnorderedMap(std::unordered_map* out) const; - - void Append(const std::string& key, const std::string& value); - - void reserve(int64_t n); - int64_t size() const; - - const std::string& key(int64_t i) const; - const std::string& value(int64_t i) const; - - /// \brief Perform linear search for key, returning -1 if not found - int FindKey(const std::string& key) const; - - std::shared_ptr Copy() const; - - bool Equals(const KeyValueMetadata& other) const; - std::string ToString() const; - - private: - std::vector keys_; - std::vector values_; - - ARROW_DISALLOW_COPY_AND_ASSIGN(KeyValueMetadata); -}; - -/// \brief Create a KeyValueMetadata instance -/// -/// \param pairs key-value mapping -std::shared_ptr ARROW_EXPORT -key_value_metadata(const std::unordered_map& pairs); - -/// \brief Create a KeyValueMetadata instance -/// -/// \param keys sequence of metadata keys -/// \param values sequence of corresponding metadata values -std::shared_ptr ARROW_EXPORT key_value_metadata( - const std::vector& keys, const std::vector& values); - -} // namespace arrow - -#endif // ARROW_UTIL_KEY_VALUE_METADATA_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/lazy.h b/cpp/thirdparty/knowhere_build/include/arrow/util/lazy.h deleted file mode 100644 index de32b5f22a..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/lazy.h +++ /dev/null @@ -1,128 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_UTIL_LAZY_H -#define ARROW_UTIL_LAZY_H - -#include -#include - -namespace arrow { -namespace internal { - -/// Create a range from a callable which takes a single index parameter -/// and returns the value of iterator on each call and a length. -/// Only iterators obtained from the same range should be compared, the -/// behaviour generally similar to other STL containers. -template -class LazyRange { - private: - // callable which generates the values - // has to be defined at the beginning of the class for type deduction - const Generator gen_; - // the length of the range - int64_t length_; -#ifdef _MSC_VER - // workaround to VS2010 not supporting decltype properly - // see https://stackoverflow.com/questions/21782846/decltype-for-class-member-function - static Generator gen_static_; -#endif - - public: -#ifdef _MSC_VER - using return_type = decltype(gen_static_(0)); -#else - using return_type = decltype(gen_(0)); -#endif - - /// Construct a new range from a callable and length - LazyRange(Generator gen, int64_t length) : gen_(gen), length_(length) {} - - // Class of the dependent iterator, created implicitly by begin and end - class RangeIter { - public: - using difference_type = int64_t; - using value_type = return_type; - using reference = const value_type&; - using pointer = const value_type*; - using iterator_category = std::forward_iterator_tag; - -#ifdef _MSC_VER - // msvc complains about unchecked iterators, - // see https://stackoverflow.com/questions/21655496/error-c4996-checked-iterators - using _Unchecked_type = typename LazyRange::RangeIter; -#endif - - RangeIter(const LazyRange& range, int64_t index) - : range_(range), index_(index) {} - - const return_type operator*() { return range_.gen_(index_); } - - RangeIter operator+(difference_type length) { - return RangeIter(range_, index_ + length); - } - - // pre-increment - RangeIter& operator++() { - ++index_; - return *this; - } - - // post-increment - RangeIter operator++(int) { - auto copy = RangeIter(*this); - ++index_; - return copy; - } - - bool operator==(const typename LazyRange::RangeIter& other) const { - return this->index_ == other.index_ && &this->range_ == &other.range_; - } - - bool operator!=(const typename LazyRange::RangeIter& other) const { - return this->index_ != other.index_ || &this->range_ != &other.range_; - } - - int64_t operator-(const typename LazyRange::RangeIter& other) { - return this->index_ - other.index_; - } - - private: - // parent range reference - const LazyRange& range_; - // current index - int64_t index_; - }; - - friend class RangeIter; - - // Create a new begin const iterator - RangeIter begin() { return RangeIter(*this, 0); } - - // Create a new end const iterator - RangeIter end() { return RangeIter(*this, length_); } -}; - -/// Helper function to create a lazy range from a callable (e.g. lambda) and length -template -LazyRange MakeLazyRange(Generator&& gen, int64_t length) { - return LazyRange(std::forward(gen), length); -} - -} // namespace internal -} // namespace arrow -#endif diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/logging.h b/cpp/thirdparty/knowhere_build/include/arrow/util/logging.h deleted file mode 100644 index a920db1b2c..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/logging.h +++ /dev/null @@ -1,253 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_UTIL_LOGGING_H -#define ARROW_UTIL_LOGGING_H - -#ifdef GANDIVA_IR - -// The LLVM IR code doesn't have an NDEBUG mode. And, it shouldn't include references to -// streams or stdc++. So, making the DCHECK calls void in that case. - -#define ARROW_IGNORE_EXPR(expr) ((void)(expr)) - -#define DCHECK(condition) ARROW_IGNORE_EXPR(condition) -#define DCHECK_OK(status) ARROW_IGNORE_EXPR(status) -#define DCHECK_EQ(val1, val2) ARROW_IGNORE_EXPR(val1) -#define DCHECK_NE(val1, val2) ARROW_IGNORE_EXPR(val1) -#define DCHECK_LE(val1, val2) ARROW_IGNORE_EXPR(val1) -#define DCHECK_LT(val1, val2) ARROW_IGNORE_EXPR(val1) -#define DCHECK_GE(val1, val2) ARROW_IGNORE_EXPR(val1) -#define DCHECK_GT(val1, val2) ARROW_IGNORE_EXPR(val1) - -#else // !GANDIVA_IR - -#include -#include -#include - -#include "arrow/util/macros.h" -#include "arrow/util/visibility.h" - -namespace arrow { -namespace util { - -enum class ArrowLogLevel : int { - ARROW_DEBUG = -1, - ARROW_INFO = 0, - ARROW_WARNING = 1, - ARROW_ERROR = 2, - ARROW_FATAL = 3 -}; - -#define ARROW_LOG_INTERNAL(level) ::arrow::util::ArrowLog(__FILE__, __LINE__, level) -#define ARROW_LOG(level) ARROW_LOG_INTERNAL(::arrow::util::ArrowLogLevel::ARROW_##level) - -#define ARROW_IGNORE_EXPR(expr) ((void)(expr)) - -#define ARROW_CHECK(condition) \ - ARROW_PREDICT_TRUE(condition) \ - ? ARROW_IGNORE_EXPR(0) \ - : ::arrow::util::Voidify() & \ - ::arrow::util::ArrowLog(__FILE__, __LINE__, \ - ::arrow::util::ArrowLogLevel::ARROW_FATAL) \ - << " Check failed: " #condition " " - -// If 'to_call' returns a bad status, CHECK immediately with a logged message -// of 'msg' followed by the status. -#define ARROW_CHECK_OK_PREPEND(to_call, msg) \ - do { \ - ::arrow::Status _s = (to_call); \ - ARROW_CHECK(_s.ok()) << "Operation failed: " << ARROW_STRINGIFY(to_call) << "\n" \ - << (msg) << ": " << _s.ToString(); \ - } while (false) - -// If the status is bad, CHECK immediately, appending the status to the -// logged message. -#define ARROW_CHECK_OK(s) ARROW_CHECK_OK_PREPEND(s, "Bad status") - -#define ARROW_CHECK_EQ(val1, val2) ARROW_CHECK((val1) == (val2)) -#define ARROW_CHECK_NE(val1, val2) ARROW_CHECK((val1) != (val2)) -#define ARROW_CHECK_LE(val1, val2) ARROW_CHECK((val1) <= (val2)) -#define ARROW_CHECK_LT(val1, val2) ARROW_CHECK((val1) < (val2)) -#define ARROW_CHECK_GE(val1, val2) ARROW_CHECK((val1) >= (val2)) -#define ARROW_CHECK_GT(val1, val2) ARROW_CHECK((val1) > (val2)) - -#ifdef NDEBUG -#define ARROW_DFATAL ::arrow::util::ArrowLogLevel::ARROW_WARNING - -// CAUTION: DCHECK_OK() always evaluates its argument, but other DCHECK*() macros -// only do so in debug mode. - -#define DCHECK(condition) \ - while (false) ARROW_IGNORE_EXPR(condition); \ - while (false) ::arrow::util::detail::NullLog() -#define DCHECK_OK(s) \ - ARROW_IGNORE_EXPR(s); \ - while (false) ::arrow::util::detail::NullLog() -#define DCHECK_EQ(val1, val2) \ - while (false) ARROW_IGNORE_EXPR(val1); \ - while (false) ARROW_IGNORE_EXPR(val2); \ - while (false) ::arrow::util::detail::NullLog() -#define DCHECK_NE(val1, val2) \ - while (false) ARROW_IGNORE_EXPR(val1); \ - while (false) ARROW_IGNORE_EXPR(val2); \ - while (false) ::arrow::util::detail::NullLog() -#define DCHECK_LE(val1, val2) \ - while (false) ARROW_IGNORE_EXPR(val1); \ - while (false) ARROW_IGNORE_EXPR(val2); \ - while (false) ::arrow::util::detail::NullLog() -#define DCHECK_LT(val1, val2) \ - while (false) ARROW_IGNORE_EXPR(val1); \ - while (false) ARROW_IGNORE_EXPR(val2); \ - while (false) ::arrow::util::detail::NullLog() -#define DCHECK_GE(val1, val2) \ - while (false) ARROW_IGNORE_EXPR(val1); \ - while (false) ARROW_IGNORE_EXPR(val2); \ - while (false) ::arrow::util::detail::NullLog() -#define DCHECK_GT(val1, val2) \ - while (false) ARROW_IGNORE_EXPR(val1); \ - while (false) ARROW_IGNORE_EXPR(val2); \ - while (false) ::arrow::util::detail::NullLog() - -#else -#define ARROW_DFATAL ::arrow::util::ArrowLogLevel::ARROW_FATAL - -#define DCHECK ARROW_CHECK -#define DCHECK_OK ARROW_CHECK_OK -#define DCHECK_EQ ARROW_CHECK_EQ -#define DCHECK_NE ARROW_CHECK_NE -#define DCHECK_LE ARROW_CHECK_LE -#define DCHECK_LT ARROW_CHECK_LT -#define DCHECK_GE ARROW_CHECK_GE -#define DCHECK_GT ARROW_CHECK_GT - -#endif // NDEBUG - -// This code is adapted from -// https://github.com/ray-project/ray/blob/master/src/ray/util/logging.h. - -// To make the logging lib plugable with other logging libs and make -// the implementation unawared by the user, ArrowLog is only a declaration -// which hide the implementation into logging.cc file. -// In logging.cc, we can choose different log libs using different macros. - -// This is also a null log which does not output anything. -class ARROW_EXPORT ArrowLogBase { - public: - virtual ~ArrowLogBase() {} - - virtual bool IsEnabled() const { return false; } - - template - ArrowLogBase& operator<<(const T& t) { - if (IsEnabled()) { - Stream() << t; - } - return *this; - } - - protected: - virtual std::ostream& Stream() = 0; -}; - -class ARROW_EXPORT ArrowLog : public ArrowLogBase { - public: - ArrowLog(const char* file_name, int line_number, ArrowLogLevel severity); - ~ArrowLog() override; - - /// Return whether or not current logging instance is enabled. - /// - /// \return True if logging is enabled and false otherwise. - bool IsEnabled() const override; - - /// The init function of arrow log for a program which should be called only once. - /// - /// \param appName The app name which starts the log. - /// \param severity_threshold Logging threshold for the program. - /// \param logDir Logging output file name. If empty, the log won't output to file. - static void StartArrowLog(const std::string& appName, - ArrowLogLevel severity_threshold = ArrowLogLevel::ARROW_INFO, - const std::string& logDir = ""); - - /// The shutdown function of arrow log, it should be used with StartArrowLog as a pair. - static void ShutDownArrowLog(); - - /// Install the failure signal handler to output call stack when crash. - /// If glog is not installed, this function won't do anything. - static void InstallFailureSignalHandler(); - - /// Uninstall the signal actions installed by InstallFailureSignalHandler. - static void UninstallSignalAction(); - - /// Return whether or not the log level is enabled in current setting. - /// - /// \param log_level The input log level to test. - /// \return True if input log level is not lower than the threshold. - static bool IsLevelEnabled(ArrowLogLevel log_level); - - private: - ARROW_DISALLOW_COPY_AND_ASSIGN(ArrowLog); - - // Hide the implementation of log provider by void *. - // Otherwise, lib user may define the same macro to use the correct header file. - void* logging_provider_; - /// True if log messages should be logged and false if they should be ignored. - bool is_enabled_; - - static ArrowLogLevel severity_threshold_; - - protected: - std::ostream& Stream() override; -}; - -// This class make ARROW_CHECK compilation pass to change the << operator to void. -// This class is copied from glog. -class ARROW_EXPORT Voidify { - public: - Voidify() {} - // This has to be an operator with a precedence lower than << but - // higher than ?: - void operator&(ArrowLogBase&) {} -}; - -namespace detail { - -/// @brief A helper for the nil log sink. -/// -/// Using this helper is analogous to sending log messages to /dev/null: -/// nothing gets logged. -class NullLog { - public: - /// The no-op output operator. - /// - /// @param [in] t - /// The object to send into the nil sink. - /// @return Reference to the updated object. - template - NullLog& operator<<(const T& t) { - return *this; - } -}; - -} // namespace detail -} // namespace util -} // namespace arrow - -#endif // GANDIVA_IR - -#endif // ARROW_UTIL_LOGGING_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/macros.h b/cpp/thirdparty/knowhere_build/include/arrow/util/macros.h deleted file mode 100644 index 8b92bce57f..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/macros.h +++ /dev/null @@ -1,166 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_UTIL_MACROS_H -#define ARROW_UTIL_MACROS_H - -#include - -#define ARROW_STRINGIFY(x) #x -#define ARROW_CONCAT(x, y) x##y - -// From Google gutil -#ifndef ARROW_DISALLOW_COPY_AND_ASSIGN -#define ARROW_DISALLOW_COPY_AND_ASSIGN(TypeName) \ - TypeName(const TypeName&) = delete; \ - void operator=(const TypeName&) = delete -#endif - -#define ARROW_UNUSED(x) (void)x -#define ARROW_ARG_UNUSED(x) -// -// GCC can be told that a certain branch is not likely to be taken (for -// instance, a CHECK failure), and use that information in static analysis. -// Giving it this information can help it optimize for the common case in -// the absence of better information (ie. -fprofile-arcs). -// -#if defined(__GNUC__) -#define ARROW_PREDICT_FALSE(x) (__builtin_expect(x, 0)) -#define ARROW_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1)) -#define ARROW_NORETURN __attribute__((noreturn)) -#define ARROW_PREFETCH(addr) __builtin_prefetch(addr) -#elif defined(_MSC_VER) -#define ARROW_NORETURN __declspec(noreturn) -#define ARROW_PREDICT_FALSE(x) x -#define ARROW_PREDICT_TRUE(x) x -#define ARROW_PREFETCH(addr) -#else -#define ARROW_NORETURN -#define ARROW_PREDICT_FALSE(x) x -#define ARROW_PREDICT_TRUE(x) x -#define ARROW_PREFETCH(addr) -#endif - -#if (defined(__GNUC__) || defined(__APPLE__)) -#define ARROW_MUST_USE_RESULT __attribute__((warn_unused_result)) -#elif defined(_MSC_VER) -#define ARROW_MUST_USE_RESULT -#else -#define ARROW_MUST_USE_RESULT -#endif - -// ---------------------------------------------------------------------- -// C++/CLI support macros (see ARROW-1134) - -#ifndef NULLPTR - -#ifdef __cplusplus_cli -#define NULLPTR __nullptr -#else -#define NULLPTR nullptr -#endif - -#endif // ifndef NULLPTR - -// ---------------------------------------------------------------------- - -// clang-format off -// [[deprecated]] is only available in C++14, use this for the time being -// This macro takes an optional deprecation message -#ifdef __COVERITY__ -# define ARROW_DEPRECATED(...) -#elif __cplusplus > 201103L -# define ARROW_DEPRECATED(...) [[deprecated(__VA_ARGS__)]] -#else -# ifdef __GNUC__ -# define ARROW_DEPRECATED(...) __attribute__((deprecated(__VA_ARGS__))) -# elif defined(_MSC_VER) -# define ARROW_DEPRECATED(...) __declspec(deprecated(__VA_ARGS__)) -# else -# define ARROW_DEPRECATED(...) -# endif -#endif - -// ---------------------------------------------------------------------- - -// macros to disable padding -// these macros are portable across different compilers and platforms -//[https://github.com/google/flatbuffers/blob/master/include/flatbuffers/flatbuffers.h#L1355] -#if !defined(MANUALLY_ALIGNED_STRUCT) -#if defined(_MSC_VER) -#define MANUALLY_ALIGNED_STRUCT(alignment) \ - __pragma(pack(1)); \ - struct __declspec(align(alignment)) -#define STRUCT_END(name, size) \ - __pragma(pack()); \ - static_assert(sizeof(name) == size, "compiler breaks packing rules") -#elif defined(__GNUC__) || defined(__clang__) -#define MANUALLY_ALIGNED_STRUCT(alignment) \ - _Pragma("pack(1)") struct __attribute__((aligned(alignment))) -#define STRUCT_END(name, size) \ - _Pragma("pack()") static_assert(sizeof(name) == size, "compiler breaks packing rules") -#else -#error Unknown compiler, please define structure alignment macros -#endif -#endif // !defined(MANUALLY_ALIGNED_STRUCT) - -// ---------------------------------------------------------------------- -// Convenience macro disabling a particular UBSan check in a function - -#if defined(__clang__) -#define ARROW_DISABLE_UBSAN(feature) __attribute__((no_sanitize(feature))) -#else -#define ARROW_DISABLE_UBSAN(feature) -#endif - -// ---------------------------------------------------------------------- -// Machine information - -#if INTPTR_MAX == INT64_MAX -#define ARROW_BITNESS 64 -#elif INTPTR_MAX == INT32_MAX -#define ARROW_BITNESS 32 -#else -#error Unexpected INTPTR_MAX -#endif - -// ---------------------------------------------------------------------- -// From googletest -// (also in parquet-cpp) - -// When you need to test the private or protected members of a class, -// use the FRIEND_TEST macro to declare your tests as friends of the -// class. For example: -// -// class MyClass { -// private: -// void MyMethod(); -// FRIEND_TEST(MyClassTest, MyMethod); -// }; -// -// class MyClassTest : public testing::Test { -// // ... -// }; -// -// TEST_F(MyClassTest, MyMethod) { -// // Can call MyClass::MyMethod() here. -// } - -#define FRIEND_TEST(test_case_name, test_name) \ - friend class test_case_name##_##test_name##_Test - -#endif // ARROW_UTIL_MACROS_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/memory.h b/cpp/thirdparty/knowhere_build/include/arrow/util/memory.h deleted file mode 100644 index 2d2a105921..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/memory.h +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_UTIL_MEMORY_H -#define ARROW_UTIL_MEMORY_H - -#include -#include - -#include "arrow/util/macros.h" - -namespace arrow { -namespace internal { - -// A helper function for doing memcpy with multiple threads. This is required -// to saturate the memory bandwidth of modern cpus. -void parallel_memcopy(uint8_t* dst, const uint8_t* src, int64_t nbytes, - uintptr_t block_size, int num_threads); - -// A helper function for checking if two wrapped objects implementing `Equals` -// are equal. -template -bool SharedPtrEquals(const std::shared_ptr& left, const std::shared_ptr& right) { - if (left == right) return true; - if (left == NULLPTR || right == NULLPTR) return false; - return left->Equals(*right); -} - -} // namespace internal -} // namespace arrow - -#endif // ARROW_UTIL_MEMORY_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/neon-util.h b/cpp/thirdparty/knowhere_build/include/arrow/util/neon-util.h deleted file mode 100644 index 714d2324f0..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/neon-util.h +++ /dev/null @@ -1,59 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -namespace arrow { - -#if defined(__aarch64__) || defined(__AARCH64__) -#ifdef __ARM_FEATURE_CRC32 -#define ARROW_HAVE_ARM_CRC -#include -#endif -#endif - -#if defined(__GNUC__) && defined(__linux__) && defined(ARROW_HAVE_ARM_CRC) - -#include -#include -#ifndef HWCAP_CRC32 -#define HWCAP_CRC32 (1 << 7) -#endif -static inline uint32_t crc32c_runtime_check(void) { - uint64_t auxv = getauxval(AT_HWCAP); - return (auxv & HWCAP_CRC32) != 0; -} - -static inline uint32_t ARMCE_crc32_u8(uint32_t crc, uint8_t v) { - return __crc32cb(crc, v); -} - -static inline uint32_t ARMCE_crc32_u16(uint32_t crc, uint16_t v) { - return __crc32ch(crc, v); -} - -static inline uint32_t ARMCE_crc32_u32(uint32_t crc, uint32_t v) { - return __crc32cw(crc, v); -} - -static inline uint32_t ARMCE_crc32_u64(uint32_t crc, uint64_t v) { - return __crc32cd(crc, v); -} - -#endif // defined(__GNUC__) && defined(__linux__) && defined(ARROW_HAVE_ARM_CRC) - -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/parallel.h b/cpp/thirdparty/knowhere_build/include/arrow/util/parallel.h deleted file mode 100644 index 8caba5f1f0..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/parallel.h +++ /dev/null @@ -1,95 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_UTIL_PARALLEL_H -#define ARROW_UTIL_PARALLEL_H - -#include -#include -#include -#include - -#include "arrow/status.h" -#include "arrow/util/thread-pool.h" - -namespace arrow { -namespace internal { - -// A parallelizer that takes a `Status(int)` function and calls it with -// arguments between 0 and `num_tasks - 1`, on an arbitrary number of threads. - -template -Status ParallelFor(int num_tasks, FUNCTION&& func) { - auto pool = internal::GetCpuThreadPool(); - std::vector> futures(num_tasks); - - for (int i = 0; i < num_tasks; ++i) { - futures[i] = pool->Submit(func, i); - } - auto st = Status::OK(); - for (auto& fut : futures) { - st &= fut.get(); - } - return st; -} - -// A variant of ParallelFor() with an explicit number of dedicated threads. -// In most cases it's more appropriate to use the 2-argument ParallelFor (above), -// or directly the global CPU thread pool (arrow/util/thread-pool.h). - -template -Status ParallelFor(int nthreads, int num_tasks, FUNCTION&& func) { - std::vector thread_pool; - thread_pool.reserve(nthreads); - std::atomic task_counter(0); - - std::mutex error_mtx; - bool error_occurred = false; - Status error; - - for (int thread_id = 0; thread_id < nthreads; ++thread_id) { - thread_pool.emplace_back( - [&num_tasks, &task_counter, &error, &error_occurred, &error_mtx, &func]() { - int task_id; - while (!error_occurred) { - task_id = task_counter.fetch_add(1); - if (task_id >= num_tasks) { - break; - } - Status s = func(task_id); - if (!s.ok()) { - std::lock_guard lock(error_mtx); - error_occurred = true; - error = s; - break; - } - } - }); - } - for (auto&& thread : thread_pool) { - thread.join(); - } - if (error_occurred) { - return error; - } - return Status::OK(); -} - -} // namespace internal -} // namespace arrow - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/parsing.h b/cpp/thirdparty/knowhere_build/include/arrow/util/parsing.h deleted file mode 100644 index 50ac0aa48d..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/parsing.h +++ /dev/null @@ -1,512 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// This is a private header for string-to-number parsing utilitiers - -#ifndef ARROW_UTIL_PARSING_H -#define ARROW_UTIL_PARSING_H - -#include -#include -#include -#include -#include -#include - -#include - -#include "arrow/type.h" -#include "arrow/type_traits.h" -#include "arrow/util/checked_cast.h" -#include "arrow/util/config.h" -#include "arrow/vendored/datetime.h" - -namespace arrow { -namespace internal { - -/// \brief A class providing conversion from strings to some Arrow data types -/// -/// Conversion is triggered by calling operator(). It returns true on -/// success, false on failure. -/// -/// The class may have a non-trivial construction cost in some cases, -/// so it's recommended to use a single instance many times, if doing bulk -/// conversion. Instances of this class are not guaranteed to be thread-safe. -/// -template -class StringConverter; - -template <> -class StringConverter { - public: - explicit StringConverter(const std::shared_ptr& = NULLPTR) {} - - using value_type = bool; - - bool operator()(const char* s, size_t length, value_type* out) { - if (length == 1) { - // "0" or "1"? - if (s[0] == '0') { - *out = false; - return true; - } - if (s[0] == '1') { - *out = true; - return true; - } - return false; - } - if (length == 4) { - // "true"? - *out = true; - return ((s[0] == 't' || s[0] == 'T') && (s[1] == 'r' || s[1] == 'R') && - (s[2] == 'u' || s[2] == 'U') && (s[3] == 'e' || s[3] == 'E')); - } - if (length == 5) { - // "false"? - *out = false; - return ((s[0] == 'f' || s[0] == 'F') && (s[1] == 'a' || s[1] == 'A') && - (s[2] == 'l' || s[2] == 'L') && (s[3] == 's' || s[3] == 'S') && - (s[4] == 'e' || s[4] == 'E')); - } - return false; - } -}; - -// Ideas for faster float parsing: -// - http://rapidjson.org/md_doc_internals.html#ParsingDouble -// - https://github.com/google/double-conversion [used here] -// - https://github.com/achan001/dtoa-fast - -template -class StringToFloatConverterMixin { - public: - using value_type = typename ARROW_TYPE::c_type; - - explicit StringToFloatConverterMixin(const std::shared_ptr& = NULLPTR) - : main_converter_(flags_, main_junk_value_, main_junk_value_, "inf", "nan"), - fallback_converter_(flags_, fallback_junk_value_, fallback_junk_value_, "inf", - "nan") {} - - bool operator()(const char* s, size_t length, value_type* out) { - value_type v; - // double-conversion doesn't give us an error flag but signals parse - // errors with sentinel values. Since a sentinel value can appear as - // legitimate input, we fallback on a second converter with a different - // sentinel to eliminate false errors. - TryConvert(main_converter_, s, length, &v); - if (ARROW_PREDICT_FALSE(v == static_cast(main_junk_value_))) { - TryConvert(fallback_converter_, s, length, &v); - if (ARROW_PREDICT_FALSE(v == static_cast(fallback_junk_value_))) { - return false; - } - } - *out = v; - return true; - } - - protected: -// This is only support in double-conversion 3.1+ -#ifdef DOUBLE_CONVERSION_HAS_CASE_INSENSIBILITY - static const int flags_ = - double_conversion::StringToDoubleConverter::ALLOW_CASE_INSENSIBILITY; -#else - static const int flags_ = double_conversion::StringToDoubleConverter::NO_FLAGS; -#endif - // Two unlikely values to signal a parsing error - static constexpr double main_junk_value_ = 0.7066424364107089; - static constexpr double fallback_junk_value_ = 0.40088499148279166; - - double_conversion::StringToDoubleConverter main_converter_; - double_conversion::StringToDoubleConverter fallback_converter_; - - inline void TryConvert(double_conversion::StringToDoubleConverter& converter, - const char* s, size_t length, float* out) { - int processed_length; - *out = converter.StringToFloat(s, static_cast(length), &processed_length); - } - - inline void TryConvert(double_conversion::StringToDoubleConverter& converter, - const char* s, size_t length, double* out) { - int processed_length; - *out = converter.StringToDouble(s, static_cast(length), &processed_length); - } -}; - -template <> -class StringConverter : public StringToFloatConverterMixin { - using StringToFloatConverterMixin::StringToFloatConverterMixin; -}; - -template <> -class StringConverter : public StringToFloatConverterMixin { - using StringToFloatConverterMixin::StringToFloatConverterMixin; -}; - -// NOTE: HalfFloatType would require a half<->float conversion library - -namespace detail { - -inline uint8_t ParseDecimalDigit(char c) { return static_cast(c - '0'); } - -#define PARSE_UNSIGNED_ITERATION(C_TYPE) \ - if (length > 0) { \ - uint8_t digit = ParseDecimalDigit(*s++); \ - result = static_cast(result * 10U); \ - length--; \ - if (ARROW_PREDICT_FALSE(digit > 9U)) { \ - /* Non-digit */ \ - return false; \ - } \ - result = static_cast(result + digit); \ - } - -#define PARSE_UNSIGNED_ITERATION_LAST(C_TYPE) \ - if (length > 0) { \ - if (ARROW_PREDICT_FALSE(result > std::numeric_limits::max() / 10U)) { \ - /* Overflow */ \ - return false; \ - } \ - uint8_t digit = ParseDecimalDigit(*s++); \ - result = static_cast(result * 10U); \ - C_TYPE new_result = static_cast(result + digit); \ - if (ARROW_PREDICT_FALSE(--length > 0)) { \ - /* Too many digits */ \ - return false; \ - } \ - if (ARROW_PREDICT_FALSE(digit > 9U)) { \ - /* Non-digit */ \ - return false; \ - } \ - if (ARROW_PREDICT_FALSE(new_result < result)) { \ - /* Overflow */ \ - return false; \ - } \ - result = new_result; \ - } - -inline bool ParseUnsigned(const char* s, size_t length, uint8_t* out) { - uint8_t result = 0; - - PARSE_UNSIGNED_ITERATION(uint8_t); - PARSE_UNSIGNED_ITERATION(uint8_t); - PARSE_UNSIGNED_ITERATION_LAST(uint8_t); - *out = result; - return true; -} - -inline bool ParseUnsigned(const char* s, size_t length, uint16_t* out) { - uint16_t result = 0; - - PARSE_UNSIGNED_ITERATION(uint16_t); - PARSE_UNSIGNED_ITERATION(uint16_t); - PARSE_UNSIGNED_ITERATION(uint16_t); - PARSE_UNSIGNED_ITERATION(uint16_t); - PARSE_UNSIGNED_ITERATION_LAST(uint16_t); - *out = result; - return true; -} - -inline bool ParseUnsigned(const char* s, size_t length, uint32_t* out) { - uint32_t result = 0; - - PARSE_UNSIGNED_ITERATION(uint32_t); - PARSE_UNSIGNED_ITERATION(uint32_t); - PARSE_UNSIGNED_ITERATION(uint32_t); - PARSE_UNSIGNED_ITERATION(uint32_t); - PARSE_UNSIGNED_ITERATION(uint32_t); - - PARSE_UNSIGNED_ITERATION(uint32_t); - PARSE_UNSIGNED_ITERATION(uint32_t); - PARSE_UNSIGNED_ITERATION(uint32_t); - PARSE_UNSIGNED_ITERATION(uint32_t); - - PARSE_UNSIGNED_ITERATION_LAST(uint32_t); - *out = result; - return true; -} - -inline bool ParseUnsigned(const char* s, size_t length, uint64_t* out) { - uint64_t result = 0; - - PARSE_UNSIGNED_ITERATION(uint64_t); - PARSE_UNSIGNED_ITERATION(uint64_t); - PARSE_UNSIGNED_ITERATION(uint64_t); - PARSE_UNSIGNED_ITERATION(uint64_t); - PARSE_UNSIGNED_ITERATION(uint64_t); - - PARSE_UNSIGNED_ITERATION(uint64_t); - PARSE_UNSIGNED_ITERATION(uint64_t); - PARSE_UNSIGNED_ITERATION(uint64_t); - PARSE_UNSIGNED_ITERATION(uint64_t); - PARSE_UNSIGNED_ITERATION(uint64_t); - - PARSE_UNSIGNED_ITERATION(uint64_t); - PARSE_UNSIGNED_ITERATION(uint64_t); - PARSE_UNSIGNED_ITERATION(uint64_t); - PARSE_UNSIGNED_ITERATION(uint64_t); - PARSE_UNSIGNED_ITERATION(uint64_t); - - PARSE_UNSIGNED_ITERATION(uint64_t); - PARSE_UNSIGNED_ITERATION(uint64_t); - PARSE_UNSIGNED_ITERATION(uint64_t); - PARSE_UNSIGNED_ITERATION(uint64_t); - - PARSE_UNSIGNED_ITERATION_LAST(uint64_t); - *out = result; - return true; -} - -#undef PARSE_UNSIGNED_ITERATION -#undef PARSE_UNSIGNED_ITERATION_LAST - -} // namespace detail - -template -class StringToUnsignedIntConverterMixin { - public: - using value_type = typename ARROW_TYPE::c_type; - - explicit StringToUnsignedIntConverterMixin(const std::shared_ptr& = NULLPTR) { - } - - bool operator()(const char* s, size_t length, value_type* out) { - if (ARROW_PREDICT_FALSE(length == 0)) { - return false; - } - // Skip leading zeros - while (length > 0 && *s == '0') { - length--; - s++; - } - return detail::ParseUnsigned(s, length, out); - } -}; - -template <> -class StringConverter : public StringToUnsignedIntConverterMixin { - using StringToUnsignedIntConverterMixin::StringToUnsignedIntConverterMixin; -}; - -template <> -class StringConverter : public StringToUnsignedIntConverterMixin { - using StringToUnsignedIntConverterMixin::StringToUnsignedIntConverterMixin; -}; - -template <> -class StringConverter : public StringToUnsignedIntConverterMixin { - using StringToUnsignedIntConverterMixin::StringToUnsignedIntConverterMixin; -}; - -template <> -class StringConverter : public StringToUnsignedIntConverterMixin { - using StringToUnsignedIntConverterMixin::StringToUnsignedIntConverterMixin; -}; - -template -class StringToSignedIntConverterMixin { - public: - using value_type = typename ARROW_TYPE::c_type; - using unsigned_type = typename std::make_unsigned::type; - - explicit StringToSignedIntConverterMixin(const std::shared_ptr& = NULLPTR) {} - - bool operator()(const char* s, size_t length, value_type* out) { - static constexpr unsigned_type max_positive = - static_cast(std::numeric_limits::max()); - // Assuming two's complement - static constexpr unsigned_type max_negative = max_positive + 1; - bool negative = false; - unsigned_type unsigned_value = 0; - - if (ARROW_PREDICT_FALSE(length == 0)) { - return false; - } - if (*s == '-') { - negative = true; - s++; - if (--length == 0) { - return false; - } - } - // Skip leading zeros - while (length > 0 && *s == '0') { - length--; - s++; - } - if (!ARROW_PREDICT_TRUE(detail::ParseUnsigned(s, length, &unsigned_value))) { - return false; - } - if (negative) { - if (ARROW_PREDICT_FALSE(unsigned_value > max_negative)) { - return false; - } - // To avoid both compiler warnings (with unsigned negation) - // and undefined behaviour (with signed negation overflow), - // use the expanded formula for 2's complement negation. - *out = static_cast(~unsigned_value + 1); - } else { - if (ARROW_PREDICT_FALSE(unsigned_value > max_positive)) { - return false; - } - *out = static_cast(unsigned_value); - } - return true; - } -}; - -template <> -class StringConverter : public StringToSignedIntConverterMixin { - using StringToSignedIntConverterMixin::StringToSignedIntConverterMixin; -}; - -template <> -class StringConverter : public StringToSignedIntConverterMixin { - using StringToSignedIntConverterMixin::StringToSignedIntConverterMixin; -}; - -template <> -class StringConverter : public StringToSignedIntConverterMixin { - using StringToSignedIntConverterMixin::StringToSignedIntConverterMixin; -}; - -template <> -class StringConverter : public StringToSignedIntConverterMixin { - using StringToSignedIntConverterMixin::StringToSignedIntConverterMixin; -}; - -template <> -class StringConverter { - public: - using value_type = TimestampType::c_type; - - explicit StringConverter(const std::shared_ptr& type) - : unit_(checked_cast(type.get())->unit()) {} - - bool operator()(const char* s, size_t length, value_type* out) { - // We allow the following formats: - // - "YYYY-MM-DD" - // - "YYYY-MM-DD[ T]hh:mm:ss" - // - "YYYY-MM-DD[ T]hh:mm:ssZ" - // UTC is always assumed, and the DataType's timezone is ignored. - arrow_vendored::date::year_month_day ymd; - if (ARROW_PREDICT_FALSE(length < 10)) { - return false; - } - if (length == 10) { - if (ARROW_PREDICT_FALSE(!ParseYYYY_MM_DD(s, &ymd))) { - return false; - } - return ConvertTimePoint(arrow_vendored::date::sys_days(ymd), out); - } - if (ARROW_PREDICT_FALSE(s[10] != ' ') && ARROW_PREDICT_FALSE(s[10] != 'T')) { - return false; - } - if (s[length - 1] == 'Z') { - --length; - } - if (length == 19) { - if (ARROW_PREDICT_FALSE(!ParseYYYY_MM_DD(s, &ymd))) { - return false; - } - std::chrono::duration seconds; - if (ARROW_PREDICT_FALSE(!ParseHH_MM_SS(s + 11, &seconds))) { - return false; - } - return ConvertTimePoint(arrow_vendored::date::sys_days(ymd) + seconds, out); - } - return false; - } - - protected: - template - bool ConvertTimePoint(TimePoint tp, value_type* out) { - auto duration = tp.time_since_epoch(); - switch (unit_) { - case TimeUnit::SECOND: - *out = std::chrono::duration_cast(duration).count(); - return true; - case TimeUnit::MILLI: - *out = std::chrono::duration_cast(duration).count(); - return true; - case TimeUnit::MICRO: - *out = std::chrono::duration_cast(duration).count(); - return true; - case TimeUnit::NANO: - *out = std::chrono::duration_cast(duration).count(); - return true; - } - // Unreachable, but suppress compiler warning - assert(0); - *out = 0; - return true; - } - - bool ParseYYYY_MM_DD(const char* s, arrow_vendored::date::year_month_day* out) { - uint16_t year; - uint8_t month, day; - if (ARROW_PREDICT_FALSE(s[4] != '-') || ARROW_PREDICT_FALSE(s[7] != '-')) { - return false; - } - if (ARROW_PREDICT_FALSE(!detail::ParseUnsigned(s + 0, 4, &year))) { - return false; - } - if (ARROW_PREDICT_FALSE(!detail::ParseUnsigned(s + 5, 2, &month))) { - return false; - } - if (ARROW_PREDICT_FALSE(!detail::ParseUnsigned(s + 8, 2, &day))) { - return false; - } - *out = {arrow_vendored::date::year{year}, arrow_vendored::date::month{month}, - arrow_vendored::date::day{day}}; - return out->ok(); - } - - bool ParseHH_MM_SS(const char* s, std::chrono::duration* out) { - uint8_t hours, minutes, seconds; - if (ARROW_PREDICT_FALSE(s[2] != ':') || ARROW_PREDICT_FALSE(s[5] != ':')) { - return false; - } - if (ARROW_PREDICT_FALSE(!detail::ParseUnsigned(s + 0, 2, &hours))) { - return false; - } - if (ARROW_PREDICT_FALSE(!detail::ParseUnsigned(s + 3, 2, &minutes))) { - return false; - } - if (ARROW_PREDICT_FALSE(!detail::ParseUnsigned(s + 6, 2, &seconds))) { - return false; - } - if (ARROW_PREDICT_FALSE(hours >= 24)) { - return false; - } - if (ARROW_PREDICT_FALSE(minutes >= 60)) { - return false; - } - if (ARROW_PREDICT_FALSE(seconds >= 60)) { - return false; - } - *out = std::chrono::duration(3600U * hours + 60U * minutes + seconds); - return true; - } - - const TimeUnit::type unit_; -}; - -} // namespace internal -} // namespace arrow - -#endif // ARROW_UTIL_PARSING_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/rle-encoding.h b/cpp/thirdparty/knowhere_build/include/arrow/util/rle-encoding.h deleted file mode 100644 index 739158a59a..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/rle-encoding.h +++ /dev/null @@ -1,604 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// Imported from Apache Impala (incubating) on 2016-01-29 and modified for use -// in parquet-cpp, Arrow - -#ifndef ARROW_UTIL_RLE_ENCODING_H -#define ARROW_UTIL_RLE_ENCODING_H - -#include -#include - -#include "arrow/util/bit-stream-utils.h" -#include "arrow/util/bit-util.h" -#include "arrow/util/macros.h" - -namespace arrow { -namespace util { - -/// Utility classes to do run length encoding (RLE) for fixed bit width values. If runs -/// are sufficiently long, RLE is used, otherwise, the values are just bit-packed -/// (literal encoding). -/// For both types of runs, there is a byte-aligned indicator which encodes the length -/// of the run and the type of the run. -/// This encoding has the benefit that when there aren't any long enough runs, values -/// are always decoded at fixed (can be precomputed) bit offsets OR both the value and -/// the run length are byte aligned. This allows for very efficient decoding -/// implementations. -/// The encoding is: -/// encoded-block := run* -/// run := literal-run | repeated-run -/// literal-run := literal-indicator < literal bytes > -/// repeated-run := repeated-indicator < repeated value. padded to byte boundary > -/// literal-indicator := varint_encode( number_of_groups << 1 | 1) -/// repeated-indicator := varint_encode( number_of_repetitions << 1 ) -// -/// Each run is preceded by a varint. The varint's least significant bit is -/// used to indicate whether the run is a literal run or a repeated run. The rest -/// of the varint is used to determine the length of the run (eg how many times the -/// value repeats). -// -/// In the case of literal runs, the run length is always a multiple of 8 (i.e. encode -/// in groups of 8), so that no matter the bit-width of the value, the sequence will end -/// on a byte boundary without padding. -/// Given that we know it is a multiple of 8, we store the number of 8-groups rather than -/// the actual number of encoded ints. (This means that the total number of encoded values -/// can not be determined from the encoded data, since the number of values in the last -/// group may not be a multiple of 8). For the last group of literal runs, we pad -/// the group to 8 with zeros. This allows for 8 at a time decoding on the read side -/// without the need for additional checks. -// -/// There is a break-even point when it is more storage efficient to do run length -/// encoding. For 1 bit-width values, that point is 8 values. They require 2 bytes -/// for both the repeated encoding or the literal encoding. This value can always -/// be computed based on the bit-width. -/// TODO: think about how to use this for strings. The bit packing isn't quite the same. -// -/// Examples with bit-width 1 (eg encoding booleans): -/// ---------------------------------------- -/// 100 1s followed by 100 0s: -/// <1, padded to 1 byte> <0, padded to 1 byte> -/// - (total 4 bytes) -// -/// alternating 1s and 0s (200 total): -/// 200 ints = 25 groups of 8 -/// <25 bytes of values, bitpacked> -/// (total 26 bytes, 1 byte overhead) -// - -/// Decoder class for RLE encoded data. -class RleDecoder { - public: - /// Create a decoder object. buffer/buffer_len is the decoded data. - /// bit_width is the width of each value (before encoding). - RleDecoder(const uint8_t* buffer, int buffer_len, int bit_width) - : bit_reader_(buffer, buffer_len), - bit_width_(bit_width), - current_value_(0), - repeat_count_(0), - literal_count_(0) { - DCHECK_GE(bit_width_, 0); - DCHECK_LE(bit_width_, 64); - } - - RleDecoder() : bit_width_(-1) {} - - void Reset(const uint8_t* buffer, int buffer_len, int bit_width) { - DCHECK_GE(bit_width, 0); - DCHECK_LE(bit_width, 64); - bit_reader_.Reset(buffer, buffer_len); - bit_width_ = bit_width; - current_value_ = 0; - repeat_count_ = 0; - literal_count_ = 0; - } - - /// Gets the next value. Returns false if there are no more. - template - bool Get(T* val); - - /// Gets a batch of values. Returns the number of decoded elements. - template - int GetBatch(T* values, int batch_size); - - /// Like GetBatch but the values are then decoded using the provided dictionary - template - int GetBatchWithDict(const T* dictionary, T* values, int batch_size); - - /// Like GetBatchWithDict but add spacing for null entries - template - int GetBatchWithDictSpaced(const T* dictionary, T* values, int batch_size, - int null_count, const uint8_t* valid_bits, - int64_t valid_bits_offset); - - protected: - BitUtil::BitReader bit_reader_; - /// Number of bits needed to encode the value. Must be between 0 and 64. - int bit_width_; - uint64_t current_value_; - uint32_t repeat_count_; - uint32_t literal_count_; - - private: - /// Fills literal_count_ and repeat_count_ with next values. Returns false if there - /// are no more. - template - bool NextCounts(); -}; - -/// Class to incrementally build the rle data. This class does not allocate any memory. -/// The encoding has two modes: encoding repeated runs and literal runs. -/// If the run is sufficiently short, it is more efficient to encode as a literal run. -/// This class does so by buffering 8 values at a time. If they are not all the same -/// they are added to the literal run. If they are the same, they are added to the -/// repeated run. When we switch modes, the previous run is flushed out. -class RleEncoder { - public: - /// buffer/buffer_len: preallocated output buffer. - /// bit_width: max number of bits for value. - /// TODO: consider adding a min_repeated_run_length so the caller can control - /// when values should be encoded as repeated runs. Currently this is derived - /// based on the bit_width, which can determine a storage optimal choice. - /// TODO: allow 0 bit_width (and have dict encoder use it) - RleEncoder(uint8_t* buffer, int buffer_len, int bit_width) - : bit_width_(bit_width), bit_writer_(buffer, buffer_len) { - DCHECK_GE(bit_width_, 0); - DCHECK_LE(bit_width_, 64); - max_run_byte_size_ = MinBufferSize(bit_width); - DCHECK_GE(buffer_len, max_run_byte_size_) << "Input buffer not big enough."; - Clear(); - } - - /// Returns the minimum buffer size needed to use the encoder for 'bit_width' - /// This is the maximum length of a single run for 'bit_width'. - /// It is not valid to pass a buffer less than this length. - static int MinBufferSize(int bit_width) { - /// 1 indicator byte and MAX_VALUES_PER_LITERAL_RUN 'bit_width' values. - int max_literal_run_size = - 1 + - static_cast(BitUtil::BytesForBits(MAX_VALUES_PER_LITERAL_RUN * bit_width)); - /// Up to MAX_VLQ_BYTE_LEN indicator and a single 'bit_width' value. - int max_repeated_run_size = BitUtil::BitReader::MAX_VLQ_BYTE_LEN + - static_cast(BitUtil::BytesForBits(bit_width)); - return std::max(max_literal_run_size, max_repeated_run_size); - } - - /// Returns the maximum byte size it could take to encode 'num_values'. - static int MaxBufferSize(int bit_width, int num_values) { - // For a bit_width > 1, the worst case is the repetition of "literal run of length 8 - // and then a repeated run of length 8". - // 8 values per smallest run, 8 bits per byte - int bytes_per_run = bit_width; - int num_runs = static_cast(BitUtil::CeilDiv(num_values, 8)); - int literal_max_size = num_runs + num_runs * bytes_per_run; - - // In the very worst case scenario, the data is a concatenation of repeated - // runs of 8 values. Repeated run has a 1 byte varint followed by the - // bit-packed repeated value - int min_repeated_run_size = 1 + static_cast(BitUtil::BytesForBits(bit_width)); - int repeated_max_size = - static_cast(BitUtil::CeilDiv(num_values, 8)) * min_repeated_run_size; - - return std::max(literal_max_size, repeated_max_size); - } - - /// Encode value. Returns true if the value fits in buffer, false otherwise. - /// This value must be representable with bit_width_ bits. - bool Put(uint64_t value); - - /// Flushes any pending values to the underlying buffer. - /// Returns the total number of bytes written - int Flush(); - - /// Resets all the state in the encoder. - void Clear(); - - /// Returns pointer to underlying buffer - uint8_t* buffer() { return bit_writer_.buffer(); } - int32_t len() { return bit_writer_.bytes_written(); } - - private: - /// Flushes any buffered values. If this is part of a repeated run, this is largely - /// a no-op. - /// If it is part of a literal run, this will call FlushLiteralRun, which writes - /// out the buffered literal values. - /// If 'done' is true, the current run would be written even if it would normally - /// have been buffered more. This should only be called at the end, when the - /// encoder has received all values even if it would normally continue to be - /// buffered. - void FlushBufferedValues(bool done); - - /// Flushes literal values to the underlying buffer. If update_indicator_byte, - /// then the current literal run is complete and the indicator byte is updated. - void FlushLiteralRun(bool update_indicator_byte); - - /// Flushes a repeated run to the underlying buffer. - void FlushRepeatedRun(); - - /// Checks and sets buffer_full_. This must be called after flushing a run to - /// make sure there are enough bytes remaining to encode the next run. - void CheckBufferFull(); - - /// The maximum number of values in a single literal run - /// (number of groups encodable by a 1-byte indicator * 8) - static const int MAX_VALUES_PER_LITERAL_RUN = (1 << 6) * 8; - - /// Number of bits needed to encode the value. Must be between 0 and 64. - const int bit_width_; - - /// Underlying buffer. - BitUtil::BitWriter bit_writer_; - - /// If true, the buffer is full and subsequent Put()'s will fail. - bool buffer_full_; - - /// The maximum byte size a single run can take. - int max_run_byte_size_; - - /// We need to buffer at most 8 values for literals. This happens when the - /// bit_width is 1 (so 8 values fit in one byte). - /// TODO: generalize this to other bit widths - int64_t buffered_values_[8]; - - /// Number of values in buffered_values_ - int num_buffered_values_; - - /// The current (also last) value that was written and the count of how - /// many times in a row that value has been seen. This is maintained even - /// if we are in a literal run. If the repeat_count_ get high enough, we switch - /// to encoding repeated runs. - uint64_t current_value_; - int repeat_count_; - - /// Number of literals in the current run. This does not include the literals - /// that might be in buffered_values_. Only after we've got a group big enough - /// can we decide if they should part of the literal_count_ or repeat_count_ - int literal_count_; - - /// Pointer to a byte in the underlying buffer that stores the indicator byte. - /// This is reserved as soon as we need a literal run but the value is written - /// when the literal run is complete. - uint8_t* literal_indicator_byte_; -}; - -template -inline bool RleDecoder::Get(T* val) { - return GetBatch(val, 1) == 1; -} - -template -inline int RleDecoder::GetBatch(T* values, int batch_size) { - DCHECK_GE(bit_width_, 0); - int values_read = 0; - - while (values_read < batch_size) { - if (repeat_count_ > 0) { - int repeat_batch = - std::min(batch_size - values_read, static_cast(repeat_count_)); - std::fill(values + values_read, values + values_read + repeat_batch, - static_cast(current_value_)); - repeat_count_ -= repeat_batch; - values_read += repeat_batch; - } else if (literal_count_ > 0) { - int literal_batch = - std::min(batch_size - values_read, static_cast(literal_count_)); - int actual_read = - bit_reader_.GetBatch(bit_width_, values + values_read, literal_batch); - DCHECK_EQ(actual_read, literal_batch); - literal_count_ -= literal_batch; - values_read += literal_batch; - } else { - if (!NextCounts()) return values_read; - } - } - - return values_read; -} - -template -inline int RleDecoder::GetBatchWithDict(const T* dictionary, T* values, int batch_size) { - DCHECK_GE(bit_width_, 0); - int values_read = 0; - - while (values_read < batch_size) { - if (repeat_count_ > 0) { - int repeat_batch = - std::min(batch_size - values_read, static_cast(repeat_count_)); - std::fill(values + values_read, values + values_read + repeat_batch, - dictionary[current_value_]); - repeat_count_ -= repeat_batch; - values_read += repeat_batch; - } else if (literal_count_ > 0) { - int literal_batch = - std::min(batch_size - values_read, static_cast(literal_count_)); - - const int buffer_size = 1024; - int indices[buffer_size]; - literal_batch = std::min(literal_batch, buffer_size); - int actual_read = bit_reader_.GetBatch(bit_width_, &indices[0], literal_batch); - DCHECK_EQ(actual_read, literal_batch); - for (int i = 0; i < literal_batch; ++i) { - values[values_read + i] = dictionary[indices[i]]; - } - literal_count_ -= literal_batch; - values_read += literal_batch; - } else { - if (!NextCounts()) return values_read; - } - } - - return values_read; -} - -template -inline int RleDecoder::GetBatchWithDictSpaced(const T* dictionary, T* values, - int batch_size, int null_count, - const uint8_t* valid_bits, - int64_t valid_bits_offset) { - DCHECK_GE(bit_width_, 0); - int values_read = 0; - int remaining_nulls = null_count; - - arrow::internal::BitmapReader bit_reader(valid_bits, valid_bits_offset, batch_size); - - while (values_read < batch_size) { - bool is_valid = bit_reader.IsSet(); - bit_reader.Next(); - - if (is_valid) { - if ((repeat_count_ == 0) && (literal_count_ == 0)) { - if (!NextCounts()) return values_read; - } - if (repeat_count_ > 0) { - T value = dictionary[current_value_]; - // The current index is already valid, we don't need to check that again - int repeat_batch = 1; - repeat_count_--; - - while (repeat_count_ > 0 && (values_read + repeat_batch) < batch_size) { - if (bit_reader.IsSet()) { - repeat_count_--; - } else { - remaining_nulls--; - } - repeat_batch++; - - bit_reader.Next(); - } - std::fill(values + values_read, values + values_read + repeat_batch, value); - values_read += repeat_batch; - } else if (literal_count_ > 0) { - int literal_batch = std::min(batch_size - values_read - remaining_nulls, - static_cast(literal_count_)); - - // Decode the literals - constexpr int kBufferSize = 1024; - int indices[kBufferSize]; - literal_batch = std::min(literal_batch, kBufferSize); - int actual_read = bit_reader_.GetBatch(bit_width_, &indices[0], literal_batch); - DCHECK_EQ(actual_read, literal_batch); - - int skipped = 0; - int literals_read = 1; - values[values_read] = dictionary[indices[0]]; - - // Read the first bitset to the end - while (literals_read < literal_batch) { - if (bit_reader.IsSet()) { - values[values_read + literals_read + skipped] = - dictionary[indices[literals_read]]; - literals_read++; - } else { - skipped++; - } - - bit_reader.Next(); - } - literal_count_ -= literal_batch; - values_read += literal_batch + skipped; - remaining_nulls -= skipped; - } - } else { - values_read++; - remaining_nulls--; - } - } - - return values_read; -} - -template -bool RleDecoder::NextCounts() { - // Read the next run's indicator int, it could be a literal or repeated run. - // The int is encoded as a vlq-encoded value. - int32_t indicator_value = 0; - bool result = bit_reader_.GetVlqInt(&indicator_value); - if (!result) return false; - - // lsb indicates if it is a literal run or repeated run - bool is_literal = indicator_value & 1; - if (is_literal) { - literal_count_ = (indicator_value >> 1) * 8; - } else { - repeat_count_ = indicator_value >> 1; - // XXX (ARROW-4018) this is not big-endian compatible - bool result = - bit_reader_.GetAligned(static_cast(BitUtil::CeilDiv(bit_width_, 8)), - reinterpret_cast(¤t_value_)); - DCHECK(result); - } - return true; -} - -/// This function buffers input values 8 at a time. After seeing all 8 values, -/// it decides whether they should be encoded as a literal or repeated run. -inline bool RleEncoder::Put(uint64_t value) { - DCHECK(bit_width_ == 64 || value < (1ULL << bit_width_)); - if (ARROW_PREDICT_FALSE(buffer_full_)) return false; - - if (ARROW_PREDICT_TRUE(current_value_ == value)) { - ++repeat_count_; - if (repeat_count_ > 8) { - // This is just a continuation of the current run, no need to buffer the - // values. - // Note that this is the fast path for long repeated runs. - return true; - } - } else { - if (repeat_count_ >= 8) { - // We had a run that was long enough but it has ended. Flush the - // current repeated run. - DCHECK_EQ(literal_count_, 0); - FlushRepeatedRun(); - } - repeat_count_ = 1; - current_value_ = value; - } - - buffered_values_[num_buffered_values_] = value; - if (++num_buffered_values_ == 8) { - DCHECK_EQ(literal_count_ % 8, 0); - FlushBufferedValues(false); - } - return true; -} - -inline void RleEncoder::FlushLiteralRun(bool update_indicator_byte) { - if (literal_indicator_byte_ == NULL) { - // The literal indicator byte has not been reserved yet, get one now. - literal_indicator_byte_ = bit_writer_.GetNextBytePtr(); - DCHECK(literal_indicator_byte_ != NULL); - } - - // Write all the buffered values as bit packed literals - for (int i = 0; i < num_buffered_values_; ++i) { - bool success = bit_writer_.PutValue(buffered_values_[i], bit_width_); - DCHECK(success) << "There is a bug in using CheckBufferFull()"; - } - num_buffered_values_ = 0; - - if (update_indicator_byte) { - // At this point we need to write the indicator byte for the literal run. - // We only reserve one byte, to allow for streaming writes of literal values. - // The logic makes sure we flush literal runs often enough to not overrun - // the 1 byte. - DCHECK_EQ(literal_count_ % 8, 0); - int num_groups = literal_count_ / 8; - int32_t indicator_value = (num_groups << 1) | 1; - DCHECK_EQ(indicator_value & 0xFFFFFF00, 0); - *literal_indicator_byte_ = static_cast(indicator_value); - literal_indicator_byte_ = NULL; - literal_count_ = 0; - CheckBufferFull(); - } -} - -inline void RleEncoder::FlushRepeatedRun() { - DCHECK_GT(repeat_count_, 0); - bool result = true; - // The lsb of 0 indicates this is a repeated run - int32_t indicator_value = repeat_count_ << 1 | 0; - result &= bit_writer_.PutVlqInt(indicator_value); - result &= bit_writer_.PutAligned(current_value_, - static_cast(BitUtil::CeilDiv(bit_width_, 8))); - DCHECK(result); - num_buffered_values_ = 0; - repeat_count_ = 0; - CheckBufferFull(); -} - -/// Flush the values that have been buffered. At this point we decide whether -/// we need to switch between the run types or continue the current one. -inline void RleEncoder::FlushBufferedValues(bool done) { - if (repeat_count_ >= 8) { - // Clear the buffered values. They are part of the repeated run now and we - // don't want to flush them out as literals. - num_buffered_values_ = 0; - if (literal_count_ != 0) { - // There was a current literal run. All the values in it have been flushed - // but we still need to update the indicator byte. - DCHECK_EQ(literal_count_ % 8, 0); - DCHECK_EQ(repeat_count_, 8); - FlushLiteralRun(true); - } - DCHECK_EQ(literal_count_, 0); - return; - } - - literal_count_ += num_buffered_values_; - DCHECK_EQ(literal_count_ % 8, 0); - int num_groups = literal_count_ / 8; - if (num_groups + 1 >= (1 << 6)) { - // We need to start a new literal run because the indicator byte we've reserved - // cannot store more values. - DCHECK(literal_indicator_byte_ != NULL); - FlushLiteralRun(true); - } else { - FlushLiteralRun(done); - } - repeat_count_ = 0; -} - -inline int RleEncoder::Flush() { - if (literal_count_ > 0 || repeat_count_ > 0 || num_buffered_values_ > 0) { - bool all_repeat = literal_count_ == 0 && (repeat_count_ == num_buffered_values_ || - num_buffered_values_ == 0); - // There is something pending, figure out if it's a repeated or literal run - if (repeat_count_ > 0 && all_repeat) { - FlushRepeatedRun(); - } else { - DCHECK_EQ(literal_count_ % 8, 0); - // Buffer the last group of literals to 8 by padding with 0s. - for (; num_buffered_values_ != 0 && num_buffered_values_ < 8; - ++num_buffered_values_) { - buffered_values_[num_buffered_values_] = 0; - } - literal_count_ += num_buffered_values_; - FlushLiteralRun(true); - repeat_count_ = 0; - } - } - bit_writer_.Flush(); - DCHECK_EQ(num_buffered_values_, 0); - DCHECK_EQ(literal_count_, 0); - DCHECK_EQ(repeat_count_, 0); - - return bit_writer_.bytes_written(); -} - -inline void RleEncoder::CheckBufferFull() { - int bytes_written = bit_writer_.bytes_written(); - if (bytes_written + max_run_byte_size_ > bit_writer_.buffer_len()) { - buffer_full_ = true; - } -} - -inline void RleEncoder::Clear() { - buffer_full_ = false; - current_value_ = 0; - repeat_count_ = 0; - num_buffered_values_ = 0; - literal_count_ = 0; - literal_indicator_byte_ = NULL; - bit_writer_.Clear(); -} - -} // namespace util -} // namespace arrow - -#endif // ARROW_UTIL_RLE_ENCODING_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/sse-util.h b/cpp/thirdparty/knowhere_build/include/arrow/util/sse-util.h deleted file mode 100644 index 6f451fd0ef..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/sse-util.h +++ /dev/null @@ -1,122 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// From Apache Impala as of 2016-01-29. Pared down to a minimal set of -// functions needed for parquet-cpp - -#pragma once - -#include "arrow/util/macros.h" - -#ifdef ARROW_USE_SIMD - -// MSVC x86-64 - -#if (defined(_M_AMD64) || defined(_M_X64)) -#define ARROW_HAVE_SSE2 1 -#define ARROW_HAVE_SSE4_2 1 -#include -#endif - -// gcc/clang (possibly others) - -#if defined(__SSE2__) -#define ARROW_HAVE_SSE2 1 -#include -#endif - -#if defined(__SSE4_2__) -#define ARROW_HAVE_SSE4_2 1 -#include -#endif - -#endif // ARROW_USE_SIMD - -// MSVC x86-64 - -namespace arrow { - -/// This class contains constants useful for text processing with SSE4.2 intrinsics. -namespace SSEUtil { -/// Number of characters that fit in 64/128 bit register. SSE provides instructions -/// for loading 64 or 128 bits into a register at a time. -static const int CHARS_PER_64_BIT_REGISTER = 8; -static const int CHARS_PER_128_BIT_REGISTER = 16; - -/// SSE4.2 adds instructions for text processing. The instructions have a control -/// byte that determines some of functionality of the instruction. (Equivalent to -/// GCC's _SIDD_CMP_EQUAL_ANY, etc). -static const int PCMPSTR_EQUAL_ANY = 0x00; // strchr -static const int PCMPSTR_EQUAL_EACH = 0x08; // strcmp -static const int PCMPSTR_UBYTE_OPS = 0x00; // unsigned char (8-bits, rather than 16) -static const int PCMPSTR_NEG_POLARITY = 0x10; // see Intel SDM chapter 4.1.4. - -/// In this mode, SSE text processing functions will return a mask of all the -/// characters that matched. -static const int STRCHR_MODE = PCMPSTR_EQUAL_ANY | PCMPSTR_UBYTE_OPS; - -/// In this mode, SSE text processing functions will return the number of -/// bytes that match consecutively from the beginning. -static const int STRCMP_MODE = - PCMPSTR_EQUAL_EACH | PCMPSTR_UBYTE_OPS | PCMPSTR_NEG_POLARITY; - -/// Precomputed mask values up to 16 bits. -static const int SSE_BITMASK[CHARS_PER_128_BIT_REGISTER] = { - 1 << 0, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7, - 1 << 8, 1 << 9, 1 << 10, 1 << 11, 1 << 12, 1 << 13, 1 << 14, 1 << 15, -}; -} // namespace SSEUtil - -#ifdef ARROW_HAVE_SSE4_2 - -/// Define the SSE 4.2 intrinsics. The caller must first verify at runtime (or codegen -/// IR load time) that the processor supports SSE 4.2 before calling these. These are -/// defined outside the namespace because the IR w/ SSE 4.2 case needs to use macros. - -template -static inline __m128i SSE4_cmpestrm(__m128i str1, int len1, __m128i str2, int len2) { - return _mm_cmpestrm(str1, len1, str2, len2, MODE); -} - -template -static inline int SSE4_cmpestri(__m128i str1, int len1, __m128i str2, int len2) { - return _mm_cmpestri(str1, len1, str2, len2, MODE); -} - -static inline uint32_t SSE4_crc32_u8(uint32_t crc, uint8_t v) { - return _mm_crc32_u8(crc, v); -} - -static inline uint32_t SSE4_crc32_u16(uint32_t crc, uint16_t v) { - return _mm_crc32_u16(crc, v); -} - -static inline uint32_t SSE4_crc32_u32(uint32_t crc, uint32_t v) { - return _mm_crc32_u32(crc, v); -} - -static inline uint32_t SSE4_crc32_u64(uint32_t crc, uint64_t v) { -#if ARROW_BITNESS == 32 - return 0; -#else - return static_cast(_mm_crc32_u64(crc, v)); -#endif -} - -#endif // ARROW_HAVE_SSE4_2 - -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/stl.h b/cpp/thirdparty/knowhere_build/include/arrow/util/stl.h deleted file mode 100644 index 48898140bf..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/stl.h +++ /dev/null @@ -1,95 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_UTIL_STL_H -#define ARROW_UTIL_STL_H - -#include -#include -#include -#include - -#include "arrow/util/logging.h" - -namespace arrow { -namespace internal { - -template -typename std::enable_if::value, std::unique_ptr>::type make_unique( - A&&... args) { - return std::unique_ptr(new T(std::forward(args)...)); -} - -template -typename std::enable_if::value && std::extent::value == 0, - std::unique_ptr>::type -make_unique(std::size_t n) { - using value_type = typename std::remove_extent::type; - return std::unique_ptr(new value_type[n]); -} - -template -inline std::vector DeleteVectorElement(const std::vector& values, size_t index) { - DCHECK(!values.empty()); - DCHECK_LT(index, values.size()); - std::vector out; - out.reserve(values.size() - 1); - for (size_t i = 0; i < index; ++i) { - out.push_back(values[i]); - } - for (size_t i = index + 1; i < values.size(); ++i) { - out.push_back(values[i]); - } - return out; -} - -template -inline std::vector AddVectorElement(const std::vector& values, size_t index, - const T& new_element) { - DCHECK_LE(index, values.size()); - std::vector out; - out.reserve(values.size() + 1); - for (size_t i = 0; i < index; ++i) { - out.push_back(values[i]); - } - out.push_back(new_element); - for (size_t i = index; i < values.size(); ++i) { - out.push_back(values[i]); - } - return out; -} - -template -inline std::vector ReplaceVectorElement(const std::vector& values, size_t index, - const T& new_element) { - DCHECK_LE(index, values.size()); - std::vector out; - out.reserve(values.size()); - for (size_t i = 0; i < index; ++i) { - out.push_back(values[i]); - } - out.push_back(new_element); - for (size_t i = index + 1; i < values.size(); ++i) { - out.push_back(values[i]); - } - return out; -} - -} // namespace internal -} // namespace arrow - -#endif // ARROW_UTIL_STL_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/stopwatch.h b/cpp/thirdparty/knowhere_build/include/arrow/util/stopwatch.h deleted file mode 100644 index db4e67f59e..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/stopwatch.h +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include - -namespace arrow { -namespace internal { - -class StopWatch { - // This clock should give us wall clock time - using ClockType = std::chrono::steady_clock; - - public: - StopWatch() {} - - void Start() { start_ = ClockType::now(); } - - // Returns time in nanoseconds. - uint64_t Stop() { - auto stop = ClockType::now(); - std::chrono::nanoseconds d = stop - start_; - assert(d.count() >= 0); - return static_cast(d.count()); - } - - private: - std::chrono::time_point start_; -}; - -} // namespace internal -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/string.h b/cpp/thirdparty/knowhere_build/include/arrow/util/string.h deleted file mode 100644 index 1d716c5a15..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/string.h +++ /dev/null @@ -1,68 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_UTIL_STRING_UTIL_H -#define ARROW_UTIL_STRING_UTIL_H - -#include -#include - -#include "arrow/status.h" -#include "arrow/util/string_view.h" - -namespace arrow { - -static const char* kAsciiTable = "0123456789ABCDEF"; - -static inline std::string HexEncode(const uint8_t* data, size_t length) { - std::string hex_string; - hex_string.reserve(length * 2); - for (size_t j = 0; j < length; ++j) { - // Convert to 2 base16 digits - hex_string.push_back(kAsciiTable[data[j] >> 4]); - hex_string.push_back(kAsciiTable[data[j] & 15]); - } - return hex_string; -} - -static inline std::string HexEncode(const char* data, size_t length) { - return HexEncode(reinterpret_cast(data), length); -} - -static inline std::string HexEncode(util::string_view str) { - return HexEncode(str.data(), str.size()); -} - -static inline Status ParseHexValue(const char* data, uint8_t* out) { - char c1 = data[0]; - char c2 = data[1]; - - const char* pos1 = std::lower_bound(kAsciiTable, kAsciiTable + 16, c1); - const char* pos2 = std::lower_bound(kAsciiTable, kAsciiTable + 16, c2); - - // Error checking - if (*pos1 != c1 || *pos2 != c2) { - return Status::Invalid("Encountered non-hex digit"); - } - - *out = static_cast((pos1 - kAsciiTable) << 4 | (pos2 - kAsciiTable)); - return Status::OK(); -} - -} // namespace arrow - -#endif // ARROW_UTIL_STRING_UTIL_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/string_builder.h b/cpp/thirdparty/knowhere_build/include/arrow/util/string_builder.h deleted file mode 100644 index 9129f12c68..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/string_builder.h +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. template - -#ifndef ARROW_UTIL_STRING_BUILDER_H -#define ARROW_UTIL_STRING_BUILDER_H - -#include -#include -#include -#include - -#include "arrow/util/visibility.h" - -namespace arrow { -namespace util { - -namespace detail { - -class ARROW_EXPORT StringStreamWrapper { - public: - StringStreamWrapper(); - ~StringStreamWrapper(); - - std::ostream& stream() { return ostream_; } - std::string str(); - - protected: - std::unique_ptr sstream_; - std::ostream& ostream_; -}; - -} // namespace detail - -template -void StringBuilderRecursive(std::ostream& stream, Head&& head) { - stream << head; -} - -template -void StringBuilderRecursive(std::ostream& stream, Head&& head, Tail&&... tail) { - StringBuilderRecursive(stream, std::forward(head)); - StringBuilderRecursive(stream, std::forward(tail)...); -} - -template -std::string StringBuilder(Args&&... args) { - detail::StringStreamWrapper ss; - StringBuilderRecursive(ss.stream(), std::forward(args)...); - return ss.str(); -} - -} // namespace util -} // namespace arrow - -#endif // ARROW_UTIL_STRING_BUILDER_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/string_view.h b/cpp/thirdparty/knowhere_build/include/arrow/util/string_view.h deleted file mode 100644 index 88748429b7..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/string_view.h +++ /dev/null @@ -1,33 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_UTIL_STRING_VIEW_H -#define ARROW_UTIL_STRING_VIEW_H - -#define nssv_CONFIG_SELECT_STRING_VIEW nssv_STRING_VIEW_NONSTD - -#include "arrow/vendored/string_view.hpp" // IWYU pragma: export - -namespace arrow { -namespace util { - -using nonstd::string_view; - -} // namespace util -} // namespace arrow - -#endif // ARROW_UTIL_STRING_VIEW_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/task-group.h b/cpp/thirdparty/knowhere_build/include/arrow/util/task-group.h deleted file mode 100644 index 390d9476e5..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/task-group.h +++ /dev/null @@ -1,91 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_UTIL_TASK_GROUP_H -#define ARROW_UTIL_TASK_GROUP_H - -#include -#include -#include - -#include "arrow/status.h" -#include "arrow/util/macros.h" -#include "arrow/util/visibility.h" - -namespace arrow { -namespace internal { - -class ThreadPool; - -// TODO Simplify this. Subgroups don't seem necessary. - -/// \brief A group of related tasks -/// -/// A TaskGroup executes tasks with the signature `Status()`. -/// Execution can be serial or parallel, depending on the TaskGroup -/// implementation. When Finish() returns, it is guaranteed that all -/// tasks have finished, or at least one has errored. -/// -class ARROW_EXPORT TaskGroup { - public: - /// Add a Status-returning function to execute. Execution order is - /// undefined. The function may be executed immediately or later. - template - void Append(Function&& func) { - return AppendReal(std::forward(func)); - } - - /// Wait for execution of all tasks (and subgroups) to be finished, - /// or for at least one task (or subgroup) to error out. - /// The returned Status propagates the error status of the first failing - /// task (or subgroup). - virtual Status Finish() = 0; - - /// The current agregate error Status. Non-blocking, useful for stopping early. - virtual Status current_status() = 0; - - /// Whether some tasks have already failed. Non-blocking , useful for stopping early. - virtual bool ok() = 0; - - /// How many tasks can typically be executed in parallel. - /// This is only a hint, useful for testing or debugging. - virtual int parallelism() = 0; - - /// Create a subgroup of this group. This group can only finish - /// when all subgroups have finished (this means you must be - /// be careful to call Finish() on subgroups before calling it - /// on the main group). - // XXX if a subgroup errors out, should it propagate immediately to the parent - // and to children? - virtual std::shared_ptr MakeSubGroup() = 0; - - static std::shared_ptr MakeSerial(); - static std::shared_ptr MakeThreaded(internal::ThreadPool*); - - virtual ~TaskGroup() = default; - - protected: - TaskGroup() = default; - ARROW_DISALLOW_COPY_AND_ASSIGN(TaskGroup); - - virtual void AppendReal(std::function task) = 0; -}; - -} // namespace internal -} // namespace arrow - -#endif // ARROW_UTIL_TASK_GROUP_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/thread-pool.h b/cpp/thirdparty/knowhere_build/include/arrow/util/thread-pool.h deleted file mode 100644 index 2de212e64c..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/thread-pool.h +++ /dev/null @@ -1,169 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_UTIL_THREAD_POOL_H -#define ARROW_UTIL_THREAD_POOL_H - -#ifndef _WIN32 -#include -#endif - -#include -#include -#include -#include -#include -#include -#include - -#include "arrow/status.h" -#include "arrow/util/macros.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -/// \brief Get the capacity of the global thread pool -/// -/// Return the number of worker threads in the thread pool to which -/// Arrow dispatches various CPU-bound tasks. This is an ideal number, -/// not necessarily the exact number of threads at a given point in time. -/// -/// You can change this number using SetCpuThreadPoolCapacity(). -ARROW_EXPORT int GetCpuThreadPoolCapacity(); - -/// \brief Set the capacity of the global thread pool -/// -/// Set the number of worker threads int the thread pool to which -/// Arrow dispatches various CPU-bound tasks. -/// -/// The current number is returned by GetCpuThreadPoolCapacity(). -ARROW_EXPORT Status SetCpuThreadPoolCapacity(int threads); - -namespace internal { - -namespace detail { - -// Needed because std::packaged_task is not copyable and hence not convertible -// to std::function. -template -struct packaged_task_wrapper { - using PackagedTask = std::packaged_task; - - explicit packaged_task_wrapper(PackagedTask&& task) - : task_(std::make_shared(std::forward(task))) {} - - void operator()(Args&&... args) { return (*task_)(std::forward(args)...); } - std::shared_ptr task_; -}; - -} // namespace detail - -class ARROW_EXPORT ThreadPool { - public: - // Construct a thread pool with the given number of worker threads - static Status Make(int threads, std::shared_ptr* out); - - // Destroy thread pool; the pool will first be shut down - ~ThreadPool(); - - // Return the desired number of worker threads. - // The actual number of workers may lag a bit before being adjusted to - // match this value. - int GetCapacity(); - - // Dynamically change the number of worker threads. - // This function returns quickly, but it may take more time before the - // thread count is fully adjusted. - Status SetCapacity(int threads); - - // Heuristic for the default capacity of a thread pool for CPU-bound tasks. - // This is exposed as a static method to help with testing. - static int DefaultCapacity(); - - // Shutdown the pool. Once the pool starts shutting down, new tasks - // cannot be submitted anymore. - // If "wait" is true, shutdown waits for all pending tasks to be finished. - // If "wait" is false, workers are stopped as soon as currently executing - // tasks are finished. - Status Shutdown(bool wait = true); - - // Spawn a fire-and-forget task on one of the workers. - template - Status Spawn(Function&& func) { - return SpawnReal(std::forward(func)); - } - - // Submit a callable and arguments for execution. Return a future that - // will return the callable's result value once. - // The callable's arguments are copied before execution. - // Since the function is variadic and needs to return a result (the future), - // an exception is raised if the task fails spawning (which currently - // only occurs if the ThreadPool is shutting down). - template ::type> - std::future Submit(Function&& func, Args&&... args) { - // Trying to templatize std::packaged_task with Function doesn't seem - // to work, so go through std::bind to simplify the packaged signature - using PackagedTask = std::packaged_task; - auto task = PackagedTask(std::bind(std::forward(func), args...)); - auto fut = task.get_future(); - - Status st = SpawnReal(detail::packaged_task_wrapper(std::move(task))); - if (!st.ok()) { - st.Abort("ThreadPool::Submit() was probably called after Shutdown()"); - } - return fut; - } - - struct State; - - protected: - FRIEND_TEST(TestThreadPool, SetCapacity); - FRIEND_TEST(TestGlobalThreadPool, Capacity); - friend ARROW_EXPORT ThreadPool* GetCpuThreadPool(); - - ThreadPool(); - - ARROW_DISALLOW_COPY_AND_ASSIGN(ThreadPool); - - Status SpawnReal(std::function task); - // Collect finished worker threads, making sure the OS threads have exited - void CollectFinishedWorkersUnlocked(); - // Launch a given number of additional workers - void LaunchWorkersUnlocked(int threads); - // Get the current actual capacity - int GetActualCapacity(); - // Reinitialize the thread pool if the pid changed - void ProtectAgainstFork(); - - static std::shared_ptr MakeCpuThreadPool(); - - std::shared_ptr sp_state_; - State* state_; - bool shutdown_on_destroy_; -#ifndef _WIN32 - pid_t pid_; -#endif -}; - -// Return the process-global thread pool for CPU-bound tasks. -ARROW_EXPORT ThreadPool* GetCpuThreadPool(); - -} // namespace internal -} // namespace arrow - -#endif // ARROW_UTIL_THREAD_POOL_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/trie.h b/cpp/thirdparty/knowhere_build/include/arrow/util/trie.h deleted file mode 100644 index 3e82bfd8ee..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/trie.h +++ /dev/null @@ -1,245 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_UTIL_TRIE_H -#define ARROW_UTIL_TRIE_H - -#include -#include -#include -#include -#include -#include -#include - -#include "arrow/status.h" -#include "arrow/util/macros.h" -#include "arrow/util/string_view.h" -#include "arrow/util/visibility.h" - -namespace arrow { -namespace internal { - -// A non-zero-terminated small string class. -// std::string usually has a small string optimization -// (see review at https://shaharmike.com/cpp/std-string/) -// but this one allows tight control and optimization of memory layout. -template -class SmallString { - public: - SmallString() : length_(0) {} - - template - SmallString(const T& v) { // NOLINT implicit constructor - *this = util::string_view(v); - } - - SmallString& operator=(const util::string_view s) { -#ifndef NDEBUG - CheckSize(s.size()); -#endif - length_ = static_cast(s.size()); - std::memcpy(data_, s.data(), length_); - return *this; - } - - SmallString& operator=(const std::string& s) { - *this = util::string_view(s); - return *this; - } - - SmallString& operator=(const char* s) { - *this = util::string_view(s); - return *this; - } - - explicit operator util::string_view() const { - return util::string_view(data_, length_); - } - - const char* data() const { return data_; } - size_t length() const { return length_; } - bool empty() const { return length_ == 0; } - char operator[](size_t pos) const { -#ifdef NDEBUG - assert(pos <= length_); -#endif - return data_[pos]; - } - - SmallString substr(size_t pos) const { - return SmallString(util::string_view(*this).substr(pos)); - } - - SmallString substr(size_t pos, size_t count) const { - return SmallString(util::string_view(*this).substr(pos, count)); - } - - template - bool operator==(T&& other) const { - return util::string_view(*this) == util::string_view(std::forward(other)); - } - - template - bool operator!=(T&& other) const { - return util::string_view(*this) != util::string_view(std::forward(other)); - } - - protected: - uint8_t length_; - char data_[N]; - -#ifndef NDEBUG - void CheckSize(size_t n) { assert(n <= N); } -#endif -}; - -template -std::ostream& operator<<(std::ostream& os, const SmallString& str) { - return os << util::string_view(str); -} - -// A trie class for byte strings, optimized for small sets of short strings. -// This class is immutable by design, use a TrieBuilder to construct it. -class ARROW_EXPORT Trie { - using index_type = int16_t; - using fast_index_type = int_fast16_t; - - public: - Trie() : size_(0) {} - Trie(Trie&&) = default; - Trie& operator=(Trie&&) = default; - - int32_t Find(util::string_view s) const { - const Node* node = &nodes_[0]; - fast_index_type pos = 0; - fast_index_type remaining = static_cast(s.length()); - - while (remaining > 0) { - auto substring_length = node->substring_length(); - if (substring_length > 0) { - auto substring_data = node->substring_data(); - if (remaining < substring_length) { - // Input too short - return -1; - } - for (fast_index_type i = 0; i < substring_length; ++i) { - if (s[pos++] != substring_data[i]) { - // Mismatching substring - return -1; - } - --remaining; - } - if (remaining == 0) { - // Matched node exactly - return node->found_index_; - } - } - // Lookup child using next input character - if (node->child_lookup_ == -1) { - // Input too long - return -1; - } - auto c = static_cast(s[pos++]); - --remaining; - auto child_index = lookup_table_[node->child_lookup_ * 256 + c]; - if (child_index == -1) { - // Child not found - return -1; - } - node = &nodes_[child_index]; - } - - // Input exhausted - if (node->substring_.empty()) { - // Matched node exactly - return node->found_index_; - } else { - return -1; - } - } - - Status Validate() const; - - void Dump() const; - - protected: - static constexpr size_t kNodeSize = 16; - static constexpr auto kMaxSubstringLength = - kNodeSize - 2 * sizeof(index_type) - sizeof(int8_t); - - struct Node { - // If this node is a valid end of string, index of found string, otherwise -1 - index_type found_index_; - // Base index for child lookup in lookup_table_ (-1 if no child nodes) - index_type child_lookup_; - // The substring for this node. - SmallString substring_; - - fast_index_type substring_length() const { - return static_cast(substring_.length()); - } - const char* substring_data() const { return substring_.data(); } - }; - - static_assert(sizeof(Node) == kNodeSize, "Unexpected node size"); - - ARROW_DISALLOW_COPY_AND_ASSIGN(Trie); - - void Dump(const Node* node, const std::string& indent) const; - - // Node table: entry 0 is the root node - std::vector nodes_; - - // Indexed lookup structure: gives index in node table, or -1 if not found - std::vector lookup_table_; - - // Number of entries - index_type size_; - - friend class TrieBuilder; -}; - -class ARROW_EXPORT TrieBuilder { - using index_type = Trie::index_type; - using fast_index_type = Trie::fast_index_type; - - public: - TrieBuilder(); - Status Append(util::string_view s, bool allow_duplicate = false); - Trie Finish(); - - protected: - // Extend the lookup table by 256 entries, return the index of the new span - Status ExtendLookupTable(index_type* out_lookup_index); - // Split the node given by the index at the substring index `split_at` - Status SplitNode(fast_index_type node_index, fast_index_type split_at); - // Append an already constructed child node to the parent - Status AppendChildNode(Trie::Node* parent, uint8_t ch, Trie::Node&& node); - // Create a matching child node from this parent - Status CreateChildNode(Trie::Node* parent, uint8_t ch, util::string_view substring); - Status CreateChildNode(Trie::Node* parent, char ch, util::string_view substring); - - Trie trie_; - - static constexpr auto kMaxIndex = std::numeric_limits::max(); -}; - -} // namespace internal -} // namespace arrow - -#endif // ARROW_UTIL_TRIE_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/type_traits.h b/cpp/thirdparty/knowhere_build/include/arrow/util/type_traits.h deleted file mode 100644 index 570f648678..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/type_traits.h +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_UTIL_TYPE_TRAITS_H -#define ARROW_UTIL_TYPE_TRAITS_H - -#include - -namespace arrow { -namespace internal { - -/// \brief Metafunction to allow checking if a type matches any of another set of types -template -struct IsOneOf : std::false_type {}; /// Base case: nothing has matched - -template -struct IsOneOf { - /// Recursive case: T == U or T matches any other types provided (not including U). - static constexpr bool value = std::is_same::value || IsOneOf::value; -}; - -/// \brief Shorthand for using IsOneOf + std::enable_if -template -using EnableIfIsOneOf = typename std::enable_if::value, T>::type; - -/// \brief is_null_pointer from C++17 -template -struct is_null_pointer : std::is_same::type> { -}; - -} // namespace internal -} // namespace arrow - -#endif // ARROW_UTIL_TYPE_TRAITS_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/ubsan.h b/cpp/thirdparty/knowhere_build/include/arrow/util/ubsan.h deleted file mode 100644 index f9fcfb5402..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/ubsan.h +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// Contains utilities for making UBSan happy. - -#pragma once - -#include - -#include "arrow/util/macros.h" - -namespace arrow { -namespace util { - -namespace internal { - -static uint8_t non_null_filler; - -} // namespace internal - -/// \brief Returns maybe_null if not null or a non-null pointer to an arbitrary memory -/// that shouldn't be dereferenced. -/// -/// Memset/Memcpy are undefinfed when a nullptr is passed as an argument use this utility -/// method to wrap locations where this could happen. -/// -/// Note: Flatbuffers has UBSan warnings if a zero length vector is passed. -/// https://github.com/google/flatbuffers/pull/5355 is trying to resolve them. -template -inline T* MakeNonNull(T* maybe_null) { - if (ARROW_PREDICT_TRUE(maybe_null != NULLPTR)) { - return maybe_null; - } - - return reinterpret_cast(&internal::non_null_filler); -} - -} // namespace util -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/uri.h b/cpp/thirdparty/knowhere_build/include/arrow/util/uri.h deleted file mode 100644 index ce082ccc8e..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/uri.h +++ /dev/null @@ -1,70 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include -#include -#include - -#include "arrow/status.h" -#include "arrow/util/visibility.h" - -namespace arrow { -namespace internal { - -/// \brief A parsed URI -class ARROW_EXPORT Uri { - public: - Uri(); - ~Uri(); - - // XXX Should we use util::string_view instead? These functions are - // not performance-critical. - - /// The URI scheme, such as "http", or the empty string if the URI has no - /// explicit scheme. - std::string scheme() const; - /// Whether the URI has an explicit host name. This may return true if - /// the URI has an empty host (e.g. "file:///tmp/foo"), while it returns - /// false is the URI has not host component at all (e.g. "file:/tmp/foo"). - bool has_host() const; - /// The URI host name, such as "localhost", "127.0.0.1" or "::1", or the empty - /// string is the URI does not have a host component. - std::string host() const; - /// The URI port number, as a string such as "80", or the empty string is the URI - /// does not have a port number component. - std::string port_text() const; - /// The URI port parsed as an integer, or -1 if the URI does not have a port - /// number component. - int32_t port() const; - /// The URI path component. - std::string path() const; - - /// Get the string representation of this URI. - const std::string& ToString() const; - - /// Factory function to parse a URI from its string representation. - Status Parse(const std::string& uri_string); - - private: - struct Impl; - std::unique_ptr impl_; -}; - -} // namespace internal -} // namespace arrow diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/utf8.h b/cpp/thirdparty/knowhere_build/include/arrow/util/utf8.h deleted file mode 100644 index af93705127..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/utf8.h +++ /dev/null @@ -1,184 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_UTIL_UTF8_H -#define ARROW_UTIL_UTF8_H - -#include -#include -#include -#include -#include - -#include "arrow/status.h" -#include "arrow/util/macros.h" -#include "arrow/util/string_view.h" -#include "arrow/util/visibility.h" - -namespace arrow { -namespace util { - -// Convert a UTF8 string to a wstring (either UTF16 or UTF32, depending -// on the wchar_t width). -ARROW_EXPORT Status UTF8ToWideString(const std::string& source, std::wstring* out); - -// Similarly, convert a wstring to a UTF8 string. -ARROW_EXPORT Status WideStringToUTF8(const std::wstring& source, std::string* out); - -namespace internal { - -// Copyright (c) 2008-2010 Bjoern Hoehrmann -// See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details. - -// A compact state table allowing UTF8 decoding using two dependent -// lookups per byte. The first lookup determines the character class -// and the second lookup reads the next state. -// In this table states are multiples of 12. -ARROW_EXPORT extern const uint8_t utf8_small_table[256 + 9 * 12]; - -// Success / reject states when looked up in the small table -static constexpr uint8_t kUTF8DecodeAccept = 0; -static constexpr uint8_t kUTF8DecodeReject = 12; - -// An expanded state table allowing transitions using a single lookup -// at the expense of a larger memory footprint (but on non-random data, -// not all the table will end up accessed and cached). -// In this table states are multiples of 256. -ARROW_EXPORT extern uint16_t utf8_large_table[9 * 256]; - -// Success / reject states when looked up in the large table -static constexpr uint16_t kUTF8ValidateAccept = 0; -static constexpr uint16_t kUTF8ValidateReject = 256; - -static inline uint8_t DecodeOneUTF8Byte(uint8_t byte, uint8_t state, uint32_t* codep) { - uint8_t type = utf8_small_table[byte]; - - *codep = (state != kUTF8DecodeAccept) ? (byte & 0x3fu) | (*codep << 6) - : (0xff >> type) & (byte); - - state = utf8_small_table[256 + state + type]; - return state; -} - -static inline uint16_t ValidateOneUTF8Byte(uint8_t byte, uint16_t state) { - return utf8_large_table[state + byte]; -} - -#ifndef NDEBUG -ARROW_EXPORT void CheckUTF8Initialized(); -#endif - -} // namespace internal - -// This function needs to be called before doing UTF8 validation. -ARROW_EXPORT void InitializeUTF8(); - -inline bool ValidateUTF8(const uint8_t* data, int64_t size) { - static constexpr uint64_t high_bits_64 = 0x8080808080808080ULL; - // For some reason, defining this variable outside the loop helps clang - uint64_t mask; - -#ifndef NDEBUG - internal::CheckUTF8Initialized(); -#endif - - while (size >= 8) { - // XXX This is doing an unaligned access. Contemporary architectures - // (x86-64, AArch64, PPC64) support it natively and often have good - // performance nevertheless. - memcpy(&mask, data, 8); - if (ARROW_PREDICT_TRUE((mask & high_bits_64) == 0)) { - // 8 bytes of pure ASCII, move forward - size -= 8; - data += 8; - continue; - } - // Non-ASCII run detected. - // We process at least 4 bytes, to avoid too many spurious 64-bit reads - // in case the non-ASCII bytes are at the end of the tested 64-bit word. - // We also only check for rejection at the end since that state is stable - // (once in reject state, we always remain in reject state). - // It is guaranteed that size >= 8 when arriving here, which allows - // us to avoid size checks. - uint16_t state = internal::kUTF8ValidateAccept; - // Byte 0 - state = internal::ValidateOneUTF8Byte(*data++, state); - --size; - // Byte 1 - state = internal::ValidateOneUTF8Byte(*data++, state); - --size; - // Byte 2 - state = internal::ValidateOneUTF8Byte(*data++, state); - --size; - // Byte 3 - state = internal::ValidateOneUTF8Byte(*data++, state); - --size; - // Byte 4 - state = internal::ValidateOneUTF8Byte(*data++, state); - --size; - if (state == internal::kUTF8ValidateAccept) { - continue; // Got full char, switch back to ASCII detection - } - // Byte 5 - state = internal::ValidateOneUTF8Byte(*data++, state); - --size; - if (state == internal::kUTF8ValidateAccept) { - continue; // Got full char, switch back to ASCII detection - } - // Byte 6 - state = internal::ValidateOneUTF8Byte(*data++, state); - --size; - if (state == internal::kUTF8ValidateAccept) { - continue; // Got full char, switch back to ASCII detection - } - // Byte 7 - state = internal::ValidateOneUTF8Byte(*data++, state); - --size; - if (state == internal::kUTF8ValidateAccept) { - continue; // Got full char, switch back to ASCII detection - } - // kUTF8ValidateAccept not reached along 4 transitions has to mean a rejection - assert(state == internal::kUTF8ValidateReject); - return false; - } - - // Validate string tail one byte at a time - // Note the state table is designed so that, once in the reject state, - // we remain in that state until the end. So we needn't check for - // rejection at each char (we don't gain much by short-circuiting here). - uint16_t state = internal::kUTF8ValidateAccept; - while (size-- > 0) { - state = internal::ValidateOneUTF8Byte(*data++, state); - } - return ARROW_PREDICT_TRUE(state == internal::kUTF8ValidateAccept); -} - -inline bool ValidateUTF8(const util::string_view& str) { - const uint8_t* data = reinterpret_cast(str.data()); - const size_t length = str.size(); - - return ValidateUTF8(data, length); -} - -// Skip UTF8 byte order mark, if any. -ARROW_EXPORT -Status SkipUTF8BOM(const uint8_t* data, int64_t size, const uint8_t** out); - -} // namespace util -} // namespace arrow - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/variant.h b/cpp/thirdparty/knowhere_build/include/arrow/util/variant.h deleted file mode 100644 index 0097c5afb2..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/variant.h +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_UTIL_VARIANT_H -#define ARROW_UTIL_VARIANT_H - -#include "arrow/vendored/variant.hpp" // IWYU pragma: export - -namespace arrow { -namespace util { - -using ::mpark::bad_variant_access; -using ::mpark::get; -using ::mpark::get_if; -using ::mpark::holds_alternative; -using ::mpark::variant; -using ::mpark::visit; - -} // namespace util -} // namespace arrow - -#endif // ARROW_UTIL_VARIANT_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/visibility.h b/cpp/thirdparty/knowhere_build/include/arrow/util/visibility.h deleted file mode 100644 index 95cd9cf5ba..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/visibility.h +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_UTIL_VISIBILITY_H -#define ARROW_UTIL_VISIBILITY_H - -#if defined(_WIN32) || defined(__CYGWIN__) -#if defined(_MSC_VER) -#pragma warning(disable : 4251) -#else -#pragma GCC diagnostic ignored "-Wattributes" -#endif - -#ifdef ARROW_STATIC -#define ARROW_EXPORT -#elif defined(ARROW_EXPORTING) -#define ARROW_EXPORT __declspec(dllexport) -#else -#define ARROW_EXPORT __declspec(dllimport) -#endif - -#define ARROW_NO_EXPORT -#else // Not Windows -#ifndef ARROW_EXPORT -#define ARROW_EXPORT __attribute__((visibility("default"))) -#endif -#ifndef ARROW_NO_EXPORT -#define ARROW_NO_EXPORT __attribute__((visibility("hidden"))) -#endif -#endif // Non-Windows - -#endif // ARROW_UTIL_VISIBILITY_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/util/windows_compatibility.h b/cpp/thirdparty/knowhere_build/include/arrow/util/windows_compatibility.h deleted file mode 100644 index 70c4313a54..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/util/windows_compatibility.h +++ /dev/null @@ -1,40 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#ifdef _WIN32 - -// Windows defines min and max macros that mess up std::min/max -#ifndef NOMINMAX -#define NOMINMAX -#endif - -#define WIN32_LEAN_AND_MEAN - -// Set Windows 7 as a conservative minimum for Apache Arrow -#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x601 -#undef _WIN32_WINNT -#endif -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x601 -#endif - -#include -#include - -#endif // _WIN32 diff --git a/cpp/thirdparty/knowhere_build/include/arrow/vendored/datetime.h b/cpp/thirdparty/knowhere_build/include/arrow/vendored/datetime.h deleted file mode 100644 index 424313a5f5..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/vendored/datetime.h +++ /dev/null @@ -1,21 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include "arrow/vendored/datetime/date.h" -#include "arrow/vendored/datetime/tz.h" diff --git a/cpp/thirdparty/knowhere_build/include/arrow/vendored/datetime/date.h b/cpp/thirdparty/knowhere_build/include/arrow/vendored/datetime/date.h deleted file mode 100644 index 02a4909132..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/vendored/datetime/date.h +++ /dev/null @@ -1,7944 +0,0 @@ -#ifndef DATE_H -#define DATE_H - -// The MIT License (MIT) -// -// Copyright (c) 2015, 2016, 2017 Howard Hinnant -// Copyright (c) 2016 Adrian Colomitchi -// Copyright (c) 2017 Florian Dang -// Copyright (c) 2017 Paul Thompson -// Copyright (c) 2018, 2019 Tomasz Kamiński -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -// -// Our apologies. When the previous paragraph was written, lowercase had not yet -// been invented (that would involve another several millennia of evolution). -// We did not mean to shout. - -#ifndef HAS_STRING_VIEW -# if __cplusplus >= 201703 || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) -# define HAS_STRING_VIEW 1 -# else -# define HAS_STRING_VIEW 0 -# endif -#endif // HAS_STRING_VIEW - -#include -#include -#include -#include -#include -#if !(__cplusplus >= 201402) -# include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if HAS_STRING_VIEW -# include -#endif -#include -#include - -#ifdef __GNUC__ -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wpedantic" -# if __GNUC__ < 5 - // GCC 4.9 Bug 61489 Wrong warning with -Wmissing-field-initializers -# pragma GCC diagnostic ignored "-Wmissing-field-initializers" -# endif -#endif - -#ifdef _MSC_VER -# pragma warning(push) -// warning C4127: conditional expression is constant -# pragma warning(disable : 4127) -#endif - -namespace arrow_vendored -{ -namespace date -{ - -//---------------+ -// Configuration | -//---------------+ - -#ifndef ONLY_C_LOCALE -# define ONLY_C_LOCALE 0 -#endif - -#if defined(_MSC_VER) && (!defined(__clang__) || (_MSC_VER < 1910)) -// MSVC -# ifndef _SILENCE_CXX17_UNCAUGHT_EXCEPTION_DEPRECATION_WARNING -# define _SILENCE_CXX17_UNCAUGHT_EXCEPTION_DEPRECATION_WARNING -# endif -# if _MSC_VER < 1910 -// before VS2017 -# define CONSTDATA const -# define CONSTCD11 -# define CONSTCD14 -# define NOEXCEPT _NOEXCEPT -# else -// VS2017 and later -# define CONSTDATA constexpr const -# define CONSTCD11 constexpr -# define CONSTCD14 constexpr -# define NOEXCEPT noexcept -# endif - -#elif defined(__SUNPRO_CC) && __SUNPRO_CC <= 0x5150 -// Oracle Developer Studio 12.6 and earlier -# define CONSTDATA constexpr const -# define CONSTCD11 constexpr -# define CONSTCD14 -# define NOEXCEPT noexcept - -#elif __cplusplus >= 201402 -// C++14 -# define CONSTDATA constexpr const -# define CONSTCD11 constexpr -# define CONSTCD14 constexpr -# define NOEXCEPT noexcept -#else -// C++11 -# define CONSTDATA constexpr const -# define CONSTCD11 constexpr -# define CONSTCD14 -# define NOEXCEPT noexcept -#endif - -#ifndef HAS_UNCAUGHT_EXCEPTIONS -# if __cplusplus > 201703 -# define HAS_UNCAUGHT_EXCEPTIONS 1 -# else -# define HAS_UNCAUGHT_EXCEPTIONS 0 -# endif -#endif // HAS_UNCAUGHT_EXCEPTIONS - -#ifndef HAS_VOID_T -# if __cplusplus >= 201703 -# define HAS_VOID_T 1 -# else -# define HAS_VOID_T 0 -# endif -#endif // HAS_VOID_T - -// Protect from Oracle sun macro -#ifdef sun -# undef sun -#endif - -//-----------+ -// Interface | -//-----------+ - -// durations - -using days = std::chrono::duration - , std::chrono::hours::period>>; - -using weeks = std::chrono::duration - , days::period>>; - -using years = std::chrono::duration - , days::period>>; - -using months = std::chrono::duration - >>; - -// time_point - -template - using sys_time = std::chrono::time_point; - -using sys_days = sys_time; -using sys_seconds = sys_time; - -struct local_t {}; - -template - using local_time = std::chrono::time_point; - -using local_seconds = local_time; -using local_days = local_time; - -// types - -struct last_spec -{ - explicit last_spec() = default; -}; - -class day; -class month; -class year; - -class weekday; -class weekday_indexed; -class weekday_last; - -class month_day; -class month_day_last; -class month_weekday; -class month_weekday_last; - -class year_month; - -class year_month_day; -class year_month_day_last; -class year_month_weekday; -class year_month_weekday_last; - -// date composition operators - -CONSTCD11 year_month operator/(const year& y, const month& m) NOEXCEPT; -CONSTCD11 year_month operator/(const year& y, int m) NOEXCEPT; - -CONSTCD11 month_day operator/(const day& d, const month& m) NOEXCEPT; -CONSTCD11 month_day operator/(const day& d, int m) NOEXCEPT; -CONSTCD11 month_day operator/(const month& m, const day& d) NOEXCEPT; -CONSTCD11 month_day operator/(const month& m, int d) NOEXCEPT; -CONSTCD11 month_day operator/(int m, const day& d) NOEXCEPT; - -CONSTCD11 month_day_last operator/(const month& m, last_spec) NOEXCEPT; -CONSTCD11 month_day_last operator/(int m, last_spec) NOEXCEPT; -CONSTCD11 month_day_last operator/(last_spec, const month& m) NOEXCEPT; -CONSTCD11 month_day_last operator/(last_spec, int m) NOEXCEPT; - -CONSTCD11 month_weekday operator/(const month& m, const weekday_indexed& wdi) NOEXCEPT; -CONSTCD11 month_weekday operator/(int m, const weekday_indexed& wdi) NOEXCEPT; -CONSTCD11 month_weekday operator/(const weekday_indexed& wdi, const month& m) NOEXCEPT; -CONSTCD11 month_weekday operator/(const weekday_indexed& wdi, int m) NOEXCEPT; - -CONSTCD11 month_weekday_last operator/(const month& m, const weekday_last& wdl) NOEXCEPT; -CONSTCD11 month_weekday_last operator/(int m, const weekday_last& wdl) NOEXCEPT; -CONSTCD11 month_weekday_last operator/(const weekday_last& wdl, const month& m) NOEXCEPT; -CONSTCD11 month_weekday_last operator/(const weekday_last& wdl, int m) NOEXCEPT; - -CONSTCD11 year_month_day operator/(const year_month& ym, const day& d) NOEXCEPT; -CONSTCD11 year_month_day operator/(const year_month& ym, int d) NOEXCEPT; -CONSTCD11 year_month_day operator/(const year& y, const month_day& md) NOEXCEPT; -CONSTCD11 year_month_day operator/(int y, const month_day& md) NOEXCEPT; -CONSTCD11 year_month_day operator/(const month_day& md, const year& y) NOEXCEPT; -CONSTCD11 year_month_day operator/(const month_day& md, int y) NOEXCEPT; - -CONSTCD11 - year_month_day_last operator/(const year_month& ym, last_spec) NOEXCEPT; -CONSTCD11 - year_month_day_last operator/(const year& y, const month_day_last& mdl) NOEXCEPT; -CONSTCD11 - year_month_day_last operator/(int y, const month_day_last& mdl) NOEXCEPT; -CONSTCD11 - year_month_day_last operator/(const month_day_last& mdl, const year& y) NOEXCEPT; -CONSTCD11 - year_month_day_last operator/(const month_day_last& mdl, int y) NOEXCEPT; - -CONSTCD11 -year_month_weekday -operator/(const year_month& ym, const weekday_indexed& wdi) NOEXCEPT; - -CONSTCD11 -year_month_weekday -operator/(const year& y, const month_weekday& mwd) NOEXCEPT; - -CONSTCD11 -year_month_weekday -operator/(int y, const month_weekday& mwd) NOEXCEPT; - -CONSTCD11 -year_month_weekday -operator/(const month_weekday& mwd, const year& y) NOEXCEPT; - -CONSTCD11 -year_month_weekday -operator/(const month_weekday& mwd, int y) NOEXCEPT; - -CONSTCD11 -year_month_weekday_last -operator/(const year_month& ym, const weekday_last& wdl) NOEXCEPT; - -CONSTCD11 -year_month_weekday_last -operator/(const year& y, const month_weekday_last& mwdl) NOEXCEPT; - -CONSTCD11 -year_month_weekday_last -operator/(int y, const month_weekday_last& mwdl) NOEXCEPT; - -CONSTCD11 -year_month_weekday_last -operator/(const month_weekday_last& mwdl, const year& y) NOEXCEPT; - -CONSTCD11 -year_month_weekday_last -operator/(const month_weekday_last& mwdl, int y) NOEXCEPT; - -// Detailed interface - -// day - -class day -{ - unsigned char d_; - -public: - day() = default; - explicit CONSTCD11 day(unsigned d) NOEXCEPT; - - CONSTCD14 day& operator++() NOEXCEPT; - CONSTCD14 day operator++(int) NOEXCEPT; - CONSTCD14 day& operator--() NOEXCEPT; - CONSTCD14 day operator--(int) NOEXCEPT; - - CONSTCD14 day& operator+=(const days& d) NOEXCEPT; - CONSTCD14 day& operator-=(const days& d) NOEXCEPT; - - CONSTCD11 explicit operator unsigned() const NOEXCEPT; - CONSTCD11 bool ok() const NOEXCEPT; -}; - -CONSTCD11 bool operator==(const day& x, const day& y) NOEXCEPT; -CONSTCD11 bool operator!=(const day& x, const day& y) NOEXCEPT; -CONSTCD11 bool operator< (const day& x, const day& y) NOEXCEPT; -CONSTCD11 bool operator> (const day& x, const day& y) NOEXCEPT; -CONSTCD11 bool operator<=(const day& x, const day& y) NOEXCEPT; -CONSTCD11 bool operator>=(const day& x, const day& y) NOEXCEPT; - -CONSTCD11 day operator+(const day& x, const days& y) NOEXCEPT; -CONSTCD11 day operator+(const days& x, const day& y) NOEXCEPT; -CONSTCD11 day operator-(const day& x, const days& y) NOEXCEPT; -CONSTCD11 days operator-(const day& x, const day& y) NOEXCEPT; - -template -std::basic_ostream& -operator<<(std::basic_ostream& os, const day& d); - -// month - -class month -{ - unsigned char m_; - -public: - month() = default; - explicit CONSTCD11 month(unsigned m) NOEXCEPT; - - CONSTCD14 month& operator++() NOEXCEPT; - CONSTCD14 month operator++(int) NOEXCEPT; - CONSTCD14 month& operator--() NOEXCEPT; - CONSTCD14 month operator--(int) NOEXCEPT; - - CONSTCD14 month& operator+=(const months& m) NOEXCEPT; - CONSTCD14 month& operator-=(const months& m) NOEXCEPT; - - CONSTCD11 explicit operator unsigned() const NOEXCEPT; - CONSTCD11 bool ok() const NOEXCEPT; -}; - -CONSTCD11 bool operator==(const month& x, const month& y) NOEXCEPT; -CONSTCD11 bool operator!=(const month& x, const month& y) NOEXCEPT; -CONSTCD11 bool operator< (const month& x, const month& y) NOEXCEPT; -CONSTCD11 bool operator> (const month& x, const month& y) NOEXCEPT; -CONSTCD11 bool operator<=(const month& x, const month& y) NOEXCEPT; -CONSTCD11 bool operator>=(const month& x, const month& y) NOEXCEPT; - -CONSTCD14 month operator+(const month& x, const months& y) NOEXCEPT; -CONSTCD14 month operator+(const months& x, const month& y) NOEXCEPT; -CONSTCD14 month operator-(const month& x, const months& y) NOEXCEPT; -CONSTCD14 months operator-(const month& x, const month& y) NOEXCEPT; - -template -std::basic_ostream& -operator<<(std::basic_ostream& os, const month& m); - -// year - -class year -{ - short y_; - -public: - year() = default; - explicit CONSTCD11 year(int y) NOEXCEPT; - - CONSTCD14 year& operator++() NOEXCEPT; - CONSTCD14 year operator++(int) NOEXCEPT; - CONSTCD14 year& operator--() NOEXCEPT; - CONSTCD14 year operator--(int) NOEXCEPT; - - CONSTCD14 year& operator+=(const years& y) NOEXCEPT; - CONSTCD14 year& operator-=(const years& y) NOEXCEPT; - - CONSTCD11 year operator-() const NOEXCEPT; - CONSTCD11 year operator+() const NOEXCEPT; - - CONSTCD11 bool is_leap() const NOEXCEPT; - - CONSTCD11 explicit operator int() const NOEXCEPT; - CONSTCD11 bool ok() const NOEXCEPT; - - static CONSTCD11 year min() NOEXCEPT; - static CONSTCD11 year max() NOEXCEPT; -}; - -CONSTCD11 bool operator==(const year& x, const year& y) NOEXCEPT; -CONSTCD11 bool operator!=(const year& x, const year& y) NOEXCEPT; -CONSTCD11 bool operator< (const year& x, const year& y) NOEXCEPT; -CONSTCD11 bool operator> (const year& x, const year& y) NOEXCEPT; -CONSTCD11 bool operator<=(const year& x, const year& y) NOEXCEPT; -CONSTCD11 bool operator>=(const year& x, const year& y) NOEXCEPT; - -CONSTCD11 year operator+(const year& x, const years& y) NOEXCEPT; -CONSTCD11 year operator+(const years& x, const year& y) NOEXCEPT; -CONSTCD11 year operator-(const year& x, const years& y) NOEXCEPT; -CONSTCD11 years operator-(const year& x, const year& y) NOEXCEPT; - -template -std::basic_ostream& -operator<<(std::basic_ostream& os, const year& y); - -// weekday - -class weekday -{ - unsigned char wd_; -public: - weekday() = default; - explicit CONSTCD11 weekday(unsigned wd) NOEXCEPT; - CONSTCD14 weekday(const sys_days& dp) NOEXCEPT; - CONSTCD14 explicit weekday(const local_days& dp) NOEXCEPT; - - CONSTCD14 weekday& operator++() NOEXCEPT; - CONSTCD14 weekday operator++(int) NOEXCEPT; - CONSTCD14 weekday& operator--() NOEXCEPT; - CONSTCD14 weekday operator--(int) NOEXCEPT; - - CONSTCD14 weekday& operator+=(const days& d) NOEXCEPT; - CONSTCD14 weekday& operator-=(const days& d) NOEXCEPT; - - CONSTCD11 bool ok() const NOEXCEPT; - - CONSTCD11 unsigned c_encoding() const NOEXCEPT; - CONSTCD11 unsigned iso_encoding() const NOEXCEPT; - - CONSTCD11 weekday_indexed operator[](unsigned index) const NOEXCEPT; - CONSTCD11 weekday_last operator[](last_spec) const NOEXCEPT; - -private: - static CONSTCD14 unsigned char weekday_from_days(int z) NOEXCEPT; - - friend CONSTCD11 bool operator==(const weekday& x, const weekday& y) NOEXCEPT; - friend CONSTCD14 days operator-(const weekday& x, const weekday& y) NOEXCEPT; - friend CONSTCD14 weekday operator+(const weekday& x, const days& y) NOEXCEPT; - template - friend std::basic_ostream& - operator<<(std::basic_ostream& os, const weekday& wd); - friend class weekday_indexed; -}; - -CONSTCD11 bool operator==(const weekday& x, const weekday& y) NOEXCEPT; -CONSTCD11 bool operator!=(const weekday& x, const weekday& y) NOEXCEPT; - -CONSTCD14 weekday operator+(const weekday& x, const days& y) NOEXCEPT; -CONSTCD14 weekday operator+(const days& x, const weekday& y) NOEXCEPT; -CONSTCD14 weekday operator-(const weekday& x, const days& y) NOEXCEPT; -CONSTCD14 days operator-(const weekday& x, const weekday& y) NOEXCEPT; - -template -std::basic_ostream& -operator<<(std::basic_ostream& os, const weekday& wd); - -// weekday_indexed - -class weekday_indexed -{ - unsigned char wd_ : 4; - unsigned char index_ : 4; - -public: - weekday_indexed() = default; - CONSTCD11 weekday_indexed(const date::weekday& wd, unsigned index) NOEXCEPT; - - CONSTCD11 date::weekday weekday() const NOEXCEPT; - CONSTCD11 unsigned index() const NOEXCEPT; - CONSTCD11 bool ok() const NOEXCEPT; -}; - -CONSTCD11 bool operator==(const weekday_indexed& x, const weekday_indexed& y) NOEXCEPT; -CONSTCD11 bool operator!=(const weekday_indexed& x, const weekday_indexed& y) NOEXCEPT; - -template -std::basic_ostream& -operator<<(std::basic_ostream& os, const weekday_indexed& wdi); - -// weekday_last - -class weekday_last -{ - date::weekday wd_; - -public: - explicit CONSTCD11 weekday_last(const date::weekday& wd) NOEXCEPT; - - CONSTCD11 date::weekday weekday() const NOEXCEPT; - CONSTCD11 bool ok() const NOEXCEPT; -}; - -CONSTCD11 bool operator==(const weekday_last& x, const weekday_last& y) NOEXCEPT; -CONSTCD11 bool operator!=(const weekday_last& x, const weekday_last& y) NOEXCEPT; - -template -std::basic_ostream& -operator<<(std::basic_ostream& os, const weekday_last& wdl); - -namespace detail -{ - -struct unspecified_month_disambiguator {}; - -} // namespace detail - -// year_month - -class year_month -{ - date::year y_; - date::month m_; - -public: - year_month() = default; - CONSTCD11 year_month(const date::year& y, const date::month& m) NOEXCEPT; - - CONSTCD11 date::year year() const NOEXCEPT; - CONSTCD11 date::month month() const NOEXCEPT; - - template - CONSTCD14 year_month& operator+=(const months& dm) NOEXCEPT; - template - CONSTCD14 year_month& operator-=(const months& dm) NOEXCEPT; - CONSTCD14 year_month& operator+=(const years& dy) NOEXCEPT; - CONSTCD14 year_month& operator-=(const years& dy) NOEXCEPT; - - CONSTCD11 bool ok() const NOEXCEPT; -}; - -CONSTCD11 bool operator==(const year_month& x, const year_month& y) NOEXCEPT; -CONSTCD11 bool operator!=(const year_month& x, const year_month& y) NOEXCEPT; -CONSTCD11 bool operator< (const year_month& x, const year_month& y) NOEXCEPT; -CONSTCD11 bool operator> (const year_month& x, const year_month& y) NOEXCEPT; -CONSTCD11 bool operator<=(const year_month& x, const year_month& y) NOEXCEPT; -CONSTCD11 bool operator>=(const year_month& x, const year_month& y) NOEXCEPT; - -template -CONSTCD14 year_month operator+(const year_month& ym, const months& dm) NOEXCEPT; -template -CONSTCD14 year_month operator+(const months& dm, const year_month& ym) NOEXCEPT; -template -CONSTCD14 year_month operator-(const year_month& ym, const months& dm) NOEXCEPT; - -CONSTCD11 months operator-(const year_month& x, const year_month& y) NOEXCEPT; -CONSTCD11 year_month operator+(const year_month& ym, const years& dy) NOEXCEPT; -CONSTCD11 year_month operator+(const years& dy, const year_month& ym) NOEXCEPT; -CONSTCD11 year_month operator-(const year_month& ym, const years& dy) NOEXCEPT; - -template -std::basic_ostream& -operator<<(std::basic_ostream& os, const year_month& ym); - -// month_day - -class month_day -{ - date::month m_; - date::day d_; - -public: - month_day() = default; - CONSTCD11 month_day(const date::month& m, const date::day& d) NOEXCEPT; - - CONSTCD11 date::month month() const NOEXCEPT; - CONSTCD11 date::day day() const NOEXCEPT; - - CONSTCD14 bool ok() const NOEXCEPT; -}; - -CONSTCD11 bool operator==(const month_day& x, const month_day& y) NOEXCEPT; -CONSTCD11 bool operator!=(const month_day& x, const month_day& y) NOEXCEPT; -CONSTCD11 bool operator< (const month_day& x, const month_day& y) NOEXCEPT; -CONSTCD11 bool operator> (const month_day& x, const month_day& y) NOEXCEPT; -CONSTCD11 bool operator<=(const month_day& x, const month_day& y) NOEXCEPT; -CONSTCD11 bool operator>=(const month_day& x, const month_day& y) NOEXCEPT; - -template -std::basic_ostream& -operator<<(std::basic_ostream& os, const month_day& md); - -// month_day_last - -class month_day_last -{ - date::month m_; - -public: - CONSTCD11 explicit month_day_last(const date::month& m) NOEXCEPT; - - CONSTCD11 date::month month() const NOEXCEPT; - CONSTCD11 bool ok() const NOEXCEPT; -}; - -CONSTCD11 bool operator==(const month_day_last& x, const month_day_last& y) NOEXCEPT; -CONSTCD11 bool operator!=(const month_day_last& x, const month_day_last& y) NOEXCEPT; -CONSTCD11 bool operator< (const month_day_last& x, const month_day_last& y) NOEXCEPT; -CONSTCD11 bool operator> (const month_day_last& x, const month_day_last& y) NOEXCEPT; -CONSTCD11 bool operator<=(const month_day_last& x, const month_day_last& y) NOEXCEPT; -CONSTCD11 bool operator>=(const month_day_last& x, const month_day_last& y) NOEXCEPT; - -template -std::basic_ostream& -operator<<(std::basic_ostream& os, const month_day_last& mdl); - -// month_weekday - -class month_weekday -{ - date::month m_; - date::weekday_indexed wdi_; -public: - CONSTCD11 month_weekday(const date::month& m, - const date::weekday_indexed& wdi) NOEXCEPT; - - CONSTCD11 date::month month() const NOEXCEPT; - CONSTCD11 date::weekday_indexed weekday_indexed() const NOEXCEPT; - - CONSTCD11 bool ok() const NOEXCEPT; -}; - -CONSTCD11 bool operator==(const month_weekday& x, const month_weekday& y) NOEXCEPT; -CONSTCD11 bool operator!=(const month_weekday& x, const month_weekday& y) NOEXCEPT; - -template -std::basic_ostream& -operator<<(std::basic_ostream& os, const month_weekday& mwd); - -// month_weekday_last - -class month_weekday_last -{ - date::month m_; - date::weekday_last wdl_; - -public: - CONSTCD11 month_weekday_last(const date::month& m, - const date::weekday_last& wd) NOEXCEPT; - - CONSTCD11 date::month month() const NOEXCEPT; - CONSTCD11 date::weekday_last weekday_last() const NOEXCEPT; - - CONSTCD11 bool ok() const NOEXCEPT; -}; - -CONSTCD11 - bool operator==(const month_weekday_last& x, const month_weekday_last& y) NOEXCEPT; -CONSTCD11 - bool operator!=(const month_weekday_last& x, const month_weekday_last& y) NOEXCEPT; - -template -std::basic_ostream& -operator<<(std::basic_ostream& os, const month_weekday_last& mwdl); - -// class year_month_day - -class year_month_day -{ - date::year y_; - date::month m_; - date::day d_; - -public: - year_month_day() = default; - CONSTCD11 year_month_day(const date::year& y, const date::month& m, - const date::day& d) NOEXCEPT; - CONSTCD14 year_month_day(const year_month_day_last& ymdl) NOEXCEPT; - - CONSTCD14 year_month_day(sys_days dp) NOEXCEPT; - CONSTCD14 explicit year_month_day(local_days dp) NOEXCEPT; - - template - CONSTCD14 year_month_day& operator+=(const months& m) NOEXCEPT; - template - CONSTCD14 year_month_day& operator-=(const months& m) NOEXCEPT; - CONSTCD14 year_month_day& operator+=(const years& y) NOEXCEPT; - CONSTCD14 year_month_day& operator-=(const years& y) NOEXCEPT; - - CONSTCD11 date::year year() const NOEXCEPT; - CONSTCD11 date::month month() const NOEXCEPT; - CONSTCD11 date::day day() const NOEXCEPT; - - CONSTCD14 operator sys_days() const NOEXCEPT; - CONSTCD14 explicit operator local_days() const NOEXCEPT; - CONSTCD14 bool ok() const NOEXCEPT; - -private: - static CONSTCD14 year_month_day from_days(days dp) NOEXCEPT; - CONSTCD14 days to_days() const NOEXCEPT; -}; - -CONSTCD11 bool operator==(const year_month_day& x, const year_month_day& y) NOEXCEPT; -CONSTCD11 bool operator!=(const year_month_day& x, const year_month_day& y) NOEXCEPT; -CONSTCD11 bool operator< (const year_month_day& x, const year_month_day& y) NOEXCEPT; -CONSTCD11 bool operator> (const year_month_day& x, const year_month_day& y) NOEXCEPT; -CONSTCD11 bool operator<=(const year_month_day& x, const year_month_day& y) NOEXCEPT; -CONSTCD11 bool operator>=(const year_month_day& x, const year_month_day& y) NOEXCEPT; - -template -CONSTCD14 year_month_day operator+(const year_month_day& ymd, const months& dm) NOEXCEPT; -template -CONSTCD14 year_month_day operator+(const months& dm, const year_month_day& ymd) NOEXCEPT; -template -CONSTCD14 year_month_day operator-(const year_month_day& ymd, const months& dm) NOEXCEPT; -CONSTCD11 year_month_day operator+(const year_month_day& ymd, const years& dy) NOEXCEPT; -CONSTCD11 year_month_day operator+(const years& dy, const year_month_day& ymd) NOEXCEPT; -CONSTCD11 year_month_day operator-(const year_month_day& ymd, const years& dy) NOEXCEPT; - -template -std::basic_ostream& -operator<<(std::basic_ostream& os, const year_month_day& ymd); - -// year_month_day_last - -class year_month_day_last -{ - date::year y_; - date::month_day_last mdl_; - -public: - CONSTCD11 year_month_day_last(const date::year& y, - const date::month_day_last& mdl) NOEXCEPT; - - template - CONSTCD14 year_month_day_last& operator+=(const months& m) NOEXCEPT; - template - CONSTCD14 year_month_day_last& operator-=(const months& m) NOEXCEPT; - CONSTCD14 year_month_day_last& operator+=(const years& y) NOEXCEPT; - CONSTCD14 year_month_day_last& operator-=(const years& y) NOEXCEPT; - - CONSTCD11 date::year year() const NOEXCEPT; - CONSTCD11 date::month month() const NOEXCEPT; - CONSTCD11 date::month_day_last month_day_last() const NOEXCEPT; - CONSTCD14 date::day day() const NOEXCEPT; - - CONSTCD14 operator sys_days() const NOEXCEPT; - CONSTCD14 explicit operator local_days() const NOEXCEPT; - CONSTCD11 bool ok() const NOEXCEPT; -}; - -CONSTCD11 - bool operator==(const year_month_day_last& x, const year_month_day_last& y) NOEXCEPT; -CONSTCD11 - bool operator!=(const year_month_day_last& x, const year_month_day_last& y) NOEXCEPT; -CONSTCD11 - bool operator< (const year_month_day_last& x, const year_month_day_last& y) NOEXCEPT; -CONSTCD11 - bool operator> (const year_month_day_last& x, const year_month_day_last& y) NOEXCEPT; -CONSTCD11 - bool operator<=(const year_month_day_last& x, const year_month_day_last& y) NOEXCEPT; -CONSTCD11 - bool operator>=(const year_month_day_last& x, const year_month_day_last& y) NOEXCEPT; - -template -CONSTCD14 -year_month_day_last -operator+(const year_month_day_last& ymdl, const months& dm) NOEXCEPT; - -template -CONSTCD14 -year_month_day_last -operator+(const months& dm, const year_month_day_last& ymdl) NOEXCEPT; - -CONSTCD11 -year_month_day_last -operator+(const year_month_day_last& ymdl, const years& dy) NOEXCEPT; - -CONSTCD11 -year_month_day_last -operator+(const years& dy, const year_month_day_last& ymdl) NOEXCEPT; - -template -CONSTCD14 -year_month_day_last -operator-(const year_month_day_last& ymdl, const months& dm) NOEXCEPT; - -CONSTCD11 -year_month_day_last -operator-(const year_month_day_last& ymdl, const years& dy) NOEXCEPT; - -template -std::basic_ostream& -operator<<(std::basic_ostream& os, const year_month_day_last& ymdl); - -// year_month_weekday - -class year_month_weekday -{ - date::year y_; - date::month m_; - date::weekday_indexed wdi_; - -public: - year_month_weekday() = default; - CONSTCD11 year_month_weekday(const date::year& y, const date::month& m, - const date::weekday_indexed& wdi) NOEXCEPT; - CONSTCD14 year_month_weekday(const sys_days& dp) NOEXCEPT; - CONSTCD14 explicit year_month_weekday(const local_days& dp) NOEXCEPT; - - template - CONSTCD14 year_month_weekday& operator+=(const months& m) NOEXCEPT; - template - CONSTCD14 year_month_weekday& operator-=(const months& m) NOEXCEPT; - CONSTCD14 year_month_weekday& operator+=(const years& y) NOEXCEPT; - CONSTCD14 year_month_weekday& operator-=(const years& y) NOEXCEPT; - - CONSTCD11 date::year year() const NOEXCEPT; - CONSTCD11 date::month month() const NOEXCEPT; - CONSTCD11 date::weekday weekday() const NOEXCEPT; - CONSTCD11 unsigned index() const NOEXCEPT; - CONSTCD11 date::weekday_indexed weekday_indexed() const NOEXCEPT; - - CONSTCD14 operator sys_days() const NOEXCEPT; - CONSTCD14 explicit operator local_days() const NOEXCEPT; - CONSTCD14 bool ok() const NOEXCEPT; - -private: - static CONSTCD14 year_month_weekday from_days(days dp) NOEXCEPT; - CONSTCD14 days to_days() const NOEXCEPT; -}; - -CONSTCD11 - bool operator==(const year_month_weekday& x, const year_month_weekday& y) NOEXCEPT; -CONSTCD11 - bool operator!=(const year_month_weekday& x, const year_month_weekday& y) NOEXCEPT; - -template -CONSTCD14 -year_month_weekday -operator+(const year_month_weekday& ymwd, const months& dm) NOEXCEPT; - -template -CONSTCD14 -year_month_weekday -operator+(const months& dm, const year_month_weekday& ymwd) NOEXCEPT; - -CONSTCD11 -year_month_weekday -operator+(const year_month_weekday& ymwd, const years& dy) NOEXCEPT; - -CONSTCD11 -year_month_weekday -operator+(const years& dy, const year_month_weekday& ymwd) NOEXCEPT; - -template -CONSTCD14 -year_month_weekday -operator-(const year_month_weekday& ymwd, const months& dm) NOEXCEPT; - -CONSTCD11 -year_month_weekday -operator-(const year_month_weekday& ymwd, const years& dy) NOEXCEPT; - -template -std::basic_ostream& -operator<<(std::basic_ostream& os, const year_month_weekday& ymwdi); - -// year_month_weekday_last - -class year_month_weekday_last -{ - date::year y_; - date::month m_; - date::weekday_last wdl_; - -public: - CONSTCD11 year_month_weekday_last(const date::year& y, const date::month& m, - const date::weekday_last& wdl) NOEXCEPT; - - template - CONSTCD14 year_month_weekday_last& operator+=(const months& m) NOEXCEPT; - template - CONSTCD14 year_month_weekday_last& operator-=(const months& m) NOEXCEPT; - CONSTCD14 year_month_weekday_last& operator+=(const years& y) NOEXCEPT; - CONSTCD14 year_month_weekday_last& operator-=(const years& y) NOEXCEPT; - - CONSTCD11 date::year year() const NOEXCEPT; - CONSTCD11 date::month month() const NOEXCEPT; - CONSTCD11 date::weekday weekday() const NOEXCEPT; - CONSTCD11 date::weekday_last weekday_last() const NOEXCEPT; - - CONSTCD14 operator sys_days() const NOEXCEPT; - CONSTCD14 explicit operator local_days() const NOEXCEPT; - CONSTCD11 bool ok() const NOEXCEPT; - -private: - CONSTCD14 days to_days() const NOEXCEPT; -}; - -CONSTCD11 -bool -operator==(const year_month_weekday_last& x, const year_month_weekday_last& y) NOEXCEPT; - -CONSTCD11 -bool -operator!=(const year_month_weekday_last& x, const year_month_weekday_last& y) NOEXCEPT; - -template -CONSTCD14 -year_month_weekday_last -operator+(const year_month_weekday_last& ymwdl, const months& dm) NOEXCEPT; - -template -CONSTCD14 -year_month_weekday_last -operator+(const months& dm, const year_month_weekday_last& ymwdl) NOEXCEPT; - -CONSTCD11 -year_month_weekday_last -operator+(const year_month_weekday_last& ymwdl, const years& dy) NOEXCEPT; - -CONSTCD11 -year_month_weekday_last -operator+(const years& dy, const year_month_weekday_last& ymwdl) NOEXCEPT; - -template -CONSTCD14 -year_month_weekday_last -operator-(const year_month_weekday_last& ymwdl, const months& dm) NOEXCEPT; - -CONSTCD11 -year_month_weekday_last -operator-(const year_month_weekday_last& ymwdl, const years& dy) NOEXCEPT; - -template -std::basic_ostream& -operator<<(std::basic_ostream& os, const year_month_weekday_last& ymwdl); - -#if !defined(_MSC_VER) || (_MSC_VER >= 1900) -inline namespace literals -{ - -CONSTCD11 date::day operator "" _d(unsigned long long d) NOEXCEPT; -CONSTCD11 date::year operator "" _y(unsigned long long y) NOEXCEPT; - -} // inline namespace literals -#endif // !defined(_MSC_VER) || (_MSC_VER >= 1900) - -// CONSTDATA date::month January{1}; -// CONSTDATA date::month February{2}; -// CONSTDATA date::month March{3}; -// CONSTDATA date::month April{4}; -// CONSTDATA date::month May{5}; -// CONSTDATA date::month June{6}; -// CONSTDATA date::month July{7}; -// CONSTDATA date::month August{8}; -// CONSTDATA date::month September{9}; -// CONSTDATA date::month October{10}; -// CONSTDATA date::month November{11}; -// CONSTDATA date::month December{12}; -// -// CONSTDATA date::weekday Sunday{0u}; -// CONSTDATA date::weekday Monday{1u}; -// CONSTDATA date::weekday Tuesday{2u}; -// CONSTDATA date::weekday Wednesday{3u}; -// CONSTDATA date::weekday Thursday{4u}; -// CONSTDATA date::weekday Friday{5u}; -// CONSTDATA date::weekday Saturday{6u}; - -#if HAS_VOID_T - -template > -struct is_clock - : std::false_type -{}; - -template -struct is_clock> - : std::true_type -{}; - -#endif // HAS_VOID_T - -//----------------+ -// Implementation | -//----------------+ - -// utilities -namespace detail { - -template> -class save_istream -{ -protected: - std::basic_ios& is_; - CharT fill_; - std::ios::fmtflags flags_; - std::streamsize width_; - std::basic_ostream* tie_; - std::locale loc_; - -public: - ~save_istream() - { - is_.fill(fill_); - is_.flags(flags_); - is_.width(width_); - is_.imbue(loc_); - is_.tie(tie_); - } - - save_istream(const save_istream&) = delete; - save_istream& operator=(const save_istream&) = delete; - - explicit save_istream(std::basic_ios& is) - : is_(is) - , fill_(is.fill()) - , flags_(is.flags()) - , width_(is.width(0)) - , tie_(is.tie(nullptr)) - , loc_(is.getloc()) - { - if (tie_ != nullptr) - tie_->flush(); - } -}; - -template> -class save_ostream - : private save_istream -{ -public: - ~save_ostream() - { - if ((this->flags_ & std::ios::unitbuf) && -#if HAS_UNCAUGHT_EXCEPTIONS - std::uncaught_exceptions() == 0 && -#else - !std::uncaught_exception() && -#endif - this->is_.good()) - this->is_.rdbuf()->pubsync(); - } - - save_ostream(const save_ostream&) = delete; - save_ostream& operator=(const save_ostream&) = delete; - - explicit save_ostream(std::basic_ios& os) - : save_istream(os) - { - } -}; - -template -struct choose_trunc_type -{ - static const int digits = std::numeric_limits::digits; - using type = typename std::conditional - < - digits < 32, - std::int32_t, - typename std::conditional - < - digits < 64, - std::int64_t, -#ifdef __SIZEOF_INT128__ - __int128 -#else - std::int64_t -#endif - >::type - >::type; -}; - -template -CONSTCD11 -inline -typename std::enable_if -< - !std::chrono::treat_as_floating_point::value, - T ->::type -trunc(T t) NOEXCEPT -{ - return t; -} - -template -CONSTCD14 -inline -typename std::enable_if -< - std::chrono::treat_as_floating_point::value, - T ->::type -trunc(T t) NOEXCEPT -{ - using std::numeric_limits; - using I = typename choose_trunc_type::type; - CONSTDATA auto digits = numeric_limits::digits; - static_assert(digits < numeric_limits::digits, ""); - CONSTDATA auto max = I{1} << (digits-1); - CONSTDATA auto min = -max; - const auto negative = t < T{0}; - if (min <= t && t <= max && t != 0 && t == t) - { - t = static_cast(static_cast(t)); - if (t == 0 && negative) - t = -t; - } - return t; -} - -template -struct static_gcd -{ - static const std::intmax_t value = static_gcd::value; -}; - -template -struct static_gcd -{ - static const std::intmax_t value = Xp; -}; - -template <> -struct static_gcd<0, 0> -{ - static const std::intmax_t value = 1; -}; - -template -struct no_overflow -{ -private: - static const std::intmax_t gcd_n1_n2 = static_gcd::value; - static const std::intmax_t gcd_d1_d2 = static_gcd::value; - static const std::intmax_t n1 = R1::num / gcd_n1_n2; - static const std::intmax_t d1 = R1::den / gcd_d1_d2; - static const std::intmax_t n2 = R2::num / gcd_n1_n2; - static const std::intmax_t d2 = R2::den / gcd_d1_d2; - static const std::intmax_t max = -((std::intmax_t(1) << - (sizeof(std::intmax_t) * CHAR_BIT - 1)) + 1); - - template - struct mul // overflow == false - { - static const std::intmax_t value = Xp * Yp; - }; - - template - struct mul - { - static const std::intmax_t value = 1; - }; - -public: - static const bool value = (n1 <= max / d2) && (n2 <= max / d1); - typedef std::ratio::value, - mul::value> type; -}; - -} // detail - -// trunc towards zero -template -CONSTCD11 -inline -typename std::enable_if -< - detail::no_overflow::value, - To ->::type -trunc(const std::chrono::duration& d) -{ - return To{detail::trunc(std::chrono::duration_cast(d).count())}; -} - -template -CONSTCD11 -inline -typename std::enable_if -< - !detail::no_overflow::value, - To ->::type -trunc(const std::chrono::duration& d) -{ - using std::chrono::duration_cast; - using std::chrono::duration; - using rep = typename std::common_type::type; - return To{detail::trunc(duration_cast(duration_cast>(d)).count())}; -} - -#ifndef HAS_CHRONO_ROUNDING -# if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 190023918 || (_MSC_FULL_VER >= 190000000 && defined (__clang__))) -# define HAS_CHRONO_ROUNDING 1 -# elif defined(__cpp_lib_chrono) && __cplusplus > 201402 && __cpp_lib_chrono >= 201510 -# define HAS_CHRONO_ROUNDING 1 -# elif defined(_LIBCPP_VERSION) && __cplusplus > 201402 && _LIBCPP_VERSION >= 3800 -# define HAS_CHRONO_ROUNDING 1 -# else -# define HAS_CHRONO_ROUNDING 0 -# endif -#endif // HAS_CHRONO_ROUNDING - -#if HAS_CHRONO_ROUNDING == 0 - -// round down -template -CONSTCD14 -inline -typename std::enable_if -< - detail::no_overflow::value, - To ->::type -floor(const std::chrono::duration& d) -{ - auto t = trunc(d); - if (t > d) - return t - To{1}; - return t; -} - -template -CONSTCD14 -inline -typename std::enable_if -< - !detail::no_overflow::value, - To ->::type -floor(const std::chrono::duration& d) -{ - using rep = typename std::common_type::type; - return floor(floor>(d)); -} - -// round to nearest, to even on tie -template -CONSTCD14 -inline -To -round(const std::chrono::duration& d) -{ - auto t0 = floor(d); - auto t1 = t0 + To{1}; - if (t1 == To{0} && t0 < To{0}) - t1 = -t1; - auto diff0 = d - t0; - auto diff1 = t1 - d; - if (diff0 == diff1) - { - if (t0 - trunc(t0/2)*2 == To{0}) - return t0; - return t1; - } - if (diff0 < diff1) - return t0; - return t1; -} - -// round up -template -CONSTCD14 -inline -To -ceil(const std::chrono::duration& d) -{ - auto t = trunc(d); - if (t < d) - return t + To{1}; - return t; -} - -template ::is_signed - >::type> -CONSTCD11 -std::chrono::duration -abs(std::chrono::duration d) -{ - return d >= d.zero() ? d : -d; -} - -// round down -template -CONSTCD11 -inline -std::chrono::time_point -floor(const std::chrono::time_point& tp) -{ - using std::chrono::time_point; - return time_point{date::floor(tp.time_since_epoch())}; -} - -// round to nearest, to even on tie -template -CONSTCD11 -inline -std::chrono::time_point -round(const std::chrono::time_point& tp) -{ - using std::chrono::time_point; - return time_point{round(tp.time_since_epoch())}; -} - -// round up -template -CONSTCD11 -inline -std::chrono::time_point -ceil(const std::chrono::time_point& tp) -{ - using std::chrono::time_point; - return time_point{ceil(tp.time_since_epoch())}; -} - -#else // HAS_CHRONO_ROUNDING == 1 - -using std::chrono::floor; -using std::chrono::ceil; -using std::chrono::round; -using std::chrono::abs; - -#endif // HAS_CHRONO_ROUNDING - -// trunc towards zero -template -CONSTCD11 -inline -std::chrono::time_point -trunc(const std::chrono::time_point& tp) -{ - using std::chrono::time_point; - return time_point{trunc(tp.time_since_epoch())}; -} - -// day - -CONSTCD11 inline day::day(unsigned d) NOEXCEPT : d_(static_cast(d)) {} -CONSTCD14 inline day& day::operator++() NOEXCEPT {++d_; return *this;} -CONSTCD14 inline day day::operator++(int) NOEXCEPT {auto tmp(*this); ++(*this); return tmp;} -CONSTCD14 inline day& day::operator--() NOEXCEPT {--d_; return *this;} -CONSTCD14 inline day day::operator--(int) NOEXCEPT {auto tmp(*this); --(*this); return tmp;} -CONSTCD14 inline day& day::operator+=(const days& d) NOEXCEPT {*this = *this + d; return *this;} -CONSTCD14 inline day& day::operator-=(const days& d) NOEXCEPT {*this = *this - d; return *this;} -CONSTCD11 inline day::operator unsigned() const NOEXCEPT {return d_;} -CONSTCD11 inline bool day::ok() const NOEXCEPT {return 1 <= d_ && d_ <= 31;} - -CONSTCD11 -inline -bool -operator==(const day& x, const day& y) NOEXCEPT -{ - return static_cast(x) == static_cast(y); -} - -CONSTCD11 -inline -bool -operator!=(const day& x, const day& y) NOEXCEPT -{ - return !(x == y); -} - -CONSTCD11 -inline -bool -operator<(const day& x, const day& y) NOEXCEPT -{ - return static_cast(x) < static_cast(y); -} - -CONSTCD11 -inline -bool -operator>(const day& x, const day& y) NOEXCEPT -{ - return y < x; -} - -CONSTCD11 -inline -bool -operator<=(const day& x, const day& y) NOEXCEPT -{ - return !(y < x); -} - -CONSTCD11 -inline -bool -operator>=(const day& x, const day& y) NOEXCEPT -{ - return !(x < y); -} - -CONSTCD11 -inline -days -operator-(const day& x, const day& y) NOEXCEPT -{ - return days{static_cast(static_cast(x) - - static_cast(y))}; -} - -CONSTCD11 -inline -day -operator+(const day& x, const days& y) NOEXCEPT -{ - return day{static_cast(x) + static_cast(y.count())}; -} - -CONSTCD11 -inline -day -operator+(const days& x, const day& y) NOEXCEPT -{ - return y + x; -} - -CONSTCD11 -inline -day -operator-(const day& x, const days& y) NOEXCEPT -{ - return x + -y; -} - -template -inline -std::basic_ostream& -operator<<(std::basic_ostream& os, const day& d) -{ - detail::save_ostream _(os); - os.fill('0'); - os.flags(std::ios::dec | std::ios::right); - os.width(2); - os << static_cast(d); - if (!d.ok()) - os << " is not a valid day"; - return os; -} - -// month - -CONSTCD11 inline month::month(unsigned m) NOEXCEPT : m_(static_cast(m)) {} -CONSTCD14 inline month& month::operator++() NOEXCEPT {*this += months{1}; return *this;} -CONSTCD14 inline month month::operator++(int) NOEXCEPT {auto tmp(*this); ++(*this); return tmp;} -CONSTCD14 inline month& month::operator--() NOEXCEPT {*this -= months{1}; return *this;} -CONSTCD14 inline month month::operator--(int) NOEXCEPT {auto tmp(*this); --(*this); return tmp;} - -CONSTCD14 -inline -month& -month::operator+=(const months& m) NOEXCEPT -{ - *this = *this + m; - return *this; -} - -CONSTCD14 -inline -month& -month::operator-=(const months& m) NOEXCEPT -{ - *this = *this - m; - return *this; -} - -CONSTCD11 inline month::operator unsigned() const NOEXCEPT {return m_;} -CONSTCD11 inline bool month::ok() const NOEXCEPT {return 1 <= m_ && m_ <= 12;} - -CONSTCD11 -inline -bool -operator==(const month& x, const month& y) NOEXCEPT -{ - return static_cast(x) == static_cast(y); -} - -CONSTCD11 -inline -bool -operator!=(const month& x, const month& y) NOEXCEPT -{ - return !(x == y); -} - -CONSTCD11 -inline -bool -operator<(const month& x, const month& y) NOEXCEPT -{ - return static_cast(x) < static_cast(y); -} - -CONSTCD11 -inline -bool -operator>(const month& x, const month& y) NOEXCEPT -{ - return y < x; -} - -CONSTCD11 -inline -bool -operator<=(const month& x, const month& y) NOEXCEPT -{ - return !(y < x); -} - -CONSTCD11 -inline -bool -operator>=(const month& x, const month& y) NOEXCEPT -{ - return !(x < y); -} - -CONSTCD14 -inline -months -operator-(const month& x, const month& y) NOEXCEPT -{ - auto const d = static_cast(x) - static_cast(y); - return months(d <= 11 ? d : d + 12); -} - -CONSTCD14 -inline -month -operator+(const month& x, const months& y) NOEXCEPT -{ - auto const mu = static_cast(static_cast(x)) + (y.count() - 1); - auto const yr = (mu >= 0 ? mu : mu-11) / 12; - return month{static_cast(mu - yr * 12 + 1)}; -} - -CONSTCD14 -inline -month -operator+(const months& x, const month& y) NOEXCEPT -{ - return y + x; -} - -CONSTCD14 -inline -month -operator-(const month& x, const months& y) NOEXCEPT -{ - return x + -y; -} - -template -inline -std::basic_ostream& -operator<<(std::basic_ostream& os, const month& m) -{ - if (m.ok()) - { - CharT fmt[] = {'%', 'b', 0}; - os << format(os.getloc(), fmt, m); - } - else - os << static_cast(m) << " is not a valid month"; - return os; -} - -// year - -CONSTCD11 inline year::year(int y) NOEXCEPT : y_(static_cast(y)) {} -CONSTCD14 inline year& year::operator++() NOEXCEPT {++y_; return *this;} -CONSTCD14 inline year year::operator++(int) NOEXCEPT {auto tmp(*this); ++(*this); return tmp;} -CONSTCD14 inline year& year::operator--() NOEXCEPT {--y_; return *this;} -CONSTCD14 inline year year::operator--(int) NOEXCEPT {auto tmp(*this); --(*this); return tmp;} -CONSTCD14 inline year& year::operator+=(const years& y) NOEXCEPT {*this = *this + y; return *this;} -CONSTCD14 inline year& year::operator-=(const years& y) NOEXCEPT {*this = *this - y; return *this;} -CONSTCD11 inline year year::operator-() const NOEXCEPT {return year{-y_};} -CONSTCD11 inline year year::operator+() const NOEXCEPT {return *this;} - -CONSTCD11 -inline -bool -year::is_leap() const NOEXCEPT -{ - return y_ % 4 == 0 && (y_ % 100 != 0 || y_ % 400 == 0); -} - -CONSTCD11 inline year::operator int() const NOEXCEPT {return y_;} - -CONSTCD11 -inline -bool -year::ok() const NOEXCEPT -{ - return y_ != std::numeric_limits::min(); -} - -CONSTCD11 -inline -year -year::min() NOEXCEPT -{ - return year{-32767}; -} - -CONSTCD11 -inline -year -year::max() NOEXCEPT -{ - return year{32767}; -} - -CONSTCD11 -inline -bool -operator==(const year& x, const year& y) NOEXCEPT -{ - return static_cast(x) == static_cast(y); -} - -CONSTCD11 -inline -bool -operator!=(const year& x, const year& y) NOEXCEPT -{ - return !(x == y); -} - -CONSTCD11 -inline -bool -operator<(const year& x, const year& y) NOEXCEPT -{ - return static_cast(x) < static_cast(y); -} - -CONSTCD11 -inline -bool -operator>(const year& x, const year& y) NOEXCEPT -{ - return y < x; -} - -CONSTCD11 -inline -bool -operator<=(const year& x, const year& y) NOEXCEPT -{ - return !(y < x); -} - -CONSTCD11 -inline -bool -operator>=(const year& x, const year& y) NOEXCEPT -{ - return !(x < y); -} - -CONSTCD11 -inline -years -operator-(const year& x, const year& y) NOEXCEPT -{ - return years{static_cast(x) - static_cast(y)}; -} - -CONSTCD11 -inline -year -operator+(const year& x, const years& y) NOEXCEPT -{ - return year{static_cast(x) + y.count()}; -} - -CONSTCD11 -inline -year -operator+(const years& x, const year& y) NOEXCEPT -{ - return y + x; -} - -CONSTCD11 -inline -year -operator-(const year& x, const years& y) NOEXCEPT -{ - return year{static_cast(x) - y.count()}; -} - -template -inline -std::basic_ostream& -operator<<(std::basic_ostream& os, const year& y) -{ - detail::save_ostream _(os); - os.fill('0'); - os.flags(std::ios::dec | std::ios::internal); - os.width(4 + (y < year{0})); - os << static_cast(y); - if (!y.ok()) - os << " is not a valid year"; - return os; -} - -// weekday - -CONSTCD14 -inline -unsigned char -weekday::weekday_from_days(int z) NOEXCEPT -{ - auto u = static_cast(z); - return static_cast(z >= -4 ? (u+4) % 7 : u % 7); -} - -CONSTCD11 -inline -weekday::weekday(unsigned wd) NOEXCEPT - : wd_(static_cast(wd != 7 ? wd : 0)) - {} - -CONSTCD14 -inline -weekday::weekday(const sys_days& dp) NOEXCEPT - : wd_(weekday_from_days(dp.time_since_epoch().count())) - {} - -CONSTCD14 -inline -weekday::weekday(const local_days& dp) NOEXCEPT - : wd_(weekday_from_days(dp.time_since_epoch().count())) - {} - -CONSTCD14 inline weekday& weekday::operator++() NOEXCEPT {*this += days{1}; return *this;} -CONSTCD14 inline weekday weekday::operator++(int) NOEXCEPT {auto tmp(*this); ++(*this); return tmp;} -CONSTCD14 inline weekday& weekday::operator--() NOEXCEPT {*this -= days{1}; return *this;} -CONSTCD14 inline weekday weekday::operator--(int) NOEXCEPT {auto tmp(*this); --(*this); return tmp;} - -CONSTCD14 -inline -weekday& -weekday::operator+=(const days& d) NOEXCEPT -{ - *this = *this + d; - return *this; -} - -CONSTCD14 -inline -weekday& -weekday::operator-=(const days& d) NOEXCEPT -{ - *this = *this - d; - return *this; -} - -CONSTCD11 inline bool weekday::ok() const NOEXCEPT {return wd_ <= 6;} - -CONSTCD11 -inline -unsigned weekday::c_encoding() const NOEXCEPT -{ - return unsigned{wd_}; -} - -CONSTCD11 -inline -unsigned weekday::iso_encoding() const NOEXCEPT -{ - return unsigned{((wd_ == 0u) ? 7u : wd_)}; -} - -CONSTCD11 -inline -bool -operator==(const weekday& x, const weekday& y) NOEXCEPT -{ - return x.wd_ == y.wd_; -} - -CONSTCD11 -inline -bool -operator!=(const weekday& x, const weekday& y) NOEXCEPT -{ - return !(x == y); -} - -CONSTCD14 -inline -days -operator-(const weekday& x, const weekday& y) NOEXCEPT -{ - auto const wdu = x.wd_ - y.wd_; - auto const wk = (wdu >= 0 ? wdu : wdu-6) / 7; - return days{wdu - wk * 7}; -} - -CONSTCD14 -inline -weekday -operator+(const weekday& x, const days& y) NOEXCEPT -{ - auto const wdu = static_cast(static_cast(x.wd_)) + y.count(); - auto const wk = (wdu >= 0 ? wdu : wdu-6) / 7; - return weekday{static_cast(wdu - wk * 7)}; -} - -CONSTCD14 -inline -weekday -operator+(const days& x, const weekday& y) NOEXCEPT -{ - return y + x; -} - -CONSTCD14 -inline -weekday -operator-(const weekday& x, const days& y) NOEXCEPT -{ - return x + -y; -} - -template -inline -std::basic_ostream& -operator<<(std::basic_ostream& os, const weekday& wd) -{ - if (wd.ok()) - { - CharT fmt[] = {'%', 'a', 0}; - os << format(fmt, wd); - } - else - os << static_cast(wd.wd_) << " is not a valid weekday"; - return os; -} - -#if !defined(_MSC_VER) || (_MSC_VER >= 1900) -inline namespace literals -{ - -CONSTCD11 -inline -date::day -operator "" _d(unsigned long long d) NOEXCEPT -{ - return date::day{static_cast(d)}; -} - -CONSTCD11 -inline -date::year -operator "" _y(unsigned long long y) NOEXCEPT -{ - return date::year(static_cast(y)); -} -#endif // !defined(_MSC_VER) || (_MSC_VER >= 1900) - -CONSTDATA date::last_spec last{}; - -CONSTDATA date::month jan{1}; -CONSTDATA date::month feb{2}; -CONSTDATA date::month mar{3}; -CONSTDATA date::month apr{4}; -CONSTDATA date::month may{5}; -CONSTDATA date::month jun{6}; -CONSTDATA date::month jul{7}; -CONSTDATA date::month aug{8}; -CONSTDATA date::month sep{9}; -CONSTDATA date::month oct{10}; -CONSTDATA date::month nov{11}; -CONSTDATA date::month dec{12}; - -CONSTDATA date::weekday sun{0u}; -CONSTDATA date::weekday mon{1u}; -CONSTDATA date::weekday tue{2u}; -CONSTDATA date::weekday wed{3u}; -CONSTDATA date::weekday thu{4u}; -CONSTDATA date::weekday fri{5u}; -CONSTDATA date::weekday sat{6u}; - -#if !defined(_MSC_VER) || (_MSC_VER >= 1900) -} // inline namespace literals -#endif - -CONSTDATA date::month January{1}; -CONSTDATA date::month February{2}; -CONSTDATA date::month March{3}; -CONSTDATA date::month April{4}; -CONSTDATA date::month May{5}; -CONSTDATA date::month June{6}; -CONSTDATA date::month July{7}; -CONSTDATA date::month August{8}; -CONSTDATA date::month September{9}; -CONSTDATA date::month October{10}; -CONSTDATA date::month November{11}; -CONSTDATA date::month December{12}; - -CONSTDATA date::weekday Monday{1}; -CONSTDATA date::weekday Tuesday{2}; -CONSTDATA date::weekday Wednesday{3}; -CONSTDATA date::weekday Thursday{4}; -CONSTDATA date::weekday Friday{5}; -CONSTDATA date::weekday Saturday{6}; -CONSTDATA date::weekday Sunday{7}; - -// weekday_indexed - -CONSTCD11 -inline -weekday -weekday_indexed::weekday() const NOEXCEPT -{ - return date::weekday{static_cast(wd_)}; -} - -CONSTCD11 inline unsigned weekday_indexed::index() const NOEXCEPT {return index_;} - -CONSTCD11 -inline -bool -weekday_indexed::ok() const NOEXCEPT -{ - return weekday().ok() && 1 <= index_ && index_ <= 5; -} - -#ifdef __GNUC__ -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wconversion" -#endif // __GNUC__ - -CONSTCD11 -inline -weekday_indexed::weekday_indexed(const date::weekday& wd, unsigned index) NOEXCEPT - : wd_(static_cast(static_cast(wd.wd_))) - , index_(static_cast(index)) - {} - -#ifdef __GNUC__ -# pragma GCC diagnostic pop -#endif // __GNUC__ - -template -inline -std::basic_ostream& -operator<<(std::basic_ostream& os, const weekday_indexed& wdi) -{ - os << wdi.weekday() << '[' << wdi.index(); - if (!(1 <= wdi.index() && wdi.index() <= 5)) - os << " is not a valid index"; - os << ']'; - return os; -} - -CONSTCD11 -inline -weekday_indexed -weekday::operator[](unsigned index) const NOEXCEPT -{ - return {*this, index}; -} - -CONSTCD11 -inline -bool -operator==(const weekday_indexed& x, const weekday_indexed& y) NOEXCEPT -{ - return x.weekday() == y.weekday() && x.index() == y.index(); -} - -CONSTCD11 -inline -bool -operator!=(const weekday_indexed& x, const weekday_indexed& y) NOEXCEPT -{ - return !(x == y); -} - -// weekday_last - -CONSTCD11 inline date::weekday weekday_last::weekday() const NOEXCEPT {return wd_;} -CONSTCD11 inline bool weekday_last::ok() const NOEXCEPT {return wd_.ok();} -CONSTCD11 inline weekday_last::weekday_last(const date::weekday& wd) NOEXCEPT : wd_(wd) {} - -CONSTCD11 -inline -bool -operator==(const weekday_last& x, const weekday_last& y) NOEXCEPT -{ - return x.weekday() == y.weekday(); -} - -CONSTCD11 -inline -bool -operator!=(const weekday_last& x, const weekday_last& y) NOEXCEPT -{ - return !(x == y); -} - -template -inline -std::basic_ostream& -operator<<(std::basic_ostream& os, const weekday_last& wdl) -{ - return os << wdl.weekday() << "[last]"; -} - -CONSTCD11 -inline -weekday_last -weekday::operator[](last_spec) const NOEXCEPT -{ - return weekday_last{*this}; -} - -// year_month - -CONSTCD11 -inline -year_month::year_month(const date::year& y, const date::month& m) NOEXCEPT - : y_(y) - , m_(m) - {} - -CONSTCD11 inline year year_month::year() const NOEXCEPT {return y_;} -CONSTCD11 inline month year_month::month() const NOEXCEPT {return m_;} -CONSTCD11 inline bool year_month::ok() const NOEXCEPT {return y_.ok() && m_.ok();} - -template -CONSTCD14 -inline -year_month& -year_month::operator+=(const months& dm) NOEXCEPT -{ - *this = *this + dm; - return *this; -} - -template -CONSTCD14 -inline -year_month& -year_month::operator-=(const months& dm) NOEXCEPT -{ - *this = *this - dm; - return *this; -} - -CONSTCD14 -inline -year_month& -year_month::operator+=(const years& dy) NOEXCEPT -{ - *this = *this + dy; - return *this; -} - -CONSTCD14 -inline -year_month& -year_month::operator-=(const years& dy) NOEXCEPT -{ - *this = *this - dy; - return *this; -} - -CONSTCD11 -inline -bool -operator==(const year_month& x, const year_month& y) NOEXCEPT -{ - return x.year() == y.year() && x.month() == y.month(); -} - -CONSTCD11 -inline -bool -operator!=(const year_month& x, const year_month& y) NOEXCEPT -{ - return !(x == y); -} - -CONSTCD11 -inline -bool -operator<(const year_month& x, const year_month& y) NOEXCEPT -{ - return x.year() < y.year() ? true - : (x.year() > y.year() ? false - : (x.month() < y.month())); -} - -CONSTCD11 -inline -bool -operator>(const year_month& x, const year_month& y) NOEXCEPT -{ - return y < x; -} - -CONSTCD11 -inline -bool -operator<=(const year_month& x, const year_month& y) NOEXCEPT -{ - return !(y < x); -} - -CONSTCD11 -inline -bool -operator>=(const year_month& x, const year_month& y) NOEXCEPT -{ - return !(x < y); -} - -template -CONSTCD14 -inline -year_month -operator+(const year_month& ym, const months& dm) NOEXCEPT -{ - auto dmi = static_cast(static_cast(ym.month())) - 1 + dm.count(); - auto dy = (dmi >= 0 ? dmi : dmi-11) / 12; - dmi = dmi - dy * 12 + 1; - return (ym.year() + years(dy)) / month(static_cast(dmi)); -} - -template -CONSTCD14 -inline -year_month -operator+(const months& dm, const year_month& ym) NOEXCEPT -{ - return ym + dm; -} - -template -CONSTCD14 -inline -year_month -operator-(const year_month& ym, const months& dm) NOEXCEPT -{ - return ym + -dm; -} - -CONSTCD11 -inline -months -operator-(const year_month& x, const year_month& y) NOEXCEPT -{ - return (x.year() - y.year()) + - months(static_cast(x.month()) - static_cast(y.month())); -} - -CONSTCD11 -inline -year_month -operator+(const year_month& ym, const years& dy) NOEXCEPT -{ - return (ym.year() + dy) / ym.month(); -} - -CONSTCD11 -inline -year_month -operator+(const years& dy, const year_month& ym) NOEXCEPT -{ - return ym + dy; -} - -CONSTCD11 -inline -year_month -operator-(const year_month& ym, const years& dy) NOEXCEPT -{ - return ym + -dy; -} - -template -inline -std::basic_ostream& -operator<<(std::basic_ostream& os, const year_month& ym) -{ - return os << ym.year() << '/' << ym.month(); -} - -// month_day - -CONSTCD11 -inline -month_day::month_day(const date::month& m, const date::day& d) NOEXCEPT - : m_(m) - , d_(d) - {} - -CONSTCD11 inline date::month month_day::month() const NOEXCEPT {return m_;} -CONSTCD11 inline date::day month_day::day() const NOEXCEPT {return d_;} - -CONSTCD14 -inline -bool -month_day::ok() const NOEXCEPT -{ - CONSTDATA date::day d[] = - { - date::day(31), date::day(29), date::day(31), - date::day(30), date::day(31), date::day(30), - date::day(31), date::day(31), date::day(30), - date::day(31), date::day(30), date::day(31) - }; - return m_.ok() && date::day{1} <= d_ && d_ <= d[static_cast(m_)-1]; -} - -CONSTCD11 -inline -bool -operator==(const month_day& x, const month_day& y) NOEXCEPT -{ - return x.month() == y.month() && x.day() == y.day(); -} - -CONSTCD11 -inline -bool -operator!=(const month_day& x, const month_day& y) NOEXCEPT -{ - return !(x == y); -} - -CONSTCD11 -inline -bool -operator<(const month_day& x, const month_day& y) NOEXCEPT -{ - return x.month() < y.month() ? true - : (x.month() > y.month() ? false - : (x.day() < y.day())); -} - -CONSTCD11 -inline -bool -operator>(const month_day& x, const month_day& y) NOEXCEPT -{ - return y < x; -} - -CONSTCD11 -inline -bool -operator<=(const month_day& x, const month_day& y) NOEXCEPT -{ - return !(y < x); -} - -CONSTCD11 -inline -bool -operator>=(const month_day& x, const month_day& y) NOEXCEPT -{ - return !(x < y); -} - -template -inline -std::basic_ostream& -operator<<(std::basic_ostream& os, const month_day& md) -{ - return os << md.month() << '/' << md.day(); -} - -// month_day_last - -CONSTCD11 inline month month_day_last::month() const NOEXCEPT {return m_;} -CONSTCD11 inline bool month_day_last::ok() const NOEXCEPT {return m_.ok();} -CONSTCD11 inline month_day_last::month_day_last(const date::month& m) NOEXCEPT : m_(m) {} - -CONSTCD11 -inline -bool -operator==(const month_day_last& x, const month_day_last& y) NOEXCEPT -{ - return x.month() == y.month(); -} - -CONSTCD11 -inline -bool -operator!=(const month_day_last& x, const month_day_last& y) NOEXCEPT -{ - return !(x == y); -} - -CONSTCD11 -inline -bool -operator<(const month_day_last& x, const month_day_last& y) NOEXCEPT -{ - return x.month() < y.month(); -} - -CONSTCD11 -inline -bool -operator>(const month_day_last& x, const month_day_last& y) NOEXCEPT -{ - return y < x; -} - -CONSTCD11 -inline -bool -operator<=(const month_day_last& x, const month_day_last& y) NOEXCEPT -{ - return !(y < x); -} - -CONSTCD11 -inline -bool -operator>=(const month_day_last& x, const month_day_last& y) NOEXCEPT -{ - return !(x < y); -} - -template -inline -std::basic_ostream& -operator<<(std::basic_ostream& os, const month_day_last& mdl) -{ - return os << mdl.month() << "/last"; -} - -// month_weekday - -CONSTCD11 -inline -month_weekday::month_weekday(const date::month& m, - const date::weekday_indexed& wdi) NOEXCEPT - : m_(m) - , wdi_(wdi) - {} - -CONSTCD11 inline month month_weekday::month() const NOEXCEPT {return m_;} - -CONSTCD11 -inline -weekday_indexed -month_weekday::weekday_indexed() const NOEXCEPT -{ - return wdi_; -} - -CONSTCD11 -inline -bool -month_weekday::ok() const NOEXCEPT -{ - return m_.ok() && wdi_.ok(); -} - -CONSTCD11 -inline -bool -operator==(const month_weekday& x, const month_weekday& y) NOEXCEPT -{ - return x.month() == y.month() && x.weekday_indexed() == y.weekday_indexed(); -} - -CONSTCD11 -inline -bool -operator!=(const month_weekday& x, const month_weekday& y) NOEXCEPT -{ - return !(x == y); -} - -template -inline -std::basic_ostream& -operator<<(std::basic_ostream& os, const month_weekday& mwd) -{ - return os << mwd.month() << '/' << mwd.weekday_indexed(); -} - -// month_weekday_last - -CONSTCD11 -inline -month_weekday_last::month_weekday_last(const date::month& m, - const date::weekday_last& wdl) NOEXCEPT - : m_(m) - , wdl_(wdl) - {} - -CONSTCD11 inline month month_weekday_last::month() const NOEXCEPT {return m_;} - -CONSTCD11 -inline -weekday_last -month_weekday_last::weekday_last() const NOEXCEPT -{ - return wdl_; -} - -CONSTCD11 -inline -bool -month_weekday_last::ok() const NOEXCEPT -{ - return m_.ok() && wdl_.ok(); -} - -CONSTCD11 -inline -bool -operator==(const month_weekday_last& x, const month_weekday_last& y) NOEXCEPT -{ - return x.month() == y.month() && x.weekday_last() == y.weekday_last(); -} - -CONSTCD11 -inline -bool -operator!=(const month_weekday_last& x, const month_weekday_last& y) NOEXCEPT -{ - return !(x == y); -} - -template -inline -std::basic_ostream& -operator<<(std::basic_ostream& os, const month_weekday_last& mwdl) -{ - return os << mwdl.month() << '/' << mwdl.weekday_last(); -} - -// year_month_day_last - -CONSTCD11 -inline -year_month_day_last::year_month_day_last(const date::year& y, - const date::month_day_last& mdl) NOEXCEPT - : y_(y) - , mdl_(mdl) - {} - -template -CONSTCD14 -inline -year_month_day_last& -year_month_day_last::operator+=(const months& m) NOEXCEPT -{ - *this = *this + m; - return *this; -} - -template -CONSTCD14 -inline -year_month_day_last& -year_month_day_last::operator-=(const months& m) NOEXCEPT -{ - *this = *this - m; - return *this; -} - -CONSTCD14 -inline -year_month_day_last& -year_month_day_last::operator+=(const years& y) NOEXCEPT -{ - *this = *this + y; - return *this; -} - -CONSTCD14 -inline -year_month_day_last& -year_month_day_last::operator-=(const years& y) NOEXCEPT -{ - *this = *this - y; - return *this; -} - -CONSTCD11 inline year year_month_day_last::year() const NOEXCEPT {return y_;} -CONSTCD11 inline month year_month_day_last::month() const NOEXCEPT {return mdl_.month();} - -CONSTCD11 -inline -month_day_last -year_month_day_last::month_day_last() const NOEXCEPT -{ - return mdl_; -} - -CONSTCD14 -inline -day -year_month_day_last::day() const NOEXCEPT -{ - CONSTDATA date::day d[] = - { - date::day(31), date::day(28), date::day(31), - date::day(30), date::day(31), date::day(30), - date::day(31), date::day(31), date::day(30), - date::day(31), date::day(30), date::day(31) - }; - return (month() != February || !y_.is_leap()) && mdl_.ok() ? - d[static_cast(month()) - 1] : date::day{29}; -} - -CONSTCD14 -inline -year_month_day_last::operator sys_days() const NOEXCEPT -{ - return sys_days(year()/month()/day()); -} - -CONSTCD14 -inline -year_month_day_last::operator local_days() const NOEXCEPT -{ - return local_days(year()/month()/day()); -} - -CONSTCD11 -inline -bool -year_month_day_last::ok() const NOEXCEPT -{ - return y_.ok() && mdl_.ok(); -} - -CONSTCD11 -inline -bool -operator==(const year_month_day_last& x, const year_month_day_last& y) NOEXCEPT -{ - return x.year() == y.year() && x.month_day_last() == y.month_day_last(); -} - -CONSTCD11 -inline -bool -operator!=(const year_month_day_last& x, const year_month_day_last& y) NOEXCEPT -{ - return !(x == y); -} - -CONSTCD11 -inline -bool -operator<(const year_month_day_last& x, const year_month_day_last& y) NOEXCEPT -{ - return x.year() < y.year() ? true - : (x.year() > y.year() ? false - : (x.month_day_last() < y.month_day_last())); -} - -CONSTCD11 -inline -bool -operator>(const year_month_day_last& x, const year_month_day_last& y) NOEXCEPT -{ - return y < x; -} - -CONSTCD11 -inline -bool -operator<=(const year_month_day_last& x, const year_month_day_last& y) NOEXCEPT -{ - return !(y < x); -} - -CONSTCD11 -inline -bool -operator>=(const year_month_day_last& x, const year_month_day_last& y) NOEXCEPT -{ - return !(x < y); -} - -template -inline -std::basic_ostream& -operator<<(std::basic_ostream& os, const year_month_day_last& ymdl) -{ - return os << ymdl.year() << '/' << ymdl.month_day_last(); -} - -template -CONSTCD14 -inline -year_month_day_last -operator+(const year_month_day_last& ymdl, const months& dm) NOEXCEPT -{ - return (ymdl.year() / ymdl.month() + dm) / last; -} - -template -CONSTCD14 -inline -year_month_day_last -operator+(const months& dm, const year_month_day_last& ymdl) NOEXCEPT -{ - return ymdl + dm; -} - -template -CONSTCD14 -inline -year_month_day_last -operator-(const year_month_day_last& ymdl, const months& dm) NOEXCEPT -{ - return ymdl + (-dm); -} - -CONSTCD11 -inline -year_month_day_last -operator+(const year_month_day_last& ymdl, const years& dy) NOEXCEPT -{ - return {ymdl.year()+dy, ymdl.month_day_last()}; -} - -CONSTCD11 -inline -year_month_day_last -operator+(const years& dy, const year_month_day_last& ymdl) NOEXCEPT -{ - return ymdl + dy; -} - -CONSTCD11 -inline -year_month_day_last -operator-(const year_month_day_last& ymdl, const years& dy) NOEXCEPT -{ - return ymdl + (-dy); -} - -// year_month_day - -CONSTCD11 -inline -year_month_day::year_month_day(const date::year& y, const date::month& m, - const date::day& d) NOEXCEPT - : y_(y) - , m_(m) - , d_(d) - {} - -CONSTCD14 -inline -year_month_day::year_month_day(const year_month_day_last& ymdl) NOEXCEPT - : y_(ymdl.year()) - , m_(ymdl.month()) - , d_(ymdl.day()) - {} - -CONSTCD14 -inline -year_month_day::year_month_day(sys_days dp) NOEXCEPT - : year_month_day(from_days(dp.time_since_epoch())) - {} - -CONSTCD14 -inline -year_month_day::year_month_day(local_days dp) NOEXCEPT - : year_month_day(from_days(dp.time_since_epoch())) - {} - -CONSTCD11 inline year year_month_day::year() const NOEXCEPT {return y_;} -CONSTCD11 inline month year_month_day::month() const NOEXCEPT {return m_;} -CONSTCD11 inline day year_month_day::day() const NOEXCEPT {return d_;} - -template -CONSTCD14 -inline -year_month_day& -year_month_day::operator+=(const months& m) NOEXCEPT -{ - *this = *this + m; - return *this; -} - -template -CONSTCD14 -inline -year_month_day& -year_month_day::operator-=(const months& m) NOEXCEPT -{ - *this = *this - m; - return *this; -} - -CONSTCD14 -inline -year_month_day& -year_month_day::operator+=(const years& y) NOEXCEPT -{ - *this = *this + y; - return *this; -} - -CONSTCD14 -inline -year_month_day& -year_month_day::operator-=(const years& y) NOEXCEPT -{ - *this = *this - y; - return *this; -} - -CONSTCD14 -inline -days -year_month_day::to_days() const NOEXCEPT -{ - static_assert(std::numeric_limits::digits >= 18, - "This algorithm has not been ported to a 16 bit unsigned integer"); - static_assert(std::numeric_limits::digits >= 20, - "This algorithm has not been ported to a 16 bit signed integer"); - auto const y = static_cast(y_) - (m_ <= February); - auto const m = static_cast(m_); - auto const d = static_cast(d_); - auto const era = (y >= 0 ? y : y-399) / 400; - auto const yoe = static_cast(y - era * 400); // [0, 399] - auto const doy = (153*(m > 2 ? m-3 : m+9) + 2)/5 + d-1; // [0, 365] - auto const doe = yoe * 365 + yoe/4 - yoe/100 + doy; // [0, 146096] - return days{era * 146097 + static_cast(doe) - 719468}; -} - -CONSTCD14 -inline -year_month_day::operator sys_days() const NOEXCEPT -{ - return sys_days{to_days()}; -} - -CONSTCD14 -inline -year_month_day::operator local_days() const NOEXCEPT -{ - return local_days{to_days()}; -} - -CONSTCD14 -inline -bool -year_month_day::ok() const NOEXCEPT -{ - if (!(y_.ok() && m_.ok())) - return false; - return date::day{1} <= d_ && d_ <= (y_ / m_ / last).day(); -} - -CONSTCD11 -inline -bool -operator==(const year_month_day& x, const year_month_day& y) NOEXCEPT -{ - return x.year() == y.year() && x.month() == y.month() && x.day() == y.day(); -} - -CONSTCD11 -inline -bool -operator!=(const year_month_day& x, const year_month_day& y) NOEXCEPT -{ - return !(x == y); -} - -CONSTCD11 -inline -bool -operator<(const year_month_day& x, const year_month_day& y) NOEXCEPT -{ - return x.year() < y.year() ? true - : (x.year() > y.year() ? false - : (x.month() < y.month() ? true - : (x.month() > y.month() ? false - : (x.day() < y.day())))); -} - -CONSTCD11 -inline -bool -operator>(const year_month_day& x, const year_month_day& y) NOEXCEPT -{ - return y < x; -} - -CONSTCD11 -inline -bool -operator<=(const year_month_day& x, const year_month_day& y) NOEXCEPT -{ - return !(y < x); -} - -CONSTCD11 -inline -bool -operator>=(const year_month_day& x, const year_month_day& y) NOEXCEPT -{ - return !(x < y); -} - -template -inline -std::basic_ostream& -operator<<(std::basic_ostream& os, const year_month_day& ymd) -{ - detail::save_ostream _(os); - os.fill('0'); - os.flags(std::ios::dec | std::ios::right); - os << ymd.year() << '-'; - os.width(2); - os << static_cast(ymd.month()) << '-'; - os << ymd.day(); - if (!ymd.ok()) - os << " is not a valid date"; - return os; -} - -CONSTCD14 -inline -year_month_day -year_month_day::from_days(days dp) NOEXCEPT -{ - static_assert(std::numeric_limits::digits >= 18, - "This algorithm has not been ported to a 16 bit unsigned integer"); - static_assert(std::numeric_limits::digits >= 20, - "This algorithm has not been ported to a 16 bit signed integer"); - auto const z = dp.count() + 719468; - auto const era = (z >= 0 ? z : z - 146096) / 146097; - auto const doe = static_cast(z - era * 146097); // [0, 146096] - auto const yoe = (doe - doe/1460 + doe/36524 - doe/146096) / 365; // [0, 399] - auto const y = static_cast(yoe) + era * 400; - auto const doy = doe - (365*yoe + yoe/4 - yoe/100); // [0, 365] - auto const mp = (5*doy + 2)/153; // [0, 11] - auto const d = doy - (153*mp+2)/5 + 1; // [1, 31] - auto const m = mp < 10 ? mp+3 : mp-9; // [1, 12] - return year_month_day{date::year{y + (m <= 2)}, date::month(m), date::day(d)}; -} - -template -CONSTCD14 -inline -year_month_day -operator+(const year_month_day& ymd, const months& dm) NOEXCEPT -{ - return (ymd.year() / ymd.month() + dm) / ymd.day(); -} - -template -CONSTCD14 -inline -year_month_day -operator+(const months& dm, const year_month_day& ymd) NOEXCEPT -{ - return ymd + dm; -} - -template -CONSTCD14 -inline -year_month_day -operator-(const year_month_day& ymd, const months& dm) NOEXCEPT -{ - return ymd + (-dm); -} - -CONSTCD11 -inline -year_month_day -operator+(const year_month_day& ymd, const years& dy) NOEXCEPT -{ - return (ymd.year() + dy) / ymd.month() / ymd.day(); -} - -CONSTCD11 -inline -year_month_day -operator+(const years& dy, const year_month_day& ymd) NOEXCEPT -{ - return ymd + dy; -} - -CONSTCD11 -inline -year_month_day -operator-(const year_month_day& ymd, const years& dy) NOEXCEPT -{ - return ymd + (-dy); -} - -// year_month_weekday - -CONSTCD11 -inline -year_month_weekday::year_month_weekday(const date::year& y, const date::month& m, - const date::weekday_indexed& wdi) - NOEXCEPT - : y_(y) - , m_(m) - , wdi_(wdi) - {} - -CONSTCD14 -inline -year_month_weekday::year_month_weekday(const sys_days& dp) NOEXCEPT - : year_month_weekday(from_days(dp.time_since_epoch())) - {} - -CONSTCD14 -inline -year_month_weekday::year_month_weekday(const local_days& dp) NOEXCEPT - : year_month_weekday(from_days(dp.time_since_epoch())) - {} - -template -CONSTCD14 -inline -year_month_weekday& -year_month_weekday::operator+=(const months& m) NOEXCEPT -{ - *this = *this + m; - return *this; -} - -template -CONSTCD14 -inline -year_month_weekday& -year_month_weekday::operator-=(const months& m) NOEXCEPT -{ - *this = *this - m; - return *this; -} - -CONSTCD14 -inline -year_month_weekday& -year_month_weekday::operator+=(const years& y) NOEXCEPT -{ - *this = *this + y; - return *this; -} - -CONSTCD14 -inline -year_month_weekday& -year_month_weekday::operator-=(const years& y) NOEXCEPT -{ - *this = *this - y; - return *this; -} - -CONSTCD11 inline year year_month_weekday::year() const NOEXCEPT {return y_;} -CONSTCD11 inline month year_month_weekday::month() const NOEXCEPT {return m_;} - -CONSTCD11 -inline -weekday -year_month_weekday::weekday() const NOEXCEPT -{ - return wdi_.weekday(); -} - -CONSTCD11 -inline -unsigned -year_month_weekday::index() const NOEXCEPT -{ - return wdi_.index(); -} - -CONSTCD11 -inline -weekday_indexed -year_month_weekday::weekday_indexed() const NOEXCEPT -{ - return wdi_; -} - -CONSTCD14 -inline -year_month_weekday::operator sys_days() const NOEXCEPT -{ - return sys_days{to_days()}; -} - -CONSTCD14 -inline -year_month_weekday::operator local_days() const NOEXCEPT -{ - return local_days{to_days()}; -} - -CONSTCD14 -inline -bool -year_month_weekday::ok() const NOEXCEPT -{ - if (!y_.ok() || !m_.ok() || !wdi_.weekday().ok() || wdi_.index() < 1) - return false; - if (wdi_.index() <= 4) - return true; - auto d2 = wdi_.weekday() - date::weekday(static_cast(y_/m_/1)) + - days((wdi_.index()-1)*7 + 1); - return static_cast(d2.count()) <= static_cast((y_/m_/last).day()); -} - -CONSTCD14 -inline -year_month_weekday -year_month_weekday::from_days(days d) NOEXCEPT -{ - sys_days dp{d}; - auto const wd = date::weekday(dp); - auto const ymd = year_month_day(dp); - return {ymd.year(), ymd.month(), wd[(static_cast(ymd.day())-1)/7+1]}; -} - -CONSTCD14 -inline -days -year_month_weekday::to_days() const NOEXCEPT -{ - auto d = sys_days(y_/m_/1); - return (d + (wdi_.weekday() - date::weekday(d) + days{(wdi_.index()-1)*7}) - ).time_since_epoch(); -} - -CONSTCD11 -inline -bool -operator==(const year_month_weekday& x, const year_month_weekday& y) NOEXCEPT -{ - return x.year() == y.year() && x.month() == y.month() && - x.weekday_indexed() == y.weekday_indexed(); -} - -CONSTCD11 -inline -bool -operator!=(const year_month_weekday& x, const year_month_weekday& y) NOEXCEPT -{ - return !(x == y); -} - -template -inline -std::basic_ostream& -operator<<(std::basic_ostream& os, const year_month_weekday& ymwdi) -{ - return os << ymwdi.year() << '/' << ymwdi.month() - << '/' << ymwdi.weekday_indexed(); -} - -template -CONSTCD14 -inline -year_month_weekday -operator+(const year_month_weekday& ymwd, const months& dm) NOEXCEPT -{ - return (ymwd.year() / ymwd.month() + dm) / ymwd.weekday_indexed(); -} - -template -CONSTCD14 -inline -year_month_weekday -operator+(const months& dm, const year_month_weekday& ymwd) NOEXCEPT -{ - return ymwd + dm; -} - -template -CONSTCD14 -inline -year_month_weekday -operator-(const year_month_weekday& ymwd, const months& dm) NOEXCEPT -{ - return ymwd + (-dm); -} - -CONSTCD11 -inline -year_month_weekday -operator+(const year_month_weekday& ymwd, const years& dy) NOEXCEPT -{ - return {ymwd.year()+dy, ymwd.month(), ymwd.weekday_indexed()}; -} - -CONSTCD11 -inline -year_month_weekday -operator+(const years& dy, const year_month_weekday& ymwd) NOEXCEPT -{ - return ymwd + dy; -} - -CONSTCD11 -inline -year_month_weekday -operator-(const year_month_weekday& ymwd, const years& dy) NOEXCEPT -{ - return ymwd + (-dy); -} - -// year_month_weekday_last - -CONSTCD11 -inline -year_month_weekday_last::year_month_weekday_last(const date::year& y, - const date::month& m, - const date::weekday_last& wdl) NOEXCEPT - : y_(y) - , m_(m) - , wdl_(wdl) - {} - -template -CONSTCD14 -inline -year_month_weekday_last& -year_month_weekday_last::operator+=(const months& m) NOEXCEPT -{ - *this = *this + m; - return *this; -} - -template -CONSTCD14 -inline -year_month_weekday_last& -year_month_weekday_last::operator-=(const months& m) NOEXCEPT -{ - *this = *this - m; - return *this; -} - -CONSTCD14 -inline -year_month_weekday_last& -year_month_weekday_last::operator+=(const years& y) NOEXCEPT -{ - *this = *this + y; - return *this; -} - -CONSTCD14 -inline -year_month_weekday_last& -year_month_weekday_last::operator-=(const years& y) NOEXCEPT -{ - *this = *this - y; - return *this; -} - -CONSTCD11 inline year year_month_weekday_last::year() const NOEXCEPT {return y_;} -CONSTCD11 inline month year_month_weekday_last::month() const NOEXCEPT {return m_;} - -CONSTCD11 -inline -weekday -year_month_weekday_last::weekday() const NOEXCEPT -{ - return wdl_.weekday(); -} - -CONSTCD11 -inline -weekday_last -year_month_weekday_last::weekday_last() const NOEXCEPT -{ - return wdl_; -} - -CONSTCD14 -inline -year_month_weekday_last::operator sys_days() const NOEXCEPT -{ - return sys_days{to_days()}; -} - -CONSTCD14 -inline -year_month_weekday_last::operator local_days() const NOEXCEPT -{ - return local_days{to_days()}; -} - -CONSTCD11 -inline -bool -year_month_weekday_last::ok() const NOEXCEPT -{ - return y_.ok() && m_.ok() && wdl_.ok(); -} - -CONSTCD14 -inline -days -year_month_weekday_last::to_days() const NOEXCEPT -{ - auto const d = sys_days(y_/m_/last); - return (d - (date::weekday{d} - wdl_.weekday())).time_since_epoch(); -} - -CONSTCD11 -inline -bool -operator==(const year_month_weekday_last& x, const year_month_weekday_last& y) NOEXCEPT -{ - return x.year() == y.year() && x.month() == y.month() && - x.weekday_last() == y.weekday_last(); -} - -CONSTCD11 -inline -bool -operator!=(const year_month_weekday_last& x, const year_month_weekday_last& y) NOEXCEPT -{ - return !(x == y); -} - -template -inline -std::basic_ostream& -operator<<(std::basic_ostream& os, const year_month_weekday_last& ymwdl) -{ - return os << ymwdl.year() << '/' << ymwdl.month() << '/' << ymwdl.weekday_last(); -} - -template -CONSTCD14 -inline -year_month_weekday_last -operator+(const year_month_weekday_last& ymwdl, const months& dm) NOEXCEPT -{ - return (ymwdl.year() / ymwdl.month() + dm) / ymwdl.weekday_last(); -} - -template -CONSTCD14 -inline -year_month_weekday_last -operator+(const months& dm, const year_month_weekday_last& ymwdl) NOEXCEPT -{ - return ymwdl + dm; -} - -template -CONSTCD14 -inline -year_month_weekday_last -operator-(const year_month_weekday_last& ymwdl, const months& dm) NOEXCEPT -{ - return ymwdl + (-dm); -} - -CONSTCD11 -inline -year_month_weekday_last -operator+(const year_month_weekday_last& ymwdl, const years& dy) NOEXCEPT -{ - return {ymwdl.year()+dy, ymwdl.month(), ymwdl.weekday_last()}; -} - -CONSTCD11 -inline -year_month_weekday_last -operator+(const years& dy, const year_month_weekday_last& ymwdl) NOEXCEPT -{ - return ymwdl + dy; -} - -CONSTCD11 -inline -year_month_weekday_last -operator-(const year_month_weekday_last& ymwdl, const years& dy) NOEXCEPT -{ - return ymwdl + (-dy); -} - -// year_month from operator/() - -CONSTCD11 -inline -year_month -operator/(const year& y, const month& m) NOEXCEPT -{ - return {y, m}; -} - -CONSTCD11 -inline -year_month -operator/(const year& y, int m) NOEXCEPT -{ - return y / month(static_cast(m)); -} - -// month_day from operator/() - -CONSTCD11 -inline -month_day -operator/(const month& m, const day& d) NOEXCEPT -{ - return {m, d}; -} - -CONSTCD11 -inline -month_day -operator/(const day& d, const month& m) NOEXCEPT -{ - return m / d; -} - -CONSTCD11 -inline -month_day -operator/(const month& m, int d) NOEXCEPT -{ - return m / day(static_cast(d)); -} - -CONSTCD11 -inline -month_day -operator/(int m, const day& d) NOEXCEPT -{ - return month(static_cast(m)) / d; -} - -CONSTCD11 inline month_day operator/(const day& d, int m) NOEXCEPT {return m / d;} - -// month_day_last from operator/() - -CONSTCD11 -inline -month_day_last -operator/(const month& m, last_spec) NOEXCEPT -{ - return month_day_last{m}; -} - -CONSTCD11 -inline -month_day_last -operator/(last_spec, const month& m) NOEXCEPT -{ - return m/last; -} - -CONSTCD11 -inline -month_day_last -operator/(int m, last_spec) NOEXCEPT -{ - return month(static_cast(m))/last; -} - -CONSTCD11 -inline -month_day_last -operator/(last_spec, int m) NOEXCEPT -{ - return m/last; -} - -// month_weekday from operator/() - -CONSTCD11 -inline -month_weekday -operator/(const month& m, const weekday_indexed& wdi) NOEXCEPT -{ - return {m, wdi}; -} - -CONSTCD11 -inline -month_weekday -operator/(const weekday_indexed& wdi, const month& m) NOEXCEPT -{ - return m / wdi; -} - -CONSTCD11 -inline -month_weekday -operator/(int m, const weekday_indexed& wdi) NOEXCEPT -{ - return month(static_cast(m)) / wdi; -} - -CONSTCD11 -inline -month_weekday -operator/(const weekday_indexed& wdi, int m) NOEXCEPT -{ - return m / wdi; -} - -// month_weekday_last from operator/() - -CONSTCD11 -inline -month_weekday_last -operator/(const month& m, const weekday_last& wdl) NOEXCEPT -{ - return {m, wdl}; -} - -CONSTCD11 -inline -month_weekday_last -operator/(const weekday_last& wdl, const month& m) NOEXCEPT -{ - return m / wdl; -} - -CONSTCD11 -inline -month_weekday_last -operator/(int m, const weekday_last& wdl) NOEXCEPT -{ - return month(static_cast(m)) / wdl; -} - -CONSTCD11 -inline -month_weekday_last -operator/(const weekday_last& wdl, int m) NOEXCEPT -{ - return m / wdl; -} - -// year_month_day from operator/() - -CONSTCD11 -inline -year_month_day -operator/(const year_month& ym, const day& d) NOEXCEPT -{ - return {ym.year(), ym.month(), d}; -} - -CONSTCD11 -inline -year_month_day -operator/(const year_month& ym, int d) NOEXCEPT -{ - return ym / day(static_cast(d)); -} - -CONSTCD11 -inline -year_month_day -operator/(const year& y, const month_day& md) NOEXCEPT -{ - return y / md.month() / md.day(); -} - -CONSTCD11 -inline -year_month_day -operator/(int y, const month_day& md) NOEXCEPT -{ - return year(y) / md; -} - -CONSTCD11 -inline -year_month_day -operator/(const month_day& md, const year& y) NOEXCEPT -{ - return y / md; -} - -CONSTCD11 -inline -year_month_day -operator/(const month_day& md, int y) NOEXCEPT -{ - return year(y) / md; -} - -// year_month_day_last from operator/() - -CONSTCD11 -inline -year_month_day_last -operator/(const year_month& ym, last_spec) NOEXCEPT -{ - return {ym.year(), month_day_last{ym.month()}}; -} - -CONSTCD11 -inline -year_month_day_last -operator/(const year& y, const month_day_last& mdl) NOEXCEPT -{ - return {y, mdl}; -} - -CONSTCD11 -inline -year_month_day_last -operator/(int y, const month_day_last& mdl) NOEXCEPT -{ - return year(y) / mdl; -} - -CONSTCD11 -inline -year_month_day_last -operator/(const month_day_last& mdl, const year& y) NOEXCEPT -{ - return y / mdl; -} - -CONSTCD11 -inline -year_month_day_last -operator/(const month_day_last& mdl, int y) NOEXCEPT -{ - return year(y) / mdl; -} - -// year_month_weekday from operator/() - -CONSTCD11 -inline -year_month_weekday -operator/(const year_month& ym, const weekday_indexed& wdi) NOEXCEPT -{ - return {ym.year(), ym.month(), wdi}; -} - -CONSTCD11 -inline -year_month_weekday -operator/(const year& y, const month_weekday& mwd) NOEXCEPT -{ - return {y, mwd.month(), mwd.weekday_indexed()}; -} - -CONSTCD11 -inline -year_month_weekday -operator/(int y, const month_weekday& mwd) NOEXCEPT -{ - return year(y) / mwd; -} - -CONSTCD11 -inline -year_month_weekday -operator/(const month_weekday& mwd, const year& y) NOEXCEPT -{ - return y / mwd; -} - -CONSTCD11 -inline -year_month_weekday -operator/(const month_weekday& mwd, int y) NOEXCEPT -{ - return year(y) / mwd; -} - -// year_month_weekday_last from operator/() - -CONSTCD11 -inline -year_month_weekday_last -operator/(const year_month& ym, const weekday_last& wdl) NOEXCEPT -{ - return {ym.year(), ym.month(), wdl}; -} - -CONSTCD11 -inline -year_month_weekday_last -operator/(const year& y, const month_weekday_last& mwdl) NOEXCEPT -{ - return {y, mwdl.month(), mwdl.weekday_last()}; -} - -CONSTCD11 -inline -year_month_weekday_last -operator/(int y, const month_weekday_last& mwdl) NOEXCEPT -{ - return year(y) / mwdl; -} - -CONSTCD11 -inline -year_month_weekday_last -operator/(const month_weekday_last& mwdl, const year& y) NOEXCEPT -{ - return y / mwdl; -} - -CONSTCD11 -inline -year_month_weekday_last -operator/(const month_weekday_last& mwdl, int y) NOEXCEPT -{ - return year(y) / mwdl; -} - -template -struct fields; - -template -std::basic_ostream& -to_stream(std::basic_ostream& os, const CharT* fmt, - const fields& fds, const std::string* abbrev = nullptr, - const std::chrono::seconds* offset_sec = nullptr); - -template -std::basic_istream& -from_stream(std::basic_istream& is, const CharT* fmt, - fields& fds, std::basic_string* abbrev = nullptr, - std::chrono::minutes* offset = nullptr); - -// hh_mm_ss - -namespace detail -{ - -struct undocumented {explicit undocumented() = default;}; - -// width::value is the number of fractional decimal digits in 1/n -// width<0>::value and width<1>::value are defined to be 0 -// If 1/n takes more than 18 fractional decimal digits, -// the result is truncated to 19. -// Example: width<2>::value == 1 -// Example: width<3>::value == 19 -// Example: width<4>::value == 2 -// Example: width<10>::value == 1 -// Example: width<1000>::value == 3 -template -struct width -{ - static CONSTDATA unsigned value = 1 + width::value; -}; - -template -struct width -{ - static CONSTDATA unsigned value = 0; -}; - -template -struct static_pow10 -{ -private: - static CONSTDATA std::uint64_t h = static_pow10::value; -public: - static CONSTDATA std::uint64_t value = h * h * (exp % 2 ? 10 : 1); -}; - -template <> -struct static_pow10<0> -{ - static CONSTDATA std::uint64_t value = 1; -}; - -template -class decimal_format_seconds -{ - using CT = typename std::common_type::type; - using rep = typename CT::rep; -public: - static unsigned constexpr width = detail::width::value < 19 ? - detail::width::value : 6u; - using precision = std::chrono::duration::value>>; - -private: - std::chrono::seconds s_; - precision sub_s_; - -public: - CONSTCD11 decimal_format_seconds() - : s_() - , sub_s_() - {} - - CONSTCD11 explicit decimal_format_seconds(const Duration& d) NOEXCEPT - : s_(std::chrono::duration_cast(d)) - , sub_s_(std::chrono::treat_as_floating_point::value ? d - s_ : - std::chrono::duration_cast(d - s_)) - {} - - CONSTCD14 std::chrono::seconds& seconds() NOEXCEPT {return s_;} - CONSTCD11 std::chrono::seconds seconds() const NOEXCEPT {return s_;} - CONSTCD11 precision subseconds() const NOEXCEPT {return sub_s_;} - - CONSTCD14 precision to_duration() const NOEXCEPT - { - return s_ + sub_s_; - } - - CONSTCD11 bool in_conventional_range() const NOEXCEPT - { - return sub_s_ < std::chrono::seconds{1} && s_ < std::chrono::minutes{1}; - } - - template - friend - std::basic_ostream& - operator<<(std::basic_ostream& os, const decimal_format_seconds& x) - { - return x.print(os, std::chrono::treat_as_floating_point{}); - } - - template - std::basic_ostream& - print(std::basic_ostream& os, std::true_type) const - { - date::detail::save_ostream _(os); - std::chrono::duration d = s_ + sub_s_; - if (d < std::chrono::seconds{10}) - os << '0'; - os << std::fixed << d.count(); - return os; - } - - template - std::basic_ostream& - print(std::basic_ostream& os, std::false_type) const - { - date::detail::save_ostream _(os); - os.fill('0'); - os.flags(std::ios::dec | std::ios::right); - os.width(2); - os << s_.count(); - if (width > 0) - { -#if !ONLY_C_LOCALE - os << std::use_facet>(os.getloc()).decimal_point(); -#else - os << '.'; -#endif - os.width(width); - os << sub_s_.count(); - } - return os; - } -}; - -template -inline -CONSTCD11 -typename std::enable_if - < - std::numeric_limits::is_signed, - std::chrono::duration - >::type -abs(std::chrono::duration d) -{ - return d >= d.zero() ? +d : -d; -} - -template -inline -CONSTCD11 -typename std::enable_if - < - !std::numeric_limits::is_signed, - std::chrono::duration - >::type -abs(std::chrono::duration d) -{ - return d; -} - -} // namespace detail - -template -class hh_mm_ss -{ - using dfs = detail::decimal_format_seconds::type>; - - std::chrono::hours h_; - std::chrono::minutes m_; - dfs s_; - bool neg_; - -public: - static unsigned CONSTDATA fractional_width = dfs::width; - using precision = typename dfs::precision; - - CONSTCD11 hh_mm_ss() NOEXCEPT - : hh_mm_ss(Duration::zero()) - {} - - CONSTCD11 explicit hh_mm_ss(Duration d) NOEXCEPT - : h_(std::chrono::duration_cast(detail::abs(d))) - , m_(std::chrono::duration_cast(detail::abs(d)) - h_) - , s_(detail::abs(d) - h_ - m_) - , neg_(d < Duration::zero()) - {} - - CONSTCD11 std::chrono::hours hours() const NOEXCEPT {return h_;} - CONSTCD11 std::chrono::minutes minutes() const NOEXCEPT {return m_;} - CONSTCD11 std::chrono::seconds seconds() const NOEXCEPT {return s_.seconds();} - CONSTCD14 std::chrono::seconds& - seconds(detail::undocumented) NOEXCEPT {return s_.seconds();} - CONSTCD11 precision subseconds() const NOEXCEPT {return s_.subseconds();} - CONSTCD11 bool is_negative() const NOEXCEPT {return neg_;} - - CONSTCD11 explicit operator precision() const NOEXCEPT {return to_duration();} - CONSTCD11 precision to_duration() const NOEXCEPT - {return (h_ + m_ + s_.to_duration()) * (1-2*neg_);} - - CONSTCD11 bool in_conventional_range() const NOEXCEPT - { - return !neg_ && h_ < days{1} && m_ < std::chrono::hours{1} && - s_.in_conventional_range(); - } - -private: - - template - friend - std::basic_ostream& - operator<<(std::basic_ostream& os, hh_mm_ss const& tod) - { - if (tod.is_negative()) - os << '-'; - if (tod.h_ < std::chrono::hours{10}) - os << '0'; - os << tod.h_.count() << ':'; - if (tod.m_ < std::chrono::minutes{10}) - os << '0'; - os << tod.m_.count() << ':' << tod.s_; - return os; - } - - template - friend - std::basic_ostream& - date::to_stream(std::basic_ostream& os, const CharT* fmt, - const fields& fds, const std::string* abbrev, - const std::chrono::seconds* offset_sec); - - template - friend - std::basic_istream& - date::from_stream(std::basic_istream& is, const CharT* fmt, - fields& fds, - std::basic_string* abbrev, std::chrono::minutes* offset); -}; - -inline -CONSTCD14 -bool -is_am(std::chrono::hours const& h) NOEXCEPT -{ - using std::chrono::hours; - return hours{0} <= h && h < hours{12}; -} - -inline -CONSTCD14 -bool -is_pm(std::chrono::hours const& h) NOEXCEPT -{ - using std::chrono::hours; - return hours{12} <= h && h < hours{24}; -} - -inline -CONSTCD14 -std::chrono::hours -make12(std::chrono::hours h) NOEXCEPT -{ - using std::chrono::hours; - if (h < hours{12}) - { - if (h == hours{0}) - h = hours{12}; - } - else - { - if (h != hours{12}) - h -= hours{12}; - } - return h; -} - -inline -CONSTCD14 -std::chrono::hours -make24(std::chrono::hours h, bool is_pm) NOEXCEPT -{ - using std::chrono::hours; - if (is_pm) - { - if (h != hours{12}) - h += hours{12}; - } - else if (h == hours{12}) - h = hours{0}; - return h; -} - -template -using time_of_day = hh_mm_ss; - -template ::value>::type> -CONSTCD11 -inline -hh_mm_ss> -make_time(const std::chrono::duration& d) -{ - return hh_mm_ss>(d); -} - -template -inline -typename std::enable_if -< - !std::chrono::treat_as_floating_point::value && - std::ratio_less::value - , std::basic_ostream& ->::type -operator<<(std::basic_ostream& os, const sys_time& tp) -{ - auto const dp = date::floor(tp); - return os << year_month_day(dp) << ' ' << make_time(tp-dp); -} - -template -inline -std::basic_ostream& -operator<<(std::basic_ostream& os, const sys_days& dp) -{ - return os << year_month_day(dp); -} - -template -inline -std::basic_ostream& -operator<<(std::basic_ostream& os, const local_time& ut) -{ - return (os << sys_time{ut.time_since_epoch()}); -} - -namespace detail -{ - -template -class string_literal; - -template -inline -CONSTCD14 -string_literal::type, - N1 + N2 - 1> -operator+(const string_literal& x, const string_literal& y) NOEXCEPT; - -template -class string_literal -{ - CharT p_[N]; - - CONSTCD11 string_literal() NOEXCEPT - : p_{} - {} - -public: - using const_iterator = const CharT*; - - string_literal(string_literal const&) = default; - string_literal& operator=(string_literal const&) = delete; - - template ::type> - CONSTCD11 string_literal(CharT c) NOEXCEPT - : p_{c} - { - } - - template ::type> - CONSTCD11 string_literal(CharT c1, CharT c2) NOEXCEPT - : p_{c1, c2} - { - } - - template ::type> - CONSTCD11 string_literal(CharT c1, CharT c2, CharT c3) NOEXCEPT - : p_{c1, c2, c3} - { - } - - CONSTCD14 string_literal(const CharT(&a)[N]) NOEXCEPT - : p_{} - { - for (std::size_t i = 0; i < N; ++i) - p_[i] = a[i]; - } - - template ::type> - CONSTCD14 string_literal(const char(&a)[N]) NOEXCEPT - : p_{} - { - for (std::size_t i = 0; i < N; ++i) - p_[i] = a[i]; - } - - template ::value>::type> - CONSTCD14 string_literal(string_literal const& a) NOEXCEPT - : p_{} - { - for (std::size_t i = 0; i < N; ++i) - p_[i] = a[i]; - } - - CONSTCD11 const CharT* data() const NOEXCEPT {return p_;} - CONSTCD11 std::size_t size() const NOEXCEPT {return N-1;} - - CONSTCD11 const_iterator begin() const NOEXCEPT {return p_;} - CONSTCD11 const_iterator end() const NOEXCEPT {return p_ + N-1;} - - CONSTCD11 CharT const& operator[](std::size_t n) const NOEXCEPT - { - return p_[n]; - } - - template - friend - std::basic_ostream& - operator<<(std::basic_ostream& os, const string_literal& s) - { - return os << s.p_; - } - - template - friend - CONSTCD14 - string_literal::type, - N1 + N2 - 1> - operator+(const string_literal& x, const string_literal& y) NOEXCEPT; -}; - -template -CONSTCD11 -inline -string_literal -operator+(const string_literal& x, const string_literal& y) NOEXCEPT -{ - return string_literal(x[0], y[0]); -} - -template -CONSTCD11 -inline -string_literal -operator+(const string_literal& x, const string_literal& y) NOEXCEPT -{ - return string_literal(x[0], x[1], y[0]); -} - -template -CONSTCD14 -inline -string_literal::type, - N1 + N2 - 1> -operator+(const string_literal& x, const string_literal& y) NOEXCEPT -{ - using CT = typename std::conditional::type; - - string_literal r; - std::size_t i = 0; - for (; i < N1-1; ++i) - r.p_[i] = CT(x.p_[i]); - for (std::size_t j = 0; j < N2; ++j, ++i) - r.p_[i] = CT(y.p_[j]); - - return r; -} - - -template -inline -std::basic_string -operator+(std::basic_string x, const string_literal& y) -{ - x.append(y.data(), y.size()); - return x; -} - -#if __cplusplus >= 201402 && (!defined(__EDG_VERSION__) || __EDG_VERSION__ > 411) \ - && (!defined(__SUNPRO_CC) || __SUNPRO_CC > 0x5150) - -template {} || - std::is_same{} || - std::is_same{} || - std::is_same{}>> -CONSTCD14 -inline -string_literal -msl(CharT c) NOEXCEPT -{ - return string_literal{c}; -} - -CONSTCD14 -inline -std::size_t -to_string_len(std::intmax_t i) -{ - std::size_t r = 0; - do - { - i /= 10; - ++r; - } while (i > 0); - return r; -} - -template -CONSTCD14 -inline -std::enable_if_t -< - N < 10, - string_literal -> -msl() NOEXCEPT -{ - return msl(char(N % 10 + '0')); -} - -template -CONSTCD14 -inline -std::enable_if_t -< - 10 <= N, - string_literal -> -msl() NOEXCEPT -{ - return msl() + msl(char(N % 10 + '0')); -} - -template -CONSTCD14 -inline -std::enable_if_t -< - std::ratio::type::den != 1, - string_literal::type::num) + - to_string_len(std::ratio::type::den) + 4> -> -msl(std::ratio) NOEXCEPT -{ - using R = typename std::ratio::type; - return msl(CharT{'['}) + msl() + msl(CharT{'/'}) + - msl() + msl(CharT{']'}); -} - -template -CONSTCD14 -inline -std::enable_if_t -< - std::ratio::type::den == 1, - string_literal::type::num) + 3> -> -msl(std::ratio) NOEXCEPT -{ - using R = typename std::ratio::type; - return msl(CharT{'['}) + msl() + msl(CharT{']'}); -} - - -#else // __cplusplus < 201402 || (defined(__EDG_VERSION__) && __EDG_VERSION__ <= 411) - -inline -std::string -to_string(std::uint64_t x) -{ - return std::to_string(x); -} - -template -inline -std::basic_string -to_string(std::uint64_t x) -{ - auto y = std::to_string(x); - return std::basic_string(y.begin(), y.end()); -} - -template -inline -typename std::enable_if -< - std::ratio::type::den != 1, - std::basic_string ->::type -msl(std::ratio) -{ - using R = typename std::ratio::type; - return std::basic_string(1, '[') + to_string(R::num) + CharT{'/'} + - to_string(R::den) + CharT{']'}; -} - -template -inline -typename std::enable_if -< - std::ratio::type::den == 1, - std::basic_string ->::type -msl(std::ratio) -{ - using R = typename std::ratio::type; - return std::basic_string(1, '[') + to_string(R::num) + CharT{']'}; -} - -#endif // __cplusplus < 201402 || (defined(__EDG_VERSION__) && __EDG_VERSION__ <= 411) - -template -CONSTCD11 -inline -string_literal -msl(std::atto) NOEXCEPT -{ - return string_literal{'a'}; -} - -template -CONSTCD11 -inline -string_literal -msl(std::femto) NOEXCEPT -{ - return string_literal{'f'}; -} - -template -CONSTCD11 -inline -string_literal -msl(std::pico) NOEXCEPT -{ - return string_literal{'p'}; -} - -template -CONSTCD11 -inline -string_literal -msl(std::nano) NOEXCEPT -{ - return string_literal{'n'}; -} - -template -CONSTCD11 -inline -typename std::enable_if -< - std::is_same::value, - string_literal ->::type -msl(std::micro) NOEXCEPT -{ - return string_literal{'\xC2', '\xB5'}; -} - -template -CONSTCD11 -inline -typename std::enable_if -< - !std::is_same::value, - string_literal ->::type -msl(std::micro) NOEXCEPT -{ - return string_literal{CharT{static_cast('\xB5')}}; -} - -template -CONSTCD11 -inline -string_literal -msl(std::milli) NOEXCEPT -{ - return string_literal{'m'}; -} - -template -CONSTCD11 -inline -string_literal -msl(std::centi) NOEXCEPT -{ - return string_literal{'c'}; -} - -template -CONSTCD11 -inline -string_literal -msl(std::deca) NOEXCEPT -{ - return string_literal{'d', 'a'}; -} - -template -CONSTCD11 -inline -string_literal -msl(std::deci) NOEXCEPT -{ - return string_literal{'d'}; -} - -template -CONSTCD11 -inline -string_literal -msl(std::hecto) NOEXCEPT -{ - return string_literal{'h'}; -} - -template -CONSTCD11 -inline -string_literal -msl(std::kilo) NOEXCEPT -{ - return string_literal{'k'}; -} - -template -CONSTCD11 -inline -string_literal -msl(std::mega) NOEXCEPT -{ - return string_literal{'M'}; -} - -template -CONSTCD11 -inline -string_literal -msl(std::giga) NOEXCEPT -{ - return string_literal{'G'}; -} - -template -CONSTCD11 -inline -string_literal -msl(std::tera) NOEXCEPT -{ - return string_literal{'T'}; -} - -template -CONSTCD11 -inline -string_literal -msl(std::peta) NOEXCEPT -{ - return string_literal{'P'}; -} - -template -CONSTCD11 -inline -string_literal -msl(std::exa) NOEXCEPT -{ - return string_literal{'E'}; -} - -template -CONSTCD11 -inline -auto -get_units(Period p) - -> decltype(msl(p) + string_literal{'s'}) -{ - return msl(p) + string_literal{'s'}; -} - -template -CONSTCD11 -inline -string_literal -get_units(std::ratio<1>) -{ - return string_literal{'s'}; -} - -template -CONSTCD11 -inline -string_literal -get_units(std::ratio<3600>) -{ - return string_literal{'h'}; -} - -template -CONSTCD11 -inline -string_literal -get_units(std::ratio<60>) -{ - return string_literal{'m', 'i', 'n'}; -} - -template -CONSTCD11 -inline -string_literal -get_units(std::ratio<86400>) -{ - return string_literal{'d'}; -} - -template > -struct make_string; - -template <> -struct make_string -{ - template - static - std::string - from(Rep n) - { - return std::to_string(n); - } -}; - -template -struct make_string -{ - template - static - std::basic_string - from(Rep n) - { - auto s = std::to_string(n); - return std::basic_string(s.begin(), s.end()); - } -}; - -template <> -struct make_string -{ - template - static - std::wstring - from(Rep n) - { - return std::to_wstring(n); - } -}; - -template -struct make_string -{ - template - static - std::basic_string - from(Rep n) - { - auto s = std::to_wstring(n); - return std::basic_string(s.begin(), s.end()); - } -}; - -} // namespace detail - -// to_stream - -CONSTDATA year nanyear{-32768}; - -template -struct fields -{ - year_month_day ymd{nanyear/0/0}; - weekday wd{8u}; - hh_mm_ss tod{}; - bool has_tod = false; - - fields() = default; - - fields(year_month_day ymd_) : ymd(ymd_) {} - fields(weekday wd_) : wd(wd_) {} - fields(hh_mm_ss tod_) : tod(tod_), has_tod(true) {} - - fields(year_month_day ymd_, weekday wd_) : ymd(ymd_), wd(wd_) {} - fields(year_month_day ymd_, hh_mm_ss tod_) : ymd(ymd_), tod(tod_), - has_tod(true) {} - - fields(weekday wd_, hh_mm_ss tod_) : wd(wd_), tod(tod_), has_tod(true) {} - - fields(year_month_day ymd_, weekday wd_, hh_mm_ss tod_) - : ymd(ymd_) - , wd(wd_) - , tod(tod_) - , has_tod(true) - {} -}; - -namespace detail -{ - -template -unsigned -extract_weekday(std::basic_ostream& os, const fields& fds) -{ - if (!fds.ymd.ok() && !fds.wd.ok()) - { - // fds does not contain a valid weekday - os.setstate(std::ios::failbit); - return 8; - } - weekday wd; - if (fds.ymd.ok()) - { - wd = weekday{sys_days(fds.ymd)}; - if (fds.wd.ok() && wd != fds.wd) - { - // fds.ymd and fds.wd are inconsistent - os.setstate(std::ios::failbit); - return 8; - } - } - else - wd = fds.wd; - return static_cast((wd - Sunday).count()); -} - -template -unsigned -extract_month(std::basic_ostream& os, const fields& fds) -{ - if (!fds.ymd.month().ok()) - { - // fds does not contain a valid month - os.setstate(std::ios::failbit); - return 0; - } - return static_cast(fds.ymd.month()); -} - -} // namespace detail - -#if ONLY_C_LOCALE - -namespace detail -{ - -inline -std::pair -weekday_names() -{ - static const std::string nm[] = - { - "Sunday", - "Monday", - "Tuesday", - "Wednesday", - "Thursday", - "Friday", - "Saturday", - "Sun", - "Mon", - "Tue", - "Wed", - "Thu", - "Fri", - "Sat" - }; - return std::make_pair(nm, nm+sizeof(nm)/sizeof(nm[0])); -} - -inline -std::pair -month_names() -{ - static const std::string nm[] = - { - "January", - "February", - "March", - "April", - "May", - "June", - "July", - "August", - "September", - "October", - "November", - "December", - "Jan", - "Feb", - "Mar", - "Apr", - "May", - "Jun", - "Jul", - "Aug", - "Sep", - "Oct", - "Nov", - "Dec" - }; - return std::make_pair(nm, nm+sizeof(nm)/sizeof(nm[0])); -} - -inline -std::pair -ampm_names() -{ - static const std::string nm[] = - { - "AM", - "PM" - }; - return std::make_pair(nm, nm+sizeof(nm)/sizeof(nm[0])); -} - -template -FwdIter -scan_keyword(std::basic_istream& is, FwdIter kb, FwdIter ke) -{ - size_t nkw = static_cast(std::distance(kb, ke)); - const unsigned char doesnt_match = '\0'; - const unsigned char might_match = '\1'; - const unsigned char does_match = '\2'; - unsigned char statbuf[100]; - unsigned char* status = statbuf; - std::unique_ptr stat_hold(0, free); - if (nkw > sizeof(statbuf)) - { - status = (unsigned char*)std::malloc(nkw); - if (status == nullptr) - throw std::bad_alloc(); - stat_hold.reset(status); - } - size_t n_might_match = nkw; // At this point, any keyword might match - size_t n_does_match = 0; // but none of them definitely do - // Initialize all statuses to might_match, except for "" keywords are does_match - unsigned char* st = status; - for (auto ky = kb; ky != ke; ++ky, ++st) - { - if (!ky->empty()) - *st = might_match; - else - { - *st = does_match; - --n_might_match; - ++n_does_match; - } - } - // While there might be a match, test keywords against the next CharT - for (size_t indx = 0; is && n_might_match > 0; ++indx) - { - // Peek at the next CharT but don't consume it - auto ic = is.peek(); - if (ic == EOF) - { - is.setstate(std::ios::eofbit); - break; - } - auto c = static_cast(toupper(ic)); - bool consume = false; - // For each keyword which might match, see if the indx character is c - // If a match if found, consume c - // If a match is found, and that is the last character in the keyword, - // then that keyword matches. - // If the keyword doesn't match this character, then change the keyword - // to doesn't match - st = status; - for (auto ky = kb; ky != ke; ++ky, ++st) - { - if (*st == might_match) - { - if (c == static_cast(toupper((*ky)[indx]))) - { - consume = true; - if (ky->size() == indx+1) - { - *st = does_match; - --n_might_match; - ++n_does_match; - } - } - else - { - *st = doesnt_match; - --n_might_match; - } - } - } - // consume if we matched a character - if (consume) - { - (void)is.get(); - // If we consumed a character and there might be a matched keyword that - // was marked matched on a previous iteration, then such keywords - // are now marked as not matching. - if (n_might_match + n_does_match > 1) - { - st = status; - for (auto ky = kb; ky != ke; ++ky, ++st) - { - if (*st == does_match && ky->size() != indx+1) - { - *st = doesnt_match; - --n_does_match; - } - } - } - } - } - // We've exited the loop because we hit eof and/or we have no more "might matches". - // Return the first matching result - for (st = status; kb != ke; ++kb, ++st) - if (*st == does_match) - break; - if (kb == ke) - is.setstate(std::ios::failbit); - return kb; -} - -} // namespace detail - -#endif // ONLY_C_LOCALE - -template -std::basic_ostream& -to_stream(std::basic_ostream& os, const CharT* fmt, - const fields& fds, const std::string* abbrev, - const std::chrono::seconds* offset_sec) -{ -#if ONLY_C_LOCALE - using detail::weekday_names; - using detail::month_names; - using detail::ampm_names; -#endif - using detail::save_ostream; - using detail::get_units; - using detail::extract_weekday; - using detail::extract_month; - using std::ios; - using std::chrono::duration_cast; - using std::chrono::seconds; - using std::chrono::minutes; - using std::chrono::hours; - date::detail::save_ostream ss(os); - os.fill(' '); - os.flags(std::ios::skipws | std::ios::dec); - os.width(0); - tm tm{}; - bool insert_negative = fds.has_tod && fds.tod.to_duration() < Duration::zero(); -#if !ONLY_C_LOCALE - auto& facet = std::use_facet>(os.getloc()); -#endif - const CharT* command = nullptr; - CharT modified = CharT{}; - for (; *fmt; ++fmt) - { - switch (*fmt) - { - case 'a': - case 'A': - if (command) - { - if (modified == CharT{}) - { - tm.tm_wday = static_cast(extract_weekday(os, fds)); - if (os.fail()) - return os; -#if !ONLY_C_LOCALE - const CharT f[] = {'%', *fmt}; - facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f)); -#else // ONLY_C_LOCALE - os << weekday_names().first[tm.tm_wday+7*(*fmt == 'a')]; -#endif // ONLY_C_LOCALE - } - else - { - os << CharT{'%'} << modified << *fmt; - modified = CharT{}; - } - command = nullptr; - } - else - os << *fmt; - break; - case 'b': - case 'B': - case 'h': - if (command) - { - if (modified == CharT{}) - { - tm.tm_mon = static_cast(extract_month(os, fds)) - 1; -#if !ONLY_C_LOCALE - const CharT f[] = {'%', *fmt}; - facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f)); -#else // ONLY_C_LOCALE - os << month_names().first[tm.tm_mon+12*(*fmt != 'B')]; -#endif // ONLY_C_LOCALE - } - else - { - os << CharT{'%'} << modified << *fmt; - modified = CharT{}; - } - command = nullptr; - } - else - os << *fmt; - break; - case 'c': - case 'x': - if (command) - { - if (modified == CharT{'O'}) - os << CharT{'%'} << modified << *fmt; - else - { - if (!fds.ymd.ok()) - os.setstate(std::ios::failbit); - if (*fmt == 'c' && !fds.has_tod) - os.setstate(std::ios::failbit); -#if !ONLY_C_LOCALE - tm = std::tm{}; - auto const& ymd = fds.ymd; - auto ld = local_days(ymd); - if (*fmt == 'c') - { - tm.tm_sec = static_cast(fds.tod.seconds().count()); - tm.tm_min = static_cast(fds.tod.minutes().count()); - tm.tm_hour = static_cast(fds.tod.hours().count()); - } - tm.tm_mday = static_cast(static_cast(ymd.day())); - tm.tm_mon = static_cast(extract_month(os, fds) - 1); - tm.tm_year = static_cast(ymd.year()) - 1900; - tm.tm_wday = static_cast(extract_weekday(os, fds)); - if (os.fail()) - return os; - tm.tm_yday = static_cast((ld - local_days(ymd.year()/1/1)).count()); - CharT f[3] = {'%'}; - auto fe = std::begin(f) + 1; - if (modified == CharT{'E'}) - *fe++ = modified; - *fe++ = *fmt; - facet.put(os, os, os.fill(), &tm, std::begin(f), fe); -#else // ONLY_C_LOCALE - if (*fmt == 'c') - { - auto wd = static_cast(extract_weekday(os, fds)); - os << weekday_names().first[static_cast(wd)+7] - << ' '; - os << month_names().first[extract_month(os, fds)-1+12] << ' '; - auto d = static_cast(static_cast(fds.ymd.day())); - if (d < 10) - os << ' '; - os << d << ' ' - << make_time(duration_cast(fds.tod.to_duration())) - << ' ' << fds.ymd.year(); - - } - else // *fmt == 'x' - { - auto const& ymd = fds.ymd; - save_ostream _(os); - os.fill('0'); - os.flags(std::ios::dec | std::ios::right); - os.width(2); - os << static_cast(ymd.month()) << CharT{'/'}; - os.width(2); - os << static_cast(ymd.day()) << CharT{'/'}; - os.width(2); - os << static_cast(ymd.year()) % 100; - } -#endif // ONLY_C_LOCALE - } - command = nullptr; - modified = CharT{}; - } - else - os << *fmt; - break; - case 'C': - if (command) - { - if (modified == CharT{'O'}) - os << CharT{'%'} << modified << *fmt; - else - { - if (!fds.ymd.year().ok()) - os.setstate(std::ios::failbit); - auto y = static_cast(fds.ymd.year()); -#if !ONLY_C_LOCALE - if (modified == CharT{}) -#endif - { - save_ostream _(os); - os.fill('0'); - os.flags(std::ios::dec | std::ios::right); - if (y >= 0) - { - os.width(2); - os << y/100; - } - else - { - os << CharT{'-'}; - os.width(2); - os << -(y-99)/100; - } - } -#if !ONLY_C_LOCALE - else if (modified == CharT{'E'}) - { - tm.tm_year = y - 1900; - CharT f[3] = {'%', 'E', 'C'}; - facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f)); - } -#endif - } - command = nullptr; - modified = CharT{}; - } - else - os << *fmt; - break; - case 'd': - case 'e': - if (command) - { - if (modified == CharT{'E'}) - os << CharT{'%'} << modified << *fmt; - else - { - if (!fds.ymd.day().ok()) - os.setstate(std::ios::failbit); - auto d = static_cast(static_cast(fds.ymd.day())); -#if !ONLY_C_LOCALE - if (modified == CharT{}) -#endif - { - save_ostream _(os); - if (*fmt == CharT{'d'}) - os.fill('0'); - else - os.fill(' '); - os.flags(std::ios::dec | std::ios::right); - os.width(2); - os << d; - } -#if !ONLY_C_LOCALE - else if (modified == CharT{'O'}) - { - tm.tm_mday = d; - CharT f[3] = {'%', 'O', *fmt}; - facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f)); - } -#endif - } - command = nullptr; - modified = CharT{}; - } - else - os << *fmt; - break; - case 'D': - if (command) - { - if (modified == CharT{}) - { - if (!fds.ymd.ok()) - os.setstate(std::ios::failbit); - auto const& ymd = fds.ymd; - save_ostream _(os); - os.fill('0'); - os.flags(std::ios::dec | std::ios::right); - os.width(2); - os << static_cast(ymd.month()) << CharT{'/'}; - os.width(2); - os << static_cast(ymd.day()) << CharT{'/'}; - os.width(2); - os << static_cast(ymd.year()) % 100; - } - else - { - os << CharT{'%'} << modified << *fmt; - modified = CharT{}; - } - command = nullptr; - } - else - os << *fmt; - break; - case 'F': - if (command) - { - if (modified == CharT{}) - { - if (!fds.ymd.ok()) - os.setstate(std::ios::failbit); - auto const& ymd = fds.ymd; - save_ostream _(os); - os.fill('0'); - os.flags(std::ios::dec | std::ios::right); - os.width(4); - os << static_cast(ymd.year()) << CharT{'-'}; - os.width(2); - os << static_cast(ymd.month()) << CharT{'-'}; - os.width(2); - os << static_cast(ymd.day()); - } - else - { - os << CharT{'%'} << modified << *fmt; - modified = CharT{}; - } - command = nullptr; - } - else - os << *fmt; - break; - case 'g': - case 'G': - if (command) - { - if (modified == CharT{}) - { - if (!fds.ymd.ok()) - os.setstate(std::ios::failbit); - auto ld = local_days(fds.ymd); - auto y = year_month_day{ld + days{3}}.year(); - auto start = local_days((y-years{1})/December/Thursday[last]) + - (Monday-Thursday); - if (ld < start) - --y; - if (*fmt == CharT{'G'}) - os << y; - else - { - save_ostream _(os); - os.fill('0'); - os.flags(std::ios::dec | std::ios::right); - os.width(2); - os << std::abs(static_cast(y)) % 100; - } - } - else - { - os << CharT{'%'} << modified << *fmt; - modified = CharT{}; - } - command = nullptr; - } - else - os << *fmt; - break; - case 'H': - case 'I': - if (command) - { - if (modified == CharT{'E'}) - os << CharT{'%'} << modified << *fmt; - else - { - if (!fds.has_tod) - os.setstate(std::ios::failbit); - if (insert_negative) - { - os << '-'; - insert_negative = false; - } - auto hms = fds.tod; -#if !ONLY_C_LOCALE - if (modified == CharT{}) -#endif - { - auto h = *fmt == CharT{'I'} ? make12(hms.hours()) : hms.hours(); - if (h < hours{10}) - os << CharT{'0'}; - os << h.count(); - } -#if !ONLY_C_LOCALE - else if (modified == CharT{'O'}) - { - const CharT f[] = {'%', modified, *fmt}; - tm.tm_hour = static_cast(hms.hours().count()); - facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f)); - } -#endif - } - modified = CharT{}; - command = nullptr; - } - else - os << *fmt; - break; - case 'j': - if (command) - { - if (modified == CharT{}) - { - if (fds.ymd.ok() || fds.has_tod) - { - days doy; - if (fds.ymd.ok()) - { - auto ld = local_days(fds.ymd); - auto y = fds.ymd.year(); - doy = ld - local_days(y/January/1) + days{1}; - } - else - { - doy = duration_cast(fds.tod.to_duration()); - } - save_ostream _(os); - os.fill('0'); - os.flags(std::ios::dec | std::ios::right); - os.width(3); - os << doy.count(); - } - else - { - os.setstate(std::ios::failbit); - } - } - else - { - os << CharT{'%'} << modified << *fmt; - modified = CharT{}; - } - command = nullptr; - } - else - os << *fmt; - break; - case 'm': - if (command) - { - if (modified == CharT{'E'}) - os << CharT{'%'} << modified << *fmt; - else - { - if (!fds.ymd.month().ok()) - os.setstate(std::ios::failbit); - auto m = static_cast(fds.ymd.month()); -#if !ONLY_C_LOCALE - if (modified == CharT{}) -#endif - { - if (m < 10) - os << CharT{'0'}; - os << m; - } -#if !ONLY_C_LOCALE - else if (modified == CharT{'O'}) - { - const CharT f[] = {'%', modified, *fmt}; - tm.tm_mon = static_cast(m-1); - facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f)); - } -#endif - } - modified = CharT{}; - command = nullptr; - } - else - os << *fmt; - break; - case 'M': - if (command) - { - if (modified == CharT{'E'}) - os << CharT{'%'} << modified << *fmt; - else - { - if (!fds.has_tod) - os.setstate(std::ios::failbit); - if (insert_negative) - { - os << '-'; - insert_negative = false; - } -#if !ONLY_C_LOCALE - if (modified == CharT{}) -#endif - { - if (fds.tod.minutes() < minutes{10}) - os << CharT{'0'}; - os << fds.tod.minutes().count(); - } -#if !ONLY_C_LOCALE - else if (modified == CharT{'O'}) - { - const CharT f[] = {'%', modified, *fmt}; - tm.tm_min = static_cast(fds.tod.minutes().count()); - facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f)); - } -#endif - } - modified = CharT{}; - command = nullptr; - } - else - os << *fmt; - break; - case 'n': - if (command) - { - if (modified == CharT{}) - os << CharT{'\n'}; - else - { - os << CharT{'%'} << modified << *fmt; - modified = CharT{}; - } - command = nullptr; - } - else - os << *fmt; - break; - case 'p': - if (command) - { - if (modified == CharT{}) - { - if (!fds.has_tod) - os.setstate(std::ios::failbit); -#if !ONLY_C_LOCALE - const CharT f[] = {'%', *fmt}; - tm.tm_hour = static_cast(fds.tod.hours().count()); - facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f)); -#else - if (is_am(fds.tod.hours())) - os << ampm_names().first[0]; - else - os << ampm_names().first[1]; -#endif - } - else - { - os << CharT{'%'} << modified << *fmt; - } - modified = CharT{}; - command = nullptr; - } - else - os << *fmt; - break; - case 'Q': - case 'q': - if (command) - { - if (modified == CharT{}) - { - if (!fds.has_tod) - os.setstate(std::ios::failbit); - auto d = fds.tod.to_duration(); - if (*fmt == 'q') - os << get_units(typename decltype(d)::period::type{}); - else - os << d.count(); - } - else - { - os << CharT{'%'} << modified << *fmt; - } - modified = CharT{}; - command = nullptr; - } - else - os << *fmt; - break; - case 'r': - if (command) - { - if (modified == CharT{}) - { - if (!fds.has_tod) - os.setstate(std::ios::failbit); -#if !ONLY_C_LOCALE - const CharT f[] = {'%', *fmt}; - tm.tm_hour = static_cast(fds.tod.hours().count()); - tm.tm_min = static_cast(fds.tod.minutes().count()); - tm.tm_sec = static_cast(fds.tod.seconds().count()); - facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f)); -#else - hh_mm_ss tod(duration_cast(fds.tod.to_duration())); - save_ostream _(os); - os.fill('0'); - os.width(2); - os << make12(tod.hours()).count() << CharT{':'}; - os.width(2); - os << tod.minutes().count() << CharT{':'}; - os.width(2); - os << tod.seconds().count() << CharT{' '}; - if (is_am(tod.hours())) - os << ampm_names().first[0]; - else - os << ampm_names().first[1]; -#endif - } - else - { - os << CharT{'%'} << modified << *fmt; - } - modified = CharT{}; - command = nullptr; - } - else - os << *fmt; - break; - case 'R': - if (command) - { - if (modified == CharT{}) - { - if (!fds.has_tod) - os.setstate(std::ios::failbit); - if (fds.tod.hours() < hours{10}) - os << CharT{'0'}; - os << fds.tod.hours().count() << CharT{':'}; - if (fds.tod.minutes() < minutes{10}) - os << CharT{'0'}; - os << fds.tod.minutes().count(); - } - else - { - os << CharT{'%'} << modified << *fmt; - modified = CharT{}; - } - command = nullptr; - } - else - os << *fmt; - break; - case 'S': - if (command) - { - if (modified == CharT{'E'}) - os << CharT{'%'} << modified << *fmt; - else - { - if (!fds.has_tod) - os.setstate(std::ios::failbit); - if (insert_negative) - { - os << '-'; - insert_negative = false; - } -#if !ONLY_C_LOCALE - if (modified == CharT{}) -#endif - { - os << fds.tod.s_; - } -#if !ONLY_C_LOCALE - else if (modified == CharT{'O'}) - { - const CharT f[] = {'%', modified, *fmt}; - tm.tm_sec = static_cast(fds.tod.s_.seconds().count()); - facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f)); - } -#endif - } - modified = CharT{}; - command = nullptr; - } - else - os << *fmt; - break; - case 't': - if (command) - { - if (modified == CharT{}) - os << CharT{'\t'}; - else - { - os << CharT{'%'} << modified << *fmt; - modified = CharT{}; - } - command = nullptr; - } - else - os << *fmt; - break; - case 'T': - if (command) - { - if (modified == CharT{}) - { - if (!fds.has_tod) - os.setstate(std::ios::failbit); - os << fds.tod; - } - else - { - os << CharT{'%'} << modified << *fmt; - modified = CharT{}; - } - command = nullptr; - } - else - os << *fmt; - break; - case 'u': - if (command) - { - if (modified == CharT{'E'}) - os << CharT{'%'} << modified << *fmt; - else - { - auto wd = extract_weekday(os, fds); -#if !ONLY_C_LOCALE - if (modified == CharT{}) -#endif - { - os << (wd != 0 ? wd : 7u); - } -#if !ONLY_C_LOCALE - else if (modified == CharT{'O'}) - { - const CharT f[] = {'%', modified, *fmt}; - tm.tm_wday = static_cast(wd); - facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f)); - } -#endif - } - modified = CharT{}; - command = nullptr; - } - else - os << *fmt; - break; - case 'U': - if (command) - { - if (modified == CharT{'E'}) - os << CharT{'%'} << modified << *fmt; - else - { - auto const& ymd = fds.ymd; - if (!ymd.ok()) - os.setstate(std::ios::failbit); - auto ld = local_days(ymd); -#if !ONLY_C_LOCALE - if (modified == CharT{}) -#endif - { - auto st = local_days(Sunday[1]/January/ymd.year()); - if (ld < st) - os << CharT{'0'} << CharT{'0'}; - else - { - auto wn = duration_cast(ld - st).count() + 1; - if (wn < 10) - os << CharT{'0'}; - os << wn; - } - } - #if !ONLY_C_LOCALE - else if (modified == CharT{'O'}) - { - const CharT f[] = {'%', modified, *fmt}; - tm.tm_year = static_cast(ymd.year()) - 1900; - tm.tm_wday = static_cast(extract_weekday(os, fds)); - if (os.fail()) - return os; - tm.tm_yday = static_cast((ld - local_days(ymd.year()/1/1)).count()); - facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f)); - } -#endif - } - modified = CharT{}; - command = nullptr; - } - else - os << *fmt; - break; - case 'V': - if (command) - { - if (modified == CharT{'E'}) - os << CharT{'%'} << modified << *fmt; - else - { - if (!fds.ymd.ok()) - os.setstate(std::ios::failbit); - auto ld = local_days(fds.ymd); -#if !ONLY_C_LOCALE - if (modified == CharT{}) -#endif - { - auto y = year_month_day{ld + days{3}}.year(); - auto st = local_days((y-years{1})/12/Thursday[last]) + - (Monday-Thursday); - if (ld < st) - { - --y; - st = local_days((y - years{1})/12/Thursday[last]) + - (Monday-Thursday); - } - auto wn = duration_cast(ld - st).count() + 1; - if (wn < 10) - os << CharT{'0'}; - os << wn; - } -#if !ONLY_C_LOCALE - else if (modified == CharT{'O'}) - { - const CharT f[] = {'%', modified, *fmt}; - auto const& ymd = fds.ymd; - tm.tm_year = static_cast(ymd.year()) - 1900; - tm.tm_wday = static_cast(extract_weekday(os, fds)); - if (os.fail()) - return os; - tm.tm_yday = static_cast((ld - local_days(ymd.year()/1/1)).count()); - facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f)); - } -#endif - } - modified = CharT{}; - command = nullptr; - } - else - os << *fmt; - break; - case 'w': - if (command) - { - auto wd = extract_weekday(os, fds); - if (os.fail()) - return os; -#if !ONLY_C_LOCALE - if (modified == CharT{}) -#else - if (modified != CharT{'E'}) -#endif - { - os << wd; - } -#if !ONLY_C_LOCALE - else if (modified == CharT{'O'}) - { - const CharT f[] = {'%', modified, *fmt}; - tm.tm_wday = static_cast(wd); - facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f)); - } -#endif - else - { - os << CharT{'%'} << modified << *fmt; - } - modified = CharT{}; - command = nullptr; - } - else - os << *fmt; - break; - case 'W': - if (command) - { - if (modified == CharT{'E'}) - os << CharT{'%'} << modified << *fmt; - else - { - auto const& ymd = fds.ymd; - if (!ymd.ok()) - os.setstate(std::ios::failbit); - auto ld = local_days(ymd); -#if !ONLY_C_LOCALE - if (modified == CharT{}) -#endif - { - auto st = local_days(Monday[1]/January/ymd.year()); - if (ld < st) - os << CharT{'0'} << CharT{'0'}; - else - { - auto wn = duration_cast(ld - st).count() + 1; - if (wn < 10) - os << CharT{'0'}; - os << wn; - } - } -#if !ONLY_C_LOCALE - else if (modified == CharT{'O'}) - { - const CharT f[] = {'%', modified, *fmt}; - tm.tm_year = static_cast(ymd.year()) - 1900; - tm.tm_wday = static_cast(extract_weekday(os, fds)); - if (os.fail()) - return os; - tm.tm_yday = static_cast((ld - local_days(ymd.year()/1/1)).count()); - facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f)); - } -#endif - } - modified = CharT{}; - command = nullptr; - } - else - os << *fmt; - break; - case 'X': - if (command) - { - if (modified == CharT{'O'}) - os << CharT{'%'} << modified << *fmt; - else - { - if (!fds.has_tod) - os.setstate(std::ios::failbit); -#if !ONLY_C_LOCALE - tm = std::tm{}; - tm.tm_sec = static_cast(fds.tod.seconds().count()); - tm.tm_min = static_cast(fds.tod.minutes().count()); - tm.tm_hour = static_cast(fds.tod.hours().count()); - CharT f[3] = {'%'}; - auto fe = std::begin(f) + 1; - if (modified == CharT{'E'}) - *fe++ = modified; - *fe++ = *fmt; - facet.put(os, os, os.fill(), &tm, std::begin(f), fe); -#else - os << fds.tod; -#endif - } - command = nullptr; - modified = CharT{}; - } - else - os << *fmt; - break; - case 'y': - if (command) - { - if (!fds.ymd.year().ok()) - os.setstate(std::ios::failbit); - auto y = static_cast(fds.ymd.year()); -#if !ONLY_C_LOCALE - if (modified == CharT{}) - { -#endif - y = std::abs(y) % 100; - if (y < 10) - os << CharT{'0'}; - os << y; -#if !ONLY_C_LOCALE - } - else - { - const CharT f[] = {'%', modified, *fmt}; - tm.tm_year = y - 1900; - facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f)); - } -#endif - modified = CharT{}; - command = nullptr; - } - else - os << *fmt; - break; - case 'Y': - if (command) - { - if (modified == CharT{'O'}) - os << CharT{'%'} << modified << *fmt; - else - { - if (!fds.ymd.year().ok()) - os.setstate(std::ios::failbit); - auto y = fds.ymd.year(); -#if !ONLY_C_LOCALE - if (modified == CharT{}) -#endif - { - os << y; - } -#if !ONLY_C_LOCALE - else if (modified == CharT{'E'}) - { - const CharT f[] = {'%', modified, *fmt}; - tm.tm_year = static_cast(y) - 1900; - facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f)); - } -#endif - } - modified = CharT{}; - command = nullptr; - } - else - os << *fmt; - break; - case 'z': - if (command) - { - if (offset_sec == nullptr) - { - // Can not format %z with unknown offset - os.setstate(ios::failbit); - return os; - } - auto m = duration_cast(*offset_sec); - auto neg = m < minutes{0}; - m = date::abs(m); - auto h = duration_cast(m); - m -= h; - if (neg) - os << CharT{'-'}; - else - os << CharT{'+'}; - if (h < hours{10}) - os << CharT{'0'}; - os << h.count(); - if (modified != CharT{}) - os << CharT{':'}; - if (m < minutes{10}) - os << CharT{'0'}; - os << m.count(); - command = nullptr; - modified = CharT{}; - } - else - os << *fmt; - break; - case 'Z': - if (command) - { - if (modified == CharT{}) - { - if (abbrev == nullptr) - { - // Can not format %Z with unknown time_zone - os.setstate(ios::failbit); - return os; - } - for (auto c : *abbrev) - os << CharT(c); - } - else - { - os << CharT{'%'} << modified << *fmt; - modified = CharT{}; - } - command = nullptr; - } - else - os << *fmt; - break; - case 'E': - case 'O': - if (command) - { - if (modified == CharT{}) - { - modified = *fmt; - } - else - { - os << CharT{'%'} << modified << *fmt; - command = nullptr; - modified = CharT{}; - } - } - else - os << *fmt; - break; - case '%': - if (command) - { - if (modified == CharT{}) - { - os << CharT{'%'}; - command = nullptr; - } - else - { - os << CharT{'%'} << modified << CharT{'%'}; - command = nullptr; - modified = CharT{}; - } - } - else - command = fmt; - break; - default: - if (command) - { - os << CharT{'%'}; - command = nullptr; - } - if (modified != CharT{}) - { - os << modified; - modified = CharT{}; - } - os << *fmt; - break; - } - } - if (command) - os << CharT{'%'}; - if (modified != CharT{}) - os << modified; - return os; -} - -template -inline -std::basic_ostream& -to_stream(std::basic_ostream& os, const CharT* fmt, const year& y) -{ - using CT = std::chrono::seconds; - fields fds{y/0/0}; - return to_stream(os, fmt, fds); -} - -template -inline -std::basic_ostream& -to_stream(std::basic_ostream& os, const CharT* fmt, const month& m) -{ - using CT = std::chrono::seconds; - fields fds{m/0/nanyear}; - return to_stream(os, fmt, fds); -} - -template -inline -std::basic_ostream& -to_stream(std::basic_ostream& os, const CharT* fmt, const day& d) -{ - using CT = std::chrono::seconds; - fields fds{d/0/nanyear}; - return to_stream(os, fmt, fds); -} - -template -inline -std::basic_ostream& -to_stream(std::basic_ostream& os, const CharT* fmt, const weekday& wd) -{ - using CT = std::chrono::seconds; - fields fds{wd}; - return to_stream(os, fmt, fds); -} - -template -inline -std::basic_ostream& -to_stream(std::basic_ostream& os, const CharT* fmt, const year_month& ym) -{ - using CT = std::chrono::seconds; - fields fds{ym/0}; - return to_stream(os, fmt, fds); -} - -template -inline -std::basic_ostream& -to_stream(std::basic_ostream& os, const CharT* fmt, const month_day& md) -{ - using CT = std::chrono::seconds; - fields fds{md/nanyear}; - return to_stream(os, fmt, fds); -} - -template -inline -std::basic_ostream& -to_stream(std::basic_ostream& os, const CharT* fmt, - const year_month_day& ymd) -{ - using CT = std::chrono::seconds; - fields fds{ymd}; - return to_stream(os, fmt, fds); -} - -template -inline -std::basic_ostream& -to_stream(std::basic_ostream& os, const CharT* fmt, - const std::chrono::duration& d) -{ - using Duration = std::chrono::duration; - using CT = typename std::common_type::type; - fields fds{hh_mm_ss{d}}; - return to_stream(os, fmt, fds); -} - -template -std::basic_ostream& -to_stream(std::basic_ostream& os, const CharT* fmt, - const local_time& tp, const std::string* abbrev = nullptr, - const std::chrono::seconds* offset_sec = nullptr) -{ - using CT = typename std::common_type::type; - auto ld = floor(tp); - fields fds{year_month_day{ld}, hh_mm_ss{tp-local_seconds{ld}}}; - return to_stream(os, fmt, fds, abbrev, offset_sec); -} - -template -std::basic_ostream& -to_stream(std::basic_ostream& os, const CharT* fmt, - const sys_time& tp) -{ - using std::chrono::seconds; - using CT = typename std::common_type::type; - const std::string abbrev("UTC"); - CONSTDATA seconds offset{0}; - auto sd = floor(tp); - fields fds{year_month_day{sd}, hh_mm_ss{tp-sys_seconds{sd}}}; - return to_stream(os, fmt, fds, &abbrev, &offset); -} - -// format - -template -auto -format(const std::locale& loc, const CharT* fmt, const Streamable& tp) - -> decltype(to_stream(std::declval&>(), fmt, tp), - std::basic_string{}) -{ - std::basic_ostringstream os; - os.exceptions(std::ios::failbit | std::ios::badbit); - os.imbue(loc); - to_stream(os, fmt, tp); - return os.str(); -} - -template -auto -format(const CharT* fmt, const Streamable& tp) - -> decltype(to_stream(std::declval&>(), fmt, tp), - std::basic_string{}) -{ - std::basic_ostringstream os; - os.exceptions(std::ios::failbit | std::ios::badbit); - to_stream(os, fmt, tp); - return os.str(); -} - -template -auto -format(const std::locale& loc, const std::basic_string& fmt, - const Streamable& tp) - -> decltype(to_stream(std::declval&>(), fmt.c_str(), tp), - std::basic_string{}) -{ - std::basic_ostringstream os; - os.exceptions(std::ios::failbit | std::ios::badbit); - os.imbue(loc); - to_stream(os, fmt.c_str(), tp); - return os.str(); -} - -template -auto -format(const std::basic_string& fmt, const Streamable& tp) - -> decltype(to_stream(std::declval&>(), fmt.c_str(), tp), - std::basic_string{}) -{ - std::basic_ostringstream os; - os.exceptions(std::ios::failbit | std::ios::badbit); - to_stream(os, fmt.c_str(), tp); - return os.str(); -} - -// parse - -namespace detail -{ - -template -bool -read_char(std::basic_istream& is, CharT fmt, std::ios::iostate& err) -{ - auto ic = is.get(); - if (Traits::eq_int_type(ic, Traits::eof()) || - !Traits::eq(Traits::to_char_type(ic), fmt)) - { - err |= std::ios::failbit; - is.setstate(std::ios::failbit); - return false; - } - return true; -} - -template -unsigned -read_unsigned(std::basic_istream& is, unsigned m = 1, unsigned M = 10) -{ - unsigned x = 0; - unsigned count = 0; - while (true) - { - auto ic = is.peek(); - if (Traits::eq_int_type(ic, Traits::eof())) - break; - auto c = static_cast(Traits::to_char_type(ic)); - if (!('0' <= c && c <= '9')) - break; - (void)is.get(); - ++count; - x = 10*x + static_cast(c - '0'); - if (count == M) - break; - } - if (count < m) - is.setstate(std::ios::failbit); - return x; -} - -template -int -read_signed(std::basic_istream& is, unsigned m = 1, unsigned M = 10) -{ - auto ic = is.peek(); - if (!Traits::eq_int_type(ic, Traits::eof())) - { - auto c = static_cast(Traits::to_char_type(ic)); - if (('0' <= c && c <= '9') || c == '-' || c == '+') - { - if (c == '-' || c == '+') - (void)is.get(); - auto x = static_cast(read_unsigned(is, std::max(m, 1u), M)); - if (!is.fail()) - { - if (c == '-') - x = -x; - return x; - } - } - } - if (m > 0) - is.setstate(std::ios::failbit); - return 0; -} - -template -long double -read_long_double(std::basic_istream& is, unsigned m = 1, unsigned M = 10) -{ - unsigned count = 0; - auto decimal_point = Traits::to_int_type( - std::use_facet>(is.getloc()).decimal_point()); - std::string buf; - while (true) - { - auto ic = is.peek(); - if (Traits::eq_int_type(ic, Traits::eof())) - break; - if (Traits::eq_int_type(ic, decimal_point)) - { - buf += '.'; - decimal_point = Traits::eof(); - is.get(); - } - else - { - auto c = static_cast(Traits::to_char_type(ic)); - if (!('0' <= c && c <= '9')) - break; - buf += c; - (void)is.get(); - } - if (++count == M) - break; - } - if (count < m) - { - is.setstate(std::ios::failbit); - return 0; - } - return std::stold(buf); -} - -struct rs -{ - int& i; - unsigned m; - unsigned M; -}; - -struct ru -{ - int& i; - unsigned m; - unsigned M; -}; - -struct rld -{ - long double& i; - unsigned m; - unsigned M; -}; - -template -void -read(std::basic_istream&) -{ -} - -template -void -read(std::basic_istream& is, CharT a0, Args&& ...args); - -template -void -read(std::basic_istream& is, rs a0, Args&& ...args); - -template -void -read(std::basic_istream& is, ru a0, Args&& ...args); - -template -void -read(std::basic_istream& is, int a0, Args&& ...args); - -template -void -read(std::basic_istream& is, rld a0, Args&& ...args); - -template -void -read(std::basic_istream& is, CharT a0, Args&& ...args) -{ - // No-op if a0 == CharT{} - if (a0 != CharT{}) - { - auto ic = is.peek(); - if (Traits::eq_int_type(ic, Traits::eof())) - { - is.setstate(std::ios::failbit | std::ios::eofbit); - return; - } - if (!Traits::eq(Traits::to_char_type(ic), a0)) - { - is.setstate(std::ios::failbit); - return; - } - (void)is.get(); - } - read(is, std::forward(args)...); -} - -template -void -read(std::basic_istream& is, rs a0, Args&& ...args) -{ - auto x = read_signed(is, a0.m, a0.M); - if (is.fail()) - return; - a0.i = x; - read(is, std::forward(args)...); -} - -template -void -read(std::basic_istream& is, ru a0, Args&& ...args) -{ - auto x = read_unsigned(is, a0.m, a0.M); - if (is.fail()) - return; - a0.i = static_cast(x); - read(is, std::forward(args)...); -} - -template -void -read(std::basic_istream& is, int a0, Args&& ...args) -{ - if (a0 != -1) - { - auto u = static_cast(a0); - CharT buf[std::numeric_limits::digits10+2] = {}; - auto e = buf; - do - { - *e++ = static_cast(CharT(u % 10) + CharT{'0'}); - u /= 10; - } while (u > 0); - std::reverse(buf, e); - for (auto p = buf; p != e && is.rdstate() == std::ios::goodbit; ++p) - read(is, *p); - } - if (is.rdstate() == std::ios::goodbit) - read(is, std::forward(args)...); -} - -template -void -read(std::basic_istream& is, rld a0, Args&& ...args) -{ - auto x = read_long_double(is, a0.m, a0.M); - if (is.fail()) - return; - a0.i = x; - read(is, std::forward(args)...); -} - -template -inline -void -checked_set(T& value, T from, T not_a_value, std::basic_ios& is) -{ - if (!is.fail()) - { - if (value == not_a_value) - value = std::move(from); - else if (value != from) - is.setstate(std::ios::failbit); - } -} - -} // namespace detail; - -template > -std::basic_istream& -from_stream(std::basic_istream& is, const CharT* fmt, - fields& fds, std::basic_string* abbrev, - std::chrono::minutes* offset) -{ - using std::numeric_limits; - using std::ios; - using std::chrono::duration; - using std::chrono::duration_cast; - using std::chrono::seconds; - using std::chrono::minutes; - using std::chrono::hours; - typename std::basic_istream::sentry ok{is, true}; - if (ok) - { - date::detail::save_istream ss(is); - is.fill(' '); - is.flags(std::ios::skipws | std::ios::dec); - is.width(0); -#if !ONLY_C_LOCALE - auto& f = std::use_facet>(is.getloc()); - std::tm tm{}; -#endif - const CharT* command = nullptr; - auto modified = CharT{}; - auto width = -1; - - CONSTDATA int not_a_year = numeric_limits::min(); - CONSTDATA int not_a_2digit_year = 100; - CONSTDATA int not_a_century = not_a_year / 100; - CONSTDATA int not_a_month = 0; - CONSTDATA int not_a_day = 0; - CONSTDATA int not_a_hour = numeric_limits::min(); - CONSTDATA int not_a_hour_12_value = 0; - CONSTDATA int not_a_minute = not_a_hour; - CONSTDATA Duration not_a_second = Duration::min(); - CONSTDATA int not_a_doy = -1; - CONSTDATA int not_a_weekday = 8; - CONSTDATA int not_a_week_num = 100; - CONSTDATA int not_a_ampm = -1; - CONSTDATA minutes not_a_offset = minutes::min(); - - int Y = not_a_year; // c, F, Y * - int y = not_a_2digit_year; // D, x, y * - int g = not_a_2digit_year; // g * - int G = not_a_year; // G * - int C = not_a_century; // C * - int m = not_a_month; // b, B, h, m, c, D, F, x * - int d = not_a_day; // c, d, D, e, F, x * - int j = not_a_doy; // j * - int wd = not_a_weekday; // a, A, u, w * - int H = not_a_hour; // c, H, R, T, X * - int I = not_a_hour_12_value; // I, r * - int p = not_a_ampm; // p, r * - int M = not_a_minute; // c, M, r, R, T, X * - Duration s = not_a_second; // c, r, S, T, X * - int U = not_a_week_num; // U * - int V = not_a_week_num; // V * - int W = not_a_week_num; // W * - std::basic_string temp_abbrev; // Z * - minutes temp_offset = not_a_offset; // z * - - using detail::read; - using detail::rs; - using detail::ru; - using detail::rld; - using detail::checked_set; - for (; *fmt && is.rdstate() == std::ios::goodbit; ++fmt) - { - switch (*fmt) - { - case 'a': - case 'A': - case 'u': - case 'w': // wd: a, A, u, w - if (command) - { - int trial_wd = not_a_weekday; - if (*fmt == 'a' || *fmt == 'A') - { - if (modified == CharT{}) - { -#if !ONLY_C_LOCALE - ios::iostate err = ios::goodbit; - f.get(is, nullptr, is, err, &tm, command, fmt+1); - is.setstate(err); - if (!is.fail()) - trial_wd = tm.tm_wday; -#else - auto nm = detail::weekday_names(); - auto i = detail::scan_keyword(is, nm.first, nm.second) - nm.first; - if (!is.fail()) - trial_wd = i % 7; -#endif - } - else - read(is, CharT{'%'}, width, modified, *fmt); - } - else // *fmt == 'u' || *fmt == 'w' - { -#if !ONLY_C_LOCALE - if (modified == CharT{}) -#else - if (modified != CharT{'E'}) -#endif - { - read(is, ru{trial_wd, 1, width == -1 ? - 1u : static_cast(width)}); - if (!is.fail()) - { - if (*fmt == 'u') - { - if (!(1 <= trial_wd && trial_wd <= 7)) - { - trial_wd = not_a_weekday; - is.setstate(ios::failbit); - } - else if (trial_wd == 7) - trial_wd = 0; - } - else // *fmt == 'w' - { - if (!(0 <= trial_wd && trial_wd <= 6)) - { - trial_wd = not_a_weekday; - is.setstate(ios::failbit); - } - } - } - } -#if !ONLY_C_LOCALE - else if (modified == CharT{'O'}) - { - ios::iostate err = ios::goodbit; - f.get(is, nullptr, is, err, &tm, command, fmt+1); - is.setstate(err); - if (!is.fail()) - trial_wd = tm.tm_wday; - } -#endif - else - read(is, CharT{'%'}, width, modified, *fmt); - } - if (trial_wd != not_a_weekday) - checked_set(wd, trial_wd, not_a_weekday, is); - } - else // !command - read(is, *fmt); - command = nullptr; - width = -1; - modified = CharT{}; - break; - case 'b': - case 'B': - case 'h': - if (command) - { - if (modified == CharT{}) - { - int ttm = not_a_month; -#if !ONLY_C_LOCALE - ios::iostate err = ios::goodbit; - f.get(is, nullptr, is, err, &tm, command, fmt+1); - if ((err & ios::failbit) == 0) - ttm = tm.tm_mon + 1; - is.setstate(err); -#else - auto nm = detail::month_names(); - auto i = detail::scan_keyword(is, nm.first, nm.second) - nm.first; - if (!is.fail()) - ttm = i % 12 + 1; -#endif - checked_set(m, ttm, not_a_month, is); - } - else - read(is, CharT{'%'}, width, modified, *fmt); - command = nullptr; - width = -1; - modified = CharT{}; - } - else - read(is, *fmt); - break; - case 'c': - if (command) - { - if (modified != CharT{'O'}) - { -#if !ONLY_C_LOCALE - ios::iostate err = ios::goodbit; - f.get(is, nullptr, is, err, &tm, command, fmt+1); - if ((err & ios::failbit) == 0) - { - checked_set(Y, tm.tm_year + 1900, not_a_year, is); - checked_set(m, tm.tm_mon + 1, not_a_month, is); - checked_set(d, tm.tm_mday, not_a_day, is); - checked_set(H, tm.tm_hour, not_a_hour, is); - checked_set(M, tm.tm_min, not_a_minute, is); - checked_set(s, duration_cast(seconds{tm.tm_sec}), - not_a_second, is); - } - is.setstate(err); -#else - // "%a %b %e %T %Y" - auto nm = detail::weekday_names(); - auto i = detail::scan_keyword(is, nm.first, nm.second) - nm.first; - checked_set(wd, static_cast(i % 7), not_a_weekday, is); - ws(is); - nm = detail::month_names(); - i = detail::scan_keyword(is, nm.first, nm.second) - nm.first; - checked_set(m, static_cast(i % 12 + 1), not_a_month, is); - ws(is); - int td = not_a_day; - read(is, rs{td, 1, 2}); - checked_set(d, td, not_a_day, is); - ws(is); - using dfs = detail::decimal_format_seconds; - CONSTDATA auto w = Duration::period::den == 1 ? 2 : 3 + dfs::width; - int tH; - int tM; - long double S; - read(is, ru{tH, 1, 2}, CharT{':'}, ru{tM, 1, 2}, - CharT{':'}, rld{S, 1, w}); - checked_set(H, tH, not_a_hour, is); - checked_set(M, tM, not_a_minute, is); - checked_set(s, round(duration{S}), - not_a_second, is); - ws(is); - int tY = not_a_year; - read(is, rs{tY, 1, 4u}); - checked_set(Y, tY, not_a_year, is); -#endif - } - else - read(is, CharT{'%'}, width, modified, *fmt); - command = nullptr; - width = -1; - modified = CharT{}; - } - else - read(is, *fmt); - break; - case 'x': - if (command) - { - if (modified != CharT{'O'}) - { -#if !ONLY_C_LOCALE - ios::iostate err = ios::goodbit; - f.get(is, nullptr, is, err, &tm, command, fmt+1); - if ((err & ios::failbit) == 0) - { - checked_set(Y, tm.tm_year + 1900, not_a_year, is); - checked_set(m, tm.tm_mon + 1, not_a_month, is); - checked_set(d, tm.tm_mday, not_a_day, is); - } - is.setstate(err); -#else - // "%m/%d/%y" - int ty = not_a_2digit_year; - int tm = not_a_month; - int td = not_a_day; - read(is, ru{tm, 1, 2}, CharT{'/'}, ru{td, 1, 2}, CharT{'/'}, - rs{ty, 1, 2}); - checked_set(y, ty, not_a_2digit_year, is); - checked_set(m, tm, not_a_month, is); - checked_set(d, td, not_a_day, is); -#endif - } - else - read(is, CharT{'%'}, width, modified, *fmt); - command = nullptr; - width = -1; - modified = CharT{}; - } - else - read(is, *fmt); - break; - case 'X': - if (command) - { - if (modified != CharT{'O'}) - { -#if !ONLY_C_LOCALE - ios::iostate err = ios::goodbit; - f.get(is, nullptr, is, err, &tm, command, fmt+1); - if ((err & ios::failbit) == 0) - { - checked_set(H, tm.tm_hour, not_a_hour, is); - checked_set(M, tm.tm_min, not_a_minute, is); - checked_set(s, duration_cast(seconds{tm.tm_sec}), - not_a_second, is); - } - is.setstate(err); -#else - // "%T" - using dfs = detail::decimal_format_seconds; - CONSTDATA auto w = Duration::period::den == 1 ? 2 : 3 + dfs::width; - int tH = not_a_hour; - int tM = not_a_minute; - long double S; - read(is, ru{tH, 1, 2}, CharT{':'}, ru{tM, 1, 2}, - CharT{':'}, rld{S, 1, w}); - checked_set(H, tH, not_a_hour, is); - checked_set(M, tM, not_a_minute, is); - checked_set(s, round(duration{S}), - not_a_second, is); -#endif - } - else - read(is, CharT{'%'}, width, modified, *fmt); - command = nullptr; - width = -1; - modified = CharT{}; - } - else - read(is, *fmt); - break; - case 'C': - if (command) - { - int tC = not_a_century; -#if !ONLY_C_LOCALE - if (modified == CharT{}) - { -#endif - read(is, rs{tC, 1, width == -1 ? 2u : static_cast(width)}); -#if !ONLY_C_LOCALE - } - else - { - ios::iostate err = ios::goodbit; - f.get(is, nullptr, is, err, &tm, command, fmt+1); - if ((err & ios::failbit) == 0) - { - auto tY = tm.tm_year + 1900; - tC = (tY >= 0 ? tY : tY-99) / 100; - } - is.setstate(err); - } -#endif - checked_set(C, tC, not_a_century, is); - command = nullptr; - width = -1; - modified = CharT{}; - } - else - read(is, *fmt); - break; - case 'D': - if (command) - { - if (modified == CharT{}) - { - int tn = not_a_month; - int td = not_a_day; - int ty = not_a_2digit_year; - read(is, ru{tn, 1, 2}, CharT{'\0'}, CharT{'/'}, CharT{'\0'}, - ru{td, 1, 2}, CharT{'\0'}, CharT{'/'}, CharT{'\0'}, - rs{ty, 1, 2}); - checked_set(y, ty, not_a_2digit_year, is); - checked_set(m, tn, not_a_month, is); - checked_set(d, td, not_a_day, is); - } - else - read(is, CharT{'%'}, width, modified, *fmt); - command = nullptr; - width = -1; - modified = CharT{}; - } - else - read(is, *fmt); - break; - case 'F': - if (command) - { - if (modified == CharT{}) - { - int tY = not_a_year; - int tn = not_a_month; - int td = not_a_day; - read(is, rs{tY, 1, width == -1 ? 4u : static_cast(width)}, - CharT{'-'}, ru{tn, 1, 2}, CharT{'-'}, ru{td, 1, 2}); - checked_set(Y, tY, not_a_year, is); - checked_set(m, tn, not_a_month, is); - checked_set(d, td, not_a_day, is); - } - else - read(is, CharT{'%'}, width, modified, *fmt); - command = nullptr; - width = -1; - modified = CharT{}; - } - else - read(is, *fmt); - break; - case 'd': - case 'e': - if (command) - { -#if !ONLY_C_LOCALE - if (modified == CharT{}) -#else - if (modified != CharT{'E'}) -#endif - { - int td = not_a_day; - read(is, rs{td, 1, width == -1 ? 2u : static_cast(width)}); - checked_set(d, td, not_a_day, is); - } -#if !ONLY_C_LOCALE - else if (modified == CharT{'O'}) - { - ios::iostate err = ios::goodbit; - f.get(is, nullptr, is, err, &tm, command, fmt+1); - command = nullptr; - width = -1; - modified = CharT{}; - if ((err & ios::failbit) == 0) - checked_set(d, tm.tm_mday, not_a_day, is); - is.setstate(err); - } -#endif - else - read(is, CharT{'%'}, width, modified, *fmt); - command = nullptr; - width = -1; - modified = CharT{}; - } - else - read(is, *fmt); - break; - case 'H': - if (command) - { -#if !ONLY_C_LOCALE - if (modified == CharT{}) -#else - if (modified != CharT{'E'}) -#endif - { - int tH = not_a_hour; - read(is, ru{tH, 1, width == -1 ? 2u : static_cast(width)}); - checked_set(H, tH, not_a_hour, is); - } -#if !ONLY_C_LOCALE - else if (modified == CharT{'O'}) - { - ios::iostate err = ios::goodbit; - f.get(is, nullptr, is, err, &tm, command, fmt+1); - if ((err & ios::failbit) == 0) - checked_set(H, tm.tm_hour, not_a_hour, is); - is.setstate(err); - } -#endif - else - read(is, CharT{'%'}, width, modified, *fmt); - command = nullptr; - width = -1; - modified = CharT{}; - } - else - read(is, *fmt); - break; - case 'I': - if (command) - { - if (modified == CharT{}) - { - int tI = not_a_hour_12_value; - // reads in an hour into I, but most be in [1, 12] - read(is, rs{tI, 1, width == -1 ? 2u : static_cast(width)}); - if (!(1 <= tI && tI <= 12)) - is.setstate(ios::failbit); - checked_set(I, tI, not_a_hour_12_value, is); - } - else - read(is, CharT{'%'}, width, modified, *fmt); - command = nullptr; - width = -1; - modified = CharT{}; - } - else - read(is, *fmt); - break; - case 'j': - if (command) - { - if (modified == CharT{}) - { - int tj = not_a_doy; - read(is, ru{tj, 1, width == -1 ? 3u : static_cast(width)}); - checked_set(j, tj, not_a_doy, is); - } - else - read(is, CharT{'%'}, width, modified, *fmt); - command = nullptr; - width = -1; - modified = CharT{}; - } - else - read(is, *fmt); - break; - case 'M': - if (command) - { -#if !ONLY_C_LOCALE - if (modified == CharT{}) -#else - if (modified != CharT{'E'}) -#endif - { - int tM = not_a_minute; - read(is, ru{tM, 1, width == -1 ? 2u : static_cast(width)}); - checked_set(M, tM, not_a_minute, is); - } -#if !ONLY_C_LOCALE - else if (modified == CharT{'O'}) - { - ios::iostate err = ios::goodbit; - f.get(is, nullptr, is, err, &tm, command, fmt+1); - if ((err & ios::failbit) == 0) - checked_set(M, tm.tm_min, not_a_minute, is); - is.setstate(err); - } -#endif - else - read(is, CharT{'%'}, width, modified, *fmt); - command = nullptr; - width = -1; - modified = CharT{}; - } - else - read(is, *fmt); - break; - case 'm': - if (command) - { -#if !ONLY_C_LOCALE - if (modified == CharT{}) -#else - if (modified != CharT{'E'}) -#endif - { - int tn = not_a_month; - read(is, rs{tn, 1, width == -1 ? 2u : static_cast(width)}); - checked_set(m, tn, not_a_month, is); - } -#if !ONLY_C_LOCALE - else if (modified == CharT{'O'}) - { - ios::iostate err = ios::goodbit; - f.get(is, nullptr, is, err, &tm, command, fmt+1); - if ((err & ios::failbit) == 0) - checked_set(m, tm.tm_mon + 1, not_a_month, is); - is.setstate(err); - } -#endif - else - read(is, CharT{'%'}, width, modified, *fmt); - command = nullptr; - width = -1; - modified = CharT{}; - } - else - read(is, *fmt); - break; - case 'n': - case 't': - if (command) - { - if (modified == CharT{}) - { - // %n matches a single white space character - // %t matches 0 or 1 white space characters - auto ic = is.peek(); - if (Traits::eq_int_type(ic, Traits::eof())) - { - ios::iostate err = ios::eofbit; - if (*fmt == 'n') - err |= ios::failbit; - is.setstate(err); - break; - } - if (isspace(ic)) - { - (void)is.get(); - } - else if (*fmt == 'n') - is.setstate(ios::failbit); - } - else - read(is, CharT{'%'}, width, modified, *fmt); - command = nullptr; - width = -1; - modified = CharT{}; - } - else - read(is, *fmt); - break; - case 'p': - if (command) - { - if (modified == CharT{}) - { - int tp = not_a_ampm; -#if !ONLY_C_LOCALE - tm = std::tm{}; - tm.tm_hour = 1; - ios::iostate err = ios::goodbit; - f.get(is, nullptr, is, err, &tm, command, fmt+1); - is.setstate(err); - if (tm.tm_hour == 1) - tp = 0; - else if (tm.tm_hour == 13) - tp = 1; - else - is.setstate(err); -#else - auto nm = detail::ampm_names(); - auto i = detail::scan_keyword(is, nm.first, nm.second) - nm.first; - tp = i; -#endif - checked_set(p, tp, not_a_ampm, is); - } - else - read(is, CharT{'%'}, width, modified, *fmt); - command = nullptr; - width = -1; - modified = CharT{}; - } - else - read(is, *fmt); - - break; - case 'r': - if (command) - { - if (modified == CharT{}) - { -#if !ONLY_C_LOCALE - ios::iostate err = ios::goodbit; - f.get(is, nullptr, is, err, &tm, command, fmt+1); - if ((err & ios::failbit) == 0) - { - checked_set(H, tm.tm_hour, not_a_hour, is); - checked_set(M, tm.tm_min, not_a_hour, is); - checked_set(s, duration_cast(seconds{tm.tm_sec}), - not_a_second, is); - } - is.setstate(err); -#else - // "%I:%M:%S %p" - using dfs = detail::decimal_format_seconds; - CONSTDATA auto w = Duration::period::den == 1 ? 2 : 3 + dfs::width; - long double S; - int tI = not_a_hour_12_value; - int tM = not_a_minute; - read(is, ru{tI, 1, 2}, CharT{':'}, ru{tM, 1, 2}, - CharT{':'}, rld{S, 1, w}); - checked_set(I, tI, not_a_hour_12_value, is); - checked_set(M, tM, not_a_minute, is); - checked_set(s, round(duration{S}), - not_a_second, is); - ws(is); - auto nm = detail::ampm_names(); - auto i = detail::scan_keyword(is, nm.first, nm.second) - nm.first; - checked_set(p, static_cast(i), not_a_ampm, is); -#endif - } - else - read(is, CharT{'%'}, width, modified, *fmt); - command = nullptr; - width = -1; - modified = CharT{}; - } - else - read(is, *fmt); - break; - case 'R': - if (command) - { - if (modified == CharT{}) - { - int tH = not_a_hour; - int tM = not_a_minute; - read(is, ru{tH, 1, 2}, CharT{'\0'}, CharT{':'}, CharT{'\0'}, - ru{tM, 1, 2}, CharT{'\0'}); - checked_set(H, tH, not_a_hour, is); - checked_set(M, tM, not_a_minute, is); - } - else - read(is, CharT{'%'}, width, modified, *fmt); - command = nullptr; - width = -1; - modified = CharT{}; - } - else - read(is, *fmt); - break; - case 'S': - if (command) - { - #if !ONLY_C_LOCALE - if (modified == CharT{}) -#else - if (modified != CharT{'E'}) -#endif - { - using dfs = detail::decimal_format_seconds; - CONSTDATA auto w = Duration::period::den == 1 ? 2 : 3 + dfs::width; - long double S; - read(is, rld{S, 1, width == -1 ? w : static_cast(width)}); - checked_set(s, round(duration{S}), - not_a_second, is); - } -#if !ONLY_C_LOCALE - else if (modified == CharT{'O'}) - { - ios::iostate err = ios::goodbit; - f.get(is, nullptr, is, err, &tm, command, fmt+1); - if ((err & ios::failbit) == 0) - checked_set(s, duration_cast(seconds{tm.tm_sec}), - not_a_second, is); - is.setstate(err); - } -#endif - else - read(is, CharT{'%'}, width, modified, *fmt); - command = nullptr; - width = -1; - modified = CharT{}; - } - else - read(is, *fmt); - break; - case 'T': - if (command) - { - if (modified == CharT{}) - { - using dfs = detail::decimal_format_seconds; - CONSTDATA auto w = Duration::period::den == 1 ? 2 : 3 + dfs::width; - int tH = not_a_hour; - int tM = not_a_minute; - long double S; - read(is, ru{tH, 1, 2}, CharT{':'}, ru{tM, 1, 2}, - CharT{':'}, rld{S, 1, w}); - checked_set(H, tH, not_a_hour, is); - checked_set(M, tM, not_a_minute, is); - checked_set(s, round(duration{S}), - not_a_second, is); - } - else - read(is, CharT{'%'}, width, modified, *fmt); - command = nullptr; - width = -1; - modified = CharT{}; - } - else - read(is, *fmt); - break; - case 'Y': - if (command) - { -#if !ONLY_C_LOCALE - if (modified == CharT{}) -#else - if (modified != CharT{'O'}) -#endif - { - int tY = not_a_year; - read(is, rs{tY, 1, width == -1 ? 4u : static_cast(width)}); - checked_set(Y, tY, not_a_year, is); - } -#if !ONLY_C_LOCALE - else if (modified == CharT{'E'}) - { - ios::iostate err = ios::goodbit; - f.get(is, nullptr, is, err, &tm, command, fmt+1); - if ((err & ios::failbit) == 0) - checked_set(Y, tm.tm_year + 1900, not_a_year, is); - is.setstate(err); - } -#endif - else - read(is, CharT{'%'}, width, modified, *fmt); - command = nullptr; - width = -1; - modified = CharT{}; - } - else - read(is, *fmt); - break; - case 'y': - if (command) - { -#if !ONLY_C_LOCALE - if (modified == CharT{}) -#endif - { - int ty = not_a_2digit_year; - read(is, ru{ty, 1, width == -1 ? 2u : static_cast(width)}); - checked_set(y, ty, not_a_2digit_year, is); - } -#if !ONLY_C_LOCALE - else - { - ios::iostate err = ios::goodbit; - f.get(is, nullptr, is, err, &tm, command, fmt+1); - if ((err & ios::failbit) == 0) - checked_set(Y, tm.tm_year + 1900, not_a_year, is); - is.setstate(err); - } -#endif - command = nullptr; - width = -1; - modified = CharT{}; - } - else - read(is, *fmt); - break; - case 'g': - if (command) - { - if (modified == CharT{}) - { - int tg = not_a_2digit_year; - read(is, ru{tg, 1, width == -1 ? 2u : static_cast(width)}); - checked_set(g, tg, not_a_2digit_year, is); - } - else - read(is, CharT{'%'}, width, modified, *fmt); - command = nullptr; - width = -1; - modified = CharT{}; - } - else - read(is, *fmt); - break; - case 'G': - if (command) - { - if (modified == CharT{}) - { - int tG = not_a_year; - read(is, rs{tG, 1, width == -1 ? 4u : static_cast(width)}); - checked_set(G, tG, not_a_year, is); - } - else - read(is, CharT{'%'}, width, modified, *fmt); - command = nullptr; - width = -1; - modified = CharT{}; - } - else - read(is, *fmt); - break; - case 'U': - if (command) - { - if (modified == CharT{}) - { - int tU = not_a_week_num; - read(is, ru{tU, 1, width == -1 ? 2u : static_cast(width)}); - checked_set(U, tU, not_a_week_num, is); - } - else - read(is, CharT{'%'}, width, modified, *fmt); - command = nullptr; - width = -1; - modified = CharT{}; - } - else - read(is, *fmt); - break; - case 'V': - if (command) - { - if (modified == CharT{}) - { - int tV = not_a_week_num; - read(is, ru{tV, 1, width == -1 ? 2u : static_cast(width)}); - checked_set(V, tV, not_a_week_num, is); - } - else - read(is, CharT{'%'}, width, modified, *fmt); - command = nullptr; - width = -1; - modified = CharT{}; - } - else - read(is, *fmt); - break; - case 'W': - if (command) - { - if (modified == CharT{}) - { - int tW = not_a_week_num; - read(is, ru{tW, 1, width == -1 ? 2u : static_cast(width)}); - checked_set(W, tW, not_a_week_num, is); - } - else - read(is, CharT{'%'}, width, modified, *fmt); - command = nullptr; - width = -1; - modified = CharT{}; - } - else - read(is, *fmt); - break; - case 'E': - case 'O': - if (command) - { - if (modified == CharT{}) - { - modified = *fmt; - } - else - { - read(is, CharT{'%'}, width, modified, *fmt); - command = nullptr; - width = -1; - modified = CharT{}; - } - } - else - read(is, *fmt); - break; - case '%': - if (command) - { - if (modified == CharT{}) - read(is, *fmt); - else - read(is, CharT{'%'}, width, modified, *fmt); - command = nullptr; - width = -1; - modified = CharT{}; - } - else - command = fmt; - break; - case 'z': - if (command) - { - int tH, tM; - minutes toff = not_a_offset; - bool neg = false; - auto ic = is.peek(); - if (!Traits::eq_int_type(ic, Traits::eof())) - { - auto c = static_cast(Traits::to_char_type(ic)); - if (c == '-') - neg = true; - } - if (modified == CharT{}) - { - read(is, rs{tH, 2, 2}); - if (!is.fail()) - toff = hours{std::abs(tH)}; - if (is.good()) - { - ic = is.peek(); - if (!Traits::eq_int_type(ic, Traits::eof())) - { - auto c = static_cast(Traits::to_char_type(ic)); - if ('0' <= c && c <= '9') - { - read(is, ru{tM, 2, 2}); - if (!is.fail()) - toff += minutes{tM}; - } - } - } - } - else - { - read(is, rs{tH, 1, 2}); - if (!is.fail()) - toff = hours{std::abs(tH)}; - if (is.good()) - { - ic = is.peek(); - if (!Traits::eq_int_type(ic, Traits::eof())) - { - auto c = static_cast(Traits::to_char_type(ic)); - if (c == ':') - { - (void)is.get(); - read(is, ru{tM, 2, 2}); - if (!is.fail()) - toff += minutes{tM}; - } - } - } - } - if (neg) - toff = -toff; - checked_set(temp_offset, toff, not_a_offset, is); - command = nullptr; - width = -1; - modified = CharT{}; - } - else - read(is, *fmt); - break; - case 'Z': - if (command) - { - if (modified == CharT{}) - { - std::basic_string buf; - while (is.rdstate() == std::ios::goodbit) - { - auto i = is.rdbuf()->sgetc(); - if (Traits::eq_int_type(i, Traits::eof())) - { - is.setstate(ios::eofbit); - break; - } - auto wc = Traits::to_char_type(i); - auto c = static_cast(wc); - // is c a valid time zone name or abbreviation character? - if (!(CharT{1} < wc && wc < CharT{127}) || !(isalnum(c) || - c == '_' || c == '/' || c == '-' || c == '+')) - break; - buf.push_back(c); - is.rdbuf()->sbumpc(); - } - if (buf.empty()) - is.setstate(ios::failbit); - checked_set(temp_abbrev, buf, {}, is); - } - else - read(is, CharT{'%'}, width, modified, *fmt); - command = nullptr; - width = -1; - modified = CharT{}; - } - else - read(is, *fmt); - break; - default: - if (command) - { - if (width == -1 && modified == CharT{} && '0' <= *fmt && *fmt <= '9') - { - width = static_cast(*fmt) - '0'; - while ('0' <= fmt[1] && fmt[1] <= '9') - width = 10*width + static_cast(*++fmt) - '0'; - } - else - { - if (modified == CharT{}) - read(is, CharT{'%'}, width, *fmt); - else - read(is, CharT{'%'}, width, modified, *fmt); - command = nullptr; - width = -1; - modified = CharT{}; - } - } - else // !command - { - if (isspace(static_cast(*fmt))) - ws(is); // space matches 0 or more white space characters - else - read(is, *fmt); - } - break; - } - } - // is.rdstate() != ios::goodbit || *fmt == CharT{} - if (is.rdstate() == ios::goodbit && command) - { - if (modified == CharT{}) - read(is, CharT{'%'}, width); - else - read(is, CharT{'%'}, width, modified); - } - if (is.rdstate() != ios::goodbit && *fmt != CharT{} && !is.fail()) - is.setstate(ios::failbit); - if (!is.fail()) - { - if (y != not_a_2digit_year) - { - // Convert y and an optional C to Y - if (!(0 <= y && y <= 99)) - goto broken; - if (C == not_a_century) - { - if (Y == not_a_year) - { - if (y >= 69) - C = 19; - else - C = 20; - } - else - { - C = (Y >= 0 ? Y : Y-100) / 100; - } - } - int tY; - if (C >= 0) - tY = 100*C + y; - else - tY = 100*(C+1) - (y == 0 ? 100 : y); - if (Y != not_a_year && Y != tY) - goto broken; - Y = tY; - } - if (g != not_a_2digit_year) - { - // Convert g and an optional C to G - if (!(0 <= g && g <= 99)) - goto broken; - if (C == not_a_century) - { - if (G == not_a_year) - { - if (g >= 69) - C = 19; - else - C = 20; - } - else - { - C = (G >= 0 ? G : G-100) / 100; - } - } - int tG; - if (C >= 0) - tG = 100*C + g; - else - tG = 100*(C+1) - (g == 0 ? 100 : g); - if (G != not_a_year && G != tG) - goto broken; - G = tG; - } - if (Y < static_cast(year::min()) || Y > static_cast(year::max())) - Y = not_a_year; - bool computed = false; - if (G != not_a_year && V != not_a_week_num && wd != not_a_weekday) - { - year_month_day ymd_trial = sys_days(year{G-1}/December/Thursday[last]) + - (Monday-Thursday) + weeks{V-1} + - (weekday{static_cast(wd)}-Monday); - if (Y == not_a_year) - Y = static_cast(ymd_trial.year()); - else if (year{Y} != ymd_trial.year()) - goto broken; - if (m == not_a_month) - m = static_cast(static_cast(ymd_trial.month())); - else if (month(static_cast(m)) != ymd_trial.month()) - goto broken; - if (d == not_a_day) - d = static_cast(static_cast(ymd_trial.day())); - else if (day(static_cast(d)) != ymd_trial.day()) - goto broken; - computed = true; - } - if (Y != not_a_year && U != not_a_week_num && wd != not_a_weekday) - { - year_month_day ymd_trial = sys_days(year{Y}/January/Sunday[1]) + - weeks{U-1} + - (weekday{static_cast(wd)} - Sunday); - if (Y == not_a_year) - Y = static_cast(ymd_trial.year()); - else if (year{Y} != ymd_trial.year()) - goto broken; - if (m == not_a_month) - m = static_cast(static_cast(ymd_trial.month())); - else if (month(static_cast(m)) != ymd_trial.month()) - goto broken; - if (d == not_a_day) - d = static_cast(static_cast(ymd_trial.day())); - else if (day(static_cast(d)) != ymd_trial.day()) - goto broken; - computed = true; - } - if (Y != not_a_year && W != not_a_week_num && wd != not_a_weekday) - { - year_month_day ymd_trial = sys_days(year{Y}/January/Monday[1]) + - weeks{W-1} + - (weekday{static_cast(wd)} - Monday); - if (Y == not_a_year) - Y = static_cast(ymd_trial.year()); - else if (year{Y} != ymd_trial.year()) - goto broken; - if (m == not_a_month) - m = static_cast(static_cast(ymd_trial.month())); - else if (month(static_cast(m)) != ymd_trial.month()) - goto broken; - if (d == not_a_day) - d = static_cast(static_cast(ymd_trial.day())); - else if (day(static_cast(d)) != ymd_trial.day()) - goto broken; - computed = true; - } - if (j != not_a_doy && Y != not_a_year) - { - auto ymd_trial = year_month_day{local_days(year{Y}/1/1) + days{j-1}}; - if (m == 0) - m = static_cast(static_cast(ymd_trial.month())); - else if (month(static_cast(m)) != ymd_trial.month()) - goto broken; - if (d == 0) - d = static_cast(static_cast(ymd_trial.day())); - else if (day(static_cast(d)) != ymd_trial.day()) - goto broken; - j = not_a_doy; - } - auto ymd = year{Y}/m/d; - if (ymd.ok()) - { - if (wd == not_a_weekday) - wd = static_cast((weekday(sys_days(ymd)) - Sunday).count()); - else if (wd != static_cast((weekday(sys_days(ymd)) - Sunday).count())) - goto broken; - if (!computed) - { - if (G != not_a_year || V != not_a_week_num) - { - sys_days sd = ymd; - auto G_trial = year_month_day{sd + days{3}}.year(); - auto start = sys_days((G_trial - years{1})/December/Thursday[last]) + - (Monday - Thursday); - if (sd < start) - { - --G_trial; - if (V != not_a_week_num) - start = sys_days((G_trial - years{1})/December/Thursday[last]) - + (Monday - Thursday); - } - if (G != not_a_year && G != static_cast(G_trial)) - goto broken; - if (V != not_a_week_num) - { - auto V_trial = duration_cast(sd - start).count() + 1; - if (V != V_trial) - goto broken; - } - } - if (U != not_a_week_num) - { - auto start = sys_days(Sunday[1]/January/ymd.year()); - auto U_trial = floor(sys_days(ymd) - start).count() + 1; - if (U != U_trial) - goto broken; - } - if (W != not_a_week_num) - { - auto start = sys_days(Monday[1]/January/ymd.year()); - auto W_trial = floor(sys_days(ymd) - start).count() + 1; - if (W != W_trial) - goto broken; - } - } - } - fds.ymd = ymd; - if (I != not_a_hour_12_value) - { - if (!(1 <= I && I <= 12)) - goto broken; - if (p != not_a_ampm) - { - // p is in [0, 1] == [AM, PM] - // Store trial H in I - if (I == 12) - --p; - I += p*12; - // Either set H from I or make sure H and I are consistent - if (H == not_a_hour) - H = I; - else if (I != H) - goto broken; - } - else // p == not_a_ampm - { - // if H, make sure H and I could be consistent - if (H != not_a_hour) - { - if (I == 12) - { - if (H != 0 && H != 12) - goto broken; - } - else if (!(I == H || I == H+12)) - { - goto broken; - } - } - } - } - if (H != not_a_hour) - { - fds.has_tod = true; - fds.tod = hh_mm_ss{hours{H}}; - } - if (M != not_a_minute) - { - fds.has_tod = true; - fds.tod.m_ = minutes{M}; - } - if (s != not_a_second) - { - fds.has_tod = true; - fds.tod.s_ = detail::decimal_format_seconds{s}; - } - if (j != not_a_doy) - { - fds.has_tod = true; - fds.tod.h_ += hours{days{j}}; - } - if (wd != not_a_weekday) - fds.wd = weekday{static_cast(wd)}; - if (abbrev != nullptr) - *abbrev = std::move(temp_abbrev); - if (offset != nullptr && temp_offset != not_a_offset) - *offset = temp_offset; - } - return is; - } -broken: - is.setstate(ios::failbit); - return is; -} - -template > -std::basic_istream& -from_stream(std::basic_istream& is, const CharT* fmt, year& y, - std::basic_string* abbrev = nullptr, - std::chrono::minutes* offset = nullptr) -{ - using CT = std::chrono::seconds; - fields fds{}; - from_stream(is, fmt, fds, abbrev, offset); - if (!fds.ymd.year().ok()) - is.setstate(std::ios::failbit); - if (!is.fail()) - y = fds.ymd.year(); - return is; -} - -template > -std::basic_istream& -from_stream(std::basic_istream& is, const CharT* fmt, month& m, - std::basic_string* abbrev = nullptr, - std::chrono::minutes* offset = nullptr) -{ - using CT = std::chrono::seconds; - fields fds{}; - from_stream(is, fmt, fds, abbrev, offset); - if (!fds.ymd.month().ok()) - is.setstate(std::ios::failbit); - if (!is.fail()) - m = fds.ymd.month(); - return is; -} - -template > -std::basic_istream& -from_stream(std::basic_istream& is, const CharT* fmt, day& d, - std::basic_string* abbrev = nullptr, - std::chrono::minutes* offset = nullptr) -{ - using CT = std::chrono::seconds; - fields fds{}; - from_stream(is, fmt, fds, abbrev, offset); - if (!fds.ymd.day().ok()) - is.setstate(std::ios::failbit); - if (!is.fail()) - d = fds.ymd.day(); - return is; -} - -template > -std::basic_istream& -from_stream(std::basic_istream& is, const CharT* fmt, weekday& wd, - std::basic_string* abbrev = nullptr, - std::chrono::minutes* offset = nullptr) -{ - using CT = std::chrono::seconds; - fields fds{}; - from_stream(is, fmt, fds, abbrev, offset); - if (!fds.wd.ok()) - is.setstate(std::ios::failbit); - if (!is.fail()) - wd = fds.wd; - return is; -} - -template > -std::basic_istream& -from_stream(std::basic_istream& is, const CharT* fmt, year_month& ym, - std::basic_string* abbrev = nullptr, - std::chrono::minutes* offset = nullptr) -{ - using CT = std::chrono::seconds; - fields fds{}; - from_stream(is, fmt, fds, abbrev, offset); - if (!fds.ymd.month().ok()) - is.setstate(std::ios::failbit); - if (!is.fail()) - ym = fds.ymd.year()/fds.ymd.month(); - return is; -} - -template > -std::basic_istream& -from_stream(std::basic_istream& is, const CharT* fmt, month_day& md, - std::basic_string* abbrev = nullptr, - std::chrono::minutes* offset = nullptr) -{ - using CT = std::chrono::seconds; - fields fds{}; - from_stream(is, fmt, fds, abbrev, offset); - if (!fds.ymd.month().ok() || !fds.ymd.day().ok()) - is.setstate(std::ios::failbit); - if (!is.fail()) - md = fds.ymd.month()/fds.ymd.day(); - return is; -} - -template > -std::basic_istream& -from_stream(std::basic_istream& is, const CharT* fmt, - year_month_day& ymd, std::basic_string* abbrev = nullptr, - std::chrono::minutes* offset = nullptr) -{ - using CT = std::chrono::seconds; - fields fds{}; - from_stream(is, fmt, fds, abbrev, offset); - if (!fds.ymd.ok()) - is.setstate(std::ios::failbit); - if (!is.fail()) - ymd = fds.ymd; - return is; -} - -template > -std::basic_istream& -from_stream(std::basic_istream& is, const CharT* fmt, - sys_time& tp, std::basic_string* abbrev = nullptr, - std::chrono::minutes* offset = nullptr) -{ - using CT = typename std::common_type::type; - std::chrono::minutes offset_local{}; - auto offptr = offset ? offset : &offset_local; - fields fds{}; - fds.has_tod = true; - from_stream(is, fmt, fds, abbrev, offptr); - if (!fds.ymd.ok() || !fds.tod.in_conventional_range()) - is.setstate(std::ios::failbit); - if (!is.fail()) - tp = round(sys_days(fds.ymd) - *offptr + fds.tod.to_duration()); - return is; -} - -template > -std::basic_istream& -from_stream(std::basic_istream& is, const CharT* fmt, - local_time& tp, std::basic_string* abbrev = nullptr, - std::chrono::minutes* offset = nullptr) -{ - using CT = typename std::common_type::type; - fields fds{}; - fds.has_tod = true; - from_stream(is, fmt, fds, abbrev, offset); - if (!fds.ymd.ok() || !fds.tod.in_conventional_range()) - is.setstate(std::ios::failbit); - if (!is.fail()) - tp = round(local_seconds{local_days(fds.ymd)} + fds.tod.to_duration()); - return is; -} - -template > -std::basic_istream& -from_stream(std::basic_istream& is, const CharT* fmt, - std::chrono::duration& d, - std::basic_string* abbrev = nullptr, - std::chrono::minutes* offset = nullptr) -{ - using Duration = std::chrono::duration; - using CT = typename std::common_type::type; - fields fds{}; - from_stream(is, fmt, fds, abbrev, offset); - if (!fds.has_tod) - is.setstate(std::ios::failbit); - if (!is.fail()) - d = std::chrono::duration_cast(fds.tod.to_duration()); - return is; -} - -template , - class Alloc = std::allocator> -struct parse_manip -{ - const std::basic_string format_; - Parsable& tp_; - std::basic_string* abbrev_; - std::chrono::minutes* offset_; - -public: - parse_manip(std::basic_string format, Parsable& tp, - std::basic_string* abbrev = nullptr, - std::chrono::minutes* offset = nullptr) - : format_(std::move(format)) - , tp_(tp) - , abbrev_(abbrev) - , offset_(offset) - {} - -}; - -template -std::basic_istream& -operator>>(std::basic_istream& is, - const parse_manip& x) -{ - return from_stream(is, x.format_.c_str(), x.tp_, x.abbrev_, x.offset_); -} - -template -inline -auto -parse(const std::basic_string& format, Parsable& tp) - -> decltype(from_stream(std::declval&>(), - format.c_str(), tp), - parse_manip{format, tp}) -{ - return {format, tp}; -} - -template -inline -auto -parse(const std::basic_string& format, Parsable& tp, - std::basic_string& abbrev) - -> decltype(from_stream(std::declval&>(), - format.c_str(), tp, &abbrev), - parse_manip{format, tp, &abbrev}) -{ - return {format, tp, &abbrev}; -} - -template -inline -auto -parse(const std::basic_string& format, Parsable& tp, - std::chrono::minutes& offset) - -> decltype(from_stream(std::declval&>(), - format.c_str(), tp, - std::declval*>(), - &offset), - parse_manip{format, tp, nullptr, &offset}) -{ - return {format, tp, nullptr, &offset}; -} - -template -inline -auto -parse(const std::basic_string& format, Parsable& tp, - std::basic_string& abbrev, std::chrono::minutes& offset) - -> decltype(from_stream(std::declval&>(), - format.c_str(), tp, &abbrev, &offset), - parse_manip{format, tp, &abbrev, &offset}) -{ - return {format, tp, &abbrev, &offset}; -} - -// const CharT* formats - -template -inline -auto -parse(const CharT* format, Parsable& tp) - -> decltype(from_stream(std::declval&>(), format, tp), - parse_manip{format, tp}) -{ - return {format, tp}; -} - -template -inline -auto -parse(const CharT* format, Parsable& tp, std::basic_string& abbrev) - -> decltype(from_stream(std::declval&>(), format, - tp, &abbrev), - parse_manip{format, tp, &abbrev}) -{ - return {format, tp, &abbrev}; -} - -template -inline -auto -parse(const CharT* format, Parsable& tp, std::chrono::minutes& offset) - -> decltype(from_stream(std::declval&>(), format, - tp, std::declval*>(), &offset), - parse_manip{format, tp, nullptr, &offset}) -{ - return {format, tp, nullptr, &offset}; -} - -template -inline -auto -parse(const CharT* format, Parsable& tp, - std::basic_string& abbrev, std::chrono::minutes& offset) - -> decltype(from_stream(std::declval&>(), format, - tp, &abbrev, &offset), - parse_manip{format, tp, &abbrev, &offset}) -{ - return {format, tp, &abbrev, &offset}; -} - -// duration streaming - -template -inline -std::basic_ostream& -operator<<(std::basic_ostream& os, - const std::chrono::duration& d) -{ - return os << detail::make_string::from(d.count()) + - detail::get_units(typename Period::type{}); -} - -} // namespace date -} // namespace arrow_vendored - -#ifdef _MSC_VER -# pragma warning(pop) -#endif - -#ifdef __GNUC__ -# pragma GCC diagnostic pop -#endif - -#endif // DATE_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/vendored/datetime/ios.h b/cpp/thirdparty/knowhere_build/include/arrow/vendored/datetime/ios.h deleted file mode 100644 index acad28d13b..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/vendored/datetime/ios.h +++ /dev/null @@ -1,53 +0,0 @@ -// -// ios.h -// DateTimeLib -// -// The MIT License (MIT) -// -// Copyright (c) 2016 Alexander Kormanovsky -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#ifndef ios_hpp -#define ios_hpp - -#if __APPLE__ -# include -# if TARGET_OS_IPHONE -# include - - namespace arrow_vendored - { - namespace date - { - namespace iOSUtils - { - - std::string get_tzdata_path(); - std::string get_current_timezone(); - - } // namespace iOSUtils - } // namespace date - } // namespace arrow_vendored - -# endif // TARGET_OS_IPHONE -#else // !__APPLE__ -# define TARGET_OS_IPHONE 0 -#endif // !__APPLE__ -#endif // ios_hpp diff --git a/cpp/thirdparty/knowhere_build/include/arrow/vendored/datetime/tz.h b/cpp/thirdparty/knowhere_build/include/arrow/vendored/datetime/tz.h deleted file mode 100644 index 3f32cec5fc..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/vendored/datetime/tz.h +++ /dev/null @@ -1,2775 +0,0 @@ -#ifndef TZ_H -#define TZ_H - -// The MIT License (MIT) -// -// Copyright (c) 2015, 2016, 2017 Howard Hinnant -// Copyright (c) 2017 Jiangang Zhuang -// Copyright (c) 2017 Aaron Bishop -// Copyright (c) 2017 Tomasz Kamiński -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -// -// Our apologies. When the previous paragraph was written, lowercase had not yet -// been invented (that would involve another several millennia of evolution). -// We did not mean to shout. - -// NOTE(wesm): If this is not set, then the library will attempt to -// use libcurl to obtain a timezone database, and we do not yet have -// curl in our build toolchain -#ifndef _WIN32 -#define USE_OS_TZDB 1 -#endif - -// Get more recent database at http://www.iana.org/time-zones - -// The notion of "current timezone" is something the operating system is expected to "just -// know". How it knows this is system specific. It's often a value set by the user at OS -// installation time and recorded by the OS somewhere. On Linux and Mac systems the current -// timezone name is obtained by looking at the name or contents of a particular file on -// disk. On Windows the current timezone name comes from the registry. In either method, -// there is no guarantee that the "native" current timezone name obtained will match any -// of the "Standard" names in this library's "database". On Linux, the names usually do -// seem to match so mapping functions to map from native to "Standard" are typically not -// required. On Windows, the names are never "Standard" so mapping is always required. -// Technically any OS may use the mapping process but currently only Windows does use it. - -#ifndef USE_OS_TZDB -# define USE_OS_TZDB 0 -#endif - -#ifndef HAS_REMOTE_API -# if USE_OS_TZDB == 0 -# ifdef _WIN32 -# define HAS_REMOTE_API 0 -# else -# define HAS_REMOTE_API 1 -# endif -# else // HAS_REMOTE_API makes no since when using the OS timezone database -# define HAS_REMOTE_API 0 -# endif -#endif - -#ifdef __clang__ -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wconstant-logical-operand" -#endif - -static_assert(!(USE_OS_TZDB && HAS_REMOTE_API), - "USE_OS_TZDB and HAS_REMOTE_API can not be used together"); - -#ifdef __clang__ -# pragma clang diagnostic pop -#endif - -#ifndef AUTO_DOWNLOAD -# define AUTO_DOWNLOAD HAS_REMOTE_API -#endif - -static_assert(HAS_REMOTE_API == 0 ? AUTO_DOWNLOAD == 0 : true, - "AUTO_DOWNLOAD can not be turned on without HAS_REMOTE_API"); - -#ifndef USE_SHELL_API -# define USE_SHELL_API 1 -#endif - -#if USE_OS_TZDB -# ifdef _WIN32 -# error "USE_OS_TZDB can not be used on Windows" -# endif -# ifndef MISSING_LEAP_SECONDS -# ifdef __APPLE__ -# define MISSING_LEAP_SECONDS 1 -# else -# define MISSING_LEAP_SECONDS 0 -# endif -# endif -#else -# define MISSING_LEAP_SECONDS 0 -#endif - -#ifndef HAS_DEDUCTION_GUIDES -# if __cplusplus >= 201703 -# define HAS_DEDUCTION_GUIDES 1 -# else -# define HAS_DEDUCTION_GUIDES 0 -# endif -#endif // HAS_DEDUCTION_GUIDES - -#include "date.h" - -#if defined(_MSC_VER) && (_MSC_VER < 1900) -#include "tz_private.h" -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef _WIN32 -# ifdef DATE_BUILD_DLL -# define DATE_API __declspec(dllexport) -# elif defined(DATE_USE_DLL) -# define DATE_API __declspec(dllimport) -# else -# define DATE_API -# endif -#else -# ifdef DATE_BUILD_DLL -# define DATE_API __attribute__ ((visibility ("default"))) -# else -# define DATE_API -# endif -#endif - -namespace arrow_vendored -{ -namespace date -{ - -enum class choose {earliest, latest}; - -namespace detail -{ - struct undocumented; -} - -struct sys_info -{ - sys_seconds begin; - sys_seconds end; - std::chrono::seconds offset; - std::chrono::minutes save; - std::string abbrev; -}; - -template -std::basic_ostream& -operator<<(std::basic_ostream& os, const sys_info& r) -{ - os << r.begin << '\n'; - os << r.end << '\n'; - os << make_time(r.offset) << "\n"; - os << make_time(r.save) << "\n"; - os << r.abbrev << '\n'; - return os; -} - -struct local_info -{ - enum {unique, nonexistent, ambiguous} result; - sys_info first; - sys_info second; -}; - -template -std::basic_ostream& -operator<<(std::basic_ostream& os, const local_info& r) -{ - if (r.result == local_info::nonexistent) - os << "nonexistent between\n"; - else if (r.result == local_info::ambiguous) - os << "ambiguous between\n"; - os << r.first; - if (r.result != local_info::unique) - { - os << "and\n"; - os << r.second; - } - return os; -} - -class nonexistent_local_time - : public std::runtime_error -{ -public: - template - nonexistent_local_time(local_time tp, const local_info& i); - -private: - template - static - std::string - make_msg(local_time tp, const local_info& i); -}; - -template -inline -nonexistent_local_time::nonexistent_local_time(local_time tp, - const local_info& i) - : std::runtime_error(make_msg(tp, i)) -{ -} - -template -std::string -nonexistent_local_time::make_msg(local_time tp, const local_info& i) -{ - assert(i.result == local_info::nonexistent); - std::ostringstream os; - os << tp << " is in a gap between\n" - << local_seconds{i.first.end.time_since_epoch()} + i.first.offset << ' ' - << i.first.abbrev << " and\n" - << local_seconds{i.second.begin.time_since_epoch()} + i.second.offset << ' ' - << i.second.abbrev - << " which are both equivalent to\n" - << i.first.end << " UTC"; - return os.str(); -} - -class ambiguous_local_time - : public std::runtime_error -{ -public: - template - ambiguous_local_time(local_time tp, const local_info& i); - -private: - template - static - std::string - make_msg(local_time tp, const local_info& i); -}; - -template -inline -ambiguous_local_time::ambiguous_local_time(local_time tp, const local_info& i) - : std::runtime_error(make_msg(tp, i)) -{ -} - -template -std::string -ambiguous_local_time::make_msg(local_time tp, const local_info& i) -{ - assert(i.result == local_info::ambiguous); - std::ostringstream os; - os << tp << " is ambiguous. It could be\n" - << tp << ' ' << i.first.abbrev << " == " - << tp - i.first.offset << " UTC or\n" - << tp << ' ' << i.second.abbrev << " == " - << tp - i.second.offset << " UTC"; - return os.str(); -} - -class time_zone; - -#if HAS_STRING_VIEW -DATE_API const time_zone* locate_zone(std::string_view tz_name); -#else -DATE_API const time_zone* locate_zone(const std::string& tz_name); -#endif - -DATE_API const time_zone* current_zone(); - -template -struct zoned_traits -{ -}; - -template <> -struct zoned_traits -{ - static - const time_zone* - default_zone() - { - return date::locate_zone("Etc/UTC"); - } - -#if HAS_STRING_VIEW - - static - const time_zone* - locate_zone(std::string_view name) - { - return date::locate_zone(name); - } - -#else // !HAS_STRING_VIEW - - static - const time_zone* - locate_zone(const std::string& name) - { - return date::locate_zone(name); - } - - static - const time_zone* - locate_zone(const char* name) - { - return date::locate_zone(name); - } - -#endif // !HAS_STRING_VIEW -}; - -template -class zoned_time; - -template -bool -operator==(const zoned_time& x, - const zoned_time& y); - -template -class zoned_time -{ -public: - using duration = typename std::common_type::type; - -private: - TimeZonePtr zone_; - sys_time tp_; - -public: -#if !defined(_MSC_VER) || (_MSC_VER > 1900) - template ::default_zone())> -#endif - zoned_time(); - -#if !defined(_MSC_VER) || (_MSC_VER > 1900) - template ::default_zone())> -#endif - zoned_time(const sys_time& st); - explicit zoned_time(TimeZonePtr z); - -#if HAS_STRING_VIEW - template ::locate_zone(std::string_view())) - >::value - >::type> - explicit zoned_time(std::string_view name); -#else -# if !defined(_MSC_VER) || (_MSC_VER > 1900) - template ::locate_zone(std::string())) - >::value - >::type> -# endif - explicit zoned_time(const std::string& name); -#endif - - template , - sys_time>::value - >::type> - zoned_time(const zoned_time& zt) NOEXCEPT; - - zoned_time(TimeZonePtr z, const sys_time& st); - -#if !defined(_MSC_VER) || (_MSC_VER > 1900) - template ()->to_sys(local_time{})), - sys_time - >::value - >::type> -#endif - zoned_time(TimeZonePtr z, const local_time& tp); - -#if !defined(_MSC_VER) || (_MSC_VER > 1900) - template ()->to_sys(local_time{}, - choose::earliest)), - sys_time - >::value - >::type> -#endif - zoned_time(TimeZonePtr z, const local_time& tp, choose c); - - template , - sys_time>::value - >::type> - zoned_time(TimeZonePtr z, const zoned_time& zt); - - template , - sys_time>::value - >::type> - zoned_time(TimeZonePtr z, const zoned_time& zt, choose); - -#if HAS_STRING_VIEW - - template ::locate_zone(std::string_view())), - sys_time - >::value - >::type> - zoned_time(std::string_view name, const sys_time& st); - - template ::locate_zone(std::string_view())), - local_time - >::value - >::type> - zoned_time(std::string_view name, const local_time& tp); - - template ::locate_zone(std::string_view())), - local_time, - choose - >::value - >::type> - zoned_time(std::string_view name, const local_time& tp, choose c); - - template , - sys_time>::value && - std::is_constructible - < - zoned_time, - decltype(zoned_traits::locate_zone(std::string_view())), - zoned_time - >::value - >::type> - zoned_time(std::string_view name, const zoned_time& zt); - - template , - sys_time>::value && - std::is_constructible - < - zoned_time, - decltype(zoned_traits::locate_zone(std::string_view())), - zoned_time, - choose - >::value - >::type> - zoned_time(std::string_view name, const zoned_time& zt, choose); - -#else // !HAS_STRING_VIEW - -#if !defined(_MSC_VER) || (_MSC_VER > 1900) - template ::locate_zone(std::string())), - sys_time - >::value - >::type> -#endif - zoned_time(const std::string& name, const sys_time& st); - -#if !defined(_MSC_VER) || (_MSC_VER > 1900) - template ::locate_zone(std::string())), - sys_time - >::value - >::type> -#endif - zoned_time(const char* name, const sys_time& st); - -#if !defined(_MSC_VER) || (_MSC_VER > 1900) - template ::locate_zone(std::string())), - local_time - >::value - >::type> -#endif - zoned_time(const std::string& name, const local_time& tp); - -#if !defined(_MSC_VER) || (_MSC_VER > 1900) - template ::locate_zone(std::string())), - local_time - >::value - >::type> -#endif - zoned_time(const char* name, const local_time& tp); - -#if !defined(_MSC_VER) || (_MSC_VER > 1900) - template ::locate_zone(std::string())), - local_time, - choose - >::value - >::type> -#endif - zoned_time(const std::string& name, const local_time& tp, choose c); - -#if !defined(_MSC_VER) || (_MSC_VER > 1900) - template ::locate_zone(std::string())), - local_time, - choose - >::value - >::type> -#endif - zoned_time(const char* name, const local_time& tp, choose c); - -#if !defined(_MSC_VER) || (_MSC_VER > 1900) - template , - sys_time>::value && - std::is_constructible - < - zoned_time, - decltype(zoned_traits::locate_zone(std::string())), - zoned_time - >::value - >::type> -#else - template -#endif - zoned_time(const std::string& name, const zoned_time& zt); - -#if !defined(_MSC_VER) || (_MSC_VER > 1900) - template , - sys_time>::value && - std::is_constructible - < - zoned_time, - decltype(zoned_traits::locate_zone(std::string())), - zoned_time - >::value - >::type> -#else - template -#endif - zoned_time(const char* name, const zoned_time& zt); - -#if !defined(_MSC_VER) || (_MSC_VER > 1900) - template , - sys_time>::value && - std::is_constructible - < - zoned_time, - decltype(zoned_traits::locate_zone(std::string())), - zoned_time, - choose - >::value - >::type> -#else - template -#endif - zoned_time(const std::string& name, const zoned_time& zt, - choose); - -#if !defined(_MSC_VER) || (_MSC_VER > 1900) - template , - sys_time>::value && - std::is_constructible - < - zoned_time, - decltype(zoned_traits::locate_zone(std::string())), - zoned_time, - choose - >::value - >::type> -#else - template -#endif - zoned_time(const char* name, const zoned_time& zt, - choose); - -#endif // !HAS_STRING_VIEW - - zoned_time& operator=(const sys_time& st); - zoned_time& operator=(const local_time& ut); - - explicit operator sys_time() const; - explicit operator local_time() const; - - TimeZonePtr get_time_zone() const; - local_time get_local_time() const; - sys_time get_sys_time() const; - sys_info get_info() const; - - template - friend - bool - operator==(const zoned_time& x, - const zoned_time& y); - - template - friend - std::basic_ostream& - operator<<(std::basic_ostream& os, - const zoned_time& t); - -private: - template friend class zoned_time; -}; - -using zoned_seconds = zoned_time; - -#if HAS_DEDUCTION_GUIDES - -zoned_time() - -> zoned_time; - -template -zoned_time(sys_time) - -> zoned_time>; - -template -zoned_time(TimeZonePtrOrName) - -> zoned_time::value, - time_zone const*, - TimeZonePtrOrName - >>; - -template -zoned_time(TimeZonePtrOrName, sys_time) - -> zoned_time, - std::conditional_t - < - std::is_convertible::value, - time_zone const*, - TimeZonePtrOrName - >>; - -template -zoned_time(TimeZonePtrOrName, local_time, choose = choose::earliest) - -> zoned_time, - std::conditional_t - < - std::is_convertible::value, - time_zone const*, - TimeZonePtrOrName - >>; - -template -zoned_time(TimeZonePtrOrName, zoned_time, choose = choose::earliest) - -> zoned_time, - std::conditional_t - < - std::is_convertible::value, - time_zone const*, - TimeZonePtrOrName - >>; - -#endif // HAS_DEDUCTION_GUIDES - -template -inline -bool -operator==(const zoned_time& x, - const zoned_time& y) -{ - return x.zone_ == y.zone_ && x.tp_ == y.tp_; -} - -template -inline -bool -operator!=(const zoned_time& x, - const zoned_time& y) -{ - return !(x == y); -} - -#if !defined(_MSC_VER) || (_MSC_VER >= 1900) - -namespace detail -{ -# if USE_OS_TZDB - struct transition; - struct expanded_ttinfo; -# else // !USE_OS_TZDB - struct zonelet; - class Rule; -# endif // !USE_OS_TZDB -} - -#endif // !defined(_MSC_VER) || (_MSC_VER >= 1900) - -class time_zone -{ -private: - std::string name_; -#if USE_OS_TZDB - std::vector transitions_; - std::vector ttinfos_; -#else // !USE_OS_TZDB - std::vector zonelets_; -#endif // !USE_OS_TZDB - std::unique_ptr adjusted_; - -public: -#if !defined(_MSC_VER) || (_MSC_VER >= 1900) - time_zone(time_zone&&) = default; - time_zone& operator=(time_zone&&) = default; -#else // defined(_MSC_VER) && (_MSC_VER < 1900) - time_zone(time_zone&& src); - time_zone& operator=(time_zone&& src); -#endif // defined(_MSC_VER) && (_MSC_VER < 1900) - - DATE_API explicit time_zone(const std::string& s, detail::undocumented); - - const std::string& name() const NOEXCEPT; - - template sys_info get_info(sys_time st) const; - template local_info get_info(local_time tp) const; - - template - sys_time::type> - to_sys(local_time tp) const; - - template - sys_time::type> - to_sys(local_time tp, choose z) const; - - template - local_time::type> - to_local(sys_time tp) const; - - friend bool operator==(const time_zone& x, const time_zone& y) NOEXCEPT; - friend bool operator< (const time_zone& x, const time_zone& y) NOEXCEPT; - friend DATE_API std::ostream& operator<<(std::ostream& os, const time_zone& z); - -#if !USE_OS_TZDB - DATE_API void add(const std::string& s); -#endif // !USE_OS_TZDB - -private: - DATE_API sys_info get_info_impl(sys_seconds tp) const; - DATE_API local_info get_info_impl(local_seconds tp) const; - - template - sys_time::type> - to_sys_impl(local_time tp, choose z, std::false_type) const; - template - sys_time::type> - to_sys_impl(local_time tp, choose, std::true_type) const; - -#if USE_OS_TZDB - DATE_API void init() const; - DATE_API void init_impl(); - DATE_API sys_info - load_sys_info(std::vector::const_iterator i) const; - - template - DATE_API void - load_data(std::istream& inf, std::int32_t tzh_leapcnt, std::int32_t tzh_timecnt, - std::int32_t tzh_typecnt, std::int32_t tzh_charcnt); -#else // !USE_OS_TZDB - DATE_API sys_info get_info_impl(sys_seconds tp, int timezone) const; - DATE_API void adjust_infos(const std::vector& rules); - DATE_API void parse_info(std::istream& in); -#endif // !USE_OS_TZDB -}; - -#if defined(_MSC_VER) && (_MSC_VER < 1900) - -inline -time_zone::time_zone(time_zone&& src) - : name_(std::move(src.name_)) - , zonelets_(std::move(src.zonelets_)) - , adjusted_(std::move(src.adjusted_)) - {} - -inline -time_zone& -time_zone::operator=(time_zone&& src) -{ - name_ = std::move(src.name_); - zonelets_ = std::move(src.zonelets_); - adjusted_ = std::move(src.adjusted_); - return *this; -} - -#endif // defined(_MSC_VER) && (_MSC_VER < 1900) - -inline -const std::string& -time_zone::name() const NOEXCEPT -{ - return name_; -} - -template -inline -sys_info -time_zone::get_info(sys_time st) const -{ - return get_info_impl(date::floor(st)); -} - -template -inline -local_info -time_zone::get_info(local_time tp) const -{ - return get_info_impl(date::floor(tp)); -} - -template -inline -sys_time::type> -time_zone::to_sys(local_time tp) const -{ - return to_sys_impl(tp, choose{}, std::true_type{}); -} - -template -inline -sys_time::type> -time_zone::to_sys(local_time tp, choose z) const -{ - return to_sys_impl(tp, z, std::false_type{}); -} - -template -inline -local_time::type> -time_zone::to_local(sys_time tp) const -{ - using LT = local_time::type>; - auto i = get_info(tp); - return LT{(tp + i.offset).time_since_epoch()}; -} - -inline bool operator==(const time_zone& x, const time_zone& y) NOEXCEPT {return x.name_ == y.name_;} -inline bool operator< (const time_zone& x, const time_zone& y) NOEXCEPT {return x.name_ < y.name_;} - -inline bool operator!=(const time_zone& x, const time_zone& y) NOEXCEPT {return !(x == y);} -inline bool operator> (const time_zone& x, const time_zone& y) NOEXCEPT {return y < x;} -inline bool operator<=(const time_zone& x, const time_zone& y) NOEXCEPT {return !(y < x);} -inline bool operator>=(const time_zone& x, const time_zone& y) NOEXCEPT {return !(x < y);} - -template -sys_time::type> -time_zone::to_sys_impl(local_time tp, choose z, std::false_type) const -{ - auto i = get_info(tp); - if (i.result == local_info::nonexistent) - { - return i.first.end; - } - else if (i.result == local_info::ambiguous) - { - if (z == choose::latest) - return sys_time{tp.time_since_epoch()} - i.second.offset; - } - return sys_time{tp.time_since_epoch()} - i.first.offset; -} - -template -sys_time::type> -time_zone::to_sys_impl(local_time tp, choose, std::true_type) const -{ - auto i = get_info(tp); - if (i.result == local_info::nonexistent) - throw nonexistent_local_time(tp, i); - else if (i.result == local_info::ambiguous) - throw ambiguous_local_time(tp, i); - return sys_time{tp.time_since_epoch()} - i.first.offset; -} - -#if !USE_OS_TZDB - -class link -{ -private: - std::string name_; - std::string target_; -public: - DATE_API explicit link(const std::string& s); - - const std::string& name() const {return name_;} - const std::string& target() const {return target_;} - - friend bool operator==(const link& x, const link& y) {return x.name_ == y.name_;} - friend bool operator< (const link& x, const link& y) {return x.name_ < y.name_;} - - friend DATE_API std::ostream& operator<<(std::ostream& os, const link& x); -}; - -inline bool operator!=(const link& x, const link& y) {return !(x == y);} -inline bool operator> (const link& x, const link& y) {return y < x;} -inline bool operator<=(const link& x, const link& y) {return !(y < x);} -inline bool operator>=(const link& x, const link& y) {return !(x < y);} - -#endif // !USE_OS_TZDB - -#if !MISSING_LEAP_SECONDS - -class leap -{ -private: - sys_seconds date_; - -public: -#if USE_OS_TZDB - DATE_API explicit leap(const sys_seconds& s, detail::undocumented); -#else - DATE_API explicit leap(const std::string& s, detail::undocumented); -#endif - - sys_seconds date() const {return date_;} - - friend bool operator==(const leap& x, const leap& y) {return x.date_ == y.date_;} - friend bool operator< (const leap& x, const leap& y) {return x.date_ < y.date_;} - - template - friend - bool - operator==(const leap& x, const sys_time& y) - { - return x.date_ == y; - } - - template - friend - bool - operator< (const leap& x, const sys_time& y) - { - return x.date_ < y; - } - - template - friend - bool - operator< (const sys_time& x, const leap& y) - { - return x < y.date_; - } - - friend DATE_API std::ostream& operator<<(std::ostream& os, const leap& x); -}; - -inline bool operator!=(const leap& x, const leap& y) {return !(x == y);} -inline bool operator> (const leap& x, const leap& y) {return y < x;} -inline bool operator<=(const leap& x, const leap& y) {return !(y < x);} -inline bool operator>=(const leap& x, const leap& y) {return !(x < y);} - -template -inline -bool -operator==(const sys_time& x, const leap& y) -{ - return y == x; -} - -template -inline -bool -operator!=(const leap& x, const sys_time& y) -{ - return !(x == y); -} - -template -inline -bool -operator!=(const sys_time& x, const leap& y) -{ - return !(x == y); -} - -template -inline -bool -operator> (const leap& x, const sys_time& y) -{ - return y < x; -} - -template -inline -bool -operator> (const sys_time& x, const leap& y) -{ - return y < x; -} - -template -inline -bool -operator<=(const leap& x, const sys_time& y) -{ - return !(y < x); -} - -template -inline -bool -operator<=(const sys_time& x, const leap& y) -{ - return !(y < x); -} - -template -inline -bool -operator>=(const leap& x, const sys_time& y) -{ - return !(x < y); -} - -template -inline -bool -operator>=(const sys_time& x, const leap& y) -{ - return !(x < y); -} - -#endif // !MISSING_LEAP_SECONDS - -#ifdef _WIN32 - -namespace detail -{ - -// The time zone mapping is modelled after this data file: -// http://unicode.org/repos/cldr/trunk/common/supplemental/windowsZones.xml -// and the field names match the element names from the mapZone element -// of windowsZones.xml. -// The website displays this file here: -// http://www.unicode.org/cldr/charts/latest/supplemental/zone_tzid.html -// The html view is sorted before being displayed but is otherwise the same -// There is a mapping between the os centric view (in this case windows) -// the html displays uses and the generic view the xml file. -// That mapping is this: -// display column "windows" -> xml field "other". -// display column "region" -> xml field "territory". -// display column "tzid" -> xml field "type". -// This structure uses the generic terminology because it could be -// used to to support other os/native name conversions, not just windows, -// and using the same generic names helps retain the connection to the -// origin of the data that we are using. -struct timezone_mapping -{ - timezone_mapping(const char* other, const char* territory, const char* type) - : other(other), territory(territory), type(type) - { - } - timezone_mapping() = default; - std::string other; - std::string territory; - std::string type; -}; - -} // detail - -#endif // _WIN32 - -struct tzdb -{ - std::string version = "unknown"; - std::vector zones; -#if !USE_OS_TZDB - std::vector links; -#endif -#if !MISSING_LEAP_SECONDS - std::vector leaps; -#endif -#if !USE_OS_TZDB - std::vector rules; -#endif -#ifdef _WIN32 - std::vector mappings; -#endif - tzdb* next = nullptr; - - tzdb() = default; -#if !defined(_MSC_VER) || (_MSC_VER >= 1900) - tzdb(tzdb&&) = default; - tzdb& operator=(tzdb&&) = default; -#else // defined(_MSC_VER) && (_MSC_VER < 1900) - tzdb(tzdb&& src) - : version(std::move(src.version)) - , zones(std::move(src.zones)) - , links(std::move(src.links)) - , leaps(std::move(src.leaps)) - , rules(std::move(src.rules)) - , mappings(std::move(src.mappings)) - {} - - tzdb& operator=(tzdb&& src) - { - version = std::move(src.version); - zones = std::move(src.zones); - links = std::move(src.links); - leaps = std::move(src.leaps); - rules = std::move(src.rules); - mappings = std::move(src.mappings); - return *this; - } -#endif // defined(_MSC_VER) && (_MSC_VER < 1900) - -#if HAS_STRING_VIEW - const time_zone* locate_zone(std::string_view tz_name) const; -#else - const time_zone* locate_zone(const std::string& tz_name) const; -#endif - const time_zone* current_zone() const; -}; - -using TZ_DB = tzdb; - -DATE_API std::ostream& -operator<<(std::ostream& os, const tzdb& db); - -DATE_API const tzdb& get_tzdb(); - -class tzdb_list -{ - std::atomic head_{nullptr}; - -public: - ~tzdb_list(); - tzdb_list() = default; - tzdb_list(tzdb_list&& x) noexcept; - - const tzdb& front() const noexcept {return *head_;} - tzdb& front() noexcept {return *head_;} - - class const_iterator; - - const_iterator begin() const noexcept; - const_iterator end() const noexcept; - - const_iterator cbegin() const noexcept; - const_iterator cend() const noexcept; - - const_iterator erase_after(const_iterator p) noexcept; - - struct undocumented_helper; -private: - void push_front(tzdb* tzdb) noexcept; -}; - -class tzdb_list::const_iterator -{ - tzdb* p_ = nullptr; - - explicit const_iterator(tzdb* p) noexcept : p_{p} {} -public: - const_iterator() = default; - - using iterator_category = std::forward_iterator_tag; - using value_type = tzdb; - using reference = const value_type&; - using pointer = const value_type*; - using difference_type = std::ptrdiff_t; - - reference operator*() const noexcept {return *p_;} - pointer operator->() const noexcept {return p_;} - - const_iterator& operator++() noexcept {p_ = p_->next; return *this;} - const_iterator operator++(int) noexcept {auto t = *this; ++(*this); return t;} - - friend - bool - operator==(const const_iterator& x, const const_iterator& y) noexcept - {return x.p_ == y.p_;} - - friend - bool - operator!=(const const_iterator& x, const const_iterator& y) noexcept - {return !(x == y);} - - friend class tzdb_list; -}; - -inline -tzdb_list::const_iterator -tzdb_list::begin() const noexcept -{ - return const_iterator{head_}; -} - -inline -tzdb_list::const_iterator -tzdb_list::end() const noexcept -{ - return const_iterator{nullptr}; -} - -inline -tzdb_list::const_iterator -tzdb_list::cbegin() const noexcept -{ - return begin(); -} - -inline -tzdb_list::const_iterator -tzdb_list::cend() const noexcept -{ - return end(); -} - -DATE_API tzdb_list& get_tzdb_list(); - -#if !USE_OS_TZDB - -DATE_API const tzdb& reload_tzdb(); -DATE_API void set_install(const std::string& install); - -#endif // !USE_OS_TZDB - -#if HAS_REMOTE_API - -DATE_API std::string remote_version(); -DATE_API bool remote_download(const std::string& version); -DATE_API bool remote_install(const std::string& version); - -#endif - -// zoned_time - -namespace detail -{ - -template -inline -T* -to_raw_pointer(T* p) noexcept -{ - return p; -} - -template -inline -auto -to_raw_pointer(Pointer p) noexcept - -> decltype(detail::to_raw_pointer(p.operator->())) -{ - return detail::to_raw_pointer(p.operator->()); -} - -} // namespace detail - -template -#if !defined(_MSC_VER) || (_MSC_VER > 1900) -template -#endif -inline -zoned_time::zoned_time() - : zone_(zoned_traits::default_zone()) - {} - -template -#if !defined(_MSC_VER) || (_MSC_VER > 1900) -template -#endif -inline -zoned_time::zoned_time(const sys_time& st) - : zone_(zoned_traits::default_zone()) - , tp_(st) - {} - -template -inline -zoned_time::zoned_time(TimeZonePtr z) - : zone_(std::move(z)) - {assert(detail::to_raw_pointer(zone_) != nullptr);} - -#if HAS_STRING_VIEW - -template -template -inline -zoned_time::zoned_time(std::string_view name) - : zoned_time(zoned_traits::locate_zone(name)) - {} - -#else // !HAS_STRING_VIEW - -template -#if !defined(_MSC_VER) || (_MSC_VER > 1900) -template -#endif -inline -zoned_time::zoned_time(const std::string& name) - : zoned_time(zoned_traits::locate_zone(name)) - {} - -#endif // !HAS_STRING_VIEW - -template -template -inline -zoned_time::zoned_time(const zoned_time& zt) NOEXCEPT - : zone_(zt.zone_) - , tp_(zt.tp_) - {} - -template -inline -zoned_time::zoned_time(TimeZonePtr z, const sys_time& st) - : zone_(std::move(z)) - , tp_(st) - {} - -template -#if !defined(_MSC_VER) || (_MSC_VER > 1900) -template -#endif -inline -zoned_time::zoned_time(TimeZonePtr z, const local_time& t) - : zone_(std::move(z)) - , tp_(zone_->to_sys(t)) - {} - -template -#if !defined(_MSC_VER) || (_MSC_VER > 1900) -template -#endif -inline -zoned_time::zoned_time(TimeZonePtr z, const local_time& t, - choose c) - : zone_(std::move(z)) - , tp_(zone_->to_sys(t, c)) - {} - -template -template -inline -zoned_time::zoned_time(TimeZonePtr z, - const zoned_time& zt) - : zone_(std::move(z)) - , tp_(zt.tp_) - {} - -template -template -inline -zoned_time::zoned_time(TimeZonePtr z, - const zoned_time& zt, choose) - : zoned_time(std::move(z), zt) - {} - -#if HAS_STRING_VIEW - -template -template -inline -zoned_time::zoned_time(std::string_view name, - const sys_time& st) - : zoned_time(zoned_traits::locate_zone(name), st) - {} - -template -template -inline -zoned_time::zoned_time(std::string_view name, - const local_time& t) - : zoned_time(zoned_traits::locate_zone(name), t) - {} - -template -template -inline -zoned_time::zoned_time(std::string_view name, - const local_time& t, choose c) - : zoned_time(zoned_traits::locate_zone(name), t, c) - {} - -template -template -inline -zoned_time::zoned_time(std::string_view name, - const zoned_time& zt) - : zoned_time(zoned_traits::locate_zone(name), zt) - {} - -template -template -inline -zoned_time::zoned_time(std::string_view name, - const zoned_time& zt, - choose c) - : zoned_time(zoned_traits::locate_zone(name), zt, c) - {} - -#else // !HAS_STRING_VIEW - -template -#if !defined(_MSC_VER) || (_MSC_VER > 1900) -template -#endif -inline -zoned_time::zoned_time(const std::string& name, - const sys_time& st) - : zoned_time(zoned_traits::locate_zone(name), st) - {} - -template -#if !defined(_MSC_VER) || (_MSC_VER > 1900) -template -#endif -inline -zoned_time::zoned_time(const char* name, - const sys_time& st) - : zoned_time(zoned_traits::locate_zone(name), st) - {} - -template -#if !defined(_MSC_VER) || (_MSC_VER > 1900) -template -#endif -inline -zoned_time::zoned_time(const std::string& name, - const local_time& t) - : zoned_time(zoned_traits::locate_zone(name), t) - {} - -template -#if !defined(_MSC_VER) || (_MSC_VER > 1900) -template -#endif -inline -zoned_time::zoned_time(const char* name, - const local_time& t) - : zoned_time(zoned_traits::locate_zone(name), t) - {} - -template -#if !defined(_MSC_VER) || (_MSC_VER > 1900) -template -#endif -inline -zoned_time::zoned_time(const std::string& name, - const local_time& t, choose c) - : zoned_time(zoned_traits::locate_zone(name), t, c) - {} - -template -#if !defined(_MSC_VER) || (_MSC_VER > 1900) -template -#endif -inline -zoned_time::zoned_time(const char* name, - const local_time& t, choose c) - : zoned_time(zoned_traits::locate_zone(name), t, c) - {} - -template -#if !defined(_MSC_VER) || (_MSC_VER > 1900) -template -#else -template -#endif -inline -zoned_time::zoned_time(const std::string& name, - const zoned_time& zt) - : zoned_time(zoned_traits::locate_zone(name), zt) - {} - -template -#if !defined(_MSC_VER) || (_MSC_VER > 1900) -template -#else -template -#endif -inline -zoned_time::zoned_time(const char* name, - const zoned_time& zt) - : zoned_time(zoned_traits::locate_zone(name), zt) - {} - -template -#if !defined(_MSC_VER) || (_MSC_VER > 1900) -template -#else -template -#endif -inline -zoned_time::zoned_time(const std::string& name, - const zoned_time& zt, - choose c) - : zoned_time(zoned_traits::locate_zone(name), zt, c) - {} - -template -#if !defined(_MSC_VER) || (_MSC_VER > 1900) -template -#else -template -#endif -inline -zoned_time::zoned_time(const char* name, - const zoned_time& zt, - choose c) - : zoned_time(zoned_traits::locate_zone(name), zt, c) - {} - -#endif // HAS_STRING_VIEW - -template -inline -zoned_time& -zoned_time::operator=(const sys_time& st) -{ - tp_ = st; - return *this; -} - -template -inline -zoned_time& -zoned_time::operator=(const local_time& ut) -{ - tp_ = zone_->to_sys(ut); - return *this; -} - -template -inline -zoned_time::operator local_time::duration>() const -{ - return get_local_time(); -} - -template -inline -zoned_time::operator sys_time::duration>() const -{ - return get_sys_time(); -} - -template -inline -TimeZonePtr -zoned_time::get_time_zone() const -{ - return zone_; -} - -template -inline -local_time::duration> -zoned_time::get_local_time() const -{ - return zone_->to_local(tp_); -} - -template -inline -sys_time::duration> -zoned_time::get_sys_time() const -{ - return tp_; -} - -template -inline -sys_info -zoned_time::get_info() const -{ - return zone_->get_info(tp_); -} - -// make_zoned_time - -inline -zoned_time -make_zoned() -{ - return zoned_time(); -} - -template -inline -zoned_time::type> -make_zoned(const sys_time& tp) -{ - return zoned_time::type>(tp); -} - -template 1900) - , class = typename std::enable_if - < - std::is_class - < - typename std::decay - < - decltype(*detail::to_raw_pointer(std::declval())) - >::type - >{} - >::type -#endif - > -inline -zoned_time -make_zoned(TimeZonePtr z) -{ - return zoned_time(std::move(z)); -} - -inline -zoned_seconds -make_zoned(const std::string& name) -{ - return zoned_seconds(name); -} - -template 1900) - , class = typename std::enable_if - < - std::is_class())>::type>{} - >::type -#endif - > -inline -zoned_time::type, TimeZonePtr> -make_zoned(TimeZonePtr zone, const local_time& tp) -{ - return zoned_time::type, - TimeZonePtr>(std::move(zone), tp); -} - -template 1900) - , class = typename std::enable_if - < - std::is_class())>::type>{} - >::type -#endif - > -inline -zoned_time::type, TimeZonePtr> -make_zoned(TimeZonePtr zone, const local_time& tp, choose c) -{ - return zoned_time::type, - TimeZonePtr>(std::move(zone), tp, c); -} - -template -inline -zoned_time::type> -make_zoned(const std::string& name, const local_time& tp) -{ - return zoned_time::type>(name, tp); -} - -template -inline -zoned_time::type> -make_zoned(const std::string& name, const local_time& tp, choose c) -{ - return zoned_time::type>(name, tp, c); -} - -template -inline -zoned_time -make_zoned(TimeZonePtr zone, const zoned_time& zt) -{ - return zoned_time(std::move(zone), zt); -} - -template -inline -zoned_time -make_zoned(const std::string& name, const zoned_time& zt) -{ - return zoned_time(name, zt); -} - -template -inline -zoned_time -make_zoned(TimeZonePtr zone, const zoned_time& zt, choose c) -{ - return zoned_time(std::move(zone), zt, c); -} - -template -inline -zoned_time -make_zoned(const std::string& name, const zoned_time& zt, choose c) -{ - return zoned_time(name, zt, c); -} - -template 1900) - , class = typename std::enable_if - < - std::is_class())>::type>{} - >::type -#endif - > -inline -zoned_time::type, TimeZonePtr> -make_zoned(TimeZonePtr zone, const sys_time& st) -{ - return zoned_time::type, - TimeZonePtr>(std::move(zone), st); -} - -template -inline -zoned_time::type> -make_zoned(const std::string& name, const sys_time& st) -{ - return zoned_time::type>(name, st); -} - -template -std::basic_ostream& -to_stream(std::basic_ostream& os, const CharT* fmt, - const zoned_time& tp) -{ - using duration = typename zoned_time::duration; - using LT = local_time; - auto const st = tp.get_sys_time(); - auto const info = tp.get_time_zone()->get_info(st); - return to_stream(os, fmt, LT{(st+info.offset).time_since_epoch()}, - &info.abbrev, &info.offset); -} - -template -inline -std::basic_ostream& -operator<<(std::basic_ostream& os, const zoned_time& t) -{ - const CharT fmt[] = {'%', 'F', ' ', '%', 'T', ' ', '%', 'Z', CharT{}}; - return to_stream(os, fmt, t); -} - -#if !MISSING_LEAP_SECONDS - -class utc_clock -{ -public: - using duration = std::chrono::system_clock::duration; - using rep = duration::rep; - using period = duration::period; - using time_point = std::chrono::time_point; - static CONSTDATA bool is_steady = false; - - static time_point now(); - - template - static - std::chrono::time_point::type> - to_sys(const std::chrono::time_point&); - - template - static - std::chrono::time_point::type> - from_sys(const std::chrono::time_point&); - - template - static - std::chrono::time_point::type> - to_local(const std::chrono::time_point&); - - template - static - std::chrono::time_point::type> - from_local(const std::chrono::time_point&); -}; - -template - using utc_time = std::chrono::time_point; - -using utc_seconds = utc_time; - -template -utc_time::type> -utc_clock::from_sys(const sys_time& st) -{ - using std::chrono::seconds; - using CD = typename std::common_type::type; - auto const& leaps = get_tzdb().leaps; - auto const lt = std::upper_bound(leaps.begin(), leaps.end(), st); - return utc_time{st.time_since_epoch() + seconds{lt-leaps.begin()}}; -} - -// Return pair -// first is true if ut is during a leap second insertion, otherwise false. -// If ut is during a leap second insertion, that leap second is included in the count -template -std::pair -is_leap_second(date::utc_time const& ut) -{ - using std::chrono::seconds; - using duration = typename std::common_type::type; - auto const& leaps = get_tzdb().leaps; - auto tp = sys_time{ut.time_since_epoch()}; - auto const lt = std::upper_bound(leaps.begin(), leaps.end(), tp); - auto ds = seconds{lt-leaps.begin()}; - tp -= ds; - auto ls = false; - if (lt > leaps.begin()) - { - if (tp < lt[-1]) - { - if (tp >= lt[-1].date() - seconds{1}) - ls = true; - else - --ds; - } - } - return {ls, ds}; -} - -struct leap_second_info -{ - bool is_leap_second; - std::chrono::seconds elapsed; -}; - -template -leap_second_info -get_leap_second_info(date::utc_time const& ut) -{ - auto p = is_leap_second(ut); - return {p.first, p.second}; -} - -template -sys_time::type> -utc_clock::to_sys(const utc_time& ut) -{ - using std::chrono::seconds; - using CD = typename std::common_type::type; - auto ls = is_leap_second(ut); - auto tp = sys_time{ut.time_since_epoch() - ls.second}; - if (ls.first) - tp = floor(tp) + seconds{1} - CD{1}; - return tp; -} - -inline -utc_clock::time_point -utc_clock::now() -{ - return from_sys(std::chrono::system_clock::now()); -} - -template -utc_time::type> -utc_clock::from_local(const local_time& st) -{ - return from_sys(sys_time{st.time_since_epoch()}); -} - -template -local_time::type> -utc_clock::to_local(const utc_time& ut) -{ - using CD = typename std::common_type::type; - return local_time{to_sys(ut).time_since_epoch()}; -} - -template -std::basic_ostream& -to_stream(std::basic_ostream& os, const CharT* fmt, - const utc_time& t) -{ - using std::chrono::seconds; - using CT = typename std::common_type::type; - const std::string abbrev("UTC"); - CONSTDATA seconds offset{0}; - auto ls = is_leap_second(t); - auto tp = sys_time{t.time_since_epoch() - ls.second}; - auto const sd = floor(tp); - year_month_day ymd = sd; - auto time = make_time(tp - sys_seconds{sd}); - time.seconds(detail::undocumented{}) += seconds{ls.first}; - fields fds{ymd, time}; - return to_stream(os, fmt, fds, &abbrev, &offset); -} - -template -std::basic_ostream& -operator<<(std::basic_ostream& os, const utc_time& t) -{ - const CharT fmt[] = {'%', 'F', ' ', '%', 'T', CharT{}}; - return to_stream(os, fmt, t); -} - -template > -std::basic_istream& -from_stream(std::basic_istream& is, const CharT* fmt, - utc_time& tp, std::basic_string* abbrev = nullptr, - std::chrono::minutes* offset = nullptr) -{ - using std::chrono::seconds; - using std::chrono::minutes; - using CT = typename std::common_type::type; - minutes offset_local{}; - auto offptr = offset ? offset : &offset_local; - fields fds{}; - fds.has_tod = true; - from_stream(is, fmt, fds, abbrev, offptr); - if (!fds.ymd.ok()) - is.setstate(std::ios::failbit); - if (!is.fail()) - { - bool is_60_sec = fds.tod.seconds() == seconds{60}; - if (is_60_sec) - fds.tod.seconds(detail::undocumented{}) -= seconds{1}; - auto tmp = utc_clock::from_sys(sys_days(fds.ymd) - *offptr + fds.tod.to_duration()); - if (is_60_sec) - tmp += seconds{1}; - if (is_60_sec != is_leap_second(tmp).first || !fds.tod.in_conventional_range()) - { - is.setstate(std::ios::failbit); - return is; - } - tp = std::chrono::time_point_cast(tmp); - } - return is; -} - -// tai_clock - -class tai_clock -{ -public: - using duration = std::chrono::system_clock::duration; - using rep = duration::rep; - using period = duration::period; - using time_point = std::chrono::time_point; - static const bool is_steady = false; - - static time_point now(); - - template - static - std::chrono::time_point::type> - to_utc(const std::chrono::time_point&) NOEXCEPT; - - template - static - std::chrono::time_point::type> - from_utc(const std::chrono::time_point&) NOEXCEPT; - - template - static - std::chrono::time_point::type> - to_local(const std::chrono::time_point&) NOEXCEPT; - - template - static - std::chrono::time_point::type> - from_local(const std::chrono::time_point&) NOEXCEPT; -}; - -template - using tai_time = std::chrono::time_point; - -using tai_seconds = tai_time; - -template -inline -utc_time::type> -tai_clock::to_utc(const tai_time& t) NOEXCEPT -{ - using std::chrono::seconds; - using CD = typename std::common_type::type; - return utc_time{t.time_since_epoch()} - - (sys_days(year{1970}/January/1) - sys_days(year{1958}/January/1) + seconds{10}); -} - -template -inline -tai_time::type> -tai_clock::from_utc(const utc_time& t) NOEXCEPT -{ - using std::chrono::seconds; - using CD = typename std::common_type::type; - return tai_time{t.time_since_epoch()} + - (sys_days(year{1970}/January/1) - sys_days(year{1958}/January/1) + seconds{10}); -} - -inline -tai_clock::time_point -tai_clock::now() -{ - return from_utc(utc_clock::now()); -} - -template -inline -local_time::type> -tai_clock::to_local(const tai_time& t) NOEXCEPT -{ - using CD = typename std::common_type::type; - return local_time{t.time_since_epoch()} - - (local_days(year{1970}/January/1) - local_days(year{1958}/January/1)); -} - -template -inline -tai_time::type> -tai_clock::from_local(const local_time& t) NOEXCEPT -{ - using CD = typename std::common_type::type; - return tai_time{t.time_since_epoch()} + - (local_days(year{1970}/January/1) - local_days(year{1958}/January/1)); -} - -template -std::basic_ostream& -to_stream(std::basic_ostream& os, const CharT* fmt, - const tai_time& t) -{ - const std::string abbrev("TAI"); - CONSTDATA std::chrono::seconds offset{0}; - return to_stream(os, fmt, tai_clock::to_local(t), &abbrev, &offset); -} - -template -std::basic_ostream& -operator<<(std::basic_ostream& os, const tai_time& t) -{ - const CharT fmt[] = {'%', 'F', ' ', '%', 'T', CharT{}}; - return to_stream(os, fmt, t); -} - -template > -std::basic_istream& -from_stream(std::basic_istream& is, const CharT* fmt, - tai_time& tp, - std::basic_string* abbrev = nullptr, - std::chrono::minutes* offset = nullptr) -{ - local_time lp; - from_stream(is, fmt, lp, abbrev, offset); - if (!is.fail()) - tp = tai_clock::from_local(lp); - return is; -} - -// gps_clock - -class gps_clock -{ -public: - using duration = std::chrono::system_clock::duration; - using rep = duration::rep; - using period = duration::period; - using time_point = std::chrono::time_point; - static const bool is_steady = false; - - static time_point now(); - - template - static - std::chrono::time_point::type> - to_utc(const std::chrono::time_point&) NOEXCEPT; - - template - static - std::chrono::time_point::type> - from_utc(const std::chrono::time_point&) NOEXCEPT; - - template - static - std::chrono::time_point::type> - to_local(const std::chrono::time_point&) NOEXCEPT; - - template - static - std::chrono::time_point::type> - from_local(const std::chrono::time_point&) NOEXCEPT; -}; - -template - using gps_time = std::chrono::time_point; - -using gps_seconds = gps_time; - -template -inline -utc_time::type> -gps_clock::to_utc(const gps_time& t) NOEXCEPT -{ - using std::chrono::seconds; - using CD = typename std::common_type::type; - return utc_time{t.time_since_epoch()} + - (sys_days(year{1980}/January/Sunday[1]) - sys_days(year{1970}/January/1) + - seconds{9}); -} - -template -inline -gps_time::type> -gps_clock::from_utc(const utc_time& t) NOEXCEPT -{ - using std::chrono::seconds; - using CD = typename std::common_type::type; - return gps_time{t.time_since_epoch()} - - (sys_days(year{1980}/January/Sunday[1]) - sys_days(year{1970}/January/1) + - seconds{9}); -} - -inline -gps_clock::time_point -gps_clock::now() -{ - return from_utc(utc_clock::now()); -} - -template -inline -local_time::type> -gps_clock::to_local(const gps_time& t) NOEXCEPT -{ - using CD = typename std::common_type::type; - return local_time{t.time_since_epoch()} + - (local_days(year{1980}/January/Sunday[1]) - local_days(year{1970}/January/1)); -} - -template -inline -gps_time::type> -gps_clock::from_local(const local_time& t) NOEXCEPT -{ - using CD = typename std::common_type::type; - return gps_time{t.time_since_epoch()} - - (local_days(year{1980}/January/Sunday[1]) - local_days(year{1970}/January/1)); -} - - -template -std::basic_ostream& -to_stream(std::basic_ostream& os, const CharT* fmt, - const gps_time& t) -{ - const std::string abbrev("GPS"); - CONSTDATA std::chrono::seconds offset{0}; - return to_stream(os, fmt, gps_clock::to_local(t), &abbrev, &offset); -} - -template -std::basic_ostream& -operator<<(std::basic_ostream& os, const gps_time& t) -{ - const CharT fmt[] = {'%', 'F', ' ', '%', 'T', CharT{}}; - return to_stream(os, fmt, t); -} - -template > -std::basic_istream& -from_stream(std::basic_istream& is, const CharT* fmt, - gps_time& tp, - std::basic_string* abbrev = nullptr, - std::chrono::minutes* offset = nullptr) -{ - local_time lp; - from_stream(is, fmt, lp, abbrev, offset); - if (!is.fail()) - tp = gps_clock::from_local(lp); - return is; -} - -// clock_time_conversion - -template -struct clock_time_conversion -{}; - -template <> -struct clock_time_conversion -{ - template - sys_time - operator()(const sys_time& st) const - { - return st; - } -}; - -template <> -struct clock_time_conversion -{ - template - utc_time - operator()(const utc_time& ut) const - { - return ut; - } -}; - -template<> -struct clock_time_conversion -{ - template - local_time - operator()(const local_time& lt) const - { - return lt; - } -}; - -template <> -struct clock_time_conversion -{ - template - utc_time::type> - operator()(const sys_time& st) const - { - return utc_clock::from_sys(st); - } -}; - -template <> -struct clock_time_conversion -{ - template - sys_time::type> - operator()(const utc_time& ut) const - { - return utc_clock::to_sys(ut); - } -}; - -template<> -struct clock_time_conversion -{ - template - local_time - operator()(const sys_time& st) const - { - return local_time{st.time_since_epoch()}; - } -}; - -template<> -struct clock_time_conversion -{ - template - sys_time - operator()(const local_time& lt) const - { - return sys_time{lt.time_since_epoch()}; - } -}; - -template<> -struct clock_time_conversion -{ - template - utc_time::type> - operator()(const local_time& lt) const - { - return utc_clock::from_local(lt); - } -}; - -template<> -struct clock_time_conversion -{ - template - local_time::type> - operator()(const utc_time& ut) const - { - return utc_clock::to_local(ut); - } -}; - -template -struct clock_time_conversion -{ - template - std::chrono::time_point - operator()(const std::chrono::time_point& tp) const - { - return tp; - } -}; - -namespace ctc_detail -{ - -template - using time_point = std::chrono::time_point; - -using std::declval; -using std::chrono::system_clock; - -//Check if TimePoint is time for given clock, -//if not emits hard error -template -struct return_clock_time -{ - using clock_time_point = time_point; - using type = TimePoint; - - static_assert(std::is_same::value, - "time point with appropariate clock shall be returned"); -}; - -// Check if Clock has to_sys method accepting TimePoint with given duration const& and -// returning sys_time. If so has nested type member equal to return type to_sys. -template -struct return_to_sys -{}; - -template -struct return_to_sys - < - Clock, Duration, - decltype(Clock::to_sys(declval const&>()), void()) - > - : return_clock_time - < - system_clock, - decltype(Clock::to_sys(declval const&>())) - > -{}; - -// Similiar to above -template -struct return_from_sys -{}; - -template -struct return_from_sys - < - Clock, Duration, - decltype(Clock::from_sys(declval const&>()), - void()) - > - : return_clock_time - < - Clock, - decltype(Clock::from_sys(declval const&>())) - > -{}; - -// Similiar to above -template -struct return_to_utc -{}; - -template -struct return_to_utc - < - Clock, Duration, - decltype(Clock::to_utc(declval const&>()), void()) - > - : return_clock_time - < - utc_clock, - decltype(Clock::to_utc(declval const&>()))> -{}; - -// Similiar to above -template -struct return_from_utc -{}; - -template -struct return_from_utc - < - Clock, Duration, - decltype(Clock::from_utc(declval const&>()), - void()) - > - : return_clock_time - < - Clock, - decltype(Clock::from_utc(declval const&>())) - > -{}; - -// Similiar to above -template -struct return_to_local -{}; - -template -struct return_to_local - < - Clock, Duration, - decltype(Clock::to_local(declval const&>()), - void()) - > - : return_clock_time - < - local_t, - decltype(Clock::to_local(declval const&>())) - > -{}; - -// Similiar to above -template -struct return_from_local -{}; - -template -struct return_from_local - < - Clock, Duration, - decltype(Clock::from_local(declval const&>()), - void()) - > - : return_clock_time - < - Clock, - decltype(Clock::from_local(declval const&>())) - > -{}; - -} // namespace ctc_detail - -template -struct clock_time_conversion -{ - template - typename ctc_detail::return_to_sys::type - operator()(const std::chrono::time_point& tp) const - { - return SrcClock::to_sys(tp); - } -}; - -template -struct clock_time_conversion -{ - template - typename ctc_detail::return_from_sys::type - operator()(const sys_time& st) const - { - return DstClock::from_sys(st); - } -}; - -template -struct clock_time_conversion -{ - template - typename ctc_detail::return_to_utc::type - operator()(const std::chrono::time_point& tp) const - { - return SrcClock::to_utc(tp); - } -}; - -template -struct clock_time_conversion -{ - template - typename ctc_detail::return_from_utc::type - operator()(const utc_time& ut) const - { - return DstClock::from_utc(ut); - } -}; - -template -struct clock_time_conversion -{ - template - typename ctc_detail::return_to_local::type - operator()(const std::chrono::time_point& tp) const - { - return SrcClock::to_local(tp); - } -}; - -template -struct clock_time_conversion -{ - template - typename ctc_detail::return_from_local::type - operator()(const local_time& lt) const - { - return DstClock::from_local(lt); - } -}; - -namespace clock_cast_detail -{ - -template - using time_point = std::chrono::time_point; -using std::chrono::system_clock; - -template -auto -conv_clock(const time_point& t) - -> decltype(std::declval>()(t)) -{ - return clock_time_conversion{}(t); -} - -//direct trait conversion, 1st candidate -template -auto -cc_impl(const time_point& t, const time_point*) - -> decltype(conv_clock(t)) -{ - return conv_clock(t); -} - -//conversion through sys, 2nd candidate -template -auto -cc_impl(const time_point& t, const void*) - -> decltype(conv_clock(conv_clock(t))) -{ - return conv_clock(conv_clock(t)); -} - -//conversion through utc, 2nd candidate -template -auto -cc_impl(const time_point& t, const void*) - -> decltype(0, // MSVC_WORKAROUND - conv_clock(conv_clock(t))) -{ - return conv_clock(conv_clock(t)); -} - -//conversion through sys and utc, 3rd candidate -template -auto -cc_impl(const time_point& t, ...) - -> decltype(conv_clock(conv_clock(conv_clock(t)))) -{ - return conv_clock(conv_clock(conv_clock(t))); -} - -//conversion through utc and sys, 3rd candidate -template -auto -cc_impl(const time_point& t, ...) - -> decltype(0, // MSVC_WORKAROUND - conv_clock(conv_clock(conv_clock(t)))) -{ - return conv_clock(conv_clock(conv_clock(t))); -} - -} // namespace clock_cast_detail - -template -auto -clock_cast(const std::chrono::time_point& tp) - -> decltype(clock_cast_detail::cc_impl(tp, &tp)) -{ - return clock_cast_detail::cc_impl(tp, &tp); -} - -// Deprecated API - -template -inline -sys_time::type> -to_sys_time(const utc_time& t) -{ - return utc_clock::to_sys(t); -} - -template -inline -sys_time::type> -to_sys_time(const tai_time& t) -{ - return utc_clock::to_sys(tai_clock::to_utc(t)); -} - -template -inline -sys_time::type> -to_sys_time(const gps_time& t) -{ - return utc_clock::to_sys(gps_clock::to_utc(t)); -} - - -template -inline -utc_time::type> -to_utc_time(const sys_time& t) -{ - return utc_clock::from_sys(t); -} - -template -inline -utc_time::type> -to_utc_time(const tai_time& t) -{ - return tai_clock::to_utc(t); -} - -template -inline -utc_time::type> -to_utc_time(const gps_time& t) -{ - return gps_clock::to_utc(t); -} - - -template -inline -tai_time::type> -to_tai_time(const sys_time& t) -{ - return tai_clock::from_utc(utc_clock::from_sys(t)); -} - -template -inline -tai_time::type> -to_tai_time(const utc_time& t) -{ - return tai_clock::from_utc(t); -} - -template -inline -tai_time::type> -to_tai_time(const gps_time& t) -{ - return tai_clock::from_utc(gps_clock::to_utc(t)); -} - - -template -inline -gps_time::type> -to_gps_time(const sys_time& t) -{ - return gps_clock::from_utc(utc_clock::from_sys(t)); -} - -template -inline -gps_time::type> -to_gps_time(const utc_time& t) -{ - return gps_clock::from_utc(t); -} - -template -inline -gps_time::type> -to_gps_time(const tai_time& t) -{ - return gps_clock::from_utc(tai_clock::to_utc(t)); -} - -#endif // !MISSING_LEAP_SECONDS - -} // namespace date -} // namespace arrow_vendored - -#endif // TZ_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/vendored/datetime/tz_private.h b/cpp/thirdparty/knowhere_build/include/arrow/vendored/datetime/tz_private.h deleted file mode 100644 index 039e56585a..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/vendored/datetime/tz_private.h +++ /dev/null @@ -1,319 +0,0 @@ -#ifndef TZ_PRIVATE_H -#define TZ_PRIVATE_H - -// The MIT License (MIT) -// -// Copyright (c) 2015, 2016 Howard Hinnant -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -// -// Our apologies. When the previous paragraph was written, lowercase had not yet -// been invented (that would involve another several millennia of evolution). -// We did not mean to shout. - -#if !defined(_MSC_VER) || (_MSC_VER >= 1900) -#include "tz.h" -#else -#include "date.h" -#include -#endif - -namespace arrow_vendored -{ -namespace date -{ - -namespace detail -{ - -#if !USE_OS_TZDB - -enum class tz {utc, local, standard}; - -//forward declare to avoid warnings in gcc 6.2 -class MonthDayTime; -std::istream& operator>>(std::istream& is, MonthDayTime& x); -std::ostream& operator<<(std::ostream& os, const MonthDayTime& x); - - -class MonthDayTime -{ -private: - struct pair - { -#if defined(_MSC_VER) && (_MSC_VER < 1900) - pair() : month_day_(date::jan / 1), weekday_(0U) {} - - pair(const date::month_day& month_day, const date::weekday& weekday) - : month_day_(month_day), weekday_(weekday) {} -#endif - - date::month_day month_day_; - date::weekday weekday_; - }; - - enum Type {month_day, month_last_dow, lteq, gteq}; - - Type type_{month_day}; - -#if !defined(_MSC_VER) || (_MSC_VER >= 1900) - union U -#else - struct U -#endif - { - date::month_day month_day_; - date::month_weekday_last month_weekday_last_; - pair month_day_weekday_; - -#if !defined(_MSC_VER) || (_MSC_VER >= 1900) - U() : month_day_{date::jan/1} {} -#else - U() : - month_day_(date::jan/1), - month_weekday_last_(date::month(0U), date::weekday_last(date::weekday(0U))) - {} - -#endif // !defined(_MSC_VER) || (_MSC_VER >= 1900) - - U& operator=(const date::month_day& x); - U& operator=(const date::month_weekday_last& x); - U& operator=(const pair& x); - } u; - - std::chrono::hours h_{0}; - std::chrono::minutes m_{0}; - std::chrono::seconds s_{0}; - tz zone_{tz::local}; - -public: - MonthDayTime() = default; - MonthDayTime(local_seconds tp, tz timezone); - MonthDayTime(const date::month_day& md, tz timezone); - - date::day day() const; - date::month month() const; - tz zone() const {return zone_;} - - void canonicalize(date::year y); - - sys_seconds - to_sys(date::year y, std::chrono::seconds offset, std::chrono::seconds save) const; - sys_days to_sys_days(date::year y) const; - - sys_seconds to_time_point(date::year y) const; - int compare(date::year y, const MonthDayTime& x, date::year yx, - std::chrono::seconds offset, std::chrono::minutes prev_save) const; - - friend std::istream& operator>>(std::istream& is, MonthDayTime& x); - friend std::ostream& operator<<(std::ostream& os, const MonthDayTime& x); -}; - -// A Rule specifies one or more set of datetimes without using an offset. -// Multiple dates are specified with multiple years. The years in effect -// go from starting_year_ to ending_year_, inclusive. starting_year_ <= -// ending_year_. save_ is in effect for times from the specified time -// onward, including the specified time. When the specified time is -// local, it uses the save_ from the chronologically previous Rule, or if -// there is none, 0. - -//forward declare to avoid warnings in gcc 6.2 -class Rule; -bool operator==(const Rule& x, const Rule& y); -bool operator<(const Rule& x, const Rule& y); -bool operator==(const Rule& x, const date::year& y); -bool operator<(const Rule& x, const date::year& y); -bool operator==(const date::year& x, const Rule& y); -bool operator<(const date::year& x, const Rule& y); -bool operator==(const Rule& x, const std::string& y); -bool operator<(const Rule& x, const std::string& y); -bool operator==(const std::string& x, const Rule& y); -bool operator<(const std::string& x, const Rule& y); -std::ostream& operator<<(std::ostream& os, const Rule& r); - -class Rule -{ -private: - std::string name_; - date::year starting_year_{0}; - date::year ending_year_{0}; - MonthDayTime starting_at_; - std::chrono::minutes save_{0}; - std::string abbrev_; - -public: - Rule() = default; - explicit Rule(const std::string& s); - Rule(const Rule& r, date::year starting_year, date::year ending_year); - - const std::string& name() const {return name_;} - const std::string& abbrev() const {return abbrev_;} - - const MonthDayTime& mdt() const {return starting_at_;} - const date::year& starting_year() const {return starting_year_;} - const date::year& ending_year() const {return ending_year_;} - const std::chrono::minutes& save() const {return save_;} - - static void split_overlaps(std::vector& rules); - - friend bool operator==(const Rule& x, const Rule& y); - friend bool operator<(const Rule& x, const Rule& y); - friend bool operator==(const Rule& x, const date::year& y); - friend bool operator<(const Rule& x, const date::year& y); - friend bool operator==(const date::year& x, const Rule& y); - friend bool operator<(const date::year& x, const Rule& y); - friend bool operator==(const Rule& x, const std::string& y); - friend bool operator<(const Rule& x, const std::string& y); - friend bool operator==(const std::string& x, const Rule& y); - friend bool operator<(const std::string& x, const Rule& y); - - friend std::ostream& operator<<(std::ostream& os, const Rule& r); - -private: - date::day day() const; - date::month month() const; - static void split_overlaps(std::vector& rules, std::size_t i, std::size_t& e); - static bool overlaps(const Rule& x, const Rule& y); - static void split(std::vector& rules, std::size_t i, std::size_t k, - std::size_t& e); -}; - -inline bool operator!=(const Rule& x, const Rule& y) {return !(x == y);} -inline bool operator> (const Rule& x, const Rule& y) {return y < x;} -inline bool operator<=(const Rule& x, const Rule& y) {return !(y < x);} -inline bool operator>=(const Rule& x, const Rule& y) {return !(x < y);} - -inline bool operator!=(const Rule& x, const date::year& y) {return !(x == y);} -inline bool operator> (const Rule& x, const date::year& y) {return y < x;} -inline bool operator<=(const Rule& x, const date::year& y) {return !(y < x);} -inline bool operator>=(const Rule& x, const date::year& y) {return !(x < y);} - -inline bool operator!=(const date::year& x, const Rule& y) {return !(x == y);} -inline bool operator> (const date::year& x, const Rule& y) {return y < x;} -inline bool operator<=(const date::year& x, const Rule& y) {return !(y < x);} -inline bool operator>=(const date::year& x, const Rule& y) {return !(x < y);} - -inline bool operator!=(const Rule& x, const std::string& y) {return !(x == y);} -inline bool operator> (const Rule& x, const std::string& y) {return y < x;} -inline bool operator<=(const Rule& x, const std::string& y) {return !(y < x);} -inline bool operator>=(const Rule& x, const std::string& y) {return !(x < y);} - -inline bool operator!=(const std::string& x, const Rule& y) {return !(x == y);} -inline bool operator> (const std::string& x, const Rule& y) {return y < x;} -inline bool operator<=(const std::string& x, const Rule& y) {return !(y < x);} -inline bool operator>=(const std::string& x, const Rule& y) {return !(x < y);} - -struct zonelet -{ - enum tag {has_rule, has_save, is_empty}; - - std::chrono::seconds gmtoff_; - tag tag_ = has_rule; - -#if !defined(_MSC_VER) || (_MSC_VER >= 1900) - union U -#else - struct U -#endif - { - std::string rule_; - std::chrono::minutes save_; - - ~U() {} - U() {} - U(const U&) {} - U& operator=(const U&) = delete; - } u; - - std::string format_; - date::year until_year_{0}; - MonthDayTime until_date_; - sys_seconds until_utc_; - local_seconds until_std_; - local_seconds until_loc_; - std::chrono::minutes initial_save_{}; - std::string initial_abbrev_; - std::pair first_rule_{nullptr, date::year::min()}; - std::pair last_rule_{nullptr, date::year::max()}; - - ~zonelet(); - zonelet(); - zonelet(const zonelet& i); - zonelet& operator=(const zonelet&) = delete; -}; - -#else // USE_OS_TZDB - -struct ttinfo -{ - std::int32_t tt_gmtoff; - unsigned char tt_isdst; - unsigned char tt_abbrind; - unsigned char pad[2]; -}; - -static_assert(sizeof(ttinfo) == 8, ""); - -struct expanded_ttinfo -{ - std::chrono::seconds offset; - std::string abbrev; - bool is_dst; -}; - -struct transition -{ - sys_seconds timepoint; - const expanded_ttinfo* info; - - transition(sys_seconds tp, const expanded_ttinfo* i = nullptr) - : timepoint(tp) - , info(i) - {} - - friend - std::ostream& - operator<<(std::ostream& os, const transition& t) - { - using date::operator<<; - os << t.timepoint << "Z "; - if (t.info->offset >= std::chrono::seconds{0}) - os << '+'; - os << make_time(t.info->offset); - if (t.info->is_dst > 0) - os << " daylight "; - else - os << " standard "; - os << t.info->abbrev; - return os; - } -}; - -#endif // USE_OS_TZDB - -} // namespace detail - -} // namespace date -} // namespace arrow_vendored - -#if defined(_MSC_VER) && (_MSC_VER < 1900) -#include "tz.h" -#endif - -#endif // TZ_PRIVATE_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/vendored/datetime/visibility.h b/cpp/thirdparty/knowhere_build/include/arrow/vendored/datetime/visibility.h deleted file mode 100644 index ae031238d8..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/vendored/datetime/visibility.h +++ /dev/null @@ -1,26 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#if defined(ARROW_STATIC) -// intentially empty -#elif defined(ARROW_EXPORTING) -#define DATE_BUILD_DLL -#else -#define DATE_USE_DLL -#endif diff --git a/cpp/thirdparty/knowhere_build/include/arrow/vendored/string_view.hpp b/cpp/thirdparty/knowhere_build/include/arrow/vendored/string_view.hpp deleted file mode 100644 index d912ee812c..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/vendored/string_view.hpp +++ /dev/null @@ -1,1330 +0,0 @@ -// Vendored from git tag 062acda5e35c8922dbbccf81300a58edea521b45 - -// Copyright 2017-2019 by Martin Moene -// -// string-view lite, a C++17-like string_view for C++98 and later. -// For more information see https://github.com/martinmoene/string-view-lite -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#pragma once - -#ifndef NONSTD_SV_LITE_H_INCLUDED -#define NONSTD_SV_LITE_H_INCLUDED - -#define string_view_lite_MAJOR 1 -#define string_view_lite_MINOR 1 -#define string_view_lite_PATCH 0 - -#define string_view_lite_VERSION nssv_STRINGIFY(string_view_lite_MAJOR) "." nssv_STRINGIFY(string_view_lite_MINOR) "." nssv_STRINGIFY(string_view_lite_PATCH) - -#define nssv_STRINGIFY( x ) nssv_STRINGIFY_( x ) -#define nssv_STRINGIFY_( x ) #x - -// string-view lite configuration: - -#define nssv_STRING_VIEW_DEFAULT 0 -#define nssv_STRING_VIEW_NONSTD 1 -#define nssv_STRING_VIEW_STD 2 - -#if !defined( nssv_CONFIG_SELECT_STRING_VIEW ) -# define nssv_CONFIG_SELECT_STRING_VIEW ( nssv_HAVE_STD_STRING_VIEW ? nssv_STRING_VIEW_STD : nssv_STRING_VIEW_NONSTD ) -#endif - -#if defined( nssv_CONFIG_SELECT_STD_STRING_VIEW ) || defined( nssv_CONFIG_SELECT_NONSTD_STRING_VIEW ) -# error nssv_CONFIG_SELECT_STD_STRING_VIEW and nssv_CONFIG_SELECT_NONSTD_STRING_VIEW are deprecated and removed, please use nssv_CONFIG_SELECT_STRING_VIEW=nssv_STRING_VIEW_... -#endif - -#ifndef nssv_CONFIG_STD_SV_OPERATOR -# define nssv_CONFIG_STD_SV_OPERATOR 0 -#endif - -#ifndef nssv_CONFIG_USR_SV_OPERATOR -# define nssv_CONFIG_USR_SV_OPERATOR 1 -#endif - -#ifdef nssv_CONFIG_CONVERSION_STD_STRING -# define nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS nssv_CONFIG_CONVERSION_STD_STRING -# define nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS nssv_CONFIG_CONVERSION_STD_STRING -#endif - -#ifndef nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS -# define nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS 1 -#endif - -#ifndef nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS -# define nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS 1 -#endif - -// Control presence of exception handling (try and auto discover): - -#ifndef nssv_CONFIG_NO_EXCEPTIONS -# if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND) -# define nssv_CONFIG_NO_EXCEPTIONS 0 -# else -# define nssv_CONFIG_NO_EXCEPTIONS 1 -# endif -#endif - -// C++ language version detection (C++20 is speculative): -// Note: VC14.0/1900 (VS2015) lacks too much from C++14. - -#ifndef nssv_CPLUSPLUS -# if defined(_MSVC_LANG ) && !defined(__clang__) -# define nssv_CPLUSPLUS (_MSC_VER == 1900 ? 201103L : _MSVC_LANG ) -# else -# define nssv_CPLUSPLUS __cplusplus -# endif -#endif - -#define nssv_CPP98_OR_GREATER ( nssv_CPLUSPLUS >= 199711L ) -#define nssv_CPP11_OR_GREATER ( nssv_CPLUSPLUS >= 201103L ) -#define nssv_CPP11_OR_GREATER_ ( nssv_CPLUSPLUS >= 201103L ) -#define nssv_CPP14_OR_GREATER ( nssv_CPLUSPLUS >= 201402L ) -#define nssv_CPP17_OR_GREATER ( nssv_CPLUSPLUS >= 201703L ) -#define nssv_CPP20_OR_GREATER ( nssv_CPLUSPLUS >= 202000L ) - -// use C++17 std::string_view if available and requested: - -#if nssv_CPP17_OR_GREATER && defined(__has_include ) -# if __has_include( ) -# define nssv_HAVE_STD_STRING_VIEW 1 -# else -# define nssv_HAVE_STD_STRING_VIEW 0 -# endif -#else -# define nssv_HAVE_STD_STRING_VIEW 0 -#endif - -#define nssv_USES_STD_STRING_VIEW ( (nssv_CONFIG_SELECT_STRING_VIEW == nssv_STRING_VIEW_STD) || ((nssv_CONFIG_SELECT_STRING_VIEW == nssv_STRING_VIEW_DEFAULT) && nssv_HAVE_STD_STRING_VIEW) ) - -#define nssv_HAVE_STARTS_WITH ( nssv_CPP20_OR_GREATER || !nssv_USES_STD_STRING_VIEW ) -#define nssv_HAVE_ENDS_WITH nssv_HAVE_STARTS_WITH - -// -// Use C++17 std::string_view: -// - -#if nssv_USES_STD_STRING_VIEW - -#include - -// Extensions for std::string: - -#if nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS - -namespace nonstd { - -template< class CharT, class Traits, class Allocator = std::allocator > -std::basic_string -to_string( std::basic_string_view v, Allocator const & a = Allocator() ) -{ - return std::basic_string( v.begin(), v.end(), a ); -} - -template< class CharT, class Traits, class Allocator > -std::basic_string_view -to_string_view( std::basic_string const & s ) -{ - return std::basic_string_view( s.data(), s.size() ); -} - -// Literal operators sv and _sv: - -#if nssv_CONFIG_STD_SV_OPERATOR - -using namespace std::literals::string_view_literals; - -#endif - -#if nssv_CONFIG_USR_SV_OPERATOR - -inline namespace literals { -inline namespace string_view_literals { - - -constexpr std::string_view operator "" _sv( const char* str, size_t len ) noexcept // (1) -{ - return std::string_view{ str, len }; -} - -constexpr std::u16string_view operator "" _sv( const char16_t* str, size_t len ) noexcept // (2) -{ - return std::u16string_view{ str, len }; -} - -constexpr std::u32string_view operator "" _sv( const char32_t* str, size_t len ) noexcept // (3) -{ - return std::u32string_view{ str, len }; -} - -constexpr std::wstring_view operator "" _sv( const wchar_t* str, size_t len ) noexcept // (4) -{ - return std::wstring_view{ str, len }; -} - -}} // namespace literals::string_view_literals - -#endif // nssv_CONFIG_USR_SV_OPERATOR - -} // namespace nonstd - -#endif // nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS - -namespace nonstd { - -using std::string_view; -using std::wstring_view; -using std::u16string_view; -using std::u32string_view; -using std::basic_string_view; - -// literal "sv" and "_sv", see above - -using std::operator==; -using std::operator!=; -using std::operator<; -using std::operator<=; -using std::operator>; -using std::operator>=; - -using std::operator<<; - -} // namespace nonstd - -#else // nssv_HAVE_STD_STRING_VIEW - -// -// Before C++17: use string_view lite: -// - -// Compiler versions: -// -// MSVC++ 6.0 _MSC_VER == 1200 (Visual Studio 6.0) -// MSVC++ 7.0 _MSC_VER == 1300 (Visual Studio .NET 2002) -// MSVC++ 7.1 _MSC_VER == 1310 (Visual Studio .NET 2003) -// MSVC++ 8.0 _MSC_VER == 1400 (Visual Studio 2005) -// MSVC++ 9.0 _MSC_VER == 1500 (Visual Studio 2008) -// MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010) -// MSVC++ 11.0 _MSC_VER == 1700 (Visual Studio 2012) -// MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013) -// MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015) -// MSVC++ 14.1 _MSC_VER >= 1910 (Visual Studio 2017) - -#if defined(_MSC_VER ) && !defined(__clang__) -# define nssv_COMPILER_MSVC_VER (_MSC_VER ) -# define nssv_COMPILER_MSVC_VERSION (_MSC_VER / 10 - 10 * ( 5 + (_MSC_VER < 1900 ) ) ) -#else -# define nssv_COMPILER_MSVC_VER 0 -# define nssv_COMPILER_MSVC_VERSION 0 -#endif - -#define nssv_COMPILER_VERSION( major, minor, patch ) ( 10 * ( 10 * (major) + (minor) ) + (patch) ) - -#if defined(__clang__) -# define nssv_COMPILER_CLANG_VERSION nssv_COMPILER_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__) -#else -# define nssv_COMPILER_CLANG_VERSION 0 -#endif - -#if defined(__GNUC__) && !defined(__clang__) -# define nssv_COMPILER_GNUC_VERSION nssv_COMPILER_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) -#else -# define nssv_COMPILER_GNUC_VERSION 0 -#endif - -// half-open range [lo..hi): -#define nssv_BETWEEN( v, lo, hi ) ( (lo) <= (v) && (v) < (hi) ) - -// Presence of language and library features: - -#ifdef _HAS_CPP0X -# define nssv_HAS_CPP0X _HAS_CPP0X -#else -# define nssv_HAS_CPP0X 0 -#endif - -// Unless defined otherwise below, consider VC14 as C++11 for variant-lite: - -#if nssv_COMPILER_MSVC_VER >= 1900 -# undef nssv_CPP11_OR_GREATER -# define nssv_CPP11_OR_GREATER 1 -#endif - -#define nssv_CPP11_90 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1500) -#define nssv_CPP11_100 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1600) -#define nssv_CPP11_110 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1700) -#define nssv_CPP11_120 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1800) -#define nssv_CPP11_140 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1900) -#define nssv_CPP11_141 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1910) - -#define nssv_CPP14_000 (nssv_CPP14_OR_GREATER) -#define nssv_CPP17_000 (nssv_CPP17_OR_GREATER) - -// Presence of C++11 language features: - -#define nssv_HAVE_CONSTEXPR_11 nssv_CPP11_140 -#define nssv_HAVE_EXPLICIT_CONVERSION nssv_CPP11_140 -#define nssv_HAVE_INLINE_NAMESPACE nssv_CPP11_140 -#define nssv_HAVE_NOEXCEPT nssv_CPP11_140 -#define nssv_HAVE_NULLPTR nssv_CPP11_100 -#define nssv_HAVE_REF_QUALIFIER nssv_CPP11_140 -#define nssv_HAVE_UNICODE_LITERALS nssv_CPP11_140 -#define nssv_HAVE_USER_DEFINED_LITERALS nssv_CPP11_140 -#define nssv_HAVE_WCHAR16_T nssv_CPP11_100 -#define nssv_HAVE_WCHAR32_T nssv_CPP11_100 - -#if ! ( ( nssv_CPP11_OR_GREATER && nssv_COMPILER_CLANG_VERSION ) || nssv_BETWEEN( nssv_COMPILER_CLANG_VERSION, 300, 400 ) ) -# define nssv_HAVE_STD_DEFINED_LITERALS nssv_CPP11_140 -#else -# define nssv_HAVE_STD_DEFINED_LITERALS 0 -#endif - -// Presence of C++14 language features: - -#define nssv_HAVE_CONSTEXPR_14 nssv_CPP14_000 - -// Presence of C++17 language features: - -#define nssv_HAVE_NODISCARD nssv_CPP17_000 - -// Presence of C++ library features: - -#define nssv_HAVE_STD_HASH nssv_CPP11_120 - -// C++ feature usage: - -#if nssv_HAVE_CONSTEXPR_11 -# define nssv_constexpr constexpr -#else -# define nssv_constexpr /*constexpr*/ -#endif - -#if nssv_HAVE_CONSTEXPR_14 -# define nssv_constexpr14 constexpr -#else -# define nssv_constexpr14 /*constexpr*/ -#endif - -#if nssv_HAVE_EXPLICIT_CONVERSION -# define nssv_explicit explicit -#else -# define nssv_explicit /*explicit*/ -#endif - -#if nssv_HAVE_INLINE_NAMESPACE -# define nssv_inline_ns inline -#else -# define nssv_inline_ns /*inline*/ -#endif - -#if nssv_HAVE_NOEXCEPT -# define nssv_noexcept noexcept -#else -# define nssv_noexcept /*noexcept*/ -#endif - -//#if nssv_HAVE_REF_QUALIFIER -//# define nssv_ref_qual & -//# define nssv_refref_qual && -//#else -//# define nssv_ref_qual /*&*/ -//# define nssv_refref_qual /*&&*/ -//#endif - -#if nssv_HAVE_NULLPTR -# define nssv_nullptr nullptr -#else -# define nssv_nullptr NULL -#endif - -#if nssv_HAVE_NODISCARD -# define nssv_nodiscard [[nodiscard]] -#else -# define nssv_nodiscard /*[[nodiscard]]*/ -#endif - -// Additional includes: - -#include -#include -#include -#include -#include -#include // std::char_traits<> - -#if ! nssv_CONFIG_NO_EXCEPTIONS -# include -#endif - -#if nssv_CPP11_OR_GREATER -# include -#endif - -// Clang, GNUC, MSVC warning suppression macros: - -#if defined(__clang__) -# pragma clang diagnostic ignored "-Wreserved-user-defined-literal" -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wuser-defined-literals" -#elif defined(__GNUC__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wliteral-suffix" -#endif // __clang__ - -#if nssv_COMPILER_MSVC_VERSION >= 140 -# define nssv_SUPPRESS_MSGSL_WARNING(expr) [[gsl::suppress(expr)]] -# define nssv_SUPPRESS_MSVC_WARNING(code, descr) __pragma(warning(suppress: code) ) -# define nssv_DISABLE_MSVC_WARNINGS(codes) __pragma(warning(push)) __pragma(warning(disable: codes)) -#else -# define nssv_SUPPRESS_MSGSL_WARNING(expr) -# define nssv_SUPPRESS_MSVC_WARNING(code, descr) -# define nssv_DISABLE_MSVC_WARNINGS(codes) -#endif - -#if defined(__clang__) -# define nssv_RESTORE_WARNINGS() _Pragma("clang diagnostic pop") -#elif defined(__GNUC__) -# define nssv_RESTORE_WARNINGS() _Pragma("GCC diagnostic pop") -#elif nssv_COMPILER_MSVC_VERSION >= 140 -# define nssv_RESTORE_WARNINGS() __pragma(warning(pop )) -#else -# define nssv_RESTORE_WARNINGS() -#endif - -// Suppress the following MSVC (GSL) warnings: -// - C4455, non-gsl : 'operator ""sv': literal suffix identifiers that do not -// start with an underscore are reserved -// - C26472, gsl::t.1 : don't use a static_cast for arithmetic conversions; -// use brace initialization, gsl::narrow_cast or gsl::narow -// - C26481: gsl::b.1 : don't use pointer arithmetic. Use span instead - -nssv_DISABLE_MSVC_WARNINGS( 4455 26481 26472 ) -//nssv_DISABLE_CLANG_WARNINGS( "-Wuser-defined-literals" ) -//nssv_DISABLE_GNUC_WARNINGS( -Wliteral-suffix ) - -namespace nonstd { namespace sv_lite { - -template -< - class CharT, - class Traits = std::char_traits -> -class basic_string_view; - -// -// basic_string_view: -// - -template -< - class CharT, - class Traits /* = std::char_traits */ -> -class basic_string_view -{ -public: - // Member types: - - typedef Traits traits_type; - typedef CharT value_type; - - typedef CharT * pointer; - typedef CharT const * const_pointer; - typedef CharT & reference; - typedef CharT const & const_reference; - - typedef const_pointer iterator; - typedef const_pointer const_iterator; - typedef std::reverse_iterator< const_iterator > reverse_iterator; - typedef std::reverse_iterator< const_iterator > const_reverse_iterator; - - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - - // 24.4.2.1 Construction and assignment: - - nssv_constexpr basic_string_view() nssv_noexcept - : data_( nssv_nullptr ) - , size_( 0 ) - {} - -#if nssv_CPP11_OR_GREATER - nssv_constexpr basic_string_view( basic_string_view const & other ) nssv_noexcept = default; -#else - nssv_constexpr basic_string_view( basic_string_view const & other ) nssv_noexcept - : data_( other.data_) - , size_( other.size_) - {} -#endif - - nssv_constexpr basic_string_view( CharT const * s, size_type count ) nssv_noexcept // non-standard noexcept - : data_( s ) - , size_( count ) - {} - - nssv_constexpr basic_string_view( CharT const * s) nssv_noexcept // non-standard noexcept - : data_( s ) - , size_( Traits::length(s) ) - {} - - // Assignment: - -#if nssv_CPP11_OR_GREATER - nssv_constexpr14 basic_string_view & operator=( basic_string_view const & other ) nssv_noexcept = default; -#else - nssv_constexpr14 basic_string_view & operator=( basic_string_view const & other ) nssv_noexcept - { - data_ = other.data_; - size_ = other.size_; - return *this; - } -#endif - - // 24.4.2.2 Iterator support: - - nssv_constexpr const_iterator begin() const nssv_noexcept { return data_; } - nssv_constexpr const_iterator end() const nssv_noexcept { return data_ + size_; } - - nssv_constexpr const_iterator cbegin() const nssv_noexcept { return begin(); } - nssv_constexpr const_iterator cend() const nssv_noexcept { return end(); } - - nssv_constexpr const_reverse_iterator rbegin() const nssv_noexcept { return const_reverse_iterator( end() ); } - nssv_constexpr const_reverse_iterator rend() const nssv_noexcept { return const_reverse_iterator( begin() ); } - - nssv_constexpr const_reverse_iterator crbegin() const nssv_noexcept { return rbegin(); } - nssv_constexpr const_reverse_iterator crend() const nssv_noexcept { return rend(); } - - // 24.4.2.3 Capacity: - - nssv_constexpr size_type size() const nssv_noexcept { return size_; } - nssv_constexpr size_type length() const nssv_noexcept { return size_; } - nssv_constexpr size_type max_size() const nssv_noexcept { return (std::numeric_limits< size_type >::max)(); } - - // since C++20 - nssv_nodiscard nssv_constexpr bool empty() const nssv_noexcept - { - return 0 == size_; - } - - // 24.4.2.4 Element access: - - nssv_constexpr const_reference operator[]( size_type pos ) const - { - return data_at( pos ); - } - - nssv_constexpr14 const_reference at( size_type pos ) const - { -#if nssv_CONFIG_NO_EXCEPTIONS - assert( pos < size() ); -#else - if ( pos >= size() ) - { - throw std::out_of_range("nonst::string_view::at()"); - } -#endif - return data_at( pos ); - } - - nssv_constexpr const_reference front() const { return data_at( 0 ); } - nssv_constexpr const_reference back() const { return data_at( size() - 1 ); } - - nssv_constexpr const_pointer data() const nssv_noexcept { return data_; } - - // 24.4.2.5 Modifiers: - - nssv_constexpr14 void remove_prefix( size_type n ) - { - assert( n <= size() ); - data_ += n; - size_ -= n; - } - - nssv_constexpr14 void remove_suffix( size_type n ) - { - assert( n <= size() ); - size_ -= n; - } - - nssv_constexpr14 void swap( basic_string_view & other ) nssv_noexcept - { - using std::swap; - swap( data_, other.data_ ); - swap( size_, other.size_ ); - } - - // 24.4.2.6 String operations: - - size_type copy( CharT * dest, size_type n, size_type pos = 0 ) const - { -#if nssv_CONFIG_NO_EXCEPTIONS - assert( pos <= size() ); -#else - if ( pos > size() ) - { - throw std::out_of_range("nonst::string_view::copy()"); - } -#endif - const size_type rlen = (std::min)( n, size() - pos ); - - (void) Traits::copy( dest, data() + pos, rlen ); - - return rlen; - } - - nssv_constexpr14 basic_string_view substr( size_type pos = 0, size_type n = npos ) const - { -#if nssv_CONFIG_NO_EXCEPTIONS - assert( pos <= size() ); -#else - if ( pos > size() ) - { - throw std::out_of_range("nonst::string_view::substr()"); - } -#endif - return basic_string_view( data() + pos, (std::min)( n, size() - pos ) ); - } - - // compare(), 6x: - - nssv_constexpr14 int compare( basic_string_view other ) const nssv_noexcept // (1) - { - if ( const int result = Traits::compare( data(), other.data(), (std::min)( size(), other.size() ) ) ) - { - return result; - } - - return size() == other.size() ? 0 : size() < other.size() ? -1 : 1; - } - - nssv_constexpr int compare( size_type pos1, size_type n1, basic_string_view other ) const // (2) - { - return substr( pos1, n1 ).compare( other ); - } - - nssv_constexpr int compare( size_type pos1, size_type n1, basic_string_view other, size_type pos2, size_type n2 ) const // (3) - { - return substr( pos1, n1 ).compare( other.substr( pos2, n2 ) ); - } - - nssv_constexpr int compare( CharT const * s ) const // (4) - { - return compare( basic_string_view( s ) ); - } - - nssv_constexpr int compare( size_type pos1, size_type n1, CharT const * s ) const // (5) - { - return substr( pos1, n1 ).compare( basic_string_view( s ) ); - } - - nssv_constexpr int compare( size_type pos1, size_type n1, CharT const * s, size_type n2 ) const // (6) - { - return substr( pos1, n1 ).compare( basic_string_view( s, n2 ) ); - } - - // 24.4.2.7 Searching: - - // starts_with(), 3x, since C++20: - - nssv_constexpr bool starts_with( basic_string_view v ) const nssv_noexcept // (1) - { - return size() >= v.size() && compare( 0, v.size(), v ) == 0; - } - - nssv_constexpr bool starts_with( CharT c ) const nssv_noexcept // (2) - { - return starts_with( basic_string_view( &c, 1 ) ); - } - - nssv_constexpr bool starts_with( CharT const * s ) const // (3) - { - return starts_with( basic_string_view( s ) ); - } - - // ends_with(), 3x, since C++20: - - nssv_constexpr bool ends_with( basic_string_view v ) const nssv_noexcept // (1) - { - return size() >= v.size() && compare( size() - v.size(), npos, v ) == 0; - } - - nssv_constexpr bool ends_with( CharT c ) const nssv_noexcept // (2) - { - return ends_with( basic_string_view( &c, 1 ) ); - } - - nssv_constexpr bool ends_with( CharT const * s ) const // (3) - { - return ends_with( basic_string_view( s ) ); - } - - // find(), 4x: - - nssv_constexpr14 size_type find( basic_string_view v, size_type pos = 0 ) const nssv_noexcept // (1) - { - return assert( v.size() == 0 || v.data() != nssv_nullptr ) - , pos >= size() - ? npos - : to_pos( std::search( cbegin() + pos, cend(), v.cbegin(), v.cend(), Traits::eq ) ); - } - - nssv_constexpr14 size_type find( CharT c, size_type pos = 0 ) const nssv_noexcept // (2) - { - return find( basic_string_view( &c, 1 ), pos ); - } - - nssv_constexpr14 size_type find( CharT const * s, size_type pos, size_type n ) const // (3) - { - return find( basic_string_view( s, n ), pos ); - } - - nssv_constexpr14 size_type find( CharT const * s, size_type pos = 0 ) const // (4) - { - return find( basic_string_view( s ), pos ); - } - - // rfind(), 4x: - - nssv_constexpr14 size_type rfind( basic_string_view v, size_type pos = npos ) const nssv_noexcept // (1) - { - if ( size() < v.size() ) - { - return npos; - } - - if ( v.empty() ) - { - return (std::min)( size(), pos ); - } - - const_iterator last = cbegin() + (std::min)( size() - v.size(), pos ) + v.size(); - const_iterator result = std::find_end( cbegin(), last, v.cbegin(), v.cend(), Traits::eq ); - - return result != last ? size_type( result - cbegin() ) : npos; - } - - nssv_constexpr14 size_type rfind( CharT c, size_type pos = npos ) const nssv_noexcept // (2) - { - return rfind( basic_string_view( &c, 1 ), pos ); - } - - nssv_constexpr14 size_type rfind( CharT const * s, size_type pos, size_type n ) const // (3) - { - return rfind( basic_string_view( s, n ), pos ); - } - - nssv_constexpr14 size_type rfind( CharT const * s, size_type pos = npos ) const // (4) - { - return rfind( basic_string_view( s ), pos ); - } - - // find_first_of(), 4x: - - nssv_constexpr size_type find_first_of( basic_string_view v, size_type pos = 0 ) const nssv_noexcept // (1) - { - return pos >= size() - ? npos - : to_pos( std::find_first_of( cbegin() + pos, cend(), v.cbegin(), v.cend(), Traits::eq ) ); - } - - nssv_constexpr size_type find_first_of( CharT c, size_type pos = 0 ) const nssv_noexcept // (2) - { - return find_first_of( basic_string_view( &c, 1 ), pos ); - } - - nssv_constexpr size_type find_first_of( CharT const * s, size_type pos, size_type n ) const // (3) - { - return find_first_of( basic_string_view( s, n ), pos ); - } - - nssv_constexpr size_type find_first_of( CharT const * s, size_type pos = 0 ) const // (4) - { - return find_first_of( basic_string_view( s ), pos ); - } - - // find_last_of(), 4x: - - nssv_constexpr size_type find_last_of( basic_string_view v, size_type pos = npos ) const nssv_noexcept // (1) - { - return empty() - ? npos - : pos >= size() - ? find_last_of( v, size() - 1 ) - : to_pos( std::find_first_of( const_reverse_iterator( cbegin() + pos + 1 ), crend(), v.cbegin(), v.cend(), Traits::eq ) ); - } - - nssv_constexpr size_type find_last_of( CharT c, size_type pos = npos ) const nssv_noexcept // (2) - { - return find_last_of( basic_string_view( &c, 1 ), pos ); - } - - nssv_constexpr size_type find_last_of( CharT const * s, size_type pos, size_type count ) const // (3) - { - return find_last_of( basic_string_view( s, count ), pos ); - } - - nssv_constexpr size_type find_last_of( CharT const * s, size_type pos = npos ) const // (4) - { - return find_last_of( basic_string_view( s ), pos ); - } - - // find_first_not_of(), 4x: - - nssv_constexpr size_type find_first_not_of( basic_string_view v, size_type pos = 0 ) const nssv_noexcept // (1) - { - return pos >= size() - ? npos - : to_pos( std::find_if( cbegin() + pos, cend(), not_in_view( v ) ) ); - } - - nssv_constexpr size_type find_first_not_of( CharT c, size_type pos = 0 ) const nssv_noexcept // (2) - { - return find_first_not_of( basic_string_view( &c, 1 ), pos ); - } - - nssv_constexpr size_type find_first_not_of( CharT const * s, size_type pos, size_type count ) const // (3) - { - return find_first_not_of( basic_string_view( s, count ), pos ); - } - - nssv_constexpr size_type find_first_not_of( CharT const * s, size_type pos = 0 ) const // (4) - { - return find_first_not_of( basic_string_view( s ), pos ); - } - - // find_last_not_of(), 4x: - - nssv_constexpr size_type find_last_not_of( basic_string_view v, size_type pos = npos ) const nssv_noexcept // (1) - { - return empty() - ? npos - : pos >= size() - ? find_last_not_of( v, size() - 1 ) - : to_pos( std::find_if( const_reverse_iterator( cbegin() + pos + 1 ), crend(), not_in_view( v ) ) ); - } - - nssv_constexpr size_type find_last_not_of( CharT c, size_type pos = npos ) const nssv_noexcept // (2) - { - return find_last_not_of( basic_string_view( &c, 1 ), pos ); - } - - nssv_constexpr size_type find_last_not_of( CharT const * s, size_type pos, size_type count ) const // (3) - { - return find_last_not_of( basic_string_view( s, count ), pos ); - } - - nssv_constexpr size_type find_last_not_of( CharT const * s, size_type pos = npos ) const // (4) - { - return find_last_not_of( basic_string_view( s ), pos ); - } - - // Constants: - -#if nssv_CPP17_OR_GREATER - static nssv_constexpr size_type npos = size_type(-1); -#elif nssv_CPP11_OR_GREATER - enum : size_type { npos = size_type(-1) }; -#else - enum { npos = size_type(-1) }; -#endif - -private: - struct not_in_view - { - const basic_string_view v; - - nssv_constexpr explicit not_in_view( basic_string_view v ) : v( v ) {} - - nssv_constexpr bool operator()( CharT c ) const - { - return npos == v.find_first_of( c ); - } - }; - - nssv_constexpr size_type to_pos( const_iterator it ) const - { - return it == cend() ? npos : size_type( it - cbegin() ); - } - - nssv_constexpr size_type to_pos( const_reverse_iterator it ) const - { - return it == crend() ? npos : size_type( crend() - it - 1 ); - } - - nssv_constexpr const_reference data_at( size_type pos ) const - { -#if nssv_BETWEEN( nssv_COMPILER_GNUC_VERSION, 1, 500 ) - return data_[pos]; -#else - return assert( pos < size() ), data_[pos]; -#endif - } - -private: - const_pointer data_; - size_type size_; - -public: -#if nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS - - template< class Allocator > - basic_string_view( std::basic_string const & s ) nssv_noexcept - : data_( s.data() ) - , size_( s.size() ) - {} - -#if nssv_HAVE_EXPLICIT_CONVERSION - - template< class Allocator > - explicit operator std::basic_string() const - { - return to_string( Allocator() ); - } - -#endif // nssv_HAVE_EXPLICIT_CONVERSION - -#if nssv_CPP11_OR_GREATER - - template< class Allocator = std::allocator > - std::basic_string - to_string( Allocator const & a = Allocator() ) const - { - return std::basic_string( begin(), end(), a ); - } - -#else - - std::basic_string - to_string() const - { - return std::basic_string( begin(), end() ); - } - - template< class Allocator > - std::basic_string - to_string( Allocator const & a ) const - { - return std::basic_string( begin(), end(), a ); - } - -#endif // nssv_CPP11_OR_GREATER - -#endif // nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS -}; - -// -// Non-member functions: -// - -// 24.4.3 Non-member comparison functions: -// lexicographically compare two string views (function template): - -template< class CharT, class Traits > -nssv_constexpr bool operator== ( - basic_string_view lhs, - basic_string_view rhs ) nssv_noexcept -{ return lhs.compare( rhs ) == 0 ; } - -template< class CharT, class Traits > -nssv_constexpr bool operator!= ( - basic_string_view lhs, - basic_string_view rhs ) nssv_noexcept -{ return lhs.compare( rhs ) != 0 ; } - -template< class CharT, class Traits > -nssv_constexpr bool operator< ( - basic_string_view lhs, - basic_string_view rhs ) nssv_noexcept -{ return lhs.compare( rhs ) < 0 ; } - -template< class CharT, class Traits > -nssv_constexpr bool operator<= ( - basic_string_view lhs, - basic_string_view rhs ) nssv_noexcept -{ return lhs.compare( rhs ) <= 0 ; } - -template< class CharT, class Traits > -nssv_constexpr bool operator> ( - basic_string_view lhs, - basic_string_view rhs ) nssv_noexcept -{ return lhs.compare( rhs ) > 0 ; } - -template< class CharT, class Traits > -nssv_constexpr bool operator>= ( - basic_string_view lhs, - basic_string_view rhs ) nssv_noexcept -{ return lhs.compare( rhs ) >= 0 ; } - -// Let S be basic_string_view, and sv be an instance of S. -// Implementations shall provide sufficient additional overloads marked -// constexpr and noexcept so that an object t with an implicit conversion -// to S can be compared according to Table 67. - -#if nssv_CPP11_OR_GREATER && ! nssv_BETWEEN( nssv_COMPILER_MSVC_VERSION, 100, 141 ) - -#define nssv_BASIC_STRING_VIEW_I(T,U) typename std::decay< basic_string_view >::type - -#if nssv_BETWEEN( nssv_COMPILER_MSVC_VERSION, 140, 150 ) -# define nssv_MSVC_ORDER(x) , int=x -#else -# define nssv_MSVC_ORDER(x) /*, int=x*/ -#endif - -// == - -template< class CharT, class Traits nssv_MSVC_ORDER(1) > -nssv_constexpr bool operator==( - basic_string_view lhs, - nssv_BASIC_STRING_VIEW_I(CharT, Traits) rhs ) nssv_noexcept -{ return lhs.compare( rhs ) == 0; } - -template< class CharT, class Traits nssv_MSVC_ORDER(2) > -nssv_constexpr bool operator==( - nssv_BASIC_STRING_VIEW_I(CharT, Traits) lhs, - basic_string_view rhs ) nssv_noexcept -{ return lhs.size() == rhs.size() && lhs.compare( rhs ) == 0; } - -// != - -template< class CharT, class Traits nssv_MSVC_ORDER(1) > -nssv_constexpr bool operator!= ( - basic_string_view < CharT, Traits > lhs, - nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs ) nssv_noexcept -{ return lhs.size() != rhs.size() || lhs.compare( rhs ) != 0 ; } - -template< class CharT, class Traits nssv_MSVC_ORDER(2) > -nssv_constexpr bool operator!= ( - nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs, - basic_string_view < CharT, Traits > rhs ) nssv_noexcept -{ return lhs.compare( rhs ) != 0 ; } - -// < - -template< class CharT, class Traits nssv_MSVC_ORDER(1) > -nssv_constexpr bool operator< ( - basic_string_view < CharT, Traits > lhs, - nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs ) nssv_noexcept -{ return lhs.compare( rhs ) < 0 ; } - -template< class CharT, class Traits nssv_MSVC_ORDER(2) > -nssv_constexpr bool operator< ( - nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs, - basic_string_view < CharT, Traits > rhs ) nssv_noexcept -{ return lhs.compare( rhs ) < 0 ; } - -// <= - -template< class CharT, class Traits nssv_MSVC_ORDER(1) > -nssv_constexpr bool operator<= ( - basic_string_view < CharT, Traits > lhs, - nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs ) nssv_noexcept -{ return lhs.compare( rhs ) <= 0 ; } - -template< class CharT, class Traits nssv_MSVC_ORDER(2) > -nssv_constexpr bool operator<= ( - nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs, - basic_string_view < CharT, Traits > rhs ) nssv_noexcept -{ return lhs.compare( rhs ) <= 0 ; } - -// > - -template< class CharT, class Traits nssv_MSVC_ORDER(1) > -nssv_constexpr bool operator> ( - basic_string_view < CharT, Traits > lhs, - nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs ) nssv_noexcept -{ return lhs.compare( rhs ) > 0 ; } - -template< class CharT, class Traits nssv_MSVC_ORDER(2) > -nssv_constexpr bool operator> ( - nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs, - basic_string_view < CharT, Traits > rhs ) nssv_noexcept -{ return lhs.compare( rhs ) > 0 ; } - -// >= - -template< class CharT, class Traits nssv_MSVC_ORDER(1) > -nssv_constexpr bool operator>= ( - basic_string_view < CharT, Traits > lhs, - nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs ) nssv_noexcept -{ return lhs.compare( rhs ) >= 0 ; } - -template< class CharT, class Traits nssv_MSVC_ORDER(2) > -nssv_constexpr bool operator>= ( - nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs, - basic_string_view < CharT, Traits > rhs ) nssv_noexcept -{ return lhs.compare( rhs ) >= 0 ; } - -#undef nssv_MSVC_ORDER -#undef nssv_BASIC_STRING_VIEW_I - -#endif // nssv_CPP11_OR_GREATER - -// 24.4.4 Inserters and extractors: - -namespace detail { - -template< class Stream > -void write_padding( Stream & os, std::streamsize n ) -{ - for ( std::streamsize i = 0; i < n; ++i ) - os.rdbuf()->sputc( os.fill() ); -} - -template< class Stream, class View > -Stream & write_to_stream( Stream & os, View const & sv ) -{ - typename Stream::sentry sentry( os ); - - if ( !os ) - return os; - - const std::streamsize length = static_cast( sv.length() ); - - // Whether, and how, to pad: - const bool pad = ( length < os.width() ); - const bool left_pad = pad && ( os.flags() & std::ios_base::adjustfield ) == std::ios_base::right; - - if ( left_pad ) - write_padding( os, os.width() - length ); - - // Write span characters: - os.rdbuf()->sputn( sv.begin(), length ); - - if ( pad && !left_pad ) - write_padding( os, os.width() - length ); - - // Reset output stream width: - os.width( 0 ); - - return os; -} - -} // namespace detail - -template< class CharT, class Traits > -std::basic_ostream & -operator<<( - std::basic_ostream& os, - basic_string_view sv ) -{ - return detail::write_to_stream( os, sv ); -} - -// Several typedefs for common character types are provided: - -typedef basic_string_view string_view; -typedef basic_string_view wstring_view; -#if nssv_HAVE_WCHAR16_T -typedef basic_string_view u16string_view; -typedef basic_string_view u32string_view; -#endif - -}} // namespace nonstd::sv_lite - -// -// 24.4.6 Suffix for basic_string_view literals: -// - -#if nssv_HAVE_USER_DEFINED_LITERALS - -namespace nonstd { -nssv_inline_ns namespace literals { -nssv_inline_ns namespace string_view_literals { - -#if nssv_CONFIG_STD_SV_OPERATOR && nssv_HAVE_STD_DEFINED_LITERALS - -nssv_constexpr nonstd::sv_lite::string_view operator "" sv( const char* str, size_t len ) nssv_noexcept // (1) -{ - return nonstd::sv_lite::string_view{ str, len }; -} - -nssv_constexpr nonstd::sv_lite::u16string_view operator "" sv( const char16_t* str, size_t len ) nssv_noexcept // (2) -{ - return nonstd::sv_lite::u16string_view{ str, len }; -} - -nssv_constexpr nonstd::sv_lite::u32string_view operator "" sv( const char32_t* str, size_t len ) nssv_noexcept // (3) -{ - return nonstd::sv_lite::u32string_view{ str, len }; -} - -nssv_constexpr nonstd::sv_lite::wstring_view operator "" sv( const wchar_t* str, size_t len ) nssv_noexcept // (4) -{ - return nonstd::sv_lite::wstring_view{ str, len }; -} - -#endif // nssv_CONFIG_STD_SV_OPERATOR && nssv_HAVE_STD_DEFINED_LITERALS - -#if nssv_CONFIG_USR_SV_OPERATOR - -nssv_constexpr nonstd::sv_lite::string_view operator "" _sv( const char* str, size_t len ) nssv_noexcept // (1) -{ - return nonstd::sv_lite::string_view{ str, len }; -} - -nssv_constexpr nonstd::sv_lite::u16string_view operator "" _sv( const char16_t* str, size_t len ) nssv_noexcept // (2) -{ - return nonstd::sv_lite::u16string_view{ str, len }; -} - -nssv_constexpr nonstd::sv_lite::u32string_view operator "" _sv( const char32_t* str, size_t len ) nssv_noexcept // (3) -{ - return nonstd::sv_lite::u32string_view{ str, len }; -} - -nssv_constexpr nonstd::sv_lite::wstring_view operator "" _sv( const wchar_t* str, size_t len ) nssv_noexcept // (4) -{ - return nonstd::sv_lite::wstring_view{ str, len }; -} - -#endif // nssv_CONFIG_USR_SV_OPERATOR - -}}} // namespace nonstd::literals::string_view_literals - -#endif - -// -// Extensions for std::string: -// - -#if nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS - -namespace nonstd { -namespace sv_lite { - -// Exclude MSVC 14 (19.00): it yields ambiguous to_string(): - -#if nssv_CPP11_OR_GREATER && nssv_COMPILER_MSVC_VERSION != 140 - -template< class CharT, class Traits, class Allocator = std::allocator > -std::basic_string -to_string( basic_string_view v, Allocator const & a = Allocator() ) -{ - return std::basic_string( v.begin(), v.end(), a ); -} - -#else - -template< class CharT, class Traits > -std::basic_string -to_string( basic_string_view v ) -{ - return std::basic_string( v.begin(), v.end() ); -} - -template< class CharT, class Traits, class Allocator > -std::basic_string -to_string( basic_string_view v, Allocator const & a ) -{ - return std::basic_string( v.begin(), v.end(), a ); -} - -#endif // nssv_CPP11_OR_GREATER - -template< class CharT, class Traits, class Allocator > -basic_string_view -to_string_view( std::basic_string const & s ) -{ - return basic_string_view( s.data(), s.size() ); -} - -}} // namespace nonstd::sv_lite - -#endif // nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS - -// -// make types and algorithms available in namespace nonstd: -// - -namespace nonstd { - -using sv_lite::basic_string_view; -using sv_lite::string_view; -using sv_lite::wstring_view; - -#if nssv_HAVE_WCHAR16_T -using sv_lite::u16string_view; -#endif -#if nssv_HAVE_WCHAR32_T -using sv_lite::u32string_view; -#endif - -// literal "sv" - -using sv_lite::operator==; -using sv_lite::operator!=; -using sv_lite::operator<; -using sv_lite::operator<=; -using sv_lite::operator>; -using sv_lite::operator>=; - -using sv_lite::operator<<; - -#if nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS -using sv_lite::to_string; -using sv_lite::to_string_view; -#endif - -} // namespace nonstd - -// 24.4.5 Hash support (C++11): - -// Note: The hash value of a string view object is equal to the hash value of -// the corresponding string object. - -#if nssv_HAVE_STD_HASH - -#include - -namespace std { - -template<> -struct hash< nonstd::string_view > -{ -public: - std::size_t operator()( nonstd::string_view v ) const nssv_noexcept - { - return std::hash()( std::string( v.data(), v.size() ) ); - } -}; - -template<> -struct hash< nonstd::wstring_view > -{ -public: - std::size_t operator()( nonstd::wstring_view v ) const nssv_noexcept - { - return std::hash()( std::wstring( v.data(), v.size() ) ); - } -}; - -template<> -struct hash< nonstd::u16string_view > -{ -public: - std::size_t operator()( nonstd::u16string_view v ) const nssv_noexcept - { - return std::hash()( std::u16string( v.data(), v.size() ) ); - } -}; - -template<> -struct hash< nonstd::u32string_view > -{ -public: - std::size_t operator()( nonstd::u32string_view v ) const nssv_noexcept - { - return std::hash()( std::u32string( v.data(), v.size() ) ); - } -}; - -} // namespace std - -#endif // nssv_HAVE_STD_HASH - -nssv_RESTORE_WARNINGS() - -#endif // nssv_HAVE_STD_STRING_VIEW -#endif // NONSTD_SV_LITE_H_INCLUDED diff --git a/cpp/thirdparty/knowhere_build/include/arrow/vendored/variant.hpp b/cpp/thirdparty/knowhere_build/include/arrow/vendored/variant.hpp deleted file mode 100644 index 8af0bfecee..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/vendored/variant.hpp +++ /dev/null @@ -1,2815 +0,0 @@ -// Vendored from v1.4.0, from single-header branch at https://github.com/mpark/variant - -// MPark.Variant -// -// Copyright Michael Park, 2015-2017 -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - -#ifndef MPARK_VARIANT_HPP -#define MPARK_VARIANT_HPP - -/* - variant synopsis - -namespace std { - - // 20.7.2, class template variant - template - class variant { - public: - - // 20.7.2.1, constructors - constexpr variant() noexcept(see below); - variant(const variant&); - variant(variant&&) noexcept(see below); - - template constexpr variant(T&&) noexcept(see below); - - template - constexpr explicit variant(in_place_type_t, Args&&...); - - template - constexpr explicit variant( - in_place_type_t, initializer_list, Args&&...); - - template - constexpr explicit variant(in_place_index_t, Args&&...); - - template - constexpr explicit variant( - in_place_index_t, initializer_list, Args&&...); - - // 20.7.2.2, destructor - ~variant(); - - // 20.7.2.3, assignment - variant& operator=(const variant&); - variant& operator=(variant&&) noexcept(see below); - - template variant& operator=(T&&) noexcept(see below); - - // 20.7.2.4, modifiers - template - T& emplace(Args&&...); - - template - T& emplace(initializer_list, Args&&...); - - template - variant_alternative& emplace(Args&&...); - - template - variant_alternative& emplace(initializer_list, Args&&...); - - // 20.7.2.5, value status - constexpr bool valueless_by_exception() const noexcept; - constexpr size_t index() const noexcept; - - // 20.7.2.6, swap - void swap(variant&) noexcept(see below); - }; - - // 20.7.3, variant helper classes - template struct variant_size; // undefined - - template - constexpr size_t variant_size_v = variant_size::value; - - template struct variant_size; - template struct variant_size; - template struct variant_size; - - template - struct variant_size>; - - template struct variant_alternative; // undefined - - template - using variant_alternative_t = typename variant_alternative::type; - - template struct variant_alternative; - template struct variant_alternative; - template struct variant_alternative; - - template - struct variant_alternative>; - - constexpr size_t variant_npos = -1; - - // 20.7.4, value access - template - constexpr bool holds_alternative(const variant&) noexcept; - - template - constexpr variant_alternative_t>& - get(variant&); - - template - constexpr variant_alternative_t>&& - get(variant&&); - - template - constexpr variant_alternative_t> const& - get(const variant&); - - template - constexpr variant_alternative_t> const&& - get(const variant&&); - - template - constexpr T& get(variant&); - - template - constexpr T&& get(variant&&); - - template - constexpr const T& get(const variant&); - - template - constexpr const T&& get(const variant&&); - - template - constexpr add_pointer_t>> - get_if(variant*) noexcept; - - template - constexpr add_pointer_t>> - get_if(const variant*) noexcept; - - template - constexpr add_pointer_t - get_if(variant*) noexcept; - - template - constexpr add_pointer_t - get_if(const variant*) noexcept; - - // 20.7.5, relational operators - template - constexpr bool operator==(const variant&, const variant&); - - template - constexpr bool operator!=(const variant&, const variant&); - - template - constexpr bool operator<(const variant&, const variant&); - - template - constexpr bool operator>(const variant&, const variant&); - - template - constexpr bool operator<=(const variant&, const variant&); - - template - constexpr bool operator>=(const variant&, const variant&); - - // 20.7.6, visitation - template - constexpr see below visit(Visitor&&, Variants&&...); - - // 20.7.7, class monostate - struct monostate; - - // 20.7.8, monostate relational operators - constexpr bool operator<(monostate, monostate) noexcept; - constexpr bool operator>(monostate, monostate) noexcept; - constexpr bool operator<=(monostate, monostate) noexcept; - constexpr bool operator>=(monostate, monostate) noexcept; - constexpr bool operator==(monostate, monostate) noexcept; - constexpr bool operator!=(monostate, monostate) noexcept; - - // 20.7.9, specialized algorithms - template - void swap(variant&, variant&) noexcept(see below); - - // 20.7.10, class bad_variant_access - class bad_variant_access; - - // 20.7.11, hash support - template struct hash; - template struct hash>; - template <> struct hash; - -} // namespace std - -*/ - -#include -#include -#include -#include -#include -#include -#include - -// MPark.Variant -// -// Copyright Michael Park, 2015-2017 -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - -#ifndef MPARK_CONFIG_HPP -#define MPARK_CONFIG_HPP - -// MSVC 2015 Update 3. -#if __cplusplus < 201103L && (!defined(_MSC_VER) || _MSC_FULL_VER < 190024210) -#error "MPark.Variant requires C++11 support." -#endif - -#ifndef __has_attribute -#define __has_attribute(x) 0 -#endif - -#ifndef __has_builtin -#define __has_builtin(x) 0 -#endif - -#ifndef __has_include -#define __has_include(x) 0 -#endif - -#ifndef __has_feature -#define __has_feature(x) 0 -#endif - -#if __has_attribute(always_inline) || defined(__GNUC__) -#define MPARK_ALWAYS_INLINE __attribute__((__always_inline__)) inline -#elif defined(_MSC_VER) -#define MPARK_ALWAYS_INLINE __forceinline -#else -#define MPARK_ALWAYS_INLINE inline -#endif - -#if __has_builtin(__builtin_addressof) || \ - (defined(__GNUC__) && __GNUC__ >= 7) || defined(_MSC_VER) -#define MPARK_BUILTIN_ADDRESSOF -#endif - -#if __has_builtin(__builtin_unreachable) || defined(__GNUC__) -#define MPARK_BUILTIN_UNREACHABLE __builtin_unreachable() -#elif defined(_MSC_VER) -#define MPARK_BUILTIN_UNREACHABLE __assume(false) -#else -#define MPARK_BUILTIN_UNREACHABLE -#endif - -#if __has_builtin(__type_pack_element) -#define MPARK_TYPE_PACK_ELEMENT -#endif - -#if defined(__cpp_constexpr) && __cpp_constexpr >= 200704 && \ - !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 9) -#define MPARK_CPP11_CONSTEXPR -#endif - -#if defined(__cpp_constexpr) && __cpp_constexpr >= 201304 -#define MPARK_CPP14_CONSTEXPR -#endif - -#if __has_feature(cxx_exceptions) || defined(__cpp_exceptions) || \ - (defined(_MSC_VER) && defined(_CPPUNWIND)) -#define MPARK_EXCEPTIONS -#endif - -#if defined(__cpp_generic_lambdas) || defined(_MSC_VER) -#define MPARK_GENERIC_LAMBDAS -#endif - -#if defined(__cpp_lib_integer_sequence) -#define MPARK_INTEGER_SEQUENCE -#endif - -#if defined(__cpp_return_type_deduction) || defined(_MSC_VER) -#define MPARK_RETURN_TYPE_DEDUCTION -#endif - -#if defined(__cpp_lib_transparent_operators) || defined(_MSC_VER) -#define MPARK_TRANSPARENT_OPERATORS -#endif - -#if defined(__cpp_variable_templates) || defined(_MSC_VER) -#define MPARK_VARIABLE_TEMPLATES -#endif - -#if !defined(__GLIBCXX__) || __has_include() // >= libstdc++-5 -#define MPARK_TRIVIALITY_TYPE_TRAITS -#define MPARK_INCOMPLETE_TYPE_TRAITS -#endif - -#endif // MPARK_CONFIG_HPP - -// MPark.Variant -// -// Copyright Michael Park, 2015-2017 -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - -#ifndef MPARK_IN_PLACE_HPP -#define MPARK_IN_PLACE_HPP - -#include - - -namespace mpark { - - struct in_place_t { explicit in_place_t() = default; }; - - template - struct in_place_index_t { explicit in_place_index_t() = default; }; - - template - struct in_place_type_t { explicit in_place_type_t() = default; }; - -#ifdef MPARK_VARIABLE_TEMPLATES - constexpr in_place_t in_place{}; - - template constexpr in_place_index_t in_place_index{}; - - template constexpr in_place_type_t in_place_type{}; -#endif - -} // namespace mpark - -#endif // MPARK_IN_PLACE_HPP - -// MPark.Variant -// -// Copyright Michael Park, 2015-2017 -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - -#ifndef MPARK_LIB_HPP -#define MPARK_LIB_HPP - -#include -#include -#include -#include - - -#define MPARK_RETURN(...) \ - noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) { return __VA_ARGS__; } - -namespace mpark { - namespace lib { - template - struct identity { using type = T; }; - - inline namespace cpp14 { - template - struct array { - constexpr const T &operator[](std::size_t index) const { - return data[index]; - } - - T data[N == 0 ? 1 : N]; - }; - - template - using add_pointer_t = typename std::add_pointer::type; - - template - using common_type_t = typename std::common_type::type; - - template - using decay_t = typename std::decay::type; - - template - using enable_if_t = typename std::enable_if::type; - - template - using remove_const_t = typename std::remove_const::type; - - template - using remove_reference_t = typename std::remove_reference::type; - - template - inline constexpr T &&forward(remove_reference_t &t) noexcept { - return static_cast(t); - } - - template - inline constexpr T &&forward(remove_reference_t &&t) noexcept { - static_assert(!std::is_lvalue_reference::value, - "can not forward an rvalue as an lvalue"); - return static_cast(t); - } - - template - inline constexpr remove_reference_t &&move(T &&t) noexcept { - return static_cast &&>(t); - } - -#ifdef MPARK_INTEGER_SEQUENCE - using std::integer_sequence; - using std::index_sequence; - using std::make_index_sequence; - using std::index_sequence_for; -#else - template - struct integer_sequence { - using value_type = T; - static constexpr std::size_t size() noexcept { return sizeof...(Is); } - }; - - template - using index_sequence = integer_sequence; - - template - struct make_index_sequence_concat; - - template - struct make_index_sequence_concat, - index_sequence> - : identity> {}; - - template - struct make_index_sequence_impl; - - template - using make_index_sequence = typename make_index_sequence_impl::type; - - template - struct make_index_sequence_impl - : make_index_sequence_concat, - make_index_sequence> {}; - - template <> - struct make_index_sequence_impl<0> : identity> {}; - - template <> - struct make_index_sequence_impl<1> : identity> {}; - - template - using index_sequence_for = make_index_sequence; -#endif - - // -#ifdef MPARK_TRANSPARENT_OPERATORS - using equal_to = std::equal_to<>; -#else - struct equal_to { - template - inline constexpr auto operator()(Lhs &&lhs, Rhs &&rhs) const - MPARK_RETURN(lib::forward(lhs) == lib::forward(rhs)) - }; -#endif - -#ifdef MPARK_TRANSPARENT_OPERATORS - using not_equal_to = std::not_equal_to<>; -#else - struct not_equal_to { - template - inline constexpr auto operator()(Lhs &&lhs, Rhs &&rhs) const - MPARK_RETURN(lib::forward(lhs) != lib::forward(rhs)) - }; -#endif - -#ifdef MPARK_TRANSPARENT_OPERATORS - using less = std::less<>; -#else - struct less { - template - inline constexpr auto operator()(Lhs &&lhs, Rhs &&rhs) const - MPARK_RETURN(lib::forward(lhs) < lib::forward(rhs)) - }; -#endif - -#ifdef MPARK_TRANSPARENT_OPERATORS - using greater = std::greater<>; -#else - struct greater { - template - inline constexpr auto operator()(Lhs &&lhs, Rhs &&rhs) const - MPARK_RETURN(lib::forward(lhs) > lib::forward(rhs)) - }; -#endif - -#ifdef MPARK_TRANSPARENT_OPERATORS - using less_equal = std::less_equal<>; -#else - struct less_equal { - template - inline constexpr auto operator()(Lhs &&lhs, Rhs &&rhs) const - MPARK_RETURN(lib::forward(lhs) <= lib::forward(rhs)) - }; -#endif - -#ifdef MPARK_TRANSPARENT_OPERATORS - using greater_equal = std::greater_equal<>; -#else - struct greater_equal { - template - inline constexpr auto operator()(Lhs &&lhs, Rhs &&rhs) const - MPARK_RETURN(lib::forward(lhs) >= lib::forward(rhs)) - }; -#endif - } // namespace cpp14 - - inline namespace cpp17 { - - // - template - using bool_constant = std::integral_constant; - - template - struct voider : identity {}; - - template - using void_t = typename voider::type; - - namespace detail { - namespace swappable { - - using std::swap; - - template - struct is_swappable { - private: - template (), - std::declval()))> - inline static std::true_type test(int); - - template - inline static std::false_type test(...); - - public: - static constexpr bool value = decltype(test(0))::value; - }; - - template - struct is_nothrow_swappable { - static constexpr bool value = - noexcept(swap(std::declval(), std::declval())); - }; - - template - struct is_nothrow_swappable : std::false_type {}; - - } // namespace swappable - } // namespace detail - - using detail::swappable::is_swappable; - - template - using is_nothrow_swappable = - detail::swappable::is_nothrow_swappable::value, T>; - - // - namespace detail { - - template - struct is_reference_wrapper : std::false_type {}; - - template - struct is_reference_wrapper> - : std::true_type {}; - - template - struct Invoke; - - template <> - struct Invoke { - template - inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&... args) - MPARK_RETURN((lib::forward(arg).*pmf)(lib::forward(args)...)) - }; - - template <> - struct Invoke { - template - inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&... args) - MPARK_RETURN((lib::forward(arg).get().*pmf)(lib::forward(args)...)) - }; - - template <> - struct Invoke { - template - inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&... args) - MPARK_RETURN(((*lib::forward(arg)).*pmf)(lib::forward(args)...)) - }; - - template <> - struct Invoke { - template - inline static constexpr auto invoke(R T::*pmo, Arg &&arg) - MPARK_RETURN(lib::forward(arg).*pmo) - }; - - template <> - struct Invoke { - template - inline static constexpr auto invoke(R T::*pmo, Arg &&arg) - MPARK_RETURN(lib::forward(arg).get().*pmo) - }; - - template <> - struct Invoke { - template - inline static constexpr auto invoke(R T::*pmo, Arg &&arg) - MPARK_RETURN((*lib::forward(arg)).*pmo) - }; - - template - inline constexpr auto invoke(R T::*f, Arg &&arg, Args &&... args) - MPARK_RETURN( - Invoke::value, - (std::is_base_of>::value - ? 0 - : is_reference_wrapper>::value - ? 1 - : 2)>::invoke(f, - lib::forward(arg), - lib::forward(args)...)) - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4100) -#endif - template - inline constexpr auto invoke(F &&f, Args &&... args) - MPARK_RETURN(lib::forward(f)(lib::forward(args)...)) -#ifdef _MSC_VER -#pragma warning(pop) -#endif - } // namespace detail - - template - inline constexpr auto invoke(F &&f, Args &&... args) - MPARK_RETURN(detail::invoke(lib::forward(f), - lib::forward(args)...)) - - namespace detail { - - template - struct invoke_result {}; - - template - struct invoke_result(), std::declval()...))>, - F, - Args...> - : identity(), std::declval()...))> {}; - - } // namespace detail - - template - using invoke_result = detail::invoke_result; - - template - using invoke_result_t = typename invoke_result::type; - - namespace detail { - - template - struct is_invocable : std::false_type {}; - - template - struct is_invocable>, F, Args...> - : std::true_type {}; - - template - struct is_invocable_r : std::false_type {}; - - template - struct is_invocable_r>, - R, - F, - Args...> - : std::is_convertible, R> {}; - - } // namespace detail - - template - using is_invocable = detail::is_invocable; - - template - using is_invocable_r = detail::is_invocable_r; - - namespace detail { - - template - struct is_nothrow_invocable { - static constexpr bool value = - noexcept(lib::invoke(std::declval(), std::declval()...)); - }; - - template - struct is_nothrow_invocable : std::false_type {}; - - template - struct is_nothrow_invocable_r { - private: - inline static R impl() { - return lib::invoke(std::declval(), std::declval()...); - } - - public: - static constexpr bool value = noexcept(impl()); - }; - - template - struct is_nothrow_invocable_r : std::false_type {}; - - } // namespace detail - - template - using is_nothrow_invocable = detail:: - is_nothrow_invocable::value, F, Args...>; - - template - using is_nothrow_invocable_r = - detail::is_nothrow_invocable_r::value, - R, - F, - Args...>; - - // -#ifdef MPARK_BUILTIN_ADDRESSOF - template - inline constexpr T *addressof(T &arg) noexcept { - return __builtin_addressof(arg); - } -#else - namespace detail { - - namespace has_addressof_impl { - - struct fail; - - template - inline fail operator&(T &&); - - template - inline static constexpr bool impl() { - return (std::is_class::value || std::is_union::value) && - !std::is_same()), fail>::value; - } - - } // namespace has_addressof_impl - - template - using has_addressof = bool_constant()>; - - template - inline constexpr T *addressof(T &arg, std::true_type) noexcept { - return std::addressof(arg); - } - - template - inline constexpr T *addressof(T &arg, std::false_type) noexcept { - return &arg; - } - - } // namespace detail - - template - inline constexpr T *addressof(T &arg) noexcept { - return detail::addressof(arg, detail::has_addressof{}); - } -#endif - - template - inline constexpr T *addressof(const T &&) = delete; - - } // namespace cpp17 - - template - struct remove_all_extents : identity {}; - - template - struct remove_all_extents> : remove_all_extents {}; - - template - using remove_all_extents_t = typename remove_all_extents::type; - - template - using size_constant = std::integral_constant; - - template - struct indexed_type : size_constant { using type = T; }; - - template - using all = std::is_same, - integer_sequence>; - -#ifdef MPARK_TYPE_PACK_ELEMENT - template - using type_pack_element_t = __type_pack_element; -#else - template - struct type_pack_element_impl { - private: - template - struct set; - - template - struct set> : indexed_type... {}; - - template - inline static std::enable_if impl(indexed_type); - - inline static std::enable_if impl(...); - - public: - using type = decltype(impl(set>{})); - }; - - template - using type_pack_element = typename type_pack_element_impl::type; - - template - using type_pack_element_t = typename type_pack_element::type; -#endif - -#ifdef MPARK_TRIVIALITY_TYPE_TRAITS - using std::is_trivially_copy_constructible; - using std::is_trivially_move_constructible; - using std::is_trivially_copy_assignable; - using std::is_trivially_move_assignable; -#else - template - struct is_trivially_copy_constructible - : bool_constant< - std::is_copy_constructible::value && __has_trivial_copy(T)> {}; - - template - struct is_trivially_move_constructible : bool_constant<__is_trivial(T)> {}; - - template - struct is_trivially_copy_assignable - : bool_constant< - std::is_copy_assignable::value && __has_trivial_assign(T)> {}; - - template - struct is_trivially_move_assignable : bool_constant<__is_trivial(T)> {}; -#endif - - template - struct dependent_type : T {}; - - template - struct push_back; - - template - using push_back_t = typename push_back::type; - - template - struct push_back, J> { - using type = index_sequence; - }; - - } // namespace lib -} // namespace mpark - -#undef MPARK_RETURN - -#endif // MPARK_LIB_HPP - - -namespace mpark { - -#ifdef MPARK_RETURN_TYPE_DEDUCTION - -#define AUTO auto -#define AUTO_RETURN(...) { return __VA_ARGS__; } - -#define AUTO_REFREF auto && -#define AUTO_REFREF_RETURN(...) { return __VA_ARGS__; } - -#define DECLTYPE_AUTO decltype(auto) -#define DECLTYPE_AUTO_RETURN(...) { return __VA_ARGS__; } - -#else - -#define AUTO auto -#define AUTO_RETURN(...) \ - -> lib::decay_t { return __VA_ARGS__; } - -#define AUTO_REFREF auto -#define AUTO_REFREF_RETURN(...) \ - -> decltype((__VA_ARGS__)) { \ - static_assert(std::is_reference::value, ""); \ - return __VA_ARGS__; \ - } - -#define DECLTYPE_AUTO auto -#define DECLTYPE_AUTO_RETURN(...) \ - -> decltype(__VA_ARGS__) { return __VA_ARGS__; } - -#endif - - class bad_variant_access : public std::exception { - public: - virtual const char *what() const noexcept override { return "bad_variant_access"; } - }; - - [[noreturn]] inline void throw_bad_variant_access() { -#ifdef MPARK_EXCEPTIONS - throw bad_variant_access{}; -#else - std::terminate(); - MPARK_BUILTIN_UNREACHABLE; -#endif - } - - template - class variant; - - template - struct variant_size; - -#ifdef MPARK_VARIABLE_TEMPLATES - template - constexpr std::size_t variant_size_v = variant_size::value; -#endif - - template - struct variant_size : variant_size {}; - - template - struct variant_size : variant_size {}; - - template - struct variant_size : variant_size {}; - - template - struct variant_size> : lib::size_constant {}; - - template - struct variant_alternative; - - template - using variant_alternative_t = typename variant_alternative::type; - - template - struct variant_alternative - : std::add_const> {}; - - template - struct variant_alternative - : std::add_volatile> {}; - - template - struct variant_alternative - : std::add_cv> {}; - - template - struct variant_alternative> { - static_assert(I < sizeof...(Ts), - "index out of bounds in `std::variant_alternative<>`"); - using type = lib::type_pack_element_t; - }; - - constexpr std::size_t variant_npos = static_cast(-1); - - namespace detail { - - constexpr std::size_t not_found = static_cast(-1); - constexpr std::size_t ambiguous = static_cast(-2); - -#ifdef MPARK_CPP14_CONSTEXPR - template - inline constexpr std::size_t find_index() { - constexpr lib::array matches = { - {std::is_same::value...} - }; - std::size_t result = not_found; - for (std::size_t i = 0; i < sizeof...(Ts); ++i) { - if (matches[i]) { - if (result != not_found) { - return ambiguous; - } - result = i; - } - } - return result; - } -#else - inline constexpr std::size_t find_index_impl(std::size_t result, - std::size_t) { - return result; - } - - template - inline constexpr std::size_t find_index_impl(std::size_t result, - std::size_t idx, - bool b, - Bs... bs) { - return b ? (result != not_found ? ambiguous - : find_index_impl(idx, idx + 1, bs...)) - : find_index_impl(result, idx + 1, bs...); - } - - template - inline constexpr std::size_t find_index() { - return find_index_impl(not_found, 0, std::is_same::value...); - } -#endif - - template - using find_index_sfinae_impl = - lib::enable_if_t>; - - template - using find_index_sfinae = find_index_sfinae_impl()>; - - template - struct find_index_checked_impl : lib::size_constant { - static_assert(I != not_found, "the specified type is not found."); - static_assert(I != ambiguous, "the specified type is ambiguous."); - }; - - template - using find_index_checked = find_index_checked_impl()>; - - struct valueless_t {}; - - enum class Trait { TriviallyAvailable, Available, Unavailable }; - - template class IsTriviallyAvailable, - template class IsAvailable> - inline constexpr Trait trait() { - return IsTriviallyAvailable::value - ? Trait::TriviallyAvailable - : IsAvailable::value ? Trait::Available - : Trait::Unavailable; - } - -#ifdef MPARK_CPP14_CONSTEXPR - template - inline constexpr Trait common_trait(Traits... traits_) { - Trait result = Trait::TriviallyAvailable; - lib::array traits = {{traits_...}}; - for (std::size_t i = 0; i < sizeof...(Traits); ++i) { - Trait t = traits[i]; - if (static_cast(t) > static_cast(result)) { - result = t; - } - } - return result; - } -#else - inline constexpr Trait common_trait_impl(Trait result) { return result; } - - template - inline constexpr Trait common_trait_impl(Trait result, - Trait t, - Traits... ts) { - return static_cast(t) > static_cast(result) - ? common_trait_impl(t, ts...) - : common_trait_impl(result, ts...); - } - - template - inline constexpr Trait common_trait(Traits... ts) { - return common_trait_impl(Trait::TriviallyAvailable, ts...); - } -#endif - - template - struct traits { - static constexpr Trait copy_constructible_trait = - common_trait(trait()...); - - static constexpr Trait move_constructible_trait = - common_trait(trait()...); - - static constexpr Trait copy_assignable_trait = - common_trait(copy_constructible_trait, - trait()...); - - static constexpr Trait move_assignable_trait = - common_trait(move_constructible_trait, - trait()...); - - static constexpr Trait destructible_trait = - common_trait(trait()...); - }; - - namespace access { - - struct recursive_union { -#ifdef MPARK_RETURN_TYPE_DEDUCTION - template - inline static constexpr auto &&get_alt(V &&v, in_place_index_t<0>) { - return lib::forward(v).head_; - } - - template - inline static constexpr auto &&get_alt(V &&v, in_place_index_t) { - return get_alt(lib::forward(v).tail_, in_place_index_t{}); - } -#else - template - struct get_alt_impl { - template - inline constexpr AUTO_REFREF operator()(V &&v) const - AUTO_REFREF_RETURN(get_alt_impl{}(lib::forward(v).tail_)) - }; - - template - struct get_alt_impl<0, Dummy> { - template - inline constexpr AUTO_REFREF operator()(V &&v) const - AUTO_REFREF_RETURN(lib::forward(v).head_) - }; - - template - inline static constexpr AUTO_REFREF get_alt(V &&v, in_place_index_t) - AUTO_REFREF_RETURN(get_alt_impl{}(lib::forward(v))) -#endif - }; - - struct base { - template - inline static constexpr AUTO_REFREF get_alt(V &&v) -#ifdef _MSC_VER - AUTO_REFREF_RETURN(recursive_union::get_alt( - lib::forward(v).data_, in_place_index_t{})) -#else - AUTO_REFREF_RETURN(recursive_union::get_alt( - data(lib::forward(v)), in_place_index_t{})) -#endif - }; - - struct variant { - template - inline static constexpr AUTO_REFREF get_alt(V &&v) - AUTO_REFREF_RETURN(base::get_alt(lib::forward(v).impl_)) - }; - - } // namespace access - - namespace visitation { - -#if defined(MPARK_CPP14_CONSTEXPR) && !defined(_MSC_VER) -#define MPARK_VARIANT_SWITCH_VISIT -#endif - - struct base { - template - using dispatch_result_t = decltype( - lib::invoke(std::declval(), - access::base::get_alt<0>(std::declval())...)); - - template - struct expected { - template - inline static constexpr bool but_got() { - return std::is_same::value; - } - }; - - template - struct visit_return_type_check { - static_assert( - expected::template but_got(), - "`visit` requires the visitor to have a single return type"); - - template - inline static constexpr DECLTYPE_AUTO invoke(Visitor &&visitor, - Alts &&... alts) - DECLTYPE_AUTO_RETURN(lib::invoke(lib::forward(visitor), - lib::forward(alts)...)) - }; - -#ifdef MPARK_VARIANT_SWITCH_VISIT - template - struct dispatcher; - - template - struct dispatcher { - template - MPARK_ALWAYS_INLINE static constexpr R dispatch( - F &&, typename ITs::type &&..., Vs &&...) { - MPARK_BUILTIN_UNREACHABLE; - } - - template - MPARK_ALWAYS_INLINE static constexpr R dispatch_case(F &&, Vs &&...) { - MPARK_BUILTIN_UNREACHABLE; - } - - template - MPARK_ALWAYS_INLINE static constexpr R dispatch_at(std::size_t, - F &&, - Vs &&...) { - MPARK_BUILTIN_UNREACHABLE; - } - }; - - template - struct dispatcher { - template - MPARK_ALWAYS_INLINE static constexpr R dispatch( - F &&f, typename ITs::type &&... visited_vs) { - using Expected = R; - using Actual = decltype(lib::invoke( - lib::forward(f), - access::base::get_alt( - lib::forward(visited_vs))...)); - return visit_return_type_check::invoke( - lib::forward(f), - access::base::get_alt( - lib::forward(visited_vs))...); - } - - template - MPARK_ALWAYS_INLINE static constexpr R dispatch( - F &&f, typename ITs::type &&... visited_vs, V &&v, Vs &&... vs) { -#define MPARK_DISPATCH(I) \ - dispatcher<(I < lib::decay_t::size()), \ - R, \ - ITs..., \ - lib::indexed_type>:: \ - template dispatch<0>(lib::forward(f), \ - lib::forward(visited_vs)..., \ - lib::forward(v), \ - lib::forward(vs)...) - -#define MPARK_DEFAULT(I) \ - dispatcher<(I < lib::decay_t::size()), R, ITs...>::template dispatch( \ - lib::forward(f), \ - lib::forward(visited_vs)..., \ - lib::forward(v), \ - lib::forward(vs)...) - - switch (v.index()) { - case B + 0: return MPARK_DISPATCH(B + 0); - case B + 1: return MPARK_DISPATCH(B + 1); - case B + 2: return MPARK_DISPATCH(B + 2); - case B + 3: return MPARK_DISPATCH(B + 3); - case B + 4: return MPARK_DISPATCH(B + 4); - case B + 5: return MPARK_DISPATCH(B + 5); - case B + 6: return MPARK_DISPATCH(B + 6); - case B + 7: return MPARK_DISPATCH(B + 7); - case B + 8: return MPARK_DISPATCH(B + 8); - case B + 9: return MPARK_DISPATCH(B + 9); - case B + 10: return MPARK_DISPATCH(B + 10); - case B + 11: return MPARK_DISPATCH(B + 11); - case B + 12: return MPARK_DISPATCH(B + 12); - case B + 13: return MPARK_DISPATCH(B + 13); - case B + 14: return MPARK_DISPATCH(B + 14); - case B + 15: return MPARK_DISPATCH(B + 15); - case B + 16: return MPARK_DISPATCH(B + 16); - case B + 17: return MPARK_DISPATCH(B + 17); - case B + 18: return MPARK_DISPATCH(B + 18); - case B + 19: return MPARK_DISPATCH(B + 19); - case B + 20: return MPARK_DISPATCH(B + 20); - case B + 21: return MPARK_DISPATCH(B + 21); - case B + 22: return MPARK_DISPATCH(B + 22); - case B + 23: return MPARK_DISPATCH(B + 23); - case B + 24: return MPARK_DISPATCH(B + 24); - case B + 25: return MPARK_DISPATCH(B + 25); - case B + 26: return MPARK_DISPATCH(B + 26); - case B + 27: return MPARK_DISPATCH(B + 27); - case B + 28: return MPARK_DISPATCH(B + 28); - case B + 29: return MPARK_DISPATCH(B + 29); - case B + 30: return MPARK_DISPATCH(B + 30); - case B + 31: return MPARK_DISPATCH(B + 31); - default: return MPARK_DEFAULT(B + 32); - } - -#undef MPARK_DEFAULT -#undef MPARK_DISPATCH - } - - template - MPARK_ALWAYS_INLINE static constexpr R dispatch_case(F &&f, - Vs &&... vs) { - using Expected = R; - using Actual = decltype( - lib::invoke(lib::forward(f), - access::base::get_alt(lib::forward(vs))...)); - return visit_return_type_check::invoke( - lib::forward(f), - access::base::get_alt(lib::forward(vs))...); - } - - template - MPARK_ALWAYS_INLINE static constexpr R dispatch_at(std::size_t index, - F &&f, - V &&v, - Vs &&... vs) { - static_assert(lib::all<(lib::decay_t::size() == - lib::decay_t::size())...>::value, - "all of the variants must be the same size."); -#define MPARK_DISPATCH_AT(I) \ - dispatcher<(I < lib::decay_t::size()), R>::template dispatch_case( \ - lib::forward(f), lib::forward(v), lib::forward(vs)...) - -#define MPARK_DEFAULT(I) \ - dispatcher<(I < lib::decay_t::size()), R>::template dispatch_at( \ - index, lib::forward(f), lib::forward(v), lib::forward(vs)...) - - switch (index) { - case B + 0: return MPARK_DISPATCH_AT(B + 0); - case B + 1: return MPARK_DISPATCH_AT(B + 1); - case B + 2: return MPARK_DISPATCH_AT(B + 2); - case B + 3: return MPARK_DISPATCH_AT(B + 3); - case B + 4: return MPARK_DISPATCH_AT(B + 4); - case B + 5: return MPARK_DISPATCH_AT(B + 5); - case B + 6: return MPARK_DISPATCH_AT(B + 6); - case B + 7: return MPARK_DISPATCH_AT(B + 7); - case B + 8: return MPARK_DISPATCH_AT(B + 8); - case B + 9: return MPARK_DISPATCH_AT(B + 9); - case B + 10: return MPARK_DISPATCH_AT(B + 10); - case B + 11: return MPARK_DISPATCH_AT(B + 11); - case B + 12: return MPARK_DISPATCH_AT(B + 12); - case B + 13: return MPARK_DISPATCH_AT(B + 13); - case B + 14: return MPARK_DISPATCH_AT(B + 14); - case B + 15: return MPARK_DISPATCH_AT(B + 15); - case B + 16: return MPARK_DISPATCH_AT(B + 16); - case B + 17: return MPARK_DISPATCH_AT(B + 17); - case B + 18: return MPARK_DISPATCH_AT(B + 18); - case B + 19: return MPARK_DISPATCH_AT(B + 19); - case B + 20: return MPARK_DISPATCH_AT(B + 20); - case B + 21: return MPARK_DISPATCH_AT(B + 21); - case B + 22: return MPARK_DISPATCH_AT(B + 22); - case B + 23: return MPARK_DISPATCH_AT(B + 23); - case B + 24: return MPARK_DISPATCH_AT(B + 24); - case B + 25: return MPARK_DISPATCH_AT(B + 25); - case B + 26: return MPARK_DISPATCH_AT(B + 26); - case B + 27: return MPARK_DISPATCH_AT(B + 27); - case B + 28: return MPARK_DISPATCH_AT(B + 28); - case B + 29: return MPARK_DISPATCH_AT(B + 29); - case B + 30: return MPARK_DISPATCH_AT(B + 30); - case B + 31: return MPARK_DISPATCH_AT(B + 31); - default: return MPARK_DEFAULT(B + 32); - } - -#undef MPARK_DEFAULT -#undef MPARK_DISPATCH_AT - } - }; -#else - template - inline static constexpr const T &at(const T &elem) noexcept { - return elem; - } - - template - inline static constexpr const lib::remove_all_extents_t &at( - const lib::array &elems, std::size_t i, Is... is) noexcept { - return at(elems[i], is...); - } - - template - inline static constexpr lib::array, sizeof...(Fs) + 1> - make_farray(F &&f, Fs &&... fs) { - return {{lib::forward(f), lib::forward(fs)...}}; - } - - template - struct make_fmatrix_impl { - - template - inline static constexpr dispatch_result_t dispatch( - F &&f, Vs &&... vs) { - using Expected = dispatch_result_t; - using Actual = decltype(lib::invoke( - lib::forward(f), - access::base::get_alt(lib::forward(vs))...)); - return visit_return_type_check::invoke( - lib::forward(f), - access::base::get_alt(lib::forward(vs))...); - } - -#ifdef MPARK_RETURN_TYPE_DEDUCTION - template - inline static constexpr auto impl(lib::index_sequence) { - return &dispatch; - } - - template - inline static constexpr auto impl(Is, - lib::index_sequence, - Ls... ls) { - return make_farray(impl(lib::push_back_t{}, ls...)...); - } -#else - template - struct impl; - - template - struct impl> { - inline constexpr AUTO operator()() const - AUTO_RETURN(&dispatch) - }; - - template - struct impl, Ls...> { - inline constexpr AUTO operator()() const - AUTO_RETURN( - make_farray(impl, Ls...>{}()...)) - }; -#endif - }; - -#ifdef MPARK_RETURN_TYPE_DEDUCTION - template - inline static constexpr auto make_fmatrix() { - return make_fmatrix_impl::impl( - lib::index_sequence<>{}, - lib::make_index_sequence::size()>{}...); - } -#else - template - inline static constexpr AUTO make_fmatrix() - AUTO_RETURN( - typename make_fmatrix_impl::template impl< - lib::index_sequence<>, - lib::make_index_sequence::size()>...>{}()) -#endif - - template - struct make_fdiagonal_impl { - template - inline static constexpr dispatch_result_t dispatch( - F &&f, Vs &&... vs) { - using Expected = dispatch_result_t; - using Actual = decltype( - lib::invoke(lib::forward(f), - access::base::get_alt(lib::forward(vs))...)); - return visit_return_type_check::invoke( - lib::forward(f), - access::base::get_alt(lib::forward(vs))...); - } - - template - inline static constexpr AUTO impl(lib::index_sequence) - AUTO_RETURN(make_farray(&dispatch...)) - }; - - template - inline static constexpr auto make_fdiagonal() - -> decltype(make_fdiagonal_impl::impl( - lib::make_index_sequence::size()>{})) { - static_assert(lib::all<(lib::decay_t::size() == - lib::decay_t::size())...>::value, - "all of the variants must be the same size."); - return make_fdiagonal_impl::impl( - lib::make_index_sequence::size()>{}); - } -#endif - }; - -#if !defined(MPARK_VARIANT_SWITCH_VISIT) && \ - (!defined(_MSC_VER) || _MSC_VER >= 1910) - template - using fmatrix_t = decltype(base::make_fmatrix()); - - template - struct fmatrix { - static constexpr fmatrix_t value = - base::make_fmatrix(); - }; - - template - constexpr fmatrix_t fmatrix::value; - - template - using fdiagonal_t = decltype(base::make_fdiagonal()); - - template - struct fdiagonal { - static constexpr fdiagonal_t value = - base::make_fdiagonal(); - }; - - template - constexpr fdiagonal_t fdiagonal::value; -#endif - - struct alt { - template - inline static constexpr DECLTYPE_AUTO visit_alt(Visitor &&visitor, - Vs &&... vs) -#ifdef MPARK_VARIANT_SWITCH_VISIT - DECLTYPE_AUTO_RETURN( - base::dispatcher< - true, - base::dispatch_result_t(vs)))...>>:: - template dispatch<0>(lib::forward(visitor), - as_base(lib::forward(vs))...)) -#elif !defined(_MSC_VER) || _MSC_VER >= 1910 - DECLTYPE_AUTO_RETURN(base::at( - fmatrix(vs)))...>::value, - vs.index()...)(lib::forward(visitor), - as_base(lib::forward(vs))...)) -#else - DECLTYPE_AUTO_RETURN(base::at( - base::make_fmatrix(vs)))...>(), - vs.index()...)(lib::forward(visitor), - as_base(lib::forward(vs))...)) -#endif - - template - inline static constexpr DECLTYPE_AUTO visit_alt_at(std::size_t index, - Visitor &&visitor, - Vs &&... vs) -#ifdef MPARK_VARIANT_SWITCH_VISIT - DECLTYPE_AUTO_RETURN( - base::dispatcher< - true, - base::dispatch_result_t(vs)))...>>:: - template dispatch_at<0>(index, - lib::forward(visitor), - as_base(lib::forward(vs))...)) -#elif !defined(_MSC_VER) || _MSC_VER >= 1910 - DECLTYPE_AUTO_RETURN(base::at( - fdiagonal(vs)))...>::value, - index)(lib::forward(visitor), - as_base(lib::forward(vs))...)) -#else - DECLTYPE_AUTO_RETURN(base::at( - base::make_fdiagonal(vs)))...>(), - index)(lib::forward(visitor), - as_base(lib::forward(vs))...)) -#endif - }; - - struct variant { - private: - template - struct visitor { - template - inline static constexpr bool does_not_handle() { - return lib::is_invocable::value; - } - }; - - template - struct visit_exhaustiveness_check { - static_assert(visitor::template does_not_handle(), - "`visit` requires the visitor to be exhaustive."); - - inline static constexpr DECLTYPE_AUTO invoke(Visitor &&visitor, - Values &&... values) - DECLTYPE_AUTO_RETURN(lib::invoke(lib::forward(visitor), - lib::forward(values)...)) - }; - - template - struct value_visitor { - Visitor &&visitor_; - - template - inline constexpr DECLTYPE_AUTO operator()(Alts &&... alts) const - DECLTYPE_AUTO_RETURN( - visit_exhaustiveness_check< - Visitor, - decltype((lib::forward(alts).value))...>:: - invoke(lib::forward(visitor_), - lib::forward(alts).value...)) - }; - - template - inline static constexpr AUTO make_value_visitor(Visitor &&visitor) - AUTO_RETURN(value_visitor{lib::forward(visitor)}) - - public: - template - inline static constexpr DECLTYPE_AUTO visit_alt(Visitor &&visitor, - Vs &&... vs) - DECLTYPE_AUTO_RETURN(alt::visit_alt(lib::forward(visitor), - lib::forward(vs).impl_...)) - - template - inline static constexpr DECLTYPE_AUTO visit_alt_at(std::size_t index, - Visitor &&visitor, - Vs &&... vs) - DECLTYPE_AUTO_RETURN( - alt::visit_alt_at(index, - lib::forward(visitor), - lib::forward(vs).impl_...)) - - template - inline static constexpr DECLTYPE_AUTO visit_value(Visitor &&visitor, - Vs &&... vs) - DECLTYPE_AUTO_RETURN( - visit_alt(make_value_visitor(lib::forward(visitor)), - lib::forward(vs)...)) - - template - inline static constexpr DECLTYPE_AUTO visit_value_at(std::size_t index, - Visitor &&visitor, - Vs &&... vs) - DECLTYPE_AUTO_RETURN( - visit_alt_at(index, - make_value_visitor(lib::forward(visitor)), - lib::forward(vs)...)) - }; - - } // namespace visitation - - template - struct alt { - using value_type = T; - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4244) -#endif - template - inline explicit constexpr alt(in_place_t, Args &&... args) - : value(lib::forward(args)...) {} -#ifdef _MSC_VER -#pragma warning(pop) -#endif - - T value; - }; - - template - union recursive_union; - - template - union recursive_union {}; - -#define MPARK_VARIANT_RECURSIVE_UNION(destructible_trait, destructor) \ - template \ - union recursive_union { \ - public: \ - inline explicit constexpr recursive_union(valueless_t) noexcept \ - : dummy_{} {} \ - \ - template \ - inline explicit constexpr recursive_union(in_place_index_t<0>, \ - Args &&... args) \ - : head_(in_place_t{}, lib::forward(args)...) {} \ - \ - template \ - inline explicit constexpr recursive_union(in_place_index_t, \ - Args &&... args) \ - : tail_(in_place_index_t{}, lib::forward(args)...) {} \ - \ - recursive_union(const recursive_union &) = default; \ - recursive_union(recursive_union &&) = default; \ - \ - destructor \ - \ - recursive_union &operator=(const recursive_union &) = default; \ - recursive_union &operator=(recursive_union &&) = default; \ - \ - private: \ - char dummy_; \ - alt head_; \ - recursive_union tail_; \ - \ - friend struct access::recursive_union; \ - } - - MPARK_VARIANT_RECURSIVE_UNION(Trait::TriviallyAvailable, - ~recursive_union() = default;); - MPARK_VARIANT_RECURSIVE_UNION(Trait::Available, - ~recursive_union() {}); - MPARK_VARIANT_RECURSIVE_UNION(Trait::Unavailable, - ~recursive_union() = delete;); - -#undef MPARK_VARIANT_RECURSIVE_UNION - - using index_t = unsigned int; - - template - class base { - public: - inline explicit constexpr base(valueless_t tag) noexcept - : data_(tag), index_(static_cast(-1)) {} - - template - inline explicit constexpr base(in_place_index_t, Args &&... args) - : data_(in_place_index_t{}, lib::forward(args)...), - index_(I) {} - - inline constexpr bool valueless_by_exception() const noexcept { - return index_ == static_cast(-1); - } - - inline constexpr std::size_t index() const noexcept { - return valueless_by_exception() ? variant_npos : index_; - } - - protected: - using data_t = recursive_union; - - friend inline constexpr base &as_base(base &b) { return b; } - friend inline constexpr const base &as_base(const base &b) { return b; } - friend inline constexpr base &&as_base(base &&b) { return lib::move(b); } - friend inline constexpr const base &&as_base(const base &&b) { return lib::move(b); } - - friend inline constexpr data_t &data(base &b) { return b.data_; } - friend inline constexpr const data_t &data(const base &b) { return b.data_; } - friend inline constexpr data_t &&data(base &&b) { return lib::move(b).data_; } - friend inline constexpr const data_t &&data(const base &&b) { return lib::move(b).data_; } - - inline static constexpr std::size_t size() { return sizeof...(Ts); } - - data_t data_; - index_t index_; - - friend struct access::base; - friend struct visitation::base; - }; - - struct dtor { -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4100) -#endif - template - inline void operator()(Alt &alt) const noexcept { alt.~Alt(); } -#ifdef _MSC_VER -#pragma warning(pop) -#endif - }; - -#if !defined(_MSC_VER) || _MSC_VER >= 1910 -#define MPARK_INHERITING_CTOR(type, base) using base::base; -#else -#define MPARK_INHERITING_CTOR(type, base) \ - template \ - inline explicit constexpr type(Args &&... args) \ - : base(lib::forward(args)...) {} -#endif - - template - class destructor; - -#define MPARK_VARIANT_DESTRUCTOR(destructible_trait, definition, destroy) \ - template \ - class destructor, destructible_trait> \ - : public base { \ - using super = base; \ - \ - public: \ - MPARK_INHERITING_CTOR(destructor, super) \ - using super::operator=; \ - \ - destructor(const destructor &) = default; \ - destructor(destructor &&) = default; \ - definition \ - destructor &operator=(const destructor &) = default; \ - destructor &operator=(destructor &&) = default; \ - \ - protected: \ - destroy \ - } - - MPARK_VARIANT_DESTRUCTOR( - Trait::TriviallyAvailable, - ~destructor() = default;, - inline void destroy() noexcept { - this->index_ = static_cast(-1); - }); - - MPARK_VARIANT_DESTRUCTOR( - Trait::Available, - ~destructor() { destroy(); }, - inline void destroy() noexcept { - if (!this->valueless_by_exception()) { - visitation::alt::visit_alt(dtor{}, *this); - } - this->index_ = static_cast(-1); - }); - - MPARK_VARIANT_DESTRUCTOR( - Trait::Unavailable, - ~destructor() = delete;, - inline void destroy() noexcept = delete;); - -#undef MPARK_VARIANT_DESTRUCTOR - - template - class constructor : public destructor { - using super = destructor; - - public: - MPARK_INHERITING_CTOR(constructor, super) - using super::operator=; - - protected: -#ifndef MPARK_GENERIC_LAMBDAS - struct ctor { - template - inline void operator()(LhsAlt &lhs_alt, RhsAlt &&rhs_alt) const { - constructor::construct_alt(lhs_alt, - lib::forward(rhs_alt).value); - } - }; -#endif - - template - inline static T &construct_alt(alt &a, Args &&... args) { - auto *result = ::new (static_cast(lib::addressof(a))) - alt(in_place_t{}, lib::forward(args)...); - return result->value; - } - - template - inline static void generic_construct(constructor &lhs, Rhs &&rhs) { - lhs.destroy(); - if (!rhs.valueless_by_exception()) { - visitation::alt::visit_alt_at( - rhs.index(), -#ifdef MPARK_GENERIC_LAMBDAS - [](auto &lhs_alt, auto &&rhs_alt) { - constructor::construct_alt( - lhs_alt, lib::forward(rhs_alt).value); - } -#else - ctor{} -#endif - , - lhs, - lib::forward(rhs)); - lhs.index_ = rhs.index_; - } - } - }; - - template - class move_constructor; - -#define MPARK_VARIANT_MOVE_CONSTRUCTOR(move_constructible_trait, definition) \ - template \ - class move_constructor, move_constructible_trait> \ - : public constructor> { \ - using super = constructor>; \ - \ - public: \ - MPARK_INHERITING_CTOR(move_constructor, super) \ - using super::operator=; \ - \ - move_constructor(const move_constructor &) = default; \ - definition \ - ~move_constructor() = default; \ - move_constructor &operator=(const move_constructor &) = default; \ - move_constructor &operator=(move_constructor &&) = default; \ - } - - MPARK_VARIANT_MOVE_CONSTRUCTOR( - Trait::TriviallyAvailable, - move_constructor(move_constructor &&that) = default;); - - MPARK_VARIANT_MOVE_CONSTRUCTOR( - Trait::Available, - move_constructor(move_constructor &&that) noexcept( - lib::all::value...>::value) - : move_constructor(valueless_t{}) { - this->generic_construct(*this, lib::move(that)); - }); - - MPARK_VARIANT_MOVE_CONSTRUCTOR( - Trait::Unavailable, - move_constructor(move_constructor &&) = delete;); - -#undef MPARK_VARIANT_MOVE_CONSTRUCTOR - - template - class copy_constructor; - -#define MPARK_VARIANT_COPY_CONSTRUCTOR(copy_constructible_trait, definition) \ - template \ - class copy_constructor, copy_constructible_trait> \ - : public move_constructor> { \ - using super = move_constructor>; \ - \ - public: \ - MPARK_INHERITING_CTOR(copy_constructor, super) \ - using super::operator=; \ - \ - definition \ - copy_constructor(copy_constructor &&) = default; \ - ~copy_constructor() = default; \ - copy_constructor &operator=(const copy_constructor &) = default; \ - copy_constructor &operator=(copy_constructor &&) = default; \ - } - - MPARK_VARIANT_COPY_CONSTRUCTOR( - Trait::TriviallyAvailable, - copy_constructor(const copy_constructor &that) = default;); - - MPARK_VARIANT_COPY_CONSTRUCTOR( - Trait::Available, - copy_constructor(const copy_constructor &that) - : copy_constructor(valueless_t{}) { - this->generic_construct(*this, that); - }); - - MPARK_VARIANT_COPY_CONSTRUCTOR( - Trait::Unavailable, - copy_constructor(const copy_constructor &) = delete;); - -#undef MPARK_VARIANT_COPY_CONSTRUCTOR - - template - class assignment : public copy_constructor { - using super = copy_constructor; - - public: - MPARK_INHERITING_CTOR(assignment, super) - using super::operator=; - - template - inline /* auto & */ auto emplace(Args &&... args) - -> decltype(this->construct_alt(access::base::get_alt(*this), - lib::forward(args)...)) { - this->destroy(); - auto &result = this->construct_alt(access::base::get_alt(*this), - lib::forward(args)...); - this->index_ = I; - return result; - } - - protected: -#ifndef MPARK_GENERIC_LAMBDAS - template - struct assigner { - template - inline void operator()(ThisAlt &this_alt, ThatAlt &&that_alt) const { - self->assign_alt(this_alt, lib::forward(that_alt).value); - } - assignment *self; - }; -#endif - - template - inline void assign_alt(alt &a, Arg &&arg) { - if (this->index() == I) { -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4244) -#endif - a.value = lib::forward(arg); -#ifdef _MSC_VER -#pragma warning(pop) -#endif - } else { - struct { - void operator()(std::true_type) const { - this_->emplace(lib::forward(arg_)); - } - void operator()(std::false_type) const { - this_->emplace(T(lib::forward(arg_))); - } - assignment *this_; - Arg &&arg_; - } impl{this, lib::forward(arg)}; - impl(lib::bool_constant< - std::is_nothrow_constructible::value || - !std::is_nothrow_move_constructible::value>{}); - } - } - - template - inline void generic_assign(That &&that) { - if (this->valueless_by_exception() && that.valueless_by_exception()) { - // do nothing. - } else if (that.valueless_by_exception()) { - this->destroy(); - } else { - visitation::alt::visit_alt_at( - that.index(), -#ifdef MPARK_GENERIC_LAMBDAS - [this](auto &this_alt, auto &&that_alt) { - this->assign_alt( - this_alt, lib::forward(that_alt).value); - } -#else - assigner{this} -#endif - , - *this, - lib::forward(that)); - } - } - }; - - template - class move_assignment; - -#define MPARK_VARIANT_MOVE_ASSIGNMENT(move_assignable_trait, definition) \ - template \ - class move_assignment, move_assignable_trait> \ - : public assignment> { \ - using super = assignment>; \ - \ - public: \ - MPARK_INHERITING_CTOR(move_assignment, super) \ - using super::operator=; \ - \ - move_assignment(const move_assignment &) = default; \ - move_assignment(move_assignment &&) = default; \ - ~move_assignment() = default; \ - move_assignment &operator=(const move_assignment &) = default; \ - definition \ - } - - MPARK_VARIANT_MOVE_ASSIGNMENT( - Trait::TriviallyAvailable, - move_assignment &operator=(move_assignment &&that) = default;); - - MPARK_VARIANT_MOVE_ASSIGNMENT( - Trait::Available, - move_assignment & - operator=(move_assignment &&that) noexcept( - lib::all<(std::is_nothrow_move_constructible::value && - std::is_nothrow_move_assignable::value)...>::value) { - this->generic_assign(lib::move(that)); - return *this; - }); - - MPARK_VARIANT_MOVE_ASSIGNMENT( - Trait::Unavailable, - move_assignment &operator=(move_assignment &&) = delete;); - -#undef MPARK_VARIANT_MOVE_ASSIGNMENT - - template - class copy_assignment; - -#define MPARK_VARIANT_COPY_ASSIGNMENT(copy_assignable_trait, definition) \ - template \ - class copy_assignment, copy_assignable_trait> \ - : public move_assignment> { \ - using super = move_assignment>; \ - \ - public: \ - MPARK_INHERITING_CTOR(copy_assignment, super) \ - using super::operator=; \ - \ - copy_assignment(const copy_assignment &) = default; \ - copy_assignment(copy_assignment &&) = default; \ - ~copy_assignment() = default; \ - definition \ - copy_assignment &operator=(copy_assignment &&) = default; \ - } - - MPARK_VARIANT_COPY_ASSIGNMENT( - Trait::TriviallyAvailable, - copy_assignment &operator=(const copy_assignment &that) = default;); - - MPARK_VARIANT_COPY_ASSIGNMENT( - Trait::Available, - copy_assignment &operator=(const copy_assignment &that) { - this->generic_assign(that); - return *this; - }); - - MPARK_VARIANT_COPY_ASSIGNMENT( - Trait::Unavailable, - copy_assignment &operator=(const copy_assignment &) = delete;); - -#undef MPARK_VARIANT_COPY_ASSIGNMENT - - template - class impl : public copy_assignment> { - using super = copy_assignment>; - - public: - MPARK_INHERITING_CTOR(impl, super) - using super::operator=; - - template - inline void assign(Arg &&arg) { - this->assign_alt(access::base::get_alt(*this), - lib::forward(arg)); - } - - inline void swap(impl &that) { - if (this->valueless_by_exception() && that.valueless_by_exception()) { - // do nothing. - } else if (this->index() == that.index()) { - visitation::alt::visit_alt_at(this->index(), -#ifdef MPARK_GENERIC_LAMBDAS - [](auto &this_alt, auto &that_alt) { - using std::swap; - swap(this_alt.value, - that_alt.value); - } -#else - swapper{} -#endif - , - *this, - that); - } else { - impl *lhs = this; - impl *rhs = lib::addressof(that); - if (lhs->move_nothrow() && !rhs->move_nothrow()) { - std::swap(lhs, rhs); - } - impl tmp(lib::move(*rhs)); -#ifdef MPARK_EXCEPTIONS - // EXTENSION: When the move construction of `lhs` into `rhs` throws - // and `tmp` is nothrow move constructible then we move `tmp` back - // into `rhs` and provide the strong exception safety guarantee. - try { - this->generic_construct(*rhs, lib::move(*lhs)); - } catch (...) { - if (tmp.move_nothrow()) { - this->generic_construct(*rhs, lib::move(tmp)); - } - throw; - } -#else - this->generic_construct(*rhs, lib::move(*lhs)); -#endif - this->generic_construct(*lhs, lib::move(tmp)); - } - } - - private: -#ifndef MPARK_GENERIC_LAMBDAS - struct swapper { - template - inline void operator()(ThisAlt &this_alt, ThatAlt &that_alt) const { - using std::swap; - swap(this_alt.value, that_alt.value); - } - }; -#endif - - inline constexpr bool move_nothrow() const { - return this->valueless_by_exception() || - lib::array{ - {std::is_nothrow_move_constructible::value...} - }[this->index()]; - } - }; - -#undef MPARK_INHERITING_CTOR - - template - struct overload_leaf { - using F = lib::size_constant (*)(T); - operator F() const { return nullptr; } - }; - - template - struct overload_impl { - private: - template - struct impl; - - template - struct impl> : overload_leaf... {}; - - public: - using type = impl>; - }; - - template - using overload = typename overload_impl::type; - - template - using best_match = lib::invoke_result_t, T &&>; - - template - struct is_in_place_index : std::false_type {}; - - template - struct is_in_place_index> : std::true_type {}; - - template - struct is_in_place_type : std::false_type {}; - - template - struct is_in_place_type> : std::true_type {}; - - } // detail - - template - class variant { - static_assert(0 < sizeof...(Ts), - "variant must consist of at least one alternative."); - - static_assert(lib::all::value...>::value, - "variant can not have an array type as an alternative."); - - static_assert(lib::all::value...>::value, - "variant can not have a reference type as an alternative."); - - static_assert(lib::all::value...>::value, - "variant can not have a void type as an alternative."); - - public: - template < - typename Front = lib::type_pack_element_t<0, Ts...>, - lib::enable_if_t::value, int> = 0> - inline constexpr variant() noexcept( - std::is_nothrow_default_constructible::value) - : impl_(in_place_index_t<0>{}) {} - - variant(const variant &) = default; - variant(variant &&) = default; - - template < - typename Arg, - typename Decayed = lib::decay_t, - lib::enable_if_t::value, int> = 0, - lib::enable_if_t::value, int> = 0, - lib::enable_if_t::value, int> = 0, - std::size_t I = detail::best_match::value, - typename T = lib::type_pack_element_t, - lib::enable_if_t::value, int> = 0> - inline constexpr variant(Arg &&arg) noexcept( - std::is_nothrow_constructible::value) - : impl_(in_place_index_t{}, lib::forward(arg)) {} - - template < - std::size_t I, - typename... Args, - typename T = lib::type_pack_element_t, - lib::enable_if_t::value, int> = 0> - inline explicit constexpr variant( - in_place_index_t, - Args &&... args) noexcept(std::is_nothrow_constructible::value) - : impl_(in_place_index_t{}, lib::forward(args)...) {} - - template < - std::size_t I, - typename Up, - typename... Args, - typename T = lib::type_pack_element_t, - lib::enable_if_t &, - Args...>::value, - int> = 0> - inline explicit constexpr variant( - in_place_index_t, - std::initializer_list il, - Args &&... args) noexcept(std:: - is_nothrow_constructible< - T, - std::initializer_list &, - Args...>::value) - : impl_(in_place_index_t{}, il, lib::forward(args)...) {} - - template < - typename T, - typename... Args, - std::size_t I = detail::find_index_sfinae::value, - lib::enable_if_t::value, int> = 0> - inline explicit constexpr variant( - in_place_type_t, - Args &&... args) noexcept(std::is_nothrow_constructible::value) - : impl_(in_place_index_t{}, lib::forward(args)...) {} - - template < - typename T, - typename Up, - typename... Args, - std::size_t I = detail::find_index_sfinae::value, - lib::enable_if_t &, - Args...>::value, - int> = 0> - inline explicit constexpr variant( - in_place_type_t, - std::initializer_list il, - Args &&... args) noexcept(std:: - is_nothrow_constructible< - T, - std::initializer_list &, - Args...>::value) - : impl_(in_place_index_t{}, il, lib::forward(args)...) {} - - ~variant() = default; - - variant &operator=(const variant &) = default; - variant &operator=(variant &&) = default; - - template , variant>::value, - int> = 0, - std::size_t I = detail::best_match::value, - typename T = lib::type_pack_element_t, - lib::enable_if_t<(std::is_assignable::value && - std::is_constructible::value), - int> = 0> - inline variant &operator=(Arg &&arg) noexcept( - (std::is_nothrow_assignable::value && - std::is_nothrow_constructible::value)) { - impl_.template assign(lib::forward(arg)); - return *this; - } - - template < - std::size_t I, - typename... Args, - typename T = lib::type_pack_element_t, - lib::enable_if_t::value, int> = 0> - inline T &emplace(Args &&... args) { - return impl_.template emplace(lib::forward(args)...); - } - - template < - std::size_t I, - typename Up, - typename... Args, - typename T = lib::type_pack_element_t, - lib::enable_if_t &, - Args...>::value, - int> = 0> - inline T &emplace(std::initializer_list il, Args &&... args) { - return impl_.template emplace(il, lib::forward(args)...); - } - - template < - typename T, - typename... Args, - std::size_t I = detail::find_index_sfinae::value, - lib::enable_if_t::value, int> = 0> - inline T &emplace(Args &&... args) { - return impl_.template emplace(lib::forward(args)...); - } - - template < - typename T, - typename Up, - typename... Args, - std::size_t I = detail::find_index_sfinae::value, - lib::enable_if_t &, - Args...>::value, - int> = 0> - inline T &emplace(std::initializer_list il, Args &&... args) { - return impl_.template emplace(il, lib::forward(args)...); - } - - inline constexpr bool valueless_by_exception() const noexcept { - return impl_.valueless_by_exception(); - } - - inline constexpr std::size_t index() const noexcept { - return impl_.index(); - } - - template , - Dummy>::value && - lib::dependent_type, - Dummy>::value)...>::value, - int> = 0> - inline void swap(variant &that) noexcept( - lib::all<(std::is_nothrow_move_constructible::value && - lib::is_nothrow_swappable::value)...>::value) { - impl_.swap(that.impl_); - } - - private: - detail::impl impl_; - - friend struct detail::access::variant; - friend struct detail::visitation::variant; - }; - - template - inline constexpr bool holds_alternative(const variant &v) noexcept { - return v.index() == I; - } - - template - inline constexpr bool holds_alternative(const variant &v) noexcept { - return holds_alternative::value>(v); - } - - namespace detail { - template - struct generic_get_impl { - constexpr generic_get_impl(int) noexcept {} - - constexpr AUTO_REFREF operator()(V &&v) const - AUTO_REFREF_RETURN( - access::variant::get_alt(lib::forward(v)).value) - }; - - template - inline constexpr AUTO_REFREF generic_get(V &&v) - AUTO_REFREF_RETURN(generic_get_impl( - holds_alternative(v) ? 0 : (throw_bad_variant_access(), 0))( - lib::forward(v))) - } // namespace detail - - template - inline constexpr variant_alternative_t> &get( - variant &v) { - return detail::generic_get(v); - } - - template - inline constexpr variant_alternative_t> &&get( - variant &&v) { - return detail::generic_get(lib::move(v)); - } - - template - inline constexpr const variant_alternative_t> &get( - const variant &v) { - return detail::generic_get(v); - } - - template - inline constexpr const variant_alternative_t> &&get( - const variant &&v) { - return detail::generic_get(lib::move(v)); - } - - template - inline constexpr T &get(variant &v) { - return get::value>(v); - } - - template - inline constexpr T &&get(variant &&v) { - return get::value>(lib::move(v)); - } - - template - inline constexpr const T &get(const variant &v) { - return get::value>(v); - } - - template - inline constexpr const T &&get(const variant &&v) { - return get::value>(lib::move(v)); - } - - namespace detail { - - template - inline constexpr /* auto * */ AUTO generic_get_if(V *v) noexcept - AUTO_RETURN(v && holds_alternative(*v) - ? lib::addressof(access::variant::get_alt(*v).value) - : nullptr) - - } // namespace detail - - template - inline constexpr lib::add_pointer_t>> - get_if(variant *v) noexcept { - return detail::generic_get_if(v); - } - - template - inline constexpr lib::add_pointer_t< - const variant_alternative_t>> - get_if(const variant *v) noexcept { - return detail::generic_get_if(v); - } - - template - inline constexpr lib::add_pointer_t - get_if(variant *v) noexcept { - return get_if::value>(v); - } - - template - inline constexpr lib::add_pointer_t - get_if(const variant *v) noexcept { - return get_if::value>(v); - } - - namespace detail { - template - struct convert_to_bool { - template - inline constexpr bool operator()(Lhs &&lhs, Rhs &&rhs) const { - static_assert(std::is_convertible, - bool>::value, - "relational operators must return a type" - " implicitly convertible to bool"); - return lib::invoke( - RelOp{}, lib::forward(lhs), lib::forward(rhs)); - } - }; - } // namespace detail - - template - inline constexpr bool operator==(const variant &lhs, - const variant &rhs) { - using detail::visitation::variant; - using equal_to = detail::convert_to_bool; -#ifdef MPARK_CPP14_CONSTEXPR - if (lhs.index() != rhs.index()) return false; - if (lhs.valueless_by_exception()) return true; - return variant::visit_value_at(lhs.index(), equal_to{}, lhs, rhs); -#else - return lhs.index() == rhs.index() && - (lhs.valueless_by_exception() || - variant::visit_value_at(lhs.index(), equal_to{}, lhs, rhs)); -#endif - } - - template - inline constexpr bool operator!=(const variant &lhs, - const variant &rhs) { - using detail::visitation::variant; - using not_equal_to = detail::convert_to_bool; -#ifdef MPARK_CPP14_CONSTEXPR - if (lhs.index() != rhs.index()) return true; - if (lhs.valueless_by_exception()) return false; - return variant::visit_value_at(lhs.index(), not_equal_to{}, lhs, rhs); -#else - return lhs.index() != rhs.index() || - (!lhs.valueless_by_exception() && - variant::visit_value_at(lhs.index(), not_equal_to{}, lhs, rhs)); -#endif - } - - template - inline constexpr bool operator<(const variant &lhs, - const variant &rhs) { - using detail::visitation::variant; - using less = detail::convert_to_bool; -#ifdef MPARK_CPP14_CONSTEXPR - if (rhs.valueless_by_exception()) return false; - if (lhs.valueless_by_exception()) return true; - if (lhs.index() < rhs.index()) return true; - if (lhs.index() > rhs.index()) return false; - return variant::visit_value_at(lhs.index(), less{}, lhs, rhs); -#else - return !rhs.valueless_by_exception() && - (lhs.valueless_by_exception() || lhs.index() < rhs.index() || - (lhs.index() == rhs.index() && - variant::visit_value_at(lhs.index(), less{}, lhs, rhs))); -#endif - } - - template - inline constexpr bool operator>(const variant &lhs, - const variant &rhs) { - using detail::visitation::variant; - using greater = detail::convert_to_bool; -#ifdef MPARK_CPP14_CONSTEXPR - if (lhs.valueless_by_exception()) return false; - if (rhs.valueless_by_exception()) return true; - if (lhs.index() > rhs.index()) return true; - if (lhs.index() < rhs.index()) return false; - return variant::visit_value_at(lhs.index(), greater{}, lhs, rhs); -#else - return !lhs.valueless_by_exception() && - (rhs.valueless_by_exception() || lhs.index() > rhs.index() || - (lhs.index() == rhs.index() && - variant::visit_value_at(lhs.index(), greater{}, lhs, rhs))); -#endif - } - - template - inline constexpr bool operator<=(const variant &lhs, - const variant &rhs) { - using detail::visitation::variant; - using less_equal = detail::convert_to_bool; -#ifdef MPARK_CPP14_CONSTEXPR - if (lhs.valueless_by_exception()) return true; - if (rhs.valueless_by_exception()) return false; - if (lhs.index() < rhs.index()) return true; - if (lhs.index() > rhs.index()) return false; - return variant::visit_value_at(lhs.index(), less_equal{}, lhs, rhs); -#else - return lhs.valueless_by_exception() || - (!rhs.valueless_by_exception() && - (lhs.index() < rhs.index() || - (lhs.index() == rhs.index() && - variant::visit_value_at(lhs.index(), less_equal{}, lhs, rhs)))); -#endif - } - - template - inline constexpr bool operator>=(const variant &lhs, - const variant &rhs) { - using detail::visitation::variant; - using greater_equal = detail::convert_to_bool; -#ifdef MPARK_CPP14_CONSTEXPR - if (rhs.valueless_by_exception()) return true; - if (lhs.valueless_by_exception()) return false; - if (lhs.index() > rhs.index()) return true; - if (lhs.index() < rhs.index()) return false; - return variant::visit_value_at(lhs.index(), greater_equal{}, lhs, rhs); -#else - return rhs.valueless_by_exception() || - (!lhs.valueless_by_exception() && - (lhs.index() > rhs.index() || - (lhs.index() == rhs.index() && - variant::visit_value_at( - lhs.index(), greater_equal{}, lhs, rhs)))); -#endif - } - - struct monostate {}; - - inline constexpr bool operator<(monostate, monostate) noexcept { - return false; - } - - inline constexpr bool operator>(monostate, monostate) noexcept { - return false; - } - - inline constexpr bool operator<=(monostate, monostate) noexcept { - return true; - } - - inline constexpr bool operator>=(monostate, monostate) noexcept { - return true; - } - - inline constexpr bool operator==(monostate, monostate) noexcept { - return true; - } - - inline constexpr bool operator!=(monostate, monostate) noexcept { - return false; - } - -#ifdef MPARK_CPP14_CONSTEXPR - namespace detail { - - inline constexpr bool all(std::initializer_list bs) { - for (bool b : bs) { - if (!b) { - return false; - } - } - return true; - } - - } // namespace detail - - template - inline constexpr decltype(auto) visit(Visitor &&visitor, Vs &&... vs) { - return (detail::all({!vs.valueless_by_exception()...}) - ? (void)0 - : throw_bad_variant_access()), - detail::visitation::variant::visit_value( - lib::forward(visitor), lib::forward(vs)...); - } -#else - namespace detail { - - template - inline constexpr bool all_impl(const lib::array &bs, - std::size_t idx) { - return idx >= N || (bs[idx] && all_impl(bs, idx + 1)); - } - - template - inline constexpr bool all(const lib::array &bs) { - return all_impl(bs, 0); - } - - } // namespace detail - - template - inline constexpr DECLTYPE_AUTO visit(Visitor &&visitor, Vs &&... vs) - DECLTYPE_AUTO_RETURN( - (detail::all( - lib::array{{!vs.valueless_by_exception()...}}) - ? (void)0 - : throw_bad_variant_access()), - detail::visitation::variant::visit_value(lib::forward(visitor), - lib::forward(vs)...)) -#endif - - template - inline auto swap(variant &lhs, - variant &rhs) noexcept(noexcept(lhs.swap(rhs))) - -> decltype(lhs.swap(rhs)) { - lhs.swap(rhs); - } - - namespace detail { - - template - using enabled_type = T; - - namespace hash { - - template - constexpr bool meets_requirements() noexcept { - return std::is_copy_constructible::value && - std::is_move_constructible::value && - lib::is_invocable_r::value; - } - - template - constexpr bool is_enabled() noexcept { - using H = std::hash; - return meets_requirements() && - std::is_default_constructible::value && - std::is_copy_assignable::value && - std::is_move_assignable::value; - } - - } // namespace hash - - } // namespace detail - -#undef AUTO -#undef AUTO_RETURN - -#undef AUTO_REFREF -#undef AUTO_REFREF_RETURN - -#undef DECLTYPE_AUTO -#undef DECLTYPE_AUTO_RETURN - -} // namespace mpark - -namespace std { - - template - struct hash, - mpark::lib::enable_if_t>()...>::value>>> { - using argument_type = mpark::variant; - using result_type = std::size_t; - - inline result_type operator()(const argument_type &v) const { - using mpark::detail::visitation::variant; - std::size_t result = - v.valueless_by_exception() - ? 299792458 // Random value chosen by the universe upon creation - : variant::visit_alt( -#ifdef MPARK_GENERIC_LAMBDAS - [](const auto &alt) { - using alt_type = mpark::lib::decay_t; - using value_type = mpark::lib::remove_const_t< - typename alt_type::value_type>; - return hash{}(alt.value); - } -#else - hasher{} -#endif - , - v); - return hash_combine(result, hash{}(v.index())); - } - - private: -#ifndef MPARK_GENERIC_LAMBDAS - struct hasher { - template - inline std::size_t operator()(const Alt &alt) const { - using alt_type = mpark::lib::decay_t; - using value_type = - mpark::lib::remove_const_t; - return hash{}(alt.value); - } - }; -#endif - - static std::size_t hash_combine(std::size_t lhs, std::size_t rhs) { - return lhs ^= rhs + 0x9e3779b9 + (lhs << 6) + (lhs >> 2); - } - }; - - template <> - struct hash { - using argument_type = mpark::monostate; - using result_type = std::size_t; - - inline result_type operator()(const argument_type &) const noexcept { - return 66740831; // return a fundamentally attractive random value. - } - }; - -} // namespace std - -#endif // MPARK_VARIANT_HPP diff --git a/cpp/thirdparty/knowhere_build/include/arrow/visitor.h b/cpp/thirdparty/knowhere_build/include/arrow/visitor.h deleted file mode 100644 index a4979e9cef..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/visitor.h +++ /dev/null @@ -1,141 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#ifndef ARROW_VISITOR_H -#define ARROW_VISITOR_H - -#include "arrow/status.h" -#include "arrow/type_fwd.h" -#include "arrow/util/visibility.h" - -namespace arrow { - -class ARROW_EXPORT ArrayVisitor { - public: - virtual ~ArrayVisitor() = default; - - virtual Status Visit(const NullArray& array); - virtual Status Visit(const BooleanArray& array); - virtual Status Visit(const Int8Array& array); - virtual Status Visit(const Int16Array& array); - virtual Status Visit(const Int32Array& array); - virtual Status Visit(const Int64Array& array); - virtual Status Visit(const UInt8Array& array); - virtual Status Visit(const UInt16Array& array); - virtual Status Visit(const UInt32Array& array); - virtual Status Visit(const UInt64Array& array); - virtual Status Visit(const HalfFloatArray& array); - virtual Status Visit(const FloatArray& array); - virtual Status Visit(const DoubleArray& array); - virtual Status Visit(const StringArray& array); - virtual Status Visit(const BinaryArray& array); - virtual Status Visit(const FixedSizeBinaryArray& array); - virtual Status Visit(const Date32Array& array); - virtual Status Visit(const Date64Array& array); - virtual Status Visit(const Time32Array& array); - virtual Status Visit(const Time64Array& array); - virtual Status Visit(const TimestampArray& array); - virtual Status Visit(const DayTimeIntervalArray& array); - virtual Status Visit(const MonthIntervalArray& array); - virtual Status Visit(const DurationArray& array); - virtual Status Visit(const Decimal128Array& array); - virtual Status Visit(const ListArray& array); - virtual Status Visit(const MapArray& array); - virtual Status Visit(const FixedSizeListArray& array); - virtual Status Visit(const StructArray& array); - virtual Status Visit(const UnionArray& array); - virtual Status Visit(const DictionaryArray& array); - virtual Status Visit(const ExtensionArray& array); -}; - -class ARROW_EXPORT TypeVisitor { - public: - virtual ~TypeVisitor() = default; - - virtual Status Visit(const NullType& type); - virtual Status Visit(const BooleanType& type); - virtual Status Visit(const Int8Type& type); - virtual Status Visit(const Int16Type& type); - virtual Status Visit(const Int32Type& type); - virtual Status Visit(const Int64Type& type); - virtual Status Visit(const UInt8Type& type); - virtual Status Visit(const UInt16Type& type); - virtual Status Visit(const UInt32Type& type); - virtual Status Visit(const UInt64Type& type); - virtual Status Visit(const HalfFloatType& type); - virtual Status Visit(const FloatType& type); - virtual Status Visit(const DoubleType& type); - virtual Status Visit(const StringType& type); - virtual Status Visit(const BinaryType& type); - virtual Status Visit(const FixedSizeBinaryType& type); - virtual Status Visit(const Date64Type& type); - virtual Status Visit(const Date32Type& type); - virtual Status Visit(const Time32Type& type); - virtual Status Visit(const Time64Type& type); - virtual Status Visit(const TimestampType& type); - virtual Status Visit(const MonthIntervalType& type); - virtual Status Visit(const DayTimeIntervalType& type); - virtual Status Visit(const DurationType& type); - virtual Status Visit(const Decimal128Type& type); - virtual Status Visit(const ListType& type); - virtual Status Visit(const MapType& type); - virtual Status Visit(const FixedSizeListType& type); - virtual Status Visit(const StructType& type); - virtual Status Visit(const UnionType& type); - virtual Status Visit(const DictionaryType& type); - virtual Status Visit(const ExtensionType& type); -}; - -class ARROW_EXPORT ScalarVisitor { - public: - virtual ~ScalarVisitor() = default; - - virtual Status Visit(const NullScalar& scalar); - virtual Status Visit(const BooleanScalar& scalar); - virtual Status Visit(const Int8Scalar& scalar); - virtual Status Visit(const Int16Scalar& scalar); - virtual Status Visit(const Int32Scalar& scalar); - virtual Status Visit(const Int64Scalar& scalar); - virtual Status Visit(const UInt8Scalar& scalar); - virtual Status Visit(const UInt16Scalar& scalar); - virtual Status Visit(const UInt32Scalar& scalar); - virtual Status Visit(const UInt64Scalar& scalar); - virtual Status Visit(const HalfFloatScalar& scalar); - virtual Status Visit(const FloatScalar& scalar); - virtual Status Visit(const DoubleScalar& scalar); - virtual Status Visit(const StringScalar& scalar); - virtual Status Visit(const BinaryScalar& scalar); - virtual Status Visit(const FixedSizeBinaryScalar& scalar); - virtual Status Visit(const Date64Scalar& scalar); - virtual Status Visit(const Date32Scalar& scalar); - virtual Status Visit(const Time32Scalar& scalar); - virtual Status Visit(const Time64Scalar& scalar); - virtual Status Visit(const TimestampScalar& scalar); - virtual Status Visit(const DayTimeIntervalScalar& scalar); - virtual Status Visit(const MonthIntervalScalar& scalar); - virtual Status Visit(const DurationScalar& scalar); - virtual Status Visit(const Decimal128Scalar& scalar); - virtual Status Visit(const ListScalar& scalar); - virtual Status Visit(const MapScalar& scalar); - virtual Status Visit(const FixedSizeListScalar& scalar); - virtual Status Visit(const StructScalar& scalar); - virtual Status Visit(const DictionaryScalar& scalar); -}; - -} // namespace arrow - -#endif // ARROW_VISITOR_H diff --git a/cpp/thirdparty/knowhere_build/include/arrow/visitor_inline.h b/cpp/thirdparty/knowhere_build/include/arrow/visitor_inline.h deleted file mode 100644 index 544763a2f7..0000000000 --- a/cpp/thirdparty/knowhere_build/include/arrow/visitor_inline.h +++ /dev/null @@ -1,289 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// Private header, not to be exported - -#ifndef ARROW_VISITOR_INLINE_H -#define ARROW_VISITOR_INLINE_H - -#include "arrow/array.h" -#include "arrow/extension_type.h" -#include "arrow/scalar.h" -#include "arrow/status.h" -#include "arrow/type.h" -#include "arrow/util/bit-util.h" -#include "arrow/util/checked_cast.h" -#include "arrow/util/string_view.h" - -namespace arrow { - -#define ARROW_GENERATE_FOR_ALL_TYPES(ACTION) \ - ACTION(Null); \ - ACTION(Boolean); \ - ACTION(Int8); \ - ACTION(UInt8); \ - ACTION(Int16); \ - ACTION(UInt16); \ - ACTION(Int32); \ - ACTION(UInt32); \ - ACTION(Int64); \ - ACTION(UInt64); \ - ACTION(HalfFloat); \ - ACTION(Float); \ - ACTION(Double); \ - ACTION(String); \ - ACTION(Binary); \ - ACTION(FixedSizeBinary); \ - ACTION(Duration); \ - ACTION(Date32); \ - ACTION(Date64); \ - ACTION(Timestamp); \ - ACTION(Time32); \ - ACTION(Time64); \ - ACTION(Decimal128); \ - ACTION(List); \ - ACTION(Map); \ - ACTION(FixedSizeList); \ - ACTION(Struct); \ - ACTION(Union); \ - ACTION(Dictionary); \ - ACTION(Extension) - -#define TYPE_VISIT_INLINE(TYPE_CLASS) \ - case TYPE_CLASS##Type::type_id: \ - return visitor->Visit(internal::checked_cast(type)); - -template -inline Status VisitTypeInline(const DataType& type, VISITOR* visitor) { - switch (type.id()) { - ARROW_GENERATE_FOR_ALL_TYPES(TYPE_VISIT_INLINE); - case Type::INTERVAL: { - const auto& interval_type = dynamic_cast(type); - if (interval_type.interval_type() == IntervalType::MONTHS) { - return visitor->Visit(internal::checked_cast(type)); - } - if (interval_type.interval_type() == IntervalType::DAY_TIME) { - return visitor->Visit(internal::checked_cast(type)); - } - break; - } - default: - break; - } - return Status::NotImplemented("Type not implemented"); -} - -#undef TYPE_VISIT_INLINE - -#define ARRAY_VISIT_INLINE(TYPE_CLASS) \ - case TYPE_CLASS##Type::type_id: \ - return visitor->Visit( \ - internal::checked_cast::ArrayType&>( \ - array)); - -template -inline Status VisitArrayInline(const Array& array, VISITOR* visitor) { - switch (array.type_id()) { - ARROW_GENERATE_FOR_ALL_TYPES(ARRAY_VISIT_INLINE); - case Type::INTERVAL: { - const auto& interval_type = dynamic_cast(*array.type()); - if (interval_type.interval_type() == IntervalType::MONTHS) { - return visitor->Visit(internal::checked_cast(array)); - } - if (interval_type.interval_type() == IntervalType::DAY_TIME) { - return visitor->Visit(internal::checked_cast(array)); - } - break; - } - - default: - break; - } - return Status::NotImplemented("Type not implemented"); -} - -// Visit an array's data values, in order, without overhead. -// -// The Visit function's `visitor` argument should define two public methods: -// - Status VisitNull() -// - Status VisitValue() -// -// The scalar value's type depends on the array data type: -// - the type's `c_type`, if any -// - for boolean arrays, a `bool` -// - for binary, string and fixed-size binary arrays, a `util::string_view` - -template -struct ArrayDataVisitor {}; - -template <> -struct ArrayDataVisitor { - template - static Status Visit(const ArrayData& arr, Visitor* visitor) { - if (arr.null_count != 0) { - internal::BitmapReader valid_reader(arr.buffers[0]->data(), arr.offset, arr.length); - internal::BitmapReader value_reader(arr.buffers[1]->data(), arr.offset, arr.length); - for (int64_t i = 0; i < arr.length; ++i) { - const bool is_null = valid_reader.IsNotSet(); - if (is_null) { - ARROW_RETURN_NOT_OK(visitor->VisitNull()); - } else { - ARROW_RETURN_NOT_OK(visitor->VisitValue(value_reader.IsSet())); - } - valid_reader.Next(); - value_reader.Next(); - } - } else { - internal::BitmapReader value_reader(arr.buffers[1]->data(), arr.offset, arr.length); - for (int64_t i = 0; i < arr.length; ++i) { - ARROW_RETURN_NOT_OK(visitor->VisitValue(value_reader.IsSet())); - value_reader.Next(); - } - } - return Status::OK(); - } -}; - -template -struct ArrayDataVisitor> { - template - static Status Visit(const ArrayData& arr, Visitor* visitor) { - using c_type = typename T::c_type; - const c_type* data = arr.GetValues(1); - - if (arr.null_count != 0) { - internal::BitmapReader valid_reader(arr.buffers[0]->data(), arr.offset, arr.length); - for (int64_t i = 0; i < arr.length; ++i) { - const bool is_null = valid_reader.IsNotSet(); - if (is_null) { - ARROW_RETURN_NOT_OK(visitor->VisitNull()); - } else { - ARROW_RETURN_NOT_OK(visitor->VisitValue(data[i])); - } - valid_reader.Next(); - } - } else { - for (int64_t i = 0; i < arr.length; ++i) { - ARROW_RETURN_NOT_OK(visitor->VisitValue(data[i])); - } - } - return Status::OK(); - } -}; - -template -struct ArrayDataVisitor> { - template - static Status Visit(const ArrayData& arr, Visitor* visitor) { - constexpr uint8_t empty_value = 0; - - const int32_t* offsets = arr.GetValues(1); - const uint8_t* data; - if (!arr.buffers[2]) { - data = &empty_value; - } else { - data = arr.GetValues(2); - } - - if (arr.null_count != 0) { - internal::BitmapReader valid_reader(arr.buffers[0]->data(), arr.offset, arr.length); - for (int64_t i = 0; i < arr.length; ++i) { - const bool is_null = valid_reader.IsNotSet(); - valid_reader.Next(); - if (is_null) { - ARROW_RETURN_NOT_OK(visitor->VisitNull()); - } else { - auto value = util::string_view(reinterpret_cast(data + offsets[i]), - offsets[i + 1] - offsets[i]); - ARROW_RETURN_NOT_OK(visitor->VisitValue(value)); - } - } - } else { - for (int64_t i = 0; i < arr.length; ++i) { - auto value = util::string_view(reinterpret_cast(data + offsets[i]), - offsets[i + 1] - offsets[i]); - ARROW_RETURN_NOT_OK(visitor->VisitValue(value)); - } - } - return Status::OK(); - } -}; - -template -struct ArrayDataVisitor> { - template - static Status Visit(const ArrayData& arr, Visitor* visitor) { - const auto& fw_type = internal::checked_cast(*arr.type); - - const int32_t byte_width = fw_type.byte_width(); - const uint8_t* data = arr.GetValues(1); - - if (arr.null_count != 0) { - internal::BitmapReader valid_reader(arr.buffers[0]->data(), arr.offset, arr.length); - for (int64_t i = 0; i < arr.length; ++i) { - const bool is_null = valid_reader.IsNotSet(); - valid_reader.Next(); - if (is_null) { - ARROW_RETURN_NOT_OK(visitor->VisitNull()); - } else { - auto value = util::string_view(reinterpret_cast(data), byte_width); - ARROW_RETURN_NOT_OK(visitor->VisitValue(value)); - } - data += byte_width; - } - } else { - for (int64_t i = 0; i < arr.length; ++i) { - auto value = util::string_view(reinterpret_cast(data), byte_width); - ARROW_RETURN_NOT_OK(visitor->VisitValue(value)); - data += byte_width; - } - } - return Status::OK(); - } -}; - -#define SCALAR_VISIT_INLINE(TYPE_CLASS) \ - case TYPE_CLASS##Type::type_id: \ - return visitor->Visit(internal::checked_cast(scalar)); - -template -inline Status VisitScalarInline(const Scalar& scalar, VISITOR* visitor) { - switch (scalar.type->id()) { - ARROW_GENERATE_FOR_ALL_TYPES(SCALAR_VISIT_INLINE); - case Type::INTERVAL: { - const auto& interval_type = - internal::checked_cast(*scalar.type); - if (interval_type.interval_type() == IntervalType::MONTHS) { - return visitor->Visit(internal::checked_cast(scalar)); - } - if (interval_type.interval_type() == IntervalType::DAY_TIME) { - return visitor->Visit( - internal::checked_cast(scalar)); - } - } - default: - break; - } - return Status::NotImplemented("Scalar visitor for type not implemented ", - scalar.type->ToString()); -} - -#undef TYPE_VISIT_INLINE - -} // namespace arrow - -#endif // ARROW_VISITOR_INLINE_H diff --git a/cpp/thirdparty/knowhere_build/include/cblas.h b/cpp/thirdparty/knowhere_build/include/cblas.h deleted file mode 100644 index 1188811887..0000000000 --- a/cpp/thirdparty/knowhere_build/include/cblas.h +++ /dev/null @@ -1,385 +0,0 @@ -#ifndef CBLAS_H -#define CBLAS_H - -#include -#include "openblas_config.h" - -#ifdef __cplusplus -extern "C" { - /* Assume C declarations for C++ */ -#endif /* __cplusplus */ - -/*Set the number of threads on runtime.*/ -void openblas_set_num_threads(int num_threads); -void goto_set_num_threads(int num_threads); - -/*Get the number of threads on runtime.*/ -int openblas_get_num_threads(void); - -/*Get the number of physical processors (cores).*/ -int openblas_get_num_procs(void); - -/*Get the build configure on runtime.*/ -char* openblas_get_config(void); - -/*Get the CPU corename on runtime.*/ -char* openblas_get_corename(void); - -/* Get the parallelization type which is used by OpenBLAS */ -int openblas_get_parallel(void); -/* OpenBLAS is compiled for sequential use */ -#define OPENBLAS_SEQUENTIAL 0 -/* OpenBLAS is compiled using normal threading model */ -#define OPENBLAS_THREAD 1 -/* OpenBLAS is compiled using OpenMP threading model */ -#define OPENBLAS_OPENMP 2 - - -/* - * Since all of GotoBlas was written without const, - * we disable it at build time. - */ -#ifndef OPENBLAS_CONST -# define OPENBLAS_CONST const -#endif - - -#define CBLAS_INDEX size_t - -typedef enum CBLAS_ORDER {CblasRowMajor=101, CblasColMajor=102} CBLAS_ORDER; -typedef enum CBLAS_TRANSPOSE {CblasNoTrans=111, CblasTrans=112, CblasConjTrans=113, CblasConjNoTrans=114} CBLAS_TRANSPOSE; -typedef enum CBLAS_UPLO {CblasUpper=121, CblasLower=122} CBLAS_UPLO; -typedef enum CBLAS_DIAG {CblasNonUnit=131, CblasUnit=132} CBLAS_DIAG; -typedef enum CBLAS_SIDE {CblasLeft=141, CblasRight=142} CBLAS_SIDE; -typedef CBLAS_ORDER CBLAS_LAYOUT; - -float cblas_sdsdot(OPENBLAS_CONST blasint n, OPENBLAS_CONST float alpha, OPENBLAS_CONST float *x, OPENBLAS_CONST blasint incx, OPENBLAS_CONST float *y, OPENBLAS_CONST blasint incy); -double cblas_dsdot (OPENBLAS_CONST blasint n, OPENBLAS_CONST float *x, OPENBLAS_CONST blasint incx, OPENBLAS_CONST float *y, OPENBLAS_CONST blasint incy); -float cblas_sdot(OPENBLAS_CONST blasint n, OPENBLAS_CONST float *x, OPENBLAS_CONST blasint incx, OPENBLAS_CONST float *y, OPENBLAS_CONST blasint incy); -double cblas_ddot(OPENBLAS_CONST blasint n, OPENBLAS_CONST double *x, OPENBLAS_CONST blasint incx, OPENBLAS_CONST double *y, OPENBLAS_CONST blasint incy); - -openblas_complex_float cblas_cdotu(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx, OPENBLAS_CONST void *y, OPENBLAS_CONST blasint incy); -openblas_complex_float cblas_cdotc(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx, OPENBLAS_CONST void *y, OPENBLAS_CONST blasint incy); -openblas_complex_double cblas_zdotu(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx, OPENBLAS_CONST void *y, OPENBLAS_CONST blasint incy); -openblas_complex_double cblas_zdotc(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx, OPENBLAS_CONST void *y, OPENBLAS_CONST blasint incy); - -void cblas_cdotu_sub(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx, OPENBLAS_CONST void *y, OPENBLAS_CONST blasint incy, void *ret); -void cblas_cdotc_sub(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx, OPENBLAS_CONST void *y, OPENBLAS_CONST blasint incy, void *ret); -void cblas_zdotu_sub(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx, OPENBLAS_CONST void *y, OPENBLAS_CONST blasint incy, void *ret); -void cblas_zdotc_sub(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx, OPENBLAS_CONST void *y, OPENBLAS_CONST blasint incy, void *ret); - -float cblas_sasum (OPENBLAS_CONST blasint n, OPENBLAS_CONST float *x, OPENBLAS_CONST blasint incx); -double cblas_dasum (OPENBLAS_CONST blasint n, OPENBLAS_CONST double *x, OPENBLAS_CONST blasint incx); -float cblas_scasum(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx); -double cblas_dzasum(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx); - -float cblas_ssum (OPENBLAS_CONST blasint n, OPENBLAS_CONST float *x, OPENBLAS_CONST blasint incx); -double cblas_dsum (OPENBLAS_CONST blasint n, OPENBLAS_CONST double *x, OPENBLAS_CONST blasint incx); -float cblas_scsum(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx); -double cblas_dzsum(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx); - -float cblas_snrm2 (OPENBLAS_CONST blasint N, OPENBLAS_CONST float *X, OPENBLAS_CONST blasint incX); -double cblas_dnrm2 (OPENBLAS_CONST blasint N, OPENBLAS_CONST double *X, OPENBLAS_CONST blasint incX); -float cblas_scnrm2(OPENBLAS_CONST blasint N, OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX); -double cblas_dznrm2(OPENBLAS_CONST blasint N, OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX); - -CBLAS_INDEX cblas_isamax(OPENBLAS_CONST blasint n, OPENBLAS_CONST float *x, OPENBLAS_CONST blasint incx); -CBLAS_INDEX cblas_idamax(OPENBLAS_CONST blasint n, OPENBLAS_CONST double *x, OPENBLAS_CONST blasint incx); -CBLAS_INDEX cblas_icamax(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx); -CBLAS_INDEX cblas_izamax(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx); - -CBLAS_INDEX cblas_isamin(OPENBLAS_CONST blasint n, OPENBLAS_CONST float *x, OPENBLAS_CONST blasint incx); -CBLAS_INDEX cblas_idamin(OPENBLAS_CONST blasint n, OPENBLAS_CONST double *x, OPENBLAS_CONST blasint incx); -CBLAS_INDEX cblas_icamin(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx); -CBLAS_INDEX cblas_izamin(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx); - -CBLAS_INDEX cblas_ismax(OPENBLAS_CONST blasint n, OPENBLAS_CONST float *x, OPENBLAS_CONST blasint incx); -CBLAS_INDEX cblas_idmax(OPENBLAS_CONST blasint n, OPENBLAS_CONST double *x, OPENBLAS_CONST blasint incx); -CBLAS_INDEX cblas_icmax(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx); -CBLAS_INDEX cblas_izmax(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx); - -CBLAS_INDEX cblas_ismin(OPENBLAS_CONST blasint n, OPENBLAS_CONST float *x, OPENBLAS_CONST blasint incx); -CBLAS_INDEX cblas_idmin(OPENBLAS_CONST blasint n, OPENBLAS_CONST double *x, OPENBLAS_CONST blasint incx); -CBLAS_INDEX cblas_icmin(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx); -CBLAS_INDEX cblas_izmin(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx); - -void cblas_saxpy(OPENBLAS_CONST blasint n, OPENBLAS_CONST float alpha, OPENBLAS_CONST float *x, OPENBLAS_CONST blasint incx, float *y, OPENBLAS_CONST blasint incy); -void cblas_daxpy(OPENBLAS_CONST blasint n, OPENBLAS_CONST double alpha, OPENBLAS_CONST double *x, OPENBLAS_CONST blasint incx, double *y, OPENBLAS_CONST blasint incy); -void cblas_caxpy(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx, void *y, OPENBLAS_CONST blasint incy); -void cblas_zaxpy(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx, void *y, OPENBLAS_CONST blasint incy); - -void cblas_scopy(OPENBLAS_CONST blasint n, OPENBLAS_CONST float *x, OPENBLAS_CONST blasint incx, float *y, OPENBLAS_CONST blasint incy); -void cblas_dcopy(OPENBLAS_CONST blasint n, OPENBLAS_CONST double *x, OPENBLAS_CONST blasint incx, double *y, OPENBLAS_CONST blasint incy); -void cblas_ccopy(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx, void *y, OPENBLAS_CONST blasint incy); -void cblas_zcopy(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx, void *y, OPENBLAS_CONST blasint incy); - -void cblas_sswap(OPENBLAS_CONST blasint n, float *x, OPENBLAS_CONST blasint incx, float *y, OPENBLAS_CONST blasint incy); -void cblas_dswap(OPENBLAS_CONST blasint n, double *x, OPENBLAS_CONST blasint incx, double *y, OPENBLAS_CONST blasint incy); -void cblas_cswap(OPENBLAS_CONST blasint n, void *x, OPENBLAS_CONST blasint incx, void *y, OPENBLAS_CONST blasint incy); -void cblas_zswap(OPENBLAS_CONST blasint n, void *x, OPENBLAS_CONST blasint incx, void *y, OPENBLAS_CONST blasint incy); - -void cblas_srot(OPENBLAS_CONST blasint N, float *X, OPENBLAS_CONST blasint incX, float *Y, OPENBLAS_CONST blasint incY, OPENBLAS_CONST float c, OPENBLAS_CONST float s); -void cblas_drot(OPENBLAS_CONST blasint N, double *X, OPENBLAS_CONST blasint incX, double *Y, OPENBLAS_CONST blasint incY, OPENBLAS_CONST double c, OPENBLAS_CONST double s); - -void cblas_srotg(float *a, float *b, float *c, float *s); -void cblas_drotg(double *a, double *b, double *c, double *s); - -void cblas_srotm(OPENBLAS_CONST blasint N, float *X, OPENBLAS_CONST blasint incX, float *Y, OPENBLAS_CONST blasint incY, OPENBLAS_CONST float *P); -void cblas_drotm(OPENBLAS_CONST blasint N, double *X, OPENBLAS_CONST blasint incX, double *Y, OPENBLAS_CONST blasint incY, OPENBLAS_CONST double *P); - -void cblas_srotmg(float *d1, float *d2, float *b1, OPENBLAS_CONST float b2, float *P); -void cblas_drotmg(double *d1, double *d2, double *b1, OPENBLAS_CONST double b2, double *P); - -void cblas_sscal(OPENBLAS_CONST blasint N, OPENBLAS_CONST float alpha, float *X, OPENBLAS_CONST blasint incX); -void cblas_dscal(OPENBLAS_CONST blasint N, OPENBLAS_CONST double alpha, double *X, OPENBLAS_CONST blasint incX); -void cblas_cscal(OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, void *X, OPENBLAS_CONST blasint incX); -void cblas_zscal(OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, void *X, OPENBLAS_CONST blasint incX); -void cblas_csscal(OPENBLAS_CONST blasint N, OPENBLAS_CONST float alpha, void *X, OPENBLAS_CONST blasint incX); -void cblas_zdscal(OPENBLAS_CONST blasint N, OPENBLAS_CONST double alpha, void *X, OPENBLAS_CONST blasint incX); - -void cblas_sgemv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_TRANSPOSE trans, OPENBLAS_CONST blasint m, OPENBLAS_CONST blasint n, - OPENBLAS_CONST float alpha, OPENBLAS_CONST float *a, OPENBLAS_CONST blasint lda, OPENBLAS_CONST float *x, OPENBLAS_CONST blasint incx, OPENBLAS_CONST float beta, float *y, OPENBLAS_CONST blasint incy); -void cblas_dgemv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_TRANSPOSE trans, OPENBLAS_CONST blasint m, OPENBLAS_CONST blasint n, - OPENBLAS_CONST double alpha, OPENBLAS_CONST double *a, OPENBLAS_CONST blasint lda, OPENBLAS_CONST double *x, OPENBLAS_CONST blasint incx, OPENBLAS_CONST double beta, double *y, OPENBLAS_CONST blasint incy); -void cblas_cgemv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_TRANSPOSE trans, OPENBLAS_CONST blasint m, OPENBLAS_CONST blasint n, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *a, OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx, OPENBLAS_CONST void *beta, void *y, OPENBLAS_CONST blasint incy); -void cblas_zgemv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_TRANSPOSE trans, OPENBLAS_CONST blasint m, OPENBLAS_CONST blasint n, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *a, OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx, OPENBLAS_CONST void *beta, void *y, OPENBLAS_CONST blasint incy); - -void cblas_sger (OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, OPENBLAS_CONST float alpha, OPENBLAS_CONST float *X, OPENBLAS_CONST blasint incX, OPENBLAS_CONST float *Y, OPENBLAS_CONST blasint incY, float *A, OPENBLAS_CONST blasint lda); -void cblas_dger (OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, OPENBLAS_CONST double alpha, OPENBLAS_CONST double *X, OPENBLAS_CONST blasint incX, OPENBLAS_CONST double *Y, OPENBLAS_CONST blasint incY, double *A, OPENBLAS_CONST blasint lda); -void cblas_cgeru(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, OPENBLAS_CONST void *Y, OPENBLAS_CONST blasint incY, void *A, OPENBLAS_CONST blasint lda); -void cblas_cgerc(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, OPENBLAS_CONST void *Y, OPENBLAS_CONST blasint incY, void *A, OPENBLAS_CONST blasint lda); -void cblas_zgeru(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, OPENBLAS_CONST void *Y, OPENBLAS_CONST blasint incY, void *A, OPENBLAS_CONST blasint lda); -void cblas_zgerc(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, OPENBLAS_CONST void *Y, OPENBLAS_CONST blasint incY, void *A, OPENBLAS_CONST blasint lda); - -void cblas_strsv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, OPENBLAS_CONST float *A, OPENBLAS_CONST blasint lda, float *X, OPENBLAS_CONST blasint incX); -void cblas_dtrsv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, OPENBLAS_CONST double *A, OPENBLAS_CONST blasint lda, double *X, OPENBLAS_CONST blasint incX); -void cblas_ctrsv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, void *X, OPENBLAS_CONST blasint incX); -void cblas_ztrsv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, void *X, OPENBLAS_CONST blasint incX); - -void cblas_strmv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, OPENBLAS_CONST float *A, OPENBLAS_CONST blasint lda, float *X, OPENBLAS_CONST blasint incX); -void cblas_dtrmv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, OPENBLAS_CONST double *A, OPENBLAS_CONST blasint lda, double *X, OPENBLAS_CONST blasint incX); -void cblas_ctrmv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, void *X, OPENBLAS_CONST blasint incX); -void cblas_ztrmv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, void *X, OPENBLAS_CONST blasint incX); - -void cblas_ssyr(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST float alpha, OPENBLAS_CONST float *X, OPENBLAS_CONST blasint incX, float *A, OPENBLAS_CONST blasint lda); -void cblas_dsyr(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST double alpha, OPENBLAS_CONST double *X, OPENBLAS_CONST blasint incX, double *A, OPENBLAS_CONST blasint lda); -void cblas_cher(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST float alpha, OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, void *A, OPENBLAS_CONST blasint lda); -void cblas_zher(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST double alpha, OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, void *A, OPENBLAS_CONST blasint lda); - -void cblas_ssyr2(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo,OPENBLAS_CONST blasint N, OPENBLAS_CONST float alpha, OPENBLAS_CONST float *X, - OPENBLAS_CONST blasint incX, OPENBLAS_CONST float *Y, OPENBLAS_CONST blasint incY, float *A, OPENBLAS_CONST blasint lda); -void cblas_dsyr2(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST double alpha, OPENBLAS_CONST double *X, - OPENBLAS_CONST blasint incX, OPENBLAS_CONST double *Y, OPENBLAS_CONST blasint incY, double *A, OPENBLAS_CONST blasint lda); -void cblas_cher2(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, - OPENBLAS_CONST void *Y, OPENBLAS_CONST blasint incY, void *A, OPENBLAS_CONST blasint lda); -void cblas_zher2(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, - OPENBLAS_CONST void *Y, OPENBLAS_CONST blasint incY, void *A, OPENBLAS_CONST blasint lda); - -void cblas_sgbmv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST blasint KL, OPENBLAS_CONST blasint KU, OPENBLAS_CONST float alpha, OPENBLAS_CONST float *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST float *X, OPENBLAS_CONST blasint incX, OPENBLAS_CONST float beta, float *Y, OPENBLAS_CONST blasint incY); -void cblas_dgbmv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST blasint KL, OPENBLAS_CONST blasint KU, OPENBLAS_CONST double alpha, OPENBLAS_CONST double *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST double *X, OPENBLAS_CONST blasint incX, OPENBLAS_CONST double beta, double *Y, OPENBLAS_CONST blasint incY); -void cblas_cgbmv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST blasint KL, OPENBLAS_CONST blasint KU, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, OPENBLAS_CONST void *beta, void *Y, OPENBLAS_CONST blasint incY); -void cblas_zgbmv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST blasint KL, OPENBLAS_CONST blasint KU, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, OPENBLAS_CONST void *beta, void *Y, OPENBLAS_CONST blasint incY); - -void cblas_ssbmv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, OPENBLAS_CONST float alpha, OPENBLAS_CONST float *A, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST float *X, OPENBLAS_CONST blasint incX, OPENBLAS_CONST float beta, float *Y, OPENBLAS_CONST blasint incY); -void cblas_dsbmv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, OPENBLAS_CONST double alpha, OPENBLAS_CONST double *A, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST double *X, OPENBLAS_CONST blasint incX, OPENBLAS_CONST double beta, double *Y, OPENBLAS_CONST blasint incY); - - -void cblas_stbmv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, OPENBLAS_CONST float *A, OPENBLAS_CONST blasint lda, float *X, OPENBLAS_CONST blasint incX); -void cblas_dtbmv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, OPENBLAS_CONST double *A, OPENBLAS_CONST blasint lda, double *X, OPENBLAS_CONST blasint incX); -void cblas_ctbmv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, void *X, OPENBLAS_CONST blasint incX); -void cblas_ztbmv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, void *X, OPENBLAS_CONST blasint incX); - -void cblas_stbsv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, OPENBLAS_CONST float *A, OPENBLAS_CONST blasint lda, float *X, OPENBLAS_CONST blasint incX); -void cblas_dtbsv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, OPENBLAS_CONST double *A, OPENBLAS_CONST blasint lda, double *X, OPENBLAS_CONST blasint incX); -void cblas_ctbsv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, void *X, OPENBLAS_CONST blasint incX); -void cblas_ztbsv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, void *X, OPENBLAS_CONST blasint incX); - -void cblas_stpmv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST float *Ap, float *X, OPENBLAS_CONST blasint incX); -void cblas_dtpmv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST double *Ap, double *X, OPENBLAS_CONST blasint incX); -void cblas_ctpmv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST void *Ap, void *X, OPENBLAS_CONST blasint incX); -void cblas_ztpmv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST void *Ap, void *X, OPENBLAS_CONST blasint incX); - -void cblas_stpsv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST float *Ap, float *X, OPENBLAS_CONST blasint incX); -void cblas_dtpsv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST double *Ap, double *X, OPENBLAS_CONST blasint incX); -void cblas_ctpsv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST void *Ap, void *X, OPENBLAS_CONST blasint incX); -void cblas_ztpsv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST void *Ap, void *X, OPENBLAS_CONST blasint incX); - -void cblas_ssymv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST float alpha, OPENBLAS_CONST float *A, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST float *X, OPENBLAS_CONST blasint incX, OPENBLAS_CONST float beta, float *Y, OPENBLAS_CONST blasint incY); -void cblas_dsymv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST double alpha, OPENBLAS_CONST double *A, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST double *X, OPENBLAS_CONST blasint incX, OPENBLAS_CONST double beta, double *Y, OPENBLAS_CONST blasint incY); -void cblas_chemv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, OPENBLAS_CONST void *beta, void *Y, OPENBLAS_CONST blasint incY); -void cblas_zhemv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, OPENBLAS_CONST void *beta, void *Y, OPENBLAS_CONST blasint incY); - - -void cblas_sspmv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST float alpha, OPENBLAS_CONST float *Ap, - OPENBLAS_CONST float *X, OPENBLAS_CONST blasint incX, OPENBLAS_CONST float beta, float *Y, OPENBLAS_CONST blasint incY); -void cblas_dspmv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST double alpha, OPENBLAS_CONST double *Ap, - OPENBLAS_CONST double *X, OPENBLAS_CONST blasint incX, OPENBLAS_CONST double beta, double *Y, OPENBLAS_CONST blasint incY); - -void cblas_sspr(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST float alpha, OPENBLAS_CONST float *X, OPENBLAS_CONST blasint incX, float *Ap); -void cblas_dspr(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST double alpha, OPENBLAS_CONST double *X, OPENBLAS_CONST blasint incX, double *Ap); - -void cblas_chpr(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST float alpha, OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, void *A); -void cblas_zhpr(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST double alpha, OPENBLAS_CONST void *X,OPENBLAS_CONST blasint incX, void *A); - -void cblas_sspr2(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST float alpha, OPENBLAS_CONST float *X, OPENBLAS_CONST blasint incX, OPENBLAS_CONST float *Y, OPENBLAS_CONST blasint incY, float *A); -void cblas_dspr2(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST double alpha, OPENBLAS_CONST double *X, OPENBLAS_CONST blasint incX, OPENBLAS_CONST double *Y, OPENBLAS_CONST blasint incY, double *A); -void cblas_chpr2(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, OPENBLAS_CONST void *Y, OPENBLAS_CONST blasint incY, void *Ap); -void cblas_zhpr2(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, OPENBLAS_CONST void *Y, OPENBLAS_CONST blasint incY, void *Ap); - -void cblas_chbmv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, OPENBLAS_CONST void *beta, void *Y, OPENBLAS_CONST blasint incY); -void cblas_zhbmv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, OPENBLAS_CONST void *beta, void *Y, OPENBLAS_CONST blasint incY); - -void cblas_chpmv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *Ap, OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, OPENBLAS_CONST void *beta, void *Y, OPENBLAS_CONST blasint incY); -void cblas_zhpmv(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *Ap, OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, OPENBLAS_CONST void *beta, void *Y, OPENBLAS_CONST blasint incY); - -void cblas_sgemm(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST float alpha, OPENBLAS_CONST float *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST float *B, OPENBLAS_CONST blasint ldb, OPENBLAS_CONST float beta, float *C, OPENBLAS_CONST blasint ldc); -void cblas_dgemm(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST double alpha, OPENBLAS_CONST double *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST double *B, OPENBLAS_CONST blasint ldb, OPENBLAS_CONST double beta, double *C, OPENBLAS_CONST blasint ldc); -void cblas_cgemm(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *B, OPENBLAS_CONST blasint ldb, OPENBLAS_CONST void *beta, void *C, OPENBLAS_CONST blasint ldc); -void cblas_cgemm3m(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *B, OPENBLAS_CONST blasint ldb, OPENBLAS_CONST void *beta, void *C, OPENBLAS_CONST blasint ldc); -void cblas_zgemm(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *B, OPENBLAS_CONST blasint ldb, OPENBLAS_CONST void *beta, void *C, OPENBLAS_CONST blasint ldc); -void cblas_zgemm3m(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *B, OPENBLAS_CONST blasint ldb, OPENBLAS_CONST void *beta, void *C, OPENBLAS_CONST blasint ldc); - - -void cblas_ssymm(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_SIDE Side, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST float alpha, OPENBLAS_CONST float *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST float *B, OPENBLAS_CONST blasint ldb, OPENBLAS_CONST float beta, float *C, OPENBLAS_CONST blasint ldc); -void cblas_dsymm(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_SIDE Side, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST double alpha, OPENBLAS_CONST double *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST double *B, OPENBLAS_CONST blasint ldb, OPENBLAS_CONST double beta, double *C, OPENBLAS_CONST blasint ldc); -void cblas_csymm(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_SIDE Side, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *B, OPENBLAS_CONST blasint ldb, OPENBLAS_CONST void *beta, void *C, OPENBLAS_CONST blasint ldc); -void cblas_zsymm(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_SIDE Side, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *B, OPENBLAS_CONST blasint ldb, OPENBLAS_CONST void *beta, void *C, OPENBLAS_CONST blasint ldc); - -void cblas_ssyrk(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, OPENBLAS_CONST float alpha, OPENBLAS_CONST float *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST float beta, float *C, OPENBLAS_CONST blasint ldc); -void cblas_dsyrk(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, OPENBLAS_CONST double alpha, OPENBLAS_CONST double *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST double beta, double *C, OPENBLAS_CONST blasint ldc); -void cblas_csyrk(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *beta, void *C, OPENBLAS_CONST blasint ldc); -void cblas_zsyrk(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *beta, void *C, OPENBLAS_CONST blasint ldc); - -void cblas_ssyr2k(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, OPENBLAS_CONST float alpha, OPENBLAS_CONST float *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST float *B, OPENBLAS_CONST blasint ldb, OPENBLAS_CONST float beta, float *C, OPENBLAS_CONST blasint ldc); -void cblas_dsyr2k(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, OPENBLAS_CONST double alpha, OPENBLAS_CONST double *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST double *B, OPENBLAS_CONST blasint ldb, OPENBLAS_CONST double beta, double *C, OPENBLAS_CONST blasint ldc); -void cblas_csyr2k(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *B, OPENBLAS_CONST blasint ldb, OPENBLAS_CONST void *beta, void *C, OPENBLAS_CONST blasint ldc); -void cblas_zsyr2k(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *B, OPENBLAS_CONST blasint ldb, OPENBLAS_CONST void *beta, void *C, OPENBLAS_CONST blasint ldc); - -void cblas_strmm(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_SIDE Side, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, OPENBLAS_CONST float alpha, OPENBLAS_CONST float *A, OPENBLAS_CONST blasint lda, float *B, OPENBLAS_CONST blasint ldb); -void cblas_dtrmm(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_SIDE Side, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, OPENBLAS_CONST double alpha, OPENBLAS_CONST double *A, OPENBLAS_CONST blasint lda, double *B, OPENBLAS_CONST blasint ldb); -void cblas_ctrmm(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_SIDE Side, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, void *B, OPENBLAS_CONST blasint ldb); -void cblas_ztrmm(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_SIDE Side, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, void *B, OPENBLAS_CONST blasint ldb); - -void cblas_strsm(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_SIDE Side, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, OPENBLAS_CONST float alpha, OPENBLAS_CONST float *A, OPENBLAS_CONST blasint lda, float *B, OPENBLAS_CONST blasint ldb); -void cblas_dtrsm(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_SIDE Side, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, OPENBLAS_CONST double alpha, OPENBLAS_CONST double *A, OPENBLAS_CONST blasint lda, double *B, OPENBLAS_CONST blasint ldb); -void cblas_ctrsm(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_SIDE Side, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, void *B, OPENBLAS_CONST blasint ldb); -void cblas_ztrsm(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_SIDE Side, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, void *B, OPENBLAS_CONST blasint ldb); - -void cblas_chemm(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_SIDE Side, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *B, OPENBLAS_CONST blasint ldb, OPENBLAS_CONST void *beta, void *C, OPENBLAS_CONST blasint ldc); -void cblas_zhemm(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_SIDE Side, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *B, OPENBLAS_CONST blasint ldb, OPENBLAS_CONST void *beta, void *C, OPENBLAS_CONST blasint ldc); - -void cblas_cherk(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST float alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST float beta, void *C, OPENBLAS_CONST blasint ldc); -void cblas_zherk(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST double alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST double beta, void *C, OPENBLAS_CONST blasint ldc); - -void cblas_cher2k(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *B, OPENBLAS_CONST blasint ldb, OPENBLAS_CONST float beta, void *C, OPENBLAS_CONST blasint ldc); -void cblas_zher2k(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *B, OPENBLAS_CONST blasint ldb, OPENBLAS_CONST double beta, void *C, OPENBLAS_CONST blasint ldc); - -void cblas_xerbla(blasint p, char *rout, char *form, ...); - -/*** BLAS extensions ***/ - -void cblas_saxpby(OPENBLAS_CONST blasint n, OPENBLAS_CONST float alpha, OPENBLAS_CONST float *x, OPENBLAS_CONST blasint incx,OPENBLAS_CONST float beta, float *y, OPENBLAS_CONST blasint incy); - -void cblas_daxpby(OPENBLAS_CONST blasint n, OPENBLAS_CONST double alpha, OPENBLAS_CONST double *x, OPENBLAS_CONST blasint incx,OPENBLAS_CONST double beta, double *y, OPENBLAS_CONST blasint incy); - -void cblas_caxpby(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx,OPENBLAS_CONST void *beta, void *y, OPENBLAS_CONST blasint incy); - -void cblas_zaxpby(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx,OPENBLAS_CONST void *beta, void *y, OPENBLAS_CONST blasint incy); - -void cblas_somatcopy(OPENBLAS_CONST enum CBLAS_ORDER CORDER, OPENBLAS_CONST enum CBLAS_TRANSPOSE CTRANS, OPENBLAS_CONST blasint crows, OPENBLAS_CONST blasint ccols, OPENBLAS_CONST float calpha, OPENBLAS_CONST float *a, - OPENBLAS_CONST blasint clda, float *b, OPENBLAS_CONST blasint cldb); -void cblas_domatcopy(OPENBLAS_CONST enum CBLAS_ORDER CORDER, OPENBLAS_CONST enum CBLAS_TRANSPOSE CTRANS, OPENBLAS_CONST blasint crows, OPENBLAS_CONST blasint ccols, OPENBLAS_CONST double calpha, OPENBLAS_CONST double *a, - OPENBLAS_CONST blasint clda, double *b, OPENBLAS_CONST blasint cldb); -void cblas_comatcopy(OPENBLAS_CONST enum CBLAS_ORDER CORDER, OPENBLAS_CONST enum CBLAS_TRANSPOSE CTRANS, OPENBLAS_CONST blasint crows, OPENBLAS_CONST blasint ccols, OPENBLAS_CONST float* calpha, OPENBLAS_CONST float* a, - OPENBLAS_CONST blasint clda, float*b, OPENBLAS_CONST blasint cldb); -void cblas_zomatcopy(OPENBLAS_CONST enum CBLAS_ORDER CORDER, OPENBLAS_CONST enum CBLAS_TRANSPOSE CTRANS, OPENBLAS_CONST blasint crows, OPENBLAS_CONST blasint ccols, OPENBLAS_CONST double* calpha, OPENBLAS_CONST double* a, - OPENBLAS_CONST blasint clda, double *b, OPENBLAS_CONST blasint cldb); - -void cblas_simatcopy(OPENBLAS_CONST enum CBLAS_ORDER CORDER, OPENBLAS_CONST enum CBLAS_TRANSPOSE CTRANS, OPENBLAS_CONST blasint crows, OPENBLAS_CONST blasint ccols, OPENBLAS_CONST float calpha, float *a, - OPENBLAS_CONST blasint clda, OPENBLAS_CONST blasint cldb); -void cblas_dimatcopy(OPENBLAS_CONST enum CBLAS_ORDER CORDER, OPENBLAS_CONST enum CBLAS_TRANSPOSE CTRANS, OPENBLAS_CONST blasint crows, OPENBLAS_CONST blasint ccols, OPENBLAS_CONST double calpha, double *a, - OPENBLAS_CONST blasint clda, OPENBLAS_CONST blasint cldb); -void cblas_cimatcopy(OPENBLAS_CONST enum CBLAS_ORDER CORDER, OPENBLAS_CONST enum CBLAS_TRANSPOSE CTRANS, OPENBLAS_CONST blasint crows, OPENBLAS_CONST blasint ccols, OPENBLAS_CONST float* calpha, float* a, - OPENBLAS_CONST blasint clda, OPENBLAS_CONST blasint cldb); -void cblas_zimatcopy(OPENBLAS_CONST enum CBLAS_ORDER CORDER, OPENBLAS_CONST enum CBLAS_TRANSPOSE CTRANS, OPENBLAS_CONST blasint crows, OPENBLAS_CONST blasint ccols, OPENBLAS_CONST double* calpha, double* a, - OPENBLAS_CONST blasint clda, OPENBLAS_CONST blasint cldb); - -void cblas_sgeadd(OPENBLAS_CONST enum CBLAS_ORDER CORDER,OPENBLAS_CONST blasint crows, OPENBLAS_CONST blasint ccols, OPENBLAS_CONST float calpha, float *a, OPENBLAS_CONST blasint clda, OPENBLAS_CONST float cbeta, - float *c, OPENBLAS_CONST blasint cldc); -void cblas_dgeadd(OPENBLAS_CONST enum CBLAS_ORDER CORDER,OPENBLAS_CONST blasint crows, OPENBLAS_CONST blasint ccols, OPENBLAS_CONST double calpha, double *a, OPENBLAS_CONST blasint clda, OPENBLAS_CONST double cbeta, - double *c, OPENBLAS_CONST blasint cldc); -void cblas_cgeadd(OPENBLAS_CONST enum CBLAS_ORDER CORDER,OPENBLAS_CONST blasint crows, OPENBLAS_CONST blasint ccols, OPENBLAS_CONST float *calpha, float *a, OPENBLAS_CONST blasint clda, OPENBLAS_CONST float *cbeta, - float *c, OPENBLAS_CONST blasint cldc); -void cblas_zgeadd(OPENBLAS_CONST enum CBLAS_ORDER CORDER,OPENBLAS_CONST blasint crows, OPENBLAS_CONST blasint ccols, OPENBLAS_CONST double *calpha, double *a, OPENBLAS_CONST blasint clda, OPENBLAS_CONST double *cbeta, - double *c, OPENBLAS_CONST blasint cldc); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/f77blas.h b/cpp/thirdparty/knowhere_build/include/f77blas.h deleted file mode 100644 index f5ced3e0b2..0000000000 --- a/cpp/thirdparty/knowhere_build/include/f77blas.h +++ /dev/null @@ -1,779 +0,0 @@ -#ifndef OPENBLAS_F77BLAS_H -#define OPENBLAS_F77BLAS_H -#include "openblas_config.h" -/*********************************************************************/ -/* Copyright 2009, 2010 The University of Texas at Austin. */ -/* All rights reserved. */ -/* */ -/* Redistribution and use in source and binary forms, with or */ -/* without modification, are permitted provided that the following */ -/* conditions are met: */ -/* */ -/* 1. Redistributions of source code must retain the above */ -/* copyright notice, this list of conditions and the following */ -/* disclaimer. */ -/* */ -/* 2. Redistributions in binary form must reproduce the above */ -/* copyright notice, this list of conditions and the following */ -/* disclaimer in the documentation and/or other materials */ -/* provided with the distribution. */ -/* */ -/* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */ -/* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */ -/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */ -/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */ -/* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */ -/* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */ -/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */ -/* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */ -/* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */ -/* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */ -/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ -/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */ -/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ -/* POSSIBILITY OF SUCH DAMAGE. */ -/* */ -/* The views and conclusions contained in the software and */ -/* documentation are those of the authors and should not be */ -/* interpreted as representing official policies, either expressed */ -/* or implied, of The University of Texas at Austin. */ -/*********************************************************************/ - -#ifndef ASSEMBLER - -#ifdef __cplusplus -extern "C" { - /* Assume C declarations for C++ */ -#endif /* __cplusplus */ - -int BLASFUNC(xerbla)(char *, blasint *info, blasint); - -void openblas_set_num_threads_(int *); - -FLOATRET BLASFUNC(sdot) (blasint *, float *, blasint *, float *, blasint *); -FLOATRET BLASFUNC(sdsdot)(blasint *, float *, float *, blasint *, float *, blasint *); - -double BLASFUNC(dsdot) (blasint *, float *, blasint *, float *, blasint *); -double BLASFUNC(ddot) (blasint *, double *, blasint *, double *, blasint *); -xdouble BLASFUNC(qdot) (blasint *, xdouble *, blasint *, xdouble *, blasint *); - - -#ifdef RETURN_BY_STRUCT -typedef struct { - float r, i; -} myccomplex_t; - -typedef struct { - double r, i; -} myzcomplex_t; - -typedef struct { - xdouble r, i; -} myxcomplex_t; - -myccomplex_t BLASFUNC(cdotu) (blasint *, float *, blasint *, float *, blasint *); -myccomplex_t BLASFUNC(cdotc) (blasint *, float *, blasint *, float *, blasint *); -myzcomplex_t BLASFUNC(zdotu) (blasint *, double *, blasint *, double *, blasint *); -myzcomplex_t BLASFUNC(zdotc) (blasint *, double *, blasint *, double *, blasint *); -myxcomplex_t BLASFUNC(xdotu) (blasint *, xdouble *, blasint *, xdouble *, blasint *); -myxcomplex_t BLASFUNC(xdotc) (blasint *, xdouble *, blasint *, xdouble *, blasint *); - -#elif defined RETURN_BY_STACK -void BLASFUNC(cdotu) (openblas_complex_float *, blasint *, float * , blasint *, float *, blasint *); -void BLASFUNC(cdotc) (openblas_complex_float *, blasint *, float *, blasint *, float *, blasint *); -void BLASFUNC(zdotu) (openblas_complex_double *, blasint *, double *, blasint *, double *, blasint *); -void BLASFUNC(zdotc) (openblas_complex_double *, blasint *, double *, blasint *, double *, blasint *); -void BLASFUNC(xdotu) (openblas_complex_xdouble *, blasint *, xdouble *, blasint *, xdouble *, blasint *); -void BLASFUNC(xdotc) (openblas_complex_xdouble *, blasint *, xdouble *, blasint *, xdouble *, blasint *); -#else -openblas_complex_float BLASFUNC(cdotu) (blasint *, float *, blasint *, float *, blasint *); -openblas_complex_float BLASFUNC(cdotc) (blasint *, float *, blasint *, float *, blasint *); -openblas_complex_double BLASFUNC(zdotu) (blasint *, double *, blasint *, double *, blasint *); -openblas_complex_double BLASFUNC(zdotc) (blasint *, double *, blasint *, double *, blasint *); -openblas_complex_xdouble BLASFUNC(xdotu) (blasint *, xdouble *, blasint *, xdouble *, blasint *); -openblas_complex_xdouble BLASFUNC(xdotc) (blasint *, xdouble *, blasint *, xdouble *, blasint *); -#endif - -void BLASFUNC(saxpy) (blasint *, float *, float *, blasint *, float *, blasint *); -void BLASFUNC(daxpy) (blasint *, double *, double *, blasint *, double *, blasint *); -void BLASFUNC(qaxpy) (blasint *, xdouble *, xdouble *, blasint *, xdouble *, blasint *); -void BLASFUNC(caxpy) (blasint *, float *, float *, blasint *, float *, blasint *); -void BLASFUNC(zaxpy) (blasint *, double *, double *, blasint *, double *, blasint *); -void BLASFUNC(xaxpy) (blasint *, xdouble *, xdouble *, blasint *, xdouble *, blasint *); -void BLASFUNC(caxpyc)(blasint *, float *, float *, blasint *, float *, blasint *); -void BLASFUNC(zaxpyc)(blasint *, double *, double *, blasint *, double *, blasint *); -void BLASFUNC(xaxpyc)(blasint *, xdouble *, xdouble *, blasint *, xdouble *, blasint *); - -void BLASFUNC(scopy) (blasint *, float *, blasint *, float *, blasint *); -void BLASFUNC(dcopy) (blasint *, double *, blasint *, double *, blasint *); -void BLASFUNC(qcopy) (blasint *, xdouble *, blasint *, xdouble *, blasint *); -void BLASFUNC(ccopy) (blasint *, float *, blasint *, float *, blasint *); -void BLASFUNC(zcopy) (blasint *, double *, blasint *, double *, blasint *); -void BLASFUNC(xcopy) (blasint *, xdouble *, blasint *, xdouble *, blasint *); - -void BLASFUNC(sswap) (blasint *, float *, blasint *, float *, blasint *); -void BLASFUNC(dswap) (blasint *, double *, blasint *, double *, blasint *); -void BLASFUNC(qswap) (blasint *, xdouble *, blasint *, xdouble *, blasint *); -void BLASFUNC(cswap) (blasint *, float *, blasint *, float *, blasint *); -void BLASFUNC(zswap) (blasint *, double *, blasint *, double *, blasint *); -void BLASFUNC(xswap) (blasint *, xdouble *, blasint *, xdouble *, blasint *); - -FLOATRET BLASFUNC(sasum) (blasint *, float *, blasint *); -FLOATRET BLASFUNC(scasum)(blasint *, float *, blasint *); -double BLASFUNC(dasum) (blasint *, double *, blasint *); -xdouble BLASFUNC(qasum) (blasint *, xdouble *, blasint *); -double BLASFUNC(dzasum)(blasint *, double *, blasint *); -xdouble BLASFUNC(qxasum)(blasint *, xdouble *, blasint *); - -FLOATRET BLASFUNC(ssum) (blasint *, float *, blasint *); -FLOATRET BLASFUNC(scsum)(blasint *, float *, blasint *); -double BLASFUNC(dsum) (blasint *, double *, blasint *); -xdouble BLASFUNC(qsum) (blasint *, xdouble *, blasint *); -double BLASFUNC(dzsum)(blasint *, double *, blasint *); -xdouble BLASFUNC(qxsum)(blasint *, xdouble *, blasint *); - -blasint BLASFUNC(isamax)(blasint *, float *, blasint *); -blasint BLASFUNC(idamax)(blasint *, double *, blasint *); -blasint BLASFUNC(iqamax)(blasint *, xdouble *, blasint *); -blasint BLASFUNC(icamax)(blasint *, float *, blasint *); -blasint BLASFUNC(izamax)(blasint *, double *, blasint *); -blasint BLASFUNC(ixamax)(blasint *, xdouble *, blasint *); - -blasint BLASFUNC(ismax) (blasint *, float *, blasint *); -blasint BLASFUNC(idmax) (blasint *, double *, blasint *); -blasint BLASFUNC(iqmax) (blasint *, xdouble *, blasint *); -blasint BLASFUNC(icmax) (blasint *, float *, blasint *); -blasint BLASFUNC(izmax) (blasint *, double *, blasint *); -blasint BLASFUNC(ixmax) (blasint *, xdouble *, blasint *); - -blasint BLASFUNC(isamin)(blasint *, float *, blasint *); -blasint BLASFUNC(idamin)(blasint *, double *, blasint *); -blasint BLASFUNC(iqamin)(blasint *, xdouble *, blasint *); -blasint BLASFUNC(icamin)(blasint *, float *, blasint *); -blasint BLASFUNC(izamin)(blasint *, double *, blasint *); -blasint BLASFUNC(ixamin)(blasint *, xdouble *, blasint *); - -blasint BLASFUNC(ismin)(blasint *, float *, blasint *); -blasint BLASFUNC(idmin)(blasint *, double *, blasint *); -blasint BLASFUNC(iqmin)(blasint *, xdouble *, blasint *); -blasint BLASFUNC(icmin)(blasint *, float *, blasint *); -blasint BLASFUNC(izmin)(blasint *, double *, blasint *); -blasint BLASFUNC(ixmin)(blasint *, xdouble *, blasint *); - -FLOATRET BLASFUNC(samax) (blasint *, float *, blasint *); -double BLASFUNC(damax) (blasint *, double *, blasint *); -xdouble BLASFUNC(qamax) (blasint *, xdouble *, blasint *); -FLOATRET BLASFUNC(scamax)(blasint *, float *, blasint *); -double BLASFUNC(dzamax)(blasint *, double *, blasint *); -xdouble BLASFUNC(qxamax)(blasint *, xdouble *, blasint *); - -FLOATRET BLASFUNC(samin) (blasint *, float *, blasint *); -double BLASFUNC(damin) (blasint *, double *, blasint *); -xdouble BLASFUNC(qamin) (blasint *, xdouble *, blasint *); -FLOATRET BLASFUNC(scamin)(blasint *, float *, blasint *); -double BLASFUNC(dzamin)(blasint *, double *, blasint *); -xdouble BLASFUNC(qxamin)(blasint *, xdouble *, blasint *); - -FLOATRET BLASFUNC(smax) (blasint *, float *, blasint *); -double BLASFUNC(dmax) (blasint *, double *, blasint *); -xdouble BLASFUNC(qmax) (blasint *, xdouble *, blasint *); -FLOATRET BLASFUNC(scmax) (blasint *, float *, blasint *); -double BLASFUNC(dzmax) (blasint *, double *, blasint *); -xdouble BLASFUNC(qxmax) (blasint *, xdouble *, blasint *); - -FLOATRET BLASFUNC(smin) (blasint *, float *, blasint *); -double BLASFUNC(dmin) (blasint *, double *, blasint *); -xdouble BLASFUNC(qmin) (blasint *, xdouble *, blasint *); -FLOATRET BLASFUNC(scmin) (blasint *, float *, blasint *); -double BLASFUNC(dzmin) (blasint *, double *, blasint *); -xdouble BLASFUNC(qxmin) (blasint *, xdouble *, blasint *); - -void BLASFUNC(sscal) (blasint *, float *, float *, blasint *); -void BLASFUNC(dscal) (blasint *, double *, double *, blasint *); -void BLASFUNC(qscal) (blasint *, xdouble *, xdouble *, blasint *); -void BLASFUNC(cscal) (blasint *, float *, float *, blasint *); -void BLASFUNC(zscal) (blasint *, double *, double *, blasint *); -void BLASFUNC(xscal) (blasint *, xdouble *, xdouble *, blasint *); -void BLASFUNC(csscal)(blasint *, float *, float *, blasint *); -void BLASFUNC(zdscal)(blasint *, double *, double *, blasint *); -void BLASFUNC(xqscal)(blasint *, xdouble *, xdouble *, blasint *); - -FLOATRET BLASFUNC(snrm2) (blasint *, float *, blasint *); -FLOATRET BLASFUNC(scnrm2)(blasint *, float *, blasint *); - -double BLASFUNC(dnrm2) (blasint *, double *, blasint *); -xdouble BLASFUNC(qnrm2) (blasint *, xdouble *, blasint *); -double BLASFUNC(dznrm2)(blasint *, double *, blasint *); -xdouble BLASFUNC(qxnrm2)(blasint *, xdouble *, blasint *); - -void BLASFUNC(srot) (blasint *, float *, blasint *, float *, blasint *, float *, float *); -void BLASFUNC(drot) (blasint *, double *, blasint *, double *, blasint *, double *, double *); -void BLASFUNC(qrot) (blasint *, xdouble *, blasint *, xdouble *, blasint *, xdouble *, xdouble *); -void BLASFUNC(csrot) (blasint *, float *, blasint *, float *, blasint *, float *, float *); -void BLASFUNC(zdrot) (blasint *, double *, blasint *, double *, blasint *, double *, double *); -void BLASFUNC(xqrot) (blasint *, xdouble *, blasint *, xdouble *, blasint *, xdouble *, xdouble *); - -void BLASFUNC(srotg) (float *, float *, float *, float *); -void BLASFUNC(drotg) (double *, double *, double *, double *); -void BLASFUNC(qrotg) (xdouble *, xdouble *, xdouble *, xdouble *); -void BLASFUNC(crotg) (float *, float *, float *, float *); -void BLASFUNC(zrotg) (double *, double *, double *, double *); -void BLASFUNC(xrotg) (xdouble *, xdouble *, xdouble *, xdouble *); - -void BLASFUNC(srotmg)(float *, float *, float *, float *, float *); -void BLASFUNC(drotmg)(double *, double *, double *, double *, double *); - -void BLASFUNC(srotm) (blasint *, float *, blasint *, float *, blasint *, float *); -void BLASFUNC(drotm) (blasint *, double *, blasint *, double *, blasint *, double *); -void BLASFUNC(qrotm) (blasint *, xdouble *, blasint *, xdouble *, blasint *, xdouble *); - -/* Level 2 routines */ - -void BLASFUNC(sger)(blasint *, blasint *, float *, float *, blasint *, - float *, blasint *, float *, blasint *); -void BLASFUNC(dger)(blasint *, blasint *, double *, double *, blasint *, - double *, blasint *, double *, blasint *); -void BLASFUNC(qger)(blasint *, blasint *, xdouble *, xdouble *, blasint *, - xdouble *, blasint *, xdouble *, blasint *); -void BLASFUNC(cgeru)(blasint *, blasint *, float *, float *, blasint *, - float *, blasint *, float *, blasint *); -void BLASFUNC(cgerc)(blasint *, blasint *, float *, float *, blasint *, - float *, blasint *, float *, blasint *); -void BLASFUNC(zgeru)(blasint *, blasint *, double *, double *, blasint *, - double *, blasint *, double *, blasint *); -void BLASFUNC(zgerc)(blasint *, blasint *, double *, double *, blasint *, - double *, blasint *, double *, blasint *); -void BLASFUNC(xgeru)(blasint *, blasint *, xdouble *, xdouble *, blasint *, - xdouble *, blasint *, xdouble *, blasint *); -void BLASFUNC(xgerc)(blasint *, blasint *, xdouble *, xdouble *, blasint *, - xdouble *, blasint *, xdouble *, blasint *); - -void BLASFUNC(sgemv)(char *, blasint *, blasint *, float *, float *, blasint *, - float *, blasint *, float *, float *, blasint *); -void BLASFUNC(dgemv)(char *, blasint *, blasint *, double *, double *, blasint *, - double *, blasint *, double *, double *, blasint *); -void BLASFUNC(qgemv)(char *, blasint *, blasint *, xdouble *, xdouble *, blasint *, - xdouble *, blasint *, xdouble *, xdouble *, blasint *); -void BLASFUNC(cgemv)(char *, blasint *, blasint *, float *, float *, blasint *, - float *, blasint *, float *, float *, blasint *); -void BLASFUNC(zgemv)(char *, blasint *, blasint *, double *, double *, blasint *, - double *, blasint *, double *, double *, blasint *); -void BLASFUNC(xgemv)(char *, blasint *, blasint *, xdouble *, xdouble *, blasint *, - xdouble *, blasint *, xdouble *, xdouble *, blasint *); - -void BLASFUNC(strsv) (char *, char *, char *, blasint *, float *, blasint *, - float *, blasint *); -void BLASFUNC(dtrsv) (char *, char *, char *, blasint *, double *, blasint *, - double *, blasint *); -void BLASFUNC(qtrsv) (char *, char *, char *, blasint *, xdouble *, blasint *, - xdouble *, blasint *); -void BLASFUNC(ctrsv) (char *, char *, char *, blasint *, float *, blasint *, - float *, blasint *); -void BLASFUNC(ztrsv) (char *, char *, char *, blasint *, double *, blasint *, - double *, blasint *); -void BLASFUNC(xtrsv) (char *, char *, char *, blasint *, xdouble *, blasint *, - xdouble *, blasint *); - -void BLASFUNC(strmv) (char *, char *, char *, blasint *, float *, blasint *, - float *, blasint *); -void BLASFUNC(dtrmv) (char *, char *, char *, blasint *, double *, blasint *, - double *, blasint *); -void BLASFUNC(qtrmv) (char *, char *, char *, blasint *, xdouble *, blasint *, - xdouble *, blasint *); -void BLASFUNC(ctrmv) (char *, char *, char *, blasint *, float *, blasint *, - float *, blasint *); -void BLASFUNC(ztrmv) (char *, char *, char *, blasint *, double *, blasint *, - double *, blasint *); -void BLASFUNC(xtrmv) (char *, char *, char *, blasint *, xdouble *, blasint *, - xdouble *, blasint *); - -void BLASFUNC(stpsv) (char *, char *, char *, blasint *, float *, float *, blasint *); -void BLASFUNC(dtpsv) (char *, char *, char *, blasint *, double *, double *, blasint *); -void BLASFUNC(qtpsv) (char *, char *, char *, blasint *, xdouble *, xdouble *, blasint *); -void BLASFUNC(ctpsv) (char *, char *, char *, blasint *, float *, float *, blasint *); -void BLASFUNC(ztpsv) (char *, char *, char *, blasint *, double *, double *, blasint *); -void BLASFUNC(xtpsv) (char *, char *, char *, blasint *, xdouble *, xdouble *, blasint *); - -void BLASFUNC(stpmv) (char *, char *, char *, blasint *, float *, float *, blasint *); -void BLASFUNC(dtpmv) (char *, char *, char *, blasint *, double *, double *, blasint *); -void BLASFUNC(qtpmv) (char *, char *, char *, blasint *, xdouble *, xdouble *, blasint *); -void BLASFUNC(ctpmv) (char *, char *, char *, blasint *, float *, float *, blasint *); -void BLASFUNC(ztpmv) (char *, char *, char *, blasint *, double *, double *, blasint *); -void BLASFUNC(xtpmv) (char *, char *, char *, blasint *, xdouble *, xdouble *, blasint *); - -void BLASFUNC(stbmv) (char *, char *, char *, blasint *, blasint *, float *, blasint *, float *, blasint *); -void BLASFUNC(dtbmv) (char *, char *, char *, blasint *, blasint *, double *, blasint *, double *, blasint *); -void BLASFUNC(qtbmv) (char *, char *, char *, blasint *, blasint *, xdouble *, blasint *, xdouble *, blasint *); -void BLASFUNC(ctbmv) (char *, char *, char *, blasint *, blasint *, float *, blasint *, float *, blasint *); -void BLASFUNC(ztbmv) (char *, char *, char *, blasint *, blasint *, double *, blasint *, double *, blasint *); -void BLASFUNC(xtbmv) (char *, char *, char *, blasint *, blasint *, xdouble *, blasint *, xdouble *, blasint *); - -void BLASFUNC(stbsv) (char *, char *, char *, blasint *, blasint *, float *, blasint *, float *, blasint *); -void BLASFUNC(dtbsv) (char *, char *, char *, blasint *, blasint *, double *, blasint *, double *, blasint *); -void BLASFUNC(qtbsv) (char *, char *, char *, blasint *, blasint *, xdouble *, blasint *, xdouble *, blasint *); -void BLASFUNC(ctbsv) (char *, char *, char *, blasint *, blasint *, float *, blasint *, float *, blasint *); -void BLASFUNC(ztbsv) (char *, char *, char *, blasint *, blasint *, double *, blasint *, double *, blasint *); -void BLASFUNC(xtbsv) (char *, char *, char *, blasint *, blasint *, xdouble *, blasint *, xdouble *, blasint *); - -void BLASFUNC(ssymv) (char *, blasint *, float *, float *, blasint *, - float *, blasint *, float *, float *, blasint *); -void BLASFUNC(dsymv) (char *, blasint *, double *, double *, blasint *, - double *, blasint *, double *, double *, blasint *); -void BLASFUNC(qsymv) (char *, blasint *, xdouble *, xdouble *, blasint *, - xdouble *, blasint *, xdouble *, xdouble *, blasint *); -void BLASFUNC(csymv) (char *, blasint *, float *, float *, blasint *, - float *, blasint *, float *, float *, blasint *); -void BLASFUNC(zsymv) (char *, blasint *, double *, double *, blasint *, - double *, blasint *, double *, double *, blasint *); -void BLASFUNC(xsymv) (char *, blasint *, xdouble *, xdouble *, blasint *, - xdouble *, blasint *, xdouble *, xdouble *, blasint *); - -void BLASFUNC(sspmv) (char *, blasint *, float *, float *, - float *, blasint *, float *, float *, blasint *); -void BLASFUNC(dspmv) (char *, blasint *, double *, double *, - double *, blasint *, double *, double *, blasint *); -void BLASFUNC(qspmv) (char *, blasint *, xdouble *, xdouble *, - xdouble *, blasint *, xdouble *, xdouble *, blasint *); -void BLASFUNC(cspmv) (char *, blasint *, float *, float *, - float *, blasint *, float *, float *, blasint *); -void BLASFUNC(zspmv) (char *, blasint *, double *, double *, - double *, blasint *, double *, double *, blasint *); -void BLASFUNC(xspmv) (char *, blasint *, xdouble *, xdouble *, - xdouble *, blasint *, xdouble *, xdouble *, blasint *); - -void BLASFUNC(ssyr) (char *, blasint *, float *, float *, blasint *, - float *, blasint *); -void BLASFUNC(dsyr) (char *, blasint *, double *, double *, blasint *, - double *, blasint *); -void BLASFUNC(qsyr) (char *, blasint *, xdouble *, xdouble *, blasint *, - xdouble *, blasint *); -void BLASFUNC(csyr) (char *, blasint *, float *, float *, blasint *, - float *, blasint *); -void BLASFUNC(zsyr) (char *, blasint *, double *, double *, blasint *, - double *, blasint *); -void BLASFUNC(xsyr) (char *, blasint *, xdouble *, xdouble *, blasint *, - xdouble *, blasint *); - -void BLASFUNC(ssyr2) (char *, blasint *, float *, - float *, blasint *, float *, blasint *, float *, blasint *); -void BLASFUNC(dsyr2) (char *, blasint *, double *, - double *, blasint *, double *, blasint *, double *, blasint *); -void BLASFUNC(qsyr2) (char *, blasint *, xdouble *, - xdouble *, blasint *, xdouble *, blasint *, xdouble *, blasint *); -void BLASFUNC(csyr2) (char *, blasint *, float *, - float *, blasint *, float *, blasint *, float *, blasint *); -void BLASFUNC(zsyr2) (char *, blasint *, double *, - double *, blasint *, double *, blasint *, double *, blasint *); -void BLASFUNC(xsyr2) (char *, blasint *, xdouble *, - xdouble *, blasint *, xdouble *, blasint *, xdouble *, blasint *); - -void BLASFUNC(sspr) (char *, blasint *, float *, float *, blasint *, - float *); -void BLASFUNC(dspr) (char *, blasint *, double *, double *, blasint *, - double *); -void BLASFUNC(qspr) (char *, blasint *, xdouble *, xdouble *, blasint *, - xdouble *); -void BLASFUNC(cspr) (char *, blasint *, float *, float *, blasint *, - float *); -void BLASFUNC(zspr) (char *, blasint *, double *, double *, blasint *, - double *); -void BLASFUNC(xspr) (char *, blasint *, xdouble *, xdouble *, blasint *, - xdouble *); - -void BLASFUNC(sspr2) (char *, blasint *, float *, - float *, blasint *, float *, blasint *, float *); -void BLASFUNC(dspr2) (char *, blasint *, double *, - double *, blasint *, double *, blasint *, double *); -void BLASFUNC(qspr2) (char *, blasint *, xdouble *, - xdouble *, blasint *, xdouble *, blasint *, xdouble *); -void BLASFUNC(cspr2) (char *, blasint *, float *, - float *, blasint *, float *, blasint *, float *); -void BLASFUNC(zspr2) (char *, blasint *, double *, - double *, blasint *, double *, blasint *, double *); -void BLASFUNC(xspr2) (char *, blasint *, xdouble *, - xdouble *, blasint *, xdouble *, blasint *, xdouble *); - -void BLASFUNC(cher) (char *, blasint *, float *, float *, blasint *, - float *, blasint *); -void BLASFUNC(zher) (char *, blasint *, double *, double *, blasint *, - double *, blasint *); -void BLASFUNC(xher) (char *, blasint *, xdouble *, xdouble *, blasint *, - xdouble *, blasint *); - -void BLASFUNC(chpr) (char *, blasint *, float *, float *, blasint *, float *); -void BLASFUNC(zhpr) (char *, blasint *, double *, double *, blasint *, double *); -void BLASFUNC(xhpr) (char *, blasint *, xdouble *, xdouble *, blasint *, xdouble *); - -void BLASFUNC(cher2) (char *, blasint *, float *, - float *, blasint *, float *, blasint *, float *, blasint *); -void BLASFUNC(zher2) (char *, blasint *, double *, - double *, blasint *, double *, blasint *, double *, blasint *); -void BLASFUNC(xher2) (char *, blasint *, xdouble *, - xdouble *, blasint *, xdouble *, blasint *, xdouble *, blasint *); - -void BLASFUNC(chpr2) (char *, blasint *, float *, - float *, blasint *, float *, blasint *, float *); -void BLASFUNC(zhpr2) (char *, blasint *, double *, - double *, blasint *, double *, blasint *, double *); -void BLASFUNC(xhpr2) (char *, blasint *, xdouble *, - xdouble *, blasint *, xdouble *, blasint *, xdouble *); - -void BLASFUNC(chemv) (char *, blasint *, float *, float *, blasint *, - float *, blasint *, float *, float *, blasint *); -void BLASFUNC(zhemv) (char *, blasint *, double *, double *, blasint *, - double *, blasint *, double *, double *, blasint *); -void BLASFUNC(xhemv) (char *, blasint *, xdouble *, xdouble *, blasint *, - xdouble *, blasint *, xdouble *, xdouble *, blasint *); - -void BLASFUNC(chpmv) (char *, blasint *, float *, float *, - float *, blasint *, float *, float *, blasint *); -void BLASFUNC(zhpmv) (char *, blasint *, double *, double *, - double *, blasint *, double *, double *, blasint *); -void BLASFUNC(xhpmv) (char *, blasint *, xdouble *, xdouble *, - xdouble *, blasint *, xdouble *, xdouble *, blasint *); - -int BLASFUNC(snorm)(char *, blasint *, blasint *, float *, blasint *); -int BLASFUNC(dnorm)(char *, blasint *, blasint *, double *, blasint *); -int BLASFUNC(cnorm)(char *, blasint *, blasint *, float *, blasint *); -int BLASFUNC(znorm)(char *, blasint *, blasint *, double *, blasint *); - -void BLASFUNC(sgbmv)(char *, blasint *, blasint *, blasint *, blasint *, float *, float *, blasint *, - float *, blasint *, float *, float *, blasint *); -void BLASFUNC(dgbmv)(char *, blasint *, blasint *, blasint *, blasint *, double *, double *, blasint *, - double *, blasint *, double *, double *, blasint *); -void BLASFUNC(qgbmv)(char *, blasint *, blasint *, blasint *, blasint *, xdouble *, xdouble *, blasint *, - xdouble *, blasint *, xdouble *, xdouble *, blasint *); -void BLASFUNC(cgbmv)(char *, blasint *, blasint *, blasint *, blasint *, float *, float *, blasint *, - float *, blasint *, float *, float *, blasint *); -void BLASFUNC(zgbmv)(char *, blasint *, blasint *, blasint *, blasint *, double *, double *, blasint *, - double *, blasint *, double *, double *, blasint *); -void BLASFUNC(xgbmv)(char *, blasint *, blasint *, blasint *, blasint *, xdouble *, xdouble *, blasint *, - xdouble *, blasint *, xdouble *, xdouble *, blasint *); - -void BLASFUNC(ssbmv)(char *, blasint *, blasint *, float *, float *, blasint *, - float *, blasint *, float *, float *, blasint *); -void BLASFUNC(dsbmv)(char *, blasint *, blasint *, double *, double *, blasint *, - double *, blasint *, double *, double *, blasint *); -void BLASFUNC(qsbmv)(char *, blasint *, blasint *, xdouble *, xdouble *, blasint *, - xdouble *, blasint *, xdouble *, xdouble *, blasint *); -void BLASFUNC(csbmv)(char *, blasint *, blasint *, float *, float *, blasint *, - float *, blasint *, float *, float *, blasint *); -void BLASFUNC(zsbmv)(char *, blasint *, blasint *, double *, double *, blasint *, - double *, blasint *, double *, double *, blasint *); -void BLASFUNC(xsbmv)(char *, blasint *, blasint *, xdouble *, xdouble *, blasint *, - xdouble *, blasint *, xdouble *, xdouble *, blasint *); - -void BLASFUNC(chbmv)(char *, blasint *, blasint *, float *, float *, blasint *, - float *, blasint *, float *, float *, blasint *); -void BLASFUNC(zhbmv)(char *, blasint *, blasint *, double *, double *, blasint *, - double *, blasint *, double *, double *, blasint *); -void BLASFUNC(xhbmv)(char *, blasint *, blasint *, xdouble *, xdouble *, blasint *, - xdouble *, blasint *, xdouble *, xdouble *, blasint *); - -/* Level 3 routines */ - -void BLASFUNC(sgemm)(char *, char *, blasint *, blasint *, blasint *, float *, - float *, blasint *, float *, blasint *, float *, float *, blasint *); -void BLASFUNC(dgemm)(char *, char *, blasint *, blasint *, blasint *, double *, - double *, blasint *, double *, blasint *, double *, double *, blasint *); -void BLASFUNC(qgemm)(char *, char *, blasint *, blasint *, blasint *, xdouble *, - xdouble *, blasint *, xdouble *, blasint *, xdouble *, xdouble *, blasint *); -void BLASFUNC(cgemm)(char *, char *, blasint *, blasint *, blasint *, float *, - float *, blasint *, float *, blasint *, float *, float *, blasint *); -void BLASFUNC(zgemm)(char *, char *, blasint *, blasint *, blasint *, double *, - double *, blasint *, double *, blasint *, double *, double *, blasint *); -void BLASFUNC(xgemm)(char *, char *, blasint *, blasint *, blasint *, xdouble *, - xdouble *, blasint *, xdouble *, blasint *, xdouble *, xdouble *, blasint *); - -void BLASFUNC(cgemm3m)(char *, char *, blasint *, blasint *, blasint *, float *, - float *, blasint *, float *, blasint *, float *, float *, blasint *); -void BLASFUNC(zgemm3m)(char *, char *, blasint *, blasint *, blasint *, double *, - double *, blasint *, double *, blasint *, double *, double *, blasint *); -void BLASFUNC(xgemm3m)(char *, char *, blasint *, blasint *, blasint *, xdouble *, - xdouble *, blasint *, xdouble *, blasint *, xdouble *, xdouble *, blasint *); - -int BLASFUNC(sge2mm)(char *, char *, char *, blasint *, blasint *, - float *, float *, blasint *, float *, blasint *, - float *, float *, blasint *); -int BLASFUNC(dge2mm)(char *, char *, char *, blasint *, blasint *, - double *, double *, blasint *, double *, blasint *, - double *, double *, blasint *); -int BLASFUNC(cge2mm)(char *, char *, char *, blasint *, blasint *, - float *, float *, blasint *, float *, blasint *, - float *, float *, blasint *); -int BLASFUNC(zge2mm)(char *, char *, char *, blasint *, blasint *, - double *, double *, blasint *, double *, blasint *, - double *, double *, blasint *); - -void BLASFUNC(strsm)(char *, char *, char *, char *, blasint *, blasint *, - float *, float *, blasint *, float *, blasint *); -void BLASFUNC(dtrsm)(char *, char *, char *, char *, blasint *, blasint *, - double *, double *, blasint *, double *, blasint *); -void BLASFUNC(qtrsm)(char *, char *, char *, char *, blasint *, blasint *, - xdouble *, xdouble *, blasint *, xdouble *, blasint *); -void BLASFUNC(ctrsm)(char *, char *, char *, char *, blasint *, blasint *, - float *, float *, blasint *, float *, blasint *); -void BLASFUNC(ztrsm)(char *, char *, char *, char *, blasint *, blasint *, - double *, double *, blasint *, double *, blasint *); -void BLASFUNC(xtrsm)(char *, char *, char *, char *, blasint *, blasint *, - xdouble *, xdouble *, blasint *, xdouble *, blasint *); - -void BLASFUNC(strmm)(char *, char *, char *, char *, blasint *, blasint *, - float *, float *, blasint *, float *, blasint *); -void BLASFUNC(dtrmm)(char *, char *, char *, char *, blasint *, blasint *, - double *, double *, blasint *, double *, blasint *); -void BLASFUNC(qtrmm)(char *, char *, char *, char *, blasint *, blasint *, - xdouble *, xdouble *, blasint *, xdouble *, blasint *); -void BLASFUNC(ctrmm)(char *, char *, char *, char *, blasint *, blasint *, - float *, float *, blasint *, float *, blasint *); -void BLASFUNC(ztrmm)(char *, char *, char *, char *, blasint *, blasint *, - double *, double *, blasint *, double *, blasint *); -void BLASFUNC(xtrmm)(char *, char *, char *, char *, blasint *, blasint *, - xdouble *, xdouble *, blasint *, xdouble *, blasint *); - -void BLASFUNC(ssymm)(char *, char *, blasint *, blasint *, float *, float *, blasint *, - float *, blasint *, float *, float *, blasint *); -void BLASFUNC(dsymm)(char *, char *, blasint *, blasint *, double *, double *, blasint *, - double *, blasint *, double *, double *, blasint *); -void BLASFUNC(qsymm)(char *, char *, blasint *, blasint *, xdouble *, xdouble *, blasint *, - xdouble *, blasint *, xdouble *, xdouble *, blasint *); -void BLASFUNC(csymm)(char *, char *, blasint *, blasint *, float *, float *, blasint *, - float *, blasint *, float *, float *, blasint *); -void BLASFUNC(zsymm)(char *, char *, blasint *, blasint *, double *, double *, blasint *, - double *, blasint *, double *, double *, blasint *); -void BLASFUNC(xsymm)(char *, char *, blasint *, blasint *, xdouble *, xdouble *, blasint *, - xdouble *, blasint *, xdouble *, xdouble *, blasint *); - -void BLASFUNC(csymm3m)(char *, char *, blasint *, blasint *, float *, float *, blasint *, - float *, blasint *, float *, float *, blasint *); -void BLASFUNC(zsymm3m)(char *, char *, blasint *, blasint *, double *, double *, blasint *, - double *, blasint *, double *, double *, blasint *); -void BLASFUNC(xsymm3m)(char *, char *, blasint *, blasint *, xdouble *, xdouble *, blasint *, - xdouble *, blasint *, xdouble *, xdouble *, blasint *); - -void BLASFUNC(ssyrk)(char *, char *, blasint *, blasint *, float *, float *, blasint *, - float *, float *, blasint *); -void BLASFUNC(dsyrk)(char *, char *, blasint *, blasint *, double *, double *, blasint *, - double *, double *, blasint *); -void BLASFUNC(qsyrk)(char *, char *, blasint *, blasint *, xdouble *, xdouble *, blasint *, - xdouble *, xdouble *, blasint *); -void BLASFUNC(csyrk)(char *, char *, blasint *, blasint *, float *, float *, blasint *, - float *, float *, blasint *); -void BLASFUNC(zsyrk)(char *, char *, blasint *, blasint *, double *, double *, blasint *, - double *, double *, blasint *); -void BLASFUNC(xsyrk)(char *, char *, blasint *, blasint *, xdouble *, xdouble *, blasint *, - xdouble *, xdouble *, blasint *); - -void BLASFUNC(ssyr2k)(char *, char *, blasint *, blasint *, float *, float *, blasint *, - float *, blasint *, float *, float *, blasint *); -void BLASFUNC(dsyr2k)(char *, char *, blasint *, blasint *, double *, double *, blasint *, - double*, blasint *, double *, double *, blasint *); -void BLASFUNC(qsyr2k)(char *, char *, blasint *, blasint *, xdouble *, xdouble *, blasint *, - xdouble*, blasint *, xdouble *, xdouble *, blasint *); -void BLASFUNC(csyr2k)(char *, char *, blasint *, blasint *, float *, float *, blasint *, - float *, blasint *, float *, float *, blasint *); -void BLASFUNC(zsyr2k)(char *, char *, blasint *, blasint *, double *, double *, blasint *, - double*, blasint *, double *, double *, blasint *); -void BLASFUNC(xsyr2k)(char *, char *, blasint *, blasint *, xdouble *, xdouble *, blasint *, - xdouble*, blasint *, xdouble *, xdouble *, blasint *); - -void BLASFUNC(chemm)(char *, char *, blasint *, blasint *, float *, float *, blasint *, - float *, blasint *, float *, float *, blasint *); -void BLASFUNC(zhemm)(char *, char *, blasint *, blasint *, double *, double *, blasint *, - double *, blasint *, double *, double *, blasint *); -void BLASFUNC(xhemm)(char *, char *, blasint *, blasint *, xdouble *, xdouble *, blasint *, - xdouble *, blasint *, xdouble *, xdouble *, blasint *); - -void BLASFUNC(chemm3m)(char *, char *, blasint *, blasint *, float *, float *, blasint *, - float *, blasint *, float *, float *, blasint *); -void BLASFUNC(zhemm3m)(char *, char *, blasint *, blasint *, double *, double *, blasint *, - double *, blasint *, double *, double *, blasint *); -void BLASFUNC(xhemm3m)(char *, char *, blasint *, blasint *, xdouble *, xdouble *, blasint *, - xdouble *, blasint *, xdouble *, xdouble *, blasint *); - -void BLASFUNC(cherk)(char *, char *, blasint *, blasint *, float *, float *, blasint *, - float *, float *, blasint *); -void BLASFUNC(zherk)(char *, char *, blasint *, blasint *, double *, double *, blasint *, - double *, double *, blasint *); -void BLASFUNC(xherk)(char *, char *, blasint *, blasint *, xdouble *, xdouble *, blasint *, - xdouble *, xdouble *, blasint *); - -void BLASFUNC(cher2k)(char *, char *, blasint *, blasint *, float *, float *, blasint *, - float *, blasint *, float *, float *, blasint *); -void BLASFUNC(zher2k)(char *, char *, blasint *, blasint *, double *, double *, blasint *, - double*, blasint *, double *, double *, blasint *); -void BLASFUNC(xher2k)(char *, char *, blasint *, blasint *, xdouble *, xdouble *, blasint *, - xdouble*, blasint *, xdouble *, xdouble *, blasint *); - -int BLASFUNC(cher2m)(char *, char *, char *, blasint *, blasint *, float *, float *, blasint *, - float *, blasint *, float *, float *, blasint *); -int BLASFUNC(zher2m)(char *, char *, char *, blasint *, blasint *, double *, double *, blasint *, - double*, blasint *, double *, double *, blasint *); -int BLASFUNC(xher2m)(char *, char *, char *, blasint *, blasint *, xdouble *, xdouble *, blasint *, - xdouble*, blasint *, xdouble *, xdouble *, blasint *); - -int BLASFUNC(sgemt)(char *, blasint *, blasint *, float *, float *, blasint *, - float *, blasint *); -int BLASFUNC(dgemt)(char *, blasint *, blasint *, double *, double *, blasint *, - double *, blasint *); -int BLASFUNC(cgemt)(char *, blasint *, blasint *, float *, float *, blasint *, - float *, blasint *); -int BLASFUNC(zgemt)(char *, blasint *, blasint *, double *, double *, blasint *, - double *, blasint *); - -int BLASFUNC(sgema)(char *, char *, blasint *, blasint *, float *, - float *, blasint *, float *, float *, blasint *, float *, blasint *); -int BLASFUNC(dgema)(char *, char *, blasint *, blasint *, double *, - double *, blasint *, double*, double *, blasint *, double*, blasint *); -int BLASFUNC(cgema)(char *, char *, blasint *, blasint *, float *, - float *, blasint *, float *, float *, blasint *, float *, blasint *); -int BLASFUNC(zgema)(char *, char *, blasint *, blasint *, double *, - double *, blasint *, double*, double *, blasint *, double*, blasint *); - -int BLASFUNC(sgems)(char *, char *, blasint *, blasint *, float *, - float *, blasint *, float *, float *, blasint *, float *, blasint *); -int BLASFUNC(dgems)(char *, char *, blasint *, blasint *, double *, - double *, blasint *, double*, double *, blasint *, double*, blasint *); -int BLASFUNC(cgems)(char *, char *, blasint *, blasint *, float *, - float *, blasint *, float *, float *, blasint *, float *, blasint *); -int BLASFUNC(zgems)(char *, char *, blasint *, blasint *, double *, - double *, blasint *, double*, double *, blasint *, double*, blasint *); - -int BLASFUNC(sgemc)(char *, char *, blasint *, blasint *, blasint *, float *, - float *, blasint *, float *, blasint *, float *, blasint *, float *, float *, blasint *); -int BLASFUNC(dgemc)(char *, char *, blasint *, blasint *, blasint *, double *, - double *, blasint *, double *, blasint *, double *, blasint *, double *, double *, blasint *); -int BLASFUNC(qgemc)(char *, char *, blasint *, blasint *, blasint *, xdouble *, - xdouble *, blasint *, xdouble *, blasint *, xdouble *, blasint *, xdouble *, xdouble *, blasint *); -int BLASFUNC(cgemc)(char *, char *, blasint *, blasint *, blasint *, float *, - float *, blasint *, float *, blasint *, float *, blasint *, float *, float *, blasint *); -int BLASFUNC(zgemc)(char *, char *, blasint *, blasint *, blasint *, double *, - double *, blasint *, double *, blasint *, double *, blasint *, double *, double *, blasint *); -int BLASFUNC(xgemc)(char *, char *, blasint *, blasint *, blasint *, xdouble *, - xdouble *, blasint *, xdouble *, blasint *, xdouble *, blasint *, xdouble *, xdouble *, blasint *); - -/* Lapack routines */ - -int BLASFUNC(sgetf2)(blasint *, blasint *, float *, blasint *, blasint *, blasint *); -int BLASFUNC(dgetf2)(blasint *, blasint *, double *, blasint *, blasint *, blasint *); -int BLASFUNC(qgetf2)(blasint *, blasint *, xdouble *, blasint *, blasint *, blasint *); -int BLASFUNC(cgetf2)(blasint *, blasint *, float *, blasint *, blasint *, blasint *); -int BLASFUNC(zgetf2)(blasint *, blasint *, double *, blasint *, blasint *, blasint *); -int BLASFUNC(xgetf2)(blasint *, blasint *, xdouble *, blasint *, blasint *, blasint *); - -int BLASFUNC(sgetrf)(blasint *, blasint *, float *, blasint *, blasint *, blasint *); -int BLASFUNC(dgetrf)(blasint *, blasint *, double *, blasint *, blasint *, blasint *); -int BLASFUNC(qgetrf)(blasint *, blasint *, xdouble *, blasint *, blasint *, blasint *); -int BLASFUNC(cgetrf)(blasint *, blasint *, float *, blasint *, blasint *, blasint *); -int BLASFUNC(zgetrf)(blasint *, blasint *, double *, blasint *, blasint *, blasint *); -int BLASFUNC(xgetrf)(blasint *, blasint *, xdouble *, blasint *, blasint *, blasint *); - -int BLASFUNC(slaswp)(blasint *, float *, blasint *, blasint *, blasint *, blasint *, blasint *); -int BLASFUNC(dlaswp)(blasint *, double *, blasint *, blasint *, blasint *, blasint *, blasint *); -int BLASFUNC(qlaswp)(blasint *, xdouble *, blasint *, blasint *, blasint *, blasint *, blasint *); -int BLASFUNC(claswp)(blasint *, float *, blasint *, blasint *, blasint *, blasint *, blasint *); -int BLASFUNC(zlaswp)(blasint *, double *, blasint *, blasint *, blasint *, blasint *, blasint *); -int BLASFUNC(xlaswp)(blasint *, xdouble *, blasint *, blasint *, blasint *, blasint *, blasint *); - -int BLASFUNC(sgetrs)(char *, blasint *, blasint *, float *, blasint *, blasint *, float *, blasint *, blasint *); -int BLASFUNC(dgetrs)(char *, blasint *, blasint *, double *, blasint *, blasint *, double *, blasint *, blasint *); -int BLASFUNC(qgetrs)(char *, blasint *, blasint *, xdouble *, blasint *, blasint *, xdouble *, blasint *, blasint *); -int BLASFUNC(cgetrs)(char *, blasint *, blasint *, float *, blasint *, blasint *, float *, blasint *, blasint *); -int BLASFUNC(zgetrs)(char *, blasint *, blasint *, double *, blasint *, blasint *, double *, blasint *, blasint *); -int BLASFUNC(xgetrs)(char *, blasint *, blasint *, xdouble *, blasint *, blasint *, xdouble *, blasint *, blasint *); - -int BLASFUNC(sgesv)(blasint *, blasint *, float *, blasint *, blasint *, float *, blasint *, blasint *); -int BLASFUNC(dgesv)(blasint *, blasint *, double *, blasint *, blasint *, double*, blasint *, blasint *); -int BLASFUNC(qgesv)(blasint *, blasint *, xdouble *, blasint *, blasint *, xdouble*, blasint *, blasint *); -int BLASFUNC(cgesv)(blasint *, blasint *, float *, blasint *, blasint *, float *, blasint *, blasint *); -int BLASFUNC(zgesv)(blasint *, blasint *, double *, blasint *, blasint *, double*, blasint *, blasint *); -int BLASFUNC(xgesv)(blasint *, blasint *, xdouble *, blasint *, blasint *, xdouble*, blasint *, blasint *); - -int BLASFUNC(spotf2)(char *, blasint *, float *, blasint *, blasint *); -int BLASFUNC(dpotf2)(char *, blasint *, double *, blasint *, blasint *); -int BLASFUNC(qpotf2)(char *, blasint *, xdouble *, blasint *, blasint *); -int BLASFUNC(cpotf2)(char *, blasint *, float *, blasint *, blasint *); -int BLASFUNC(zpotf2)(char *, blasint *, double *, blasint *, blasint *); -int BLASFUNC(xpotf2)(char *, blasint *, xdouble *, blasint *, blasint *); - -int BLASFUNC(spotrf)(char *, blasint *, float *, blasint *, blasint *); -int BLASFUNC(dpotrf)(char *, blasint *, double *, blasint *, blasint *); -int BLASFUNC(qpotrf)(char *, blasint *, xdouble *, blasint *, blasint *); -int BLASFUNC(cpotrf)(char *, blasint *, float *, blasint *, blasint *); -int BLASFUNC(zpotrf)(char *, blasint *, double *, blasint *, blasint *); -int BLASFUNC(xpotrf)(char *, blasint *, xdouble *, blasint *, blasint *); - -int BLASFUNC(spotrs)(char *, blasint *, blasint *, float *, blasint *, float *, blasint *, blasint *); -int BLASFUNC(dpotrs)(char *, blasint *, blasint *, double *, blasint *, double *, blasint *, blasint *); -int BLASFUNC(qpotrs)(char *, blasint *, blasint *, xdouble *, blasint *, xdouble *, blasint *, blasint *); -int BLASFUNC(cpotrs)(char *, blasint *, blasint *, float *, blasint *, float *, blasint *, blasint *); -int BLASFUNC(zpotrs)(char *, blasint *, blasint *, double *, blasint *, double *, blasint *, blasint *); -int BLASFUNC(xpotrs)(char *, blasint *, blasint *, xdouble *, blasint *, xdouble *, blasint *, blasint *); - -int BLASFUNC(slauu2)(char *, blasint *, float *, blasint *, blasint *); -int BLASFUNC(dlauu2)(char *, blasint *, double *, blasint *, blasint *); -int BLASFUNC(qlauu2)(char *, blasint *, xdouble *, blasint *, blasint *); -int BLASFUNC(clauu2)(char *, blasint *, float *, blasint *, blasint *); -int BLASFUNC(zlauu2)(char *, blasint *, double *, blasint *, blasint *); -int BLASFUNC(xlauu2)(char *, blasint *, xdouble *, blasint *, blasint *); - -int BLASFUNC(slauum)(char *, blasint *, float *, blasint *, blasint *); -int BLASFUNC(dlauum)(char *, blasint *, double *, blasint *, blasint *); -int BLASFUNC(qlauum)(char *, blasint *, xdouble *, blasint *, blasint *); -int BLASFUNC(clauum)(char *, blasint *, float *, blasint *, blasint *); -int BLASFUNC(zlauum)(char *, blasint *, double *, blasint *, blasint *); -int BLASFUNC(xlauum)(char *, blasint *, xdouble *, blasint *, blasint *); - -int BLASFUNC(strti2)(char *, char *, blasint *, float *, blasint *, blasint *); -int BLASFUNC(dtrti2)(char *, char *, blasint *, double *, blasint *, blasint *); -int BLASFUNC(qtrti2)(char *, char *, blasint *, xdouble *, blasint *, blasint *); -int BLASFUNC(ctrti2)(char *, char *, blasint *, float *, blasint *, blasint *); -int BLASFUNC(ztrti2)(char *, char *, blasint *, double *, blasint *, blasint *); -int BLASFUNC(xtrti2)(char *, char *, blasint *, xdouble *, blasint *, blasint *); - -int BLASFUNC(strtri)(char *, char *, blasint *, float *, blasint *, blasint *); -int BLASFUNC(dtrtri)(char *, char *, blasint *, double *, blasint *, blasint *); -int BLASFUNC(qtrtri)(char *, char *, blasint *, xdouble *, blasint *, blasint *); -int BLASFUNC(ctrtri)(char *, char *, blasint *, float *, blasint *, blasint *); -int BLASFUNC(ztrtri)(char *, char *, blasint *, double *, blasint *, blasint *); -int BLASFUNC(xtrtri)(char *, char *, blasint *, xdouble *, blasint *, blasint *); - - -FLOATRET BLASFUNC(slamch)(char *); -double BLASFUNC(dlamch)(char *); -xdouble BLASFUNC(qlamch)(char *); - -FLOATRET BLASFUNC(slamc3)(float *, float *); -double BLASFUNC(dlamc3)(double *, double *); -xdouble BLASFUNC(qlamc3)(xdouble *, xdouble *); - -/* BLAS extensions */ - -void BLASFUNC(saxpby) (blasint *, float *, float *, blasint *, float *, float *, blasint *); -void BLASFUNC(daxpby) (blasint *, double *, double *, blasint *, double *, double *, blasint *); -void BLASFUNC(caxpby) (blasint *, float *, float *, blasint *, float *, float *, blasint *); -void BLASFUNC(zaxpby) (blasint *, double *, double *, blasint *, double *, double *, blasint *); - -void BLASFUNC(somatcopy) (char *, char *, blasint *, blasint *, float *, float *, blasint *, float *, blasint *); -void BLASFUNC(domatcopy) (char *, char *, blasint *, blasint *, double *, double *, blasint *, double *, blasint *); -void BLASFUNC(comatcopy) (char *, char *, blasint *, blasint *, float *, float *, blasint *, float *, blasint *); -void BLASFUNC(zomatcopy) (char *, char *, blasint *, blasint *, double *, double *, blasint *, double *, blasint *); - -void BLASFUNC(simatcopy) (char *, char *, blasint *, blasint *, float *, float *, blasint *, blasint *); -void BLASFUNC(dimatcopy) (char *, char *, blasint *, blasint *, double *, double *, blasint *, blasint *); -void BLASFUNC(cimatcopy) (char *, char *, blasint *, blasint *, float *, float *, blasint *, blasint *); -void BLASFUNC(zimatcopy) (char *, char *, blasint *, blasint *, double *, double *, blasint *, blasint *); - -void BLASFUNC(sgeadd) (blasint *, blasint *, float *, float *, blasint *, float *, float *, blasint*); -void BLASFUNC(dgeadd) (blasint *, blasint *, double *, double *, blasint *, double *, double *, blasint*); -void BLASFUNC(cgeadd) (blasint *, blasint *, float *, float *, blasint *, float *, float *, blasint*); -void BLASFUNC(zgeadd) (blasint *, blasint *, double *, double *, blasint *, double *, double *, blasint*); - - -#ifdef __cplusplus -} - -#endif /* __cplusplus */ - -#endif -#endif diff --git a/cpp/thirdparty/knowhere_build/include/faiss/AutoTune.h b/cpp/thirdparty/knowhere_build/include/faiss/AutoTune.h deleted file mode 100644 index 611e7a68c9..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/AutoTune.h +++ /dev/null @@ -1,261 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -#ifndef FAISS_AUTO_TUNE_H -#define FAISS_AUTO_TUNE_H - -#include -#include -#include - -#include "Index.h" -#include "IndexBinary.h" - -namespace faiss { - - -/** - * Evaluation criterion. Returns a performance measure in [0,1], - * higher is better. - */ -struct AutoTuneCriterion { - typedef Index::idx_t idx_t; - idx_t nq; ///< nb of queries this criterion is evaluated on - idx_t nnn; ///< nb of NNs that the query should request - idx_t gt_nnn; ///< nb of GT NNs required to evaluate crterion - - std::vector gt_D; ///< Ground-truth distances (size nq * gt_nnn) - std::vector gt_I; ///< Ground-truth indexes (size nq * gt_nnn) - - AutoTuneCriterion (idx_t nq, idx_t nnn); - - /** Intitializes the gt_D and gt_I vectors. Must be called before evaluating - * - * @param gt_D_in size nq * gt_nnn - * @param gt_I_in size nq * gt_nnn - */ - void set_groundtruth (int gt_nnn, const float *gt_D_in, - const idx_t *gt_I_in); - - /** Evaluate the criterion. - * - * @param D size nq * nnn - * @param I size nq * nnn - * @return the criterion, between 0 and 1. Larger is better. - */ - virtual double evaluate (const float *D, const idx_t *I) const = 0; - - virtual ~AutoTuneCriterion () {} - -}; - -struct OneRecallAtRCriterion: AutoTuneCriterion { - - idx_t R; - - OneRecallAtRCriterion (idx_t nq, idx_t R); - - double evaluate(const float* D, const idx_t* I) const override; - - ~OneRecallAtRCriterion() override {} -}; - - -struct IntersectionCriterion: AutoTuneCriterion { - - idx_t R; - - IntersectionCriterion (idx_t nq, idx_t R); - - double evaluate(const float* D, const idx_t* I) const override; - - ~IntersectionCriterion() override {} -}; - -/** - * Maintains a list of experimental results. Each operating point is a - * (perf, t, key) triplet, where higher perf and lower t is - * better. The key field is an arbitrary identifier for the operating point - */ - -struct OperatingPoint { - double perf; ///< performance measure (output of a Criterion) - double t; ///< corresponding execution time (ms) - std::string key; ///< key that identifies this op pt - int64_t cno; ///< integer identifer -}; - -struct OperatingPoints { - /// all operating points - std::vector all_pts; - - /// optimal operating points, sorted by perf - std::vector optimal_pts; - - // begins with a single operating point: t=0, perf=0 - OperatingPoints (); - - /// add operating points from other to this, with a prefix to the keys - int merge_with (const OperatingPoints &other, - const std::string & prefix = ""); - - void clear (); - - /// add a performance measure. Return whether it is an optimal point - bool add (double perf, double t, const std::string & key, size_t cno = 0); - - /// get time required to obtain a given performance measure - double t_for_perf (double perf) const; - - /// easy-to-read output - void display (bool only_optimal = true) const; - - /// output to a format easy to digest by gnuplot - void all_to_gnuplot (const char *fname) const; - void optimal_to_gnuplot (const char *fname) const; - -}; - -/// possible values of a parameter, sorted from least to most expensive/accurate -struct ParameterRange { - std::string name; - std::vector values; -}; - -/** Uses a-priori knowledge on the Faiss indexes to extract tunable parameters. - */ -struct ParameterSpace { - /// all tunable parameters - std::vector parameter_ranges; - - // exploration parameters - - /// verbosity during exploration - int verbose; - - /// nb of experiments during optimization (0 = try all combinations) - int n_experiments; - - /// maximum number of queries to submit at a time. - size_t batchsize; - - /// use multithreading over batches (useful to benchmark - /// independent single-searches) - bool thread_over_batches; - - /// run tests several times until they reach at least this - /// duration (to avoid jittering in MT mode) - double min_test_duration; - - ParameterSpace (); - - /// nb of combinations, = product of values sizes - size_t n_combinations () const; - - /// returns whether combinations c1 >= c2 in the tuple sense - bool combination_ge (size_t c1, size_t c2) const; - - /// get string representation of the combination - std::string combination_name (size_t cno) const; - - /// print a description on stdout - void display () const; - - /// add a new parameter (or return it if it exists) - ParameterRange &add_range(const char * name); - - /// initialize with reasonable parameters for the index - virtual void initialize (const Index * index); - - /// set a combination of parameters on an index - void set_index_parameters (Index *index, size_t cno) const; - - /// set a combination of parameters described by a string - void set_index_parameters (Index *index, const char *param_string) const; - - /// set one of the parameters - virtual void set_index_parameter ( - Index * index, const std::string & name, double val) const; - - /** find an upper bound on the performance and a lower bound on t - * for configuration cno given another operating point op */ - void update_bounds (size_t cno, const OperatingPoint & op, - double *upper_bound_perf, - double *lower_bound_t) const; - - /** explore operating points - * @param index index to run on - * @param xq query vectors (size nq * index.d) - * @param crit selection criterion - * @param ops resutling operating points - */ - void explore (Index *index, - size_t nq, const float *xq, - const AutoTuneCriterion & crit, - OperatingPoints * ops) const; - - virtual ~ParameterSpace () {} -}; - -/** Build and index with the sequence of processing steps described in - * the string. */ -Index *index_factory (int d, const char *description, - MetricType metric = METRIC_L2); - -IndexBinary *index_binary_factory (int d, const char *description); - - -/** Reports some statistics on a dataset and comments on them. - * - * It is a class rather than a function so that all stats can also be - * accessed from code */ - -struct MatrixStats { - MatrixStats (size_t n, size_t d, const float *x); - std::string comments; - - // raw statistics - size_t n, d; - size_t n_collision, n_valid, n0; - double min_norm2, max_norm2; - - struct PerDimStats { - size_t n, n_nan, n_inf, n0; - - float min, max; - double sum, sum2; - - size_t n_valid; - double mean, stddev; - - PerDimStats(); - void add (float x); - void compute_mean_std (); - }; - - std::vector per_dim_stats; - struct Occurrence { - size_t first; - size_t count; - }; - std::unordered_map occurrences; - - char *buf; - size_t nbuf; - void do_comment (const char *fmt, ...); - -}; - - - -} // namespace faiss - - - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/faiss/AuxIndexStructures.h b/cpp/thirdparty/knowhere_build/include/faiss/AuxIndexStructures.h deleted file mode 100644 index 37056729b2..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/AuxIndexStructures.h +++ /dev/null @@ -1,286 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -// Auxiliary index structures, that are used in indexes but that can -// be forward-declared - -#ifndef FAISS_AUX_INDEX_STRUCTURES_H -#define FAISS_AUX_INDEX_STRUCTURES_H - -#include - -#include -#include -#include -#include - -#include "Index.h" - -namespace faiss { - -/** The objective is to have a simple result structure while - * minimizing the number of mem copies in the result. The method - * do_allocation can be overloaded to allocate the result tables in - * the matrix type of a scripting language like Lua or Python. */ -struct RangeSearchResult { - size_t nq; ///< nb of queries - size_t *lims; ///< size (nq + 1) - - typedef Index::idx_t idx_t; - - idx_t *labels; ///< result for query i is labels[lims[i]:lims[i+1]] - float *distances; ///< corresponding distances (not sorted) - - size_t buffer_size; ///< size of the result buffers used - - /// lims must be allocated on input to range_search. - explicit RangeSearchResult (idx_t nq, bool alloc_lims=true); - - /// called when lims contains the nb of elements result entries - /// for each query - virtual void do_allocation (); - - virtual ~RangeSearchResult (); -}; - - -/** Encapsulates a set of ids to remove. */ -struct IDSelector { - typedef Index::idx_t idx_t; - virtual bool is_member (idx_t id) const = 0; - virtual ~IDSelector() {} -}; - - - -/** remove ids between [imni, imax) */ -struct IDSelectorRange: IDSelector { - idx_t imin, imax; - - IDSelectorRange (idx_t imin, idx_t imax); - bool is_member(idx_t id) const override; - ~IDSelectorRange() override {} -}; - - -/** Remove ids from a set. Repetitions of ids in the indices set - * passed to the constructor does not hurt performance. The hash - * function used for the bloom filter and GCC's implementation of - * unordered_set are just the least significant bits of the id. This - * works fine for random ids or ids in sequences but will produce many - * hash collisions if lsb's are always the same */ -struct IDSelectorBatch: IDSelector { - - std::unordered_set set; - - typedef unsigned char uint8_t; - std::vector bloom; // assumes low bits of id are a good hash value - int nbits; - idx_t mask; - - IDSelectorBatch (size_t n, const idx_t *indices); - bool is_member(idx_t id) const override; - ~IDSelectorBatch() override {} -}; - -/**************************************************************** - * Result structures for range search. - * - * The main constraint here is that we want to support parallel - * queries from different threads in various ways: 1 thread per query, - * several threads per query. We store the actual results in blocks of - * fixed size rather than exponentially increasing memory. At the end, - * we copy the block content to a linear result array. - *****************************************************************/ - -/** List of temporary buffers used to store results before they are - * copied to the RangeSearchResult object. */ -struct BufferList { - typedef Index::idx_t idx_t; - - // buffer sizes in # entries - size_t buffer_size; - - struct Buffer { - idx_t *ids; - float *dis; - }; - - std::vector buffers; - size_t wp; ///< write pointer in the last buffer. - - explicit BufferList (size_t buffer_size); - - ~BufferList (); - - /// create a new buffer - void append_buffer (); - - /// add one result, possibly appending a new buffer if needed - void add (idx_t id, float dis); - - /// copy elemnts ofs:ofs+n-1 seen as linear data in the buffers to - /// tables dest_ids, dest_dis - void copy_range (size_t ofs, size_t n, - idx_t * dest_ids, float *dest_dis); - -}; - -struct RangeSearchPartialResult; - -/// result structure for a single query -struct RangeQueryResult { - using idx_t = Index::idx_t; - idx_t qno; //< id of the query - size_t nres; //< nb of results for this query - RangeSearchPartialResult * pres; - - /// called by search function to report a new result - void add (float dis, idx_t id); -}; - -/// the entries in the buffers are split per query -struct RangeSearchPartialResult: BufferList { - RangeSearchResult * res; - - /// eventually the result will be stored in res_in - explicit RangeSearchPartialResult (RangeSearchResult * res_in); - - /// query ids + nb of results per query. - std::vector queries; - - /// begin a new result - RangeQueryResult & new_result (idx_t qno); - - /***************************************** - * functions used at the end of the search to merge the result - * lists */ - void finalize (); - - /// called by range_search before do_allocation - void set_lims (); - - /// called by range_search after do_allocation - void copy_result (bool incremental = false); - - /// merge a set of PartialResult's into one RangeSearchResult - /// on ouptut the partialresults are empty! - static void merge (std::vector & - partial_results, bool do_delete=true); - -}; - -/*********************************************************** - * Abstract I/O objects - ***********************************************************/ - -struct IOReader { - // name that can be used in error messages - std::string name; - - // fread - virtual size_t operator()( - void *ptr, size_t size, size_t nitems) = 0; - - // return a file number that can be memory-mapped - virtual int fileno (); - - virtual ~IOReader() {} -}; - -struct IOWriter { - // name that can be used in error messages - std::string name; - - // fwrite - virtual size_t operator()( - const void *ptr, size_t size, size_t nitems) = 0; - - // return a file number that can be memory-mapped - virtual int fileno (); - - virtual ~IOWriter() {} -}; - - -struct VectorIOReader:IOReader { - std::vector data; - size_t rp = 0; - size_t operator()(void *ptr, size_t size, size_t nitems) override; -}; - -struct VectorIOWriter:IOWriter { - std::vector data; - size_t operator()(const void *ptr, size_t size, size_t nitems) override; -}; - -/*********************************************************** - * The distance computer maintains a current query and computes - * distances to elements in an index that supports random access. - * - * The DistanceComputer is not intended to be thread-safe (eg. because - * it maintains counters) so the distance functions are not const, - * instanciate one from each thread if needed. - ***********************************************************/ -struct DistanceComputer { - using idx_t = Index::idx_t; - - /// called before computing distances - virtual void set_query(const float *x) = 0; - - /// compute distance of vector i to current query - virtual float operator () (idx_t i) = 0; - - /// compute distance between two stored vectors - virtual float symmetric_dis (idx_t i, idx_t j) = 0; - - virtual ~DistanceComputer() {} -}; - -/*********************************************************** - * Interrupt callback - ***********************************************************/ - -struct InterruptCallback { - virtual bool want_interrupt () = 0; - virtual ~InterruptCallback() {} - - // lock that protects concurrent calls to is_interrupted - static std::mutex lock; - - static std::unique_ptr instance; - - static void clear_instance (); - - /** check if: - * - an interrupt callback is set - * - the callback retuns true - * if this is the case, then throw an exception. Should not be called - * from multiple threds. - */ - static void check (); - - /// same as check() but return true if is interrupted instead of - /// throwing. Can be called from multiple threads. - static bool is_interrupted (); - - /** assuming each iteration takes a certain number of flops, what - * is a reasonable interval to check for interrupts? - */ - static size_t get_period_hint (size_t flops); - -}; - - - -}; // namespace faiss - - - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/faiss/Clustering.h b/cpp/thirdparty/knowhere_build/include/faiss/Clustering.h deleted file mode 100644 index 475de10c4c..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/Clustering.h +++ /dev/null @@ -1,101 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -#ifndef FAISS_CLUSTERING_H -#define FAISS_CLUSTERING_H -#include "Index.h" - -#include - -namespace faiss { - - -/** Class for the clustering parameters. Can be passed to the - * constructor of the Clustering object. - */ -struct ClusteringParameters { - int niter; ///< clustering iterations - int nredo; ///< redo clustering this many times and keep best - - bool verbose; - bool spherical; ///< do we want normalized centroids? - bool int_centroids; ///< round centroids coordinates to integer - bool update_index; ///< update index after each iteration? - bool frozen_centroids; ///< use the centroids provided as input and do not change them during iterations - - int min_points_per_centroid; ///< otherwise you get a warning - int max_points_per_centroid; ///< to limit size of dataset - - int seed; ///< seed for the random number generator - - /// sets reasonable defaults - ClusteringParameters (); -}; - - -/** clustering based on assignment - centroid update iterations - * - * The clustering is based on an Index object that assigns training - * points to the centroids. Therefore, at each iteration the centroids - * are added to the index. - * - * On output, the centoids table is set to the latest version - * of the centroids and they are also added to the index. If the - * centroids table it is not empty on input, it is also used for - * initialization. - * - * To do several clusterings, just call train() several times on - * different training sets, clearing the centroid table in between. - */ -struct Clustering: ClusteringParameters { - typedef Index::idx_t idx_t; - size_t d; ///< dimension of the vectors - size_t k; ///< nb of centroids - - /// centroids (k * d) - std::vector centroids; - - /// objective values (sum of distances reported by index) over - /// iterations - std::vector obj; - - /// the only mandatory parameters are k and d - Clustering (int d, int k); - Clustering (int d, int k, const ClusteringParameters &cp); - - /// Index is used during the assignment stage - virtual void train (idx_t n, const float * x, faiss::Index & index); - - /// Post-process the centroids after each centroid update. - /// includes optional L2 normalization and nearest integer rounding - void post_process_centroids (); - - virtual ~Clustering() {} -}; - - -/** simplified interface - * - * @param d dimension of the data - * @param n nb of training vectors - * @param k nb of output centroids - * @param x training set (size n * d) - * @param centroids output centroids (size k * d) - * @return final quantization error - */ -float kmeans_clustering (size_t d, size_t n, size_t k, - const float *x, - float *centroids); - - - -} - - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/faiss/FaissAssert.h b/cpp/thirdparty/knowhere_build/include/faiss/FaissAssert.h deleted file mode 100644 index 64a0eafc9a..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/FaissAssert.h +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -#ifndef FAISS_ASSERT_INCLUDED -#define FAISS_ASSERT_INCLUDED - -#include "FaissException.h" -#include -#include -#include - -/// -/// Assertions -/// - -#define FAISS_ASSERT(X) \ - do { \ - if (! (X)) { \ - fprintf(stderr, "Faiss assertion '%s' failed in %s " \ - "at %s:%d\n", \ - #X, __PRETTY_FUNCTION__, __FILE__, __LINE__); \ - abort(); \ - } \ - } while (false) - -#define FAISS_ASSERT_MSG(X, MSG) \ - do { \ - if (! (X)) { \ - fprintf(stderr, "Faiss assertion '%s' failed in %s " \ - "at %s:%d; details: " MSG "\n", \ - #X, __PRETTY_FUNCTION__, __FILE__, __LINE__); \ - abort(); \ - } \ - } while (false) - -#define FAISS_ASSERT_FMT(X, FMT, ...) \ - do { \ - if (! (X)) { \ - fprintf(stderr, "Faiss assertion '%s' failed in %s " \ - "at %s:%d; details: " FMT "\n", \ - #X, __PRETTY_FUNCTION__, __FILE__, __LINE__, __VA_ARGS__); \ - abort(); \ - } \ - } while (false) - -/// -/// Exceptions for returning user errors -/// - -#define FAISS_THROW_MSG(MSG) \ - do { \ - throw faiss::FaissException(MSG, __PRETTY_FUNCTION__, __FILE__, __LINE__); \ - } while (false) - -#define FAISS_THROW_FMT(FMT, ...) \ - do { \ - std::string __s; \ - int __size = snprintf(nullptr, 0, FMT, __VA_ARGS__); \ - __s.resize(__size + 1); \ - snprintf(&__s[0], __s.size(), FMT, __VA_ARGS__); \ - throw faiss::FaissException(__s, __PRETTY_FUNCTION__, __FILE__, __LINE__); \ - } while (false) - -/// -/// Exceptions thrown upon a conditional failure -/// - -#define FAISS_THROW_IF_NOT(X) \ - do { \ - if (!(X)) { \ - FAISS_THROW_FMT("Error: '%s' failed", #X); \ - } \ - } while (false) - -#define FAISS_THROW_IF_NOT_MSG(X, MSG) \ - do { \ - if (!(X)) { \ - FAISS_THROW_FMT("Error: '%s' failed: " MSG, #X); \ - } \ - } while (false) - -#define FAISS_THROW_IF_NOT_FMT(X, FMT, ...) \ - do { \ - if (!(X)) { \ - FAISS_THROW_FMT("Error: '%s' failed: " FMT, #X, __VA_ARGS__); \ - } \ - } while (false) - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/faiss/FaissException.h b/cpp/thirdparty/knowhere_build/include/faiss/FaissException.h deleted file mode 100644 index 9d54edbad5..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/FaissException.h +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -#ifndef FAISS_EXCEPTION_INCLUDED -#define FAISS_EXCEPTION_INCLUDED - -#include -#include -#include -#include - -namespace faiss { - -/// Base class for Faiss exceptions -class FaissException : public std::exception { - public: - explicit FaissException(const std::string& msg); - - FaissException(const std::string& msg, - const char* funcName, - const char* file, - int line); - - /// from std::exception - const char* what() const noexcept override; - - std::string msg; -}; - -/// Handle multiple exceptions from worker threads, throwing an appropriate -/// exception that aggregates the information -/// The pair int is the thread that generated the exception -void -handleExceptions(std::vector>& exceptions); - -/** bare-bones unique_ptr - * this one deletes with delete [] */ -template -struct ScopeDeleter { - const T * ptr; - explicit ScopeDeleter (const T* ptr = nullptr): ptr (ptr) {} - void release () {ptr = nullptr; } - void set (const T * ptr_in) { ptr = ptr_in; } - void swap (ScopeDeleter &other) {std::swap (ptr, other.ptr); } - ~ScopeDeleter () { - delete [] ptr; - } -}; - -/** same but deletes with the simple delete (least common case) */ -template -struct ScopeDeleter1 { - const T * ptr; - explicit ScopeDeleter1 (const T* ptr = nullptr): ptr (ptr) {} - void release () {ptr = nullptr; } - void set (const T * ptr_in) { ptr = ptr_in; } - void swap (ScopeDeleter1 &other) {std::swap (ptr, other.ptr); } - ~ScopeDeleter1 () { - delete ptr; - } -}; - -} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/faiss/HNSW.h b/cpp/thirdparty/knowhere_build/include/faiss/HNSW.h deleted file mode 100644 index bb25006efd..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/HNSW.h +++ /dev/null @@ -1,274 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -#pragma once - -#include -#include -#include - -#include - -#include "Index.h" -#include "FaissAssert.h" -#include "utils.h" - - -namespace faiss { - - -/** Implementation of the Hierarchical Navigable Small World - * datastructure. - * - * Efficient and robust approximate nearest neighbor search using - * Hierarchical Navigable Small World graphs - * - * Yu. A. Malkov, D. A. Yashunin, arXiv 2017 - * - * This implmentation is heavily influenced by the NMSlib - * implementation by Yury Malkov and Leonid Boystov - * (https://github.com/searchivarius/nmslib) - * - * The HNSW object stores only the neighbor link structure, see - * IndexHNSW.h for the full index object. - */ - - -struct VisitedTable; -struct DistanceComputer; // from AuxIndexStructures - -struct HNSW { - /// internal storage of vectors (32 bits: this is expensive) - typedef int storage_idx_t; - - /// Faiss results are 64-bit - typedef Index::idx_t idx_t; - - typedef std::pair Node; - - /** Heap structure that allows fast - */ - struct MinimaxHeap { - int n; - int k; - int nvalid; - - std::vector ids; - std::vector dis; - typedef faiss::CMax HC; - - explicit MinimaxHeap(int n): n(n), k(0), nvalid(0), ids(n), dis(n) {} - - void push(storage_idx_t i, float v); - - float max() const; - - int size() const; - - void clear(); - - int pop_min(float *vmin_out = nullptr); - - int count_below(float thresh); - }; - - - /// to sort pairs of (id, distance) from nearest to fathest or the reverse - struct NodeDistCloser { - float d; - int id; - NodeDistCloser(float d, int id): d(d), id(id) {} - bool operator < (const NodeDistCloser &obj1) const { return d < obj1.d; } - }; - - struct NodeDistFarther { - float d; - int id; - NodeDistFarther(float d, int id): d(d), id(id) {} - bool operator < (const NodeDistFarther &obj1) const { return d > obj1.d; } - }; - - - /// assignment probability to each layer (sum=1) - std::vector assign_probas; - - /// number of neighbors stored per layer (cumulative), should not - /// be changed after first add - std::vector cum_nneighbor_per_level; - - /// level of each vector (base level = 1), size = ntotal - std::vector levels; - - /// offsets[i] is the offset in the neighbors array where vector i is stored - /// size ntotal + 1 - std::vector offsets; - - /// neighbors[offsets[i]:offsets[i+1]] is the list of neighbors of vector i - /// for all levels. this is where all storage goes. - std::vector neighbors; - - /// entry point in the search structure (one of the points with maximum level - storage_idx_t entry_point; - - faiss::RandomGenerator rng; - - /// maximum level - int max_level; - - /// expansion factor at construction time - int efConstruction; - - /// expansion factor at search time - int efSearch; - - /// during search: do we check whether the next best distance is good enough? - bool check_relative_distance = true; - - /// number of entry points in levels > 0. - int upper_beam; - - /// use bounded queue during exploration - bool search_bounded_queue = true; - - // methods that initialize the tree sizes - - /// initialize the assign_probas and cum_nneighbor_per_level to - /// have 2*M links on level 0 and M links on levels > 0 - void set_default_probas(int M, float levelMult); - - /// set nb of neighbors for this level (before adding anything) - void set_nb_neighbors(int level_no, int n); - - // methods that access the tree sizes - - /// nb of neighbors for this level - int nb_neighbors(int layer_no) const; - - /// cumumlative nb up to (and excluding) this level - int cum_nb_neighbors(int layer_no) const; - - /// range of entries in the neighbors table of vertex no at layer_no - void neighbor_range(idx_t no, int layer_no, - size_t * begin, size_t * end) const; - - /// only mandatory parameter: nb of neighbors - explicit HNSW(int M = 32); - - /// pick a random level for a new point - int random_level(); - - /// add n random levels to table (for debugging...) - void fill_with_random_links(size_t n); - - void add_links_starting_from(DistanceComputer& ptdis, - storage_idx_t pt_id, - storage_idx_t nearest, - float d_nearest, - int level, - omp_lock_t *locks, - VisitedTable &vt); - - - /** add point pt_id on all levels <= pt_level and build the link - * structure for them. */ - void add_with_locks(DistanceComputer& ptdis, int pt_level, int pt_id, - std::vector& locks, - VisitedTable& vt); - - int search_from_candidates(DistanceComputer& qdis, int k, - idx_t *I, float *D, - MinimaxHeap& candidates, - VisitedTable &vt, - int level, int nres_in = 0) const; - - std::priority_queue search_from_candidate_unbounded( - const Node& node, - DistanceComputer& qdis, - int ef, - VisitedTable *vt - ) const; - - /// search interface - void search(DistanceComputer& qdis, int k, - idx_t *I, float *D, - VisitedTable& vt) const; - - void reset(); - - void clear_neighbor_tables(int level); - void print_neighbor_stats(int level) const; - - int prepare_level_tab(size_t n, bool preset_levels = false); - - static void shrink_neighbor_list( - DistanceComputer& qdis, - std::priority_queue& input, - std::vector& output, - int max_size); - -}; - - -/************************************************************** - * Auxiliary structures - **************************************************************/ - -/// set implementation optimized for fast access. -struct VisitedTable { - std::vector visited; - int visno; - - explicit VisitedTable(int size) - : visited(size), visno(1) {} - - /// set flog #no to true - void set(int no) { - visited[no] = visno; - } - - /// get flag #no - bool get(int no) const { - return visited[no] == visno; - } - - /// reset all flags to false - void advance() { - visno++; - if (visno == 250) { - // 250 rather than 255 because sometimes we use visno and visno+1 - memset(visited.data(), 0, sizeof(visited[0]) * visited.size()); - visno = 1; - } - } -}; - - -struct HNSWStats { - size_t n1, n2, n3; - size_t ndis; - size_t nreorder; - bool view; - - HNSWStats() { - reset(); - } - - void reset() { - n1 = n2 = n3 = 0; - ndis = 0; - nreorder = 0; - view = false; - } -}; - -// global var that collects them all -extern HNSWStats hnsw_stats; - - -} // namespace faiss diff --git a/cpp/thirdparty/knowhere_build/include/faiss/Heap.h b/cpp/thirdparty/knowhere_build/include/faiss/Heap.h deleted file mode 100644 index e691c36c7f..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/Heap.h +++ /dev/null @@ -1,495 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -/* - * C++ support for heaps. The set of functions is tailored for - * efficient similarity search. - * - * There is no specific object for a heap, and the functions that - * operate on a signle heap are inlined, because heaps are often - * small. More complex functions are implemented in Heaps.cpp - * - */ - - -#ifndef FAISS_Heap_h -#define FAISS_Heap_h - -#include -#include -#include - -#include -#include -#include - -#include - - -namespace faiss { - -/******************************************************************* - * C object: uniform handling of min and max heap - *******************************************************************/ - -/** The C object gives the type T of the values in the heap, the type - * of the keys, TI and the comparison that is done: > for the minheap - * and < for the maxheap. The neutral value will always be dropped in - * favor of any other value in the heap. - */ - -template -struct CMax; - -// traits of minheaps = heaps where the minimum value is stored on top -// useful to find the *max* values of an array -template -struct CMin { - typedef T_ T; - typedef TI_ TI; - typedef CMax Crev; - inline static bool cmp (T a, T b) { - return a < b; - } - // value that will be popped first -> must be smaller than all others - // for int types this is not strictly the smallest val (-max - 1) - inline static T neutral () { - return -std::numeric_limits::max(); - } -}; - - -template -struct CMax { - typedef T_ T; - typedef TI_ TI; - typedef CMin Crev; - inline static bool cmp (T a, T b) { - return a > b; - } - inline static T neutral () { - return std::numeric_limits::max(); - } -}; - - -/******************************************************************* - * Basic heap ops: push and pop - *******************************************************************/ - -/** Pops the top element from the heap defined by bh_val[0..k-1] and - * bh_ids[0..k-1]. on output the element at k-1 is undefined. - */ -template inline -void heap_pop (size_t k, typename C::T * bh_val, typename C::TI * bh_ids) -{ - bh_val--; /* Use 1-based indexing for easier node->child translation */ - bh_ids--; - typename C::T val = bh_val[k]; - size_t i = 1, i1, i2; - while (1) { - i1 = i << 1; - i2 = i1 + 1; - if (i1 > k) - break; - if (i2 == k + 1 || C::cmp(bh_val[i1], bh_val[i2])) { - if (C::cmp(val, bh_val[i1])) - break; - bh_val[i] = bh_val[i1]; - bh_ids[i] = bh_ids[i1]; - i = i1; - } - else { - if (C::cmp(val, bh_val[i2])) - break; - bh_val[i] = bh_val[i2]; - bh_ids[i] = bh_ids[i2]; - i = i2; - } - } - bh_val[i] = bh_val[k]; - bh_ids[i] = bh_ids[k]; -} - - - -/** Pushes the element (val, ids) into the heap bh_val[0..k-2] and - * bh_ids[0..k-2]. on output the element at k-1 is defined. - */ -template inline -void heap_push (size_t k, - typename C::T * bh_val, typename C::TI * bh_ids, - typename C::T val, typename C::TI ids) -{ - bh_val--; /* Use 1-based indexing for easier node->child translation */ - bh_ids--; - size_t i = k, i_father; - while (i > 1) { - i_father = i >> 1; - if (!C::cmp (val, bh_val[i_father])) /* the heap structure is ok */ - break; - bh_val[i] = bh_val[i_father]; - bh_ids[i] = bh_ids[i_father]; - i = i_father; - } - bh_val[i] = val; - bh_ids[i] = ids; -} - - - -/* Partial instanciation for heaps with TI = int64_t */ - -template inline -void minheap_pop (size_t k, T * bh_val, int64_t * bh_ids) -{ - heap_pop > (k, bh_val, bh_ids); -} - - -template inline -void minheap_push (size_t k, T * bh_val, int64_t * bh_ids, T val, int64_t ids) -{ - heap_push > (k, bh_val, bh_ids, val, ids); -} - - -template inline -void maxheap_pop (size_t k, T * bh_val, int64_t * bh_ids) -{ - heap_pop > (k, bh_val, bh_ids); -} - - -template inline -void maxheap_push (size_t k, T * bh_val, int64_t * bh_ids, T val, int64_t ids) -{ - heap_push > (k, bh_val, bh_ids, val, ids); -} - - - -/******************************************************************* - * Heap initialization - *******************************************************************/ - -/* Initialization phase for the heap (with unconditionnal pushes). - * Store k0 elements in a heap containing up to k values. Note that - * (bh_val, bh_ids) can be the same as (x, ids) */ -template inline -void heap_heapify ( - size_t k, - typename C::T * bh_val, - typename C::TI * bh_ids, - const typename C::T * x = nullptr, - const typename C::TI * ids = nullptr, - size_t k0 = 0) -{ - if (k0 > 0) assert (x); - - if (ids) { - for (size_t i = 0; i < k0; i++) - heap_push (i+1, bh_val, bh_ids, x[i], ids[i]); - } else { - for (size_t i = 0; i < k0; i++) - heap_push (i+1, bh_val, bh_ids, x[i], i); - } - - for (size_t i = k0; i < k; i++) { - bh_val[i] = C::neutral(); - bh_ids[i] = -1; - } - -} - -template inline -void minheap_heapify ( - size_t k, T * bh_val, - int64_t * bh_ids, - const T * x = nullptr, - const int64_t * ids = nullptr, - size_t k0 = 0) -{ - heap_heapify< CMin > (k, bh_val, bh_ids, x, ids, k0); -} - - -template inline -void maxheap_heapify ( - size_t k, - T * bh_val, - int64_t * bh_ids, - const T * x = nullptr, - const int64_t * ids = nullptr, - size_t k0 = 0) -{ - heap_heapify< CMax > (k, bh_val, bh_ids, x, ids, k0); -} - - - -/******************************************************************* - * Add n elements to the heap - *******************************************************************/ - - -/* Add some elements to the heap */ -template inline -void heap_addn (size_t k, - typename C::T * bh_val, typename C::TI * bh_ids, - const typename C::T * x, - const typename C::TI * ids, - size_t n) -{ - size_t i; - if (ids) - for (i = 0; i < n; i++) { - if (C::cmp (bh_val[0], x[i])) { - heap_pop (k, bh_val, bh_ids); - heap_push (k, bh_val, bh_ids, x[i], ids[i]); - } - } - else - for (i = 0; i < n; i++) { - if (C::cmp (bh_val[0], x[i])) { - heap_pop (k, bh_val, bh_ids); - heap_push (k, bh_val, bh_ids, x[i], i); - } - } -} - - -/* Partial instanciation for heaps with TI = int64_t */ - -template inline -void minheap_addn (size_t k, T * bh_val, int64_t * bh_ids, - const T * x, const int64_t * ids, size_t n) -{ - heap_addn > (k, bh_val, bh_ids, x, ids, n); -} - -template inline -void maxheap_addn (size_t k, T * bh_val, int64_t * bh_ids, - const T * x, const int64_t * ids, size_t n) -{ - heap_addn > (k, bh_val, bh_ids, x, ids, n); -} - - - - - - -/******************************************************************* - * Heap finalization (reorder elements) - *******************************************************************/ - - -/* This function maps a binary heap into an sorted structure. - It returns the number */ -template inline -size_t heap_reorder (size_t k, typename C::T * bh_val, typename C::TI * bh_ids) -{ - size_t i, ii; - - for (i = 0, ii = 0; i < k; i++) { - /* top element should be put at the end of the list */ - typename C::T val = bh_val[0]; - typename C::TI id = bh_ids[0]; - - /* boundary case: we will over-ride this value if not a true element */ - heap_pop (k-i, bh_val, bh_ids); - bh_val[k-ii-1] = val; - bh_ids[k-ii-1] = id; - if (id != -1) ii++; - } - /* Count the number of elements which are effectively returned */ - size_t nel = ii; - - memmove (bh_val, bh_val+k-ii, ii * sizeof(*bh_val)); - memmove (bh_ids, bh_ids+k-ii, ii * sizeof(*bh_ids)); - - for (; ii < k; ii++) { - bh_val[ii] = C::neutral(); - bh_ids[ii] = -1; - } - return nel; -} - -template inline -size_t minheap_reorder (size_t k, T * bh_val, int64_t * bh_ids) -{ - return heap_reorder< CMin > (k, bh_val, bh_ids); -} - -template inline -size_t maxheap_reorder (size_t k, T * bh_val, int64_t * bh_ids) -{ - return heap_reorder< CMax > (k, bh_val, bh_ids); -} - - - - - -/******************************************************************* - * Operations on heap arrays - *******************************************************************/ - -/** a template structure for a set of [min|max]-heaps it is tailored - * so that the actual data of the heaps can just live in compact - * arrays. - */ -template -struct HeapArray { - typedef typename C::TI TI; - typedef typename C::T T; - - size_t nh; ///< number of heaps - size_t k; ///< allocated size per heap - TI * ids; ///< identifiers (size nh * k) - T * val; ///< values (distances or similarities), size nh * k - - /// Return the list of values for a heap - T * get_val (size_t key) { return val + key * k; } - - /// Correspponding identifiers - TI * get_ids (size_t key) { return ids + key * k; } - - /// prepare all the heaps before adding - void heapify (); - - /** add nj elements to heaps i0:i0+ni, with sequential ids - * - * @param nj nb of elements to add to each heap - * @param vin elements to add, size ni * nj - * @param j0 add this to the ids that are added - * @param i0 first heap to update - * @param ni nb of elements to update (-1 = use nh) - */ - void addn (size_t nj, const T *vin, TI j0 = 0, - size_t i0 = 0, int64_t ni = -1); - - /** same as addn - * - * @param id_in ids of the elements to add, size ni * nj - * @param id_stride stride for id_in - */ - void addn_with_ids ( - size_t nj, const T *vin, const TI *id_in = nullptr, - int64_t id_stride = 0, size_t i0 = 0, int64_t ni = -1); - - /// reorder all the heaps - void reorder (); - - /** this is not really a heap function. It just finds the per-line - * extrema of each line of array D - * @param vals_out extreme value of each line (size nh, or NULL) - * @param idx_out index of extreme value (size nh or NULL) - */ - void per_line_extrema (T *vals_out, TI *idx_out) const; - -}; - - -/* Define useful heaps */ -typedef HeapArray > float_minheap_array_t; -typedef HeapArray > int_minheap_array_t; - -typedef HeapArray > float_maxheap_array_t; -typedef HeapArray > int_maxheap_array_t; - -// The heap templates are instanciated explicitly in Heap.cpp - - - - - - - - - - - - - - - - - - - -/********************************************************************* - * Indirect heaps: instead of having - * - * node i = (bh_ids[i], bh_val[i]), - * - * in indirect heaps, - * - * node i = (bh_ids[i], bh_val[bh_ids[i]]), - * - *********************************************************************/ - - -template -inline -void indirect_heap_pop ( - size_t k, - const typename C::T * bh_val, - typename C::TI * bh_ids) -{ - bh_ids--; /* Use 1-based indexing for easier node->child translation */ - typename C::T val = bh_val[bh_ids[k]]; - size_t i = 1; - while (1) { - size_t i1 = i << 1; - size_t i2 = i1 + 1; - if (i1 > k) - break; - typename C::TI id1 = bh_ids[i1], id2 = bh_ids[i2]; - if (i2 == k + 1 || C::cmp(bh_val[id1], bh_val[id2])) { - if (C::cmp(val, bh_val[id1])) - break; - bh_ids[i] = id1; - i = i1; - } else { - if (C::cmp(val, bh_val[id2])) - break; - bh_ids[i] = id2; - i = i2; - } - } - bh_ids[i] = bh_ids[k]; -} - - - -template -inline -void indirect_heap_push (size_t k, - const typename C::T * bh_val, typename C::TI * bh_ids, - typename C::TI id) -{ - bh_ids--; /* Use 1-based indexing for easier node->child translation */ - typename C::T val = bh_val[id]; - size_t i = k; - while (i > 1) { - size_t i_father = i >> 1; - if (!C::cmp (val, bh_val[bh_ids[i_father]])) - break; - bh_ids[i] = bh_ids[i_father]; - i = i_father; - } - bh_ids[i] = id; -} - - -} // namespace faiss - -#endif /* FAISS_Heap_h */ diff --git a/cpp/thirdparty/knowhere_build/include/faiss/IVFlib.h b/cpp/thirdparty/knowhere_build/include/faiss/IVFlib.h deleted file mode 100644 index dcd03ee910..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/IVFlib.h +++ /dev/null @@ -1,129 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -#ifndef FAISS_IVFLIB_H -#define FAISS_IVFLIB_H - -/** Since IVF (inverted file) indexes are of so much use for - * large-scale use cases, we group a few functions related to them in - * this small library. Most functions work both on IndexIVFs and - * IndexIVFs embedded within an IndexPreTransform. - */ - -#include -#include "IndexIVF.h" - -namespace faiss { namespace ivflib { - - -/** check if two indexes have the same parameters and are trained in - * the same way, otherwise throw. */ -void check_compatible_for_merge (const Index * index1, - const Index * index2); - -/** get an IndexIVF from an index. The index may be an IndexIVF or - * some wrapper class that encloses an IndexIVF - * - * throws an exception if this is not the case. - */ -const IndexIVF * extract_index_ivf (const Index * index); -IndexIVF * extract_index_ivf (Index * index); - -/** Merge index1 into index0. Works on IndexIVF's and IndexIVF's - * embedded in a IndexPreTransform. On output, the index1 is empty. - * - * @param shift_ids: translate the ids from index1 to index0->prev_ntotal - */ -void merge_into(Index *index0, Index *index1, bool shift_ids); - -typedef Index::idx_t idx_t; - -/* Returns the cluster the embeddings belong to. - * - * @param index Index, which should be an IVF index - * (otherwise there are no clusters) - * @param embeddings object descriptors for which the centroids should be found, - * size num_objects * d - * @param centroid_ids - * cluster id each object belongs to, size num_objects - */ -void search_centroid(Index *index, - const float* x, int n, - idx_t* centroid_ids); - -/* Returns the cluster the embeddings belong to. - * - * @param index Index, which should be an IVF index - * (otherwise there are no clusters) - * @param query_centroid_ids - * centroid ids corresponding to the query vectors (size n) - * @param result_centroid_ids - * centroid ids corresponding to the results (size n * k) - * other arguments are the same as the standard search function - */ -void search_and_return_centroids(Index *index, - size_t n, - const float* xin, - long k, - float *distances, - idx_t* labels, - idx_t* query_centroid_ids, - idx_t* result_centroid_ids); - - -/** A set of IndexIVFs concatenated together in a FIFO fashion. - * at each "step", the oldest index slice is removed and a new index is added. - */ -struct SlidingIndexWindow { - /// common index that contains the sliding window - Index * index; - - /// InvertedLists of index - ArrayInvertedLists *ils; - - /// number of slices currently in index - int n_slice; - - /// same as index->nlist - size_t nlist; - - /// cumulative list sizes at each slice - std::vector > sizes; - - /// index should be initially empty and trained - SlidingIndexWindow (Index *index); - - /** Add one index to the current index and remove the oldest one. - * - * @param sub_index slice to swap in (can be NULL) - * @param remove_oldest if true, remove the oldest slices */ - void step(const Index *sub_index, bool remove_oldest); - -}; - - -/// Get a subset of inverted lists [i0, i1) -ArrayInvertedLists * get_invlist_range (const Index *index, - long i0, long i1); - -/// Set a subset of inverted lists -void set_invlist_range (Index *index, long i0, long i1, - ArrayInvertedLists * src); - - -// search an IndexIVF, possibly embedded in an IndexPreTransform -// with given parameters -void search_with_parameters (const Index *index, - idx_t n, const float *x, idx_t k, - float *distances, idx_t *labels, - IVFSearchParameters *params); - -} } // namespace faiss::ivflib - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/faiss/Index.h b/cpp/thirdparty/knowhere_build/include/faiss/Index.h deleted file mode 100644 index a1921c8364..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/Index.h +++ /dev/null @@ -1,221 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -#ifndef FAISS_INDEX_H -#define FAISS_INDEX_H - - -#include -#include -#include -#include - -#define FAISS_VERSION_MAJOR 1 -#define FAISS_VERSION_MINOR 5 -#define FAISS_VERSION_PATCH 3 - -/** - * @namespace faiss - * - * Throughout the library, vectors are provided as float * pointers. - * Most algorithms can be optimized when several vectors are processed - * (added/searched) together in a batch. In this case, they are passed - * in as a matrix. When n vectors of size d are provided as float * x, - * component j of vector i is - * - * x[ i * d + j ] - * - * where 0 <= i < n and 0 <= j < d. In other words, matrices are - * always compact. When specifying the size of the matrix, we call it - * an n*d matrix, which implies a row-major storage. - */ - - -namespace faiss { - - -/// Some algorithms support both an inner product version and a L2 search version. -enum MetricType { - METRIC_INNER_PRODUCT = 0, ///< maximum inner product search - METRIC_L2 = 1, ///< squared L2 search - METRIC_L1, ///< L1 (aka cityblock) - METRIC_Linf, ///< infinity distance - METRIC_Lp, ///< L_p distance, p is given by metric_arg - - /// some additional metrics defined in scipy.spatial.distance - METRIC_Canberra = 20, - METRIC_BrayCurtis, - METRIC_JensenShannon, - -}; - - -/// Forward declarations see AuxIndexStructures.h -struct IDSelector; -struct RangeSearchResult; -struct DistanceComputer; - -/** Abstract structure for an index - * - * Supports adding vertices and searching them. - * - * Currently only asymmetric queries are supported: - * database-to-database queries are not implemented. - */ -struct Index { - using idx_t = int64_t; ///< all indices are this type - using component_t = float; - using distance_t = float; - - int d; ///< vector dimension - idx_t ntotal; ///< total nb of indexed vectors - bool verbose; ///< verbosity level - - /// set if the Index does not require training, or if training is - /// done already - bool is_trained; - - /// type of metric this index uses for search - MetricType metric_type; - float metric_arg; ///< argument of the metric type - - explicit Index (idx_t d = 0, MetricType metric = METRIC_L2): - d(d), - ntotal(0), - verbose(false), - is_trained(true), - metric_type (metric), - metric_arg(0) {} - - virtual ~Index (); - - - /** Perform training on a representative set of vectors - * - * @param n nb of training vectors - * @param x training vecors, size n * d - */ - virtual void train(idx_t n, const float* x); - - /** Add n vectors of dimension d to the index. - * - * Vectors are implicitly assigned labels ntotal .. ntotal + n - 1 - * This function slices the input vectors in chuncks smaller than - * blocksize_add and calls add_core. - * @param x input matrix, size n * d - */ - virtual void add (idx_t n, const float *x) = 0; - - /** Same as add, but stores xids instead of sequential ids. - * - * The default implementation fails with an assertion, as it is - * not supported by all indexes. - * - * @param xids if non-null, ids to store for the vectors (size n) - */ - virtual void add_with_ids (idx_t n, const float * x, const idx_t *xids); - - /** query n vectors of dimension d to the index. - * - * return at most k vectors. If there are not enough results for a - * query, the result array is padded with -1s. - * - * @param x input vectors to search, size n * d - * @param labels output labels of the NNs, size n*k - * @param distances output pairwise distances, size n*k - */ - virtual void search (idx_t n, const float *x, idx_t k, - float *distances, idx_t *labels) const = 0; - - /** query n vectors of dimension d to the index. - * - * return all vectors with distance < radius. Note that many - * indexes do not implement the range_search (only the k-NN search - * is mandatory). - * - * @param x input vectors to search, size n * d - * @param radius search radius - * @param result result table - */ - virtual void range_search (idx_t n, const float *x, float radius, - RangeSearchResult *result) const; - - /** return the indexes of the k vectors closest to the query x. - * - * This function is identical as search but only return labels of neighbors. - * @param x input vectors to search, size n * d - * @param labels output labels of the NNs, size n*k - */ - void assign (idx_t n, const float * x, idx_t * labels, idx_t k = 1); - - /// removes all elements from the database. - virtual void reset() = 0; - - /** removes IDs from the index. Not supported by all - * indexes. Returns the number of elements removed. - */ - virtual size_t remove_ids (const IDSelector & sel); - - /** Reconstruct a stored vector (or an approximation if lossy coding) - * - * this function may not be defined for some indexes - * @param key id of the vector to reconstruct - * @param recons reconstucted vector (size d) - */ - virtual void reconstruct (idx_t key, float * recons) const; - - /** Reconstruct vectors i0 to i0 + ni - 1 - * - * this function may not be defined for some indexes - * @param recons reconstucted vector (size ni * d) - */ - virtual void reconstruct_n (idx_t i0, idx_t ni, float *recons) const; - - /** Similar to search, but also reconstructs the stored vectors (or an - * approximation in the case of lossy coding) for the search results. - * - * If there are not enough results for a query, the resulting arrays - * is padded with -1s. - * - * @param recons reconstructed vectors size (n, k, d) - **/ - virtual void search_and_reconstruct (idx_t n, const float *x, idx_t k, - float *distances, idx_t *labels, - float *recons) const; - - /** Computes a residual vector after indexing encoding. - * - * The residual vector is the difference between a vector and the - * reconstruction that can be decoded from its representation in - * the index. The residual can be used for multiple-stage indexing - * methods, like IndexIVF's methods. - * - * @param x input vector, size d - * @param residual output residual vector, size d - * @param key encoded index, as returned by search and assign - */ - void compute_residual (const float * x, float * residual, idx_t key) const; - - /** Display the actual class name and some more info */ - void display () const; - - /** Get a DistanceComputer (defined in AuxIndexStructures) object - * for this kind of index. - * - * DistanceComputer is implemented for indexes that support random - * access of their vectors. - */ - virtual DistanceComputer * get_distance_computer() const; - -}; - -} - - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/faiss/IndexBinary.h b/cpp/thirdparty/knowhere_build/include/faiss/IndexBinary.h deleted file mode 100644 index 83e95951af..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/IndexBinary.h +++ /dev/null @@ -1,163 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -#ifndef FAISS_INDEX_BINARY_H -#define FAISS_INDEX_BINARY_H - -#include -#include -#include -#include - -#include "FaissAssert.h" -#include "Index.h" - - -namespace faiss { - - -/// Forward declarations see AuxIndexStructures.h -struct IDSelector; -struct RangeSearchResult; - -/** Abstract structure for a binary index. - * - * Supports adding vertices and searching them. - * - * All queries are symmetric because there is no distinction between codes and - * vectors. - */ -struct IndexBinary { - using idx_t = Index::idx_t; ///< all indices are this type - using component_t = uint8_t; - using distance_t = int32_t; - - int d; ///< vector dimension - int code_size; ///< number of bytes per vector ( = d / 8 ) - idx_t ntotal; ///< total nb of indexed vectors - bool verbose; ///< verbosity level - - /// set if the Index does not require training, or if training is done already - bool is_trained; - - /// type of metric this index uses for search - MetricType metric_type; - - explicit IndexBinary(idx_t d = 0, MetricType metric = METRIC_L2) - : d(d), - code_size(d / 8), - ntotal(0), - verbose(false), - is_trained(true), - metric_type(metric) { - FAISS_THROW_IF_NOT(d % 8 == 0); - } - - virtual ~IndexBinary(); - - - /** Perform training on a representative set of vectors. - * - * @param n nb of training vectors - * @param x training vecors, size n * d / 8 - */ - virtual void train(idx_t n, const uint8_t *x); - - /** Add n vectors of dimension d to the index. - * - * Vectors are implicitly assigned labels ntotal .. ntotal + n - 1 - * @param x input matrix, size n * d / 8 - */ - virtual void add(idx_t n, const uint8_t *x) = 0; - - /** Same as add, but stores xids instead of sequential ids. - * - * The default implementation fails with an assertion, as it is - * not supported by all indexes. - * - * @param xids if non-null, ids to store for the vectors (size n) - */ - virtual void add_with_ids(idx_t n, const uint8_t *x, const idx_t *xids); - - /** Query n vectors of dimension d to the index. - * - * return at most k vectors. If there are not enough results for a - * query, the result array is padded with -1s. - * - * @param x input vectors to search, size n * d / 8 - * @param labels output labels of the NNs, size n*k - * @param distances output pairwise distances, size n*k - */ - virtual void search(idx_t n, const uint8_t *x, idx_t k, - int32_t *distances, idx_t *labels) const = 0; - - /** Query n vectors of dimension d to the index. - * - * return all vectors with distance < radius. Note that many - * indexes do not implement the range_search (only the k-NN search - * is mandatory). - * - * @param x input vectors to search, size n * d / 8 - * @param radius search radius - * @param result result table - */ - virtual void range_search(idx_t n, const uint8_t *x, int radius, - RangeSearchResult *result) const; - - /** Return the indexes of the k vectors closest to the query x. - * - * This function is identical to search but only returns labels of neighbors. - * @param x input vectors to search, size n * d / 8 - * @param labels output labels of the NNs, size n*k - */ - void assign(idx_t n, const uint8_t *x, idx_t *labels, idx_t k = 1); - - /// Removes all elements from the database. - virtual void reset() = 0; - - /** Removes IDs from the index. Not supported by all indexes. - */ - virtual size_t remove_ids(const IDSelector& sel); - - /** Reconstruct a stored vector. - * - * This function may not be defined for some indexes. - * @param key id of the vector to reconstruct - * @param recons reconstucted vector (size d / 8) - */ - virtual void reconstruct(idx_t key, uint8_t *recons) const; - - - /** Reconstruct vectors i0 to i0 + ni - 1. - * - * This function may not be defined for some indexes. - * @param recons reconstucted vectors (size ni * d / 8) - */ - virtual void reconstruct_n(idx_t i0, idx_t ni, uint8_t *recons) const; - - /** Similar to search, but also reconstructs the stored vectors (or an - * approximation in the case of lossy coding) for the search results. - * - * If there are not enough results for a query, the resulting array - * is padded with -1s. - * - * @param recons reconstructed vectors size (n, k, d) - **/ - virtual void search_and_reconstruct(idx_t n, const uint8_t *x, idx_t k, - int32_t *distances, idx_t *labels, - uint8_t *recons) const; - - /** Display the actual class name and some more info. */ - void display() const; -}; - - -} // namespace faiss - -#endif // FAISS_INDEX_BINARY_H diff --git a/cpp/thirdparty/knowhere_build/include/faiss/IndexBinaryFlat.h b/cpp/thirdparty/knowhere_build/include/faiss/IndexBinaryFlat.h deleted file mode 100644 index 4e14884a2c..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/IndexBinaryFlat.h +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -#ifndef INDEX_BINARY_FLAT_H -#define INDEX_BINARY_FLAT_H - -#include - -#include "IndexBinary.h" - -namespace faiss { - - -/** Index that stores the full vectors and performs exhaustive search. */ -struct IndexBinaryFlat : IndexBinary { - /// database vectors, size ntotal * d / 8 - std::vector xb; - - /** Select between using a heap or counting to select the k smallest values - * when scanning inverted lists. - */ - bool use_heap = true; - - size_t query_batch_size = 32; - - explicit IndexBinaryFlat(idx_t d); - - void add(idx_t n, const uint8_t *x) override; - - void reset() override; - - void search(idx_t n, const uint8_t *x, idx_t k, - int32_t *distances, idx_t *labels) const override; - - void reconstruct(idx_t key, uint8_t *recons) const override; - - /** Remove some ids. Note that because of the indexing structure, - * the semantics of this operation are different from the usual ones: - * the new ids are shifted. */ - size_t remove_ids(const IDSelector& sel) override; - - IndexBinaryFlat() {} -}; - - -} // namespace faiss - -#endif // INDEX_BINARY_FLAT_H diff --git a/cpp/thirdparty/knowhere_build/include/faiss/IndexBinaryFromFloat.h b/cpp/thirdparty/knowhere_build/include/faiss/IndexBinaryFromFloat.h deleted file mode 100644 index b6c3d1fc4d..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/IndexBinaryFromFloat.h +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -#ifndef FAISS_INDEX_BINARY_FROM_FLOAT_H -#define FAISS_INDEX_BINARY_FROM_FLOAT_H - -#include "IndexBinary.h" - - -namespace faiss { - - -struct Index; - -/** IndexBinary backed by a float Index. - * - * Supports adding vertices and searching them. - * - * All queries are symmetric because there is no distinction between codes and - * vectors. - */ -struct IndexBinaryFromFloat : IndexBinary { - Index *index = nullptr; - - bool own_fields = false; ///< Whether object owns the index pointer. - - IndexBinaryFromFloat(); - - explicit IndexBinaryFromFloat(Index *index); - - ~IndexBinaryFromFloat(); - - void add(idx_t n, const uint8_t *x) override; - - void reset() override; - - void search(idx_t n, const uint8_t *x, idx_t k, - int32_t *distances, idx_t *labels) const override; - - void train(idx_t n, const uint8_t *x) override; -}; - - -} // namespace faiss - -#endif // FAISS_INDEX_BINARY_FROM_FLOAT_H diff --git a/cpp/thirdparty/knowhere_build/include/faiss/IndexBinaryHNSW.h b/cpp/thirdparty/knowhere_build/include/faiss/IndexBinaryHNSW.h deleted file mode 100644 index f46addfaea..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/IndexBinaryHNSW.h +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -#pragma once - -#include "HNSW.h" -#include "IndexBinaryFlat.h" -#include "utils.h" - - -namespace faiss { - - -/** The HNSW index is a normal random-access index with a HNSW - * link structure built on top */ - -struct IndexBinaryHNSW : IndexBinary { - typedef HNSW::storage_idx_t storage_idx_t; - - // the link strcuture - HNSW hnsw; - - // the sequential storage - bool own_fields; - IndexBinary *storage; - - explicit IndexBinaryHNSW(); - explicit IndexBinaryHNSW(int d, int M = 32); - explicit IndexBinaryHNSW(IndexBinary *storage, int M = 32); - - ~IndexBinaryHNSW() override; - - DistanceComputer *get_distance_computer() const; - - void add(idx_t n, const uint8_t *x) override; - - /// Trains the storage if needed - void train(idx_t n, const uint8_t* x) override; - - /// entry point for search - void search(idx_t n, const uint8_t *x, idx_t k, - int32_t *distances, idx_t *labels) const override; - - void reconstruct(idx_t key, uint8_t* recons) const override; - - void reset() override; -}; - - -} // namespace faiss diff --git a/cpp/thirdparty/knowhere_build/include/faiss/IndexBinaryIVF.h b/cpp/thirdparty/knowhere_build/include/faiss/IndexBinaryIVF.h deleted file mode 100644 index 497223a242..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/IndexBinaryIVF.h +++ /dev/null @@ -1,211 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -#ifndef FAISS_INDEX_BINARY_IVF_H -#define FAISS_INDEX_BINARY_IVF_H - - -#include - -#include "IndexBinary.h" -#include "IndexIVF.h" -#include "Clustering.h" -#include "Heap.h" - - -namespace faiss { - -struct BinaryInvertedListScanner; - -/** Index based on a inverted file (IVF) - * - * In the inverted file, the quantizer (an IndexBinary instance) provides a - * quantization index for each vector to be added. The quantization - * index maps to a list (aka inverted list or posting list), where the - * id of the vector is stored. - * - * Otherwise the object is similar to the IndexIVF - */ -struct IndexBinaryIVF : IndexBinary { - /// Acess to the actual data - InvertedLists *invlists; - bool own_invlists; - - size_t nprobe; ///< number of probes at query time - size_t max_codes; ///< max nb of codes to visit to do a query - - /** Select between using a heap or counting to select the k smallest values - * when scanning inverted lists. - */ - bool use_heap = true; - - /// map for direct access to the elements. Enables reconstruct(). - bool maintain_direct_map; - std::vector direct_map; - - IndexBinary *quantizer; ///< quantizer that maps vectors to inverted lists - size_t nlist; ///< number of possible key values - - bool own_fields; ///< whether object owns the quantizer - - ClusteringParameters cp; ///< to override default clustering params - Index *clustering_index; ///< to override index used during clustering - - /** The Inverted file takes a quantizer (an IndexBinary) on input, - * which implements the function mapping a vector to a list - * identifier. The pointer is borrowed: the quantizer should not - * be deleted while the IndexBinaryIVF is in use. - */ - IndexBinaryIVF(IndexBinary *quantizer, size_t d, size_t nlist); - - IndexBinaryIVF(); - - ~IndexBinaryIVF() override; - - void reset() override; - - /// Trains the quantizer - void train(idx_t n, const uint8_t *x) override; - - void add(idx_t n, const uint8_t *x) override; - - void add_with_ids(idx_t n, const uint8_t *x, const idx_t *xids) override; - - /// same as add_with_ids, with precomputed coarse quantizer - void add_core (idx_t n, const uint8_t * x, const idx_t *xids, - const idx_t *precomputed_idx); - - /** Search a set of vectors, that are pre-quantized by the IVF - * quantizer. Fill in the corresponding heaps with the query - * results. search() calls this. - * - * @param n nb of vectors to query - * @param x query vectors, size nx * d - * @param assign coarse quantization indices, size nx * nprobe - * @param centroid_dis - * distances to coarse centroids, size nx * nprobe - * @param distance - * output distances, size n * k - * @param labels output labels, size n * k - * @param store_pairs store inv list index + inv list offset - * instead in upper/lower 32 bit of result, - * instead of ids (used for reranking). - * @param params used to override the object's search parameters - */ - void search_preassigned(idx_t n, const uint8_t *x, idx_t k, - const idx_t *assign, - const int32_t *centroid_dis, - int32_t *distances, idx_t *labels, - bool store_pairs, - const IVFSearchParameters *params=nullptr - ) const; - - virtual BinaryInvertedListScanner *get_InvertedListScanner ( - bool store_pairs=false) const; - - /** assign the vectors, then call search_preassign */ - virtual void search(idx_t n, const uint8_t *x, idx_t k, - int32_t *distances, idx_t *labels) const override; - - void reconstruct(idx_t key, uint8_t *recons) const override; - - /** Reconstruct a subset of the indexed vectors. - * - * Overrides default implementation to bypass reconstruct() which requires - * direct_map to be maintained. - * - * @param i0 first vector to reconstruct - * @param ni nb of vectors to reconstruct - * @param recons output array of reconstructed vectors, size ni * d / 8 - */ - void reconstruct_n(idx_t i0, idx_t ni, uint8_t *recons) const override; - - /** Similar to search, but also reconstructs the stored vectors (or an - * approximation in the case of lossy coding) for the search results. - * - * Overrides default implementation to avoid having to maintain direct_map - * and instead fetch the code offsets through the `store_pairs` flag in - * search_preassigned(). - * - * @param recons reconstructed vectors size (n, k, d / 8) - */ - void search_and_reconstruct(idx_t n, const uint8_t *x, idx_t k, - int32_t *distances, idx_t *labels, - uint8_t *recons) const override; - - /** Reconstruct a vector given the location in terms of (inv list index + - * inv list offset) instead of the id. - * - * Useful for reconstructing when the direct_map is not maintained and - * the inv list offset is computed by search_preassigned() with - * `store_pairs` set. - */ - virtual void reconstruct_from_offset(idx_t list_no, idx_t offset, - uint8_t* recons) const; - - - /// Dataset manipulation functions - size_t remove_ids(const IDSelector& sel) override; - - /** moves the entries from another dataset to self. On output, - * other is empty. add_id is added to all moved ids (for - * sequential ids, this would be this->ntotal */ - virtual void merge_from(IndexBinaryIVF& other, idx_t add_id); - - size_t get_list_size(size_t list_no) const - { return invlists->list_size(list_no); } - - /** intialize a direct map - * - * @param new_maintain_direct_map if true, create a direct map, - * else clear it - */ - void make_direct_map(bool new_maintain_direct_map=true); - - void replace_invlists(InvertedLists *il, bool own=false); -}; - - -struct BinaryInvertedListScanner { - - using idx_t = Index::idx_t; - - /// from now on we handle this query. - virtual void set_query (const uint8_t *query_vector) = 0; - - /// following codes come from this inverted list - virtual void set_list (idx_t list_no, uint8_t coarse_dis) = 0; - - /// compute a single query-to-code distance - virtual uint32_t distance_to_code (const uint8_t *code) const = 0; - - /** compute the distances to codes. (distances, labels) should be - * organized as a min- or max-heap - * - * @param n number of codes to scan - * @param codes codes to scan (n * code_size) - * @param ids corresponding ids (ignored if store_pairs) - * @param distances heap distances (size k) - * @param labels heap labels (size k) - * @param k heap size - */ - virtual size_t scan_codes (size_t n, - const uint8_t *codes, - const idx_t *ids, - int32_t *distances, idx_t *labels, - size_t k) const = 0; - - virtual ~BinaryInvertedListScanner () {} - -}; - - -} // namespace faiss - -#endif // FAISS_INDEX_BINARY_IVF_H diff --git a/cpp/thirdparty/knowhere_build/include/faiss/IndexFlat.h b/cpp/thirdparty/knowhere_build/include/faiss/IndexFlat.h deleted file mode 100644 index 3f8cff90ee..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/IndexFlat.h +++ /dev/null @@ -1,165 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -#ifndef INDEX_FLAT_H -#define INDEX_FLAT_H - -#include - -#include "Index.h" - - -namespace faiss { - -/** Index that stores the full vectors and performs exhaustive search */ -struct IndexFlat: Index { - /// database vectors, size ntotal * d - std::vector xb; - - explicit IndexFlat (idx_t d, MetricType metric = METRIC_L2); - - void add(idx_t n, const float* x) override; - - void reset() override; - - void search( - idx_t n, - const float* x, - idx_t k, - float* distances, - idx_t* labels) const override; - - void range_search( - idx_t n, - const float* x, - float radius, - RangeSearchResult* result) const override; - - void reconstruct(idx_t key, float* recons) const override; - - /** compute distance with a subset of vectors - * - * @param x query vectors, size n * d - * @param labels indices of the vectors that should be compared - * for each query vector, size n * k - * @param distances - * corresponding output distances, size n * k - */ - void compute_distance_subset ( - idx_t n, - const float *x, - idx_t k, - float *distances, - const idx_t *labels) const; - - /** remove some ids. NB that Because of the structure of the - * indexing structre, the semantics of this operation are - * different from the usual ones: the new ids are shifted */ - size_t remove_ids(const IDSelector& sel) override; - - IndexFlat () {} - - DistanceComputer * get_distance_computer() const override; -}; - - - -struct IndexFlatIP:IndexFlat { - explicit IndexFlatIP (idx_t d): IndexFlat (d, METRIC_INNER_PRODUCT) {} - IndexFlatIP () {} -}; - - -struct IndexFlatL2:IndexFlat { - explicit IndexFlatL2 (idx_t d): IndexFlat (d, METRIC_L2) {} - IndexFlatL2 () {} -}; - - -// same as an IndexFlatL2 but a value is subtracted from each distance -struct IndexFlatL2BaseShift: IndexFlatL2 { - std::vector shift; - - IndexFlatL2BaseShift (idx_t d, size_t nshift, const float *shift); - - void search( - idx_t n, - const float* x, - idx_t k, - float* distances, - idx_t* labels) const override; -}; - - -/** Index that queries in a base_index (a fast one) and refines the - * results with an exact search, hopefully improving the results. - */ -struct IndexRefineFlat: Index { - - /// storage for full vectors - IndexFlat refine_index; - - /// faster index to pre-select the vectors that should be filtered - Index *base_index; - bool own_fields; ///< should the base index be deallocated? - - /// factor between k requested in search and the k requested from - /// the base_index (should be >= 1) - float k_factor; - - explicit IndexRefineFlat (Index *base_index); - - IndexRefineFlat (); - - void train(idx_t n, const float* x) override; - - void add(idx_t n, const float* x) override; - - void reset() override; - - void search( - idx_t n, - const float* x, - idx_t k, - float* distances, - idx_t* labels) const override; - - ~IndexRefineFlat() override; -}; - - -/// optimized version for 1D "vectors" -struct IndexFlat1D:IndexFlatL2 { - bool continuous_update; ///< is the permutation updated continuously? - - std::vector perm; ///< sorted database indices - - explicit IndexFlat1D (bool continuous_update=true); - - /// if not continuous_update, call this between the last add and - /// the first search - void update_permutation (); - - void add(idx_t n, const float* x) override; - - void reset() override; - - /// Warn: the distances returned are L1 not L2 - void search( - idx_t n, - const float* x, - idx_t k, - float* distances, - idx_t* labels) const override; -}; - - -} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/faiss/IndexHNSW.h b/cpp/thirdparty/knowhere_build/include/faiss/IndexHNSW.h deleted file mode 100644 index ddc1dbfbaf..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/IndexHNSW.h +++ /dev/null @@ -1,170 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -#pragma once - -#include - -#include "HNSW.h" -#include "IndexFlat.h" -#include "IndexPQ.h" -#include "IndexScalarQuantizer.h" -#include "utils.h" - - -namespace faiss { - -struct IndexHNSW; - -struct ReconstructFromNeighbors { - typedef Index::idx_t idx_t; - typedef HNSW::storage_idx_t storage_idx_t; - - const IndexHNSW & index; - size_t M; // number of neighbors - size_t k; // number of codebook entries - size_t nsq; // number of subvectors - size_t code_size; - int k_reorder; // nb to reorder. -1 = all - - std::vector codebook; // size nsq * k * (M + 1) - - std::vector codes; // size ntotal * code_size - size_t ntotal; - size_t d, dsub; // derived values - - explicit ReconstructFromNeighbors(const IndexHNSW& index, - size_t k=256, size_t nsq=1); - - /// codes must be added in the correct order and the IndexHNSW - /// must be populated and sorted - void add_codes(size_t n, const float *x); - - size_t compute_distances(size_t n, const idx_t *shortlist, - const float *query, float *distances) const; - - /// called by add_codes - void estimate_code(const float *x, storage_idx_t i, uint8_t *code) const; - - /// called by compute_distances - void reconstruct(storage_idx_t i, float *x, float *tmp) const; - - void reconstruct_n(storage_idx_t n0, storage_idx_t ni, float *x) const; - - /// get the M+1 -by-d table for neighbor coordinates for vector i - void get_neighbor_table(storage_idx_t i, float *out) const; - -}; - - -/** The HNSW index is a normal random-access index with a HNSW - * link structure built on top */ - -struct IndexHNSW : Index { - - typedef HNSW::storage_idx_t storage_idx_t; - - // the link strcuture - HNSW hnsw; - - // the sequential storage - bool own_fields; - Index *storage; - - ReconstructFromNeighbors *reconstruct_from_neighbors; - - explicit IndexHNSW (int d = 0, int M = 32); - explicit IndexHNSW (Index *storage, int M = 32); - - ~IndexHNSW() override; - - void add(idx_t n, const float *x) override; - - /// Trains the storage if needed - void train(idx_t n, const float* x) override; - - /// entry point for search - void search (idx_t n, const float *x, idx_t k, - float *distances, idx_t *labels) const override; - - void reconstruct(idx_t key, float* recons) const override; - - void reset () override; - - void shrink_level_0_neighbors(int size); - - /** Perform search only on level 0, given the starting points for - * each vertex. - * - * @param search_type 1:perform one search per nprobe, 2: enqueue - * all entry points - */ - void search_level_0(idx_t n, const float *x, idx_t k, - const storage_idx_t *nearest, const float *nearest_d, - float *distances, idx_t *labels, int nprobe = 1, - int search_type = 1) const; - - /// alternative graph building - void init_level_0_from_knngraph( - int k, const float *D, const idx_t *I); - - /// alternative graph building - void init_level_0_from_entry_points( - int npt, const storage_idx_t *points, - const storage_idx_t *nearests); - - // reorder links from nearest to farthest - void reorder_links(); - - void link_singletons(); -}; - - -/** Flat index topped with with a HNSW structure to access elements - * more efficiently. - */ - -struct IndexHNSWFlat : IndexHNSW { - IndexHNSWFlat(); - IndexHNSWFlat(int d, int M); -}; - -/** PQ index topped with with a HNSW structure to access elements - * more efficiently. - */ -struct IndexHNSWPQ : IndexHNSW { - IndexHNSWPQ(); - IndexHNSWPQ(int d, int pq_m, int M); - void train(idx_t n, const float* x) override; -}; - -/** SQ index topped with with a HNSW structure to access elements - * more efficiently. - */ -struct IndexHNSWSQ : IndexHNSW { - IndexHNSWSQ(); - IndexHNSWSQ(int d, ScalarQuantizer::QuantizerType qtype, int M); -}; - -/** 2-level code structure with fast random access - */ -struct IndexHNSW2Level : IndexHNSW { - IndexHNSW2Level(); - IndexHNSW2Level(Index *quantizer, size_t nlist, int m_pq, int M); - - void flip_to_ivf(); - - /// entry point for search - void search (idx_t n, const float *x, idx_t k, - float *distances, idx_t *labels) const override; - -}; - - -} // namespace faiss diff --git a/cpp/thirdparty/knowhere_build/include/faiss/IndexIVF.h b/cpp/thirdparty/knowhere_build/include/faiss/IndexIVF.h deleted file mode 100644 index 4584cdc324..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/IndexIVF.h +++ /dev/null @@ -1,336 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -#ifndef FAISS_INDEX_IVF_H -#define FAISS_INDEX_IVF_H - - -#include -#include - -#include "Index.h" -#include "InvertedLists.h" -#include "Clustering.h" -#include "Heap.h" - - -namespace faiss { - - -/** Encapsulates a quantizer object for the IndexIVF - * - * The class isolates the fields that are independent of the storage - * of the lists (especially training) - */ -struct Level1Quantizer { - Index * quantizer; ///< quantizer that maps vectors to inverted lists - size_t nlist; ///< number of possible key values - - /** - * = 0: use the quantizer as index in a kmeans training - * = 1: just pass on the training set to the train() of the quantizer - * = 2: kmeans training on a flat index + add the centroids to the quantizer - */ - char quantizer_trains_alone; - bool own_fields; ///< whether object owns the quantizer - - ClusteringParameters cp; ///< to override default clustering params - Index *clustering_index; ///< to override index used during clustering - - /// Trains the quantizer and calls train_residual to train sub-quantizers - void train_q1 (size_t n, const float *x, bool verbose, - MetricType metric_type); - - Level1Quantizer (Index * quantizer, size_t nlist); - - Level1Quantizer (); - - ~Level1Quantizer (); - -}; - - - -struct IVFSearchParameters { - size_t nprobe; ///< number of probes at query time - size_t max_codes; ///< max nb of codes to visit to do a query - virtual ~IVFSearchParameters () {} -}; - - - -struct InvertedListScanner; - -/** Index based on a inverted file (IVF) - * - * In the inverted file, the quantizer (an Index instance) provides a - * quantization index for each vector to be added. The quantization - * index maps to a list (aka inverted list or posting list), where the - * id of the vector is stored. - * - * The inverted list object is required only after trainng. If none is - * set externally, an ArrayInvertedLists is used automatically. - * - * At search time, the vector to be searched is also quantized, and - * only the list corresponding to the quantization index is - * searched. This speeds up the search by making it - * non-exhaustive. This can be relaxed using multi-probe search: a few - * (nprobe) quantization indices are selected and several inverted - * lists are visited. - * - * Sub-classes implement a post-filtering of the index that refines - * the distance estimation from the query to databse vectors. - */ -struct IndexIVF: Index, Level1Quantizer { - /// Acess to the actual data - InvertedLists *invlists; - bool own_invlists; - - size_t code_size; ///< code size per vector in bytes - - size_t nprobe; ///< number of probes at query time - size_t max_codes; ///< max nb of codes to visit to do a query - - /** Parallel mode determines how queries are parallelized with OpenMP - * - * 0 (default): parallelize over queries - * 1: parallelize over over inverted lists - * 2: parallelize over both - */ - int parallel_mode; - - /// map for direct access to the elements. Enables reconstruct(). - bool maintain_direct_map; - std::vector direct_map; - - /** The Inverted file takes a quantizer (an Index) on input, - * which implements the function mapping a vector to a list - * identifier. The pointer is borrowed: the quantizer should not - * be deleted while the IndexIVF is in use. - */ - IndexIVF (Index * quantizer, size_t d, - size_t nlist, size_t code_size, - MetricType metric = METRIC_L2); - - void reset() override; - - /// Trains the quantizer and calls train_residual to train sub-quantizers - void train(idx_t n, const float* x) override; - - /// Calls add_with_ids with NULL ids - void add(idx_t n, const float* x) override; - - /// default implementation that calls encode_vectors - void add_with_ids(idx_t n, const float* x, const idx_t* xids) override; - - /** Encodes a set of vectors as they would appear in the inverted lists - * - * @param list_nos inverted list ids as returned by the - * quantizer (size n). -1s are ignored. - * @param codes output codes, size n * code_size - */ - virtual void encode_vectors(idx_t n, const float* x, - const idx_t *list_nos, - uint8_t * codes) const = 0; - - /// Sub-classes that encode the residuals can train their encoders here - /// does nothing by default - virtual void train_residual (idx_t n, const float *x); - - /** search a set of vectors, that are pre-quantized by the IVF - * quantizer. Fill in the corresponding heaps with the query - * results. The default implementation uses InvertedListScanners - * to do the search. - * - * @param n nb of vectors to query - * @param x query vectors, size nx * d - * @param assign coarse quantization indices, size nx * nprobe - * @param centroid_dis - * distances to coarse centroids, size nx * nprobe - * @param distance - * output distances, size n * k - * @param labels output labels, size n * k - * @param store_pairs store inv list index + inv list offset - * instead in upper/lower 32 bit of result, - * instead of ids (used for reranking). - * @param params used to override the object's search parameters - */ - virtual void search_preassigned (idx_t n, const float *x, idx_t k, - const idx_t *assign, - const float *centroid_dis, - float *distances, idx_t *labels, - bool store_pairs, - const IVFSearchParameters *params=nullptr - ) const; - - /** assign the vectors, then call search_preassign */ - void search (idx_t n, const float *x, idx_t k, - float *distances, idx_t *labels) const override; - - void range_search (idx_t n, const float* x, float radius, - RangeSearchResult* result) const override; - - void range_search_preassigned(idx_t nx, const float *x, float radius, - const idx_t *keys, const float *coarse_dis, - RangeSearchResult *result) const; - - /// get a scanner for this index (store_pairs means ignore labels) - virtual InvertedListScanner *get_InvertedListScanner ( - bool store_pairs=false) const; - - void reconstruct (idx_t key, float* recons) const override; - - /** Reconstruct a subset of the indexed vectors. - * - * Overrides default implementation to bypass reconstruct() which requires - * direct_map to be maintained. - * - * @param i0 first vector to reconstruct - * @param ni nb of vectors to reconstruct - * @param recons output array of reconstructed vectors, size ni * d - */ - void reconstruct_n(idx_t i0, idx_t ni, float* recons) const override; - - /** Similar to search, but also reconstructs the stored vectors (or an - * approximation in the case of lossy coding) for the search results. - * - * Overrides default implementation to avoid having to maintain direct_map - * and instead fetch the code offsets through the `store_pairs` flag in - * search_preassigned(). - * - * @param recons reconstructed vectors size (n, k, d) - */ - void search_and_reconstruct (idx_t n, const float *x, idx_t k, - float *distances, idx_t *labels, - float *recons) const override; - - /** Reconstruct a vector given the location in terms of (inv list index + - * inv list offset) instead of the id. - * - * Useful for reconstructing when the direct_map is not maintained and - * the inv list offset is computed by search_preassigned() with - * `store_pairs` set. - */ - virtual void reconstruct_from_offset (int64_t list_no, int64_t offset, - float* recons) const; - - - /// Dataset manipulation functions - - size_t remove_ids(const IDSelector& sel) override; - - /** check that the two indexes are compatible (ie, they are - * trained in the same way and have the same - * parameters). Otherwise throw. */ - void check_compatible_for_merge (const IndexIVF &other) const; - - /** moves the entries from another dataset to self. On output, - * other is empty. add_id is added to all moved ids (for - * sequential ids, this would be this->ntotal */ - virtual void merge_from (IndexIVF &other, idx_t add_id); - - /** copy a subset of the entries index to the other index - * - * if subset_type == 0: copies ids in [a1, a2) - * if subset_type == 1: copies ids if id % a1 == a2 - * if subset_type == 2: copies inverted lists such that a1 - * elements are left before and a2 elements are after - */ - virtual void copy_subset_to (IndexIVF & other, int subset_type, - idx_t a1, idx_t a2) const; - - ~IndexIVF() override; - - size_t get_list_size (size_t list_no) const - { return invlists->list_size(list_no); } - - /** intialize a direct map - * - * @param new_maintain_direct_map if true, create a direct map, - * else clear it - */ - void make_direct_map (bool new_maintain_direct_map=true); - - /// replace the inverted lists, old one is deallocated if own_invlists - void replace_invlists (InvertedLists *il, bool own=false); - - IndexIVF (); -}; - -struct RangeQueryResult; - -/** Object that handles a query. The inverted lists to scan are - * provided externally. The object has a lot of state, but - * distance_to_code and scan_codes can be called in multiple - * threads */ -struct InvertedListScanner { - - using idx_t = Index::idx_t; - - /// from now on we handle this query. - virtual void set_query (const float *query_vector) = 0; - - /// following codes come from this inverted list - virtual void set_list (idx_t list_no, float coarse_dis) = 0; - - /// compute a single query-to-code distance - virtual float distance_to_code (const uint8_t *code) const = 0; - - /** scan a set of codes, compute distances to current query and - * update heap of results if necessary. - * - * @param n number of codes to scan - * @param codes codes to scan (n * code_size) - * @param ids corresponding ids (ignored if store_pairs) - * @param distances heap distances (size k) - * @param labels heap labels (size k) - * @param k heap size - * @return number of heap updates performed - */ - virtual size_t scan_codes (size_t n, - const uint8_t *codes, - const idx_t *ids, - float *distances, idx_t *labels, - size_t k) const = 0; - - /** scan a set of codes, compute distances to current query and - * update results if distances are below radius - * - * (default implementation fails) */ - virtual void scan_codes_range (size_t n, - const uint8_t *codes, - const idx_t *ids, - float radius, - RangeQueryResult &result) const; - - virtual ~InvertedListScanner () {} - -}; - - -struct IndexIVFStats { - size_t nq; // nb of queries run - size_t nlist; // nb of inverted lists scanned - size_t ndis; // nb of distancs computed - size_t nheap_updates; // nb of times the heap was updated - double quantization_time; // time spent quantizing vectors (in ms) - double search_time; // time spent searching lists (in ms) - - IndexIVFStats () {reset (); } - void reset (); -}; - -// global var that collects them all -extern IndexIVFStats indexIVF_stats; - - -} // namespace faiss - - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/faiss/IndexIVFFlat.h b/cpp/thirdparty/knowhere_build/include/faiss/IndexIVFFlat.h deleted file mode 100644 index ffc0f123b0..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/IndexIVFFlat.h +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -#ifndef FAISS_INDEX_IVF_FLAT_H -#define FAISS_INDEX_IVF_FLAT_H - -#include -#include - -#include "IndexIVF.h" - - -namespace faiss { - -/** Inverted file with stored vectors. Here the inverted file - * pre-selects the vectors to be searched, but they are not otherwise - * encoded, the code array just contains the raw float entries. - */ -struct IndexIVFFlat: IndexIVF { - - IndexIVFFlat ( - Index * quantizer, size_t d, size_t nlist_, - MetricType = METRIC_L2); - - /// same as add_with_ids, with precomputed coarse quantizer - virtual void add_core (idx_t n, const float * x, const int64_t *xids, - const int64_t *precomputed_idx); - - /// implemented for all IndexIVF* classes - void add_with_ids(idx_t n, const float* x, const idx_t* xids) override; - - void encode_vectors(idx_t n, const float* x, - const idx_t *list_nos, - uint8_t * codes) const override; - - - InvertedListScanner *get_InvertedListScanner (bool store_pairs) - const override; - - /** Update a subset of vectors. - * - * The index must have a direct_map - * - * @param nv nb of vectors to update - * @param idx vector indices to update, size nv - * @param v vectors of new values, size nv*d - */ - virtual void update_vectors (int nv, idx_t *idx, const float *v); - - void reconstruct_from_offset (int64_t list_no, int64_t offset, - float* recons) const override; - - IndexIVFFlat () {} -}; - - -struct IndexIVFFlatDedup: IndexIVFFlat { - - /** Maps ids stored in the index to the ids of vectors that are - * the same. When a vector is unique, it does not appear in the - * instances map */ - std::unordered_multimap instances; - - IndexIVFFlatDedup ( - Index * quantizer, size_t d, size_t nlist_, - MetricType = METRIC_L2); - - /// also dedups the training set - void train(idx_t n, const float* x) override; - - /// implemented for all IndexIVF* classes - void add_with_ids(idx_t n, const float* x, const idx_t* xids) override; - - void search_preassigned (idx_t n, const float *x, idx_t k, - const idx_t *assign, - const float *centroid_dis, - float *distances, idx_t *labels, - bool store_pairs, - const IVFSearchParameters *params=nullptr - ) const override; - - size_t remove_ids(const IDSelector& sel) override; - - /// not implemented - void range_search( - idx_t n, - const float* x, - float radius, - RangeSearchResult* result) const override; - - /// not implemented - void update_vectors (int nv, idx_t *idx, const float *v) override; - - - /// not implemented - void reconstruct_from_offset (int64_t list_no, int64_t offset, - float* recons) const override; - - IndexIVFFlatDedup () {} - - -}; - - - -} // namespace faiss - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/faiss/IndexIVFPQ.h b/cpp/thirdparty/knowhere_build/include/faiss/IndexIVFPQ.h deleted file mode 100644 index 749ca13e42..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/IndexIVFPQ.h +++ /dev/null @@ -1,258 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -#ifndef FAISS_INDEX_IVFPQ_H -#define FAISS_INDEX_IVFPQ_H - - -#include - -#include "IndexIVF.h" -#include "IndexPQ.h" - - -namespace faiss { - -struct IVFPQSearchParameters: IVFSearchParameters { - size_t scan_table_threshold; ///< use table computation or on-the-fly? - int polysemous_ht; ///< Hamming thresh for polysemous filtering - ~IVFPQSearchParameters () {} -}; - - - - -/** Inverted file with Product Quantizer encoding. Each residual - * vector is encoded as a product quantizer code. - */ -struct IndexIVFPQ: IndexIVF { - bool by_residual; ///< Encode residual or plain vector? - - ProductQuantizer pq; ///< produces the codes - - bool do_polysemous_training; ///< reorder PQ centroids after training? - PolysemousTraining *polysemous_training; ///< if NULL, use default - - // search-time parameters - size_t scan_table_threshold; ///< use table computation or on-the-fly? - int polysemous_ht; ///< Hamming thresh for polysemous filtering - - /** Precompute table that speed up query preprocessing at some - * memory cost - * =-1: force disable - * =0: decide heuristically (default: use tables only if they are - * < precomputed_tables_max_bytes) - * =1: tables that work for all quantizers (size 256 * nlist * M) - * =2: specific version for MultiIndexQuantizer (much more compact) - */ - int use_precomputed_table; ///< if by_residual, build precompute tables - static size_t precomputed_table_max_bytes; - - /// if use_precompute_table - /// size nlist * pq.M * pq.ksub - std::vector precomputed_table; - - IndexIVFPQ ( - Index * quantizer, size_t d, size_t nlist, - size_t M, size_t nbits_per_idx); - - void add_with_ids(idx_t n, const float* x, const idx_t* xids = nullptr) - override; - - void encode_vectors(idx_t n, const float* x, - const idx_t *list_nos, - uint8_t * codes) const override; - - /// same as add_core, also: - /// - output 2nd level residuals if residuals_2 != NULL - /// - use precomputed list numbers if precomputed_idx != NULL - void add_core_o (idx_t n, const float *x, - const idx_t *xids, float *residuals_2, - const idx_t *precomputed_idx = nullptr); - - /// trains the product quantizer - void train_residual(idx_t n, const float* x) override; - - /// same as train_residual, also output 2nd level residuals - void train_residual_o (idx_t n, const float *x, float *residuals_2); - - void reconstruct_from_offset (int64_t list_no, int64_t offset, - float* recons) const override; - - /** Find exact duplicates in the dataset. - * - * the duplicates are returned in pre-allocated arrays (see the - * max sizes). - * - * @params lims limits between groups of duplicates - * (max size ntotal / 2 + 1) - * @params ids ids[lims[i]] : ids[lims[i+1]-1] is a group of - * duplicates (max size ntotal) - * @return n number of groups found - */ - size_t find_duplicates (idx_t *ids, size_t *lims) const; - - // map a vector to a binary code knowning the index - void encode (idx_t key, const float * x, uint8_t * code) const; - - /** Encode multiple vectors - * - * @param n nb vectors to encode - * @param keys posting list ids for those vectors (size n) - * @param x vectors (size n * d) - * @param codes output codes (size n * code_size) - * @param compute_keys if false, assume keys are precomputed, - * otherwise compute them - */ - void encode_multiple (size_t n, idx_t *keys, - const float * x, uint8_t * codes, - bool compute_keys = false) const; - - /// inverse of encode_multiple - void decode_multiple (size_t n, const idx_t *keys, - const uint8_t * xcodes, float * x) const; - - InvertedListScanner *get_InvertedListScanner (bool store_pairs) - const override; - - /// build precomputed table - void precompute_table (); - - IndexIVFPQ (); - -}; - - -/// statistics are robust to internal threading, but not if -/// IndexIVFPQ::search_preassigned is called by multiple threads -struct IndexIVFPQStats { - size_t nrefine; // nb of refines (IVFPQR) - - size_t n_hamming_pass; - // nb of passed Hamming distance tests (for polysemous) - - // timings measured with the CPU RTC - // on all threads - size_t search_cycles; - size_t refine_cycles; // only for IVFPQR - - IndexIVFPQStats () {reset (); } - void reset (); -}; - -// global var that collects them all -extern IndexIVFPQStats indexIVFPQ_stats; - - - -/** Index with an additional level of PQ refinement */ -struct IndexIVFPQR: IndexIVFPQ { - ProductQuantizer refine_pq; ///< 3rd level quantizer - std::vector refine_codes; ///< corresponding codes - - /// factor between k requested in search and the k requested from the IVFPQ - float k_factor; - - IndexIVFPQR ( - Index * quantizer, size_t d, size_t nlist, - size_t M, size_t nbits_per_idx, - size_t M_refine, size_t nbits_per_idx_refine); - - void reset() override; - - size_t remove_ids(const IDSelector& sel) override; - - /// trains the two product quantizers - void train_residual(idx_t n, const float* x) override; - - void add_with_ids(idx_t n, const float* x, const idx_t* xids) override; - - /// same as add_with_ids, but optionally use the precomputed list ids - void add_core (idx_t n, const float *x, const idx_t *xids, - const idx_t *precomputed_idx = nullptr); - - void reconstruct_from_offset (int64_t list_no, int64_t offset, - float* recons) const override; - - void merge_from (IndexIVF &other, idx_t add_id) override; - - - void search_preassigned (idx_t n, const float *x, idx_t k, - const idx_t *assign, - const float *centroid_dis, - float *distances, idx_t *labels, - bool store_pairs, - const IVFSearchParameters *params=nullptr - ) const override; - - IndexIVFPQR(); -}; - - - -/** Same as an IndexIVFPQ without the inverted lists: codes are stored sequentially - * - * The class is mainly inteded to store encoded vectors that can be - * accessed randomly, the search function is not implemented. - */ -struct Index2Layer: Index { - /// first level quantizer - Level1Quantizer q1; - - /// second level quantizer is always a PQ - ProductQuantizer pq; - - /// Codes. Size ntotal * code_size. - std::vector codes; - - /// size of the code for the first level (ceil(log8(q1.nlist))) - size_t code_size_1; - - /// size of the code for the second level - size_t code_size_2; - - /// code_size_1 + code_size_2 - size_t code_size; - - Index2Layer (Index * quantizer, size_t nlist, - int M, MetricType metric = METRIC_L2); - - Index2Layer (); - ~Index2Layer (); - - void train(idx_t n, const float* x) override; - - void add(idx_t n, const float* x) override; - - /// not implemented - void search( - idx_t n, - const float* x, - idx_t k, - float* distances, - idx_t* labels) const override; - - void reconstruct_n(idx_t i0, idx_t ni, float* recons) const override; - - void reconstruct(idx_t key, float* recons) const override; - - void reset() override; - - DistanceComputer * get_distance_computer() const override; - - /// transfer the flat codes to an IVFPQ index - void transfer_to_IVFPQ(IndexIVFPQ & other) const; - -}; - - -} // namespace faiss - - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/faiss/IndexIVFSpectralHash.h b/cpp/thirdparty/knowhere_build/include/faiss/IndexIVFSpectralHash.h deleted file mode 100644 index 5262ec4a1c..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/IndexIVFSpectralHash.h +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -#ifndef FAISS_INDEX_IVFSH_H -#define FAISS_INDEX_IVFSH_H - - -#include - -#include "IndexIVF.h" - - -namespace faiss { - -struct VectorTransform; - -/** Inverted list that stores binary codes of size nbit. Before the - * binary conversion, the dimension of the vectors is transformed from - * dim d into dim nbit by vt (a random rotation by default). - * - * Each coordinate is subtracted from a value determined by - * threshold_type, and split into intervals of size period. Half of - * the interval is a 0 bit, the other half a 1. - */ -struct IndexIVFSpectralHash: IndexIVF { - - VectorTransform *vt; // transformation from d to nbit dim - bool own_fields; - - int nbit; - float period; - - enum ThresholdType { - Thresh_global, - Thresh_centroid, - Thresh_centroid_half, - Thresh_median - }; - ThresholdType threshold_type; - - // size nlist * nbit or 0 if Thresh_global - std::vector trained; - - IndexIVFSpectralHash (Index * quantizer, size_t d, size_t nlist, - int nbit, float period); - - IndexIVFSpectralHash (); - - void train_residual(idx_t n, const float* x) override; - - void encode_vectors(idx_t n, const float* x, - const idx_t *list_nos, - uint8_t * codes) const override; - - InvertedListScanner *get_InvertedListScanner (bool store_pairs) - const override; - - ~IndexIVFSpectralHash () override; - -}; - - - - -}; // namespace faiss - - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/faiss/IndexLSH.h b/cpp/thirdparty/knowhere_build/include/faiss/IndexLSH.h deleted file mode 100644 index 0357ba9bef..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/IndexLSH.h +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -#ifndef INDEX_LSH_H -#define INDEX_LSH_H - -#include - -#include "Index.h" -#include "VectorTransform.h" - -namespace faiss { - - -/** The sign of each vector component is put in a binary signature */ -struct IndexLSH:Index { - typedef unsigned char uint8_t; - - int nbits; ///< nb of bits per vector - int bytes_per_vec; ///< nb of 8-bits per encoded vector - bool rotate_data; ///< whether to apply a random rotation to input - bool train_thresholds; ///< whether we train thresholds or use 0 - - RandomRotationMatrix rrot; ///< optional random rotation - - std::vector thresholds; ///< thresholds to compare with - - /// encoded dataset - std::vector codes; - - IndexLSH ( - idx_t d, int nbits, - bool rotate_data = true, - bool train_thresholds = false); - - /** Preprocesses and resizes the input to the size required to - * binarize the data - * - * @param x input vectors, size n * d - * @return output vectors, size n * bits. May be the same pointer - * as x, otherwise it should be deleted by the caller - */ - const float *apply_preprocess (idx_t n, const float *x) const; - - void train(idx_t n, const float* x) override; - - void add(idx_t n, const float* x) override; - - void search( - idx_t n, - const float* x, - idx_t k, - float* distances, - idx_t* labels) const override; - - void reset() override; - - /// transfer the thresholds to a pre-processing stage (and unset - /// train_thresholds) - void transfer_thresholds (LinearTransform * vt); - - ~IndexLSH() override {} - - IndexLSH (); -}; - - -} - - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/faiss/IndexPQ.h b/cpp/thirdparty/knowhere_build/include/faiss/IndexPQ.h deleted file mode 100644 index de18313c23..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/IndexPQ.h +++ /dev/null @@ -1,189 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -#ifndef FAISS_INDEX_PQ_H -#define FAISS_INDEX_PQ_H - -#include - -#include - -#include "Index.h" -#include "ProductQuantizer.h" -#include "PolysemousTraining.h" - -namespace faiss { - - -/** Index based on a product quantizer. Stored vectors are - * approximated by PQ codes. */ -struct IndexPQ: Index { - - /// The product quantizer used to encode the vectors - ProductQuantizer pq; - - /// Codes. Size ntotal * pq.code_size - std::vector codes; - - /** Constructor. - * - * @param d dimensionality of the input vectors - * @param M number of subquantizers - * @param nbits number of bit per subvector index - */ - IndexPQ (int d, ///< dimensionality of the input vectors - size_t M, ///< number of subquantizers - size_t nbits, ///< number of bit per subvector index - MetricType metric = METRIC_L2); - - IndexPQ (); - - void train(idx_t n, const float* x) override; - - void add(idx_t n, const float* x) override; - - void search( - idx_t n, - const float* x, - idx_t k, - float* distances, - idx_t* labels) const override; - - void reset() override; - - void reconstruct_n(idx_t i0, idx_t ni, float* recons) const override; - - void reconstruct(idx_t key, float* recons) const override; - - size_t remove_ids(const IDSelector& sel) override; - - DistanceComputer * get_distance_computer() const override; - - /****************************************************** - * Polysemous codes implementation - ******************************************************/ - bool do_polysemous_training; ///< false = standard PQ - - /// parameters used for the polysemous training - PolysemousTraining polysemous_training; - - /// how to perform the search in search_core - enum Search_type_t { - ST_PQ, ///< asymmetric product quantizer (default) - ST_HE, ///< Hamming distance on codes - ST_generalized_HE, ///< nb of same codes - ST_SDC, ///< symmetric product quantizer (SDC) - ST_polysemous, ///< HE filter (using ht) + PQ combination - ST_polysemous_generalize, ///< Filter on generalized Hamming - }; - - Search_type_t search_type; - - // just encode the sign of the components, instead of using the PQ encoder - // used only for the queries - bool encode_signs; - - /// Hamming threshold used for polysemy - int polysemous_ht; - - // actual polysemous search - void search_core_polysemous (idx_t n, const float *x, idx_t k, - float *distances, idx_t *labels) const; - - /// prepare query for a polysemous search, but instead of - /// computing the result, just get the histogram of Hamming - /// distances. May be computed on a provided dataset if xb != NULL - /// @param dist_histogram (M * nbits + 1) - void hamming_distance_histogram (idx_t n, const float *x, - idx_t nb, const float *xb, - int64_t *dist_histogram); - - /** compute pairwise distances between queries and database - * - * @param n nb of query vectors - * @param x query vector, size n * d - * @param dis output distances, size n * ntotal - */ - void hamming_distance_table (idx_t n, const float *x, - int32_t *dis) const; - -}; - - -/// statistics are robust to internal threading, but not if -/// IndexPQ::search is called by multiple threads -struct IndexPQStats { - size_t nq; // nb of queries run - size_t ncode; // nb of codes visited - - size_t n_hamming_pass; // nb of passed Hamming distance tests (for polysemy) - - IndexPQStats () {reset (); } - void reset (); -}; - -extern IndexPQStats indexPQ_stats; - - - -/** Quantizer where centroids are virtual: they are the Cartesian - * product of sub-centroids. */ -struct MultiIndexQuantizer: Index { - ProductQuantizer pq; - - MultiIndexQuantizer (int d, ///< dimension of the input vectors - size_t M, ///< number of subquantizers - size_t nbits); ///< number of bit per subvector index - - void train(idx_t n, const float* x) override; - - void search( - idx_t n, const float* x, idx_t k, - float* distances, idx_t* labels) const override; - - /// add and reset will crash at runtime - void add(idx_t n, const float* x) override; - void reset() override; - - MultiIndexQuantizer () {} - - void reconstruct(idx_t key, float* recons) const override; -}; - - -/** MultiIndexQuantizer where the PQ assignmnet is performed by sub-indexes - */ -struct MultiIndexQuantizer2: MultiIndexQuantizer { - - /// M Indexes on d / M dimensions - std::vector assign_indexes; - bool own_fields; - - MultiIndexQuantizer2 ( - int d, size_t M, size_t nbits, - Index **indexes); - - MultiIndexQuantizer2 ( - int d, size_t nbits, - Index *assign_index_0, - Index *assign_index_1); - - void train(idx_t n, const float* x) override; - - void search( - idx_t n, const float* x, idx_t k, - float* distances, idx_t* labels) const override; - -}; - - -} // namespace faiss - - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/faiss/IndexReplicas.h b/cpp/thirdparty/knowhere_build/include/faiss/IndexReplicas.h deleted file mode 100644 index 142892c752..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/IndexReplicas.h +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#include "Index.h" -#include "IndexBinary.h" -#include "ThreadedIndex.h" - -namespace faiss { - -/// Takes individual faiss::Index instances, and splits queries for -/// sending to each Index instance, and joins the results together -/// when done. -/// Each index is managed by a separate CPU thread. -template -class IndexReplicasTemplate : public ThreadedIndex { - public: - using idx_t = typename IndexT::idx_t; - using component_t = typename IndexT::component_t; - using distance_t = typename IndexT::distance_t; - - /// The dimension that all sub-indices must share will be the dimension of the - /// first sub-index added - /// @param threaded do we use one thread per sub-index or do queries - /// sequentially? - explicit IndexReplicasTemplate(bool threaded = true); - - /// @param d the dimension that all sub-indices must share - /// @param threaded do we use one thread per sub index or do queries - /// sequentially? - explicit IndexReplicasTemplate(idx_t d, bool threaded = true); - - /// int version due to the implicit bool conversion ambiguity of int as - /// dimension - explicit IndexReplicasTemplate(int d, bool threaded = true); - - /// Alias for addIndex() - void add_replica(IndexT* index) { this->addIndex(index); } - - /// Alias for removeIndex() - void remove_replica(IndexT* index) { this->removeIndex(index); } - - /// faiss::Index API - /// All indices receive the same call - void train(idx_t n, const component_t* x) override; - - /// faiss::Index API - /// All indices receive the same call - void add(idx_t n, const component_t* x) override; - - /// faiss::Index API - /// Query is partitioned into a slice for each sub-index - /// split by ceil(n / #indices) for our sub-indices - void search(idx_t n, - const component_t* x, - idx_t k, - distance_t* distances, - idx_t* labels) const override; - - /// reconstructs from the first index - void reconstruct(idx_t, component_t *v) const override; - - protected: - /// Called just after an index is added - void onAfterAddIndex(IndexT* index) override; -}; - -using IndexReplicas = IndexReplicasTemplate; -using IndexBinaryReplicas = IndexReplicasTemplate; - -} // namespace diff --git a/cpp/thirdparty/knowhere_build/include/faiss/IndexScalarQuantizer.h b/cpp/thirdparty/knowhere_build/include/faiss/IndexScalarQuantizer.h deleted file mode 100644 index 3496562454..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/IndexScalarQuantizer.h +++ /dev/null @@ -1,172 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -#ifndef FAISS_INDEX_SCALAR_QUANTIZER_H -#define FAISS_INDEX_SCALAR_QUANTIZER_H - -#include - - -#include - - -#include "IndexIVF.h" - - -namespace faiss { - -/** - * The uniform quantizer has a range [vmin, vmax]. The range can be - * the same for all dimensions (uniform) or specific per dimension - * (default). - */ - -struct SQDistanceComputer; - -struct ScalarQuantizer { - - enum QuantizerType { - QT_8bit, ///< 8 bits per component - QT_4bit, ///< 4 bits per component - QT_8bit_uniform, ///< same, shared range for all dimensions - QT_4bit_uniform, - QT_fp16, - QT_8bit_direct, /// fast indexing of uint8s - QT_6bit, ///< 6 bits per component - }; - - QuantizerType qtype; - - /** The uniform encoder can estimate the range of representable - * values of the unform encoder using different statistics. Here - * rs = rangestat_arg */ - - // rangestat_arg. - enum RangeStat { - RS_minmax, ///< [min - rs*(max-min), max + rs*(max-min)] - RS_meanstd, ///< [mean - std * rs, mean + std * rs] - RS_quantiles, ///< [Q(rs), Q(1-rs)] - RS_optim, ///< alternate optimization of reconstruction error - }; - - RangeStat rangestat; - float rangestat_arg; - - /// dimension of input vectors - size_t d; - - /// bytes per vector - size_t code_size; - - /// trained values (including the range) - std::vector trained; - - ScalarQuantizer (size_t d, QuantizerType qtype); - ScalarQuantizer (); - - void train (size_t n, const float *x); - - - /// same as compute_code for several vectors - void compute_codes (const float * x, - uint8_t * codes, - size_t n) const ; - - /// decode a vector from a given code (or n vectors if third argument) - void decode (const uint8_t *code, float *x, size_t n) const; - - - SQDistanceComputer *get_distance_computer (MetricType metric = METRIC_L2) - const; - -}; - -struct DistanceComputer; - -struct IndexScalarQuantizer: Index { - /// Used to encode the vectors - ScalarQuantizer sq; - - /// Codes. Size ntotal * pq.code_size - std::vector codes; - - size_t code_size; - - /** Constructor. - * - * @param d dimensionality of the input vectors - * @param M number of subquantizers - * @param nbits number of bit per subvector index - */ - IndexScalarQuantizer (int d, - ScalarQuantizer::QuantizerType qtype, - MetricType metric = METRIC_L2); - - IndexScalarQuantizer (); - - void train(idx_t n, const float* x) override; - - void add(idx_t n, const float* x) override; - - void search( - idx_t n, - const float* x, - idx_t k, - float* distances, - idx_t* labels) const override; - - void reset() override; - - void reconstruct_n(idx_t i0, idx_t ni, float* recons) const override; - - void reconstruct(idx_t key, float* recons) const override; - - DistanceComputer *get_distance_computer () const override; - -}; - - - /** An IVF implementation where the components of the residuals are - * encoded with a scalar uniform quantizer. All distance computations - * are asymmetric, so the encoded vectors are decoded and approximate - * distances are computed. - */ - -struct IndexIVFScalarQuantizer: IndexIVF { - ScalarQuantizer sq; - bool by_residual; - - IndexIVFScalarQuantizer(Index *quantizer, size_t d, size_t nlist, - ScalarQuantizer::QuantizerType qtype, - MetricType metric = METRIC_L2); - - IndexIVFScalarQuantizer(); - - void train_residual(idx_t n, const float* x) override; - - void encode_vectors(idx_t n, const float* x, - const idx_t *list_nos, - uint8_t * codes) const override; - - void add_with_ids(idx_t n, const float* x, const idx_t* xids) override; - - InvertedListScanner *get_InvertedListScanner (bool store_pairs) - const override; - - - void reconstruct_from_offset (int64_t list_no, int64_t offset, - float* recons) const override; - -}; - - -} - - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/faiss/IndexShards.h b/cpp/thirdparty/knowhere_build/include/faiss/IndexShards.h deleted file mode 100644 index 6bb2f57055..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/IndexShards.h +++ /dev/null @@ -1,100 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#include "Index.h" -#include "IndexBinary.h" -#include "ThreadedIndex.h" - -namespace faiss { - -/** - * Index that concatenates the results from several sub-indexes - */ -template -struct IndexShardsTemplate : public ThreadedIndex { - using idx_t = typename IndexT::idx_t; - using component_t = typename IndexT::component_t; - using distance_t = typename IndexT::distance_t; - - /** - * The dimension that all sub-indices must share will be the dimension of the - * first sub-index added - * - * @param threaded do we use one thread per sub_index or do - * queries sequentially? - * @param successive_ids should we shift the returned ids by - * the size of each sub-index or return them - * as they are? - */ - explicit IndexShardsTemplate(bool threaded = false, - bool successive_ids = true); - - /** - * @param threaded do we use one thread per sub_index or do - * queries sequentially? - * @param successive_ids should we shift the returned ids by - * the size of each sub-index or return them - * as they are? - */ - explicit IndexShardsTemplate(idx_t d, - bool threaded = false, - bool successive_ids = true); - - /// int version due to the implicit bool conversion ambiguity of int as - /// dimension - explicit IndexShardsTemplate(int d, - bool threaded = false, - bool successive_ids = true); - - /// Alias for addIndex() - void add_shard(IndexT* index) { this->addIndex(index); } - - /// Alias for removeIndex() - void remove_shard(IndexT* index) { this->removeIndex(index); } - - /// supported only for sub-indices that implement add_with_ids - void add(idx_t n, const component_t* x) override; - - /** - * Cases (successive_ids, xids): - * - true, non-NULL ERROR: it makes no sense to pass in ids and - * request them to be shifted - * - true, NULL OK, but should be called only once (calls add() - * on sub-indexes). - * - false, non-NULL OK: will call add_with_ids with passed in xids - * distributed evenly over shards - * - false, NULL OK: will call add_with_ids on each sub-index, - * starting at ntotal - */ - void add_with_ids(idx_t n, const component_t* x, const idx_t* xids) override; - - void search(idx_t n, const component_t* x, idx_t k, - distance_t* distances, idx_t* labels) const override; - - void train(idx_t n, const component_t* x) override; - - // update metric_type and ntotal. Call if you changes something in - // the shard indexes. - void sync_with_shard_indexes(); - - bool successive_ids; - - protected: - /// Called just after an index is added - void onAfterAddIndex(IndexT* index) override; - - /// Called just after an index is removed - void onAfterRemoveIndex(IndexT* index) override; -}; - -using IndexShards = IndexShardsTemplate; -using IndexBinaryShards = IndexShardsTemplate; - - -} // namespace faiss diff --git a/cpp/thirdparty/knowhere_build/include/faiss/InvertedLists.h b/cpp/thirdparty/knowhere_build/include/faiss/InvertedLists.h deleted file mode 100644 index d54ef9879c..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/InvertedLists.h +++ /dev/null @@ -1,334 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -#ifndef FAISS_INVERTEDLISTS_IVF_H -#define FAISS_INVERTEDLISTS_IVF_H - -/** - * Definition of inverted lists + a few common classes that implement - * the interface. - */ - -#include -#include "Index.h" - - -namespace faiss { - -/** Table of inverted lists - * multithreading rules: - * - concurrent read accesses are allowed - * - concurrent update accesses are allowed - * - for resize and add_entries, only concurrent access to different lists - * are allowed - */ -struct InvertedLists { - typedef Index::idx_t idx_t; - - size_t nlist; ///< number of possible key values - size_t code_size; ///< code size per vector in bytes - - InvertedLists (size_t nlist, size_t code_size); - - /************************* - * Read only functions */ - - /// get the size of a list - virtual size_t list_size(size_t list_no) const = 0; - - /** get the codes for an inverted list - * must be released by release_codes - * - * @return codes size list_size * code_size - */ - virtual const uint8_t * get_codes (size_t list_no) const = 0; - - /** get the ids for an inverted list - * must be released by release_ids - * - * @return ids size list_size - */ - virtual const idx_t * get_ids (size_t list_no) const = 0; - - /// release codes returned by get_codes (default implementation is nop - virtual void release_codes (size_t list_no, const uint8_t *codes) const; - - /// release ids returned by get_ids - virtual void release_ids (size_t list_no, const idx_t *ids) const; - - /// @return a single id in an inverted list - virtual idx_t get_single_id (size_t list_no, size_t offset) const; - - /// @return a single code in an inverted list - /// (should be deallocated with release_codes) - virtual const uint8_t * get_single_code ( - size_t list_no, size_t offset) const; - - /// prepare the following lists (default does nothing) - /// a list can be -1 hence the signed long - virtual void prefetch_lists (const idx_t *list_nos, int nlist) const; - - /************************* - * writing functions */ - - /// add one entry to an inverted list - virtual size_t add_entry (size_t list_no, idx_t theid, - const uint8_t *code); - - virtual size_t add_entries ( - size_t list_no, size_t n_entry, - const idx_t* ids, const uint8_t *code) = 0; - - virtual void update_entry (size_t list_no, size_t offset, - idx_t id, const uint8_t *code); - - virtual void update_entries (size_t list_no, size_t offset, size_t n_entry, - const idx_t *ids, const uint8_t *code) = 0; - - virtual void resize (size_t list_no, size_t new_size) = 0; - - virtual void reset (); - - /// move all entries from oivf (empty on output) - void merge_from (InvertedLists *oivf, size_t add_id); - - virtual ~InvertedLists (); - - /************************* - * statistics */ - - /// 1= perfectly balanced, >1: imbalanced - double imbalance_factor () const; - - /// display some stats about the inverted lists - void print_stats () const; - - /// sum up list sizes - size_t compute_ntotal () const; - - /************************************** - * Scoped inverted lists (for automatic deallocation) - * - * instead of writing: - * - * uint8_t * codes = invlists->get_codes (10); - * ... use codes - * invlists->release_codes(10, codes) - * - * write: - * - * ScopedCodes codes (invlists, 10); - * ... use codes.get() - * // release called automatically when codes goes out of scope - * - * the following function call also works: - * - * foo (123, ScopedCodes (invlists, 10).get(), 456); - * - */ - - struct ScopedIds { - const InvertedLists *il; - const idx_t *ids; - size_t list_no; - - ScopedIds (const InvertedLists *il, size_t list_no): - il (il), ids (il->get_ids (list_no)), list_no (list_no) - {} - - const idx_t *get() {return ids; } - - idx_t operator [] (size_t i) const { - return ids[i]; - } - - ~ScopedIds () { - il->release_ids (list_no, ids); - } - }; - - struct ScopedCodes { - const InvertedLists *il; - const uint8_t *codes; - size_t list_no; - - ScopedCodes (const InvertedLists *il, size_t list_no): - il (il), codes (il->get_codes (list_no)), list_no (list_no) - {} - - ScopedCodes (const InvertedLists *il, size_t list_no, size_t offset): - il (il), codes (il->get_single_code (list_no, offset)), - list_no (list_no) - {} - - const uint8_t *get() {return codes; } - - ~ScopedCodes () { - il->release_codes (list_no, codes); - } - }; - - -}; - - -/// simple (default) implementation as an array of inverted lists -struct ArrayInvertedLists: InvertedLists { - std::vector < std::vector > codes; // binary codes, size nlist - std::vector < std::vector > ids; ///< Inverted lists for indexes - - ArrayInvertedLists (size_t nlist, size_t code_size); - - size_t list_size(size_t list_no) const override; - const uint8_t * get_codes (size_t list_no) const override; - const idx_t * get_ids (size_t list_no) const override; - - size_t add_entries ( - size_t list_no, size_t n_entry, - const idx_t* ids, const uint8_t *code) override; - - void update_entries (size_t list_no, size_t offset, size_t n_entry, - const idx_t *ids, const uint8_t *code) override; - - void resize (size_t list_no, size_t new_size) override; - - virtual ~ArrayInvertedLists (); -}; - -/***************************************************************** - * Meta-inverted lists - * - * About terminology: the inverted lists are seen as a sparse matrix, - * that can be stacked horizontally, vertically and sliced. - *****************************************************************/ - -struct ReadOnlyInvertedLists: InvertedLists { - - ReadOnlyInvertedLists (size_t nlist, size_t code_size): - InvertedLists (nlist, code_size) {} - - size_t add_entries ( - size_t list_no, size_t n_entry, - const idx_t* ids, const uint8_t *code) override; - - void update_entries (size_t list_no, size_t offset, size_t n_entry, - const idx_t *ids, const uint8_t *code) override; - - void resize (size_t list_no, size_t new_size) override; - -}; - - -/// Horizontal stack of inverted lists -struct HStackInvertedLists: ReadOnlyInvertedLists { - - std::vectorils; - - /// build InvertedLists by concatenating nil of them - HStackInvertedLists (int nil, const InvertedLists **ils); - - size_t list_size(size_t list_no) const override; - const uint8_t * get_codes (size_t list_no) const override; - const idx_t * get_ids (size_t list_no) const override; - - void prefetch_lists (const idx_t *list_nos, int nlist) const override; - - void release_codes (size_t list_no, const uint8_t *codes) const override; - void release_ids (size_t list_no, const idx_t *ids) const override; - - idx_t get_single_id (size_t list_no, size_t offset) const override; - - const uint8_t * get_single_code ( - size_t list_no, size_t offset) const override; - -}; - -using ConcatenatedInvertedLists = HStackInvertedLists; - - -/// vertical slice of indexes in another InvertedLists -struct SliceInvertedLists: ReadOnlyInvertedLists { - const InvertedLists *il; - idx_t i0, i1; - - SliceInvertedLists(const InvertedLists *il, idx_t i0, idx_t i1); - - size_t list_size(size_t list_no) const override; - const uint8_t * get_codes (size_t list_no) const override; - const idx_t * get_ids (size_t list_no) const override; - - void release_codes (size_t list_no, const uint8_t *codes) const override; - void release_ids (size_t list_no, const idx_t *ids) const override; - - idx_t get_single_id (size_t list_no, size_t offset) const override; - - const uint8_t * get_single_code ( - size_t list_no, size_t offset) const override; - - void prefetch_lists (const idx_t *list_nos, int nlist) const override; -}; - - -struct VStackInvertedLists: ReadOnlyInvertedLists { - std::vectorils; - std::vector cumsz; - - /// build InvertedLists by concatenating nil of them - VStackInvertedLists (int nil, const InvertedLists **ils); - - size_t list_size(size_t list_no) const override; - const uint8_t * get_codes (size_t list_no) const override; - const idx_t * get_ids (size_t list_no) const override; - - void release_codes (size_t list_no, const uint8_t *codes) const override; - void release_ids (size_t list_no, const idx_t *ids) const override; - - idx_t get_single_id (size_t list_no, size_t offset) const override; - - const uint8_t * get_single_code ( - size_t list_no, size_t offset) const override; - - void prefetch_lists (const idx_t *list_nos, int nlist) const override; - -}; - - -/** use the first inverted lists if they are non-empty otherwise use the second - * - * This is useful if il1 has a few inverted lists that are too long, - * and that il0 has replacement lists for those, with empty lists for - * the others. */ -struct MaskedInvertedLists: ReadOnlyInvertedLists { - - const InvertedLists *il0; - const InvertedLists *il1; - - MaskedInvertedLists (const InvertedLists *il0, - const InvertedLists *il1); - - size_t list_size(size_t list_no) const override; - const uint8_t * get_codes (size_t list_no) const override; - const idx_t * get_ids (size_t list_no) const override; - - void release_codes (size_t list_no, const uint8_t *codes) const override; - void release_ids (size_t list_no, const idx_t *ids) const override; - - idx_t get_single_id (size_t list_no, size_t offset) const override; - - const uint8_t * get_single_code ( - size_t list_no, size_t offset) const override; - - void prefetch_lists (const idx_t *list_nos, int nlist) const override; - -}; - -} // namespace faiss - - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/faiss/MetaIndexes.h b/cpp/thirdparty/knowhere_build/include/faiss/MetaIndexes.h deleted file mode 100644 index 4a206426ff..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/MetaIndexes.h +++ /dev/null @@ -1,126 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -#ifndef META_INDEXES_H -#define META_INDEXES_H - -#include -#include -#include "Index.h" -#include "IndexShards.h" -#include "IndexReplicas.h" - -namespace faiss { - -/** Index that translates search results to ids */ -template -struct IndexIDMapTemplate : IndexT { - using idx_t = typename IndexT::idx_t; - using component_t = typename IndexT::component_t; - using distance_t = typename IndexT::distance_t; - - IndexT * index; ///! the sub-index - bool own_fields; ///! whether pointers are deleted in destructo - std::vector id_map; - - explicit IndexIDMapTemplate (IndexT *index); - - /// @param xids if non-null, ids to store for the vectors (size n) - void add_with_ids(idx_t n, const component_t* x, const idx_t* xids) override; - - /// this will fail. Use add_with_ids - void add(idx_t n, const component_t* x) override; - - void search( - idx_t n, const component_t* x, idx_t k, - distance_t* distances, - idx_t* labels) const override; - - void train(idx_t n, const component_t* x) override; - - void reset() override; - - /// remove ids adapted to IndexFlat - size_t remove_ids(const IDSelector& sel) override; - - void range_search (idx_t n, const component_t *x, distance_t radius, - RangeSearchResult *result) const override; - - ~IndexIDMapTemplate () override; - IndexIDMapTemplate () {own_fields=false; index=nullptr; } -}; - -using IndexIDMap = IndexIDMapTemplate; -using IndexBinaryIDMap = IndexIDMapTemplate; - - -/** same as IndexIDMap but also provides an efficient reconstruction - * implementation via a 2-way index */ -template -struct IndexIDMap2Template : IndexIDMapTemplate { - using idx_t = typename IndexT::idx_t; - using component_t = typename IndexT::component_t; - using distance_t = typename IndexT::distance_t; - - std::unordered_map rev_map; - - explicit IndexIDMap2Template (IndexT *index); - - /// make the rev_map from scratch - void construct_rev_map (); - - void add_with_ids(idx_t n, const component_t* x, const idx_t* xids) override; - - size_t remove_ids(const IDSelector& sel) override; - - void reconstruct (idx_t key, component_t * recons) const override; - - ~IndexIDMap2Template() override {} - IndexIDMap2Template () {} -}; - -using IndexIDMap2 = IndexIDMap2Template; -using IndexBinaryIDMap2 = IndexIDMap2Template; - - -/** splits input vectors in segments and assigns each segment to a sub-index - * used to distribute a MultiIndexQuantizer - */ -struct IndexSplitVectors: Index { - bool own_fields; - bool threaded; - std::vector sub_indexes; - idx_t sum_d; /// sum of dimensions seen so far - - explicit IndexSplitVectors (idx_t d, bool threaded = false); - - void add_sub_index (Index *); - void sync_with_sub_indexes (); - - void add(idx_t n, const float* x) override; - - void search( - idx_t n, - const float* x, - idx_t k, - float* distances, - idx_t* labels) const override; - - void train(idx_t n, const float* x) override; - - void reset() override; - - ~IndexSplitVectors() override; -}; - - -} // namespace faiss - - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/faiss/OnDiskInvertedLists.h b/cpp/thirdparty/knowhere_build/include/faiss/OnDiskInvertedLists.h deleted file mode 100644 index 8dc279b0cb..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/OnDiskInvertedLists.h +++ /dev/null @@ -1,127 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -#ifndef FAISS_ON_DISK_INVERTED_LISTS_H -#define FAISS_ON_DISK_INVERTED_LISTS_H - -#include -#include - -#include "IndexIVF.h" - -namespace faiss { - - -struct LockLevels; - -/** On-disk storage of inverted lists. - * - * The data is stored in a mmapped chunk of memory (base ptointer ptr, - * size totsize). Each list is a range of memory that contains (object - * List) that contains: - * - * - uint8_t codes[capacity * code_size] - * - followed by idx_t ids[capacity] - * - * in each of the arrays, the size <= capacity first elements are - * used, the rest is not initialized. - * - * Addition and resize are supported by: - * - roundind up the capacity of the lists to a power of two - * - maintaining a list of empty slots, sorted by size. - * - resizing the mmapped block is adjusted as needed. - * - * An OnDiskInvertedLists is compact if the size == capacity for all - * lists and there are no available slots. - * - * Addition to the invlists is slow. For incremental add it is better - * to use a default ArrayInvertedLists object and convert it to an - * OnDisk with merge_from. - * - * When it is known that a set of lists will be accessed, it is useful - * to call prefetch_lists, that launches a set of threads to read the - * lists in parallel. - */ -struct OnDiskInvertedLists: InvertedLists { - - struct List { - size_t size; // size of inverted list (entries) - size_t capacity; // allocated size (entries) - size_t offset; // offset in buffer (bytes) - List (); - }; - - // size nlist - std::vector lists; - - struct Slot { - size_t offset; // bytes - size_t capacity; // bytes - Slot (size_t offset, size_t capacity); - Slot (); - }; - - // size whatever space remains - std::list slots; - - std::string filename; - size_t totsize; - uint8_t *ptr; // mmap base pointer - bool read_only; /// are inverted lists mapped read-only - - OnDiskInvertedLists (size_t nlist, size_t code_size, - const char *filename); - - size_t list_size(size_t list_no) const override; - const uint8_t * get_codes (size_t list_no) const override; - const idx_t * get_ids (size_t list_no) const override; - - size_t add_entries ( - size_t list_no, size_t n_entry, - const idx_t* ids, const uint8_t *code) override; - - void update_entries (size_t list_no, size_t offset, size_t n_entry, - const idx_t *ids, const uint8_t *code) override; - - void resize (size_t list_no, size_t new_size) override; - - // copy all inverted lists into *this, in compact form (without - // allocating slots) - size_t merge_from (const InvertedLists **ils, int n_il, bool verbose=false); - - /// restrict the inverted lists to l0:l1 without touching the mmapped region - void crop_invlists(size_t l0, size_t l1); - - void prefetch_lists (const idx_t *list_nos, int nlist) const override; - - virtual ~OnDiskInvertedLists (); - - // private - - LockLevels * locks; - - // encapsulates the threads that are busy prefeteching - struct OngoingPrefetch; - OngoingPrefetch *pf; - int prefetch_nthread; - - void do_mmap (); - void update_totsize (size_t new_totsize); - void resize_locked (size_t list_no, size_t new_size); - size_t allocate_slot (size_t capacity); - void free_slot (size_t offset, size_t capacity); - - // empty constructor for the I/O functions - OnDiskInvertedLists (); -}; - - -} // namespace faiss - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/faiss/PolysemousTraining.h b/cpp/thirdparty/knowhere_build/include/faiss/PolysemousTraining.h deleted file mode 100644 index ada8512941..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/PolysemousTraining.h +++ /dev/null @@ -1,158 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -#ifndef FAISS_POLYSEMOUS_TRAINING_INCLUDED -#define FAISS_POLYSEMOUS_TRAINING_INCLUDED - - -#include "ProductQuantizer.h" - - -namespace faiss { - - -/// parameters used for the simulated annealing method -struct SimulatedAnnealingParameters { - - // optimization parameters - double init_temperature; // init probaility of accepting a bad swap - double temperature_decay; // at each iteration the temp is multiplied by this - int n_iter; // nb of iterations - int n_redo; // nb of runs of the simulation - int seed; // random seed - int verbose; - bool only_bit_flips; // restrict permutation changes to bit flips - bool init_random; // intialize with a random permutation (not identity) - - // set reasonable defaults - SimulatedAnnealingParameters (); - -}; - - -/// abstract class for the loss function -struct PermutationObjective { - - int n; - - virtual double compute_cost (const int *perm) const = 0; - - // what would the cost update be if iw and jw were swapped? - // default implementation just computes both and computes the difference - virtual double cost_update (const int *perm, int iw, int jw) const; - - virtual ~PermutationObjective () {} -}; - - -struct ReproduceDistancesObjective : PermutationObjective { - - double dis_weight_factor; - - static double sqr (double x) { return x * x; } - - // weihgting of distances: it is more important to reproduce small - // distances well - double dis_weight (double x) const; - - std::vector source_dis; ///< "real" corrected distances (size n^2) - const double * target_dis; ///< wanted distances (size n^2) - std::vector weights; ///< weights for each distance (size n^2) - - double get_source_dis (int i, int j) const; - - // cost = quadratic difference between actual distance and Hamming distance - double compute_cost(const int* perm) const override; - - // what would the cost update be if iw and jw were swapped? - // computed in O(n) instead of O(n^2) for the full re-computation - double cost_update(const int* perm, int iw, int jw) const override; - - ReproduceDistancesObjective ( - int n, - const double *source_dis_in, - const double *target_dis_in, - double dis_weight_factor); - - static void compute_mean_stdev (const double *tab, size_t n2, - double *mean_out, double *stddev_out); - - void set_affine_target_dis (const double *source_dis_in); - - ~ReproduceDistancesObjective() override {} -}; - -struct RandomGenerator; - -/// Simulated annealing optimization algorithm for permutations. - struct SimulatedAnnealingOptimizer: SimulatedAnnealingParameters { - - PermutationObjective *obj; - int n; ///< size of the permutation - FILE *logfile; /// logs values of the cost function - - SimulatedAnnealingOptimizer (PermutationObjective *obj, - const SimulatedAnnealingParameters &p); - RandomGenerator *rnd; - - /// remember intial cost of optimization - double init_cost; - - // main entry point. Perform the optimization loop, starting from - // and modifying permutation in-place - double optimize (int *perm); - - // run the optimization and return the best result in best_perm - double run_optimization (int * best_perm); - - virtual ~SimulatedAnnealingOptimizer (); -}; - - - - -/// optimizes the order of indices in a ProductQuantizer -struct PolysemousTraining: SimulatedAnnealingParameters { - - enum Optimization_type_t { - OT_None, - OT_ReproduceDistances_affine, ///< default - OT_Ranking_weighted_diff /// same as _2, but use rank of y+ - rank of y- - }; - Optimization_type_t optimization_type; - - // use 1/4 of the training points for the optimization, with - // max. ntrain_permutation. If ntrain_permutation == 0: train on - // centroids - int ntrain_permutation; - double dis_weight_factor; // decay of exp that weights distance loss - - // filename pattern for the logging of iterations - std::string log_pattern; - - // sets default values - PolysemousTraining (); - - /// reorder the centroids so that the Hamming distace becomes a - /// good approximation of the SDC distance (called by train) - void optimize_pq_for_hamming (ProductQuantizer & pq, - size_t n, const float *x) const; - - /// called by optimize_pq_for_hamming - void optimize_ranking (ProductQuantizer &pq, size_t n, const float *x) const; - /// called by optimize_pq_for_hamming - void optimize_reproduce_distances (ProductQuantizer &pq) const; - -}; - - -} // namespace faiss - - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/faiss/ProductQuantizer.h b/cpp/thirdparty/knowhere_build/include/faiss/ProductQuantizer.h deleted file mode 100644 index 0c3cc9eb5e..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/ProductQuantizer.h +++ /dev/null @@ -1,242 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -#ifndef FAISS_PRODUCT_QUANTIZER_H -#define FAISS_PRODUCT_QUANTIZER_H - -#include - -#include - -#include "Clustering.h" -#include "Heap.h" - -namespace faiss { - -/** Product Quantizer. Implemented only for METRIC_L2 */ -struct ProductQuantizer { - - using idx_t = Index::idx_t; - - size_t d; ///< size of the input vectors - size_t M; ///< number of subquantizers - size_t nbits; ///< number of bits per quantization index - - // values derived from the above - size_t dsub; ///< dimensionality of each subvector - size_t code_size; ///< byte per indexed vector - size_t ksub; ///< number of centroids for each subquantizer - bool verbose; ///< verbose during training? - - /// initialization - enum train_type_t { - Train_default, - Train_hot_start, ///< the centroids are already initialized - Train_shared, ///< share dictionary accross PQ segments - Train_hypercube, ///< intialize centroids with nbits-D hypercube - Train_hypercube_pca, ///< intialize centroids with nbits-D hypercube - }; - train_type_t train_type; - - ClusteringParameters cp; ///< parameters used during clustering - - /// if non-NULL, use this index for assignment (should be of size - /// d / M) - Index *assign_index; - - /// Centroid table, size M * ksub * dsub - std::vector centroids; - - /// return the centroids associated with subvector m - float * get_centroids (size_t m, size_t i) { - return ¢roids [(m * ksub + i) * dsub]; - } - const float * get_centroids (size_t m, size_t i) const { - return ¢roids [(m * ksub + i) * dsub]; - } - - // Train the product quantizer on a set of points. A clustering - // can be set on input to define non-default clustering parameters - void train (int n, const float *x); - - ProductQuantizer(size_t d, /* dimensionality of the input vectors */ - size_t M, /* number of subquantizers */ - size_t nbits); /* number of bit per subvector index */ - - ProductQuantizer (); - - /// compute derived values when d, M and nbits have been set - void set_derived_values (); - - /// Define the centroids for subquantizer m - void set_params (const float * centroids, int m); - - /// Quantize one vector with the product quantizer - void compute_code (const float * x, uint8_t * code) const ; - - /// same as compute_code for several vectors - void compute_codes (const float * x, - uint8_t * codes, - size_t n) const ; - - /// speed up code assignment using assign_index - /// (non-const because the index is changed) - void compute_codes_with_assign_index ( - const float * x, - uint8_t * codes, - size_t n); - - /// decode a vector from a given code (or n vectors if third argument) - void decode (const uint8_t *code, float *x) const; - void decode (const uint8_t *code, float *x, size_t n) const; - - /// If we happen to have the distance tables precomputed, this is - /// more efficient to compute the codes. - void compute_code_from_distance_table (const float *tab, - uint8_t *code) const; - - - /** Compute distance table for one vector. - * - * The distance table for x = [x_0 x_1 .. x_(M-1)] is a M * ksub - * matrix that contains - * - * dis_table (m, j) = || x_m - c_(m, j)||^2 - * for m = 0..M-1 and j = 0 .. ksub - 1 - * - * where c_(m, j) is the centroid no j of sub-quantizer m. - * - * @param x input vector size d - * @param dis_table output table, size M * ksub - */ - void compute_distance_table (const float * x, - float * dis_table) const; - - void compute_inner_prod_table (const float * x, - float * dis_table) const; - - - /** compute distance table for several vectors - * @param nx nb of input vectors - * @param x input vector size nx * d - * @param dis_table output table, size nx * M * ksub - */ - void compute_distance_tables (size_t nx, - const float * x, - float * dis_tables) const; - - void compute_inner_prod_tables (size_t nx, - const float * x, - float * dis_tables) const; - - - /** perform a search (L2 distance) - * @param x query vectors, size nx * d - * @param nx nb of queries - * @param codes database codes, size ncodes * code_size - * @param ncodes nb of nb vectors - * @param res heap array to store results (nh == nx) - * @param init_finalize_heap initialize heap (input) and sort (output)? - */ - void search (const float * x, - size_t nx, - const uint8_t * codes, - const size_t ncodes, - float_maxheap_array_t *res, - bool init_finalize_heap = true) const; - - /** same as search, but with inner product similarity */ - void search_ip (const float * x, - size_t nx, - const uint8_t * codes, - const size_t ncodes, - float_minheap_array_t *res, - bool init_finalize_heap = true) const; - - - /// Symmetric Distance Table - std::vector sdc_table; - - // intitialize the SDC table from the centroids - void compute_sdc_table (); - - void search_sdc (const uint8_t * qcodes, - size_t nq, - const uint8_t * bcodes, - const size_t ncodes, - float_maxheap_array_t * res, - bool init_finalize_heap = true) const; - - struct PQEncoderGeneric { - uint8_t *code; ///< code for this vector - uint8_t offset; - const int nbits; ///< number of bits per subquantizer index - - uint8_t reg; - - PQEncoderGeneric(uint8_t *code, int nbits, uint8_t offset = 0); - - void encode(uint64_t x); - - ~PQEncoderGeneric(); - }; - - - struct PQEncoder8 { - uint8_t *code; - - PQEncoder8(uint8_t *code, int nbits); - - void encode(uint64_t x); - }; - - struct PQEncoder16 { - uint16_t *code; - - PQEncoder16(uint8_t *code, int nbits); - - void encode(uint64_t x); - }; - - - struct PQDecoderGeneric { - const uint8_t *code; - uint8_t offset; - const int nbits; - const uint64_t mask; - uint8_t reg; - - PQDecoderGeneric(const uint8_t *code, int nbits); - - uint64_t decode(); - }; - - struct PQDecoder8 { - const uint8_t *code; - - PQDecoder8(const uint8_t *code, int nbits); - - uint64_t decode(); - }; - - struct PQDecoder16 { - const uint16_t *code; - - PQDecoder16(const uint8_t *code, int nbits); - - uint64_t decode(); - }; - -}; - - -} // namespace faiss - - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/faiss/ThreadedIndex-inl.h b/cpp/thirdparty/knowhere_build/include/faiss/ThreadedIndex-inl.h deleted file mode 100644 index 7416fe2c1d..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/ThreadedIndex-inl.h +++ /dev/null @@ -1,192 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#include "FaissAssert.h" -#include -#include - -namespace faiss { - -template -ThreadedIndex::ThreadedIndex(bool threaded) - // 0 is default dimension - : ThreadedIndex(0, threaded) { -} - -template -ThreadedIndex::ThreadedIndex(int d, bool threaded) - : IndexT(d), - own_fields(false), - isThreaded_(threaded) { - } - -template -ThreadedIndex::~ThreadedIndex() { - for (auto& p : indices_) { - if (isThreaded_) { - // should have worker thread - FAISS_ASSERT((bool) p.second); - - // This will also flush all pending work - p.second->stop(); - p.second->waitForThreadExit(); - } else { - // should not have worker thread - FAISS_ASSERT(!(bool) p.second); - } - - if (own_fields) { - delete p.first; - } - } -} - -template -void ThreadedIndex::addIndex(IndexT* index) { - // We inherit the dimension from the first index added to us if we don't have - // a set dimension - if (indices_.empty() && this->d == 0) { - this->d = index->d; - } - - // The new index must match our set dimension - FAISS_THROW_IF_NOT_FMT(this->d == index->d, - "addIndex: dimension mismatch for " - "newly added index; expecting dim %d, " - "new index has dim %d", - this->d, index->d); - - if (!indices_.empty()) { - auto& existing = indices_.front().first; - - FAISS_THROW_IF_NOT_MSG(index->metric_type == existing->metric_type, - "addIndex: newly added index is " - "of different metric type than old index"); - - // Make sure this index is not duplicated - for (auto& p : indices_) { - FAISS_THROW_IF_NOT_MSG(p.first != index, - "addIndex: attempting to add index " - "that is already in the collection"); - } - } - - indices_.emplace_back( - std::make_pair( - index, - std::unique_ptr(isThreaded_ ? - new WorkerThread : nullptr))); - - onAfterAddIndex(index); -} - -template -void ThreadedIndex::removeIndex(IndexT* index) { - for (auto it = indices_.begin(); it != indices_.end(); ++it) { - if (it->first == index) { - // This is our index; stop the worker thread before removing it, - // to ensure that it has finished before function exit - if (isThreaded_) { - // should have worker thread - FAISS_ASSERT((bool) it->second); - it->second->stop(); - it->second->waitForThreadExit(); - } else { - // should not have worker thread - FAISS_ASSERT(!(bool) it->second); - } - - indices_.erase(it); - onAfterRemoveIndex(index); - - if (own_fields) { - delete index; - } - - return; - } - } - - // could not find our index - FAISS_THROW_MSG("IndexReplicas::removeIndex: index not found"); -} - -template -void ThreadedIndex::runOnIndex(std::function f) { - if (isThreaded_) { - std::vector> v; - - for (int i = 0; i < this->indices_.size(); ++i) { - auto& p = this->indices_[i]; - auto indexPtr = p.first; - v.emplace_back(p.second->add([f, i, indexPtr](){ f(i, indexPtr); })); - } - - waitAndHandleFutures(v); - } else { - // Multiple exceptions may be thrown; gather them as we encounter them, - // while letting everything else run to completion - std::vector> exceptions; - - for (int i = 0; i < this->indices_.size(); ++i) { - auto& p = this->indices_[i]; - try { - f(i, p.first); - } catch (...) { - exceptions.emplace_back(std::make_pair(i, std::current_exception())); - } - } - - handleExceptions(exceptions); - } -} - -template -void ThreadedIndex::runOnIndex( - std::function f) const { - const_cast*>(this)->runOnIndex( - [f](int i, IndexT* idx){ f(i, idx); }); -} - -template -void ThreadedIndex::reset() { - runOnIndex([](int, IndexT* index){ index->reset(); }); - this->ntotal = 0; - this->is_trained = false; -} - -template -void -ThreadedIndex::onAfterAddIndex(IndexT* index) { -} - -template -void -ThreadedIndex::onAfterRemoveIndex(IndexT* index) { -} - -template -void -ThreadedIndex::waitAndHandleFutures(std::vector>& v) { - // Blocking wait for completion for all of the indices, capturing any - // exceptions that are generated - std::vector> exceptions; - - for (int i = 0; i < v.size(); ++i) { - auto& fut = v[i]; - - try { - fut.get(); - } catch (...) { - exceptions.emplace_back(std::make_pair(i, std::current_exception())); - } - } - - handleExceptions(exceptions); -} - -} // namespace diff --git a/cpp/thirdparty/knowhere_build/include/faiss/ThreadedIndex.h b/cpp/thirdparty/knowhere_build/include/faiss/ThreadedIndex.h deleted file mode 100644 index 2e6632a72f..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/ThreadedIndex.h +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#include "Index.h" -#include "IndexBinary.h" -#include "WorkerThread.h" -#include -#include - -namespace faiss { - -/// A holder of indices in a collection of threads -/// The interface to this class itself is not thread safe -template -class ThreadedIndex : public IndexT { - public: - explicit ThreadedIndex(bool threaded); - explicit ThreadedIndex(int d, bool threaded); - - ~ThreadedIndex() override; - - /// override an index that is managed by ourselves. - /// WARNING: once an index is added, it becomes unsafe to touch it from any - /// other thread than that on which is managing it, until we are shut - /// down. Use runOnIndex to perform work on it instead. - void addIndex(IndexT* index); - - /// Remove an index that is managed by ourselves. - /// This will flush all pending work on that index, and then shut - /// down its managing thread, and will remove the index. - void removeIndex(IndexT* index); - - /// Run a function on all indices, in the thread that the index is - /// managed in. - /// Function arguments are (index in collection, index pointer) - void runOnIndex(std::function f); - void runOnIndex(std::function f) const; - - /// faiss::Index API - /// All indices receive the same call - void reset() override; - - /// Returns the number of sub-indices - int count() const { return indices_.size(); } - - /// Returns the i-th sub-index - IndexT* at(int i) { return indices_[i].first; } - - /// Returns the i-th sub-index (const version) - const IndexT* at(int i) const { return indices_[i].first; } - - /// Whether or not we are responsible for deleting our contained indices - bool own_fields; - - protected: - /// Called just after an index is added - virtual void onAfterAddIndex(IndexT* index); - - /// Called just after an index is removed - virtual void onAfterRemoveIndex(IndexT* index); - -protected: - static void waitAndHandleFutures(std::vector>& v); - - /// Collection of Index instances, with their managing worker thread if any - std::vector>> indices_; - - /// Is this index multi-threaded? - bool isThreaded_; -}; - -} // namespace - -#include "ThreadedIndex-inl.h" diff --git a/cpp/thirdparty/knowhere_build/include/faiss/VectorTransform.h b/cpp/thirdparty/knowhere_build/include/faiss/VectorTransform.h deleted file mode 100644 index 694c0dbd0e..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/VectorTransform.h +++ /dev/null @@ -1,337 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -#ifndef FAISS_VECTOR_TRANSFORM_H -#define FAISS_VECTOR_TRANSFORM_H - -/** Defines a few objects that apply transformations to a set of - * vectors Often these are pre-processing steps. - */ - -#include -#include - -#include "Index.h" - - -namespace faiss { - - -/** Any transformation applied on a set of vectors */ -struct VectorTransform { - - typedef Index::idx_t idx_t; - - int d_in; ///! input dimension - int d_out; ///! output dimension - - explicit VectorTransform (int d_in = 0, int d_out = 0): - d_in(d_in), d_out(d_out), is_trained(true) - {} - - - /// set if the VectorTransform does not require training, or if - /// training is done already - bool is_trained; - - - /** Perform training on a representative set of vectors. Does - * nothing by default. - * - * @param n nb of training vectors - * @param x training vecors, size n * d - */ - virtual void train (idx_t n, const float *x); - - /** apply the random roation, return new allocated matrix - * @param x size n * d_in - * @return size n * d_out - */ - float *apply (idx_t n, const float * x) const; - - /// same as apply, but result is pre-allocated - virtual void apply_noalloc (idx_t n, const float * x, - float *xt) const = 0; - - /// reverse transformation. May not be implemented or may return - /// approximate result - virtual void reverse_transform (idx_t n, const float * xt, - float *x) const; - - virtual ~VectorTransform () {} - -}; - - - -/** Generic linear transformation, with bias term applied on output - * y = A * x + b - */ -struct LinearTransform: VectorTransform { - - bool have_bias; ///! whether to use the bias term - - /// check if matrix A is orthonormal (enables reverse_transform) - bool is_orthonormal; - - /// Transformation matrix, size d_out * d_in - std::vector A; - - /// bias vector, size d_out - std::vector b; - - /// both d_in > d_out and d_out < d_in are supported - explicit LinearTransform (int d_in = 0, int d_out = 0, - bool have_bias = false); - - /// same as apply, but result is pre-allocated - void apply_noalloc(idx_t n, const float* x, float* xt) const override; - - /// compute x = A^T * (x - b) - /// is reverse transform if A has orthonormal lines - void transform_transpose (idx_t n, const float * y, - float *x) const; - - /// works only if is_orthonormal - void reverse_transform (idx_t n, const float * xt, - float *x) const override; - - /// compute A^T * A to set the is_orthonormal flag - void set_is_orthonormal (); - - bool verbose; - - ~LinearTransform() override {} -}; - - - -/// Randomly rotate a set of vectors -struct RandomRotationMatrix: LinearTransform { - - /// both d_in > d_out and d_out < d_in are supported - RandomRotationMatrix (int d_in, int d_out): - LinearTransform(d_in, d_out, false) {} - - /// must be called before the transform is used - void init(int seed); - - // intializes with an arbitrary seed - void train(Index::idx_t n, const float* x) override; - - RandomRotationMatrix () {} -}; - - -/** Applies a principal component analysis on a set of vectors, - * with optionally whitening and random rotation. */ -struct PCAMatrix: LinearTransform { - - /** after transformation the components are multiplied by - * eigenvalues^eigen_power - * - * =0: no whitening - * =-0.5: full whitening - */ - float eigen_power; - - /// random rotation after PCA - bool random_rotation; - - /// ratio between # training vectors and dimension - size_t max_points_per_d; - - /// try to distribute output eigenvectors in this many bins - int balanced_bins; - - /// Mean, size d_in - std::vector mean; - - /// eigenvalues of covariance matrix (= squared singular values) - std::vector eigenvalues; - - /// PCA matrix, size d_in * d_in - std::vector PCAMat; - - // the final matrix is computed after random rotation and/or whitening - explicit PCAMatrix (int d_in = 0, int d_out = 0, - float eigen_power = 0, bool random_rotation = false); - - /// train on n vectors. If n < d_in then the eigenvector matrix - /// will be completed with 0s - void train(Index::idx_t n, const float* x) override; - - /// copy pre-trained PCA matrix - void copy_from (const PCAMatrix & other); - - /// called after mean, PCAMat and eigenvalues are computed - void prepare_Ab(); - -}; - - -struct ProductQuantizer; - -/** Applies a rotation to align the dimensions with a PQ to minimize - * the reconstruction error. Can be used before an IndexPQ or an - * IndexIVFPQ. The method is the non-parametric version described in: - * - * "Optimized Product Quantization for Approximate Nearest Neighbor Search" - * Tiezheng Ge, Kaiming He, Qifa Ke, Jian Sun, CVPR'13 - * - */ -struct OPQMatrix: LinearTransform { - - int M; ///< nb of subquantizers - int niter; ///< Number of outer training iterations - int niter_pq; ///< Number of training iterations for the PQ - int niter_pq_0; ///< same, for the first outer iteration - - /// if there are too many training points, resample - size_t max_train_points; - bool verbose; - - /// if non-NULL, use this product quantizer for training - /// should be constructed with (d_out, M, _) - ProductQuantizer * pq; - - /// if d2 != -1, output vectors of this dimension - explicit OPQMatrix (int d = 0, int M = 1, int d2 = -1); - - void train(Index::idx_t n, const float* x) override; -}; - - -/** remap dimensions for intput vectors, possibly inserting 0s - * strictly speaking this is also a linear transform but we don't want - * to compute it with matrix multiplies */ -struct RemapDimensionsTransform: VectorTransform { - - /// map from output dimension to input, size d_out - /// -1 -> set output to 0 - std::vector map; - - RemapDimensionsTransform (int d_in, int d_out, const int *map); - - /// remap input to output, skipping or inserting dimensions as needed - /// if uniform: distribute dimensions uniformly - /// otherwise just take the d_out first ones. - RemapDimensionsTransform (int d_in, int d_out, bool uniform = true); - - void apply_noalloc(idx_t n, const float* x, float* xt) const override; - - /// reverse transform correct only when the mapping is a permuation - void reverse_transform(idx_t n, const float* xt, float* x) const override; - - RemapDimensionsTransform () {} -}; - - -/** per-vector normalization */ -struct NormalizationTransform: VectorTransform { - float norm; - - explicit NormalizationTransform (int d, float norm = 2.0); - NormalizationTransform (); - - void apply_noalloc(idx_t n, const float* x, float* xt) const override; - - /// Identity transform since norm is not revertible - void reverse_transform(idx_t n, const float* xt, float* x) const override; -}; - -/** Subtract the mean of each component from the vectors. */ -struct CenteringTransform: VectorTransform { - - /// Mean, size d_in = d_out - std::vector mean; - - explicit CenteringTransform (int d = 0); - - /// train on n vectors. - void train(Index::idx_t n, const float* x) override; - - /// subtract the mean - void apply_noalloc(idx_t n, const float* x, float* xt) const override; - - /// add the mean - void reverse_transform (idx_t n, const float * xt, - float *x) const override; - -}; - - -/** Index that applies a LinearTransform transform on vectors before - * handing them over to a sub-index */ -struct IndexPreTransform: Index { - - std::vector chain; ///! chain of tranforms - Index * index; ///! the sub-index - - bool own_fields; ///! whether pointers are deleted in destructor - - explicit IndexPreTransform (Index *index); - - IndexPreTransform (); - - /// ltrans is the last transform before the index - IndexPreTransform (VectorTransform * ltrans, Index * index); - - void prepend_transform (VectorTransform * ltrans); - - void train(idx_t n, const float* x) override; - - void add(idx_t n, const float* x) override; - - void add_with_ids(idx_t n, const float* x, const idx_t* xids) override; - - void reset() override; - - /** removes IDs from the index. Not supported by all indexes. - */ - size_t remove_ids(const IDSelector& sel) override; - - void search( - idx_t n, - const float* x, - idx_t k, - float* distances, - idx_t* labels) const override; - - - /* range search, no attempt is done to change the radius */ - void range_search (idx_t n, const float* x, float radius, - RangeSearchResult* result) const override; - - - void reconstruct (idx_t key, float * recons) const override; - - void reconstruct_n (idx_t i0, idx_t ni, float *recons) - const override; - - void search_and_reconstruct (idx_t n, const float *x, idx_t k, - float *distances, idx_t *labels, - float *recons) const override; - - /// apply the transforms in the chain. The returned float * may be - /// equal to x, otherwise it should be deallocated. - const float * apply_chain (idx_t n, const float *x) const; - - /// Reverse the transforms in the chain. May not be implemented for - /// all transforms in the chain or may return approximate results. - void reverse_chain (idx_t n, const float* xt, float* x) const; - - ~IndexPreTransform() override; -}; - - -} // namespace faiss - - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/faiss/WorkerThread.h b/cpp/thirdparty/knowhere_build/include/faiss/WorkerThread.h deleted file mode 100644 index 7ab21e9f90..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/WorkerThread.h +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - - -#pragma once - -#include -#include -#include -#include - -namespace faiss { - -class WorkerThread { - public: - WorkerThread(); - - /// Stops and waits for the worker thread to exit, flushing all - /// pending lambdas - ~WorkerThread(); - - /// Request that the worker thread stop itself - void stop(); - - /// Blocking waits in the current thread for the worker thread to - /// stop - void waitForThreadExit(); - - /// Adds a lambda to run on the worker thread; returns a future that - /// can be used to block on its completion. - /// Future status is `true` if the lambda was run in the worker - /// thread; `false` if it was not run, because the worker thread is - /// exiting or has exited. - std::future add(std::function f); - - private: - void startThread(); - void threadMain(); - void threadLoop(); - - /// Thread that all queued lambdas are run on - std::thread thread_; - - /// Mutex for the queue and exit status - std::mutex mutex_; - - /// Monitor for the exit status and the queue - std::condition_variable monitor_; - - /// Whether or not we want the thread to exit - bool wantStop_; - - /// Queue of pending lambdas to call - std::deque, std::promise>> queue_; -}; - -} // namespace diff --git a/cpp/thirdparty/knowhere_build/include/faiss/distances.h b/cpp/thirdparty/knowhere_build/include/faiss/distances.h deleted file mode 100644 index 9432b3e78d..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/distances.h +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -#ifndef FAISS_distances_h -#define FAISS_distances_h - -/** In this file are the implementations of extra metrics beyond L2 - * and inner product */ - -#include - -#include "Index.h" - -#include "Heap.h" - - - -namespace faiss { - - -void pairwise_extra_distances ( - int64_t d, - int64_t nq, const float *xq, - int64_t nb, const float *xb, - MetricType mt, float metric_arg, - float *dis, - int64_t ldq = -1, int64_t ldb = -1, int64_t ldd = -1); - - -void knn_extra_metrics ( - const float * x, - const float * y, - size_t d, size_t nx, size_t ny, - MetricType mt, float metric_arg, - float_maxheap_array_t * res); - - -/** get a DistanceComputer that refers to this type of distance and - * indexes a flat array of size nb */ -DistanceComputer *get_extra_distance_computer ( - size_t d, - MetricType mt, float metric_arg, - size_t nb, const float *xb); - -} - - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuAutoTune.h b/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuAutoTune.h deleted file mode 100644 index 3e20b16d99..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuAutoTune.h +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#include "../Index.h" -#include "../AutoTune.h" -#include "GpuClonerOptions.h" -#include "GpuIndex.h" -#include "GpuIndicesOptions.h" - -namespace faiss { namespace gpu { - -class GpuResources; - -// to support auto-tuning we need cloning to/from CPU - -/// converts any GPU index inside gpu_index to a CPU index -faiss::Index * index_gpu_to_cpu(const faiss::Index *gpu_index); - -/// converts any CPU index that can be converted to GPU -faiss::Index * index_cpu_to_gpu( - GpuResources* resources, int device, - const faiss::Index *index, - const GpuClonerOptions *options = nullptr); - -faiss::Index * index_cpu_to_gpu_multiple( - std::vector & resources, - std::vector &devices, - const faiss::Index *index, - const GpuMultipleClonerOptions *options = nullptr); - -/// parameter space and setters for GPU indexes -struct GpuParameterSpace: faiss::ParameterSpace { - /// initialize with reasonable parameters for the index - void initialize (const faiss::Index * index) override; - - /// set a combination of parameters on an index - void set_index_parameter ( - faiss::Index * index, const std::string & name, - double val) const override; -}; - -} } // namespace diff --git a/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuClonerOptions.h b/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuClonerOptions.h deleted file mode 100644 index 9a4521f095..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuClonerOptions.h +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#include "GpuIndicesOptions.h" - -namespace faiss { namespace gpu { - -/// set some options on how to copy to GPU -struct GpuClonerOptions { - GpuClonerOptions(); - - /// how should indices be stored on index types that support indices - /// (anything but GpuIndexFlat*)? - IndicesOptions indicesOptions; - - /// is the coarse quantizer in float16? - bool useFloat16CoarseQuantizer; - - /// for GpuIndexIVFFlat, is storage in float16? - /// for GpuIndexIVFPQ, are intermediate calculations in float16? - bool useFloat16; - - /// use precomputed tables? - bool usePrecomputed; - - /// reserve vectors in the invfiles? - long reserveVecs; - - /// For GpuIndexFlat, store data in transposed layout? - bool storeTransposed; - - /// Set verbose options on the index - bool verbose; -}; - -struct GpuMultipleClonerOptions : public GpuClonerOptions { - GpuMultipleClonerOptions (); - - /// Whether to shard the index across GPUs, versus replication - /// across GPUs - bool shard; - - /// IndexIVF::copy_subset_to subset type - int shard_type; -}; - -} } // namespace diff --git a/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuDistance.h b/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuDistance.h deleted file mode 100644 index 2bcb2f6d37..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuDistance.h +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - - -#pragma once - -#include "../Index.h" - -namespace faiss { namespace gpu { - -class GpuResources; - -/// A wrapper for gpu/impl/Distance.cuh to expose direct brute-force k-nearest -/// neighbor searches on an externally-provided region of memory (e.g., from a -/// pytorch tensor). -/// The data (vectors, queries, outDistances, outIndices) can be resident on the -/// GPU or the CPU, but all calculations are performed on the GPU. If the result -/// buffers are on the CPU, results will be copied back when done. -/// -/// All GPU computation is performed on the current CUDA device, and ordered -/// with respect to resources->getDefaultStreamCurrentDevice(). -/// -/// For each vector in `queries`, searches all of `vectors` to find its k -/// nearest neighbors with respect to the given metric -void bruteForceKnn(GpuResources* resources, - faiss::MetricType metric, - // If vectorsRowMajor is true, this is - // numVectors x dims, with dims innermost; otherwise, - // dims x numVectors, with numVectors innermost - const float* vectors, - bool vectorsRowMajor, - int numVectors, - // If queriesRowMajor is true, this is - // numQueries x dims, with dims innermost; otherwise, - // dims x numQueries, with numQueries innermost - const float* queries, - bool queriesRowMajor, - int numQueries, - int dims, - int k, - // A region of memory size numQueries x k, with k - // innermost (row major) - float* outDistances, - // A region of memory size numQueries x k, with k - // innermost (row major) - faiss::Index::idx_t* outIndices); - -} } // namespace diff --git a/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuFaissAssert.h b/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuFaissAssert.h deleted file mode 100644 index e6ae0de31b..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuFaissAssert.h +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - - -#ifndef GPU_FAISS_ASSERT_INCLUDED -#define GPU_FAISS_ASSERT_INCLUDED - -#include "../FaissAssert.h" -#include - -/// -/// Assertions -/// - -#ifdef __CUDA_ARCH__ -#define GPU_FAISS_ASSERT(X) assert(X) -#define GPU_FAISS_ASSERT_MSG(X, MSG) assert(X) -#define GPU_FAISS_ASSERT_FMT(X, FMT, ...) assert(X) -#else -#define GPU_FAISS_ASSERT(X) FAISS_ASSERT(X) -#define GPU_FAISS_ASSERT_MSG(X, MSG) FAISS_ASSERT_MSG(X, MSG) -#define GPU_FAISS_ASSERT_FMT(X, FMT, ...) FAISS_ASSERT_FMT(X, FMT, __VA_ARGS) -#endif // __CUDA_ARCH__ - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuIndex.h b/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuIndex.h deleted file mode 100644 index ef4b7f71b4..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuIndex.h +++ /dev/null @@ -1,135 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - - -#pragma once - -#include "../Index.h" -#include "utils/MemorySpace.h" - -namespace faiss { namespace gpu { - -class GpuResources; - -struct GpuIndexConfig { - inline GpuIndexConfig() - : device(0), - memorySpace(MemorySpace::Device) { - } - - /// GPU device on which the index is resident - int device; - - /// What memory space to use for primary storage. - /// On Pascal and above (CC 6+) architectures, allows GPUs to use - /// more memory than is available on the GPU. - MemorySpace memorySpace; -}; - -class GpuIndex : public faiss::Index { - public: - GpuIndex(GpuResources* resources, - int dims, - faiss::MetricType metric, - GpuIndexConfig config); - - inline int getDevice() const { - return device_; - } - - inline GpuResources* getResources() { - return resources_; - } - - /// Set the minimum data size for searches (in MiB) for which we use - /// CPU -> GPU paging - void setMinPagingSize(size_t size); - - /// Returns the current minimum data size for paged searches - size_t getMinPagingSize() const; - - /// `x` can be resident on the CPU or any GPU; copies are performed - /// as needed - /// Handles paged adds if the add set is too large; calls addInternal_ - void add(faiss::Index::idx_t, const float* x) override; - - /// `x` and `ids` can be resident on the CPU or any GPU; copies are - /// performed as needed - /// Handles paged adds if the add set is too large; calls addInternal_ - void add_with_ids(Index::idx_t n, - const float* x, - const Index::idx_t* ids) override; - - /// `x`, `distances` and `labels` can be resident on the CPU or any - /// GPU; copies are performed as needed - void search(Index::idx_t n, - const float* x, - Index::idx_t k, - float* distances, - Index::idx_t* labels) const override; - - protected: - /// Does addImpl_ require IDs? If so, and no IDs are provided, we will - /// generate them sequentially based on the order in which the IDs are added - virtual bool addImplRequiresIDs_() const = 0; - - /// Overridden to actually perform the add - /// All data is guaranteed to be resident on our device - virtual void addImpl_(int n, - const float* x, - const Index::idx_t* ids) = 0; - - /// Overridden to actually perform the search - /// All data is guaranteed to be resident on our device - virtual void searchImpl_(int n, - const float* x, - int k, - float* distances, - Index::idx_t* labels) const = 0; - -private: - /// Handles paged adds if the add set is too large, passes to - /// addImpl_ to actually perform the add for the current page - void addPaged_(int n, - const float* x, - const Index::idx_t* ids); - - /// Calls addImpl_ for a single page of GPU-resident data - void addPage_(int n, - const float* x, - const Index::idx_t* ids); - - /// Calls searchImpl_ for a single page of GPU-resident data - void searchNonPaged_(int n, - const float* x, - int k, - float* outDistancesData, - Index::idx_t* outIndicesData) const; - - /// Calls searchImpl_ for a single page of GPU-resident data, - /// handling paging of the data and copies from the CPU - void searchFromCpuPaged_(int n, - const float* x, - int k, - float* outDistancesData, - Index::idx_t* outIndicesData) const; - - protected: - /// Manages streams, cuBLAS handles and scratch memory for devices - GpuResources* resources_; - - /// The GPU device we are resident on - const int device_; - - /// The memory space of our primary storage on the GPU - const MemorySpace memorySpace_; - - /// Size above which we page copies from the CPU to GPU - size_t minPagedSize_; -}; - -} } // namespace diff --git a/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuIndexBinaryFlat.h b/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuIndexBinaryFlat.h deleted file mode 100644 index ee7ad52566..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuIndexBinaryFlat.h +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#include "../IndexBinaryFlat.h" -#include "GpuIndex.h" - -namespace faiss { namespace gpu { - -class BinaryFlatIndex; -class GpuResources; - -struct GpuIndexBinaryFlatConfig : public GpuIndexConfig { -}; - -/// A GPU version of IndexBinaryFlat for brute-force comparison of bit vectors -/// via Hamming distance -class GpuIndexBinaryFlat : public IndexBinary { - public: - /// Construct from a pre-existing faiss::IndexBinaryFlat instance, copying - /// data over to the given GPU - GpuIndexBinaryFlat(GpuResources* resources, - const faiss::IndexBinaryFlat* index, - GpuIndexBinaryFlatConfig config = - GpuIndexBinaryFlatConfig()); - - /// Construct an empty instance that can be added to - GpuIndexBinaryFlat(GpuResources* resources, - int dims, - GpuIndexBinaryFlatConfig config = - GpuIndexBinaryFlatConfig()); - - ~GpuIndexBinaryFlat() override; - - /// Initialize ourselves from the given CPU index; will overwrite - /// all data in ourselves - void copyFrom(const faiss::IndexBinaryFlat* index); - - /// Copy ourselves to the given CPU index; will overwrite all data - /// in the index instance - void copyTo(faiss::IndexBinaryFlat* index) const; - - void add(faiss::IndexBinary::idx_t n, - const uint8_t* x) override; - - void reset() override; - - void search(faiss::IndexBinary::idx_t n, - const uint8_t* x, - faiss::IndexBinary::idx_t k, - int32_t* distances, - faiss::IndexBinary::idx_t* labels) const override; - - void reconstruct(faiss::IndexBinary::idx_t key, - uint8_t* recons) const override; - - protected: - /// Called from search when the input data is on the CPU; - /// potentially allows for pinned memory usage - void searchFromCpuPaged_(int n, - const uint8_t* x, - int k, - int32_t* outDistancesData, - int* outIndicesData) const; - - void searchNonPaged_(int n, - const uint8_t* x, - int k, - int32_t* outDistancesData, - int* outIndicesData) const; - - protected: - /// Manages streans, cuBLAS handles and scratch memory for devices - GpuResources* resources_; - - /// Configuration options - GpuIndexBinaryFlatConfig config_; - - /// Holds our GPU data containing the list of vectors; is managed via raw - /// pointer so as to allow non-CUDA compilers to see this header - BinaryFlatIndex* data_; -}; - -} } // namespace gpu diff --git a/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuIndexFlat.h b/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuIndexFlat.h deleted file mode 100644 index 10faf68987..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuIndexFlat.h +++ /dev/null @@ -1,180 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - - -#pragma once - -#include "GpuIndex.h" - -namespace faiss { - -struct IndexFlat; -struct IndexFlatL2; -struct IndexFlatIP; - -} - -namespace faiss { namespace gpu { - -struct FlatIndex; - -struct GpuIndexFlatConfig : public GpuIndexConfig { - inline GpuIndexFlatConfig() - : useFloat16(false), - useFloat16Accumulator(false), - storeTransposed(false) { - } - - /// Whether or not data is stored as float16 - bool useFloat16; - - /// Whether or not all math is performed in float16, if useFloat16 is - /// specified. If true, we use cublasHgemm, supported only on CC - /// 5.3+. Otherwise, we use cublasSgemmEx. - bool useFloat16Accumulator; - - /// Whether or not data is stored (transparently) in a transposed - /// layout, enabling use of the NN GEMM call, which is ~10% faster. - /// This will improve the speed of the flat index, but will - /// substantially slow down any add() calls made, as all data must - /// be transposed, and will increase storage requirements (we store - /// data in both transposed and non-transposed layouts). - bool storeTransposed; -}; - -/// Wrapper around the GPU implementation that looks like -/// faiss::IndexFlat; copies over centroid data from a given -/// faiss::IndexFlat -class GpuIndexFlat : public GpuIndex { - public: - /// Construct from a pre-existing faiss::IndexFlat instance, copying - /// data over to the given GPU - GpuIndexFlat(GpuResources* resources, - const faiss::IndexFlat* index, - GpuIndexFlatConfig config = GpuIndexFlatConfig()); - - /// Construct an empty instance that can be added to - GpuIndexFlat(GpuResources* resources, - int dims, - faiss::MetricType metric, - GpuIndexFlatConfig config = GpuIndexFlatConfig()); - - ~GpuIndexFlat() override; - - /// Initialize ourselves from the given CPU index; will overwrite - /// all data in ourselves - void copyFrom(const faiss::IndexFlat* index); - - /// Copy ourselves to the given CPU index; will overwrite all data - /// in the index instance - void copyTo(faiss::IndexFlat* index) const; - - /// Returns the number of vectors we contain - size_t getNumVecs() const; - - /// Clears all vectors from this index - void reset() override; - - /// This index is not trained, so this does nothing - void train(Index::idx_t n, const float* x) override; - - /// Overrides to avoid excessive copies - void add(faiss::Index::idx_t, const float* x) override; - - /// Reconstruction methods; prefer the batch reconstruct as it will - /// be more efficient - void reconstruct(faiss::Index::idx_t key, float* out) const override; - - /// Batch reconstruction method - void reconstruct_n( - faiss::Index::idx_t i0, - faiss::Index::idx_t num, - float* out) const override; - - /// For internal access - inline FlatIndex* getGpuData() { return data_; } - - protected: - /// Flat index does not require IDs as there is no storage available for them - bool addImplRequiresIDs_() const override; - - /// Called from GpuIndex for add - void addImpl_(int n, - const float* x, - const Index::idx_t* ids) override; - - /// Called from GpuIndex for search - void searchImpl_(int n, - const float* x, - int k, - float* distances, - faiss::Index::idx_t* labels) const override; - - private: - /// Checks user settings for consistency - void verifySettings_() const; - - protected: - /// Our config object - const GpuIndexFlatConfig config_; - - /// Holds our GPU data containing the list of vectors; is managed via raw - /// pointer so as to allow non-CUDA compilers to see this header - FlatIndex* data_; -}; - -/// Wrapper around the GPU implementation that looks like -/// faiss::IndexFlatL2; copies over centroid data from a given -/// faiss::IndexFlat -class GpuIndexFlatL2 : public GpuIndexFlat { - public: - /// Construct from a pre-existing faiss::IndexFlatL2 instance, copying - /// data over to the given GPU - GpuIndexFlatL2(GpuResources* resources, - faiss::IndexFlatL2* index, - GpuIndexFlatConfig config = GpuIndexFlatConfig()); - - /// Construct an empty instance that can be added to - GpuIndexFlatL2(GpuResources* resources, - int dims, - GpuIndexFlatConfig config = GpuIndexFlatConfig()); - - /// Initialize ourselves from the given CPU index; will overwrite - /// all data in ourselves - void copyFrom(faiss::IndexFlatL2* index); - - /// Copy ourselves to the given CPU index; will overwrite all data - /// in the index instance - void copyTo(faiss::IndexFlatL2* index); -}; - -/// Wrapper around the GPU implementation that looks like -/// faiss::IndexFlatIP; copies over centroid data from a given -/// faiss::IndexFlat -class GpuIndexFlatIP : public GpuIndexFlat { - public: - /// Construct from a pre-existing faiss::IndexFlatIP instance, copying - /// data over to the given GPU - GpuIndexFlatIP(GpuResources* resources, - faiss::IndexFlatIP* index, - GpuIndexFlatConfig config = GpuIndexFlatConfig()); - - /// Construct an empty instance that can be added to - GpuIndexFlatIP(GpuResources* resources, - int dims, - GpuIndexFlatConfig config = GpuIndexFlatConfig()); - - /// Initialize ourselves from the given CPU index; will overwrite - /// all data in ourselves - void copyFrom(faiss::IndexFlatIP* index); - - /// Copy ourselves to the given CPU index; will overwrite all data - /// in the index instance - void copyTo(faiss::IndexFlatIP* index); -}; - -} } // namespace diff --git a/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuIndexIVF.h b/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuIndexIVF.h deleted file mode 100644 index eb23708e12..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuIndexIVF.h +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - - -#pragma once - -#include "GpuIndex.h" -#include "GpuIndexFlat.h" -#include "GpuIndicesOptions.h" -#include "../Clustering.h" - -namespace faiss { struct IndexIVF; } - -namespace faiss { namespace gpu { - -class GpuIndexFlat; -class GpuResources; - -struct GpuIndexIVFConfig : public GpuIndexConfig { - inline GpuIndexIVFConfig() - : indicesOptions(INDICES_64_BIT) { - } - - /// Index storage options for the GPU - IndicesOptions indicesOptions; - - /// Configuration for the coarse quantizer object - GpuIndexFlatConfig flatConfig; -}; - -class GpuIndexIVF : public GpuIndex { - public: - GpuIndexIVF(GpuResources* resources, - int dims, - faiss::MetricType metric, - int nlist, - GpuIndexIVFConfig config = GpuIndexIVFConfig()); - - ~GpuIndexIVF() override; - - private: - /// Shared initialization functions - void init_(); - - public: - /// Copy what we need from the CPU equivalent - void copyFrom(const faiss::IndexIVF* index); - - /// Copy what we have to the CPU equivalent - void copyTo(faiss::IndexIVF* index) const; - - /// Returns the number of inverted lists we're managing - int getNumLists() const; - - /// Return the quantizer we're using - GpuIndexFlat* getQuantizer(); - - /// Sets the number of list probes per query - void setNumProbes(int nprobe); - - /// Returns our current number of list probes per query - int getNumProbes() const; - - protected: - bool addImplRequiresIDs_() const override; - void trainQuantizer_(faiss::Index::idx_t n, const float* x); - - public: - /// Exposed as IndexIVF does to allow overriding clustering - /// parameters - ClusteringParameters cp; - - protected: - GpuIndexIVFConfig ivfConfig_; - - /// Number of inverted lists that we manage - int nlist_; - - /// Number of inverted list probes per query - int nprobe_; - - /// Quantizer for inverted lists - GpuIndexFlat* quantizer_; -}; - -} } // namespace diff --git a/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuIndexIVFFlat.h b/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuIndexIVFFlat.h deleted file mode 100644 index a383c30b62..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuIndexIVFFlat.h +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - - -#pragma once - -#include "GpuIndexIVF.h" - -namespace faiss { struct IndexIVFFlat; } - -namespace faiss { namespace gpu { - -class IVFFlat; -class GpuIndexFlat; - -struct GpuIndexIVFFlatConfig : public GpuIndexIVFConfig { - inline GpuIndexIVFFlatConfig() - : useFloat16IVFStorage(false) { - } - - /// Whether or not IVFFlat inverted list storage is in float16; - /// supported on all architectures - bool useFloat16IVFStorage; -}; - -/// Wrapper around the GPU implementation that looks like -/// faiss::IndexIVFFlat -class GpuIndexIVFFlat : public GpuIndexIVF { - public: - /// Construct from a pre-existing faiss::IndexIVFFlat instance, copying - /// data over to the given GPU, if the input index is trained. - GpuIndexIVFFlat(GpuResources* resources, - const faiss::IndexIVFFlat* index, - GpuIndexIVFFlatConfig config = GpuIndexIVFFlatConfig()); - - /// Constructs a new instance with an empty flat quantizer; the user - /// provides the number of lists desired. - GpuIndexIVFFlat(GpuResources* resources, - int dims, - int nlist, - faiss::MetricType metric, - GpuIndexIVFFlatConfig config = GpuIndexIVFFlatConfig()); - - ~GpuIndexIVFFlat() override; - - /// Reserve GPU memory in our inverted lists for this number of vectors - void reserveMemory(size_t numVecs); - - /// Initialize ourselves from the given CPU index; will overwrite - /// all data in ourselves - void copyFrom(const faiss::IndexIVFFlat* index); - - /// Copy ourselves to the given CPU index; will overwrite all data - /// in the index instance - void copyTo(faiss::IndexIVFFlat* index) const; - - /// After adding vectors, one can call this to reclaim device memory - /// to exactly the amount needed. Returns space reclaimed in bytes - size_t reclaimMemory(); - - void reset() override; - - void train(Index::idx_t n, const float* x) override; - - protected: - /// Called from GpuIndex for add/add_with_ids - void addImpl_(int n, - const float* x, - const Index::idx_t* ids) override; - - /// Called from GpuIndex for search - void searchImpl_(int n, - const float* x, - int k, - float* distances, - Index::idx_t* labels) const override; - - private: - GpuIndexIVFFlatConfig ivfFlatConfig_; - - /// Desired inverted list memory reservation - size_t reserveMemoryVecs_; - - /// Instance that we own; contains the inverted list - IVFFlat* index_; -}; - -} } // namespace diff --git a/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuIndexIVFPQ.h b/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuIndexIVFPQ.h deleted file mode 100644 index 86169ce17f..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuIndexIVFPQ.h +++ /dev/null @@ -1,143 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - - -#pragma once - -#include "GpuIndexIVF.h" -#include - -namespace faiss { struct IndexIVFPQ; } - -namespace faiss { namespace gpu { - -class GpuIndexFlat; -class IVFPQ; - -struct GpuIndexIVFPQConfig : public GpuIndexIVFConfig { - inline GpuIndexIVFPQConfig() - : useFloat16LookupTables(false), - usePrecomputedTables(false) { - } - - /// Whether or not float16 residual distance tables are used in the - /// list scanning kernels. When subQuantizers * 2^bitsPerCode > - /// 16384, this is required. - bool useFloat16LookupTables; - - /// Whether or not we enable the precomputed table option for - /// search, which can substantially increase the memory requirement. - bool usePrecomputedTables; -}; - -/// IVFPQ index for the GPU -class GpuIndexIVFPQ : public GpuIndexIVF { - public: - /// Construct from a pre-existing faiss::IndexIVFPQ instance, copying - /// data over to the given GPU, if the input index is trained. - GpuIndexIVFPQ(GpuResources* resources, - const faiss::IndexIVFPQ* index, - GpuIndexIVFPQConfig config = GpuIndexIVFPQConfig()); - - /// Construct an empty index - GpuIndexIVFPQ(GpuResources* resources, - int dims, - int nlist, - int subQuantizers, - int bitsPerCode, - faiss::MetricType metric, - GpuIndexIVFPQConfig config = GpuIndexIVFPQConfig()); - - ~GpuIndexIVFPQ() override; - - /// Reserve space on the GPU for the inverted lists for `num` - /// vectors, assumed equally distributed among - - /// Initialize ourselves from the given CPU index; will overwrite - /// all data in ourselves - void copyFrom(const faiss::IndexIVFPQ* index); - - /// Copy ourselves to the given CPU index; will overwrite all data - /// in the index instance - void copyTo(faiss::IndexIVFPQ* index) const; - - /// Reserve GPU memory in our inverted lists for this number of vectors - void reserveMemory(size_t numVecs); - - /// Enable or disable pre-computed codes - void setPrecomputedCodes(bool enable); - - /// Are pre-computed codes enabled? - bool getPrecomputedCodes() const; - - /// Return the number of sub-quantizers we are using - int getNumSubQuantizers() const; - - /// Return the number of bits per PQ code - int getBitsPerCode() const; - - /// Return the number of centroids per PQ code (2^bits per code) - int getCentroidsPerSubQuantizer() const; - - /// After adding vectors, one can call this to reclaim device memory - /// to exactly the amount needed. Returns space reclaimed in bytes - size_t reclaimMemory(); - - /// Clears out all inverted lists, but retains the coarse and - /// product centroid information - void reset() override; - - void train(Index::idx_t n, const float* x) override; - - /// For debugging purposes, return the list length of a particular - /// list - int getListLength(int listId) const; - - /// For debugging purposes, return the list codes of a particular - /// list - std::vector getListCodes(int listId) const; - - /// For debugging purposes, return the list indices of a particular - /// list - std::vector getListIndices(int listId) const; - - protected: - /// Called from GpuIndex for add/add_with_ids - void addImpl_(int n, - const float* x, - const Index::idx_t* ids) override; - - /// Called from GpuIndex for search - void searchImpl_(int n, - const float* x, - int k, - float* distances, - Index::idx_t* labels) const override; - - private: - void verifySettings_() const; - - void trainResidualQuantizer_(Index::idx_t n, const float* x); - - private: - GpuIndexIVFPQConfig ivfpqConfig_; - - /// Number of sub-quantizers per encoded vector - int subQuantizers_; - - /// Bits per sub-quantizer code - int bitsPerCode_; - - /// Desired inverted list memory reservation - size_t reserveMemoryVecs_; - - /// The product quantizer instance that we own; contains the - /// inverted lists - IVFPQ* index_; -}; - -} } // namespace diff --git a/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuIndicesOptions.h b/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuIndicesOptions.h deleted file mode 100644 index 768f981f71..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuIndicesOptions.h +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - - -#pragma once - -namespace faiss { namespace gpu { - -/// How user vector index data is stored on the GPU -enum IndicesOptions { - /// The user indices are only stored on the CPU; the GPU returns - /// (inverted list, offset) to the CPU which is then translated to - /// the real user index. - INDICES_CPU = 0, - /// The indices are not stored at all, on either the CPU or - /// GPU. Only (inverted list, offset) is returned to the user as the - /// index. - INDICES_IVF = 1, - /// Indices are stored as 32 bit integers on the GPU, but returned - /// as 64 bit integers - INDICES_32_BIT = 2, - /// Indices are stored as 64 bit integers on the GPU - INDICES_64_BIT = 3, -}; - -} } // namespace diff --git a/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuResources.h b/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuResources.h deleted file mode 100644 index 258cb62d32..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/gpu/GpuResources.h +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - - -#pragma once - -#include "utils/DeviceMemory.h" -#include -#include -#include -#include - -namespace faiss { namespace gpu { - -/// Base class of GPU-side resource provider; hides provision of -/// cuBLAS handles, CUDA streams and a temporary memory manager -class GpuResources { - public: - virtual ~GpuResources(); - - /// Call to pre-allocate resources for a particular device. If this is - /// not called, then resources will be allocated at the first time - /// of demand - virtual void initializeForDevice(int device) = 0; - - /// Returns the cuBLAS handle that we use for the given device - virtual cublasHandle_t getBlasHandle(int device) = 0; - - /// Returns the stream that we order all computation on for the - /// given device - virtual cudaStream_t getDefaultStream(int device) = 0; - - /// Returns the set of alternative streams that we use for the given device - virtual std::vector getAlternateStreams(int device) = 0; - - /// Returns the temporary memory manager for the given device - virtual DeviceMemory& getMemoryManager(int device) = 0; - - /// Returns the available CPU pinned memory buffer - virtual std::pair getPinnedMemory() = 0; - - /// Returns the stream on which we perform async CPU <-> GPU copies - virtual cudaStream_t getAsyncCopyStream(int device) = 0; - - /// Calls getBlasHandle with the current device - cublasHandle_t getBlasHandleCurrentDevice(); - - /// Calls getDefaultStream with the current device - cudaStream_t getDefaultStreamCurrentDevice(); - - /// Synchronizes the CPU with respect to the default stream for the - /// given device - // equivalent to cudaDeviceSynchronize(getDefaultStream(device)) - void syncDefaultStream(int device); - - /// Calls syncDefaultStream for the current device - void syncDefaultStreamCurrentDevice(); - - /// Calls getAlternateStreams for the current device - std::vector getAlternateStreamsCurrentDevice(); - - /// Calls getMemoryManager for the current device - DeviceMemory& getMemoryManagerCurrentDevice(); - - /// Calls getAsyncCopyStream for the current device - cudaStream_t getAsyncCopyStreamCurrentDevice(); -}; - -} } // namespace diff --git a/cpp/thirdparty/knowhere_build/include/faiss/gpu/StandardGpuResources.h b/cpp/thirdparty/knowhere_build/include/faiss/gpu/StandardGpuResources.h deleted file mode 100644 index 834e45919b..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/gpu/StandardGpuResources.h +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - - -#pragma once - -#include "GpuResources.h" -#include "utils/StackDeviceMemory.h" -#include "utils/DeviceUtils.h" -#include -#include - -namespace faiss { namespace gpu { - -/// Default implementation of GpuResources that allocates a cuBLAS -/// stream and 2 streams for use, as well as temporary memory -class StandardGpuResources : public GpuResources { - public: - StandardGpuResources(); - - ~StandardGpuResources() override; - - /// Disable allocation of temporary memory; all temporary memory - /// requests will call cudaMalloc / cudaFree at the point of use - void noTempMemory(); - - /// Specify that we wish to use a certain fixed size of memory on - /// all devices as temporary memory. This is the upper bound for the GPU - /// memory that we will reserve. We will never go above 1.5 GiB on any GPU; - /// smaller GPUs (with <= 4 GiB or <= 8 GiB) will use less memory than that. - /// To avoid any temporary memory allocation, pass 0. - void setTempMemory(size_t size); - - /// Set amount of pinned memory to allocate, for async GPU <-> CPU - /// transfers - void setPinnedMemory(size_t size); - - /// Called to change the stream for work ordering - void setDefaultStream(int device, cudaStream_t stream); - - /// Called to change the work ordering streams to the null stream - /// for all devices - void setDefaultNullStreamAllDevices(); - - /// Enable or disable the warning about not having enough temporary memory - /// when cudaMalloc gets called - void setCudaMallocWarning(bool b); - - public: - /// Internal system calls - - /// Initialize resources for this device - void initializeForDevice(int device) override; - - cublasHandle_t getBlasHandle(int device) override; - - cudaStream_t getDefaultStream(int device) override; - - std::vector getAlternateStreams(int device) override; - - DeviceMemory& getMemoryManager(int device) override; - - std::pair getPinnedMemory() override; - - cudaStream_t getAsyncCopyStream(int device) override; - - private: - /// Have GPU resources been initialized for this device yet? - bool isInitialized(int device) const; - - /// Adjust the default temporary memory allocation based on the total GPU - /// memory size - static size_t getDefaultTempMemForGPU(int device, size_t requested); - - private: - /// Our default stream that work is ordered on, one per each device - std::unordered_map defaultStreams_; - - /// This contains particular streams as set by the user for - /// ordering, if any - std::unordered_map userDefaultStreams_; - - /// Other streams we can use, per each device - std::unordered_map > alternateStreams_; - - /// Async copy stream to use for GPU <-> CPU pinned memory copies - std::unordered_map asyncCopyStreams_; - - /// cuBLAS handle for each device - std::unordered_map blasHandles_; - - /// Temporary memory provider, per each device - std::unordered_map > memory_; - - /// Pinned memory allocation for use with this GPU - void* pinnedMemAlloc_; - size_t pinnedMemAllocSize_; - - /// Another option is to use a specified amount of memory on all - /// devices - size_t tempMemSize_; - - /// Amount of pinned memory we should allocate - size_t pinnedMemSize_; - - /// Whether or not a warning upon cudaMalloc is generated - bool cudaMallocWarning_; -}; - -} } // namespace diff --git a/cpp/thirdparty/knowhere_build/include/faiss/gpu/impl/RemapIndices.h b/cpp/thirdparty/knowhere_build/include/faiss/gpu/impl/RemapIndices.h deleted file mode 100644 index 234148451f..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/gpu/impl/RemapIndices.h +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - - -#pragma once - -#include - -namespace faiss { namespace gpu { - -/// Utility function to translate (list id, offset) to a user index on -/// the CPU. In a cpp in order to use OpenMP. -void ivfOffsetToUserIndex( - long* indices, - int numLists, - int queries, - int k, - const std::vector>& listOffsetToUserIndex); - -} } // namespace diff --git a/cpp/thirdparty/knowhere_build/include/faiss/gpu/utils/DeviceMemory.h b/cpp/thirdparty/knowhere_build/include/faiss/gpu/utils/DeviceMemory.h deleted file mode 100644 index 1bffdc00ac..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/gpu/utils/DeviceMemory.h +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - - -#pragma once - -#include -#include - -namespace faiss { namespace gpu { - -class DeviceMemory; - -class DeviceMemoryReservation { - public: - DeviceMemoryReservation(); - DeviceMemoryReservation(DeviceMemory* state, - int device, void* p, size_t size, - cudaStream_t stream); - DeviceMemoryReservation(DeviceMemoryReservation&& m) noexcept; - ~DeviceMemoryReservation(); - - DeviceMemoryReservation& operator=(DeviceMemoryReservation&& m); - - int device() { return device_; } - void* get() { return data_; } - size_t size() { return size_; } - cudaStream_t stream() { return stream_; } - - private: - DeviceMemory* state_; - - int device_; - void* data_; - size_t size_; - cudaStream_t stream_; -}; - -/// Manages temporary memory allocations on a GPU device -class DeviceMemory { - public: - virtual ~DeviceMemory(); - - /// Returns the device we are managing memory for - virtual int getDevice() const = 0; - - /// Obtains a temporary memory allocation for our device, - /// whose usage is ordered with respect to the given stream. - virtual DeviceMemoryReservation getMemory(cudaStream_t stream, - size_t size) = 0; - - /// Returns the current size available without calling cudaMalloc - virtual size_t getSizeAvailable() const = 0; - - /// Returns a string containing our current memory manager state - virtual std::string toString() const = 0; - - /// Returns the high-water mark of cudaMalloc allocations for our - /// device - virtual size_t getHighWaterCudaMalloc() const = 0; - - protected: - friend class DeviceMemoryReservation; - virtual void returnAllocation(DeviceMemoryReservation& m) = 0; -}; - -} } // namespace diff --git a/cpp/thirdparty/knowhere_build/include/faiss/gpu/utils/DeviceUtils.h b/cpp/thirdparty/knowhere_build/include/faiss/gpu/utils/DeviceUtils.h deleted file mode 100644 index 8abc7af70b..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/gpu/utils/DeviceUtils.h +++ /dev/null @@ -1,179 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - - -#pragma once - -#include "../../FaissAssert.h" -#include -#include -#include - -namespace faiss { namespace gpu { - -/// Returns the current thread-local GPU device -int getCurrentDevice(); - -/// Sets the current thread-local GPU device -void setCurrentDevice(int device); - -/// Returns the number of available GPU devices -int getNumDevices(); - -/// Synchronizes the CPU against all devices (equivalent to -/// cudaDeviceSynchronize for each device) -void synchronizeAllDevices(); - -/// Returns a cached cudaDeviceProp for the given device -const cudaDeviceProp& getDeviceProperties(int device); - -/// Returns the cached cudaDeviceProp for the current device -const cudaDeviceProp& getCurrentDeviceProperties(); - -/// Returns the maximum number of threads available for the given GPU -/// device -int getMaxThreads(int device); - -/// Equivalent to getMaxThreads(getCurrentDevice()) -int getMaxThreadsCurrentDevice(); - -/// Returns the maximum smem available for the given GPU device -size_t getMaxSharedMemPerBlock(int device); - -/// Equivalent to getMaxSharedMemPerBlock(getCurrentDevice()) -size_t getMaxSharedMemPerBlockCurrentDevice(); - -/// For a given pointer, returns whether or not it is located on -/// a device (deviceId >= 0) or the host (-1). -int getDeviceForAddress(const void* p); - -/// Does the given device support full unified memory sharing host -/// memory? -bool getFullUnifiedMemSupport(int device); - -/// Equivalent to getFullUnifiedMemSupport(getCurrentDevice()) -bool getFullUnifiedMemSupportCurrentDevice(); - -/// Returns the maximum k-selection value supported based on the CUDA SDK that -/// we were compiled with. .cu files can use DeviceDefs.cuh, but this is for -/// non-CUDA files -int getMaxKSelection(); - -/// RAII object to set the current device, and restore the previous -/// device upon destruction -class DeviceScope { - public: - explicit DeviceScope(int device); - ~DeviceScope(); - - private: - int prevDevice_; -}; - -/// RAII object to manage a cublasHandle_t -class CublasHandleScope { - public: - CublasHandleScope(); - ~CublasHandleScope(); - - cublasHandle_t get() { return blasHandle_; } - - private: - cublasHandle_t blasHandle_; -}; - -// RAII object to manage a cudaEvent_t -class CudaEvent { - public: - /// Creates an event and records it in this stream - explicit CudaEvent(cudaStream_t stream); - CudaEvent(const CudaEvent& event) = delete; - CudaEvent(CudaEvent&& event) noexcept; - ~CudaEvent(); - - inline cudaEvent_t get() { return event_; } - - /// Wait on this event in this stream - void streamWaitOnEvent(cudaStream_t stream); - - /// Have the CPU wait for the completion of this event - void cpuWaitOnEvent(); - - CudaEvent& operator=(CudaEvent&& event) noexcept; - CudaEvent& operator=(CudaEvent& event) = delete; - - private: - cudaEvent_t event_; -}; - -/// Wrapper to test return status of CUDA functions -#define CUDA_VERIFY(X) \ - do { \ - auto err__ = (X); \ - FAISS_ASSERT_FMT(err__ == cudaSuccess, "CUDA error %d %s", \ - (int) err__, cudaGetErrorString(err__)); \ - } while (0) - -/// Wrapper to synchronously probe for CUDA errors -// #define FAISS_GPU_SYNC_ERROR 1 - -#ifdef FAISS_GPU_SYNC_ERROR -#define CUDA_TEST_ERROR() \ - do { \ - CUDA_VERIFY(cudaDeviceSynchronize()); \ - } while (0) -#else -#define CUDA_TEST_ERROR() \ - do { \ - CUDA_VERIFY(cudaGetLastError()); \ - } while (0) -#endif - -/// Call for a collection of streams to wait on -template -void streamWaitBase(const L1& listWaiting, const L2& listWaitOn) { - // For all the streams we are waiting on, create an event - std::vector events; - for (auto& stream : listWaitOn) { - cudaEvent_t event; - CUDA_VERIFY(cudaEventCreateWithFlags(&event, cudaEventDisableTiming)); - CUDA_VERIFY(cudaEventRecord(event, stream)); - events.push_back(event); - } - - // For all the streams that are waiting, issue a wait - for (auto& stream : listWaiting) { - for (auto& event : events) { - CUDA_VERIFY(cudaStreamWaitEvent(stream, event, 0)); - } - } - - for (auto& event : events) { - CUDA_VERIFY(cudaEventDestroy(event)); - } -} - -/// These versions allow usage of initializer_list as arguments, since -/// otherwise {...} doesn't have a type -template -void streamWait(const L1& a, - const std::initializer_list& b) { - streamWaitBase(a, b); -} - -template -void streamWait(const std::initializer_list& a, - const L2& b) { - streamWaitBase(a, b); -} - -inline void streamWait(const std::initializer_list& a, - const std::initializer_list& b) { - streamWaitBase(a, b); -} - -} } // namespace diff --git a/cpp/thirdparty/knowhere_build/include/faiss/gpu/utils/MemorySpace.h b/cpp/thirdparty/knowhere_build/include/faiss/gpu/utils/MemorySpace.h deleted file mode 100644 index f269f06a39..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/gpu/utils/MemorySpace.h +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - - -#pragma once - -#include - -#if CUDA_VERSION >= 8000 -// Whether or not we enable usage of CUDA Unified Memory -#define FAISS_UNIFIED_MEM 1 -#endif - -namespace faiss { namespace gpu { - -enum MemorySpace { - /// Managed using cudaMalloc/cudaFree - Device = 1, - /// Managed using cudaMallocManaged/cudaFree - Unified = 2, - /// Managed using cudaHostAlloc/cudaFreeHost - HostPinned = 3, -}; - -/// All memory allocations and de-allocations come through these functions - -/// Allocates CUDA memory for a given memory space (void pointer) -/// Throws a FaissException if we are unable to allocate the memory -void allocMemorySpaceV(MemorySpace space, void** p, size_t size); - -template -inline void allocMemorySpace(MemorySpace space, T** p, size_t size) { - allocMemorySpaceV(space, (void**)(void*) p, size); -} - -/// Frees CUDA memory for a given memory space -/// Asserts if we are unable to free the region -void freeMemorySpace(MemorySpace space, void* p); - -} } diff --git a/cpp/thirdparty/knowhere_build/include/faiss/gpu/utils/StackDeviceMemory.h b/cpp/thirdparty/knowhere_build/include/faiss/gpu/utils/StackDeviceMemory.h deleted file mode 100644 index 82f0f88d52..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/gpu/utils/StackDeviceMemory.h +++ /dev/null @@ -1,129 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - - -#pragma once - -#include "DeviceMemory.h" -#include -#include -#include - -namespace faiss { namespace gpu { - -/// Device memory manager that provides temporary memory allocations -/// out of a region of memory -class StackDeviceMemory : public DeviceMemory { - public: - /// Allocate a new region of memory that we manage - explicit StackDeviceMemory(int device, size_t allocPerDevice); - - /// Manage a region of memory for a particular device, with or - /// without ownership - StackDeviceMemory(int device, void* p, size_t size, bool isOwner); - - ~StackDeviceMemory() override; - - /// Enable or disable the warning about not having enough temporary memory - /// when cudaMalloc gets called - void setCudaMallocWarning(bool b); - - int getDevice() const override; - - DeviceMemoryReservation getMemory(cudaStream_t stream, - size_t size) override; - - size_t getSizeAvailable() const override; - std::string toString() const override; - size_t getHighWaterCudaMalloc() const override; - - protected: - void returnAllocation(DeviceMemoryReservation& m) override; - - protected: - /// Previous allocation ranges and the streams for which - /// synchronization is required - struct Range { - inline Range(char* s, char* e, cudaStream_t str) : - start_(s), end_(e), stream_(str) { - } - - // References a memory range [start, end) - char* start_; - char* end_; - cudaStream_t stream_; - }; - - struct Stack { - /// Constructor that allocates memory via cudaMalloc - Stack(int device, size_t size); - - /// Constructor that references a pre-allocated region of memory - Stack(int device, void* p, size_t size, bool isOwner); - ~Stack(); - - /// Returns how much size is available for an allocation without - /// calling cudaMalloc - size_t getSizeAvailable() const; - - /// Obtains an allocation; all allocations are guaranteed to be 16 - /// byte aligned - char* getAlloc(size_t size, cudaStream_t stream); - - /// Returns an allocation - void returnAlloc(char* p, size_t size, cudaStream_t stream); - - /// Returns the stack state - std::string toString() const; - - /// Returns the high-water mark of cudaMalloc activity - size_t getHighWaterCudaMalloc() const; - - /// Device this allocation is on - int device_; - - /// Do we own our region of memory? - bool isOwner_; - - /// Where our allocation begins and ends - /// [start_, end_) is valid - char* start_; - char* end_; - - /// Total size end_ - start_ - size_t size_; - - /// Stack head within [start, end) - char* head_; - - /// List of previous last users of allocations on our stack, for - /// possible synchronization purposes - std::list lastUsers_; - - /// How much cudaMalloc memory is currently outstanding? - size_t mallocCurrent_; - - /// What's the high water mark in terms of memory used from the - /// temporary buffer? - size_t highWaterMemoryUsed_; - - /// What's the high water mark in terms of memory allocated via - /// cudaMalloc? - size_t highWaterMalloc_; - - /// Whether or not a warning upon cudaMalloc is generated - bool cudaMallocWarning_; - }; - - /// Our device - int device_; - - /// Memory stack - Stack stack_; -}; - -} } // namespace diff --git a/cpp/thirdparty/knowhere_build/include/faiss/gpu/utils/StaticUtils.h b/cpp/thirdparty/knowhere_build/include/faiss/gpu/utils/StaticUtils.h deleted file mode 100644 index ec8fb8a3b2..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/gpu/utils/StaticUtils.h +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - - -#pragma once - -#include - -namespace faiss { namespace gpu { namespace utils { - -template -constexpr __host__ __device__ auto divUp(U a, V b) -> decltype(a + b) { - return (a + b - 1) / b; -} - -template -constexpr __host__ __device__ auto roundDown(U a, V b) -> decltype(a + b) { - return (a / b) * b; -} - -template -constexpr __host__ __device__ auto roundUp(U a, V b) -> decltype(a + b) { - return divUp(a, b) * b; -} - -template -constexpr __host__ __device__ T pow(T n, T power) { - return (power > 0 ? n * pow(n, power - 1) : 1); -} - -template -constexpr __host__ __device__ T pow2(T n) { - return pow(2, (T) n); -} - -static_assert(pow2(8) == 256, "pow2"); - -template -constexpr __host__ __device__ int log2(T n, int p = 0) { - return (n <= 1) ? p : log2(n / 2, p + 1); -} - -static_assert(log2(2) == 1, "log2"); -static_assert(log2(3) == 1, "log2"); -static_assert(log2(4) == 2, "log2"); - -template -constexpr __host__ __device__ bool isPowerOf2(T v) { - return (v && !(v & (v - 1))); -} - -static_assert(isPowerOf2(2048), "isPowerOf2"); -static_assert(!isPowerOf2(3333), "isPowerOf2"); - -template -constexpr __host__ __device__ T nextHighestPowerOf2(T v) { - return (isPowerOf2(v) ? (T) 2 * v : ((T) 1 << (log2(v) + 1))); -} - -static_assert(nextHighestPowerOf2(1) == 2, "nextHighestPowerOf2"); -static_assert(nextHighestPowerOf2(2) == 4, "nextHighestPowerOf2"); -static_assert(nextHighestPowerOf2(3) == 4, "nextHighestPowerOf2"); -static_assert(nextHighestPowerOf2(4) == 8, "nextHighestPowerOf2"); - -static_assert(nextHighestPowerOf2(15) == 16, "nextHighestPowerOf2"); -static_assert(nextHighestPowerOf2(16) == 32, "nextHighestPowerOf2"); -static_assert(nextHighestPowerOf2(17) == 32, "nextHighestPowerOf2"); - -static_assert(nextHighestPowerOf2(1536000000u) == 2147483648u, - "nextHighestPowerOf2"); -static_assert(nextHighestPowerOf2((size_t) 2147483648ULL) == - (size_t) 4294967296ULL, "nextHighestPowerOf2"); - -} } } // namespace diff --git a/cpp/thirdparty/knowhere_build/include/faiss/gpu/utils/Timer.h b/cpp/thirdparty/knowhere_build/include/faiss/gpu/utils/Timer.h deleted file mode 100644 index ef2a161a32..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/gpu/utils/Timer.h +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - - -#pragma once - -#include -#include - -namespace faiss { namespace gpu { - -/// Utility class for timing execution of a kernel -class KernelTimer { - public: - /// Constructor starts the timer and adds an event into the current - /// device stream - KernelTimer(cudaStream_t stream = 0); - - /// Destructor releases event resources - ~KernelTimer(); - - /// Adds a stop event then synchronizes on the stop event to get the - /// actual GPU-side kernel timings for any kernels launched in the - /// current stream. Returns the number of milliseconds elapsed. - /// Can only be called once. - float elapsedMilliseconds(); - - private: - cudaEvent_t startEvent_; - cudaEvent_t stopEvent_; - cudaStream_t stream_; - bool valid_; -}; - -/// CPU wallclock elapsed timer -class CpuTimer { - public: - /// Creates and starts a new timer - CpuTimer(); - - /// Returns elapsed time in milliseconds - float elapsedMilliseconds(); - - private: - struct timespec start_; -}; - -} } // namespace diff --git a/cpp/thirdparty/knowhere_build/include/faiss/hamming.h b/cpp/thirdparty/knowhere_build/include/faiss/hamming.h deleted file mode 100644 index e5ef13c9b5..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/hamming.h +++ /dev/null @@ -1,572 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -/* - * Hamming distances. The binary vector dimensionality should be a - * multiple of 8, as the elementary operations operate on bytes. If - * you need other sizes, just pad with 0s (this is done by function - * fvecs2bitvecs). - * - * User-defined type hamdis_t is used for distances because at this time - * it is still uncler clear how we will need to balance - * - flexibility in vector size (may need 16- or even 8-bit vectors) - * - memory usage - * - cache-misses when dealing with large volumes of data (fewer bits is better) - * - */ - -#ifndef FAISS_hamming_h -#define FAISS_hamming_h - - -#include - -#include "Heap.h" - - -/* The Hamming distance type */ -typedef int32_t hamdis_t; - -namespace faiss { - - -extern size_t hamming_batch_size; - -inline int popcount64(uint64_t x) { - return __builtin_popcountl(x); -} - - -/** Compute a set of Hamming distances between na and nb binary vectors - * - * @param a size na * nbytespercode - * @param b size nb * nbytespercode - * @param nbytespercode should be multiple of 8 - * @param dis output distances, size na * nb - */ -void hammings ( - const uint8_t * a, - const uint8_t * b, - size_t na, size_t nb, - size_t nbytespercode, - hamdis_t * dis); - -void bitvec_print (const uint8_t * b, size_t d); - - -/* Functions for casting vectors of regular types to compact bits. - They assume proper allocation done beforehand, meaning that b - should be be able to receive as many bits as x may produce. */ - -/* Makes an array of bits from the signs of a float array. The length - of the output array b is rounded up to byte size (allocate - accordingly) */ -void fvecs2bitvecs ( - const float * x, - uint8_t * b, - size_t d, - size_t n); - - -void fvec2bitvec (const float * x, uint8_t * b, size_t d); - - - -/** Return the k smallest Hamming distances for a set of binary query vectors, - * using a max heap. - * @param a queries, size ha->nh * ncodes - * @param b database, size nb * ncodes - * @param nb number of database vectors - * @param ncodes size of the binary codes (bytes) - * @param ordered if != 0: order the results by decreasing distance - * (may be bottleneck for k/n > 0.01) */ -void hammings_knn_hc ( - int_maxheap_array_t * ha, - const uint8_t * a, - const uint8_t * b, - size_t nb, - size_t ncodes, - int ordered); - -/* Legacy alias to hammings_knn_hc. */ -void hammings_knn ( - int_maxheap_array_t * ha, - const uint8_t * a, - const uint8_t * b, - size_t nb, - size_t ncodes, - int ordered); - -/** Return the k smallest Hamming distances for a set of binary query vectors, - * using counting max. - * @param a queries, size na * ncodes - * @param b database, size nb * ncodes - * @param na number of query vectors - * @param nb number of database vectors - * @param k number of vectors/distances to return - * @param ncodes size of the binary codes (bytes) - * @param distances output distances from each query vector to its k nearest - * neighbors - * @param labels output ids of the k nearest neighbors to each query vector - */ -void hammings_knn_mc ( - const uint8_t * a, - const uint8_t * b, - size_t na, - size_t nb, - size_t k, - size_t ncodes, - int32_t *distances, - int64_t *labels); - -/* Counting the number of matches or of cross-matches (without returning them) - For use with function that assume pre-allocated memory */ -void hamming_count_thres ( - const uint8_t * bs1, - const uint8_t * bs2, - size_t n1, - size_t n2, - hamdis_t ht, - size_t ncodes, - size_t * nptr); - -/* Return all Hamming distances/index passing a thres. Pre-allocation of output - is required. Use hamming_count_thres to determine the proper size. */ -size_t match_hamming_thres ( - const uint8_t * bs1, - const uint8_t * bs2, - size_t n1, - size_t n2, - hamdis_t ht, - size_t ncodes, - int64_t * idx, - hamdis_t * dis); - -/* Cross-matching in a set of vectors */ -void crosshamming_count_thres ( - const uint8_t * dbs, - size_t n, - hamdis_t ht, - size_t ncodes, - size_t * nptr); - - -/* compute the Hamming distances between two codewords of nwords*64 bits */ -hamdis_t hamming ( - const uint64_t * bs1, - const uint64_t * bs2, - size_t nwords); - - - - -/****************************************************************** - * The HammingComputer series of classes compares a single code of - * size 4 to 32 to incoming codes. They are intended for use as a - * template class where it would be inefficient to switch on the code - * size in the inner loop. Hopefully the compiler will inline the - * hamming() functions and put the a0, a1, ... in registers. - ******************************************************************/ - - -struct HammingComputer4 { - uint32_t a0; - - HammingComputer4 () {} - - HammingComputer4 (const uint8_t *a, int code_size) { - set (a, code_size); - } - - void set (const uint8_t *a, int code_size) { - assert (code_size == 4); - a0 = *(uint32_t *)a; - } - - inline int hamming (const uint8_t *b) const { - return popcount64 (*(uint32_t *)b ^ a0); - } - -}; - -struct HammingComputer8 { - uint64_t a0; - - HammingComputer8 () {} - - HammingComputer8 (const uint8_t *a, int code_size) { - set (a, code_size); - } - - void set (const uint8_t *a, int code_size) { - assert (code_size == 8); - a0 = *(uint64_t *)a; - } - - inline int hamming (const uint8_t *b) const { - return popcount64 (*(uint64_t *)b ^ a0); - } - -}; - - -struct HammingComputer16 { - uint64_t a0, a1; - - HammingComputer16 () {} - - HammingComputer16 (const uint8_t *a8, int code_size) { - set (a8, code_size); - } - - void set (const uint8_t *a8, int code_size) { - assert (code_size == 16); - const uint64_t *a = (uint64_t *)a8; - a0 = a[0]; a1 = a[1]; - } - - inline int hamming (const uint8_t *b8) const { - const uint64_t *b = (uint64_t *)b8; - return popcount64 (b[0] ^ a0) + popcount64 (b[1] ^ a1); - } - -}; - -// when applied to an array, 1/2 of the 64-bit accesses are unaligned. -// This incurs a penalty of ~10% wrt. fully aligned accesses. -struct HammingComputer20 { - uint64_t a0, a1; - uint32_t a2; - - HammingComputer20 () {} - - HammingComputer20 (const uint8_t *a8, int code_size) { - set (a8, code_size); - } - - void set (const uint8_t *a8, int code_size) { - assert (code_size == 20); - const uint64_t *a = (uint64_t *)a8; - a0 = a[0]; a1 = a[1]; a2 = a[2]; - } - - inline int hamming (const uint8_t *b8) const { - const uint64_t *b = (uint64_t *)b8; - return popcount64 (b[0] ^ a0) + popcount64 (b[1] ^ a1) + - popcount64 (*(uint32_t*)(b + 2) ^ a2); - } -}; - -struct HammingComputer32 { - uint64_t a0, a1, a2, a3; - - HammingComputer32 () {} - - HammingComputer32 (const uint8_t *a8, int code_size) { - set (a8, code_size); - } - - void set (const uint8_t *a8, int code_size) { - assert (code_size == 32); - const uint64_t *a = (uint64_t *)a8; - a0 = a[0]; a1 = a[1]; a2 = a[2]; a3 = a[3]; - } - - inline int hamming (const uint8_t *b8) const { - const uint64_t *b = (uint64_t *)b8; - return popcount64 (b[0] ^ a0) + popcount64 (b[1] ^ a1) + - popcount64 (b[2] ^ a2) + popcount64 (b[3] ^ a3); - } - -}; - -struct HammingComputer64 { - uint64_t a0, a1, a2, a3, a4, a5, a6, a7; - - HammingComputer64 () {} - - HammingComputer64 (const uint8_t *a8, int code_size) { - set (a8, code_size); - } - - void set (const uint8_t *a8, int code_size) { - assert (code_size == 64); - const uint64_t *a = (uint64_t *)a8; - a0 = a[0]; a1 = a[1]; a2 = a[2]; a3 = a[3]; - a4 = a[4]; a5 = a[5]; a6 = a[6]; a7 = a[7]; - } - - inline int hamming (const uint8_t *b8) const { - const uint64_t *b = (uint64_t *)b8; - return popcount64 (b[0] ^ a0) + popcount64 (b[1] ^ a1) + - popcount64 (b[2] ^ a2) + popcount64 (b[3] ^ a3) + - popcount64 (b[4] ^ a4) + popcount64 (b[5] ^ a5) + - popcount64 (b[6] ^ a6) + popcount64 (b[7] ^ a7); - } - -}; - -// very inefficient... -struct HammingComputerDefault { - const uint8_t *a; - int n; - - HammingComputerDefault () {} - - HammingComputerDefault (const uint8_t *a8, int code_size) { - set (a8, code_size); - } - - void set (const uint8_t *a8, int code_size) { - a = a8; - n = code_size; - } - - int hamming (const uint8_t *b8) const { - int accu = 0; - for (int i = 0; i < n; i++) - accu += popcount64 (a[i] ^ b8[i]); - return accu; - } - -}; - - -struct HammingComputerM8 { - const uint64_t *a; - int n; - - HammingComputerM8 () {} - - HammingComputerM8 (const uint8_t *a8, int code_size) { - set (a8, code_size); - } - - void set (const uint8_t *a8, int code_size) { - assert (code_size % 8 == 0); - a = (uint64_t *)a8; - n = code_size / 8; - } - - int hamming (const uint8_t *b8) const { - const uint64_t *b = (uint64_t *)b8; - int accu = 0; - for (int i = 0; i < n; i++) - accu += popcount64 (a[i] ^ b[i]); - return accu; - } - -}; - -// even more inefficient! -struct HammingComputerM4 { - const uint32_t *a; - int n; - - HammingComputerM4 () {} - - HammingComputerM4 (const uint8_t *a4, int code_size) { - set (a4, code_size); - } - - void set (const uint8_t *a4, int code_size) { - assert (code_size % 4 == 0); - a = (uint32_t *)a4; - n = code_size / 4; - } - - int hamming (const uint8_t *b8) const { - const uint32_t *b = (uint32_t *)b8; - int accu = 0; - for (int i = 0; i < n; i++) - accu += popcount64 (a[i] ^ b[i]); - return accu; - } - -}; - -/*************************************************************************** - * Equivalence with a template class when code size is known at compile time - **************************************************************************/ - -// default template -template -struct HammingComputer: HammingComputerM8 { - HammingComputer (const uint8_t *a, int code_size): - HammingComputerM8(a, code_size) {} -}; - -#define SPECIALIZED_HC(CODE_SIZE) \ - template<> struct HammingComputer: \ - HammingComputer ## CODE_SIZE { \ - HammingComputer (const uint8_t *a): \ - HammingComputer ## CODE_SIZE(a, CODE_SIZE) {} \ - } - -SPECIALIZED_HC(4); -SPECIALIZED_HC(8); -SPECIALIZED_HC(16); -SPECIALIZED_HC(20); -SPECIALIZED_HC(32); -SPECIALIZED_HC(64); - -#undef SPECIALIZED_HC - - -/*************************************************************************** - * generalized Hamming = number of bytes that are different between - * two codes. - ***************************************************************************/ - - -inline int generalized_hamming_64 (uint64_t a) { - a |= a >> 1; - a |= a >> 2; - a |= a >> 4; - a &= 0x0101010101010101UL; - return popcount64 (a); -} - - -struct GenHammingComputer8 { - uint64_t a0; - - GenHammingComputer8 (const uint8_t *a, int code_size) { - assert (code_size == 8); - a0 = *(uint64_t *)a; - } - - inline int hamming (const uint8_t *b) const { - return generalized_hamming_64 (*(uint64_t *)b ^ a0); - } - -}; - - -struct GenHammingComputer16 { - uint64_t a0, a1; - GenHammingComputer16 (const uint8_t *a8, int code_size) { - assert (code_size == 16); - const uint64_t *a = (uint64_t *)a8; - a0 = a[0]; a1 = a[1]; - } - - inline int hamming (const uint8_t *b8) const { - const uint64_t *b = (uint64_t *)b8; - return generalized_hamming_64 (b[0] ^ a0) + - generalized_hamming_64 (b[1] ^ a1); - } - -}; - -struct GenHammingComputer32 { - uint64_t a0, a1, a2, a3; - - GenHammingComputer32 (const uint8_t *a8, int code_size) { - assert (code_size == 32); - const uint64_t *a = (uint64_t *)a8; - a0 = a[0]; a1 = a[1]; a2 = a[2]; a3 = a[3]; - } - - inline int hamming (const uint8_t *b8) const { - const uint64_t *b = (uint64_t *)b8; - return generalized_hamming_64 (b[0] ^ a0) + - generalized_hamming_64 (b[1] ^ a1) + - generalized_hamming_64 (b[2] ^ a2) + - generalized_hamming_64 (b[3] ^ a3); - } - -}; - -struct GenHammingComputerM8 { - const uint64_t *a; - int n; - - GenHammingComputerM8 (const uint8_t *a8, int code_size) { - assert (code_size % 8 == 0); - a = (uint64_t *)a8; - n = code_size / 8; - } - - int hamming (const uint8_t *b8) const { - const uint64_t *b = (uint64_t *)b8; - int accu = 0; - for (int i = 0; i < n; i++) - accu += generalized_hamming_64 (a[i] ^ b[i]); - return accu; - } - -}; - - -/** generalized Hamming distances (= count number of code bytes that - are the same) */ -void generalized_hammings_knn_hc ( - int_maxheap_array_t * ha, - const uint8_t * a, - const uint8_t * b, - size_t nb, - size_t code_size, - int ordered = true); - - - -/** This class maintains a list of best distances seen so far. - * - * Since the distances are in a limited range (0 to nbit), the - * object maintains one list per possible distance, and fills - * in only the n-first lists, such that the sum of sizes of the - * n lists is below k. - */ -template -struct HCounterState { - int *counters; - int64_t *ids_per_dis; - - HammingComputer hc; - int thres; - int count_lt; - int count_eq; - int k; - - HCounterState(int *counters, int64_t *ids_per_dis, - const uint8_t *x, int d, int k) - : counters(counters), - ids_per_dis(ids_per_dis), - hc(x, d / 8), - thres(d + 1), - count_lt(0), - count_eq(0), - k(k) {} - - void update_counter(const uint8_t *y, size_t j) { - int32_t dis = hc.hamming(y); - - if (dis <= thres) { - if (dis < thres) { - ids_per_dis[dis * k + counters[dis]++] = j; - ++count_lt; - while (count_lt == k && thres > 0) { - --thres; - count_eq = counters[thres]; - count_lt -= count_eq; - } - } else if (count_eq < k) { - ids_per_dis[dis * k + count_eq++] = j; - counters[dis] = count_eq; - } - } - } -}; - - -} // namespace faiss - - -#endif /* FAISS_hamming_h */ diff --git a/cpp/thirdparty/knowhere_build/include/faiss/index_io.h b/cpp/thirdparty/knowhere_build/include/faiss/index_io.h deleted file mode 100644 index 3564dc617d..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/index_io.h +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -// I/O code for indexes - -#ifndef FAISS_INDEX_IO_H -#define FAISS_INDEX_IO_H - - -#include - -/** I/O functions can read/write to a filename, a file handle or to an - * object that abstracts the medium. - * - * The read functions return objects that should be deallocated with - * delete. All references within these objectes are owned by the - * object. - */ - -namespace faiss { - -struct Index; -struct IndexBinary; -struct VectorTransform; -struct IndexIVF; -struct ProductQuantizer; -struct IOReader; -struct IOWriter; -struct InvertedLists; - -void write_index (const Index *idx, const char *fname); -void write_index (const Index *idx, FILE *f); -void write_index (const Index *idx, IOWriter *writer); - -void write_index_binary (const IndexBinary *idx, const char *fname); -void write_index_binary (const IndexBinary *idx, FILE *f); -void write_index_binary (const IndexBinary *idx, IOWriter *writer); - -// The read_index flags are implemented only for a subset of index types. -const int IO_FLAG_MMAP = 1; // try to memmap if possible -const int IO_FLAG_READ_ONLY = 2; -// strip directory component from ondisk filename, and assume it's in -// the same directory as the index file -const int IO_FLAG_ONDISK_SAME_DIR = 4; - -Index *read_index (const char *fname, int io_flags = 0); -Index *read_index (FILE * f, int io_flags = 0); -Index *read_index (IOReader *reader, int io_flags = 0); - -IndexBinary *read_index_binary (const char *fname, int io_flags = 0); -IndexBinary *read_index_binary (FILE * f, int io_flags = 0); -IndexBinary *read_index_binary (IOReader *reader, int io_flags = 0); - -void write_VectorTransform (const VectorTransform *vt, const char *fname); -VectorTransform *read_VectorTransform (const char *fname); - -ProductQuantizer * read_ProductQuantizer (const char*fname); -ProductQuantizer * read_ProductQuantizer (IOReader *reader); - -void write_ProductQuantizer (const ProductQuantizer*pq, const char *fname); -void write_ProductQuantizer (const ProductQuantizer*pq, IOWriter *f); - -void write_InvertedLists (const InvertedLists *ils, IOWriter *f); -InvertedLists *read_InvertedLists (IOReader *reader, int io_flags = 0); - -/* cloning functions */ -Index *clone_index (const Index *); - -/** Cloner class, useful to override classes with other cloning - * functions. The cloning function above just calls - * Cloner::clone_Index. */ -struct Cloner { - virtual VectorTransform *clone_VectorTransform (const VectorTransform *); - virtual Index *clone_Index (const Index *); - virtual IndexIVF *clone_IndexIVF (const IndexIVF *); - virtual ~Cloner() {} -}; - - - -} // namespace faiss - - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/faiss/utils.h b/cpp/thirdparty/knowhere_build/include/faiss/utils.h deleted file mode 100644 index 6d802a5533..0000000000 --- a/cpp/thirdparty/knowhere_build/include/faiss/utils.h +++ /dev/null @@ -1,418 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// -*- c++ -*- - -/* - * A few utilitary functions for similarity search: - * - random generators - * - optimized exhaustive distance and knn search functions - * - some functions reimplemented from torch for speed - */ - -#ifndef FAISS_utils_h -#define FAISS_utils_h - -#include -#include - -#include "Heap.h" - - -namespace faiss { - - -/************************************************** - * Get some stats about the system -**************************************************/ - - -/// ms elapsed since some arbitrary epoch -double getmillisecs (); - -/// get current RSS usage in kB -size_t get_mem_usage_kb (); - - -/************************************************** - * Random data generation functions - **************************************************/ - -/// random generator that can be used in multithreaded contexts -struct RandomGenerator { - - std::mt19937 mt; - - /// random positive integer - int rand_int (); - - /// random int64_t - int64_t rand_int64 (); - - /// generate random integer between 0 and max-1 - int rand_int (int max); - - /// between 0 and 1 - float rand_float (); - - double rand_double (); - - explicit RandomGenerator (int64_t seed = 1234); -}; - -/* Generate an array of uniform random floats / multi-threaded implementation */ -void float_rand (float * x, size_t n, int64_t seed); -void float_randn (float * x, size_t n, int64_t seed); -void int64_rand (int64_t * x, size_t n, int64_t seed); -void byte_rand (uint8_t * x, size_t n, int64_t seed); - -/* random permutation */ -void rand_perm (int * perm, size_t n, int64_t seed); - - - - /********************************************************* - * Optimized distance/norm/inner prod computations - *********************************************************/ - - -/// Squared L2 distance between two vectors -float fvec_L2sqr ( - const float * x, - const float * y, - size_t d); - -/// inner product -float fvec_inner_product ( - const float * x, - const float * y, - size_t d); - -/// L1 distance -float fvec_L1 ( - const float * x, - const float * y, - size_t d); - -float fvec_Linf ( - const float * x, - const float * y, - size_t d); - - -/// a balanced assignment has a IF of 1 -double imbalance_factor (int n, int k, const int64_t *assign); - -/// same, takes a histogram as input -double imbalance_factor (int k, const int *hist); - -/** Compute pairwise distances between sets of vectors - * - * @param d dimension of the vectors - * @param nq nb of query vectors - * @param nb nb of database vectors - * @param xq query vectors (size nq * d) - * @param xb database vectros (size nb * d) - * @param dis output distances (size nq * nb) - * @param ldq,ldb, ldd strides for the matrices - */ -void pairwise_L2sqr (int64_t d, - int64_t nq, const float *xq, - int64_t nb, const float *xb, - float *dis, - int64_t ldq = -1, int64_t ldb = -1, int64_t ldd = -1); - -/* compute the inner product between nx vectors x and one y */ -void fvec_inner_products_ny ( - float * ip, /* output inner product */ - const float * x, - const float * y, - size_t d, size_t ny); - -/* compute ny square L2 distance bewteen x and a set of contiguous y vectors */ -void fvec_L2sqr_ny ( - float * dis, - const float * x, - const float * y, - size_t d, size_t ny); - - -/** squared norm of a vector */ -float fvec_norm_L2sqr (const float * x, - size_t d); - -/** compute the L2 norms for a set of vectors - * - * @param ip output norms, size nx - * @param x set of vectors, size nx * d - */ -void fvec_norms_L2 (float * ip, const float * x, size_t d, size_t nx); - -/// same as fvec_norms_L2, but computes square norms -void fvec_norms_L2sqr (float * ip, const float * x, size_t d, size_t nx); - -/* L2-renormalize a set of vector. Nothing done if the vector is 0-normed */ -void fvec_renorm_L2 (size_t d, size_t nx, float * x); - - -/* This function exists because the Torch counterpart is extremly slow - (not multi-threaded + unexpected overhead even in single thread). - It is here to implement the usual property |x-y|^2=|x|^2+|y|^2-2 */ -void inner_product_to_L2sqr (float * dis, - const float * nr1, - const float * nr2, - size_t n1, size_t n2); - -/*************************************************************************** - * Compute a subset of distances - ***************************************************************************/ - - /* compute the inner product between x and a subset y of ny vectors, - whose indices are given by idy. */ -void fvec_inner_products_by_idx ( - float * ip, - const float * x, - const float * y, - const int64_t *ids, - size_t d, size_t nx, size_t ny); - -/* same but for a subset in y indexed by idsy (ny vectors in total) */ -void fvec_L2sqr_by_idx ( - float * dis, - const float * x, - const float * y, - const int64_t *ids, /* ids of y vecs */ - size_t d, size_t nx, size_t ny); - -/*************************************************************************** - * KNN functions - ***************************************************************************/ - -// threshold on nx above which we switch to BLAS to compute distances -extern int distance_compute_blas_threshold; - -/** Return the k nearest neighors of each of the nx vectors x among the ny - * vector y, w.r.t to max inner product - * - * @param x query vectors, size nx * d - * @param y database vectors, size ny * d - * @param res result array, which also provides k. Sorted on output - */ -void knn_inner_product ( - const float * x, - const float * y, - size_t d, size_t nx, size_t ny, - float_minheap_array_t * res); - -/** Same as knn_inner_product, for the L2 distance */ -void knn_L2sqr ( - const float * x, - const float * y, - size_t d, size_t nx, size_t ny, - float_maxheap_array_t * res); - - - -/** same as knn_L2sqr, but base_shift[bno] is subtracted to all - * computed distances. - * - * @param base_shift size ny - */ -void knn_L2sqr_base_shift ( - const float * x, - const float * y, - size_t d, size_t nx, size_t ny, - float_maxheap_array_t * res, - const float *base_shift); - -/* Find the nearest neighbors for nx queries in a set of ny vectors - * indexed by ids. May be useful for re-ranking a pre-selected vector list - */ -void knn_inner_products_by_idx ( - const float * x, - const float * y, - const int64_t * ids, - size_t d, size_t nx, size_t ny, - float_minheap_array_t * res); - -void knn_L2sqr_by_idx (const float * x, - const float * y, - const int64_t * ids, - size_t d, size_t nx, size_t ny, - float_maxheap_array_t * res); - -/*************************************************************************** - * Range search - ***************************************************************************/ - - - -/// Forward declaration, see AuxIndexStructures.h -struct RangeSearchResult; - -/** Return the k nearest neighors of each of the nx vectors x among the ny - * vector y, w.r.t to max inner product - * - * @param x query vectors, size nx * d - * @param y database vectors, size ny * d - * @param radius search radius around the x vectors - * @param result result structure - */ -void range_search_L2sqr ( - const float * x, - const float * y, - size_t d, size_t nx, size_t ny, - float radius, - RangeSearchResult *result); - -/// same as range_search_L2sqr for the inner product similarity -void range_search_inner_product ( - const float * x, - const float * y, - size_t d, size_t nx, size_t ny, - float radius, - RangeSearchResult *result); - - - - - -/*************************************************************************** - * Misc matrix and vector manipulation functions - ***************************************************************************/ - - -/** compute c := a + bf * b for a, b and c tables - * - * @param n size of the tables - * @param a size n - * @param b size n - * @param c restult table, size n - */ -void fvec_madd (size_t n, const float *a, - float bf, const float *b, float *c); - - -/** same as fvec_madd, also return index of the min of the result table - * @return index of the min of table c - */ -int fvec_madd_and_argmin (size_t n, const float *a, - float bf, const float *b, float *c); - - -/* perform a reflection (not an efficient implementation, just for test ) */ -void reflection (const float * u, float * x, size_t n, size_t d, size_t nu); - - -/** For k-means: update stage. - * - * @param x training vectors, size n * d - * @param centroids centroid vectors, size k * d - * @param assign nearest centroid for each training vector, size n - * @param k_frozen do not update the k_frozen first centroids - * @return nb of spliting operations to fight empty clusters - */ -int km_update_centroids ( - const float * x, - float * centroids, - int64_t * assign, - size_t d, size_t k, size_t n, - size_t k_frozen); - -/** compute the Q of the QR decomposition for m > n - * @param a size n * m: input matrix and output Q - */ -void matrix_qr (int m, int n, float *a); - -/** distances are supposed to be sorted. Sorts indices with same distance*/ -void ranklist_handle_ties (int k, int64_t *idx, const float *dis); - -/** count the number of comon elements between v1 and v2 - * algorithm = sorting + bissection to avoid double-counting duplicates - */ -size_t ranklist_intersection_size (size_t k1, const int64_t *v1, - size_t k2, const int64_t *v2); - -/** merge a result table into another one - * - * @param I0, D0 first result table, size (n, k) - * @param I1, D1 second result table, size (n, k) - * @param keep_min if true, keep min values, otherwise keep max - * @param translation add this value to all I1's indexes - * @return nb of values that were taken from the second table - */ -size_t merge_result_table_with (size_t n, size_t k, - int64_t *I0, float *D0, - const int64_t *I1, const float *D1, - bool keep_min = true, - int64_t translation = 0); - - - -void fvec_argsort (size_t n, const float *vals, - size_t *perm); - -void fvec_argsort_parallel (size_t n, const float *vals, - size_t *perm); - - -/// compute histogram on v -int ivec_hist (size_t n, const int * v, int vmax, int *hist); - -/** Compute histogram of bits on a code array - * - * @param codes size(n, nbits / 8) - * @param hist size(nbits): nb of 1s in the array of codes - */ -void bincode_hist(size_t n, size_t nbits, const uint8_t *codes, int *hist); - - -/// compute a checksum on a table. -size_t ivec_checksum (size_t n, const int *a); - - -/** random subsamples a set of vectors if there are too many of them - * - * @param d dimension of the vectors - * @param n on input: nb of input vectors, output: nb of output vectors - * @param nmax max nb of vectors to keep - * @param x input array, size *n-by-d - * @param seed random seed to use for sampling - * @return x or an array allocated with new [] with *n vectors - */ -const float *fvecs_maybe_subsample ( - size_t d, size_t *n, size_t nmax, const float *x, - bool verbose = false, int64_t seed = 1234); - -/** Convert binary vector to +1/-1 valued float vector. - * - * @param d dimension of the vector (multiple of 8) - * @param x_in input binary vector (uint8_t table of size d / 8) - * @param x_out output float vector (float table of size d) - */ -void binary_to_real(size_t d, const uint8_t *x_in, float *x_out); - -/** Convert float vector to binary vector. Components > 0 are converted to 1, - * others to 0. - * - * @param d dimension of the vector (multiple of 8) - * @param x_in input float vector (float table of size d) - * @param x_out output binary vector (uint8_t table of size d / 8) - */ -void real_to_binary(size_t d, const float *x_in, uint8_t *x_out); - - -/** A reasonable hashing function */ -uint64_t hash_bytes (const uint8_t *bytes, int64_t n); - -/** Whether OpenMP annotations were respected. */ -bool check_openmp(); - -} // namspace faiss - - -#endif /* FAISS_utils_h */ diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/basic_json.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/basic_json.hpp deleted file mode 100644 index 76e58e278f..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/basic_json.hpp +++ /dev/null @@ -1,4984 +0,0 @@ -// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_BASIC_JSON_HPP -#define JSONCONS_BASIC_JSON_HPP - -#include // std::numeric_limits -#include -#include -#include -#include -#include -#include // std::allocator -#include -#include // std::memcpy -#include // std::swap -#include // std::initializer_list -#include // std::move -#include // std::enable_if -#include // std::basic_istream -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace jsoncons { - -struct sorted_policy -{ - static constexpr bool preserve_order = false; - - template - using sequence_container_type = std::vector; - - template - using key_storage = std::basic_string; - - template - using string_storage = std::basic_string; - - typedef default_parse_error_handler parse_error_handler_type; -}; - -struct preserve_order_policy : public sorted_policy -{ - static constexpr bool preserve_order = true; -}; - -template -class range -{ - IteratorT first_; - IteratorT last_; -public: - range(const IteratorT& first, const IteratorT& last) - : first_(first), last_(last) - { - } - -public: - IteratorT begin() - { - return first_; - } - IteratorT end() - { - return last_; - } -}; - -enum class storage_type : uint8_t -{ - null_val = 0x00, - bool_val = 0x01, - int64_val = 0x02, - uint64_val = 0x03, - double_val = 0x04, - short_string_val = 0x05, - long_string_val = 0x06, - byte_string_val = 0x07, - array_val = 0x08, - empty_object_val = 0x09, - object_val = 0x0a, - tag_val = 0x0b -}; - -template -class basic_json -{ -public: - - typedef Allocator allocator_type; - - typedef ImplementationPolicy implementation_policy; - - typedef typename ImplementationPolicy::parse_error_handler_type parse_error_handler_type; - - typedef CharT char_type; - typedef typename std::char_traits char_traits_type; - typedef basic_string_view string_view_type; - - typedef typename std::allocator_traits:: template rebind_alloc char_allocator_type; - - typedef std::basic_string string_type; - - typedef basic_json json_type; - - typedef json_type& reference; - typedef const json_type& const_reference; - typedef json_type* pointer; - typedef const json_type* const_pointer; - - typedef key_value key_value_type; - -#if !defined(JSONCONS_NO_DEPRECATED) - typedef json_type value_type; - typedef string_type key_type; - typedef key_value_type kvp_type; - typedef key_value_type member_type; - typedef jsoncons::null_type null_type; -#endif - - typedef typename std::allocator_traits:: template rebind_alloc byte_allocator_type; - using byte_string_storage_type = typename implementation_policy::template sequence_container_type; - - typedef json_array array; - - typedef typename std::allocator_traits:: template rebind_alloc key_value_allocator_type; - - typedef json_object object; - - typedef typename std::allocator_traits:: template rebind_alloc array_allocator; - typedef typename std::allocator_traits:: template rebind_alloc object_allocator; - - typedef typename object::iterator object_iterator; - typedef typename object::const_iterator const_object_iterator; - typedef typename array::iterator array_iterator; - typedef typename array::const_iterator const_array_iterator; - - struct variant - { - class data_base - { - static const uint8_t major_type_shift = 0x04; - static const uint8_t additional_information_mask = (1U << 4) - 1; - - uint8_t type_; - public: - data_base(uint8_t type) - : type_(type) - {} - - data_base(storage_type data_type, semantic_tag semantic_type) - : type_((static_cast(data_type) << major_type_shift) | static_cast(semantic_type)) - {} - - uint8_t type() const - { - return type_; - } - - storage_type get_storage_type() const - { - - uint8_t value = type_ >> major_type_shift; - return static_cast(value); - } - - semantic_tag get_semantic_tag() const - { - uint8_t value = type_ & additional_information_mask; - return static_cast(value); - } - }; - - class null_data final : public data_base - { - public: - null_data() - : data_base(storage_type::null_val, semantic_tag::none) - { - } - null_data(semantic_tag tag) - : data_base(storage_type::null_val, tag) - { - } - }; - - class empty_object_data final : public data_base - { - public: - empty_object_data(semantic_tag tag) - : data_base(storage_type::empty_object_val, tag) - { - } - }; - - class bool_data final : public data_base - { - bool val_; - public: - bool_data(bool val, semantic_tag tag) - : data_base(storage_type::bool_val, tag),val_(val) - { - } - - bool_data(const bool_data& val) - : data_base(val.type()),val_(val.val_) - { - } - - bool value() const - { - return val_; - } - - }; - - class int64_data final : public data_base - { - int64_t val_; - public: - int64_data(int64_t val, - semantic_tag tag = semantic_tag::none) - : data_base(storage_type::int64_val, tag),val_(val) - { - } - - int64_data(const int64_data& val) - : data_base(val.type()),val_(val.val_) - { - } - - int64_t value() const - { - return val_; - } - }; - - class uint64_data final : public data_base - { - uint64_t val_; - public: - uint64_data(uint64_t val, - semantic_tag tag = semantic_tag::none) - : data_base(storage_type::uint64_val, tag),val_(val) - { - } - - uint64_data(const uint64_data& val) - : data_base(val.type()),val_(val.val_) - { - } - - uint64_t value() const - { - return val_; - } - }; - - class double_data final : public data_base - { - double val_; - public: - double_data(double val, - semantic_tag tag = semantic_tag::none) - : data_base(storage_type::double_val, tag), - val_(val) - { - } - - double_data(const double_data& val) - : data_base(val.type()), - val_(val.val_) - { - } - - double value() const - { - return val_; - } - }; - - class short_string_data final : public data_base - { - static const size_t capacity = 14/sizeof(char_type); - uint8_t length_; - char_type data_[capacity]; - public: - static const size_t max_length = (14 / sizeof(char_type)) - 1; - - short_string_data(semantic_tag tag, const char_type* p, uint8_t length) - : data_base(storage_type::short_string_val, tag), length_(length) - { - JSONCONS_ASSERT(length <= max_length); - std::memcpy(data_,p,length*sizeof(char_type)); - data_[length] = 0; - } - - short_string_data(const short_string_data& val) - : data_base(val.type()), length_(val.length_) - { - std::memcpy(data_,val.data_,val.length_*sizeof(char_type)); - data_[length_] = 0; - } - - uint8_t length() const - { - return length_; - } - - const char_type* data() const - { - return data_; - } - - const char_type* c_str() const - { - return data_; - } - }; - - // long_string_data - class long_string_data final : public data_base - { - typedef typename jsoncons::detail::heap_only_string_factory::string_pointer pointer; - - pointer ptr_; - public: - - long_string_data(semantic_tag tag, const char_type* data, size_t length, const Allocator& a) - : data_base(storage_type::long_string_val, tag) - { - ptr_ = jsoncons::detail::heap_only_string_factory::create(data,length,a); - } - - long_string_data(const long_string_data& val) - : data_base(val.type()) - { - ptr_ = jsoncons::detail::heap_only_string_factory::create(val.data(),val.length(),val.get_allocator()); - } - - long_string_data(long_string_data&& val) - : data_base(val.type()), ptr_(nullptr) - { - std::swap(val.ptr_,ptr_); - } - - long_string_data(const long_string_data& val, const Allocator& a) - : data_base(val.type()) - { - ptr_ = jsoncons::detail::heap_only_string_factory::create(val.data(),val.length(),a); - } - - ~long_string_data() - { - if (ptr_ != nullptr) - { - jsoncons::detail::heap_only_string_factory::destroy(ptr_); - } - } - - void swap(long_string_data& val) - { - std::swap(val.ptr_,ptr_); - } - - const char_type* data() const - { - return ptr_->data(); - } - - const char_type* c_str() const - { - return ptr_->c_str(); - } - - size_t length() const - { - return ptr_->length(); - } - - allocator_type get_allocator() const - { - return ptr_->get_allocator(); - } - }; - - // byte_string_data - class byte_string_data final : public data_base - { - typedef typename std::allocator_traits:: template rebind_alloc string_holder_allocator_type; - typedef typename std::allocator_traits::pointer pointer; - - pointer ptr_; - - template - void create(string_holder_allocator_type allocator, Args&& ... args) - { - typename std::allocator_traits:: template rebind_alloc alloc(allocator); - ptr_ = alloc.allocate(1); - try - { - std::allocator_traits:: template rebind_traits::construct(alloc, jsoncons::detail::to_plain_pointer(ptr_), std::forward(args)...); - } - catch (...) - { - alloc.deallocate(ptr_,1); - throw; - } - } - public: - - byte_string_data(semantic_tag semantic_type, - const uint8_t* data, size_t length, - const Allocator& a) - : data_base(storage_type::byte_string_val, semantic_type) - { - create(string_holder_allocator_type(a), data, data+length, a); - } - - byte_string_data(const byte_string_data& val) - : data_base(val.type()) - { - create(val.ptr_->get_allocator(), *(val.ptr_)); - } - - byte_string_data(byte_string_data&& val) - : data_base(val.type()), ptr_(nullptr) - { - std::swap(val.ptr_,ptr_); - } - - byte_string_data(const byte_string_data& val, const Allocator& a) - : data_base(val.type()) - { - create(string_holder_allocator_type(a), *(val.ptr_), a); - } - - ~byte_string_data() - { - if (ptr_ != nullptr) - { - typename std::allocator_traits:: template rebind_alloc alloc(ptr_->get_allocator()); - std::allocator_traits:: template rebind_traits::destroy(alloc, jsoncons::detail::to_plain_pointer(ptr_)); - alloc.deallocate(ptr_,1); - } - } - - void swap(byte_string_data& val) - { - std::swap(val.ptr_,ptr_); - } - - const uint8_t* data() const - { - return ptr_->data(); - } - - size_t length() const - { - return ptr_->size(); - } - - const uint8_t* begin() const - { - return ptr_->data(); - } - - const uint8_t* end() const - { - return ptr_->data() + ptr_->size(); - } - - allocator_type get_allocator() const - { - return ptr_->get_allocator(); - } - }; - - // array_data - class array_data final : public data_base - { - typedef typename std::allocator_traits::pointer pointer; - pointer ptr_; - - template - void create(array_allocator allocator, Args&& ... args) - { - typename std::allocator_traits:: template rebind_alloc alloc(allocator); - ptr_ = alloc.allocate(1); - try - { - std::allocator_traits:: template rebind_traits::construct(alloc, jsoncons::detail::to_plain_pointer(ptr_), std::forward(args)...); - } - catch (...) - { - alloc.deallocate(ptr_,1); - throw; - } - } - public: - array_data(const array& val, semantic_tag tag) - : data_base(storage_type::array_val, tag) - { - create(val.get_allocator(), val); - } - - array_data(const array& val, semantic_tag tag, const Allocator& a) - : data_base(storage_type::array_val, tag) - { - create(array_allocator(a), val, a); - } - - array_data(const array_data& val) - : data_base(val.type()) - { - create(val.ptr_->get_allocator(), *(val.ptr_)); - } - - array_data(array_data&& val) - : data_base(val.type()), ptr_(nullptr) - { - std::swap(val.ptr_, ptr_); - } - - array_data(const array_data& val, const Allocator& a) - : data_base(val.type()) - { - create(array_allocator(a), *(val.ptr_), a); - } - ~array_data() - { - if (ptr_ != nullptr) - { - typename std::allocator_traits:: template rebind_alloc alloc(ptr_->get_allocator()); - std::allocator_traits:: template rebind_traits::destroy(alloc, jsoncons::detail::to_plain_pointer(ptr_)); - alloc.deallocate(ptr_,1); - } - } - - allocator_type get_allocator() const - { - return ptr_->get_allocator(); - } - - void swap(array_data& val) - { - std::swap(val.ptr_,ptr_); - } - - array& value() - { - return *ptr_; - } - - const array& value() const - { - return *ptr_; - } - }; - - // object_data - class object_data final : public data_base - { - typedef typename std::allocator_traits::pointer pointer; - pointer ptr_; - - template - void create(Allocator allocator, Args&& ... args) - { - typename std::allocator_traits:: template rebind_alloc alloc(allocator); - ptr_ = alloc.allocate(1); - try - { - std::allocator_traits:: template rebind_traits::construct(alloc, jsoncons::detail::to_plain_pointer(ptr_), std::forward(args)...); - } - catch (...) - { - alloc.deallocate(ptr_,1); - throw; - } - } - public: - explicit object_data(const object& val, semantic_tag tag) - : data_base(storage_type::object_val, tag) - { - create(val.get_allocator(), val); - } - - explicit object_data(const object& val, semantic_tag tag, const Allocator& a) - : data_base(storage_type::object_val, tag) - { - create(object_allocator(a), val, a); - } - - explicit object_data(const object_data& val) - : data_base(val.type()) - { - create(val.ptr_->get_allocator(), *(val.ptr_)); - } - - explicit object_data(object_data&& val) - : data_base(val.type()), ptr_(nullptr) - { - std::swap(val.ptr_,ptr_); - } - - explicit object_data(const object_data& val, const Allocator& a) - : data_base(val.type()) - { - create(object_allocator(a), *(val.ptr_), a); - } - - ~object_data() - { - if (ptr_ != nullptr) - { - typename std::allocator_traits:: template rebind_alloc alloc(ptr_->get_allocator()); - std::allocator_traits:: template rebind_traits::destroy(alloc, jsoncons::detail::to_plain_pointer(ptr_)); - alloc.deallocate(ptr_,1); - } - } - - void swap(object_data& val) - { - std::swap(val.ptr_,ptr_); - } - - object& value() - { - return *ptr_; - } - - const object& value() const - { - return *ptr_; - } - - allocator_type get_allocator() const - { - return ptr_->get_allocator(); - } - }; - - private: - static const size_t data_size = static_max::value; - static const size_t data_align = static_max::value; - - typedef typename std::aligned_storage::type data_t; - - data_t data_; - public: - variant(semantic_tag tag) - { - new(reinterpret_cast(&data_))empty_object_data(tag); - } - - explicit variant(null_type, semantic_tag tag) - { - new(reinterpret_cast(&data_))null_data(tag); - } - - explicit variant(bool val, semantic_tag tag) - { - new(reinterpret_cast(&data_))bool_data(val,tag); - } - explicit variant(int64_t val, semantic_tag tag) - { - new(reinterpret_cast(&data_))int64_data(val, tag); - } - explicit variant(uint64_t val, semantic_tag tag) - { - new(reinterpret_cast(&data_))uint64_data(val, tag); - } - - variant(double val, semantic_tag tag) - { - new(reinterpret_cast(&data_))double_data(val, tag); - } - - variant(const char_type* s, size_t length, semantic_tag tag) - { - if (length <= short_string_data::max_length) - { - new(reinterpret_cast(&data_))short_string_data(tag, s, static_cast(length)); - } - else - { - new(reinterpret_cast(&data_))long_string_data(tag, s, length, char_allocator_type()); - } - } - - variant(const char_type* s, size_t length, semantic_tag tag, const Allocator& alloc) - { - if (length <= short_string_data::max_length) - { - new(reinterpret_cast(&data_))short_string_data(tag, s, static_cast(length)); - } - else - { - new(reinterpret_cast(&data_))long_string_data(tag, s, length, char_allocator_type(alloc)); - } - } - - variant(const byte_string_view& bs, semantic_tag tag) - { - new(reinterpret_cast(&data_))byte_string_data(tag, bs.data(), bs.length(), byte_allocator_type()); - } - - variant(const byte_string_view& bs, semantic_tag tag, const Allocator& allocator) - { - new(reinterpret_cast(&data_))byte_string_data(tag, bs.data(), bs.length(), allocator); - } - - variant(const basic_bignum& n) - { - std::basic_string s; - n.dump(s); - - if (s.length() <= short_string_data::max_length) - { - new(reinterpret_cast(&data_))short_string_data(semantic_tag::bigint, s.data(), static_cast(s.length())); - } - else - { - new(reinterpret_cast(&data_))long_string_data(semantic_tag::bigint, s.data(), s.length(), char_allocator_type()); - } - } - - variant(const basic_bignum& n, const Allocator& allocator) - { - std::basic_string s; - n.dump(s); - - if (s.length() <= short_string_data::max_length) - { - new(reinterpret_cast(&data_))short_string_data(semantic_tag::bigint, s.data(), static_cast(s.length())); - } - else - { - new(reinterpret_cast(&data_))long_string_data(semantic_tag::bigint, s.data(), s.length(), char_allocator_type(allocator)); - } - } - variant(const object& val, semantic_tag tag) - { - new(reinterpret_cast(&data_))object_data(val, tag); - } - variant(const object& val, semantic_tag tag, const Allocator& alloc) - { - new(reinterpret_cast(&data_))object_data(val, tag, alloc); - } - variant(const array& val, semantic_tag tag) - { - new(reinterpret_cast(&data_))array_data(val, tag); - } - variant(const array& val, semantic_tag tag, const Allocator& alloc) - { - new(reinterpret_cast(&data_))array_data(val, tag, alloc); - } - - variant(const variant& val) - { - Init_(val); - } - - variant(const variant& val, const Allocator& allocator) - { - Init_(val,allocator); - } - - variant(variant&& val) noexcept - { - Init_rv_(std::forward(val)); - } - - variant(variant&& val, const Allocator& allocator) noexcept - { - Init_rv_(std::forward(val), allocator, - typename std::allocator_traits::propagate_on_container_move_assignment()); - } - - ~variant() - { - Destroy_(); - } - - void Destroy_() - { - switch (get_storage_type()) - { - case storage_type::long_string_val: - reinterpret_cast(&data_)->~long_string_data(); - break; - case storage_type::byte_string_val: - reinterpret_cast(&data_)->~byte_string_data(); - break; - case storage_type::array_val: - reinterpret_cast(&data_)->~array_data(); - break; - case storage_type::object_val: - reinterpret_cast(&data_)->~object_data(); - break; - default: - break; - } - } - - variant& operator=(const variant& val) - { - if (this !=&val) - { - Destroy_(); - switch (val.get_storage_type()) - { - case storage_type::null_val: - new(reinterpret_cast(&data_))null_data(*(val.null_data_cast())); - break; - case storage_type::empty_object_val: - new(reinterpret_cast(&data_))empty_object_data(*(val.empty_object_data_cast())); - break; - case storage_type::bool_val: - new(reinterpret_cast(&data_))bool_data(*(val.bool_data_cast())); - break; - case storage_type::int64_val: - new(reinterpret_cast(&data_))int64_data(*(val.int64_data_cast())); - break; - case storage_type::uint64_val: - new(reinterpret_cast(&data_))uint64_data(*(val.uint64_data_cast())); - break; - case storage_type::double_val: - new(reinterpret_cast(&data_))double_data(*(val.double_data_cast())); - break; - case storage_type::short_string_val: - new(reinterpret_cast(&data_))short_string_data(*(val.short_string_data_cast())); - break; - case storage_type::long_string_val: - new(reinterpret_cast(&data_))long_string_data(*(val.string_data_cast())); - break; - case storage_type::byte_string_val: - new(reinterpret_cast(&data_))byte_string_data(*(val.byte_string_data_cast())); - break; - case storage_type::array_val: - new(reinterpret_cast(&data_))array_data(*(val.array_data_cast())); - break; - case storage_type::object_val: - new(reinterpret_cast(&data_))object_data(*(val.object_data_cast())); - break; - default: - JSONCONS_UNREACHABLE(); - break; - } - } - return *this; - } - - variant& operator=(variant&& val) noexcept - { - if (this !=&val) - { - swap(val); - } - return *this; - } - - storage_type get_storage_type() const - { - return reinterpret_cast(&data_)->get_storage_type(); - } - - semantic_tag get_semantic_tag() const - { - return reinterpret_cast(&data_)->get_semantic_tag(); - } - - const null_data* null_data_cast() const - { - return reinterpret_cast(&data_); - } - - const empty_object_data* empty_object_data_cast() const - { - return reinterpret_cast(&data_); - } - - const bool_data* bool_data_cast() const - { - return reinterpret_cast(&data_); - } - - const int64_data* int64_data_cast() const - { - return reinterpret_cast(&data_); - } - - const uint64_data* uint64_data_cast() const - { - return reinterpret_cast(&data_); - } - - const double_data* double_data_cast() const - { - return reinterpret_cast(&data_); - } - - const short_string_data* short_string_data_cast() const - { - return reinterpret_cast(&data_); - } - - long_string_data* string_data_cast() - { - return reinterpret_cast(&data_); - } - - const long_string_data* string_data_cast() const - { - return reinterpret_cast(&data_); - } - - byte_string_data* byte_string_data_cast() - { - return reinterpret_cast(&data_); - } - - const byte_string_data* byte_string_data_cast() const - { - return reinterpret_cast(&data_); - } - - object_data* object_data_cast() - { - return reinterpret_cast(&data_); - } - - const object_data* object_data_cast() const - { - return reinterpret_cast(&data_); - } - - array_data* array_data_cast() - { - return reinterpret_cast(&data_); - } - - const array_data* array_data_cast() const - { - return reinterpret_cast(&data_); - } - - size_t size() const - { - switch (get_storage_type()) - { - case storage_type::array_val: - return array_data_cast()->value().size(); - case storage_type::object_val: - return object_data_cast()->value().size(); - default: - return 0; - } - } - - string_view_type as_string_view() const - { - switch (get_storage_type()) - { - case storage_type::short_string_val: - return string_view_type(short_string_data_cast()->data(),short_string_data_cast()->length()); - case storage_type::long_string_val: - return string_view_type(string_data_cast()->data(),string_data_cast()->length()); - default: - JSONCONS_THROW(json_runtime_error("Not a string")); - } - } - - template > - basic_byte_string as_byte_string() const - { - switch (get_storage_type()) - { - case storage_type::short_string_val: - case storage_type::long_string_val: - { - switch (get_semantic_tag()) - { - case semantic_tag::base16: - { - basic_byte_string bs; - auto s = as_string_view(); - decode_base16(s.begin(), s.end(), bs); - return bs; - } - case semantic_tag::base64: - { - basic_byte_string bs; - auto s = as_string_view(); - decode_base64(s.begin(), s.end(), bs); - return bs; - } - case semantic_tag::base64url: - { - basic_byte_string bs; - auto s = as_string_view(); - decode_base64url(s.begin(), s.end(), bs); - return bs; - } - default: - JSONCONS_THROW(json_runtime_error("Not a byte string")); - } - break; - } - case storage_type::byte_string_val: - return basic_byte_string(byte_string_data_cast()->data(),byte_string_data_cast()->length()); - default: - JSONCONS_THROW(json_runtime_error("Not a byte string")); - } - } - - byte_string_view as_byte_string_view() const - { - switch (get_storage_type()) - { - case storage_type::byte_string_val: - return byte_string_view(byte_string_data_cast()->data(),byte_string_data_cast()->length()); - default: - JSONCONS_THROW(json_runtime_error("Not a byte string")); - } - } - - template > - basic_bignum as_bignum() const - { - switch (get_storage_type()) - { - case storage_type::short_string_val: - case storage_type::long_string_val: - if (!jsoncons::detail::is_integer(as_string_view().data(), as_string_view().length())) - { - JSONCONS_THROW(json_runtime_error("Not an integer")); - } - return basic_bignum(as_string_view().data(), as_string_view().length()); - case storage_type::double_val: - return basic_bignum(double_data_cast()->value()); - case storage_type::int64_val: - return basic_bignum(int64_data_cast()->value()); - case storage_type::uint64_val: - return basic_bignum(uint64_data_cast()->value()); - case storage_type::bool_val: - return basic_bignum(bool_data_cast()->value() ? 1 : 0); - default: - JSONCONS_THROW(json_runtime_error("Not a bignum")); - } - } - - bool operator==(const variant& rhs) const - { - if (this ==&rhs) - { - return true; - } - switch (get_storage_type()) - { - case storage_type::null_val: - switch (rhs.get_storage_type()) - { - case storage_type::null_val: - return true; - default: - return false; - } - break; - case storage_type::empty_object_val: - switch (rhs.get_storage_type()) - { - case storage_type::empty_object_val: - return true; - case storage_type::object_val: - return rhs.size() == 0; - default: - return false; - } - break; - case storage_type::bool_val: - switch (rhs.get_storage_type()) - { - case storage_type::bool_val: - return bool_data_cast()->value() == rhs.bool_data_cast()->value(); - default: - return false; - } - break; - case storage_type::int64_val: - switch (rhs.get_storage_type()) - { - case storage_type::int64_val: - return int64_data_cast()->value() == rhs.int64_data_cast()->value(); - case storage_type::uint64_val: - return int64_data_cast()->value() >= 0 ? static_cast(int64_data_cast()->value()) == rhs.uint64_data_cast()->value() : false; - case storage_type::double_val: - return static_cast(int64_data_cast()->value()) == rhs.double_data_cast()->value(); - default: - return false; - } - break; - case storage_type::uint64_val: - switch (rhs.get_storage_type()) - { - case storage_type::int64_val: - return rhs.int64_data_cast()->value() >= 0 ? uint64_data_cast()->value() == static_cast(rhs.int64_data_cast()->value()) : false; - case storage_type::uint64_val: - return uint64_data_cast()->value() == rhs.uint64_data_cast()->value(); - case storage_type::double_val: - return static_cast(uint64_data_cast()->value()) == rhs.double_data_cast()->value(); - default: - return false; - } - break; - case storage_type::double_val: - switch (rhs.get_storage_type()) - { - case storage_type::int64_val: - return double_data_cast()->value() == static_cast(rhs.int64_data_cast()->value()); - case storage_type::uint64_val: - return double_data_cast()->value() == static_cast(rhs.uint64_data_cast()->value()); - case storage_type::double_val: - return double_data_cast()->value() == rhs.double_data_cast()->value(); - default: - return false; - } - break; - case storage_type::short_string_val: - switch (rhs.get_storage_type()) - { - case storage_type::short_string_val: - return as_string_view() == rhs.as_string_view(); - case storage_type::long_string_val: - return as_string_view() == rhs.as_string_view(); - default: - return false; - } - break; - case storage_type::long_string_val: - switch (rhs.get_storage_type()) - { - case storage_type::short_string_val: - return as_string_view() == rhs.as_string_view(); - case storage_type::long_string_val: - return as_string_view() == rhs.as_string_view(); - default: - return false; - } - break; - case storage_type::byte_string_val: - switch (rhs.get_storage_type()) - { - case storage_type::byte_string_val: - { - return as_byte_string_view() == rhs.as_byte_string_view(); - } - default: - return false; - } - break; - case storage_type::array_val: - switch (rhs.get_storage_type()) - { - case storage_type::array_val: - return array_data_cast()->value() == rhs.array_data_cast()->value(); - default: - return false; - } - break; - case storage_type::object_val: - switch (rhs.get_storage_type()) - { - case storage_type::empty_object_val: - return size() == 0; - case storage_type::object_val: - return object_data_cast()->value() == rhs.object_data_cast()->value(); - default: - return false; - } - break; - default: - JSONCONS_UNREACHABLE(); - break; - } - } - - bool operator!=(const variant& rhs) const - { - return !(*this == rhs); - } - - bool operator<(const variant& rhs) const - { - if (this == &rhs) - { - return false; - } - switch (get_storage_type()) - { - case storage_type::null_val: - return (int)get_storage_type() < (int)rhs.get_storage_type(); - case storage_type::empty_object_val: - switch (rhs.get_storage_type()) - { - case storage_type::empty_object_val: - return false; - case storage_type::object_val: - return rhs.size() != 0; - default: - return (int)get_storage_type() < (int)rhs.get_storage_type(); - } - break; - case storage_type::bool_val: - switch (rhs.get_storage_type()) - { - case storage_type::bool_val: - return bool_data_cast()->value() < rhs.bool_data_cast()->value(); - default: - return (int)get_storage_type() < (int)rhs.get_storage_type(); - } - break; - case storage_type::int64_val: - switch (rhs.get_storage_type()) - { - case storage_type::int64_val: - return int64_data_cast()->value() < rhs.int64_data_cast()->value(); - case storage_type::uint64_val: - return int64_data_cast()->value() >= 0 ? static_cast(int64_data_cast()->value()) < rhs.uint64_data_cast()->value() : true; - case storage_type::double_val: - return static_cast(int64_data_cast()->value()) < rhs.double_data_cast()->value(); - default: - return (int)get_storage_type() < (int)rhs.get_storage_type(); - } - break; - case storage_type::uint64_val: - switch (rhs.get_storage_type()) - { - case storage_type::int64_val: - return rhs.int64_data_cast()->value() >= 0 ? uint64_data_cast()->value() < static_cast(rhs.int64_data_cast()->value()) : true; - case storage_type::uint64_val: - return uint64_data_cast()->value() < rhs.uint64_data_cast()->value(); - case storage_type::double_val: - return static_cast(uint64_data_cast()->value()) < rhs.double_data_cast()->value(); - default: - return (int)get_storage_type() < (int)rhs.get_storage_type(); - } - break; - case storage_type::double_val: - switch (rhs.get_storage_type()) - { - case storage_type::int64_val: - return double_data_cast()->value() < static_cast(rhs.int64_data_cast()->value()); - case storage_type::uint64_val: - return double_data_cast()->value() < static_cast(rhs.uint64_data_cast()->value()); - case storage_type::double_val: - return double_data_cast()->value() < rhs.double_data_cast()->value(); - default: - return (int)get_storage_type() < (int)rhs.get_storage_type(); - } - break; - case storage_type::short_string_val: - switch (rhs.get_storage_type()) - { - case storage_type::short_string_val: - return as_string_view() < rhs.as_string_view(); - case storage_type::long_string_val: - return as_string_view() < rhs.as_string_view(); - default: - return (int)get_storage_type() < (int)rhs.get_storage_type(); - } - break; - case storage_type::long_string_val: - switch (rhs.get_storage_type()) - { - case storage_type::short_string_val: - return as_string_view() < rhs.as_string_view(); - case storage_type::long_string_val: - return as_string_view() < rhs.as_string_view(); - default: - return (int)get_storage_type() < (int)rhs.get_storage_type(); - } - break; - case storage_type::byte_string_val: - switch (rhs.get_storage_type()) - { - case storage_type::byte_string_val: - { - return as_byte_string_view() < rhs.as_byte_string_view(); - } - default: - return (int)get_storage_type() < (int)rhs.get_storage_type(); - } - break; - case storage_type::array_val: - switch (rhs.get_storage_type()) - { - case storage_type::array_val: - return array_data_cast()->value() < rhs.array_data_cast()->value(); - default: - return (int)get_storage_type() < (int)rhs.get_storage_type(); - } - break; - case storage_type::object_val: - switch (rhs.get_storage_type()) - { - case storage_type::empty_object_val: - return false; - case storage_type::object_val: - return object_data_cast()->value() < rhs.object_data_cast()->value(); - default: - return (int)get_storage_type() < (int)rhs.get_storage_type(); - } - break; - default: - JSONCONS_UNREACHABLE(); - break; - } - } - - template - typename std::enable_if::pointer>::value,void>::type - swap(variant& other) noexcept - { - if (this ==&other) - { - return; - } - - std::swap(data_,other.data_); - } - - template - typename std::enable_if::pointer>::value, void>::type - swap(variant& other) noexcept - { - if (this ==&other) - { - return; - } - - variant temp(other); - switch (get_storage_type()) - { - case storage_type::null_val: - new(reinterpret_cast(&(other.data_)))null_data(*null_data_cast()); - break; - case storage_type::empty_object_val: - new(reinterpret_cast(&(other.data_)))empty_object_data(*empty_object_data_cast()); - break; - case storage_type::bool_val: - new(reinterpret_cast(&(other.data_)))bool_data(*bool_data_cast()); - break; - case storage_type::int64_val: - new(reinterpret_cast(&(other.data_)))int64_data(*int64_data_cast()); - break; - case storage_type::uint64_val: - new(reinterpret_cast(&(other.data_)))uint64_data(*uint64_data_cast()); - break; - case storage_type::double_val: - new(reinterpret_cast(&(other.data_)))double_data(*double_data_cast()); - break; - case storage_type::short_string_val: - new(reinterpret_cast(&(other.data_)))short_string_data(*short_string_data_cast()); - break; - case storage_type::long_string_val: - new(reinterpret_cast(&other.data_))long_string_data(std::move(*string_data_cast())); - break; - case storage_type::byte_string_val: - new(reinterpret_cast(&other.data_))byte_string_data(std::move(*byte_string_data_cast())); - break; - case storage_type::array_val: - new(reinterpret_cast(&(other.data_)))array_data(std::move(*array_data_cast())); - break; - case storage_type::object_val: - new(reinterpret_cast(&(other.data_)))object_data(std::move(*object_data_cast())); - break; - default: - JSONCONS_UNREACHABLE(); - break; - } - switch (temp.get_storage_type()) - { - case storage_type::long_string_val: - new(reinterpret_cast(&data_))long_string_data(std::move(*temp.string_data_cast())); - break; - case storage_type::byte_string_val: - new(reinterpret_cast(&data_))byte_string_data(std::move(*temp.byte_string_data_cast())); - break; - case storage_type::array_val: - new(reinterpret_cast(&(data_)))array_data(std::move(*temp.array_data_cast())); - break; - case storage_type::object_val: - new(reinterpret_cast(&(data_)))object_data(std::move(*temp.object_data_cast())); - break; - default: - std::swap(data_,temp.data_); - break; - } - } - private: - - void Init_(const variant& val) - { - switch (val.get_storage_type()) - { - case storage_type::null_val: - new(reinterpret_cast(&data_))null_data(*(val.null_data_cast())); - break; - case storage_type::empty_object_val: - new(reinterpret_cast(&data_))empty_object_data(*(val.empty_object_data_cast())); - break; - case storage_type::bool_val: - new(reinterpret_cast(&data_))bool_data(*(val.bool_data_cast())); - break; - case storage_type::int64_val: - new(reinterpret_cast(&data_))int64_data(*(val.int64_data_cast())); - break; - case storage_type::uint64_val: - new(reinterpret_cast(&data_))uint64_data(*(val.uint64_data_cast())); - break; - case storage_type::double_val: - new(reinterpret_cast(&data_))double_data(*(val.double_data_cast())); - break; - case storage_type::short_string_val: - new(reinterpret_cast(&data_))short_string_data(*(val.short_string_data_cast())); - break; - case storage_type::long_string_val: - new(reinterpret_cast(&data_))long_string_data(*(val.string_data_cast())); - break; - case storage_type::byte_string_val: - new(reinterpret_cast(&data_))byte_string_data(*(val.byte_string_data_cast())); - break; - case storage_type::object_val: - new(reinterpret_cast(&data_))object_data(*(val.object_data_cast())); - break; - case storage_type::array_val: - new(reinterpret_cast(&data_))array_data(*(val.array_data_cast())); - break; - default: - break; - } - } - - void Init_(const variant& val, const Allocator& a) - { - switch (val.get_storage_type()) - { - case storage_type::null_val: - case storage_type::empty_object_val: - case storage_type::bool_val: - case storage_type::int64_val: - case storage_type::uint64_val: - case storage_type::double_val: - case storage_type::short_string_val: - Init_(val); - break; - case storage_type::long_string_val: - new(reinterpret_cast(&data_))long_string_data(*(val.string_data_cast()),a); - break; - case storage_type::byte_string_val: - new(reinterpret_cast(&data_))byte_string_data(*(val.byte_string_data_cast()),a); - break; - case storage_type::array_val: - new(reinterpret_cast(&data_))array_data(*(val.array_data_cast()),a); - break; - case storage_type::object_val: - new(reinterpret_cast(&data_))object_data(*(val.object_data_cast()),a); - break; - default: - break; - } - } - - void Init_rv_(variant&& val) noexcept - { - switch (val.get_storage_type()) - { - case storage_type::null_val: - case storage_type::empty_object_val: - case storage_type::double_val: - case storage_type::int64_val: - case storage_type::uint64_val: - case storage_type::bool_val: - case storage_type::short_string_val: - Init_(val); - break; - case storage_type::long_string_val: - { - new(reinterpret_cast(&data_))long_string_data(std::move(*val.string_data_cast())); - new(reinterpret_cast(&val.data_))null_data(); - } - break; - case storage_type::byte_string_val: - { - new(reinterpret_cast(&data_))byte_string_data(std::move(*val.byte_string_data_cast())); - new(reinterpret_cast(&val.data_))null_data(); - } - break; - case storage_type::array_val: - { - new(reinterpret_cast(&data_))array_data(std::move(*val.array_data_cast())); - new(reinterpret_cast(&val.data_))null_data(); - } - break; - case storage_type::object_val: - { - new(reinterpret_cast(&data_))object_data(std::move(*val.object_data_cast())); - new(reinterpret_cast(&val.data_))null_data(); - } - break; - default: - JSONCONS_UNREACHABLE(); - break; - } - } - - void Init_rv_(variant&& val, const Allocator&, std::true_type) noexcept - { - Init_rv_(std::forward(val)); - } - - void Init_rv_(variant&& val, const Allocator& a, std::false_type) noexcept - { - switch (val.get_storage_type()) - { - case storage_type::null_val: - case storage_type::empty_object_val: - case storage_type::double_val: - case storage_type::int64_val: - case storage_type::uint64_val: - case storage_type::bool_val: - case storage_type::short_string_val: - Init_(std::forward(val)); - break; - case storage_type::long_string_val: - { - if (a == val.string_data_cast()->get_allocator()) - { - Init_rv_(std::forward(val), a, std::true_type()); - } - else - { - Init_(val,a); - } - } - break; - case storage_type::byte_string_val: - { - if (a == val.byte_string_data_cast()->get_allocator()) - { - Init_rv_(std::forward(val), a, std::true_type()); - } - else - { - Init_(val,a); - } - } - break; - case storage_type::object_val: - { - if (a == val.object_data_cast()->get_allocator()) - { - Init_rv_(std::forward(val), a, std::true_type()); - } - else - { - Init_(val,a); - } - } - break; - case storage_type::array_val: - { - if (a == val.array_data_cast()->get_allocator()) - { - Init_rv_(std::forward(val), a, std::true_type()); - } - else - { - Init_(val,a); - } - } - break; - default: - break; - } - } - }; - - template - class json_proxy - { - private: - - ParentT& parent_; - const char_type* data_; - size_t length_; - - json_proxy() = delete; - json_proxy& operator = (const json_proxy& other) = delete; - - json_proxy(ParentT& parent, const char_type* data, size_t length) - : parent_(parent), data_(data), length_(length) - { - } - - basic_json& evaluate() - { - return parent_.evaluate(string_view_type(data_,length_)); - } - - const basic_json& evaluate() const - { - return parent_.evaluate(string_view_type(data_,length_)); - } - - basic_json& evaluate_with_default() - { - basic_json& val = parent_.evaluate_with_default(); - auto it = val.find(string_view_type(data_,length_)); - if (it == val.object_range().end()) - { - it = val.insert_or_assign(val.object_range().begin(),string_view_type(data_,length_),object(val.object_value().get_allocator())); - } - return it->value(); - } - - basic_json& evaluate(size_t index) - { - return evaluate().at(index); - } - - const basic_json& evaluate(size_t index) const - { - return evaluate().at(index); - } - - basic_json& evaluate(const string_view_type& index) - { - return evaluate().at(index); - } - - const basic_json& evaluate(const string_view_type& index) const - { - return evaluate().at(index); - } - public: - - friend class basic_json; - typedef json_proxy proxy_type; - - range object_range() - { - return evaluate().object_range(); - } - - range object_range() const - { - return evaluate().object_range(); - } - - range array_range() - { - return evaluate().array_range(); - } - - range array_range() const - { - return evaluate().array_range(); - } - - size_t size() const noexcept - { - return evaluate().size(); - } - - storage_type get_storage_type() const - { - return evaluate().get_storage_type(); - } - - semantic_tag get_semantic_tag() const - { - return evaluate().get_semantic_tag(); - } - - size_t count(const string_view_type& name) const - { - return evaluate().count(name); - } - - allocator_type get_allocator() const - { - return evaluate().get_allocator(); - } - - bool contains(const string_view_type& name) const - { - return evaluate().contains(name); - } - - bool is_null() const noexcept - { - return evaluate().is_null(); - } - - bool empty() const - { - return evaluate().empty(); - } - - size_t capacity() const - { - return evaluate().capacity(); - } - - void reserve(size_t n) - { - evaluate().reserve(n); - } - - void resize(size_t n) - { - evaluate().resize(n); - } - - template - void resize(size_t n, T val) - { - evaluate().resize(n,val); - } - - template - bool is(Args&&... args) const - { - return evaluate().template is(std::forward(args)...); - } - - bool is_string() const noexcept - { - return evaluate().is_string(); - } - - bool is_string_view() const noexcept - { - return evaluate().is_string_view(); - } - - bool is_byte_string() const noexcept - { - return evaluate().is_byte_string(); - } - - bool is_byte_string_view() const noexcept - { - return evaluate().is_byte_string_view(); - } - - bool is_bignum() const noexcept - { - return evaluate().is_bignum(); - } - - bool is_number() const noexcept - { - return evaluate().is_number(); - } - bool is_bool() const noexcept - { - return evaluate().is_bool(); - } - - bool is_object() const noexcept - { - return evaluate().is_object(); - } - - bool is_array() const noexcept - { - return evaluate().is_array(); - } - - bool is_int64() const noexcept - { - return evaluate().is_int64(); - } - - bool is_uint64() const noexcept - { - return evaluate().is_uint64(); - } - - bool is_double() const noexcept - { - return evaluate().is_double(); - } - - string_view_type as_string_view() const - { - return evaluate().as_string_view(); - } - - byte_string_view as_byte_string_view() const - { - return evaluate().as_byte_string_view(); - } - - basic_bignum as_bignum() const - { - return evaluate().as_bignum(); - } - - template > - string_type as_string() const - { - return evaluate().as_string(); - } - - template > - string_type as_string(const SAllocator& allocator) const - { - return evaluate().as_string(allocator); - } - - template > - basic_byte_string as_byte_string() const - { - return evaluate().template as_byte_string(); - } - - template > - string_type as_string(const basic_json_options& options) const - { - return evaluate().as_string(options); - } - - template > - string_type as_string(const basic_json_options& options, - const SAllocator& allocator) const - { - return evaluate().as_string(options,allocator); - } - - template - T as(Args&&... args) const - { - return evaluate().template as(std::forward(args)...); - } - - template - typename std::enable_if::value,T>::type - as(const char_allocator_type& allocator) const - { - return evaluate().template as(allocator); - } - bool as_bool() const - { - return evaluate().as_bool(); - } - - double as_double() const - { - return evaluate().as_double(); - } - - template - T as_integer() const - { - return evaluate().template as_integer(); - } - - template - json_proxy& operator=(T&& val) - { - parent_.evaluate_with_default().insert_or_assign(string_view_type(data_,length_), std::forward(val)); - return *this; - } - - bool operator==(const basic_json& rhs) const - { - return evaluate() == rhs; - } - - bool operator!=(const basic_json& rhs) const - { - return evaluate() != rhs; - } - - bool operator<(const basic_json& rhs) const - { - return evaluate() < rhs; - } - - bool operator<=(const basic_json& rhs) const - { - return !(rhs < evaluate()); - } - - bool operator>(const basic_json& rhs) const - { - return !(evaluate() <= rhs); - } - - bool operator>=(const basic_json& rhs) const - { - return !(evaluate() < rhs); - } - - basic_json& operator[](size_t i) - { - return evaluate_with_default().at(i); - } - - const basic_json& operator[](size_t i) const - { - return evaluate().at(i); - } - - json_proxy operator[](const string_view_type& key) - { - return json_proxy(*this,key.data(),key.length()); - } - - const basic_json& operator[](const string_view_type& name) const - { - return at(name); - } - - basic_json& at(const string_view_type& name) - { - return evaluate().at(name); - } - - const basic_json& at(const string_view_type& name) const - { - return evaluate().at(name); - } - - const basic_json& at(size_t index) - { - return evaluate().at(index); - } - - const basic_json& at(size_t index) const - { - return evaluate().at(index); - } - - object_iterator find(const string_view_type& name) - { - return evaluate().find(name); - } - - const_object_iterator find(const string_view_type& name) const - { - return evaluate().find(name); - } - - template - T get_with_default(const string_view_type& name, const T& default_val) const - { - return evaluate().template get_with_default(name,default_val); - } - - template > - T get_with_default(const string_view_type& name, const CharT* default_val) const - { - return evaluate().template get_with_default(name,default_val); - } - - void shrink_to_fit() - { - evaluate_with_default().shrink_to_fit(); - } - - void clear() - { - evaluate().clear(); - } - // Remove all elements from an array or object - - void erase(const_object_iterator pos) - { - evaluate().erase(pos); - } - // Remove a range of elements from an object - - void erase(const_object_iterator first, const_object_iterator last) - { - evaluate().erase(first, last); - } - // Remove a range of elements from an object - - void erase(const string_view_type& name) - { - evaluate().erase(name); - } - - void erase(const_array_iterator pos) - { - evaluate().erase(pos); - } - // Removes the element at pos - - void erase(const_array_iterator first, const_array_iterator last) - { - evaluate().erase(first, last); - } - // Remove a range of elements from an array - - // merge - - void merge(const basic_json& source) - { - return evaluate().merge(source); - } - - void merge(basic_json&& source) - { - return evaluate().merge(std::forward(source)); - } - - void merge(object_iterator hint, const basic_json& source) - { - return evaluate().merge(hint, source); - } - - void merge(object_iterator hint, basic_json&& source) - { - return evaluate().merge(hint, std::forward(source)); - } - - // merge_or_update - - void merge_or_update(const basic_json& source) - { - return evaluate().merge_or_update(source); - } - - void merge_or_update(basic_json&& source) - { - return evaluate().merge_or_update(std::forward(source)); - } - - void merge_or_update(object_iterator hint, const basic_json& source) - { - return evaluate().merge_or_update(hint, source); - } - - void merge_or_update(object_iterator hint, basic_json&& source) - { - return evaluate().merge_or_update(hint, std::forward(source)); - } - - template - std::pair insert_or_assign(const string_view_type& name, T&& val) - { - return evaluate().insert_or_assign(name,std::forward(val)); - } - - // emplace - - template - std::pair try_emplace(const string_view_type& name, Args&&... args) - { - return evaluate().try_emplace(name,std::forward(args)...); - } - - template - object_iterator insert_or_assign(object_iterator hint, const string_view_type& name, T&& val) - { - return evaluate().insert_or_assign(hint, name, std::forward(val)); - } - - template - object_iterator try_emplace(object_iterator hint, const string_view_type& name, Args&&... args) - { - return evaluate().try_emplace(hint, name, std::forward(args)...); - } - - template - array_iterator emplace(const_array_iterator pos, Args&&... args) - { - evaluate_with_default().emplace(pos, std::forward(args)...); - } - - template - basic_json& emplace_back(Args&&... args) - { - return evaluate_with_default().emplace_back(std::forward(args)...); - } - - template - void push_back(T&& val) - { - evaluate_with_default().push_back(std::forward(val)); - } - - template - array_iterator insert(const_array_iterator pos, T&& val) - { - return evaluate_with_default().insert(pos, std::forward(val)); - } - - template - array_iterator insert(const_array_iterator pos, InputIt first, InputIt last) - { - return evaluate_with_default().insert(pos, first, last); - } - - template - void insert(InputIt first, InputIt last) - { - evaluate_with_default().insert(first, last); - } - - template - void insert(sorted_unique_range_tag tag, InputIt first, InputIt last) - { - evaluate_with_default().insert(tag, first, last); - } - - template - void dump(std::basic_string& s) const - { - evaluate().dump(s); - } - - template - void dump(std::basic_string& s, - indenting line_indent) const - { - evaluate().dump(s, line_indent); - } - - template - void dump(std::basic_string& s, - const basic_json_options& options) const - { - evaluate().dump(s,options); - } - - template - void dump(std::basic_string& s, - const basic_json_options& options, - indenting line_indent) const - { - evaluate().dump(s,options,line_indent); - } - - void dump(basic_json_content_handler& handler) const - { - evaluate().dump(handler); - } - - void dump(std::basic_ostream& os) const - { - evaluate().dump(os); - } - - void dump(std::basic_ostream& os, indenting line_indent) const - { - evaluate().dump(os, line_indent); - } - - void dump(std::basic_ostream& os, const basic_json_options& options) const - { - evaluate().dump(os,options); - } - - void dump(std::basic_ostream& os, const basic_json_options& options, indenting line_indent) const - { - evaluate().dump(os,options,line_indent); - } -#if !defined(JSONCONS_NO_DEPRECATED) - - bool is_datetime() const noexcept - { - return evaluate().is_datetime(); - } - - bool is_epoch_time() const noexcept - { - return evaluate().is_epoch_time(); - } - - template - void add(T&& val) - { - evaluate_with_default().add(std::forward(val)); - } - - template - array_iterator add(const_array_iterator pos, T&& val) - { - return evaluate_with_default().add(pos, std::forward(val)); - } - - // set - - template - std::pair set(const string_view_type& name, T&& val) - { - return evaluate().set(name,std::forward(val)); - } - - template - object_iterator set(object_iterator hint, const string_view_type& name, T&& val) - { - return evaluate().set(hint, name, std::forward(val)); - } - - bool has_key(const string_view_type& name) const - { - return evaluate().has_key(name); - } - - bool is_integer() const noexcept - { - return evaluate().is_int64(); - } - - bool is_uinteger() const noexcept - { - return evaluate().is_uint64(); - } - - unsigned long long as_ulonglong() const - { - return evaluate().as_ulonglong(); - } - - uint64_t as_uinteger() const - { - return evaluate().as_uinteger(); - } - - void dump(std::basic_ostream& os, const basic_json_options& options, bool pprint) const - { - evaluate().dump(os,options,pprint); - } - - void dump(std::basic_ostream& os, bool pprint) const - { - evaluate().dump(os, pprint); - } - - string_type to_string(const char_allocator_type& allocator = char_allocator_type()) const noexcept - { - return evaluate().to_string(allocator); - } - void write(basic_json_content_handler& handler) const - { - evaluate().write(handler); - } - - void write(std::basic_ostream& os) const - { - evaluate().write(os); - } - - void write(std::basic_ostream& os, const basic_json_options& options) const - { - evaluate().write(os,options); - } - - void write(std::basic_ostream& os, const basic_json_options& options, bool pprint) const - { - evaluate().write(os,options,pprint); - } - - string_type to_string(const basic_json_options& options, char_allocator_type& allocator = char_allocator_type()) const - { - return evaluate().to_string(options,allocator); - } - - range members() - { - return evaluate().members(); - } - - range members() const - { - return evaluate().members(); - } - - range elements() - { - return evaluate().elements(); - } - - range elements() const - { - return evaluate().elements(); - } - void to_stream(basic_json_content_handler& handler) const - { - evaluate().to_stream(handler); - } - - void to_stream(std::basic_ostream& os) const - { - evaluate().to_stream(os); - } - - void to_stream(std::basic_ostream& os, const basic_json_options& options) const - { - evaluate().to_stream(os,options); - } - - void to_stream(std::basic_ostream& os, const basic_json_options& options, bool pprint) const - { - evaluate().to_stream(os,options,pprint); - } -#endif - void swap(basic_json& val) - { - evaluate_with_default().swap(val); - } - - friend std::basic_ostream& operator<<(std::basic_ostream& os, const json_proxy& o) - { - o.dump(os); - return os; - } - -#if !defined(JSONCONS_NO_DEPRECATED) - - void resize_array(size_t n) - { - evaluate().resize_array(n); - } - - template - void resize_array(size_t n, T val) - { - evaluate().resize_array(n,val); - } - - object_iterator begin_members() - { - return evaluate().begin_members(); - } - - const_object_iterator begin_members() const - { - return evaluate().begin_members(); - } - - object_iterator end_members() - { - return evaluate().end_members(); - } - - const_object_iterator end_members() const - { - return evaluate().end_members(); - } - - array_iterator begin_elements() - { - return evaluate().begin_elements(); - } - - const_array_iterator begin_elements() const - { - return evaluate().begin_elements(); - } - - array_iterator end_elements() - { - return evaluate().end_elements(); - } - - const_array_iterator end_elements() const - { - return evaluate().end_elements(); - } - - template - basic_json get(const string_view_type& name, T&& default_val) const - { - return evaluate().get(name,std::forward(default_val)); - } - - const basic_json& get(const string_view_type& name) const - { - return evaluate().get(name); - } - - bool is_ulonglong() const noexcept - { - return evaluate().is_ulonglong(); - } - - bool is_longlong() const noexcept - { - return evaluate().is_longlong(); - } - - int as_int() const - { - return evaluate().as_int(); - } - - unsigned int as_uint() const - { - return evaluate().as_uint(); - } - - long as_long() const - { - return evaluate().as_long(); - } - - unsigned long as_ulong() const - { - return evaluate().as_ulong(); - } - - long long as_longlong() const - { - return evaluate().as_longlong(); - } - - bool has_member(const string_type& name) const - { - return evaluate().has_member(name); - } - - // Remove a range of elements from an array - void remove_range(size_t from_index, size_t to_index) - { - evaluate().remove_range(from_index, to_index); - } - // Remove a range of elements from an array - void remove(const string_view_type& name) - { - evaluate().remove(name); - } - void remove_member(const string_view_type& name) - { - evaluate().remove(name); - } - bool is_empty() const noexcept - { - return empty(); - } - bool is_numeric() const noexcept - { - return is_number(); - } -#endif - }; - - static basic_json parse(std::basic_istream& is) - { - parse_error_handler_type err_handler; - return parse(is,err_handler); - } - - static basic_json parse(std::basic_istream& is, parse_error_handler& err_handler) - { - json_decoder> handler; - basic_json_reader> reader(is, handler, err_handler); - reader.read_next(); - reader.check_done(); - if (!handler.is_valid()) - { - JSONCONS_THROW(json_runtime_error("Failed to parse json stream")); - } - return handler.get_result(); - } - - static basic_json parse(const string_view_type& s) - { - parse_error_handler_type err_handler; - return parse(s,err_handler); - } - -#if !defined(JSONCONS_NO_DEPRECATED) - - void add(size_t index, const basic_json& value) - { - evaluate_with_default().add(index, value); - } - - void add(size_t index, basic_json&& value) - { - evaluate_with_default().add(index, std::forward(value)); - } - - static basic_json parse(const char_type* s, size_t length) - { - parse_error_handler_type err_handler; - return parse(s,length,err_handler); - } - - static basic_json parse(const char_type* s, size_t length, parse_error_handler& err_handler) - { - return parse(string_view_type(s,length),err_handler); - } -#endif - - static basic_json parse(const string_view_type& s, parse_error_handler& err_handler) - { - json_decoder decoder; - basic_json_parser parser(err_handler); - - auto result = unicons::skip_bom(s.begin(), s.end()); - if (result.ec != unicons::encoding_errc()) - { - throw ser_error(result.ec); - } - size_t offset = result.it - s.begin(); - parser.update(s.data()+offset,s.size()-offset); - parser.parse_some(decoder); - parser.finish_parse(decoder); - parser.check_done(); - if (!decoder.is_valid()) - { - JSONCONS_THROW(json_runtime_error("Failed to parse json string")); - } - return decoder.get_result(); - } - - static basic_json parse(std::basic_istream& is, const basic_json_options& options) - { - parse_error_handler_type err_handler; - return parse(is,options,err_handler); - } - - static basic_json parse(std::basic_istream& is, const basic_json_options& options, parse_error_handler& err_handler) - { - json_decoder> handler; - basic_json_reader> reader(is, handler, options, err_handler); - reader.read_next(); - reader.check_done(); - if (!handler.is_valid()) - { - JSONCONS_THROW(json_runtime_error("Failed to parse json stream")); - } - return handler.get_result(); - } - - static basic_json parse(const string_view_type& s, const basic_json_options& options) - { - parse_error_handler_type err_handler; - return parse(s,options,err_handler); - } - - static basic_json parse(const string_view_type& s, const basic_json_options& options, parse_error_handler& err_handler) - { - json_decoder decoder; - basic_json_parser parser(options,err_handler); - - auto result = unicons::skip_bom(s.begin(), s.end()); - if (result.ec != unicons::encoding_errc()) - { - throw ser_error(result.ec); - } - size_t offset = result.it - s.begin(); - parser.update(s.data()+offset,s.size()-offset); - parser.parse_some(decoder); - parser.finish_parse(decoder); - parser.check_done(); - if (!decoder.is_valid()) - { - JSONCONS_THROW(json_runtime_error("Failed to parse json string")); - } - return decoder.get_result(); - } - - static basic_json make_array() - { - return basic_json(array()); - } - - static basic_json make_array(const array& a) - { - return basic_json(a); - } - - static basic_json make_array(const array& a, allocator_type allocator) - { - return basic_json(variant(a, semantic_tag::none, allocator)); - } - - static basic_json make_array(std::initializer_list init, const Allocator& allocator = Allocator()) - { - return array(std::move(init),allocator); - } - - static basic_json make_array(size_t n, const Allocator& allocator = Allocator()) - { - return array(n,allocator); - } - - template - static basic_json make_array(size_t n, const T& val, const Allocator& allocator = Allocator()) - { - return basic_json::array(n, val,allocator); - } - - template - static typename std::enable_if::type make_array(size_t n) - { - return array(n); - } - - template - static typename std::enable_if::type make_array(size_t n, const T& val, const Allocator& allocator = Allocator()) - { - return array(n,val,allocator); - } - - template - static typename std::enable_if<(dim>1),basic_json>::type make_array(size_t n, Args... args) - { - const size_t dim1 = dim - 1; - - basic_json val = make_array(std::forward(args)...); - val.resize(n); - for (size_t i = 0; i < n; ++i) - { - val[i] = make_array(std::forward(args)...); - } - return val; - } - - static const basic_json& null() - { - static basic_json a_null = basic_json(null_type(), semantic_tag::none); - return a_null; - } - - variant var_; - - basic_json(semantic_tag tag = semantic_tag::none) - : var_(tag) - { - } - - explicit basic_json(const Allocator& allocator, semantic_tag tag = semantic_tag::none) - : var_(object(allocator),tag) - { - } - - basic_json(const basic_json& val) - : var_(val.var_) - { - } - - basic_json(const basic_json& val, const Allocator& allocator) - : var_(val.var_,allocator) - { - } - - basic_json(basic_json&& other) noexcept - : var_(std::move(other.var_)) - { - } - - basic_json(basic_json&& other, const Allocator&) noexcept - : var_(std::move(other.var_) /*,allocator*/ ) - { - } - - basic_json(const variant& val) - : var_(val) - { - } - - basic_json(variant&& other) - : var_(std::forward(other)) - { - } - - basic_json(const array& val, semantic_tag tag = semantic_tag::none) - : var_(val, tag) - { - } - - basic_json(array&& other, semantic_tag tag = semantic_tag::none) - : var_(std::forward(other), tag) - { - } - - basic_json(const object& other, semantic_tag tag = semantic_tag::none) - : var_(other, tag) - { - } - - basic_json(object&& other, semantic_tag tag = semantic_tag::none) - : var_(std::forward(other), tag) - { - } - - template - basic_json(const json_proxy& proxy) - : var_(proxy.evaluate().var_) - { - } - - template - basic_json(const json_proxy& proxy, const Allocator& allocator) - : var_(proxy.evaluate().var_,allocator) - { - } - - template - basic_json(const T& val) - : var_(json_type_traits::to_json(val).var_) - { - } - - template - basic_json(const T& val, const Allocator& allocator) - : var_(json_type_traits::to_json(val,allocator).var_) - { - } - - basic_json(const char_type* s, semantic_tag tag = semantic_tag::none) - : var_(s, char_traits_type::length(s), tag) - { - } - - basic_json(const char_type* s, const Allocator& allocator) - : var_(s, char_traits_type::length(s), semantic_tag::none, allocator) - { - } - -#if !defined(JSONCONS_NO_DEPRECATED) - basic_json(double val, uint8_t) - : var_(val, semantic_tag::none) - { - } - basic_json(double val, - const floating_point_options&, - semantic_tag tag = semantic_tag::none) - : var_(val, tag) - { - } -#endif - - basic_json(double val, semantic_tag tag) - : var_(val, tag) - { - } - - template - basic_json(T val, semantic_tag tag, typename std::enable_if::value && std::is_signed::value>::type* = 0) - : var_(static_cast(val), tag) - { - } - - template - basic_json(T val, semantic_tag tag, typename std::enable_if::value && !std::is_signed::value>::type* = 0) - : var_(static_cast(val), tag) - { - } - - basic_json(const char_type *s, size_t length, semantic_tag tag = semantic_tag::none) - : var_(s, length, tag) - { - } - - basic_json(const string_view_type& sv, semantic_tag tag) - : var_(sv.data(), sv.length(), tag) - { - } - - basic_json(null_type val, semantic_tag tag) - : var_(val, tag) - { - } - - basic_json(bool val, semantic_tag tag) - : var_(val, tag) - { - } - - basic_json(const string_view_type& sv, semantic_tag tag, const Allocator& allocator) - : var_(sv.data(), sv.length(), tag, allocator) - { - } - - basic_json(const char_type *s, size_t length, - semantic_tag tag, const Allocator& allocator) - : var_(s, length, tag, allocator) - { - } - -#if !defined(JSONCONS_NO_DEPRECATED) - - basic_json(const byte_string_view& bs, - byte_string_chars_format encoding_hint, - semantic_tag tag = semantic_tag::none) - : var_(bs, tag) - { - switch (encoding_hint) - { - { - case byte_string_chars_format::base16: - var_ = variant(bs, semantic_tag::base16); - break; - case byte_string_chars_format::base64: - var_ = variant(bs, semantic_tag::base64); - break; - case byte_string_chars_format::base64url: - var_ = variant(bs, semantic_tag::base64url); - break; - default: - break; - } - } - } -#endif - - explicit basic_json(const byte_string_view& bs, - semantic_tag tag = semantic_tag::none) - : var_(bs, tag) - { - } - - basic_json(const byte_string_view& bs, - semantic_tag tag, - const Allocator& allocator) - : var_(bs, tag, allocator) - { - } - - explicit basic_json(const basic_bignum& bs) - : var_(bs) - { - } - - explicit basic_json(const basic_bignum& bs, const Allocator& allocator) - : var_(bs, byte_allocator_type(allocator)) - { - } - -#if !defined(JSONCONS_NO_DEPRECATED) - - template - basic_json(InputIterator first, InputIterator last, const Allocator& allocator = Allocator()) - : var_(first,last,allocator) - { - } -#endif - - ~basic_json() - { - } - - basic_json& operator=(const basic_json& rhs) - { - if (this != &rhs) - { - var_ = rhs.var_; - } - return *this; - } - - basic_json& operator=(basic_json&& rhs) noexcept - { - if (this !=&rhs) - { - var_ = std::move(rhs.var_); - } - return *this; - } - - template - basic_json& operator=(const T& val) - { - var_ = json_type_traits::to_json(val).var_; - return *this; - } - - basic_json& operator=(const char_type* s) - { - var_ = variant(s, char_traits_type::length(s), semantic_tag::none); - return *this; - } - - friend bool operator==(const basic_json& lhs, const basic_json& rhs) - { - return lhs.var_ == rhs.var_; - } - - friend bool operator!=(const basic_json& lhs, const basic_json& rhs) - { - return !(lhs == rhs); - } - - friend bool operator<(const basic_json& lhs, const basic_json& rhs) - { - return lhs.var_ < rhs.var_; - } - - friend bool operator<=(const basic_json& lhs, const basic_json& rhs) - { - return !(rhs < lhs); - } - - friend bool operator>(const basic_json& lhs, const basic_json& rhs) - { - return !(lhs <= rhs); - } - - friend bool operator>=(const basic_json& lhs, const basic_json& rhs) - { - return !(lhs < rhs); - } - - size_t size() const noexcept - { - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - return 0; - case storage_type::object_val: - return object_value().size(); - case storage_type::array_val: - return array_value().size(); - default: - return 0; - } - } - - basic_json& operator[](size_t i) - { - return at(i); - } - - const basic_json& operator[](size_t i) const - { - return at(i); - } - - json_proxy operator[](const string_view_type& name) - { - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - create_object_implicitly(); - JSONCONS_FALLTHROUGH; - case storage_type::object_val: - return json_proxy(*this, name.data(),name.length()); - break; - default: - JSONCONS_THROW(not_an_object(name.data(),name.length())); - break; - } - } - - const basic_json& operator[](const string_view_type& name) const - { - return at(name); - } - - template - void dump(std::basic_string& s) const - { - typedef std::basic_string string_type; - basic_json_compressed_encoder> encoder(s); - dump(encoder); - } - - template - void dump(std::basic_string& s, indenting line_indent) const - { - typedef std::basic_string string_type; - if (line_indent == indenting::indent) - { - basic_json_encoder> encoder(s); - dump(encoder); - } - else - { - basic_json_compressed_encoder> encoder(s); - dump(encoder); - } - } - - template - void dump(std::basic_string& s, - const basic_json_options& options) const - { - typedef std::basic_string string_type; - basic_json_compressed_encoder> encoder(s, options); - dump(encoder); - } - - template - void dump(std::basic_string& s, - const basic_json_options& options, - indenting line_indent) const - { - typedef std::basic_string string_type; - if (line_indent == indenting::indent) - { - basic_json_encoder> encoder(s, options); - dump(encoder); - } - else - { - basic_json_compressed_encoder> encoder(s, options); - dump(encoder); - } - } - - void dump(basic_json_content_handler& handler) const - { - dump_noflush(handler); - handler.flush(); - } - - void dump(std::basic_ostream& os) const - { - basic_json_compressed_encoder encoder(os); - dump(encoder); - } - - void dump(std::basic_ostream& os, indenting line_indent) const - { - if (line_indent == indenting::indent) - { - basic_json_encoder encoder(os); - dump(encoder); - } - else - { - basic_json_compressed_encoder encoder(os); - dump(encoder); - } - } - - void dump(std::basic_ostream& os, const basic_json_options& options) const - { - basic_json_compressed_encoder encoder(os, options); - dump(encoder); - } - - void dump(std::basic_ostream& os, const basic_json_options& options, indenting line_indent) const - { - if (line_indent == indenting::indent) - { - basic_json_encoder encoder(os, options); - dump(encoder); - } - else - { - basic_json_compressed_encoder encoder(os, options); - dump(encoder); - } - } - - string_type to_string(const char_allocator_type& allocator=char_allocator_type()) const noexcept - { - string_type s(allocator); - basic_json_compressed_encoder> encoder(s); - dump(encoder); - return s; - } - - string_type to_string(const basic_json_options& options, - const char_allocator_type& allocator=char_allocator_type()) const - { - string_type s(allocator); - basic_json_compressed_encoder> encoder(s,options); - dump(encoder); - return s; - } - -#if !defined(JSONCONS_NO_DEPRECATED) - void dump_fragment(basic_json_content_handler& handler) const - { - dump(handler); - } - - void dump_body(basic_json_content_handler& handler) const - { - dump(handler); - } - - void dump(std::basic_ostream& os, bool pprint) const - { - if (pprint) - { - basic_json_encoder encoder(os); - dump(encoder); - } - else - { - basic_json_compressed_encoder encoder(os); - dump(encoder); - } - } - - void dump(std::basic_ostream& os, const basic_json_options& options, bool pprint) const - { - if (pprint) - { - basic_json_encoder encoder(os, options); - dump(encoder); - } - else - { - basic_json_compressed_encoder encoder(os, options); - dump(encoder); - } - } - - void write_body(basic_json_content_handler& handler) const - { - dump(handler); - } - void write(basic_json_content_handler& handler) const - { - dump(handler); - } - - void write(std::basic_ostream& os) const - { - dump(os); - } - - void write(std::basic_ostream& os, const basic_json_options& options) const - { - dump(os,options); - } - - void write(std::basic_ostream& os, const basic_json_options& options, bool pprint) const - { - dump(os,options,pprint); - } - - void to_stream(basic_json_content_handler& handler) const - { - dump(handler); - } - - void to_stream(std::basic_ostream& os) const - { - dump(os); - } - - void to_stream(std::basic_ostream& os, const basic_json_options& options) const - { - dump(os,options); - } - - void to_stream(std::basic_ostream& os, const basic_json_options& options, bool pprint) const - { - dump(os,options,pprint ? indenting::indent : indenting::no_indent); - } -#endif - bool is_null() const noexcept - { - return var_.get_storage_type() == storage_type::null_val; - } - - allocator_type get_allocator() const - { - switch (var_.get_storage_type()) - { - case storage_type::long_string_val: - { - return var_.string_data_cast()->get_allocator(); - } - case storage_type::byte_string_val: - { - return var_.byte_string_data_cast()->get_allocator(); - } - case storage_type::array_val: - { - return var_.array_data_cast()->get_allocator(); - } - case storage_type::object_val: - { - return var_.object_data_cast()->get_allocator(); - } - default: - return allocator_type(); - } - } - - bool contains(const string_view_type& name) const - { - switch (var_.get_storage_type()) - { - case storage_type::object_val: - { - const_object_iterator it = object_value().find(name); - return it != object_range().end(); - } - break; - default: - return false; - } - } - - size_t count(const string_view_type& name) const - { - switch (var_.get_storage_type()) - { - case storage_type::object_val: - { - auto it = object_value().find(name); - if (it == object_range().end()) - { - return 0; - } - size_t count = 0; - while (it != object_range().end()&& it->key() == name) - { - ++count; - ++it; - } - return count; - } - break; - default: - return 0; - } - } - - template - bool is(Args&&... args) const - { - return json_type_traits::is(*this,std::forward(args)...); - } - - bool is_string() const noexcept - { - return (var_.get_storage_type() == storage_type::long_string_val) || (var_.get_storage_type() == storage_type::short_string_val); - } - - bool is_string_view() const noexcept - { - return is_string(); - } - - bool is_byte_string() const noexcept - { - return var_.get_storage_type() == storage_type::byte_string_val; - } - - bool is_byte_string_view() const noexcept - { - return is_byte_string(); - } - - bool is_bignum() const - { - switch (get_storage_type()) - { - case storage_type::short_string_val: - case storage_type::long_string_val: - return jsoncons::detail::is_integer(as_string_view().data(), as_string_view().length()); - case storage_type::int64_val: - case storage_type::uint64_val: - return true; - default: - return false; - } - } - - bool is_bool() const noexcept - { - return var_.get_storage_type() == storage_type::bool_val; - } - - bool is_object() const noexcept - { - return var_.get_storage_type() == storage_type::object_val || var_.get_storage_type() == storage_type::empty_object_val; - } - - bool is_array() const noexcept - { - return var_.get_storage_type() == storage_type::array_val; - } - - bool is_int64() const noexcept - { - return var_.get_storage_type() == storage_type::int64_val || (var_.get_storage_type() == storage_type::uint64_val&& (as_integer() <= static_cast((std::numeric_limits::max)()))); - } - - bool is_uint64() const noexcept - { - return var_.get_storage_type() == storage_type::uint64_val || (var_.get_storage_type() == storage_type::int64_val&& as_integer() >= 0); - } - - bool is_double() const noexcept - { - return var_.get_storage_type() == storage_type::double_val; - } - - bool is_number() const noexcept - { - switch (var_.get_storage_type()) - { - case storage_type::int64_val: - case storage_type::uint64_val: - case storage_type::double_val: - return true; - case storage_type::short_string_val: - case storage_type::long_string_val: - return var_.get_semantic_tag() == semantic_tag::bigint || - var_.get_semantic_tag() == semantic_tag::bigdec || - var_.get_semantic_tag() == semantic_tag::bigfloat; -#if !defined(JSONCONS_NO_DEPRECATED) - case storage_type::array_val: - return var_.get_semantic_tag() == semantic_tag::bigfloat; -#endif - default: - return false; - } - } - - bool empty() const noexcept - { - switch (var_.get_storage_type()) - { - case storage_type::byte_string_val: - return var_.byte_string_data_cast()->length() == 0; - break; - case storage_type::short_string_val: - return var_.short_string_data_cast()->length() == 0; - case storage_type::long_string_val: - return var_.string_data_cast()->length() == 0; - case storage_type::array_val: - return array_value().size() == 0; - case storage_type::empty_object_val: - return true; - case storage_type::object_val: - return object_value().size() == 0; - default: - return false; - } - } - - size_t capacity() const - { - switch (var_.get_storage_type()) - { - case storage_type::array_val: - return array_value().capacity(); - case storage_type::object_val: - return object_value().capacity(); - default: - return 0; - } - } - - template - void create_object_implicitly() - { - static_assert(is_stateless::value, "Cannot create object implicitly - allocator is stateful."); - var_ = variant(object(Allocator()), semantic_tag::none); - } - - void reserve(size_t n) - { - switch (var_.get_storage_type()) - { - case storage_type::array_val: - array_value().reserve(n); - break; - case storage_type::empty_object_val: - { - create_object_implicitly(); - object_value().reserve(n); - } - break; - case storage_type::object_val: - { - object_value().reserve(n); - } - break; - default: - break; - } - } - - void resize(size_t n) - { - switch (var_.get_storage_type()) - { - case storage_type::array_val: - array_value().resize(n); - break; - default: - break; - } - } - - template - void resize(size_t n, T val) - { - switch (var_.get_storage_type()) - { - case storage_type::array_val: - array_value().resize(n, val); - break; - default: - break; - } - } - - template - T as(Args&&... args) const - { - return json_type_traits::as(*this,std::forward(args)...); - } - - template - typename std::enable_if::value,T>::type - as(const char_allocator_type& allocator) const - { - return json_type_traits::as(*this,allocator); - } - - bool as_bool() const - { - switch (var_.get_storage_type()) - { - case storage_type::short_string_val: - case storage_type::long_string_val: - if (var_.get_semantic_tag() == semantic_tag::bigint) - { - return static_cast(var_.as_bignum()); - } - - try - { - basic_json j = basic_json::parse(as_string_view()); - return j.as_bool(); - } - catch (...) - { - JSONCONS_THROW(json_runtime_error("Not a bool")); - } - break; - case storage_type::bool_val: - return var_.bool_data_cast()->value(); - case storage_type::double_val: - return var_.double_data_cast()->value() != 0.0; - case storage_type::int64_val: - return var_.int64_data_cast()->value() != 0; - case storage_type::uint64_val: - return var_.uint64_data_cast()->value() != 0; - default: - JSONCONS_THROW(json_runtime_error("Not a bool")); - } - } - - template - T as_integer() const - { - switch (var_.get_storage_type()) - { - case storage_type::short_string_val: - case storage_type::long_string_val: - { - auto result = jsoncons::detail::to_integer(as_string_view().data(), as_string_view().length()); - if (result.ec != jsoncons::detail::to_integer_errc()) - { - JSONCONS_THROW(json_runtime_error(make_error_code(result.ec).message())); - } - return result.value; - } - case storage_type::double_val: - return static_cast(var_.double_data_cast()->value()); - case storage_type::int64_val: - return static_cast(var_.int64_data_cast()->value()); - case storage_type::uint64_val: - return static_cast(var_.uint64_data_cast()->value()); - case storage_type::bool_val: - return static_cast(var_.bool_data_cast()->value() ? 1 : 0); - default: - JSONCONS_THROW(json_runtime_error("Not an integer")); - } - } - -#if !defined(JSONCONS_NO_DEPRECATED) - size_t precision() const - { - switch (var_.get_storage_type()) - { - case storage_type::double_val: - return 0; - default: - JSONCONS_THROW(json_runtime_error("Not a double")); - } - } - - size_t decimal_places() const - { - switch (var_.get_storage_type()) - { - case storage_type::double_val: - return 0; - default: - JSONCONS_THROW(json_runtime_error("Not a double")); - } - } -#endif - - double as_double() const - { - switch (var_.get_storage_type()) - { - case storage_type::short_string_val: - case storage_type::long_string_val: - { - jsoncons::detail::string_to_double to_double; - // to_double() throws std::invalid_argument if conversion fails - return to_double(as_cstring(), as_string_view().length()); - } - case storage_type::double_val: - return var_.double_data_cast()->value(); - case storage_type::int64_val: - return static_cast(var_.int64_data_cast()->value()); - case storage_type::uint64_val: - return static_cast(var_.uint64_data_cast()->value()); -#if !defined(JSONCONS_NO_DEPRECATED) - case storage_type::array_val: - if (get_semantic_tag() == semantic_tag::bigfloat) - { - jsoncons::detail::string_to_double to_double; - string_type s = as_string(); - return to_double(s.c_str(), s.length()); - } - else - { - JSONCONS_THROW(json_runtime_error("Not a double")); - } -#endif - default: - JSONCONS_THROW(json_runtime_error("Not a double")); - } - } - - string_view_type as_string_view() const - { - return var_.as_string_view(); - } - - byte_string_view as_byte_string_view() const - { - return var_.as_byte_string_view(); - } - - template > - basic_byte_string as_byte_string() const - { - return var_.template as_byte_string(); - } - - basic_bignum as_bignum() const - { - return var_.as_bignum(); - } - - template > - string_type as_string() const - { - return as_string(basic_json_options(),SAllocator()); - } - - template > - string_type as_string(const SAllocator& allocator) const - { - return as_string(basic_json_options(),allocator); - } - - template > - string_type as_string(const basic_json_options& options) const - { - return as_string(options,SAllocator()); - } - - template > - string_type as_string(const basic_json_options& options, - const SAllocator& allocator) const - { - switch (var_.get_storage_type()) - { - case storage_type::short_string_val: - case storage_type::long_string_val: - { - return string_type(as_string_view().data(),as_string_view().length(),allocator); - } - case storage_type::byte_string_val: - { - string_type s(allocator); - byte_string_chars_format format = jsoncons::detail::resolve_byte_string_chars_format(options.byte_string_format(), - byte_string_chars_format::none, - byte_string_chars_format::base64url); - switch (format) - { - case byte_string_chars_format::base64: - encode_base64(var_.byte_string_data_cast()->begin(), - var_.byte_string_data_cast()->end(), - s); - break; - case byte_string_chars_format::base16: - encode_base16(var_.byte_string_data_cast()->begin(), - var_.byte_string_data_cast()->end(), - s); - break; - default: - encode_base64url(var_.byte_string_data_cast()->begin(), - var_.byte_string_data_cast()->end(), - s); - break; - } - return s; - } - case storage_type::array_val: - { - string_type s(allocator); -#if !defined(JSONCONS_NO_DEPRECATED) - if (get_semantic_tag() == semantic_tag::bigfloat) - { - JSONCONS_ASSERT(size() == 2); - int64_t exp = at(0).template as_integer(); - string_type mantissa = at(1).as_string(); - bignum n(mantissa); - int64_t new_exp = 0; - bignum five(5); - if (exp > 0) - { - new_exp = static_cast(std::floor(exp*std::log(2)/std::log(10))); - bignum five_power = power(five,(unsigned)new_exp); - uint64_t binShift = exp - new_exp; - n = ((n) << (unsigned)binShift)/five_power; - } - else - { - new_exp = static_cast(std::ceil(-exp*std::log(2)/std::log(10))); - bignum five_power = power(five,(unsigned)new_exp); - uint64_t binShift = -exp - new_exp; - n = (n*five_power) >> (unsigned)binShift; - } - - std::string str; - n.dump(str); - if (str[0] == '-') - { - s.push_back('-'); - jsoncons::detail::prettify_string(str.c_str()+1, str.size()-1, -(int)new_exp, -4, 17, s); - } - else - { - jsoncons::detail::prettify_string(str.c_str(), str.size(), -(int)new_exp, -4, 17, s); - } - } - else -#endif - { - basic_json_compressed_encoder> encoder(s,options); - dump(encoder); - } - return s; - } - default: - { - string_type s(allocator); - basic_json_compressed_encoder> encoder(s,options); - dump(encoder); - return s; - } - } - } - - const char_type* as_cstring() const - { - switch (var_.get_storage_type()) - { - case storage_type::short_string_val: - return var_.short_string_data_cast()->c_str(); - case storage_type::long_string_val: - return var_.string_data_cast()->c_str(); - default: - JSONCONS_THROW(json_runtime_error("Not a cstring")); - } - } - -#if !defined(JSONCONS_NO_DEPRECATED) - - bool is_datetime() const noexcept - { - return var_.get_semantic_tag() == semantic_tag::datetime; - } - - bool is_epoch_time() const noexcept - { - return var_.get_semantic_tag() == semantic_tag::timestamp; - } - - bool has_key(const string_view_type& name) const - { - return contains(name); - } - - bool is_integer() const noexcept - { - return var_.get_storage_type() == storage_type::int64_val || (var_.get_storage_type() == storage_type::uint64_val&& (as_integer() <= static_cast((std::numeric_limits::max)()))); - } - - bool is_uinteger() const noexcept - { - return var_.get_storage_type() == storage_type::uint64_val || (var_.get_storage_type() == storage_type::int64_val&& as_integer() >= 0); - } - - int64_t as_uinteger() const - { - return as_integer(); - } - - size_t double_precision() const - { - switch (var_.get_storage_type()) - { - case storage_type::double_val: - return 0; - default: - JSONCONS_THROW(json_runtime_error("Not a double")); - } - } -#endif - - basic_json& at(const string_view_type& name) - { - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - JSONCONS_THROW(key_not_found(name.data(),name.length())); - case storage_type::object_val: - { - auto it = object_value().find(name); - if (it == object_range().end()) - { - JSONCONS_THROW(key_not_found(name.data(),name.length())); - } - return it->value(); - } - break; - default: - { - JSONCONS_THROW(not_an_object(name.data(),name.length())); - } - } - } - - basic_json& evaluate() - { - return *this; - } - - basic_json& evaluate_with_default() - { - return *this; - } - - const basic_json& evaluate() const - { - return *this; - } - basic_json& evaluate(const string_view_type& name) - { - return at(name); - } - - const basic_json& evaluate(const string_view_type& name) const - { - return at(name); - } - - const basic_json& at(const string_view_type& name) const - { - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - JSONCONS_THROW(key_not_found(name.data(),name.length())); - case storage_type::object_val: - { - auto it = object_value().find(name); - if (it == object_range().end()) - { - JSONCONS_THROW(key_not_found(name.data(),name.length())); - } - return it->value(); - } - break; - default: - { - JSONCONS_THROW(not_an_object(name.data(),name.length())); - } - } - } - - basic_json& at(size_t i) - { - switch (var_.get_storage_type()) - { - case storage_type::array_val: - if (i >= array_value().size()) - { - JSONCONS_THROW(json_runtime_error("Invalid array subscript")); - } - return array_value().operator[](i); - case storage_type::object_val: - return object_value().at(i); - default: - JSONCONS_THROW(json_runtime_error("Index on non-array value not supported")); - } - } - - const basic_json& at(size_t i) const - { - switch (var_.get_storage_type()) - { - case storage_type::array_val: - if (i >= array_value().size()) - { - JSONCONS_THROW(json_runtime_error("Invalid array subscript")); - } - return array_value().operator[](i); - case storage_type::object_val: - return object_value().at(i); - default: - JSONCONS_THROW(json_runtime_error("Index on non-array value not supported")); - } - } - - object_iterator find(const string_view_type& name) - { - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - return object_range().end(); - case storage_type::object_val: - return object_value().find(name); - default: - { - JSONCONS_THROW(not_an_object(name.data(),name.length())); - } - } - } - - const_object_iterator find(const string_view_type& name) const - { - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - return object_range().end(); - case storage_type::object_val: - return object_value().find(name); - default: - { - JSONCONS_THROW(not_an_object(name.data(),name.length())); - } - } - } - - template - T get_with_default(const string_view_type& name, const T& default_val) const - { - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - { - return default_val; - } - case storage_type::object_val: - { - const_object_iterator it = object_value().find(name); - if (it != object_range().end()) - { - return it->value().template as(); - } - else - { - return default_val; - } - } - default: - { - JSONCONS_THROW(not_an_object(name.data(),name.length())); - } - } - } - - template> - T get_with_default(const string_view_type& name, const CharT* default_val) const - { - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - { - return T(default_val); - } - case storage_type::object_val: - { - const_object_iterator it = object_value().find(name); - if (it != object_range().end()) - { - return it->value().template as(); - } - else - { - return T(default_val); - } - } - default: - { - JSONCONS_THROW(not_an_object(name.data(),name.length())); - } - } - } - - // Modifiers - - void shrink_to_fit() - { - switch (var_.get_storage_type()) - { - case storage_type::array_val: - array_value().shrink_to_fit(); - break; - case storage_type::object_val: - object_value().shrink_to_fit(); - break; - default: - break; - } - } - - void clear() - { - switch (var_.get_storage_type()) - { - case storage_type::array_val: - array_value().clear(); - break; - case storage_type::object_val: - object_value().clear(); - break; - default: - break; - } - } - - void erase(const_object_iterator pos) - { - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - break; - case storage_type::object_val: - object_value().erase(pos); - break; - default: - JSONCONS_THROW(json_runtime_error("Not an object")); - break; - } - } - - void erase(const_object_iterator first, const_object_iterator last) - { - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - break; - case storage_type::object_val: - object_value().erase(first, last); - break; - default: - JSONCONS_THROW(json_runtime_error("Not an object")); - break; - } - } - - void erase(const_array_iterator pos) - { - switch (var_.get_storage_type()) - { - case storage_type::array_val: - array_value().erase(pos); - break; - default: - JSONCONS_THROW(json_runtime_error("Not an array")); - break; - } - } - - void erase(const_array_iterator first, const_array_iterator last) - { - switch (var_.get_storage_type()) - { - case storage_type::array_val: - array_value().erase(first, last); - break; - default: - JSONCONS_THROW(json_runtime_error("Not an array")); - break; - } - } - - // Removes all elements from an array value whose index is between from_index, inclusive, and to_index, exclusive. - - void erase(const string_view_type& name) - { - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - break; - case storage_type::object_val: - object_value().erase(name); - break; - default: - JSONCONS_THROW(not_an_object(name.data(),name.length())); - break; - } - } - - template - std::pair insert_or_assign(const string_view_type& name, T&& val) - { - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - create_object_implicitly(); - JSONCONS_FALLTHROUGH; - case storage_type::object_val: - return object_value().insert_or_assign(name, std::forward(val)); - default: - { - JSONCONS_THROW(not_an_object(name.data(),name.length())); - } - } - } - - template - std::pair try_emplace(const string_view_type& name, Args&&... args) - { - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - create_object_implicitly(); - JSONCONS_FALLTHROUGH; - case storage_type::object_val: - return object_value().try_emplace(name, std::forward(args)...); - default: - { - JSONCONS_THROW(not_an_object(name.data(),name.length())); - } - } - } - - // merge - - void merge(const basic_json& source) - { - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - create_object_implicitly(); - JSONCONS_FALLTHROUGH; - case storage_type::object_val: - return object_value().merge(source.object_value()); - default: - { - JSONCONS_THROW(json_runtime_error("Attempting to merge a value that is not an object")); - } - } - } - - void merge(basic_json&& source) - { - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - create_object_implicitly(); - JSONCONS_FALLTHROUGH; - case storage_type::object_val: - return object_value().merge(std::move(source.object_value())); - default: - { - JSONCONS_THROW(json_runtime_error("Attempting to merge a value that is not an object")); - } - } - } - - void merge(object_iterator hint, const basic_json& source) - { - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - create_object_implicitly(); - JSONCONS_FALLTHROUGH; - case storage_type::object_val: - return object_value().merge(hint, source.object_value()); - default: - { - JSONCONS_THROW(json_runtime_error("Attempting to merge a value that is not an object")); - } - } - } - - void merge(object_iterator hint, basic_json&& source) - { - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - create_object_implicitly(); - JSONCONS_FALLTHROUGH; - case storage_type::object_val: - return object_value().merge(hint, std::move(source.object_value())); - default: - { - JSONCONS_THROW(json_runtime_error("Attempting to merge a value that is not an object")); - } - } - } - - // merge_or_update - - void merge_or_update(const basic_json& source) - { - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - create_object_implicitly(); - JSONCONS_FALLTHROUGH; - case storage_type::object_val: - return object_value().merge_or_update(source.object_value()); - default: - { - JSONCONS_THROW(json_runtime_error("Attempting to merge or update a value that is not an object")); - } - } - } - - void merge_or_update(basic_json&& source) - { - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - create_object_implicitly(); - JSONCONS_FALLTHROUGH; - case storage_type::object_val: - return object_value().merge_or_update(std::move(source.object_value())); - default: - { - JSONCONS_THROW(json_runtime_error("Attempting to merge or update a value that is not an object")); - } - } - } - - void merge_or_update(object_iterator hint, const basic_json& source) - { - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - create_object_implicitly(); - JSONCONS_FALLTHROUGH; - case storage_type::object_val: - return object_value().merge_or_update(hint, source.object_value()); - default: - { - JSONCONS_THROW(json_runtime_error("Attempting to merge or update a value that is not an object")); - } - } - } - - void merge_or_update(object_iterator hint, basic_json&& source) - { - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - create_object_implicitly(); - JSONCONS_FALLTHROUGH; - case storage_type::object_val: - return object_value().merge_or_update(hint, std::move(source.object_value())); - default: - { - JSONCONS_THROW(json_runtime_error("Attempting to merge or update a value that is not an object")); - } - } - } - - template - object_iterator insert_or_assign(object_iterator hint, const string_view_type& name, T&& val) - { - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - create_object_implicitly(); - JSONCONS_FALLTHROUGH; - case storage_type::object_val: - return object_value().insert_or_assign(hint, name, std::forward(val)); - default: - { - JSONCONS_THROW(not_an_object(name.data(),name.length())); - } - } - } - - template - object_iterator try_emplace(object_iterator hint, const string_view_type& name, Args&&... args) - { - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - create_object_implicitly(); - JSONCONS_FALLTHROUGH; - case storage_type::object_val: - return object_value().try_emplace(hint, name, std::forward(args)...); - default: - { - JSONCONS_THROW(not_an_object(name.data(),name.length())); - } - } - } - - template - array_iterator insert(const_array_iterator pos, T&& val) - { - switch (var_.get_storage_type()) - { - case storage_type::array_val: - return array_value().insert(pos, std::forward(val)); - break; - default: - { - JSONCONS_THROW(json_runtime_error("Attempting to insert into a value that is not an array")); - } - } - } - - template - array_iterator insert(const_array_iterator pos, InputIt first, InputIt last) - { - switch (var_.get_storage_type()) - { - case storage_type::array_val: - return array_value().insert(pos, first, last); - break; - default: - { - JSONCONS_THROW(json_runtime_error("Attempting to insert into a value that is not an array")); - } - } - } - - template - void insert(InputIt first, InputIt last) - { - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - case storage_type::object_val: - return object_value().insert(first, last, get_key_value()); - break; - default: - { - JSONCONS_THROW(json_runtime_error("Attempting to insert into a value that is not an object")); - } - } - } - - template - void insert(sorted_unique_range_tag tag, InputIt first, InputIt last) - { - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - case storage_type::object_val: - return object_value().insert(tag, first, last, get_key_value()); - break; - default: - { - JSONCONS_THROW(json_runtime_error("Attempting to insert into a value that is not an object")); - } - } - } - - template - array_iterator emplace(const_array_iterator pos, Args&&... args) - { - switch (var_.get_storage_type()) - { - case storage_type::array_val: - return array_value().emplace(pos, std::forward(args)...); - break; - default: - { - JSONCONS_THROW(json_runtime_error("Attempting to insert into a value that is not an array")); - } - } - } - - template - basic_json& emplace_back(Args&&... args) - { - switch (var_.get_storage_type()) - { - case storage_type::array_val: - return array_value().emplace_back(std::forward(args)...); - default: - { - JSONCONS_THROW(json_runtime_error("Attempting to insert into a value that is not an array")); - } - } - } - - storage_type get_storage_type() const - { - return var_.get_storage_type(); - } - - semantic_tag get_semantic_tag() const - { - return var_.get_semantic_tag(); - } - - void swap(basic_json& b) - { - var_.swap(b.var_); - } - - friend void swap(basic_json& a, basic_json& b) - { - a.swap(b); - } - - template - void push_back(T&& val) - { - switch (var_.get_storage_type()) - { - case storage_type::array_val: - array_value().push_back(std::forward(val)); - break; - default: - { - JSONCONS_THROW(json_runtime_error("Attempting to insert into a value that is not an array")); - } - } - } - -#if !defined(JSONCONS_NO_DEPRECATED) - - template - void add(T&& val) - { - push_back(std::forward(val)); - } - - template - array_iterator add(const_array_iterator pos, T&& val) - { - return insert(pos, std::forward(val)); - } - - template - std::pair set(const string_view_type& name, T&& val) - { - return insert_or_assign(name, std::forward(val)); - } - - // set - - template - object_iterator set(object_iterator hint, const string_view_type& name, T&& val) - { - return insert_or_assign(hint, name, std::forward(val)); - } - - static basic_json parse_file(const std::basic_string& filename) - { - parse_error_handler_type err_handler; - return parse_file(filename,err_handler); - } - - static basic_json parse_file(const std::basic_string& filename, - parse_error_handler& err_handler) - { - std::basic_ifstream is(filename); - return parse(is,err_handler); - } - - static basic_json parse_stream(std::basic_istream& is) - { - return parse(is); - } - static basic_json parse_stream(std::basic_istream& is, parse_error_handler& err_handler) - { - return parse(is,err_handler); - } - - static basic_json parse_string(const string_type& s) - { - return parse(s); - } - - static basic_json parse_string(const string_type& s, parse_error_handler& err_handler) - { - return parse(s,err_handler); - } - - void resize_array(size_t n) - { - resize(n); - } - - template - void resize_array(size_t n, T val) - { - resize(n,val); - } - - object_iterator begin_members() - { - return object_range().begin(); - } - - const_object_iterator begin_members() const - { - return object_range().begin(); - } - - object_iterator end_members() - { - return object_range().end(); - } - - const_object_iterator end_members() const - { - return object_range().end(); - } - - array_iterator begin_elements() - { - return array_range().begin(); - } - - const_array_iterator begin_elements() const - { - return array_range().begin(); - } - - array_iterator end_elements() - { - return array_range().end(); - } - - const_array_iterator end_elements() const - { - return array_range().end(); - } - - template - basic_json get(const string_view_type& name, T&& default_val) const - { - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - { - return basic_json(std::forward(default_val)); - } - case storage_type::object_val: - { - const_object_iterator it = object_value().find(name); - if (it != object_range().end()) - { - return it->value(); - } - else - { - return basic_json(std::forward(default_val)); - } - } - default: - { - JSONCONS_THROW(not_an_object(name.data(),name.length())); - } - } - } - - const basic_json& get(const string_view_type& name) const - { - static const basic_json a_null = null_type(); - - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - return a_null; - case storage_type::object_val: - { - const_object_iterator it = object_value().find(name); - return it != object_range().end() ? it->value() : a_null; - } - default: - { - JSONCONS_THROW(not_an_object(name.data(),name.length())); - } - } - } - - bool is_longlong() const noexcept - { - return var_.get_storage_type() == storage_type::int64_val; - } - - bool is_ulonglong() const noexcept - { - return var_.get_storage_type() == storage_type::uint64_val; - } - - long long as_longlong() const - { - return as_integer(); - } - - unsigned long long as_ulonglong() const - { - return as_integer(); - } - - int as_int() const - { - switch (var_.get_storage_type()) - { - case storage_type::double_val: - return static_cast(var_.double_data_cast()->value()); - case storage_type::int64_val: - return static_cast(var_.int64_data_cast()->value()); - case storage_type::uint64_val: - return static_cast(var_.uint64_data_cast()->value()); - case storage_type::bool_val: - return var_.bool_data_cast()->value() ? 1 : 0; - default: - JSONCONS_THROW(json_runtime_error("Not an int")); - } - } - - unsigned int as_uint() const - { - switch (var_.get_storage_type()) - { - case storage_type::double_val: - return static_cast(var_.double_data_cast()->value()); - case storage_type::int64_val: - return static_cast(var_.int64_data_cast()->value()); - case storage_type::uint64_val: - return static_cast(var_.uint64_data_cast()->value()); - case storage_type::bool_val: - return var_.bool_data_cast()->value() ? 1 : 0; - default: - JSONCONS_THROW(json_runtime_error("Not an unsigned int")); - } - } - - long as_long() const - { - switch (var_.get_storage_type()) - { - case storage_type::double_val: - return static_cast(var_.double_data_cast()->value()); - case storage_type::int64_val: - return static_cast(var_.int64_data_cast()->value()); - case storage_type::uint64_val: - return static_cast(var_.uint64_data_cast()->value()); - case storage_type::bool_val: - return var_.bool_data_cast()->value() ? 1 : 0; - default: - JSONCONS_THROW(json_runtime_error("Not a long")); - } - } - - unsigned long as_ulong() const - { - switch (var_.get_storage_type()) - { - case storage_type::double_val: - return static_cast(var_.double_data_cast()->value()); - case storage_type::int64_val: - return static_cast(var_.int64_data_cast()->value()); - case storage_type::uint64_val: - return static_cast(var_.uint64_data_cast()->value()); - case storage_type::bool_val: - return var_.bool_data_cast()->value() ? 1 : 0; - default: - JSONCONS_THROW(json_runtime_error("Not an unsigned long")); - } - } - - bool has_member(const string_type& name) const - { - switch (var_.get_storage_type()) - { - case storage_type::object_val: - { - const_object_iterator it = object_value().find(name); - return it != object_range().end(); - } - break; - default: - return false; - } - } - - void remove_range(size_t from_index, size_t to_index) - { - switch (var_.get_storage_type()) - { - case storage_type::array_val: - array_value().remove_range(from_index, to_index); - break; - default: - break; - } - } - // Removes all elements from an array value whose index is between from_index, inclusive, and to_index, exclusive. - - void remove(const string_view_type& name) - { - erase(name); - } - void remove_member(const string_view_type& name) - { - erase(name); - } - // Removes a member from an object value - - bool is_empty() const noexcept - { - return empty(); - } - bool is_numeric() const noexcept - { - return is_number(); - } - - template - static typename std::enable_if::type make_multi_array() - { - return make_array(); - } - template - static typename std::enable_if::type make_multi_array(size_t n) - { - return make_array(n); - } - template - static typename std::enable_if::type make_multi_array(size_t n, T val) - { - return make_array(n,val); - } - template - static typename std::enable_if::type make_multi_array(size_t m, size_t n) - { - return make_array<2>(m, n); - } - template - static typename std::enable_if::type make_multi_array(size_t m, size_t n, T val) - { - return make_array<2>(m, n, val); - } - template - static typename std::enable_if::type make_multi_array(size_t m, size_t n, size_t k) - { - return make_array<3>(m, n, k); - } - template - static typename std::enable_if::type make_multi_array(size_t m, size_t n, size_t k, T val) - { - return make_array<3>(m, n, k, val); - } - range members() - { - return object_range(); - } - - range members() const - { - return object_range(); - } - - range elements() - { - return array_range(); - } - - range elements() const - { - return array_range(); - } -#endif - - range object_range() - { - static basic_json empty_object = object(); - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - return range(empty_object.object_range().begin(), empty_object.object_range().end()); - case storage_type::object_val: - return range(object_value().begin(),object_value().end()); - default: - JSONCONS_THROW(json_runtime_error("Not an object")); - } - } - - range object_range() const - { - static const basic_json empty_object = object(); - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - return range(empty_object.object_range().begin(), empty_object.object_range().end()); - case storage_type::object_val: - return range(object_value().begin(),object_value().end()); - default: - JSONCONS_THROW(json_runtime_error("Not an object")); - } - } - - range array_range() - { - switch (var_.get_storage_type()) - { - case storage_type::array_val: - return range(array_value().begin(),array_value().end()); - default: - JSONCONS_THROW(json_runtime_error("Not an array")); - } - } - - range array_range() const - { - switch (var_.get_storage_type()) - { - case storage_type::array_val: - return range(array_value().begin(),array_value().end()); - default: - JSONCONS_THROW(json_runtime_error("Not an array")); - } - } - - array& array_value() - { - switch (var_.get_storage_type()) - { - case storage_type::array_val: - return var_.array_data_cast()->value(); - default: - JSONCONS_THROW(json_runtime_error("Bad array cast")); - break; - } - } - - const array& array_value() const - { - switch (var_.get_storage_type()) - { - case storage_type::array_val: - return var_.array_data_cast()->value(); - default: - JSONCONS_THROW(json_runtime_error("Bad array cast")); - break; - } - } - - object& object_value() - { - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - create_object_implicitly(); - JSONCONS_FALLTHROUGH; - case storage_type::object_val: - return var_.object_data_cast()->value(); - default: - JSONCONS_THROW(json_runtime_error("Bad object cast")); - break; - } - } - - const object& object_value() const - { - switch (var_.get_storage_type()) - { - case storage_type::empty_object_val: - const_cast(this)->create_object_implicitly(); // HERE - JSONCONS_FALLTHROUGH; - case storage_type::object_val: - return var_.object_data_cast()->value(); - default: - JSONCONS_THROW(json_runtime_error("Bad object cast")); - break; - } - } - -private: - - void dump_noflush(basic_json_content_handler& handler) const - { - switch (var_.get_storage_type()) - { - case storage_type::short_string_val: - case storage_type::long_string_val: - handler.string_value(as_string_view(), var_.get_semantic_tag()); - break; - case storage_type::byte_string_val: - handler.byte_string_value(var_.byte_string_data_cast()->data(), var_.byte_string_data_cast()->length(), - var_.get_semantic_tag()); - break; - case storage_type::double_val: - handler.double_value(var_.double_data_cast()->value(), - var_.get_semantic_tag()); - break; - case storage_type::int64_val: - handler.int64_value(var_.int64_data_cast()->value(), var_.get_semantic_tag()); - break; - case storage_type::uint64_val: - handler.uint64_value(var_.uint64_data_cast()->value(), var_.get_semantic_tag()); - break; - case storage_type::bool_val: - handler.bool_value(var_.bool_data_cast()->value(), var_.get_semantic_tag()); - break; - case storage_type::null_val: - handler.null_value(var_.get_semantic_tag()); - break; - case storage_type::empty_object_val: - handler.begin_object(0, var_.get_semantic_tag()); - handler.end_object(); - break; - case storage_type::object_val: - { - handler.begin_object(size(), var_.get_semantic_tag()); - const object& o = object_value(); - for (const_object_iterator it = o.begin(); it != o.end(); ++it) - { - handler.name(string_view_type((it->key()).data(),it->key().length())); - it->value().dump_noflush(handler); - } - handler.end_object(); - } - break; - case storage_type::array_val: - { - handler.begin_array(size(), var_.get_semantic_tag()); - const array& o = array_value(); - for (const_array_iterator it = o.begin(); it != o.end(); ++it) - { - it->dump_noflush(handler); - } - handler.end_array(); - } - break; - default: - break; - } - } - - friend std::basic_ostream& operator<<(std::basic_ostream& os, const basic_json& o) - { - o.dump(os); - return os; - } - - friend std::basic_istream& operator<<(std::basic_istream& is, basic_json& o) - { - json_decoder handler; - basic_json_reader> reader(is, handler); - reader.read_next(); - reader.check_done(); - if (!handler.is_valid()) - { - JSONCONS_THROW(json_runtime_error("Failed to parse json stream")); - } - o = handler.get_result(); - return is; - } -}; - -template -void swap(typename Json::key_value_type& a, typename Json::key_value_type& b) -{ - a.swap(b); -} - -template -std::basic_istream& operator>>(std::basic_istream& is, Json& o) -{ - typedef typename Json::char_type char_type; - - json_decoder handler; - basic_json_reader> reader(is, handler); - reader.read_next(); - reader.check_done(); - if (!handler.is_valid()) - { - JSONCONS_THROW(json_runtime_error("Failed to parse json stream")); - } - o = handler.get_result(); - return is; -} - -typedef basic_json> json; -typedef basic_json> wjson; -typedef basic_json> ojson; -typedef basic_json> wojson; - -#if !defined(JSONCONS_NO_DEPRECATED) -typedef basic_json> owjson; -typedef json_decoder json_deserializer; -typedef json_decoder wjson_deserializer; -typedef json_decoder ojson_deserializer; -typedef json_decoder wojson_deserializer; -#endif - -inline namespace literals { - -inline -jsoncons::json operator "" _json(const char* s, std::size_t n) -{ - return jsoncons::json::parse(jsoncons::json::string_view_type(s, n)); -} - -inline -jsoncons::wjson operator "" _json(const wchar_t* s, std::size_t n) -{ - return jsoncons::wjson::parse(jsoncons::wjson::string_view_type(s, n)); -} - -inline -jsoncons::ojson operator "" _ojson(const char* s, std::size_t n) -{ - return jsoncons::ojson::parse(jsoncons::ojson::string_view_type(s, n)); -} - -inline -jsoncons::wojson operator "" _ojson(const wchar_t* s, std::size_t n) -{ - return jsoncons::wojson::parse(jsoncons::wojson::string_view_type(s, n)); -} - -} - -} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/bignum.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/bignum.hpp deleted file mode 100644 index f0a650ff94..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/bignum.hpp +++ /dev/null @@ -1,1604 +0,0 @@ -// Copyright 2018 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_BIGNUM_HPP -#define JSONCONS_BIGNUM_HPP - -#include -#include // std::vector -#include -#include -#include // assert -#include // std::numeric_limits -#include // std::max, std::min, std::reverse -#include // std::string -#include // std::memcpy -#include // std::fmod -#include // std::allocator -#include // std::initializer_list -#include // std::enable_if - -namespace jsoncons { - -/* -This implementation is based on Chapter 2 and Appendix A of -Ammeraal, L. (1996) Algorithms and Data Structures in C++, -Chichester: John Wiley. - -*/ - -template -class basic_bignum_base -{ -public: - typedef Allocator allocator_type; - typedef typename std::allocator_traits:: template rebind_alloc basic_type_allocator_type; - -private: - basic_type_allocator_type allocator_; - -public: - basic_bignum_base() - : allocator_() - { - } - explicit basic_bignum_base(const allocator_type& allocator) - : allocator_(basic_type_allocator_type(allocator)) - { - } - - basic_type_allocator_type allocator() const - { - return allocator_; - } -}; - -template > -class basic_bignum : protected basic_bignum_base -{ -private: - using basic_bignum_base::allocator; - - static constexpr uint64_t max_basic_type = (std::numeric_limits::max)(); - static constexpr uint64_t basic_type_bits = sizeof(uint64_t) * 8; // Number of bits - static constexpr uint64_t basic_type_halfBits = basic_type_bits/2; - - static constexpr uint16_t word_length = 4; // Use multiples of word_length words - static constexpr uint64_t r_mask = (uint64_t(1) << basic_type_halfBits) - 1; - static constexpr uint64_t l_mask = max_basic_type - r_mask; - static constexpr uint64_t l_bit = max_basic_type - (max_basic_type >> 1); - - union - { - size_t capacity_; - uint64_t values_[2]; - }; - uint64_t* data_; - bool neg_; - bool dynamic_; - size_t length_; -public: -// Constructors and Destructor - basic_bignum() - : values_{0,0}, data_(values_), neg_(false), dynamic_(false), length_(0) - { - } - - explicit basic_bignum(const Allocator& allocator) - : basic_bignum_base(allocator), values_{0,0}, data_(values_), neg_(false), dynamic_(false), length_(0) - { - } - - basic_bignum(const basic_bignum& n) - : basic_bignum_base(n.allocator()), neg_(n.neg_), length_(n.length_) - { - if (!n.dynamic_) - { - values_[0] = n.values_[0]; - values_[1] = n.values_[1]; - data_ = values_; - dynamic_ = false; - } - else - { - capacity_ = n.capacity_; - data_ = allocator().allocate(capacity_); - dynamic_ = true; - std::memcpy( data_, n.data_, n.length_*sizeof(uint64_t) ); - } - } - - basic_bignum(basic_bignum&& other) - : basic_bignum_base(other.allocator()), neg_(other.neg_), dynamic_(false), length_(other.length_) - { - initialize(std::move(other)); - } - - template - explicit basic_bignum(const CharT* str) - : values_{0,0} - { - initialize(str, strlen(str)); - } - - template - basic_bignum(const std::basic_string& s) - : values_{0,0} - { - initialize(s.data(), s.length()); - } - - template - basic_bignum(const CharT* data, size_t length) - : values_{0,0} - { - initialize(data, length); - } - - template - basic_bignum(const std::basic_string& s, uint8_t base) - : values_{0,0} - { - initialize(s.data(), s.length(), base); - } - - template - basic_bignum(const CharT* data, size_t length, uint8_t base) - : values_{0,0} - { - initialize(data, length, base); - } - - basic_bignum(int signum, std::initializer_list l) - : values_{0,0} - { - if (l.size() > 0) - { - basic_bignum v = 0; - for (auto c: l) - { - v = (v * 256) + (uint64_t)(c); - } - - if (signum == -1) - { - v = -1 - v; - } - - initialize(v); - } - else - { - neg_ = false; - initialize_from_integer(0u); - } - } - - basic_bignum(int signum, const uint8_t* str, size_t n) - : values_{0,0} - { - if (n > 0) - { - basic_bignum v = 0; - for (size_t i = 0; i < n; i++) - { - v = (v * 256) + (uint64_t)(str[i]); - } - - if (signum == -1) - { - v = -1 - v; - } - - initialize(v); - } - else - { - neg_ = false; - initialize_from_integer(0u); - } - } - - basic_bignum(short i) - : values_{0,0} - { - neg_ = i < 0; - uint64_t u = neg_ ? -i : i; - initialize_from_integer( u ); - } - - basic_bignum(unsigned short u) - : values_{0,0} - { - neg_ = false; - initialize_from_integer( u ); - } - - basic_bignum(int i) - : values_{0,0} - { - neg_ = i < 0; - uint64_t u = neg_ ? -i : i; - initialize_from_integer( u ); - } - - basic_bignum(unsigned int u) - : values_{0,0} - { - neg_ = false; - initialize_from_integer( u ); - } - - basic_bignum(long i) - : values_{0,0} - { - neg_ = i < 0; - uint64_t u = neg_ ? -i : i; - initialize_from_integer( u ); - } - - basic_bignum(unsigned long u) - : values_{0,0} - { - neg_ = false; - initialize_from_integer( u ); - } - - basic_bignum(long long i) - : values_{0,0} - { - neg_ = i < 0; - uint64_t u = neg_ ? -i : i; - initialize_from_integer( u ); - } - - basic_bignum(unsigned long long u) - : values_{0,0} - { - neg_ = false; - initialize_from_integer( u ); - } - - explicit basic_bignum( double x ) - : values_{0,0} - { - bool neg = false; - - if ( x < 0 ) - { - neg = true; - x = -x; - } - basic_bignum v = 0; - - double values = (double)max_basic_type + 1.0; - basic_bignum factor = 1; - - while ( x >= 1 ) - { - uint64_t u = (uint64_t) std::fmod( x, values ); - v = v + factor* basic_bignum(u); - x /= values; - factor = factor*(basic_bignum( max_basic_type ) + basic_bignum(1)); - } - - if ( neg ) - { - v.neg_ = true; - } - initialize( v ); - } - - explicit basic_bignum(long double x) - : values_{0,0} - { - bool neg = false; - - if ( x < 0 ) - { - neg = true; - x = -x; - } - - basic_bignum v = 0; - - long double values = (long double)max_basic_type + 1.0; - basic_bignum factor = 1; - - while ( x >= 1.0 ) - { - uint64_t u = (uint64_t) std::fmod( x, values ); - v = v + factor* basic_bignum(u); - x /= values; - factor = factor*(basic_bignum( max_basic_type ) + basic_bignum(1)); - } - - if ( neg ) - { - v.neg_ = true; - } - initialize( v ); - } - - ~basic_bignum() - { - if ( dynamic_ ) - { - allocator().deallocate(data_, capacity_); - } - } - - size_t capacity() const { return dynamic_ ? capacity_ : 2; } - -// Operators - bool operator!() const - { - return length() == 0 ? true : false; - } - - basic_bignum operator-() const - { - basic_bignum v = *this; - v.neg_ = !v.neg_; - return v; - } - - basic_bignum& operator=( const basic_bignum& y ) - { - if ( this != &y ) - { - set_length( y.length() ); - neg_ = y.neg_; - if ( y.length() > 0 ) - { - std::memcpy( data_, y.data_, y.length()*sizeof(uint64_t) ); - } - } - return *this; - } - - basic_bignum& operator+=( const basic_bignum& y ) - { - if ( neg_ != y.neg_ ) - return *this -= -y; - uint64_t d; - uint64_t carry = 0; - - incr_length( (std::max)(y.length(), length()) + 1 ); - - for (size_t i = 0; i < length(); i++ ) - { - if ( i >= y.length() && carry == 0 ) - break; - d = data_[i] + carry; - carry = d < carry; - if ( i < y.length() ) - { - data_[i] = d + y.data_[i]; - if ( data_[i] < d ) - carry = 1; - } - else - data_[i] = d; - } - reduce(); - return *this; - } - - basic_bignum& operator-=( const basic_bignum& y ) - { - if ( neg_ != y.neg_ ) - return *this += -y; - if ( (!neg_ && y > *this) || (neg_ && y < *this) ) - return *this = -(y - *this); - uint64_t borrow = 0; - uint64_t d; - for (size_t i = 0; i < length(); i++ ) - { - if ( i >= y.length() && borrow == 0 ) - break; - d = data_[i] - borrow; - borrow = d > data_[i]; - if ( i < y.length()) - { - data_[i] = d - y.data_[i]; - if ( data_[i] > d ) - borrow = 1; - } - else - data_[i] = d; - } - reduce(); - return *this; - } - - basic_bignum& operator*=( int64_t y ) - { - *this *= uint64_t(y < 0 ? -y : y); - if ( y < 0 ) - neg_ = !neg_; - return *this; - } - - basic_bignum& operator*=( uint64_t y ) - { - size_t len0 = length(); - uint64_t hi; - uint64_t lo; - uint64_t dig = data_[0]; - uint64_t carry = 0; - - incr_length( length() + 1 ); - - size_t i = 0; - for (i = 0; i < len0; i++ ) - { - DDproduct( dig, y, hi, lo ); - data_[i] = lo + carry; - dig = data_[i+1]; - carry = hi + (data_[i] < lo); - } - data_[i] = carry; - reduce(); - return *this; - } - - basic_bignum& operator*=( basic_bignum y ) - { - if ( length() == 0 || y.length() == 0 ) - return *this = 0; - bool difSigns = neg_ != y.neg_; - if ( length() + y.length() == 2 ) // length() = y.length() = 1 - { - uint64_t a = data_[0], b = y.data_[0]; - data_[0] = a * b; - if ( data_[0] / a != b ) - { - set_length( 2 ); - DDproduct( a, b, data_[1], data_[0] ); - } - neg_ = difSigns; - return *this; - } - if ( length() == 1 ) // && y.length() > 1 - { - uint64_t digit = data_[0]; - *this = y; - *this *= digit; - } - else - { - if ( y.length() == 1 ) - *this *= y.data_[0]; - else - { - size_t lenProd = length() + y.length(), jA, jB; - uint64_t sumHi = 0, sumLo, hi, lo, - sumLo_old, sumHi_old, carry=0; - basic_bignum x = *this; - set_length( lenProd ); // Give *this length lenProd - - for (size_t i = 0; i < lenProd; i++ ) - { - sumLo = sumHi; - sumHi = carry; - carry = 0; - for ( jA=0; jA < x.length(); jA++ ) - { - jB = i - jA; - if ( jB >= 0 && jB < y.length() ) - { - DDproduct( x.data_[jA], y.data_[jB], hi, lo ); - sumLo_old = sumLo; - sumHi_old = sumHi; - sumLo += lo; - if ( sumLo < sumLo_old ) - sumHi++; - sumHi += hi; - carry += (sumHi < sumHi_old); - } - } - data_[i] = sumLo; - } - } - } - reduce(); - neg_ = difSigns; - return *this; - } - - basic_bignum& operator/=( const basic_bignum& divisor ) - { - basic_bignum r; - divide( divisor, *this, r, false ); - return *this; - } - - basic_bignum& operator%=( const basic_bignum& divisor ) - { - basic_bignum q; - divide( divisor, q, *this, true ); - return *this; - } - - basic_bignum& operator<<=( uint64_t k ) - { - size_t q = (size_t)(k / basic_type_bits); - if ( q ) // Increase length_ by q: - { - incr_length(length() + q); - for (size_t i = length(); i-- > 0; ) - data_[i] = ( i < q ? 0 : data_[i - q]); - k %= basic_type_bits; - } - if ( k ) // 0 < k < basic_type_bits: - { - uint64_t k1 = basic_type_bits - k; - uint64_t mask = (1 << k) - 1; - incr_length( length() + 1 ); - for (size_t i = length(); i-- > 0; ) - { - data_[i] <<= k; - if ( i > 0 ) - data_[i] |= (data_[i-1] >> k1) & mask; - } - } - reduce(); - return *this; - } - - basic_bignum& operator>>=(uint64_t k) - { - size_t q = (size_t)(k / basic_type_bits); - if ( q >= length() ) - { - set_length( 0 ); - return *this; - } - if (q > 0) - { - memmove( data_, data_+q, (size_t)((length() - q)*sizeof(uint64_t)) ); - set_length( length() - q ); - k %= basic_type_bits; - if ( k == 0 ) - { - reduce(); - return *this; - } - } - - size_t n = (size_t)(length() - 1); - int64_t k1 = basic_type_bits - k; - uint64_t mask = (1 << k) - 1; - for (size_t i = 0; i <= n; i++) - { - data_[i] >>= k; - if ( i < n ) - data_[i] |= ((data_[i+1] & mask) << k1); - } - reduce(); - return *this; - } - - basic_bignum& operator++() - { - *this += 1; - return *this; - } - - basic_bignum operator++(int) - { - basic_bignum old = *this; - ++(*this); - return old; - } - - basic_bignum& operator--() - { - *this -= 1; - return *this; - } - - basic_bignum operator--(int) - { - basic_bignum old = *this; - --(*this); - return old; - } - - basic_bignum& operator|=( const basic_bignum& a ) - { - if ( length() < a.length() ) - { - incr_length( a.length() ); - } - - const uint64_t* qBegin = a.begin(); - const uint64_t* q = a.end() - 1; - uint64_t* p = begin() + a.length() - 1; - - while ( q >= qBegin ) - { - *p-- |= *q--; - } - - reduce(); - - return *this; - } - - basic_bignum& operator^=( const basic_bignum& a ) - { - if ( length() < a.length() ) - { - incr_length( a.length() ); - } - - const uint64_t* qBegin = a.begin(); - const uint64_t* q = a.end() - 1; - uint64_t* p = begin() + a.length() - 1; - - while ( q >= qBegin ) - { - *p-- ^= *q--; - } - - reduce(); - - return *this; - } - - basic_bignum& operator&=( const basic_bignum& a ) - { - size_t old_length = length(); - - set_length( (std::min)( length(), a.length() ) ); - - const uint64_t* pBegin = begin(); - uint64_t* p = end() - 1; - const uint64_t* q = a.begin() + length() - 1; - - while ( p >= pBegin ) - { - *p-- &= *q--; - } - - if ( old_length > length() ) - { - memset( data_ + length(), 0, old_length - length() ); - } - - reduce(); - - return *this; - } - - explicit operator bool() const - { - return length() != 0 ? true : false; - } - - explicit operator int64_t() const - { - int64_t x = 0; - if ( length() > 0 ) - { - x = data_ [0]; - } - - return neg_ ? -x : x; - } - - explicit operator uint64_t() const - { - uint64_t u = 0; - if ( length() > 0 ) - { - u = data_ [0]; - } - - return u; - } - - explicit operator double() const - { - double x = 0.0; - double factor = 1.0; - double values = (double)max_basic_type + 1.0; - - const uint64_t* p = begin(); - const uint64_t* pEnd = end(); - while ( p < pEnd ) - { - x += *p*factor; - factor *= values; - ++p; - } - - return neg_ ? -x : x; - } - - explicit operator long double() const - { - long double x = 0.0; - long double factor = 1.0; - long double values = (long double)max_basic_type + 1.0; - - const uint64_t* p = begin(); - const uint64_t* pEnd = end(); - while ( p < pEnd ) - { - x += *p*factor; - factor *= values; - ++p; - } - - return neg_ ? -x : x; - } - - template - void dump(int& signum, std::vector& data) const - { - basic_bignum n(*this); - if (neg_) - { - signum = -1; - n = - n -1; - } - else - { - signum = 1; - } - basic_bignum divisor(256); - - while (n >= 256) - { - basic_bignum q; - basic_bignum r; - n.divide(divisor, q, r, true); - n = q; - data.push_back((uint8_t)(uint64_t)r); - } - if (n >= 0) - { - data.push_back((uint8_t)(uint64_t)n); - } - std::reverse(data.begin(),data.end()); - } - - template - void dump(std::basic_string& data) const - { - basic_bignum v(*this); - - int len = int(uint32_t(v.length()) * basic_bignum::basic_type_bits / 3) + 2; - data.resize(len); - - int n = len; - int i = 0; - // 1/3 > ln(2)/ln(10) - static uint64_t p10 = 1; - static uint64_t ip10 = 0; - - if ( v.length() == 0 ) - { - data[0] = '0'; - i = 1; - } - else - { - uint64_t r; - if ( p10 == 1 ) - { - while ( p10 <= (std::numeric_limits::max)()/10 ) - { - p10 *= 10; - ip10++; - } - } // p10 is max unsigned power of 10 - basic_bignum R; - basic_bignum LP10 = p10; // LP10 = p10 = ::pow(10, ip10) - if ( v.neg_ ) - { - data[0] = '-'; - i = 1; - } - do - { - v.divide( LP10, v, R, true ); - r = (R.length() ? R.data_[0] : 0); - for ( size_t j=0; j < ip10; j++ ) - { - data[--n] = char(r % 10 + '0'); - r /= 10; - if ( r + v.length() == 0 ) - break; - } - } while ( v.length() ); - while ( n < len ) - data[i++] = data[n++]; - } - data.resize(i); - } - - template - void dump_hex_string(std::basic_string& data) const - { - basic_bignum v(*this); - - int len = int(uint32_t(v.length()) * basic_bignum::basic_type_bits / 3) + 2; - data.resize(len); - - int n = len; - int i = 0; - // 1/3 > ln(2)/ln(10) - static uint64_t p10 = 1; - static uint64_t ip10 = 0; - - if ( v.length() == 0 ) - { - data[0] = '0'; - i = 1; - } - else - { - uint64_t r; - if ( p10 == 1 ) - { - while ( p10 <= (std::numeric_limits::max)()/16 ) - { - p10 *= 16; - ip10++; - } - } // p10 is max unsigned power of 16 - basic_bignum R; - basic_bignum LP10 = p10; // LP10 = p10 = ::pow(16, ip10) - if ( v.neg_ ) - { - data[0] = '-'; - i = 1; - } - do - { - v.divide( LP10, v, R, true ); - r = (R.length() ? R.data_[0] : 0); - for ( size_t j=0; j < ip10; j++ ) - { - uint8_t c = r % 16; - data[--n] = (c < 10) ? ('0' + c) : ('A' - 10 + c); - r /= 16; - if ( r + v.length() == 0 ) - break; - } - } while ( v.length() ); - while ( n < len ) - data[i++] = data[n++]; - } - data.resize(i); - } - -// Global Operators - - friend bool operator==( const basic_bignum& x, const basic_bignum& y ) - { - return x.compare(y) == 0 ? true : false; - } - - friend bool operator==( const basic_bignum& x, int y ) - { - return x.compare(y) == 0 ? true : false; - } - - friend bool operator!=( const basic_bignum& x, const basic_bignum& y ) - { - return x.compare(y) != 0 ? true : false; - } - - friend bool operator!=( const basic_bignum& x, int y ) - { - return x.compare(basic_bignum(y)) != 0 ? true : false; - } - - friend bool operator<( const basic_bignum& x, const basic_bignum& y ) - { - return x.compare(y) < 0 ? true : false; - } - - friend bool operator<( const basic_bignum& x, int64_t y ) - { - return x.compare(y) < 0 ? true : false; - } - - friend bool operator>( const basic_bignum& x, const basic_bignum& y ) - { - return x.compare(y) > 0 ? true : false; - } - - friend bool operator>( const basic_bignum& x, int y ) - { - return x.compare(basic_bignum(y)) > 0 ? true : false; - } - - friend bool operator<=( const basic_bignum& x, const basic_bignum& y ) - { - return x.compare(y) <= 0 ? true : false; - } - - friend bool operator<=( const basic_bignum& x, int y ) - { - return x.compare(y) <= 0 ? true : false; - } - - friend bool operator>=( const basic_bignum& x, const basic_bignum& y ) - { - return x.compare(y) >= 0 ? true : false; - } - - friend bool operator>=( const basic_bignum& x, int y ) - { - return x.compare(y) >= 0 ? true : false; - } - - friend basic_bignum operator+( basic_bignum x, const basic_bignum& y ) - { - return x += y; - } - - friend basic_bignum operator+( basic_bignum x, int64_t y ) - { - return x += y; - } - - friend basic_bignum operator-( basic_bignum x, const basic_bignum& y ) - { - return x -= y; - } - - friend basic_bignum operator-( basic_bignum x, int64_t y ) - { - return x -= y; - } - - friend basic_bignum operator*( int64_t x, const basic_bignum& y ) - { - return basic_bignum(y) *= x; - } - - friend basic_bignum operator*( basic_bignum x, const basic_bignum& y ) - { - return x *= y; - } - - friend basic_bignum operator*( basic_bignum x, int64_t y ) - { - return x *= y; - } - - friend basic_bignum operator/( basic_bignum x, const basic_bignum& y ) - { - return x /= y; - } - - friend basic_bignum operator/( basic_bignum x, int y ) - { - return x /= y; - } - - friend basic_bignum operator%( basic_bignum x, const basic_bignum& y ) - { - return x %= y; - } - - friend basic_bignum operator<<( basic_bignum u, unsigned k ) - { - return u <<= k; - } - - friend basic_bignum operator<<( basic_bignum u, int k ) - { - return u <<= k; - } - - friend basic_bignum operator>>( basic_bignum u, unsigned k ) - { - return u >>= k; - } - - friend basic_bignum operator>>( basic_bignum u, int k ) - { - return u >>= k; - } - - friend basic_bignum operator|( basic_bignum x, const basic_bignum& y ) - { - return x |= y; - } - - friend basic_bignum operator|( basic_bignum x, int y ) - { - return x |= y; - } - - friend basic_bignum operator|( basic_bignum x, unsigned y ) - { - return x |= y; - } - - friend basic_bignum operator^( basic_bignum x, const basic_bignum& y ) - { - return x ^= y; - } - - friend basic_bignum operator^( basic_bignum x, int y ) - { - return x ^= y; - } - - friend basic_bignum operator^( basic_bignum x, unsigned y ) - { - return x ^= y; - } - - friend basic_bignum operator&( basic_bignum x, const basic_bignum& y ) - { - return x &= y; - } - - friend basic_bignum operator&( basic_bignum x, int y ) - { - return x &= y; - } - - friend basic_bignum operator&( basic_bignum x, unsigned y ) - { - return x &= y; - } - - friend basic_bignum abs( const basic_bignum& a ) - { - if ( a.neg_ ) - { - return -a; - } - return a; - } - - friend basic_bignum power( basic_bignum x, unsigned n ) - { - basic_bignum y = 1; - - while ( n ) - { - if ( n & 1 ) - { - y *= x; - } - x *= x; - n >>= 1; - } - - return y; - } - - friend basic_bignum sqrt( const basic_bignum& a ) - { - basic_bignum x = a; - basic_bignum b = a; - basic_bignum q; - - b <<= 1; - while ( b >>= 2, b > 0 ) - { - x >>= 1; - } - while ( x > (q = a/x) + 1 || x < q - 1 ) - { - x += q; - x >>= 1; - } - return x < q ? x : q; - } - - template - friend std::basic_ostream& operator<<(std::basic_ostream& os, const basic_bignum& v) - { - std::basic_string s; - v.dump(s); - os << s; - - return os; - } - - int compare( const basic_bignum& y ) const - { - if ( neg_ != y.neg_ ) - return y.neg_ - neg_; - int code = 0; - if ( length() == 0 && y.length() == 0 ) - code = 0; - else if ( length() < y.length() ) - code = -1; - else if ( length() > y.length() ) - code = +1; - else - { - for (size_t i = length(); i-- > 0; ) - { - if (data_[i] > y.data_[i]) - { - code = 1; - break; - } - else if (data_[i] < y.data_[i]) - { - code = -1; - break; - } - } - } - return neg_ ? -code : code; - } - -private: - void DDproduct( uint64_t A, uint64_t B, - uint64_t& hi, uint64_t& lo ) const - // Multiplying two digits: (hi, lo) = A * B - { - uint64_t hiA = A >> basic_type_halfBits, loA = A & r_mask, - hiB = B >> basic_type_halfBits, loB = B & r_mask, - mid1, mid2, old; - - lo = loA * loB; - hi = hiA * hiB; - mid1 = loA * hiB; - mid2 = hiA * loB; - old = lo; - lo += mid1 << basic_type_halfBits; - hi += (lo < old) + (mid1 >> basic_type_halfBits); - old = lo; - lo += mid2 << basic_type_halfBits; - hi += (lo < old) + (mid2 >> basic_type_halfBits); - } - - uint64_t DDquotient( uint64_t A, uint64_t B, uint64_t d ) const - // Divide double word (A, B) by d. Quotient = (qHi, qLo) - { - uint64_t left, middle, right, qHi, qLo, x, dLo1, - dHi = d >> basic_type_halfBits, dLo = d & r_mask; - qHi = A/(dHi + 1); - // This initial guess of qHi may be too small. - middle = qHi * dLo; - left = qHi * dHi; - x = B - (middle << basic_type_halfBits); - A -= (middle >> basic_type_halfBits) + left + (x > B); - B = x; - dLo1 = dLo << basic_type_halfBits; - // Increase qHi if necessary: - while ( A > dHi || (A == dHi && B >= dLo1) ) - { - x = B - dLo1; - A -= dHi + (x > B); - B = x; - qHi++; - } - qLo = ((A << basic_type_halfBits) | (B >> basic_type_halfBits))/(dHi + 1); - // This initial guess of qLo may be too small. - right = qLo * dLo; - middle = qLo * dHi; - x = B - right; - A -= (x > B); - B = x; - x = B - (middle << basic_type_halfBits); - A -= (middle >> basic_type_halfBits) + (x > B); - B = x; - // Increase qLo if necessary: - while ( A || B >= d ) - { - x = B - d; - A -= (x > B); - B = x; - qLo++; - } - return (qHi << basic_type_halfBits) + qLo; - } - - void subtractmul( uint64_t* a, uint64_t* b, size_t n, uint64_t& q ) const - // a -= q * b: b in n positions; correct q if necessary - { - uint64_t hi, lo, d, carry = 0; - size_t i; - for ( i = 0; i < n; i++ ) - { - DDproduct( b[i], q, hi, lo ); - d = a[i]; - a[i] -= lo; - if ( a[i] > d ) - carry++; - d = a[i + 1]; - a[i + 1] -= hi + carry; - carry = a[i + 1] > d; - } - if ( carry ) // q was too large - { - q--; - carry = 0; - for ( i = 0; i < n; i++ ) - { - d = a[i] + carry; - carry = d < carry; - a[i] = d + b[i]; - if ( a[i] < d ) - carry = 1; - } - a[n] = 0; - } - } - - int normalize( basic_bignum& denom, basic_bignum& num, int& x ) const - { - size_t r = denom.length() - 1; - uint64_t y = denom.data_[r]; - - x = 0; - while ( (y & l_bit) == 0 ) - { - y <<= 1; - x++; - } - denom <<= x; - num <<= x; - if ( r > 0 && denom.data_[r] < denom.data_[r-1] ) - { - denom *= max_basic_type; - num *= max_basic_type; - return 1; - } - return 0; - } - - void unnormalize( basic_bignum& rem, int x, int secondDone ) const - { - if ( secondDone ) - { - rem /= max_basic_type; - } - if ( x > 0 ) - { - rem >>= x; - } - else - { - rem.reduce(); - } - } - - void divide( basic_bignum denom, basic_bignum& quot, basic_bignum& rem, bool remDesired ) const - { - if ( denom.length() == 0 ) - { - throw std::runtime_error( "Zero divide." ); - } - bool quot_neg = neg_ ^ denom.neg_; - bool rem_neg = neg_; - int x = 0; - basic_bignum num = *this; - num.neg_ = denom.neg_ = false; - if ( num < denom ) - { - quot = uint64_t(0); - rem = num; - rem.neg_ = rem_neg; - return; - } - if ( denom.length() == 1 && num.length() == 1 ) - { - quot = uint64_t( num.data_[0]/denom.data_[0] ); - rem = uint64_t( num.data_[0]%denom.data_[0] ); - quot.neg_ = quot_neg; - rem.neg_ = rem_neg; - return; - } - else if (denom.length() == 1 && (denom.data_[0] & l_mask) == 0 ) - { - // Denominator fits into a half word - uint64_t divisor = denom.data_[0], dHi = 0, - q1, r, q2, dividend; - quot.set_length(length()); - for (size_t i=length(); i-- > 0; ) - { - dividend = (dHi << basic_type_halfBits) | (data_[i] >> basic_type_halfBits); - q1 = dividend/divisor; - r = dividend % divisor; - dividend = (r << basic_type_halfBits) | (data_[i] & r_mask); - q2 = dividend/divisor; - dHi = dividend % divisor; - quot.data_[i] = (q1 << basic_type_halfBits) | q2; - } - quot.reduce(); - rem = dHi; - quot.neg_ = quot_neg; - rem.neg_ = rem_neg; - return; - } - basic_bignum num0 = num, denom0 = denom; - int second_done = normalize(denom, num, x); - size_t l = denom.length() - 1; - size_t n = num.length() - 1; - quot.set_length(n - l); - for (size_t i=quot.length(); i-- > 0; ) - quot.data_[i] = 0; - rem = num; - if ( rem.data_[n] >= denom.data_[l] ) - { - rem.incr_length(rem.length() + 1); - n++; - quot.incr_length(quot.length() + 1); - } - uint64_t d = denom.data_[l]; - for ( size_t k = n; k > l; k-- ) - { - uint64_t q = DDquotient(rem.data_[k], rem.data_[k-1], d); - subtractmul( rem.data_ + k - l - 1, denom.data_, l + 1, q ); - quot.data_[k - l - 1] = q; - } - quot.reduce(); - quot.neg_ = quot_neg; - if ( remDesired ) - { - unnormalize(rem, x, second_done); - rem.neg_ = rem_neg; - } - } - - size_t length() const { return length_; } - uint64_t* begin() { return data_; } - const uint64_t* begin() const { return data_; } - uint64_t* end() { return data_ + length_; } - const uint64_t* end() const { return data_ + length_; } - - void set_length(size_t n) - { - length_ = n; - if ( length_ > capacity() ) - { - if ( dynamic_ ) - { - delete[] data_; - } - capacity_ = round_up(length_); - data_ = allocator().allocate(capacity_); - dynamic_ = true; - } - } - - size_t round_up(size_t i) const // Find suitable new block size - { - return (i/word_length + 1) * word_length; - } - - template - typename std::enable_if::value && - !std::is_signed::value && - sizeof(T) <= sizeof(int64_t),void>::type - initialize_from_integer(T u) - { - data_ = values_; - dynamic_ = false; - length_ = u != 0 ? 1 : 0; - - data_ [0] = u; - } - - template - typename std::enable_if::value && - !std::is_signed::value && - sizeof(int64_t) < sizeof(T) && - sizeof(T) <= sizeof(int64_t)*2, void>::type - initialize_from_integer(T u) - { - data_ = values_; - dynamic_ = false; - length_ = u != 0 ? 2 : 0; - - data_[0] = uint64_t(u & max_basic_type); - u >>= basic_type_bits; - data_[1] = uint64_t(u & max_basic_type); - } - - void initialize( const basic_bignum& n ) - { - neg_ = n.neg_; - length_ = n.length_; - - if ( length_ <= 2 ) - { - data_ = values_; - dynamic_ = false; - values_ [0] = n.data_ [0]; - values_ [1] = n.data_ [1]; - } - else - { - capacity_ = round_up( length_ ); - data_ = allocator().allocate(capacity_); - dynamic_ = true; - if ( length_ > 0 ) - { - std::memcpy( data_, n.data_, length_*sizeof(uint64_t) ); - } - reduce(); - } - } - - void initialize(basic_bignum&& other) - { - neg_ = other.neg_; - length_ = other.length_; - dynamic_ = other.dynamic_; - - if (other.dynamic_) - { - capacity_ = other.capacity_; - data_ = other.data_; - - other.data_ = other.values_; - other.dynamic_ = false; - other.length_ = 0; - other.neg_ = false; - } - else - { - values_[0] = other.data_[0]; - values_[1] = other.data_[1]; - data_ = values_; - } - } - - void reduce() - { - uint64_t* p = end() - 1; - uint64_t* pBegin = begin(); - while ( p >= pBegin ) - { - if ( *p ) - { - break; - } - --length_; - --p; - } - if ( length_ == 0 ) - { - neg_ = false; - } - } - - void incr_length( size_t len_new ) - { - size_t len_old = length_; - length_ = len_new; // length_ > len_old - - if ( length_ > capacity() ) - { - size_t capacity_new = round_up( length_ ); - - uint64_t* data_old = data_; - - data_ = allocator().allocate(capacity_new); - - if ( len_old > 0 ) - { - std::memcpy( data_, data_old, len_old*sizeof(uint64_t) ); - } - if ( dynamic_ ) - { - allocator().deallocate(data_old,capacity_); - } - capacity_ = capacity_new; - dynamic_ = true; - } - - if ( length_ > len_old ) - { - memset( data_+len_old, 0, (length_ - len_old)*sizeof(uint64_t) ); - } - } - - template - void initialize(const CharT* data, size_t length) - { - bool neg; - if (*data == '-') - { - neg = true; - data++; - --length; - } - else - { - neg = false; - } - - basic_bignum v = 0; - for (size_t i = 0; i < length; i++) - { - CharT c = data[i]; - switch (c) - { - case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8': case '9': - v = (v * 10) + (uint64_t)(c - '0'); - break; - default: - throw std::runtime_error(std::string("Invalid digit ") + "\'" + (char)c + "\'"); - } - } - - if ( neg ) - { - v.neg_ = true; - } - initialize(std::move(v)); - } - - template - void initialize(const CharT* data, size_t length, uint8_t base) - { - if (!(base >= 2 && base <= 16)) - { - throw std::runtime_error("Unsupported base"); - } - - bool neg; - if (*data == '-') - { - neg = true; - data++; - --length; - } - else - { - neg = false; - } - - basic_bignum v = 0; - for (size_t i = 0; i < length; i++) - { - CharT c = data[i]; - uint64_t d; - switch (c) - { - case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8': case '9': - d = (uint64_t)(c - '0'); - break; - case 'a':case 'b':case 'c':case 'd':case 'e':case 'f': - d = (uint64_t)(c - ('a' - 10)); - break; - case 'A':case 'B':case 'C':case 'D':case 'E':case 'F': - d = (uint64_t)(c - ('A' - 10)); - break; - default: - throw std::runtime_error(std::string("Invalid digit in base ") + std::to_string(base) + ": \'" + (char)c + "\'"); - } - if (d >= base) - { - throw std::runtime_error(std::string("Invalid digit in base ") + std::to_string(base) + ": \'" + (char)c + "\'"); - } - v = (v * base) + d; - } - - if ( neg ) - { - v.neg_ = true; - } - initialize(std::move(v)); - } -}; - -typedef basic_bignum> bignum; - -} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/byte_string.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/byte_string.hpp deleted file mode 100644 index 8d638e813a..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/byte_string.hpp +++ /dev/null @@ -1,710 +0,0 @@ -// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_BYTE_STRING_HPP -#define JSONCONS_BYTE_STRING_HPP - -#include -#include -#include -#include -#include // std::memcmp -#include // std::allocator -#include -#include -#include -#include // std::move -#include -#include - -namespace jsoncons { - -// Algorithms - -namespace detail { -template -typename std::enable_if::value_type,uint8_t>::value,size_t>::type -encode_base64_generic(InputIt first, InputIt last, const char alphabet[65], Container& result) -{ - size_t count = 0; - unsigned char a3[3]; - unsigned char a4[4]; - unsigned char fill = alphabet[64]; - int i = 0; - int j = 0; - - while (first != last) - { - a3[i++] = *first++; - if (i == 3) - { - a4[0] = (a3[0] & 0xfc) >> 2; - a4[1] = ((a3[0] & 0x03) << 4) + ((a3[1] & 0xf0) >> 4); - a4[2] = ((a3[1] & 0x0f) << 2) + ((a3[2] & 0xc0) >> 6); - a4[3] = a3[2] & 0x3f; - - for (i = 0; i < 4; i++) - { - result.push_back(alphabet[a4[i]]); - ++count; - } - i = 0; - } - } - - if (i > 0) - { - for (j = i; j < 3; ++j) - { - a3[j] = 0; - } - - a4[0] = (a3[0] & 0xfc) >> 2; - a4[1] = ((a3[0] & 0x03) << 4) + ((a3[1] & 0xf0) >> 4); - a4[2] = ((a3[1] & 0x0f) << 2) + ((a3[2] & 0xc0) >> 6); - - for (j = 0; j < i + 1; ++j) - { - result.push_back(alphabet[a4[j]]); - ++count; - } - - if (fill != 0) - { - while (i++ < 3) - { - result.push_back(fill); - ++count; - } - } - } - - return count; -} - -// Hack to support vs2015 -template -typename std::enable_if::type -decode_base64_generic(InputIt first, InputIt last, - const uint8_t reverse_alphabet[256], - F f, - Container& result) -{ - uint8_t a4[4], a3[3]; - uint8_t i = 0; - uint8_t j = 0; - - while (first != last && *first != '=') - { - if (!f(*first)) - { - JSONCONS_THROW(json_runtime_error("Cannot decode encoded byte string")); - } - - a4[i++] = *first++; - if (i == 4) - { - for (i = 0; i < 4; ++i) - { - a4[i] = reverse_alphabet[a4[i]]; - } - - a3[0] = (a4[0] << 2) + ((a4[1] & 0x30) >> 4); - a3[1] = ((a4[1] & 0xf) << 4) + ((a4[2] & 0x3c) >> 2); - a3[2] = ((a4[2] & 0x3) << 6) + a4[3]; - - for (i = 0; i < 3; i++) - { - result.push_back(a3[i]); - } - i = 0; - } - } - - if (i > 0) - { - for (j = 0; j < i; ++j) - { - a4[j] = reverse_alphabet[a4[j]]; - } - - a3[0] = (a4[0] << 2) + ((a4[1] & 0x30) >> 4); - a3[1] = ((a4[1] & 0xf) << 4) + ((a4[2] & 0x3c) >> 2); - - for (j = 0; j < i - 1; ++j) - { - result.push_back(a3[j]); - } - } -} - -} - -template -typename std::enable_if::value_type,uint8_t>::value,size_t>::type -encode_base16(InputIt first, InputIt last, Container& result) -{ - static constexpr char characters[] = "0123456789ABCDEF"; - - for (auto it = first; it != last; ++it) - { - uint8_t c = *it; - result.push_back(characters[c >> 4]); - result.push_back(characters[c & 0xf]); - } - return (last-first)*2; -} - -template -typename std::enable_if::value_type,uint8_t>::value,size_t>::type -encode_base64url(InputIt first, InputIt last, Container& result) -{ - static constexpr char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789-_" - "\0"; - return detail::encode_base64_generic(first, last, alphabet, result); -} - -template -typename std::enable_if::value_type,uint8_t>::value,size_t>::type -encode_base64(InputIt first, InputIt last, Container& result) -{ - static constexpr char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789+/" - "="; - return detail::encode_base64_generic(first, last, alphabet, result); -} - -template -bool is_base64(Char c) -{ - return (c >= 0 && c < 128) && (isalnum((int)c) || c == '+' || c == '/'); -} - -template -bool is_base64url(Char c) -{ - return (c >= 0 && c < 128) && (isalnum((int)c) || c == '-' || c == '_'); -} - -inline -static bool is_base64url(int c) -{ - return isalnum(c) || c == '-' || c == '_'; -} - -// decode - -// Hack to support vs2015 -template -typename std::enable_if::type -decode_base64url(InputIt first, InputIt last, Container& result) -{ - static constexpr uint8_t reverse_alphabet[256] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 62, 0xff, 0xff, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0xff, 0xff, 0xff, 0xff, 63, - 0xff, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff - }; - - - jsoncons::detail::decode_base64_generic(first, last, reverse_alphabet, - is_base64url::value_type>, - result); -} - -// Hack to support vs2015 -template -typename std::enable_if::type -decode_base64(InputIt first, InputIt last, Container& result) -{ - static constexpr uint8_t reverse_alphabet[256] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 62, 0xff, 0xff, 0xff, 63, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff - }; - jsoncons::detail::decode_base64_generic(first, last, reverse_alphabet, - is_base64::value_type>, - result); -} - -// Hack to support vs2015 -template -typename std::enable_if::type -decode_base16(InputIt first, InputIt last, Container& result) -{ - size_t len = std::distance(first,last); - if (len & 1) - { - JSONCONS_THROW(json_runtime_error("Cannot decode encoded base16 string - odd length")); - } - - InputIt it = first; - while (it != last) - { - uint8_t val; - auto a = *it++; - if (a >= '0' && a <= '9') - { - val = (a - '0') << 4; - } - else if ((a | 0x20) >= 'a' && (a | 0x20) <= 'f') - { - val = ((a | 0x20) - 'a' + 10) << 4; - } - else - { - JSONCONS_THROW(json_runtime_error("Not a hex digit. Cannot decode encoded base16 string")); - } - - auto b = *it++; - if (b >= '0' && b <= '9') - { - val |= (b - '0'); - } - else if ((b | 0x20) >= 'a' && (b | 0x20) <= 'f') - { - val |= ((b | 0x20) - 'a' + 10); - } - else - { - JSONCONS_THROW(json_runtime_error("Not a hex digit. Cannot decode encoded base16 string")); - } - - result.push_back(val); - } -} - -struct byte_traits -{ - typedef uint8_t char_type; - - static constexpr int eof() - { - return std::char_traits::eof(); - } - - static int compare(const char_type* s1, const char_type* s2, std::size_t count) - { - return std::memcmp(s1,s2,count); - } -}; - -// basic_byte_string - -template -class basic_byte_string; - -// byte_string_view -class byte_string_view -{ - const uint8_t* data_; - size_t length_; -public: - typedef byte_traits traits_type; - - typedef const uint8_t* const_iterator; - typedef const uint8_t* iterator; - typedef std::size_t size_type; - typedef uint8_t value_type; - - byte_string_view() - : data_(nullptr), length_(0) - { - } - - byte_string_view(const uint8_t* data, size_t length) - : data_(data), length_(length) - { - } - - byte_string_view(const byte_string_view&) = default; - - byte_string_view(byte_string_view&&) = default; - - byte_string_view& operator=(const byte_string_view&) = default; - - byte_string_view& operator=(byte_string_view&&) = default; - - const uint8_t* data() const - { - return data_; - } - - size_t length() const - { - return length_; - } - - size_t size() const - { - return length_; - } - - // iterator support - const_iterator begin() const noexcept - { - return data_; - } - const_iterator end() const noexcept - { - return data_ + length_; - } - - uint8_t operator[](size_type pos) const - { - return data_[pos]; - } - - int compare(const byte_string_view& s) const - { - const int rc = traits_type::compare(data_, s.data(), (std::min)(length_, s.length())); - return rc != 0 ? rc : (length_ == s.length() ? 0 : length_ < s.length() ? -1 : 1); - } - - template - int compare(const basic_byte_string& s) const - { - const int rc = traits_type::compare(data_, s.data(), (std::min)(length_, s.length())); - return rc != 0 ? rc : (length_ == s.length() ? 0 : length_ < s.length() ? -1 : 1); - } - - template - friend std::basic_ostream& operator<<(std::basic_ostream& os, const byte_string_view& o) - { - std::basic_ostringstream ss; - ss.flags(std::ios::hex); - ss.precision(2); - ss.width(2); - ss.fill('0'); - - for (auto b : o) - { - ss << (int)b; - } - os << ss.str(); - return os; - } -}; - -// basic_byte_string -template > -class basic_byte_string -{ - std::vector data_; -public: - typedef byte_traits traits_type; - - typedef typename std::vector::const_iterator const_iterator; - typedef typename std::vector::const_iterator iterator; - typedef std::size_t size_type; - typedef uint8_t value_type; - - basic_byte_string() = default; - - explicit basic_byte_string(const Allocator& alloc) - : data_(alloc) - { - } - - basic_byte_string(std::initializer_list init) - : data_(std::move(init)) - { - } - - basic_byte_string(std::initializer_list init, const Allocator& alloc) - : data_(std::move(init), alloc) - { - } - - explicit basic_byte_string(const byte_string_view& v) - : data_(v.begin(),v.end()) - { - } - - basic_byte_string(const basic_byte_string& v) - : data_(v.data_) - { - } - - basic_byte_string(basic_byte_string&& v) - { - data_.swap(v.data_); - } - - basic_byte_string(const byte_string_view& v, const Allocator& alloc) - : data_(v.begin(),v.end(),alloc) - { - } - - basic_byte_string(const char* s) - { - while (*s) - { - data_.push_back(*s++); - } - } - - basic_byte_string(const uint8_t* data, size_t length) - : data_(data, data+length) - { - } - - basic_byte_string& operator=(const basic_byte_string& s) = default; - - basic_byte_string& operator=(basic_byte_string&& s) = default; - - operator byte_string_view() const noexcept - { - return byte_string_view(data(),length()); - } - - void reserve(size_t new_cap) - { - data_.reserve(new_cap); - } - - void push_back(uint8_t b) - { - data_.push_back(b); - } - - void assign(const uint8_t* s, size_t count) - { - data_.clear(); - data_.insert(s, s+count); - } - - void append(const uint8_t* s, size_t count) - { - data_.insert(s, s+count); - } - - void clear() - { - data_.clear(); - } - - uint8_t operator[](size_type pos) const - { - return data_[pos]; - } - - // iterator support - const_iterator begin() const noexcept - { - return data_.begin(); - } - const_iterator end() const noexcept - { - return data_.end(); - } - - const uint8_t* data() const - { - return data_.data(); - } - - size_t size() const - { - return data_.size(); - } - - size_t length() const - { - return data_.size(); - } - - int compare(const byte_string_view& s) const - { - const int rc = traits_type::compare(data(), s.data(), (std::min)(length(), s.length())); - return rc != 0 ? rc : (length() == s.length() ? 0 : length() < s.length() ? -1 : 1); - } - - int compare(const basic_byte_string& s) const - { - const int rc = traits_type::compare(data(), s.data(), (std::min)(length(), s.length())); - return rc != 0 ? rc : (length() == s.length() ? 0 : length() < s.length() ? -1 : 1); - } - - template - friend std::basic_ostream& operator<<(std::basic_ostream& os, const basic_byte_string& o) - { - os << byte_string_view(o); - return os; - } -}; - -// == -inline -bool operator==(const byte_string_view& lhs, const byte_string_view& rhs) -{ - return lhs.compare(rhs) == 0; -} -template -bool operator==(const byte_string_view& lhs, const basic_byte_string& rhs) -{ - return lhs.compare(rhs) == 0; -} -template -bool operator==(const basic_byte_string& lhs, const byte_string_view& rhs) -{ - return rhs.compare(lhs) == 0; -} -template -bool operator==(const basic_byte_string& lhs, const basic_byte_string& rhs) -{ - return rhs.compare(lhs) == 0; -} - -// != - -inline -bool operator!=(const byte_string_view& lhs, const byte_string_view& rhs) -{ - return lhs.compare(rhs) != 0; -} -template -bool operator!=(const byte_string_view& lhs, const basic_byte_string& rhs) -{ - return lhs.compare(rhs) != 0; -} -template -bool operator!=(const basic_byte_string& lhs, const byte_string_view& rhs) -{ - return rhs.compare(lhs) != 0; -} -template -bool operator!=(const basic_byte_string& lhs, const basic_byte_string& rhs) -{ - return rhs.compare(lhs) != 0; -} - -// <= - -inline -bool operator<=(const byte_string_view& lhs, const byte_string_view& rhs) -{ - return lhs.compare(rhs) <= 0; -} -template -bool operator<=(const byte_string_view& lhs, const basic_byte_string& rhs) -{ - return lhs.compare(rhs) <= 0; -} -template -bool operator<=(const basic_byte_string& lhs, const byte_string_view& rhs) -{ - return rhs.compare(lhs) >= 0; -} -template -bool operator<=(const basic_byte_string& lhs, const basic_byte_string& rhs) -{ - return rhs.compare(lhs) >= 0; -} - -// < - -inline -bool operator<(const byte_string_view& lhs, const byte_string_view& rhs) -{ - return lhs.compare(rhs) < 0; -} -template -bool operator<(const byte_string_view& lhs, const basic_byte_string& rhs) -{ - return lhs.compare(rhs) < 0; -} -template -bool operator<(const basic_byte_string& lhs, const byte_string_view& rhs) -{ - return rhs.compare(lhs) > 0; -} -template -bool operator<(const basic_byte_string& lhs, const basic_byte_string& rhs) -{ - return rhs.compare(lhs) > 0; -} - -// >= - -inline -bool operator>=(const byte_string_view& lhs, const byte_string_view& rhs) -{ - return lhs.compare(rhs) >= 0; -} -template -bool operator>=(const byte_string_view& lhs, const basic_byte_string& rhs) -{ - return lhs.compare(rhs) >= 0; -} -template -bool operator>=(const basic_byte_string& lhs, const byte_string_view& rhs) -{ - return rhs.compare(lhs) <= 0; -} -template -bool operator>=(const basic_byte_string& lhs, const basic_byte_string& rhs) -{ - return rhs.compare(lhs) <= 0; -} - -// > - -inline -bool operator>(const byte_string_view& lhs, const byte_string_view& rhs) -{ - return lhs.compare(rhs) > 0; -} -template -bool operator>(const byte_string_view& lhs, const basic_byte_string& rhs) -{ - return lhs.compare(rhs) > 0; -} -template -bool operator>(const basic_byte_string& lhs, const byte_string_view& rhs) -{ - return rhs.compare(lhs) < 0; -} -template -bool operator>(const basic_byte_string& lhs, const basic_byte_string& rhs) -{ - return rhs.compare(lhs) < 0; -} - -typedef basic_byte_string> byte_string; - - -} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/config/binary_detail.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/config/binary_detail.hpp deleted file mode 100644 index 9b94906982..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/config/binary_detail.hpp +++ /dev/null @@ -1,547 +0,0 @@ -// Copyright 2017 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_CONFIG_BINARY_DETAIL_HPP -#define JSONCONS_CONFIG_BINARY_DETAIL_HPP - -#include -#include -#include -#include // std::memcpy -#include -#include // std::enable_if - -#if defined(__apple_build_version__) && ((__clang_major__ < 8) || ((__clang_major__ == 8) && (__clang_minor__ < 1))) -#define APPLE_MISSING_INTRINSICS 1 -#endif - -// The definitions below follow the definitions in compiler_support_p.h, https://github.com/01org/tinycbor -// MIT license - -#ifdef __F16C__ -# include -#endif - -#ifndef __has_builtin -# define __has_builtin(x) 0 -#endif - -#if (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 403)) || \ - (__has_builtin(__builtin_bswap64) && __has_builtin(__builtin_bswap32)) -# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ -# define JSONCONS_BE64_TO_H __builtin_bswap64 -# define JSONCONS_H_TO_BE64 __builtin_bswap64 -# define JSONCONS_BE32_TO_H __builtin_bswap32 -# define JSONCONS_H_TO_BE32 __builtin_bswap32 -# ifdef __INTEL_COMPILER -# define JSONCONS_BE16_TO_H _bswap16 -# define JSONCONS_H_TO_BE16 _bswap16 -# elif (__GNUC__ * 100 + __GNUC_MINOR__ >= 608) || __has_builtin(__builtin_bswap16) -# define JSONCONS_BE16_TO_H __builtin_bswap16 -# define JSONCONS_H_TO_BE16 __builtin_bswap16 -# else -# define JSONCONS_BE16_TO_H(x) (((uint16_t)x >> 8) | ((uint16_t)x << 8)) -# define JSONCONS_H_TO_BE16 JSONCONS_BE16_TO_H -# endif -# define JSONCONS_LE64_TO_H -# define JSONCONS_H_TO_LE64 -# define JSONCONS_LE32_TO_H -# define JSONCONS_H_TO_LE32 -# define JSONCONS_LE16_TO_H -# define JSONCONS_H_TO_LE16 -# else -# define JSONCONS_LE64_TO_H __builtin_bswap64 -# define JSONCONS_H_TO_LE64 __builtin_bswap64 -# define JSONCONS_LE32_TO_H __builtin_bswap32 -# define JSONCONS_H_TO_LE32 __builtin_bswap32 -# ifdef __INTEL_COMPILER -# define JSONCONS_LE16_TO_H _bswap16 -# define JSONCONS_H_TO_LE16 _bswap16 -# elif (__GNUC__ * 100 + __GNUC_MINOR__ >= 608) || __has_builtin(__builtin_bswap16) -# define JSONCONS_LE16_TO_H __builtin_bswap16 -# define JSONCONS_H_TO_LE16 __builtin_bswap16 -# else -# define JSONCONS_LE16_TO_H(x) (((uint16_t)x >> 8) | ((uint16_t)x << 8)) -# define JSONCONS_H_TO_LE16 JSONCONS_LE16_TO_H -# endif -# define JSONCONS_BE64_TO_H -# define JSONCONS_H_TO_BE64 -# define JSONCONS_BE32_TO_H -# define JSONCONS_H_TO_BE32 -# define JSONCONS_BE16_TO_H -# define JSONCONS_H_TO_BE16 -# endif -#elif defined(__sun) -# include -#elif defined(_MSC_VER) -/* MSVC, which implies Windows, which implies little-endian and sizeof(long) == 4 */ -# define JSONCONS_BE64_TO_H _byteswap_uint64 -# define JSONCONS_H_TO_BE64 _byteswap_uint64 -# define JSONCONS_BE32_TO_H _byteswap_ulong -# define JSONCONS_H_TO_BE32 _byteswap_ulong -# define JSONCONS_BE16_TO_H _byteswap_ushort -# define JSONCONS_H_TO_BE16 _byteswap_ushort -# define JSONCONS_LE64_TO_H -# define JSONCONS_H_TO_LE64 -# define JSONCONS_LE32_TO_H -# define JSONCONS_H_TO_LE32 -# define JSONCONS_LE16_TO_H -# define JSONCONS_H_TO_LE16 -#endif -#ifndef JSONCONS_BE16_TO_H -# include -# define JSONCONS_BE16_TO_H ntohs -# define JSONCONS_H_TO_BE16 htons -#endif -#ifndef JSONCONS_BE32_TO_H -# include -# define JSONCONS_BE32_TO_H ntohl -# define JSONCONS_H_TO_BE32 htonl -#endif -#ifndef JSONCONS_BE64_TO_H -# define JSONCONS_BE64_TO_H ntohll -# define JSONCONS_H_TO_BE64 htonll -/* ntohll isn't usually defined */ -# ifndef ntohll -# if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ -# define ntohll -# define htonll -# elif defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ -# define ntohll(x) ((ntohl((uint32_t)(x)) * UINT64_C(0x100000000)) + (ntohl((x) >> 32))) -# define htonll ntohll -# else -# error "Unable to determine byte order!" -# endif -# endif -#endif - -namespace jsoncons { namespace detail { - -class read_nbytes_failed : public std::invalid_argument, public virtual json_exception -{ -public: - explicit read_nbytes_failed(size_t count) noexcept - : std::invalid_argument("") - { - buffer_.append("Failed attempting to read "); - buffer_.append(std::to_string(count)); - buffer_.append(" bytes from vector"); - } - ~read_nbytes_failed() noexcept - { - } - const char* what() const noexcept override - { - return buffer_.c_str(); - } -private: - std::string buffer_; -}; - -namespace detail { - -static inline bool add_check_overflow(size_t v1, size_t v2, size_t *r) -{ -#if ((defined(__GNUC__) && (__GNUC__ >= 5)) && !defined(__INTEL_COMPILER)) || __has_builtin(__builtin_add_overflow) - return __builtin_add_overflow(v1, v2, r); -#else - // unsigned additions are well-defined - *r = v1 + v2; - return v1 > v1 + v2; -#endif -} - -} - -inline -uint16_t encode_half(double val) -{ -#if defined(__F16C__) && !defined(APPLE_MISSING_INTRINSICS) - return _cvtss_sh((float)val, 3); -#else - uint64_t v; - std::memcpy(&v, &val, sizeof(v)); - int sign = v >> 63 << 15; - int exp = (v >> 52) & 0x7ff; - int mant = v << 12 >> 12 >> (53-11); /* keep only the 11 most significant bits of the mantissa */ - exp -= 1023; - if (exp == 1024) { - /* infinity or NaN */ - exp = 16; - mant >>= 1; - } else if (exp >= 16) { - /* overflow, as largest number */ - exp = 15; - mant = 1023; - } else if (exp >= -14) { - /* regular normal */ - } else if (exp >= -24) { - /* subnormal */ - mant |= 1024; - mant >>= -(exp + 14); - exp = -15; - } else { - /* underflow, make zero */ - return 0; - } - - /* safe cast here as bit operations above guarantee not to overflow */ - return (uint16_t)(sign | ((exp + 15) << 10) | mant); -#endif -} - -/* this function was copied & adapted from RFC 7049 Appendix D */ -inline -double decode_half(uint16_t half) -{ -#if defined(__F16C__) && !defined(APPLE_MISSING_INTRINSICS) - return _cvtsh_ss(half); -#else - int exp = (half >> 10) & 0x1f; - int mant = half & 0x3ff; - double val; - if (exp == 0) - { - val = ldexp((double)mant, -24); - } - else if (exp != 31) - { - val = ldexp(mant + 1024.0, exp - 25); - } - else - { - val = mant == 0 ? INFINITY : NAN; - } - return half & 0x8000 ? -val : val; -#endif -} - -// to_big_endian - - -template -typename std::enable_if::value && sizeof(T) == sizeof(uint8_t),void>::type -to_big_endian(T val, OutputIt d_first) -{ - *d_first = static_cast(val); -} - - -template -typename std::enable_if::value && -sizeof(T) == sizeof(uint16_t),void>::type -to_big_endian(T val, OutputIt d_first) -{ - T x = JSONCONS_H_TO_BE16(val); - - uint8_t where[sizeof(T)]; - std::memcpy(where, &x, sizeof(T)); - - *d_first++ = where[0]; - *d_first++ = where[1]; -} - -template -typename std::enable_if::value && -sizeof(T) == sizeof(uint32_t),void>::type -to_big_endian(T val, OutputIt d_first) -{ - T x = JSONCONS_H_TO_BE32(val); - - uint8_t where[sizeof(T)]; - std::memcpy(where, &x, sizeof(T)); - - *d_first++ = where[0]; - *d_first++ = where[1]; - *d_first++ = where[2]; - *d_first++ = where[3]; -} - -template -typename std::enable_if::value && -sizeof(T) == sizeof(uint64_t),void>::type -to_big_endian(T val, OutputIt d_first) -{ - T x = JSONCONS_H_TO_BE64(val); - - uint8_t where[sizeof(T)]; - std::memcpy(where, &x, sizeof(T)); - - *d_first++ = where[0]; - *d_first++ = where[1]; - *d_first++ = where[2]; - *d_first++ = where[3]; - *d_first++ = where[4]; - *d_first++ = where[5]; - *d_first++ = where[6]; - *d_first++ = where[7]; -} - -template -void to_big_endian(float val, OutputIt d_first) -{ - uint32_t where; - std::memcpy(&where,&val,sizeof(val)); - to_big_endian(where, d_first); -} - -template -void to_big_endian(double val, OutputIt d_first) -{ - uint64_t where; - std::memcpy(&where,&val,sizeof(val)); - to_big_endian(where, d_first); -} - -// to_little_endian - -template -typename std::enable_if::value && -sizeof(T) == sizeof(uint32_t),void>::type -to_little_endian(T val, OutputIt d_first) -{ - T x = JSONCONS_H_TO_LE32(val); - - uint8_t where[sizeof(T)]; - std::memcpy(where, &x, sizeof(T)); - - *d_first++ = where[0]; - *d_first++ = where[1]; - *d_first++ = where[2]; - *d_first++ = where[3]; -} - -template -typename std::enable_if::value && -sizeof(T) == sizeof(uint64_t),void>::type -to_little_endian(T val, OutputIt d_first) -{ - T x = JSONCONS_H_TO_LE64(val); - - uint8_t where[sizeof(T)]; - std::memcpy(where, &x, sizeof(T)); - - *d_first++ = where[0]; - *d_first++ = where[1]; - *d_first++ = where[2]; - *d_first++ = where[3]; - *d_first++ = where[4]; - *d_first++ = where[5]; - *d_first++ = where[6]; - *d_first++ = where[7]; -} - -template -void to_little_endian(float val, OutputIt d_first) -{ - uint32_t where; - std::memcpy(&where,&val,sizeof(val)); - to_little_endian(where, d_first); -} - -template -void to_little_endian(double val, OutputIt d_first) -{ - uint64_t where; - std::memcpy(&where,&val,sizeof(val)); - to_little_endian(where, d_first); -} - -// from_big_endian - -template -typename std::enable_if::value && -sizeof(T) == sizeof(uint8_t),T>::type -from_big_endian(const uint8_t* first, const uint8_t* last, const uint8_t** endp) -{ - if (first + sizeof(T) > last) - { - *endp = first; - return 0; - } - else - { - *endp = first + sizeof(T); - return static_cast(*(first)); - } -} - -template -typename std::enable_if::value && -sizeof(T) == sizeof(uint16_t),T>::type -from_big_endian(const uint8_t* first, const uint8_t* last, const uint8_t** endp) -{ - if (first + sizeof(T) > last) - { - *endp = first; - return 0; - } - else - { - *endp = first + sizeof(T); - T val; - std::memcpy(&val,first,sizeof(T)); - return JSONCONS_BE16_TO_H(val); - } -} - -template -typename std::enable_if::value && sizeof(T) == sizeof(uint32_t),T>::type -from_big_endian(const uint8_t* first, const uint8_t* last, const uint8_t** endp) -{ - if (first + sizeof(T) > last) - { - *endp = first; - return 0; - } - else - { - *endp = first + sizeof(T); - T val; - std::memcpy(&val,first,sizeof(T)); - return JSONCONS_BE32_TO_H(val); - } -} - -template -typename std::enable_if::value && sizeof(T) == sizeof(uint64_t),T>::type -from_big_endian(const uint8_t* first, const uint8_t* last, const uint8_t** endp) -{ - if (first + sizeof(T) > last) - { - *endp = first; - return 0; - } - else - { - *endp = first + sizeof(T); - T val; - std::memcpy(&val,first,sizeof(T)); - return JSONCONS_BE64_TO_H(val); - } -} - -template -typename std::enable_if::value && -sizeof(T) == sizeof(uint32_t),T>::type -from_big_endian(const uint8_t* first, const uint8_t* last, const uint8_t** endp) -{ - uint32_t data = from_big_endian(first,last,endp); - T val; - std::memcpy(&val,&data,sizeof(T)); - return val; -} - -template -typename std::enable_if::value && -sizeof(T) == sizeof(uint64_t),T>::type -from_big_endian(const uint8_t* first, const uint8_t* last, const uint8_t** endp) -{ - uint64_t data = from_big_endian(first,last,endp); - T val; - std::memcpy(&val,&data,sizeof(T)); - return val; -} - -// from_little_endian - -template -typename std::enable_if::value && -sizeof(T) == sizeof(uint8_t),T>::type -from_little_endian(const uint8_t* first, const uint8_t* last, const uint8_t** endp) -{ - if (first + sizeof(T) > last) - { - *endp = first; - return 0; - } - else - { - *endp = first + sizeof(T); - return static_cast(*(first)); - } -} - -template -typename std::enable_if::value && -sizeof(T) == sizeof(uint16_t),T>::type -from_little_endian(const uint8_t* first, const uint8_t* last, const uint8_t** endp) -{ - if (first + sizeof(T) > last) - { - *endp = first; - return 0; - } - else - { - *endp = first + sizeof(T); - T val; - std::memcpy(&val,first,sizeof(T)); - return JSONCONS_LE16_TO_H(val); - } -} - -template -typename std::enable_if::value && sizeof(T) == sizeof(uint32_t),T>::type -from_little_endian(const uint8_t* first, const uint8_t* last, const uint8_t** endp) -{ - if (first + sizeof(T) > last) - { - *endp = first; - return 0; - } - else - { - *endp = first + sizeof(T); - T val; - std::memcpy(&val,first,sizeof(T)); - return JSONCONS_LE32_TO_H(val); - } -} - -template -typename std::enable_if::value && sizeof(T) == sizeof(uint64_t),T>::type -from_little_endian(const uint8_t* first, const uint8_t* last, const uint8_t** endp) -{ - if (first + sizeof(T) > last) - { - *endp = first; - return 0; - } - else - { - *endp = first + sizeof(T); - T val; - std::memcpy(&val,first,sizeof(T)); - return JSONCONS_LE64_TO_H(val); - } -} - -template -typename std::enable_if::value && -sizeof(T) == sizeof(uint32_t),T>::type -from_little_endian(const uint8_t* first, const uint8_t* last, const uint8_t** endp) -{ - uint32_t data = from_little_endian(first,last,endp); - T val; - std::memcpy(&val,&data,sizeof(T)); - return val; -} - -template -typename std::enable_if::value && -sizeof(T) == sizeof(uint64_t),T>::type -from_little_endian(const uint8_t* first, const uint8_t* last, const uint8_t** endp) -{ - uint64_t data = from_little_endian(first,last,endp); - T val; - std::memcpy(&val,&data,sizeof(T)); - return val; -} - -}} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/config/jsoncons_config.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/config/jsoncons_config.hpp deleted file mode 100644 index f61c18b14c..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/config/jsoncons_config.hpp +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_JSONCONS_CONFIG_HPP -#define JSONCONS_JSONCONS_CONFIG_HPP - -#include -#include -#include -#include - -// Uncomment the following line to suppress deprecated names (recommended for new code) -//#define JSONCONS_NO_DEPRECATED - -// The definitions below follow the definitions in compiler_support_p.h, https://github.com/01org/tinycbor -// MIT license - -// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54577 -#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 9 -#define JSONCONS_NO_ERASE_TAKING_CONST_ITERATOR 1 -#endif - -#if defined(__clang__) -# define JSONCONS_FALLTHROUGH [[clang::fallthrough]] -#elif defined(__GNUC__) && ((__GNUC__ >= 7)) -# define JSONCONS_FALLTHROUGH __attribute__((fallthrough)) -#elif defined (__GNUC__) -# define JSONCONS_FALLTHROUGH // FALLTHRU -#else -# define JSONCONS_FALLTHROUGH -#endif - -#if defined(__GNUC__) || defined(__clang__) -#define JSONCONS_LIKELY(x) __builtin_expect(!!(x), 1) -#define JSONCONS_UNLIKELY(x) __builtin_expect(!!(x), 0) -#define JSONCONS_UNREACHABLE() __builtin_unreachable() -#elif defined(_MSC_VER) -#define JSONCONS_LIKELY(x) x -#define JSONCONS_UNLIKELY(x) x -#define JSONCONS_UNREACHABLE() __assume(0) -#else -#define JSONCONS_LIKELY(x) x -#define JSONCONS_UNLIKELY(x) x -#define JSONCONS_UNREACHABLE() do {} while (0) -#endif - -// Follows boost 1_68 -#if !defined(JSONCONS_HAS_STRING_VIEW) -# if defined(__clang__) -# if (__cplusplus >= 201703) -# if __has_include() -# define JSONCONS_HAS_STRING_VIEW 1 -# endif // __has_include() -# endif // (__cplusplus >= 201703) -# endif // defined(__clang__) -# if defined(__GNUC__) -# if (__GNUC__ >= 7) -# if (__cplusplus >= 201703) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) -# define JSONCONS_HAS_STRING_VIEW 1 -# endif // (__cplusplus >= 201703) -# endif // (__GNUC__ >= 7) -# endif // defined(__GNUC__) -# if defined(_MSC_VER) -# if (_MSC_VER >= 1910 && _HAS_CXX17) -# define JSONCONS_HAS_STRING_VIEW -# endif // (_MSC_VER >= 1910 && _HAS_CXX17) -# endif // defined(_MSC_VER) -#endif // !defined(JSONCONS_HAS_STRING_VIEW) - -#define JSONCONS_NO_TO_CHARS - -#if defined(ANDROID) || defined(__ANDROID__) -#define JSONCONS_HAS_STRTOLD_L -#if __ANDROID_API__ >= 21 -#else -#define JSONCONS_NO_LOCALECONV -#endif -#endif - -#if defined(_MSC_VER) -#define JSONCONS_HAS_MSC__STRTOD_L -#define JSONCONS_HAS_FOPEN_S -#endif - -#if !defined(JSONCONS_HAS_STRING_VIEW) -#include -namespace jsoncons { -template > -using basic_string_view = jsoncons::detail::basic_string_view; -using string_view = basic_string_view>; -using wstring_view = basic_string_view>; -} -#else -#include -namespace jsoncons { -template > -using basic_string_view = std::basic_string_view; -using string_view = std::string_view; -using wstring_view = std::wstring_view; -} -#endif - -#define JSONCONS_STRING_LITERAL(name, ...) \ - template \ - const std::basic_string& name##_literal() {\ - static const CharT s[] = { __VA_ARGS__};\ - static const std::basic_string sv(s, sizeof(s) / sizeof(CharT));\ - return sv;\ - } - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/config/version.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/config/version.hpp deleted file mode 100644 index 7c012b5536..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/config/version.hpp +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2017 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_VERSION_HPP -#define JSONCONS_VERSION_HPP - -#include - -#define JSONCONS_VERSION_MAJOR 0 -#define JSONCONS_VERSION_MINOR 125 -#define JSONCONS_VERSION_PATCH 0 - -namespace jsoncons { - -struct versioning_info -{ - unsigned int const major; - unsigned int const minor; - unsigned int const patch; - - friend std::ostream& operator<<(std::ostream& os, const versioning_info& ver) - { - os << ver.major << '.' - << ver.minor << '.' - << ver.patch; - return os; - } -}; - -constexpr versioning_info version() -{ - return versioning_info{JSONCONS_VERSION_MAJOR, JSONCONS_VERSION_MINOR, JSONCONS_VERSION_PATCH}; -} - -} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/detail/grisu3.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/detail/grisu3.hpp deleted file mode 100644 index d8bd81107f..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/detail/grisu3.hpp +++ /dev/null @@ -1,405 +0,0 @@ -/* -Implements the Grisu3 algorithm for printing floating-point numbers. - -Follows Florian Loitsch's grisu3_59_56 implementation, available at -http://florian.loitsch.com/publications, in bench.tar.gz, with -minor modifications. -*/ - -/* - Copyright (c) 2009 Florian Loitsch - - Permission is hereby granted, free of charge, to any person - obtaining a copy of this software and associated documentation - files (the "Software"), to deal in the Software without - restriction, including without limitation the rights to use, - copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the - Software is furnished to do so, subject to the following - conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef JSONCONS_GRISU3_HPP -#define JSONCONS_GRISU3_HPP - -#pragma once -#include -#include -#include -#include -#include -#include // std::memmove - -namespace jsoncons { namespace detail { - -// diy_fp - -typedef struct diy_fp_t { - uint64_t f; - int e; -} diy_fp_t; - -inline -diy_fp_t minus(diy_fp_t x, diy_fp_t y) -{ - assert(x.e == y.e); - assert(x.f >= y.f); - diy_fp_t r = { x.f = x.f - y.f, x.e = x.e }; - return r; -} - -inline -diy_fp_t multiply(diy_fp_t x, diy_fp_t y) -{ - uint64_t a, b, c, d, ac, bc, ad, bd, tmp; - diy_fp_t r; uint64_t M32 = 0xFFFFFFFF; - a = x.f >> 32; b = x.f & M32; - c = y.f >> 32; d = y.f & M32; - ac = a * c; bc = b * c; ad = a * d; bd = b * d; - tmp = (bd >> 32) + (ad & M32) + (bc & M32); - tmp += 1U << 31; /// mult_round - r.f = ac + (ad >> 32) + (bc >> 32) + (tmp >> 32); - r.e = x.e + y.e + 64; - return r; -} - -// k_comp - -inline -int k_comp(int e, int alpha, int /*gamma*/) -{ - constexpr double d_1_log2_10 = 0.30102999566398114; // 1 / lg(10) - return static_cast(std::ceil((alpha - e + 63) * d_1_log2_10)); -} - -// powers_ten_round64 - -constexpr int diy_significand_size = 64; - -static const uint64_t powers_ten[] = { 0xbf29dcaba82fdeae, 0xeef453d6923bd65a, 0x9558b4661b6565f8, 0xbaaee17fa23ebf76, 0xe95a99df8ace6f54, 0x91d8a02bb6c10594, 0xb64ec836a47146fa, 0xe3e27a444d8d98b8, 0x8e6d8c6ab0787f73, 0xb208ef855c969f50, 0xde8b2b66b3bc4724, 0x8b16fb203055ac76, 0xaddcb9e83c6b1794, 0xd953e8624b85dd79, 0x87d4713d6f33aa6c, 0xa9c98d8ccb009506, 0xd43bf0effdc0ba48, 0x84a57695fe98746d, 0xa5ced43b7e3e9188, 0xcf42894a5dce35ea, 0x818995ce7aa0e1b2, 0xa1ebfb4219491a1f, 0xca66fa129f9b60a7, 0xfd00b897478238d1, 0x9e20735e8cb16382, 0xc5a890362fddbc63, 0xf712b443bbd52b7c, 0x9a6bb0aa55653b2d, 0xc1069cd4eabe89f9, 0xf148440a256e2c77, 0x96cd2a865764dbca, 0xbc807527ed3e12bd, 0xeba09271e88d976c, 0x93445b8731587ea3, 0xb8157268fdae9e4c, 0xe61acf033d1a45df, 0x8fd0c16206306bac, 0xb3c4f1ba87bc8697, 0xe0b62e2929aba83c, 0x8c71dcd9ba0b4926, 0xaf8e5410288e1b6f, 0xdb71e91432b1a24b, 0x892731ac9faf056f, 0xab70fe17c79ac6ca, 0xd64d3d9db981787d, 0x85f0468293f0eb4e, 0xa76c582338ed2622, 0xd1476e2c07286faa, 0x82cca4db847945ca, 0xa37fce126597973d, 0xcc5fc196fefd7d0c, 0xff77b1fcbebcdc4f, 0x9faacf3df73609b1, 0xc795830d75038c1e, 0xf97ae3d0d2446f25, 0x9becce62836ac577, 0xc2e801fb244576d5, 0xf3a20279ed56d48a, 0x9845418c345644d7, 0xbe5691ef416bd60c, 0xedec366b11c6cb8f, 0x94b3a202eb1c3f39, 0xb9e08a83a5e34f08, 0xe858ad248f5c22ca, 0x91376c36d99995be, 0xb58547448ffffb2e, 0xe2e69915b3fff9f9, 0x8dd01fad907ffc3c, 0xb1442798f49ffb4b, 0xdd95317f31c7fa1d, 0x8a7d3eef7f1cfc52, 0xad1c8eab5ee43b67, 0xd863b256369d4a41, 0x873e4f75e2224e68, 0xa90de3535aaae202, 0xd3515c2831559a83, 0x8412d9991ed58092, 0xa5178fff668ae0b6, 0xce5d73ff402d98e4, 0x80fa687f881c7f8e, 0xa139029f6a239f72, 0xc987434744ac874f, 0xfbe9141915d7a922, 0x9d71ac8fada6c9b5, 0xc4ce17b399107c23, 0xf6019da07f549b2b, 0x99c102844f94e0fb, 0xc0314325637a193a, 0xf03d93eebc589f88, 0x96267c7535b763b5, 0xbbb01b9283253ca3, 0xea9c227723ee8bcb, 0x92a1958a7675175f, 0xb749faed14125d37, 0xe51c79a85916f485, 0x8f31cc0937ae58d3, 0xb2fe3f0b8599ef08, 0xdfbdcece67006ac9, 0x8bd6a141006042be, 0xaecc49914078536d, 0xda7f5bf590966849, 0x888f99797a5e012d, 0xaab37fd7d8f58179, 0xd5605fcdcf32e1d7, 0x855c3be0a17fcd26, 0xa6b34ad8c9dfc070, 0xd0601d8efc57b08c, 0x823c12795db6ce57, 0xa2cb1717b52481ed, 0xcb7ddcdda26da269, 0xfe5d54150b090b03, 0x9efa548d26e5a6e2, 0xc6b8e9b0709f109a, 0xf867241c8cc6d4c1, 0x9b407691d7fc44f8, 0xc21094364dfb5637, 0xf294b943e17a2bc4, 0x979cf3ca6cec5b5b, 0xbd8430bd08277231, 0xece53cec4a314ebe, 0x940f4613ae5ed137, 0xb913179899f68584, 0xe757dd7ec07426e5, 0x9096ea6f3848984f, 0xb4bca50b065abe63, 0xe1ebce4dc7f16dfc, 0x8d3360f09cf6e4bd, 0xb080392cc4349ded, 0xdca04777f541c568, 0x89e42caaf9491b61, 0xac5d37d5b79b6239, 0xd77485cb25823ac7, 0x86a8d39ef77164bd, 0xa8530886b54dbdec, 0xd267caa862a12d67, 0x8380dea93da4bc60, 0xa46116538d0deb78, 0xcd795be870516656, 0x806bd9714632dff6, 0xa086cfcd97bf97f4, 0xc8a883c0fdaf7df0, 0xfad2a4b13d1b5d6c, 0x9cc3a6eec6311a64, 0xc3f490aa77bd60fd, 0xf4f1b4d515acb93c, 0x991711052d8bf3c5, 0xbf5cd54678eef0b7, 0xef340a98172aace5, 0x9580869f0e7aac0f, 0xbae0a846d2195713, 0xe998d258869facd7, 0x91ff83775423cc06, 0xb67f6455292cbf08, 0xe41f3d6a7377eeca, 0x8e938662882af53e, 0xb23867fb2a35b28e, 0xdec681f9f4c31f31, 0x8b3c113c38f9f37f, 0xae0b158b4738705f, 0xd98ddaee19068c76, 0x87f8a8d4cfa417ca, 0xa9f6d30a038d1dbc, 0xd47487cc8470652b, 0x84c8d4dfd2c63f3b, 0xa5fb0a17c777cf0a, 0xcf79cc9db955c2cc, 0x81ac1fe293d599c0, 0xa21727db38cb0030, 0xca9cf1d206fdc03c, 0xfd442e4688bd304b, 0x9e4a9cec15763e2f, 0xc5dd44271ad3cdba, 0xf7549530e188c129, 0x9a94dd3e8cf578ba, 0xc13a148e3032d6e8, 0xf18899b1bc3f8ca2, 0x96f5600f15a7b7e5, 0xbcb2b812db11a5de, 0xebdf661791d60f56, 0x936b9fcebb25c996, 0xb84687c269ef3bfb, 0xe65829b3046b0afa, 0x8ff71a0fe2c2e6dc, 0xb3f4e093db73a093, 0xe0f218b8d25088b8, 0x8c974f7383725573, 0xafbd2350644eead0, 0xdbac6c247d62a584, 0x894bc396ce5da772, 0xab9eb47c81f5114f, 0xd686619ba27255a3, 0x8613fd0145877586, 0xa798fc4196e952e7, 0xd17f3b51fca3a7a1, 0x82ef85133de648c5, 0xa3ab66580d5fdaf6, 0xcc963fee10b7d1b3, 0xffbbcfe994e5c620, 0x9fd561f1fd0f9bd4, 0xc7caba6e7c5382c9, 0xf9bd690a1b68637b, 0x9c1661a651213e2d, 0xc31bfa0fe5698db8, 0xf3e2f893dec3f126, 0x986ddb5c6b3a76b8, 0xbe89523386091466, 0xee2ba6c0678b597f, 0x94db483840b717f0, 0xba121a4650e4ddec, 0xe896a0d7e51e1566, 0x915e2486ef32cd60, 0xb5b5ada8aaff80b8, 0xe3231912d5bf60e6, 0x8df5efabc5979c90, 0xb1736b96b6fd83b4, 0xddd0467c64bce4a1, 0x8aa22c0dbef60ee4, 0xad4ab7112eb3929e, 0xd89d64d57a607745, 0x87625f056c7c4a8b, 0xa93af6c6c79b5d2e, 0xd389b47879823479, 0x843610cb4bf160cc, 0xa54394fe1eedb8ff, 0xce947a3da6a9273e, 0x811ccc668829b887, 0xa163ff802a3426a9, 0xc9bcff6034c13053, 0xfc2c3f3841f17c68, 0x9d9ba7832936edc1, 0xc5029163f384a931, 0xf64335bcf065d37d, 0x99ea0196163fa42e, 0xc06481fb9bcf8d3a, 0xf07da27a82c37088, 0x964e858c91ba2655, 0xbbe226efb628afeb, 0xeadab0aba3b2dbe5, 0x92c8ae6b464fc96f, 0xb77ada0617e3bbcb, 0xe55990879ddcaabe, 0x8f57fa54c2a9eab7, 0xb32df8e9f3546564, 0xdff9772470297ebd, 0x8bfbea76c619ef36, 0xaefae51477a06b04, 0xdab99e59958885c5, 0x88b402f7fd75539b, 0xaae103b5fcd2a882, 0xd59944a37c0752a2, 0x857fcae62d8493a5, 0xa6dfbd9fb8e5b88f, 0xd097ad07a71f26b2, 0x825ecc24c8737830, 0xa2f67f2dfa90563b, 0xcbb41ef979346bca, 0xfea126b7d78186bd, 0x9f24b832e6b0f436, 0xc6ede63fa05d3144, 0xf8a95fcf88747d94, 0x9b69dbe1b548ce7d, 0xc24452da229b021c, 0xf2d56790ab41c2a3, 0x97c560ba6b0919a6, 0xbdb6b8e905cb600f, 0xed246723473e3813, 0x9436c0760c86e30c, 0xb94470938fa89bcf, 0xe7958cb87392c2c3, 0x90bd77f3483bb9ba, 0xb4ecd5f01a4aa828, 0xe2280b6c20dd5232, 0x8d590723948a535f, 0xb0af48ec79ace837, 0xdcdb1b2798182245, 0x8a08f0f8bf0f156b, 0xac8b2d36eed2dac6, 0xd7adf884aa879177, 0x86ccbb52ea94baeb, 0xa87fea27a539e9a5, 0xd29fe4b18e88640f, 0x83a3eeeef9153e89, 0xa48ceaaab75a8e2b, 0xcdb02555653131b6, 0x808e17555f3ebf12, 0xa0b19d2ab70e6ed6, 0xc8de047564d20a8c, 0xfb158592be068d2f, 0x9ced737bb6c4183d, 0xc428d05aa4751e4d, 0xf53304714d9265e0, 0x993fe2c6d07b7fac, 0xbf8fdb78849a5f97, 0xef73d256a5c0f77d, 0x95a8637627989aae, 0xbb127c53b17ec159, 0xe9d71b689dde71b0, 0x9226712162ab070e, 0xb6b00d69bb55c8d1, 0xe45c10c42a2b3b06, 0x8eb98a7a9a5b04e3, 0xb267ed1940f1c61c, 0xdf01e85f912e37a3, 0x8b61313bbabce2c6, 0xae397d8aa96c1b78, 0xd9c7dced53c72256, 0x881cea14545c7575, 0xaa242499697392d3, 0xd4ad2dbfc3d07788, 0x84ec3c97da624ab5, 0xa6274bbdd0fadd62, 0xcfb11ead453994ba, 0x81ceb32c4b43fcf5, 0xa2425ff75e14fc32, 0xcad2f7f5359a3b3e, 0xfd87b5f28300ca0e, 0x9e74d1b791e07e48, 0xc612062576589ddb, 0xf79687aed3eec551, 0x9abe14cd44753b53, 0xc16d9a0095928a27, 0xf1c90080baf72cb1, 0x971da05074da7bef, 0xbce5086492111aeb, 0xec1e4a7db69561a5, 0x9392ee8e921d5d07, 0xb877aa3236a4b449, 0xe69594bec44de15b, 0x901d7cf73ab0acd9, 0xb424dc35095cd80f, 0xe12e13424bb40e13, 0x8cbccc096f5088cc, 0xafebff0bcb24aaff, 0xdbe6fecebdedd5bf, 0x89705f4136b4a597, 0xabcc77118461cefd, 0xd6bf94d5e57a42bc, 0x8637bd05af6c69b6, 0xa7c5ac471b478423, 0xd1b71758e219652c, 0x83126e978d4fdf3b, 0xa3d70a3d70a3d70a, 0xcccccccccccccccd, 0x8000000000000000, 0xa000000000000000, 0xc800000000000000, 0xfa00000000000000, 0x9c40000000000000, 0xc350000000000000, 0xf424000000000000, 0x9896800000000000, 0xbebc200000000000, 0xee6b280000000000, 0x9502f90000000000, 0xba43b74000000000, 0xe8d4a51000000000, 0x9184e72a00000000, 0xb5e620f480000000, 0xe35fa931a0000000, 0x8e1bc9bf04000000, 0xb1a2bc2ec5000000, 0xde0b6b3a76400000, 0x8ac7230489e80000, 0xad78ebc5ac620000, 0xd8d726b7177a8000, 0x878678326eac9000, 0xa968163f0a57b400, 0xd3c21bcecceda100, 0x84595161401484a0, 0xa56fa5b99019a5c8, 0xcecb8f27f4200f3a, 0x813f3978f8940984, 0xa18f07d736b90be5, 0xc9f2c9cd04674edf, 0xfc6f7c4045812296, 0x9dc5ada82b70b59e, 0xc5371912364ce305, 0xf684df56c3e01bc7, 0x9a130b963a6c115c, 0xc097ce7bc90715b3, 0xf0bdc21abb48db20, 0x96769950b50d88f4, 0xbc143fa4e250eb31, 0xeb194f8e1ae525fd, 0x92efd1b8d0cf37be, 0xb7abc627050305ae, 0xe596b7b0c643c719, 0x8f7e32ce7bea5c70, 0xb35dbf821ae4f38c, 0xe0352f62a19e306f, 0x8c213d9da502de45, 0xaf298d050e4395d7, 0xdaf3f04651d47b4c, 0x88d8762bf324cd10, 0xab0e93b6efee0054, 0xd5d238a4abe98068, 0x85a36366eb71f041, 0xa70c3c40a64e6c52, 0xd0cf4b50cfe20766, 0x82818f1281ed44a0, 0xa321f2d7226895c8, 0xcbea6f8ceb02bb3a, 0xfee50b7025c36a08, 0x9f4f2726179a2245, 0xc722f0ef9d80aad6, 0xf8ebad2b84e0d58c, 0x9b934c3b330c8577, 0xc2781f49ffcfa6d5, 0xf316271c7fc3908b, 0x97edd871cfda3a57, 0xbde94e8e43d0c8ec, 0xed63a231d4c4fb27, 0x945e455f24fb1cf9, 0xb975d6b6ee39e437, 0xe7d34c64a9c85d44, 0x90e40fbeea1d3a4b, 0xb51d13aea4a488dd, 0xe264589a4dcdab15, 0x8d7eb76070a08aed, 0xb0de65388cc8ada8, 0xdd15fe86affad912, 0x8a2dbf142dfcc7ab, 0xacb92ed9397bf996, 0xd7e77a8f87daf7fc, 0x86f0ac99b4e8dafd, 0xa8acd7c0222311bd, 0xd2d80db02aabd62c, 0x83c7088e1aab65db, 0xa4b8cab1a1563f52, 0xcde6fd5e09abcf27, 0x80b05e5ac60b6178, 0xa0dc75f1778e39d6, 0xc913936dd571c84c, 0xfb5878494ace3a5f, 0x9d174b2dcec0e47b, 0xc45d1df942711d9a, 0xf5746577930d6501, 0x9968bf6abbe85f20, 0xbfc2ef456ae276e9, 0xefb3ab16c59b14a3, 0x95d04aee3b80ece6, 0xbb445da9ca61281f, 0xea1575143cf97227, 0x924d692ca61be758, 0xb6e0c377cfa2e12e, 0xe498f455c38b997a, 0x8edf98b59a373fec, 0xb2977ee300c50fe7, 0xdf3d5e9bc0f653e1, 0x8b865b215899f46d, 0xae67f1e9aec07188, 0xda01ee641a708dea, 0x884134fe908658b2, 0xaa51823e34a7eedf, 0xd4e5e2cdc1d1ea96, 0x850fadc09923329e, 0xa6539930bf6bff46, 0xcfe87f7cef46ff17, 0x81f14fae158c5f6e, 0xa26da3999aef774a, 0xcb090c8001ab551c, 0xfdcb4fa002162a63, 0x9e9f11c4014dda7e, 0xc646d63501a1511e, 0xf7d88bc24209a565, 0x9ae757596946075f, 0xc1a12d2fc3978937, 0xf209787bb47d6b85, 0x9745eb4d50ce6333, 0xbd176620a501fc00, 0xec5d3fa8ce427b00, 0x93ba47c980e98ce0, 0xb8a8d9bbe123f018, 0xe6d3102ad96cec1e, 0x9043ea1ac7e41393, 0xb454e4a179dd1877, 0xe16a1dc9d8545e95, 0x8ce2529e2734bb1d, 0xb01ae745b101e9e4, 0xdc21a1171d42645d, 0x899504ae72497eba, 0xabfa45da0edbde69, 0xd6f8d7509292d603, 0x865b86925b9bc5c2, 0xa7f26836f282b733, 0xd1ef0244af2364ff, 0x8335616aed761f1f, 0xa402b9c5a8d3a6e7, 0xcd036837130890a1, 0x802221226be55a65, 0xa02aa96b06deb0fe, 0xc83553c5c8965d3d, 0xfa42a8b73abbf48d, 0x9c69a97284b578d8, 0xc38413cf25e2d70e, 0xf46518c2ef5b8cd1, 0x98bf2f79d5993803, 0xbeeefb584aff8604, 0xeeaaba2e5dbf6785, 0x952ab45cfa97a0b3, 0xba756174393d88e0, 0xe912b9d1478ceb17, 0x91abb422ccb812ef, 0xb616a12b7fe617aa, 0xe39c49765fdf9d95, 0x8e41ade9fbebc27d, 0xb1d219647ae6b31c, 0xde469fbd99a05fe3, 0x8aec23d680043bee, 0xada72ccc20054aea, 0xd910f7ff28069da4, 0x87aa9aff79042287, 0xa99541bf57452b28, 0xd3fa922f2d1675f2, 0x847c9b5d7c2e09b7, 0xa59bc234db398c25, 0xcf02b2c21207ef2f, 0x8161afb94b44f57d, 0xa1ba1ba79e1632dc, 0xca28a291859bbf93, 0xfcb2cb35e702af78, 0x9defbf01b061adab, 0xc56baec21c7a1916, 0xf6c69a72a3989f5c, 0x9a3c2087a63f6399, 0xc0cb28a98fcf3c80, 0xf0fdf2d3f3c30b9f, 0x969eb7c47859e744, 0xbc4665b596706115, 0xeb57ff22fc0c795a, 0x9316ff75dd87cbd8, 0xb7dcbf5354e9bece, 0xe5d3ef282a242e82, 0x8fa475791a569d11, 0xb38d92d760ec4455, 0xe070f78d3927556b, 0x8c469ab843b89563, 0xaf58416654a6babb, 0xdb2e51bfe9d0696a, 0x88fcf317f22241e2, 0xab3c2fddeeaad25b, 0xd60b3bd56a5586f2, 0x85c7056562757457, 0xa738c6bebb12d16d, 0xd106f86e69d785c8, 0x82a45b450226b39d, 0xa34d721642b06084, 0xcc20ce9bd35c78a5, 0xff290242c83396ce, 0x9f79a169bd203e41, 0xc75809c42c684dd1, 0xf92e0c3537826146, 0x9bbcc7a142b17ccc, 0xc2abf989935ddbfe, 0xf356f7ebf83552fe, 0x98165af37b2153df, 0xbe1bf1b059e9a8d6, 0xeda2ee1c7064130c, 0x9485d4d1c63e8be8, 0xb9a74a0637ce2ee1, 0xe8111c87c5c1ba9a, 0x910ab1d4db9914a0, 0xb54d5e4a127f59c8, 0xe2a0b5dc971f303a, 0x8da471a9de737e24, 0xb10d8e1456105dad, 0xdd50f1996b947519, 0x8a5296ffe33cc930, 0xace73cbfdc0bfb7b, 0xd8210befd30efa5a, 0x8714a775e3e95c78, 0xa8d9d1535ce3b396, 0xd31045a8341ca07c, 0x83ea2b892091e44e, 0xa4e4b66b68b65d61, 0xce1de40642e3f4b9, 0x80d2ae83e9ce78f4, 0xa1075a24e4421731, 0xc94930ae1d529cfd, 0xfb9b7cd9a4a7443c, 0x9d412e0806e88aa6, 0xc491798a08a2ad4f, 0xf5b5d7ec8acb58a3, 0x9991a6f3d6bf1766, 0xbff610b0cc6edd3f, 0xeff394dcff8a948f, 0x95f83d0a1fb69cd9, 0xbb764c4ca7a44410, 0xea53df5fd18d5514, 0x92746b9be2f8552c, 0xb7118682dbb66a77, 0xe4d5e82392a40515, 0x8f05b1163ba6832d, 0xb2c71d5bca9023f8, 0xdf78e4b2bd342cf7, 0x8bab8eefb6409c1a, 0xae9672aba3d0c321, 0xda3c0f568cc4f3e9, 0x8865899617fb1871, 0xaa7eebfb9df9de8e, 0xd51ea6fa85785631, 0x8533285c936b35df, 0xa67ff273b8460357, 0xd01fef10a657842c, 0x8213f56a67f6b29c, 0xa298f2c501f45f43, 0xcb3f2f7642717713, 0xfe0efb53d30dd4d8, 0x9ec95d1463e8a507, 0xc67bb4597ce2ce49, 0xf81aa16fdc1b81db, 0x9b10a4e5e9913129, 0xc1d4ce1f63f57d73, 0xf24a01a73cf2dcd0, 0x976e41088617ca02, 0xbd49d14aa79dbc82, 0xec9c459d51852ba3, 0x93e1ab8252f33b46, 0xb8da1662e7b00a17, 0xe7109bfba19c0c9d, 0x906a617d450187e2, 0xb484f9dc9641e9db, 0xe1a63853bbd26451, 0x8d07e33455637eb3, 0xb049dc016abc5e60, 0xdc5c5301c56b75f7, 0x89b9b3e11b6329bb, 0xac2820d9623bf429, 0xd732290fbacaf134, 0x867f59a9d4bed6c0, 0xa81f301449ee8c70, 0xd226fc195c6a2f8c, 0x83585d8fd9c25db8, 0xa42e74f3d032f526, 0xcd3a1230c43fb26f, 0x80444b5e7aa7cf85, 0xa0555e361951c367, 0xc86ab5c39fa63441, 0xfa856334878fc151, 0x9c935e00d4b9d8d2, 0xc3b8358109e84f07, 0xf4a642e14c6262c9, 0x98e7e9cccfbd7dbe, 0xbf21e44003acdd2d, 0xeeea5d5004981478, 0x95527a5202df0ccb, 0xbaa718e68396cffe, 0xe950df20247c83fd, 0x91d28b7416cdd27e, 0xb6472e511c81471e, 0xe3d8f9e563a198e5, 0x8e679c2f5e44ff8f, 0xb201833b35d63f73, 0xde81e40a034bcf50, 0x8b112e86420f6192, 0xadd57a27d29339f6, 0xd94ad8b1c7380874, 0x87cec76f1c830549, 0xa9c2794ae3a3c69b, 0xd433179d9c8cb841, 0x849feec281d7f329, 0xa5c7ea73224deff3, 0xcf39e50feae16bf0, 0x81842f29f2cce376, 0xa1e53af46f801c53, 0xca5e89b18b602368, 0xfcf62c1dee382c42, 0x9e19db92b4e31ba9, 0xc5a05277621be294, 0xf70867153aa2db39, 0x9a65406d44a5c903, 0xc0fe908895cf3b44, 0xf13e34aabb430a15, 0x96c6e0eab509e64d, 0xbc789925624c5fe1, 0xeb96bf6ebadf77d9, 0x933e37a534cbaae8, 0xb80dc58e81fe95a1, 0xe61136f2227e3b0a, 0x8fcac257558ee4e6, 0xb3bd72ed2af29e20, 0xe0accfa875af45a8, 0x8c6c01c9498d8b89, 0xaf87023b9bf0ee6b, 0xdb68c2ca82ed2a06, 0x892179be91d43a44, 0xab69d82e364948d4 }; -static const int powers_ten_e[] = { -1203, -1200, -1196, -1193, -1190, -1186, -1183, -1180, -1176, -1173, -1170, -1166, -1163, -1160, -1156, -1153, -1150, -1146, -1143, -1140, -1136, -1133, -1130, -1127, -1123, -1120, -1117, -1113, -1110, -1107, -1103, -1100, -1097, -1093, -1090, -1087, -1083, -1080, -1077, -1073, -1070, -1067, -1063, -1060, -1057, -1053, -1050, -1047, -1043, -1040, -1037, -1034, -1030, -1027, -1024, -1020, -1017, -1014, -1010, -1007, -1004, -1000, -997, -994, -990, -987, -984, -980, -977, -974, -970, -967, -964, -960, -957, -954, -950, -947, -944, -940, -937, -934, -931, -927, -924, -921, -917, -914, -911, -907, -904, -901, -897, -894, -891, -887, -884, -881, -877, -874, -871, -867, -864, -861, -857, -854, -851, -847, -844, -841, -838, -834, -831, -828, -824, -821, -818, -814, -811, -808, -804, -801, -798, -794, -791, -788, -784, -781, -778, -774, -771, -768, -764, -761, -758, -754, -751, -748, -744, -741, -738, -735, -731, -728, -725, -721, -718, -715, -711, -708, -705, -701, -698, -695, -691, -688, -685, -681, -678, -675, -671, -668, -665, -661, -658, -655, -651, -648, -645, -642, -638, -635, -632, -628, -625, -622, -618, -615, -612, -608, -605, -602, -598, -595, -592, -588, -585, -582, -578, -575, -572, -568, -565, -562, -558, -555, -552, -549, -545, -542, -539, -535, -532, -529, -525, -522, -519, -515, -512, -509, -505, -502, -499, -495, -492, -489, -485, -482, -479, -475, -472, -469, -465, -462, -459, -455, -452, -449, -446, -442, -439, -436, -432, -429, -426, -422, -419, -416, -412, -409, -406, -402, -399, -396, -392, -389, -386, -382, -379, -376, -372, -369, -366, -362, -359, -356, -353, -349, -346, -343, -339, -336, -333, -329, -326, -323, -319, -316, -313, -309, -306, -303, -299, -296, -293, -289, -286, -283, -279, -276, -273, -269, -266, -263, -259, -256, -253, -250, -246, -243, -240, -236, -233, -230, -226, -223, -220, -216, -213, -210, -206, -203, -200, -196, -193, -190, -186, -183, -180, -176, -173, -170, -166, -163, -160, -157, -153, -150, -147, -143, -140, -137, -133, -130, -127, -123, -120, -117, -113, -110, -107, -103, -100, -97, -93, -90, -87, -83, -80, -77, -73, -70, -67, -63, -60, -57, -54, -50, -47, -44, -40, -37, -34, -30, -27, -24, -20, -17, -14, -10, -7, -4, 0, 3, 6, 10, 13, 16, 20, 23, 26, 30, 33, 36, 39, 43, 46, 49, 53, 56, 59, 63, 66, 69, 73, 76, 79, 83, 86, 89, 93, 96, 99, 103, 106, 109, 113, 116, 119, 123, 126, 129, 132, 136, 139, 142, 146, 149, 152, 156, 159, 162, 166, 169, 172, 176, 179, 182, 186, 189, 192, 196, 199, 202, 206, 209, 212, 216, 219, 222, 226, 229, 232, 235, 239, 242, 245, 249, 252, 255, 259, 262, 265, 269, 272, 275, 279, 282, 285, 289, 292, 295, 299, 302, 305, 309, 312, 315, 319, 322, 325, 328, 332, 335, 338, 342, 345, 348, 352, 355, 358, 362, 365, 368, 372, 375, 378, 382, 385, 388, 392, 395, 398, 402, 405, 408, 412, 415, 418, 422, 425, 428, 431, 435, 438, 441, 445, 448, 451, 455, 458, 461, 465, 468, 471, 475, 478, 481, 485, 488, 491, 495, 498, 501, 505, 508, 511, 515, 518, 521, 524, 528, 531, 534, 538, 541, 544, 548, 551, 554, 558, 561, 564, 568, 571, 574, 578, 581, 584, 588, 591, 594, 598, 601, 604, 608, 611, 614, 617, 621, 624, 627, 631, 634, 637, 641, 644, 647, 651, 654, 657, 661, 664, 667, 671, 674, 677, 681, 684, 687, 691, 694, 697, 701, 704, 707, 711, 714, 717, 720, 724, 727, 730, 734, 737, 740, 744, 747, 750, 754, 757, 760, 764, 767, 770, 774, 777, 780, 784, 787, 790, 794, 797, 800, 804, 807, 810, 813, 817, 820, 823, 827, 830, 833, 837, 840, 843, 847, 850, 853, 857, 860, 863, 867, 870, 873, 877, 880, 883, 887, 890, 893, 897, 900, 903, 907, 910, 913, 916, 920, 923, 926, 930, 933, 936, 940, 943, 946, 950, 953, 956, 960, 963, 966, 970, 973, 976, 980, 983, 986, 990, 993, 996, 1000, 1003, 1006, 1009, 1013, 1016, 1019, 1023, 1026, 1029, 1033, 1036, 1039, 1043, 1046, 1049, 1053, 1056, 1059, 1063, 1066, 1069, 1073, 1076 }; - -inline -diy_fp_t cached_power(int k) -{ - diy_fp_t res; - int index = 343 + k; - res.f = powers_ten[index]; - res.e = powers_ten_e[index]; - return res; -} - -// double - -typedef union { - double d; - uint64_t n; -} converter_t; - -inline -uint64_t double_to_uint64(double d) { converter_t tmp; tmp.d = d; return tmp.n; } - -inline -double uint64_to_double(uint64_t d64) { converter_t tmp; tmp.n = d64; return tmp.d; } - -constexpr int dp_significand_size = 52; -constexpr int dp_exponent_bias = (0x3FF + dp_significand_size); -constexpr int dp_min_exponent = (-dp_exponent_bias); -constexpr uint64_t dp_exponent_mask = 0x7FF0000000000000; -constexpr uint64_t dp_significand_mask = 0x000FFFFFFFFFFFFF; -constexpr uint64_t dp_hidden_bit = 0x0010000000000000; - -inline -diy_fp_t normalize_diy_fp(diy_fp_t in) -{ - diy_fp_t res = in; - /* Normalize now */ - /* the original number could have been a denormal. */ - while (!(res.f & dp_hidden_bit)) - { - res.f <<= 1; - res.e--; - } - /* do the final shifts in one go. Don't forget the hidden bit (the '-1') */ - res.f <<= (diy_significand_size - dp_significand_size - 1); - res.e = res.e - (diy_significand_size - dp_significand_size - 1); - return res; -} - -inline -diy_fp_t double2diy_fp(double d) -{ - uint64_t d64 = double_to_uint64(d); - int biased_e = (d64 & dp_exponent_mask) >> dp_significand_size; - uint64_t significand = (d64 & dp_significand_mask); - diy_fp_t res; - if (biased_e != 0) - { - res.f = significand + dp_hidden_bit; - res.e = biased_e - dp_exponent_bias; - } - else - { - res.f = significand; - res.e = dp_min_exponent + 1; - } - return res; -} - -inline -diy_fp_t normalize_boundary(diy_fp_t in) -{ - diy_fp_t res = in; - /* Normalize now */ - /* the original number could have been a denormal. */ - while (!(res.f & (dp_hidden_bit << 1))) - { - res.f <<= 1; - res.e--; - } - /* do the final shifts in one go. Don't forget the hidden bit (the '-1') */ - res.f <<= (diy_significand_size - dp_significand_size - 2); - res.e = res.e - (diy_significand_size - dp_significand_size - 2); - return res; -} - -inline -void normalized_boundaries(double d, diy_fp_t *out_m_minus, diy_fp_t *out_m_plus) -{ - diy_fp_t v = double2diy_fp(d); - diy_fp_t pl, mi; - bool significand_is_zero = v.f == dp_hidden_bit; - pl.f = (v.f << 1) + 1; pl.e = v.e - 1; - pl = normalize_boundary(pl); - if (significand_is_zero) - { - mi.f = (v.f << 2) - 1; - mi.e = v.e - 2; - } else - { - mi.f = (v.f << 1) - 1; - mi.e = v.e - 1; - } - mi.f <<= mi.e - pl.e; - mi.e = pl.e; - *out_m_plus = pl; - *out_m_minus = mi; -} - -inline -double random_double() -{ - uint64_t tmp = 0; - int i; - for (i = 0; i < 8; i++) - { - tmp <<= 8; - tmp += rand() % 256; - } - return uint64_to_double(tmp); -} - -// fast_exponent -template -void fill_exponent(int K, Result& result) -{ - if (K < 0) - { - result.push_back('-'); - K = -K; - } - else - { - result.push_back('+'); // compatibility with sprintf - } - if (K >= 100) - { - result.push_back((char)('0' + K / 100)); K %= 100; - result.push_back((char)('0' + K / 10)); K %= 10; - result.push_back((char)('0' + K)); - } - else if (K >= 10) - { - result.push_back((char)('0' + K / 10)); K %= 10; - result.push_back((char)('0' + K)); - } - else - { - result.push_back('0'); // compatibility with sprintf - result.push_back((char)('0' + K)); - } -} - -template -void prettify_string(const char *buffer, size_t length, int k, int min_exp, int max_exp, Result& result) -{ - int nb_digits = (int)length; - int offset; - /* v = buffer * 10^k - kk is such that 10^(kk-1) <= v < 10^kk - this way kk gives the position of the decimal point. - */ - int kk = nb_digits + k; - - if (nb_digits <= kk && kk <= max_exp) - { - /* the first digits are already in. Add some 0s and call it a day. */ - /* the max_exp is a personal choice. Only 16 digits could possibly be relevant. - * Basically we want to print 12340000000 rather than 1234.0e7 or 1.234e10 */ - for (int i = 0; i < nb_digits; ++i) - { - result.push_back(buffer[i]); - } - for (int i = nb_digits; i < kk; ++i) - { - result.push_back('0'); - } - result.push_back('.'); - result.push_back('0'); - } - else if (0 < kk && kk <= max_exp) - { - /* comma number. Just insert a '.' at the correct location. */ - for (int i = 0; i < kk; ++i) - { - result.push_back(buffer[i]); - } - result.push_back('.'); - for (int i = kk; i < nb_digits; ++i) - { - result.push_back(buffer[i]); - } - } - else if (min_exp < kk && kk <= 0) - { - offset = 2 - kk; - - result.push_back('0'); - result.push_back('.'); - for (int i = 2; i < offset; ++i) - result.push_back('0'); - for (int i = 0; i < nb_digits; ++i) - { - result.push_back(buffer[i]); - } - } - else if (nb_digits == 1) - { - result.push_back(buffer[0]); - result.push_back('e'); - fill_exponent(kk - 1, result); - } - else - { - result.push_back(buffer[0]); - result.push_back('.'); - for (int i = 1; i < nb_digits; ++i) - { - result.push_back(buffer[i]); - } - result.push_back('e'); - fill_exponent(kk - 1, result); - } -} - -// grisu3 - -inline -bool round_weed(char *buffer, int len, - uint64_t wp_W, uint64_t Delta, - uint64_t rest, uint64_t ten_kappa, - uint64_t ulp) -{ - uint64_t wp_Wup = wp_W - ulp; - uint64_t wp_Wdown = wp_W + ulp; - while (rest < wp_Wup && /// round1 - Delta - rest >= ten_kappa && - (rest + ten_kappa < wp_Wup || /// closer - wp_Wup - rest >= rest + ten_kappa - wp_Wup)) - { - buffer[len - 1]--; rest += ten_kappa; - } - if (rest < wp_Wdown && /// round2 - Delta - rest >= ten_kappa && - (rest + ten_kappa < wp_Wdown || - wp_Wdown - rest > rest + ten_kappa - wp_Wdown)) return 0; - return 2 * ulp <= rest && rest <= Delta - 4 * ulp; /// weed -} - -inline -bool digit_gen(diy_fp_t Wm, diy_fp_t W, diy_fp_t Wp, - char *buffer, int *len, int *K) -{ - const uint32_t TEN2 = 100; - - uint32_t div, p1; uint64_t p2, tmp, unit = 1; - int d, kappa; - diy_fp_t one, wp_W, Delta; - Delta = minus(Wp, Wm); Delta.f += 2 * unit; - wp_W = minus(Wp, W); wp_W.f += unit; - one.f = ((uint64_t)1) << -Wp.e; one.e = Wp.e; - p1 = static_cast((Wp.f + 1) >> -one.e); - p2 = (Wp.f + 1) & (one.f - 1); - *len = 0; kappa = 3; div = TEN2; - while (kappa > 0) - { - d = p1 / div; - if (d || *len) buffer[(*len)++] = (char)('0' + d); - p1 %= div; kappa--; - tmp = (((uint64_t)p1) << -one.e) + p2; - if (tmp < Delta.f) - { - *K += kappa; - return round_weed(buffer, *len, wp_W.f, Delta.f, tmp, - ((uint64_t)div) << -one.e, unit); - } - div /= 10; - } - while (1) - { - p2 *= 10; Delta.f *= 10; unit *= 10; - d = static_cast(p2 >> -one.e); - if (d || *len) buffer[(*len)++] = (char)('0' + d); - p2 &= one.f - 1; kappa--; - if (p2 < Delta.f) - { - *K += kappa; - return round_weed(buffer, *len, wp_W.f * unit, Delta.f, p2, - one.f, unit); - } - } -} - -inline -bool grisu3(double v, char *buffer, int *length, int *K) -{ - diy_fp_t w_m, w_p; - int q = 64, alpha = -59, gamma = -56; - normalized_boundaries(v, &w_m, &w_p); - diy_fp_t w = normalize_diy_fp(double2diy_fp(v)); - int mk = k_comp(w_p.e + q, alpha, gamma); - diy_fp_t c_mk = cached_power(mk); - diy_fp_t W = multiply(w, c_mk); - diy_fp_t Wp = multiply(w_p, c_mk); - diy_fp_t Wm = multiply(w_m, c_mk); - *K = -mk; - bool result = digit_gen(Wm, W, Wp, buffer, length, K); - buffer[*length] = 0; - return result; -} - -}} // namespace detail namespace jsoncons - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/detail/heap_only_string.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/detail/heap_only_string.hpp deleted file mode 100644 index a90d863d49..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/detail/heap_only_string.hpp +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_DETAIL_HEAP_ONLY_STRING_HPP -#define JSONCONS_DETAIL_HEAP_ONLY_STRING_HPP - -#include -#include -#include -#include -#include // std::memcpy -#include // std::allocator -#include - -namespace jsoncons { namespace detail { - -template -class heap_only_string_base -{ - Allocator allocator_; -public: - Allocator& get_allocator() - { - return allocator_; - } - - const Allocator& get_allocator() const - { - return allocator_; - } -protected: - heap_only_string_base(const Allocator& allocator) - : allocator_(allocator) - { - } - - ~heap_only_string_base() {} -}; - -template -class heap_only_string_factory; - -template -class heap_only_string : public heap_only_string_base -{ - typedef typename std::allocator_traits::template rebind_alloc allocator_type; - typedef std::allocator_traits allocator_traits_type; - typedef typename allocator_traits_type::pointer pointer; - - friend class heap_only_string_factory; -public: - typedef CharT char_type; - typedef heap_only_string value_type; - - ~heap_only_string() {} - - const char_type* c_str() const { return to_plain_pointer(p_); } - const char_type* data() const { return to_plain_pointer(p_); } - size_t length() const { return length_; } - - using heap_only_string_base::get_allocator; - - - friend std::basic_ostream& operator<<(std::basic_ostream& os, const heap_only_string& s) - { - os.write(s.data(),s.length()); - return os; - } -private: - heap_only_string() - : heap_only_string_base(Allocator()) - { - - } - heap_only_string(const Allocator& allocator) - : heap_only_string_base(allocator) - { - - } - - pointer p_; - size_t length_; - - heap_only_string(const heap_only_string&) = delete; - heap_only_string& operator=(const heap_only_string&) = delete; - -}; - -template -class heap_only_string_factory -{ - typedef CharT char_type; - typedef typename std::allocator_traits::template rebind_alloc byte_allocator_type; - typedef std::allocator_traits byte_allocator_traits_type; - typedef typename byte_allocator_traits_type::pointer byte_pointer; - typedef typename heap_only_string::pointer pointer; -public: - - typedef typename std::allocator_traits::template rebind_alloc> string_allocator_type; - typedef std::allocator_traits string_allocator_traits_type; - typedef typename string_allocator_traits_type::pointer string_pointer; - - typedef heap_only_string* raw_string_pointer_type; - - struct string_storage - { - heap_only_string data; - char_type c[1]; - }; - typedef typename std::aligned_storage::type storage_type; - - static size_t aligned_size(size_t n) - { - return sizeof(storage_type) + n; - } -public: - static string_pointer create(const char_type* s, size_t length) - { - return create(s, length, Allocator()); - } - static string_pointer create(const char_type* s, size_t length, const Allocator& allocator) - { - size_t mem_size = aligned_size(length*sizeof(char_type)); - - byte_allocator_type alloc(allocator); - byte_pointer ptr = alloc.allocate(mem_size); - - char* storage = to_plain_pointer(ptr); - raw_string_pointer_type ps = new(storage)heap_only_string(alloc); - auto psa = reinterpret_cast(storage); - - CharT* p = new(&psa->c)char_type[length + 1]; - std::memcpy(p, s, length*sizeof(char_type)); - p[length] = 0; - ps->p_ = std::pointer_traits::pointer_to(*p); - ps->length_ = length; - return std::pointer_traits::pointer_to(*ps); - } - - static void destroy(string_pointer ptr) - { - raw_string_pointer_type rawp = to_plain_pointer(ptr); - char* p = reinterpret_cast(rawp); - size_t mem_size = aligned_size(ptr->length_*sizeof(char_type)); - byte_allocator_type alloc(ptr->get_allocator()); - alloc.deallocate(p,mem_size); - } -}; - - -}} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/detail/parse_number.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/detail/parse_number.hpp deleted file mode 100644 index 221bc4512c..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/detail/parse_number.hpp +++ /dev/null @@ -1,526 +0,0 @@ -// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_DETAIL_PARSE_NUMBER_HPP -#define JSONCONS_DETAIL_PARSE_NUMBER_HPP - -#include -#include -#include -#include -#include -#include // std::numeric_limits -#include // std::enable_if -#include -#include -#include - -namespace jsoncons { namespace detail { - -enum class to_integer_errc : uint8_t {ok=0,overflow,invalid_digit}; - -template -struct to_integer_result -{ - T value; - to_integer_errc ec; -}; - -class to_integer_error_category_impl - : public std::error_category -{ -public: - const char* name() const noexcept override - { - return "jsoncons/to_integer"; - } - std::string message(int ev) const override - { - switch (static_cast(ev)) - { - case to_integer_errc::overflow: - return "Integer overflow"; - case to_integer_errc::invalid_digit: - return "Invalid digit"; - default: - return "Unknown to_integer error"; - } - } -}; - -inline -const std::error_category& to_integer_error_category() -{ - static to_integer_error_category_impl instance; - return instance; -} - -inline -std::error_code make_error_code(to_integer_errc e) -{ - return std::error_code(static_cast(e),to_integer_error_category()); -} - -template -bool is_integer(const CharT* s, size_t length) -{ - const CharT* end = s + length; - if (s == end) - { - return false; - } - if (*s == '-') - { - ++s; - } - if (s == end) - { - return false; - } - for (;s < end; ++s) - { - if (!(*s >= '0' && *s <= '9')) - { - return false; - } - } - return true; -} - -template -bool is_uinteger(const CharT* s, size_t length) -{ - const CharT* end = s + length; - if (s == end) - { - return false; - } - for (;s < end; ++s) - { - if (!(*s >= '0' && *s <= '9')) - { - return false; - } - } - return true; -} - -// Precondition: s satisfies - -// digit -// digit1-digits -// - digit -// - digit1-digits - -template -typename std::enable_if::value && std::is_signed::value,to_integer_result>::type -to_integer(const CharT* s, size_t length) -{ - static_assert(std::numeric_limits::is_specialized, "Integer type not specialized"); - JSONCONS_ASSERT(length > 0); - - to_integer_errc ec{}; - - T n = 0; - const CharT* end = s + length; - if (*s == '-') - { - static const T min_value = (std::numeric_limits::lowest)(); - static const T min_value_div_10 = min_value / 10; - ++s; - for (; s < end; ++s) - { - T x = *s - '0'; - if (n < min_value_div_10) - { - ec = to_integer_errc::overflow; - break; - } - n = n * 10; - if (n < min_value + x) - { - ec = to_integer_errc::overflow; - break; - } - - n -= x; - } - } - else - { - static const T max_value = (std::numeric_limits::max)(); - static const T max_value_div_10 = max_value / 10; - for (; s < end; ++s) - { - T x = *s - '0'; - if (n > max_value_div_10) - { - ec = to_integer_errc::overflow; - break; - } - n = n * 10; - if (n > max_value - x) - { - ec = to_integer_errc::overflow; - break; - } - - n += x; - } - } - - return to_integer_result({n,ec}); -} - -// Precondition: s satisfies - -// digit -// digit1-digits -// - digit -// - digit1-digits - -template -typename std::enable_if::value && !std::is_signed::value,to_integer_result>::type -to_integer(const CharT* s, size_t length) -{ - static_assert(std::numeric_limits::is_specialized, "Integer type not specialized"); - JSONCONS_ASSERT(length > 0); - - T n = 0; - to_integer_errc ec{}; - - const CharT* end = s + length; - - static const T max_value = (std::numeric_limits::max)(); - static const T max_value_div_10 = max_value / 10; - for (; s < end; ++s) - { - T x = *s - '0'; - if (n > max_value_div_10) - { - ec = to_integer_errc::overflow; - break; - } - n = n * 10; - if (n > max_value - x) - { - ec = to_integer_errc::overflow; - break; - } - - n += x; - } - - return to_integer_result({ n,ec }); -} - -// base16_to_integer - -template -typename std::enable_if::value && std::is_signed::value,to_integer_result>::type -base16_to_integer(const CharT* s, size_t length) -{ - static_assert(std::numeric_limits::is_specialized, "Integer type not specialized"); - JSONCONS_ASSERT(length > 0); - - T n = 0; - to_integer_errc ec{}; - const CharT* end = s + length; - if (*s == '-') - { - static const T min_value = (std::numeric_limits::lowest)(); - static const T min_value_div_16 = min_value / 16; - ++s; - for (; s < end; ++s) - { - CharT c = *s; - T x = 0; - switch (c) - { - case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8': case '9': - x = c - '0'; - break; - case 'a':case 'b':case 'c':case 'd':case 'e':case 'f': - x = c - ('a' - 10); - break; - case 'A':case 'B':case 'C':case 'D':case 'E':case 'F': - x = c - ('A' - 10); - break; - default: - throw std::runtime_error("Invalid hex digit"); - } - if (n < min_value_div_16) - { - ec = to_integer_errc::overflow; - break; - } - n = n * 16; - if (n < min_value + x) - { - ec = to_integer_errc::overflow; - break; - } - n -= x; - } - } - else - { - static const T max_value = (std::numeric_limits::max)(); - static const T max_value_div_16 = max_value / 16; - for (; s < end; ++s) - { - CharT c = *s; - T x = 0; - switch (c) - { - case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8': case '9': - x = c - '0'; - break; - case 'a':case 'b':case 'c':case 'd':case 'e':case 'f': - x = c - ('a' - 10); - break; - case 'A':case 'B':case 'C':case 'D':case 'E':case 'F': - x = c - ('A' - 10); - break; - default: - throw std::runtime_error("Invalid hex digit"); - } - if (n > max_value_div_16) - { - ec = to_integer_errc::overflow; - break; - } - n = n * 16; - if (n > max_value - x) - { - ec = to_integer_errc::overflow; - break; - } - - n += x; - } - } - - return to_integer_result({ n,ec }); -} - -template -typename std::enable_if::value && !std::is_signed::value,to_integer_result>::type -base16_to_integer(const CharT* s, size_t length) -{ - static_assert(std::numeric_limits::is_specialized, "Integer type not specialized"); - JSONCONS_ASSERT(length > 0); - - T n = 0; - to_integer_errc ec{}; - const CharT* end = s + length; - - static const T max_value = (std::numeric_limits::max)(); - static const T max_value_div_16 = max_value / 16; - for (; s < end; ++s) - { - CharT c = *s; - T x = *s; - switch (c) - { - case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8': case '9': - x = c - '0'; - break; - case 'a':case 'b':case 'c':case 'd':case 'e':case 'f': - x = c - ('a' - 10); - break; - case 'A':case 'B':case 'C':case 'D':case 'E':case 'F': - x = c - ('A' - 10); - break; - default: - throw std::runtime_error("Invalid hex digit"); - } - if (n > max_value_div_16) - { - ec = to_integer_errc::overflow; - break; - } - n = n * 16; - if (n > max_value - x) - { - ec = to_integer_errc::overflow; - break; - } - - n += x; - } - - return to_integer_result({ n,ec }); -} - -#if defined(JSONCONS_HAS_MSC__STRTOD_L) - -class string_to_double -{ -private: - _locale_t locale_; -public: - string_to_double() - { - locale_ = _create_locale(LC_NUMERIC, "C"); - } - ~string_to_double() - { - _free_locale(locale_); - } - - char get_decimal_point() const - { - return '.'; - } - - template - typename std::enable_if::value,double>::type - operator()(const CharT* s, size_t) const - { - CharT *end = nullptr; - double val = _strtod_l(s, &end, locale_); - if (s == end) - { - JSONCONS_THROW(json_runtime_error("Convert string to double failed")); - } - return val; - } - - template - typename std::enable_if::value,double>::type - operator()(const CharT* s, size_t) const - { - CharT *end = nullptr; - double val = _wcstod_l(s, &end, locale_); - if (s == end) - { - JSONCONS_THROW(json_runtime_error("Convert string to double failed")); - } - return val; - } -private: - // noncopyable and nonmoveable - string_to_double(const string_to_double&) = delete; - string_to_double& operator=(const string_to_double&) = delete; -}; - -#elif defined(JSONCONS_HAS_STRTOLD_L) - -class string_to_double -{ -private: - locale_t locale_; -public: - string_to_double() - { - locale_ = newlocale(LC_ALL_MASK, "C", (locale_t) 0); - } - ~string_to_double() - { - freelocale(locale_); - } - - char get_decimal_point() const - { - return '.'; - } - - template - typename std::enable_if::value,double>::type - operator()(const CharT* s, size_t length) const - { - char *end = nullptr; - double val = strtold_l(s, &end, locale_); - if (s == end) - { - JSONCONS_THROW(json_runtime_error("Convert string to double failed")); - } - return val; - } - - template - typename std::enable_if::value,double>::type - operator()(const CharT* s, size_t length) const - { - CharT *end = nullptr; - double val = wcstold_l(s, &end, locale_); - if (s == end) - { - JSONCONS_THROW(json_runtime_error("Convert string to double failed")); - } - return val; - } - -private: - // noncopyable and nonmoveable - string_to_double(const string_to_double& fr) = delete; - string_to_double& operator=(const string_to_double& fr) = delete; -}; - -#else -class string_to_double -{ -private: - std::vector buffer_; - char decimal_point_; -public: - string_to_double() - : buffer_() - { - struct lconv * lc = localeconv(); - if (lc != nullptr && lc->decimal_point[0] != 0) - { - decimal_point_ = lc->decimal_point[0]; - } - else - { - decimal_point_ = '.'; - } - buffer_.reserve(100); - } - - char get_decimal_point() const - { - return decimal_point_; - } - - template - typename std::enable_if::value,double>::type - operator()(const CharT* s, size_t /*length*/) const - { - CharT *end = nullptr; - double val = strtod(s, &end); - if (s == end) - { - JSONCONS_THROW(json_runtime_error("Convert string to double failed")); - } - return val; - } - - template - typename std::enable_if::value,double>::type - operator()(const CharT* s, size_t /*length*/) const - { - CharT *end = nullptr; - double val = wcstod(s, &end); - if (s == end) - { - JSONCONS_THROW(json_runtime_error("Convert string to double failed")); - } - return val; - } - -private: - // noncopyable and nonmoveable - string_to_double(const string_to_double& fr) = delete; - string_to_double& operator=(const string_to_double& fr) = delete; -}; -#endif - -}} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/detail/print_number.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/detail/print_number.hpp deleted file mode 100644 index 8fa870d3f7..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/detail/print_number.hpp +++ /dev/null @@ -1,344 +0,0 @@ -// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_DETAIL_PRINT_NUMBER_HPP -#define JSONCONS_DETAIL_PRINT_NUMBER_HPP - -#include -#include -#include -#include -#include // std::numeric_limits -#include -#include -#include -#include -#include - -namespace jsoncons { namespace detail { - -// print_integer - -template -size_t print_integer(int64_t value, Result& result) -{ - typedef typename Result::value_type char_type; - - size_t count = 0; - - char_type buf[255]; - uint64_t u = (value < 0) ? static_cast(-value) : static_cast(value); - char_type* p = buf; - do - { - *p++ = static_cast(48 + u%10); - } - while (u /= 10); - count += (p-buf); - if (value < 0) - { - result.push_back('-'); - ++count; - } - while (--p >= buf) - { - result.push_back(*p); - } - - return count; -} - -// print_uinteger - -template -size_t print_uinteger(uint64_t value, Result& result) -{ - typedef typename Result::value_type char_type; - - size_t count = 0; - - char_type buf[255]; - char_type* p = buf; - do - { - *p++ = static_cast(48 + value % 10); - } - while (value /= 10); - count += (p-buf); - while (--p >= buf) - { - result.push_back(*p); - } - return count; -} - -// print_integer - -template -size_t integer_to_hex_string(int64_t value, Result& result) -{ - typedef typename Result::value_type char_type; - - size_t count = 0; - - char_type buf[255]; - uint64_t u = (value < 0) ? static_cast(-value) : static_cast(value); - char_type* p = buf; - do - { - *p++ = to_hex_character(u%16); - } - while (u /= 16); - count += (p-buf); - if (value < 0) - { - result.push_back('-'); - ++count; - } - while (--p >= buf) - { - result.push_back(*p); - } - - return count; -} - -// print_uinteger - -template -size_t uinteger_to_hex_string(uint64_t value, Result& result) -{ - typedef typename Result::value_type char_type; - - size_t count = 0; - - char_type buf[255]; - char_type* p = buf; - do - { - *p++ = to_hex_character(value % 16); - } - while (value /= 16); - count += (p-buf); - while (--p >= buf) - { - result.push_back(*p); - } - return count; -} - -// print_double - -template -void dump_buffer(const char* buffer, size_t length, char decimal_point, Result& result) -{ - const char* sbeg = buffer; - const char* send = sbeg + length; - - if (sbeg != send) - { - bool needs_dot = true; - for (const char* q = sbeg; q < send; ++q) - { - switch (*q) - { - case '-':case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8':case '9':case '+': - result.push_back(*q); - break; - case 'e': - case 'E': - result.push_back('e'); - needs_dot = false; - break; - default: - if (*q == decimal_point) - { - needs_dot = false; - result.push_back('.'); - } - break; - } - } - if (needs_dot) - { - result.push_back('.'); - result.push_back('0'); - needs_dot = true; - } - } -} - -template -bool dtoa(double val, char decimal_point, Result& result, std::false_type) -{ - if (val == 0) - { - result.push_back('0'); - result.push_back('.'); - result.push_back('0'); - return true; - } - - jsoncons::detail::string_to_double to_double_; - - char buffer[100]; - int precision = std::numeric_limits::digits10; - int length = snprintf(buffer, sizeof(buffer), "%1.*g", precision, val); - if (length < 0) - { - return false; - } - if (to_double_(buffer,sizeof(buffer)) != val) - { - const int precision2 = std::numeric_limits::max_digits10; - length = snprintf(buffer, sizeof(buffer), "%1.*g", precision2, val); - if (length < 0) - { - return false; - } - } - dump_buffer(buffer, length, decimal_point, result); - return true; -} - -template -bool dtoa(double v, char decimal_point, Result& result, std::true_type) -{ - if (v == 0) - { - result.push_back('0'); - result.push_back('.'); - result.push_back('0'); - return true; - } - - int length = 0; - int k; - - char buffer[100]; - - double u = std::signbit(v) ? -v : v; - if (jsoncons::detail::grisu3(u, buffer, &length, &k)) - { - if (std::signbit(v)) - { - result.push_back('-'); - } - // min exp: -4 is consistent with sprintf - // max exp: std::numeric_limits::max_digits10 - jsoncons::detail::prettify_string(buffer, length, k, -4, std::numeric_limits::max_digits10, result); - return true; - } - else - { - return dtoa(v, decimal_point, result, std::false_type()); - } -} - -template -bool dtoa(double v, char decimal_point, Result& result) -{ - return dtoa(v, decimal_point, result, std::integral_constant::is_iec559>()); -} - -class print_double -{ -private: - string_to_double to_double_; - floating_point_options override_; - char decimal_point_; -public: - print_double(const floating_point_options& options) - : override_(options) - { -#if !defined(JSONCONS_NO_LOCALECONV) - struct lconv * lc = localeconv(); - if (lc != nullptr && lc->decimal_point[0] != 0) - { - decimal_point_ = lc->decimal_point[0]; - } - else -#endif - { - decimal_point_ = '.'; - } - } - - template - size_t operator()(double val, Result& result) - { - size_t count = 0; - - chars_format format = override_.format() != chars_format() ? override_.format() : chars_format::general; - - int decimal_places; - if (override_.decimal_places() != 0) - { - decimal_places = override_.decimal_places(); - } - else - { - format = chars_format::general; - decimal_places = 0; - } - - char number_buffer[200]; - int length = 0; - - switch (format) - { - case chars_format::fixed: - { - length = snprintf(number_buffer, sizeof(number_buffer), "%1.*f", decimal_places, val); - if (length < 0) - { - JSONCONS_THROW(json_runtime_error("print_double failed.")); - } - dump_buffer(number_buffer, length, decimal_point_, result); - } - break; - case chars_format::scientific: - { - length = snprintf(number_buffer, sizeof(number_buffer), "%1.*e", decimal_places, val); - if (length < 0) - { - JSONCONS_THROW(json_runtime_error("print_double failed.")); - } - dump_buffer(number_buffer, length, decimal_point_, result); - } - break; - case chars_format::general: - { - if (override_.precision() != 0) - { - int precision = override_.precision(); - length = snprintf(number_buffer, sizeof(number_buffer), "%1.*g", precision, val); - if (length < 0) - { - JSONCONS_THROW(json_runtime_error("print_double failed.")); - } - dump_buffer(number_buffer, length, decimal_point_, result); - } - else - { - if (!dtoa(val, decimal_point_, result)) - { - JSONCONS_THROW(json_runtime_error("print_double failed.")); - } - } - break; - } - default: - JSONCONS_THROW(json_runtime_error("print_double failed.")); - break; - } - return count; - } -}; - -}} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/detail/string_view.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/detail/string_view.hpp deleted file mode 100644 index e85abff6b8..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/detail/string_view.hpp +++ /dev/null @@ -1,525 +0,0 @@ -// Copyright 2019 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_STRING_VIEW_HPP -#define JSONCONS_STRING_VIEW_HPP - -#include -#include -#include -#include -#include -#include // std::find, std::min, std::reverse -#include -#include -#include -#include -#include // std::basic_istream - -namespace jsoncons { namespace detail { - -template > -class basic_string_view -{ -private: - const CharT* data_; - size_t length_; -public: - typedef CharT value_type; - typedef const CharT& const_reference; - typedef Traits traits_type; - typedef std::size_t size_type; - static const size_type npos = size_type(-1); - typedef const CharT* const_iterator; - typedef const CharT* iterator; - typedef std::reverse_iterator const_reverse_iterator; - - basic_string_view() - : data_(nullptr), length_(0) - { - } - basic_string_view(const CharT* data, size_t length) - : data_(data), length_(length) - { - } - basic_string_view(const CharT* data) - : data_(data), length_(Traits::length(data)) - { - } - basic_string_view(const basic_string_view& other) = default; - - template - basic_string_view(const std::basic_string& s) - : data_(s.data()), length_(s.length()) - { - } - - template - explicit operator std::basic_string() const - { - return std::basic_string(data_,length_); - } - - // iterator support - const_iterator begin() const noexcept - { - return data_; - } - const_iterator end() const noexcept - { - return data_ + length_; - } - const_iterator cbegin() const noexcept - { - return data_; - } - const_iterator cend() const noexcept - { - return data_ + length_; - } - const_reverse_iterator rbegin() const noexcept - { - return const_reverse_iterator(end()); - } - const_reverse_iterator rend() const noexcept - { - return const_reverse_iterator(begin()); - } - const_reverse_iterator crbegin() const noexcept - { - return const_reverse_iterator(end()); - } - const_reverse_iterator crend() const noexcept - { - return const_reverse_iterator(begin()); - } - - // capacity - - size_t size() const - { - return length_; - } - - size_t length() const - { - return length_; - } - size_type max_size() const noexcept - { - return length_; - } - bool empty() const noexcept - { - return length_ == 0; - } - - // element access - - const_reference operator[](size_type pos) const - { - return data_[pos]; - } - - const_reference at(size_t pos) const - { - if (pos >= length_) - { - throw std::out_of_range("pos exceeds length"); - } - return data_[pos]; - } - - const_reference front() const - { - return data_[0]; - } - const_reference back() const - { - return data_[length_-1]; - } - - const CharT* data() const - { - return data_; - } - - // string operations - - basic_string_view substr(size_type pos, size_type n=npos) const - { - if (pos > length_) - { - throw std::out_of_range("pos exceeds size"); - } - if (n == npos || pos + n > length_) - { - n = length_ - pos; - } - return basic_string_view(data_ + pos, n); - } - - int compare(const basic_string_view& s) const - { - const int rc = Traits::compare(data_, s.data_, (std::min)(length_, s.length_)); - return rc != 0 ? rc : (length_ == s.length_ ? 0 : length_ < s.length_ ? -1 : 1); - } - - int compare(const CharT* data) const - { - const size_t length = Traits::length(data); - const int rc = Traits::compare(data_, data, (std::min)(length_, length)); - return rc != 0 ? rc : (length_ == length? 0 : length_ < length? -1 : 1); - } - - template - int compare(const std::basic_string& s) const - { - const int rc = Traits::compare(data_, s.data(), (std::min)(length_, s.length())); - return rc != 0 ? rc : (length_ == s.length() ? 0 : length_ < s.length() ? -1 : 1); - } - - size_type find(basic_string_view s, size_type pos = 0) const noexcept - { - if (pos > length_) - { - return npos; - } - if (s.length_ == 0) - { - return pos; - } - const_iterator it = std::search(cbegin() + pos, cend(), - s.cbegin(), s.cend(), Traits::eq); - return it == cend() ? npos : std::distance(cbegin(), it); - } - size_type find(CharT ch, size_type pos = 0) const noexcept - { - return find(basic_string_view(&ch, 1), pos); - } - size_type find(const CharT* s, size_type pos, size_type n) const noexcept - { - return find(basic_string_view(s, n), pos); - } - size_type find(const CharT* s, size_type pos = 0) const noexcept - { - return find(basic_string_view(s), pos); - } - - size_type rfind(basic_string_view s, size_type pos = npos) const noexcept - { - if (length_ < s.length_) - { - return npos; - } - if (pos > length_ - s.length_) - { - pos = length_ - s.length_; - } - if (s.length_ == 0) - { - return pos; - } - for (const CharT* p = data_ + pos; true; --p) - { - if (Traits::compare(p, s.data_, s.length_) == 0) - { - return p - data_; - } - if (p == data_) - { - return npos; - } - }; - } - size_type rfind(CharT ch, size_type pos = npos) const noexcept - { - return rfind(basic_string_view(&ch, 1), pos); - } - size_type rfind(const CharT* s, size_type pos, size_type n) const noexcept - { - return rfind(basic_string_view(s, n), pos); - } - size_type rfind(const CharT* s, size_type pos = npos) const noexcept - { - return rfind(basic_string_view(s), pos); - } - - size_type find_first_of(basic_string_view s, size_type pos = 0) const noexcept - { - if (pos >= length_ || s.length_ == 0) - { - return npos; - } - const_iterator it = std::find_first_of - (cbegin() + pos, cend(), s.cbegin(), s.cend(), Traits::eq); - return it == cend() ? npos : std::distance (cbegin(), it); - } - size_type find_first_of(CharT ch, size_type pos = 0) const noexcept - { - return find_first_of(basic_string_view(&ch, 1), pos); - } - size_type find_first_of(const CharT* s, size_type pos, size_type n) const noexcept - { - return find_first_of(basic_string_view(s, n), pos); - } - size_type find_first_of(const CharT* s, size_type pos = 0) const noexcept - { - return find_first_of(basic_string_view(s), pos); - } - - size_type find_last_of(basic_string_view s, size_type pos = npos) const noexcept - { - if (s.length_ == 0) - { - return npos; - } - if (pos >= length_) - { - pos = 0; - } - else - { - pos = length_ - (pos+1); - } - const_reverse_iterator it = std::find_first_of - (crbegin() + pos, crend(), s.cbegin(), s.cend(), Traits::eq); - return it == crend() ? npos : (length_ - 1 - std::distance(crbegin(), it)); - } - size_type find_last_of(CharT ch, size_type pos = npos) const noexcept - { - return find_last_of(basic_string_view(&ch, 1), pos); - } - size_type find_last_of(const CharT* s, size_type pos, size_type n) const noexcept - { - return find_last_of(basic_string_view(s, n), pos); - } - size_type find_last_of(const CharT* s, size_type pos = npos) const noexcept - { - return find_last_of(basic_string_view(s), pos); - } - - size_type find_first_not_of(basic_string_view s, size_type pos = 0) const noexcept - { - if (pos >= length_) - return npos; - if (s.length_ == 0) - return pos; - - const_iterator it = cend(); - for (auto p = cbegin()+pos; p != cend(); ++p) - { - if (Traits::find(s.data_, s.length_, *p) == 0) - { - it = p; - break; - } - } - return it == cend() ? npos : std::distance (cbegin(), it); - } - size_type find_first_not_of(CharT ch, size_type pos = 0) const noexcept - { - return find_first_not_of(basic_string_view(&ch, 1), pos); - } - size_type find_first_not_of(const CharT* s, size_type pos, size_type n) const noexcept - { - return find_first_not_of(basic_string_view(s, n), pos); - } - size_type find_first_not_of(const CharT* s, size_type pos = 0) const noexcept - { - return find_first_not_of(basic_string_view(s), pos); - } - - size_type find_last_not_of(basic_string_view s, size_type pos = npos) const noexcept - { - if (pos >= length_) - { - pos = length_ - 1; - } - if (s.length_ == 0) - { - return pos; - } - pos = length_ - (pos+1); - - const_iterator it = crend(); - for (auto p = crbegin()+pos; p != crend(); ++p) - { - if (Traits::find(s.data_, s.length_, *p) == 0) - { - it = p; - break; - } - } - return it == crend() ? npos : (length_ - 1 - std::distance(crbegin(), it)); - } - size_type find_last_not_of(CharT ch, size_type pos = npos) const noexcept - { - return find_last_not_of(basic_string_view(&ch, 1), pos); - } - size_type find_last_not_of(const CharT* s, size_type pos, size_type n) const noexcept - { - return find_last_not_of(basic_string_view(s, n), pos); - } - size_type find_last_not_of(const CharT* s, size_type pos = npos) const noexcept - { - return find_last_not_of(basic_string_view(s), pos); - } - - friend std::basic_ostream& operator<<(std::basic_ostream& os, const basic_string_view& sv) - { - os.write(sv.data_,sv.length_); - return os; - } -}; - -// == -template -bool operator==(const basic_string_view& lhs, - const basic_string_view& rhs) -{ - return lhs.compare(rhs) == 0; -} -template -bool operator==(const basic_string_view& lhs, - const std::basic_string& rhs) -{ - return lhs.compare(rhs) == 0; -} -template -bool operator==(const std::basic_string& lhs, - const basic_string_view& rhs) -{ - return rhs.compare(lhs) == 0; -} -template -bool operator==(const basic_string_view& lhs, - const CharT* rhs) -{ - return lhs.compare(rhs) == 0; -} -template -bool operator==(const CharT* lhs, - const basic_string_view& rhs) -{ - return rhs.compare(lhs) == 0; -} - -// != -template -bool operator!=(const basic_string_view& lhs, - const basic_string_view& rhs) -{ - return lhs.compare(rhs) != 0; -} -template -bool operator!=(const basic_string_view& lhs, - const std::basic_string& rhs) -{ - return lhs.compare(rhs) != 0; -} -template -bool operator!=(const std::basic_string& lhs, - const basic_string_view& rhs) -{ - return rhs.compare(lhs) != 0; -} -template -bool operator!=(const basic_string_view& lhs, - const CharT* rhs) -{ - return lhs.compare(rhs) != 0; -} -template -bool operator!=(const CharT* lhs, - const basic_string_view& rhs) -{ - return rhs.compare(lhs) != 0; -} - -// <= -template -bool operator<=(const basic_string_view& lhs, - const basic_string_view& rhs) -{ - return lhs.compare(rhs) <= 0; -} -template -bool operator<=(const basic_string_view& lhs, - const std::basic_string& rhs) -{ - return lhs.compare(rhs) <= 0; -} -template -bool operator<=(const std::basic_string& lhs, - const basic_string_view& rhs) -{ - return rhs.compare(lhs) >= 0; -} - -// < -template -bool operator<(const basic_string_view& lhs, - const basic_string_view& rhs) -{ - return lhs.compare(rhs) < 0; -} -template -bool operator<(const basic_string_view& lhs, - const std::basic_string& rhs) -{ - return lhs.compare(rhs) < 0; -} -template -bool operator<(const std::basic_string& lhs, - const basic_string_view& rhs) -{ - return rhs.compare(lhs) > 0; -} - -// >= -template -bool operator>=(const basic_string_view& lhs, - const basic_string_view& rhs) -{ - return lhs.compare(rhs) >= 0; -} -template -bool operator>=(const basic_string_view& lhs, - const std::basic_string& rhs) -{ - return lhs.compare(rhs) >= 0; -} -template -bool operator>=(const std::basic_string& lhs, - const basic_string_view& rhs) -{ - return rhs.compare(lhs) <= 0; -} - -// > -template -bool operator>(const basic_string_view& lhs, - const basic_string_view& rhs) -{ - return lhs.compare(rhs) > 0; -} -template -bool operator>(const basic_string_view& lhs, - const std::basic_string& rhs) -{ - return lhs.compare(rhs) > 0; -} -template -bool operator>(const std::basic_string& lhs, - const basic_string_view& rhs) -{ - return rhs.compare(lhs) < 0; -} - -}} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/detail/type_traits.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/detail/type_traits.hpp deleted file mode 100644 index 53c5514376..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/detail/type_traits.hpp +++ /dev/null @@ -1,228 +0,0 @@ -// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_DETAIL_TYPE_TRAITS_HPP -#define JSONCONS_DETAIL_TYPE_TRAITS_HPP - -#include -#include -#include -#include // std::enable_if, std::true_type -#include -#include // std::iterator_traits -#include -#include -#include -#include - -namespace jsoncons -{ -// static_max - -template -struct static_max; - -template -struct static_max -{ - static const size_t value = arg; -}; - -template -struct static_max -{ - static const size_t value = arg1 >= arg2 ? - static_max::value : - static_max::value; -}; - -// type_wrapper - -template -struct type_wrapper -{ - typedef T* pointer_type; - typedef const T* const_pointer_type; - typedef T value_type; - typedef T& reference; - typedef const T& const_reference; -}; - -template -struct type_wrapper -{ - typedef T* pointer_type; - typedef const T* const_pointer_type; - typedef T value_type; - typedef T& reference; - typedef const T& const_reference; -}; - -template -struct type_wrapper -{ - typedef T* pointer_type; - typedef const T* const_pointer_type; - typedef T value_type; - typedef T& reference; - typedef const T& const_reference; -}; - -template -struct type_wrapper -{ - typedef T* pointer_type; - typedef const T* const_pointer_type; - typedef T value_type; - typedef T& reference; - typedef const T& const_reference; -}; - -inline -char to_hex_character(uint8_t c) -{ - JSONCONS_ASSERT(c <= 0xF); - - return (char)((c < 10) ? ('0' + c) : ('A' - 10 + c)); -} - -inline -bool is_control_character(uint32_t c) -{ - return c <= 0x1F || c == 0x7f; -} - -inline -bool is_non_ascii_codepoint(uint32_t cp) -{ - return cp >= 0x80; -} - -template -struct is_stateless - : public std::integral_constant::value && - std::is_empty::value)> -{}; - -// type traits extensions - - -namespace detail { - -// to_plain_pointer - -template inline -typename std::pointer_traits::element_type* to_plain_pointer(Pointer ptr) -{ - return (std::addressof(*ptr)); -} - -template inline -T * to_plain_pointer(T * ptr) -{ - return (ptr); -} - -// has_char_traits_member_type - -template -struct has_char_traits_member_type : std::false_type {}; - -template -struct has_char_traits_member_type::value ->::type> : std::true_type {}; - - -// is_string_like - -template -struct is_string_like : std::false_type {}; - -template -struct is_string_like::value && !std::is_void::value && !std::is_void::value ->::type> : std::true_type {}; - -// is_string_view_like - -template -struct is_string_view_like : std::false_type {}; - -template -struct is_string_view_like::value && !std::is_void::value && !is_string_like::value ->::type> : std::true_type {}; - -// is_integer_like - -template -struct is_integer_like : std::false_type {}; - -template -struct is_integer_like::value && - std::is_signed::value && - !std::is_same::value>::type> : std::true_type {}; - -// is_uinteger_like - -template -struct is_uinteger_like : std::false_type {}; - -template -struct is_uinteger_like::value && - !std::is_signed::value && - !std::is_same::value>::type> : std::true_type {}; - -// is_floating_point_like - -template -struct is_floating_point_like : std::false_type {}; - -template -struct is_floating_point_like::value>::type> : std::true_type {}; - -// is_map_like - -template -struct is_map_like : std::false_type {}; - -template -struct is_map_like::value>::type> - : std::true_type {}; - -// is_array_like -template -struct is_array_like : std::false_type {}; - -template -struct is_array_like> : std::true_type {}; - -// is_vector_like - -template -struct is_vector_like : std::false_type {}; - -template -struct is_vector_like::value && - !std::is_void::value_type>::value && - !is_array_like::value && - !has_char_traits_member_type::value && - !is_map_like::value ->::type> - : std::true_type {}; - -} - -} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/encode_decode_json.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/encode_decode_json.hpp deleted file mode 100644 index 196b2244b9..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/encode_decode_json.hpp +++ /dev/null @@ -1,280 +0,0 @@ -// Copyright 2017 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_ENCODE_DECODE_JSON_HPP -#define JSONCONS_ENCODE_DECODE_JSON_HPP - -#include -#include -#include -#include -#include // std::basic_istream -#include -#include - -namespace jsoncons { - -// decode_json - -template -typename std::enable_if::value,T>::type -decode_json(const std::basic_string& s, - const basic_json_decode_options& options = basic_json_options::default_options()) -{ - jsoncons::json_decoder decoder; - basic_json_reader> reader(s, decoder, options); - reader.read(); - return decoder.get_result(); -} - -template -typename std::enable_if::value,T>::type -decode_json(const std::basic_string& s, - const basic_json_decode_options& options = basic_json_options::default_options()) -{ - basic_json_cursor reader(s, options); - T val; - read_from(basic_json(), reader, val); - return val; -} - -template -typename std::enable_if::value,T>::type -decode_json(std::basic_istream& is, - const basic_json_decode_options& options = basic_json_options::default_options()) -{ - jsoncons::json_decoder decoder; - basic_json_reader> reader(is, decoder, options); - reader.read(); - return decoder.get_result(); -} - -template -typename std::enable_if::value,T>::type -decode_json(std::basic_istream& is, - const basic_json_decode_options& options = basic_json_options::default_options()) -{ - basic_json_cursor reader(is, options); - T val; - read_from(basic_json(), reader, val); - return val; -} - -template -T decode_json(const basic_json& j, - const std::basic_string& s, - const basic_json_decode_options& options = basic_json_options::default_options()) -{ - basic_json_cursor reader(s, options); - T val; - read_from(j, reader, val); - return val; -} - -template -T decode_json(const basic_json& j, - std::basic_istream& is, - const basic_json_decode_options& options = basic_json_options::default_options()) -{ - basic_json_cursor reader(is, options); - T val; - read_from(j, reader, val); - return val; -} - -// encode_json - -template -void encode_json(const T& val, - basic_json_content_handler& receiver) -{ - write_to(basic_json(), val, receiver); - receiver.flush(); -} - -// to stream - -template -typename std::enable_if::value>::type -encode_json(const T& val, - std::basic_ostream& os, - const basic_json_encode_options& options = basic_json_options::default_options(), - indenting line_indent = indenting::no_indent) -{ - if (line_indent == indenting::indent) - { - basic_json_encoder encoder(os, options); - val.dump(encoder); - } - else - { - basic_json_compressed_encoder encoder(os, options); - val.dump(encoder); - } -} - -template -typename std::enable_if::value>::type -encode_json(const T& val, - std::basic_ostream& os, - const basic_json_encode_options& options = basic_json_options::default_options(), - indenting line_indent = indenting::no_indent) -{ - if (line_indent == indenting::indent) - { - basic_json_encoder encoder(os, options); - encode_json(val, encoder); - } - else - { - basic_json_compressed_encoder encoder(os, options); - encode_json(val, encoder); - } -} - -template -void encode_json(const T& val, - std::basic_ostream& os, - indenting line_indent) -{ - encode_json(val, os, basic_json_options::default_options(), line_indent); -} - -// to string - -template -typename std::enable_if::value>::type -encode_json(const T& val, - std::basic_string& s, - const basic_json_encode_options& options = basic_json_options::default_options(), - indenting line_indent = indenting::no_indent) -{ - if (line_indent == indenting::indent) - { - basic_json_encoder>> encoder(s, options); - val.dump(encoder); - } - else - { - basic_json_compressed_encoder>> encoder(s, options); - val.dump(encoder); - } -} - -template -typename std::enable_if::value>::type -encode_json(const T& val, - std::basic_string& s, - const basic_json_encode_options& options = basic_json_options::default_options(), - indenting line_indent = indenting::no_indent) -{ - if (line_indent == indenting::indent) - { - basic_json_encoder>> encoder(s, options); - encode_json(val, encoder); - } - else - { - basic_json_compressed_encoder>> encoder(s, options); - encode_json(val, encoder); - } -} - -template -void encode_json(const T& val, - std::basic_string& s, - indenting line_indent) -{ - encode_json(val, s, basic_json_options::default_options(), line_indent); -} - -template -void encode_json(const basic_json& j, - const T& val, - basic_json_content_handler& receiver) -{ - write_to(j, val, receiver); - receiver.flush(); -} - -template -void encode_json(const basic_json& j, - const T& val, - std::basic_ostream& os, - const basic_json_encode_options& options = basic_json_options::default_options(), - indenting line_indent = indenting::no_indent) -{ - if (line_indent == indenting::indent) - { - basic_json_encoder encoder(os, options); - encode_json(j, val, encoder); - } - else - { - basic_json_compressed_encoder encoder(os, options); - encode_json(j, val, encoder); - } -} - -template -void encode_json(const basic_json& j, - const T& val, - std::basic_ostream& os, - indenting line_indent) -{ - if (line_indent == indenting::indent) - { - basic_json_encoder encoder(os, basic_json_options::default_options()); - encode_json(j, val, encoder); - } - else - { - basic_json_compressed_encoder encoder(os, basic_json_options::default_options()); - encode_json(j, val, encoder); - } -} - -template -void encode_json(const basic_json& j, - const T& val, - std::basic_string& s, - const basic_json_encode_options& options = basic_json_options::default_options(), - indenting line_indent = indenting::no_indent) -{ - if (line_indent == indenting::indent) - { - basic_json_encoder>> encoder(s, options); - encode_json(j, val, encoder); - } - else - { - basic_json_compressed_encoder>> encoder(s, options); - encode_json(j, val, encoder); - } -} - -template -void encode_json(const basic_json& j, - const T& val, - std::basic_string& s, - indenting line_indent) -{ - if (line_indent == indenting::indent) - { - basic_json_encoder>> encoder(s, basic_json_options::default_options()); - encode_json(j, val, encoder); - } - else - { - basic_json_compressed_encoder>> encoder(s, basic_json_options::default_options()); - encode_json(j, val, encoder); - } -} - -} - -#endif - diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/json.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/json.hpp deleted file mode 100644 index 0dad529e33..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/json.hpp +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2018 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_JSON_HPP -#define JSONCONS_JSON_HPP - -#include -#include - -#endif - diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/json_container_types.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/json_container_types.hpp deleted file mode 100644 index 8bc415a5b1..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/json_container_types.hpp +++ /dev/null @@ -1,1962 +0,0 @@ -// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_JSON_CONTAINER_TYPES_HPP -#define JSONCONS_JSON_CONTAINER_TYPES_HPP - -#include -#include -#include -#include -#include -#include // std::sort, std::stable_sort, std::lower_bound, std::unique -#include -#include -#include // std::iterator_traits -#include // std::allocator -#include // std::move -#include // std::enable_if -#include -#include - -namespace jsoncons { - -// key_value - -template -class key_value -{ -public: - typedef KeyT key_type; - typedef ValueT value_type; - typedef typename KeyT::allocator_type allocator_type; - typedef typename value_type::string_view_type string_view_type; -private: - key_type key_; - value_type value_; -public: - - key_value() - { - } - - key_value(const key_type& name, const value_type& val) - : key_(name), value_(val) - { - } - - key_value(const string_view_type& name) - : key_(name) - { - } - - template - key_value(key_type&& name, T&& val) - : key_(std::forward(name)), - value_(std::forward(val)) - { - } - - template - key_value(key_type&& name, - T&& val, - const allocator_type& allocator) - : key_(std::forward(name)), value_(std::forward(val), allocator) - { - } - - key_value(const key_value& member) - : key_(member.key_), value_(member.value_) - { - } - - key_value(key_value&& member) - : key_(std::move(member.key_)), value_(std::move(member.value_)) - { - } - - string_view_type key() const - { - return string_view_type(key_.data(),key_.size()); - } - - value_type& value() - { - return value_; - } - - const value_type& value() const - { - return value_; - } - - template - void value(T&& value) - { - value_ = std::forward(value); - } - - void swap(key_value& member) - { - key_.swap(member.key_); - value_.swap(member.value_); - } - - key_value& operator=(const key_value& member) - { - if (this != & member) - { - key_ = member.key_; - value_ = member.value_; - } - return *this; - } - - key_value& operator=(key_value&& member) - { - if (this != &member) - { - key_.swap(member.key_); - value_.swap(member.value_); - } - return *this; - } - - void shrink_to_fit() - { - key_.shrink_to_fit(); - value_.shrink_to_fit(); - } -#if !defined(JSONCONS_NO_DEPRECATED) - const key_type& name() const - { - return key_; - } -#endif - - friend bool operator==(const key_value& lhs, const key_value& rhs) - { - return lhs.key_ == rhs.key_ && lhs.value_ == rhs.value_; - } - - friend bool operator!=(const key_value& lhs, const key_value& rhs) - { - return !(lhs == rhs); - } - - friend bool operator<(const key_value& lhs, const key_value& rhs) - { - if (lhs.key_ < rhs.key_) - { - return true; - } - if (lhs.key_ == rhs.key_ && lhs.value_ < rhs.value_) - { - return true; - } - return false; - } - - friend bool operator<=(const key_value& lhs, const key_value& rhs) - { - return !(rhs < lhs); - } - - friend bool operator>(const key_value& lhs, const key_value& rhs) - { - return !(lhs <= rhs); - } - - friend bool operator>=(const key_value& lhs, const key_value& rhs) - { - return !(lhs < rhs); - } -}; - -template -struct get_key_value -{ - typedef key_value key_value_type; - - template - key_value_type operator()(const std::pair& p) - { - return key_value_type(p.first,p.second); - } - template - key_value_type operator()(std::pair&& p) - { - return key_value_type(std::forward(p.first),std::forward(p.second)); - } - template - const key_value_type& operator()(const key_value& p) - { - return p; - } - template - key_value_type operator()(key_value&& p) - { - return std::move(p); - } -}; - -// json_array - -template -class container_base -{ -public: - typedef Allocator allocator_type; -private: - allocator_type allocator_; -public: - container_base() - : allocator_() - { - } - container_base(const allocator_type& allocator) - : allocator_(allocator) - { - } - - allocator_type get_allocator() const - { - return allocator_; - } -}; - -// json_array - -template -class json_array : public container_base -{ -public: - typedef typename Json::allocator_type allocator_type; - typedef Json value_type; -private: - typedef typename Json::implementation_policy implementation_policy; - typedef typename std::allocator_traits:: template rebind_alloc value_allocator_type; - using value_container_type = typename implementation_policy::template sequence_container_type; - value_container_type elements_; -public: - typedef typename value_container_type::iterator iterator; - typedef typename value_container_type::const_iterator const_iterator; - typedef typename std::iterator_traits::reference reference; - typedef typename std::iterator_traits::reference const_reference; - - using container_base::get_allocator; - - json_array() - { - } - - explicit json_array(const allocator_type& allocator) - : container_base(allocator), - elements_(value_allocator_type(allocator)) - { - } - - explicit json_array(size_t n, - const allocator_type& allocator = allocator_type()) - : container_base(allocator), - elements_(n,Json(),value_allocator_type(allocator)) - { - } - - explicit json_array(size_t n, - const Json& value, - const allocator_type& allocator = allocator_type()) - : container_base(allocator), - elements_(n,value,value_allocator_type(allocator)) - { - } - - template - json_array(InputIterator begin, InputIterator end, const allocator_type& allocator = allocator_type()) - : container_base(allocator), - elements_(begin,end,value_allocator_type(allocator)) - { - } - json_array(const json_array& val) - : container_base(val.get_allocator()), - elements_(val.elements_) - { - } - json_array(const json_array& val, const allocator_type& allocator) - : container_base(allocator), - elements_(val.elements_,value_allocator_type(allocator)) - { - } - - json_array(json_array&& val) noexcept - : container_base(val.get_allocator()), - elements_(std::move(val.elements_)) - { - } - json_array(json_array&& val, const allocator_type& allocator) - : container_base(allocator), - elements_(std::move(val.elements_),value_allocator_type(allocator)) - { - } - - json_array(std::initializer_list init) - : container_base(), - elements_(std::move(init)) - { - } - - json_array(std::initializer_list init, - const allocator_type& allocator) - : container_base(allocator), - elements_(std::move(init),value_allocator_type(allocator)) - { - } - ~json_array() - { - } - - void swap(json_array& val) - { - elements_.swap(val.elements_); - } - - size_t size() const {return elements_.size();} - - size_t capacity() const {return elements_.capacity();} - - void clear() {elements_.clear();} - - void shrink_to_fit() - { - for (size_t i = 0; i < elements_.size(); ++i) - { - elements_[i].shrink_to_fit(); - } - elements_.shrink_to_fit(); - } - - void reserve(size_t n) {elements_.reserve(n);} - - void resize(size_t n) {elements_.resize(n);} - - void resize(size_t n, const Json& val) {elements_.resize(n,val);} - -#if !defined(JSONCONS_NO_DEPRECATED) - void remove_range(size_t from_index, size_t to_index) - { - JSONCONS_ASSERT(from_index <= to_index); - JSONCONS_ASSERT(to_index <= elements_.size()); - elements_.erase(elements_.cbegin()+from_index,elements_.cbegin()+to_index); - } -#endif - void erase(const_iterator pos) - { -#if defined(JSONCONS_NO_ERASE_TAKING_CONST_ITERATOR) - iterator it = elements_.begin() + (pos - elements_.begin()); - elements_.erase(it); -#else - elements_.erase(pos); -#endif - } - - void erase(const_iterator first, const_iterator last) - { -#if defined(JSONCONS_NO_ERASE_TAKING_CONST_ITERATOR) - iterator it1 = elements_.begin() + (first - elements_.begin()); - iterator it2 = elements_.begin() + (last - elements_.begin()); - elements_.erase(it1,it2); -#else - elements_.erase(first,last); -#endif - } - - Json& operator[](size_t i) {return elements_[i];} - - const Json& operator[](size_t i) const {return elements_[i];} - - // push_back - - template - typename std::enable_if::value,void>::type - push_back(T&& value) - { - elements_.emplace_back(std::forward(value)); - } - - template - typename std::enable_if::value,void>::type - push_back(T&& value) - { - elements_.emplace_back(std::forward(value),get_allocator()); - } - - template - typename std::enable_if::value,iterator>::type - insert(const_iterator pos, T&& value) - { -#if defined(JSONCONS_NO_ERASE_TAKING_CONST_ITERATOR) - iterator it = elements_.begin() + (pos - elements_.begin()); - return elements_.emplace(it, std::forward(value)); -#else - return elements_.emplace(pos, std::forward(value)); -#endif - } - template - typename std::enable_if::value,iterator>::type - insert(const_iterator pos, T&& value) - { -#if defined(JSONCONS_NO_ERASE_TAKING_CONST_ITERATOR) - iterator it = elements_.begin() + (pos - elements_.begin()); - return elements_.emplace(it, std::forward(value), get_allocator()); -#else - return elements_.emplace(pos, std::forward(value), get_allocator()); -#endif - } - - template - iterator insert(const_iterator pos, InputIt first, InputIt last) - { -#if defined(JSONCONS_NO_ERASE_TAKING_CONST_ITERATOR) - iterator it = elements_.begin() + (pos - elements_.begin()); - elements_.insert(it, first, last); - return first == last ? it : it + 1; -#else - return elements_.insert(pos, first, last); -#endif - } - - template - typename std::enable_if::value,iterator>::type - emplace(const_iterator pos, Args&&... args) - { -#if defined(JSONCONS_NO_ERASE_TAKING_CONST_ITERATOR) - iterator it = elements_.begin() + (pos - elements_.begin()); - return elements_.emplace(it, std::forward(args)...); -#else - return elements_.emplace(pos, std::forward(args)...); -#endif - } - - template - Json& emplace_back(Args&&... args) - { - elements_.emplace_back(std::forward(args)...); - return elements_.back(); - } - - iterator begin() {return elements_.begin();} - - iterator end() {return elements_.end();} - - const_iterator begin() const {return elements_.begin();} - - const_iterator end() const {return elements_.end();} - - bool operator==(const json_array& rhs) const - { - return elements_ == rhs.elements_; - } - - bool operator<(const json_array& rhs) const - { - return elements_ < rhs.elements_; - } -private: - - json_array& operator=(const json_array&) = delete; -}; - -struct sorted_unique_range_tag -{ -}; - -// json_object - -template -class json_object -{ -}; - -// Sort keys -template -class json_object::type> : - public container_base -{ -public: - typedef typename Json::allocator_type allocator_type; - typedef KeyT key_type; - typedef key_value key_value_type; - typedef typename Json::char_type char_type; - typedef typename Json::string_view_type string_view_type; -private: - typedef typename Json::implementation_policy implementation_policy; - typedef typename std::allocator_traits:: template rebind_alloc key_value_allocator_type; - using key_value_container_type = typename implementation_policy::template sequence_container_type; - - key_value_container_type members_; -public: - typedef typename key_value_container_type::iterator iterator; - typedef typename key_value_container_type::const_iterator const_iterator; - - using container_base::get_allocator; - - json_object() - { - } - - explicit json_object(const allocator_type& allocator) - : container_base(allocator), - members_(key_value_allocator_type(allocator)) - { - } - - json_object(const json_object& val) - : container_base(val.get_allocator()), - members_(val.members_) - { - } - - json_object(json_object&& val) - : container_base(val.get_allocator()), - members_(std::move(val.members_)) - { - } - - json_object(const json_object& val, const allocator_type& allocator) - : container_base(allocator), - members_(val.members_,key_value_allocator_type(allocator)) - { - } - - json_object(json_object&& val,const allocator_type& allocator) - : container_base(allocator), members_(std::move(val.members_),key_value_allocator_type(allocator)) - { - } - - template - json_object(InputIt first, InputIt last) - { - size_t count = std::distance(first,last); - members_.reserve(count); - for (auto s = first; s != last; ++s) - { - members_.emplace_back(get_key_value()(*s)); - } - std::stable_sort(members_.begin(),members_.end(), - [](const key_value_type& a, const key_value_type& b){return a.key().compare(b.key()) < 0;}); - auto it = std::unique(members_.begin(), members_.end(), - [](const key_value_type& a, const key_value_type& b){ return !(a.key().compare(b.key()));}); - members_.erase(it, members_.end()); - } - - template - json_object(InputIt first, InputIt last, - const allocator_type& allocator) - : container_base(allocator), - members_(key_value_allocator_type(allocator)) - { - size_t count = std::distance(first,last); - members_.reserve(count); - for (auto s = first; s != last; ++s) - { - members_.emplace_back(get_key_value()(*s)); - } - std::stable_sort(members_.begin(),members_.end(), - [](const key_value_type& a, const key_value_type& b){return a.key().compare(b.key()) < 0;}); - auto it = std::unique(members_.begin(), members_.end(), - [](const key_value_type& a, const key_value_type& b){ return !(a.key().compare(b.key()));}); - members_.erase(it, members_.end()); - } - - json_object(std::initializer_list init) - { - for (const auto& element : init) - { - if (element.size() != 2 || !element[0].is_string()) - { - JSONCONS_THROW(json_runtime_error("Cannot create object from initializer list")); - break; - } - } - for (auto& element : init) - { - insert_or_assign(element[0].as_string_view(), std::move(element[1])); - } - } - - json_object(std::initializer_list init, - const allocator_type& allocator) - : container_base(allocator), - members_(key_value_allocator_type(allocator)) - { - for (const auto& element : init) - { - if (element.size() != 2 || !element[0].is_string()) - { - JSONCONS_THROW(json_runtime_error("Cannot create object from initializer list")); - break; - } - } - for (auto& element : init) - { - insert_or_assign(element[0].as_string_view(), std::move(element[1])); - } - } - - void swap(json_object& val) - { - members_.swap(val.members_); - } - - iterator begin() - { - return members_.begin(); - } - - iterator end() - { - return members_.end(); - } - - const_iterator begin() const - { - return members_.begin(); - } - - const_iterator end() const - { - return members_.end(); - } - - size_t size() const {return members_.size();} - - size_t capacity() const {return members_.capacity();} - - void clear() {members_.clear();} - - void shrink_to_fit() - { - for (size_t i = 0; i < members_.size(); ++i) - { - members_[i].shrink_to_fit(); - } - members_.shrink_to_fit(); - } - - void reserve(size_t n) {members_.reserve(n);} - - Json& at(size_t i) - { - if (i >= members_.size()) - { - JSONCONS_THROW(json_runtime_error("Invalid array subscript")); - } - return members_[i].value(); - } - - const Json& at(size_t i) const - { - if (i >= members_.size()) - { - JSONCONS_THROW(json_runtime_error("Invalid array subscript")); - } - return members_[i].value(); - } - - iterator find(const string_view_type& name) - { - auto it = std::lower_bound(members_.begin(),members_.end(), name, - [](const key_value_type& a, const string_view_type& k){return a.key().compare(k) < 0;}); - auto result = (it != members_.end() && it->key() == name) ? it : members_.end(); - return result; - } - - const_iterator find(const string_view_type& name) const - { - auto it = std::lower_bound(members_.begin(),members_.end(), - name, - [](const key_value_type& a, const string_view_type& k){return a.key().compare(k) < 0;}); - auto result = (it != members_.end() && it->key() == name) ? it : members_.end(); - return result; - } - - void erase(const_iterator pos) - { -#if defined(JSONCONS_NO_ERASE_TAKING_CONST_ITERATOR) - iterator it = members_.begin() + (pos - members_.begin()); - members_.erase(it); -#else - members_.erase(pos); -#endif - } - - void erase(const_iterator first, const_iterator last) - { -#if defined(JSONCONS_NO_ERASE_TAKING_CONST_ITERATOR) - iterator it1 = members_.begin() + (first - members_.begin()); - iterator it2 = members_.begin() + (last - members_.begin()); - members_.erase(it1,it2); -#else - members_.erase(first,last); -#endif - } - - void erase(const string_view_type& name) - { - auto it = std::lower_bound(members_.begin(),members_.end(), name, - [](const key_value_type& a, const string_view_type& k){return a.key().compare(k) < 0;}); - if (it != members_.end() && it->key() == name) - { - members_.erase(it); - } - } - - template - void insert(InputIt first, InputIt last, Convert convert) - { - size_t count = std::distance(first,last); - members_.reserve(members_.size() + count); - for (auto s = first; s != last; ++s) - { - members_.emplace_back(convert(*s)); - } - std::stable_sort(members_.begin(),members_.end(), - [](const key_value_type& a, const key_value_type& b){return a.key().compare(b.key()) < 0;}); - auto it = std::unique(members_.begin(), members_.end(), - [](const key_value_type& a, const key_value_type& b){ return !(a.key().compare(b.key()));}); - members_.erase(it, members_.end()); - } - - template - void insert(sorted_unique_range_tag, InputIt first, InputIt last, Convert convert) - { - if (first != last) - { - size_t count = std::distance(first,last); - members_.reserve(members_.size() + count); - - auto it = find(convert(*first).key()); - if (it != members_.end()) - { - for (auto s = first; s != last; ++s) - { - it = members_.emplace(it, convert(*s)); - } - } - else - { - for (auto s = first; s != last; ++s) - { - members_.emplace_back(convert(*s)); - } - } - } - } - - // insert_or_assign - - template - typename std::enable_if::value,std::pair>::type - insert_or_assign(const string_view_type& name, T&& value) - { - bool inserted; - auto it = std::lower_bound(members_.begin(),members_.end(), name, - [](const key_value_type& a, const string_view_type& k){return a.key().compare(k) < 0;}); - if (it == members_.end()) - { - members_.emplace_back(key_type(name.begin(),name.end()), - std::forward(value)); - inserted = true; - it = members_.begin() + members_.size() - 1; - } - else if (it->key() == name) - { - it->value(Json(std::forward(value))); - inserted = false; // assigned - } - else - { - it = members_.emplace(it, - key_type(name.begin(),name.end()), - std::forward(value)); - inserted = true; - } - return std::make_pair(it,inserted); - } - - template - typename std::enable_if::value,std::pair>::type - insert_or_assign(const string_view_type& name, T&& value) - { - bool inserted; - auto it = std::lower_bound(members_.begin(),members_.end(), name, - [](const key_value_type& a, const string_view_type& k){return a.key().compare(k) < 0;}); - if (it == members_.end()) - { - members_.emplace_back(key_type(name.begin(),name.end(), get_allocator()), - std::forward(value),get_allocator()); - inserted = true; - it = members_.begin() + members_.size() - 1; - } - else if (it->key() == name) - { - it->value(Json(std::forward(value), get_allocator())); - inserted = false; // assigned - } - else - { - it = members_.emplace(it, - key_type(name.begin(),name.end(), get_allocator()), - std::forward(value),get_allocator()); - inserted = true; - } - return std::make_pair(it,inserted); - } - - // try_emplace - - template - typename std::enable_if::value,std::pair>::type - try_emplace(const string_view_type& name, Args&&... args) - { - bool inserted; - auto it = std::lower_bound(members_.begin(),members_.end(), name, - [](const key_value_type& a, const string_view_type& k){return a.key().compare(k) < 0;}); - if (it == members_.end()) - { - members_.emplace_back(key_type(name.begin(),name.end()), - std::forward(args)...); - it = members_.begin() + members_.size() - 1; - inserted = true; - } - else if (it->key() == name) - { - inserted = false; - } - else - { - it = members_.emplace(it, - key_type(name.begin(),name.end()), - std::forward(args)...); - inserted = true; - } - return std::make_pair(it,inserted); - } - - template - typename std::enable_if::value,std::pair>::type - try_emplace(const string_view_type& name, Args&&... args) - { - bool inserted; - auto it = std::lower_bound(members_.begin(),members_.end(), name, - [](const key_value_type& a, const string_view_type& k){return a.key().compare(k) < 0;}); - if (it == members_.end()) - { - members_.emplace_back(key_type(name.begin(),name.end(), get_allocator()), - std::forward(args)...); - it = members_.begin() + members_.size() - 1; - inserted = true; - } - else if (it->key() == name) - { - inserted = false; - } - else - { - it = members_.emplace(it, - key_type(name.begin(),name.end(), get_allocator()), - std::forward(args)...); - inserted = true; - } - return std::make_pair(it,inserted); - } - - template - typename std::enable_if::value,iterator>::type - try_emplace(iterator hint, const string_view_type& name, Args&&... args) - { - iterator it = hint; - - if (hint != members_.end() && hint->key() <= name) - { - it = std::lower_bound(hint,members_.end(), name, - [](const key_value_type& a, const string_view_type& k){return a.key().compare(k) < 0;}); - } - else - { - it = std::lower_bound(members_.begin(),members_.end(), name, - [](const key_value_type& a, const string_view_type& k){return a.key().compare(k) < 0;}); - } - - if (it == members_.end()) - { - members_.emplace_back(key_type(name.begin(),name.end()), - std::forward(args)...); - it = members_.begin() + (members_.size() - 1); - } - else if (it->key() == name) - { - } - else - { - it = members_.emplace(it, - key_type(name.begin(),name.end()), - std::forward(args)...); - } - - return it; - } - - template - typename std::enable_if::value,iterator>::type - try_emplace(iterator hint, const string_view_type& name, Args&&... args) - { - iterator it = hint; - if (hint != members_.end() && hint->key() <= name) - { - it = std::lower_bound(hint,members_.end(), name, - [](const key_value_type& a, const string_view_type& k){return a.key().compare(k) < 0;}); - } - else - { - it = std::lower_bound(members_.begin(),members_.end(), name, - [](const key_value_type& a, const string_view_type& k){return a.key().compare(k) < 0;}); - } - - if (it == members_.end()) - { - members_.emplace_back(key_type(name.begin(),name.end(), get_allocator()), - std::forward(args)...); - it = members_.begin() + (members_.size() - 1); - } - else if (it->key() == name) - { - } - else - { - it = members_.emplace(it, - key_type(name.begin(),name.end(), get_allocator()), - std::forward(args)...); - } - return it; - } - - // insert_or_assign - - template - typename std::enable_if::value,iterator>::type - insert_or_assign(iterator hint, const string_view_type& name, T&& value) - { - iterator it; - if (hint != members_.end() && hint->key() <= name) - { - it = std::lower_bound(hint,members_.end(), name, - [](const key_value_type& a, const string_view_type& k){return a.key().compare(k) < 0;}); - } - else - { - it = std::lower_bound(members_.begin(),members_.end(), name, - [](const key_value_type& a, const string_view_type& k){return a.key().compare(k) < 0;}); - } - - if (it == members_.end()) - { - members_.emplace_back(key_type(name.begin(),name.end()), - std::forward(value)); - it = members_.begin() + (members_.size() - 1); - } - else if (it->key() == name) - { - it->value(Json(std::forward(value))); - } - else - { - it = members_.emplace(it, - key_type(name.begin(),name.end()), - std::forward(value)); - } - return it; - } - - template - typename std::enable_if::value,iterator>::type - insert_or_assign(iterator hint, const string_view_type& name, T&& value) - { - iterator it; - if (hint != members_.end() && hint->key() <= name) - { - it = std::lower_bound(hint,members_.end(), name, - [](const key_value_type& a, const string_view_type& k){return a.key().compare(k) < 0;}); - } - else - { - it = std::lower_bound(members_.begin(),members_.end(), name, - [](const key_value_type& a, const string_view_type& k){return a.key().compare(k) < 0;}); - } - - if (it == members_.end()) - { - members_.emplace_back(key_type(name.begin(),name.end(), get_allocator()), - std::forward(value),get_allocator()); - it = members_.begin() + (members_.size() - 1); - } - else if (it->key() == name) - { - it->value(Json(std::forward(value),get_allocator())); - } - else - { - it = members_.emplace(it, - key_type(name.begin(),name.end(), get_allocator()), - std::forward(value),get_allocator()); - } - return it; - } - - // merge - - void merge(const json_object& source) - { - for (auto it = source.begin(); it != source.end(); ++it) - { - try_emplace(it->key(),it->value()); - } - } - - void merge(json_object&& source) - { - auto it = std::make_move_iterator(source.begin()); - auto end = std::make_move_iterator(source.end()); - for (; it != end; ++it) - { - auto pos = std::lower_bound(members_.begin(),members_.end(), it->key(), - [](const key_value_type& a, const string_view_type& k){return a.key().compare(k) < 0;}); - if (pos == members_.end() ) - { - members_.emplace_back(*it); - } - else if (it->key() != pos->key()) - { - members_.emplace(pos,*it); - } - } - } - - void merge(iterator hint, const json_object& source) - { - for (auto it = source.begin(); it != source.end(); ++it) - { - hint = try_emplace(hint, it->key(),it->value()); - } - } - - void merge(iterator hint, json_object&& source) - { - auto it = std::make_move_iterator(source.begin()); - auto end = std::make_move_iterator(source.end()); - for (; it != end; ++it) - { - iterator pos; - if (hint != members_.end() && hint->key() <= it->key()) - { - pos = std::lower_bound(hint,members_.end(), it->key(), - [](const key_value_type& a, const string_view_type& k){return a.key().compare(k) < 0;}); - } - else - { - pos = std::lower_bound(members_.begin(),members_.end(), it->key(), - [](const key_value_type& a, const string_view_type& k){return a.key().compare(k) < 0;}); - } - if (pos == members_.end() ) - { - members_.emplace_back(*it); - hint = members_.begin() + (members_.size() - 1); - } - else if (it->key() != pos->key()) - { - hint = members_.emplace(pos,*it); - } - } - } - - // merge_or_update - - void merge_or_update(const json_object& source) - { - for (auto it = source.begin(); it != source.end(); ++it) - { - insert_or_assign(it->key(),it->value()); - } - } - - void merge_or_update(json_object&& source) - { - auto it = std::make_move_iterator(source.begin()); - auto end = std::make_move_iterator(source.end()); - for (; it != end; ++it) - { - auto pos = std::lower_bound(members_.begin(),members_.end(), it->key(), - [](const key_value_type& a, const string_view_type& k){return a.key().compare(k) < 0;}); - if (pos == members_.end() ) - { - members_.emplace_back(*it); - } - else - { - pos->value(it->value()); - } - } - } - - void merge_or_update(iterator hint, const json_object& source) - { - for (auto it = source.begin(); it != source.end(); ++it) - { - hint = insert_or_assign(hint, it->key(),it->value()); - } - } - - void merge_or_update(iterator hint, json_object&& source) - { - auto it = std::make_move_iterator(source.begin()); - auto end = std::make_move_iterator(source.end()); - for (; it != end; ++it) - { - iterator pos; - if (hint != members_.end() && hint->key() <= it->key()) - { - pos = std::lower_bound(hint,members_.end(), it->key(), - [](const key_value_type& a, const string_view_type& k){return a.key().compare(k) < 0;}); - } - else - { - pos = std::lower_bound(members_.begin(),members_.end(), it->key(), - [](const key_value_type& a, const string_view_type& k){return a.key().compare(k) < 0;}); - } - if (pos == members_.end() ) - { - members_.emplace_back(*it); - hint = members_.begin() + (members_.size() - 1); - } - else - { - pos->value(it->value()); - hint = pos; - } - } - } - - bool operator==(const json_object& rhs) const - { - return members_ == rhs.members_; - } - - bool operator<(const json_object& rhs) const - { - return members_ < rhs.members_; - } -private: - json_object& operator=(const json_object&) = delete; -}; - -// Preserve order -template -class json_object::type> : - public container_base -{ -public: - typedef typename Json::allocator_type allocator_type; - typedef typename Json::char_type char_type; - typedef KeyT key_type; - typedef typename Json::string_view_type string_view_type; - typedef key_value key_value_type; -private: - typedef typename Json::implementation_policy implementation_policy; - typedef typename std::allocator_traits:: template rebind_alloc key_value_allocator_type; - using key_value_container_type = typename implementation_policy::template sequence_container_type; - typedef typename std::allocator_traits:: template rebind_alloc index_allocator_type; - using index_container_type = typename implementation_policy::template sequence_container_type; - - key_value_container_type members_; - index_container_type index_; -public: - typedef typename key_value_container_type::iterator iterator; - typedef typename key_value_container_type::const_iterator const_iterator; - - using container_base::get_allocator; - - json_object() - { - } - json_object(const allocator_type& allocator) - : container_base(allocator), - members_(key_value_allocator_type(allocator)), - index_(index_allocator_type(allocator)) - { - } - - json_object(const json_object& val) - : container_base(val.get_allocator()), - members_(val.members_), - index_(val.index_) - { - } - - json_object(json_object&& val) - : container_base(val.get_allocator()), - members_(std::move(val.members_)), - index_(std::move(val.index_)) - { - } - - json_object(const json_object& val, const allocator_type& allocator) - : container_base(allocator), - members_(val.members_,key_value_allocator_type(allocator)), - index_(val.index_,index_allocator_type(allocator)) - { - } - - json_object(json_object&& val,const allocator_type& allocator) - : container_base(allocator), - members_(std::move(val.members_),key_value_allocator_type(allocator)), - index_(std::move(val.index_),index_allocator_type(allocator)) - { - } - - template - json_object(InputIt first, InputIt last) - { - size_t count = std::distance(first,last); - members_.reserve(count); - for (auto s = first; s != last; ++s) - { - members_.emplace_back(get_key_value()(*s)); - } - - build_index(); - auto last_unique = std::unique(index_.begin(), index_.end(), - [&](size_t a, size_t b) { return !(members_.at(a).key().compare(members_.at(b).key())); }); - - if (last_unique != index_.end()) - { - index_.erase(last_unique, index_.end()); - std::sort(index_.begin(), index_.end()); - - auto result = index_.rbegin(); - if (*result != members_.size()) - { - members_.erase(members_.begin() + (*result + 1), members_.end()); - } - for (auto it = index_.rbegin() + 1; it != index_.rend(); ++it, ++result) - { - if (*result - *it > 1) - { - members_.erase(members_.begin() + (*it + 1), members_.begin() + *result); - } - } - } - build_index(); - } - - template - json_object(InputIt first, InputIt last, - const allocator_type& allocator) - : container_base(allocator), - members_(key_value_allocator_type(allocator)), - index_(index_allocator_type(allocator)) - { - size_t count = std::distance(first,last); - members_.reserve(count); - for (auto s = first; s != last; ++s) - { - members_.emplace_back(get_key_value()(*s)); - } - - build_index(); - auto last_unique = std::unique(index_.begin(), index_.end(), - [&](size_t a, size_t b) { return !(members_.at(a).key().compare(members_.at(b).key())); }); - - if (last_unique != index_.end()) - { - index_.erase(last_unique, index_.end()); - std::sort(index_.begin(), index_.end()); - - auto result = index_.rbegin(); - if (*result != members_.size()) - { - members_.erase(members_.begin() + (*result + 1), members_.end()); - } - for (auto it = index_.rbegin() + 1; it != index_.rend(); ++it, ++result) - { - if (*result - *it > 1) - { - members_.erase(members_.begin() + (*it + 1), members_.begin() + *result); - } - } - } - build_index(); - } - - json_object(std::initializer_list init) - { - for (const auto& element : init) - { - if (element.size() != 2 || !element[0].is_string()) - { - JSONCONS_THROW(json_runtime_error("Cannot create object from initializer list")); - break; - } - } - for (auto& element : init) - { - insert_or_assign(element[0].as_string_view(), std::move(element[1])); - } - } - - json_object(std::initializer_list init, - const allocator_type& allocator) - : container_base(allocator), - members_(key_value_allocator_type(allocator)), - index_(index_allocator_type(allocator)) - { - for (const auto& element : init) - { - if (element.size() != 2 || !element[0].is_string()) - { - JSONCONS_THROW(json_runtime_error("Cannot create object from initializer list")); - break; - } - } - for (auto& element : init) - { - insert_or_assign(element[0].as_string_view(), std::move(element[1])); - } - } - - void swap(json_object& val) - { - members_.swap(val.members_); - } - - iterator begin() - { - return members_.begin(); - } - - iterator end() - { - return members_.end(); - } - - const_iterator begin() const - { - return members_.begin(); - } - - const_iterator end() const - { - return members_.end(); - } - - size_t size() const {return members_.size();} - - size_t capacity() const {return members_.capacity();} - - void clear() - { - members_.clear(); - index_.clear(); - } - - void shrink_to_fit() - { - for (size_t i = 0; i < members_.size(); ++i) - { - members_[i].shrink_to_fit(); - } - members_.shrink_to_fit(); - index_.shrink_to_fit(); - } - - void reserve(size_t n) {members_.reserve(n);} - - Json& at(size_t i) - { - if (i >= members_.size()) - { - JSONCONS_THROW(json_runtime_error("Invalid array subscript")); - } - return members_[i].value(); - } - - const Json& at(size_t i) const - { - if (i >= members_.size()) - { - JSONCONS_THROW(json_runtime_error("Invalid array subscript")); - } - return members_[i].value(); - } - - iterator find(const string_view_type& name) - { - auto it = std::lower_bound(index_.begin(),index_.end(), name, - [&](size_t i, const string_view_type& k){return members_.at(i).key().compare(k) < 0;}); - if (it != index_.end() && members_.at(*it).key() == name) - { - return members_.begin() + *it; - } - else - { - return members_.end(); - } - } - - const_iterator find(const string_view_type& name) const - { - auto it = std::lower_bound(index_.begin(),index_.end(), name, - [&](size_t i, const string_view_type& k){return members_.at(i).key().compare(k) < 0;}); - if (it != index_.end() && members_.at(*it).key() == name) - { - return members_.begin() + *it; - } - else - { - return members_.end(); - } - } - - void erase(const_iterator first, const_iterator last) - { - size_t pos1 = first == members_.end() ? members_.size() : first - members_.begin(); - size_t pos2 = last == members_.end() ? members_.size() : last - members_.begin(); - - if (pos1 < members_.size() && pos2 <= members_.size()) - { - erase_index_entries(pos1,pos2); - -#if defined(JSONCONS_NO_ERASE_TAKING_CONST_ITERATOR) - iterator it1 = members_.begin() + (first - members_.begin()); - iterator it2 = members_.begin() + (last - members_.begin()); - members_.erase(it1,it2); -#else - members_.erase(first,last); -#endif - } - } - - void erase(const string_view_type& name) - { - auto pos = find(name); - if (pos != members_.end()) - { - erase_index_entry(name); -#if defined(JSONCONS_NO_ERASE_TAKING_CONST_ITERATOR) - iterator it = members_.begin() + (pos - members_.begin()); - members_.erase(it); -#else - members_.erase(pos); -#endif - } - } - - template - void insert(InputIt first, InputIt last, Convert convert) - { - size_t count = std::distance(first,last); - members_.reserve(members_.size() + count); - for (auto s = first; s != last; ++s) - { - members_.emplace_back(convert(*s)); - } - - build_index(); - auto last_unique = std::unique(index_.begin(), index_.end(), - [&](size_t a, size_t b) { return !(members_.at(a).key().compare(members_.at(b).key())); }); - - if (last_unique != index_.end()) - { - index_.erase(last_unique, index_.end()); - std::sort(index_.begin(), index_.end()); - - auto result = index_.rbegin(); - if (*result != members_.size()) - { - members_.erase(members_.begin() + (*result + 1), members_.end()); - } - for (auto it = index_.rbegin() + 1; it != index_.rend(); ++it, ++result) - { - if (*result - *it > 1) - { - members_.erase(members_.begin() + (*it + 1), members_.begin() + *result); - } - } - } - build_index(); - } - - template - void insert(sorted_unique_range_tag, InputIt first, InputIt last, Convert convert) - { - size_t count = std::distance(first,last); - - members_.reserve(members_.size() + count); - for (auto s = first; s != last; ++s) - { - members_.emplace_back(convert(*s)); - } - - build_index(); - } - - template - typename std::enable_if::value,std::pair>::type - insert_or_assign(const string_view_type& name, T&& value) - { - auto result = insert_index_entry(name,members_.size()); - if (result.second) - { - members_.emplace_back(key_type(name.begin(), name.end()), std::forward(value)); - auto it = members_.begin() + result.first; - return std::make_pair(it,true); - } - else - { - auto it = members_.begin() + result.first; - it->value(Json(std::forward(value))); - return std::make_pair(it,false); - } - } - - template - typename std::enable_if::value,std::pair>::type - insert_or_assign(const string_view_type& name, T&& value) - { - auto result = insert_index_entry(name,members_.size()); - if (result.second) - { - members_.emplace_back(key_type(name.begin(),name.end(),get_allocator()), - std::forward(value),get_allocator()); - auto it = members_.begin() + result.first; - return std::make_pair(it,true); - } - else - { - auto it = members_.begin() + result.first; - it->value(Json(std::forward(value),get_allocator())); - return std::make_pair(it,false); - } - } - - template - typename std::enable_if::value,iterator>::type - insert_or_assign(iterator hint, const string_view_type& key, T&& value) - { - if (hint == members_.end()) - { - auto result = insert_or_assign(key, std::forward(value)); - return result.first; - } - else - { - size_t pos = hint - members_.begin(); - auto result = insert_index_entry(key,pos); - - if (result.second) - { - auto it = members_.emplace(hint, key_type(key.begin(), key.end()), std::forward(value)); - return it; - } - else - { - auto it = members_.begin() + result.first; - it->value(Json(std::forward(value))); - return it; - } - } - } - - template - typename std::enable_if::value,iterator>::type - insert_or_assign(iterator hint, const string_view_type& key, T&& value) - { - if (hint == members_.end()) - { - auto result = insert_or_assign(key, std::forward(value)); - return result.first; - } - else - { - size_t pos = hint - members_.begin(); - auto result = insert_index_entry(key,pos); - - if (result.second) - { - auto it = members_.emplace(hint, - key_type(key.begin(),key.end(),get_allocator()), - std::forward(value),get_allocator()); - return it; - } - else - { - auto it = members_.begin() + result.first; - it->value(Json(std::forward(value),get_allocator())); - return it; - } - } - } - - // merge - - void merge(const json_object& source) - { - for (auto it = source.begin(); it != source.end(); ++it) - { - try_emplace(it->key(),it->value()); - } - } - - void merge(json_object&& source) - { - auto it = std::make_move_iterator(source.begin()); - auto end = std::make_move_iterator(source.end()); - for (; it != end; ++it) - { - auto pos = find(it->key()); - if (pos == members_.end() ) - { - try_emplace(it->key(),std::move(it->value())); - } - } - } - - void merge(iterator hint, const json_object& source) - { - size_t pos = hint - members_.begin(); - for (auto it = source.begin(); it != source.end(); ++it) - { - hint = try_emplace(hint, it->key(),it->value()); - size_t newpos = hint - members_.begin(); - if (newpos == pos) - { - ++hint; - pos = hint - members_.begin(); - } - else - { - hint = members_.begin() + pos; - } - } - } - - void merge(iterator hint, json_object&& source) - { - size_t pos = hint - members_.begin(); - - auto it = std::make_move_iterator(source.begin()); - auto end = std::make_move_iterator(source.end()); - for (; it != end; ++it) - { - hint = try_emplace(hint, it->key(), std::move(it->value())); - size_t newpos = hint - members_.begin(); - if (newpos == pos) - { - ++hint; - pos = hint - members_.begin(); - } - else - { - hint = members_.begin() + pos; - } - } - } - - // merge_or_update - - void merge_or_update(const json_object& source) - { - for (auto it = source.begin(); it != source.end(); ++it) - { - insert_or_assign(it->key(),it->value()); - } - } - - void merge_or_update(json_object&& source) - { - auto it = std::make_move_iterator(source.begin()); - auto end = std::make_move_iterator(source.end()); - for (; it != end; ++it) - { - auto pos = find(it->key()); - if (pos == members_.end() ) - { - insert_or_assign(it->key(),std::move(it->value())); - } - else - { - pos->value(std::move(it->value())); - } - } - } - - void merge_or_update(iterator hint, const json_object& source) - { - size_t pos = hint - members_.begin(); - for (auto it = source.begin(); it != source.end(); ++it) - { - hint = insert_or_assign(hint, it->key(),it->value()); - size_t newpos = hint - members_.begin(); - if (newpos == pos) - { - ++hint; - pos = hint - members_.begin(); - } - else - { - hint = members_.begin() + pos; - } - } - } - - void merge_or_update(iterator hint, json_object&& source) - { -/* - auto it = std::make_move_iterator(source.begin()); - auto end = std::make_move_iterator(source.end()); - for (; it != end; ++it) - { - auto pos = find(it->key()); - if (pos == members_.end() ) - { - hint = try_emplace(hint,it->key(),std::move(it->value())); - } - else - { - pos->value(std::move(it->value())); - hint = pos; - } - } -*/ - size_t pos = hint - members_.begin(); - auto it = std::make_move_iterator(source.begin()); - auto end = std::make_move_iterator(source.end()); - for (; it != end; ++it) - { - hint = insert_or_assign(hint, it->key(),std::move(it->value())); - size_t newpos = hint - members_.begin(); - if (newpos == pos) - { - ++hint; - pos = hint - members_.begin(); - } - else - { - hint = members_.begin() + pos; - } - } - } - - // try_emplace - - template - typename std::enable_if::value,std::pair>::type - try_emplace(const string_view_type& name, Args&&... args) - { - auto result = insert_index_entry(name,members_.size()); - if (result.second) - { - members_.emplace_back(key_type(name.begin(), name.end()), std::forward(args)...); - auto it = members_.begin() + result.first; - return std::make_pair(it,true); - } - else - { - auto it = members_.begin() + result.first; - return std::make_pair(it,false); - } - } - - template - typename std::enable_if::value,std::pair>::type - try_emplace(const string_view_type& key, Args&&... args) - { - auto result = insert_index_entry(key,members_.size()); - if (result.second) - { - members_.emplace_back(key_type(key.begin(),key.end(), get_allocator()), - std::forward(args)...); - auto it = members_.begin() + result.first; - return std::make_pair(it,true); - } - else - { - auto it = members_.begin() + result.first; - return std::make_pair(it,false); - } - } - - template - typename std::enable_if::value,iterator>::type - try_emplace(iterator hint, const string_view_type& key, Args&&... args) - { - if (hint == members_.end()) - { - auto result = try_emplace(key, std::forward(args)...); - return result.first; - } - else - { - size_t pos = hint - members_.begin(); - auto result = insert_index_entry(key, pos); - - if (result.second) - { - auto it = members_.emplace(hint, key_type(key.begin(), key.end()), std::forward(args)...); - return it; - } - else - { - auto it = members_.begin() + result.first; - return it; - } - } - } - - template - typename std::enable_if::value,iterator>::type - try_emplace(iterator hint, const string_view_type& key, Args&&... args) - { - if (hint == members_.end()) - { - auto result = try_emplace(key, std::forward(args)...); - return result.first; - } - else - { - size_t pos = hint - members_.begin(); - auto result = insert_index_entry(key, pos); - - if (result.second) - { - auto it = members_.emplace(hint, - key_type(key.begin(),key.end(), get_allocator()), - std::forward(args)...); - return it; - } - else - { - auto it = members_.begin() + result.first; - return it; - } - } - } - - bool operator==(const json_object& rhs) const - { - return members_ == rhs.members_; - } - - bool operator<(const json_object& rhs) const - { - return members_ < rhs.members_; - } -private: - - std::pair insert_index_entry(const string_view_type& key, size_t pos) - { - JSONCONS_ASSERT(pos <= index_.size()); - - auto it = std::lower_bound(index_.begin(),index_.end(), key, - [&](size_t i, const string_view_type& k){return members_.at(i).key().compare(k) < 0;}); - - if (it == index_.end()) - { - size_t count = index_.size() - pos; - for (size_t i = 0; count > 0 && i < index_.size(); ++i) - { - if (index_[i] >= pos) - { - ++index_[i]; - --count; - } - } - index_.push_back(pos); - return std::make_pair(pos,true); - } - else if (members_.at(*it).key() != key) - { - size_t count = index_.size() - pos; - for (size_t i = 0; count > 0 && i < index_.size(); ++i) - { - if (index_[i] >= pos) - { - ++index_[i]; - --count; - } - } - auto it2 = index_.insert(it, pos); - return std::make_pair(*it2,true); - } - else - { - return std::make_pair(*it,false); - } - } - - void erase_index_entry(const string_view_type& key) - { - auto it = std::lower_bound(index_.begin(),index_.end(), key, - [&](size_t i, const string_view_type& k){return members_.at(i).key().compare(k) < 0;}); - - if (it != index_.end() && members_.at(*it).key() != key) - { - size_t pos = *it; - size_t count = index_.size() - pos; - for (size_t i = 0; i < index_.size() && count > 0; ++i) - { - if (index_[i] > pos) - { - --index_[i]; - --count; - } - } - index_.erase(it); - } - } - - void erase_index_entries(size_t pos1, size_t pos2) - { - for (size_t i = 0; i < index_.size(); ++i) - { - if (index_[i] >= pos1 && index_[i] < pos2) - { - index_.erase(index_.begin()+index_[i]); - } - else if (index_[i] > pos2) - { - --index_[i]; - } - } - } - - void build_index() - { - index_.clear(); - index_.reserve(members_.size()); - for (size_t i = 0; i < members_.size(); ++i) - { - index_.push_back(i); - } - std::stable_sort(index_.begin(),index_.end(), - [&](size_t a, size_t b){return members_.at(a).key().compare(members_.at(b).key()) < 0;}); - } - - json_object& operator=(const json_object&) = delete; -}; - -} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/json_content_handler.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/json_content_handler.hpp deleted file mode 100644 index 131e2b6729..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/json_content_handler.hpp +++ /dev/null @@ -1,431 +0,0 @@ -// Copyright 2018 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_JSON_CONTENT_HANDLER_HPP -#define JSONCONS_JSON_CONTENT_HANDLER_HPP - -#include -#include -#include -#include -#include - -namespace jsoncons { - -// null_type - -struct null_type -{ -}; - -enum class semantic_tag : uint8_t -{ - none = 0, - undefined = 0x01, - datetime = 0x02, - timestamp = 0x03, - bigint = 0x04, - bigdec = 0x05, - bigfloat = 0x06, - base16 = 0x07, - base64 = 0x08, - base64url = 0x09, - uri = 0x0a -#if !defined(JSONCONS_NO_DEPRECATED) - , big_integer = bigint - , big_decimal = bigdec - , big_float = bigfloat - , date_time = datetime -#endif -}; - -#if !defined(JSONCONS_NO_DEPRECATED) - typedef semantic_tag semantic_tag_type; -#endif - -template -class basic_json_content_handler -{ -#if !defined(JSONCONS_NO_DEPRECATED) - std::basic_string buffer_; -#endif -public: - typedef CharT char_type; - typedef std::char_traits char_traits_type; - - typedef basic_string_view string_view_type; - - basic_json_content_handler(basic_json_content_handler&&) = default; - - basic_json_content_handler& operator=(basic_json_content_handler&&) = default; - - basic_json_content_handler() = default; - - virtual ~basic_json_content_handler() {} - - void flush() - { - do_flush(); - } - - bool begin_object(semantic_tag tag=semantic_tag::none, - const ser_context& context=null_ser_context()) - { - return do_begin_object(tag, context); - } - - bool begin_object(size_t length, - semantic_tag tag=semantic_tag::none, - const ser_context& context = null_ser_context()) - { - return do_begin_object(length, tag, context); - } - - bool end_object(const ser_context& context = null_ser_context()) - { - return do_end_object(context); - } - - bool begin_array(semantic_tag tag=semantic_tag::none, - const ser_context& context=null_ser_context()) - { - return do_begin_array(tag, context); - } - - bool begin_array(size_t length, - semantic_tag tag=semantic_tag::none, - const ser_context& context=null_ser_context()) - { - return do_begin_array(length, tag, context); - } - - bool end_array(const ser_context& context=null_ser_context()) - { - return do_end_array(context); - } - - bool name(const string_view_type& name, const ser_context& context=null_ser_context()) - { - return do_name(name, context); - } - - bool string_value(const string_view_type& value, - semantic_tag tag = semantic_tag::none, - const ser_context& context=null_ser_context()) - { - return do_string_value(value, tag, context); - } - - bool byte_string_value(const byte_string_view& b, - semantic_tag tag=semantic_tag::none, - const ser_context& context=null_ser_context()) - { - return do_byte_string_value(b, tag, context); - } - - bool byte_string_value(const uint8_t* p, size_t size, - semantic_tag tag=semantic_tag::none, - const ser_context& context=null_ser_context()) - { - return do_byte_string_value(byte_string(p, size), tag, context); - } -#if !defined(JSONCONS_NO_DEPRECATED) - bool byte_string_value(const byte_string_view& b, - byte_string_chars_format encoding_hint, - semantic_tag tag=semantic_tag::none, - const ser_context& context=null_ser_context()) - { - switch (encoding_hint) - { - case byte_string_chars_format::base16: - tag = semantic_tag::base16; - break; - case byte_string_chars_format::base64: - tag = semantic_tag::base64; - break; - case byte_string_chars_format::base64url: - tag = semantic_tag::base64url; - break; - default: - break; - } - return do_byte_string_value(b, tag, context); - } - - bool byte_string_value(const uint8_t* p, size_t size, - byte_string_chars_format encoding_hint, - semantic_tag tag=semantic_tag::none, - const ser_context& context=null_ser_context()) - { - switch (encoding_hint) - { - case byte_string_chars_format::base16: - tag = semantic_tag::base16; - break; - case byte_string_chars_format::base64: - tag = semantic_tag::base64; - break; - case byte_string_chars_format::base64url: - tag = semantic_tag::base64url; - break; - default: - break; - } - return do_byte_string_value(byte_string(p, size), tag, context); - } - bool big_integer_value(const string_view_type& s, const ser_context& context=null_ser_context()) - { - return do_string_value(s, semantic_tag::bigint, context); - } - - bool big_decimal_value(const string_view_type& s, const ser_context& context=null_ser_context()) - { - return do_string_value(s, semantic_tag::bigdec, context); - } - - bool date_time_value(const string_view_type& s, const ser_context& context=null_ser_context()) - { - return do_string_value(s, semantic_tag::datetime, context); - } - - bool timestamp_value(int64_t val, const ser_context& context=null_ser_context()) - { - return do_int64_value(val, semantic_tag::timestamp, context); - } -#endif - - bool int64_value(int64_t value, - semantic_tag tag = semantic_tag::none, - const ser_context& context=null_ser_context()) - { - return do_int64_value(value, tag, context); - } - - bool uint64_value(uint64_t value, - semantic_tag tag = semantic_tag::none, - const ser_context& context=null_ser_context()) - { - return do_uint64_value(value, tag, context); - } - - bool double_value(double value, - semantic_tag tag = semantic_tag::none, - const ser_context& context=null_ser_context()) - { - return do_double_value(value, tag, context); - } - - bool bool_value(bool value, - semantic_tag tag = semantic_tag::none, - const ser_context& context=null_ser_context()) - { - return do_bool_value(value, tag, context); - } - - bool null_value(semantic_tag tag = semantic_tag::none, - const ser_context& context=null_ser_context()) - { - return do_null_value(tag, context); - } - -#if !defined(JSONCONS_NO_DEPRECATED) - - bool begin_document() - { - return true; - } - - bool end_document() - { - flush(); - return true; - } - - void begin_json() - { - } - - void end_json() - { - end_document(); - } - - void name(const CharT* p, size_t length, const ser_context& context) - { - name(string_view_type(p, length), context); - } - - void integer_value(int64_t value) - { - int64_value(value); - } - - void integer_value(int64_t value, const ser_context& context) - { - int64_value(value,context); - } - - void uinteger_value(uint64_t value) - { - uint64_value(value); - } - - void uinteger_value(uint64_t value, const ser_context& context) - { - uint64_value(value,context); - } - - bool bignum_value(const string_view_type& s, const ser_context& context=null_ser_context()) - { - return do_string_value(s, semantic_tag::bigint, context); - } - - bool decimal_value(const string_view_type& s, const ser_context& context=null_ser_context()) - { - return do_string_value(s, semantic_tag::bigdec, context); - } - - bool epoch_time_value(int64_t val, const ser_context& context=null_ser_context()) - { - return do_int64_value(val, semantic_tag::timestamp, context); - } - -#endif - -private: - virtual void do_flush() = 0; - - virtual bool do_begin_object(semantic_tag, const ser_context& context) = 0; - - virtual bool do_begin_object(size_t, semantic_tag tag, const ser_context& context) - { - return do_begin_object(tag, context); - } - - virtual bool do_end_object(const ser_context& context) = 0; - - virtual bool do_begin_array(semantic_tag, const ser_context& context) = 0; - - virtual bool do_begin_array(size_t, semantic_tag tag, const ser_context& context) - { - return do_begin_array(tag, context); - } - - virtual bool do_end_array(const ser_context& context) = 0; - - virtual bool do_name(const string_view_type& name, const ser_context& context) = 0; - - virtual bool do_null_value(semantic_tag, const ser_context& context) = 0; - - virtual bool do_string_value(const string_view_type& value, semantic_tag tag, const ser_context& context) = 0; - - virtual bool do_byte_string_value(const byte_string_view& b, - semantic_tag tag, - const ser_context& context) = 0; - - virtual bool do_double_value(double value, - semantic_tag tag, - const ser_context& context) = 0; - - virtual bool do_int64_value(int64_t value, - semantic_tag tag, - const ser_context& context) = 0; - - virtual bool do_uint64_value(uint64_t value, - semantic_tag tag, - const ser_context& context) = 0; - - virtual bool do_bool_value(bool value, semantic_tag tag, const ser_context& context) = 0; -}; - -template -class basic_null_json_content_handler final : public basic_json_content_handler -{ -public: - using typename basic_json_content_handler::string_view_type; -private: - void do_flush() override - { - } - - bool do_begin_object(semantic_tag, const ser_context&) override - { - return true; - } - - bool do_end_object(const ser_context&) override - { - return true; - } - - bool do_begin_array(semantic_tag, const ser_context&) override - { - return true; - } - - bool do_end_array(const ser_context&) override - { - return true; - } - - bool do_name(const string_view_type&, const ser_context&) override - { - return true; - } - - bool do_null_value(semantic_tag, const ser_context&) override - { - return true; - } - - bool do_string_value(const string_view_type&, semantic_tag, const ser_context&) override - { - return true; - } - - bool do_byte_string_value(const byte_string_view&, - semantic_tag, - const ser_context&) override - { - return true; - } - - bool do_int64_value(int64_t, - semantic_tag, - const ser_context&) override - { - return true; - } - - bool do_uint64_value(uint64_t, - semantic_tag, - const ser_context&) override - { - return true; - } - - bool do_double_value(double, - semantic_tag, - const ser_context&) override - { - return true; - } - - bool do_bool_value(bool, semantic_tag, const ser_context&) override - { - return true; - } -}; - -typedef basic_json_content_handler json_content_handler; -typedef basic_json_content_handler wjson_content_handler; - -typedef basic_null_json_content_handler null_json_content_handler; -typedef basic_null_json_content_handler wnull_json_content_handler; - -} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/json_conversion_traits.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/json_conversion_traits.hpp deleted file mode 100644 index 2aee25a233..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/json_conversion_traits.hpp +++ /dev/null @@ -1,196 +0,0 @@ -// Copyright 2017 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_JSON_CONVERSION_TRAITS_HPP -#define JSONCONS_JSON_CONVERSION_TRAITS_HPP - -#include -#include -#include -#include -#include // std::enable_if -#include -#include -#include -#include -#include -#include -#include - -namespace jsoncons { - -template -void read_from(const Json& j, basic_staj_reader& reader, T& val, std::error_code& ec); - -template -void read_from(const Json& j, basic_staj_reader& reader, T& val) -{ - std::error_code ec; - read_from(j, reader, val, ec); - if (ec) - { - throw ser_error(ec, reader.context().line(), reader.context().column()); - } -} - -template -void write_to(const T&val, basic_json_content_handler& receiver); - -} // namespace jsoncons - -#include - -namespace jsoncons { - -template -struct json_conversion_traits -{ - template - static T decode(basic_staj_reader& reader, std::error_code& ec) - { - json_decoder decoder; - reader.accept(decoder, ec); - return decoder.get_result().template as(); - } - - template - static void encode(const T& val, basic_json_content_handler& receiver) - { - auto j = json_type_traits::to_json(val); - j.dump(receiver); - } -}; - -// specializations - -// vector like - -template -struct json_conversion_traits::value && jsoncons::detail::is_vector_like::value ->::type> -{ - typedef typename T::value_type value_type; - - template - static T decode(basic_staj_reader& reader, std::error_code& ec) - { - T v; - basic_staj_array_iterator end; - basic_staj_array_iterator it(reader, ec); - - while (it != end && !ec) - { - v.push_back(*it); - it.increment(ec); - } - return v; - } - - template - static void encode(const T& val, basic_json_content_handler& receiver) - { - receiver.begin_array(); - for (auto it = std::begin(val); it != std::end(val); ++it) - { - json_conversion_traits::template encode(*it,receiver); - } - receiver.end_array(); - receiver.flush(); - } -}; -// std::array - -template -struct json_conversion_traits> -{ - typedef typename std::array::value_type value_type; - - template - static std::array decode(basic_staj_reader& reader, std::error_code& ec) - { - std::array v; - v.fill(T{}); - basic_staj_array_iterator end; - basic_staj_array_iterator it(reader, ec); - - for (size_t i = 0; it != end && i < N && !ec; ++i) - { - v[i] = *it; - it.increment(ec); - } - return v; - } - - template - static void encode(const std::array& val, basic_json_content_handler& receiver) - { - receiver.begin_array(); - for (auto it = std::begin(val); it != std::end(val); ++it) - { - json_conversion_traits::template encode(*it,receiver); - } - receiver.end_array(); - receiver.flush(); - } -}; - -// map like - -template -struct json_conversion_traits::value && jsoncons::detail::is_map_like::value ->::type> -{ - typedef typename T::mapped_type mapped_type; - typedef typename T::value_type value_type; - typedef typename T::key_type key_type; - - template - static T decode(basic_staj_reader& reader, std::error_code& ec) - { - T m; - basic_staj_object_iterator end; - basic_staj_object_iterator it(reader, ec); - - while (it != end && !ec) - { - m.emplace(it->first,it->second); - it.increment(ec); - } - return m; - } - - template - static void encode(const T& val, basic_json_content_handler& receiver) - { - receiver.begin_object(); - for (auto it = std::begin(val); it != std::end(val); ++it) - { - receiver.name(it->first); - json_conversion_traits::template encode(it->second,receiver); - } - receiver.end_object(); - receiver.flush(); - } -}; - -template -void read_from(const Json&, basic_staj_reader& reader, T& val, std::error_code& ec) -{ - val = json_conversion_traits::template decode(reader,ec); -} - -template -void write_to(const Json&, const T&val, basic_json_content_handler& receiver) -{ - json_conversion_traits::template encode(val, receiver); -} - -} - -#endif - diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/json_cursor.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/json_cursor.hpp deleted file mode 100644 index 8659eb4911..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/json_cursor.hpp +++ /dev/null @@ -1,680 +0,0 @@ -// Copyright 2018 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_JSON_CURSOR_HPP -#define JSONCONS_JSON_CURSOR_HPP - -#include // std::allocator -#include -#include -#include -#include -#include -#include // std::basic_istream -#include -#include -#include -#include -#include -#include -#include -#include - -namespace jsoncons { - -template -class basic_staj_event_handler final : public basic_json_content_handler -{ -public: - using typename basic_json_content_handler::string_view_type; -private: - basic_staj_event event_; -public: - basic_staj_event_handler() - : event_(staj_event_type::null_value) - { - } - - basic_staj_event_handler(staj_event_type event_type) - : event_(event_type) - { - } - - const basic_staj_event& event() const - { - return event_; - } -private: - - bool do_begin_object(semantic_tag, const ser_context&) override - { - event_ = basic_staj_event(staj_event_type::begin_object); - return false; - } - - bool do_end_object(const ser_context&) override - { - event_ = basic_staj_event(staj_event_type::end_object); - return false; - } - - bool do_begin_array(semantic_tag, const ser_context&) override - { - event_ = basic_staj_event(staj_event_type::begin_array); - return false; - } - - bool do_end_array(const ser_context&) override - { - event_ = basic_staj_event(staj_event_type::end_array); - return false; - } - - bool do_name(const string_view_type& name, const ser_context&) override - { - event_ = basic_staj_event(name.data(), name.length(), staj_event_type::name); - return false; - } - - bool do_null_value(semantic_tag, const ser_context&) override - { - event_ = basic_staj_event(staj_event_type::null_value); - return false; - } - - bool do_bool_value(bool value, semantic_tag, const ser_context&) override - { - event_ = basic_staj_event(value); - return false; - } - - bool do_string_value(const string_view_type& s, semantic_tag tag, const ser_context&) override - { - event_ = basic_staj_event(s.data(), s.length(), staj_event_type::string_value, tag); - return false; - } - - bool do_byte_string_value(const byte_string_view&, - semantic_tag, - const ser_context&) override - { - JSONCONS_UNREACHABLE(); - } - - bool do_int64_value(int64_t value, - semantic_tag tag, - const ser_context&) override - { - event_ = basic_staj_event(value, tag); - return false; - } - - bool do_uint64_value(uint64_t value, - semantic_tag tag, - const ser_context&) override - { - event_ = basic_staj_event(value, tag); - return false; - } - - bool do_double_value(double value, - semantic_tag tag, - const ser_context&) override - { - event_ = basic_staj_event(value, tag); - return false; - } - - void do_flush() override - { - } -}; - -template,class Allocator=std::allocator> -class basic_json_cursor : public basic_staj_reader, private virtual ser_context -{ -public: - typedef Src source_type; - typedef CharT char_type; - typedef Allocator allocator_type; -private: - static const size_t default_max_buffer_length = 16384; - - basic_staj_event_handler event_handler_; - default_parse_error_handler default_err_handler_; - - default_basic_staj_filter default_filter_; - - typedef typename std::allocator_traits:: template rebind_alloc char_allocator_type; - - basic_json_parser parser_; - basic_staj_filter& filter_; - source_type source_; - std::vector buffer_; - size_t buffer_length_; - bool eof_; - bool begin_; - - // Noncopyable and nonmoveable - basic_json_cursor(const basic_json_cursor&) = delete; - basic_json_cursor& operator=(const basic_json_cursor&) = delete; - -public: - typedef basic_string_view string_view_type; - - // Constructors that throw parse exceptions - template - basic_json_cursor(Source&& source) - : basic_json_cursor(std::forward(source), - default_filter_, - basic_json_options::default_options(), - default_err_handler_) - { - } - - template - basic_json_cursor(Source&& source, - basic_staj_filter& filter) - : basic_json_cursor(std::forward(source), - filter,basic_json_options::default_options(), - default_err_handler_) - { - } - - template - basic_json_cursor(Source&& source, - parse_error_handler& err_handler) - : basic_json_cursor(std::forward(source), - default_filter_, - basic_json_options::default_options(), - err_handler) - { - } - - template - basic_json_cursor(Source&& source, - basic_staj_filter& filter, - parse_error_handler& err_handler) - : basic_json_cursor(std::forward(source), - filter, - basic_json_options::default_options(), - err_handler) - { - } - - template - basic_json_cursor(Source&& source, - const basic_json_decode_options& options) - : basic_json_cursor(std::forward(source), - default_filter_, - options, - default_err_handler_) - { - } - - template - basic_json_cursor(Source&& source, - basic_staj_filter& filter, - const basic_json_decode_options& options) - : basic_json_cursor(std::forward(source), - filter, - options, - default_err_handler_) - { - } - - template - basic_json_cursor(Source&& source, - basic_staj_filter& filter, - const basic_json_decode_options& options, - parse_error_handler& err_handler, - typename std::enable_if,Source>::value>::type* = 0) - : parser_(options,err_handler), - filter_(filter), - source_(source), - buffer_length_(default_max_buffer_length), - eof_(false), - begin_(true) - { - buffer_.reserve(buffer_length_); - if (!done()) - { - next(); - } - } - - template - basic_json_cursor(Source&& source, - basic_staj_filter& filter, - const basic_json_decode_options& options, - parse_error_handler& err_handler, - typename std::enable_if,Source>::value>::type* = 0) - : parser_(options,err_handler), - filter_(filter), - buffer_length_(0), - eof_(false), - begin_(false) - { - basic_string_view sv(std::forward(source)); - auto result = unicons::skip_bom(sv.begin(), sv.end()); - if (result.ec != unicons::encoding_errc()) - { - throw ser_error(result.ec,parser_.line(),parser_.column()); - } - size_t offset = result.it - sv.begin(); - parser_.update(sv.data()+offset,sv.size()-offset); - if (!done()) - { - next(); - } - } - - // Constructors that set parse error codes - template - basic_json_cursor(Source&& source, - std::error_code& ec) - : basic_json_cursor(std::forward(source),default_filter_,basic_json_options::default_options(),default_err_handler_,ec) - { - } - - template - basic_json_cursor(Source&& source, - basic_staj_filter& filter, - std::error_code& ec) - : basic_json_cursor(std::forward(source), - filter, - basic_json_options::default_options(), - default_err_handler_, - ec) - { - } - - template - basic_json_cursor(Source&& source, - parse_error_handler& err_handler, - std::error_code& ec) - : basic_json_cursor(std::forward(source), - default_filter_, - basic_json_options::default_options(), - err_handler, - ec) - { - } - - template - basic_json_cursor(Source&& source, - basic_staj_filter& filter, - parse_error_handler& err_handler, - std::error_code& ec) - : basic_json_cursor(std::forward(source), - filter, - basic_json_options::default_options(), - err_handler, - ec) - { - } - - template - basic_json_cursor(Source&& source, - const basic_json_decode_options& options, - std::error_code& ec) - : basic_json_cursor(std::forward(source), - default_filter_, - options, - default_err_handler_, - ec) - { - } - - template - basic_json_cursor(Source&& source, - basic_staj_filter& filter, - const basic_json_decode_options& options, - std::error_code& ec) - : basic_json_cursor(std::forward(source), - filter,options, - default_err_handler_, - ec) - { - } - - template - basic_json_cursor(Source&& source, - basic_staj_filter& filter, - const basic_json_decode_options& options, - parse_error_handler& err_handler, - std::error_code& ec, - typename std::enable_if,Source>::value>::type* = 0) - : parser_(options,err_handler), - filter_(filter), - source_(source), - eof_(false), - buffer_length_(default_max_buffer_length), - begin_(true) - { - buffer_.reserve(buffer_length_); - if (!done()) - { - next(ec); - } - } - - template - basic_json_cursor(Source&& source, - basic_staj_filter& filter, - const basic_json_decode_options& options, - parse_error_handler& err_handler, - std::error_code& ec, - typename std::enable_if,Source>::value>::type* = 0) - : parser_(options,err_handler), - filter_(filter), - eof_(false), - buffer_length_(0), - begin_(false) - { - basic_string_view sv(std::forward(source)); - auto result = unicons::skip_bom(sv.begin(), sv.end()); - if (result.ec != unicons::encoding_errc()) - { - ec = result.ec; - return; - } - size_t offset = result.it - sv.begin(); - parser_.update(sv.data()+offset,sv.size()-offset); - if (!done()) - { - next(ec); - } - } - - size_t buffer_length() const - { - return buffer_length_; - } - - void buffer_length(size_t length) - { - buffer_length_ = length; - buffer_.reserve(buffer_length_); - } - - bool done() const override - { - return parser_.done(); - } - - const basic_staj_event& current() const override - { - return event_handler_.event(); - } - - void accept(basic_json_content_handler& handler) override - { - std::error_code ec; - accept(handler, ec); - if (ec) - { - throw ser_error(ec,parser_.line(),parser_.column()); - } - } - - void accept(basic_json_content_handler& handler, - std::error_code& ec) override - { - switch (event_handler_.event().event_type()) - { - case staj_event_type::begin_array: - if (!handler.begin_array(semantic_tag::none, *this)) - { - return; - } - break; - case staj_event_type::end_array: - if (!handler.end_array(*this)) - { - return; - } - break; - case staj_event_type::begin_object: - if (!handler.begin_object(semantic_tag::none, *this)) - { - return; - } - break; - case staj_event_type::end_object: - if (!handler.end_object(*this)) - { - return; - } - break; - case staj_event_type::name: - if (!handler.name(event_handler_.event().template as>(), *this)) - { - return; - } - break; - case staj_event_type::string_value: - if (!handler.string_value(event_handler_.event().template as>(), semantic_tag::none, *this)) - { - return; - } - break; - case staj_event_type::null_value: - if (!handler.null_value(semantic_tag::none, *this)) - { - return; - } - break; - case staj_event_type::bool_value: - if (!handler.bool_value(event_handler_.event().template as(), semantic_tag::none, *this)) - { - return; - } - break; - case staj_event_type::int64_value: - if (!handler.int64_value(event_handler_.event().template as(), semantic_tag::none, *this)) - { - return; - } - break; - case staj_event_type::uint64_value: - if (!handler.uint64_value(event_handler_.event().template as(), semantic_tag::none, *this)) - { - return; - } - break; - case staj_event_type::double_value: - if (!handler.double_value(event_handler_.event().template as(), semantic_tag::none, *this)) - { - return; - } - break; - default: - break; - } - do - { - read_next(handler, ec); - } - while (!ec && !done() && !filter_.accept(event_handler_.event(), *this)); - } - - void next() override - { - std::error_code ec; - next(ec); - if (ec) - { - throw ser_error(ec,parser_.line(),parser_.column()); - } - } - - void next(std::error_code& ec) override - { - do - { - read_next(ec); - } - while (!ec && !done() && !filter_.accept(event_handler_.event(), *this)); - } - - void read_buffer(std::error_code& ec) - { - buffer_.clear(); - buffer_.resize(buffer_length_); - size_t count = source_.read(buffer_.data(), buffer_length_); - buffer_.resize(static_cast(count)); - if (buffer_.size() == 0) - { - eof_ = true; - } - else if (begin_) - { - auto result = unicons::skip_bom(buffer_.begin(), buffer_.end()); - if (result.ec != unicons::encoding_errc()) - { - ec = result.ec; - return; - } - size_t offset = result.it - buffer_.begin(); - parser_.update(buffer_.data()+offset,buffer_.size()-offset); - begin_ = false; - } - else - { - parser_.update(buffer_.data(),buffer_.size()); - } - } - - void read_next(std::error_code& ec) - { - read_next(event_handler_, ec); - } - - void read_next(basic_json_content_handler& handler, std::error_code& ec) - { - parser_.restart(); - while (!parser_.stopped()) - { - if (parser_.source_exhausted()) - { - if (!source_.eof()) - { - read_buffer(ec); - if (ec) return; - } - else - { - eof_ = true; - } - } - parser_.parse_some(handler, ec); - if (ec) return; - } - } - - void check_done() - { - std::error_code ec; - check_done(ec); - if (ec) - { - throw ser_error(ec,parser_.line(),parser_.column()); - } - } - - const ser_context& context() const override - { - return *this; - } - - void check_done(std::error_code& ec) - { - try - { - if (source_.is_error()) - { - ec = json_errc::source_error; - return; - } - if (eof_) - { - parser_.check_done(ec); - if (ec) return; - } - else - { - while (!eof_) - { - if (parser_.source_exhausted()) - { - if (!source_.eof()) - { - read_buffer(ec); - if (ec) return; - } - else - { - eof_ = true; - } - } - if (!eof_) - { - parser_.check_done(ec); - if (ec) return; - } - } - } - } - catch (const ser_error& e) - { - ec = e.code(); - } - } - - bool eof() const - { - return eof_; - } - - size_t line() const override - { - return parser_.line(); - } - - size_t column() const override - { - return parser_.column(); - } -private: -}; - -typedef basic_json_cursor json_cursor; -typedef basic_json_cursor wjson_cursor; - -#if !defined(JSONCONS_NO_DEPRECATED) -template> -using basic_json_pull_reader = basic_json_cursor; -typedef basic_json_cursor json_pull_reader; -typedef basic_json_cursor wjson_pull_reader; - -template> -using basic_json_stream_reader = basic_json_cursor; - -template> -using basic_json_staj_reader = basic_json_cursor; - -typedef basic_json_cursor json_stream_reader; -typedef basic_json_cursor wjson_stream_reader; - -typedef basic_json_cursor json_staj_reader; -typedef basic_json_cursor wjson_staj_reader; -#endif - -} - -#endif - diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/json_decoder.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/json_decoder.hpp deleted file mode 100644 index 653d48addc..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/json_decoder.hpp +++ /dev/null @@ -1,357 +0,0 @@ -// Copyright 2013-2016 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_JSON_DECODER_HPP -#define JSONCONS_JSON_DECODER_HPP - -#include -#include -#include // std::true_type -#include // std::allocator -#include // std::make_move_iterator -#include // std::move -#include -#include - -namespace jsoncons { - -template > -class json_decoder final : public basic_json_content_handler -{ -public: - typedef typename Json::char_type char_type; - using typename basic_json_content_handler::string_view_type; - - typedef typename Json::key_value_type key_value_type; - typedef typename Json::string_type string_type; - typedef typename Json::array array; - typedef typename Json::object object; - typedef typename Json::allocator_type json_allocator_type; - typedef typename string_type::allocator_type json_string_allocator; - typedef typename array::allocator_type json_array_allocator; - typedef typename object::allocator_type json_object_allocator; - typedef typename std::allocator_traits:: template rebind_alloc json_byte_allocator_type; -private: - json_string_allocator string_allocator_; - json_object_allocator object_allocator_; - json_array_allocator array_allocator_; - json_byte_allocator_type byte_allocator_; - - Json result_; - - struct stack_item - { - template - stack_item(std::true_type, Args&& ... args) - : name_(std::forward(args)...) - { - } - template - stack_item(std::false_type, Args&& ... args) - : value_(std::forward(args)...) - { - } - - stack_item() = default; - stack_item(const stack_item&) = default; - stack_item(stack_item&&) = default; - stack_item& operator=(const stack_item&) = default; - stack_item& operator=(stack_item&&) = default; - - string_type name_; - Json value_; - }; - - enum class container_type {root_t, array_t, object_t}; - - struct structure_offset - { - size_t offset_; - container_type type_; - }; - - typedef Allocator allocator_type; - typedef typename std::allocator_traits:: template rebind_alloc stack_item_allocator_type; - typedef typename std::allocator_traits:: template rebind_alloc size_t_allocator_type; - - - std::vector stack_; - std::vector stack_offsets_; - bool is_valid_; - -public: - json_decoder(const json_allocator_type& jallocator = json_allocator_type()) - : string_allocator_(jallocator), - object_allocator_(jallocator), - array_allocator_(jallocator), - is_valid_(false) - - { - stack_.reserve(1000); - stack_offsets_.reserve(100); - stack_offsets_.push_back({0,container_type::root_t}); - } - - bool is_valid() const - { - return is_valid_; - } - - Json get_result() - { - is_valid_ = false; - return std::move(result_); - } - -#if !defined(JSONCONS_NO_DEPRECATED) - Json& root() - { - return result_; - } -#endif - -private: - - void do_flush() override - { - } - - bool do_begin_object(semantic_tag tag, const ser_context&) override - { - switch (stack_offsets_.back().type_) - { - case container_type::object_t: - stack_.back().value_ = Json(object(object_allocator_), tag); - break; - case container_type::array_t: - stack_.emplace_back(std::false_type(), object(object_allocator_), tag); - break; - case container_type::root_t: - stack_.clear(); - is_valid_ = false; - stack_.emplace_back(std::false_type(), object(object_allocator_), tag); - break; - } - stack_offsets_.push_back({stack_.size()-1,container_type::object_t}); - return true; - } - - bool do_end_object(const ser_context&) override - { - JSONCONS_ASSERT(stack_offsets_.size() > 0); - JSONCONS_ASSERT(stack_offsets_.back().type_ == container_type::object_t); - const size_t structure_index = stack_offsets_.back().offset_; - JSONCONS_ASSERT(stack_.size() > structure_index); - const size_t count = stack_.size() - (structure_index + 1); - auto first = stack_.begin() + (structure_index+1); - auto last = first + count; - stack_[structure_index].value_.object_value().insert( - std::make_move_iterator(first), - std::make_move_iterator(last), - [](stack_item&& val){return key_value_type(std::move(val.name_), std::move(val.value_));} - ); - stack_.erase(stack_.begin()+structure_index+1, stack_.end()); - stack_offsets_.pop_back(); - if (stack_offsets_.back().type_ == container_type::root_t) - { - result_.swap(stack_.front().value_); - stack_.pop_back(); - is_valid_ = true; - return false; - } - return true; - } - - bool do_begin_array(semantic_tag tag, const ser_context&) override - { - switch (stack_offsets_.back().type_) - { - case container_type::object_t: - stack_.back().value_ = Json(array(array_allocator_), tag); - break; - case container_type::array_t: - stack_.emplace_back(std::false_type(), array(array_allocator_), tag); - break; - case container_type::root_t: - stack_.clear(); - is_valid_ = false; - stack_.emplace_back(std::false_type(), array(array_allocator_), tag); - break; - } - stack_offsets_.push_back({stack_.size()-1,container_type::array_t}); - return true; - } - - bool do_end_array(const ser_context&) override - { - JSONCONS_ASSERT(stack_offsets_.size() > 0); - JSONCONS_ASSERT(stack_offsets_.back().type_ == container_type::array_t); - const size_t structure_index = stack_offsets_.back().offset_; - JSONCONS_ASSERT(stack_.size() > structure_index); - const size_t count = stack_.size() - (structure_index + 1); - auto first = stack_.begin() + (structure_index+1); - auto last = first + count; - auto& j = stack_[structure_index].value_; - j.reserve(count); - while (first != last) - { - j.push_back(std::move(first->value_)); - ++first; - } - stack_.erase(stack_.begin()+structure_index+1, stack_.end()); - stack_offsets_.pop_back(); - if (stack_offsets_.back().type_ == container_type::root_t) - { - result_.swap(stack_.front().value_); - stack_.pop_back(); - is_valid_ = true; - return false; - } - return true; - } - - bool do_name(const string_view_type& name, const ser_context&) override - { - stack_.emplace_back(std::true_type(), name.data(), name.length(), string_allocator_); - return true; - } - - bool do_string_value(const string_view_type& sv, semantic_tag tag, const ser_context&) override - { - switch (stack_offsets_.back().type_) - { - case container_type::object_t: - stack_.back().value_ = Json(sv, tag, string_allocator_); - break; - case container_type::array_t: - stack_.emplace_back(std::false_type(), sv, tag, string_allocator_); - break; - case container_type::root_t: - result_ = Json(sv, tag, string_allocator_); - is_valid_ = true; - return false; - } - return true; - } - - bool do_byte_string_value(const byte_string_view& b, semantic_tag tag, const ser_context&) override - { - switch (stack_offsets_.back().type_) - { - case container_type::object_t: - stack_.back().value_ = Json(b, tag, byte_allocator_); - break; - case container_type::array_t: - stack_.emplace_back(std::false_type(), b, tag, byte_allocator_); - break; - case container_type::root_t: - result_ = Json(b, tag, byte_allocator_); - is_valid_ = true; - return false; - } - return true; - } - - bool do_int64_value(int64_t value, - semantic_tag tag, - const ser_context&) override - { - switch (stack_offsets_.back().type_) - { - case container_type::object_t: - stack_.back().value_ = Json(value,tag); - break; - case container_type::array_t: - stack_.emplace_back(std::false_type(), value, tag); - break; - case container_type::root_t: - result_ = Json(value,tag); - is_valid_ = true; - return false; - } - return true; - } - - bool do_uint64_value(uint64_t value, - semantic_tag tag, - const ser_context&) override - { - switch (stack_offsets_.back().type_) - { - case container_type::object_t: - stack_.back().value_ = Json(value,tag); - break; - case container_type::array_t: - stack_.emplace_back(std::false_type(), value, tag); - break; - case container_type::root_t: - result_ = Json(value,tag); - is_valid_ = true; - return false; - } - return true; - } - - bool do_double_value(double value, - semantic_tag tag, - const ser_context&) override - { - switch (stack_offsets_.back().type_) - { - case container_type::object_t: - stack_.back().value_ = Json(value, tag); - break; - case container_type::array_t: - stack_.emplace_back(std::false_type(), value, tag); - break; - case container_type::root_t: - result_ = Json(value, tag); - is_valid_ = true; - return false; - } - return true; - } - - bool do_bool_value(bool value, semantic_tag tag, const ser_context&) override - { - switch (stack_offsets_.back().type_) - { - case container_type::object_t: - stack_.back().value_ = Json(value, tag); - break; - case container_type::array_t: - stack_.emplace_back(std::false_type(), value, tag); - break; - case container_type::root_t: - result_ = Json(value, tag); - is_valid_ = true; - return false; - } - return true; - } - - bool do_null_value(semantic_tag tag, const ser_context&) override - { - switch (stack_offsets_.back().type_) - { - case container_type::object_t: - stack_.back().value_ = Json(null_type(),tag); - break; - case container_type::array_t: - stack_.emplace_back(std::false_type(), null_type(), tag); - break; - case container_type::root_t: - result_ = Json(null_type(), tag); - is_valid_ = true; - return false; - } - return true; - } -}; - -} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/json_encoder.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/json_encoder.hpp deleted file mode 100644 index 356348c15a..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/json_encoder.hpp +++ /dev/null @@ -1,1470 +0,0 @@ -// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_JSON_ENCODER_HPP -#define JSONCONS_JSON_ENCODER_HPP - -#include // std::array -#include -#include -#include // std::isfinite, std::isnan -#include // std::numeric_limits -#include -#include // std::move -#include -#include -#include -#include -#include -#include -#include -#include - -namespace jsoncons { namespace detail { -template -size_t escape_string(const CharT* s, size_t length, - bool escape_all_non_ascii, bool escape_solidus, - Result& result) -{ - size_t count = 0; - const CharT* begin = s; - const CharT* end = s + length; - for (const CharT* it = begin; it != end; ++it) - { - CharT c = *it; - switch (c) - { - case '\\': - result.push_back('\\'); - result.push_back('\\'); - count += 2; - break; - case '"': - result.push_back('\\'); - result.push_back('\"'); - count += 2; - break; - case '\b': - result.push_back('\\'); - result.push_back('b'); - count += 2; - break; - case '\f': - result.push_back('\\'); - result.push_back('f'); - count += 2; - break; - case '\n': - result.push_back('\\'); - result.push_back('n'); - count += 2; - break; - case '\r': - result.push_back('\\'); - result.push_back('r'); - count += 2; - break; - case '\t': - result.push_back('\\'); - result.push_back('t'); - count += 2; - break; - default: - if (escape_solidus && c == '/') - { - result.push_back('\\'); - result.push_back('/'); - count += 2; - } - else if (is_control_character(c) || escape_all_non_ascii) - { - // convert utf8 to codepoint - unicons::sequence_generator g(it, end, unicons::conv_flags::strict); - if (g.done() || g.status() != unicons::conv_errc()) - { - throw ser_error(json_errc::illegal_codepoint); - } - uint32_t cp = g.get().codepoint(); - it += (g.get().length() - 1); - if (is_non_ascii_codepoint(cp) || is_control_character(c)) - { - if (cp > 0xFFFF) - { - cp -= 0x10000; - uint32_t first = (cp >> 10) + 0xD800; - uint32_t second = ((cp & 0x03FF) + 0xDC00); - - result.push_back('\\'); - result.push_back('u'); - result.push_back(to_hex_character(first >> 12 & 0x000F)); - result.push_back(to_hex_character(first >> 8 & 0x000F)); - result.push_back(to_hex_character(first >> 4 & 0x000F)); - result.push_back(to_hex_character(first & 0x000F)); - result.push_back('\\'); - result.push_back('u'); - result.push_back(to_hex_character(second >> 12 & 0x000F)); - result.push_back(to_hex_character(second >> 8 & 0x000F)); - result.push_back(to_hex_character(second >> 4 & 0x000F)); - result.push_back(to_hex_character(second & 0x000F)); - count += 12; - } - else - { - result.push_back('\\'); - result.push_back('u'); - result.push_back(to_hex_character(cp >> 12 & 0x000F)); - result.push_back(to_hex_character(cp >> 8 & 0x000F)); - result.push_back(to_hex_character(cp >> 4 & 0x000F)); - result.push_back(to_hex_character(cp & 0x000F)); - count += 6; - } - } - else - { - result.push_back(c); - ++count; - } - } - else - { - result.push_back(c); - ++count; - } - break; - } - } - return count; -} - -inline -byte_string_chars_format resolve_byte_string_chars_format(byte_string_chars_format format1, - byte_string_chars_format format2, - byte_string_chars_format default_format = byte_string_chars_format::base64url) -{ - byte_string_chars_format result; - switch (format1) - { - case byte_string_chars_format::base16: - case byte_string_chars_format::base64: - case byte_string_chars_format::base64url: - result = format1; - break; - default: - switch (format2) - { - case byte_string_chars_format::base64url: - case byte_string_chars_format::base64: - case byte_string_chars_format::base16: - result = format2; - break; - default: // base64url - { - result = default_format; - break; - } - } - break; - } - return result; -} - -}} - -namespace jsoncons { - -template> -class basic_json_encoder final : public basic_json_content_handler -{ - static const std::array& null_k() - { - static constexpr std::array k{'n','u','l','l'}; - return k; - } - static const std::array& true_k() - { - static constexpr std::array k{'t','r','u','e'}; - return k; - } - static const std::array& false_k() - { - static constexpr std::array k{'f','a','l','s','e'}; - return k; - } -public: - typedef CharT char_type; - using typename basic_json_content_handler::string_view_type; - typedef Result result_type; - typedef typename basic_json_options::string_type string_type; - -private: - enum class container_type {object, array}; - - class encoding_context - { - container_type type_; - size_t count_; - line_split_kind line_splits_; - bool indent_before_; - bool new_line_after_; - size_t begin_pos_; - size_t data_pos_; - public: - encoding_context(container_type type, line_split_kind split_lines, bool indent_once, - size_t begin_pos, size_t data_pos) - : type_(type), count_(0), line_splits_(split_lines), indent_before_(indent_once), new_line_after_(false), - begin_pos_(begin_pos), data_pos_(data_pos) - { - } - - void set_position(size_t pos) - { - data_pos_ = pos; - } - - size_t begin_pos() const - { - return begin_pos_; - } - - size_t data_pos() const - { - return data_pos_; - } - - size_t count() const - { - return count_; - } - - void increment_count() - { - ++count_; - } - - bool new_line_after() const - { - return new_line_after_; - } - - void new_line_after(bool value) - { - new_line_after_ = value; - } - - bool is_object() const - { - return type_ == container_type::object; - } - - bool is_array() const - { - return type_ == container_type::array; - } - - bool is_same_line() const - { - return line_splits_ == line_split_kind::same_line; - } - - bool is_new_line() const - { - return line_splits_ == line_split_kind::new_line; - } - - bool is_multi_line() const - { - return line_splits_ == line_split_kind::multi_line; - } - - bool is_indent_once() const - { - return count_ == 0 ? indent_before_ : false; - } - - }; - - size_t indent_size_; - - const basic_json_encode_options& options_; - - jsoncons::detail::print_double fp_; - - Result result_; - - std::vector stack_; - int indent_amount_; - size_t column_; - std::basic_string colon_str_; - std::basic_string comma_str_; - std::basic_string open_object_brace_str_; - std::basic_string close_object_brace_str_; - std::basic_string open_array_bracket_str_; - std::basic_string close_array_bracket_str_; - - // Noncopyable and nonmoveable - basic_json_encoder(const basic_json_encoder&) = delete; - basic_json_encoder& operator=(const basic_json_encoder&) = delete; -public: - basic_json_encoder(result_type result) - : basic_json_encoder(std::move(result), basic_json_options::default_options()) - { - } - - basic_json_encoder(result_type result, - const basic_json_encode_options& options) - : options_(options), - fp_(floating_point_options(options.floating_point_format(), - options.precision(), - 0)), - result_(std::move(result)), - indent_amount_(0), - column_(0) - { - switch (options.spaces_around_colon()) - { - case spaces_option::space_after: - colon_str_ = std::basic_string({':',' '}); - break; - case spaces_option::space_before: - colon_str_ = std::basic_string({' ',':'}); - break; - case spaces_option::space_before_and_after: - colon_str_ = std::basic_string({' ',':',' '}); - break; - default: - colon_str_.push_back(':'); - break; - } - switch (options.spaces_around_comma()) - { - case spaces_option::space_after: - comma_str_ = std::basic_string({',',' '}); - break; - case spaces_option::space_before: - comma_str_ = std::basic_string({' ',','}); - break; - case spaces_option::space_before_and_after: - comma_str_ = std::basic_string({' ',',',' '}); - break; - default: - comma_str_.push_back(','); - break; - } - if (options.pad_inside_object_braces()) - { - open_object_brace_str_ = std::basic_string({'{', ' '}); - close_object_brace_str_ = std::basic_string({' ', '}'}); - } - else - { - open_object_brace_str_.push_back('{'); - close_object_brace_str_.push_back('}'); - } - if (options.pad_inside_array_brackets()) - { - open_array_bracket_str_ = std::basic_string({'[', ' '}); - close_array_bracket_str_ = std::basic_string({' ', ']'}); - } - else - { - open_array_bracket_str_.push_back('['); - close_array_bracket_str_.push_back(']'); - } - } - - ~basic_json_encoder() - { - try - { - result_.flush(); - } - catch (...) - { - } - } - -private: - // Implementing methods - void do_flush() override - { - result_.flush(); - } - - bool do_begin_object(semantic_tag, const ser_context&) override - { - if (!stack_.empty() && stack_.back().is_array() && stack_.back().count() > 0) - { - result_.append(comma_str_.data(),comma_str_.length()); - column_ += comma_str_.length(); - } - - if (!stack_.empty()) // object or array - { - if (stack_.back().is_object()) - { - switch (options_.object_object_line_splits()) - { - case line_split_kind::same_line: - if (column_ >= options_.line_length_limit()) - { - break_line(); - } - break; - case line_split_kind::new_line: - if (column_ >= options_.line_length_limit()) - { - break_line(); - } - break; - default: // multi_line - break; - } - stack_.emplace_back(container_type::object,options_.object_object_line_splits(), false, - column_, column_+open_object_brace_str_.length()); - } - else // array - { - switch (options_.array_object_line_splits()) - { - case line_split_kind::same_line: - if (column_ >= options_.line_length_limit()) - { - //stack_.back().new_line_after(true); - new_line(); - } - break; - case line_split_kind::new_line: - stack_.back().new_line_after(true); - new_line(); - break; - default: // multi_line - stack_.back().new_line_after(true); - new_line(); - break; - } - stack_.emplace_back(container_type::object,options_.array_object_line_splits(), false, - column_, column_+open_object_brace_str_.length()); - } - } - else - { - stack_.emplace_back(container_type::object, line_split_kind::multi_line, false, - column_, column_+open_object_brace_str_.length()); - } - indent(); - - result_.append(open_object_brace_str_.data(), open_object_brace_str_.length()); - column_ += open_object_brace_str_.length(); - return true; - } - - bool do_end_object(const ser_context&) override - { - JSONCONS_ASSERT(!stack_.empty()); - unindent(); - if (stack_.back().new_line_after()) - { - new_line(); - } - stack_.pop_back(); - result_.append(close_object_brace_str_.data(), close_object_brace_str_.length()); - column_ += close_object_brace_str_.length(); - - end_value(); - return true; - } - - bool do_begin_array(semantic_tag, const ser_context&) override - { - if (!stack_.empty() && stack_.back().is_array() && stack_.back().count() > 0) - { - result_.append(comma_str_.data(),comma_str_.length()); - column_ += comma_str_.length(); - } - if (!stack_.empty()) - { - if (stack_.back().is_object()) - { - switch (options_.object_array_line_splits()) - { - case line_split_kind::same_line: - stack_.emplace_back(container_type::array,options_.object_array_line_splits(),false, - column_, column_ + open_array_bracket_str_.length()); - break; - case line_split_kind::new_line: - { - stack_.emplace_back(container_type::array,options_.object_array_line_splits(),true, - column_, column_+open_array_bracket_str_.length()); - break; - } - default: // multi_line - stack_.emplace_back(container_type::array,options_.object_array_line_splits(),true, - column_, column_+open_array_bracket_str_.length()); - break; - } - } - else // array - { - switch (options_.array_array_line_splits()) - { - case line_split_kind::same_line: - if (stack_.back().is_multi_line()) - { - stack_.back().new_line_after(true); - new_line(); - } - stack_.emplace_back(container_type::array,options_.array_array_line_splits(), false, - column_, column_+open_array_bracket_str_.length()); - break; - case line_split_kind::new_line: - stack_.back().new_line_after(true); - new_line(); - stack_.emplace_back(container_type::array,options_.array_array_line_splits(), false, - column_, column_+open_array_bracket_str_.length()); - break; - default: // multi_line - stack_.back().new_line_after(true); - new_line(); - stack_.emplace_back(container_type::array,options_.array_array_line_splits(), false, - column_, column_+open_array_bracket_str_.length()); - //new_line(); - break; - } - } - } - else - { - stack_.emplace_back(container_type::array, line_split_kind::multi_line, false, - column_, column_+open_array_bracket_str_.length()); - } - indent(); - result_.append(open_array_bracket_str_.data(), open_array_bracket_str_.length()); - column_ += open_array_bracket_str_.length(); - return true; - } - - bool do_end_array(const ser_context&) override - { - JSONCONS_ASSERT(!stack_.empty()); - unindent(); - if (stack_.back().new_line_after()) - { - new_line(); - } - stack_.pop_back(); - result_.append(close_array_bracket_str_.data(), close_array_bracket_str_.length()); - column_ += close_array_bracket_str_.length(); - end_value(); - return true; - } - - bool do_name(const string_view_type& name, const ser_context&) override - { - JSONCONS_ASSERT(!stack_.empty()); - if (stack_.back().count() > 0) - { - result_.append(comma_str_.data(),comma_str_.length()); - column_ += comma_str_.length(); - } - - if (stack_.back().is_multi_line()) - { - stack_.back().new_line_after(true); - new_line(); - } - else if (stack_.back().count() > 0 && column_ >= options_.line_length_limit()) - { - //stack_.back().new_line_after(true); - new_line(stack_.back().data_pos()); - } - - if (stack_.back().count() == 0) - { - stack_.back().set_position(column_); - } - result_.push_back('\"'); - size_t length = jsoncons::detail::escape_string(name.data(), name.length(),options_.escape_all_non_ascii(),options_.escape_solidus(),result_); - result_.push_back('\"'); - result_.append(colon_str_.data(),colon_str_.length()); - column_ += (length+2+colon_str_.length()); - return true; - } - - bool do_null_value(semantic_tag, const ser_context&) override - { - if (!stack_.empty()) - { - if (stack_.back().is_array()) - { - begin_scalar_value(); - } - if (!stack_.back().is_multi_line() && column_ >= options_.line_length_limit()) - { - break_line(); - } - } - - result_.append(null_k().data(), null_k().size()); - column_ += null_k().size(); - - end_value(); - return true; - } - - bool do_string_value(const string_view_type& sv, semantic_tag tag, const ser_context&) override - { - if (!stack_.empty()) - { - if (stack_.back().is_array()) - { - begin_scalar_value(); - } - if (!stack_.back().is_multi_line() && column_ >= options_.line_length_limit()) - { - break_line(); - } - } - - switch (tag) - { - case semantic_tag::bigint: - write_bigint_value(sv); - break; - default: - { - result_.push_back('\"'); - size_t length = jsoncons::detail::escape_string(sv.data(), sv.length(),options_.escape_all_non_ascii(),options_.escape_solidus(),result_); - result_.push_back('\"'); - column_ += (length+2); - break; - } - } - - end_value(); - return true; - } - - bool do_byte_string_value(const byte_string_view& b, - semantic_tag tag, - const ser_context&) override - { - if (!stack_.empty()) - { - if (stack_.back().is_array()) - { - begin_scalar_value(); - } - if (!stack_.back().is_multi_line() && column_ >= options_.line_length_limit()) - { - break_line(); - } - } - - byte_string_chars_format encoding_hint; - switch (tag) - { - case semantic_tag::base16: - encoding_hint = byte_string_chars_format::base16; - break; - case semantic_tag::base64: - encoding_hint = byte_string_chars_format::base64; - break; - case semantic_tag::base64url: - encoding_hint = byte_string_chars_format::base64url; - break; - default: - encoding_hint = byte_string_chars_format::none; - break; - } - - byte_string_chars_format format = jsoncons::detail::resolve_byte_string_chars_format(options_.byte_string_format(), - encoding_hint, - byte_string_chars_format::base64url); - switch (format) - { - case byte_string_chars_format::base16: - { - result_.push_back('\"'); - size_t length = encode_base16(b.begin(),b.end(),result_); - result_.push_back('\"'); - column_ += (length + 2); - break; - } - case byte_string_chars_format::base64: - { - result_.push_back('\"'); - size_t length = encode_base64(b.begin(), b.end(), result_); - result_.push_back('\"'); - column_ += (length + 2); - break; - } - case byte_string_chars_format::base64url: - { - result_.push_back('\"'); - size_t length = encode_base64url(b.begin(),b.end(),result_); - result_.push_back('\"'); - column_ += (length + 2); - break; - } - default: - { - JSONCONS_UNREACHABLE(); - } - } - - end_value(); - return true; - } - - bool do_double_value(double value, - semantic_tag, - const ser_context& context) override - { - if (!stack_.empty()) - { - if (stack_.back().is_array()) - { - begin_scalar_value(); - } - if (!stack_.back().is_multi_line() && column_ >= options_.line_length_limit()) - { - break_line(); - } - } - - if (!std::isfinite(value)) - { - if ((std::isnan)(value)) - { - if (options_.is_nan_to_num()) - { - result_.append(options_.nan_to_num().data(), options_.nan_to_num().length()); - column_ += options_.nan_to_num().length(); - } - else if (options_.is_nan_to_str()) - { - do_string_value(options_.nan_to_str(), semantic_tag::none, context); - } - else - { - result_.append(null_k().data(), null_k().size()); - column_ += null_k().size(); - } - } - else if (value == std::numeric_limits::infinity()) - { - if (options_.is_inf_to_num()) - { - result_.append(options_.inf_to_num().data(), options_.inf_to_num().length()); - column_ += options_.inf_to_num().length(); - } - else if (options_.is_inf_to_str()) - { - do_string_value(options_.inf_to_str(), semantic_tag::none, context); - } - else - { - result_.append(null_k().data(), null_k().size()); - column_ += null_k().size(); - } - } - else - { - if (options_.is_neginf_to_num()) - { - result_.append(options_.neginf_to_num().data(), options_.neginf_to_num().length()); - column_ += options_.neginf_to_num().length(); - } - else if (options_.is_neginf_to_str()) - { - do_string_value(options_.neginf_to_str(), semantic_tag::none, context); - } - else - { - result_.append(null_k().data(), null_k().size()); - column_ += null_k().size(); - } - } - } - else - { - size_t length = fp_(value, result_); - column_ += length; - } - - end_value(); - return true; - } - - bool do_int64_value(int64_t value, - semantic_tag, - const ser_context&) override - { - if (!stack_.empty()) - { - if (stack_.back().is_array()) - { - begin_scalar_value(); - } - if (!stack_.back().is_multi_line() && column_ >= options_.line_length_limit()) - { - break_line(); - } - } - size_t length = jsoncons::detail::print_integer(value, result_); - column_ += length; - end_value(); - return true; - } - - bool do_uint64_value(uint64_t value, - semantic_tag, - const ser_context&) override - { - if (!stack_.empty()) - { - if (stack_.back().is_array()) - { - begin_scalar_value(); - } - if (!stack_.back().is_multi_line() && column_ >= options_.line_length_limit()) - { - break_line(); - } - } - size_t length = jsoncons::detail::print_uinteger(value, result_); - column_ += length; - end_value(); - return true; - } - - bool do_bool_value(bool value, semantic_tag, const ser_context&) override - { - if (!stack_.empty()) - { - if (stack_.back().is_array()) - { - begin_scalar_value(); - } - if (!stack_.back().is_multi_line() && column_ >= options_.line_length_limit()) - { - break_line(); - } - } - - if (value) - { - result_.append(true_k().data(), true_k().size()); - column_ += true_k().size(); - } - else - { - result_.append(false_k().data(), false_k().size()); - column_ += false_k().size(); - } - - end_value(); - return true; - } - - void begin_scalar_value() - { - if (!stack_.empty()) - { - if (stack_.back().count() > 0) - { - result_.append(comma_str_.data(),comma_str_.length()); - column_ += comma_str_.length(); - } - if (stack_.back().is_multi_line() || stack_.back().is_indent_once()) - { - stack_.back().new_line_after(true); - new_line(); - } - } - } - - void write_bigint_value(const string_view_type& sv) - { - switch (options_.bigint_format()) - { - case bigint_chars_format::number: - { - result_.append(sv.data(),sv.size()); - column_ += sv.size(); - break; - } - case bigint_chars_format::base64: - { - bignum n(sv.data(), sv.length()); - int signum; - std::vector v; - n.dump(signum, v); - - result_.push_back('\"'); - if (signum == -1) - { - result_.push_back('~'); - ++column_; - } - size_t length = encode_base64(v.begin(), v.end(), result_); - result_.push_back('\"'); - column_ += (length+2); - break; - } - case bigint_chars_format::base64url: - { - bignum n(sv.data(), sv.length()); - int signum; - std::vector v; - n.dump(signum, v); - - result_.push_back('\"'); - if (signum == -1) - { - result_.push_back('~'); - ++column_; - } - size_t length = encode_base64url(v.begin(), v.end(), result_); - result_.push_back('\"'); - column_ += (length+2); - break; - } - default: - { - result_.push_back('\"'); - result_.append(sv.data(),sv.size()); - result_.push_back('\"'); - column_ += (sv.size() + 2); - break; - } - } - } - - void end_value() - { - if (!stack_.empty()) - { - stack_.back().increment_count(); - } - } - - void indent() - { - indent_amount_ += static_cast(options_.indent_size()); - } - - void unindent() - { - indent_amount_ -= static_cast(options_.indent_size()); - } - - void new_line() - { - result_.append(options_.new_line_chars().data(),options_.new_line_chars().length()); - for (int i = 0; i < indent_amount_; ++i) - { - result_.push_back(' '); - } - column_ = indent_amount_; - } - - void new_line(size_t len) - { - result_.append(options_.new_line_chars().data(),options_.new_line_chars().length()); - for (size_t i = 0; i < len; ++i) - { - result_.push_back(' '); - } - column_ = len; - } - - void break_line() - { - stack_.back().new_line_after(true); - new_line(); - } -}; - -template> -class basic_json_compressed_encoder final : public basic_json_content_handler -{ - static const std::array& null_k() - { - static constexpr std::array k{'n','u','l','l'}; - return k; - } - static const std::array& true_k() - { - static constexpr std::array k{'t','r','u','e'}; - return k; - } - static const std::array& false_k() - { - static constexpr std::array k{'f','a','l','s','e'}; - return k; - } -public: - typedef CharT char_type; - using typename basic_json_content_handler::string_view_type; - typedef Result result_type; - typedef typename basic_json_options::string_type string_type; - -private: - enum class container_type {object, array}; - - class encoding_context - { - container_type type_; - size_t count_; - public: - encoding_context(container_type type) - : type_(type), count_(0) - { - } - - size_t count() const - { - return count_; - } - - void increment_count() - { - ++count_; - } - - bool is_array() const - { - return type_ == container_type::array; - } - }; - - const basic_json_encode_options& options_; - - std::vector stack_; - jsoncons::detail::print_double fp_; - Result result_; - - // Noncopyable and nonmoveable - basic_json_compressed_encoder(const basic_json_compressed_encoder&) = delete; - basic_json_compressed_encoder& operator=(const basic_json_compressed_encoder&) = delete; -public: - basic_json_compressed_encoder(result_type result) - : basic_json_compressed_encoder(std::move(result), basic_json_options::default_options()) - { - } - - basic_json_compressed_encoder(result_type result, - const basic_json_encode_options& options) - : options_(options), - fp_(floating_point_options(options.floating_point_format(), - options.precision(), - 0)), - result_(std::move(result)) - { - } - - ~basic_json_compressed_encoder() - { - try - { - result_.flush(); - } - catch (...) - { - } - } - - -private: - // Implementing methods - void do_flush() override - { - result_.flush(); - } - - bool do_begin_object(semantic_tag, const ser_context&) override - { - if (!stack_.empty() && stack_.back().is_array() && stack_.back().count() > 0) - { - result_.push_back(','); - } - - stack_.emplace_back(container_type::object); - result_.push_back('{'); - return true; - } - - bool do_end_object(const ser_context&) override - { - JSONCONS_ASSERT(!stack_.empty()); - stack_.pop_back(); - result_.push_back('}'); - - if (!stack_.empty()) - { - stack_.back().increment_count(); - } - return true; - } - - - bool do_begin_array(semantic_tag, const ser_context&) override - { - if (!stack_.empty() && stack_.back().is_array() && stack_.back().count() > 0) - { - result_.push_back(','); - } - stack_.emplace_back(container_type::array); - result_.push_back('['); - return true; - } - - bool do_end_array(const ser_context&) override - { - JSONCONS_ASSERT(!stack_.empty()); - stack_.pop_back(); - result_.push_back(']'); - if (!stack_.empty()) - { - stack_.back().increment_count(); - } - return true; - } - - bool do_name(const string_view_type& name, const ser_context&) override - { - if (!stack_.empty() && stack_.back().count() > 0) - { - result_.push_back(','); - } - - result_.push_back('\"'); - jsoncons::detail::escape_string(name.data(), name.length(),options_.escape_all_non_ascii(),options_.escape_solidus(),result_); - result_.push_back('\"'); - result_.push_back(':'); - return true; - } - - bool do_null_value(semantic_tag, const ser_context&) override - { - if (!stack_.empty() && stack_.back().is_array() && stack_.back().count() > 0) - { - result_.push_back(','); - } - - result_.append(null_k().data(), null_k().size()); - - if (!stack_.empty()) - { - stack_.back().increment_count(); - } - return true; - } - - void write_bigint_value(const string_view_type& sv) - { - switch (options_.bigint_format()) - { - case bigint_chars_format::number: - { - result_.append(sv.data(),sv.size()); - break; - } - case bigint_chars_format::base64: - { - bignum n(sv.data(), sv.length()); - int signum; - std::vector v; - n.dump(signum, v); - - result_.push_back('\"'); - if (signum == -1) - { - result_.push_back('~'); - } - encode_base64(v.begin(), v.end(), result_); - result_.push_back('\"'); - break; - } - case bigint_chars_format::base64url: - { - bignum n(sv.data(), sv.length()); - int signum; - std::vector v; - n.dump(signum, v); - - result_.push_back('\"'); - if (signum == -1) - { - result_.push_back('~'); - } - encode_base64url(v.begin(), v.end(), result_); - result_.push_back('\"'); - break; - } - default: - { - result_.push_back('\"'); - result_.append(sv.data(),sv.size()); - result_.push_back('\"'); - break; - } - } - } - - bool do_string_value(const string_view_type& sv, semantic_tag tag, const ser_context&) override - { - if (!stack_.empty() && stack_.back().is_array() && stack_.back().count() > 0) - { - result_.push_back(','); - } - - switch (tag) - { - case semantic_tag::bigint: - write_bigint_value(sv); - break; - default: - { - result_.push_back('\"'); - jsoncons::detail::escape_string(sv.data(), sv.length(),options_.escape_all_non_ascii(),options_.escape_solidus(),result_); - result_.push_back('\"'); - break; - } - } - - if (!stack_.empty()) - { - stack_.back().increment_count(); - } - return true; - } - - bool do_byte_string_value(const byte_string_view& b, - semantic_tag tag, - const ser_context&) override - { - if (!stack_.empty() && stack_.back().is_array() && stack_.back().count() > 0) - { - result_.push_back(','); - } - - byte_string_chars_format encoding_hint; - switch (tag) - { - case semantic_tag::base16: - encoding_hint = byte_string_chars_format::base16; - break; - case semantic_tag::base64: - encoding_hint = byte_string_chars_format::base64; - break; - case semantic_tag::base64url: - encoding_hint = byte_string_chars_format::base64url; - break; - default: - encoding_hint = byte_string_chars_format::none; - break; - } - - byte_string_chars_format format = jsoncons::detail::resolve_byte_string_chars_format(options_.byte_string_format(), - encoding_hint, - byte_string_chars_format::base64url); - switch (format) - { - case byte_string_chars_format::base16: - { - result_.push_back('\"'); - encode_base16(b.begin(),b.end(),result_); - result_.push_back('\"'); - break; - } - case byte_string_chars_format::base64: - { - result_.push_back('\"'); - encode_base64(b.begin(), b.end(), result_); - result_.push_back('\"'); - break; - } - case byte_string_chars_format::base64url: - { - result_.push_back('\"'); - encode_base64url(b.begin(),b.end(),result_); - result_.push_back('\"'); - break; - } - default: - { - JSONCONS_UNREACHABLE(); - } - } - - if (!stack_.empty()) - { - stack_.back().increment_count(); - } - return true; - } - - bool do_double_value(double value, - semantic_tag, - const ser_context& context) override - { - if (!stack_.empty() && stack_.back().is_array() && stack_.back().count() > 0) - { - result_.push_back(','); - } - - if (JSONCONS_UNLIKELY(!std::isfinite(value))) - { - if ((std::isnan)(value)) - { - if (options_.is_nan_to_num()) - { - result_.append(options_.nan_to_num().data(), options_.nan_to_num().length()); - } - else if (options_.is_nan_to_str()) - { - do_string_value(options_.nan_to_str(), semantic_tag::none, context); - } - else - { - result_.append(null_k().data(), null_k().size()); - } - } - else if (value == std::numeric_limits::infinity()) - { - if (options_.is_inf_to_num()) - { - result_.append(options_.inf_to_num().data(), options_.inf_to_num().length()); - } - else if (options_.is_inf_to_str()) - { - do_string_value(options_.inf_to_str(), semantic_tag::none, context); - } - else - { - result_.append(null_k().data(), null_k().size()); - } - } - else - { - if (options_.is_neginf_to_num()) - { - result_.append(options_.neginf_to_num().data(), options_.neginf_to_num().length()); - } - else if (options_.is_neginf_to_str()) - { - do_string_value(options_.neginf_to_str(), semantic_tag::none, context); - } - else - { - result_.append(null_k().data(), null_k().size()); - } - } - } - else - { - fp_(value, result_); - } - - if (!stack_.empty()) - { - stack_.back().increment_count(); - } - return true; - } - - bool do_int64_value(int64_t value, - semantic_tag, - const ser_context&) override - { - if (!stack_.empty() && stack_.back().is_array() && stack_.back().count() > 0) - { - result_.push_back(','); - } - jsoncons::detail::print_integer(value, result_); - if (!stack_.empty()) - { - stack_.back().increment_count(); - } - return true; - } - - bool do_uint64_value(uint64_t value, - semantic_tag, - const ser_context&) override - { - if (!stack_.empty() && stack_.back().is_array() && stack_.back().count() > 0) - { - result_.push_back(','); - } - jsoncons::detail::print_uinteger(value, result_); - if (!stack_.empty()) - { - stack_.back().increment_count(); - } - return true; - } - - bool do_bool_value(bool value, semantic_tag, const ser_context&) override - { - if (!stack_.empty() && stack_.back().is_array() && stack_.back().count() > 0) - { - result_.push_back(','); - } - - if (value) - { - result_.append(true_k().data(), true_k().size()); - } - else - { - result_.append(false_k().data(), false_k().size()); - } - - if (!stack_.empty()) - { - stack_.back().increment_count(); - } - return true; - } -}; - -typedef basic_json_encoder> json_encoder; -typedef basic_json_encoder> wjson_encoder; - -typedef basic_json_compressed_encoder> json_compressed_encoder; -typedef basic_json_compressed_encoder> wjson_compressed_encoder; - -typedef basic_json_encoder> json_string_encoder; -typedef basic_json_encoder> wjson_string_encoder; - -typedef basic_json_compressed_encoder> json_compressed_string_encoder; -typedef basic_json_compressed_encoder> wjson_compressed_string_encoder; - -#if !defined(JSONCONS_NO_DEPRECATED) -template> -using basic_json_serializer = basic_json_encoder; - -template> -using basic_json_compressed_serializer = basic_json_compressed_encoder; - -typedef basic_json_serializer> json_serializer; -typedef basic_json_serializer> wjson_encoder; - -typedef basic_json_compressed_serializer> json_compressed_serializer; -typedef basic_json_compressed_serializer> wjson_compressed_serializer; - -typedef basic_json_serializer> json_string_serializer; -typedef basic_json_serializer> wjson_string_serializer; - -typedef basic_json_compressed_serializer> json_compressed_string_serializer; -typedef basic_json_compressed_serializer> wjson_compressed_string_serializer; -#endif - -} -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/json_error.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/json_error.hpp deleted file mode 100644 index 90410a41a1..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/json_error.hpp +++ /dev/null @@ -1,154 +0,0 @@ -/// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_JSON_ERROR_HPP -#define JSONCONS_JSON_ERROR_HPP - -#include -#include - -namespace jsoncons { - - enum class json_errc - { - ok = 0, - unexpected_eof = 1, - source_error, - invalid_json_text, - extra_character, - max_depth_exceeded, - single_quote, - illegal_character_in_string, - extra_comma, - expected_name, - expected_value, - invalid_value, - expected_colon, - illegal_control_character, - illegal_escaped_character, - expected_codepoint_surrogate_pair, - invalid_hex_escape_sequence, - invalid_unicode_escape_sequence, - leading_zero, - invalid_number, - expected_comma_or_right_brace, - expected_comma_or_right_bracket, - unexpected_right_bracket, - unexpected_right_brace, - illegal_comment, - expected_continuation_byte, - over_long_utf8_sequence, - illegal_codepoint, - illegal_surrogate_value, - unpaired_high_surrogate - }; - -class json_error_category_impl - : public std::error_category -{ -public: - const char* name() const noexcept override - { - return "jsoncons/json"; - } - std::string message(int ev) const override - { - switch (static_cast(ev)) - { - case json_errc::unexpected_eof: - return "Unexpected end of file"; - case json_errc::source_error: - return "Source error"; - case json_errc::invalid_json_text: - return "Invalid JSON text"; - case json_errc::extra_character: - return "Unexpected non-whitespace character after JSON text"; - case json_errc::max_depth_exceeded: - return "Maximum JSON depth exceeded"; - case json_errc::single_quote: - return "JSON strings cannot be quoted with single quotes"; - case json_errc::illegal_character_in_string: - return "Illegal character in string"; - case json_errc::extra_comma: - return "Extra comma"; - case json_errc::expected_name: - return "Expected object member name"; - case json_errc::expected_value: - return "Expected value"; - case json_errc::invalid_value: - return "Invalid value"; - case json_errc::expected_colon: - return "Expected name separator ':'"; - case json_errc::illegal_control_character: - return "Illegal control character in string"; - case json_errc::illegal_escaped_character: - return "Illegal escaped character in string"; - case json_errc::expected_codepoint_surrogate_pair: - return "Invalid codepoint, expected another \\u token to begin the second half of a codepoint surrogate pair."; - case json_errc::invalid_hex_escape_sequence: - return "Invalid codepoint, expected hexadecimal digit."; - case json_errc::invalid_unicode_escape_sequence: - return "Invalid codepoint, expected four hexadecimal digits."; - case json_errc::leading_zero: - return "A number cannot have a leading zero"; - case json_errc::invalid_number: - return "Invalid number"; - case json_errc::expected_comma_or_right_brace: - return "Expected comma or right brace '}'"; - case json_errc::expected_comma_or_right_bracket: - return "Expected comma or right bracket ']'"; - case json_errc::unexpected_right_brace: - return "Unexpected right brace '}'"; - case json_errc::unexpected_right_bracket: - return "Unexpected right bracket ']'"; - case json_errc::illegal_comment: - return "Illegal comment"; - case json_errc::expected_continuation_byte: - return "Expected continuation byte"; - case json_errc::over_long_utf8_sequence: - return "Over long UTF-8 sequence"; - case json_errc::illegal_codepoint: - return "Illegal codepoint (>= 0xd800 && <= 0xdfff)"; - case json_errc::illegal_surrogate_value: - return "UTF-16 surrogate values are illegal in UTF-32"; - case json_errc::unpaired_high_surrogate: - return "Expected low surrogate following the high surrogate"; - default: - return "Unknown JSON parser error"; - } - } -}; - -inline -const std::error_category& json_error_category() -{ - static json_error_category_impl instance; - return instance; -} - -inline -std::error_code make_error_code(json_errc result) -{ - return std::error_code(static_cast(result),json_error_category()); -} - -#if !defined(JSONCONS_NO_DEPRECATED) -typedef json_errc json_parser_errc; - -typedef json_errc json_parse_errc; -#endif - - -} - -namespace std { - template<> - struct is_error_code_enum : public true_type - { - }; -} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/json_exception.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/json_exception.hpp deleted file mode 100644 index 87269c7d5e..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/json_exception.hpp +++ /dev/null @@ -1,183 +0,0 @@ -// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSON_EXCEPTION_HPP -#define JSON_EXCEPTION_HPP - -#include // std::string -#include // std::ostringstream -#include // std::error_code -#include // unicons::convert -#include - -namespace jsoncons { - -// json_exception - -class json_exception -{ -public: - virtual const char* what() const noexcept = 0; -}; - -template -class json_runtime_error : public Base, public virtual json_exception -{ -public: - json_runtime_error(const std::string& s) noexcept - : Base(""), message_(s) - { - } - ~json_runtime_error() noexcept - { - } - const char* what() const noexcept override - { - return message_.c_str(); - } -private: - std::string message_; -}; - -class key_not_found : public std::out_of_range, public virtual json_exception -{ -public: - template - explicit key_not_found(const CharT* key, size_t length) noexcept - : std::out_of_range("") - { - buffer_.append("Key '"); - unicons::convert(key, key+length, std::back_inserter(buffer_), - unicons::conv_flags::strict); - buffer_.append("' not found"); - } - ~key_not_found() noexcept - { - } - const char* what() const noexcept override - { - return buffer_.c_str(); - } -private: - std::string buffer_; -}; - -class not_an_object : public std::runtime_error, public virtual json_exception -{ -public: - template - explicit not_an_object(const CharT* key, size_t length) noexcept - : std::runtime_error("") - { - buffer_.append("Attempting to access or modify '"); - unicons::convert(key, key+length, std::back_inserter(buffer_), - unicons::conv_flags::strict); - buffer_.append("' on a value that is not an object"); - } - ~not_an_object() noexcept - { - } - const char* what() const noexcept override - { - return buffer_.c_str(); - } -private: - std::string buffer_; -}; - -class ser_error : public std::system_error, public virtual json_exception -{ -public: - ser_error(std::error_code ec) - : std::system_error(ec), line_number_(0), column_number_(0) - { - } - ser_error(std::error_code ec, size_t position) - : std::system_error(ec), line_number_(0), column_number_(position) - { - } - ser_error(std::error_code ec, size_t line, size_t column) - : std::system_error(ec), line_number_(line), column_number_(column) - { - } - ser_error(const ser_error& other) = default; - - ser_error(ser_error&& other) = default; - - const char* what() const noexcept override - { - try - { - std::ostringstream os; - os << this->code().message(); - if (line_number_ != 0 && column_number_ != 0) - { - os << " at line " << line_number_ << " and column " << column_number_; - } - else if (column_number_ != 0) - { - os << " at position " << column_number_; - } - const_cast(buffer_) = os.str(); - return buffer_.c_str(); - } - catch (...) - { - return std::system_error::what(); - } - } - - size_t line() const noexcept - { - return line_number_; - } - - size_t column() const noexcept - { - return column_number_; - } - -#if !defined(JSONCONS_NO_DEPRECATED) - size_t line_number() const noexcept - { - return line(); - } - - size_t column_number() const noexcept - { - return column(); - } -#endif -private: - std::string buffer_; - size_t line_number_; - size_t column_number_; -}; - -#if !defined(JSONCONS_NO_DEPRECATED) -typedef ser_error serialization_error; -typedef ser_error json_parse_exception; -typedef ser_error parse_exception; -typedef ser_error parse_error; -#endif - -#define JSONCONS_STR2(x) #x -#define JSONCONS_STR(x) JSONCONS_STR2(x) - -#ifdef _DEBUG -#define JSONCONS_ASSERT(x) if (!(x)) { \ - throw jsoncons::json_runtime_error("assertion '" #x "' failed at " __FILE__ ":" \ - JSONCONS_STR(__LINE__)); } -#else -#define JSONCONS_ASSERT(x) if (!(x)) { \ - throw jsoncons::json_runtime_error("assertion '" #x "' failed at <> :" \ - JSONCONS_STR( 0 )); } -#endif // _DEBUG - -#define JSONCONS_THROW(x) throw (x) - -} -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/json_filter.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/json_filter.hpp deleted file mode 100644 index 116e6b822e..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/json_filter.hpp +++ /dev/null @@ -1,382 +0,0 @@ -// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_JSON_FILTER_HPP -#define JSONCONS_JSON_FILTER_HPP - -#include - -#include -#include - -namespace jsoncons { - -template -class basic_json_filter : public basic_json_content_handler -{ -public: - using typename basic_json_content_handler::string_view_type; -private: - basic_json_content_handler& to_handler_; - - // noncopyable and nonmoveable - basic_json_filter(const basic_json_filter&) = delete; - basic_json_filter& operator=(const basic_json_filter&) = delete; -public: - basic_json_filter(basic_json_content_handler& handler) - : to_handler_(handler) - { - } - -#if !defined(JSONCONS_NO_DEPRECATED) - basic_json_content_handler& input_handler() - { - return to_handler_; - } - - basic_json_content_handler& downstream_handler() - { - return to_handler_; - } - - basic_json_content_handler& destination_handler() - { - return to_handler_; - } -#endif - - basic_json_content_handler& to_handler() - { - return to_handler_; - } - -private: - void do_flush() override - { - to_handler_.flush(); - } - - bool do_begin_object(semantic_tag tag, const ser_context& context) override - { - return to_handler_.begin_object(tag, context); - } - - bool do_begin_object(size_t length, semantic_tag tag, const ser_context& context) override - { - return to_handler_.begin_object(length, tag, context); - } - - bool do_end_object(const ser_context& context) override - { - return to_handler_.end_object(context); - } - - bool do_begin_array(semantic_tag tag, const ser_context& context) override - { - return to_handler_.begin_array(tag, context); - } - - bool do_begin_array(size_t length, semantic_tag tag, const ser_context& context) override - { - return to_handler_.begin_array(length, tag, context); - } - - bool do_end_array(const ser_context& context) override - { - return to_handler_.end_array(context); - } - - bool do_name(const string_view_type& name, - const ser_context& context) override - { - return to_handler_.name(name, context); - } - - bool do_string_value(const string_view_type& value, - semantic_tag tag, - const ser_context& context) override - { - return to_handler_.string_value(value, tag, context); - } - - bool do_byte_string_value(const byte_string_view& b, - semantic_tag tag, - const ser_context& context) override - { - return to_handler_.byte_string_value(b, tag, context); - } - - bool do_double_value(double value, - semantic_tag tag, - const ser_context& context) override - { - return to_handler_.double_value(value, tag, context); - } - - bool do_int64_value(int64_t value, - semantic_tag tag, - const ser_context& context) override - { - return to_handler_.int64_value(value, tag, context); - } - - bool do_uint64_value(uint64_t value, - semantic_tag tag, - const ser_context& context) override - { - return to_handler_.uint64_value(value, tag, context); - } - - bool do_bool_value(bool value, semantic_tag tag, const ser_context& context) override - { - return to_handler_.bool_value(value, tag, context); - } - - bool do_null_value(semantic_tag tag, const ser_context& context) override - { - return to_handler_.null_value(tag, context); - } - -}; - -// Filters out begin_document and end_document events -template -class basic_json_fragment_filter : public basic_json_filter -{ -public: - using typename basic_json_filter::string_view_type; - - basic_json_fragment_filter(basic_json_content_handler& handler) - : basic_json_filter(handler) - { - } -private: - void do_flush() override - { - } -}; - -template -class basic_rename_object_member_filter : public basic_json_filter -{ -public: - using typename basic_json_filter::string_view_type; - -private: - std::basic_string name_; - std::basic_string new_name_; -public: - basic_rename_object_member_filter(const std::basic_string& name, - const std::basic_string& new_name, - basic_json_content_handler& handler) - : basic_json_filter(handler), - name_(name), new_name_(new_name) - { - } - -private: - bool do_name(const string_view_type& name, - const ser_context& context) override - { - if (name == name_) - { - return this->to_handler().name(new_name_,context); - } - else - { - return this->to_handler().name(name,context); - } - } -}; - -template -class json_content_handler_adaptor : public From -{ -public: - using typename From::string_view_type; -private: - To* to_handler_; - - // noncopyable - json_content_handler_adaptor(const json_content_handler_adaptor&) = delete; - json_content_handler_adaptor& operator=(const json_content_handler_adaptor&) = delete; -public: - - json_content_handler_adaptor() - : to_handler_(nullptr) - { - } - json_content_handler_adaptor(To& handler) - : to_handler_(std::addressof(handler)) - { - } - - // moveable - json_content_handler_adaptor(json_content_handler_adaptor&&) = default; - json_content_handler_adaptor& operator=(json_content_handler_adaptor&&) = default; - - To& to_handler() - { - return *to_handler_; - } - -private: - void do_flush() override - { - to_handler_->flush(); - } - - bool do_begin_object(semantic_tag tag, - const ser_context& context) override - { - return to_handler_->begin_object(tag, context); - } - - bool do_begin_object(size_t length, - semantic_tag tag, - const ser_context& context) override - { - return to_handler_->begin_object(length, tag, context); - } - - bool do_end_object(const ser_context& context) override - { - return to_handler_->end_object(context); - } - - bool do_begin_array(semantic_tag tag, - const ser_context& context) override - { - return to_handler_->begin_array(tag, context); - } - - bool do_begin_array(size_t length, - semantic_tag tag, - const ser_context& context) override - { - return to_handler_->begin_array(length, tag, context); - } - - bool do_end_array(const ser_context& context) override - { - return to_handler_->end_array(context); - } - - bool do_name(const string_view_type& name, - const ser_context& context) override - { - std::basic_string target; - auto result = unicons::convert(name.begin(),name.end(),std::back_inserter(target),unicons::conv_flags::strict); - if (result.ec != unicons::conv_errc()) - { - throw ser_error(result.ec); - } - return to_handler().name(target, context); - } - - bool do_string_value(const string_view_type& value, - semantic_tag tag, - const ser_context& context) override - { - std::basic_string target; - auto result = unicons::convert(value.begin(),value.end(),std::back_inserter(target),unicons::conv_flags::strict); - if (result.ec != unicons::conv_errc()) - { - throw ser_error(result.ec); - } - return to_handler().string_value(target, tag, context); - } - - bool do_byte_string_value(const byte_string_view& b, - semantic_tag tag, - const ser_context& context) override - { - return to_handler_->byte_string_value(b, tag, context); - } - - bool do_double_value(double value, - semantic_tag tag, - const ser_context& context) override - { - return to_handler_->double_value(value, tag, context); - } - - bool do_int64_value(int64_t value, - semantic_tag tag, - const ser_context& context) override - { - return to_handler_->int64_value(value, tag, context); - } - - bool do_uint64_value(uint64_t value, - semantic_tag tag, - const ser_context& context) override - { - return to_handler_->uint64_value(value, tag, context); - } - - bool do_bool_value(bool value, semantic_tag tag, const ser_context& context) override - { - return to_handler_->bool_value(value, tag, context); - } - - bool do_null_value(semantic_tag tag, const ser_context& context) override - { - return to_handler_->null_value(tag, context); - } - -}; - -template -class json_content_handler_adaptor::value>::type> -{ -public: - typedef typename From::char_type char_type; - typedef typename From::char_traits_type char_traits_type; - typedef typename From::string_view_type string_view_type; -private: - To* to_handler_; -public: - json_content_handler_adaptor() - : to_handler_(nullptr) - { - } - json_content_handler_adaptor(To& handler) - : to_handler_(std::addressof(handler)) - { - } - - operator From&() { return *to_handler_; } - - // moveable - json_content_handler_adaptor(json_content_handler_adaptor&&) = default; - json_content_handler_adaptor& operator=(json_content_handler_adaptor&&) = default; - - To& to_handler() - { - return *to_handler_; - } -}; - -template -json_content_handler_adaptor make_json_content_handler_adaptor(To& to) -{ - return json_content_handler_adaptor(to); -} - -typedef basic_json_filter json_filter; -typedef basic_json_filter wjson_filter; -typedef basic_rename_object_member_filter rename_object_member_filter; -typedef basic_rename_object_member_filter wrename_object_member_filter; - -#if !defined(JSONCONS_NO_DEPRECATED) -typedef basic_rename_object_member_filter rename_name_filter; -typedef basic_rename_object_member_filter wrename_name_filter; -#endif - -} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/json_fwd.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/json_fwd.hpp deleted file mode 100644 index d9b44cf8b1..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/json_fwd.hpp +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_JSON_FWD_HPP -#define JSONCONS_JSON_FWD_HPP - -#include // std::allocator - -namespace jsoncons { - -struct sorted_policy; - -template > -class basic_json; - -} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/json_options.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/json_options.hpp deleted file mode 100644 index fa434ee934..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/json_options.hpp +++ /dev/null @@ -1,837 +0,0 @@ -// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_JSON_OPTIONS_HPP -#define JSONCONS_JSON_OPTIONS_HPP - -#include -#include // std::numeric_limits -#include -#include -#include - -namespace jsoncons { - -#if !defined(JSONCONS_NO_TO_CHARS) -using chars_format = std::chars_format; -#else -enum class chars_format : uint8_t {fixed=1,scientific=2,hex=4,general=fixed|scientific}; -#endif - -// floating_point_options - -class floating_point_options -{ - chars_format format_; - int precision_; - uint8_t decimal_places_; -public: - floating_point_options() - : format_(chars_format::general), precision_(0), decimal_places_(0) - { - } - - floating_point_options(chars_format format, int precision, uint8_t decimal_places = 0) - : format_(format), precision_(precision), decimal_places_(decimal_places) - { - } - - explicit floating_point_options(chars_format format) - : format_(format), precision_(0), decimal_places_(0) - { - } - - floating_point_options(const floating_point_options&) = default; - floating_point_options(floating_point_options&&) = default; - floating_point_options& operator=(const floating_point_options& e) = default; - floating_point_options& operator=(floating_point_options&& e) = default; - - int precision() const - { - return precision_; - } - - uint8_t decimal_places() const - { - return decimal_places_; - } - - chars_format format() const - { - return format_; - } -}; - -enum class indenting : uint8_t {no_indent = 0, indent = 1}; - -enum class line_split_kind : uint8_t {same_line,new_line,multi_line}; - -enum class bigint_chars_format : uint8_t {number, base10, base64, base64url -#if !defined(JSONCONS_NO_DEPRECATED) -,integer = number -#endif -}; - -#if !defined(JSONCONS_NO_DEPRECATED) -typedef bigint_chars_format bignum_chars_format; -typedef bigint_chars_format big_integer_chars_format; -#endif - -enum class byte_string_chars_format : uint8_t {none=0,base16,base64,base64url}; - -enum class spaces_option{no_spaces=0,space_after,space_before,space_before_and_after}; - -template -class basic_json_decode_options -{ -public: - typedef std::basic_string string_type; - - virtual ~basic_json_decode_options() = default; - - virtual size_t max_nesting_depth() const = 0; - - virtual bool is_str_to_nan() const = 0; - - virtual std::basic_string nan_to_str() const = 0; - - virtual bool is_str_to_inf() const = 0; - - virtual std::basic_string inf_to_str() const = 0; - - virtual bool is_str_to_neginf() const = 0; - - virtual std::basic_string neginf_to_str() const = 0; - - virtual bool lossless_number() const = 0; -}; - -template -class basic_json_encode_options -{ -public: - typedef std::basic_string string_type; - - virtual ~basic_json_encode_options() = default; - - virtual size_t max_nesting_depth() const = 0; - - virtual byte_string_chars_format byte_string_format() const = 0; - - virtual bigint_chars_format bigint_format() const = 0; - - virtual line_split_kind object_object_line_splits() const = 0; - - virtual line_split_kind array_object_line_splits() const = 0; - - virtual line_split_kind object_array_line_splits() const = 0; - - virtual line_split_kind array_array_line_splits() const = 0; - - virtual size_t indent_size() const = 0; - - virtual size_t line_length_limit() const = 0; - - virtual chars_format floating_point_format() const = 0; - - virtual int precision() const = 0; - - virtual bool escape_all_non_ascii() const = 0; - - virtual bool escape_solidus() const = 0; - - virtual spaces_option spaces_around_colon() const = 0; - - virtual spaces_option spaces_around_comma() const = 0; - - virtual bool pad_inside_object_braces() const = 0; - - virtual bool pad_inside_array_brackets() const = 0; - - virtual std::basic_string new_line_chars() const = 0; - - virtual bool is_nan_to_num() const = 0; - - virtual std::basic_string nan_to_num() const = 0; - - virtual bool is_inf_to_num() const = 0; - - virtual std::basic_string inf_to_num() const = 0; - - virtual bool is_neginf_to_num() const = 0; - - virtual std::basic_string neginf_to_num() const = 0; - - virtual bool is_nan_to_str() const = 0; - - virtual std::basic_string nan_to_str() const = 0; - - virtual bool is_inf_to_str() const = 0; - - virtual std::basic_string inf_to_str() const = 0; - - virtual bool is_neginf_to_str() const = 0; - - virtual std::basic_string neginf_to_str() const = 0; -}; - -template -class basic_json_options : public virtual basic_json_decode_options, - public virtual basic_json_encode_options -{ -public: - typedef CharT char_type; - typedef std::basic_string string_type; -private: - size_t indent_size_; - chars_format floating_point_format_; - int precision_; -#if !defined(JSONCONS_NO_DEPRECATED) - bool can_read_nan_replacement_; - bool can_read_pos_inf_replacement_; - bool can_read_neg_inf_replacement_; - string_type nan_replacement_; - string_type pos_inf_replacement_; - string_type neg_inf_replacement_; -#endif - bool escape_all_non_ascii_; - bool escape_solidus_; - byte_string_chars_format byte_string_format_; - bigint_chars_format bigint_format_; - line_split_kind object_object_line_splits_; - line_split_kind object_array_line_splits_; - line_split_kind array_array_line_splits_; - line_split_kind array_object_line_splits_; - size_t line_length_limit_; - - size_t max_nesting_depth_; - spaces_option spaces_around_colon_; - spaces_option spaces_around_comma_; - bool pad_inside_object_braces_; - bool pad_inside_array_brackets_; - std::basic_string new_line_chars_; - - bool is_nan_to_num_; - bool is_inf_to_num_; - bool is_neginf_to_num_; - bool is_nan_to_str_; - bool is_inf_to_str_; - bool is_neginf_to_str_; - bool is_str_to_nan_; - bool is_str_to_inf_; - bool is_str_to_neginf_; - - std::basic_string nan_to_num_; - std::basic_string inf_to_num_; - std::basic_string neginf_to_num_; - std::basic_string nan_to_str_; - std::basic_string inf_to_str_; - std::basic_string neginf_to_str_; - - bool lossless_number_; -public: - static const size_t indent_size_default = 4; - static const size_t line_length_limit_default = 120; - - static const basic_json_options& default_options() - { - static basic_json_options options{}; - return options; - } - -// Constructors - - basic_json_options() - : indent_size_(indent_size_default), - floating_point_format_(chars_format()), - precision_(0), -#if !defined(JSONCONS_NO_DEPRECATED) - can_read_nan_replacement_(false), - can_read_pos_inf_replacement_(false), - can_read_neg_inf_replacement_(false), -#endif - escape_all_non_ascii_(false), - escape_solidus_(false), - byte_string_format_(byte_string_chars_format::none), - bigint_format_(bigint_chars_format::base10), - object_object_line_splits_(line_split_kind::multi_line), - object_array_line_splits_(line_split_kind::same_line), - array_array_line_splits_(line_split_kind::new_line), - array_object_line_splits_(line_split_kind::multi_line), - line_length_limit_(line_length_limit_default), - max_nesting_depth_((std::numeric_limits::max)()), - spaces_around_colon_(spaces_option::space_after), - spaces_around_comma_(spaces_option::space_after), - pad_inside_object_braces_(false), - pad_inside_array_brackets_(false), - is_nan_to_num_(false), - is_inf_to_num_(false), - is_neginf_to_num_(false), - is_nan_to_str_(false), - is_inf_to_str_(false), - is_neginf_to_str_(false), - is_str_to_nan_(false), - is_str_to_inf_(false), - is_str_to_neginf_(false), - lossless_number_(false) - { - new_line_chars_.push_back('\n'); - } - -// Properties - byte_string_chars_format byte_string_format() const override {return byte_string_format_;} - basic_json_options& byte_string_format(byte_string_chars_format value) {byte_string_format_ = value; return *this;} - - bigint_chars_format bigint_format() const override {return bigint_format_;} - basic_json_options& bigint_format(bigint_chars_format value) {bigint_format_ = value; return *this;} - -#if !defined(JSONCONS_NO_DEPRECATED) - basic_json_options& big_integer_format(bigint_chars_format value) {bigint_format_ = value; return *this;} - bignum_chars_format bignum_format() const {return bigint_format_;} - basic_json_options& bignum_format(bignum_chars_format value) {bigint_format_ = value; return *this;} -#endif - line_split_kind object_object_line_splits() const override {return object_object_line_splits_;} - basic_json_options& object_object_line_splits(line_split_kind value) {object_object_line_splits_ = value; return *this;} - - line_split_kind array_object_line_splits() const override {return array_object_line_splits_;} - basic_json_options& array_object_line_splits(line_split_kind value) {array_object_line_splits_ = value; return *this;} - - line_split_kind object_array_line_splits() const override {return object_array_line_splits_;} - basic_json_options& object_array_line_splits(line_split_kind value) {object_array_line_splits_ = value; return *this;} - - line_split_kind array_array_line_splits() const override {return array_array_line_splits_;} - basic_json_options& array_array_line_splits(line_split_kind value) {array_array_line_splits_ = value; return *this;} - - size_t indent_size() const override - { - return indent_size_; - } - - basic_json_options& indent_size(size_t value) - { - indent_size_ = value; - return *this; - } - - spaces_option spaces_around_colon() const override - { - return spaces_around_colon_; - } - - basic_json_options& spaces_around_colon(spaces_option value) - { - spaces_around_colon_ = value; - return *this; - } - - spaces_option spaces_around_comma() const override - { - return spaces_around_comma_; - } - - basic_json_options& spaces_around_comma(spaces_option value) - { - spaces_around_comma_ = value; - return *this; - } - - bool pad_inside_object_braces() const override - { - return pad_inside_object_braces_; - } - - basic_json_options& pad_inside_object_braces(bool value) - { - pad_inside_object_braces_ = value; - return *this; - } - - bool pad_inside_array_brackets() const override - { - return pad_inside_array_brackets_; - } - - basic_json_options& pad_inside_array_brackets(bool value) - { - pad_inside_array_brackets_ = value; - return *this; - } - - std::basic_string new_line_chars() const override - { - return new_line_chars_; - } - - basic_json_options& new_line_chars(const std::basic_string& value) - { - new_line_chars_ = value; - return *this; - } - - bool is_nan_to_num() const override - { - return is_nan_to_num_; - } - - bool is_inf_to_num() const override - { - return is_inf_to_num_; - } - - bool is_neginf_to_num() const override - { - return is_neginf_to_num_ || is_inf_to_num_; - } - - bool is_nan_to_str() const override - { - return is_nan_to_str_; - } - - bool is_str_to_nan() const override - { - return is_str_to_nan_; - } - - bool is_inf_to_str() const override - { - return is_inf_to_str_; - } - - bool is_str_to_inf() const override - { - return is_str_to_inf_; - } - - bool is_neginf_to_str() const override - { - return is_neginf_to_str_ || is_inf_to_str_; - } - - bool is_str_to_neginf() const override - { - return is_str_to_neginf_ || is_str_to_inf_; - } - - std::basic_string nan_to_num() const override - { - if (is_nan_to_num_) - { - return nan_to_num_; - } -#if !defined(JSONCONS_NO_DEPRECATED) - else if (!can_read_nan_replacement_) // not string - { - return nan_replacement_; - } -#endif - else - { - return nan_to_num_; // empty string - } - } - - basic_json_options& nan_to_num(const std::basic_string& value) - { - is_nan_to_num_ = true; - nan_to_str_.clear(); - nan_to_num_ = value; - return *this; - } - - std::basic_string inf_to_num() const override - { - if (is_inf_to_num_) - { - return inf_to_num_; - } -#if !defined(JSONCONS_NO_DEPRECATED) - else if (!can_read_pos_inf_replacement_) // not string - { - return pos_inf_replacement_; - } -#endif - else - { - return inf_to_num_; // empty string - } - } - - basic_json_options& inf_to_num(const std::basic_string& value) - { - is_inf_to_num_ = true; - inf_to_str_.clear(); - inf_to_num_ = value; - return *this; - } - - std::basic_string neginf_to_num() const override - { - if (is_neginf_to_num_) - { - return neginf_to_num_; - } - else if (is_inf_to_num_) - { - std::basic_string s; - s.push_back('-'); - s.append(inf_to_num_); - return s; - } -#if !defined(JSONCONS_NO_DEPRECATED) - else if (!can_read_neg_inf_replacement_) // not string - { - return neg_inf_replacement_; - } -#endif - else - { - return neginf_to_num_; // empty string - } - } - - basic_json_options& neginf_to_num(const std::basic_string& value) - { - is_neginf_to_num_ = true; - neginf_to_str_.clear(); - neginf_to_num_ = value; - return *this; - } - - std::basic_string nan_to_str() const override - { - if (is_nan_to_str_) - { - return nan_to_str_; - } -#if !defined(JSONCONS_NO_DEPRECATED) - else if (can_read_nan_replacement_ && nan_replacement_.size() >= 2) // string - { - return nan_replacement_.substr(1,nan_replacement_.size()-2); // Remove quotes - } -#endif - else - { - return nan_to_str_; // empty string - } - } - - basic_json_options& nan_to_str(const std::basic_string& value, bool is_str_to_nan = true) - { - is_nan_to_str_ = true; - is_str_to_nan_ = is_str_to_nan; - nan_to_num_.clear(); - nan_to_str_ = value; - return *this; - } - - std::basic_string inf_to_str() const override - { - if (is_inf_to_str_) - { - return inf_to_str_; - } -#if !defined(JSONCONS_NO_DEPRECATED) - else if (can_read_pos_inf_replacement_ && pos_inf_replacement_.size() >= 2) // string - { - return pos_inf_replacement_.substr(1,pos_inf_replacement_.size()-2); // Strip quotes - } -#endif - else - { - return inf_to_str_; // empty string - } - } - - basic_json_options& inf_to_str(const std::basic_string& value, bool is_inf_to_str = true) - { - is_inf_to_str_ = true; - is_inf_to_str_ = is_inf_to_str; - inf_to_num_.clear(); - inf_to_str_ = value; - return *this; - } - - std::basic_string neginf_to_str() const override - { - if (is_neginf_to_str_) - { - return neginf_to_str_; - } - else if (is_inf_to_str_) - { - std::basic_string s; - s.push_back('-'); - s.append(inf_to_str_); - return s; - } -#if !defined(JSONCONS_NO_DEPRECATED) - else if (can_read_neg_inf_replacement_ && neg_inf_replacement_.size() >= 2) // string - { - return neg_inf_replacement_.substr(1,neg_inf_replacement_.size()-2); // Strip quotes - } -#endif - else - { - return neginf_to_str_; // empty string - } - } - - basic_json_options& neginf_to_str(const std::basic_string& value, bool is_neginf_to_str = true) - { - is_neginf_to_str_ = true; - is_neginf_to_str_ = is_neginf_to_str; - neginf_to_num_.clear(); - neginf_to_str_ = value; - return *this; - } - - bool lossless_number() const override - { - return lossless_number_; - } - - basic_json_options& lossless_number(bool value) - { - lossless_number_ = value; - return *this; - } - - size_t line_length_limit() const override - { - return line_length_limit_; - } - - basic_json_options& line_length_limit(size_t value) - { - line_length_limit_ = value; - return *this; - } - - chars_format floating_point_format() const override - { - return floating_point_format_; - } - - basic_json_options& floating_point_format(chars_format value) - { - floating_point_format_ = value; - return *this; - } - - int precision() const override - { - return precision_; - } - - basic_json_options& precision(int value) - { - precision_ = value; - return *this; - } - - bool escape_all_non_ascii() const override - { - return escape_all_non_ascii_; - } - - basic_json_options& escape_all_non_ascii(bool value) - { - escape_all_non_ascii_ = value; - return *this; - } - - bool escape_solidus() const override - { - return escape_solidus_; - } - - basic_json_options& escape_solidus(bool value) - { - escape_solidus_ = value; - return *this; - } - - size_t max_nesting_depth() const override - { - return max_nesting_depth_; - } - - void max_nesting_depth(size_t value) - { - max_nesting_depth_ = value; - } - -#if !defined(JSONCONS_NO_DEPRECATED) - - bool dec_to_str() const - { - return lossless_number_; - } - - basic_json_options& dec_to_str(bool value) - { - lossless_number_ = value; - return *this; - } - - size_t indent() const - { - return indent_size(); - } - - basic_json_options& indent(size_t value) - { - return indent_size(value); - } - - bool can_read_nan_replacement() const {return can_read_nan_replacement_;} - - bool can_read_pos_inf_replacement() const {return can_read_pos_inf_replacement_;} - - bool can_read_neg_inf_replacement() const {return can_read_neg_inf_replacement_;} - - bool can_write_nan_replacement() const {return !nan_replacement_.empty();} - - bool can_write_pos_inf_replacement() const {return !pos_inf_replacement_.empty();} - - bool can_write_neg_inf_replacement() const {return !neg_inf_replacement_.empty();} - - basic_json_options& replace_inf(bool replace) - { - can_read_pos_inf_replacement_ = replace; - can_read_neg_inf_replacement_ = replace; - return *this; - } - - basic_json_options& replace_pos_inf(bool replace) - { - can_read_pos_inf_replacement_ = replace; - return *this; - } - - basic_json_options& replace_neg_inf(bool replace) - { - can_read_neg_inf_replacement_ = replace; - return *this; - } - - const string_type& nan_replacement() const - { - return nan_replacement_; - } - - basic_json_options& nan_replacement(const string_type& value) - { - nan_replacement_ = value; - - can_read_nan_replacement_ = is_string(value); - - return *this; - } - - const string_type& pos_inf_replacement() const - { - return pos_inf_replacement_; - } - - basic_json_options& pos_inf_replacement(const string_type& value) - { - pos_inf_replacement_ = value; - can_read_pos_inf_replacement_ = is_string(value); - return *this; - } - - const string_type& neg_inf_replacement() const - { - return neg_inf_replacement_; - } - - basic_json_options& neg_inf_replacement(const string_type& value) - { - neg_inf_replacement_ = value; - can_read_neg_inf_replacement_ = is_string(value); - return *this; - } - - line_split_kind object_object_split_lines() const {return object_object_line_splits_;} - basic_json_options& object_object_split_lines(line_split_kind value) {object_object_line_splits_ = value; return *this;} - - line_split_kind array_object_split_lines() const {return array_object_line_splits_;} - basic_json_options& array_object_split_lines(line_split_kind value) {array_object_line_splits_ = value; return *this;} - - line_split_kind object_array_split_lines() const {return object_array_line_splits_;} - basic_json_options& object_array_split_lines(line_split_kind value) {object_array_line_splits_ = value; return *this;} - - line_split_kind array_array_split_lines() const {return array_array_line_splits_;} - basic_json_options& array_array_split_lines(line_split_kind value) {array_array_line_splits_ = value; return *this;} -#endif -private: - enum class input_state {initial,begin_quote,character,end_quote,escape,error}; - bool is_string(const string_type& s) const - { - input_state state = input_state::initial; - for (CharT c : s) - { - switch (c) - { - case '\t': case ' ': case '\n': case'\r': - break; - case '\\': - state = input_state::escape; - break; - case '\"': - switch (state) - { - case input_state::initial: - state = input_state::begin_quote; - break; - case input_state::begin_quote: - state = input_state::end_quote; - break; - case input_state::character: - state = input_state::end_quote; - break; - case input_state::end_quote: - state = input_state::error; - break; - case input_state::escape: - state = input_state::character; - break; - default: - state = input_state::character; - break; - } - break; - default: - break; - } - - } - return state == input_state::end_quote; - } -}; - -typedef basic_json_options json_options; -typedef basic_json_options wjson_options; - -typedef basic_json_decode_options json_decode_options; -typedef basic_json_decode_options wjson_decode_options; - -typedef basic_json_encode_options json_encode_options; -typedef basic_json_encode_options wjson_encode_options; - -#if !defined(JSONCONS_NO_DEPRECATED) -typedef basic_json_options output_format; -typedef basic_json_options woutput_format; -typedef basic_json_options serialization_options; -typedef basic_json_options wserialization_options; -typedef basic_json_options json_serializing_options; -typedef basic_json_options wjson_serializing_options; -#endif - -} -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/json_parser.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/json_parser.hpp deleted file mode 100644 index 7f6747a746..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/json_parser.hpp +++ /dev/null @@ -1,2841 +0,0 @@ -// Copyright 2015 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_JSON_PARSER_HPP -#define JSONCONS_JSON_PARSER_HPP - -#include // std::allocator -#include -#include -#include -#include -#include // std::numeric_limits -#include -#include -#include -#include -#include -#include -#include - -#define JSONCONS_ILLEGAL_CONTROL_CHARACTER \ - case 0x00:case 0x01:case 0x02:case 0x03:case 0x04:case 0x05:case 0x06:case 0x07:case 0x08:case 0x0b: \ - case 0x0c:case 0x0e:case 0x0f:case 0x10:case 0x11:case 0x12:case 0x13:case 0x14:case 0x15:case 0x16: \ - case 0x17:case 0x18:case 0x19:case 0x1a:case 0x1b:case 0x1c:case 0x1d:case 0x1e:case 0x1f - -namespace jsoncons { - -namespace detail { - -template -class replacement_filter : public basic_json_filter -{ - typedef typename basic_json_content_handler::string_view_type string_view_type; - typedef typename basic_json_options::string_type string_type; - - bool is_str_to_nan_; - bool is_str_to_inf_; - bool is_str_to_neginf_; - string_type nan_to_str_; - string_type inf_to_str_; - string_type neginf_to_str_; - -public: - replacement_filter() = delete; - - replacement_filter(basic_json_content_handler& handler, - bool is_str_to_nan, - bool is_str_to_inf, - bool is_str_to_neginf, - const string_type& nan_to_str, - const string_type& inf_to_str, - const string_type& neginf_to_str) - : basic_json_filter(handler), - is_str_to_nan_(is_str_to_nan), - is_str_to_inf_(is_str_to_inf), - is_str_to_neginf_(is_str_to_neginf), - nan_to_str_(nan_to_str), - inf_to_str_(inf_to_str), - neginf_to_str_(neginf_to_str) - { - } - - bool do_string_value(const string_view_type& s, - semantic_tag tag, - const ser_context& context) override - { - if (tag == semantic_tag::none) - { - if (is_str_to_nan_ && s == nan_to_str_) - { - return this->to_handler().double_value(std::nan(""), tag, context); - } - else if (is_str_to_inf_ && s == inf_to_str_) - { - return this->to_handler().double_value(std::numeric_limits::infinity(), tag, context); - } - else if (is_str_to_neginf_ && s == neginf_to_str_) - { - return this->to_handler().double_value(-std::numeric_limits::infinity(), tag, context); - } - else - { - return this->to_handler().string_value(s, tag, context); - } - } - else - { - return this->to_handler().string_value(s, tag, context); - } - } -}; - -} - -enum class json_parse_state : uint8_t -{ - root, - start, - before_done, - slash, - slash_slash, - slash_star, - slash_star_star, - expect_comma_or_end, - object, - expect_member_name_or_end, - expect_member_name, - expect_colon, - expect_value_or_end, - expect_value, - array, - string, - member_name, - escape, - escape_u1, - escape_u2, - escape_u3, - escape_u4, - escape_expect_surrogate_pair1, - escape_expect_surrogate_pair2, - escape_u6, - escape_u7, - escape_u8, - escape_u9, - minus, - zero, - integer, - fraction1, - fraction2, - exp1, - exp2, - exp3, - n, - nu, - nul, - t, - tr, - tru, - f, - fa, - fal, - fals, - cr, - done -}; - -template > -class basic_json_parser : public ser_context -{ - typedef std::basic_string string_type; - typedef typename basic_json_content_handler::string_view_type string_view_type; - typedef Allocator allocator_type; - typedef typename std::allocator_traits:: template rebind_alloc char_allocator_type; - typedef typename std::allocator_traits:: template rebind_alloc numeral_allocator_type; - typedef typename std::allocator_traits:: template rebind_alloc byte_allocator_type; - - static const size_t initial_string_buffer_capacity_ = 1024; - static const int default_initial_stack_capacity_ = 100; - - default_parse_error_handler default_err_handler_; - - const basic_json_decode_options& options_; - - parse_error_handler& err_handler_; - int initial_stack_capacity_; - size_t nesting_depth_; - uint32_t cp_; - uint32_t cp2_; - size_t line_; - size_t column_; - const CharT* begin_input_; - const CharT* input_end_; - const CharT* input_ptr_; - json_parse_state state_; - bool continue_; - bool done_; - - std::basic_string,char_allocator_type> string_buffer_; - jsoncons::detail::string_to_double to_double_; - - typedef typename std::allocator_traits:: template rebind_alloc parse_state_allocator_type; - std::vector state_stack_; - - // Noncopyable and nonmoveable - basic_json_parser(const basic_json_parser&) = delete; - basic_json_parser& operator=(const basic_json_parser&) = delete; - -public: - basic_json_parser() - : basic_json_parser(basic_json_options::default_options(), default_err_handler_) - { - } - - basic_json_parser(parse_error_handler& err_handler) - : basic_json_parser(basic_json_options::default_options(), err_handler) - { - } - - basic_json_parser(const basic_json_decode_options& options) - : basic_json_parser(options, default_err_handler_) - { - } - - basic_json_parser(const basic_json_decode_options& options, - parse_error_handler& err_handler) - : options_(options), - err_handler_(err_handler), - initial_stack_capacity_(default_initial_stack_capacity_), - nesting_depth_(0), - cp_(0), - cp2_(0), - line_(1), - column_(1), - begin_input_(nullptr), - input_end_(nullptr), - input_ptr_(nullptr), - state_(json_parse_state::start), - continue_(true), - done_(false) - { - string_buffer_.reserve(initial_string_buffer_capacity_); - - state_stack_.reserve(initial_stack_capacity_); - push_state(json_parse_state::root); - } - - void set_column_number(size_t column) - { - column_ = column; - } - - bool source_exhausted() const - { - return input_ptr_ == input_end_; - } - - ~basic_json_parser() - { - } - -#if !defined(JSONCONS_NO_DEPRECATED) - size_t max_nesting_depth() const - { - return options_.max_nesting_depth(); - } - - void max_nesting_depth(size_t value) - { - options_.max_nesting_depth() = value; - } -#endif - json_parse_state parent() const - { - JSONCONS_ASSERT(state_stack_.size() >= 1); - return state_stack_.back(); - } - - bool done() const - { - return done_; - } - - bool stopped() const - { - return !continue_; - } - - bool finished() const - { - return !continue_ && state_ != json_parse_state::before_done; - } - - void skip_space() - { - const CharT* local_input_end = input_end_; - while (input_ptr_ != local_input_end) - { - switch (*input_ptr_) - { - case ' ': - case '\t': - ++input_ptr_; - ++column_; - break; - case '\r': - push_state(state_); - ++input_ptr_; - ++column_; - state_ = json_parse_state::cr; - return; - case '\n': - ++input_ptr_; - ++line_; - column_ = 1; - return; - default: - return; - } - } - } - - void skip_whitespace() - { - const CharT* local_input_end = input_end_; - - while (input_ptr_ != local_input_end) - { - switch (state_) - { - case json_parse_state::cr: - ++line_; - column_ = 1; - switch (*input_ptr_) - { - case '\n': - ++input_ptr_; - state_ = pop_state(); - break; - default: - state_ = pop_state(); - break; - } - break; - - default: - switch (*input_ptr_) - { - case ' ': - case '\t': - case '\n': - case '\r': - skip_space(); - break; - default: - return; - } - break; - } - } - } - - void begin_object(basic_json_content_handler& handler, std::error_code& ec) - { - if (++nesting_depth_ > options_.max_nesting_depth()) - { - continue_ = err_handler_.error(json_errc::max_depth_exceeded, *this); - if (!continue_) - { - ec = json_errc::max_depth_exceeded; - return; - } - } - push_state(json_parse_state::object); - state_ = json_parse_state::expect_member_name_or_end; - continue_ = handler.begin_object(semantic_tag::none, *this); - } - - void end_object(basic_json_content_handler& handler, std::error_code& ec) - { - if (nesting_depth_ < 1) - { - err_handler_.fatal_error(json_errc::unexpected_right_brace, *this); - ec = json_errc::unexpected_right_brace; - continue_ = false; - return; - } - --nesting_depth_; - state_ = pop_state(); - if (state_ == json_parse_state::object) - { - continue_ = handler.end_object(*this); - } - else if (state_ == json_parse_state::array) - { - err_handler_.fatal_error(json_errc::expected_comma_or_right_bracket, *this); - ec = json_errc::expected_comma_or_right_bracket; - continue_ = false; - return; - } - else - { - err_handler_.fatal_error(json_errc::unexpected_right_brace, *this); - ec = json_errc::unexpected_right_brace; - continue_ = false; - return; - } - - if (parent() == json_parse_state::root) - { - state_ = json_parse_state::before_done; - } - else - { - state_ = json_parse_state::expect_comma_or_end; - } - } - - void begin_array(basic_json_content_handler& handler, std::error_code& ec) - { - if (++nesting_depth_ > options_.max_nesting_depth()) - { - continue_ = err_handler_.error(json_errc::max_depth_exceeded, *this); - if (!continue_) - { - ec = json_errc::max_depth_exceeded; - return; - } - } - push_state(json_parse_state::array); - state_ = json_parse_state::expect_value_or_end; - continue_ = handler.begin_array(semantic_tag::none, *this); - } - - void end_array(basic_json_content_handler& handler, std::error_code& ec) - { - if (nesting_depth_ < 1) - { - err_handler_.fatal_error(json_errc::unexpected_right_bracket, *this); - ec = json_errc::unexpected_right_bracket; - continue_ = false; - return; - } - --nesting_depth_; - state_ = pop_state(); - if (state_ == json_parse_state::array) - { - continue_ = handler.end_array(*this); - } - else if (state_ == json_parse_state::object) - { - err_handler_.fatal_error(json_errc::expected_comma_or_right_brace, *this); - ec = json_errc::expected_comma_or_right_brace; - continue_ = false; - return; - } - else - { - err_handler_.fatal_error(json_errc::unexpected_right_bracket, *this); - ec = json_errc::unexpected_right_bracket; - continue_ = false; - return; - } - if (parent() == json_parse_state::root) - { - state_ = json_parse_state::before_done; - } - else - { - state_ = json_parse_state::expect_comma_or_end; - } - } - - void reset() - { - state_stack_.clear(); - state_stack_.reserve(initial_stack_capacity_); - push_state(json_parse_state::root); - state_ = json_parse_state::start; - continue_ = true; - done_ = false; - line_ = 1; - column_ = 1; - nesting_depth_ = 0; - } - - void restart() - { - continue_ = true; - } - - void check_done() - { - std::error_code ec; - check_done(ec); - if (ec) - { - throw ser_error(ec,line_,column_); - } - } - - void check_done(std::error_code& ec) - { - for (; input_ptr_ != input_end_; ++input_ptr_) - { - CharT curr_char_ = *input_ptr_; - switch (curr_char_) - { - case '\n': - case '\r': - case '\t': - case ' ': - break; - default: - continue_ = err_handler_.error(json_errc::extra_character, *this); - if (!continue_) - { - ec = json_errc::extra_character; - return; - } - break; - } - } - } - - json_parse_state state() const - { - return state_; - } - - void update(const string_view_type sv) - { - update(sv.data(),sv.length()); - } - - void update(const CharT* data, size_t length) - { - begin_input_ = data; - input_end_ = data + length; - input_ptr_ = begin_input_; - } - - void parse_some(basic_json_content_handler& handler) - { - std::error_code ec; - parse_some(handler, ec); - if (ec) - { - throw ser_error(ec,line_,column_); - } - } - - void parse_some(basic_json_content_handler& handler, std::error_code& ec) - { - if (options_.is_str_to_nan() || options_.is_str_to_inf() || options_.is_str_to_neginf()) - { - jsoncons::detail::replacement_filter h(handler, - options_.is_str_to_nan(), - options_.is_str_to_inf(), - options_.is_str_to_neginf(), - options_.nan_to_str(), - options_.inf_to_str(), - options_.neginf_to_str()); - parse_some_(h, ec); - } - else - { - parse_some_(handler, ec); - } - } - - void finish_parse(basic_json_content_handler& handler) - { - std::error_code ec; - finish_parse(handler, ec); - if (ec) - { - throw ser_error(ec,line_,column_); - } - } - - void finish_parse(basic_json_content_handler& handler, std::error_code& ec) - { - while (!finished()) - { - parse_some(handler, ec); - } - } - - void parse_some_(basic_json_content_handler& handler, std::error_code& ec) - { - if (state_ == json_parse_state::before_done) - { - handler.flush(); - done_ = true; - state_ = json_parse_state::done; - continue_ = false; - return; - } - const CharT* local_input_end = input_end_; - - if (input_ptr_ == local_input_end && continue_) - { - switch (state_) - { - case json_parse_state::zero: - case json_parse_state::integer: - end_integer_value(handler, ec); - if (ec) return; - break; - case json_parse_state::fraction2: - end_fraction_value(handler, ec); - if (ec) return; - break; - case json_parse_state::exp3: - end_fraction_value(handler, ec); - if (ec) return; - break; - case json_parse_state::before_done: - handler.flush(); - done_ = true; - state_ = json_parse_state::done; - continue_ = false; - break; - case json_parse_state::done: - continue_ = false; - break; - case json_parse_state::cr: - state_ = pop_state(); - break; - default: - err_handler_.fatal_error(json_errc::unexpected_eof, *this); - ec = json_errc::unexpected_eof; - continue_ = false; - return; - } - } - - while ((input_ptr_ < local_input_end) && continue_) - { - switch (state_) - { - case json_parse_state::before_done: - handler.flush(); - done_ = true; - state_ = json_parse_state::done; - continue_ = false; - break; - case json_parse_state::cr: - ++line_; - column_ = 1; - switch (*input_ptr_) - { - case '\n': - ++input_ptr_; - state_ = pop_state(); - break; - default: - state_ = pop_state(); - break; - } - break; - case json_parse_state::start: - { - switch (*input_ptr_) - { - JSONCONS_ILLEGAL_CONTROL_CHARACTER: - continue_ = err_handler_.error(json_errc::illegal_control_character, *this); - if (!continue_) - { - ec = json_errc::illegal_control_character; - return; - } - break; - case '\r': - push_state(state_); - ++input_ptr_; - ++column_; - state_ = json_parse_state::cr; - break; - case '\n': - ++input_ptr_; - ++line_; - column_ = 1; - break; - case ' ':case '\t': - skip_space(); - break; - case '/': - ++input_ptr_; - ++column_; - push_state(state_); - state_ = json_parse_state::slash; - break; - case '{': - begin_object(handler, ec); - if (ec) return; - ++input_ptr_; - ++column_; - break; - case '[': - begin_array(handler, ec); - if (ec) return; - ++input_ptr_; - ++column_; - break; - case '\"': - state_ = json_parse_state::string; - ++input_ptr_; - ++column_; - string_buffer_.clear(); - parse_string(handler, ec); - if (ec) return; - break; - case '-': - string_buffer_.clear(); - string_buffer_.push_back('-'); - ++input_ptr_; - ++column_; - state_ = json_parse_state::minus; - parse_number(handler, ec); - if (ec) {return;} - break; - case '0': - string_buffer_.clear(); - string_buffer_.push_back(static_cast(*input_ptr_)); - state_ = json_parse_state::zero; - ++input_ptr_; - ++column_; - parse_number(handler, ec); - if (ec) {return;} - break; - case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8': case '9': - string_buffer_.clear(); - string_buffer_.push_back(static_cast(*input_ptr_)); - ++input_ptr_; - ++column_; - state_ = json_parse_state::integer; - parse_number(handler, ec); - if (ec) {return;} - break; - case 'n': - parse_null(handler, ec); - if (ec) {return;} - break; - case 't': - parse_true(handler, ec); - if (ec) {return;} - break; - case 'f': - parse_false(handler, ec); - if (ec) {return;} - break; - case '}': - err_handler_.fatal_error(json_errc::unexpected_right_brace, *this); - ec = json_errc::unexpected_right_brace; - continue_ = false; - return; - case ']': - err_handler_.fatal_error(json_errc::unexpected_right_bracket, *this); - ec = json_errc::unexpected_right_bracket; - continue_ = false; - return; - default: - err_handler_.fatal_error(json_errc::invalid_json_text, *this); - ec = json_errc::invalid_json_text; - continue_ = false; - return; - } - } - break; - - case json_parse_state::expect_comma_or_end: - { - switch (*input_ptr_) - { - JSONCONS_ILLEGAL_CONTROL_CHARACTER: - continue_ = err_handler_.error(json_errc::illegal_control_character, *this); - if (!continue_) - { - ec = json_errc::illegal_control_character; - return; - } - ++input_ptr_; - ++column_; - break; - case '\r': - ++input_ptr_; - ++column_; - push_state(state_); - state_ = json_parse_state::cr; - break; - case '\n': - ++input_ptr_; - ++line_; - column_ = 1; - break; - case ' ':case '\t': - skip_space(); - break; - case '/': - ++input_ptr_; - ++column_; - push_state(state_); - state_ = json_parse_state::slash; - break; - case '}': - end_object(handler, ec); - if (ec) return; - ++input_ptr_; - ++column_; - break; - case ']': - end_array(handler, ec); - if (ec) return; - ++input_ptr_; - ++column_; - break; - case ',': - begin_member_or_element(ec); - if (ec) return; - ++input_ptr_; - ++column_; - break; - default: - if (parent() == json_parse_state::array) - { - continue_ = err_handler_.error(json_errc::expected_comma_or_right_bracket, *this); - if (!continue_) - { - ec = json_errc::expected_comma_or_right_bracket; - return; - } - } - else if (parent() == json_parse_state::object) - { - continue_ = err_handler_.error(json_errc::expected_comma_or_right_brace, *this); - if (!continue_) - { - ec = json_errc::expected_comma_or_right_brace; - return; - } - } - ++input_ptr_; - ++column_; - break; - } - } - break; - case json_parse_state::expect_member_name_or_end: - { - switch (*input_ptr_) - { - JSONCONS_ILLEGAL_CONTROL_CHARACTER: - continue_ = err_handler_.error(json_errc::illegal_control_character, *this); - if (!continue_) - { - ec = json_errc::illegal_control_character; - return; - } - ++input_ptr_; - ++column_; - break; - case '\r': - ++input_ptr_; - ++column_; - push_state(state_); - state_ = json_parse_state::cr; - break; - case '\n': - ++input_ptr_; - ++line_; - column_ = 1; - break; - case ' ':case '\t': - skip_space(); - break; - case '/': - ++input_ptr_; - ++column_; - push_state(state_); - state_ = json_parse_state::slash; - break; - case '}': - end_object(handler, ec); - if (ec) return; - ++input_ptr_; - ++column_; - break; - case '\"': - ++input_ptr_; - ++column_; - push_state(json_parse_state::member_name); - state_ = json_parse_state::string; - string_buffer_.clear(); - parse_string(handler, ec); - if (ec) return; - break; - case '\'': - continue_ = err_handler_.error(json_errc::single_quote, *this); - if (!continue_) - { - ec = json_errc::single_quote; - return; - } - ++input_ptr_; - ++column_; - break; - default: - continue_ = err_handler_.error(json_errc::expected_name, *this); - if (!continue_) - { - ec = json_errc::expected_name; - return; - } - ++input_ptr_; - ++column_; - break; - } - } - break; - case json_parse_state::expect_member_name: - { - switch (*input_ptr_) - { - JSONCONS_ILLEGAL_CONTROL_CHARACTER: - continue_ = err_handler_.error(json_errc::illegal_control_character, *this); - if (!continue_) - { - ec = json_errc::illegal_control_character; - return; - } - ++input_ptr_; - ++column_; - break; - case '\r': - ++input_ptr_; - ++column_; - push_state(state_); - state_ = json_parse_state::cr; - break; - case '\n': - ++input_ptr_; - ++line_; - column_ = 1; - break; - case ' ':case '\t': - skip_space(); - break; - case '/': - ++input_ptr_; - ++column_; - push_state(state_); - state_ = json_parse_state::slash; - break; - case '\"': - ++input_ptr_; - ++column_; - push_state(json_parse_state::member_name); - state_ = json_parse_state::string; - string_buffer_.clear(); - parse_string(handler, ec); - if (ec) return; - break; - case '}': - continue_ = err_handler_.error(json_errc::extra_comma, *this); - if (!continue_) - { - ec = json_errc::extra_comma; - return; - } - end_object(handler, ec); // Recover - if (ec) return; - ++input_ptr_; - ++column_; - break; - case '\'': - continue_ = err_handler_.error(json_errc::single_quote, *this); - if (!continue_) - { - ec = json_errc::single_quote; - return; - } - ++input_ptr_; - ++column_; - break; - default: - continue_ = err_handler_.error(json_errc::expected_name, *this); - if (!continue_) - { - ec = json_errc::expected_name; - return; - } - ++input_ptr_; - ++column_; - break; - } - } - break; - case json_parse_state::expect_colon: - { - switch (*input_ptr_) - { - JSONCONS_ILLEGAL_CONTROL_CHARACTER: - continue_ = err_handler_.error(json_errc::illegal_control_character, *this); - if (!continue_) - { - ec = json_errc::illegal_control_character; - return; - } - ++input_ptr_; - ++column_; - break; - case '\r': - push_state(state_); - state_ = json_parse_state::cr; - ++input_ptr_; - ++column_; - break; - case '\n': - ++input_ptr_; - ++line_; - column_ = 1; - break; - case ' ':case '\t': - skip_space(); - break; - case '/': - push_state(state_); - state_ = json_parse_state::slash; - ++input_ptr_; - ++column_; - break; - case ':': - state_ = json_parse_state::expect_value; - ++input_ptr_; - ++column_; - break; - default: - continue_ = err_handler_.error(json_errc::expected_colon, *this); - if (!continue_) - { - ec = json_errc::expected_colon; - return; - } - ++input_ptr_; - ++column_; - break; - } - } - break; - - case json_parse_state::expect_value: - { - switch (*input_ptr_) - { - JSONCONS_ILLEGAL_CONTROL_CHARACTER: - continue_ = err_handler_.error(json_errc::illegal_control_character, *this); - if (!continue_) - { - ec = json_errc::illegal_control_character; - return; - } - ++input_ptr_; - ++column_; - break; - case '\r': - push_state(state_); - ++input_ptr_; - ++column_; - state_ = json_parse_state::cr; - break; - case '\n': - ++input_ptr_; - ++line_; - column_ = 1; - break; - case ' ':case '\t': - skip_space(); - break; - case '/': - push_state(state_); - ++input_ptr_; - ++column_; - state_ = json_parse_state::slash; - break; - case '{': - begin_object(handler, ec); - if (ec) return; - ++input_ptr_; - ++column_; - break; - case '[': - begin_array(handler, ec); - if (ec) return; - ++input_ptr_; - ++column_; - break; - case '\"': - ++input_ptr_; - ++column_; - state_ = json_parse_state::string; - string_buffer_.clear(); - parse_string(handler, ec); - if (ec) return; - break; - case '-': - string_buffer_.clear(); - string_buffer_.push_back('-'); - ++input_ptr_; - ++column_; - state_ = json_parse_state::minus; - parse_number(handler, ec); - if (ec) {return;} - break; - case '0': - string_buffer_.clear(); - string_buffer_.push_back(static_cast(*input_ptr_)); - ++input_ptr_; - ++column_; - state_ = json_parse_state::zero; - parse_number(handler, ec); - if (ec) {return;} - break; - case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8': case '9': - string_buffer_.clear(); - string_buffer_.push_back(static_cast(*input_ptr_)); - ++input_ptr_; - ++column_; - state_ = json_parse_state::integer; - parse_number(handler, ec); - if (ec) {return;} - break; - case 'n': - parse_null(handler, ec); - if (ec) {return;} - break; - case 't': - parse_true(handler, ec); - if (ec) {return;} - break; - case 'f': - parse_false(handler, ec); - if (ec) {return;} - break; - case ']': - if (parent() == json_parse_state::array) - { - continue_ = err_handler_.error(json_errc::extra_comma, *this); - if (!continue_) - { - ec = json_errc::extra_comma; - return; - } - end_array(handler, ec); // Recover - if (ec) return; - } - else - { - continue_ = err_handler_.error(json_errc::expected_value, *this); - if (!continue_) - { - ec = json_errc::expected_value; - return; - } - } - ++input_ptr_; - ++column_; - break; - case '\'': - continue_ = err_handler_.error(json_errc::single_quote, *this); - if (!continue_) - { - ec = json_errc::single_quote; - return; - } - ++input_ptr_; - ++column_; - break; - default: - continue_ = err_handler_.error(json_errc::expected_value, *this); - if (!continue_) - { - ec = json_errc::expected_value; - return; - } - ++input_ptr_; - ++column_; - break; - } - } - break; - case json_parse_state::expect_value_or_end: - { - switch (*input_ptr_) - { - JSONCONS_ILLEGAL_CONTROL_CHARACTER: - continue_ = err_handler_.error(json_errc::illegal_control_character, *this); - if (!continue_) - { - ec = json_errc::illegal_control_character; - return; - } - ++input_ptr_; - ++column_; - break; - case '\r': - ++input_ptr_; - ++column_; - push_state(state_); - state_ = json_parse_state::cr; - break; - case '\n': - ++input_ptr_; - ++line_; - column_ = 1; - break; - case ' ':case '\t': - skip_space(); - break; - case '/': - ++input_ptr_; - ++column_; - push_state(state_); - state_ = json_parse_state::slash; - break; - case '{': - begin_object(handler, ec); - if (ec) return; - ++input_ptr_; - ++column_; - break; - case '[': - begin_array(handler, ec); - if (ec) return; - ++input_ptr_; - ++column_; - break; - case ']': - end_array(handler, ec); - if (ec) return; - ++input_ptr_; - ++column_; - break; - case '\"': - ++input_ptr_; - ++column_; - state_ = json_parse_state::string; - string_buffer_.clear(); - parse_string(handler, ec); - if (ec) return; - break; - case '-': - string_buffer_.clear(); - string_buffer_.push_back('-'); - ++input_ptr_; - ++column_; - state_ = json_parse_state::minus; - parse_number(handler, ec); - if (ec) {return;} - break; - case '0': - string_buffer_.clear(); - string_buffer_.push_back(static_cast(*input_ptr_)); - ++input_ptr_; - ++column_; - state_ = json_parse_state::zero; - parse_number(handler, ec); - if (ec) {return;} - break; - case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8': case '9': - string_buffer_.clear(); - string_buffer_.push_back(static_cast(*input_ptr_)); - ++input_ptr_; - ++column_; - state_ = json_parse_state::integer; - parse_number(handler, ec); - if (ec) {return;} - break; - case 'n': - parse_null(handler, ec); - if (ec) {return;} - break; - case 't': - parse_true(handler, ec); - if (ec) {return;} - break; - case 'f': - parse_false(handler, ec); - if (ec) {return;} - break; - case '\'': - continue_ = err_handler_.error(json_errc::single_quote, *this); - if (!continue_) - { - ec = json_errc::single_quote; - return; - } - ++input_ptr_; - ++column_; - break; - default: - continue_ = err_handler_.error(json_errc::expected_value, *this); - if (!continue_) - { - ec = json_errc::expected_value; - return; - } - ++input_ptr_; - ++column_; - break; - } - } - break; - case json_parse_state::string: - case json_parse_state::escape: - case json_parse_state::escape_u1: - case json_parse_state::escape_u2: - case json_parse_state::escape_u3: - case json_parse_state::escape_u4: - case json_parse_state::escape_expect_surrogate_pair1: - case json_parse_state::escape_expect_surrogate_pair2: - case json_parse_state::escape_u6: - case json_parse_state::escape_u7: - case json_parse_state::escape_u8: - case json_parse_state::escape_u9: - parse_string(handler, ec); - if (ec) return; - break; - case json_parse_state::minus: - case json_parse_state::zero: - case json_parse_state::integer: - case json_parse_state::fraction1: - case json_parse_state::fraction2: - case json_parse_state::exp1: - case json_parse_state::exp2: - case json_parse_state::exp3: - parse_number(handler, ec); - if (ec) return; - break; - case json_parse_state::t: - switch (*input_ptr_) - { - case 'r': - ++input_ptr_; - ++column_; - state_ = json_parse_state::tr; - break; - default: - err_handler_.fatal_error(json_errc::invalid_value, *this); - ec = json_errc::invalid_value; - continue_ = false; - return; - } - break; - case json_parse_state::tr: - switch (*input_ptr_) - { - case 'u': - state_ = json_parse_state::tru; - break; - default: - err_handler_.fatal_error(json_errc::invalid_value, *this); - ec = json_errc::invalid_value; - continue_ = false; - return; - } - ++input_ptr_; - ++column_; - break; - case json_parse_state::tru: - switch (*input_ptr_) - { - case 'e': - continue_ = handler.bool_value(true, semantic_tag::none, *this); - if (parent() == json_parse_state::root) - { - state_ = json_parse_state::before_done; - } - else - { - state_ = json_parse_state::expect_comma_or_end; - } - break; - default: - err_handler_.fatal_error(json_errc::invalid_value, *this); - ec = json_errc::invalid_value; - continue_ = false; - return; - } - ++input_ptr_; - ++column_; - break; - case json_parse_state::f: - switch (*input_ptr_) - { - case 'a': - ++input_ptr_; - ++column_; - state_ = json_parse_state::fa; - break; - default: - err_handler_.fatal_error(json_errc::invalid_value, *this); - ec = json_errc::invalid_value; - continue_ = false; - return; - } - break; - case json_parse_state::fa: - switch (*input_ptr_) - { - case 'l': - state_ = json_parse_state::fal; - break; - default: - err_handler_.fatal_error(json_errc::invalid_value, *this); - ec = json_errc::invalid_value; - continue_ = false; - return; - } - ++input_ptr_; - ++column_; - break; - case json_parse_state::fal: - switch (*input_ptr_) - { - case 's': - state_ = json_parse_state::fals; - break; - default: - err_handler_.fatal_error(json_errc::invalid_value, *this); - ec = json_errc::invalid_value; - continue_ = false; - return; - } - ++input_ptr_; - ++column_; - break; - case json_parse_state::fals: - switch (*input_ptr_) - { - case 'e': - continue_ = handler.bool_value(false, semantic_tag::none, *this); - if (parent() == json_parse_state::root) - { - state_ = json_parse_state::before_done; - } - else - { - state_ = json_parse_state::expect_comma_or_end; - } - break; - default: - err_handler_.fatal_error(json_errc::invalid_value, *this); - ec = json_errc::invalid_value; - continue_ = false; - return; - } - ++input_ptr_; - ++column_; - break; - case json_parse_state::n: - switch (*input_ptr_) - { - case 'u': - ++input_ptr_; - ++column_; - state_ = json_parse_state::nu; - break; - default: - err_handler_.fatal_error(json_errc::invalid_value, *this); - ec = json_errc::invalid_value; - continue_ = false; - return; - } - break; - case json_parse_state::nu: - switch (*input_ptr_) - { - case 'l': - state_ = json_parse_state::nul; - break; - default: - err_handler_.fatal_error(json_errc::invalid_value, *this); - ec = json_errc::invalid_value; - continue_ = false; - return; - } - ++input_ptr_; - ++column_; - break; - case json_parse_state::nul: - switch (*input_ptr_) - { - case 'l': - continue_ = handler.null_value(semantic_tag::none, *this); - if (parent() == json_parse_state::root) - { - state_ = json_parse_state::before_done; - } - else - { - state_ = json_parse_state::expect_comma_or_end; - } - break; - default: - err_handler_.fatal_error(json_errc::invalid_value, *this); - ec = json_errc::invalid_value; - continue_ = false; - return; - } - ++input_ptr_; - ++column_; - break; - case json_parse_state::slash: - { - switch (*input_ptr_) - { - case '*': - state_ = json_parse_state::slash_star; - continue_ = err_handler_.error(json_errc::illegal_comment, *this); - if (!continue_) - { - ec = json_errc::illegal_comment; - return; - } - break; - case '/': - state_ = json_parse_state::slash_slash; - continue_ = err_handler_.error(json_errc::illegal_comment, *this); - if (!continue_) - { - ec = json_errc::illegal_comment; - return; - } - break; - default: - continue_ = err_handler_.error(json_errc::invalid_json_text, *this); - if (!continue_) - { - ec = json_errc::invalid_json_text; - return; - } - break; - } - ++input_ptr_; - ++column_; - break; - } - case json_parse_state::slash_star: - { - switch (*input_ptr_) - { - case '\r': - push_state(state_); - state_ = json_parse_state::cr; - break; - case '\n': - ++line_; - column_ = 1; - break; - case '*': - state_ = json_parse_state::slash_star_star; - break; - } - ++input_ptr_; - ++column_; - break; - } - case json_parse_state::slash_slash: - { - switch (*input_ptr_) - { - case '\r': - state_ = pop_state(); - break; - case '\n': - state_ = pop_state(); - break; - default: - ++input_ptr_; - ++column_; - } - break; - } - case json_parse_state::slash_star_star: - { - switch (*input_ptr_) - { - case '/': - state_ = pop_state(); - break; - default: - state_ = json_parse_state::slash_star; - break; - } - ++input_ptr_; - ++column_; - break; - } - default: - JSONCONS_ASSERT(false); - break; - } - } - } - - void parse_true(basic_json_content_handler& handler, std::error_code& ec) - { - if (JSONCONS_LIKELY(input_end_ - input_ptr_ >= 4)) - { - if (*(input_ptr_+1) == 'r' && *(input_ptr_+2) == 'u' && *(input_ptr_+3) == 'e') - { - continue_ = handler.bool_value(true, semantic_tag::none, *this); - input_ptr_ += 4; - column_ += 4; - if (parent() == json_parse_state::root) - { - state_ = json_parse_state::before_done; - } - else - { - state_ = json_parse_state::expect_comma_or_end; - } - } - else - { - err_handler_.fatal_error(json_errc::invalid_value, *this); - ec = json_errc::invalid_value; - continue_ = false; - return; - } - } - else - { - ++input_ptr_; - ++column_; - state_ = json_parse_state::t; - } - } - - void parse_null(basic_json_content_handler& handler, std::error_code& ec) - { - if (JSONCONS_LIKELY(input_end_ - input_ptr_ >= 4)) - { - if (*(input_ptr_+1) == 'u' && *(input_ptr_+2) == 'l' && *(input_ptr_+3) == 'l') - { - continue_ = handler.null_value(semantic_tag::none, *this); - input_ptr_ += 4; - column_ += 4; - if (parent() == json_parse_state::root) - { - state_ = json_parse_state::before_done; - } - else - { - state_ = json_parse_state::expect_comma_or_end; - } - } - else - { - err_handler_.fatal_error(json_errc::invalid_value, *this); - ec = json_errc::invalid_value; - continue_ = false; - return; - } - } - else - { - ++input_ptr_; - ++column_; - state_ = json_parse_state::n; - } - } - - void parse_false(basic_json_content_handler& handler, std::error_code& ec) - { - if (JSONCONS_LIKELY(input_end_ - input_ptr_ >= 5)) - { - if (*(input_ptr_+1) == 'a' && *(input_ptr_+2) == 'l' && *(input_ptr_+3) == 's' && *(input_ptr_+4) == 'e') - { - continue_ = handler.bool_value(false, semantic_tag::none, *this); - input_ptr_ += 5; - column_ += 5; - if (parent() == json_parse_state::root) - { - state_ = json_parse_state::before_done; - } - else - { - state_ = json_parse_state::expect_comma_or_end; - } - } - else - { - err_handler_.fatal_error(json_errc::invalid_value, *this); - ec = json_errc::invalid_value; - continue_ = false; - return; - } - } - else - { - ++input_ptr_; - ++column_; - state_ = json_parse_state::f; - } - } - - void parse_number(basic_json_content_handler& handler, std::error_code& ec) - { - const CharT* local_input_end = input_end_; - - switch (state_) - { - case json_parse_state::minus: - goto minus_sign; - case json_parse_state::zero: - goto zero; - case json_parse_state::integer: - goto integer; - case json_parse_state::fraction1: - goto fraction1; - case json_parse_state::fraction2: - goto fraction2; - case json_parse_state::exp1: - goto exp1; - case json_parse_state::exp2: - goto exp2; - case json_parse_state::exp3: - goto exp3; - default: - JSONCONS_UNREACHABLE(); - } -minus_sign: - if (JSONCONS_UNLIKELY(input_ptr_ >= local_input_end)) // Buffer exhausted - { - state_ = json_parse_state::minus; - return; - } - switch (*input_ptr_) - { - case '0': - string_buffer_.push_back(static_cast(*input_ptr_)); - ++input_ptr_; - ++column_; - goto zero; - case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8': case '9': - string_buffer_.push_back(static_cast(*input_ptr_)); - ++input_ptr_; - ++column_; - goto integer; - default: - err_handler_.fatal_error(json_errc::expected_value, *this); - ec = json_errc::expected_value; - continue_ = false; - return; - } -zero: - if (JSONCONS_UNLIKELY(input_ptr_ >= local_input_end)) // Buffer exhausted - { - state_ = json_parse_state::zero; - return; - } - switch (*input_ptr_) - { - case '\r': - end_integer_value(handler, ec); - if (ec) return; - ++input_ptr_; - ++column_; - push_state(state_); - state_ = json_parse_state::cr; - return; - case '\n': - end_integer_value(handler, ec); - if (ec) return; - ++input_ptr_; - ++line_; - column_ = 1; - return; - case ' ':case '\t': - end_integer_value(handler, ec); - if (ec) return; - skip_space(); - return; - case '/': - end_integer_value(handler, ec); - if (ec) return; - ++input_ptr_; - ++column_; - push_state(state_); - state_ = json_parse_state::slash; - return; - case '}': - end_integer_value(handler, ec); - if (ec) return; - state_ = json_parse_state::expect_comma_or_end; - return; - case ']': - end_integer_value(handler, ec); - if (ec) return; - state_ = json_parse_state::expect_comma_or_end; - return; - case '.': - string_buffer_.push_back(to_double_.get_decimal_point()); - ++input_ptr_; - ++column_; - goto fraction1; - case 'e':case 'E': - string_buffer_.push_back(static_cast(*input_ptr_)); - ++input_ptr_; - ++column_; - goto exp1; - case ',': - end_integer_value(handler, ec); - if (ec) return; - begin_member_or_element(ec); - if (ec) return; - ++input_ptr_; - ++column_; - return; - case '0': case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8': case '9': - err_handler_.fatal_error(json_errc::leading_zero, *this); - ec = json_errc::leading_zero; - continue_ = false; - state_ = json_parse_state::zero; - return; - default: - err_handler_.fatal_error(json_errc::invalid_number, *this); - ec = json_errc::invalid_number; - continue_ = false; - state_ = json_parse_state::zero; - return; - } -integer: - if (JSONCONS_UNLIKELY(input_ptr_ >= local_input_end)) // Buffer exhausted - { - state_ = json_parse_state::integer; - return; - } - switch (*input_ptr_) - { - case '\r': - end_integer_value(handler, ec); - if (ec) return; - push_state(state_); - ++input_ptr_; - ++column_; - state_ = json_parse_state::cr; - return; - case '\n': - end_integer_value(handler, ec); - if (ec) return; - ++input_ptr_; - ++line_; - column_ = 1; - return; - case ' ':case '\t': - end_integer_value(handler, ec); - if (ec) return; - skip_space(); - return; - case '/': - end_integer_value(handler, ec); - if (ec) return; - push_state(state_); - ++input_ptr_; - ++column_; - state_ = json_parse_state::slash; - return; - case '}': - end_integer_value(handler, ec); - if (ec) return; - state_ = json_parse_state::expect_comma_or_end; - return; - case ']': - end_integer_value(handler, ec); - if (ec) return; - state_ = json_parse_state::expect_comma_or_end; - return; - case '0': case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8': case '9': - string_buffer_.push_back(static_cast(*input_ptr_)); - ++input_ptr_; - ++column_; - goto integer; - case '.': - string_buffer_.push_back(to_double_.get_decimal_point()); - ++input_ptr_; - ++column_; - goto fraction1; - case 'e':case 'E': - string_buffer_.push_back(static_cast(*input_ptr_)); - ++input_ptr_; - ++column_; - goto exp1; - case ',': - end_integer_value(handler, ec); - if (ec) return; - begin_member_or_element(ec); - if (ec) return; - ++input_ptr_; - ++column_; - return; - default: - err_handler_.fatal_error(json_errc::invalid_number, *this); - ec = json_errc::invalid_number; - continue_ = false; - state_ = json_parse_state::integer; - return; - } -fraction1: - if (JSONCONS_UNLIKELY(input_ptr_ >= local_input_end)) // Buffer exhausted - { - state_ = json_parse_state::fraction1; - return; - } - switch (*input_ptr_) - { - case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8': case '9': - string_buffer_.push_back(static_cast(*input_ptr_)); - ++input_ptr_; - ++column_; - goto fraction2; - default: - err_handler_.fatal_error(json_errc::invalid_number, *this); - ec = json_errc::invalid_number; - continue_ = false; - state_ = json_parse_state::fraction1; - return; - } -fraction2: - if (JSONCONS_UNLIKELY(input_ptr_ >= local_input_end)) // Buffer exhausted - { - state_ = json_parse_state::fraction2; - return; - } - switch (*input_ptr_) - { - case '\r': - end_fraction_value(handler, ec); - if (ec) return; - push_state(state_); - ++input_ptr_; - ++column_; - state_ = json_parse_state::cr; - return; - case '\n': - end_fraction_value(handler, ec); - if (ec) return; - ++input_ptr_; - ++line_; - column_ = 1; - return; - case ' ':case '\t': - end_fraction_value(handler, ec); - if (ec) return; - skip_space(); - return; - case '/': - end_fraction_value(handler, ec); - if (ec) return; - push_state(state_); - ++input_ptr_; - ++column_; - state_ = json_parse_state::slash; - return; - case '}': - end_fraction_value(handler, ec); - if (ec) return; - state_ = json_parse_state::expect_comma_or_end; - return; - case ']': - end_fraction_value(handler, ec); - if (ec) return; - state_ = json_parse_state::expect_comma_or_end; - return; - case ',': - end_fraction_value(handler, ec); - if (ec) return; - begin_member_or_element(ec); - if (ec) return; - ++input_ptr_; - ++column_; - return; - case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8': case '9': - string_buffer_.push_back(static_cast(*input_ptr_)); - ++input_ptr_; - ++column_; - goto fraction2; - case 'e':case 'E': - string_buffer_.push_back(static_cast(*input_ptr_)); - ++input_ptr_; - ++column_; - goto exp1; - default: - err_handler_.fatal_error(json_errc::invalid_number, *this); - ec = json_errc::invalid_number; - continue_ = false; - state_ = json_parse_state::fraction2; - return; - } -exp1: - if (JSONCONS_UNLIKELY(input_ptr_ >= local_input_end)) // Buffer exhausted - { - state_ = json_parse_state::exp1; - return; - } - switch (*input_ptr_) - { - case '+': - ++input_ptr_; - ++column_; - goto exp2; - case '-': - string_buffer_.push_back(static_cast(*input_ptr_)); - ++input_ptr_; - ++column_; - goto exp2; - case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8': case '9': - string_buffer_.push_back(static_cast(*input_ptr_)); - ++input_ptr_; - ++column_; - goto exp3; - default: - err_handler_.fatal_error(json_errc::expected_value, *this); - ec = json_errc::expected_value; - continue_ = false; - state_ = json_parse_state::exp1; - return; - } -exp2: - if (JSONCONS_UNLIKELY(input_ptr_ >= local_input_end)) // Buffer exhausted - { - state_ = json_parse_state::exp2; - return; - } - switch (*input_ptr_) - { - case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8': case '9': - string_buffer_.push_back(static_cast(*input_ptr_)); - ++input_ptr_; - ++column_; - goto exp3; - default: - err_handler_.fatal_error(json_errc::expected_value, *this); - ec = json_errc::expected_value; - continue_ = false; - state_ = json_parse_state::exp2; - return; - } - -exp3: - if (JSONCONS_UNLIKELY(input_ptr_ >= local_input_end)) // Buffer exhausted - { - state_ = json_parse_state::exp3; - return; - } - switch (*input_ptr_) - { - case '\r': - end_fraction_value(handler, ec); - if (ec) return; - ++input_ptr_; - ++column_; - push_state(state_); - state_ = json_parse_state::cr; - return; - case '\n': - end_fraction_value(handler, ec); - if (ec) return; - ++input_ptr_; - ++line_; - column_ = 1; - return; - case ' ':case '\t': - end_fraction_value(handler, ec); - if (ec) return; - skip_space(); - return; - case '/': - end_fraction_value(handler, ec); - if (ec) return; - push_state(state_); - ++input_ptr_; - ++column_; - state_ = json_parse_state::slash; - return; - case '}': - end_fraction_value(handler, ec); - if (ec) return; - state_ = json_parse_state::expect_comma_or_end; - return; - case ']': - end_fraction_value(handler, ec); - if (ec) return; - state_ = json_parse_state::expect_comma_or_end; - return; - case ',': - end_fraction_value(handler, ec); - if (ec) return; - begin_member_or_element(ec); - if (ec) return; - ++input_ptr_; - ++column_; - return; - case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8': case '9': - string_buffer_.push_back(static_cast(*input_ptr_)); - ++input_ptr_; - ++column_; - goto exp3; - default: - err_handler_.fatal_error(json_errc::invalid_number, *this); - ec = json_errc::invalid_number; - continue_ = false; - state_ = json_parse_state::exp3; - return; - } - - JSONCONS_UNREACHABLE(); - } - - void parse_string(basic_json_content_handler& handler, std::error_code& ec) - { - const CharT* local_input_end = input_end_; - const CharT* sb = input_ptr_; - - switch (state_) - { - case json_parse_state::string: - goto string_u1; - case json_parse_state::escape: - goto escape; - case json_parse_state::escape_u1: - goto escape_u1; - case json_parse_state::escape_u2: - goto escape_u2; - case json_parse_state::escape_u3: - goto escape_u3; - case json_parse_state::escape_u4: - goto escape_u4; - case json_parse_state::escape_expect_surrogate_pair1: - goto escape_expect_surrogate_pair1; - case json_parse_state::escape_expect_surrogate_pair2: - goto escape_expect_surrogate_pair2; - case json_parse_state::escape_u6: - goto escape_u6; - case json_parse_state::escape_u7: - goto escape_u7; - case json_parse_state::escape_u8: - goto escape_u8; - case json_parse_state::escape_u9: - goto escape_u9; - default: - JSONCONS_UNREACHABLE(); - } - -string_u1: - while (input_ptr_ < local_input_end) - { - switch (*input_ptr_) - { - JSONCONS_ILLEGAL_CONTROL_CHARACTER: - { - column_ += (input_ptr_ - sb + 1); - continue_ = err_handler_.error(json_errc::illegal_control_character, *this); - if (!continue_) - { - ec = json_errc::illegal_control_character; - state_ = json_parse_state::string; - return; - } - // recovery - skip - string_buffer_.append(sb,input_ptr_-sb); - ++input_ptr_; - state_ = json_parse_state::string; - return; - } - case '\r': - { - column_ += (input_ptr_ - sb + 1); - continue_ = err_handler_.error(json_errc::illegal_character_in_string, *this); - if (!continue_) - { - ec = json_errc::illegal_character_in_string; - state_ = json_parse_state::string; - return; - } - // recovery - keep - string_buffer_.append(sb, input_ptr_ - sb + 1); - ++input_ptr_; - push_state(state_); - state_ = json_parse_state::cr; - return; - } - case '\n': - { - ++line_; - column_ = 1; - continue_ = err_handler_.error(json_errc::illegal_character_in_string, *this); - if (!continue_) - { - ec = json_errc::illegal_character_in_string; - state_ = json_parse_state::string; - return; - } - // recovery - keep - string_buffer_.append(sb, input_ptr_ - sb + 1); - ++input_ptr_; - return; - } - case '\t': - { - column_ += (input_ptr_ - sb + 1); - continue_ = err_handler_.error(json_errc::illegal_character_in_string, *this); - if (!continue_) - { - ec = json_errc::illegal_character_in_string; - state_ = json_parse_state::string; - return; - } - // recovery - keep - string_buffer_.append(sb, input_ptr_ - sb + 1); - ++input_ptr_; - state_ = json_parse_state::string; - return; - } - case '\\': - { - string_buffer_.append(sb,input_ptr_-sb); - column_ += (input_ptr_ - sb + 1); - ++input_ptr_; - goto escape; - } - case '\"': - { - if (string_buffer_.length() == 0) - { - end_string_value(sb,input_ptr_-sb, handler, ec); - if (ec) {return;} - } - else - { - string_buffer_.append(sb,input_ptr_-sb); - end_string_value(string_buffer_.data(),string_buffer_.length(), handler, ec); - if (ec) {return;} - } - column_ += (input_ptr_ - sb + 1); - ++input_ptr_; - return; - } - default: - break; - } - ++input_ptr_; - } - - // Buffer exhausted - { - string_buffer_.append(sb,input_ptr_-sb); - column_ += (input_ptr_ - sb + 1); - state_ = json_parse_state::string; - return; - } - -escape: - if (JSONCONS_UNLIKELY(input_ptr_ >= local_input_end)) // Buffer exhausted - { - state_ = json_parse_state::escape; - return; - } - switch (*input_ptr_) - { - case '\"': - string_buffer_.push_back('\"'); - sb = ++input_ptr_; - ++column_; - goto string_u1; - case '\\': - string_buffer_.push_back('\\'); - sb = ++input_ptr_; - ++column_; - goto string_u1; - case '/': - string_buffer_.push_back('/'); - sb = ++input_ptr_; - ++column_; - goto string_u1; - case 'b': - string_buffer_.push_back('\b'); - sb = ++input_ptr_; - ++column_; - goto string_u1; - case 'f': - string_buffer_.push_back('\f'); - sb = ++input_ptr_; - ++column_; - goto string_u1; - case 'n': - string_buffer_.push_back('\n'); - sb = ++input_ptr_; - ++column_; - goto string_u1; - case 'r': - string_buffer_.push_back('\r'); - sb = ++input_ptr_; - ++column_; - goto string_u1; - case 't': - string_buffer_.push_back('\t'); - sb = ++input_ptr_; - ++column_; - goto string_u1; - case 'u': - cp_ = 0; - ++input_ptr_; - ++column_; - goto escape_u1; - default: - err_handler_.fatal_error(json_errc::illegal_escaped_character, *this); - ec = json_errc::illegal_escaped_character; - continue_ = false; - state_ = json_parse_state::escape; - return; - } - -escape_u1: - if (JSONCONS_UNLIKELY(input_ptr_ >= local_input_end)) // Buffer exhausted - { - state_ = json_parse_state::escape_u1; - return; - } - { - append_codepoint(*input_ptr_,ec); - if (ec) - { - state_ = json_parse_state::escape_u1; - return; - } - ++input_ptr_; - ++column_; - goto escape_u2; - } - -escape_u2: - if (JSONCONS_UNLIKELY(input_ptr_ >= local_input_end)) // Buffer exhausted - { - state_ = json_parse_state::escape_u2; - return; - } - { - append_codepoint(*input_ptr_, ec); - if (ec) - { - state_ = json_parse_state::escape_u2; - return; - } - ++input_ptr_; - ++column_; - goto escape_u3; - } - -escape_u3: - if (JSONCONS_UNLIKELY(input_ptr_ >= local_input_end)) // Buffer exhausted - { - state_ = json_parse_state::escape_u3; - return; - } - { - append_codepoint(*input_ptr_, ec); - if (ec) - { - state_ = json_parse_state::escape_u3; - return; - } - ++input_ptr_; - ++column_; - goto escape_u4; - } - -escape_u4: - if (JSONCONS_UNLIKELY(input_ptr_ >= local_input_end)) // Buffer exhausted - { - state_ = json_parse_state::escape_u4; - return; - } - { - append_codepoint(*input_ptr_, ec); - if (ec) - { - state_ = json_parse_state::escape_u4; - return; - } - if (unicons::is_high_surrogate(cp_)) - { - ++input_ptr_; - ++column_; - goto escape_expect_surrogate_pair1; - } - else - { - unicons::convert(&cp_, &cp_ + 1, std::back_inserter(string_buffer_)); - sb = ++input_ptr_; - ++column_; - state_ = json_parse_state::string; - return; - } - } - -escape_expect_surrogate_pair1: - if (JSONCONS_UNLIKELY(input_ptr_ >= local_input_end)) // Buffer exhausted - { - state_ = json_parse_state::escape_expect_surrogate_pair1; - return; - } - { - switch (*input_ptr_) - { - case '\\': - cp2_ = 0; - ++input_ptr_; - ++column_; - goto escape_expect_surrogate_pair2; - default: - err_handler_.fatal_error(json_errc::expected_codepoint_surrogate_pair, *this); - ec = json_errc::expected_codepoint_surrogate_pair; - continue_ = false; - state_ = json_parse_state::escape_expect_surrogate_pair1; - return; - } - } - -escape_expect_surrogate_pair2: - if (JSONCONS_UNLIKELY(input_ptr_ >= local_input_end)) // Buffer exhausted - { - state_ = json_parse_state::escape_expect_surrogate_pair2; - return; - } - { - switch (*input_ptr_) - { - case 'u': - ++input_ptr_; - ++column_; - goto escape_u6; - default: - err_handler_.fatal_error(json_errc::expected_codepoint_surrogate_pair, *this); - ec = json_errc::expected_codepoint_surrogate_pair; - continue_ = false; - state_ = json_parse_state::escape_expect_surrogate_pair2; - return; - } - } - -escape_u6: - if (JSONCONS_UNLIKELY(input_ptr_ >= local_input_end)) // Buffer exhausted - { - state_ = json_parse_state::escape_u6; - return; - } - { - append_second_codepoint(*input_ptr_, ec); - if (ec) - { - state_ = json_parse_state::escape_u6; - return; - } - } - ++input_ptr_; - ++column_; - goto escape_u7; - -escape_u7: - if (JSONCONS_UNLIKELY(input_ptr_ >= local_input_end)) // Buffer exhausted - { - state_ = json_parse_state::escape_u7; - return; - } - { - append_second_codepoint(*input_ptr_, ec); - if (ec) - { - state_ = json_parse_state::escape_u7; - return; - } - ++input_ptr_; - ++column_; - goto escape_u8; - } - -escape_u8: - if (JSONCONS_UNLIKELY(input_ptr_ >= local_input_end)) // Buffer exhausted - { - state_ = json_parse_state::escape_u8; - return; - } - { - append_second_codepoint(*input_ptr_, ec); - if (ec) - { - state_ = json_parse_state::escape_u8; - return; - } - ++input_ptr_; - ++column_; - goto escape_u9; - } - -escape_u9: - if (JSONCONS_UNLIKELY(input_ptr_ >= local_input_end)) // Buffer exhausted - { - state_ = json_parse_state::escape_u9; - return; - } - { - append_second_codepoint(*input_ptr_, ec); - if (ec) - { - state_ = json_parse_state::escape_u9; - return; - } - uint32_t cp = 0x10000 + ((cp_ & 0x3FF) << 10) + (cp2_ & 0x3FF); - unicons::convert(&cp, &cp + 1, std::back_inserter(string_buffer_)); - sb = ++input_ptr_; - ++column_; - goto string_u1; - } - - JSONCONS_UNREACHABLE(); - } - - void translate_conv_errc(unicons::conv_errc result, std::error_code& ec) - { - switch (result) - { - case unicons::conv_errc(): - break; - case unicons::conv_errc::over_long_utf8_sequence: - continue_ = err_handler_.error(json_errc::over_long_utf8_sequence, *this); - if (!continue_) - { - ec = json_errc::over_long_utf8_sequence; - return; - } - break; - case unicons::conv_errc::unpaired_high_surrogate: - continue_ = err_handler_.error(json_errc::unpaired_high_surrogate, *this); - if (!continue_) - { - ec = json_errc::unpaired_high_surrogate; - return; - } - break; - case unicons::conv_errc::expected_continuation_byte: - continue_ = err_handler_.error(json_errc::expected_continuation_byte, *this); - if (!continue_) - { - ec = json_errc::expected_continuation_byte; - return; - } - break; - case unicons::conv_errc::illegal_surrogate_value: - continue_ = err_handler_.error(json_errc::illegal_surrogate_value, *this); - if (!continue_) - { - ec = json_errc::illegal_surrogate_value; - return; - } - break; - default: - continue_ = err_handler_.error(json_errc::illegal_codepoint, *this); - if (!continue_) - { - ec = json_errc::illegal_codepoint; - return; - } - break; - } - } - -#if !defined(JSONCONS_NO_DEPRECATED) - - void end_parse(basic_json_content_handler& handler) - { - std::error_code ec; - finish_parse(handler, ec); - if (ec) - { - throw ser_error(ec,line_,column_); - } - } - - void end_parse(basic_json_content_handler& handler, std::error_code& ec) - { - while (!finished()) - { - parse_some(handler, ec); - } - } - - void set_source(const CharT* data, size_t length) - { - begin_input_ = data; - input_end_ = data + length; - input_ptr_ = begin_input_; - } -#endif - - size_t line() const override - { - return line_; - } - - size_t column() const override - { - return column_; - } -private: - - void end_integer_value(basic_json_content_handler& handler, std::error_code& ec) - { - if (string_buffer_[0] == '-') - { - end_negative_value(handler, ec); - } - else - { - end_positive_value(handler, ec); - } - } - - void end_negative_value(basic_json_content_handler& handler, std::error_code& ec) - { - auto result = jsoncons::detail::to_integer(string_buffer_.data(), string_buffer_.length()); - if (result.ec == jsoncons::detail::to_integer_errc()) - { - continue_ = handler.int64_value(result.value, semantic_tag::none, *this); - } - else // Must be overflow - { - continue_ = handler.string_value(string_buffer_, semantic_tag::bigint, *this); - } - after_value(ec); - } - - void end_positive_value(basic_json_content_handler& handler, std::error_code& ec) - { - auto result = jsoncons::detail::to_integer(string_buffer_.data(), string_buffer_.length()); - if (result.ec == jsoncons::detail::to_integer_errc()) - { - continue_ = handler.uint64_value(result.value, semantic_tag::none, *this); - } - else // Must be overflow - { - continue_ = handler.string_value(string_buffer_, semantic_tag::bigint, *this); - } - after_value(ec); - } - - void end_fraction_value(basic_json_content_handler& handler, std::error_code& ec) - { - try - { - if (options_.lossless_number()) - { - continue_ = handler.string_value(string_buffer_, semantic_tag::bigdec, *this); - } - else - { - double d = to_double_(string_buffer_.c_str(), string_buffer_.length()); - continue_ = handler.double_value(d, semantic_tag::none, *this); - } - } - catch (...) - { - continue_ = err_handler_.error(json_errc::invalid_number, *this); - if (!continue_) - { - ec = json_errc::invalid_number; - return; - } - continue_ = handler.null_value(semantic_tag::none, *this); // recovery - } - - after_value(ec); - } - - void append_codepoint(int c, std::error_code& ec) - { - switch (c) - { - case '0': case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8': case '9': - case 'a':case 'b':case 'c':case 'd':case 'e':case 'f': - case 'A':case 'B':case 'C':case 'D':case 'E':case 'F': - cp_ = append_to_codepoint(cp_, c, ec); - if (ec) return; - break; - default: - continue_ = err_handler_.error(json_errc::expected_value, *this); - if (!continue_) - { - ec = json_errc::expected_value; - return; - } - break; - } - } - - void append_second_codepoint(int c, std::error_code& ec) - { - switch (c) - { - case '0': - case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8': case '9': - case 'a':case 'b':case 'c':case 'd':case 'e':case 'f': - case 'A':case 'B':case 'C':case 'D':case 'E':case 'F': - cp2_ = append_to_codepoint(cp2_, c, ec); - if (ec) return; - break; - default: - continue_ = err_handler_.error(json_errc::expected_value, *this); - if (!continue_) - { - ec = json_errc::expected_value; - return; - } - break; - } - } - - void end_string_value(const CharT* s, size_t length, basic_json_content_handler& handler, std::error_code& ec) - { - auto result = unicons::validate(s,s+length); - if (result.ec != unicons::conv_errc()) - { - translate_conv_errc(result.ec,ec); - column_ += (result.it - s); - return; - } - switch (parent()) - { - case json_parse_state::member_name: - continue_ = handler.name(string_view_type(s, length), *this); - state_ = pop_state(); - state_ = json_parse_state::expect_colon; - break; - case json_parse_state::object: - case json_parse_state::array: - continue_ = handler.string_value(string_view_type(s, length), semantic_tag::none, *this); - state_ = json_parse_state::expect_comma_or_end; - break; - case json_parse_state::root: - continue_ = handler.string_value(string_view_type(s, length), semantic_tag::none, *this); - state_ = json_parse_state::before_done; - break; - default: - continue_ = err_handler_.error(json_errc::invalid_json_text, *this); - if (!continue_) - { - ec = json_errc::invalid_json_text; - return; - } - break; - } - } - - void begin_member_or_element(std::error_code& ec) - { - switch (parent()) - { - case json_parse_state::object: - state_ = json_parse_state::expect_member_name; - break; - case json_parse_state::array: - state_ = json_parse_state::expect_value; - break; - case json_parse_state::root: - break; - default: - continue_ = err_handler_.error(json_errc::invalid_json_text, *this); - if (!continue_) - { - ec = json_errc::invalid_json_text; - return; - } - break; - } - } - - void after_value(std::error_code& ec) - { - switch (parent()) - { - case json_parse_state::array: - case json_parse_state::object: - state_ = json_parse_state::expect_comma_or_end; - break; - case json_parse_state::root: - state_ = json_parse_state::before_done; - break; - default: - continue_ = err_handler_.error(json_errc::invalid_json_text, *this); - if (!continue_) - { - ec = json_errc::invalid_json_text; - return; - } - break; - } - } - - void push_state(json_parse_state state) - { - state_stack_.push_back(state); - } - - json_parse_state pop_state() - { - JSONCONS_ASSERT(!state_stack_.empty()) - json_parse_state state = state_stack_.back(); - state_stack_.pop_back(); - return state; - } - - uint32_t append_to_codepoint(uint32_t cp, int c, std::error_code& ec) - { - cp *= 16; - if (c >= '0' && c <= '9') - { - cp += c - '0'; - } - else if (c >= 'a' && c <= 'f') - { - cp += c - 'a' + 10; - } - else if (c >= 'A' && c <= 'F') - { - cp += c - 'A' + 10; - } - else - { - continue_ = err_handler_.error(json_errc::invalid_hex_escape_sequence, *this); - if (!continue_) - { - ec = json_errc::invalid_hex_escape_sequence; - return cp; - } - } - return cp; - } -}; - -typedef basic_json_parser json_parser; -typedef basic_json_parser wjson_parser; - -} - -#endif - diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/json_pull_reader.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/json_pull_reader.hpp deleted file mode 100644 index 4a9b58a685..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/json_pull_reader.hpp +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2018 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_JSON_PULL_READER_HPP -#define JSONCONS_JSON_PULL_READER_HPP - -#include - -#endif - diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/json_reader.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/json_reader.hpp deleted file mode 100644 index d67d1ec12f..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/json_reader.hpp +++ /dev/null @@ -1,514 +0,0 @@ -// Copyright 2015 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_JSON_READER_HPP -#define JSONCONS_JSON_READER_HPP - -#include // std::allocator -#include -#include -#include -#include -#include -#include // std::move -#include -#include -#include -#include -#include - -namespace jsoncons { - -// utf8_other_json_input_adapter - -template -class json_utf8_other_content_handler_adapter : public json_content_handler -{ -public: - using json_content_handler::string_view_type; -private: - basic_null_json_content_handler default_content_handler_; - basic_json_content_handler& other_handler_; - //parse_error_handler& err_handler_; - - // noncopyable and nonmoveable - json_utf8_other_content_handler_adapter(const json_utf8_other_content_handler_adapter&) = delete; - json_utf8_other_content_handler_adapter& operator=(const json_utf8_other_content_handler_adapter&) = delete; - -public: - json_utf8_other_content_handler_adapter() - : other_handler_(default_content_handler_) - { - } - - json_utf8_other_content_handler_adapter(basic_json_content_handler& other_handler/*, - parse_error_handler& err_handler*/) - : other_handler_(other_handler)/*, - err_handler_(err_handler)*/ - { - } - -private: - - void do_flush() override - { - other_handler_.flush(); - } - - bool do_begin_object(semantic_tag tag, const ser_context& context) override - { - return other_handler_.begin_object(tag, context); - } - - bool do_end_object(const ser_context& context) override - { - return other_handler_.end_object(context); - } - - bool do_begin_array(semantic_tag tag, const ser_context& context) override - { - return other_handler_.begin_array(tag, context); - } - - bool do_end_array(const ser_context& context) override - { - return other_handler_.end_array(context); - } - - bool do_name(const string_view_type& name, const ser_context& context) override - { - std::basic_string target; - auto result = unicons::convert( - name.begin(), name.end(), std::back_inserter(target), - unicons::conv_flags::strict); - if (result.ec != unicons::conv_errc()) - { - throw ser_error(result.ec,context.line(),context.column()); - } - return other_handler_.name(target, context); - } - - bool do_string_value(const string_view_type& value, semantic_tag tag, const ser_context& context) override - { - std::basic_string target; - auto result = unicons::convert( - value.begin(), value.end(), std::back_inserter(target), - unicons::conv_flags::strict); - if (result.ec != unicons::conv_errc()) - { - throw ser_error(result.ec,context.line(),context.column()); - } - return other_handler_.string_value(target, tag, context); - } - - bool do_int64_value(int64_t value, - semantic_tag tag, - const ser_context& context) override - { - return other_handler_.int64_value(value, tag, context); - } - - bool do_uint64_value(uint64_t value, - semantic_tag tag, - const ser_context& context) override - { - return other_handler_.uint64_value(value, tag, context); - } - - bool do_double_value(double value, - semantic_tag tag, - const ser_context& context) override - { - return other_handler_.double_value(value, tag, context); - } - - bool do_bool_value(bool value, semantic_tag tag, const ser_context& context) override - { - return other_handler_.bool_value(value, tag, context); - } - - bool do_null_value(semantic_tag tag, const ser_context& context) override - { - return other_handler_.null_value(tag, context); - } -}; - -template,class Allocator=std::allocator> -class basic_json_reader -{ -public: - typedef CharT char_type; - typedef Src source_type; - typedef basic_string_view string_view_type; - typedef Allocator allocator_type; -private: - typedef typename std::allocator_traits:: template rebind_alloc char_allocator_type; - - static const size_t default_max_buffer_length = 16384; - - basic_null_json_content_handler default_content_handler_; - default_parse_error_handler default_err_handler_; - - basic_json_content_handler& handler_; - - basic_json_parser parser_; - - source_type source_; - std::vector buffer_; - size_t buffer_length_; - bool eof_; - bool begin_; - - // Noncopyable and nonmoveable - basic_json_reader(const basic_json_reader&) = delete; - basic_json_reader& operator=(const basic_json_reader&) = delete; - -public: - template - explicit basic_json_reader(Source&& source) - : basic_json_reader(std::forward(source), - default_content_handler_, - basic_json_options::default_options(), - default_err_handler_) - { - } - - template - basic_json_reader(Source&& source, - const basic_json_decode_options& options) - : basic_json_reader(std::forward(source), - default_content_handler_, - options, - default_err_handler_) - { - } - - template - basic_json_reader(Source&& source, - parse_error_handler& err_handler) - : basic_json_reader(std::forward(source), - default_content_handler_, - basic_json_options::default_options(), - err_handler) - { - } - - template - basic_json_reader(Source&& source, - const basic_json_decode_options& options, - parse_error_handler& err_handler) - : basic_json_reader(std::forward(source), - default_content_handler_, - options, - err_handler) - { - } - - template - basic_json_reader(Source&& source, - basic_json_content_handler& handler) - : basic_json_reader(std::forward(source), - handler, - basic_json_options::default_options(), - default_err_handler_) - { - } - - template - basic_json_reader(Source&& source, - basic_json_content_handler& handler, - const basic_json_decode_options& options) - : basic_json_reader(std::forward(source), - handler, - options, - default_err_handler_) - { - } - - template - basic_json_reader(Source&& source, - basic_json_content_handler& handler, - parse_error_handler& err_handler) - : basic_json_reader(std::forward(source), - handler, - basic_json_options::default_options(), - err_handler) - { - } - - template - basic_json_reader(Source&& source, - basic_json_content_handler& handler, - const basic_json_decode_options& options, - parse_error_handler& err_handler, - typename std::enable_if,Source>::value>::type* = 0) - : handler_(handler), - parser_(options,err_handler), - source_(std::forward(source)), - buffer_length_(default_max_buffer_length), - eof_(false), - begin_(true) - { - buffer_.reserve(buffer_length_); - } - - template - basic_json_reader(Source&& source, - basic_json_content_handler& handler, - const basic_json_decode_options& options, - parse_error_handler& err_handler, - typename std::enable_if,Source>::value>::type* = 0) - : handler_(handler), - parser_(options,err_handler), - buffer_length_(0), - eof_(false), - begin_(false) - { - basic_string_view sv(std::forward(source)); - auto result = unicons::skip_bom(sv.begin(), sv.end()); - if (result.ec != unicons::encoding_errc()) - { - throw ser_error(result.ec,parser_.line(),parser_.column()); - } - size_t offset = result.it - sv.begin(); - parser_.update(sv.data()+offset,sv.size()-offset); - } - - size_t buffer_length() const - { - return buffer_length_; - } - - void buffer_length(size_t length) - { - buffer_length_ = length; - buffer_.reserve(buffer_length_); - } -#if !defined(JSONCONS_NO_DEPRECATED) - size_t max_nesting_depth() const - { - return parser_.max_nesting_depth(); - } - - void max_nesting_depth(size_t depth) - { - parser_.max_nesting_depth(depth); - } -#endif - void read_next() - { - std::error_code ec; - read_next(ec); - if (ec) - { - throw ser_error(ec,parser_.line(),parser_.column()); - } - } - - void read_next(std::error_code& ec) - { - try - { - if (source_.is_error()) - { - ec = json_errc::source_error; - return; - } - parser_.reset(); - while (!parser_.finished()) - { - if (parser_.source_exhausted()) - { - if (!source_.eof()) - { - read_buffer(ec); - if (ec) return; - } - else - { - eof_ = true; - } - } - parser_.parse_some(handler_, ec); - if (ec) return; - } - - while (!eof_) - { - parser_.skip_whitespace(); - if (parser_.source_exhausted()) - { - if (!source_.eof()) - { - read_buffer(ec); - if (ec) return; - } - else - { - eof_ = true; - } - } - else - { - break; - } - } - } - catch (const ser_error& e) - { - ec = e.code(); - } - } - - void check_done() - { - std::error_code ec; - check_done(ec); - if (ec) - { - throw ser_error(ec,parser_.line(),parser_.column()); - } - } - - size_t line() const - { - return parser_.line(); - } - - size_t column() const - { - return parser_.column(); - } - - void check_done(std::error_code& ec) - { - try - { - if (source_.is_error()) - { - ec = json_errc::source_error; - return; - } - if (eof_) - { - parser_.check_done(ec); - if (ec) return; - } - else - { - while (!eof_) - { - if (parser_.source_exhausted()) - { - if (!source_.eof()) - { - read_buffer(ec); - if (ec) return; - } - else - { - eof_ = true; - } - } - if (!eof_) - { - parser_.check_done(ec); - if (ec) return; - } - } - } - } - catch (const ser_error& e) - { - ec = e.code(); - } - } - - bool eof() const - { - return eof_; - } - - void read() - { - read_next(); - check_done(); - } - - void read(std::error_code& ec) - { - read_next(ec); - if (!ec) - { - check_done(ec); - } - } - -#if !defined(JSONCONS_NO_DEPRECATED) - - size_t buffer_capacity() const - { - return buffer_length_; - } - - void buffer_capacity(size_t length) - { - buffer_length_ = length; - buffer_.reserve(buffer_length_); - } - size_t max_depth() const - { - return parser_.max_nesting_depth(); - } - - void max_depth(size_t depth) - { - parser_.max_nesting_depth(depth); - } -#endif - -private: - - void read_buffer(std::error_code& ec) - { - buffer_.clear(); - buffer_.resize(buffer_length_); - size_t count = source_.read(buffer_.data(), buffer_length_); - buffer_.resize(static_cast(count)); - if (buffer_.size() == 0) - { - eof_ = true; - } - else if (begin_) - { - auto result = unicons::skip_bom(buffer_.begin(), buffer_.end()); - if (result.ec != unicons::encoding_errc()) - { - ec = result.ec; - return; - } - size_t offset = result.it - buffer_.begin(); - parser_.update(buffer_.data()+offset,buffer_.size()-offset); - begin_ = false; - } - else - { - parser_.update(buffer_.data(),buffer_.size()); - } - } -}; - -typedef basic_json_reader json_reader; -typedef basic_json_reader wjson_reader; -#if !defined(JSONCONS_NO_DEPRECATED) -typedef basic_json_reader> json_string_reader; -typedef basic_json_reader> wjson_string_reader; -#endif - -} - -#endif - diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/json_serializer.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/json_serializer.hpp deleted file mode 100644 index 2db2635cda..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/json_serializer.hpp +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_JSON_SERIALIZER_HPP -#define JSONCONS_JSON_SERIALIZER_HPP - -#include - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/json_type_traits.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/json_type_traits.hpp deleted file mode 100644 index d21995eca0..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/json_type_traits.hpp +++ /dev/null @@ -1,1047 +0,0 @@ -// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_JSON_TYPE_TRAITS_HPP -#define JSONCONS_JSON_TYPE_TRAITS_HPP - -#include -#include -#include -#include -#include -#include -#include -#include // std::swap -#include // std::numeric_limits -#include // std::enable_if -#include // std::iterator_traits, std::input_iterator_tag -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace jsoncons { - - -template -struct is_basic_json_class : std::false_type -{}; - -#if defined(_MSC_VER) && _MSC_VER < 1916 -template -struct is_basic_json_class::value && - !std::is_void::value && - !std::is_void::value>::type> : std::true_type -{}; -#else -template -struct is_basic_json_class>(),void())> : std::true_type -{}; -#endif - -template -struct is_json_type_traits_declared : public std::false_type -{}; - -#if !defined(JSONCONS_NO_DEPRECATED) -template -using is_json_type_traits_impl = is_json_type_traits_declared; -#endif - -// json_type_traits - -template -struct unimplemented : std::false_type -{}; - -template -struct json_type_traits -{ - typedef typename Json::allocator_type allocator_type; - - static constexpr bool is_compatible = false; - - static constexpr bool is(const Json&) - { - return false; - } - - static T as(const Json&) - { - static_assert(unimplemented::value, "as not implemented"); - } - - static Json to_json(const T&, allocator_type = allocator_type()) - { - static_assert(unimplemented::value, "to_json not implemented"); - } -}; - -namespace detail { - -// is_incompatible -template -struct is_incompatible : std::false_type {}; - - -// is_incompatible -template -struct is_incompatible::is_compatible>::value>::type -> : std::true_type {}; - -// is_compatible_string_type -template -struct is_compatible_string_type : std::false_type {}; - -template -struct is_compatible_string_type::value && - jsoncons::detail::is_string_like::value && - !is_incompatible::value_type>::value ->::type> : std::true_type {}; - -// is_compatible_string_view_type -template -struct is_compatible_string_view_type : std::false_type {}; - -template -struct is_compatible_string_view_type::value && - jsoncons::detail::is_string_view_like::value && - !is_incompatible::value_type>::value ->::type> : std::true_type {}; - -// is_compatible_array_type -template -struct is_compatible_array_type : std::false_type {}; - -template -struct is_compatible_array_type::value && - jsoncons::detail::is_vector_like::value && - !is_incompatible::value_type>::value ->::type> : std::true_type {}; - -// is_compatible_object_type -template -struct is_compatible_object_type : std::false_type {}; - -template -struct is_compatible_object_type::value ->::type> : std::true_type {}; - -template -class json_array_input_iterator -{ -public: - typedef typename Json::const_array_iterator iterator_base; - typedef typename std::iterator_traits::value_type value_type; - typedef typename std::iterator_traits::difference_type difference_type; - typedef typename std::iterator_traits::pointer pointer; - typedef T reference; - typedef std::input_iterator_tag iterator_category; - - json_array_input_iterator() - { - } - - json_array_input_iterator(iterator_base it) - : it_(it) - { - } - - json_array_input_iterator& operator=(json_array_input_iterator rhs) - { - swap(*this,rhs); - return *this; - } - - json_array_input_iterator& operator++() - { - ++it_; - return *this; - } - - json_array_input_iterator operator++(int) // postfix increment - { - json_array_input_iterator temp(*this); - ++it_; - return temp; - } - - json_array_input_iterator& operator--() - { - --it_; - return *this; - } - - json_array_input_iterator operator--(int) - { - json_array_input_iterator temp(*this); - --it_; - return temp; - } - - reference operator*() const - { - return json_type_traits::as(*it_); - } - - friend bool operator==(const json_array_input_iterator& it1, const json_array_input_iterator& it2) - { - return it1.it_ == it2.it_; - } - friend bool operator!=(const json_array_input_iterator& it1, const json_array_input_iterator& it2) - { - return !(it1.it_ == it2.it_); - } - friend void swap(json_array_input_iterator& lhs, json_array_input_iterator& rhs) - { - using std::swap; - swap(lhs.it_,rhs.it_); - swap(lhs.empty_,rhs.empty_); - } - -private: - iterator_base it_; -}; - -template -class json_object_input_iterator -{ -public: - typedef typename Json::const_object_iterator iterator_base; - typedef typename std::iterator_traits::value_type value_type; - typedef typename std::iterator_traits::difference_type difference_type; - typedef typename std::iterator_traits::pointer pointer; - typedef T reference; - typedef std::input_iterator_tag iterator_category; - typedef typename T::first_type key_type; - typedef typename T::second_type mapped_type; - - json_object_input_iterator() - { - } - - json_object_input_iterator(iterator_base it) - : it_(it) - { - } - - json_object_input_iterator& operator=(json_object_input_iterator rhs) - { - swap(*this,rhs); - return *this; - } - - json_object_input_iterator& operator++() - { - ++it_; - return *this; - } - - json_object_input_iterator operator++(int) // postfix increment - { - json_object_input_iterator temp(*this); - ++it_; - return temp; - } - - json_object_input_iterator& operator--() - { - --it_; - return *this; - } - - json_object_input_iterator operator--(int) - { - json_object_input_iterator temp(*this); - --it_; - return temp; - } - - reference operator*() const - { - return T(key_type(it_->key()),json_type_traits::as(it_->value())); - } - - friend bool operator==(const json_object_input_iterator& it1, const json_object_input_iterator& it2) - { - return it1.it_ == it2.it_; - } - friend bool operator!=(const json_object_input_iterator& it1, const json_object_input_iterator& it2) - { - return !(it1.it_ == it2.it_); - } - friend void swap(json_object_input_iterator& lhs, json_object_input_iterator& rhs) - { - using std::swap; - swap(lhs.it_,rhs.it_); - swap(lhs.empty_,rhs.empty_); - } - -private: - iterator_base it_; -}; - -} - -template -struct json_type_traits::const_pointer_type> -{ - typedef typename Json::char_type char_type; - typedef typename Json::allocator_type allocator_type; - - static bool is(const Json& j) noexcept - { - return j.is_string(); - } - static const char_type* as(const Json& j) - { - return j.as_cstring(); - } - template - static Json to_json(const char_type* s, Args&&... args) - { - return Json(s, semantic_tag::none, std::forward(args)...); - } -}; - -template -struct json_type_traits::pointer_type> -{ - typedef typename Json::char_type char_type; - typedef typename Json::allocator_type allocator_type; - - static bool is(const Json& j) noexcept - { - return j.is_string(); - } - template - static Json to_json(const char_type* s, Args&&... args) - { - return Json(s, semantic_tag::none, std::forward(args)...); - } -}; - -// integral - -template -struct json_type_traits::value ->::type> -{ - typedef typename Json::allocator_type allocator_type; - - static bool is(const Json& j) noexcept - { - if (j.is_int64()) - { - return (j.template as_integer() >= (std::numeric_limits::lowest)()) && (j.template as_integer() <= (std::numeric_limits::max)()); - } - else if (j.is_uint64()) - { - return j.template as_integer() <= static_cast((std::numeric_limits::max)()); - } - else - { - return false; - } - } - static T as(const Json& j) - { - return j.template as_integer(); - } - static Json to_json(T val, allocator_type = allocator_type()) - { - return Json(val, semantic_tag::none); - } -}; - -template -struct json_type_traits::value>::type> -{ - typedef typename Json::allocator_type allocator_type; - - static bool is(const Json& j) noexcept - { - if (j.is_int64()) - { - return j.template as_integer() >= 0 && static_cast(j.template as_integer()) <= (std::numeric_limits::max)(); - } - else if (j.is_uint64()) - { - return j.template as_integer() <= (std::numeric_limits::max)(); - } - else - { - return false; - } - } - - static T as(const Json& j) - { - return j.template as_integer(); - } - - static Json to_json(T val, allocator_type = allocator_type()) - { - return Json(val, semantic_tag::none); - } -}; - -template -struct json_type_traits::value ->::type> -{ - typedef typename Json::allocator_type allocator_type; - - static bool is(const Json& j) noexcept - { - return j.is_double(); - } - static T as(const Json& j) - { - return static_cast(j.as_double()); - } - static Json to_json(T val, allocator_type = allocator_type()) - { - return Json(val, semantic_tag::none); - } -}; - -template -struct json_type_traits -{ - typedef typename Json::object json_object; - typedef typename Json::allocator_type allocator_type; - - static bool is(const Json& j) noexcept - { - return j.is_object(); - } - static Json to_json(const json_object& o) - { - return Json(o,semantic_tag::none); - } -}; - -template -struct json_type_traits -{ - typedef typename Json::array json_array; - typedef typename Json::allocator_type allocator_type; - - static bool is(const Json& j) noexcept - { - return j.is_array(); - } - static Json to_json(const json_array& a) - { - return Json(a, semantic_tag::none); - } -}; - -template -struct json_type_traits -{ - typedef typename Json::allocator_type allocator_type; - - static bool is(const Json&) noexcept - { - return true; - } - static Json as(Json j) - { - return j; - } - static Json to_json(const Json& val, allocator_type = allocator_type()) - { - return val; - } -}; - -template -struct json_type_traits -{ - typedef typename Json::allocator_type allocator_type; - - static bool is(const Json& j) noexcept - { - return j.is_null(); - } - static typename jsoncons::null_type as(const Json& j) - { - JSONCONS_ASSERT(j.is_null()); - return jsoncons::null_type(); - } - static Json to_json(jsoncons::null_type, allocator_type = allocator_type()) - { - return Json::null(); - } -}; - -template -struct json_type_traits -{ - typedef typename Json::allocator_type allocator_type; - - static bool is(const Json& j) noexcept - { - return j.is_bool(); - } - static bool as(const Json& j) - { - return j.as_bool(); - } - static Json to_json(bool val, allocator_type = allocator_type()) - { - return Json(val, semantic_tag::none); - } -}; - -template -struct json_type_traits::const_reference>::value, - std::vector::const_reference, - void>::type>::value>::type> -{ - typedef typename Json::allocator_type allocator_type; - - static bool is(const Json& j) noexcept - { - return j.is_bool(); - } - static bool as(const Json& j) - { - return j.as_bool(); - } - static Json to_json(bool val, allocator_type = allocator_type()) - { - return Json(val, semantic_tag::none); - } -}; - -template -struct json_type_traits::reference> -{ - typedef typename Json::allocator_type allocator_type; - - static bool is(const Json& j) noexcept - { - return j.is_bool(); - } - static bool as(const Json& j) - { - return j.as_bool(); - } - static Json to_json(bool val, allocator_type = allocator_type()) - { - return Json(val, semantic_tag::none); - } -}; - -template -struct json_type_traits::value && jsoncons::detail::is_compatible_array_type::value>::type> -{ - typedef typename std::iterator_traits::value_type element_type; - typedef typename Json::allocator_type allocator_type; - - static bool is(const Json& j) noexcept - { - bool result = j.is_array(); - if (result) - { - for (auto e : j.array_range()) - { - if (!e.template is()) - { - result = false; - break; - } - } - } - return result; - } - - template - static typename std::enable_if::value && !std::is_same::value),T>::type - as(const Json& j) - { - if (j.is_array()) - { - T v(jsoncons::detail::json_array_input_iterator(j.array_range().begin()), - jsoncons::detail::json_array_input_iterator(j.array_range().end())); - return v; - } - else - { - JSONCONS_THROW(json_runtime_error("Attempt to cast json non-array to array")); - } - } - - template - static typename std::enable_if::value && !std::is_same::value,T>::type - as(const Json& j) - { - if (j.is_array()) - { - T v(jsoncons::detail::json_array_input_iterator(j.array_range().begin()), - jsoncons::detail::json_array_input_iterator(j.array_range().end())); - return v; - } - else if (j.is_byte_string_view()) - { - T v(j.as_byte_string_view().begin(),j.as_byte_string_view().end()); - return v; - } - else if (j.is_byte_string()) - { - auto s = j.as_byte_string(); - T v(s.begin(),s.end()); - return v; - } - else - { - JSONCONS_THROW(json_runtime_error("Attempt to cast json non-array to array")); - } - } - - static Json to_json(const T& val) - { - Json j = typename Json::array(); - auto first = std::begin(val); - auto last = std::end(val); - size_t size = std::distance(first,last); - j.reserve(size); - for (auto it = first; it != last; ++it) - { - j.push_back(*it); - } - return j; - } - - static Json to_json(const T& val, const allocator_type& allocator) - { - Json j = typename Json::array(allocator); - auto first = std::begin(val); - auto last = std::end(val); - size_t size = std::distance(first, last); - j.reserve(size); - for (auto it = first; it != last; ++it) - { - j.push_back(*it); - } - return j; - } -}; - -template -struct json_type_traits::value && jsoncons::detail::is_compatible_string_type::value>::type> -{ - typedef typename Json::allocator_type allocator_type; - - static bool is(const Json& j) noexcept - { - return j.is_string(); - } - - static T as(const Json& j) - { - return T(j.as_string()); - } - - static Json to_json(const T& val) - { - return Json(val, semantic_tag::none); - } - - static Json to_json(const T& val, const allocator_type& allocator) - { - return Json(val, semantic_tag::none, allocator); - } -}; - -template -struct json_type_traits::value && jsoncons::detail::is_compatible_string_view_type::value>::type> -{ - typedef typename Json::allocator_type allocator_type; - - static bool is(const Json& j) noexcept - { - return j.is_string_view(); - } - - static T as(const Json& j) - { - return T(j.as_string_view().data(),j.as_string_view().size()); - } - - static Json to_json(const T& val) - { - return Json(val, semantic_tag::none); - } - - static Json to_json(const T& val, const allocator_type& allocator) - { - return Json(val, semantic_tag::none, allocator); - } -}; - -template -struct json_type_traits::value && jsoncons::detail::is_compatible_object_type::value>::type -> -{ - typedef typename T::mapped_type mapped_type; - typedef typename T::value_type value_type; - typedef typename Json::allocator_type allocator_type; - - static bool is(const Json& j) noexcept - { - bool result = j.is_object(); - for (auto member : j.object_range()) - { - if (!member.value().template is()) - { - result = false; - } - } - return result; - } - - static T as(const Json& j) - { - T v(jsoncons::detail::json_object_input_iterator(j.object_range().begin()), - jsoncons::detail::json_object_input_iterator(j.object_range().end())); - return v; - } - - static Json to_json(const T& val) - { - Json j = typename Json::object(val.begin(), val.end()); - return j; - } - - static Json to_json(const T& val, const allocator_type& allocator) - { - Json j = typename Json::object(val.begin(), val.end(), allocator); - return j; - } -}; - -template -struct json_type_traits> -{ - typedef typename Json::allocator_type allocator_type; - - typedef E element_type; - - static bool is(const Json& j) noexcept - { - bool result = j.is_array() && j.size() == N; - if (result) - { - for (auto e : j.array_range()) - { - if (!e.template is()) - { - result = false; - break; - } - } - } - return result; - } - - static std::array as(const Json& j) - { - std::array buff; - JSONCONS_ASSERT(j.size() == N); - for (size_t i = 0; i < N; i++) - { - buff[i] = j[i].template as(); - } - return buff; - } - - static Json to_json(const std::array& val) - { - Json j = typename Json::array(); - j.reserve(N); - for (auto it = val.begin(); it != val.end(); ++it) - { - j.push_back(*it); - } - return j; - } - - static Json to_json(const std::array& val, - const allocator_type& allocator) - { - Json j = typename Json::array(allocator); - j.reserve(N); - for (auto it = val.begin(); it != val.end(); ++it) - { - j.push_back(*it); - } - return j; - } -}; - -namespace detail -{ - -template -struct json_tuple_helper -{ - using element_type = typename std::tuple_element::type; - using next = json_tuple_helper; - - static bool is(const Json& j) noexcept - { - if(j[Pos - 1].template is()) - { - return next::is(j); - } - else - { - return false; - } - } - - static void as(Tuple& tuple, const Json& j) - { - std::get(tuple) = j[Pos - 1].template as(); - next::as(tuple, j); - } - - static void to_json(const Tuple& tuple, std::array::value>& jsons) - { - jsons[Pos - 1] = json_type_traits::to_json(std::get(tuple)); - next::to_json(tuple, jsons); - } -}; - -template -struct json_tuple_helper<0, Json, Tuple> -{ - static bool is(const Json&) noexcept - { - return true; - } - - static void as(Tuple&, const Json&) - { - } - - static void to_json(const Tuple&, std::array::value>&) - { - } -}; - -} - -template -struct json_type_traits> -{ -private: - using helper = jsoncons::detail::json_tuple_helper>; - -public: - static bool is(const Json& j) noexcept - { - return helper::is(j); - } - - static std::tuple as(const Json& j) - { - std::tuple buff; - helper::as(buff, j); - return buff; - } - - static Json to_json(const std::tuple& val) - { - std::array buf; - helper::to_json(val, buf); - return Json(typename Json::array(buf.begin(), buf.end())); - } -}; - -template -struct json_type_traits> -{ -public: - static bool is(const Json& j) noexcept - { - return j.is_array() && j.size() == 2; - } - - static std::pair as(const Json& j) - { - return std::make_pair(j[0].template as(),j[1].template as()); - } - - static Json to_json(const std::pair& val) - { - return typename Json::array{val.first,val.second}; - } -}; - -template -struct json_type_traits> -{ -public: - typedef typename Json::allocator_type allocator_type; - - static bool is(const Json& j) noexcept - { - return j.is_byte_string(); - } - - static basic_byte_string as(const Json& j) - { - return j.template as_byte_string(); - } - - static Json to_json(const basic_byte_string& val, - const allocator_type& allocator = allocator_type()) - { - return Json(val, semantic_tag::none, allocator); - } -}; - -template -struct json_type_traits -{ -public: - static bool is(const Json& j) noexcept - { - return j.is_byte_string_view(); - } - - static byte_string_view as(const Json& j) - { - return j.as_byte_string_view(); - } - - static Json to_json(const byte_string_view& val) - { - return Json(val); - } -}; - -// basic_bignum - -template -struct json_type_traits> -{ -public: - static bool is(const Json& j) noexcept - { - return j.is_bignum(); - } - - static basic_bignum as(const Json& j) - { - return j.as_bignum(); - } - - static Json to_json(const basic_bignum& val) - { - std::basic_string s; - val.dump(s); - return Json(s,semantic_tag::bigint); - } -}; - -// std::valarray - -template -struct json_type_traits> -{ - typedef typename Json::allocator_type allocator_type; - - static bool is(const Json& j) noexcept - { - bool result = j.is_array(); - if (result) - { - for (auto e : j.array_range()) - { - if (!e.template is()) - { - result = false; - break; - } - } - } - return result; - } - - static std::valarray as(const Json& j) - { - if (j.is_array()) - { - std::valarray v(j.size()); - for (size_t i = 0; i < j.size(); ++i) - { - v[i] = j[i].template as(); - } - return v; - } - else - { - JSONCONS_THROW(json_runtime_error("Attempt to cast json non-array to array")); - } - } - - static Json to_json(const std::valarray& val) - { - Json j = typename Json::array(); - auto first = std::begin(val); - auto last = std::end(val); - size_t size = std::distance(first,last); - j.reserve(size); - for (auto it = first; it != last; ++it) - { - j.push_back(*it); - } - return j; - } - - static Json to_json(const std::valarray& val, const allocator_type& allocator) - { - Json j = typename Json::array(allocator); - auto first = std::begin(val); - auto last = std::end(val); - size_t size = std::distance(first,last); - j.reserve(size); - for (auto it = first; it != last; ++it) - { - j.push_back(*it); - } - return j; - } -}; - -} // jsoncons - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/json_type_traits_macros.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/json_type_traits_macros.hpp deleted file mode 100644 index 8d29fed0c3..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/json_type_traits_macros.hpp +++ /dev/null @@ -1,181 +0,0 @@ -// Copyright 2019 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_JSON_TYPE_TRAITS_MACROS_HPP -#define JSONCONS_JSON_TYPE_TRAITS_MACROS_HPP - -#include -#include -#include -#include -#include -#include -#include -#include // std::swap -#include // std::numeric_limits -#include // std::enable_if -#include // std::iterator_traits, std::input_iterator_tag -#include -#include -#include -#include -#include -#include -#include -#include - -// This follows https://github.com/Loki-Astari/ThorsSerializer/blob/master/src/Serialize/Traits.h - -#define JSONCONS_EXPAND(X) X - -#define JSONCONS_NARGS(...) JSONCONS_NARG_(__VA_ARGS__, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) -#define JSONCONS_NARG_(...) JSONCONS_EXPAND( JSONCONS_ARG_N(__VA_ARGS__) ) -#define JSONCONS_ARG_N(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, N, ...) N - -#define JSONCONS_QUOTE(A) JSONCONS_EXPAND(#A) - -#define JSONCONS_GENERATE(Call, TC, JVal, TVal, P2) Call(TC, JVal, TVal, P2) - -#define JSONCONS_REP_N(Call, TC, JVal, TVal, ...) JSONCONS_REP_OF_N(Call, TC, JVal, TVal, JSONCONS_NARGS(__VA_ARGS__), __VA_ARGS__) -#define JSONCONS_REP_OF_N(Call, TC, JVal, TVal, Count, ...) JSONCONS_REP_OF_N_(Call, TC, JVal, TVal, Count, __VA_ARGS__) -#define JSONCONS_REP_OF_N_(Call, TC, JVal, TVal, Count, ...) JSONCONS_EXPAND(JSONCONS_REP_OF_ ## Count(Call, TC, JVal, TVal, __VA_ARGS__)) - -#define JSONCONS_REP_OF_50(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_49(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_49(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_48(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_48(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_47(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_47(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_46(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_46(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_45(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_45(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_44(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_44(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_43(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_43(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_42(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_42(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_41(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_41(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_40(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_40(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_39(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_39(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_38(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_38(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_37(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_37(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_36(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_36(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_35(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_35(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_34(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_34(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_33(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_33(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_32(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_32(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_31(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_31(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_30(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_30(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_29(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_29(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_28(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_28(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_27(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_27(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_26(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_26(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_25(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_25(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_24(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_24(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_23(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_23(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_22(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_22(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_21(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_21(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_20(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_20(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_19(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_19(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_18(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_18(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_17(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_17(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_16(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_16(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_15(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_15(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_14(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_14(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_13(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_13(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_12(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_12(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_11(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_11(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_10(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_10(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_9(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_9(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_8(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_8(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_7(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_7(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_6(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_6(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_5(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_5(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_4(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_4(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_3(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_3(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal ,P2) JSONCONS_EXPAND(JSONCONS_REP_OF_2(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_2(Call, TC, JVal, TVal, P2, ...) JSONCONS_GENERATE(Call, TC, JVal, TVal, P2) JSONCONS_EXPAND(JSONCONS_REP_OF_1(Call, TC, JVal, TVal, __VA_ARGS__)) -#define JSONCONS_REP_OF_1(Call, TC, JVal, TVal, P2) JSONCONS_EXPAND(Call ## _LAST(TC, JVal, TVal, P2)) - -#define JSONCONS_IS(TC, JVal, TVal, Member) if (!(JVal).contains(JSONCONS_QUOTE(Member))) return false; -#define JSONCONS_IS_LAST(TC, JVal, TVal, Member) if (!(JVal).contains(JSONCONS_QUOTE(Member))) return false; - -#define JSONCONS_TO_JSON(TC, JVal, TVal, Member) (JVal).try_emplace(JSONCONS_QUOTE(Member), TVal.Member); -#define JSONCONS_TO_JSON_LAST(TC, JVal, TVal, Member) (JVal).try_emplace(JSONCONS_QUOTE(Member), TVal.Member); - -#define JSONCONS_AS(TC, JVal, TVal, Member) if ((JVal).contains(JSONCONS_QUOTE(Member))) {val.Member = (JVal).at(JSONCONS_QUOTE(Member)).template as();} -#define JSONCONS_AS_LAST(TC, JVal, TVal, Member) if ((JVal).contains(JSONCONS_QUOTE(Member))) {val.Member = (JVal).at(JSONCONS_QUOTE(Member)).template as();} - -#define JSONCONS_MEMBER_TRAITS_DECL(ValueType, ...) \ -namespace jsoncons \ -{ \ - template \ - struct json_type_traits \ - { \ - typedef ValueType value_type; \ - typedef typename Json::allocator_type allocator_type; \ - static bool is(const Json& j) noexcept \ - { \ - if (!j.is_object()) return false; \ - JSONCONS_REP_N(JSONCONS_IS, 0, j, void(), __VA_ARGS__)\ - return true; \ - } \ - static ValueType as(const Json& j) \ - { \ - ValueType val{}; \ - JSONCONS_REP_N(JSONCONS_AS, 0, j, val, __VA_ARGS__) \ - return val; \ - } \ - static Json to_json(const ValueType& val, allocator_type allocator=allocator_type()) \ - { \ - Json j(allocator); \ - JSONCONS_REP_N(JSONCONS_TO_JSON, 0, j, val, __VA_ARGS__) \ - return j; \ - } \ - }; \ -} \ - /**/ - -#define JSONCONS_IS2(TC, JVal, TVal, Member) if (!(JVal).contains(JSONCONS_QUOTE(Member))) return false; -#define JSONCONS_IS2_LAST(TC, JVal, TVal, Member) if (!(JVal).contains(JSONCONS_QUOTE(Member))) return false; - -#define JSONCONS_TO_JSON2(TC, JVal, TVal, Member) (JVal).try_emplace(JSONCONS_QUOTE(Member), TVal.Member() ); -#define JSONCONS_TO_JSON2_LAST(TC, JVal, TVal, Member) (JVal).try_emplace(JSONCONS_QUOTE(Member), TVal.Member() ); - -#define JSONCONS_AS2(TC, JVal, TVal, Member) ((JVal).at(JSONCONS_QUOTE(Member))).template asMember())>::type>(), -#define JSONCONS_AS2_LAST(TC, JVal, TVal, Member) ((JVal).at(JSONCONS_QUOTE(Member))).template asMember())>::type>() - -#define JSONCONS_GETTER_CTOR_TRAITS_DECL(ValueType, ...) \ -namespace jsoncons \ -{ \ - template \ - struct json_type_traits \ - { \ - typedef ValueType value_type; \ - typedef typename Json::allocator_type allocator_type; \ - static bool is(const Json& j) noexcept \ - { \ - if (!j.is_object()) return false; \ - JSONCONS_REP_N(JSONCONS_IS2, 0, j, void(), __VA_ARGS__)\ - return true; \ - } \ - static value_type as(const Json& j) \ - { \ - return value_type ( JSONCONS_REP_N(JSONCONS_AS2, 0, j, void(), __VA_ARGS__) ); \ - } \ - static Json to_json(const value_type& val, allocator_type allocator=allocator_type()) \ - { \ - Json j(allocator); \ - JSONCONS_REP_N(JSONCONS_TO_JSON2, 0, j, val, __VA_ARGS__) \ - return j; \ - } \ - }; \ -} \ - /**/ - -#define JSONCONS_TYPE_TRAITS_FRIEND \ - template \ - friend struct jsoncons::json_type_traits - -#if !defined(JSONCONS_NO_DEPRECATED) -#define JSONCONS_TYPE_TRAITS_DECL JSONCONS_MEMBER_TRAITS_DECL -#endif - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/parse_error_handler.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/parse_error_handler.hpp deleted file mode 100644 index 0f8b86e948..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/parse_error_handler.hpp +++ /dev/null @@ -1,74 +0,0 @@ -/// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_PARSE_ERROR_HANDLER_HPP -#define JSONCONS_PARSE_ERROR_HANDLER_HPP - -#include -#include -#include - -namespace jsoncons { - -class parse_error_handler -{ -public: - virtual ~parse_error_handler() - { - } - - bool error(std::error_code ec, - const ser_context& context) noexcept - { - return do_error(ec,context); - } - - void fatal_error(std::error_code ec, - const ser_context& context) noexcept - { - do_fatal_error(ec,context); - } - -private: - virtual bool do_error(std::error_code, - const ser_context& context) noexcept = 0; - - virtual void do_fatal_error(std::error_code, - const ser_context&) noexcept - { - } -}; - -class default_parse_error_handler : public parse_error_handler -{ -private: - bool do_error(std::error_code code, - const ser_context&) noexcept override - { - static const std::error_code illegal_comment = make_error_code(json_errc::illegal_comment); - - if (code == illegal_comment) - { - return true; // Recover, allow comments - } - else - { - return false; - } - } -}; - -class strict_parse_error_handler : public parse_error_handler -{ -private: - bool do_error(std::error_code, const ser_context&) noexcept override - { - return false; - } -}; - -} -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/pretty_print.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/pretty_print.hpp deleted file mode 100644 index 4ddf20eec2..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/pretty_print.hpp +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_PRETTY_PRINT_HPP -#define JSONCONS_PRETTY_PRINT_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace jsoncons { - -template -class json_printable -{ -public: - typedef typename Json::char_type char_type; - - json_printable(const Json& j, indenting line_indent) - : j_(&j), indenting_(line_indent) - { - } - - json_printable(const Json& j, - const basic_json_options& options, - indenting line_indent) - : j_(&j), options_(options), indenting_(line_indent) - { - } - - void dump(std::basic_ostream& os) const - { - j_->dump(os, options_, indenting_); - } - - friend std::basic_ostream& operator<<(std::basic_ostream& os, const json_printable& pr) - { - pr.dump(os); - return os; - } - - const Json *j_; - basic_json_options options_; - indenting indenting_; -private: - json_printable(); -}; - -template -json_printable print(const Json& j) -{ - return json_printable(j, indenting::no_indent); -} - -template -json_printable print(const Json& j, - const basic_json_options& options) -{ - return json_printable(j, options, indenting::no_indent); -} - -template -json_printable pretty_print(const Json& j) -{ - return json_printable(j, indenting::indent); -} - -template -json_printable pretty_print(const Json& j, - const basic_json_options& options) -{ - return json_printable(j, options, indenting::indent); -} - -} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/result.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/result.hpp deleted file mode 100644 index d53341f2fe..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/result.hpp +++ /dev/null @@ -1,284 +0,0 @@ -// Copyright 2018 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_RESULT_HPP -#define JSONCONS_RESULT_HPP - -#include -#include -#include -#include -#include -#include -#include // std::addressof -#include // std::memcpy -#include -#include - -namespace jsoncons { - -// stream_result - -template -class stream_result -{ -public: - typedef CharT value_type; - typedef std::basic_ostream output_type; - -private: - static const size_t default_buffer_length = 16384; - - std::basic_ostream* os_; - std::vector buffer_; - CharT * begin_buffer_; - const CharT* end_buffer_; - CharT* p_; - - // Noncopyable - stream_result(const stream_result&) = delete; - stream_result& operator=(const stream_result&) = delete; - -public: - stream_result(stream_result&&) = default; - - stream_result(std::basic_ostream& os) - : os_(std::addressof(os)), buffer_(default_buffer_length), begin_buffer_(buffer_.data()), end_buffer_(begin_buffer_+buffer_.size()), p_(begin_buffer_) - { - } - stream_result(std::basic_ostream& os, size_t buflen) - : os_(std::addressof(os)), buffer_(buflen), begin_buffer_(buffer_.data()), end_buffer_(begin_buffer_+buffer_.size()), p_(begin_buffer_) - { - } - ~stream_result() - { - os_->write(begin_buffer_, buffer_length()); - os_->flush(); - } - - stream_result& operator=(stream_result&&) = default; - - void flush() - { - os_->write(begin_buffer_, buffer_length()); - os_->flush(); - p_ = buffer_.data(); - } - - void append(const CharT* s, size_t length) - { - size_t diff = end_buffer_ - p_; - if (diff >= length) - { - std::memcpy(p_, s, length*sizeof(CharT)); - p_ += length; - } - else - { - os_->write(begin_buffer_, buffer_length()); - os_->write(s,length); - p_ = begin_buffer_; - } - } - - void push_back(CharT ch) - { - if (p_ < end_buffer_) - { - *p_++ = ch; - } - else - { - os_->write(begin_buffer_, buffer_length()); - p_ = begin_buffer_; - push_back(ch); - } - } -private: - - size_t buffer_length() const - { - return p_ - begin_buffer_; - } -}; - -// binary_stream_result - -class binary_stream_result -{ -public: - typedef uint8_t value_type; - typedef std::basic_ostream output_type; -private: - static const size_t default_buffer_length = 16384; - - std::basic_ostream* os_; - std::vector buffer_; - uint8_t * begin_buffer_; - const uint8_t* end_buffer_; - uint8_t* p_; - - // Noncopyable - binary_stream_result(const binary_stream_result&) = delete; - binary_stream_result& operator=(const binary_stream_result&) = delete; - -public: - binary_stream_result(binary_stream_result&&) = default; - - binary_stream_result(std::basic_ostream& os) - : os_(std::addressof(os)), - buffer_(default_buffer_length), - begin_buffer_(buffer_.data()), - end_buffer_(begin_buffer_+buffer_.size()), - p_(begin_buffer_) - { - } - binary_stream_result(std::basic_ostream& os, size_t buflen) - : os_(std::addressof(os)), - buffer_(buflen), - begin_buffer_(buffer_.data()), - end_buffer_(begin_buffer_+buffer_.size()), - p_(begin_buffer_) - { - } - ~binary_stream_result() - { - os_->write((char*)begin_buffer_, buffer_length()); - os_->flush(); - } - - binary_stream_result& operator=(binary_stream_result&&) = default; - - void flush() - { - os_->write((char*)begin_buffer_, buffer_length()); - p_ = buffer_.data(); - } - - void append(const uint8_t* s, size_t length) - { - size_t diff = end_buffer_ - p_; - if (diff >= length) - { - std::memcpy(p_, s, length*sizeof(uint8_t)); - p_ += length; - } - else - { - os_->write((char*)begin_buffer_, buffer_length()); - os_->write((const char*)s,length); - p_ = begin_buffer_; - } - } - - void push_back(uint8_t ch) - { - if (p_ < end_buffer_) - { - *p_++ = ch; - } - else - { - os_->write((char*)begin_buffer_, buffer_length()); - p_ = begin_buffer_; - push_back(ch); - } - } -private: - - size_t buffer_length() const - { - return p_ - begin_buffer_; - } -}; - -// string_result - -template -class string_result -{ -public: - typedef typename StringT::value_type value_type; - typedef StringT output_type; -private: - output_type* s_; - - // Noncopyable - string_result(const string_result&) = delete; - string_result& operator=(const string_result&) = delete; -public: - string_result(string_result&& val) - : s_(nullptr) - { - std::swap(s_,val.s_); - } - - string_result(output_type& s) - : s_(std::addressof(s)) - { - } - - string_result& operator=(string_result&& val) - { - std::swap(s_, val.s_); - } - - void flush() - { - } - - void append(const value_type* s, size_t length) - { - s_->insert(s_->end(), s, s+length); - } - - void push_back(value_type ch) - { - s_->push_back(ch); - } -}; - -// bytes_result - -class bytes_result -{ -public: - typedef uint8_t value_type; - typedef std::vector output_type; -private: - output_type& s_; - - // Noncopyable - bytes_result(const bytes_result&) = delete; - bytes_result& operator=(const bytes_result&) = delete; -public: - bytes_result(bytes_result&&) = default; - - bytes_result(output_type& s) - : s_(s) - { - } - - bytes_result& operator=(bytes_result&&) = default; - - void flush() - { - } - - void append(const uint8_t* s, size_t length) - { - s_.insert(s_.end(), s, s+length); - } - - void push_back(uint8_t ch) - { - s_.push_back(ch); - } -}; - -} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/ser_context.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/ser_context.hpp deleted file mode 100644 index 12397d0134..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/ser_context.hpp +++ /dev/null @@ -1,50 +0,0 @@ -/// Copyright 2013-2018 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_SER_CONTEXT_HPP -#define JSONCONS_SER_CONTEXT_HPP - -namespace jsoncons { - -class ser_context -{ -public: - virtual ~ser_context() = default; - - virtual size_t line() const = 0; - - virtual size_t column() const = 0; - -#if !defined(JSONCONS_NO_DEPRECATED) - size_t line_number() const - { - return line(); - } - - size_t column_number() const - { - return column(); - } -#endif -}; - -class null_ser_context : public ser_context -{ -private: - size_t line() const override { return 0; } - - size_t column() const override { return 0; } -}; - -#if !defined(JSONCONS_NO_DEPRECATED) -typedef ser_context parsing_context; -typedef ser_context serializing_context; -typedef null_ser_context null_parsing_context; -typedef null_ser_context null_serializing_context; -#endif - -} -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/source.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/source.hpp deleted file mode 100644 index f1feec5706..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/source.hpp +++ /dev/null @@ -1,746 +0,0 @@ -// Copyright 2018 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_SOURCE_HPP -#define JSONCONS_SOURCE_HPP - -#include -#include -#include -#include -#include // std::addressof -#include // std::memcpy -#include -#include // std::enable_if -#include -#include // jsoncons::byte_traits - -namespace jsoncons { - -template -class basic_null_istream : public std::basic_istream -{ - class null_buffer : public std::basic_streambuf - { - public: - using typename std::basic_streambuf::int_type; - using typename std::basic_streambuf::traits_type; - - null_buffer() = default; - null_buffer(const null_buffer&) = default; - null_buffer& operator=(const null_buffer&) = default; - - int_type overflow( int_type ch = traits_type::eof() ) override - { - return ch; - } - } nb_; -public: - basic_null_istream() - : std::basic_istream(&nb_) - { - } - basic_null_istream(basic_null_istream&&) = default; - - basic_null_istream& operator=(basic_null_istream&&) = default; -}; - -// text sources - -template -class stream_source -{ -public: - typedef CharT value_type; - typedef std::char_traits traits_type; -private: - basic_null_istream null_is_; - std::basic_istream* is_; - std::basic_streambuf* sbuf_; - size_t position_; - - // Noncopyable - stream_source(const stream_source&) = delete; - stream_source& operator=(const stream_source&) = delete; -public: - stream_source() - : is_(&null_is_), sbuf_(null_is_.rdbuf()), position_(0) - { - } - - stream_source(std::basic_istream& is) - : is_(std::addressof(is)), sbuf_(is.rdbuf()), position_(0) - { - } - - stream_source(stream_source&& other) - { - std::swap(is_,other.is_); - std::swap(sbuf_,other.sbuf_); - std::swap(position_,other.position_); - } - - ~stream_source() - { - } - - stream_source& operator=(stream_source&& other) - { - std::swap(is_,other.is_); - std::swap(sbuf_,other.sbuf_); - std::swap(position_,other.position_); - return *this; - } - - bool eof() const - { - return is_->eof(); - } - - bool is_error() const - { - return is_->bad(); - } - - size_t position() const - { - return position_; - } - - size_t get(value_type& c) - { - try - { - int val = sbuf_->sbumpc(); - if (!(val == traits_type::eof())) - { - c = (value_type)val; - ++position_; - return 1; - } - else - { - is_->clear(is_->rdstate() | std::ios::eofbit); - return 0; - } - } - catch (const std::exception&) - { - is_->clear(is_->rdstate() | std::ios::badbit | std::ios::eofbit); - return 0; - } - } - - int get() - { - try - { - int c = sbuf_->sbumpc(); - if (c == traits_type::eof()) - { - is_->clear(is_->rdstate() | std::ios::eofbit); - } - else - { - ++position_; - } - return c; - } - catch (const std::exception&) - { - is_->clear(is_->rdstate() | std::ios::badbit | std::ios::eofbit); - return traits_type::eof(); - } - } - - void ignore(size_t count) - { - try - { - for (size_t i = 0; i < count; ++i) - { - int c = sbuf_->sbumpc(); - if (c == traits_type::eof()) - { - is_->clear(is_->rdstate() | std::ios::eofbit); - return; - } - else - { - ++position_; - } - } - } - catch (const std::exception&) - { - is_->clear(is_->rdstate() | std::ios::badbit | std::ios::eofbit); - } - } - - int peek() - { - try - { - int c = sbuf_->sgetc(); - if (c == traits_type::eof()) - { - is_->clear(is_->rdstate() | std::ios::eofbit); - } - return c; - } - catch (const std::exception&) - { - is_->clear(is_->rdstate() | std::ios::badbit); - return traits_type::eof(); - } - } - - size_t read(value_type* p, size_t length) - { - try - { - std::streamsize count = sbuf_->sgetn(p, length); // never negative - if (static_cast(count) < length) - { - is_->clear(is_->rdstate() | std::ios::eofbit); - } - position_ += length; - return static_cast(count); - } - catch (const std::exception&) - { - is_->clear(is_->rdstate() | std::ios::badbit | std::ios::eofbit); - return 0; - } - } - - template - typename std::enable_if::value,size_t>::type - read(OutputIt p, size_t length) - { - size_t count = 0; - try - { - for (count = 0; count < length; ++count) - { - int c = sbuf_->sbumpc(); - if (c == traits_type::eof()) - { - is_->clear(is_->rdstate() | std::ios::eofbit); - return count; - } - else - { - ++position_; - } - *p++ = (value_type)c; - } - return count; - } - catch (const std::exception&) - { - is_->clear(is_->rdstate() | std::ios::badbit | std::ios::eofbit); - return count; - } - } -}; - -// string_source - -template -struct is_string_sourceable : std::false_type {}; - -template -struct is_string_sourceable::value>::type> : std::true_type {}; - -template -class string_source -{ -public: - typedef CharT value_type; - typedef std::char_traits traits_type; - typedef jsoncons::basic_string_view string_view_type; -private: - const value_type* data_; - const value_type* input_ptr_; - const value_type* input_end_; - bool eof_; - - // Noncopyable - string_source(const string_source&) = delete; - string_source& operator=(const string_source&) = delete; -public: - string_source() - : data_(nullptr), input_ptr_(nullptr), input_end_(nullptr), eof_(true) - { - } - - template - string_source(const Source& s, - typename std::enable_if::type>::value>::type* = 0) - : data_(s.data()), input_ptr_(s.data()), input_end_(s.data()+s.size()), eof_(s.size() == 0) - { - } - - string_source(const value_type* data, size_t size) - : data_(data), input_ptr_(data), input_end_(data+size), eof_(size == 0) - { - } - - string_source(string_source&& val) - : data_(nullptr), input_ptr_(nullptr), input_end_(nullptr), eof_(true) - { - std::swap(data_,val.data_); - std::swap(input_ptr_,val.input_ptr_); - std::swap(input_end_,val.input_end_); - std::swap(eof_,val.eof_); - } - - string_source& operator=(string_source&& val) - { - std::swap(data_,val.data_); - std::swap(input_ptr_,val.input_ptr_); - std::swap(input_end_,val.input_end_); - std::swap(eof_,val.eof_); - return *this; - } - - bool eof() const - { - return eof_; - } - - bool is_error() const - { - return false; - } - - size_t position() const - { - return (input_ptr_ - data_)/sizeof(value_type) + 1; - } - - size_t get(value_type& c) - { - if (input_ptr_ < input_end_) - { - c = *input_ptr_++; - return 1; - } - else - { - eof_ = true; - input_ptr_ = input_end_; - return 0; - } - } - - int get() - { - if (input_ptr_ < input_end_) - { - return *input_ptr_++; - } - else - { - eof_ = true; - input_ptr_ = input_end_; - return traits_type::eof(); - } - } - - void ignore(size_t count) - { - size_t len; - if ((size_t)(input_end_ - input_ptr_) < count) - { - len = input_end_ - input_ptr_; - eof_ = true; - } - else - { - len = count; - } - input_ptr_ += len; - } - - int peek() - { - return input_ptr_ < input_end_ ? *input_ptr_ : traits_type::eof(); - } - - size_t read(value_type* p, size_t length) - { - size_t len; - if ((size_t)(input_end_ - input_ptr_) < length) - { - len = input_end_ - input_ptr_; - eof_ = true; - } - else - { - len = length; - } - std::memcpy(p, input_ptr_, len*sizeof(value_type)); - input_ptr_ += len; - return len; - } - - template - typename std::enable_if::value,size_t>::type - read(OutputIt d_first, size_t count) - { - size_t len; - if ((size_t)(input_end_ - input_ptr_) < count) - { - len = input_end_ - input_ptr_; - eof_ = true; - } - else - { - len = count; - } - for (size_t i = 0; i < len; ++i) - { - *d_first++ = *input_ptr_++; - } - return len; - } -}; - -// binary sources - -class binary_stream_source -{ -public: - typedef uint8_t value_type; - typedef byte_traits traits_type; -private: - basic_null_istream null_is_; - std::istream* is_; - std::streambuf* sbuf_; - size_t position_; - - // Noncopyable - binary_stream_source(const binary_stream_source&) = delete; - binary_stream_source& operator=(const binary_stream_source&) = delete; -public: - binary_stream_source() - : is_(&null_is_), sbuf_(null_is_.rdbuf()), position_(0) - { - } - - binary_stream_source(std::istream& is) - : is_(std::addressof(is)), sbuf_(is.rdbuf()), position_(0) - { - } - - binary_stream_source(binary_stream_source&& other) - { - std::swap(is_,other.is_); - std::swap(sbuf_,other.sbuf_); - std::swap(position_,other.position_); - } - - ~binary_stream_source() - { - } - - binary_stream_source& operator=(binary_stream_source&& other) - { - std::swap(is_,other.is_); - std::swap(sbuf_,other.sbuf_); - std::swap(position_,other.position_); - return *this; - } - - bool eof() const - { - return is_->eof(); - } - - bool is_error() const - { - return is_->bad(); - } - - size_t position() const - { - return position_; - } - - size_t get(value_type& c) - { - try - { - int val = sbuf_->sbumpc(); - if (!(val == traits_type::eof())) - { - c = (value_type)val; - ++position_; - return 1; - } - else - { - is_->clear(is_->rdstate() | std::ios::eofbit); - return 0; - } - } - catch (const std::exception&) - { - is_->clear(is_->rdstate() | std::ios::badbit | std::ios::eofbit); - return 0; - } - } - - int get() - { - try - { - int c = sbuf_->sbumpc(); - if (c == traits_type::eof()) - { - is_->clear(is_->rdstate() | std::ios::eofbit); - } - else - { - ++position_; - } - return c; - } - catch (const std::exception&) - { - is_->clear(is_->rdstate() | std::ios::badbit | std::ios::eofbit); - return traits_type::eof(); - } - } - - void ignore(size_t count) - { - try - { - for (size_t i = 0; i < count; ++i) - { - int c = sbuf_->sbumpc(); - if (c == traits_type::eof()) - { - is_->clear(is_->rdstate() | std::ios::eofbit); - return; - } - else - { - ++position_; - } - } - } - catch (const std::exception&) - { - is_->clear(is_->rdstate() | std::ios::badbit | std::ios::eofbit); - } - } - - int peek() - { - try - { - int c = sbuf_->sgetc(); - if (c == traits_type::eof()) - { - is_->clear(is_->rdstate() | std::ios::eofbit); - } - return c; - } - catch (const std::exception&) - { - is_->clear(is_->rdstate() | std::ios::badbit); - return traits_type::eof(); - } - } - - template - size_t read(OutputIt p, size_t length) - { - size_t count = 0; - try - { - for (count = 0; count < length; ++count) - { - int c = sbuf_->sbumpc(); - if (c == traits_type::eof()) - { - is_->clear(is_->rdstate() | std::ios::eofbit); - return count; - } - else - { - ++position_; - } - *p++ = (value_type)c; - } - return count; - } - catch (const std::exception&) - { - is_->clear(is_->rdstate() | std::ios::badbit | std::ios::eofbit); - return count; - } - } -}; - -template -struct is_bytes_sourceable : std::false_type {}; - -template -struct is_bytes_sourceable::value>::type> : std::true_type {}; - -class bytes_source -{ -public: - typedef uint8_t value_type; - typedef byte_traits traits_type; -private: - const value_type* data_; - const value_type* input_ptr_; - const value_type* input_end_; - bool eof_; - - // Noncopyable - bytes_source(const bytes_source&) = delete; - bytes_source& operator=(const bytes_source&) = delete; -public: - bytes_source() - : data_(nullptr), input_ptr_(nullptr), input_end_(nullptr), eof_(true) - { - } - - template - bytes_source(const Source& s, - typename std::enable_if::type>::value>::type* = 0) - : data_(s.data()), - input_ptr_(s.data()), - input_end_(s.data()+s.size()), - eof_(s.size() == 0) - { - } - - bytes_source(const value_type* data, size_t size) - : data_(data), - input_ptr_(data), - input_end_(data+size), - eof_(size == 0) - { - } - - bytes_source(bytes_source&&) = default; - - bytes_source& operator=(bytes_source&&) = default; - - bool eof() const - { - return eof_; - } - - bool is_error() const - { - return false; - } - - size_t position() const - { - return input_ptr_ - data_ + 1; - } - - size_t get(value_type& c) - { - if (input_ptr_ < input_end_) - { - c = *input_ptr_++; - return 1; - } - else - { - eof_ = true; - input_ptr_ = input_end_; - return 0; - } - } - - int get() - { - if (input_ptr_ < input_end_) - { - return *input_ptr_++; - } - else - { - eof_ = true; - input_ptr_ = input_end_; - return traits_type::eof(); - } - } - - void ignore(size_t count) - { - size_t len; - if ((size_t)(input_end_ - input_ptr_) < count) - { - len = input_end_ - input_ptr_; - eof_ = true; - } - else - { - len = count; - } - input_ptr_ += len; - } - - int peek() - { - return input_ptr_ < input_end_ ? *input_ptr_ : traits_type::eof(); - } - - size_t read(value_type* p, size_t length) - { - size_t len; - if ((size_t)(input_end_ - input_ptr_) < length) - { - len = input_end_ - input_ptr_; - eof_ = true; - } - else - { - len = length; - } - std::memcpy(p, input_ptr_, len); - input_ptr_ += len; - return len; - } - - template - typename std::enable_if::value,size_t>::type - read(OutputIt d_first, size_t count) - { - size_t len; - if ((size_t)(input_end_ - input_ptr_) < count) - { - len = input_end_ - input_ptr_; - eof_ = true; - } - else - { - len = count; - } - for (size_t i = 0; i < len; ++i) - { - *d_first++ = *input_ptr_++; - } - return len; - } -}; - -} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/staj_iterator.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/staj_iterator.hpp deleted file mode 100644 index 5937972952..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/staj_iterator.hpp +++ /dev/null @@ -1,354 +0,0 @@ -// Copyright 2018 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_STAJ_ITERATOR_HPP -#define JSONCONS_STAJ_ITERATOR_HPP - -#include -#include -#include -#include -#include -#include // std::input_iterator_tag -#include -#include -#include - -namespace jsoncons { - -template> -class basic_staj_array_iterator -{ - typedef CharT char_type; - - basic_staj_reader* reader_; - T value_; -public: - typedef T value_type; - typedef std::ptrdiff_t difference_type; - typedef T* pointer; - typedef T& reference; - typedef std::input_iterator_tag iterator_category; - - basic_staj_array_iterator() noexcept - : reader_(nullptr) - { - } - - basic_staj_array_iterator(basic_staj_reader& reader) - : reader_(std::addressof(reader)) - { - if (reader_->current().event_type() == staj_event_type::begin_array) - { - next(); - } - else - { - reader_ = nullptr; - } - } - - basic_staj_array_iterator(basic_staj_reader& reader, - std::error_code& ec) - : reader_(std::addressof(reader)) - { - if (reader_->current().event_type() == staj_event_type::begin_array) - { - next(ec); - if (ec) - { - reader_ = nullptr; - } - } - else - { - reader_ = nullptr; - } - } - - const T& operator*() const - { - return value_; - } - - const T* operator->() const - { - return &value_; - } - - basic_staj_array_iterator& operator++() - { - next(); - return *this; - } - - basic_staj_array_iterator& increment(std::error_code& ec) - { - next(ec); - if (ec) - { - reader_ = nullptr; - } - return *this; - } - - basic_staj_array_iterator operator++(int) // postfix increment - { - basic_staj_array_iterator temp(*this); - next(); - return temp; - } - - friend bool operator==(const basic_staj_array_iterator& a, const basic_staj_array_iterator& b) - { - return (!a.reader_ && !b.reader_) - || (!a.reader_ && b.done()) - || (!b.reader_ && a.done()); - } - - friend bool operator!=(const basic_staj_array_iterator& a, const basic_staj_array_iterator& b) - { - return !(a == b); - } - -private: - - bool done() const - { - return reader_->done() || reader_->current().event_type() == staj_event_type::end_array; - } - - void next(); - - void next(std::error_code& ec); -}; - -template -basic_staj_array_iterator begin(basic_staj_array_iterator iter) noexcept -{ - return iter; -} - -template -basic_staj_array_iterator end(const basic_staj_array_iterator&) noexcept -{ - return basic_staj_array_iterator(); -} - -template -class basic_staj_object_iterator -{ -public: - typedef CharT char_type; - typedef std::basic_string key_type; - typedef std::pair value_type; - typedef std::ptrdiff_t difference_type; - typedef value_type* pointer; - typedef value_type& reference; - typedef std::input_iterator_tag iterator_category; - -private: - basic_staj_reader* reader_; - value_type kv_; -public: - - basic_staj_object_iterator() noexcept - : reader_(nullptr) - { - } - - basic_staj_object_iterator(basic_staj_reader& reader) - : reader_(std::addressof(reader)) - { - if (reader_->current().event_type() == staj_event_type::begin_object) - { - next(); - } - else - { - reader_ = nullptr; - } - } - - basic_staj_object_iterator(basic_staj_reader& reader, - std::error_code& ec) - : reader_(std::addressof(reader)) - { - if (reader_->current().event_type() == staj_event_type::begin_object) - { - next(ec); - if (ec) - { - reader_ = nullptr; - } - } - else - { - reader_ = nullptr; - } - } - - const value_type& operator*() const - { - return kv_; - } - - const value_type* operator->() const - { - return &kv_; - } - - basic_staj_object_iterator& operator++() - { - next(); - return *this; - } - - basic_staj_object_iterator& increment(std::error_code& ec) - { - next(ec); - if (ec) - { - reader_ = nullptr; - } - return *this; - } - - basic_staj_object_iterator operator++(int) // postfix increment - { - basic_staj_object_iterator temp(*this); - next(); - return temp; - } - - friend bool operator==(const basic_staj_object_iterator& a, const basic_staj_object_iterator& b) - { - return (!a.reader_ && !b.reader_) - || (!a.reader_ && b.done()) - || (!b.reader_ && a.done()); - } - - friend bool operator!=(const basic_staj_object_iterator& a, const basic_staj_object_iterator& b) - { - return !(a == b); - } - -private: - - bool done() const - { - return reader_->done() || reader_->current().event_type() == staj_event_type::end_object; - } - - void next(); - - void next(std::error_code& ec); -}; - -template -basic_staj_object_iterator begin(basic_staj_object_iterator iter) noexcept -{ - return iter; -} - -template -basic_staj_object_iterator end(const basic_staj_object_iterator&) noexcept -{ - return basic_staj_object_iterator(); -} - -template -using staj_array_iterator = basic_staj_array_iterator; - -template -using wstaj_array_iterator = basic_staj_array_iterator; - -template -using staj_object_iterator = basic_staj_object_iterator; - -template -using wstaj_object_iterator = basic_staj_object_iterator; - -} - -#include - -namespace jsoncons { - -template -void basic_staj_array_iterator::next() -{ - if (!done()) - { - reader_->next(); - if (!done()) - { - read_from(Json(), *reader_, value_); - } - } -} - -template -void basic_staj_array_iterator::next(std::error_code& ec) -{ - if (!done()) - { - reader_->next(ec); - if (ec) - { - return; - } - if (!done()) - { - read_from(Json(), *reader_, value_, ec); - } - } -} - -template -void basic_staj_object_iterator::next() -{ - reader_->next(); - if (!done()) - { - JSONCONS_ASSERT(reader_->current().event_type() == staj_event_type::name); - kv_.first =reader_->current(). template as(); - reader_->next(); - if (!done()) - { - read_from(Json(), *reader_, kv_.second); - } - } -} - -template -void basic_staj_object_iterator::next(std::error_code& ec) -{ - reader_->next(ec); - if (ec) - { - return; - } - if (!done()) - { - JSONCONS_ASSERT(reader_->current().event_type() == staj_event_type::name); - kv_.first =reader_->current(). template as(); - reader_->next(ec); - if (ec) - { - return; - } - if (!done()) - { - read_from(Json(), *reader_, kv_.second, ec); - } - } -} - -} - -#endif - diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/staj_reader.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/staj_reader.hpp deleted file mode 100644 index 269437361f..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/staj_reader.hpp +++ /dev/null @@ -1,434 +0,0 @@ -// Copyright 2018 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_STAJ_READER_HPP -#define JSONCONS_STAJ_READER_HPP - -#include // std::allocator -#include -#include -#include -#include -#include // std::enable_if -#include // std::array -#include -#include -#include -#include -#include -#include -#include - -namespace jsoncons { - -enum class staj_event_type -{ - begin_array, - end_array, - begin_object, - end_object, - name, - string_value, - byte_string_value, - null_value, - bool_value, - int64_value, - uint64_value, - double_value -}; - -JSONCONS_STRING_LITERAL(null,'n','u','l','l') -JSONCONS_STRING_LITERAL(true,'t','r','u','e') -JSONCONS_STRING_LITERAL(false,'f','a','l','s','e') - -template -class basic_staj_event -{ - staj_event_type event_type_; - semantic_tag semantic_tag_; - union - { - bool bool_value_; - int64_t int64_value_; - uint64_t uint64_value_; - double double_value_; - const CharT* string_data_; - const uint8_t* byte_string_data_; - } value_; - size_t length_; -public: - basic_staj_event(staj_event_type event_type, semantic_tag semantic_tag = semantic_tag::none) - : event_type_(event_type), semantic_tag_(semantic_tag), length_(0) - { - } - - basic_staj_event(null_type) - : event_type_(staj_event_type::null_value), semantic_tag_(semantic_tag::none), length_(0) - { - } - - basic_staj_event(bool value) - : event_type_(staj_event_type::bool_value), semantic_tag_(semantic_tag::none), length_(0) - { - value_.bool_value_ = value; - } - - basic_staj_event(int64_t value, semantic_tag semantic_tag) - : event_type_(staj_event_type::int64_value), semantic_tag_(semantic_tag), length_(0) - { - value_.int64_value_ = value; - } - - basic_staj_event(uint64_t value, semantic_tag semantic_tag) - : event_type_(staj_event_type::uint64_value), semantic_tag_(semantic_tag), length_(0) - { - value_.uint64_value_ = value; - } - - basic_staj_event(double value, semantic_tag semantic_tag) - : event_type_(staj_event_type::double_value), semantic_tag_(semantic_tag), length_(0) - { - value_.double_value_ = value; - } - - basic_staj_event(const CharT* data, size_t length, - staj_event_type event_type, - semantic_tag semantic_tag = semantic_tag::none) - : event_type_(event_type), semantic_tag_(semantic_tag), length_(length) - { - value_.string_data_ = data; - } - - template - typename std::enable_if::value && std::is_same::value, T>::type - as() const - { - T s; - switch (event_type_) - { - case staj_event_type::name: - case staj_event_type::string_value: - s = T(value_.string_data_, length_); - break; - case staj_event_type::int64_value: - { - jsoncons::string_result result(s); - jsoncons::detail::print_integer(value_.int64_value_, result); - break; - } - case staj_event_type::uint64_value: - { - jsoncons::string_result result(s); - jsoncons::detail::print_uinteger(value_.uint64_value_, result); - break; - } - case staj_event_type::double_value: - { - jsoncons::string_result result(s); - jsoncons::detail::print_double f{ floating_point_options() }; - f(value_.double_value_, result); - break; - } - case staj_event_type::bool_value: - { - jsoncons::string_result result(s); - if (value_.bool_value_) - { - result.append(true_literal().data(),true_literal().size()); - } - else - { - result.append(false_literal().data(),false_literal().size()); - } - break; - } - case staj_event_type::null_value: - { - jsoncons::string_result result(s); - result.append(null_literal().data(),null_literal().size()); - break; - } - default: - JSONCONS_THROW(json_runtime_error("Not a string")); - } - return s; - } - - template - typename std::enable_if::value && std::is_same::value, T>::type - as() const - { - T s; - switch (event_type_) - { - case staj_event_type::name: - case staj_event_type::string_value: - s = T(value_.string_data_, length_); - break; - default: - JSONCONS_THROW(json_runtime_error("Not a string")); - } - return s; - } - - template - typename std::enable_if::value, T>::type - as() const - { - return static_cast(as_int64()); - } - - template - typename std::enable_if::value, T>::type - as() const - { - return static_cast(as_uint64()); - } - - template - typename std::enable_if::value, T>::type - as() const - { - return static_cast(as_double()); - } - - template> - typename std::enable_if>::value, T>::type - as() const - { - return as_bignum(); - } - - template - typename std::enable_if::value, T>::type - as() const - { - return as_bool(); - } - - staj_event_type event_type() const noexcept { return event_type_; } - - semantic_tag get_semantic_tag() const noexcept { return semantic_tag_; } -private: - - int64_t as_int64() const - { - int64_t value = 0; - switch (event_type_) - { - case staj_event_type::name: - case staj_event_type::string_value: - { - auto result = jsoncons::detail::to_integer(value_.string_data_, length_); - if (result.ec != jsoncons::detail::to_integer_errc()) - { - JSONCONS_THROW(json_runtime_error(make_error_code(result.ec).message())); - } - value = result.value; - break; - } - case staj_event_type::double_value: - value = static_cast(value_.double_value_); - break; - case staj_event_type::int64_value: - value = value_.int64_value_; - break; - case staj_event_type::uint64_value: - value = static_cast(value_.uint64_value_); - break; - case staj_event_type::bool_value: - value = value_.bool_value_ ? 1 : 0; - break; - default: - JSONCONS_THROW(json_runtime_error("Not an integer")); - } - return value; - } - - uint64_t as_uint64() const - { - uint64_t value = 0; - switch (event_type_) - { - case staj_event_type::name: - case staj_event_type::string_value: - { - auto result = jsoncons::detail::to_integer(value_.string_data_, length_); - if (result.ec != jsoncons::detail::to_integer_errc()) - { - JSONCONS_THROW(json_runtime_error(make_error_code(result.ec).message())); - } - value = result.value; - break; - } - case staj_event_type::double_value: - value = static_cast(value_.double_value_); - break; - case staj_event_type::int64_value: - value = static_cast(value_.int64_value_); - break; - case staj_event_type::uint64_value: - value = value_.uint64_value_; - break; - case staj_event_type::bool_value: - value = value_.bool_value_ ? 1 : 0; - break; - default: - JSONCONS_THROW(json_runtime_error("Not an unsigned integer")); - } - return value; - } - - double as_double() const - { - switch (event_type_) - { - case staj_event_type::name: - case staj_event_type::string_value: - { - std::string target; - auto result = unicons::convert( - value_.string_data_, value_.string_data_ + length_, std::back_inserter(target), unicons::conv_flags::strict); - if (result.ec != unicons::conv_errc()) - { - JSONCONS_THROW(json_runtime_error("Not a double")); - } - jsoncons::detail::string_to_double f; - return f(target.data(), target.length()); - } - case staj_event_type::double_value: - return value_.double_value_; - case staj_event_type::int64_value: - return static_cast(value_.int64_value_); - case staj_event_type::uint64_value: - return static_cast(value_.uint64_value_); - default: - JSONCONS_THROW(json_runtime_error("Not a double")); - } - } - - bool as_bool() const - { - switch (event_type_) - { - case staj_event_type::bool_value: - return value_.bool_value_; - case staj_event_type::double_value: - return value_.double_value_ != 0.0; - case staj_event_type::int64_value: - return value_.int64_value_ != 0; - case staj_event_type::uint64_value: - return value_.uint64_value_ != 0; - default: - JSONCONS_THROW(json_runtime_error("Not a bool")); - } - } - - template > - basic_bignum as_bignum() const - { - switch (event_type_) - { - case staj_event_type::string_value: - if (!jsoncons::detail::is_integer(value_.string_data_, length_)) - { - JSONCONS_THROW(json_runtime_error("Not a bignum")); - } - return basic_bignum(value_.string_data_, length_); - case staj_event_type::double_value: - return basic_bignum(value_.double_value_); - case staj_event_type::int64_value: - return basic_bignum(value_.int64_value_); - case staj_event_type::uint64_value: - return basic_bignum(value_.uint64_value_); - case staj_event_type::bool_value: - return basic_bignum(value_.bool_value_ ? 1 : 0); - default: - JSONCONS_THROW(json_runtime_error("Not a bignum")); - } - } - -}; - -template -class basic_staj_reader -{ -public: - virtual ~basic_staj_reader() = default; - - virtual bool done() const = 0; - - virtual const basic_staj_event& current() const = 0; - - virtual void accept(basic_json_content_handler& handler) = 0; - - virtual void accept(basic_json_content_handler& handler, - std::error_code& ec) = 0; - - virtual void next() = 0; - - virtual void next(std::error_code& ec) = 0; - - virtual const ser_context& context() const = 0; -}; - -template -class basic_staj_filter -{ -public: - - virtual ~basic_staj_filter() = default; - - virtual bool accept(const basic_staj_event& event, const ser_context& context) = 0; -}; - -template -class default_basic_staj_filter : public basic_staj_filter -{ -public: - bool accept(const basic_staj_event&, const ser_context&) override - { - return true; - } -}; - -typedef basic_staj_event staj_event; -typedef basic_staj_event wstaj_event; - -typedef basic_staj_reader staj_reader; -typedef basic_staj_reader wstaj_reader; - -typedef basic_staj_filter staj_filter; -typedef basic_staj_filter wstaj_filter; - -#if !defined(JSONCONS_NO_DEPRECATED) - -typedef staj_event_type stream_event_type; - -template -using basic_stream_event = basic_staj_event; - -template -using basic_stream_reader = basic_staj_reader; - -template -using basic_stream_filter = basic_staj_filter; - -typedef basic_staj_event stream_event; -typedef basic_staj_event wstream_event; - -typedef basic_staj_reader stream_reader; -typedef basic_staj_reader wstream_reader; - -typedef basic_staj_filter stream_filter; -typedef basic_staj_filter wstream_filter; - -#endif - -} - -#endif - diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons/unicode_traits.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons/unicode_traits.hpp deleted file mode 100644 index 56bc9e7aa6..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons/unicode_traits.hpp +++ /dev/null @@ -1,1492 +0,0 @@ -// Copyright 2016 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/unicode_traits for latest version - -/* - * Includes code derived from Unicode, Inc decomposition code in ConvertUTF.h and ConvertUTF.c - * http://www.unicode.org/ - * - * "Unicode, Inc. hereby grants the right to freely use the information - * supplied in this file in the creation of products supporting the - * Unicode Standard." -*/ - -#ifndef JSONCONS_UNICONS_UNICODE_TRAITS_HPP -#define JSONCONS_UNICONS_UNICODE_TRAITS_HPP - -#if defined(__clang__) -# define UNICONS_FALLTHROUGH [[clang::fallthrough]] -#elif defined(__GNUC__) && ((__GNUC__ >= 7)) -# define UNICONS_FALLTHROUGH __attribute__((fallthrough)) -#elif defined (__GNUC__) -# define UNICONS_FALLTHROUGH // FALLTHRU -#else -# define UNICONS_FALLTHROUGH -#endif - -#if defined (__clang__) -#if defined(_GLIBCXX_USE_NOEXCEPT) -#define UNICONS_NOEXCEPT _GLIBCXX_USE_NOEXCEPT -#else -#define UNICONS_NOEXCEPT noexcept -#endif -#elif defined(__GNUC__) -#define UNICONS_NOEXCEPT _GLIBCXX_USE_NOEXCEPT -#elif defined(_MSC_VER) -#if _MSC_VER >= 1900 -#define UNICONS_NOEXCEPT noexcept -#else -#define UNICONS_NOEXCEPT -#endif -#else -#define UNICONS_NOEXCEPT -#endif - -#include -#include -#include -#include - -namespace jsoncons { namespace unicons { - -/* - * Magic values subtracted from a buffer value during UTF8 conversion. - * This table contains as many values as there might be trailing bytes - * in a UTF-8 sequence. Source: ConvertUTF.c - */ -const uint32_t offsets_from_utf8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, - 0x03C82080UL, 0xFA082080UL, 0x82082080UL }; - -/* - * Once the bits are split out into bytes of UTF-8, this is a mask OR-ed - * into the first byte, depending on how many bytes follow. There are - * as many entries in this table as there are UTF-8 sequence types. - * (I.e., one byte sequence, two byte... etc.). Remember that sequencs - * for *legal* UTF-8 will be 4 or fewer bytes total. Source: ConvertUTF.c - */ -const uint8_t first_byte_mark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; - -/* - * Index into the table below with the first byte of a UTF-8 sequence to - * get the number of trailing bytes that are supposed to follow it. - * Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is - * left as-is for anyone who may want to do such conversion, which was - * allowed in earlier algorithms. Source: ConvertUTF.c - */ -const uint8_t trailing_bytes_for_utf8[256] = { - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5 -}; - -// Some fundamental constants. Source: ConvertUTF.h -const uint32_t replacement_char = 0x0000FFFD; -const uint32_t max_bmp = 0x0000FFFF; -const uint32_t max_utf16 = 0x0010FFFF; -const uint32_t max_utf32 = 0x7FFFFFFF; -const uint32_t max_legal_utf32 = 0x0010FFFF; - -const int half_shift = 10; // used for shifting by 10 bits -const uint32_t half_base = 0x0010000UL; -const uint32_t half_mask = 0x3FFUL; - -const uint16_t sur_high_start = 0xD800; -const uint16_t sur_high_end = 0xDBFF; -const uint16_t sur_low_start = 0xDC00; -const uint16_t sur_low_end = 0xDFFF; - -inline -static bool is_continuation_byte(unsigned char ch) -{ - return (ch & 0xC0) == 0x80; -} - -inline -bool is_high_surrogate(uint32_t ch) UNICONS_NOEXCEPT -{ - return (ch >= sur_high_start && ch <= sur_high_end); -} - -inline -bool is_low_surrogate(uint32_t ch) UNICONS_NOEXCEPT -{ - return (ch >= sur_low_start && ch <= sur_low_end); -} - -inline -bool is_surrogate(uint32_t ch) UNICONS_NOEXCEPT -{ - return (ch >= sur_high_start && ch <= sur_low_end); -} - -enum class conv_flags -{ - strict = 0, - lenient -}; - -// conv_errc - -enum class conv_errc -{ - ok = 0, - over_long_utf8_sequence = 1, // over long utf8 sequence - expected_continuation_byte, // expected continuation byte - unpaired_high_surrogate, // unpaired high surrogate UTF-16 - illegal_surrogate_value, // UTF-16 surrogate values are illegal in UTF-32 - source_exhausted, // partial character in source, but hit end - source_illegal // source sequence is illegal/malformed -}; - -class Unicode_traits_error_category_impl_ - : public std::error_category -{ -public: - virtual const char* name() const UNICONS_NOEXCEPT - { - return "unicons conversion error"; - } - virtual std::string message(int ev) const - { - switch (static_cast(ev)) - { - case conv_errc::over_long_utf8_sequence: - return "Over long utf8 sequence"; - case conv_errc::expected_continuation_byte: - return "Expected continuation byte"; - case conv_errc::unpaired_high_surrogate: - return "Unpaired high surrogate UTF-16"; - case conv_errc::illegal_surrogate_value: - return "UTF-16 surrogate values are illegal in UTF-32"; - case conv_errc::source_exhausted: - return "Partial character in source, but hit end"; - case conv_errc::source_illegal: - return "Source sequence is illegal/malformed"; - default: - return ""; - break; - } - } -}; - -inline -const std::error_category& unicode_traits_error_category() -{ - static Unicode_traits_error_category_impl_ instance; - return instance; -} - -inline -std::error_code make_error_code(conv_errc result) -{ - return std::error_code(static_cast(result),unicode_traits_error_category()); -} - -// encoding_errc - -enum class encoding_errc -{ - ok = 0, - expected_u8_found_u16 = 1, - expected_u8_found_u32, - expected_u16_found_fffe, - expected_u32_found_fffe -}; - -class Encoding_errc_impl_ - : public std::error_category -{ -public: - virtual const char* name() const UNICONS_NOEXCEPT - { - return "unicons encoding error"; - } - virtual std::string message(int ev) const - { - switch (static_cast(ev)) - { - case encoding_errc::expected_u8_found_u16: - return "Expected UTF-8, found UTF-16"; - case encoding_errc::expected_u8_found_u32: - return "Expected UTF-8, found UTF-32"; - case encoding_errc::expected_u16_found_fffe: - return "Expected UTF-16, found non character"; - case encoding_errc::expected_u32_found_fffe: - return "Expected UTF-32, found non character"; - default: - return ""; - break; - } - } -}; - -inline -const std::error_category& encoding_error_category() -{ - static Encoding_errc_impl_ instance; - return instance; -} - -inline -std::error_code make_error_code(encoding_errc result) -{ - return std::error_code(static_cast(result),encoding_error_category()); -} - -// utf8 - -template -typename std::enable_if::value_type>::value - && sizeof(typename std::iterator_traits::value_type) == sizeof(uint8_t), - conv_errc >::type -is_legal_utf8(Iterator first, size_t length) -{ - uint8_t a; - Iterator srcptr = first+length; - switch (length) { - default: - return conv_errc::over_long_utf8_sequence; - case 4: - if (((a = (*--srcptr))& 0xC0) != 0x80) - return conv_errc::expected_continuation_byte; - UNICONS_FALLTHROUGH; - case 3: - if (((a = (*--srcptr))& 0xC0) != 0x80) - return conv_errc::expected_continuation_byte; - UNICONS_FALLTHROUGH; - case 2: - if (((a = (*--srcptr))& 0xC0) != 0x80) - return conv_errc::expected_continuation_byte; - - switch (static_cast(*first)) - { - /* no fall-through in this inner switch */ - case 0xE0: if (a < 0xA0) return conv_errc::source_illegal; break; - case 0xED: if (a > 0x9F) return conv_errc::source_illegal; break; - case 0xF0: if (a < 0x90) return conv_errc::source_illegal; break; - case 0xF4: if (a > 0x8F) return conv_errc::source_illegal; break; - default: if (a < 0x80) return conv_errc::source_illegal; - } - - UNICONS_FALLTHROUGH; - case 1: - if (static_cast(*first) >= 0x80 && static_cast(*first) < 0xC2) - return conv_errc::source_illegal; - break; - } - if (static_cast(*first) > 0xF4) - return conv_errc::source_illegal; - - return conv_errc(); -} - -template using void_t = void; - -template -struct is_output_iterator : std::false_type {}; - -template -struct is_output_iterator::iterator_category, - decltype(*std::declval() = std::declval())>> : std::true_type {}; - -// is_same_size fixes issue with vs2013 - -// primary template -template -struct is_same_size : std::false_type -{ -}; - -// specialization for non void types -template -struct is_same_size::value && !std::is_void::value>::type> -{ - static const bool value = (sizeof(T1) == sizeof(T2)); -}; - -template -struct is_compatible_output_iterator : std::false_type {}; - -template -struct is_compatible_output_iterator::value - && std::is_void::value_type>::value - && std::is_integral::value - && !std::is_void::value - && is_same_size::value>::type -> : std::true_type {}; - -template -struct is_compatible_output_iterator::value - && std::is_integral::value_type>::value - && is_same_size::value_type,CharT>::value>::type -> : std::true_type {}; - -template -struct is_compatible_output_iterator::value - && std::is_void::value_type>::value - && is_same_size::value>::type -> : std::true_type {}; - -// convert - -template -struct convert_result -{ - Iterator it; - conv_errc ec; -}; - -template -typename std::enable_if::value_type>::value && sizeof(typename std::iterator_traits::value_type) == sizeof(uint8_t) - && is_compatible_output_iterator::value,convert_result>::type -convert(InputIt first, InputIt last, OutputIt target, conv_flags flags=conv_flags::strict) -{ - (void)flags; - - conv_errc result = conv_errc(); - while (first != last) - { - size_t length = trailing_bytes_for_utf8[static_cast(*first)] + 1; - if (length > (size_t)(last - first)) - { - return convert_result{first, conv_errc::source_exhausted}; - } - if ((result=is_legal_utf8(first, length)) != conv_errc()) - { - return convert_result{first,result}; - } - - switch (length) { - case 4: *target++ = (static_cast(*first++)); - UNICONS_FALLTHROUGH; - case 3: *target++ = (static_cast(*first++)); - UNICONS_FALLTHROUGH; - case 2: *target++ = (static_cast(*first++)); - UNICONS_FALLTHROUGH; - case 1: *target++ = (static_cast(*first++)); - } - } - return convert_result{first,result} ; -} - -template -typename std::enable_if::value_type>::value && sizeof(typename std::iterator_traits::value_type) == sizeof(uint8_t) - && is_compatible_output_iterator::value,convert_result>::type -convert(InputIt first, InputIt last, - OutputIt target, - conv_flags flags = conv_flags::strict) -{ - conv_errc result = conv_errc(); - - while (first != last) - { - uint32_t ch = 0; - unsigned short extra_bytes_to_read = trailing_bytes_for_utf8[static_cast(*first)]; - if (extra_bytes_to_read >= last - first) - { - result = conv_errc::source_exhausted; - break; - } - /* Do this check whether lenient or strict */ - if ((result=is_legal_utf8(first, extra_bytes_to_read+1)) != conv_errc()) - { - break; - } - /* - * The cases all fall through. See "Note A" below. - */ - switch (extra_bytes_to_read) { - case 5: ch += static_cast(*first++); ch <<= 6; /* remember, illegal UTF-8 */ - case 4: ch += static_cast(*first++); ch <<= 6; /* remember, illegal UTF-8 */ - case 3: ch += static_cast(*first++); ch <<= 6; - case 2: ch += static_cast(*first++); ch <<= 6; - case 1: ch += static_cast(*first++); ch <<= 6; - case 0: ch += static_cast(*first++); - } - ch -= offsets_from_utf8[extra_bytes_to_read]; - - if (ch <= max_bmp) { /* Target is a character <= 0xFFFF */ - /* UTF-16 surrogate values are illegal in UTF-32 */ - if (is_surrogate(ch) ) { - if (flags == conv_flags::strict) { - first -= (extra_bytes_to_read+1); /* return to the illegal value itself */ - result = conv_errc::source_illegal; - break; - } else { - *target++ = (replacement_char); - } - } else { - *target++ = ((uint16_t)ch); /* normal case */ - } - } else if (ch > max_utf16) { - if (flags == conv_flags::strict) { - result = conv_errc::source_illegal; - first -= (extra_bytes_to_read+1); /* return to the start */ - break; /* Bail out; shouldn't continue */ - } else { - *target++ = (replacement_char); - } - } else { - /* target is a character in range 0xFFFF - 0x10FFFF. */ - ch -= half_base; - *target++ = ((uint16_t)((ch >> half_shift) + sur_high_start)); - *target++ = ((uint16_t)((ch & half_mask) + sur_low_start)); - } - } - return convert_result{first,result} ; -} - -template -typename std::enable_if::value_type>::value && sizeof(typename std::iterator_traits::value_type) == sizeof(uint8_t) - && is_compatible_output_iterator::value,convert_result>::type -convert(InputIt first, InputIt last, - OutputIt target, - conv_flags flags = conv_flags::strict) -{ - conv_errc result = conv_errc(); - - while (first < last) - { - uint32_t ch = 0; - unsigned short extra_bytes_to_read = trailing_bytes_for_utf8[static_cast(*first)]; - if (extra_bytes_to_read >= last - first) - { - result = conv_errc::source_exhausted; - break; - } - /* Do this check whether lenient or strict */ - if ((result=is_legal_utf8(first, extra_bytes_to_read+1)) != conv_errc()) { - break; - } - /* - * The cases all fall through. See "Note A" below. - */ - switch (extra_bytes_to_read) - { - case 5: - ch += static_cast(*first++); - ch <<= 6; - UNICONS_FALLTHROUGH; - case 4: - ch += static_cast(*first++); - ch <<= 6; - UNICONS_FALLTHROUGH; - case 3: - ch += static_cast(*first++); - ch <<= 6; - UNICONS_FALLTHROUGH; - case 2: - ch += static_cast(*first++); - ch <<= 6; - UNICONS_FALLTHROUGH; - case 1: - ch += static_cast(*first++); - ch <<= 6; - UNICONS_FALLTHROUGH; - case 0: - ch += static_cast(*first++); - break; - } - ch -= offsets_from_utf8[extra_bytes_to_read]; - - if (ch <= max_legal_utf32) { - /* - * UTF-16 surrogate values are illegal in UTF-32, and anything - * over Plane 17 (> 0x10FFFF) is illegal. - */ - if (is_surrogate(ch) ) { - if (flags == conv_flags::strict) { - first -= (extra_bytes_to_read+1); /* return to the illegal value itself */ - result = conv_errc::source_illegal; - break; - } else { - *target++ = (replacement_char); - } - } else { - *target++ = (ch); - } - } else { /* i.e., ch > max_legal_utf32 */ - result = conv_errc::source_illegal; - *target++ = (replacement_char); - } - } - return convert_result{first,result} ; -} - -// utf16 - -template -typename std::enable_if::value_type>::value && sizeof(typename std::iterator_traits::value_type) == sizeof(uint16_t) - && is_compatible_output_iterator::value,convert_result>::type -convert(InputIt first, InputIt last, - OutputIt target, - conv_flags flags = conv_flags::strict) { - conv_errc result = conv_errc(); - while (first < last) { - unsigned short bytes_to_write = 0; - const uint32_t byteMask = 0xBF; - const uint32_t byteMark = 0x80; - uint32_t ch = *first++; - /* If we have a surrogate pair, convert to uint32_t first. */ - if (is_high_surrogate(ch)) { - /* If the 16 bits following the high surrogate are in the first buffer... */ - if (first < last) { - uint32_t ch2 = *first; - /* If it's a low surrogate, convert to uint32_t. */ - if (ch2 >= sur_low_start && ch2 <= sur_low_end) { - ch = ((ch - sur_high_start) << half_shift) - + (ch2 - sur_low_start) + half_base; - ++first; - } else if (flags == conv_flags::strict) { /* it's an unpaired high surrogate */ - --first; /* return to the illegal value itself */ - result = conv_errc::unpaired_high_surrogate; - break; - } - } else { /* We don't have the 16 bits following the high surrogate. */ - --first; /* return to the high surrogate */ - result = conv_errc::source_exhausted; - break; - } - } else if (flags == conv_flags::strict) { - /* UTF-16 surrogate values are illegal in UTF-32 */ - if (is_low_surrogate(ch)) { - --first; /* return to the illegal value itself */ - result = conv_errc::source_illegal; - break; - } - } - /* Figure out how many bytes the result will require */ - if (ch < (uint32_t)0x80) { - bytes_to_write = 1; - } else if (ch < (uint32_t)0x800) { - bytes_to_write = 2; - } else if (ch < (uint32_t)0x10000) { - bytes_to_write = 3; - } else if (ch < (uint32_t)0x110000) { - bytes_to_write = 4; - } else { - bytes_to_write = 3; - ch = replacement_char; - } - - uint8_t byte1 = 0; - uint8_t byte2 = 0; - uint8_t byte3 = 0; - uint8_t byte4 = 0; - - switch (bytes_to_write) { // note: everything falls through - case 4: byte4 = (uint8_t)((ch | byteMark) & byteMask); ch >>= 6; - case 3: byte3 = (uint8_t)((ch | byteMark) & byteMask); ch >>= 6; - case 2: byte2 = (uint8_t)((ch | byteMark) & byteMask); ch >>= 6; - case 1: byte1 = (uint8_t)(ch | first_byte_mark[bytes_to_write]); - } - switch (bytes_to_write) - { - case 4: - *target++ = (byte1); - *target++ = (byte2); - *target++ = (byte3); - *target++ = (byte4); - break; - case 3: - *target++ = (byte1); - *target++ = (byte2); - *target++ = (byte3); - break; - case 2: - *target++ = (byte1); - *target++ = (byte2); - break; - case 1: - *target++ = (byte1); - break; - } - } - return convert_result{first,result} ; -} - -template -typename std::enable_if::value_type>::value && sizeof(typename std::iterator_traits::value_type) == sizeof(uint16_t) - && is_compatible_output_iterator::value,convert_result>::type -convert(InputIt first, InputIt last, - OutputIt target, - conv_flags flags = conv_flags::strict) -{ - conv_errc result = conv_errc(); - - while (first != last) - { - uint32_t ch = *first++; - /* If we have a surrogate pair, convert to uint32_t first. */ - if (is_high_surrogate(ch)) - { - /* If the 16 bits following the high surrogate are in the first buffer... */ - if (first < last) { - uint32_t ch2 = *first; - /* If it's a low surrogate, */ - if (ch2 >= sur_low_start && ch2 <= sur_low_end) { - *target++ = ((uint16_t)ch); - *target++ = ((uint16_t)ch2); - ++first; - } else if (flags == conv_flags::strict) { /* it's an unpaired high surrogate */ - --first; /* return to the illegal value itself */ - result = conv_errc::unpaired_high_surrogate; - break; - } - } else { /* We don't have the 16 bits following the high surrogate. */ - --first; /* return to the high surrogate */ - result = conv_errc::source_exhausted; - break; - } - } else if (is_low_surrogate(ch)) - { - // illegal leading low surrogate - if (flags == conv_flags::strict) { - --first; /* return to the illegal value itself */ - result = conv_errc::source_illegal; - break; - } - else - { - *target++ = ((uint16_t)ch); - } - } - else - { - *target++ = ((uint16_t)ch); - } - } - return convert_result{first,result} ; -} - -template -typename std::enable_if::value_type>::value && sizeof(typename std::iterator_traits::value_type) == sizeof(uint16_t) - && is_compatible_output_iterator::value,convert_result>::type -convert(InputIt first, InputIt last, - OutputIt target, - conv_flags flags = conv_flags::strict) -{ - conv_errc result = conv_errc(); - - while (first != last) - { - uint32_t ch = *first++; - /* If we have a surrogate pair, convert to UTF32 first. */ - if (is_high_surrogate(ch)) { - /* If the 16 bits following the high surrogate are in the first buffer... */ - if (first < last) { - uint32_t ch2 = *first; - /* If it's a low surrogate, convert to UTF32. */ - if (ch2 >= sur_low_start && ch2 <= sur_low_end ) { - ch = ((ch - sur_high_start) << half_shift) - + (ch2 - sur_low_start) + half_base; - ++first; - } else if (flags == conv_flags::strict) { /* it's an unpaired high surrogate */ - --first; /* return to the illegal value itself */ - result = conv_errc::source_illegal; - break; - } - } else { /* We don't have the 16 bits following the high surrogate. */ - --first; /* return to the high surrogate */ - result = conv_errc::source_exhausted; - break; - } - } else if (flags == conv_flags::strict) { - /* UTF-16 surrogate values are illegal in UTF-32 */ - if (is_low_surrogate(ch) ) { - --first; /* return to the illegal value itself */ - result = conv_errc::source_illegal; - break; - } - } - *target++ = (ch); - } - return convert_result{first,result} ; -} - -// utf32 - -template -typename std::enable_if::value_type>::value && sizeof(typename std::iterator_traits::value_type) == sizeof(uint32_t) - && is_compatible_output_iterator::value,convert_result>::type -convert(InputIt first, InputIt last, - OutputIt target, - conv_flags flags = conv_flags::strict) -{ - conv_errc result = conv_errc(); - while (first < last) { - unsigned short bytes_to_write = 0; - const uint32_t byteMask = 0xBF; - const uint32_t byteMark = 0x80; - uint32_t ch = *first++; - if (flags == conv_flags::strict ) { - /* UTF-16 surrogate values are illegal in UTF-32 */ - if (is_surrogate(ch)) { - --first; /* return to the illegal value itself */ - result = conv_errc::illegal_surrogate_value; - break; - } - } - /* - * Figure out how many bytes the result will require. Turn any - * illegally large UTF32 things (> Plane 17) into replacement chars. - */ - if (ch < (uint32_t)0x80) { bytes_to_write = 1; - } else if (ch < (uint32_t)0x800) { bytes_to_write = 2; - } else if (ch < (uint32_t)0x10000) { bytes_to_write = 3; - } else if (ch <= max_legal_utf32) { bytes_to_write = 4; - } else { - bytes_to_write = 3; - ch = replacement_char; - result = conv_errc::source_illegal; - } - - uint8_t byte1 = 0; - uint8_t byte2 = 0; - uint8_t byte3 = 0; - uint8_t byte4 = 0; - - switch (bytes_to_write) { - case 4: - byte4 = (uint8_t)((ch | byteMark) & byteMask); ch >>= 6; - UNICONS_FALLTHROUGH; - case 3: - byte3 = (uint8_t)((ch | byteMark) & byteMask); ch >>= 6; - UNICONS_FALLTHROUGH; - case 2: - byte2 = (uint8_t)((ch | byteMark) & byteMask); ch >>= 6; - UNICONS_FALLTHROUGH; - case 1: - byte1 = (uint8_t) (ch | first_byte_mark[bytes_to_write]); - } - - switch (bytes_to_write) - { - case 4: - *target++ = (byte1); - *target++ = (byte2); - *target++ = (byte3); - *target++ = (byte4); - break; - case 3: - *target++ = (byte1); - *target++ = (byte2); - *target++ = (byte3); - break; - case 2: - *target++ = (byte1); - *target++ = (byte2); - break; - case 1: - *target++ = (byte1); - break; - } - } - return convert_result{first,result} ; -} - -template -typename std::enable_if::value_type>::value && sizeof(typename std::iterator_traits::value_type) == sizeof(uint32_t) - && is_compatible_output_iterator::value,convert_result>::type -convert(InputIt first, InputIt last, - OutputIt target, - conv_flags flags = conv_flags::strict) -{ - conv_errc result = conv_errc(); - - while (first != last) - { - uint32_t ch = *first++; - if (ch <= max_bmp) { /* Target is a character <= 0xFFFF */ - /* UTF-16 surrogate values are illegal in UTF-32; 0xffff or 0xfffe are both reserved values */ - if (is_surrogate(ch) ) { - if (flags == conv_flags::strict) { - --first; /* return to the illegal value itself */ - result = conv_errc::source_illegal; - break; - } else { - *target++ = (replacement_char); - } - } else { - *target++ = ((uint16_t)ch); /* normal case */ - } - } else if (ch > max_legal_utf32) { - if (flags == conv_flags::strict) { - result = conv_errc::source_illegal; - } else { - *target++ = (replacement_char); - } - } else { - /* target is a character in range 0xFFFF - 0x10FFFF. */ - ch -= half_base; - *target++ = ((uint16_t)((ch >> half_shift) + sur_high_start)); - *target++ = ((uint16_t)((ch & half_mask) + sur_low_start)); - } - } - return convert_result{first,result} ; -} - -template -typename std::enable_if::value_type>::value && sizeof(typename std::iterator_traits::value_type) == sizeof(uint32_t) - && is_compatible_output_iterator::value,convert_result>::type -convert(InputIt first, InputIt last, - OutputIt target, - conv_flags flags = conv_flags::strict) -{ - conv_errc result = conv_errc(); - - while (first != last) - { - uint32_t ch = *first++; - if (flags == conv_flags::strict ) { - /* UTF-16 surrogate values are illegal in UTF-32 */ - if (is_surrogate(ch)) { - --first; /* return to the illegal value itself */ - result = conv_errc::illegal_surrogate_value; - break; - } - } - if (ch <= max_legal_utf32) - { - *target++ = (ch); - } - else - { - *target++ = (replacement_char); - result = conv_errc::source_illegal; - } - } - return convert_result{first,result} ; -} - -// validate - -template -typename std::enable_if::value_type>::value && sizeof(typename std::iterator_traits::value_type) == sizeof(uint8_t) - ,convert_result>::type -validate(InputIt first, InputIt last) UNICONS_NOEXCEPT -{ - conv_errc result = conv_errc(); - while (first != last) - { - size_t length = trailing_bytes_for_utf8[static_cast(*first)] + 1; - if (length > (size_t)(last - first)) - { - return convert_result{first, conv_errc::source_exhausted}; - } - if ((result=is_legal_utf8(first, length)) != conv_errc()) - { - return convert_result{first,result} ; - } - first += length; - } - return convert_result{first,result} ; -} - -// utf16 - -template -typename std::enable_if::value_type>::value && sizeof(typename std::iterator_traits::value_type) == sizeof(uint16_t) - ,convert_result>::type -validate(InputIt first, InputIt last) UNICONS_NOEXCEPT -{ - conv_errc result = conv_errc(); - - while (first != last) - { - uint32_t ch = *first++; - /* If we have a surrogate pair, validate to uint32_t first. */ - if (is_high_surrogate(ch)) - { - /* If the 16 bits following the high surrogate are in the first buffer... */ - if (first < last) { - uint32_t ch2 = *first; - /* If it's a low surrogate, */ - if (ch2 >= sur_low_start && ch2 <= sur_low_end) { - ++first; - } else { - --first; /* return to the illegal value itself */ - result = conv_errc::unpaired_high_surrogate; - break; - } - } else { /* We don't have the 16 bits following the high surrogate. */ - --first; /* return to the high surrogate */ - result = conv_errc::source_exhausted; - break; - } - } else if (is_low_surrogate(ch)) - { - /* UTF-16 surrogate values are illegal in UTF-32 */ - --first; /* return to the illegal value itself */ - result = conv_errc::source_illegal; - break; - } - } - return convert_result{first,result} ; -} - - -// utf32 - - -template -typename std::enable_if::value_type>::value && sizeof(typename std::iterator_traits::value_type) == sizeof(uint32_t) - ,convert_result>::type -validate(InputIt first, InputIt last) UNICONS_NOEXCEPT -{ - conv_errc result = conv_errc(); - - while (first != last) - { - uint32_t ch = *first++; - /* UTF-16 surrogate values are illegal in UTF-32 */ - if (is_surrogate(ch)) { - --first; /* return to the illegal value itself */ - result = conv_errc::illegal_surrogate_value; - break; - } - if (!(ch <= max_legal_utf32)) - { - result = conv_errc::source_illegal; - } - } - return convert_result{first,result} ; -} - -// sequence - -template -class sequence -{ - Iterator first_; - size_t length_; -public: - sequence(Iterator first, size_t length) - : first_(first), length_(length) - { - } - - Iterator begin() const - { - return first_; - } - - size_t length() const - { - return length_; - } - - template ::value_type> - typename std::enable_if::type - codepoint() const UNICONS_NOEXCEPT - { - uint32_t ch = 0; - Iterator it = first_; - switch (length_) - { - default: - return replacement_char; - break; - case 4: - ch += static_cast(*it++); ch <<= 6; - UNICONS_FALLTHROUGH; - case 3: - ch += static_cast(*it++); ch <<= 6; - UNICONS_FALLTHROUGH; - case 2: - ch += static_cast(*it++); ch <<= 6; - UNICONS_FALLTHROUGH; - case 1: - ch += static_cast(*it++); - ch -= offsets_from_utf8[length_ - 1]; - break; - } - if (ch <= max_legal_utf32) - { - if (is_surrogate(ch)) - { - ch = replacement_char; - } - } - else // ch > max_legal_utf32 - { - ch = replacement_char; - } - return ch; - } - - template ::value_type> - typename std::enable_if::type - codepoint() const UNICONS_NOEXCEPT - { - if (length_ == 0) - { - return replacement_char; - } - if (length_ == 2) - { - uint32_t ch = *first_; - uint32_t ch2 = *(first_+ 1); - ch = ((ch - sur_high_start) << half_shift) - + (ch2 - sur_low_start) + half_base; - return ch; - } - else - { - return *first_; - } - } - - template ::value_type> - typename std::enable_if::type - codepoint() const UNICONS_NOEXCEPT - { - if (length_ == 0) - { - return replacement_char; - } - return *(first_); - } -}; - -// sequence_generator - -template -class sequence_generator -{ - Iterator begin_; - Iterator last_; - conv_flags flags_; - size_t length_; - conv_errc err_cd_; -public: - typedef sequence sequence_type; - - sequence_generator(Iterator first, Iterator last, - conv_flags flags = conv_flags::strict) UNICONS_NOEXCEPT - : begin_(first), last_(last), flags_(flags), - length_(0), err_cd_(conv_errc()) - { - next(); - } - - bool done() const UNICONS_NOEXCEPT - { - return err_cd_ != conv_errc() || begin_ == last_; - } - - conv_errc status() const UNICONS_NOEXCEPT - { - return err_cd_; - } - - sequence_type get() const UNICONS_NOEXCEPT - { - return sequence(begin_,length_); - } - - template ::value_type> - typename std::enable_if::type - next() UNICONS_NOEXCEPT - { - begin_ += length_; - if (begin_ != last_) - { - size_t length = trailing_bytes_for_utf8[static_cast(*begin_)] + 1; - if (length > (size_t)(last_ - begin_)) - { - err_cd_ = conv_errc::source_exhausted; - } - else if ((err_cd_ = is_legal_utf8(begin_, length)) != conv_errc()) - { - } - else - { - length_ = length; - } - } - } - - template ::value_type> - typename std::enable_if::type - next() UNICONS_NOEXCEPT - { - begin_ += length_; - if (begin_ != last_) - { - if (begin_ != last_) - { - - Iterator it = begin_; - - uint32_t ch = *it++; - /* If we have a surrogate pair, validate to uint32_t it. */ - if (is_high_surrogate(ch)) - { - /* If the 16 bits following the high surrogate are in the it buffer... */ - if (it < last_) { - uint32_t ch2 = *it; - /* If it's a low surrogate, */ - if (ch2 >= sur_low_start && ch2 <= sur_low_end) - { - ++it; - length_ = 2; - } - else - { - err_cd_ = conv_errc::unpaired_high_surrogate; - } - } - else - { - // We don't have the 16 bits following the high surrogate. - err_cd_ = conv_errc::source_exhausted; - } - } - else if (is_low_surrogate(ch)) - { - /* leading low surrogate */ - err_cd_ = conv_errc::source_illegal; - } - else - { - length_ = 1; - } - } - } - } - - template ::value_type> - typename std::enable_if::type - next() UNICONS_NOEXCEPT - { - begin_ += length_; - length_ = 1; - } -}; - -template -sequence_generator make_sequence_generator(Iterator first, Iterator last, - conv_flags flags = conv_flags::strict) -{ - return sequence_generator(first, last, flags); -} - -template -typename std::enable_if::value_type>::value - && (sizeof(typename std::iterator_traits::value_type) == sizeof(uint8_t) || sizeof(typename std::iterator_traits::value_type) == sizeof(uint16_t)), - sequence>::type -sequence_at(InputIt first, InputIt last, size_t index) -{ - sequence_generator g(first, last, unicons::conv_flags::strict); - - size_t count = 0; - while (!g.done() && count < index) - { - g.next(); - ++count; - } - return (!g.done() && count == index) ? g.get() : sequence(last,0); -} - -template -typename std::enable_if::value_type>::value && sizeof(typename std::iterator_traits::value_type) == sizeof(uint32_t), - sequence>::type -sequence_at(InputIt first, InputIt last, size_t index) -{ - size_t size = std::distance(first,last); - return index < size ? sequence(first+index,1) : sequence(last,0); -} - -// u8_length - -template -typename std::enable_if::value_type>::value && sizeof(typename std::iterator_traits::value_type) == sizeof(uint8_t),size_t>::type -u8_length(InputIt first, InputIt last) UNICONS_NOEXCEPT -{ - return std::distance(first,last); -} - -// utf16 - -template -typename std::enable_if::value_type>::value && sizeof(typename std::iterator_traits::value_type) == sizeof(uint16_t),size_t>::type -u8_length(InputIt first, InputIt last) UNICONS_NOEXCEPT -{ - conv_flags flags = conv_flags::strict; - size_t count = 0; - for (InputIt p = first; p != last; ++p) - { - uint32_t ch = *p; - if (is_high_surrogate(ch)) { - /* If the 16 bits following the high surrogate are in the p buffer... */ - if (p < last) { - uint32_t ch2 = *(++p); - /* If it's a low surrogate, convert to uint32_t. */ - if (ch2 >= sur_low_start && ch2 <= sur_low_end) { - ch = ((ch - sur_high_start) << half_shift) - + (ch2 - sur_low_start) + half_base; - - } else if (flags == conv_flags::strict) { /* it's an unpaired high surrogate */ - break; - } - } else { /* We don't have the 16 bits following the high surrogate. */ - break; - } - } else if (flags == conv_flags::strict) { - /* UTF-16 surrogate values are illegal in UTF-32 */ - if (is_low_surrogate(ch)) { - break; - } - } - if (ch < (uint32_t)0x80) { - ++count; - } else if (ch < (uint32_t)0x800) { - count += 2; - } else if (ch < (uint32_t)0x10000) { - count += 3; - } else if (ch < (uint32_t)0x110000) { - count += 4; - } else { - count += 3; - } - } - return count; -} - - -// utf32 - -template -typename std::enable_if::value_type>::value && sizeof(typename std::iterator_traits::value_type) == sizeof(uint32_t),size_t>::type -u8_length(InputIt first, InputIt last) UNICONS_NOEXCEPT -{ - size_t count = 0; - for (InputIt p = first; p < last; ++p) - { - uint32_t ch = *p; - if (ch < (uint32_t)0x80) { - ++count; - } else if (ch < (uint32_t)0x800) { - count += 2; - } else if (ch < (uint32_t)0x10000) { - count += 3; - } else if (ch <= max_legal_utf32) { - count += 4; - } else { - count += 3; - } - } - return count; -} - -// u32_length - -template -typename std::enable_if::value_type>::value - && (sizeof(typename std::iterator_traits::value_type) == sizeof(uint8_t) || sizeof(typename std::iterator_traits::value_type) == sizeof(uint16_t)), - size_t>::type -u32_length(InputIt first, InputIt last) UNICONS_NOEXCEPT -{ - sequence_generator g(first, last, unicons::conv_flags::strict); - - size_t count = 0; - while (!g.done()) - { - g.next(); - ++count; - } - return count; -} - -template -typename std::enable_if::value_type>::value && sizeof(typename std::iterator_traits::value_type) == sizeof(uint32_t), - size_t>::type -u32_length(InputIt first, InputIt last) UNICONS_NOEXCEPT -{ - return std::distance(first,last); -} - -enum class encoding {u8,u16le,u16be,u32le,u32be,undetected}; - -template -struct detect_encoding_result -{ - Iterator it; - encoding ec; -}; - -template -typename std::enable_if::value_type>::value && sizeof(typename std::iterator_traits::value_type) == sizeof(uint8_t), - detect_encoding_result>::type -detect_encoding(Iterator first, Iterator last) UNICONS_NOEXCEPT -{ - Iterator it1 = first; - if (std::distance(first,last) < 4) - { - if (std::distance(first,last) == 3) - { - Iterator it2 = ++first; - Iterator it3 = ++first; - if (static_cast(*it1) == 0xEF && static_cast(*it2) == 0xBB && static_cast(*it3) == 0xBF) - { - return detect_encoding_result{last,encoding::u8}; - } - } - return detect_encoding_result{it1,encoding::undetected}; - } - else - { - Iterator it2 = ++first; - Iterator it3 = ++first; - Iterator it4 = ++first; - - uint32_t bom = static_cast(*it1) | (static_cast(*it2) << 8) | (static_cast(*it3) << 16) | (static_cast(*it4) << 24); - if (bom == 0xFFFE0000) - { - return detect_encoding_result{it4++,encoding::u32be}; - } - else if (bom == 0x0000FEFF) - { - return detect_encoding_result{first,encoding::u32le}; - } - else if ((bom & 0xFFFF) == 0xFFFE) - { - return detect_encoding_result{it3,encoding::u16be}; - } - else if ((bom & 0xFFFF) == 0xFEFF) - { - return detect_encoding_result{it3,encoding::u16le}; - } - else if ((bom & 0xFFFFFF) == 0xBFBBEF) - { - return detect_encoding_result{it4,encoding::u8}; - } - else - { - uint32_t pattern = (static_cast(*it1) ? 1 : 0) | (static_cast(*it2) ? 2 : 0) | (static_cast(*it3) ? 4 : 0) | (static_cast(*it4) ? 8 : 0); - switch (pattern) { - case 0x08: - return detect_encoding_result{it1,encoding::u32be}; - case 0x0A: - return detect_encoding_result{it1,encoding::u16be}; - case 0x01: - return detect_encoding_result{it1,encoding::u32le}; - case 0x05: - return detect_encoding_result{it1,encoding::u16le}; - case 0x0F: - return detect_encoding_result{it1,encoding::u8}; - default: - return detect_encoding_result{it1,encoding::undetected}; - } - } - } -} - -template -struct skip_bom_result -{ - Iterator it; - encoding_errc ec; -}; - -template -typename std::enable_if::value_type>::value && sizeof(typename std::iterator_traits::value_type) == sizeof(uint8_t), - skip_bom_result>::type -skip_bom(Iterator first, Iterator last) UNICONS_NOEXCEPT -{ - auto result = unicons::detect_encoding(first,last); - switch (result.ec) - { - case unicons::encoding::u8: - return skip_bom_result{result.it,encoding_errc()}; - break; - case unicons::encoding::u16le: - case unicons::encoding::u16be: - return skip_bom_result{result.it,encoding_errc::expected_u8_found_u16}; - break; - case unicons::encoding::u32le: - case unicons::encoding::u32be: - return skip_bom_result{result.it,encoding_errc::expected_u8_found_u32}; - break; - default: - return skip_bom_result{result.it,encoding_errc()}; - break; - } -} - -template -typename std::enable_if::value_type>::value && sizeof(typename std::iterator_traits::value_type) == sizeof(uint16_t), - skip_bom_result>::type -skip_bom(Iterator first, Iterator last) UNICONS_NOEXCEPT -{ - if (first == last) - { - return skip_bom_result{first,encoding_errc()}; - } - uint16_t bom = static_cast(*first); - if (bom == 0xFEFF) - { - return skip_bom_result{++first,encoding_errc()}; - } - else if (bom == 0xFFFE) - { - return skip_bom_result{last,encoding_errc::expected_u16_found_fffe}; - } - else - { - return skip_bom_result{first,encoding_errc()}; - } -} - -template -typename std::enable_if::value_type>::value && sizeof(typename std::iterator_traits::value_type) == sizeof(uint32_t), - skip_bom_result>::type -skip_bom(Iterator first, Iterator last) UNICONS_NOEXCEPT -{ - if (first == last) - { - return skip_bom_result{first,encoding_errc()}; - } - uint32_t bom = static_cast(*first); - if (bom == 0xFEFF0000) - { - return skip_bom_result{++first,encoding_errc()}; - } - else if (bom == 0xFFFE0000) - { - return skip_bom_result{last,encoding_errc::expected_u32_found_fffe}; - } - else - { - return skip_bom_result{first,encoding_errc()}; - } -} - -} // unicons -} // jsoncons - -namespace std { - template<> - struct is_error_code_enum : public true_type - { - }; - template<> - struct is_error_code_enum : public true_type - { - }; -} - -#endif - diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/bson/bson.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/bson/bson.hpp deleted file mode 100644 index 7d14eda0c4..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/bson/bson.hpp +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_BSON_BSON_HPP -#define JSONCONS_BSON_BSON_HPP - -#include -#include -#include -#include // std::enable_if -#include // std::basic_istream -#include -#include -#include -#include - -namespace jsoncons { namespace bson { - -// encode_bson - -template -typename std::enable_if::value,void>::type -encode_bson(const T& j, std::vector& v) -{ - typedef typename T::char_type char_type; - bson_bytes_encoder encoder(v); - auto adaptor = make_json_content_handler_adaptor>(encoder); - j.dump(adaptor); -} - -template -typename std::enable_if::value,void>::type -encode_bson(const T& val, std::vector& v) -{ - bson_bytes_encoder encoder(v); - write_to(json(), val, encoder); -} - -template -typename std::enable_if::value,void>::type -encode_bson(const T& j, std::ostream& os) -{ - typedef typename T::char_type char_type; - bson_encoder encoder(os); - auto adaptor = make_json_content_handler_adaptor>(encoder); - j.dump(adaptor); -} - -template -typename std::enable_if::value,void>::type -encode_bson(const T& val, std::ostream& os) -{ - bson_encoder encoder(os); - write_to(json(), val, encoder); -} - -// decode_bson - -template -typename std::enable_if::value,T>::type -decode_bson(const std::vector& v) -{ - jsoncons::json_decoder decoder; - auto adaptor = make_json_content_handler_adaptor(decoder); - basic_bson_reader reader(v, adaptor); - reader.read(); - return decoder.get_result(); -} - -template -typename std::enable_if::value,T>::type -decode_bson(const std::vector& v) -{ - jsoncons::json_decoder decoder; - basic_bson_reader reader(v, decoder); - reader.read(); - return decoder.get_result().template as(); -} - -template -typename std::enable_if::value,T>::type -decode_bson(std::istream& is) -{ - jsoncons::json_decoder decoder; - auto adaptor = make_json_content_handler_adaptor(decoder); - bson_reader reader(is, adaptor); - reader.read(); - return decoder.get_result(); -} - -template -typename std::enable_if::value,T>::type -decode_bson(std::istream& is) -{ - jsoncons::json_decoder decoder; - bson_reader reader(is, decoder); - reader.read(); - return decoder.get_result(); -} - -}} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/bson/bson_detail.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/bson/bson_detail.hpp deleted file mode 100644 index a1b50025eb..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/bson/bson_detail.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_BSON_BSON_DETAIL_HPP -#define JSONCONS_BSON_BSON_DETAIL_HPP - -#include -#include -#include - -namespace jsoncons { namespace bson { namespace detail { - -namespace bson_format -{ - const uint8_t double_cd = 0x01; - const uint8_t string_cd = 0x02; // UTF-8 string - const uint8_t document_cd = 0x03; - const uint8_t array_cd = 0x04; - const uint8_t binary_cd = 0x05; - const uint8_t object_id_cd = 0x07; - const uint8_t bool_cd = 0x08; - const uint8_t datetime_cd = 0x09; - const uint8_t null_cd = 0x0a; - const uint8_t regex_cd = 0x0b; - const uint8_t javascript_cd = 0x0d; - const uint8_t javascript_with_scope_cd = 0x0f; - const uint8_t int32_cd = 0x10; - const uint8_t timestamp_cd = 0x11; // MongoDB internal Timestamp, uint64 - const uint8_t int64_cd = 0x12; - const uint8_t decimal128_cd = 0x13; - const uint8_t min_key_cd = 0xff; - const uint8_t max_key_cd = 0x7f; -} - -enum class bson_container_type {document, array}; - -}}} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/bson/bson_encoder.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/bson/bson_encoder.hpp deleted file mode 100644 index 4161bb2505..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/bson/bson_encoder.hpp +++ /dev/null @@ -1,342 +0,0 @@ -// Copyright 2018 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_BSON_BSON_ENCODER_HPP -#define JSONCONS_BSON_BSON_ENCODER_HPP - -#include -#include -#include // std::numeric_limits -#include -#include // std::move -#include -#include -#include -#include -#include -#include - -namespace jsoncons { namespace bson { - -template -class basic_bson_encoder final : public basic_json_content_handler -{ - enum class decimal_parse_state { start, integer, exp1, exp2, fraction1 }; -public: - typedef char char_type; - using typename basic_json_content_handler::string_view_type; - typedef Result result_type; - -private: - struct stack_item - { - jsoncons::bson::detail::bson_container_type type_; - size_t offset_; - size_t name_offset_; - size_t index_; - - stack_item(jsoncons::bson::detail::bson_container_type type, size_t offset) - : type_(type), offset_(offset), name_offset_(0), index_(0) - { - } - - size_t offset() const - { - return offset_; - } - - size_t member_offset() const - { - return name_offset_; - } - - void member_offset(size_t offset) - { - name_offset_ = offset; - } - - size_t next_index() - { - return index_++; - } - - bool is_object() const - { - return type_ == jsoncons::bson::detail::bson_container_type::document; - } - - - }; - - std::vector stack_; - std::vector buffer_; - result_type result_; - - // Noncopyable and nonmoveable - basic_bson_encoder(const basic_bson_encoder&) = delete; - basic_bson_encoder& operator=(const basic_bson_encoder&) = delete; -public: - explicit basic_bson_encoder(result_type result) - : result_(std::move(result)) - { - } - - ~basic_bson_encoder() - { - try - { - result_.flush(); - } - catch (...) - { - } - } - -private: - // Implementing methods - - void do_flush() override - { - result_.flush(); - } - - bool do_begin_object(semantic_tag, const ser_context&) override - { - if (buffer_.size() > 0) - { - before_value(jsoncons::bson::detail::bson_format::document_cd); - } - stack_.emplace_back(jsoncons::bson::detail::bson_container_type::document, buffer_.size()); - buffer_.insert(buffer_.end(), sizeof(int32_t), 0); - - return true; - } - - bool do_end_object(const ser_context&) override - { - JSONCONS_ASSERT(!stack_.empty()); - - buffer_.push_back(0x00); - - size_t length = buffer_.size() - stack_.back().offset(); - jsoncons::detail::to_little_endian(static_cast(length), buffer_.begin()+stack_.back().offset()); - - stack_.pop_back(); - if (stack_.empty()) - { - for (auto c : buffer_) - { - result_.push_back(c); - } - } - return true; - } - - bool do_begin_array(semantic_tag, const ser_context&) override - { - if (buffer_.size() > 0) - { - before_value(jsoncons::bson::detail::bson_format::array_cd); - } - stack_.emplace_back(jsoncons::bson::detail::bson_container_type::array, buffer_.size()); - buffer_.insert(buffer_.end(), sizeof(int32_t), 0); - return true; - } - - bool do_end_array(const ser_context&) override - { - JSONCONS_ASSERT(!stack_.empty()); - - buffer_.push_back(0x00); - - size_t length = buffer_.size() - stack_.back().offset(); - jsoncons::detail::to_little_endian(static_cast(length), buffer_.begin()+stack_.back().offset()); - - stack_.pop_back(); - if (stack_.empty()) - { - for (auto c : buffer_) - { - result_.push_back(c); - } - } - return true; - } - - bool do_name(const string_view_type& name, const ser_context&) override - { - stack_.back().member_offset(buffer_.size()); - buffer_.push_back(0x00); // reserve space for code - for (auto c : name) - { - buffer_.push_back(c); - } - buffer_.push_back(0x00); - return true; - } - - bool do_null_value(semantic_tag, const ser_context&) override - { - before_value(jsoncons::bson::detail::bson_format::null_cd); - return true; - } - - bool do_bool_value(bool val, semantic_tag, const ser_context&) override - { - before_value(jsoncons::bson::detail::bson_format::bool_cd); - if (val) - { - buffer_.push_back(0x01); - } - else - { - buffer_.push_back(0x00); - } - - return true; - } - - bool do_string_value(const string_view_type& sv, semantic_tag, const ser_context&) override - { - before_value(jsoncons::bson::detail::bson_format::string_cd); - - size_t offset = buffer_.size(); - buffer_.insert(buffer_.end(), sizeof(int32_t), 0); - size_t string_offset = buffer_.size(); - - auto result = unicons::validate(sv.begin(), sv.end()); - if (result.ec != unicons::conv_errc()) - { - JSONCONS_THROW(json_runtime_error("Illegal unicode")); - } - for (auto c : sv) - { - buffer_.push_back(c); - } - buffer_.push_back(0x00); - size_t length = buffer_.size() - string_offset; - jsoncons::detail::to_little_endian(static_cast(length), buffer_.begin()+offset); - - return true; - } - - bool do_byte_string_value(const byte_string_view& b, - semantic_tag, - const ser_context&) override - { - before_value(jsoncons::bson::detail::bson_format::binary_cd); - - size_t offset = buffer_.size(); - buffer_.insert(buffer_.end(), sizeof(int32_t), 0); - size_t string_offset = buffer_.size(); - - for (auto c : b) - { - buffer_.push_back(c); - } - size_t length = buffer_.size() - string_offset; - jsoncons::detail::to_little_endian(static_cast(length), buffer_.begin()+offset); - - return true; - } - - bool do_int64_value(int64_t val, - semantic_tag tag, - const ser_context&) override - { - if (tag == semantic_tag::timestamp) - { - before_value(jsoncons::bson::detail::bson_format::datetime_cd); - } - else - { - before_value(jsoncons::bson::detail::bson_format::int64_cd); - } - if (val >= (std::numeric_limits::lowest)() && val <= (std::numeric_limits::max)()) - { - jsoncons::detail::to_little_endian(static_cast(val),std::back_inserter(buffer_)); - } - else if (val >= (std::numeric_limits::lowest)() && val <= (std::numeric_limits::max)()) - { - jsoncons::detail::to_little_endian(static_cast(val),std::back_inserter(buffer_)); - } - else - { - // error - } - - return true; - } - - bool do_uint64_value(uint64_t val, - semantic_tag tag, - const ser_context&) override - { - if (tag == semantic_tag::timestamp) - { - before_value(jsoncons::bson::detail::bson_format::datetime_cd); - } - else - { - before_value(jsoncons::bson::detail::bson_format::int64_cd); - } - if (val <= (std::numeric_limits::max)()) - { - jsoncons::detail::to_little_endian(static_cast(val),std::back_inserter(buffer_)); - } - else if (val <= (uint64_t)(std::numeric_limits::max)()) - { - jsoncons::detail::to_little_endian(static_cast(val),std::back_inserter(buffer_)); - } - else - { - // error - } - - return true; - } - - bool do_double_value(double val, - semantic_tag, - const ser_context&) override - { - before_value(jsoncons::bson::detail::bson_format::double_cd); - - jsoncons::detail::to_little_endian(val,std::back_inserter(buffer_)); - - return true; - } - - void before_value(uint8_t code) - { - if (stack_.back().is_object()) - { - buffer_[stack_.back().member_offset()] = code; - } - else - { - buffer_.push_back(code); - std::string name = std::to_string(stack_.back().next_index()); - buffer_.insert(buffer_.end(), name.begin(), name.end()); - buffer_.push_back(0x00); - } - } -}; - -typedef basic_bson_encoder bson_encoder; -typedef basic_bson_encoder bson_bytes_encoder; - -#if !defined(JSONCONS_NO_DEPRECATED) -template -using basic_bson_serializer = basic_bson_encoder; - -typedef basic_bson_encoder bson_serializer; -typedef basic_bson_encoder bson_buffer_serializer; - -#endif - -}} -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/bson/bson_error.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/bson/bson_error.hpp deleted file mode 100644 index 47204f67e9..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/bson/bson_error.hpp +++ /dev/null @@ -1,70 +0,0 @@ -/// Copyright 2018 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_BSON_BSON_ERROR_HPP -#define JSONCONS_BSON_BSON_ERROR_HPP - -#include -#include - -namespace jsoncons { namespace bson { - -enum class bson_errc -{ - ok = 0, - unexpected_eof = 1, - source_error, - invalid_utf8_text_string -}; - -class bson_error_category_impl - : public std::error_category -{ -public: - const char* name() const noexcept override - { - return "jsoncons/bson"; - } - std::string message(int ev) const override - { - switch (static_cast(ev)) - { - case bson_errc::unexpected_eof: - return "Unexpected end of file"; - case bson_errc::source_error: - return "Source error"; - case bson_errc::invalid_utf8_text_string: - return "Illegal UTF-8 encoding in text string"; - default: - return "Unknown BSON parser error"; - } - } -}; - -inline -const std::error_category& bson_error_category() -{ - static bson_error_category_impl instance; - return instance; -} - -inline -std::error_code make_error_code(bson_errc result) -{ - return std::error_code(static_cast(result),bson_error_category()); -} - - -}} - -namespace std { - template<> - struct is_error_code_enum : public true_type - { - }; -} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/bson/bson_reader.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/bson/bson_reader.hpp deleted file mode 100644 index f0d3d1b458..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/bson/bson_reader.hpp +++ /dev/null @@ -1,297 +0,0 @@ -// Copyright 2017 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_BSON_BSON_READER_HPP -#define JSONCONS_BSON_BSON_READER_HPP - -#include -#include -#include -#include // std::move -#include -#include -#include -#include -#include -#include - -namespace jsoncons { namespace bson { - -template -class basic_bson_reader : public ser_context -{ - Src source_; - json_content_handler& handler_; - size_t nesting_depth_; -public: - template - basic_bson_reader(Source&& source, json_content_handler& handler) - : source_(std::forward(source)), - handler_(handler), - nesting_depth_(0) - { - } - - void read() - { - std::error_code ec; - read(ec); - if (ec) - { - throw ser_error(ec,line(),column()); - } - } - - void read(std::error_code& ec) - { - try - { - if (source_.is_error()) - { - ec = bson_errc::source_error; - return; - } - uint8_t buf[sizeof(int32_t)]; - if (source_.read(buf, sizeof(int32_t)) != sizeof(int32_t)) - { - ec = bson_errc::unexpected_eof; - return; - } - const uint8_t* endp; - /* auto len = */jsoncons::detail::from_little_endian(buf, buf+sizeof(int32_t),&endp); - - handler_.begin_object(semantic_tag::none, *this); - ++nesting_depth_; - read_e_list(jsoncons::bson::detail::bson_container_type::document, ec); - handler_.end_object(*this); - --nesting_depth_; - } - catch (const ser_error& e) - { - ec = e.code(); - } - } - - size_t line() const override - { - return 0; - } - - size_t column() const override - { - return source_.position(); - } -private: - - void read_e_list(jsoncons::bson::detail::bson_container_type type, std::error_code& ec) - { - uint8_t t{}; - while (source_.get(t) > 0 && t != 0x00) - { - std::basic_string s; - uint8_t c{}; - while (source_.get(c) > 0 && c != 0) - { - s.push_back(c); - } - - if (type == jsoncons::bson::detail::bson_container_type::document) - { - auto result = unicons::validate(s.begin(),s.end()); - if (result.ec != unicons::conv_errc()) - { - ec = bson_errc::invalid_utf8_text_string; - return; - } - handler_.name(basic_string_view(s.data(),s.length()), *this); - } - read_internal(t, ec); - } - } - - void read_internal(uint8_t type, std::error_code& ec) - { - switch (type) - { - case jsoncons::bson::detail::bson_format::double_cd: - { - uint8_t buf[sizeof(double)]; - if (source_.read(buf, sizeof(double)) != sizeof(double)) - { - ec = bson_errc::unexpected_eof; - return; - } - const uint8_t* endp; - double res = jsoncons::detail::from_little_endian(buf,buf+sizeof(buf),&endp); - handler_.double_value(res, semantic_tag::none, *this); - break; - } - case jsoncons::bson::detail::bson_format::string_cd: - { - uint8_t buf[sizeof(int32_t)]; - if (source_.read(buf, sizeof(int32_t)) != sizeof(int32_t)) - { - ec = bson_errc::unexpected_eof; - return; - } - const uint8_t* endp; - auto len = jsoncons::detail::from_little_endian(buf, buf+sizeof(buf),&endp); - - std::basic_string s; - s.reserve(len - 1); - if ((int32_t)source_.read(std::back_inserter(s), len-1) != len-1) - { - ec = bson_errc::unexpected_eof; - return; - } - uint8_t c{}; - source_.get(c); // discard 0 - auto result = unicons::validate(s.begin(),s.end()); - if (result.ec != unicons::conv_errc()) - { - ec = bson_errc::invalid_utf8_text_string; - return; - } - handler_.string_value(basic_string_view(s.data(),s.length()), semantic_tag::none, *this); - break; - } - case jsoncons::bson::detail::bson_format::document_cd: - { - read(ec); - if (ec) - { - return; - } - break; - } - - case jsoncons::bson::detail::bson_format::array_cd: - { - uint8_t buf[sizeof(int32_t)]; - if (source_.read(buf, sizeof(int32_t)) != sizeof(int32_t)) - { - ec = bson_errc::unexpected_eof; - return; - } - const uint8_t* endp; - /* auto len = */ jsoncons::detail::from_little_endian(buf, buf+sizeof(int32_t),&endp); - - handler_.begin_array(semantic_tag::none, *this); - ++nesting_depth_; - read_e_list(jsoncons::bson::detail::bson_container_type::document, ec); - handler_.end_array(*this); - --nesting_depth_; - break; - } - case jsoncons::bson::detail::bson_format::null_cd: - { - handler_.null_value(semantic_tag::none, *this); - break; - } - case jsoncons::bson::detail::bson_format::bool_cd: - { - uint8_t val{}; - if (source_.get(val) == 0) - { - ec = bson_errc::unexpected_eof; - return; - } - handler_.bool_value(val != 0, semantic_tag::none, *this); - break; - } - case jsoncons::bson::detail::bson_format::int32_cd: - { - uint8_t buf[sizeof(int32_t)]; - if (source_.read(buf, sizeof(int32_t)) != sizeof(int32_t)) - { - ec = bson_errc::unexpected_eof; - return; - } - const uint8_t* endp; - auto val = jsoncons::detail::from_little_endian(buf, buf+sizeof(int32_t),&endp); - handler_.int64_value(val, semantic_tag::none, *this); - break; - } - - case jsoncons::bson::detail::bson_format::timestamp_cd: - { - uint8_t buf[sizeof(uint64_t)]; - if (source_.read(buf, sizeof(uint64_t)) != sizeof(uint64_t)) - { - ec = bson_errc::unexpected_eof; - return; - } - const uint8_t* endp; - auto val = jsoncons::detail::from_little_endian(buf, buf+sizeof(uint64_t),&endp); - handler_.uint64_value(val, semantic_tag::timestamp, *this); - break; - } - - case jsoncons::bson::detail::bson_format::int64_cd: - { - uint8_t buf[sizeof(int64_t)]; - if (source_.read(buf, sizeof(int64_t)) != sizeof(int64_t)) - { - ec = bson_errc::unexpected_eof; - return; - } - const uint8_t* endp; - auto val = jsoncons::detail::from_little_endian(buf, buf+sizeof(int64_t),&endp); - handler_.int64_value(val, semantic_tag::none, *this); - break; - } - - case jsoncons::bson::detail::bson_format::datetime_cd: - { - uint8_t buf[sizeof(int64_t)]; - if (source_.read(buf, sizeof(int64_t)) != sizeof(int64_t)) - { - ec = bson_errc::unexpected_eof; - return; - } - const uint8_t* endp; - auto val = jsoncons::detail::from_little_endian(buf, buf+sizeof(int64_t),&endp); - handler_.int64_value(val, semantic_tag::timestamp, *this); - break; - } - case jsoncons::bson::detail::bson_format::binary_cd: - { - uint8_t buf[sizeof(int32_t)]; - if (source_.read(buf, sizeof(int32_t)) != sizeof(int32_t)) - { - ec = bson_errc::unexpected_eof; - return; - } - const uint8_t* endp; - const auto len = jsoncons::detail::from_little_endian(buf, buf+sizeof(int32_t),&endp); - - std::vector v(len, 0); - if (source_.read(v.data(), v.size()) != v.size()) - { - ec = bson_errc::unexpected_eof; - return; - } - - handler_.byte_string_value(byte_string_view(v.data(),v.size()), - semantic_tag::none, - *this); - break; - } - } - - } -}; - -typedef basic_bson_reader bson_reader; -typedef basic_bson_reader bson_bytes_reader; - -#if !defined(JSONCONS_NO_DEPRECATED) -typedef bson_bytes_reader bson_buffer_reader; -#endif - -}} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/cbor/cbor.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/cbor/cbor.hpp deleted file mode 100644 index c05b3c2439..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/cbor/cbor.hpp +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright 2017 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_CBOR_CBOR_HPP -#define JSONCONS_CBOR_CBOR_HPP - -#include -#include -#include -#include // std::enable_if -#include // std::basic_istream -#include -#include -#include -#include -#include - -namespace jsoncons { namespace cbor { - -// encode_cbor - -template -void encode_cbor(const T& j, std::vector& v) -{ - encode_cbor(j,v,cbor_options::default_options()); -} - -template -void encode_cbor(const T& j, std::ostream& os) -{ - encode_cbor(j,os,cbor_options::default_options()); -} - -template -typename std::enable_if::value,void>::type -encode_cbor(const T& j, std::vector& v, const cbor_encode_options& options) -{ - typedef typename T::char_type char_type; - cbor_bytes_encoder encoder(v, options); - auto adaptor = make_json_content_handler_adaptor>(encoder); - j.dump(adaptor); -} - -template -typename std::enable_if::value,void>::type -encode_cbor(const T& val, std::vector& v, const cbor_encode_options& options) -{ - cbor_bytes_encoder encoder(v, options); - write_to(json(), val, encoder); -} - -template -typename std::enable_if::value,void>::type -encode_cbor(const T& j, std::ostream& os, const cbor_encode_options& options) -{ - typedef typename T::char_type char_type; - cbor_encoder encoder(os, options); - auto adaptor = make_json_content_handler_adaptor>(encoder); - j.dump(adaptor); -} - -template -typename std::enable_if::value,void>::type -encode_cbor(const T& val, std::ostream& os, const cbor_encode_options& options) -{ - cbor_encoder encoder(os, options); - write_to(json(), val, encoder); -} - -// decode_cbor - -template -typename std::enable_if::value,T>::type -decode_cbor(const std::vector& v) -{ - jsoncons::json_decoder decoder; - auto adaptor = make_json_content_handler_adaptor(decoder); - basic_cbor_reader reader(v, adaptor); - reader.read(); - return decoder.get_result(); -} - -template -typename std::enable_if::value,T>::type -decode_cbor(const std::vector& v) -{ - jsoncons::json_decoder decoder; - basic_cbor_reader reader(v, decoder); - reader.read(); - return decoder.get_result().template as(); -} - -template -typename std::enable_if::value,T>::type -decode_cbor(std::istream& is) -{ - jsoncons::json_decoder decoder; - auto adaptor = make_json_content_handler_adaptor(decoder); - cbor_reader reader(is, adaptor); - reader.read(); - return decoder.get_result(); -} - -template -typename std::enable_if::value,T>::type -decode_cbor(std::istream& is) -{ - jsoncons::json_decoder decoder; - cbor_reader reader(is, decoder); - reader.read(); - return decoder.get_result().template as(); -} - - -#if !defined(JSONCONS_NO_DEPRECATED) -template -std::vector encode_cbor(const Json& j) -{ - std::vector v; - encode_cbor(j, v); - return v; -} -#endif - -}} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/cbor/cbor_detail.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/cbor/cbor_detail.hpp deleted file mode 100644 index d59397bd27..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/cbor/cbor_detail.hpp +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2017 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_CBOR_CBOR_DETAIL_HPP -#define JSONCONS_CBOR_CBOR_DETAIL_HPP - -#include -#include -#include -#include // std::forward_iterator_tag -#include // std::numeric_limits -#include // std::move -#include -#include -#include - -namespace jsoncons { namespace cbor { namespace detail { - -// 0x00..0x17 (0..23) -#define JSONCONS_CBOR_0x00_0x17 \ - 0x00:case 0x01:case 0x02:case 0x03:case 0x04:case 0x05:case 0x06:case 0x07:case 0x08:case 0x09:case 0x0a:case 0x0b:case 0x0c:case 0x0d:case 0x0e:case 0x0f:case 0x10:case 0x11:case 0x12:case 0x13:case 0x14:case 0x15:case 0x16:case 0x17 - -enum class cbor_major_type : uint8_t -{ - unsigned_integer = 0x00, - negative_integer = 0x01, - byte_string = 0x02, - text_string = 0x03, - array = 0x04, - map = 0x05, - semantic_tag = 0x06, - simple = 0x7 -}; - -namespace additional_info -{ - const uint8_t indefinite_length = 0x1f; -} - -inline -size_t min_length_for_stringref(uint64_t index) -{ - size_t n; - if (index <= 23) - { - n = 3; - } - else if (index <= 255) - { - n = 4; - } - else if (index <= 65535) - { - n = 5; - } - else if (index <= 4294967295) - { - n = 7; - } - else - { - n = 11; - } - return n; -} - -}}} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/cbor/cbor_encoder.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/cbor/cbor_encoder.hpp deleted file mode 100644 index 6fb3ad185a..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/cbor/cbor_encoder.hpp +++ /dev/null @@ -1,1062 +0,0 @@ -// Copyright 2018 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_CBOR_CBOR_ENCODER_HPP -#define JSONCONS_CBOR_CBOR_ENCODER_HPP - -#include -#include -#include // std::numeric_limits -#include -#include // std::move -#include // jsoncons::ser_error -#include -#include -#include -#include -#include -#include - -namespace jsoncons { namespace cbor { - -enum class cbor_container_type {object, indefinite_length_object, array, indefinite_length_array}; - -template -class basic_cbor_encoder final : public basic_json_content_handler -{ - enum class decimal_parse_state { start, integer, exp1, exp2, fraction1 }; - enum class hexfloat_parse_state { start, expect_0, expect_x, integer, exp1, exp2, fraction1 }; - -public: - typedef char char_type; - typedef Result result_type; - using typename basic_json_content_handler::string_view_type; - -private: - struct stack_item - { - cbor_container_type type_; - size_t length_; - size_t count_; - - stack_item(cbor_container_type type, size_t length = 0) - : type_(type), length_(length), count_(0) - { - } - - size_t length() const - { - return length_; - } - - size_t count() const - { - return count_; - } - - bool is_object() const - { - return type_ == cbor_container_type::object || type_ == cbor_container_type::indefinite_length_object; - } - - bool is_indefinite_length() const - { - return type_ == cbor_container_type::indefinite_length_array || type_ == cbor_container_type::indefinite_length_object; - } - - }; - std::vector stack_; - Result result_; - const cbor_encode_options& options_; - - // Noncopyable and nonmoveable - basic_cbor_encoder(const basic_cbor_encoder&) = delete; - basic_cbor_encoder& operator=(const basic_cbor_encoder&) = delete; - - std::map stringref_map_; - std::map bytestringref_map_; - size_t next_stringref_ = 0; -public: - explicit basic_cbor_encoder(result_type result) - : result_(std::move(result)), options_(cbor_options::default_options()) - { - } - basic_cbor_encoder(result_type result, const cbor_encode_options& options) - : result_(std::move(result)), options_(options) - { - if (options.pack_strings()) - { - // tag(256) - result_.push_back(0xd9); - result_.push_back(0x01); - result_.push_back(0x00); - } - } - - ~basic_cbor_encoder() - { - try - { - result_.flush(); - } - catch (...) - { - } - } - -private: - // Implementing methods - - void do_flush() override - { - result_.flush(); - } - - bool do_begin_object(semantic_tag, const ser_context&) override - { - stack_.push_back(stack_item(cbor_container_type::indefinite_length_object)); - - result_.push_back(0xbf); - return true; - } - - bool do_begin_object(size_t length, semantic_tag, const ser_context&) override - { - stack_.push_back(stack_item(cbor_container_type::object, length)); - - if (length <= 0x17) - { - jsoncons::detail::to_big_endian(static_cast(0xa0 + length), - std::back_inserter(result_)); - } - else if (length <= 0xff) - { - jsoncons::detail::to_big_endian(static_cast(0xb8), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(length), - std::back_inserter(result_)); - } - else if (length <= 0xffff) - { - jsoncons::detail::to_big_endian(static_cast(0xb9), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(length), - std::back_inserter(result_)); - } - else if (length <= 0xffffffff) - { - jsoncons::detail::to_big_endian(static_cast(0xba), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(length), - std::back_inserter(result_)); - } - else if (length <= 0xffffffffffffffff) - { - jsoncons::detail::to_big_endian(static_cast(0xbb), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(length), - std::back_inserter(result_)); - } - - return true; - } - - bool do_end_object(const ser_context&) override - { - JSONCONS_ASSERT(!stack_.empty()); - if (stack_.back().is_indefinite_length()) - { - result_.push_back(0xff); - } - else - { - if (stack_.back().count() < stack_.back().length()) - { - throw ser_error(cbor_errc::too_few_items); - } - if (stack_.back().count() > stack_.back().length()) - { - throw ser_error(cbor_errc::too_many_items); - } - } - - stack_.pop_back(); - end_value(); - - return true; - } - - bool do_begin_array(semantic_tag, const ser_context&) override - { - stack_.push_back(stack_item(cbor_container_type::indefinite_length_array)); - result_.push_back(0x9f); - return true; - } - - bool do_begin_array(size_t length, semantic_tag tag, const ser_context&) override - { -#if !defined(JSONCONS_NO_DEPRECATED) - if (length == 2 && tag == semantic_tag::bigfloat) - { - result_.push_back(0xc5); - } -#endif - stack_.push_back(stack_item(cbor_container_type::array, length)); - if (length <= 0x17) - { - jsoncons::detail::to_big_endian(static_cast(0x80 + length), - std::back_inserter(result_)); - } - else if (length <= 0xff) - { - jsoncons::detail::to_big_endian(static_cast(0x98), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(length), - std::back_inserter(result_)); - } - else if (length <= 0xffff) - { - jsoncons::detail::to_big_endian(static_cast(0x99), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(length), - std::back_inserter(result_)); - } - else if (length <= 0xffffffff) - { - jsoncons::detail::to_big_endian(static_cast(0x9a), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(length), - std::back_inserter(result_)); - } - else if (length <= 0xffffffffffffffff) - { - jsoncons::detail::to_big_endian(static_cast(0x9b), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(length), - std::back_inserter(result_)); - } - return true; - } - - bool do_end_array(const ser_context&) override - { - JSONCONS_ASSERT(!stack_.empty()); - - if (stack_.back().is_indefinite_length()) - { - result_.push_back(0xff); - } - else - { - if (stack_.back().count() < stack_.back().length()) - { - throw ser_error(cbor_errc::too_few_items); - } - if (stack_.back().count() > stack_.back().length()) - { - throw ser_error(cbor_errc::too_many_items); - } - } - - stack_.pop_back(); - end_value(); - - return true; - } - - bool do_name(const string_view_type& name, const ser_context&) override - { - write_string(name); - return true; - } - - bool do_null_value(semantic_tag tag, const ser_context&) override - { - if (tag == semantic_tag::undefined) - { - result_.push_back(0xf7); - } - else - { - result_.push_back(0xf6); - } - - end_value(); - return true; - } - - void write_string(const string_view& sv) - { - auto result = unicons::validate(sv.begin(), sv.end()); - if (result.ec != unicons::conv_errc()) - { - JSONCONS_THROW(json_runtime_error("Illegal unicode")); - } - - if (options_.pack_strings() && sv.size() >= jsoncons::cbor::detail::min_length_for_stringref(next_stringref_)) - { - std::string s(sv); - auto it = stringref_map_.find(s); - if (it == stringref_map_.end()) - { - stringref_map_.insert(std::make_pair(std::move(s), next_stringref_++)); - write_utf8_string(sv); - } - else - { - // tag(25) - result_.push_back(0xd8); - result_.push_back(0x19); - write_uint64_value(it->second); - } - } - else - { - write_utf8_string(sv); - } - } - - void write_utf8_string(const string_view& sv) - { - const size_t length = sv.size(); - - if (length <= 0x17) - { - // fixstr stores a byte array whose length is upto 31 bytes - jsoncons::detail::to_big_endian(static_cast(0x60 + length), - std::back_inserter(result_)); - } - else if (length <= 0xff) - { - jsoncons::detail::to_big_endian(static_cast(0x78), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(length), - std::back_inserter(result_)); - } - else if (length <= 0xffff) - { - jsoncons::detail::to_big_endian(static_cast(0x79), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(length), - std::back_inserter(result_)); - } - else if (length <= 0xffffffff) - { - jsoncons::detail::to_big_endian(static_cast(0x7a), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(length), - std::back_inserter(result_)); - } - else if (length <= 0xffffffffffffffff) - { - jsoncons::detail::to_big_endian(static_cast(0x7b), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(length), - std::back_inserter(result_)); - } - - for (auto c : sv) - { - result_.push_back(c); - } - } - - void write_bignum(const bignum& n) - { - int signum; - std::vector data; - n.dump(signum, data); - size_t length = data.size(); - - if (signum == -1) - { - result_.push_back(0xc3); - } - else - { - result_.push_back(0xc2); - } - - if (length <= 0x17) - { - // fixstr stores a byte array whose length is upto 31 bytes - jsoncons::detail::to_big_endian(static_cast(0x40 + length), - std::back_inserter(result_)); - } - else if (length <= 0xff) - { - jsoncons::detail::to_big_endian(static_cast(0x58), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(length), - std::back_inserter(result_)); - } - else if (length <= 0xffff) - { - jsoncons::detail::to_big_endian(static_cast(0x59), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(length), - std::back_inserter(result_)); - } - else if (length <= 0xffffffff) - { - jsoncons::detail::to_big_endian(static_cast(0x5a), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(length), - std::back_inserter(result_)); - } - else if (length <= 0xffffffffffffffff) - { - jsoncons::detail::to_big_endian(static_cast(0x5b), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(length), - std::back_inserter(result_)); - } - - for (auto c : data) - { - result_.push_back(c); - } - } - - void write_decimal_value(const string_view_type& sv, const ser_context& context) - { - decimal_parse_state state = decimal_parse_state::start; - std::basic_string s; - std::basic_string exponent; - int64_t scale = 0; - for (auto c : sv) - { - switch (state) - { - case decimal_parse_state::start: - { - switch (c) - { - case '-': - s.push_back(c); - state = decimal_parse_state::integer; - break; - case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8': case '9': - s.push_back(c); - state = decimal_parse_state::integer; - break; - default: - throw std::invalid_argument("Invalid decimal string"); - } - break; - } - case decimal_parse_state::integer: - { - switch (c) - { - case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8': case '9': - s.push_back(c); - state = decimal_parse_state::integer; - break; - case 'e': case 'E': - state = decimal_parse_state::exp1; - break; - case '.': - state = decimal_parse_state::fraction1; - break; - default: - throw std::invalid_argument("Invalid decimal string"); - } - break; - } - case decimal_parse_state::exp1: - { - switch (c) - { - case '+': - state = decimal_parse_state::exp2; - break; - case '-': - exponent.push_back(c); - state = decimal_parse_state::exp2; - break; - case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8': case '9': - exponent.push_back(c); - state = decimal_parse_state::exp2; - break; - default: - throw std::invalid_argument("Invalid decimal string"); - } - break; - } - case decimal_parse_state::exp2: - { - switch (c) - { - case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8': case '9': - exponent.push_back(c); - break; - default: - throw std::invalid_argument("Invalid decimal string"); - } - break; - } - case decimal_parse_state::fraction1: - { - switch (c) - { - case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8': case '9': - s.push_back(c); - --scale; - break; - default: - throw std::invalid_argument("Invalid decimal string"); - } - break; - } - } - } - - result_.push_back(0xc4); - do_begin_array((size_t)2, semantic_tag::none, context); - if (exponent.length() > 0) - { - auto result = jsoncons::detail::to_integer(exponent.data(), exponent.length()); - if (result.ec != jsoncons::detail::to_integer_errc()) - { - JSONCONS_THROW(json_runtime_error(make_error_code(result.ec).message())); - } - scale += result.value; - } - do_int64_value(scale, semantic_tag::none, context); - - auto result = jsoncons::detail::to_integer(s.data(),s.length()); - if (result.ec == jsoncons::detail::to_integer_errc()) - { - do_int64_value(result.value, semantic_tag::none, context); - } - else if (result.ec == jsoncons::detail::to_integer_errc::overflow) - { - bignum n(s.data(), s.length()); - write_bignum(n); - end_value(); - } - else - { - JSONCONS_THROW(json_runtime_error(make_error_code(result.ec).message())); - } - do_end_array(context); - } - - void write_hexfloat_value(const string_view_type& sv, const ser_context& context) - { - hexfloat_parse_state state = hexfloat_parse_state::start; - std::basic_string s; - std::basic_string exponent; - int64_t scale = 0; - - for (auto c : sv) - { - switch (state) - { - case hexfloat_parse_state::start: - { - switch (c) - { - case '-': - s.push_back(c); - state = hexfloat_parse_state::expect_0; - break; - case '0': - state = hexfloat_parse_state::expect_x; - break; - default: - throw std::invalid_argument("Invalid hexfloat string"); - } - break; - } - case hexfloat_parse_state::expect_0: - { - switch (c) - { - case '0': - state = hexfloat_parse_state::expect_x; - break; - default: - throw std::invalid_argument("Invalid hexfloat string"); - } - break; - } - case hexfloat_parse_state::expect_x: - { - switch (c) - { - case 'x': - case 'X': - state = hexfloat_parse_state::integer; - break; - default: - throw std::invalid_argument("Invalid hexfloat string"); - } - break; - } - case hexfloat_parse_state::integer: - { - switch (c) - { - case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8': case '9':case 'a':case 'b':case 'c':case 'd':case 'e':case 'f':case 'A':case 'B':case 'C':case 'D':case 'E':case 'F': - s.push_back(c); - state = hexfloat_parse_state::integer; - break; - case 'p': case 'P': - state = hexfloat_parse_state::exp1; - break; - case '.': - state = hexfloat_parse_state::fraction1; - break; - default: - throw std::invalid_argument("Invalid hexfloat string"); - } - break; - } - case hexfloat_parse_state::exp1: - { - switch (c) - { - case '+': - state = hexfloat_parse_state::exp2; - break; - case '-': - exponent.push_back(c); - state = hexfloat_parse_state::exp2; - break; - case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8': case '9':case 'a':case 'b':case 'c':case 'd':case 'e':case 'f':case 'A':case 'B':case 'C':case 'D':case 'E':case 'F': - exponent.push_back(c); - state = hexfloat_parse_state::exp2; - break; - default: - throw std::invalid_argument("Invalid hexfloat string"); - } - break; - } - case hexfloat_parse_state::exp2: - { - switch (c) - { - case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8': case '9':case 'a':case 'b':case 'c':case 'd':case 'e':case 'f':case 'A':case 'B':case 'C':case 'D':case 'E':case 'F': - exponent.push_back(c); - break; - default: - throw std::invalid_argument("Invalid hexfloat string"); - } - break; - } - case hexfloat_parse_state::fraction1: - { - switch (c) - { - case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8': case '9':case 'a':case 'b':case 'c':case 'd':case 'e':case 'f':case 'A':case 'B':case 'C':case 'D':case 'E':case 'F': - s.push_back(c); - scale -= 4; - break; - default: - throw std::invalid_argument("Invalid hexfloat string"); - } - break; - } - } - } - - result_.push_back(0xc5); - do_begin_array((size_t)2, semantic_tag::none, context); - if (exponent.length() > 0) - { - auto result = jsoncons::detail::base16_to_integer(exponent.data(), exponent.length()); - if (result.ec != jsoncons::detail::to_integer_errc()) - { - JSONCONS_THROW(json_runtime_error(make_error_code(result.ec).message())); - } - scale += result.value; - } - do_int64_value(scale, semantic_tag::none, context); - - auto result = jsoncons::detail::base16_to_integer(s.data(),s.length()); - if (result.ec == jsoncons::detail::to_integer_errc()) - { - do_int64_value(result.value, semantic_tag::none, context); - } - else if (result.ec == jsoncons::detail::to_integer_errc::overflow) - { - bignum n(s.data(), s.length(), 16); - write_bignum(n); - end_value(); - } - else - { - JSONCONS_THROW(json_runtime_error(make_error_code(result.ec).message())); - } - do_end_array(context); - } - - bool do_string_value(const string_view_type& sv, semantic_tag tag, const ser_context& context) override - { - switch (tag) - { - case semantic_tag::bigint: - { - bignum n(sv.data(), sv.length()); - write_bignum(n); - end_value(); - break; - } - case semantic_tag::bigdec: - { - write_decimal_value(sv, context); - break; - } - case semantic_tag::bigfloat: - { - write_hexfloat_value(sv, context); - break; - } - case semantic_tag::datetime: - { - result_.push_back(0xc0); - write_string(sv); - end_value(); - break; - } - case semantic_tag::uri: - { - result_.push_back(32); - write_string(sv); - end_value(); - break; - } - case semantic_tag::base64url: - { - result_.push_back(33); - write_string(sv); - end_value(); - break; - } - case semantic_tag::base64: - { - result_.push_back(34); - write_string(sv); - end_value(); - break; - } - default: - { - write_string(sv); - end_value(); - break; - } - } - return true; - } - - bool do_byte_string_value(const byte_string_view& b, - semantic_tag tag, - const ser_context&) override - { - byte_string_chars_format encoding_hint; - switch (tag) - { - case semantic_tag::base16: - encoding_hint = byte_string_chars_format::base16; - break; - case semantic_tag::base64: - encoding_hint = byte_string_chars_format::base64; - break; - case semantic_tag::base64url: - encoding_hint = byte_string_chars_format::base64url; - break; - default: - encoding_hint = byte_string_chars_format::none; - break; - } - switch (encoding_hint) - { - case byte_string_chars_format::base64url: - result_.push_back(0xd5); - break; - case byte_string_chars_format::base64: - result_.push_back(0xd6); - break; - case byte_string_chars_format::base16: - result_.push_back(0xd7); - break; - default: - break; - } - if (options_.pack_strings() && b.length() >= jsoncons::cbor::detail::min_length_for_stringref(next_stringref_)) - { - auto it = bytestringref_map_.find(byte_string(b)); - if (it == bytestringref_map_.end()) - { - bytestringref_map_.insert(std::make_pair(byte_string(b), next_stringref_++)); - write_byte_string_value(b); - } - else - { - // tag(25) - result_.push_back(0xd8); - result_.push_back(0x19); - write_uint64_value(it->second); - } - } - else - { - write_byte_string_value(b); - } - - end_value(); - return true; - } - - void write_byte_string_value(const byte_string_view& b) - { - if (b.length() <= 0x17) - { - // fixstr stores a byte array whose length is upto 31 bytes - jsoncons::detail::to_big_endian(static_cast(0x40 + b.length()), - std::back_inserter(result_)); - } - else if (b.length() <= 0xff) - { - jsoncons::detail::to_big_endian(static_cast(0x58), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(b.length()), - std::back_inserter(result_)); - } - else if (b.length() <= 0xffff) - { - jsoncons::detail::to_big_endian(static_cast(0x59), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(b.length()), - std::back_inserter(result_)); - } - else if (b.length() <= 0xffffffff) - { - jsoncons::detail::to_big_endian(static_cast(0x5a), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(b.length()), - std::back_inserter(result_)); - } - else if (b.length() <= 0xffffffffffffffff) - { - jsoncons::detail::to_big_endian(static_cast(0x5b), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(b.length()), - std::back_inserter(result_)); - } - - for (auto c : b) - { - result_.push_back(c); - } - } - - bool do_double_value(double val, - semantic_tag tag, - const ser_context&) override - { - if (tag == semantic_tag::timestamp) - { - result_.push_back(0xc1); - } - - float valf = (float)val; - if ((double)valf == val) - { - jsoncons::detail::to_big_endian(static_cast(0xfa), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(valf, std::back_inserter(result_)); - } - else - { - jsoncons::detail::to_big_endian(static_cast(0xfb), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(val, std::back_inserter(result_)); - } - - // write double - - end_value(); - return true; - } - - bool do_int64_value(int64_t value, - semantic_tag tag, - const ser_context&) override - { - if (tag == semantic_tag::timestamp) - { - result_.push_back(0xc1); - } - if (value >= 0) - { - if (value <= 0x17) - { - jsoncons::detail::to_big_endian(static_cast(value), - std::back_inserter(result_)); - } - else if (value <= (std::numeric_limits::max)()) - { - jsoncons::detail::to_big_endian(static_cast(0x18), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(value), - std::back_inserter(result_)); - } - else if (value <= (std::numeric_limits::max)()) - { - jsoncons::detail::to_big_endian(static_cast(0x19), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(value), - std::back_inserter(result_)); - } - else if (value <= (std::numeric_limits::max)()) - { - jsoncons::detail::to_big_endian(static_cast(0x1a), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(value), - std::back_inserter(result_)); - } - else if (value <= (std::numeric_limits::max)()) - { - jsoncons::detail::to_big_endian(static_cast(0x1b), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(value), - std::back_inserter(result_)); - } - } else - { - const auto posnum = -1 - value; - if (value >= -24) - { - jsoncons::detail::to_big_endian(static_cast(0x20 + posnum), - std::back_inserter(result_)); - } - else if (posnum <= (std::numeric_limits::max)()) - { - jsoncons::detail::to_big_endian(static_cast(0x38), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(posnum), - std::back_inserter(result_)); - } - else if (posnum <= (std::numeric_limits::max)()) - { - jsoncons::detail::to_big_endian(static_cast(0x39), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(posnum), - std::back_inserter(result_)); - } - else if (posnum <= (std::numeric_limits::max)()) - { - jsoncons::detail::to_big_endian(static_cast(0x3a), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(posnum), - std::back_inserter(result_)); - } - else if (posnum <= (std::numeric_limits::max)()) - { - jsoncons::detail::to_big_endian(static_cast(0x3b), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(posnum), - std::back_inserter(result_)); - } - } - end_value(); - return true; - } - - bool do_uint64_value(uint64_t value, - semantic_tag tag, - const ser_context&) override - { - if (tag == semantic_tag::timestamp) - { - result_.push_back(0xc1); - } - - write_uint64_value(value); - end_value(); - return true; - } - - void write_uint64_value(uint64_t value) - { - if (value <= 0x17) - { - jsoncons::detail::to_big_endian(static_cast(value), - std::back_inserter(result_)); - } - else if (value <=(std::numeric_limits::max)()) - { - jsoncons::detail::to_big_endian(static_cast(0x18), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(value), - std::back_inserter(result_)); - } - else if (value <=(std::numeric_limits::max)()) - { - jsoncons::detail::to_big_endian(static_cast(0x19), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(value), - std::back_inserter(result_)); - } - else if (value <=(std::numeric_limits::max)()) - { - jsoncons::detail::to_big_endian(static_cast(0x1a), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(value), - std::back_inserter(result_)); - } - else if (value <=(std::numeric_limits::max)()) - { - jsoncons::detail::to_big_endian(static_cast(0x1b), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(value), - std::back_inserter(result_)); - } - } - - bool do_bool_value(bool value, semantic_tag, const ser_context&) override - { - if (value) - { - result_.push_back(0xf5); - } - else - { - result_.push_back(0xf4); - } - - end_value(); - return true; - } - - void end_value() - { - if (!stack_.empty()) - { - ++stack_.back().count_; - } - } -}; - -typedef basic_cbor_encoder cbor_encoder; -typedef basic_cbor_encoder cbor_bytes_encoder; - -#if !defined(JSONCONS_NO_DEPRECATED) -typedef basic_cbor_encoder cbor_bytes_serializer; - -template -using basic_cbor_serializer = basic_cbor_encoder; - -typedef basic_cbor_encoder cbor_serializer; -typedef basic_cbor_encoder cbor_buffer_serializer; -#endif - -}} -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/cbor/cbor_error.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/cbor/cbor_error.hpp deleted file mode 100644 index 79c3de976f..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/cbor/cbor_error.hpp +++ /dev/null @@ -1,96 +0,0 @@ -/// Copyright 2018 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_CBOR_CBOR_ERROR_HPP -#define JSONCONS_CBOR_CBOR_ERROR_HPP - -#include -#include -#include // jsoncons::ser_error - -namespace jsoncons { namespace cbor { - -enum class cbor_errc -{ - ok = 0, - unexpected_eof, - source_error, - invalid_decimal, - invalid_bigfloat, - invalid_utf8_text_string, - too_many_items, - too_few_items, - number_too_large, - stringref_too_large -}; - -class cbor_error_category_impl - : public std::error_category -{ -public: - const char* name() const noexcept override - { - return "jsoncons/cbor"; - } - std::string message(int ev) const override - { - switch (static_cast(ev)) - { - case cbor_errc::unexpected_eof: - return "Unexpected end of file"; - case cbor_errc::source_error: - return "Source error"; - case cbor_errc::invalid_decimal: - return "Invalid decimal"; - case cbor_errc::invalid_bigfloat: - return "Invalid bigfloat"; - case cbor_errc::invalid_utf8_text_string: - return "Illegal UTF-8 encoding in text string"; - case cbor_errc::too_many_items: - return "Too many items were added to a CBOR map or array of known length"; - case cbor_errc::too_few_items: - return "Too few items were added to a CBOR map or array of known length"; - case cbor_errc::number_too_large: - return "Number exceeds implementation limits"; - case cbor_errc::stringref_too_large: - return "stringref exceeds stringref map size"; - default: - return "Unknown CBOR parser error"; - } - } -}; - -inline -const std::error_category& cbor_error_category() -{ - static cbor_error_category_impl instance; - return instance; -} - -inline -std::error_code make_error_code(cbor_errc e) -{ - return std::error_code(static_cast(e),cbor_error_category()); -} - - -#if !defined(JSONCONS_NO_DEPRECATED) - -typedef ser_error cbor_error; -typedef ser_error cbor_decode_error; -typedef cbor_errc cbor_reader_errc; -#endif - -}} - -namespace std { - template<> - struct is_error_code_enum : public true_type - { - }; -} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/cbor/cbor_options.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/cbor/cbor_options.hpp deleted file mode 100644 index cc780ca80a..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/cbor/cbor_options.hpp +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2019 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_CBOR_CBOR_OPTIONS_HPP -#define JSONCONS_CBOR_CBOR_OPTIONS_HPP - -#include -#include // std::numeric_limits -#include -#include -#include - -namespace jsoncons { namespace cbor { - -class cbor_decode_options -{ -public: - virtual ~cbor_decode_options() = default; -}; - -class cbor_encode_options -{ -public: - virtual ~cbor_encode_options() = default; - - virtual bool pack_strings() const = 0; -}; - -class cbor_options : public virtual cbor_decode_options, - public virtual cbor_encode_options -{ -private: - bool pack_strings_; -public: - - static const cbor_options& default_options() - { - static cbor_options options{}; - return options; - } - - -// Constructors - - cbor_options() - : pack_strings_(false) - { - } - - bool pack_strings() const override - { - return pack_strings_; - } - - cbor_options& pack_strings(bool value) - { - pack_strings_ = value; - return *this; - } -}; - -}} -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/cbor/cbor_reader.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/cbor/cbor_reader.hpp deleted file mode 100644 index cb63bcafd1..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/cbor/cbor_reader.hpp +++ /dev/null @@ -1,1491 +0,0 @@ -// Copyright 2017 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_CBOR_CBOR_READER_HPP -#define JSONCONS_CBOR_CBOR_READER_HPP - -#include -#include -#include -#include // std::move -#include -#include -#include -#include -#include -#include -#include - -namespace jsoncons { namespace cbor { - -enum class parse_mode {root,array,indefinite_array,map,indefinite_map}; - -struct mapped_string -{ - jsoncons::cbor::detail::cbor_major_type type; - std::string s; - std::vector bs; - - mapped_string(const std::string& s) - : type(jsoncons::cbor::detail::cbor_major_type::text_string), s(s) - { - } - - mapped_string(std::string&& s) - : type(jsoncons::cbor::detail::cbor_major_type::text_string), s(std::move(s)) - { - } - - mapped_string(const std::vector& bs) - : type(jsoncons::cbor::detail::cbor_major_type::byte_string), bs(bs) - { - } - - mapped_string(std::vector&& bs) - : type(jsoncons::cbor::detail::cbor_major_type::byte_string), bs(std::move(bs)) - { - } - - mapped_string(const mapped_string&) = default; - - mapped_string(mapped_string&&) = default; - - mapped_string& operator=(const mapped_string&) = default; - - mapped_string& operator=(mapped_string&&) = default; -}; - -typedef std::vector stringref_map_type; - -struct parse_state -{ - parse_mode mode; - size_t length; - size_t index; - std::shared_ptr stringref_map; - - parse_state(parse_mode mode, size_t length) - : mode(mode), length(length), index(0) - { - } - - parse_state(parse_mode mode, size_t length, std::shared_ptr stringref_map) - : mode(mode), length(length), index(0), stringref_map(stringref_map) - { - } - - parse_state(const parse_state&) = default; - parse_state(parse_state&&) = default; -}; - -template -class basic_cbor_reader : public ser_context -{ - Src source_; - json_content_handler& handler_; - std::string buffer_; - std::vector tags_; - std::vector state_stack_; -public: - template - basic_cbor_reader(Source&& source, json_content_handler& handler) - : source_(std::forward(source)), - handler_(handler) - { - } - - void read() - { - std::error_code ec; - read(ec); - if (ec) - { - throw ser_error(ec,line(),column()); - } - } - - void read(std::error_code& ec) - { - if (source_.is_error()) - { - ec = cbor_errc::source_error; - return; - } - try - { - state_stack_.emplace_back(parse_mode::root,0); - read_internal(ec); - if (ec) - { - return; - } - } - catch (const ser_error& e) - { - ec = e.code(); - } - } - - size_t line() const override - { - return 0; - } - - size_t column() const override - { - return source_.position(); - } -private: - - void read_internal(std::error_code& ec) - { - while (!state_stack_.empty()) - { - switch (state_stack_.back().mode) - { - case parse_mode::array: - { - if (state_stack_.back().index < state_stack_.back().length) - { - ++state_stack_.back().index; - read_item(ec); - if (ec) - { - return; - } - } - else - { - end_array(ec); - } - break; - } - case parse_mode::indefinite_array: - { - int c = source_.peek(); - switch (c) - { - case Src::traits_type::eof(): - ec = cbor_errc::unexpected_eof; - return; - case 0xff: - end_array(ec); - if (ec) - { - return; - } - break; - default: - read_item(ec); - if (ec) - { - return; - } - break; - } - break; - } - case parse_mode::map: - { - if (state_stack_.back().index < state_stack_.back().length) - { - ++state_stack_.back().index; - read_name(ec); - if (ec) - { - return; - } - read_item(ec); - if (ec) - { - return; - } - } - else - { - end_map(ec); - } - break; - } - case parse_mode::indefinite_map: - { - int c = source_.peek(); - switch (c) - { - case Src::traits_type::eof(): - ec = cbor_errc::unexpected_eof; - return; - case 0xff: - end_map(ec); - if (ec) - { - return; - } - break; - default: - read_name(ec); - if (ec) - { - return; - } - read_item(ec); - if (ec) - { - return; - } - break; - } - break; - } - case parse_mode::root: - { - read_item(ec); - if (ec) - { - return; - } - } - break; - } - - JSONCONS_ASSERT(!state_stack_.empty()); - if (state_stack_.back().mode == parse_mode::root) - { - state_stack_.pop_back(); - handler_.flush(); - } - } - } - - void read_item(std::error_code& ec) - { - read_tags(ec); - if (ec) - { - return; - } - int c = source_.peek(); - if (c == Src::traits_type::eof()) - { - ec = cbor_errc::unexpected_eof; - return; - } - jsoncons::cbor::detail::cbor_major_type major_type = get_major_type((uint8_t)c); - - uint8_t info = get_additional_information_value((uint8_t)c); - switch (major_type) - { - case jsoncons::cbor::detail::cbor_major_type::unsigned_integer: - { - uint64_t val = get_uint64_value(source_, ec); - if (ec) - { - return; - } - if (state_stack_.back().stringref_map && !tags_.empty() && tags_.back() == 25) - { - tags_.pop_back(); - if (val >= state_stack_.back().stringref_map->size()) - { - ec = cbor_errc::stringref_too_large; - return; - } - stringref_map_type::size_type index = (stringref_map_type::size_type)val; - if (index != val) - { - ec = cbor_errc::number_too_large; - return; - } - auto& str = state_stack_.back().stringref_map->at(index); - switch (str.type) - { - case jsoncons::cbor::detail::cbor_major_type::text_string: - { - handle_string(basic_string_view(str.s.data(),str.s.length()),ec); - if (ec) - { - return; - } - break; - } - case jsoncons::cbor::detail::cbor_major_type::byte_string: - { - handle_byte_string(byte_string_view(str.bs.data(),str.bs.size()), ec); - if (ec) - { - return; - } - break; - } - default: - JSONCONS_UNREACHABLE(); - break; - } - } - else - { - semantic_tag tag = semantic_tag::none; - if (!tags_.empty()) - { - if (tags_.back() == 1) - { - tag = semantic_tag::timestamp; - } - tags_.clear(); - } - handler_.uint64_value(val, tag, *this); - } - break; - } - case jsoncons::cbor::detail::cbor_major_type::negative_integer: - { - int64_t val = get_int64_value(source_, ec); - if (ec) - { - return; - } - semantic_tag tag = semantic_tag::none; - if (!tags_.empty()) - { - if (tags_.back() == 1) - { - tag = semantic_tag::timestamp; - } - tags_.clear(); - } - handler_.int64_value(val, tag, *this); - break; - } - case jsoncons::cbor::detail::cbor_major_type::byte_string: - { - std::vector v = get_byte_string(ec); - if (ec) - { - return; - } - handle_byte_string(byte_string_view(v.data(), v.size()), ec); - if (ec) - { - return; - } - break; - } - case jsoncons::cbor::detail::cbor_major_type::text_string: - { - std::string s = get_text_string(ec); - auto result = unicons::validate(s.begin(),s.end()); - if (result.ec != unicons::conv_errc()) - { - ec = cbor_errc::invalid_utf8_text_string; - return; - } - handle_string(basic_string_view(s.data(),s.length()),ec); - if (ec) - { - return; - } - break; - } - case jsoncons::cbor::detail::cbor_major_type::semantic_tag: - { - JSONCONS_UNREACHABLE(); - break; - } - case jsoncons::cbor::detail::cbor_major_type::simple: - { - switch (info) - { - case 0x14: - handler_.bool_value(false, semantic_tag::none, *this); - source_.ignore(1); - break; - case 0x15: - handler_.bool_value(true, semantic_tag::none, *this); - source_.ignore(1); - break; - case 0x16: - handler_.null_value(semantic_tag::none, *this); - source_.ignore(1); - break; - case 0x17: - handler_.null_value(semantic_tag::undefined, *this); - source_.ignore(1); - break; - case 0x19: // Half-Precision Float (two-byte IEEE 754) - case 0x1a: // Single-Precision Float (four-byte IEEE 754) - case 0x1b: // Double-Precision Float (eight-byte IEEE 754) - double val = get_double(source_, ec); - if (ec) - { - return; - } - semantic_tag tag = semantic_tag::none; - if (!tags_.empty()) - { - if (tags_.back() == 1) - { - tag = semantic_tag::timestamp; - } - tags_.clear(); - } - handler_.double_value(val, tag, *this); - break; - } - break; - } - case jsoncons::cbor::detail::cbor_major_type::array: - { - if (!tags_.empty() && tags_.back() == 0x04) - { - std::string s = get_array_as_decimal_string(ec); - if (ec) - { - return; - } - handler_.string_value(s, semantic_tag::bigdec); - tags_.pop_back(); - } - else if (!tags_.empty() && tags_.back() == 0x05) - { - std::string s = get_array_as_hexfloat_string(ec); - if (ec) - { - return; - } - handler_.string_value(s, semantic_tag::bigfloat); - tags_.pop_back(); - } - else - { - begin_array(info, ec); - } - break; - } - case jsoncons::cbor::detail::cbor_major_type::map: - { - begin_map(info,ec); - break; - } - default: - break; - } - tags_.clear(); - } - - void begin_array(uint8_t info, std::error_code& ec) - { - semantic_tag tag = semantic_tag::none; - auto stringref_map = state_stack_.back().stringref_map; - for (auto t : tags_) - { - switch (t) - { - case 0x05: - tag = semantic_tag::bigfloat; - break; - case 0x100: // 256 (stringref-namespace) - stringref_map = std::make_shared(); - break; - default: - break; - } - } - tags_.clear(); - switch (info) - { - case jsoncons::cbor::detail::additional_info::indefinite_length: - { - state_stack_.push_back(parse_state(parse_mode::indefinite_array,0,stringref_map)); - handler_.begin_array(tag, *this); - source_.ignore(1); - break; - } - default: // definite length - { - size_t len = get_definite_length(source_,ec); - if (ec) - { - return; - } - state_stack_.push_back(parse_state(parse_mode::array,len,stringref_map)); - handler_.begin_array(len, tag, *this); - break; - } - } - } - - void end_array(std::error_code&) - { - switch (state_stack_.back().mode) - { - case parse_mode::indefinite_array: - { - source_.ignore(1); - break; - } - default: - break; - } - handler_.end_array(*this); - state_stack_.pop_back(); - } - - void begin_map(uint8_t info, std::error_code& ec) - { - auto stringref_map = state_stack_.back().stringref_map; - for (auto t : tags_) - { - switch (t) - { - case 0x100: // 256 (stringref-namespace) - stringref_map = std::make_shared(); - break; - default: - break; - } - } - tags_.clear(); - switch (info) - { - case jsoncons::cbor::detail::additional_info::indefinite_length: - { - state_stack_.push_back(parse_state(parse_mode::indefinite_map,0,stringref_map)); - handler_.begin_object(semantic_tag::none, *this); - source_.ignore(1); - break; - } - default: // definite_length - { - size_t len = get_definite_length(source_, ec); - if (ec) - { - return; - } - state_stack_.push_back(parse_state(parse_mode::map,len,stringref_map)); - handler_.begin_object(len, semantic_tag::none, *this); - break; - } - } - } - - void end_map(std::error_code&) - { - switch (state_stack_.back().mode) - { - case parse_mode::indefinite_map: - { - source_.ignore(1); - break; - } - default: - break; - } - handler_.end_object(*this); - state_stack_.pop_back(); - } - - void read_name(std::error_code& ec) - { - read_tags(ec); - if (ec) - { - return; - } - jsoncons::cbor::detail::cbor_major_type major_type; - int c = source_.peek(); - switch (c) - { - case Src::traits_type::eof(): - ec = cbor_errc::unexpected_eof; - return; - default: - major_type = get_major_type((uint8_t)c); - break; - } - switch (major_type) - { - case jsoncons::cbor::detail::cbor_major_type::text_string: - { - std::string s = get_text_string(ec); - if (ec) - { - return; - } - auto result = unicons::validate(s.begin(),s.end()); - if (result.ec != unicons::conv_errc()) - { - ec = cbor_errc::invalid_utf8_text_string; - return; - } - handler_.name(basic_string_view(s.data(),s.length()), *this); - break; - } - case jsoncons::cbor::detail::cbor_major_type::byte_string: - { - std::vector v = get_byte_string(ec); - if (ec) - { - return; - } - std::string s; - encode_base64url(v.begin(),v.end(),s); - handler_.name(basic_string_view(s.data(),s.length()), *this); - break; - } - case jsoncons::cbor::detail::cbor_major_type::unsigned_integer: - { - if (state_stack_.back().stringref_map && !tags_.empty() && tags_.back() == 25) - { - uint64_t ref = get_uint64_value(source_, ec); - if (ec) - { - return; - } - if (ref >= state_stack_.back().stringref_map->size()) - { - ec = cbor_errc::stringref_too_large; - return; - } - - stringref_map_type::size_type index = (stringref_map_type::size_type)ref; - if (index != ref) - { - ec = cbor_errc::number_too_large; - return; - } - auto& val = state_stack_.back().stringref_map->at(index); - switch (val.type) - { - case jsoncons::cbor::detail::cbor_major_type::text_string: - { - handler_.name(basic_string_view(val.s.data(),val.s.length()), *this); - break; - } - case jsoncons::cbor::detail::cbor_major_type::byte_string: - { - std::string s; - encode_base64url(val.bs.begin(),val.bs.end(),s); - handler_.name(basic_string_view(s.data(),s.length()), *this); - break; - } - default: - JSONCONS_UNREACHABLE(); - break; - } - tags_.pop_back(); - break; - } - } - JSONCONS_FALLTHROUGH; - default: - { - std::string s; - json_string_encoder encoder(s); - basic_cbor_reader reader(std::move(source_), encoder); - reader.read(ec); - source_ = std::move(reader.source_); - auto result = unicons::validate(s.begin(),s.end()); - if (result.ec != unicons::conv_errc()) - { - ec = cbor_errc::invalid_utf8_text_string; - return; - } - handler_.name(basic_string_view(s.data(),s.length()), *this); - } - } - } - - std::string get_text_string(std::error_code& ec) - { - std::string s; - - jsoncons::cbor::detail::cbor_major_type major_type; - uint8_t info; - int c = source_.peek(); - switch (c) - { - case Src::traits_type::eof(): - ec = cbor_errc::unexpected_eof; - return s; - default: - major_type = get_major_type((uint8_t)c); - info = get_additional_information_value((uint8_t)c); - break; - } - JSONCONS_ASSERT(major_type == jsoncons::cbor::detail::cbor_major_type::text_string); - auto func = [&s](Src& source_, size_t length, std::error_code& ec) - { - s.reserve(s.size()+length); - source_.read(std::back_inserter(s), length); - if (source_.eof()) - { - ec = cbor_errc::unexpected_eof; - return; - } - }; - iterate_string_chunks(source_, func, ec); - if (state_stack_.back().stringref_map && - info != jsoncons::cbor::detail::additional_info::indefinite_length && - s.length() >= jsoncons::cbor::detail::min_length_for_stringref(state_stack_.back().stringref_map->size())) - { - state_stack_.back().stringref_map->emplace_back(s); - } - - return s; - } - - static size_t get_definite_length(Src& source, std::error_code& ec) - { - if (JSONCONS_UNLIKELY(source.eof())) - { - ec = cbor_errc::unexpected_eof; - return 0; - } - switch (get_major_type((uint8_t)source.peek())) - { - case jsoncons::cbor::detail::cbor_major_type::byte_string: - case jsoncons::cbor::detail::cbor_major_type::text_string: - case jsoncons::cbor::detail::cbor_major_type::array: - case jsoncons::cbor::detail::cbor_major_type::map: - break; - default: - return 0; - } - - uint64_t u = get_uint64_value(source, ec); - size_t len = (size_t)u; - if (len != u) - { - ec = cbor_errc::number_too_large; - } - return len; - } - - std::vector get_byte_string(std::error_code& ec) - { - std::vector v; - - jsoncons::cbor::detail::cbor_major_type major_type; - uint8_t info; - int c = source_.peek(); - switch (c) - { - case Src::traits_type::eof(): - ec = cbor_errc::unexpected_eof; - return v; - default: - major_type = get_major_type((uint8_t)c); - info = get_additional_information_value((uint8_t)c); - break; - } - JSONCONS_ASSERT(major_type == jsoncons::cbor::detail::cbor_major_type::byte_string); - auto func = [&v](Src& source_, size_t length, std::error_code& ec) - { - v.reserve(v.size()+length); - source_.read(std::back_inserter(v), length); - if (source_.eof()) - { - ec = cbor_errc::unexpected_eof; - return; - } - }; - iterate_string_chunks(source_, func, ec); - if (state_stack_.back().stringref_map && - info != jsoncons::cbor::detail::additional_info::indefinite_length && - v.size() >= jsoncons::cbor::detail::min_length_for_stringref(state_stack_.back().stringref_map->size())) - { - state_stack_.back().stringref_map->emplace_back(v); - } - return v; - } - - template - static void iterate_string_chunks(Src& source, - Function func, - std::error_code& ec) - { - int c = source.peek(); - if (c == Src::traits_type::eof()) - { - ec = cbor_errc::unexpected_eof; - return; - } - - jsoncons::cbor::detail::cbor_major_type major_type = get_major_type((uint8_t)c); - JSONCONS_ASSERT(major_type == jsoncons::cbor::detail::cbor_major_type::text_string || major_type == jsoncons::cbor::detail::cbor_major_type::byte_string); - uint8_t info = get_additional_information_value((uint8_t)c); - - switch (info) - { - case jsoncons::cbor::detail::additional_info::indefinite_length: - { - source.ignore(1); - bool done = false; - while (!done) - { - int test = source.peek(); - switch (test) - { - case Src::traits_type::eof(): - ec = cbor_errc::unexpected_eof; - return; - case 0xff: - done = true; - break; - default: - iterate_string_chunks(source, func, ec); - if (ec) - { - return; - } - break; - } - } - source.ignore(1); - break; - } - default: // definite length - { - size_t length = get_definite_length(source, ec); - if (ec) - { - return; - } - func(source, length, ec); - if (ec) - { - return; - } - break; - } - } - } - - static uint64_t get_uint64_value(Src& source, std::error_code& ec) - { - uint64_t val = 0; - if (JSONCONS_UNLIKELY(source.eof())) - { - ec = cbor_errc::unexpected_eof; - return val; - } - const uint8_t* endp = nullptr; - - uint8_t type{}; - if (source.get(type) == 0) - { - ec = cbor_errc::unexpected_eof; - return 0; - } - uint8_t info = get_additional_information_value(type); - switch (info) - { - case JSONCONS_CBOR_0x00_0x17: // Integer 0x00..0x17 (0..23) - { - val = info; - break; - } - - case 0x18: // Unsigned integer (one-byte uint8_t follows) - { - uint8_t c{}; - source.get(c); - if (source.eof()) - { - ec = cbor_errc::unexpected_eof; - return val; - } - val = c; - break; - } - - case 0x19: // Unsigned integer (two-byte uint16_t follows) - { - uint8_t buf[sizeof(uint16_t)]; - source.read(buf, sizeof(uint16_t)); - val = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - break; - } - - case 0x1a: // Unsigned integer (four-byte uint32_t follows) - { - uint8_t buf[sizeof(uint32_t)]; - source.read(buf, sizeof(uint32_t)); - val = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - break; - } - - case 0x1b: // Unsigned integer (eight-byte uint64_t follows) - { - uint8_t buf[sizeof(uint64_t)]; - source.read(buf, sizeof(uint64_t)); - val = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - break; - } - default: - break; - } - return val; - } - - static int64_t get_int64_value(Src& source, std::error_code& ec) - { - int64_t val = 0; - if (JSONCONS_UNLIKELY(source.eof())) - { - ec = cbor_errc::unexpected_eof; - return val; - } - const uint8_t* endp = nullptr; - - uint8_t info = get_additional_information_value((uint8_t)source.peek()); - switch (get_major_type((uint8_t)source.peek())) - { - case jsoncons::cbor::detail::cbor_major_type::negative_integer: - source.ignore(1); - switch (info) - { - case JSONCONS_CBOR_0x00_0x17: // 0x00..0x17 (0..23) - { - val = static_cast(- 1 - info); - break; - } - case 0x18: // Negative integer (one-byte uint8_t follows) - { - uint8_t c{}; - source.get(c); - if (source.eof()) - { - ec = cbor_errc::unexpected_eof; - return val; - } - val = static_cast(-1)- c; - break; - } - - case 0x19: // Negative integer -1-n (two-byte uint16_t follows) - { - uint8_t buf[sizeof(uint16_t)]; - if (source.read(buf, sizeof(uint16_t)) != sizeof(uint16_t)) - { - return val; - } - auto x = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - val = static_cast(-1)- x; - break; - } - - case 0x1a: // Negative integer -1-n (four-byte uint32_t follows) - { - uint8_t buf[sizeof(uint32_t)]; - if (source.read(buf, sizeof(uint32_t)) != sizeof(uint32_t)) - { - return val; - } - auto x = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - val = static_cast(-1)- x; - break; - } - - case 0x1b: // Negative integer -1-n (eight-byte uint64_t follows) - { - uint8_t buf[sizeof(uint64_t)]; - if (source.read(buf, sizeof(uint64_t)) != sizeof(uint64_t)) - { - return val; - } - auto x = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - val = static_cast(-1)- static_cast(x); - break; - } - } - break; - - case jsoncons::cbor::detail::cbor_major_type::unsigned_integer: - { - uint64_t x = get_uint64_value(source, ec); - if (ec) - { - return 0; - } - if (x <= static_cast((std::numeric_limits::max)())) - { - val = x; - } - else - { - // error; - } - - break; - } - break; - default: - break; - } - - return val; - } - - static double get_double(Src& source, std::error_code& ec) - { - double val = 0; - if (JSONCONS_UNLIKELY(source.eof())) - { - ec = cbor_errc::unexpected_eof; - return val; - } - const uint8_t* endp = nullptr; - - uint8_t type{}; - if (source.get(type) == 0) - { - ec = cbor_errc::unexpected_eof; - return 0; - } - uint8_t info = get_additional_information_value(type); - switch (info) - { - case 0x19: // Half-Precision Float (two-byte IEEE 754) - { - uint8_t buf[sizeof(uint16_t)]; - source.read(buf, sizeof(uint16_t)); - if (source.eof()) - { - ec = cbor_errc::unexpected_eof; - return 0; - } - uint16_t x = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - val = jsoncons::detail::decode_half(x); - break; - } - - - case 0x1a: // Single-Precision Float (four-byte IEEE 754) - { - uint8_t buf[sizeof(float)]; - source.read(buf, sizeof(float)); - if (source.eof()) - { - ec = cbor_errc::unexpected_eof; - return 0; - } - val = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - break; - } - - case 0x1b: // Double-Precision Float (eight-byte IEEE 754) - { - uint8_t buf[sizeof(double)]; - source.read(buf, sizeof(double)); - if (source.eof()) - { - ec = cbor_errc::unexpected_eof; - return 0; - } - val = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - break; - } - default: - break; - } - - return val; - } - - std::string get_array_as_decimal_string(std::error_code& ec) - { - std::string s; - - int c; - if ((c=source_.get()) == Src::traits_type::eof()) - { - ec = cbor_errc::unexpected_eof; - return s; - } - jsoncons::cbor::detail::cbor_major_type major_type = get_major_type((uint8_t)c); - uint8_t info = get_additional_information_value((uint8_t)c); - JSONCONS_ASSERT(major_type == jsoncons::cbor::detail::cbor_major_type::array); - JSONCONS_ASSERT(info == 2); - - if ((c=source_.peek()) == Src::traits_type::eof()) - { - ec = cbor_errc::unexpected_eof; - return s; - } - int64_t exponent = 0; - switch (get_major_type((uint8_t)c)) - { - case jsoncons::cbor::detail::cbor_major_type::unsigned_integer: - { - exponent = get_uint64_value(source_,ec); - if (ec) - { - return s; - } - break; - } - case jsoncons::cbor::detail::cbor_major_type::negative_integer: - { - exponent = get_int64_value(source_,ec); - if (ec) - { - return s; - } - break; - } - default: - { - ec = cbor_errc::invalid_decimal; - return s; - } - } - - switch (get_major_type((uint8_t)source_.peek())) - { - case jsoncons::cbor::detail::cbor_major_type::unsigned_integer: - { - uint64_t val = get_uint64_value(source_,ec); - if (ec) - { - return s; - } - jsoncons::detail::print_uinteger(val, s); - break; - } - case jsoncons::cbor::detail::cbor_major_type::negative_integer: - { - int64_t val = get_int64_value(source_,ec); - if (ec) - { - return s; - } - jsoncons::detail::print_integer(val, s); - break; - } - case jsoncons::cbor::detail::cbor_major_type::semantic_tag: - { - if ((c=source_.get()) == Src::traits_type::eof()) - { - ec = cbor_errc::unexpected_eof; - return s; - } - uint8_t tag = get_additional_information_value((uint8_t)c); - if ((c=source_.peek()) == Src::traits_type::eof()) - { - ec = cbor_errc::unexpected_eof; - return s; - } - - if (get_major_type((uint8_t)c) == jsoncons::cbor::detail::cbor_major_type::byte_string) - { - std::vector v = get_byte_string(ec); - if (ec) - { - return s; - } - if (tag == 2) - { - bignum n(1, v.data(), v.size()); - n.dump(s); - } - else if (tag == 3) - { - bignum n(-1, v.data(), v.size()); - n.dump(s); - } - } - break; - } - default: - { - ec = cbor_errc::invalid_decimal; - return s; - } - } - - std::string result; - if (s.size() > 0) - { - if (s[0] == '-') - { - result.push_back('-'); - jsoncons::detail::prettify_string(s.c_str()+1, s.size()-1, (int)exponent, -4, 17, result); - } - else - { - jsoncons::detail::prettify_string(s.c_str(), s.size(), (int)exponent, -4, 17, result); - } - } - //std::cout << "s: " << s << ", exponent: " << std::dec << exponent << ", result: " << result << "\n"; - return result; - } - - std::string get_array_as_hexfloat_string(std::error_code& ec) - { - std::string s; - - int c; - if ((c=source_.get()) == Src::traits_type::eof()) - { - ec = cbor_errc::unexpected_eof; - return s; - } - jsoncons::cbor::detail::cbor_major_type major_type = get_major_type((uint8_t)c); - uint8_t info = get_additional_information_value((uint8_t)c); - JSONCONS_ASSERT(major_type == jsoncons::cbor::detail::cbor_major_type::array); - JSONCONS_ASSERT(info == 2); - - if ((c=source_.peek()) == Src::traits_type::eof()) - { - ec = cbor_errc::unexpected_eof; - return s; - } - int64_t exponent = 0; - switch (get_major_type((uint8_t)c)) - { - case jsoncons::cbor::detail::cbor_major_type::unsigned_integer: - { - exponent = get_uint64_value(source_,ec); - if (ec) - { - return s; - } - break; - } - case jsoncons::cbor::detail::cbor_major_type::negative_integer: - { - exponent = get_int64_value(source_,ec); - if (ec) - { - return s; - } - break; - } - default: - { - ec = cbor_errc::invalid_bigfloat; - return s; - } - } - - switch (get_major_type((uint8_t)source_.peek())) - { - case jsoncons::cbor::detail::cbor_major_type::unsigned_integer: - { - uint64_t val = get_uint64_value(source_,ec); - if (ec) - { - return s; - } - s.push_back('0'); - s.push_back('x'); - jsoncons::detail::uinteger_to_hex_string(val, s); - break; - } - case jsoncons::cbor::detail::cbor_major_type::negative_integer: - { - int64_t val = get_int64_value(source_,ec); - if (ec) - { - return s; - } - s.push_back('-'); - s.push_back('0'); - s.push_back('x'); - jsoncons::detail::uinteger_to_hex_string(static_cast(-val), s); - break; - } - case jsoncons::cbor::detail::cbor_major_type::semantic_tag: - { - if ((c=source_.get()) == Src::traits_type::eof()) - { - ec = cbor_errc::unexpected_eof; - return s; - } - uint8_t tag = get_additional_information_value((uint8_t)c); - if ((c=source_.peek()) == Src::traits_type::eof()) - { - ec = cbor_errc::unexpected_eof; - return s; - } - - if (get_major_type((uint8_t)c) == jsoncons::cbor::detail::cbor_major_type::byte_string) - { - std::vector v = get_byte_string(ec); - if (ec) - { - return s; - } - if (tag == 2) - { - s.push_back('-'); - s.push_back('0'); - s.push_back('x'); - bignum n(1, v.data(), v.size()); - n.dump_hex_string(s); - } - else if (tag == 3) - { - s.push_back('-'); - s.push_back('0'); - bignum n(-1, v.data(), v.size()); - n.dump_hex_string(s); - s[2] = 'x'; - } - } - break; - } - default: - { - ec = cbor_errc::invalid_bigfloat; - return s; - } - } - - s.push_back('p'); - if (exponent >=0) - { - jsoncons::detail::uinteger_to_hex_string(static_cast(exponent), s); - } - else - { - s.push_back('-'); - jsoncons::detail::uinteger_to_hex_string(static_cast(-exponent), s); - } - return s; - } - - static jsoncons::cbor::detail::cbor_major_type get_major_type(uint8_t type) - { - static const uint8_t major_type_shift = 0x05; - uint8_t value = type >> major_type_shift; - return static_cast(value); - } - - static uint8_t get_additional_information_value(uint8_t type) - { - static const uint8_t additional_information_mask = (1U << 5) - 1; - uint8_t value = type & additional_information_mask; - return value; - } - - void read_tags(std::error_code& ec) - { - int c = source_.peek(); - if (c == Src::traits_type::eof()) - { - ec = cbor_errc::unexpected_eof; - return; - } - jsoncons::cbor::detail::cbor_major_type major_type = get_major_type((uint8_t)c); - while (major_type == jsoncons::cbor::detail::cbor_major_type::semantic_tag) - { - uint64_t val = get_uint64_value(source_, ec); - if (ec) - { - return; - } - tags_.push_back(val); - c = source_.peek(); - if (c == Src::traits_type::eof()) - { - ec = cbor_errc::unexpected_eof; - return; - } - major_type = get_major_type((uint8_t)c); - } - } - - void handle_string(const basic_string_view& v, std::error_code&) - { - semantic_tag tag = semantic_tag::none; - if (!tags_.empty()) - { - switch (tags_.back()) - { - case 0: - tag = semantic_tag::datetime; - break; - case 32: - tag = semantic_tag::uri; - break; - case 33: - tag = semantic_tag::base64url; - break; - case 34: - tag = semantic_tag::base64; - break; - default: - break; - } - tags_.clear(); - } - handler_.string_value(v, tag, *this); - } - - void handle_byte_string(const byte_string_view& v, std::error_code&) - { - if (!tags_.empty()) - { - switch (tags_.back()) - { - case 0x2: - { - bignum n(1, v.data(), v.size()); - buffer_.clear(); - n.dump(buffer_); - handler_.string_value(buffer_, semantic_tag::bigint, *this); - break; - } - case 0x3: - { - bignum n(-1, v.data(), v.size()); - buffer_.clear(); - n.dump(buffer_); - handler_.string_value(buffer_, semantic_tag::bigint, *this); - break; - } - case 0x15: - { - handler_.byte_string_value(byte_string_view(v.data(), v.size()), semantic_tag::base64url, *this); - break; - } - case 0x16: - { - handler_.byte_string_value(byte_string_view(v.data(), v.size()), semantic_tag::base64, *this); - break; - } - case 0x17: - { - handler_.byte_string_value(byte_string_view(v.data(), v.size()), semantic_tag::base16, *this); - break; - } - default: - handler_.byte_string_value(byte_string_view(v.data(), v.size()), semantic_tag::none, *this); - break; - } - tags_.clear(); - } - else - { - handler_.byte_string_value(byte_string_view(v.data(), v.size()), semantic_tag::none, *this); - } - } - -}; - -typedef basic_cbor_reader cbor_reader; - -typedef basic_cbor_reader cbor_bytes_reader; - -#if !defined(JSONCONS_NO_DEPRECATED) -typedef cbor_bytes_reader cbor_buffer_reader; -#endif - -}} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/csv/csv.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/csv/csv.hpp deleted file mode 100644 index d0d5597c98..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/csv/csv.hpp +++ /dev/null @@ -1,14 +0,0 @@ -/// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_CSV_CSV_HPP -#define JSONCONS_CSV_CSV_HPP - -#include -#include -#include - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/csv/csv_encoder.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/csv/csv_encoder.hpp deleted file mode 100644 index 1bc98d9830..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/csv/csv_encoder.hpp +++ /dev/null @@ -1,619 +0,0 @@ -// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_CSV_CSV_ENCODER_HPP -#define JSONCONS_CSV_CSV_ENCODER_HPP - -#include // std::array -#include -#include -#include -#include -#include // std::move -#include // std::unordered_map -#include // std::allocator -#include // std::numeric_limits -#include -#include -#include -#include -#include - -namespace jsoncons { namespace csv { - -template,class Allocator=std::allocator> -class basic_csv_encoder final : public basic_json_content_handler -{ - static const std::array& null_k() - { - static constexpr std::array k{'n','u','l','l'}; - return k; - } - static const std::array& true_k() - { - static constexpr std::array k{'t','r','u','e'}; - return k; - } - static const std::array& false_k() - { - static constexpr std::array k{'f','a','l','s','e'}; - return k; - } - -public: - typedef CharT char_type; - using typename basic_json_content_handler::string_view_type; - typedef Result result_type; - - typedef Allocator allocator_type; - typedef typename std::allocator_traits:: template rebind_alloc char_allocator_type; - typedef std::basic_string, char_allocator_type> string_type; - typedef typename std::allocator_traits:: template rebind_alloc string_allocator_type; - -private: - struct stack_item - { - stack_item(bool is_object) - : is_object_(is_object), count_(0) - { - } - bool is_object() const - { - return is_object_; - } - - bool is_object_; - size_t count_; - string_type name_; - }; - Result result_; - const basic_csv_encode_options& options_; - std::vector stack_; - jsoncons::detail::print_double fp_; - std::vector column_names_; - - typedef typename std::allocator_traits:: template rebind_alloc> string_string_allocator_type; - std::unordered_map,std::equal_to,string_string_allocator_type> buffered_line_; - - // Noncopyable and nonmoveable - basic_csv_encoder(const basic_csv_encoder&) = delete; - basic_csv_encoder& operator=(const basic_csv_encoder&) = delete; -public: - basic_csv_encoder(result_type result) - : basic_csv_encoder(std::move(result), basic_csv_options::default_options()) - { - } - - basic_csv_encoder(result_type result, - const basic_csv_encode_options& options) - : - result_(std::move(result)), - options_(options), - stack_(), - fp_(floating_point_options(options.floating_point_format(), - options.precision(), - 0)), - column_names_(options_.column_names()) - { - } - - ~basic_csv_encoder() - { - try - { - result_.flush(); - } - catch (...) - { - } - } - -private: - - template - void escape_string(const CharT* s, - size_t length, - CharT quote_char, CharT quote_escape_char, - AnyWriter& result) - { - const CharT* begin = s; - const CharT* end = s + length; - for (const CharT* it = begin; it != end; ++it) - { - CharT c = *it; - if (c == quote_char) - { - result.push_back(quote_escape_char); - result.push_back(quote_char); - } - else - { - result.push_back(c); - } - } - } - - void do_flush() override - { - result_.flush(); - } - - bool do_begin_object(semantic_tag, const ser_context&) override - { - stack_.push_back(stack_item(true)); - return true; - } - - bool do_end_object(const ser_context&) override - { - if (stack_.size() == 2) - { - if (stack_[0].count_ == 0) - { - for (size_t i = 0; i < column_names_.size(); ++i) - { - if (i > 0) - { - result_.push_back(options_.field_delimiter()); - } - result_.append(column_names_[i].data(), - column_names_[i].length()); - } - result_.append(options_.line_delimiter().data(), - options_.line_delimiter().length()); - } - for (size_t i = 0; i < column_names_.size(); ++i) - { - if (i > 0) - { - result_.push_back(options_.field_delimiter()); - } - auto it = buffered_line_.find(column_names_[i]); - if (it != buffered_line_.end()) - { - result_.append(it->second.data(),it->second.length()); - it->second.clear(); - } - } - result_.append(options_.line_delimiter().data(), options_.line_delimiter().length()); - } - stack_.pop_back(); - - end_value(); - return true; - } - - bool do_begin_array(semantic_tag, const ser_context&) override - { - stack_.push_back(stack_item(false)); - if (stack_.size() == 2) - { - if (stack_[0].count_ == 0) - { - for (size_t i = 0; i < column_names_.size(); ++i) - { - if (i > 0) - { - result_.push_back(options_.field_delimiter()); - } - result_.append(column_names_[i].data(),column_names_[i].length()); - } - if (column_names_.size() > 0) - { - result_.append(options_.line_delimiter().data(), - options_.line_delimiter().length()); - } - } - } - return true; - } - - bool do_end_array(const ser_context&) override - { - if (stack_.size() == 2) - { - result_.append(options_.line_delimiter().data(), - options_.line_delimiter().length()); - } - stack_.pop_back(); - - end_value(); - return true; - } - - bool do_name(const string_view_type& name, const ser_context&) override - { - if (stack_.size() == 2) - { - stack_.back().name_ = string_type(name); - buffered_line_[string_type(name)] = std::basic_string(); - if (stack_[0].count_ == 0 && options_.column_names().size() == 0) - { - column_names_.push_back(string_type(name)); - } - } - return true; - } - - template - bool string_value(const CharT* s, size_t length, AnyWriter& result) - { - bool quote = false; - if (options_.quote_style() == quote_style_type::all || options_.quote_style() == quote_style_type::nonnumeric || - (options_.quote_style() == quote_style_type::minimal && - (std::char_traits::find(s, length, options_.field_delimiter()) != nullptr || std::char_traits::find(s, length, options_.quote_char()) != nullptr))) - { - quote = true; - result.push_back(options_.quote_char()); - } - escape_string(s, length, options_.quote_char(), options_.quote_escape_char(), result); - if (quote) - { - result.push_back(options_.quote_char()); - } - - return true; - } - - bool do_null_value(semantic_tag, const ser_context&) override - { - if (stack_.size() == 2) - { - if (stack_.back().is_object()) - { - auto it = buffered_line_.find(stack_.back().name_); - if (it != buffered_line_.end()) - { - std::basic_string s; - jsoncons::string_result> bo(s); - accept_null_value(bo); - bo.flush(); - it->second = s; - } - } - else - { - accept_null_value(result_); - } - } - return true; - } - - bool do_string_value(const string_view_type& sv, semantic_tag, const ser_context&) override - { - if (stack_.size() == 2) - { - if (stack_.back().is_object()) - { - auto it = buffered_line_.find(stack_.back().name_); - if (it != buffered_line_.end()) - { - std::basic_string s; - jsoncons::string_result> bo(s); - value(sv,bo); - bo.flush(); - it->second = s; - } - } - else - { - value(sv,result_); - } - } - return true; - } - - bool do_byte_string_value(const byte_string_view& b, - semantic_tag tag, - const ser_context& context) override - { - byte_string_chars_format encoding_hint; - switch (tag) - { - case semantic_tag::base16: - encoding_hint = byte_string_chars_format::base16; - break; - case semantic_tag::base64: - encoding_hint = byte_string_chars_format::base64; - break; - case semantic_tag::base64url: - encoding_hint = byte_string_chars_format::base64url; - break; - default: - encoding_hint = byte_string_chars_format::none; - break; - } - byte_string_chars_format format = jsoncons::detail::resolve_byte_string_chars_format(encoding_hint,byte_string_chars_format::none,byte_string_chars_format::base64url); - - std::basic_string s; - switch (format) - { - case byte_string_chars_format::base16: - { - encode_base16(b.begin(),b.end(),s); - do_string_value(s, semantic_tag::none, context); - break; - } - case byte_string_chars_format::base64: - { - encode_base64(b.begin(),b.end(),s); - do_string_value(s, semantic_tag::none, context); - break; - } - case byte_string_chars_format::base64url: - { - encode_base64url(b.begin(),b.end(),s); - do_string_value(s, semantic_tag::none, context); - break; - } - default: - { - JSONCONS_UNREACHABLE(); - } - } - - return true; - } - - bool do_double_value(double val, - semantic_tag, - const ser_context&) override - { - if (stack_.size() == 2) - { - if (stack_.back().is_object()) - { - auto it = buffered_line_.find(stack_.back().name_); - if (it != buffered_line_.end()) - { - std::basic_string s; - jsoncons::string_result> bo(s); - value(val, bo); - bo.flush(); - it->second = s; - } - } - else - { - value(val, result_); - } - } - return true; - } - - bool do_int64_value(int64_t val, - semantic_tag, - const ser_context&) override - { - if (stack_.size() == 2) - { - if (stack_.back().is_object()) - { - auto it = buffered_line_.find(stack_.back().name_); - if (it != buffered_line_.end()) - { - std::basic_string s; - jsoncons::string_result> bo(s); - value(val,bo); - bo.flush(); - it->second = s; - } - } - else - { - value(val,result_); - } - } - return true; - } - - bool do_uint64_value(uint64_t val, - semantic_tag, - const ser_context&) override - { - if (stack_.size() == 2) - { - if (stack_.back().is_object()) - { - auto it = buffered_line_.find(stack_.back().name_); - if (it != buffered_line_.end()) - { - std::basic_string s; - jsoncons::string_result> bo(s); - value(val,bo); - bo.flush(); - it->second = s; - } - } - else - { - value(val,result_); - } - } - return true; - } - - bool do_bool_value(bool val, semantic_tag, const ser_context&) override - { - if (stack_.size() == 2) - { - if (stack_.back().is_object()) - { - auto it = buffered_line_.find(stack_.back().name_); - if (it != buffered_line_.end()) - { - std::basic_string s; - jsoncons::string_result> bo(s); - value(val,bo); - bo.flush(); - it->second = s; - } - } - else - { - value(val,result_); - } - } - return true; - } - - template - void value(const string_view_type& value, AnyWriter& result) - { - begin_value(result); - string_value(value.data(),value.length(),result); - end_value(); - } - - template - void value(double val, AnyWriter& result) - { - begin_value(result); - - if ((std::isnan)(val)) - { - result.append(null_k().data(), null_k().size()); - } - else if (val == std::numeric_limits::infinity()) - { - result.append(null_k().data(), null_k().size()); - } - else if (!(std::isfinite)(val)) - { - result.append(null_k().data(), null_k().size()); - } - else - { - fp_(val, result); - } - - end_value(); - - } - - template - void value(int64_t val, AnyWriter& result) - { - begin_value(result); - - std::basic_ostringstream ss; - ss << val; - result.append(ss.str().data(),ss.str().length()); - - end_value(); - } - - template - void value(uint64_t val, AnyWriter& result) - { - begin_value(result); - - std::basic_ostringstream ss; - ss << val; - result.append(ss.str().data(),ss.str().length()); - - end_value(); - } - - template - void value(bool val, AnyWriter& result) - { - begin_value(result); - - if (val) - { - result.append(true_k().data(), true_k().size()); - } - else - { - result.append(false_k().data(), false_k().size()); - } - - end_value(); - } - - template - bool accept_null_value(AnyWriter& result) - { - begin_value(result); - result.append(null_k().data(), null_k().size()); - end_value(); - return true; - } - - template - void begin_value(AnyWriter& result) - { - if (!stack_.empty()) - { - if (!stack_.back().is_object_ && stack_.back().count_ > 0) - { - result.push_back(options_.field_delimiter()); - } - } - } - - void end_value() - { - if (!stack_.empty()) - { - ++stack_.back().count_; - } - } -}; - -// encode_csv - -template -typename std::enable_if::value,void>::type -encode_csv(const T& j, std::basic_string& s, const basic_csv_options& options = basic_csv_options::default_options()) -{ - typedef CharT char_type; - basic_csv_encoder>> encoder(s,options); - j.dump(encoder); -} - -template -typename std::enable_if::value,void>::type -encode_csv(const T& val, std::basic_string& s, const basic_csv_options& options = basic_csv_options::default_options()) -{ - typedef CharT char_type; - basic_csv_encoder>> encoder(s,options); - write_to(basic_json(), val, encoder); -} - -template -typename std::enable_if::value,void>::type -encode_csv(const T& j, std::basic_ostream& os, const basic_csv_options& options = basic_csv_options::default_options()) -{ - typedef CharT char_type; - basic_csv_encoder> encoder(os,options); - j.dump(encoder); -} - -template -typename std::enable_if::value,void>::type -encode_csv(const T& val, std::basic_ostream& os, const basic_csv_options& options = basic_csv_options::default_options()) -{ - typedef CharT char_type; - basic_csv_encoder> encoder(os,options); - write_to(basic_json(), val, encoder); -} - -typedef basic_csv_encoder csv_encoder; -typedef basic_csv_encoder> csv_string_encoder; - -#if !defined(JSONCONS_NO_DEPRECATED) -template, class Allocator = std::allocator> -using basic_csv_serializer = basic_csv_encoder; - -typedef basic_csv_serializer csv_serializer; -typedef basic_csv_serializer> csv_string_serializer; -#endif - -}} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/csv/csv_error.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/csv/csv_error.hpp deleted file mode 100644 index 49a09a0d6d..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/csv/csv_error.hpp +++ /dev/null @@ -1,77 +0,0 @@ -/// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_CSV_CSV_ERROR_HPP -#define JSONCONS_CSV_CSV_ERROR_HPP - -#include -#include - -namespace jsoncons { namespace csv { - - enum class csv_errc : int - { - ok = 0, - unexpected_eof = 1, - source_error, - expected_quote, - invalid_csv_text, - invalid_state - }; - -#if !defined(JSONCONS_NO_DEPRECATED) -typedef csv_errc csv_parser_errc; -#endif - -class csv_error_category_impl - : public std::error_category -{ -public: - const char* name() const noexcept override - { - return "jsoncons/csv"; - } - std::string message(int ev) const override - { - switch (static_cast(ev)) - { - case csv_errc::unexpected_eof: - return "Unexpected end of file"; - case csv_errc::source_error: - return "Source error"; - case csv_errc::expected_quote: - return "Expected quote character"; - case csv_errc::invalid_csv_text: - return "Invalid CSV text"; - default: - return "Unknown JSON parser error"; - } - } -}; - -inline -const std::error_category& csv_error_category() -{ - static csv_error_category_impl instance; - return instance; -} - -inline -std::error_code make_error_code(csv_errc result) -{ - return std::error_code(static_cast(result),csv_error_category()); -} - -}} - -namespace std { - template<> - struct is_error_code_enum : public true_type - { - }; -} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/csv/csv_options.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/csv/csv_options.hpp deleted file mode 100644 index 5cae9e1610..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/csv/csv_options.hpp +++ /dev/null @@ -1,771 +0,0 @@ -// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_CSV_CSV_OPTIONS_HPP -#define JSONCONS_CSV_CSV_OPTIONS_HPP - -#include -#include -#include // std::pair -#include // std::unordered_map -#include // std::numeric_limits -#include - -namespace jsoncons { namespace csv { - -namespace detail { - JSONCONS_STRING_LITERAL(string,'s','t','r','i','n','g') - JSONCONS_STRING_LITERAL(integer,'i','n','t','e','g','e','r') - JSONCONS_STRING_LITERAL(float,'f','l','o','a','t') - JSONCONS_STRING_LITERAL(boolean,'b','o','o','l','e','a','n') -} - -enum class csv_column_type -{ - string_t,integer_t,float_t,boolean_t,repeat_t -}; - -enum class quote_style_type -{ - all,minimal,none,nonnumeric -}; - -typedef quote_style_type quote_styles; - -enum class mapping_type -{ - n_rows, - n_objects, - m_columns -}; - -enum class column_state {sequence,label}; - -struct csv_type_info -{ - csv_type_info() = default; - csv_type_info(const csv_type_info&) = default; - csv_type_info(csv_type_info&&) = default; - - csv_type_info(csv_column_type ctype, size_t lev, size_t repcount = 0) - { - col_type = ctype; - level = lev; - rep_count = repcount; - } - - csv_column_type col_type; - size_t level; - size_t rep_count; -}; - -template -class basic_csv_decode_options -{ -public: - typedef std::basic_string string_type; - - virtual size_t header_lines() const = 0; - - virtual bool assume_header() const = 0; - - virtual bool ignore_empty_values() const = 0; - - virtual bool ignore_empty_lines() const = 0; - - virtual bool trim_leading() const = 0; - - virtual bool trim_trailing() const = 0; - - virtual bool trim_leading_inside_quotes() const = 0; - - virtual bool trim_trailing_inside_quotes() const = 0; - - virtual bool trim() const = 0; - - virtual bool trim_inside_quotes() const = 0; - - virtual bool unquoted_empty_value_is_null() const = 0; - - virtual std::vector column_names() const = 0; - - virtual std::vector column_types() const = 0; - - virtual std::vector column_defaults() const = 0; - - virtual CharT field_delimiter() const = 0; - - virtual const std::pair& subfield_delimiter() const = 0; - - virtual string_type line_delimiter() const = 0; - - virtual CharT quote_char() const = 0; - - virtual bool infer_types() const = 0; - - virtual bool lossless_number() const = 0; - - virtual CharT quote_escape_char() const = 0; - - virtual CharT comment_starter() const = 0; - - virtual mapping_type mapping() const = 0; - - virtual unsigned long max_lines() const = 0; -}; - -template -class basic_csv_encode_options -{ -public: - typedef std::basic_string string_type; - - virtual chars_format floating_point_format() const = 0; - - virtual int precision() const = 0; - - virtual std::vector column_names() const = 0; - - virtual CharT field_delimiter() const = 0; - - virtual const std::pair& subfield_delimiter() const = 0; - - virtual string_type line_delimiter() const = 0; - - virtual CharT quote_char() const = 0; - - virtual CharT quote_escape_char() const = 0; - - virtual quote_style_type quote_style() const = 0; -}; - -template -class basic_csv_options : public virtual basic_csv_decode_options, - public virtual basic_csv_encode_options -{ - typedef CharT char_type; - typedef std::basic_string string_type; - - chars_format floating_point_format_; - int precision_; - bool assume_header_; - bool ignore_empty_values_; - bool ignore_empty_lines_; - bool trim_leading_; - bool trim_trailing_; - bool trim_leading_inside_quotes_; - bool trim_trailing_inside_quotes_; - bool unquoted_empty_value_is_null_; - CharT field_delimiter_; - std::pair subfield_delimiter_; - CharT quote_char_; - CharT quote_escape_char_; - CharT comment_starter_; - quote_style_type quote_style_; - std::pair mapping_; - unsigned long max_lines_; - size_t header_lines_; - string_type line_delimiter_; - bool infer_types_; - bool lossless_number_; - - std::vector column_names_; - std::vector column_types_; - std::vector column_defaults_; -public: - static const size_t default_indent = 4; - - static const basic_csv_options& default_options() - { - static basic_csv_options options{}; - return options; - } - -// Constructors - - basic_csv_options() : - floating_point_format_(chars_format()), - precision_(0), - assume_header_(false), - ignore_empty_values_(false), - ignore_empty_lines_(true), - trim_leading_(false), - trim_trailing_(false), - trim_leading_inside_quotes_(false), - trim_trailing_inside_quotes_(false), - unquoted_empty_value_is_null_(false), - field_delimiter_(','), - subfield_delimiter_(std::make_pair(',',false)), - quote_char_('\"'), - quote_escape_char_('\"'), - comment_starter_('\0'), - quote_style_(quote_style_type::minimal), - mapping_({mapping_type::n_rows,false}), - max_lines_((std::numeric_limits::max)()), - header_lines_(0), - infer_types_(true), - lossless_number_(false) - { - line_delimiter_.push_back('\n'); - } - -// Properties - - chars_format floating_point_format() const override - { - return floating_point_format_; - } - - basic_csv_options& floating_point_format(chars_format value) - { - floating_point_format_ = value; - return *this; - } - - int precision() const override - { - return precision_; - } - - basic_csv_options& precision(int value) - { - precision_ = value; - return *this; - } - - size_t header_lines() const override - { - return (assume_header_ && header_lines_ <= 1) ? 1 : header_lines_; - } - - basic_csv_options& header_lines(size_t value) - { - header_lines_ = value; - return *this; - } - - bool assume_header() const override - { - return assume_header_; - } - - basic_csv_options& assume_header(bool value) - { - assume_header_ = value; - return *this; - } - - bool ignore_empty_values() const override - { - return ignore_empty_values_; - } - - basic_csv_options& ignore_empty_values(bool value) - { - ignore_empty_values_ = value; - return *this; - } - - bool ignore_empty_lines() const override - { - return ignore_empty_lines_; - } - - basic_csv_options& ignore_empty_lines(bool value) - { - ignore_empty_lines_ = value; - return *this; - } - - bool trim_leading() const override - { - return trim_leading_; - } - - basic_csv_options& trim_leading(bool value) - { - trim_leading_ = value; - return *this; - } - - bool trim_trailing() const override - { - return trim_trailing_; - } - - basic_csv_options& trim_trailing(bool value) - { - trim_trailing_ = value; - return *this; - } - - bool trim_leading_inside_quotes() const override - { - return trim_leading_inside_quotes_; - } - - basic_csv_options& trim_leading_inside_quotes(bool value) - { - trim_leading_inside_quotes_ = value; - return *this; - } - - bool trim_trailing_inside_quotes() const override - { - return trim_trailing_inside_quotes_; - } - - basic_csv_options& trim_trailing_inside_quotes(bool value) - { - trim_trailing_inside_quotes_ = value; - return *this; - } - - bool trim() const override - { - return trim_leading_ && trim_trailing_; - } - - basic_csv_options& trim(bool value) - { - trim_leading_ = value; - trim_trailing_ = value; - return *this; - } - - bool trim_inside_quotes() const override - { - return trim_leading_inside_quotes_ && trim_trailing_inside_quotes_; - } - - basic_csv_options& trim_inside_quotes(bool value) - { - trim_leading_inside_quotes_ = value; - trim_trailing_inside_quotes_ = value; - return *this; - } - - bool unquoted_empty_value_is_null() const override - { - return unquoted_empty_value_is_null_; - } - - basic_csv_options& unquoted_empty_value_is_null(bool value) - { - unquoted_empty_value_is_null_ = value; - return *this; - } - - std::vector column_names() const override - { - return column_names_; - } - -#if !defined(JSONCONS_NO_DEPRECATED) - basic_csv_options& column_names(const std::vector& value) - { - column_names_ = value; - return *this; - } - - basic_csv_options& column_defaults(const std::vector& value) - { - column_defaults_ = value; - return *this; - } - - basic_csv_options& column_types(const std::vector& value) - { - if (value.size() > 0) - { - column_types_.reserve(value.size()); - for (size_t i = 0; i < value.size(); ++i) - { - if (value[i] == jsoncons::csv::detail::string_literal()()) - { - column_types_.emplace_back(csv_column_type::string_t,0); - } - else if (value[i] == jsoncons::csv::detail::integer_literal()()) - { - column_types_.emplace_back(csv_column_type::integer_t,0); - } - else if (value[i] == jsoncons::csv::detail::float_literal()()) - { - column_types_.emplace_back(csv_column_type::float_t,0); - } - else if (value[i] == jsoncons::csv::detail::boolean_literal()()) - { - column_types_.emplace_back(csv_column_type::boolean_t,0); - } - } - } - return *this; - } -#endif - basic_csv_options& column_names(const string_type& names) - { - column_names_ = parse_column_names(names); - return *this; - } - - std::vector column_types() const override - { - return column_types_; - } - - basic_csv_options& column_types(const string_type& types) - { - column_types_ = parse_column_types(types); - return *this; - } - - std::vector column_defaults() const override - { - return column_defaults_; - } - - basic_csv_options& column_defaults(const string_type& defaults) - { - column_defaults_ = parse_column_names(defaults); - return *this; - } - - CharT field_delimiter() const override - { - return field_delimiter_; - } - - const std::pair& subfield_delimiter() const override - { - return subfield_delimiter_; - } - - basic_csv_options& field_delimiter(CharT value) - { - field_delimiter_ = value; - return *this; - } - - basic_csv_options& subfield_delimiter(CharT value) - { - subfield_delimiter_ = std::make_pair(value,true); - return *this; - } - - string_type line_delimiter() const override - { - return line_delimiter_; - } - - basic_csv_options& line_delimiter(string_type value) - { - line_delimiter_ = value; - return *this; - } - - CharT quote_char() const override - { - return quote_char_; - } - - basic_csv_options& quote_char(CharT value) - { - quote_char_ = value; - return *this; - } - - bool infer_types() const override - { - return infer_types_; - } - - basic_csv_options& infer_types(bool value) - { - infer_types_ = value; - return *this; - } - - bool lossless_number() const override - { - return lossless_number_; - } - - basic_csv_options& lossless_number(bool value) - { - lossless_number_ = value; - return *this; - } - - CharT quote_escape_char() const override - { - return quote_escape_char_; - } - - basic_csv_options& quote_escape_char(CharT value) - { - quote_escape_char_ = value; - return *this; - } - - CharT comment_starter() const override - { - return comment_starter_; - } - - basic_csv_options& comment_starter(CharT value) - { - comment_starter_ = value; - return *this; - } - - quote_style_type quote_style() const override - { - return quote_style_; - } - - mapping_type mapping() const override - { - return mapping_.second ? (mapping_.first) : (assume_header() || column_names_.size() > 0 ? mapping_type::n_objects : mapping_type::n_rows); - } - - basic_csv_options& quote_style(quote_style_type value) - { - quote_style_ = value; - return *this; - } - - basic_csv_options& mapping(mapping_type value) - { - mapping_ = {value,true}; - return *this; - } - - unsigned long max_lines() const override - { - return max_lines_; - } - - basic_csv_options& max_lines(unsigned long value) - { - max_lines_ = value; - return *this; - } - - static std::vector parse_column_names(const string_type& names) - { - std::vector column_names; - - column_state state = column_state::sequence; - string_type buffer; - - auto p = names.begin(); - while (p != names.end()) - { - switch (state) - { - case column_state::sequence: - { - switch (*p) - { - case ' ': case '\t':case '\r': case '\n': - ++p; - break; - default: - buffer.clear(); - state = column_state::label; - break; - } - break; - } - case column_state::label: - { - switch (*p) - { - case ',': - column_names.push_back(buffer); - buffer.clear(); - ++p; - state = column_state::sequence; - break; - default: - buffer.push_back(*p); - ++p; - break; - } - break; - } - } - } - if (state == column_state::label) - { - column_names.push_back(buffer); - buffer.clear(); - } - return column_names; - } - - static std::vector parse_column_types(const string_type& types) - { - const std::unordered_map,std::equal_to> type_dictionary = - { - - {detail::string_literal(),csv_column_type::string_t}, - {detail::integer_literal(),csv_column_type::integer_t}, - {detail::float_literal(),csv_column_type::float_t}, - {detail::boolean_literal(),csv_column_type::boolean_t} - }; - - std::vector column_types; - - column_state state = column_state::sequence; - int depth = 0; - string_type buffer; - - auto p = types.begin(); - while (p != types.end()) - { - switch (state) - { - case column_state::sequence: - { - switch (*p) - { - case ' ': case '\t':case '\r': case '\n': - ++p; - break; - case '[': - ++depth; - ++p; - break; - case ']': - JSONCONS_ASSERT(depth > 0); - --depth; - ++p; - break; - case '*': - { - JSONCONS_ASSERT(column_types.size() != 0); - size_t offset = 0; - size_t level = column_types.size() > 0 ? column_types.back().level: 0; - if (level > 0) - { - for (auto it = column_types.rbegin(); - it != column_types.rend() && level == it->level; - ++it) - { - ++offset; - } - } - else - { - offset = 1; - } - column_types.emplace_back(csv_column_type::repeat_t,depth,offset); - ++p; - break; - } - default: - buffer.clear(); - state = column_state::label; - break; - } - break; - } - case column_state::label: - { - switch (*p) - { - case '*': - { - auto it = type_dictionary.find(buffer); - if (it != type_dictionary.end()) - { - column_types.emplace_back(it->second,depth); - buffer.clear(); - } - else - { - JSONCONS_ASSERT(false); - } - state = column_state::sequence; - break; - } - case ',': - { - auto it = type_dictionary.find(buffer); - if (it != type_dictionary.end()) - { - column_types.emplace_back(it->second,depth); - buffer.clear(); - } - else - { - JSONCONS_ASSERT(false); - } - ++p; - state = column_state::sequence; - break; - } - case ']': - { - JSONCONS_ASSERT(depth > 0); - auto it = type_dictionary.find(buffer); - if (it != type_dictionary.end()) - { - column_types.emplace_back(it->second,depth); - buffer.clear(); - } - else - { - JSONCONS_ASSERT(false); - } - --depth; - ++p; - state = column_state::sequence; - break; - } - default: - { - buffer.push_back(*p); - ++p; - break; - } - } - break; - } - } - } - if (state == column_state::label) - { - auto it = type_dictionary.find(buffer); - if (it != type_dictionary.end()) - { - column_types.emplace_back(it->second,depth); - buffer.clear(); - } - else - { - JSONCONS_ASSERT(false); - } - } - return column_types; - } - -}; - -typedef basic_csv_options csv_options; -typedef basic_csv_options wcsv_options; - -#if !defined(JSONCONS_NO_DEPRECATED) -typedef basic_csv_options csv_parameters; -typedef basic_csv_options wcsv_parameters; -typedef basic_csv_options csv_serializing_options; -typedef basic_csv_options wcsv_serializing_options; -#endif - - -}} -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/csv/csv_parser.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/csv/csv_parser.hpp deleted file mode 100644 index 51d131d9c1..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/csv/csv_parser.hpp +++ /dev/null @@ -1,1357 +0,0 @@ -// Copyright 2015 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_CSV_CSV_PARSER_HPP -#define JSONCONS_CSV_CSV_PARSER_HPP - -#include // std::allocator -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace jsoncons { namespace csv { - -enum class csv_mode_type -{ - initial, - header, - data, - subfields -}; - -enum class csv_state_type -{ - start, - comment, - expect_value, - between_fields, - quoted_string, - unquoted_string, - escaped_value, - minus, - zero, - integer, - fraction, - exp1, - exp2, - exp3, - done -}; - -template> -class basic_csv_parser : public ser_context -{ - typedef basic_string_view string_view_type; - typedef CharT char_type; - typedef Allocator allocator_type; - typedef typename std::allocator_traits:: template rebind_alloc char_allocator_type; - typedef std::basic_string,char_allocator_type> string_type; - typedef typename std::allocator_traits:: template rebind_alloc string_allocator_type; - typedef typename std::allocator_traits:: template rebind_alloc csv_mode_allocator_type; - typedef typename std::allocator_traits:: template rebind_alloc csv_type_info_allocator_type; - typedef typename std::allocator_traits:: template rebind_alloc> string_vector_allocator_type; - typedef basic_json json_type; - - static const int default_depth = 3; - - default_parse_error_handler default_err_handler_; - csv_state_type state_; - int top_; - std::vector stack_; - basic_json_content_handler& handler_; - parse_error_handler& err_handler_; - unsigned long column_; - unsigned long line_; - CharT prev_char_; - string_type value_buffer_; - int depth_; - const basic_csv_decode_options& options_; - std::vector column_names_; - std::vector,string_vector_allocator_type> column_values_; - std::vector column_types_; - std::vector column_defaults_; - size_t column_index_; - basic_json_fragment_filter filter_; - size_t level_; - size_t offset_; - jsoncons::detail::string_to_double to_double_; - std::vector> decoders_; - const CharT* begin_input_; - const CharT* input_end_; - const CharT* input_ptr_; - bool continue_; - -public: - basic_csv_parser(basic_json_content_handler& handler) - : basic_csv_parser(handler, basic_csv_options::default_options(), default_err_handler_) - { - } - - basic_csv_parser(basic_json_content_handler& handler, - const basic_csv_decode_options& options) - : basic_csv_parser(handler, options, default_err_handler_) - { - } - - basic_csv_parser(basic_json_content_handler& handler, - parse_error_handler& err_handler) - : basic_csv_parser(handler, basic_csv_options::default_options(), err_handler) - { - } - - basic_csv_parser(basic_json_content_handler& handler, - const basic_csv_decode_options& options, - parse_error_handler& err_handler) - : top_(-1), - stack_(default_depth), - handler_(handler), - err_handler_(err_handler), - options_(options), - filter_(handler), - level_(0), - offset_(0), - begin_input_(nullptr), - input_end_(nullptr), - input_ptr_(nullptr), - continue_(true) - { - depth_ = default_depth; - state_ = csv_state_type::start; - top_ = -1; - line_ = 1; - column_ = 0; - column_index_ = 0; - } - - ~basic_csv_parser() - { - } - - bool done() const - { - return state_ == csv_state_type::done; - } - - bool stopped() const - { - return !continue_; - } - - bool source_exhausted() const - { - return input_ptr_ == input_end_; - } - - const std::vector>& column_labels() const - { - return column_names_; - } - - void before_field() - { - switch (stack_[top_]) - { - case csv_mode_type::header: - if (options_.assume_header() && line_ == 1) - { - column_names_.push_back(value_buffer_); - } - break; - case csv_mode_type::data: - case csv_mode_type::subfields: - switch (options_.mapping()) - { - case mapping_type::n_objects: - if (!(options_.ignore_empty_values() && value_buffer_.size() == 0)) - { - if (column_index_ < column_names_.size() + offset_) - { - continue_ = handler_.name(column_names_[column_index_ - offset_], *this); - } - } - break; - default: - break; - } - break; - default: - break; - } - } - - void before_multi_valued_field() - { - push_mode(csv_mode_type::subfields); - switch (options_.mapping()) - { - case mapping_type::n_rows: - case mapping_type::n_objects: - continue_ = handler_.begin_array(semantic_tag::none, *this); - break; - case mapping_type::m_columns: - decoders_[column_index_].begin_array(semantic_tag::none, *this); - break; - default: - break; - } - } - - void after_field() - { - if (stack_[top_] == csv_mode_type::subfields) - { - pop_mode(csv_mode_type::subfields); - switch (options_.mapping()) - { - case mapping_type::n_rows: - case mapping_type::n_objects: - continue_ = handler_.end_array(*this); - break; - case mapping_type::m_columns: - decoders_[column_index_].end_array(*this); - break; - default: - break; - } - } - ++column_index_; - } - - void before_record() - { - offset_ = 0; - if (stack_[top_] == csv_mode_type::data) - { - switch (options_.mapping()) - { - case mapping_type::n_rows: - continue_ = handler_.begin_array(semantic_tag::none, *this); - break; - case mapping_type::n_objects: - continue_ = handler_.begin_object(semantic_tag::none, *this); - break; - case mapping_type::m_columns: - break; - default: - break; - } - } - } - - void after_record() - { - if (column_types_.size() > 0) - { - if (level_ > 0) - { - continue_ = handler_.end_array(*this); - level_ = 0; - } - } - if (stack_[top_] == csv_mode_type::header) - { - if (line_ >= options_.header_lines()) - { - flip(csv_mode_type::header, csv_mode_type::data); - } - column_values_.resize(column_names_.size()); - switch (options_.mapping()) - { - case mapping_type::n_rows: - if (column_names_.size() > 0) - { - continue_ = handler_.begin_array(semantic_tag::none, *this); - for (const auto& name : column_names_) - { - continue_ = handler_.string_value(name, semantic_tag::none, *this); - } - continue_ = handler_.end_array(*this); - } - break; - case mapping_type::m_columns: - for (size_t i = 0; i < column_names_.size(); ++i) - { - decoders_.push_back(json_decoder()); - decoders_.back().begin_array(semantic_tag::none, *this); - } - break; - default: - break; - } - } - else if (stack_[top_] == csv_mode_type::data || stack_[top_] == csv_mode_type::subfields) - { - switch (options_.mapping()) - { - case mapping_type::n_rows: - continue_ = handler_.end_array(*this); - break; - case mapping_type::n_objects: - continue_ = handler_.end_object(*this); - break; - default: - break; - } - } - column_index_ = 0; - } - - void reset() - { - push_mode(csv_mode_type::initial); - - for (auto name : options_.column_names()) - { - column_names_.emplace_back(name.data(),name.size()); - } - for (auto name : options_.column_types()) - { - column_types_.push_back(name); - } - for (auto name : options_.column_defaults()) - { - column_defaults_.emplace_back(name.data(), name.size()); - } - if (options_.header_lines() > 0) - { - push_mode(csv_mode_type::header); - } - else - { - push_mode(csv_mode_type::data); - } - if (options_.mapping() != mapping_type::m_columns) - { - continue_ = handler_.begin_array(semantic_tag::none, *this); - } - state_ = csv_state_type::expect_value; - column_index_ = 0; - prev_char_ = 0; - column_ = 1; - level_ = 0; - } - - void parse_some() - { - std::error_code ec; - parse_some(ec); - if (ec) - { - throw ser_error(ec,line_,column_); - } - } - - void parse_some(std::error_code& ec) - { - const CharT* local_input_end = input_end_; - - if (input_ptr_ == local_input_end && continue_) - { - switch (state_) - { - case csv_state_type::unquoted_string: - if (options_.trim_leading() || options_.trim_trailing()) - { - trim_string_buffer(options_.trim_leading(),options_.trim_trailing()); - } - if (!options_.ignore_empty_lines() || (column_index_ > 0 || value_buffer_.length() > 0)) - { - if (column_index_ == 0) - { - before_record(); - } - if (stack_[top_] != csv_mode_type::subfields) - { - before_field(); - } - end_unquoted_string_value(); - after_field(); - } - break; - case csv_state_type::escaped_value: - if (options_.quote_escape_char() == options_.quote_char()) - { - if (column_index_ == 0) - { - before_record(); - } - if (stack_[top_] != csv_mode_type::subfields) - { - before_field(); - } - end_quoted_string_value(ec); - if (ec) return; - after_field(); - } - break; - default: - break; - } - if (column_index_ > 0) - { - after_record(); - } - switch (stack_[top_]) - { - case csv_mode_type::header: - pop_mode(csv_mode_type::header); - break; - case csv_mode_type::data: - pop_mode(csv_mode_type::data); - break; - default: - break; - } - if (options_.mapping() == mapping_type::m_columns) - { - basic_json_fragment_filter fragment_filter(handler_); - continue_ = handler_.begin_object(semantic_tag::none, *this); - for (size_t i = 0; i < column_names_.size(); ++i) - { - continue_ = handler_.name(column_names_[i],*this); - decoders_[i].end_array(*this); - decoders_[i].flush(); - decoders_[i].get_result().dump(fragment_filter); - } - continue_ = handler_.end_object(*this); - } - else - { - continue_ = handler_.end_array(*this); - } - if (!pop_mode(csv_mode_type::initial)) - { - err_handler_.fatal_error(csv_errc::unexpected_eof, *this); - ec = csv_errc::unexpected_eof; - continue_ = false; - return; - } - handler_.flush(); - continue_ = false; - } - - for (; (input_ptr_ < local_input_end) && continue_; ++input_ptr_) - { - CharT curr_char = *input_ptr_; -all_csv_states: - switch (state_) - { - case csv_state_type::comment: - if (curr_char == '\n') - { - state_ = csv_state_type::expect_value; - } - else if (prev_char_ == '\r') - { - state_ = csv_state_type::expect_value; - goto all_csv_states; - } - break; - case csv_state_type::expect_value: - if (column_ == 1 && curr_char == options_.comment_starter()) - { - state_ = csv_state_type::comment; - } - else - { - state_ = csv_state_type::unquoted_string; - goto all_csv_states; - } - break; - case csv_state_type::escaped_value: - { - if (curr_char == options_.quote_char()) - { - value_buffer_.push_back(static_cast(curr_char)); - state_ = csv_state_type::quoted_string; - } - else if (options_.quote_escape_char() == options_.quote_char()) - { - state_ = csv_state_type::between_fields; - goto all_csv_states; - } - } - break; - case csv_state_type::quoted_string: - { - if (curr_char == options_.quote_escape_char()) - { - state_ = csv_state_type::escaped_value; - } - else if (curr_char == options_.quote_char()) - { - state_ = csv_state_type::between_fields; - } - else - { - value_buffer_.push_back(static_cast(curr_char)); - } - } - break; - case csv_state_type::between_fields: - if (prev_char_ == '\r' && curr_char == '\n') - { - } - else if (curr_char == '\r' || curr_char == '\n') - { - if (options_.trim_leading() || options_.trim_trailing()) - { - trim_string_buffer(options_.trim_leading(),options_.trim_trailing()); - } - if (!options_.ignore_empty_lines() || (column_index_ > 0 || value_buffer_.length() > 0)) - { - if (column_index_ == 0) - { - before_record(); - } - if (stack_[top_] != csv_mode_type::subfields) - { - before_field(); - } - end_quoted_string_value(ec); - if (ec) return; - after_field(); - after_record(); - } - state_ = csv_state_type::expect_value; - } - else if (curr_char == options_.field_delimiter() || (options_.subfield_delimiter().second && curr_char == options_.subfield_delimiter().first)) - { - if (column_index_ == 0 && stack_[top_] != csv_mode_type::subfields) - { - before_record(); - } - if (options_.trim_leading() || options_.trim_trailing()) - { - trim_string_buffer(options_.trim_leading(),options_.trim_trailing()); - } - if (stack_[top_] != csv_mode_type::subfields) - { - before_field(); - if (options_.subfield_delimiter().second && curr_char == options_.subfield_delimiter().first) - { - before_multi_valued_field(); - } - } - end_quoted_string_value(ec); - if (ec) return; - if (curr_char == options_.field_delimiter()) - { - after_field(); - } - state_ = csv_state_type::unquoted_string; - } - break; - case csv_state_type::unquoted_string: - { - if (prev_char_ == '\r' && curr_char == '\n') - { - } - else if (curr_char == '\r' || curr_char == '\n') - { - if (options_.trim_leading() || options_.trim_trailing()) - { - trim_string_buffer(options_.trim_leading(),options_.trim_trailing()); - } - if (!options_.ignore_empty_lines() || (column_index_ > 0 || value_buffer_.length() > 0)) - { - if (column_index_ == 0) - { - before_record(); - } - if (stack_[top_] != csv_mode_type::subfields) - { - before_field(); - } - end_unquoted_string_value(); - after_field(); - after_record(); - } - state_ = csv_state_type::expect_value; - } - else if (curr_char == options_.field_delimiter() || (options_.subfield_delimiter().second && curr_char == options_.subfield_delimiter().first)) - { - if (column_index_ == 0 && stack_[top_] != csv_mode_type::subfields) - { - before_record(); - } - if (options_.trim_leading() || options_.trim_trailing()) - { - trim_string_buffer(options_.trim_leading(),options_.trim_trailing()); - } - if (stack_[top_] != csv_mode_type::subfields) - { - before_field(); - if (options_.subfield_delimiter().second && curr_char == options_.subfield_delimiter().first) - { - before_multi_valued_field(); - } - } - end_unquoted_string_value(); - if (curr_char == options_.field_delimiter()) - { - after_field(); - } - state_ = csv_state_type::unquoted_string; - } - else if (curr_char == options_.quote_char()) - { - value_buffer_.clear(); - state_ = csv_state_type::quoted_string; - } - else - { - value_buffer_.push_back(static_cast(curr_char)); - } - } - break; - default: - err_handler_.fatal_error(csv_errc::invalid_state, *this); - ec = csv_errc::invalid_state; - continue_ = false; - return; - } - if (line_ > options_.max_lines()) - { - state_ = csv_state_type::done; - continue_ = false; - } - switch (curr_char) - { - case '\r': - ++line_; - column_ = 1; - break; - case '\n': - if (prev_char_ != '\r') - { - ++line_; - } - column_ = 1; - break; - default: - ++column_; - break; - } - prev_char_ = curr_char; - } - } - - void finish_parse() - { - std::error_code ec; - finish_parse(ec); - if (ec) - { - throw ser_error(ec,line_,column_); - } - } - - void finish_parse(std::error_code& ec) - { - while (continue_) - { - parse_some(ec); - } - } - - csv_state_type state() const - { - return state_; - } - - void update(const string_view_type sv) - { - update(sv.data(),sv.length()); - } - - void update(const CharT* data, size_t length) - { - begin_input_ = data; - input_end_ = data + length; - input_ptr_ = begin_input_; - } - - size_t line() const override - { - return line_; - } - - size_t column() const override - { - return column_; - } -private: - - void trim_string_buffer(bool trim_leading, bool trim_trailing) - { - size_t start = 0; - size_t length = value_buffer_.length(); - if (trim_leading) - { - bool done = false; - while (!done && start < value_buffer_.length()) - { - if ((value_buffer_[start] < 256) && std::isspace(value_buffer_[start])) - { - ++start; - } - else - { - done = true; - } - } - } - if (trim_trailing) - { - bool done = false; - while (!done && length > 0) - { - if ((value_buffer_[length-1] < 256) && std::isspace(value_buffer_[length-1])) - { - --length; - } - else - { - done = true; - } - } - } - if (start != 0 || length != value_buffer_.size()) - { - value_buffer_ = value_buffer_.substr(start,length-start); - } - } - - void end_unquoted_string_value() - { - switch (stack_[top_]) - { - case csv_mode_type::data: - case csv_mode_type::subfields: - switch (options_.mapping()) - { - case mapping_type::n_rows: - if (options_.unquoted_empty_value_is_null() && value_buffer_.length() == 0) - { - continue_ = handler_.null_value(semantic_tag::none, *this); - } - else - { - end_value(value_buffer_,column_index_,options_.infer_types(),handler_); - } - break; - case mapping_type::n_objects: - if (!(options_.ignore_empty_values() && value_buffer_.size() == 0)) - { - if (column_index_ < column_names_.size() + offset_) - { - if (options_.unquoted_empty_value_is_null() && value_buffer_.length() == 0) - { - continue_ = handler_.null_value(semantic_tag::none, *this); - } - else - { - end_value(value_buffer_,column_index_,options_.infer_types(),handler_); - } - } - else if (level_ > 0) - { - if (options_.unquoted_empty_value_is_null() && value_buffer_.length() == 0) - { - continue_ = handler_.null_value(semantic_tag::none, *this); - } - else - { - end_value(value_buffer_,column_index_,options_.infer_types(),handler_); - } - } - } - break; - case mapping_type::m_columns: - if (column_index_ < decoders_.size()) - { - if (!(options_.ignore_empty_values() && value_buffer_.size() == 0)) - { - end_value(value_buffer_,column_index_,options_.infer_types(),decoders_[column_index_]); - } - } - break; - } - break; - default: - break; - } - state_ = csv_state_type::expect_value; - value_buffer_.clear(); - } - - void end_quoted_string_value(std::error_code& ec) - { - if (options_.trim_leading_inside_quotes() | options_.trim_trailing_inside_quotes()) - { - trim_string_buffer(options_.trim_leading_inside_quotes(),options_.trim_trailing_inside_quotes()); - } - switch (stack_[top_]) - { - case csv_mode_type::header: - break; - case csv_mode_type::data: - case csv_mode_type::subfields: - switch (options_.mapping()) - { - case mapping_type::n_rows: - end_value(value_buffer_,column_index_,false,handler_); - break; - case mapping_type::n_objects: - if (!(options_.ignore_empty_values() && value_buffer_.size() == 0)) - { - if (column_index_ < column_names_.size() + offset_) - { - if (options_.unquoted_empty_value_is_null() && value_buffer_.length() == 0) - { - continue_ = handler_.null_value(semantic_tag::none, *this); - } - else - { - end_value(value_buffer_,column_index_,false,handler_); - } - } - else if (level_ > 0) - { - if (options_.unquoted_empty_value_is_null() && value_buffer_.length() == 0) - { - continue_ = handler_.null_value(semantic_tag::none, *this); - } - else - { - end_value(value_buffer_,column_index_,false,handler_); - } - } - } - break; - case mapping_type::m_columns: - if (column_index_ < decoders_.size()) - { - end_value(value_buffer_,column_index_,options_.infer_types(),decoders_[column_index_]); - } - break; - } - break; - default: - err_handler_.fatal_error(csv_errc::invalid_csv_text, *this); - ec = csv_errc::invalid_csv_text; - continue_ = false; - return; - } - state_ = csv_state_type::expect_value; - value_buffer_.clear(); - } - - void end_value(const string_view_type& value, - size_t column_index, - bool infer_types, - basic_json_content_handler& handler) - { - if (column_index < column_types_.size() + offset_) - { - if (column_types_[column_index - offset_].col_type == csv_column_type::repeat_t) - { - offset_ = offset_ + column_types_[column_index - offset_].rep_count; - if (column_index - offset_ + 1 < column_types_.size()) - { - if (column_index == offset_ || level_ > column_types_[column_index-offset_].level) - { - handler.end_array(*this); - } - level_ = column_index == offset_ ? 0 : column_types_[column_index - offset_].level; - } - } - if (level_ < column_types_[column_index - offset_].level) - { - handler.begin_array(semantic_tag::none, *this); - level_ = column_types_[column_index - offset_].level; - } - else if (level_ > column_types_[column_index - offset_].level) - { - handler.end_array(*this); - level_ = column_types_[column_index - offset_].level; - } - switch (column_types_[column_index - offset_].col_type) - { - case csv_column_type::integer_t: - { - std::istringstream iss{ std::string(value) }; - int64_t val; - iss >> val; - if (!iss.fail()) - { - handler.int64_value(val, semantic_tag::none, *this); - } - else - { - if (column_index - offset_ < column_defaults_.size() && column_defaults_[column_index - offset_].length() > 0) - { - basic_json_parser parser(err_handler_); - parser.update(column_defaults_[column_index - offset_].data(),column_defaults_[column_index - offset_].length()); - parser.parse_some(filter_); - parser.finish_parse(filter_); - } - else - { - handler.null_value(semantic_tag::none, *this); - } - } - } - break; - case csv_column_type::float_t: - { - if (options_.lossless_number()) - { - handler.string_value(value,semantic_tag::bigdec, *this); - } - else - { - std::istringstream iss{ std::string(value) }; - double val; - iss >> val; - if (!iss.fail()) - { - handler.double_value(val, semantic_tag::none, *this); - } - else - { - if (column_index - offset_ < column_defaults_.size() && column_defaults_[column_index - offset_].length() > 0) - { - basic_json_parser parser(err_handler_); - parser.update(column_defaults_[column_index - offset_].data(),column_defaults_[column_index - offset_].length()); - parser.parse_some(filter_); - parser.finish_parse(filter_); - } - else - { - handler.null_value(semantic_tag::none, *this); - } - } - } - } - break; - case csv_column_type::boolean_t: - { - if (value.length() == 1 && value[0] == '0') - { - handler.bool_value(false, semantic_tag::none, *this); - } - else if (value.length() == 1 && value[0] == '1') - { - handler.bool_value(true, semantic_tag::none, *this); - } - else if (value.length() == 5 && ((value[0] == 'f' || value[0] == 'F') && (value[1] == 'a' || value[1] == 'A') && (value[2] == 'l' || value[2] == 'L') && (value[3] == 's' || value[3] == 'S') && (value[4] == 'e' || value[4] == 'E'))) - { - handler.bool_value(false, semantic_tag::none, *this); - } - else if (value.length() == 4 && ((value[0] == 't' || value[0] == 'T') && (value[1] == 'r' || value[1] == 'R') && (value[2] == 'u' || value[2] == 'U') && (value[3] == 'e' || value[3] == 'E'))) - { - handler.bool_value(true, semantic_tag::none, *this); - } - else - { - if (column_index - offset_ < column_defaults_.size() && column_defaults_[column_index - offset_].length() > 0) - { - basic_json_parser parser(err_handler_); - parser.update(column_defaults_[column_index - offset_].data(),column_defaults_[column_index - offset_].length()); - parser.parse_some(filter_); - parser.finish_parse(filter_); - } - else - { - handler.null_value(semantic_tag::none, *this); - } - } - } - break; - default: - if (value.length() > 0) - { - handler.string_value(value, semantic_tag::none, *this); - } - else - { - if (column_index < column_defaults_.size() + offset_ && column_defaults_[column_index - offset_].length() > 0) - { - basic_json_parser parser(err_handler_); - parser.update(column_defaults_[column_index - offset_].data(),column_defaults_[column_index - offset_].length()); - parser.parse_some(filter_); - parser.finish_parse(filter_); - } - else - { - handler.string_value(string_view_type(), semantic_tag::none, *this); - } - } - break; - } - } - else - { - if (infer_types) - { - end_value_with_numeric_check(value, handler); - } - else - { - handler.string_value(value, semantic_tag::none, *this); - } - } - } - - enum class numeric_check_state - { - initial, - null, - boolean_true, - boolean_false, - minus, - zero, - integer, - fraction1, - fraction, - exp1, - exp, - done - }; - - void end_value_with_numeric_check(const string_view_type& value, basic_json_content_handler& handler) - { - numeric_check_state state = numeric_check_state::initial; - bool is_negative = false; - int precision = 0; - uint8_t decimal_places = 0; - - auto last = value.end(); - - std::string buffer; - for (auto p = value.begin(); state != numeric_check_state::done && p != last; ++p) - { - switch (state) - { - case numeric_check_state::initial: - { - switch (*p) - { - case 'n':case 'N': - if ((last-p) == 4 && (p[1] == 'u' || p[1] == 'U') && (p[2] == 'l' || p[2] == 'L') && (p[3] == 'l' || p[3] == 'L')) - { - state = numeric_check_state::null; - } - else - { - state = numeric_check_state::done; - } - break; - case 't':case 'T': - if ((last-p) == 4 && (p[1] == 'r' || p[1] == 'R') && (p[2] == 'u' || p[2] == 'U') && (p[3] == 'e' || p[3] == 'U')) - { - state = numeric_check_state::boolean_true; - } - else - { - state = numeric_check_state::done; - } - break; - case 'f':case 'F': - if ((last-p) == 5 && (p[1] == 'a' || p[1] == 'A') && (p[2] == 'l' || p[2] == 'L') && (p[3] == 's' || p[3] == 'S') && (p[4] == 'e' || p[4] == 'E')) - { - state = numeric_check_state::boolean_false; - } - else - { - state = numeric_check_state::done; - } - break; - case '-': - is_negative = true; - buffer.push_back(*p); - state = numeric_check_state::minus; - break; - case '0': - ++precision; - buffer.push_back(*p); - state = numeric_check_state::zero; - break; - case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8':case '9': - ++precision; - buffer.push_back(*p); - state = numeric_check_state::integer; - break; - default: - state = numeric_check_state::done; - break; - } - break; - } - case numeric_check_state::zero: - { - switch (*p) - { - case '.': - buffer.push_back(to_double_.get_decimal_point()); - state = numeric_check_state::fraction1; - break; - case 'e':case 'E': - buffer.push_back(*p); - state = numeric_check_state::exp1; - break; - default: - state = numeric_check_state::done; - break; - } - break; - } - case numeric_check_state::integer: - { - switch (*p) - { - case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8':case '9': - ++precision; - buffer.push_back(*p); - break; - case '.': - buffer.push_back(to_double_.get_decimal_point()); - state = numeric_check_state::fraction1; - break; - case 'e':case 'E': - buffer.push_back(*p); - state = numeric_check_state::exp1; - break; - default: - state = numeric_check_state::done; - break; - } - break; - } - case numeric_check_state::minus: - { - switch (*p) - { - case '0': - ++precision; - buffer.push_back(*p); - state = numeric_check_state::zero; - break; - case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8':case '9': - ++precision; - buffer.push_back(*p); - state = numeric_check_state::integer; - break; - case 'e':case 'E': - buffer.push_back(*p); - state = numeric_check_state::exp1; - break; - default: - state = numeric_check_state::done; - break; - } - break; - } - case numeric_check_state::fraction1: - { - switch (*p) - { - case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8':case '9': - ++precision; - ++decimal_places; - buffer.push_back(*p); - state = numeric_check_state::fraction; - break; - default: - state = numeric_check_state::done; - break; - } - break; - } - case numeric_check_state::fraction: - { - switch (*p) - { - case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8':case '9': - ++precision; - ++decimal_places; - buffer.push_back(*p); - break; - case 'e':case 'E': - buffer.push_back(*p); - state = numeric_check_state::exp1; - break; - default: - state = numeric_check_state::done; - break; - } - break; - } - case numeric_check_state::exp1: - { - switch (*p) - { - case '-': - buffer.push_back(*p); - state = numeric_check_state::exp; - break; - case '+': - state = numeric_check_state::exp; - break; - case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8':case '9': - buffer.push_back(*p); - state = numeric_check_state::integer; - break; - default: - state = numeric_check_state::done; - break; - } - break; - } - case numeric_check_state::exp: - { - switch (*p) - { - case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8':case '9': - buffer.push_back(*p); - break; - default: - state = numeric_check_state::done; - break; - } - break; - } - default: - break; - } - } - - switch (state) - { - case numeric_check_state::null: - handler.null_value(semantic_tag::none, *this); - break; - case numeric_check_state::boolean_true: - handler.bool_value(true, semantic_tag::none, *this); - break; - case numeric_check_state::boolean_false: - handler.bool_value(false, semantic_tag::none, *this); - break; - case numeric_check_state::zero: - case numeric_check_state::integer: - { - if (is_negative) - { - auto result = jsoncons::detail::to_integer(value.data(), value.length()); - if (result.ec == jsoncons::detail::to_integer_errc()) - { - handler.int64_value(result.value, semantic_tag::none, *this); - } - else // Must be overflow - { - handler.string_value(value, semantic_tag::bigint, *this); - } - } - else - { - auto result = jsoncons::detail::to_integer(value.data(), value.length()); - if (result.ec == jsoncons::detail::to_integer_errc()) - { - handler.uint64_value(result.value, semantic_tag::none, *this); - } - else if (result.ec == jsoncons::detail::to_integer_errc::overflow) - { - handler.string_value(value, semantic_tag::bigint, *this); - } - else - { - JSONCONS_THROW(json_runtime_error(make_error_code(result.ec).message())); - } - } - break; - } - case numeric_check_state::fraction: - case numeric_check_state::exp: - { - if (options_.lossless_number()) - { - handler.string_value(value,semantic_tag::bigdec, *this); - } - else - { - double d = to_double_(buffer.c_str(), buffer.length()); - handler.double_value(d, semantic_tag::none, *this); - } - break; - } - default: - handler.string_value(value, semantic_tag::none, *this); - } - } - - void push_mode(csv_mode_type mode) - { - ++top_; - if (top_ >= depth_) - { - depth_ *= 2; - stack_.resize(depth_); - } - stack_[top_] = mode; - } - - int peek() - { - return stack_[top_]; - } - - bool peek(csv_mode_type mode) - { - return stack_[top_] == mode; - } - - bool flip(csv_mode_type mode1, csv_mode_type mode2) - { - if (top_ < 0 || stack_[top_] != mode1) - { - return false; - } - stack_[top_] = mode2; - return true; - } - - bool pop_mode(csv_mode_type mode) - { - if (top_ < 0 || stack_[top_] != mode) - { - return false; - } - --top_; - return true; - } -}; - -typedef basic_csv_parser csv_parser; -typedef basic_csv_parser wcsv_parser; - -}} - -#endif - diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/csv/csv_reader.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/csv/csv_reader.hpp deleted file mode 100644 index 46d94a50b1..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/csv/csv_reader.hpp +++ /dev/null @@ -1,328 +0,0 @@ -// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_CSV_CSV_READER_HPP -#define JSONCONS_CSV_CSV_READER_HPP - -#include -#include -#include -#include // std::allocator -#include // std::move -#include // std::basic_istream -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace jsoncons { namespace csv { - -template,class Allocator=std::allocator> -class basic_csv_reader -{ - struct stack_item - { - stack_item() - : array_begun_(false) - { - } - - bool array_begun_; - }; - typedef CharT char_type; - typedef Allocator allocator_type; - typedef typename std::allocator_traits:: template rebind_alloc char_allocator_type; - - basic_csv_reader(const basic_csv_reader&) = delete; - basic_csv_reader& operator = (const basic_csv_reader&) = delete; - - default_parse_error_handler default_err_handler_; - - basic_csv_parser parser_; - Src source_; - std::vector buffer_; - size_t buffer_length_; - bool eof_; - bool begin_; -public: - // Structural characters - static const size_t default_max_buffer_length = 16384; - //! Parse an input stream of CSV text into a json object - /*! - \param is The input stream to read from - */ - - template - basic_csv_reader(Source&& source, - basic_json_content_handler& handler) - - : basic_csv_reader(std::forward(source), - handler, - basic_csv_options::default_options(), - default_err_handler_) - { - } - - template - basic_csv_reader(Source&& source, - basic_json_content_handler& handler, - const basic_csv_options& options) - - : basic_csv_reader(std::forward(source), - handler, - options, - default_err_handler_) - { - } - - template - basic_csv_reader(Source&& source, - basic_json_content_handler& handler, - parse_error_handler& err_handler) - : basic_csv_reader(std::forward(source), - handler, - basic_csv_options::default_options(), - err_handler) - { - } - - template - basic_csv_reader(Source&& source, - basic_json_content_handler& handler, - const basic_csv_decode_options& options, - parse_error_handler& err_handler, - typename std::enable_if,Source>::value>::type* = 0) - : - parser_(handler, options, err_handler), - source_(std::forward(source)), - buffer_length_(default_max_buffer_length), - eof_(false), - begin_(true) - { - buffer_.reserve(buffer_length_); - } - - template - basic_csv_reader(Source&& source, - basic_json_content_handler& handler, - const basic_csv_decode_options& options, - parse_error_handler& err_handler, - typename std::enable_if,Source>::value>::type* = 0) - : - parser_(handler, options, err_handler), - buffer_length_(0), - eof_(false), - begin_(false) - { - basic_string_view sv(std::forward(source)); - auto result = unicons::skip_bom(sv.begin(), sv.end()); - if (result.ec != unicons::encoding_errc()) - { - throw ser_error(result.ec,parser_.line(),parser_.column()); - } - size_t offset = result.it - sv.begin(); - parser_.update(sv.data()+offset,sv.size()-offset); - } - - ~basic_csv_reader() - { - } - - void read() - { - std::error_code ec; - read(ec); - if (ec) - { - throw ser_error(ec,parser_.line(),parser_.column()); - } - } - - void read(std::error_code& ec) - { - try - { - read_internal(ec); - } - catch (const ser_error& e) - { - ec = e.code(); - } - } - - bool eof() const - { - return eof_; - } - - size_t buffer_length() const - { - return buffer_length_; - } - - void buffer_length(size_t length) - { - buffer_length_ = length; - buffer_.reserve(buffer_length_); - } - -#if !defined(JSONCONS_NO_DEPRECATED) - - size_t buffer_capacity() const - { - return buffer_length_; - } - - void buffer_capacity(size_t length) - { - buffer_length_ = length; - buffer_.reserve(buffer_length_); - } -#endif -private: - - void read_internal(std::error_code& ec) - { - if (source_.is_error()) - { - ec = csv_errc::source_error; - return; - } - parser_.reset(); - if (ec) - { - return; - } - while (!parser_.stopped()) - { - if (parser_.source_exhausted()) - { - if (!source_.eof()) - { - read_buffer(ec); - if (ec) - { - return; - } - /* buffer_.clear(); - buffer_.resize(buffer_length_); - size_t count = source_.read(buffer_.data(), buffer_length_); - buffer_.resize(count); - if (buffer_.size() == 0) - { - eof_ = true; - } - parser_.update(buffer_.data(),buffer_.size());*/ - } - else - { - parser_.update(buffer_.data(),0); - eof_ = true; - } - } - parser_.parse_some(ec); - if (ec) return; - } - } - void read_buffer(std::error_code& ec) - { - buffer_.clear(); - buffer_.resize(buffer_length_); - size_t count = source_.read(buffer_.data(), buffer_length_); - buffer_.resize(static_cast(count)); - if (buffer_.size() == 0) - { - eof_ = true; - } - else if (begin_) - { - auto result = unicons::skip_bom(buffer_.begin(), buffer_.end()); - if (result.ec != unicons::encoding_errc()) - { - ec = result.ec; - return; - } - size_t offset = result.it - buffer_.begin(); - parser_.update(buffer_.data()+offset,buffer_.size()-offset); - begin_ = false; - } - else - { - parser_.update(buffer_.data(),buffer_.size()); - } - } - -}; - -template -typename std::enable_if::value,T>::type -decode_csv(const std::basic_string& s, const basic_csv_options& options = basic_csv_options::default_options()) -{ - typedef CharT char_type; - - json_decoder decoder; - - basic_csv_reader> reader(s,decoder,options); - reader.read(); - return decoder.get_result(); -} - -template -typename std::enable_if::value,T>::type -decode_csv(const std::basic_string& s, const basic_csv_options& options = basic_csv_options::default_options()) -{ - typedef CharT char_type; - - json_decoder> decoder; - - basic_csv_reader> reader(s,decoder,options); - reader.read(); - return decoder.get_result().template as(); -} - -template -typename std::enable_if::value,T>::type -decode_csv(std::basic_istream& is, const basic_csv_options& options = basic_csv_options::default_options()) -{ - typedef CharT char_type; - - json_decoder decoder; - - basic_csv_reader> reader(is,decoder,options); - reader.read(); - return decoder.get_result(); -} - -template -typename std::enable_if::value,T>::type -decode_csv(std::basic_istream& is, const basic_csv_options& options = basic_csv_options::default_options()) -{ - typedef CharT char_type; - - json_decoder> decoder; - - basic_csv_reader> reader(is,decoder,options); - reader.read(); - return decoder.get_result().template as(); -} - -typedef basic_csv_reader csv_reader; -typedef basic_csv_reader wcsv_reader; - -#if !defined(JSONCONS_NO_DEPRECATED) -typedef basic_csv_reader> csv_string_reader; -typedef basic_csv_reader> wcsv_string_reader; -#endif - -}} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/csv/csv_serializer.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/csv/csv_serializer.hpp deleted file mode 100644 index ec73510bf7..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/csv/csv_serializer.hpp +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_CSV_CSV_SERIALIZER_HPP -#define JSONCONS_CSV_CSV_SERIALIZER_HPP - -#include - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpatch/jsonpatch.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpatch/jsonpatch.hpp deleted file mode 100644 index 600dd9cffb..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpatch/jsonpatch.hpp +++ /dev/null @@ -1,492 +0,0 @@ -// Copyright 2017 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_JSONPOINTER_JSONPATCH_HPP -#define JSONCONS_JSONPOINTER_JSONPATCH_HPP - -#include -#include -#include -#include -#include // std::min -#include // std::move -#include -#include -#include - -namespace jsoncons { namespace jsonpatch { - -namespace detail { - - JSONCONS_STRING_LITERAL(test,'t','e','s','t') - JSONCONS_STRING_LITERAL(add,'a','d','d') - JSONCONS_STRING_LITERAL(remove,'r','e','m','o','v','e') - JSONCONS_STRING_LITERAL(replace,'r','e','p','l','a','c','e') - JSONCONS_STRING_LITERAL(move,'m','o','v','e') - JSONCONS_STRING_LITERAL(copy,'c','o','p','y') - JSONCONS_STRING_LITERAL(op,'o','p') - JSONCONS_STRING_LITERAL(path,'p','a','t','h') - JSONCONS_STRING_LITERAL(from,'f','r','o','m') - JSONCONS_STRING_LITERAL(value,'v','a','l','u','e') - - enum class op_type {add,remove,replace}; - enum class state_type {begin,abort,commit}; - - template - struct operation_unwinder - { - typedef typename Json::string_type string_type; - typedef typename Json::string_view_type string_view_type; - - struct entry - { - op_type op; - string_type path; - Json value; - }; - - Json& target; - state_type state; - std::vector stack; - - operation_unwinder(Json& j) - : target(j), state(state_type::begin) - { - } - - ~operation_unwinder() - { - std::error_code ec; - //std::cout << "state: " << std::boolalpha << (state == state_type::commit) << ", stack size: " << stack.size() << std::endl; - if (state != state_type::commit) - { - for (auto it = stack.rbegin(); it != stack.rend(); ++it) - { - if (it->op == op_type::add) - { - jsonpointer::insert_or_assign(target,it->path,it->value,ec); - if (ec) - { - //std::cout << "add: " << it->path << std::endl; - break; - } - } - else if (it->op == op_type::remove) - { - jsonpointer::remove(target,it->path,ec); - if (ec) - { - //std::cout << "remove: " << it->path << std::endl; - break; - } - } - else if (it->op == op_type::replace) - { - jsonpointer::replace(target,it->path,it->value,ec); - if (ec) - { - //std::cout << "replace: " << it->path << std::endl; - break; - } - } - } - } - } - }; - - template - Json from_diff(const Json& source, const Json& target, const typename Json::string_type& path) - { - typedef typename Json::char_type char_type; - - Json result = typename Json::array(); - - if (source == target) - { - return result; - } - - if (source.is_array() && target.is_array()) - { - size_t common = (std::min)(source.size(),target.size()); - for (size_t i = 0; i < common; ++i) - { - std::basic_ostringstream ss; - ss << path << '/' << i; - auto temp_diff = from_diff(source[i],target[i],ss.str()); - result.insert(result.array_range().end(),temp_diff.array_range().begin(),temp_diff.array_range().end()); - } - // Element in source, not in target - remove - for (size_t i = target.size(); i < source.size(); ++i) - { - std::basic_ostringstream ss; - ss << path << '/' << i; - Json val = typename Json::object(); - val.insert_or_assign(op_literal(), remove_literal()); - val.insert_or_assign(path_literal(), ss.str()); - result.push_back(std::move(val)); - } - // Element in target, not in source - add, - // Fix contributed by Alexander rog13 - for (size_t i = source.size(); i < target.size(); ++i) - { - const auto& a = target[i]; - std::basic_ostringstream ss; - ss << path << '/' << i; - Json val = typename Json::object(); - val.insert_or_assign(op_literal(), add_literal()); - val.insert_or_assign(path_literal(), ss.str()); - val.insert_or_assign(value_literal(), a); - result.push_back(std::move(val)); - } - } - else if (source.is_object() && target.is_object()) - { - for (const auto& a : source.object_range()) - { - std::basic_ostringstream ss; - ss << path << '/'; - jsonpointer::escape(a.key(),ss); - auto it = target.find(a.key()); - if (it != target.object_range().end()) - { - auto temp_diff = from_diff(a.value(),it->value(),ss.str()); - result.insert(result.array_range().end(),temp_diff.array_range().begin(),temp_diff.array_range().end()); - } - else - { - Json val = typename Json::object(); - val.insert_or_assign(op_literal(), remove_literal()); - val.insert_or_assign(path_literal(), ss.str()); - result.push_back(std::move(val)); - } - } - for (const auto& a : target.object_range()) - { - auto it = source.find(a.key()); - if (it == source.object_range().end()) - { - std::basic_ostringstream ss; - ss << path << '/'; - jsonpointer::escape(a.key(),ss); - Json val = typename Json::object(); - val.insert_or_assign(op_literal(), add_literal()); - val.insert_or_assign(path_literal(), ss.str()); - val.insert_or_assign(value_literal(), a.value()); - result.push_back(std::move(val)); - } - } - } - else - { - Json val = typename Json::object(); - val.insert_or_assign(op_literal(), replace_literal()); - val.insert_or_assign(path_literal(), path); - val.insert_or_assign(value_literal(), target); - result.push_back(std::move(val)); - } - - return result; - } -} - -template -void apply_patch(Json& target, const Json& patch, std::error_code& patch_ec) -{ - typedef typename Json::char_type char_type; - typedef typename Json::string_type string_type; - typedef typename Json::string_view_type string_view_type; - - jsoncons::jsonpatch::detail::operation_unwinder unwinder(target); - - // Validate - - string_type bad_path; - for (const auto& operation : patch.array_range()) - { - unwinder.state =jsoncons::jsonpatch::detail::state_type::begin; - - if (operation.count(detail::op_literal()) != 1 || operation.count(detail::path_literal()) != 1) - { - patch_ec = jsonpatch_errc::invalid_patch; - unwinder.state =jsoncons::jsonpatch::detail::state_type::abort; - } - else - { - string_view_type op = operation.at(detail::op_literal()).as_string_view(); - string_view_type path = operation.at(detail::path_literal()).as_string_view(); - - if (op ==jsoncons::jsonpatch::detail::test_literal()) - { - std::error_code ec; - Json val = jsonpointer::get(target,path,ec); - if (ec) - { - patch_ec = jsonpatch_errc::test_failed; - unwinder.state =jsoncons::jsonpatch::detail::state_type::abort; - } - else if (operation.count(detail::value_literal()) != 1) - { - patch_ec = jsonpatch_errc::invalid_patch; - unwinder.state =jsoncons::jsonpatch::detail::state_type::abort; - } - else if (val != operation.at(detail::value_literal())) - { - patch_ec = jsonpatch_errc::test_failed; - unwinder.state =jsoncons::jsonpatch::detail::state_type::abort; - } - } - else if (op ==jsoncons::jsonpatch::detail::add_literal()) - { - if (operation.count(detail::value_literal()) != 1) - { - patch_ec = jsonpatch_errc::invalid_patch; - unwinder.state =jsoncons::jsonpatch::detail::state_type::abort; - } - else - { - std::error_code insert_ec; - Json val = operation.at(detail::value_literal()); - auto npath = jsonpointer::normalized_path(target,path); - jsonpointer::insert(target,npath,val,insert_ec); // try insert without replace - if (insert_ec) // try a replace - { - std::error_code select_ec; - Json orig_val = jsonpointer::get(target,npath,select_ec); - if (select_ec) // shouldn't happen - { - patch_ec = jsonpatch_errc::add_failed; - unwinder.state =jsoncons::jsonpatch::detail::state_type::abort; - } - else - { - std::error_code replace_ec; - jsonpointer::replace(target,npath,val,replace_ec); - if (replace_ec) - { - patch_ec = jsonpatch_errc::add_failed; - unwinder.state =jsoncons::jsonpatch::detail::state_type::abort; - } - else - { - unwinder.stack.push_back({detail::op_type::replace,npath,orig_val}); - } - } - } - else // insert without replace succeeded - { - unwinder.stack.push_back({detail::op_type::remove,npath,Json::null()}); - } - } - } - else if (op ==jsoncons::jsonpatch::detail::remove_literal()) - { - std::error_code ec; - Json val = jsonpointer::get(target,path,ec); - if (ec) - { - patch_ec = jsonpatch_errc::remove_failed; - unwinder.state =jsoncons::jsonpatch::detail::state_type::abort; - } - else - { - jsonpointer::remove(target,path,ec); - if (ec) - { - patch_ec = jsonpatch_errc::remove_failed; - unwinder.state =jsoncons::jsonpatch::detail::state_type::abort; - } - else - { - unwinder.stack.push_back({detail::op_type::add,string_type(path),val}); - } - } - } - else if (op ==jsoncons::jsonpatch::detail::replace_literal()) - { - std::error_code ec; - Json val = jsonpointer::get(target,path,ec); - if (ec) - { - patch_ec = jsonpatch_errc::replace_failed; - unwinder.state =jsoncons::jsonpatch::detail::state_type::abort; - } - else if (operation.count(detail::value_literal()) != 1) - { - patch_ec = jsonpatch_errc::invalid_patch; - unwinder.state =jsoncons::jsonpatch::detail::state_type::abort; - } - else - { - jsonpointer::replace(target,path,operation.at(detail::value_literal()),ec); - if (ec) - { - patch_ec = jsonpatch_errc::replace_failed; - unwinder.state =jsoncons::jsonpatch::detail::state_type::abort; - } - else - { - unwinder.stack.push_back({detail::op_type::replace,string_type(path),val}); - } - } - } - else if (op ==jsoncons::jsonpatch::detail::move_literal()) - { - if (operation.count(detail::from_literal()) != 1) - { - patch_ec = jsonpatch_errc::invalid_patch; - unwinder.state =jsoncons::jsonpatch::detail::state_type::abort; - } - else - { - string_view_type from = operation.at(detail::from_literal()).as_string_view(); - std::error_code ec; - Json val = jsonpointer::get(target,from,ec); - if (ec) - { - patch_ec = jsonpatch_errc::move_failed; - unwinder.state =jsoncons::jsonpatch::detail::state_type::abort; - } - else - { - jsonpointer::remove(target,from,ec); - if (ec) - { - patch_ec = jsonpatch_errc::move_failed; - unwinder.state =jsoncons::jsonpatch::detail::state_type::abort; - } - else - { - unwinder.stack.push_back({detail::op_type::add,string_type(from),val}); - // add - std::error_code insert_ec; - auto npath = jsonpointer::normalized_path(target,path); - jsonpointer::insert(target,npath,val,insert_ec); // try insert without replace - if (insert_ec) // try a replace - { - std::error_code select_ec; - Json orig_val = jsonpointer::get(target,npath,select_ec); - if (select_ec) // shouldn't happen - { - patch_ec = jsonpatch_errc::copy_failed; - unwinder.state =jsoncons::jsonpatch::detail::state_type::abort; - } - else - { - std::error_code replace_ec; - jsonpointer::replace(target, npath, val, replace_ec); - if (replace_ec) - { - patch_ec = jsonpatch_errc::copy_failed; - unwinder.state =jsoncons::jsonpatch::detail::state_type::abort; - - } - else - { - unwinder.stack.push_back({jsoncons::jsonpatch::detail::op_type::replace,npath,orig_val }); - } - - } - } - else - { - unwinder.stack.push_back({detail::op_type::remove,npath,Json::null()}); - } - } - } - } - } - else if (op ==jsoncons::jsonpatch::detail::copy_literal()) - { - if (operation.count(detail::from_literal()) != 1) - { - patch_ec = jsonpatch_errc::invalid_patch; - unwinder.state =jsoncons::jsonpatch::detail::state_type::abort; - } - else - { - std::error_code ec; - string_view_type from = operation.at(detail::from_literal()).as_string_view(); - Json val = jsonpointer::get(target,from,ec); - if (ec) - { - patch_ec = jsonpatch_errc::copy_failed; - unwinder.state =jsoncons::jsonpatch::detail::state_type::abort; - } - else - { - // add - auto npath = jsonpointer::normalized_path(target,path); - std::error_code insert_ec; - jsonpointer::insert(target,npath,val,insert_ec); // try insert without replace - if (insert_ec) // Failed, try a replace - { - std::error_code select_ec; - Json orig_val = jsonpointer::get(target,npath, select_ec); - if (select_ec) // shouldn't happen - { - patch_ec = jsonpatch_errc::copy_failed; - unwinder.state =jsoncons::jsonpatch::detail::state_type::abort; - } - else - { - std::error_code replace_ec; - jsonpointer::replace(target, npath, val,replace_ec); - if (replace_ec) - { - patch_ec = jsonpatch_errc::copy_failed; - unwinder.state =jsoncons::jsonpatch::detail::state_type::abort; - } - else - { - unwinder.stack.push_back({jsoncons::jsonpatch::detail::op_type::replace,npath,orig_val }); - } - } - } - else - { - unwinder.stack.push_back({detail::op_type::remove,npath,Json::null()}); - } - } - } - } - if (unwinder.state !=jsoncons::jsonpatch::detail::state_type::begin) - { - bad_path = string_type(path); - } - } - if (unwinder.state !=jsoncons::jsonpatch::detail::state_type::begin) - { - break; - } - } - if (unwinder.state ==jsoncons::jsonpatch::detail::state_type::begin) - { - unwinder.state =jsoncons::jsonpatch::detail::state_type::commit; - } -} - -template -Json from_diff(const Json& source, const Json& target) -{ - typename Json::string_type path; - return jsoncons::jsonpatch::detail::from_diff(source, target, path); -} - -template -void apply_patch(Json& target, const Json& patch) -{ - std::error_code ec; - apply_patch(target, patch, ec); - if (ec) - { - JSONCONS_THROW(jsonpatch_error(ec)); - } -} - -}} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpatch/jsonpatch_error.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpatch/jsonpatch_error.hpp deleted file mode 100644 index 731b25f816..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpatch/jsonpatch_error.hpp +++ /dev/null @@ -1,114 +0,0 @@ -/// Copyright 2017 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_JSONPATCH_JSONPATCH_ERROR_HPP -#define JSONCONS_JSONPATCH_JSONPATCH_ERROR_HPP - -#include -#include - -namespace jsoncons { namespace jsonpatch { - -class jsonpatch_error : public std::system_error, public virtual json_exception -{ -public: - jsonpatch_error(const std::error_code& ec) - : std::system_error(ec) - { - } - - jsonpatch_error(const std::error_code& ec, const std::string& what_arg) - : std::system_error(ec, what_arg) - { - } - - jsonpatch_error(const std::error_code& ec, const char* what_arg) - : std::system_error(ec, what_arg) - { - } - - jsonpatch_error(const jsonpatch_error& other) = default; - - jsonpatch_error(jsonpatch_error&& other) = default; - - const char* what() const noexcept override - { - return std::system_error::what(); - } - - jsonpatch_error& operator=(const jsonpatch_error& e) = default; - jsonpatch_error& operator=(jsonpatch_error&& e) = default; -private: -}; - -enum class jsonpatch_errc -{ - ok = 0, - invalid_patch = 1, - test_failed, - add_failed, - remove_failed, - replace_failed, - move_failed, - copy_failed - -}; - -class jsonpatch_error_category_impl - : public std::error_category -{ -public: - const char* name() const noexcept override - { - return "jsoncons/jsonpatch"; - } - std::string message(int ev) const override - { - switch (static_cast(ev)) - { - case jsonpatch_errc::invalid_patch: - return "Invalid JSON Patch document"; - case jsonpatch_errc::test_failed: - return "JSON Patch test operation failed"; - case jsonpatch_errc::add_failed: - return "JSON Patch add operation failed"; - case jsonpatch_errc::remove_failed: - return "JSON Patch remove operation failed"; - case jsonpatch_errc::replace_failed: - return "JSON Patch replace operation failed"; - case jsonpatch_errc::move_failed: - return "JSON Patch move operation failed"; - case jsonpatch_errc::copy_failed: - return "JSON Patch copy operation failed"; - default: - return "Unknown JSON Patch error"; - } - } -}; - -inline -const std::error_category& jsonpatch_error_category() -{ - static jsonpatch_error_category_impl instance; - return instance; -} - -inline -std::error_code make_error_code(jsonpatch_errc result) -{ - return std::error_code(static_cast(result),jsonpatch_error_category()); -} - -}} - -namespace std { - template<> - struct is_error_code_enum : public true_type - { - }; -} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpath/json_query.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpath/json_query.hpp deleted file mode 100644 index 0c97f3371b..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpath/json_query.hpp +++ /dev/null @@ -1,1808 +0,0 @@ -// Copyright 2013 Daniel Parkerpath_single_quoted -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_JSONPATH_JSON_QUERY_HPP -#define JSONCONS_JSONPATH_JSON_QUERY_HPP - -#include // std::array -#include -#include -#include -#include // std::is_const -#include // std::numeric_limits -#include // std::move -#include -#include // std::set -#include // std::make_move_iterator -#include -#include -#include -#include - -namespace jsoncons { namespace jsonpath { - -struct array_slice -{ - size_t start_; - bool is_start_positive; - size_t end_; - bool is_end_positive; - bool is_end_defined; - size_t step_; - bool is_step_positive; - - array_slice() - : start_(0), is_start_positive(true), - end_(0), is_end_positive(true), is_end_defined(false), - step_(1), is_step_positive(true) - { - } - - array_slice(size_t start, bool is_start_positive, - size_t end, bool is_end_positive, bool is_end_defined, - size_t step, bool is_step_positive) - : start_(start), is_start_positive(is_start_positive), - end_(end), is_end_positive(is_end_positive), is_end_defined(is_end_defined), - step_(step), is_step_positive(is_step_positive) - { - } - - size_t get_start(size_t size) const - { - return is_start_positive ? start_ : size - start_; - } - - size_t get_end(size_t size) const - { - if (is_end_defined) - { - return is_end_positive ? end_ : size - end_; - } - else - { - return size; - } - } - - size_t step() const - { - return step_; - } - - array_slice(const array_slice&) = default; - - array_slice& operator=(const array_slice&) = default; -}; - -// work around for std::make_unique not being available until C++14 -template -std::unique_ptr make_unique_ptr(Args&&... args) -{ - return std::unique_ptr(new T(std::forward(args)...)); -} - -enum class result_type {value,path}; - -template -Json json_query(const Json& root, const typename Json::string_view_type& path, result_type result_t = result_type::value) -{ - if (result_t == result_type::value) - { - jsoncons::jsonpath::detail::jsonpath_evaluator> evaluator; - evaluator.evaluate(root, path); - return evaluator.get_values(); - } - else - { - jsoncons::jsonpath::detail::jsonpath_evaluator> evaluator; - evaluator.evaluate(root, path); - return evaluator.get_normalized_paths(); - } -} - -template -void json_replace(Json& root, const typename Json::string_view_type& path, T&& new_value) -{ - jsoncons::jsonpath::detail::jsonpath_evaluator> evaluator; - evaluator.evaluate(root, path); - evaluator.replace(std::forward(new_value)); -} - -namespace detail { - -template -bool try_string_to_index(const CharT *s, size_t length, size_t* value, bool* positive) -{ - static const size_t max_value = (std::numeric_limits::max)(); - static const size_t max_value_div_10 = max_value / 10; - - size_t start = 0; - size_t n = 0; - if (length > 0) - { - if (s[start] == '-') - { - *positive = false; - ++start; - } - else - { - *positive = true; - } - } - if (length > start) - { - for (size_t i = start; i < length; ++i) - { - CharT c = s[i]; - switch (c) - { - case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8':case '9': - { - size_t x = c - '0'; - if (n > max_value_div_10) - { - return false; - } - n = n * 10; - if (n > max_value - x) - { - return false; - } - - n += x; - break; - } - default: - return false; - break; - } - } - *value = n; - return true; - } - else - { - return false; - } -} - -enum class path_state -{ - start, - dot_or_left_bracket, - name_or_left_bracket, - name, - unquoted_name, - unquoted_name2, - single_quoted_name, - double_quoted_name, - bracketed_unquoted_name, - bracketed_single_quoted_name, - bracketed_double_quoted_name, - bracketed_name_or_path, - bracketed_wildcard_or_path, - wildcard_or_rpath_or_slice_or_filter, - slice_end_or_end_step, - slice_end, - slice_step, - slice_step2, - comma_or_right_bracket, - path_or_function_name, - function, - arg_or_right_paren, - path_argument, - unquoted_arg, - single_quoted_arg, - double_quoted_arg, - more_args_or_right_paren, - dot, - path, - path2, - path_single_quoted, - path_double_quoted -}; - -struct state_item -{ - path_state state; - bool is_recursive_descent; - bool is_union; - - state_item() - : state(path_state::start), is_recursive_descent(false), is_union(false) - { - } - - explicit state_item(path_state state) - : state(state), is_recursive_descent(false), is_union(false) - { - } - - state_item(path_state state, const state_item& parent) - : state(state), - is_recursive_descent(parent.is_recursive_descent), - is_union(parent.is_union) - { - } - - state_item(const state_item&) = default; - state_item& operator=(const state_item&) = default; -}; - -JSONCONS_STRING_LITERAL(length, 'l', 'e', 'n', 'g', 't', 'h') - -template -class jsonpath_evaluator : public ser_context -{ - typedef typename Json::char_type char_type; - typedef typename Json::char_traits_type char_traits_type; - typedef std::basic_string string_type; - typedef typename Json::string_view_type string_view_type; - typedef JsonReference reference; - using pointer = typename std::conditional::type>::value,typename Json::const_pointer,typename Json::pointer>::type; - typedef typename Json::const_pointer const_pointer; - - struct node_type - { - string_type path; - pointer val_ptr; - - node_type() = default; - node_type(const string_type& p, const pointer& valp) - : path(p),val_ptr(valp) - { - } - node_type(string_type&& p, pointer&& valp) - : path(std::move(p)),val_ptr(valp) - { - } - node_type(const node_type&) = default; - node_type(node_type&& other) - : path(std::move(other.path)), val_ptr(other.val_ptr) - { - - } - node_type& operator=(const node_type&) = default; - node_type& operator=(node_type&& other) - { - path.swap(other.path); - val_ptr = other.val_ptr; - } - - }; - typedef std::vector node_set; - - struct node_less - { - bool operator()(const node_type& a, const node_type& b) const - { - return *(a.val_ptr) < *(b.val_ptr); - } - }; - - class selector_base - { - public: - virtual ~selector_base() - { - } - virtual void select(jsonpath_evaluator& evaluator, - const string_type& path, reference val, node_set& nodes) = 0; - - virtual bool is_filter() const - { - return false; - } - }; - - class path_selector final : public selector_base - { - private: - std::basic_string path_; - public: - path_selector(const std::basic_string& path) - : path_(path) - { - } - - void select(jsonpath_evaluator&, - const string_type& path, reference val, - node_set& nodes) override - { - std::error_code ec; - jsonpath_evaluator e; - e.evaluate(val, path_, ec); - if (!ec) - { - for (auto ptr : e.get_pointers()) - { - nodes.emplace_back(PathCons()(path,path_),ptr); - } - } - } - }; - - class expr_selector final : public selector_base - { - private: - jsonpath_filter_expr result_; - public: - expr_selector(const jsonpath_filter_expr& result) - : result_(result) - { - } - - void select(jsonpath_evaluator& evaluator, - const string_type& path, reference val, - node_set& nodes) override - { - auto index = result_.eval(val); - if (index.template is()) - { - size_t start = index.template as(); - if (val.is_array() && start < val.size()) - { - nodes.emplace_back(PathCons()(path,start),std::addressof(val[start])); - } - } - else if (index.is_string()) - { - name_selector selector(index.as_string_view()); - selector.select(evaluator, path, val, nodes); - } - } - }; - - class filter_selector final : public selector_base - { - private: - jsonpath_filter_expr result_; - public: - filter_selector(const jsonpath_filter_expr& result) - : result_(result) - { - } - - bool is_filter() const override - { - return true; - } - - void select(jsonpath_evaluator&, - const string_type& path, reference val, - node_set& nodes) override - { - //std::cout << "filter_selector select "; - if (val.is_array()) - { - //std::cout << "from array \n"; - for (size_t i = 0; i < val.size(); ++i) - { - if (result_.exists(val[i])) - { - nodes.emplace_back(PathCons()(path,i),std::addressof(val[i])); - } - } - } - else if (val.is_object()) - { - //std::cout << "from object \n"; - if (result_.exists(val)) - { - nodes.emplace_back(path, std::addressof(val)); - } - } - } - }; - - class name_selector final : public selector_base - { - private: - string_type name_; - public: - name_selector(const string_view_type& name) - : name_(name) - { - } - - void select(jsonpath_evaluator& evaluator, - const string_type& path, reference val, - node_set& nodes) override - { - bool is_start_positive = true; - - if (val.is_object() && val.contains(name_)) - { - nodes.emplace_back(PathCons()(path,name_),std::addressof(val.at(name_))); - } - else if (val.is_array()) - { - size_t pos = 0; - if (try_string_to_index(name_.data(), name_.size(), &pos, &is_start_positive)) - { - size_t index = is_start_positive ? pos : val.size() - pos; - if (index < val.size()) - { - nodes.emplace_back(PathCons()(path,index),std::addressof(val[index])); - } - } - else if (name_ == length_literal() && val.size() > 0) - { - pointer ptr = evaluator.create_temp(val.size()); - nodes.emplace_back(PathCons()(path, name_), ptr); - } - } - else if (val.is_string()) - { - size_t pos = 0; - string_view_type sv = val.as_string_view(); - if (try_string_to_index(name_.data(), name_.size(), &pos, &is_start_positive)) - { - size_t index = is_start_positive ? pos : sv.size() - pos; - auto sequence = unicons::sequence_at(sv.data(), sv.data() + sv.size(), index); - if (sequence.length() > 0) - { - pointer ptr = evaluator.create_temp(sequence.begin(),sequence.length()); - nodes.emplace_back(PathCons()(path, index), ptr); - } - } - else if (name_ == length_literal() && sv.size() > 0) - { - size_t count = unicons::u32_length(sv.begin(),sv.end()); - pointer ptr = evaluator.create_temp(count); - nodes.emplace_back(PathCons()(path, name_), ptr); - } - } - } - }; - - class array_slice_selector final : public selector_base - { - private: - array_slice slice_; - public: - array_slice_selector(const array_slice& slice) - : slice_(slice) - { - } - - void select(jsonpath_evaluator&, - const string_type& path, reference val, - node_set& nodes) override - { - if (slice_.is_step_positive) - { - end_array_slice1(path, val, nodes); - } - else - { - end_array_slice2(path, val, nodes); - } - } - - void end_array_slice1(const string_type& path, reference val, node_set& nodes) - { - if (val.is_array()) - { - size_t start = slice_.get_start(val.size()); - size_t end = slice_.get_end(val.size()); - for (size_t j = start; j < end; j += slice_.step()) - { - if (j < val.size()) - { - nodes.emplace_back(PathCons()(path,j),std::addressof(val[j])); - } - } - } - } - - void end_array_slice2(const string_type& path, reference val, node_set& nodes) - { - if (val.is_array()) - { - size_t start = slice_.get_start(val.size()); - size_t end = slice_.get_end(val.size()); - - size_t j = end + slice_.step() - 1; - while (j > (start+slice_.step()-1)) - { - j -= slice_.step(); - if (j < val.size()) - { - nodes.emplace_back(PathCons()(path,j),std::addressof(val[j])); - } - } - } - } - }; - - function_table functions_; - - default_parse_error_handler default_err_handler_; - node_set nodes_; - std::vector stack_; - size_t line_; - size_t column_; - const char_type* begin_input_; - const char_type* end_input_; - const char_type* p_; - std::vector> selectors_; - std::vector> temp_json_values_; - - typedef std::vector argument_type; - std::vector function_stack_; - std::vector state_stack_; - -public: - jsonpath_evaluator() - : line_(1), column_(1), - begin_input_(nullptr), end_input_(nullptr), - p_(nullptr) - { - } - - jsonpath_evaluator(size_t line, size_t column) - : line_(line), column_(column), - begin_input_(nullptr), end_input_(nullptr), - p_(nullptr) - { - } - - size_t line() const - { - return line_; - } - - size_t column() const - { - return column_; - } - - Json get_values() const - { - Json result = typename Json::array(); - - if (stack_.size() > 0) - { - result.reserve(stack_.back().size()); - for (const auto& p : stack_.back()) - { - result.push_back(*(p.val_ptr)); - } - } - return result; - } - - std::vector get_pointers() const - { - std::vector result; - - if (stack_.size() > 0) - { - result.reserve(stack_.back().size()); - for (const auto& p : stack_.back()) - { - result.push_back(p.val_ptr); - } - } - return result; - } - - void call_function(const string_type& function_name, std::error_code& ec) - { - auto f = functions_.get(function_name, ec); - if (ec) - { - return; - } - auto result = f(function_stack_, ec); - if (ec) - { - return; - } - - string_type s = {'$'}; - node_set v; - pointer ptr = create_temp(std::move(result)); - v.emplace_back(s,ptr); - stack_.push_back(v); - } - - template - pointer create_temp(Args&& ... args) - { - auto temp = make_unique_ptr(std::forward(args)...); - pointer ptr = temp.get(); - temp_json_values_.emplace_back(std::move(temp)); - return ptr; - } - - Json get_normalized_paths() const - { - Json result = typename Json::array(); - if (stack_.size() > 0) - { - result.reserve(stack_.back().size()); - for (const auto& p : stack_.back()) - { - result.push_back(p.path); - } - } - return result; - } - - template - void replace(T&& new_value) - { - if (stack_.size() > 0) - { - for (size_t i = 0; i < stack_.back().size(); ++i) - { - *(stack_.back()[i].val_ptr) = new_value; - } - } - } - - void evaluate(reference root, const string_view_type& path) - { - std::error_code ec; - evaluate(root, path.data(), path.length(), ec); - if (ec) - { - throw jsonpath_error(ec, line_, column_); - } - } - - void evaluate(reference root, const string_view_type& path, std::error_code& ec) - { - try - { - evaluate(root, path.data(), path.length(), ec); - } - catch (...) - { - ec = jsonpath_errc::unidentified_error; - } - } - - void evaluate(reference root, - const char_type* path, - size_t length, - std::error_code& ec) - { - state_stack_.emplace_back(path_state::start); - - string_type function_name; - string_type buffer; - - begin_input_ = path; - end_input_ = path + length; - p_ = begin_input_; - - string_type s = {'$'}; - node_set v; - v.emplace_back(std::move(s),std::addressof(root)); - stack_.push_back(v); - - array_slice slice; - - while (p_ < end_input_) - { - switch (state_stack_.back().state) - { - case path_state::start: - { - switch (*p_) - { - case ' ':case '\t':case '\r':case '\n': - advance_past_space_character(); - break; - case '$': - { - state_stack_.emplace_back(path_state::dot_or_left_bracket, state_stack_.back()); - ++p_; - ++column_; - break; - } - default: - { - switch (*p_) - { - case '.': - case '[': - ec = jsonpath_errc::expected_root; - return; - default: // might be function, validate name later - state_stack_.emplace_back(path_state::dot_or_left_bracket, state_stack_.back()); - state_stack_.emplace_back(path_state::path_or_function_name, state_stack_.back()); - break; - } - break; - } - - return; - }; - break; - } - case path_state::path_or_function_name: - switch (*p_) - { - case ' ':case '\t':case '\r':case '\n': - { - selectors_.push_back(make_unique_ptr(buffer)); - apply_selectors(); - buffer.clear(); - state_stack_.pop_back(); - advance_past_space_character(); - break; - } - case '(': - state_stack_.back().state = path_state::arg_or_right_paren; - function_name = std::move(buffer); - buffer.clear(); - ++p_; - ++column_; - break; - case '[': - { - if (buffer.size() > 0) - { - selectors_.push_back(make_unique_ptr(buffer)); - apply_selectors(); - buffer.clear(); - } - slice.start_ = 0; - - state_stack_.back().state = path_state::wildcard_or_rpath_or_slice_or_filter; - ++p_; - ++column_; - break; - } - case '.': - { - if (buffer.size() > 0) - { - selectors_.push_back(make_unique_ptr(buffer)); - apply_selectors(); - buffer.clear(); - } - state_stack_.back().state = path_state::dot; - ++p_; - ++column_; - break; - } - case '*': - { - end_all(); - transfer_nodes(); - state_stack_.back().state = path_state::dot; - ++p_; - ++column_; - break; - } - case '\'': - { - buffer.clear(); - state_stack_.back().state = path_state::single_quoted_name; - ++p_; - ++column_; - break; - } - case '\"': - { - buffer.clear(); - state_stack_.back().state = path_state::double_quoted_name; - ++p_; - ++column_; - break; - } - default: - buffer.push_back(*p_); - ++p_; - ++column_; - break; - } - break; - case path_state::arg_or_right_paren: - switch (*p_) - { - case ' ':case '\t':case '\r':case '\n': - advance_past_space_character(); - break; - case '$': - buffer.clear(); - buffer.push_back(*p_); - state_stack_.emplace_back(path_state::path_argument, state_stack_.back()); - ++p_; - ++column_; - break; - case '\'': - buffer.clear(); - buffer.push_back('\"'); - state_stack_.back().state = path_state::more_args_or_right_paren; - state_stack_.emplace_back(path_state::single_quoted_arg, state_stack_.back()); - ++p_; - ++column_; - break; - case '\"': - buffer.clear(); - buffer.push_back('\"'); - state_stack_.back().state = path_state::more_args_or_right_paren; - state_stack_.emplace_back(path_state::double_quoted_arg, state_stack_.back()); - ++p_; - ++column_; - break; - case ')': - { - jsonpath_evaluator evaluator; - evaluator.evaluate(root, buffer, ec); - if (ec) - { - return; - } - function_stack_.push_back(evaluator.get_pointers()); - - call_function(function_name, ec); - if (ec) - { - return; - } - state_stack_.pop_back(); - ++p_; - ++column_; - break; - } - default: - buffer.clear(); - state_stack_.back().state = path_state::more_args_or_right_paren; - state_stack_.emplace_back(path_state::unquoted_arg, state_stack_.back()); - ++p_; - ++column_; - break; - } - break; - case path_state::path_argument: - switch (*p_) - { - case ',': - { - jsonpath_evaluator evaluator; - evaluator.evaluate(root, buffer, ec); - if (ec) - { - return; - } - function_stack_.push_back(evaluator.get_pointers()); - state_stack_.pop_back(); - ++p_; - ++column_; - break; - } - case ')': - { - state_stack_.pop_back(); - break; - } - default: - buffer.push_back(*p_); // path_argument - ++p_; - ++column_; - break; - } - break; - case path_state::unquoted_arg: - switch (*p_) - { - case ',': - try - { - auto val = Json::parse(buffer); - auto temp = create_temp(val); - function_stack_.push_back(std::vector{temp}); - } - catch (const ser_error&) - { - ec = jsonpath_errc::argument_parse_error; - return; - } - buffer.clear(); - //state_ = path_state::arg_or_right_paren; - state_stack_.pop_back(); - break; - case ')': - { - try - { - auto val = Json::parse(buffer); - auto temp = create_temp(val); - function_stack_.push_back(std::vector{temp}); - } - catch (const ser_error&) - { - ec = jsonpath_errc::argument_parse_error; - return; - } - call_function(function_name, ec); - if (ec) - { - return; - } - state_stack_.pop_back(); - break; - } - default: - buffer.push_back(*p_); - break; - } - ++p_; - ++column_; - break; - case path_state::single_quoted_arg: - switch (*p_) - { - case '\'': - buffer.push_back('\"'); - state_stack_.pop_back(); - break; - case '\"': - buffer.push_back('\\'); - buffer.push_back('\"'); - state_stack_.pop_back(); - break; - default: - buffer.push_back(*p_); - break; - } - ++p_; - ++column_; - break; - case path_state::double_quoted_arg: - switch (*p_) - { - case '\"': - buffer.push_back('\"'); - state_stack_.pop_back(); - break; - default: - buffer.push_back(*p_); - break; - } - ++p_; - ++column_; - break; - case path_state::more_args_or_right_paren: - switch (*p_) - { - case ' ':case '\t':case '\r':case '\n': - advance_past_space_character(); - break; - case ',': - try - { - auto val = Json::parse(buffer); - auto temp = create_temp(val); - function_stack_.push_back(std::vector{temp}); - } - catch (const ser_error&) - { - ec = jsonpath_errc::argument_parse_error; - return; - } - buffer.clear(); - //state_ = path_state::arg_or_right_paren; - state_stack_.pop_back(); - ++p_; - ++column_; - break; - case ')': - { - try - { - auto val = Json::parse(buffer); - auto temp = create_temp(val); - function_stack_.push_back(std::vector{temp}); - } - catch (const ser_error&) - { - ec = jsonpath_errc::argument_parse_error; - return; - } - call_function(function_name, ec); - if (ec) - { - return; - } - state_stack_.pop_back(); - ++p_; - ++column_; - break; - } - default: - ec = jsonpath_errc::invalid_filter_unsupported_operator; - return; - } - break; - case path_state::dot: - switch (*p_) - { - case '.': - state_stack_.back().is_recursive_descent = true; - ++p_; - ++column_; - state_stack_.back().state = path_state::name_or_left_bracket; - break; - default: - state_stack_.back().state = path_state::name; - break; - } - break; - case path_state::name_or_left_bracket: - switch (*p_) - { - case ' ':case '\t':case '\r':case '\n': - advance_past_space_character(); - break; - case '[': // [ can follow .. - state_stack_.back().state = path_state::wildcard_or_rpath_or_slice_or_filter; - ++p_; - ++column_; - break; - default: - buffer.clear(); - state_stack_.back().state = path_state::name; - break; - } - break; - case path_state::name: - switch (*p_) - { - case ' ':case '\t':case '\r':case '\n': - advance_past_space_character(); - break; - case '*': - end_all(); - transfer_nodes(); - state_stack_.pop_back(); - ++p_; - ++column_; - break; - case '\'': - state_stack_.back().state = path_state::single_quoted_name; - ++p_; - ++column_; - break; - case '\"': - state_stack_.back().state = path_state::double_quoted_name; - ++p_; - ++column_; - break; - case '[': - case '.': - ec = jsonpath_errc::expected_name; - return; - default: - buffer.clear(); - state_stack_.back().state = path_state::unquoted_name; - break; - } - break; - case path_state::dot_or_left_bracket: - switch (*p_) - { - case ' ':case '\t':case '\r':case '\n': - advance_past_space_character(); - break; - case '.': - state_stack_.emplace_back(path_state::dot, state_stack_.back()); - ++p_; - ++column_; - break; - case '[': - state_stack_.emplace_back(path_state::wildcard_or_rpath_or_slice_or_filter, state_stack_.back()); - ++p_; - ++column_; - break; - default: - ec = jsonpath_errc::expected_separator; - return; - }; - break; - case path_state::unquoted_name: - switch (*p_) - { - case '[': - case '.': - case ' ':case '\t': - case '\r': - case '\n': - state_stack_.back().state = path_state::unquoted_name2; - break; - default: - buffer.push_back(*p_); - ++p_; - ++column_; - break; - }; - break; - case path_state::unquoted_name2: - switch (*p_) - { - case ' ':case '\t':case '\r':case '\n': - advance_past_space_character(); - break; - case '[': - selectors_.push_back(make_unique_ptr(buffer)); - apply_selectors(); - buffer.clear(); - slice.start_ = 0; - state_stack_.pop_back(); - break; - case '.': - selectors_.push_back(make_unique_ptr(buffer)); - apply_selectors(); - buffer.clear(); - state_stack_.pop_back(); - break; - default: - ec = jsonpath_errc::expected_name; - return; - }; - break; - case path_state::single_quoted_name: - switch (*p_) - { - case '\'': - selectors_.push_back(make_unique_ptr(buffer)); - apply_selectors(); - buffer.clear(); - state_stack_.pop_back(); - break; - case '\\': - if (p_+1 < end_input_) - { - ++p_; - ++column_; - buffer.push_back(*p_); - } - else - { - ec = jsonpath_errc::unexpected_end_of_input; - return; - } - break; - default: - buffer.push_back(*p_); - break; - }; - ++p_; - ++column_; - break; - case path_state::double_quoted_name: - switch (*p_) - { - case '\"': - selectors_.push_back(make_unique_ptr(buffer)); - apply_selectors(); - buffer.clear(); - state_stack_.pop_back(); - break; - case '\\': - if (p_+1 < end_input_) - { - ++p_; - ++column_; - buffer.push_back(*p_); - } - else - { - ec = jsonpath_errc::unexpected_end_of_input; - return; - } - break; - default: - buffer.push_back(*p_); - break; - }; - ++p_; - ++column_; - break; - case path_state::comma_or_right_bracket: - switch (*p_) - { - case ' ':case '\t':case '\r':case '\n': - advance_past_space_character(); - break; - case ',': - state_stack_.back().is_union = true; - state_stack_.back().state = path_state::wildcard_or_rpath_or_slice_or_filter; - ++p_; - ++column_; - break; - case ']': - apply_selectors(); - state_stack_.pop_back(); - ++p_; - ++column_; - break; - default: - ec = jsonpath_errc::expected_right_bracket; - return; - } - break; - case path_state::wildcard_or_rpath_or_slice_or_filter: - switch (*p_) - { - case ' ':case '\t':case '\r':case '\n': - advance_past_space_character(); - break; - case '(': - { - jsonpath_filter_parser parser(line_,column_); - auto result = parser.parse(root, p_,end_input_,&p_); - line_ = parser.line(); - column_ = parser.column(); - selectors_.push_back(make_unique_ptr(result)); - state_stack_.back().state = path_state::comma_or_right_bracket; - break; - } - case '?': - { - jsonpath_filter_parser parser(line_,column_); - auto result = parser.parse(root,p_,end_input_,&p_); - line_ = parser.line(); - column_ = parser.column(); - selectors_.push_back(make_unique_ptr(result)); - state_stack_.back().state = path_state::comma_or_right_bracket; - break; - } - case ':': - slice = array_slice(); - buffer.clear(); - state_stack_.back().state = path_state::comma_or_right_bracket; - state_stack_.emplace_back(path_state::slice_end_or_end_step, state_stack_.back()); - ++p_; - ++column_; - break; - case '*': - state_stack_.back().state = path_state::comma_or_right_bracket; - state_stack_.emplace_back(path_state::bracketed_wildcard_or_path, state_stack_.back()); - ++p_; - ++column_; - break; - case '\'': - state_stack_.back().state = path_state::comma_or_right_bracket; - state_stack_.emplace_back(path_state::bracketed_single_quoted_name, state_stack_.back()); - ++p_; - ++column_; - break; - case '\"': - state_stack_.back().state = path_state::comma_or_right_bracket; - state_stack_.emplace_back(path_state::bracketed_double_quoted_name, state_stack_.back()); - ++p_; - ++column_; - break; - default: - slice = array_slice(); - buffer.clear(); - buffer.push_back(*p_); - state_stack_.back().state = path_state::comma_or_right_bracket; - state_stack_.emplace_back(path_state::bracketed_unquoted_name, state_stack_.back()); - ++p_; - ++column_; - break; - } - break; - case path_state::bracketed_unquoted_name: - switch (*p_) - { - case ':': - if (!try_string_to_index(buffer.data(), buffer.size(), &slice.start_, &slice.is_start_positive)) - { - ec = jsonpath_errc::expected_slice_start; - return; - } - state_stack_.back().state = path_state::slice_end_or_end_step; - ++p_; - ++column_; - break; - case '.': - case '[': - case ',': - case ']': - state_stack_.back().state = path_state::bracketed_name_or_path; - break; - default: - buffer.push_back(*p_); - ++p_; - ++column_; - break; - } - break; - case path_state::bracketed_name_or_path: - switch (*p_) - { - case ' ':case '\t':case '\r':case '\n': - advance_past_space_character(); - break; - case '.': - buffer.push_back(*p_); - state_stack_.back().state = path_state::path; - ++p_; - ++column_; - break; - case '[': - buffer.push_back(*p_); - state_stack_.back().state = path_state::path2; - ++p_; - ++column_; - break; - case ',': - case ']': - if (!buffer.empty()) - { - selectors_.push_back(make_unique_ptr(buffer)); - buffer.clear(); - } - state_stack_.pop_back(); - break; - default: - ec = jsonpath_errc::expected_right_bracket; - return; - } - break; - case path_state::bracketed_wildcard_or_path: - switch (*p_) - { - case ' ':case '\t':case '\r':case '\n': - advance_past_space_character(); - break; - case '.': - buffer.push_back('*'); - buffer.push_back(*p_); - state_stack_.back().state = path_state::path; - ++p_; - ++column_; - break; - case '[': - buffer.push_back('*'); - buffer.push_back(*p_); - state_stack_.back().state = path_state::path2; - ++p_; - ++column_; - break; - case ',': - case ']': - end_all(); - state_stack_.pop_back(); - break; - default: - ec = jsonpath_errc::expected_right_bracket; - return; - } - break; - case path_state::path: - switch (*p_) - { - case '\'': - buffer.push_back(*p_); - state_stack_.emplace_back(path_state::path_single_quoted, state_stack_.back()); - ++p_; - ++column_; - break; - case '\"': - buffer.push_back(*p_); - state_stack_.emplace_back(path_state::path_double_quoted, state_stack_.back()); - ++p_; - ++column_; - break; - case ',': - case ']': - if (!buffer.empty()) - { - selectors_.push_back(make_unique_ptr(buffer)); - buffer.clear(); - } - state_stack_.pop_back(); - break; - default: - buffer.push_back(*p_); - ++p_; - ++column_; - break; - } - break; - case path_state::path_double_quoted: - switch (*p_) - { - case '\"': - buffer.push_back(*p_); - state_stack_.pop_back(); - break; - case '\\': - if (p_+1 < end_input_) - { - ++p_; - ++column_; - buffer.push_back(*p_); - } - else - { - ec = jsonpath_errc::unexpected_end_of_input; - return; - } - break; - default: - buffer.push_back(*p_); - break; - } - ++p_; - ++column_; - break; - case path_state::path_single_quoted: - switch (*p_) - { - case '\'': - buffer.push_back(*p_); - state_stack_.pop_back(); - break; - case '\\': - if (p_+1 < end_input_) - { - ++p_; - ++column_; - buffer.push_back(*p_); - } - else - { - ec = jsonpath_errc::unexpected_end_of_input; - return; - } - break; - default: - buffer.push_back(*p_); - break; - } - ++p_; - ++column_; - break; - case path_state::path2: - switch (*p_) - { - case ']': - buffer.push_back(*p_); - state_stack_.back().state = path_state::path; - break; - default: - buffer.push_back(*p_); - break; - } - ++p_; - ++column_; - break; - case path_state::slice_end_or_end_step: - switch (*p_) - { - case '-': - slice.is_end_positive = false; - state_stack_.back().state = path_state::slice_end; - ++p_; - ++column_; - break; - case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8':case '9': - slice.is_end_defined = true; - slice.end_ = static_cast(*p_-'0'); - state_stack_.back().state = path_state::slice_end; - ++p_; - ++column_; - break; - case ':': - slice.step_ = 0; - state_stack_.back().state = path_state::slice_step; - ++p_; - ++column_; - break; - case ',': - case ']': - selectors_.push_back(make_unique_ptr(slice)); - state_stack_.pop_back(); - break; - default: - ec = jsonpath_errc::expected_minus_or_digit_or_colon_or_comma_or_right_bracket; - return; - } - break; - case path_state::slice_end: - switch (*p_) - { - case ':': - slice.step_ = 0; - state_stack_.back().state = path_state::slice_step; - ++p_; - ++column_; - break; - case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8':case '9': - slice.is_end_defined = true; - slice.end_ = slice.end_*10 + static_cast(*p_-'0'); - ++p_; - ++column_; - break; - case ',': - case ']': - if (!slice.is_end_defined) - { - ec = jsonpath_errc::expected_slice_end; - return; - } - selectors_.push_back(make_unique_ptr(slice)); - state_stack_.pop_back(); - break; - default: - ec = jsonpath_errc::expected_digit_or_colon_or_comma_or_right_bracket; - return; - } - break; - case path_state::slice_step: - switch (*p_) - { - case '-': - slice.is_step_positive = false; - slice.step_ = 0; - state_stack_.back().state = path_state::slice_step2; - ++p_; - ++column_; - break; - default: - slice.step_ = 0; - state_stack_.back().state = path_state::slice_step2; - break; - } - break; - case path_state::slice_step2: - switch (*p_) - { - case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8':case '9': - slice.step_ = slice.step_*10 + static_cast(*p_-'0'); - ++p_; - ++column_; - break; - case ',': - case ']': - if (slice.step_ == 0) - { - ec = jsonpath_errc::expected_slice_step; - return; - } - selectors_.push_back(make_unique_ptr(slice)); - state_stack_.pop_back(); - break; - default: - ec = jsonpath_errc::expected_minus_or_digit_or_comma_or_right_bracket; - return; - } - break; - case path_state::bracketed_single_quoted_name: - switch (*p_) - { - case '\'': - state_stack_.back().state = path_state::bracketed_name_or_path; - break; - case '\\': - if (p_+1 < end_input_) - { - ++p_; - ++column_; - buffer.push_back(*p_); - } - else - { - ec = jsonpath_errc::unexpected_end_of_input; - return; - } - break; - default: - buffer.push_back(*p_); - break; - }; - ++p_; - ++column_; - break; - case path_state::bracketed_double_quoted_name: - switch (*p_) - { - case '\"': - state_stack_.back().state = path_state::bracketed_name_or_path; - break; - case '\\': - if (p_+1 < end_input_) - { - ++p_; - ++column_; - buffer.push_back(*p_); - } - else - { - ec = jsonpath_errc::unexpected_end_of_input; - return; - } - break; - default: - buffer.push_back(*p_); - break; - }; - ++p_; - ++column_; - break; - default: - ++p_; - ++column_; - break; - } - } - - switch (state_stack_.back().state) - { - case path_state::unquoted_name: - case path_state::unquoted_name2: - { - selectors_.push_back(make_unique_ptr(buffer)); - apply_selectors(); - buffer.clear(); - state_stack_.pop_back(); // unquoted_name - break; - } - default: - break; - } - - if (state_stack_.size() > 2) - { - ec = jsonpath_errc::unexpected_end_of_input; - return; - } - - JSONCONS_ASSERT(state_stack_.size() == 2); - state_stack_.pop_back(); - - JSONCONS_ASSERT(state_stack_.back().state == path_state::start); - state_stack_.pop_back(); - } - - void end_all() - { - for (const auto& node : stack_.back()) - { - const auto& path = node.path; - pointer p = node.val_ptr; - - if (p->is_array()) - { - for (auto it = p->array_range().begin(); it != p->array_range().end(); ++it) - { - nodes_.emplace_back(PathCons()(path,it - p->array_range().begin()),std::addressof(*it)); - } - } - else if (p->is_object()) - { - for (auto it = p->object_range().begin(); it != p->object_range().end(); ++it) - { - nodes_.emplace_back(PathCons()(path,it->key()),std::addressof(it->value())); - } - } - - } - } - - void apply_selectors() - { - //std::cout << "apply_selectors count: " << selectors_.size() << "\n"; - if (selectors_.size() > 0) - { - for (auto& node : stack_.back()) - { - //std::cout << "apply selector to:\n" << pretty_print(*(node.val_ptr)) << "\n"; - for (auto& selector : selectors_) - { - apply_selector(node.path, *(node.val_ptr), *selector, true); - } - } - selectors_.clear(); - } - transfer_nodes(); - } - - void apply_selector(const string_type& path, reference val, selector_base& selector, bool process) - { - if (process) - { - selector.select(*this, path, val, nodes_); - } - //std::cout << "*it: " << val << "\n"; - //std::cout << "apply_selectors 1 done\n"; - if (state_stack_.back().is_recursive_descent) - { - //std::cout << "is_recursive_descent\n"; - if (val.is_object()) - { - //std::cout << "is_object\n"; - for (auto& nvp : val.object_range()) - { - if (nvp.value().is_array() || nvp.value().is_object()) - { - apply_selector(PathCons()(path,nvp.key()), nvp.value(), selector, true); - } - } - } - else if (val.is_array()) - { - //std::cout << "is_array\n"; - auto first = val.array_range().begin(); - auto last = val.array_range().end(); - for (auto it = first; it != last; ++it) - { - if (it->is_array()) - { - apply_selector(PathCons()(path,it - first), *it,selector, true); - //std::cout << "*it: " << *it << "\n"; - } - else if (it->is_object()) - { - apply_selector(PathCons()(path,it - first), *it, selector, !selector.is_filter()); - } - } - } - } - } - - void transfer_nodes() - { - if (state_stack_.back().is_union) - { - std::set temp(nodes_.begin(), nodes_.end()); - stack_.push_back(std::vector(temp.begin(),temp.end())); - } - else - { - stack_.push_back(std::move(nodes_)); - } - nodes_.clear(); - state_stack_.back().is_recursive_descent = false; - state_stack_.back().is_union = false; - } - - void advance_past_space_character() - { - switch (*p_) - { - case ' ':case '\t': - ++p_; - ++column_; - break; - case '\r': - if (p_+1 < end_input_ && *(p_+1) == '\n') - ++p_; - ++line_; - column_ = 1; - ++p_; - break; - case '\n': - ++line_; - column_ = 1; - ++p_; - break; - default: - break; - } - } -}; - -} - -}} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpath/jsonpath_error.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpath/jsonpath_error.hpp deleted file mode 100644 index 54aa4f6ae8..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpath/jsonpath_error.hpp +++ /dev/null @@ -1,206 +0,0 @@ -/// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_JSONPATH_JSONPATH_ERROR_HPP -#define JSONCONS_JSONPATH_JSONPATH_ERROR_HPP - -#include -#include - -namespace jsoncons { namespace jsonpath { - -class jsonpath_error : public std::system_error, public virtual json_exception -{ - std::string buffer_; - size_t line_number_; - size_t column_number_; -public: - jsonpath_error(std::error_code ec) - : std::system_error(ec), line_number_(0), column_number_(0) - { - } - jsonpath_error(std::error_code ec, size_t position) - : std::system_error(ec), line_number_(0), column_number_(position) - { - } - jsonpath_error(std::error_code ec, size_t line, size_t column) - : std::system_error(ec), line_number_(line), column_number_(column) - { - } - jsonpath_error(const jsonpath_error& other) = default; - - jsonpath_error(jsonpath_error&& other) = default; - - const char* what() const noexcept override - { - try - { - std::ostringstream os; - os << std::system_error::what(); - if (line_number_ != 0 && column_number_ != 0) - { - os << " at line " << line_number_ << " and column " << column_number_; - } - else if (column_number_ != 0) - { - os << " at position " << column_number_; - } - const_cast(buffer_) = os.str(); - return buffer_.c_str(); - } - catch (...) - { - return std::system_error::what(); - } - } - - size_t line() const noexcept - { - return line_number_; - } - - size_t column() const noexcept - { - return column_number_; - } -#if !defined(JSONCONS_NO_DEPRECATED) - size_t line_number() const noexcept - { - return line(); - } - - size_t column_number() const noexcept - { - return column(); - } -#endif -}; - -enum class jsonpath_errc -{ - ok = 0, - expected_root, - expected_current_node, - expected_right_bracket, - expected_name, - expected_separator, - invalid_filter, - invalid_filter_expected_slash, - invalid_filter_unbalanced_paren, - invalid_filter_unsupported_operator, - invalid_filter_expected_right_brace, - invalid_filter_expected_primary, - expected_slice_start, - expected_slice_end, - expected_slice_step, - expected_left_bracket_token, - expected_minus_or_digit_or_colon_or_comma_or_right_bracket, - expected_digit_or_colon_or_comma_or_right_bracket, - expected_minus_or_digit_or_comma_or_right_bracket, - expected_digit_or_comma_or_right_bracket, - unexpected_operator, - invalid_function_name, - invalid_argument, - function_name_not_found, - parse_error_in_filter, - argument_parse_error, - unidentified_error, - unexpected_end_of_input -}; - -class jsonpath_error_category_impl - : public std::error_category -{ -public: - const char* name() const noexcept override - { - return "jsoncons/jsonpath"; - } - std::string message(int ev) const override - { - switch (static_cast(ev)) - { - case jsonpath_errc::expected_root: - return "Expected $"; - case jsonpath_errc::expected_current_node: - return "Expected @"; - case jsonpath_errc::expected_right_bracket: - return "Expected ]"; - case jsonpath_errc::expected_name: - return "Expected a name following a dot"; - case jsonpath_errc::expected_slice_start: - return "Expected slice start"; - case jsonpath_errc::expected_slice_end: - return "Expected slice end"; - case jsonpath_errc::expected_slice_step: - return "Expected slice step"; - case jsonpath_errc::expected_separator: - return "Expected dot or left bracket separator"; - case jsonpath_errc::invalid_filter: - return "Invalid path filter"; - case jsonpath_errc::invalid_filter_expected_slash: - return "Invalid path filter, expected '/'"; - case jsonpath_errc::invalid_filter_unbalanced_paren: - return "Invalid path filter, unbalanced parenthesis"; - case jsonpath_errc::invalid_filter_unsupported_operator: - return "Unsupported operator"; - case jsonpath_errc::invalid_filter_expected_right_brace: - return "Invalid path filter, expected right brace }"; - case jsonpath_errc::invalid_filter_expected_primary: - return "Invalid path filter, expected primary expression."; - case jsonpath_errc::expected_left_bracket_token: - return "Expected ?,',\",0-9,*"; - case jsonpath_errc::expected_minus_or_digit_or_colon_or_comma_or_right_bracket: - return "Expected - or 0-9 or : or , or ]"; - case jsonpath_errc::expected_minus_or_digit_or_comma_or_right_bracket: - return "Expected - or 0-9 or , or ]"; - case jsonpath_errc::expected_digit_or_comma_or_right_bracket: - return "Expected - or 0-9 or , or ]"; - case jsonpath_errc::expected_digit_or_colon_or_comma_or_right_bracket: - return "Expected 0-9 or : or , or ]"; - case jsonpath_errc::invalid_function_name: - return "Invalid function name"; - case jsonpath_errc::invalid_argument: - return "Invalid argument type"; - case jsonpath_errc::function_name_not_found: - return "Function name not found"; - case jsonpath_errc::parse_error_in_filter: - return "Could not parse JSON expression in a JSONPath filter"; - case jsonpath_errc::argument_parse_error: - return "Could not parse JSON expression passed to JSONPath function"; - case jsonpath_errc::unidentified_error: - return "Unidentified error"; - case jsonpath_errc::unexpected_end_of_input: - return "Unexpected end of jsonpath input"; - default: - return "Unknown jsonpath parser error"; - } - } -}; - -inline -const std::error_category& jsonpath_error_category() -{ - static jsonpath_error_category_impl instance; - return instance; -} - -inline -std::error_code make_error_code(jsonpath_errc result) -{ - return std::error_code(static_cast(result),jsonpath_error_category()); -} - -}} - -namespace std { - template<> - struct is_error_code_enum : public true_type - { - }; -} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpath/jsonpath_filter.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpath/jsonpath_filter.hpp deleted file mode 100644 index 444ac17f77..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpath/jsonpath_filter.hpp +++ /dev/null @@ -1,1953 +0,0 @@ -// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_JSONPATH_FILTER_HPP -#define JSONCONS_JSONPATH_FILTER_HPP - -#include -#include // std::map -#include -#include -#include -#include -#include -#include // std::numeric_limits -#include -#include - -namespace jsoncons { namespace jsonpath { namespace detail { - -JSONCONS_STRING_LITERAL(eqtilde,'=','~') -JSONCONS_STRING_LITERAL(star,'*') -JSONCONS_STRING_LITERAL(forwardslash,'/') -JSONCONS_STRING_LITERAL(plus,'+') -JSONCONS_STRING_LITERAL(minus,'-') -JSONCONS_STRING_LITERAL(lt,'<') -JSONCONS_STRING_LITERAL(lte,'<','=') -JSONCONS_STRING_LITERAL(gt,'>') -JSONCONS_STRING_LITERAL(gte,'>','=') -JSONCONS_STRING_LITERAL(eq,'=','=') -JSONCONS_STRING_LITERAL(ne,'!', '=') -JSONCONS_STRING_LITERAL(ampamp,'&','&') -JSONCONS_STRING_LITERAL(pipepipe,'|','|') - -template -struct PathConstructor -{ - typedef typename Json::char_type char_type; - typedef typename Json::string_view_type string_view_type; - typedef typename Json::string_type string_type; - - string_type operator()(const string_type& path, size_t index) const - { - char_type buf[255]; - char_type* p = buf; - do - { - *p++ = static_cast(48 + index % 10); - } while (index /= 10); - - string_type s; - s.append(path); - s.push_back('['); - while (--p >= buf) - { - s.push_back(*p); - } - s.push_back(']'); - return s; - } - - string_type operator()(const string_type& path, const string_view_type& sv) const - { - string_type s; - s.append(path); - s.push_back('['); - s.push_back('\''); - s.append(sv.data(),sv.length()); - s.push_back('\''); - s.push_back(']'); - return s; - } -}; - -template -struct VoidPathConstructor -{ - typedef typename Json::char_type char_type; - typedef typename Json::string_view_type string_view_type; - typedef typename Json::string_type string_type; - - string_type operator()(const string_type&, size_t) const - { - return string_type{}; - } - - string_type operator()(const string_type&, string_view_type) const - { - return string_type{}; - } -}; - -template -class jsonpath_evaluator; - -enum class filter_path_mode -{ - path, - root_path, - current_path -}; - -enum class filter_state -{ - start, - expect_right_round_bracket, - expect_oper_or_right_round_bracket, - expect_path_or_value_or_unary_op, - expect_regex, - regex, - single_quoted_text, - double_quoted_text, - unquoted_text, - path, - value, - oper, - expect_arg, - path_argument, - unquoted_argument, - single_quoted_argument, - double_quoted_argument, - expect_more_args_or_right_round_bracket, - done -}; - -enum class token_type -{ - operand, - unary_operator, - binary_operator, - lparen, - rparen -}; - -template -class term -{ -public: - typedef typename Json::string_type string_type; - typedef typename Json::char_type char_type; - - virtual ~term() {} - - virtual void initialize(const Json&) = 0; - - virtual bool accept_single_node() const - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator); - } - virtual Json get_single_node() const - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator); - } - virtual bool exclaim() const - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator); - } - virtual bool eq_term(const term&) const - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator); - } - virtual bool eq(const Json&) const - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator); - } - virtual bool ne_term(const term&) const - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator); - } - virtual bool ne(const Json&) const - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator); - } - virtual bool regex_term(const term&) const - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator); - } - virtual bool regex2(const string_type&) const - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator); - } - virtual bool ampamp_term(const term&) const - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator); - } - virtual bool ampamp(const Json&) const - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator); - } - virtual bool pipepipe_term(const term&) const - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator); - } - virtual bool pipepipe(const Json&) const - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator); - } - virtual bool lt_term(const term&) const - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator); - } - virtual bool lt(const Json&) const - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator); - } - virtual bool gt_term(const term&) const - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator); - } - virtual bool gt(const Json&) const - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator); - } - - virtual Json minus_term(const term&) const - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator); - } - virtual Json minus(const Json&) const - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator); - } - - virtual Json left_minus(const Json&) const - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator); - } - - virtual Json unary_minus() const - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator); - } - virtual Json plus_term(const term&) const - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator); - } - virtual Json plus(const Json&) const - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator); - } - virtual Json mult_term(const term&) const - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator); - } - virtual Json mult(const Json&) const - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator); - } - - virtual Json div_term(const term&) const - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator); - } - virtual Json div(const Json&) const - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator); - } - - virtual Json left_div(const Json&) const - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator); - } -}; - -template -struct operator_properties -{ - typedef std::function&, const term&)> operator_type; - - size_t precedence_level; - bool is_right_associative; - operator_type op; -}; - -template -class token -{ -public: - typedef std::function&)> unary_operator_type; - typedef std::function&, const term&)> operator_type; -private: - token_type type_; - size_t precedence_level_; - bool is_right_associative_; - std::shared_ptr> operand_ptr_; - unary_operator_type unary_operator_; - operator_type operator_; -public: - - token(token_type type) - : type_(type),precedence_level_(0),is_right_associative_(false) - { - } - token(token_type type, std::shared_ptr> term_ptr) - : type_(type),precedence_level_(0),is_right_associative_(false),operand_ptr_(term_ptr) - { - } - token(size_t precedence_level, - bool is_right_associative, - unary_operator_type unary_operator) - : type_(token_type::unary_operator), - precedence_level_(precedence_level), - is_right_associative_(is_right_associative), - unary_operator_(unary_operator) - { - } - token(const operator_properties& properties) - : type_(token_type::binary_operator), - precedence_level_(properties.precedence_level), - is_right_associative_(properties.is_right_associative), - operator_(properties.op) - { - } - - token(const token& t) = default; - - token_type type() const - { - return type_; - } - - Json operator()(const term& a) - { - return unary_operator_(a); - } - - Json operator()(const term& a, const term& b) - { - return operator_(a,b); - } - - token& operator=(const token& val) = default; - - bool is_operator() const - { - return is_unary_operator() || is_binary_operator(); - } - - bool is_unary_operator() const - { - return type_ == token_type::unary_operator; - } - - bool is_binary_operator() const - { - return type_ == token_type::binary_operator; - } - - bool is_operand() const - { - return type_ == token_type::operand; - } - - bool is_lparen() const - { - return type_ == token_type::lparen; - } - - bool is_rparen() const - { - return type_ == token_type::rparen; - } - - size_t precedence_level() const - { - return precedence_level_; - } - - bool is_right_associative() const - { - return is_right_associative_; - } - - const term& operand() - { - JSONCONS_ASSERT(type_ == token_type::operand && operand_ptr_ != nullptr); - return *operand_ptr_; - } - - void initialize(const Json& current_node) - { - if (operand_ptr_.get() != nullptr) - { - operand_ptr_->initialize(current_node); - } - } -}; - -template -bool ampamp(const Json& lhs, const Json& rhs) -{ - return lhs.as_bool() && rhs.as_bool(); -} - -template -bool pipepipe(const Json& lhs, const Json& rhs) -{ - return lhs.as_bool() || rhs.as_bool(); -} - -template -bool lt(const Json& lhs, const Json& rhs) -{ - bool result = false; - if (lhs.template is() && rhs.template is()) - { - result = lhs.template as() < rhs.template as(); - } - else if (lhs.template is() && rhs.template is()) - { - result = lhs.template as() < rhs.template as(); - } - else if (lhs.is_number() && rhs.is_number()) - { - result = lhs.as_double() < rhs.as_double(); - } - else if (lhs.is_string() && rhs.is_string()) - { - result = lhs.as_string_view() < rhs.as_string_view(); - } - return result; -} - -template -bool gt(const Json& lhs, const Json& rhs) -{ - return lt(rhs,lhs); -} - -template -Json plus(const Json& lhs, const Json& rhs) -{ - Json result = Json(jsoncons::null_type()); - if (lhs.is_int64() && rhs.is_int64()) - { - result = Json(((lhs.template as() + rhs.template as()))); - } - else if (lhs.is_uint64() && rhs.is_uint64()) - { - result = Json((lhs.template as() + rhs.template as())); - } - else if ((lhs.is_number() && rhs.is_number())) - { - result = Json((lhs.as_double() + rhs.as_double())); - } - return result; -} - -template -Json mult(const Json& lhs, const Json& rhs) -{ - Json result = Json(jsoncons::null_type()); - if (lhs.is_int64() && rhs.is_int64()) - { - result = Json(((lhs.template as() * rhs.template as()))); - } - else if (lhs.is_uint64() && rhs.is_uint64()) - { - result = Json((lhs.template as() * rhs.template as())); - } - else if ((lhs.is_number() && rhs.is_number())) - { - result = Json((lhs.as_double() * rhs.as_double())); - } - return result; -} - -template -Json div(const Json& lhs, const Json& rhs) -{ - Json result = Json(jsoncons::null_type()); - if (lhs.is_int64() && rhs.is_int64()) - { - result = Json((double)(lhs.template as() / (double)rhs.template as())); - } - else if (lhs.is_uint64() && rhs.is_uint64()) - { - result = Json((double)(lhs.template as() / (double)rhs.template as())); - } - else if ((lhs.is_number() && rhs.is_number())) - { - result = Json((lhs.as_double() / rhs.as_double())); - } - return result; -} - -template -Json unary_minus(const Json& lhs) -{ - Json result = Json::null(); - if (lhs.is_int64()) - { - result = -lhs.template as(); - } - else if (lhs.is_double()) - { - result = -lhs.as_double(); - } - return result; -} - -template -Json minus(const Json& lhs, const Json& rhs) -{ - Json result = Json::null(); - if (lhs.is_int64() && rhs.is_int64()) - { - result = ((lhs.template as() - rhs.template as())); - } - else if (lhs.is_uint64() && rhs.is_uint64() && lt(rhs,lhs)) - { - result = (lhs.template as() - rhs.template as()); - } - else if ((lhs.is_number() && rhs.is_number())) - { - result = (lhs.as_double() - rhs.as_double()); - } - return result; -} - -template -class value_term final : public term -{ - Json value_; -public: - value_term(const Json& val) - : value_(val) - { - } - value_term(Json&& val) - : value_(std::move(val)) - { - } - - void initialize(const Json&) override - { - } - - bool accept_single_node() const override - { - return value_.as_bool(); - } - - Json get_single_node() const override - { - return value_; - } - - bool exclaim() const override - { - return !value_.as_bool(); - } - - bool eq_term(const term& rhs) const override - { - return rhs.eq(value_); - } - - bool eq(const Json& rhs) const override - { - return value_ == rhs; - } - - bool ne_term(const term& rhs) const override - { - return rhs.ne(value_); - } - bool ne(const Json& rhs) const override - { - return value_ != rhs; - } - bool regex_term(const term& rhs) const override - { - return rhs.regex2(value_.as_string()); - } - bool ampamp_term(const term& rhs) const override - { - return rhs.ampamp(value_); - } - bool ampamp(const Json& rhs) const override - { - return jsoncons::jsonpath::detail::ampamp(value_,rhs); - } - bool pipepipe_term(const term& rhs) const override - { - return rhs.pipepipe(value_); - } - bool pipepipe(const Json& rhs) const override - { - return jsoncons::jsonpath::detail::pipepipe(value_,rhs); - } - - bool lt_term(const term& rhs) const override - { - return rhs.gt(value_); - } - bool lt(const Json& rhs) const override - { - return jsoncons::jsonpath::detail::lt(value_,rhs); - } - - bool gt_term(const term& rhs) const override - { - return rhs.lt(value_); - } - bool gt(const Json& rhs) const override - { - return jsoncons::jsonpath::detail::gt(value_,rhs); - } - - Json minus_term(const term& rhs) const override - { - return rhs.left_minus(value_); - } - Json minus(const Json& rhs) const override - { - return jsoncons::jsonpath::detail::minus(value_,rhs); - } - - Json left_minus(const Json& lhs) const override - { - return jsoncons::jsonpath::detail::minus(lhs,value_); - } - - Json unary_minus() const override - { - return jsoncons::jsonpath::detail::unary_minus(value_); - } - - Json plus_term(const term& rhs) const override - { - return rhs.plus(value_); - } - - Json plus(const Json& rhs) const override - { - return jsoncons::jsonpath::detail::plus(value_,rhs); - } - Json mult_term(const term& rhs) const override - { - return rhs.mult(value_); - } - - Json mult(const Json& rhs) const override - { - return jsoncons::jsonpath::detail::mult(value_,rhs); - } - - Json div_term(const term& rhs) const override - { - return rhs.left_div(value_); - } - Json div(const Json& rhs) const override - { - return jsoncons::jsonpath::detail::div(value_,rhs); - } - - Json left_div(const Json& lhs) const override - { - return jsoncons::jsonpath::detail::div(lhs,value_); - } -}; - -template -class regex_term final : public term -{ - typedef typename Json::char_type char_type; - typedef typename Json::string_type string_type; - const std::basic_regex pattern_; -public: - regex_term(const string_type& pattern, std::regex::flag_type flags) - : pattern_(pattern,flags) - { - } - - void initialize(const Json&) override - { - } - - bool regex2(const string_type& subject) const override - { - return std::regex_match(subject, pattern_); - } -}; - -template -class path_term final : public term -{ - typedef typename Json::string_type string_type; - - string_type path_; - size_t line_; - size_t column_; - Json nodes_; -public: - path_term(const string_type& path, size_t line, size_t column) - : path_(path), line_(line), column_(column) - { - } - - void initialize(const Json& current_node) override - { - jsonpath_evaluator> evaluator(line_,column_); - evaluator.evaluate(current_node, path_); - nodes_ = evaluator.get_values(); - } - - bool accept_single_node() const override - { - return nodes_.size() != 0; - } - - Json get_single_node() const override - { - return nodes_.size() == 1 ? nodes_[0] : nodes_; - } - - bool exclaim() const override - { - return nodes_.size() == 0; - } - - bool eq_term(const term& rhs) const override - { - bool result = false; - if (nodes_.size() > 0) - { - result = true; - for (size_t i = 0; result && i < nodes_.size(); ++i) - { - result = rhs.eq(nodes_[i]); - } - } - return result; - } - - bool eq(const Json& rhs) const override - { - bool result = false; - if (nodes_.size() > 0) - { - result = true; - for (size_t i = 0; result && i < nodes_.size(); ++i) - { - result = nodes_[i] == rhs; - } - } - return result; - } - - bool ne_term(const term& rhs) const override - { - bool result = false; - if (nodes_.size() > 0) - { - result = true; - for (size_t i = 0; result && i < nodes_.size(); ++i) - { - result = rhs.ne(nodes_[i]); - } - } - return result; - - } - bool ne(const Json& rhs) const override - { - bool result = false; - if (nodes_.size() > 0) - { - result = true; - for (size_t i = 0; result && i < nodes_.size(); ++i) - { - result = nodes_[i] != rhs; - } - } - return result; - } - bool regex_term(const term& rhs) const override - { - bool result = false; - if (nodes_.size() > 0) - { - result = true; - for (size_t i = 0; result && i < nodes_.size(); ++i) - { - result = rhs.regex2(nodes_[i].as_string()); - } - } - return result; - } - bool ampamp_term(const term& rhs) const override - { - bool result = false; - if (nodes_.size() > 0) - { - result = true; - for (size_t i = 0; result && i < nodes_.size(); ++i) - { - result = rhs.ampamp(nodes_[i]); - } - } - return result; - } - bool ampamp(const Json& rhs) const override - { - bool result = false; - if (nodes_.size() > 0) - { - result = true; - for (size_t i = 0; result && i < nodes_.size(); ++i) - { - result = jsoncons::jsonpath::detail::ampamp(nodes_[i],rhs); - } - } - return result; - } - bool pipepipe_term(const term& rhs) const override - { - bool result = false; - if (nodes_.size() > 0) - { - result = true; - for (size_t i = 0; result && i < nodes_.size(); ++i) - { - result = rhs.pipepipe(nodes_[i]); - } - } - return result; - } - bool pipepipe(const Json& rhs) const override - { - bool result = false; - if (nodes_.size() > 0) - { - result = true; - for (size_t i = 0; result && i < nodes_.size(); ++i) - { - result = jsoncons::jsonpath::detail::pipepipe(nodes_[i],rhs); - } - } - return result; - } - - bool lt(const Json& rhs) const override - { - bool result = false; - if (nodes_.size() > 0) - { - result = true; - for (size_t i = 0; result && i < nodes_.size(); ++i) - { - result = jsoncons::jsonpath::detail::lt(nodes_[i],rhs); - } - } - return result; - } - - bool lt_term(const term& rhs) const override - { - bool result = false; - if (nodes_.size() > 0) - { - result = true; - for (size_t i = 0; result && i < nodes_.size(); ++i) - { - result = rhs.gt(nodes_[i]); - } - } - return result; - } - - bool gt(const Json& rhs) const override - { - bool result = false; - if (nodes_.size() > 0) - { - result = true; - for (size_t i = 0; result && i < nodes_.size(); ++i) - { - result = jsoncons::jsonpath::detail::gt(nodes_[i],rhs); - } - } - return result; - } - - bool gt_term(const term& rhs) const override - { - bool result = false; - if (nodes_.size() > 0) - { - result = true; - for (size_t i = 0; result && i < nodes_.size(); ++i) - { - result = rhs.lt(nodes_[i]); - } - } - return result; - } - - Json minus_term(const term& rhs) const override - { - static auto a_null = Json(jsoncons::null_type()); - return nodes_.size() == 1 ? rhs.left_minus(nodes_[0]) : a_null; - } - Json minus(const Json& rhs) const override - { - return nodes_.size() == 1 ? jsoncons::jsonpath::detail::minus(nodes_[0],rhs) : Json(jsoncons::null_type()); - } - - Json left_minus(const Json& lhs) const override - { - static auto a_null = Json(jsoncons::null_type()); - return nodes_.size() == 1 ? jsoncons::jsonpath::detail::minus(lhs,nodes_[0]) : a_null; - } - - Json unary_minus() const override - { - return nodes_.size() == 1 ? jsoncons::jsonpath::detail::unary_minus(nodes_[0]) : Json::null(); - } - - Json plus_term(const term& rhs) const override - { - static auto a_null = Json(jsoncons::null_type()); - return nodes_.size() == 1 ? rhs.plus(nodes_[0]) : a_null; - } - Json plus(const Json& rhs) const override - { - static auto a_null = Json(jsoncons::null_type()); - return nodes_.size() == 1 ? jsoncons::jsonpath::detail::plus(nodes_[0],rhs) : a_null; - } - - Json mult_term(const term& rhs) const override - { - static auto a_null = Json(jsoncons::null_type()); - return nodes_.size() == 1 ? rhs.mult(nodes_[0]) : a_null; - } - Json mult(const Json& rhs) const override - { - static auto a_null = Json(jsoncons::null_type()); - return nodes_.size() == 1 ? jsoncons::jsonpath::detail::mult(nodes_[0],rhs) : a_null; - } - - Json div_term(const term& rhs) const override - { - static auto a_null = Json(jsoncons::null_type()); - return nodes_.size() == 1 ? rhs.left_div(nodes_[0]) : a_null; - } - Json div(const Json& rhs) const override - { - static auto a_null = Json(jsoncons::null_type()); - return nodes_.size() == 1 ? jsoncons::jsonpath::detail::div(nodes_[0],rhs) : a_null; - } - - Json left_div(const Json& lhs) const override - { - static auto a_null = Json(jsoncons::null_type()); - return nodes_.size() == 1 ? jsoncons::jsonpath::detail::div(lhs, nodes_[0]) : a_null; - } -}; - -template -token evaluate(const Json& context, std::vector>& tokens) -{ - for (auto it= tokens.begin(); it != tokens.end(); ++it) - { - it->initialize(context); - } - std::vector> stack; - for (auto t : tokens) - { - if (t.is_operand()) - { - stack.push_back(t); - } - else if (t.is_unary_operator()) - { - auto rhs = stack.back(); - stack.pop_back(); - Json val = t(rhs.operand()); - stack.push_back(token(token_type::operand,std::make_shared>(std::move(val)))); - } - else if (t.is_binary_operator()) - { - auto rhs = stack.back(); - stack.pop_back(); - auto lhs = stack.back(); - stack.pop_back(); - Json val = t(lhs.operand(), rhs.operand()); - stack.push_back(token(token_type::operand,std::make_shared>(std::move(val)))); - } - } - if (stack.size() != 1) - { - JSONCONS_THROW(json_runtime_error("Invalid state")); - } - - return stack.back(); -} - -template -class jsonpath_filter_expr -{ -public: - std::vector> tokens_; -public: - jsonpath_filter_expr() - { - } - - jsonpath_filter_expr(const std::vector>& tokens) - : tokens_(tokens) - { - } - - Json eval(const Json& current_node) - { - auto t = evaluate(current_node, tokens_); - return t.operand().get_single_node(); - } - - bool exists(const Json& current_node) - { - auto t = evaluate(current_node,tokens_); - return t.operand().accept_single_node(); - } -}; - -template -class jsonpath_filter_parser -{ - typedef typename Json::string_type string_type; - typedef typename Json::string_view_type string_view_type; - typedef typename Json::char_type char_type; - - std::vector> output_stack_; - std::vector> operator_stack_; - std::vector state_stack_; - std::vector path_mode_stack_; - - size_t line_; - size_t column_; - - static const operator_properties op_properties_[]; - - class binary_operator_table - { - typedef std::map> binary_operator_map; - - const binary_operator_map operators = - { - {eqtilde_literal(),{2,false,[](const term& a, const term& b) {return Json(a.regex_term(b)); }}}, - {star_literal(),{3,false,[](const term& a, const term& b) {return a.mult_term(b); }}}, - {forwardslash_literal(),{3,false,[](const term& a, const term& b) {return a.div_term(b); }}}, - {plus_literal(),{4,false,[](const term& a, const term& b) {return a.plus_term(b); }}}, - {minus_literal(),{4,false,[](const term& a, const term& b) {return a.minus_term(b); }}}, - {lt_literal(),{5,false,[](const term& a, const term& b) {return Json(a.lt_term(b)); }}}, - {lte_literal(),{5,false,[](const term& a, const term& b) {return Json(a.lt_term(b) || a.eq_term(b)); }}}, - {gt_literal(),{5,false,[](const term& a, const term& b) {return Json(a.gt_term(b)); }}}, - {gte_literal(),{5,false,[](const term& a, const term& b) {return Json(a.gt_term(b) || a.eq_term(b)); }}}, - {eq_literal(),{6,false,[](const term& a, const term& b) {return Json(a.eq_term(b)); }}}, - {ne_literal(),{6,false,[](const term& a, const term& b) {return Json(a.ne_term(b)); }}}, - {ampamp_literal(),{7,false,[](const term& a, const term& b) {return Json(a.ampamp_term(b)); }}}, - {pipepipe_literal(),{8,false,[](const term& a, const term& b) {return Json(a.pipepipe_term(b)); }}} - }; - - public: - typename binary_operator_map::const_iterator find(const string_type& key) const - { - return operators.find(key); - } - typename binary_operator_map::const_iterator end() const - { - return operators.end(); - } - }; - - binary_operator_table binary_operators_; - -public: - jsonpath_filter_parser() - : line_(1), column_(1) - { - } - jsonpath_filter_parser(size_t line, size_t column) - : line_(line), column_(column) - { - } - - size_t line() const - { - return line_; - } - - size_t column() const - { - return column_; - } - - void push_state(filter_state state) - { - state_stack_.push_back(state); - } - - filter_state pop_state() - { - JSONCONS_ASSERT(!state_stack_.empty()) - filter_state state = state_stack_.back(); - state_stack_.pop_back(); - return state; - } - - void push_token(token token) - { - switch (token.type()) - { - case token_type::operand: - output_stack_.push_back(token); - break; - case token_type::lparen: - operator_stack_.push_back(token); - break; - case token_type::rparen: - { - auto it = operator_stack_.rbegin(); - while (it != operator_stack_.rend() && !it->is_lparen()) - { - output_stack_.push_back(*it); - ++it; - } - if (it == operator_stack_.rend()) - { - JSONCONS_THROW(json_runtime_error("Unbalanced parenthesis")); - } - operator_stack_.erase(it.base(),operator_stack_.end()); - operator_stack_.pop_back(); - break; - } - case token_type::unary_operator: - case token_type::binary_operator: - { - if (operator_stack_.empty() || operator_stack_.back().is_lparen()) - { - operator_stack_.push_back(token); - } - else if (token.precedence_level() < operator_stack_.back().precedence_level() - || (token.precedence_level() == operator_stack_.back().precedence_level() && token.is_right_associative())) - { - operator_stack_.push_back(token); - } - else - { - auto it = operator_stack_.rbegin(); - while (it != operator_stack_.rend() && it->is_operator() - && (token.precedence_level() > it->precedence_level() - || (token.precedence_level() == it->precedence_level() && token.is_right_associative()))) - { - output_stack_.push_back(*it); - ++it; - } - - operator_stack_.erase(it.base(),operator_stack_.end()); - operator_stack_.push_back(token); - } - break; - } - default: - break; - } - } - - jsonpath_filter_expr parse(const Json& root, const char_type* p, const char_type* end_expr, const char_type** end_ptr) - { - output_stack_.clear(); - operator_stack_.clear(); - state_stack_.clear(); - - string_type buffer; - size_t buffer_line = 1; - size_t buffer_column = 1; - - int depth = 0; - filter_state state = filter_state::start; - while (p < end_expr && state != filter_state::done) - { - switch (state) - { - case filter_state::start: - switch (*p) - { - case '\r': - if (p+1 < end_expr && *(p+1) == '\n') - ++p; - ++line_; - column_ = 1; - ++p; - break; - case '\n': - ++line_; - column_ = 1; - ++p; - break; - case '(': - state = filter_state::expect_path_or_value_or_unary_op; - ++depth; - push_token(token(token_type::lparen)); - break; - case ')': - state = filter_state::expect_path_or_value_or_unary_op; - push_token(token(token_type::rparen)); - if (--depth == 0) - { - state = filter_state::done; - } - break; - } - ++p; - ++column_; - break; - - case filter_state::expect_arg: - { - switch (*p) - { - case ' ':case '\t': - break; - case '\r': - if (p+1 < end_expr && *(p+1) == '\n') - ++p; - ++line_; - column_ = 1; - ++p; - break; - case '\n': - ++line_; - column_ = 1; - ++p; - break; - case '$': - buffer.push_back(*p); - path_mode_stack_.back() = filter_path_mode::root_path; - state = filter_state::path_argument; - break; - case '@': - buffer.push_back('$'); - path_mode_stack_.back() = filter_path_mode::current_path; - state = filter_state::path_argument; - break; - // Maybe error from here down - case '\'': - buffer.push_back('\"'); - state = filter_state::single_quoted_argument; - break; - case '\"': - buffer.push_back('\"'); - state = filter_state::double_quoted_argument; - break; - default: - buffer.push_back(*p); - state = filter_state::unquoted_argument; - break; - } - ++p; - ++column_; - break; - } - - case filter_state::path_argument: - { - switch (*p) - { - case '\r': - if (p+1 < end_expr && *(p+1) == '\n') - ++p; - ++line_; - column_ = 1; - ++p; - break; - case '\n': - ++line_; - column_ = 1; - ++p; - break; - case ' ':case '\t': - break; - case ',': - buffer.push_back(*p); - state = filter_state::expect_arg; - break; - case ')': - { - buffer.push_back(*p); - state = filter_state::path; - break; - } - default: - buffer.push_back(*p); - break; - } - ++p; - ++column_; - break; - } - case filter_state::single_quoted_argument: - { - switch (*p) - { - case '\'': - buffer.push_back('\"'); - state = filter_state::expect_more_args_or_right_round_bracket; - break; - default: - buffer.push_back(*p); - break; - } - ++p; - ++column_; - break; - } - case filter_state::double_quoted_argument: - { - switch (*p) - { - case '\"': - buffer.push_back('\"'); - state = filter_state::expect_more_args_or_right_round_bracket; - break; - default: - buffer.push_back(*p); - break; - } - ++p; - ++column_; - break; - } - case filter_state::unquoted_argument: - { - switch (*p) - { - case ',': - buffer.push_back(*p); - state = filter_state::expect_arg; - break; - case ')': - { - buffer.push_back(*p); - state = filter_state::path; - break; - } - default: - buffer.push_back(*p); - break; - } - ++p; - ++column_; - break; - } - case filter_state::expect_more_args_or_right_round_bracket: - { - switch (*p) - { - case ' ': - case '\t': - break; - case ',': - buffer.push_back(*p); - state = filter_state::expect_arg; - break; - case ')': - { - buffer.push_back(*p); - state = filter_state::path; - break; - } - default: - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator, line_, column_); - } - ++p; - ++column_; - break; - } - - case filter_state::oper: - switch (*p) - { - case '~': - { - buffer.push_back(*p); - ++p; - ++column_; - auto it = binary_operators_.find(buffer); - if (it == binary_operators_.end()) - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator, line_, column_); - } - buffer.clear(); - buffer_line = buffer_column = 1; - push_token(token(it->second)); - state = filter_state::expect_regex; - break; - } - case '=': - case '&': - case '|': - { - buffer.push_back(*p); - ++p; - ++column_; - auto it = binary_operators_.find(buffer); - if (it == binary_operators_.end()) - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator, line_, column_); - } - buffer.clear(); - buffer_line = buffer_column = 1; - push_token(token(it->second)); - state = filter_state::expect_path_or_value_or_unary_op; - break; - } - default: - { - auto it = binary_operators_.find(buffer); - if (it == binary_operators_.end()) - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unsupported_operator, line_, column_); - } - buffer.clear(); - buffer_line = buffer_column = 1; - push_token(token(it->second)); - state = filter_state::expect_path_or_value_or_unary_op; - break; - } - } - break; - case filter_state::unquoted_text: - { - switch (*p) - { - case ' ':case '\t': - if (buffer.length() > 0) - { - try - { - auto val = Json::parse(buffer); - push_token(token(token_type::operand,std::make_shared>(std::move(val)))); - } - catch (const ser_error&) - { - throw jsonpath_error(jsonpath_errc::parse_error_in_filter,line_,column_); - } - buffer.clear(); - buffer_line = buffer_column = 1; - } - ++p; - ++column_; - break; - case '(': - { - buffer.push_back(*p); - path_mode_stack_.push_back(filter_path_mode::path); - state = filter_state::expect_arg; - ++p; - ++column_; - break; - } - case '<': - case '>': - case '!': - case '=': - case '&': - case '|': - case '+': - case '-': - case '*': - case '/': - { - if (buffer.length() > 0) - { - try - { - auto val = Json::parse(buffer); - push_token(token(token_type::operand,std::make_shared>(std::move(val)))); - } - catch (const ser_error&) - { - throw jsonpath_error(jsonpath_errc::parse_error_in_filter,line_,column_); - } - buffer.clear(); - buffer_line = buffer_column = 1; - } - buffer.push_back(*p); - state = filter_state::oper; - ++p; - ++column_; - } - break; - case ')': - if (buffer.length() > 0) - { - try - { - auto val = Json::parse(buffer); - push_token(token(token_type::operand,std::make_shared>(std::move(val)))); - } - catch (const ser_error&) - { - throw jsonpath_error(jsonpath_errc::parse_error_in_filter,line_,column_); - } - buffer.clear(); - buffer_line = buffer_column = 1; - } - push_token(token(token_type::rparen)); - if (--depth == 0) - { - state = filter_state::done; - } - else - { - state = filter_state::expect_path_or_value_or_unary_op; - } - ++p; - ++column_; - break; - default: - buffer.push_back(*p); - ++p; - ++column_; - break; - } - } - break; - case filter_state::single_quoted_text: - { - switch (*p) - { - case '\\': - buffer.push_back(*p); - if (p+1 < end_expr) - { - ++p; - ++column_; - buffer.push_back(*p); - } - break; - case '\'': - buffer.push_back('\"'); - //if (buffer.length() > 0) - { - try - { - auto val = Json::parse(buffer); - push_token(token(token_type::operand,std::make_shared>(std::move(val)))); - } - catch (const ser_error&) - { - throw jsonpath_error(jsonpath_errc::parse_error_in_filter,line_,column_); - } - buffer.clear(); - buffer_line = buffer_column = 1; - } - state = filter_state::expect_path_or_value_or_unary_op; - break; - - default: - buffer.push_back(*p); - break; - } - } - ++p; - ++column_; - break; - case filter_state::double_quoted_text: - { - switch (*p) - { - case '\\': - buffer.push_back(*p); - if (p+1 < end_expr) - { - ++p; - ++column_; - buffer.push_back(*p); - } - break; - case '\"': - buffer.push_back(*p); - try - { - auto val = Json::parse(buffer); - push_token(token(token_type::operand,std::make_shared>(std::move(val)))); - } - catch (const ser_error&) - { - throw jsonpath_error(jsonpath_errc::parse_error_in_filter,line_,column_); - } - buffer.clear(); - buffer_line = buffer_column = 1; - state = filter_state::expect_path_or_value_or_unary_op; - break; - - default: - buffer.push_back(*p); - break; - } - } - ++p; - ++column_; - break; - case filter_state::expect_path_or_value_or_unary_op: - switch (*p) - { - case '\r': - if (p+1 < end_expr && *(p+1) == '\n') - ++p; - ++line_; - column_ = 1; - ++p; - break; - case '\n': - ++line_; - column_ = 1; - ++p; - break; - case ' ':case '\t': - ++p; - ++column_; - break; - case '!': - { - std::function&)> f = [](const term& b) {return Json(b.exclaim());}; - push_token(token(1, true, f)); - ++p; - ++column_; - break; - } - case '-': - { - std::function&)> f = [](const term& b) {return b.unary_minus();}; - push_token(token(1, true, f)); - ++p; - ++column_; - break; - } - case '@': - buffer_line = line_; - buffer_column = column_; - buffer.push_back('$'); - state = filter_state::path; - ++p; - ++column_; - break; - case '\'': - buffer.push_back('\"'); - state = filter_state::single_quoted_text; - ++p; - ++column_; - break; - case '\"': - buffer.push_back(*p); - state = filter_state::double_quoted_text; - ++p; - ++column_; - break; - case '(': - ++depth; - push_token(token(token_type::lparen)); - ++p; - ++column_; - break; - case ')': - push_token(token(token_type::rparen)); - if (--depth == 0) - { - state = filter_state::done; - } - ++p; - ++column_; - break; - default: - // don't increment - state = filter_state::unquoted_text; - break; - }; - break; - case filter_state::expect_oper_or_right_round_bracket: - switch (*p) - { - case '\r': - if (p+1 < end_expr && *(p+1) == '\n') - ++p; - ++line_; - column_ = 1; - ++p; - break; - case '\n': - ++line_; - column_ = 1; - ++p; - break; - case ' ':case '\t': - ++p; - ++column_; - break; - case ')': - push_token(token(token_type::rparen)); - if (--depth == 0) - { - state = filter_state::done; - ++p; // fix - } - break; - case '<': - case '>': - case '!': - case '=': - case '&': - case '|': - case '+': - case '-': - case '*': - case '/': - { - buffer.push_back(*p); - state = filter_state::oper; - ++p; - ++column_; - } - break; - default: - throw jsonpath_error(jsonpath_errc::invalid_filter,line_,column_); - break; - }; - break; - case filter_state::expect_right_round_bracket: - switch (*p) - { - case '\r': - if (p+1 < end_expr && *(p+1) == '\n') - ++p; - ++line_; - column_ = 1; - ++p; - break; - case '\n': - ++line_; - column_ = 1; - ++p; - break; - case ' ':case '\t': - break; - case ')': - push_token(token(token_type::rparen)); - if (--depth == 0) - { - state = filter_state::done; - } - else - { - state = filter_state::expect_oper_or_right_round_bracket; - } - break; - default: - throw jsonpath_error(jsonpath_errc::invalid_filter,line_,column_); - break; - }; - ++p; - ++column_; - break; - case filter_state::path: - switch (*p) - { - case '<': - case '>': - case '!': - case '=': - case '&': - case '|': - case '+': - case '-': - case '*': - case '/': - { - if (!path_mode_stack_.empty()) - { - if (path_mode_stack_[0] == filter_path_mode::root_path) - { - jsonpath_evaluator> evaluator(buffer_line,buffer_column); - evaluator.evaluate(root, buffer); - auto result = evaluator.get_values(); - if (result.size() > 0) - { - push_token(token(token_type::operand,std::make_shared>(std::move(result[0])))); - } - } - else - { - push_token(token(token_type::operand,std::make_shared>(buffer, buffer_line, buffer_column))); - } - path_mode_stack_.pop_back(); - } - else - { - push_token(token(token_type::operand,std::make_shared>(buffer, buffer_line, buffer_column))); - } - buffer.clear(); - buffer_line = buffer_column = 1; - buffer.push_back(*p); - ++p; - ++column_; - state = filter_state::oper; - } - break; - case ')': - if (!path_mode_stack_.empty()) - { - if (path_mode_stack_[0] == filter_path_mode::root_path) - { - jsonpath_evaluator> evaluator(buffer_line,buffer_column); - evaluator.evaluate(root, buffer); - auto result = evaluator.get_values(); - if (result.size() > 0) - { - push_token(token(token_type::operand,std::make_shared>(std::move(result[0])))); - } - push_token(token(token_type::rparen)); - } - else - { - push_token(token(token_type::operand,std::make_shared>(buffer, buffer_line, buffer_column))); - } - path_mode_stack_.pop_back(); - } - else - { - push_token(token(token_type::operand,std::make_shared>(buffer, buffer_line, buffer_column))); - push_token(token(token_type::rparen)); - } - buffer.clear(); - buffer_line = buffer_column = 1; - if (--depth == 0) - { - state = filter_state::done; - } - else - { - state = filter_state::expect_path_or_value_or_unary_op; - } - ++p; - ++column_; - break; - default: - buffer.push_back(*p); - ++p; - ++column_; - break; - }; - break; - case filter_state::expect_regex: - switch (*p) - { - case '\r': - if (p+1 < end_expr && *(p+1) == '\n') - ++p; - ++line_; - column_ = 1; - ++p; - break; - case '\n': - ++line_; - column_ = 1; - ++p; - break; - case ' ':case '\t': - break; - case '/': - state = filter_state::regex; - break; - default: - throw jsonpath_error(jsonpath_errc::invalid_filter_expected_slash,line_,column_); - break; - }; - ++p; - ++column_; - break; - case filter_state::regex: - { - switch (*p) - { - case '/': - //if (buffer.length() > 0) - { - std::regex::flag_type flags = std::regex_constants::ECMAScript; - if (p+1 < end_expr && *(p+1) == 'i') - { - ++p; - ++column_; - flags |= std::regex_constants::icase; - } - push_token(token(token_type::operand,std::make_shared>(buffer,flags))); - buffer.clear(); - buffer_line = buffer_column = 1; - } - state = filter_state::expect_path_or_value_or_unary_op; - break; - - default: - buffer.push_back(*p); - break; - } - ++p; - ++column_; - break; - } - default: - ++p; - ++column_; - break; - } - } - if (depth != 0) - { - throw jsonpath_error(jsonpath_errc::invalid_filter_unbalanced_paren,line_,column_); - } - *end_ptr = p; - - return jsonpath_filter_expr(output_stack_); - } -}; - -template -const operator_properties jsonpath_filter_parser::op_properties_[] = -{ - {2,false,[](const term& a, const term& b) {return Json(a.regex_term(b));}}, - {3,false,[](const term& a, const term& b) {return a.mult_term(b);}}, - {3,false,[](const term& a, const term& b) {return a.div_term(b);}}, - {4,false,[](const term& a, const term& b) {return a.plus_term(b);}}, - {4,false,[](const term& a, const term& b) {return a.minus_term(b);}}, - {5,false,[](const term& a, const term& b) {return Json(a.lt_term(b));}}, - {5,false,[](const term& a, const term& b) {return Json(a.lt_term(b) || a.eq_term(b));}}, - {5,false,[](const term& a, const term& b) {return Json(a.gt_term(b));}}, - {5,false,[](const term& a, const term& b) {return Json(a.gt_term(b) || a.eq_term(b));}}, - {6,false,[](const term& a, const term& b) {return Json(a.eq_term(b)); }}, - {6,false,[](const term& a, const term& b) {return Json(a.ne_term(b)); }}, - {7,false,[](const term& a, const term& b) {return Json(a.ampamp_term(b));}}, - {8,false,[](const term& a, const term& b) {return Json(a.pipepipe_term(b));}} -}; - -}}} - -#endif \ No newline at end of file diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpath/jsonpath_function.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpath/jsonpath_function.hpp deleted file mode 100644 index 793ea2aa58..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpath/jsonpath_function.hpp +++ /dev/null @@ -1,225 +0,0 @@ -// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_JSONPATH_JSONPATH_FUNCTION_HPP -#define JSONCONS_JSONPATH_JSONPATH_FUNCTION_HPP - -#include // std::basic_string -#include // std::vector -#include // std::unordered_map -#include // std::numeric_limits -#include // std::move -#include - -namespace jsoncons { namespace jsonpath { - -JSONCONS_STRING_LITERAL(keys,'k','e','y','s') -JSONCONS_STRING_LITERAL(avg,'a','v','g') -JSONCONS_STRING_LITERAL(max,'m','a','x') -JSONCONS_STRING_LITERAL(min,'m','i','n') -JSONCONS_STRING_LITERAL(sum,'s','u','m') -JSONCONS_STRING_LITERAL(prod,'p','r','o','d') -JSONCONS_STRING_LITERAL(count,'c','o','u','n','t') -JSONCONS_STRING_LITERAL(tokenize,'t','o','k','e','n','i','z','e') - -template -class function_table -{ -public: - typedef typename Json::char_type char_type; - typedef typename Json::char_traits_type char_traits_type; - typedef std::basic_string string_type; - typedef typename Json::string_view_type string_view_type; - typedef JsonPointer pointer; - typedef std::vector argument_type; - typedef std::function&, std::error_code&)> function_type; - typedef std::unordered_map function_dictionary; -private: - const function_dictionary functions_ = - { - { - keys_literal(),[](const std::vector& args, std::error_code& ec) - { - Json j = typename Json::array(); - if (args.size() != 1) - { - ec = jsonpath_errc::invalid_argument; - return j; - } - if (args[0].size() != 1 && !args[0][0]->is_object()) - { - return j; - } - pointer arg = args[0][0]; - for (const auto& kv : arg->object_range()) - { - j.emplace_back(kv.key()); - } - - return j; - } - }, - { - max_literal(),[](const std::vector& args, std::error_code& ec) - { - if (args.size() != 1) - { - ec = jsonpath_errc::invalid_argument; - return Json(); - } - const auto& arg = args[0]; - double v = std::numeric_limits::lowest(); - for (auto& node : arg) - { - double x = node->template as(); - if (x > v) - { - v = x; - } - } - return Json(v); - } - }, - { - min_literal(),[](const std::vector& args, std::error_code& ec) - { - if (args.size() != 1) - { - ec = jsonpath_errc::invalid_argument; - return Json(); - } - const auto& arg = args[0]; - double v = (std::numeric_limits::max)(); - for (const auto& node : arg) - { - double x = node->template as(); - if (x < v) - { - v = x; - } - } - return Json(v); - } - }, - { - avg_literal(),[](const std::vector& args, std::error_code& ec) - { - if (args.size() != 1) - { - ec = jsonpath_errc::invalid_argument; - return Json(); - } - const auto& arg = args[0]; - double v = 0.0; - for (const auto& node : arg) - { - v += node->template as(); - } - return arg.size() > 0 ? Json(v/arg.size()) : Json(null_type()); - } - }, - { - sum_literal(),[](const std::vector& args, std::error_code& ec) - { - if (args.size() != 1) - { - ec = jsonpath_errc::invalid_argument; - return Json(); - } - const auto& arg = args[0]; - double v = 0.0; - for (const auto& node : arg) - { - v += node->template as(); - } - return Json(v); - } - }, - { - count_literal(),[](const std::vector& args, std::error_code& ec) - { - if (args.size() != 1) - { - ec = jsonpath_errc::invalid_argument; - return Json(); - } - const auto& arg = args[0]; - size_t count = 0; - while (count < arg.size()) - { - ++count; - } - return Json(count); - } - }, - { - prod_literal(),[](const std::vector& args, std::error_code& ec) - { - if (args.size() != 1) - { - ec = jsonpath_errc::invalid_argument; - return Json(); - } - const auto& arg = args[0]; - double v = 0.0; - for (const auto& node : arg) - { - double x = node->template as(); - v == 0.0 && x != 0.0 - ? (v = x) - : (v *= x); - - } - return Json(v); - } - } -#if !(defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ < 9)) -// GCC 4.8 has broken regex support: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53631 - ,{ - tokenize_literal(),[](const std::vector& args, std::error_code& ec) - { - if (args.size() != 2) - { - ec = jsonpath_errc::invalid_argument; - return Json(); - } - string_type arg1 = args[0][0]->as_string(); - string_type arg2 = args[1][0]->as_string(); - - std::regex::flag_type flags = std::regex_constants::ECMAScript; - std::basic_regex pieces_regex(arg2, flags); - - std::regex_token_iterator rit ( arg1.begin(), arg1.end(), pieces_regex, -1); - std::regex_token_iterator rend; - - Json j = typename Json::array(); - while (rit!=rend) - { - j.push_back(rit->str()); - ++rit; - } - return j; - } - } -#endif - }; -public: - function_type get(const string_type& name, std::error_code& ec) const - { - auto it = functions_.find(name); - if (it == functions_.end()) - { - //std::cout << "Function name " << name << " not found\n"; - ec = jsonpath_errc::function_name_not_found; - return nullptr; - } - return it->second; - } -}; - -}} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpointer/jsonpointer.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpointer/jsonpointer.hpp deleted file mode 100644 index ec1b00824d..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpointer/jsonpointer.hpp +++ /dev/null @@ -1,959 +0,0 @@ -// Copyright 2017 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_JSONPOINTER_JSONPOINTER_HPP -#define JSONCONS_JSONPOINTER_JSONPOINTER_HPP - -#include -#include -#include -#include -#include -#include -#include // std::move -#include // system_error -#include // std::enable_if, std::true_type -#include -#include -#include - -namespace jsoncons { namespace jsonpointer { - -// find_by_reference - -template -struct is_accessible_by_reference : std::false_type {}; - -template -struct is_accessible_by_reference().at(typename J::string_view_type()))>::value - && std::is_reference().at(0))>::value>::type> -: std::true_type {}; - -namespace detail { - -enum class pointer_state -{ - start, - escaped, - delim -}; - -} // detail - -// address_iterator -template -class address_iterator -{ - typedef typename std::iterator_traits::value_type char_type; - typedef std::basic_string string_type; - typedef InputIt base_iterator; - - base_iterator path_ptr_; - base_iterator end_input_; - base_iterator p_; - base_iterator q_; - jsonpointer::detail::pointer_state state_; - size_t line_; - size_t column_; - std::basic_string buffer_; -public: - typedef string_type value_type; - typedef std::ptrdiff_t difference_type; - typedef value_type* pointer; - typedef const value_type& reference; - typedef std::input_iterator_tag iterator_category; - - address_iterator(base_iterator first, base_iterator last) - : address_iterator(first, last, first) - { - std::error_code ec; - increment(ec); - } - - address_iterator(base_iterator first, base_iterator last, base_iterator current) - : path_ptr_(first), end_input_(last), p_(current), q_(current), state_(jsonpointer::detail::pointer_state::start) - { - } - - address_iterator(const address_iterator&) = default; - - address_iterator(address_iterator&&) = default; - - address_iterator& operator=(const address_iterator&) = default; - - address_iterator& operator=(address_iterator&&) = default; - - address_iterator& operator++() - { - std::error_code ec; - increment(ec); - if (ec) - { - throw jsonpointer_error(ec); - } - return *this; - } - - address_iterator& increment(std::error_code& ec) - { - q_ = p_; - buffer_.clear(); - - bool done = false; - while (p_ != end_input_ && !done) - { - switch (state_) - { - case jsonpointer::detail::pointer_state::start: - switch (*p_) - { - case '/': - state_ = jsonpointer::detail::pointer_state::delim; - break; - default: - ec = jsonpointer_errc::expected_slash; - done = true; - break; - }; - break; - case jsonpointer::detail::pointer_state::delim: - switch (*p_) - { - case '/': - state_ = jsonpointer::detail::pointer_state::delim; - done = true; - break; - case '~': - state_ = jsonpointer::detail::pointer_state::escaped; - break; - default: - buffer_.push_back(*p_); - break; - }; - break; - case jsonpointer::detail::pointer_state::escaped: - switch (*p_) - { - case '0': - buffer_.push_back('~'); - state_ = jsonpointer::detail::pointer_state::delim; - break; - case '1': - buffer_.push_back('/'); - state_ = jsonpointer::detail::pointer_state::delim; - break; - default: - ec = jsonpointer_errc::expected_0_or_1; - done = true; - break; - }; - break; - default: - JSONCONS_UNREACHABLE(); - break; - } - ++p_; - ++column_; - } - return *this; - } - - address_iterator operator++(int) // postfix increment - { - address_iterator temp(*this); - ++(*this); - return temp; - } - - reference operator*() const - { - return buffer_; - } - - friend bool operator==(const address_iterator& it1, const address_iterator& it2) - { - return it1.q_ == it2.q_; - } - friend bool operator!=(const address_iterator& it1, const address_iterator& it2) - { - return !(it1 == it2); - } - -private: -}; - -template -std::basic_string escape_string(const std::basic_string& s) -{ - std::basic_string result; - for (auto c : s) - { - switch (c) - { - case '~': - result.push_back('~'); - result.push_back('0'); - break; - case '/': - result.push_back('~'); - result.push_back('1'); - break; - default: - result.push_back(c); - break; - } - } - return result; -} - -// address - -template -class basic_address -{ -public: - std::basic_string path_; -public: - // Member types - typedef CharT char_type; - typedef std::basic_string string_type; - typedef basic_string_view string_view_type; - typedef address_iterator const_iterator; - typedef const_iterator iterator; - - // Constructors - basic_address() - { - } - explicit basic_address(const string_type& s) - : path_(s) - { - } - explicit basic_address(string_type&& s) - : path_(std::move(s)) - { - } - explicit basic_address(const CharT* s) - : path_(s) - { - } - - basic_address(const basic_address&) = default; - - basic_address(basic_address&&) = default; - - // operator= - basic_address& operator=(const basic_address&) = default; - - basic_address& operator=(basic_address&&) = default; - - // Modifiers - - void clear() - { - path_.clear(); - } - - basic_address& operator/=(const string_type& s) - { - path_.push_back('/'); - path_.append(escape_string(s)); - - return *this; - } - - basic_address& operator+=(const basic_address& p) - { - path_.append(p.path_); - return *this; - } - - // Accessors - bool empty() const - { - return path_.empty(); - } - - const string_type& string() const - { - return path_; - } - - operator string_view_type() const - { - return path_; - } - - // Iterators - iterator begin() const - { - return iterator(path_.begin(),path_.end()); - } - iterator end() const - { - return iterator(path_.begin(), path_.end(), path_.end()); - } - - // Non-member functions - friend basic_address operator/(const basic_address& lhs, const string_type& rhs) - { - basic_address p(lhs); - p /= rhs; - return p; - } - - friend basic_address operator+( const basic_address& lhs, const basic_address& rhs ) - { - basic_address p(lhs); - p += rhs; - return p; - } - - friend bool operator==( const basic_address& lhs, const basic_address& rhs ) - { - return lhs.path_ == rhs.path_; - } - - friend bool operator!=( const basic_address& lhs, const basic_address& rhs ) - { - return lhs.path_ != rhs.path_; - } - - friend std::basic_ostream& - operator<<( std::basic_ostream& os, const basic_address& p ) - { - os << p.path_; - return os; - } -}; - -typedef basic_address address; - -namespace detail { - -template -class handle_type -{ -public: - using value_type = typename J::value_type; - using type = value_type; - - handle_type(const value_type& val) noexcept - : val_(val) - { - } - - handle_type(value_type&& val) noexcept - : val_(std::move(val)) - { - } - - handle_type(const handle_type& w) noexcept - : val_(w.val_) - { - } - - handle_type& operator=(const handle_type&) noexcept = default; - - type get() const noexcept - { - return val_; - } -private: - value_type val_; -}; - -template -class handle_type::value>::type> -{ -public: - using reference = JReference; - using type = reference; - using pointer = typename std::conditional::type>::value,typename J::const_pointer,typename J::pointer>::type; - - handle_type(reference ref) noexcept - : ptr_(std::addressof(ref)) - { - } - - handle_type(const handle_type&) noexcept = default; - - handle_type& operator=(const handle_type&) noexcept = default; - - type get() const noexcept - { - return *ptr_; - } -private: - pointer ptr_; -}; - -template -class jsonpointer_evaluator : public ser_context -{ - typedef typename handle_type::type type; - typedef typename J::string_type string_type; - typedef typename string_type::value_type char_type; - typedef typename J::string_view_type string_view_type; - using reference = JReference; - using pointer = typename std::conditional::type>::value,typename J::const_pointer,typename J::pointer>::type; - - size_t line_; - size_t column_; - string_type buffer_; - std::vector> current_; -public: - type get_result() - { - return current_.back().get(); - } - - void get(reference root, const string_view_type& path, std::error_code& ec) - { - evaluate(root, path, ec); - if (ec) - { - return; - } - if (path.empty()) - { - return; - } - resolve(current_, buffer_, ec); - } - - string_type normalized_path(reference root, const string_view_type& path) - { - std::error_code ec; - evaluate(root, path, ec); - if (ec) - { - return string_type(path); - } - if (current_.back().get().is_array() && buffer_.size() == 1 && buffer_[0] == '-') - { - string_type p = string_type(path.substr(0,path.length()-1)); - std::string s = std::to_string(current_.back().get().size()); - for (auto c : s) - { - p.push_back(c); - } - return p; - } - else - { - return string_type(path); - } - } - - void insert_or_assign(reference root, const string_view_type& path, const J& value, std::error_code& ec) - { - evaluate(root, path, ec); - if (ec) - { - return; - } - if (current_.back().get().is_array()) - { - if (buffer_.size() == 1 && buffer_[0] == '-') - { - current_.back().get().push_back(value); - } - else - { - if (!jsoncons::detail::is_integer(buffer_.data(), buffer_.length())) - { - ec = jsonpointer_errc::invalid_index; - return; - } - auto result = jsoncons::detail::to_integer(buffer_.data(), buffer_.length()); - if (result.ec != jsoncons::detail::to_integer_errc()) - { - ec = jsonpointer_errc::invalid_index; - return; - } - size_t index = result.value; - if (index > current_.back().get().size()) - { - ec = jsonpointer_errc::index_exceeds_array_size; - return; - } - if (index == current_.back().get().size()) - { - current_.back().get().push_back(value); - } - else - { - current_.back().get().insert(current_.back().get().array_range().begin()+index,value); - } - } - } - else if (current_.back().get().is_object()) - { - current_.back().get().insert_or_assign(buffer_,value); - } - else - { - ec = jsonpointer_errc::expected_object_or_array; - return; - } - } - - void insert(reference root, const string_view_type& path, const J& value, std::error_code& ec) - { - evaluate(root, path, ec); - if (ec) - { - return; - } - if (current_.back().get().is_array()) - { - if (buffer_.size() == 1 && buffer_[0] == '-') - { - current_.back().get().push_back(value); - } - else - { - if (!jsoncons::detail::is_integer(buffer_.data(), buffer_.length())) - { - ec = jsonpointer_errc::invalid_index; - return; - } - auto result = jsoncons::detail::to_integer(buffer_.data(), buffer_.length()); - if (result.ec != jsoncons::detail::to_integer_errc()) - { - ec = jsonpointer_errc::invalid_index; - return; - } - size_t index = result.value; - if (index > current_.back().get().size()) - { - ec = jsonpointer_errc::index_exceeds_array_size; - return; - } - if (index == current_.back().get().size()) - { - current_.back().get().push_back(value); - } - else - { - current_.back().get().insert(current_.back().get().array_range().begin()+index,value); - } - } - } - else if (current_.back().get().is_object()) - { - if (current_.back().get().contains(buffer_)) - { - ec = jsonpointer_errc::key_already_exists; - return; - } - else - { - current_.back().get().insert_or_assign(buffer_,value); - } - } - else - { - ec = jsonpointer_errc::expected_object_or_array; - return; - } - } - - void remove(reference root, const string_view_type& path, std::error_code& ec) - { - evaluate(root, path, ec); - if (ec) - { - return; - } - if (current_.back().get().is_array()) - { - if (buffer_.size() == 1 && buffer_[0] == '-') - { - ec = jsonpointer_errc::index_exceeds_array_size; - return; - } - else - { - if (!jsoncons::detail::is_integer(buffer_.data(), buffer_.length())) - { - ec = jsonpointer_errc::invalid_index; - return; - } - auto result = jsoncons::detail::to_integer(buffer_.data(), buffer_.length()); - if (result.ec != jsoncons::detail::to_integer_errc()) - { - ec = jsonpointer_errc::invalid_index; - return; - } - size_t index = result.value; - if (index >= current_.back().get().size()) - { - ec = jsonpointer_errc::index_exceeds_array_size; - return; - } - current_.back().get().erase(current_.back().get().array_range().begin()+index); - } - } - else if (current_.back().get().is_object()) - { - if (!current_.back().get().contains(buffer_)) - { - ec = jsonpointer_errc::name_not_found; - return; - } - else - { - current_.back().get().erase(buffer_); - } - } - else - { - ec = jsonpointer_errc::expected_object_or_array; - return; - } - } - - void replace(reference root, const string_view_type& path, const J& value, std::error_code& ec) - { - evaluate(root, path, ec); - if (ec) - { - return; - } - if (current_.back().get().is_array()) - { - if (buffer_.size() == 1 && buffer_[0] == '-') - { - ec = jsonpointer_errc::index_exceeds_array_size; - return; - } - else - { - if (!jsoncons::detail::is_integer(buffer_.data(), buffer_.length())) - { - ec = jsonpointer_errc::invalid_index; - return; - } - auto result = jsoncons::detail::to_integer(buffer_.data(), buffer_.length()); - if (result.ec != jsoncons::detail::to_integer_errc()) - { - ec = jsonpointer_errc::invalid_index; - return; - } - size_t index = result.value; - if (index >= current_.back().get().size()) - { - ec = jsonpointer_errc::index_exceeds_array_size; - return; - } - (current_.back().get())[index] = value; - } - } - else if (current_.back().get().is_object()) - { - if (!current_.back().get().contains(buffer_)) - { - ec = jsonpointer_errc::key_already_exists; - return; - } - else - { - current_.back().get().insert_or_assign(buffer_,value); - } - } - else - { - ec = jsonpointer_errc::expected_object_or_array; - return; - } - } - - void evaluate(reference root, const string_view_type& path, std::error_code& ec) - { - current_.push_back(root); - - address_iterator it(path.begin(), path.end()); - address_iterator end(path.begin(), path.end(), path.end()); - while (it != end) - { - buffer_ = *it; - it.increment(ec); - if (ec) - return; - if (it == end) - { - return; - } - resolve(current_, buffer_, ec); - if (ec) - return; - } - } - - static void resolve(std::vector>& current, - const string_view_type& buffer, - std::error_code& ec) - { - if (current.back().get().is_array()) - { - if (buffer.size() == 1 && buffer[0] == '-') - { - ec = jsonpointer_errc::index_exceeds_array_size; - return; - } - else - { - if (!jsoncons::detail::is_integer(buffer.data(), buffer.length())) - { - ec = jsonpointer_errc::invalid_index; - return; - } - auto result = jsoncons::detail::to_integer(buffer.data(), buffer.length()); - if (result.ec != jsoncons::detail::to_integer_errc()) - { - ec = jsonpointer_errc::invalid_index; - return; - } - size_t index = result.value; - if (index >= current.back().get().size()) - { - ec = jsonpointer_errc::index_exceeds_array_size; - return; - } - current.push_back(current.back().get().at(index)); - } - } - else if (current.back().get().is_object()) - { - if (!current.back().get().contains(buffer)) - { - ec = jsonpointer_errc::name_not_found; - return; - } - current.push_back(current.back().get().at(buffer)); - } - else - { - ec = jsonpointer_errc::expected_object_or_array; - return; - } - } - - // ser_context - - size_t line() const override - { - return line_; - } - - size_t column() const override - { - return column_; - } -}; - -} - -template -typename J::string_type normalized_path(const J& root, const typename J::string_view_type& path) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - return evaluator.normalized_path(root,path); -} - -template -typename std::enable_if::value,J&>::type -get(J& root, const typename J::string_view_type& path) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - std::error_code ec; - evaluator.get(root, path, ec); - if (ec) - { - JSONCONS_THROW(jsonpointer_error(ec)); - } - return evaluator.get_result(); -} - -template -typename std::enable_if::value,const J&>::type -get(const J& root, const typename J::string_view_type& path) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - - std::error_code ec; - evaluator.get(root, path, ec); - if (ec) - { - JSONCONS_THROW(jsonpointer_error(ec)); - } - return evaluator.get_result(); -} - -template -typename std::enable_if::value,J>::type -get(const J& root, const typename J::string_view_type& path) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - - std::error_code ec; - evaluator.get(root, path, ec); - if (ec) - { - JSONCONS_THROW(jsonpointer_error(ec)); - } - return evaluator.get_result(); -} - -template -typename std::enable_if::value,J&>::type -get(J& root, const typename J::string_view_type& path, std::error_code& ec) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - evaluator.get(root, path, ec); - return evaluator.get_result(); -} - -template -typename std::enable_if::value,const J&>::type -get(const J& root, const typename J::string_view_type& path, std::error_code& ec) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - evaluator.get(root, path, ec); - return evaluator.get_result(); -} - -template -typename std::enable_if::value,J>::type -get(const J& root, const typename J::string_view_type& path, std::error_code& ec) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - evaluator.get(root, path, ec); - return evaluator.get_result(); -} - -template -bool contains(const J& root, const typename J::string_view_type& path) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - std::error_code ec; - evaluator.get(root, path, ec); - return !ec ? true : false; -} - -template -void insert_or_assign(J& root, const typename J::string_view_type& path, const J& value) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - - std::error_code ec; - evaluator.insert_or_assign(root, path, value, ec); - if (ec) - { - JSONCONS_THROW(jsonpointer_error(ec)); - } -} - -template -void insert_or_assign(J& root, const typename J::string_view_type& path, const J& value, std::error_code& ec) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - - evaluator.insert_or_assign(root, path, value, ec); -} - -template -void insert(J& root, const typename J::string_view_type& path, const J& value) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - - std::error_code ec; - evaluator.insert(root, path, value, ec); - if (ec) - { - JSONCONS_THROW(jsonpointer_error(ec)); - } -} - -template -void insert(J& root, const typename J::string_view_type& path, const J& value, std::error_code& ec) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - - evaluator.insert(root, path, value, ec); -} - -template -void remove(J& root, const typename J::string_view_type& path) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - - std::error_code ec; - evaluator.remove(root, path, ec); - if (ec) - { - JSONCONS_THROW(jsonpointer_error(ec)); - } -} - -template -void remove(J& root, const typename J::string_view_type& path, std::error_code& ec) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - - evaluator.remove(root, path, ec); -} - -template -void replace(J& root, const typename J::string_view_type& path, const J& value) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - - std::error_code ec; - evaluator.replace(root, path, value, ec); - if (ec) - { - JSONCONS_THROW(jsonpointer_error(ec)); - } -} - -template -void replace(J& root, const typename J::string_view_type& path, const J& value, std::error_code& ec) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - - evaluator.replace(root, path, value, ec); -} - -template -void escape(const String& s, std::basic_ostringstream& os) -{ - for (auto c : s) - { - if (c == '~') - { - os.put('~'); - os.put('0'); - } - else if (c == '/') - { - os.put('~'); - os.put('1'); - } - else - { - os.put(c); - } - } -} - -}} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpointer/jsonpointer.hpp.orig b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpointer/jsonpointer.hpp.orig deleted file mode 100644 index c18dd12aef..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpointer/jsonpointer.hpp.orig +++ /dev/null @@ -1,1060 +0,0 @@ -// Copyright 2017 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_JSONPOINTER_JSONPOINTER_HPP -#define JSONCONS_JSONPOINTER_JSONPOINTER_HPP - -#include -#include -#include -#include -#include -#include -#include // std::move -#include // std::enable_if, std::true_type -#include -#include -#include - -namespace jsoncons { namespace jsonpointer { - -class jsonpointer_error : public std::exception, public virtual json_exception -{ -public: - jsonpointer_error(const std::error_code& ec) - : error_code_(ec) - { - } - jsonpointer_error(const jsonpointer_error& other) = default; - - jsonpointer_error(jsonpointer_error&& other) = default; - - const char* what() const noexcept override - { - try - { - const_cast(buffer_) = error_code_.message(); - return buffer_.c_str(); - } - catch (...) - { - return ""; - } - } - - const std::error_code code() const - { - return error_code_; - } - - jsonpointer_error& operator=(const jsonpointer_error& e) = default; - jsonpointer_error& operator=(jsonpointer_error&& e) = default; -private: - std::string buffer_; - std::error_code error_code_; -}; - -// find_by_reference - -template -struct is_accessible_by_reference : std::false_type {}; - -template -struct is_accessible_by_reference().at(typename J::string_view_type()))>::value - && std::is_reference().at(0))>::value>::type> -: std::true_type {}; - -namespace detail { - -enum class pointer_state -{ - start, - escaped, - delim -}; - -} // detail - -// address_iterator -template -class address_iterator -{ - typedef typename std::iterator_traits::value_type char_type; - typedef std::basic_string string_type; - typedef InputIt base_iterator; - - base_iterator path_ptr_; - base_iterator end_input_; - base_iterator p_; - base_iterator q_; - jsonpointer::detail::pointer_state state_; - size_t line_; - size_t column_; - std::basic_string buffer_; -public: - typedef string_type value_type; - typedef std::ptrdiff_t difference_type; - typedef value_type* pointer; - typedef const value_type& reference; - typedef std::input_iterator_tag iterator_category; - - address_iterator(base_iterator first, base_iterator last) - : address_iterator(first, last, first) - { - std::error_code ec; - increment(ec); - } - - address_iterator(base_iterator first, base_iterator last, base_iterator current) - : path_ptr_(first), end_input_(last), p_(current), q_(current), state_(jsonpointer::detail::pointer_state::start) - { - } - - address_iterator(const address_iterator&) = default; - - address_iterator(address_iterator&&) = default; - - address_iterator& operator=(const address_iterator&) = default; - - address_iterator& operator=(address_iterator&&) = default; - - address_iterator& operator++() - { - std::error_code ec; - increment(ec); - if (ec) - { - throw jsonpointer_error(ec); - } - return *this; - } - - address_iterator& increment(std::error_code& ec) - { - q_ = p_; - buffer_.clear(); - - bool done = false; - while (p_ != end_input_ && !done) - { - switch (state_) - { - case jsonpointer::detail::pointer_state::start: - switch (*p_) - { - case '/': - state_ = jsonpointer::detail::pointer_state::delim; - break; - default: - ec = jsonpointer_errc::expected_slash; - done = true; - break; - }; - break; - case jsonpointer::detail::pointer_state::delim: - switch (*p_) - { - case '/': - state_ = jsonpointer::detail::pointer_state::delim; - done = true; - break; - case '~': - state_ = jsonpointer::detail::pointer_state::escaped; - break; - default: - buffer_.push_back(*p_); - break; - }; - break; - case jsonpointer::detail::pointer_state::escaped: - switch (*p_) - { - case '0': - buffer_.push_back('~'); - state_ = jsonpointer::detail::pointer_state::delim; - break; - case '1': - buffer_.push_back('/'); - state_ = jsonpointer::detail::pointer_state::delim; - break; - default: - ec = jsonpointer_errc::expected_0_or_1; - done = true; - break; - }; - break; - default: - JSONCONS_UNREACHABLE(); - break; - } - ++p_; - ++column_; - } - return *this; - } - - address_iterator operator++(int) // postfix increment - { - address_iterator temp(*this); - ++(*this); - return temp; - } - - reference operator*() const - { - return buffer_; - } - - friend bool operator==(const address_iterator& it1, const address_iterator& it2) - { - return it1.q_ == it2.q_; - } - friend bool operator!=(const address_iterator& it1, const address_iterator& it2) - { - return !(it1 == it2); - } - -private: -}; - -inline -std::basic_string escape_string(const std::basic_string& s) -{ - std::basic_string result; - for (auto c : s) - { - switch (c) - { - case '~': - result.push_back('~'); - result.push_back('0'); - break; - case '/': - result.push_back('~'); - result.push_back('1'); - break; - default: - result.push_back(c); - break; - } - } - return result; -} - -// address - -<<<<<<< HEAD -template -class basic_address -======= -class address ->>>>>>> efc18942efb17086d3de2d1d853d56a11666ebb0 -{ -public: - std::basic_string path_; -public: - // Member types - typedef char char_type; - typedef std::basic_string string_type; - typedef basic_string_view string_view_type; - typedef address_iterator const_iterator; - typedef const_iterator iterator; - - // Constructors -<<<<<<< HEAD - basic_address() - { - } - explicit basic_address(const string_type& s) - : path_(s) - { - } - explicit basic_address(string_type&& s) - : path_(std::move(s)) - { - } - explicit basic_address(const CharT* s) -======= - address() - { - } - explicit address(const string_type& s) - : path_(s) - { - } - explicit address(string_type&& s) - : path_(std::move(s)) - { - } - explicit address(const char_type* s) ->>>>>>> efc18942efb17086d3de2d1d853d56a11666ebb0 - : path_(s) - { - } - -<<<<<<< HEAD - basic_address(const basic_address&) = default; - - basic_address(basic_address&&) = default; - - // operator= - basic_address& operator=(const basic_address&) = default; - - basic_address& operator=(basic_address&&) = default; -======= - address(const address&) = default; - - address(address&&) = default; - - // operator= - address& operator=(const address&) = default; - - address& operator=(address&&) = default; ->>>>>>> efc18942efb17086d3de2d1d853d56a11666ebb0 - - // Modifiers - - void clear() - { - path_.clear(); - } - -<<<<<<< HEAD - basic_address& operator/=(const string_type& s) -======= - address& operator/=(const string_type& s) ->>>>>>> efc18942efb17086d3de2d1d853d56a11666ebb0 - { - path_.push_back('/'); - path_.append(escape_string(s)); - - return *this; - } - -<<<<<<< HEAD - basic_address& operator+=(const basic_address& p) -======= - address& operator+=(const address& p) ->>>>>>> efc18942efb17086d3de2d1d853d56a11666ebb0 - { - path_.append(p.path_); - return *this; - } - - // Accessors - bool empty() const - { - return path_.empty(); - } - - const string_type& string() const - { - return path_; - } - - operator string_view_type() const - { - return path_; - } - - // Iterators - iterator begin() const - { - return iterator(path_.begin(),path_.end()); - } - iterator end() const - { - return iterator(path_.begin(), path_.end(), path_.end()); - } - - // Non-member functions -<<<<<<< HEAD - friend basic_address operator/(const basic_address& lhs, const string_type& rhs) - { - basic_address p(lhs); -======= - friend address operator/(const address& lhs, const string_type& rhs) - { - address p(lhs); ->>>>>>> efc18942efb17086d3de2d1d853d56a11666ebb0 - p /= rhs; - return p; - } - -<<<<<<< HEAD - friend basic_address operator+( const basic_address& lhs, const basic_address& rhs ) - { - basic_address p(lhs); -======= - friend address operator+( const address& lhs, const address& rhs ) - { - address p(lhs); ->>>>>>> efc18942efb17086d3de2d1d853d56a11666ebb0 - p += rhs; - return p; - } - -<<<<<<< HEAD - friend bool operator==( const basic_address& lhs, const basic_address& rhs ) -======= - friend bool operator==( const address& lhs, const address& rhs ) ->>>>>>> efc18942efb17086d3de2d1d853d56a11666ebb0 - { - return lhs.path_ == rhs.path_; - } - -<<<<<<< HEAD - friend bool operator!=( const basic_address& lhs, const basic_address& rhs ) -======= - friend bool operator!=( const address& lhs, const address& rhs ) ->>>>>>> efc18942efb17086d3de2d1d853d56a11666ebb0 - { - return lhs.path_ != rhs.path_; - } - -<<<<<<< HEAD - friend std::basic_ostream& - operator<<( std::basic_ostream& os, const basic_address& p ) -======= - friend std::ostream& - operator<<( std::ostream& os, const address& p ) ->>>>>>> efc18942efb17086d3de2d1d853d56a11666ebb0 - { - os << p.path_; - return os; - } -}; - -<<<<<<< HEAD -typedef basic_address address; - -======= ->>>>>>> efc18942efb17086d3de2d1d853d56a11666ebb0 -namespace detail { - -template -class handle_type -{ -public: - using value_type = typename J::value_type; - using type = value_type; - - handle_type(const value_type& val) noexcept - : val_(val) - { - } - - handle_type(value_type&& val) noexcept - : val_(std::move(val)) - { - } - - handle_type(const handle_type& w) noexcept - : val_(w.val_) - { - } - - handle_type& operator=(const handle_type&) noexcept = default; - - type get() const noexcept - { - return val_; - } -private: - value_type val_; -}; - -template -class handle_type::value>::type> -{ -public: - using reference = JReference; - using type = reference; - using pointer = typename std::conditional::type>::value,typename J::const_pointer,typename J::pointer>::type; - - handle_type(reference ref) noexcept - : ptr_(std::addressof(ref)) - { - } - - handle_type(const handle_type&) noexcept = default; - - handle_type& operator=(const handle_type&) noexcept = default; - - type get() const noexcept - { - return *ptr_; - } -private: - pointer ptr_; -}; - -template -class jsonpointer_evaluator : private serializing_context -{ - typedef typename handle_type::type type; - typedef typename J::string_type string_type; - typedef typename string_type::value_type char_type; - typedef typename J::string_view_type string_view_type; - using reference = JReference; - using pointer = typename std::conditional::type>::value,typename J::const_pointer,typename J::pointer>::type; - - size_t line_; - size_t column_; - string_type buffer_; - std::vector> current_; -public: - type get_result() - { - return current_.back().get(); - } - - void get(reference root, const string_view_type& path, std::error_code& ec) - { - evaluate(root, path, ec); - if (ec) - { - return; - } - if (path.empty()) - { - return; - } - resolve(current_, buffer_, ec); - } - - string_type normalized_path(reference root, const string_view_type& path) - { - std::error_code ec; - evaluate(root, path, ec); - if (ec) - { - return string_type(path); - } - if (current_.back().get().is_array() && buffer_.size() == 1 && buffer_[0] == '-') - { - string_type p = string_type(path.substr(0,path.length()-1)); - std::string s = std::to_string(current_.back().get().size()); - for (auto c : s) - { - p.push_back(c); - } - return p; - } - else - { - return string_type(path); - } - } - - void insert_or_assign(reference root, const string_view_type& path, const J& value, std::error_code& ec) - { - evaluate(root, path, ec); - if (ec) - { - return; - } - if (current_.back().get().is_array()) - { - if (buffer_.size() == 1 && buffer_[0] == '-') - { - current_.back().get().push_back(value); - } - else - { - if (!jsoncons::detail::is_integer(buffer_.data(), buffer_.length())) - { - ec = jsonpointer_errc::invalid_index; - return; - } - auto result = jsoncons::detail::to_integer(buffer_.data(), buffer_.length()); - if (result.overflow) - { - ec = jsonpointer_errc::invalid_index; - return; - } - size_t index = result.value; - if (index > current_.back().get().size()) - { - ec = jsonpointer_errc::index_exceeds_array_size; - return; - } - if (index == current_.back().get().size()) - { - current_.back().get().push_back(value); - } - else - { - current_.back().get().insert(current_.back().get().array_range().begin()+index,value); - } - } - } - else if (current_.back().get().is_object()) - { - current_.back().get().insert_or_assign(buffer_,value); - } - else - { - ec = jsonpointer_errc::expected_object_or_array; - return; - } - } - - void insert(reference root, const string_view_type& path, const J& value, std::error_code& ec) - { - evaluate(root, path, ec); - if (ec) - { - return; - } - if (current_.back().get().is_array()) - { - if (buffer_.size() == 1 && buffer_[0] == '-') - { - current_.back().get().push_back(value); - } - else - { - if (!jsoncons::detail::is_integer(buffer_.data(), buffer_.length())) - { - ec = jsonpointer_errc::invalid_index; - return; - } - auto result = jsoncons::detail::to_integer(buffer_.data(), buffer_.length()); - if (result.overflow) - { - ec = jsonpointer_errc::invalid_index; - return; - } - size_t index = result.value; - if (index > current_.back().get().size()) - { - ec = jsonpointer_errc::index_exceeds_array_size; - return; - } - if (index == current_.back().get().size()) - { - current_.back().get().push_back(value); - } - else - { - current_.back().get().insert(current_.back().get().array_range().begin()+index,value); - } - } - } - else if (current_.back().get().is_object()) - { - if (current_.back().get().contains(buffer_)) - { - ec = jsonpointer_errc::key_already_exists; - return; - } - else - { - current_.back().get().insert_or_assign(buffer_,value); - } - } - else - { - ec = jsonpointer_errc::expected_object_or_array; - return; - } - } - - void remove(reference root, const string_view_type& path, std::error_code& ec) - { - evaluate(root, path, ec); - if (ec) - { - return; - } - if (current_.back().get().is_array()) - { - if (buffer_.size() == 1 && buffer_[0] == '-') - { - ec = jsonpointer_errc::index_exceeds_array_size; - return; - } - else - { - if (!jsoncons::detail::is_integer(buffer_.data(), buffer_.length())) - { - ec = jsonpointer_errc::invalid_index; - return; - } - auto result = jsoncons::detail::to_integer(buffer_.data(), buffer_.length()); - if (result.overflow) - { - ec = jsonpointer_errc::invalid_index; - return; - } - size_t index = result.value; - if (index >= current_.back().get().size()) - { - ec = jsonpointer_errc::index_exceeds_array_size; - return; - } - current_.back().get().erase(current_.back().get().array_range().begin()+index); - } - } - else if (current_.back().get().is_object()) - { - if (!current_.back().get().contains(buffer_)) - { - ec = jsonpointer_errc::name_not_found; - return; - } - else - { - current_.back().get().erase(buffer_); - } - } - else - { - ec = jsonpointer_errc::expected_object_or_array; - return; - } - } - - void replace(reference root, const string_view_type& path, const J& value, std::error_code& ec) - { - evaluate(root, path, ec); - if (ec) - { - return; - } - if (current_.back().get().is_array()) - { - if (buffer_.size() == 1 && buffer_[0] == '-') - { - ec = jsonpointer_errc::index_exceeds_array_size; - return; - } - else - { - if (!jsoncons::detail::is_integer(buffer_.data(), buffer_.length())) - { - ec = jsonpointer_errc::invalid_index; - return; - } - auto result = jsoncons::detail::to_integer(buffer_.data(), buffer_.length()); - if (result.overflow) - { - ec = jsonpointer_errc::invalid_index; - return; - } - size_t index = result.value; - if (index >= current_.back().get().size()) - { - ec = jsonpointer_errc::index_exceeds_array_size; - return; - } - (current_.back().get())[index] = value; - } - } - else if (current_.back().get().is_object()) - { - if (!current_.back().get().contains(buffer_)) - { - ec = jsonpointer_errc::key_already_exists; - return; - } - else - { - current_.back().get().insert_or_assign(buffer_,value); - } - } - else - { - ec = jsonpointer_errc::expected_object_or_array; - return; - } - } - - void evaluate(reference root, const string_view_type& path, std::error_code& ec) - { - current_.push_back(root); - - address_iterator it(path.begin(), path.end()); - address_iterator end(path.begin(), path.end(), path.end()); - while (it != end) - { - buffer_ = *it; - it.increment(ec); - if (ec) - return; - if (it == end) - { - return; - } - resolve(current_, buffer_, ec); - if (ec) - return; - } - } - - static void resolve(std::vector>& current, - const string_view_type& buffer, - std::error_code& ec) - { - if (current.back().get().is_array()) - { - if (buffer.size() == 1 && buffer[0] == '-') - { - ec = jsonpointer_errc::index_exceeds_array_size; - return; - } - else - { - if (!jsoncons::detail::is_integer(buffer.data(), buffer.length())) - { - ec = jsonpointer_errc::invalid_index; - return; - } - auto result = jsoncons::detail::to_integer(buffer.data(), buffer.length()); - if (result.overflow) - { - ec = jsonpointer_errc::invalid_index; - return; - } - size_t index = result.value; - if (index >= current.back().get().size()) - { - ec = jsonpointer_errc::index_exceeds_array_size; - return; - } - current.push_back(current.back().get().at(index)); - } - } - else if (current.back().get().is_object()) - { - if (!current.back().get().contains(buffer)) - { - ec = jsonpointer_errc::name_not_found; - return; - } - current.push_back(current.back().get().at(buffer)); - } - else - { - ec = jsonpointer_errc::expected_object_or_array; - return; - } - } - - // serializing_context - - size_t line_number() const override - { - return line_; - } - - size_t column_number() const override - { - return column_; - } -}; - -} - -template -typename J::string_type normalized_path(const J& root, const typename J::string_view_type& path) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - return evaluator.normalized_path(root,path); -} - -template -typename std::enable_if::value,J&>::type -get(J& root, const typename J::string_view_type& path) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - std::error_code ec; - evaluator.get(root, path, ec); - if (ec) - { - JSONCONS_THROW(jsonpointer_error(ec)); - } - return evaluator.get_result(); -} - -template -typename std::enable_if::value,const J&>::type -get(const J& root, const typename J::string_view_type& path) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - - std::error_code ec; - evaluator.get(root, path, ec); - if (ec) - { - JSONCONS_THROW(jsonpointer_error(ec)); - } - return evaluator.get_result(); -} - -template -typename std::enable_if::value,J>::type -get(const J& root, const typename J::string_view_type& path) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - - std::error_code ec; - evaluator.get(root, path, ec); - if (ec) - { - JSONCONS_THROW(jsonpointer_error(ec)); - } - return evaluator.get_result(); -} - -template -typename std::enable_if::value,J&>::type -get(J& root, const typename J::string_view_type& path, std::error_code& ec) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - evaluator.get(root, path, ec); - return evaluator.get_result(); -} - -template -typename std::enable_if::value,const J&>::type -get(const J& root, const typename J::string_view_type& path, std::error_code& ec) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - evaluator.get(root, path, ec); - return evaluator.get_result(); -} - -template -typename std::enable_if::value,J>::type -get(const J& root, const typename J::string_view_type& path, std::error_code& ec) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - evaluator.get(root, path, ec); - return evaluator.get_result(); -} - -template -bool contains(const J& root, const typename J::string_view_type& path) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - std::error_code ec; - evaluator.get(root, path, ec); - return !ec ? true : false; -} - -template -void insert_or_assign(J& root, const typename J::string_view_type& path, const J& value) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - - std::error_code ec; - evaluator.insert_or_assign(root, path, value, ec); - if (ec) - { - JSONCONS_THROW(jsonpointer_error(ec)); - } -} - -template -void insert_or_assign(J& root, const typename J::string_view_type& path, const J& value, std::error_code& ec) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - - evaluator.insert_or_assign(root, path, value, ec); -} - -template -void insert(J& root, const typename J::string_view_type& path, const J& value) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - - std::error_code ec; - evaluator.insert(root, path, value, ec); - if (ec) - { - JSONCONS_THROW(jsonpointer_error(ec)); - } -} - -template -void insert(J& root, const typename J::string_view_type& path, const J& value, std::error_code& ec) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - - evaluator.insert(root, path, value, ec); -} - -template -void remove(J& root, const typename J::string_view_type& path) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - - std::error_code ec; - evaluator.remove(root, path, ec); - if (ec) - { - JSONCONS_THROW(jsonpointer_error(ec)); - } -} - -template -void remove(J& root, const typename J::string_view_type& path, std::error_code& ec) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - - evaluator.remove(root, path, ec); -} - -template -void replace(J& root, const typename J::string_view_type& path, const J& value) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - - std::error_code ec; - evaluator.replace(root, path, value, ec); - if (ec) - { - JSONCONS_THROW(jsonpointer_error(ec)); - } -} - -template -void replace(J& root, const typename J::string_view_type& path, const J& value, std::error_code& ec) -{ - jsoncons::jsonpointer::detail::jsonpointer_evaluator evaluator; - - evaluator.replace(root, path, value, ec); -} - -template -void escape(const String& s, std::basic_ostringstream& os) -{ - for (auto c : s) - { - if (c == '~') - { - os.put('~'); - os.put('0'); - } - else if (c == '/') - { - os.put('~'); - os.put('1'); - } - else - { - os.put(c); - } - } -} - -}} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpointer/jsonpointer_error.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpointer/jsonpointer_error.hpp deleted file mode 100644 index dfd26184c7..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/jsonpointer/jsonpointer_error.hpp +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_JSONPOINTER_JSONPOINTER_ERROR_HPP -#define JSONCONS_JSONPOINTER_JSONPOINTER_ERROR_HPP - -#include -#include - -namespace jsoncons { namespace jsonpointer { - -class jsonpointer_error : public std::system_error, public virtual json_exception -{ -public: - jsonpointer_error(const std::error_code& ec) - : std::system_error(ec) - { - } - jsonpointer_error(const std::error_code& ec, const std::string& what_arg) - : std::system_error(ec, what_arg) - { - } - jsonpointer_error(const std::error_code& ec, const char* what_arg) - : std::system_error(ec, what_arg) - { - } - jsonpointer_error(const jsonpointer_error& other) = default; - - jsonpointer_error(jsonpointer_error&& other) = default; - - const char* what() const noexcept override - { - return std::system_error::what(); - } -}; - -enum class jsonpointer_errc -{ - ok = 0, - expected_slash = 1, - index_exceeds_array_size, - expected_0_or_1, - invalid_index, - name_not_found, - key_already_exists, - expected_object_or_array, - end_of_input -}; - -class jsonpointer_error_category_impl - : public std::error_category -{ -public: - const char* name() const noexcept override - { - return "jsoncons/jsonpointer"; - } - std::string message(int ev) const override - { - switch (static_cast(ev)) - { - case jsonpointer_errc::expected_slash: - return "Expected /"; - case jsonpointer_errc::index_exceeds_array_size: - return "Index exceeds array size"; - case jsonpointer_errc::expected_0_or_1: - return "Expected '0' or '1' after escape character '~'"; - case jsonpointer_errc::name_not_found: - return "Name not found"; - case jsonpointer_errc::invalid_index: - return "Invalid array index"; - case jsonpointer_errc::key_already_exists: - return "Key already exists"; - case jsonpointer_errc::expected_object_or_array: - return "Expected object or array"; - case jsonpointer_errc::end_of_input: - return "Unexpected end of input"; - default: - return "Unknown jsonpointer error"; - } - } -}; - -inline -const std::error_category& jsonpointer_error_category() -{ - static jsonpointer_error_category_impl instance; - return instance; -} - -inline -std::error_code make_error_code(jsonpointer_errc result) -{ - return std::error_code(static_cast(result),jsonpointer_error_category()); -} - -}} - -namespace std { - template<> - struct is_error_code_enum : public true_type - { - }; -} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/msgpack/msgpack.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/msgpack/msgpack.hpp deleted file mode 100644 index d5c8360edb..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/msgpack/msgpack.hpp +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_MSGPACK_MSGPACK_HPP -#define JSONCONS_MSGPACK_MSGPACK_HPP - -#include -#include -#include -#include // std::enable_if -#include // std::basic_istream -#include -#include -#include -#include - -namespace jsoncons { namespace msgpack { - -// encode_msgpack - -template -typename std::enable_if::value,void>::type -encode_msgpack(const T& j, std::vector& v) -{ - typedef typename T::char_type char_type; - msgpack_bytes_encoder encoder(v); - auto adaptor = make_json_content_handler_adaptor>(encoder); - j.dump(adaptor); -} - -template -typename std::enable_if::value,void>::type -encode_msgpack(const T& val, std::vector& v) -{ - msgpack_bytes_encoder encoder(v); - write_to(json(), val, encoder); -} - -template -typename std::enable_if::value,void>::type -encode_msgpack(const T& j, std::ostream& os) -{ - typedef typename T::char_type char_type; - msgpack_encoder encoder(os); - auto adaptor = make_json_content_handler_adaptor>(encoder); - j.dump(adaptor); -} - -template -typename std::enable_if::value,void>::type -encode_msgpack(const T& val, std::ostream& os) -{ - msgpack_encoder encoder(os); - write_to(json(), val, encoder); -} - -// decode_msgpack - -template -typename std::enable_if::value,T>::type -decode_msgpack(const std::vector& v) -{ - jsoncons::json_decoder decoder; - auto adaptor = make_json_content_handler_adaptor(decoder); - basic_msgpack_reader reader(v, adaptor); - std::error_code ec; - reader.read(ec); - if (ec) - { - throw ser_error(ec,reader.line(),reader.column()); - } - return decoder.get_result(); -} - -template -typename std::enable_if::value,T>::type -decode_msgpack(const std::vector& v) -{ - jsoncons::json_decoder decoder; - basic_msgpack_reader reader(v, decoder); - reader.read(); - return decoder.get_result().template as(); -} - -template -typename std::enable_if::value,T>::type -decode_msgpack(std::istream& is) -{ - jsoncons::json_decoder decoder; - auto adaptor = make_json_content_handler_adaptor(decoder); - msgpack_reader reader(is, adaptor); - std::error_code ec; - reader.read(ec); - if (ec) - { - throw ser_error(ec,reader.line(),reader.column()); - } - return decoder.get_result(); -} - -template -typename std::enable_if::value,T>::type -decode_msgpack(std::istream& is) -{ - jsoncons::json_decoder decoder; - msgpack_reader reader(is, decoder); - reader.read(); - return decoder.get_result(); -} - -#if !defined(JSONCONS_NO_DEPRECATED) -template -std::vector encode_msgpack(const Json& j) -{ - std::vector v; - encode_msgpack(j, v); - return v; -} -#endif - -}} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/msgpack/msgpack_detail.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/msgpack/msgpack_detail.hpp deleted file mode 100644 index 75f8ce0702..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/msgpack/msgpack_detail.hpp +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_MSGPACK_MSGPACK_DETAIL_HPP -#define JSONCONS_MSGPACK_MSGPACK_DETAIL_HPP - -#include -#include -#include - -namespace jsoncons { namespace msgpack { namespace detail { - -namespace msgpack_format -{ - const uint8_t positive_fixint_base_cd = 0x00; - const uint8_t nil_cd = 0xc0; - const uint8_t false_cd = 0xc2; - const uint8_t true_cd = 0xc3; - const uint8_t float32_cd = 0xca; - const uint8_t float64_cd = 0xcb; - const uint8_t uint8_cd = 0xcc; - const uint8_t uint16_cd = 0xcd; - const uint8_t uint32_cd = 0xce; - const uint8_t uint64_cd = 0xcf; - const uint8_t int8_cd = 0xd0; - const uint8_t int16_cd = 0xd1; - const uint8_t int32_cd = 0xd2; - const uint8_t int64_cd = 0xd3; - const uint8_t fixmap_base_cd = 0x80; - const uint8_t fixarray_base_cd = 0x90; - const uint8_t fixstr_base_cd = 0xa0; - const uint8_t str8_cd = 0xd9; - const uint8_t str16_cd = 0xda; - const uint8_t str32_cd = 0xdb; - const uint8_t bin8_cd = 0xc7; - const uint8_t bin16_cd = 0xc8; - const uint8_t bin32_cd = 0xc9; - const uint8_t array16_cd = 0xdc; - const uint8_t array32_cd = 0xdd; - const uint8_t map16_cd = 0xde; - const uint8_t map32_cd = 0xdf; - const uint8_t negative_fixint_base_cd = 0xe0; -} - -}}} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/msgpack/msgpack_encoder.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/msgpack/msgpack_encoder.hpp deleted file mode 100644 index 6240156692..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/msgpack/msgpack_encoder.hpp +++ /dev/null @@ -1,459 +0,0 @@ -// Copyright 2018 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_MSGPACK_MSGPACK_ENCODER_HPP -#define JSONCONS_MSGPACK_MSGPACK_ENCODER_HPP - -#include -#include -#include // std::numeric_limits -#include -#include // std::move -#include -#include -#include -#include -#include -#include -#include - -namespace jsoncons { namespace msgpack { - -enum class msgpack_container_type {object, indefinite_length_object, array, indefinite_length_array}; - -template -class basic_msgpack_encoder final : public basic_json_content_handler -{ - enum class decimal_parse_state { start, integer, exp1, exp2, fraction1 }; -public: - typedef char char_type; - using typename basic_json_content_handler::string_view_type; - typedef Result result_type; - -private: - struct stack_item - { - msgpack_container_type type_; - size_t length_; - size_t count_; - - stack_item(msgpack_container_type type, size_t length = 0) - : type_(type), length_(length), count_(0) - { - } - - size_t length() const - { - return length_; - } - - size_t count() const - { - return count_; - } - - bool is_object() const - { - return type_ == msgpack_container_type::object || type_ == msgpack_container_type::indefinite_length_object; - } - - bool is_indefinite_length() const - { - return type_ == msgpack_container_type::indefinite_length_array || type_ == msgpack_container_type::indefinite_length_object; - } - - }; - std::vector stack_; - Result result_; - - // Noncopyable and nonmoveable - basic_msgpack_encoder(const basic_msgpack_encoder&) = delete; - basic_msgpack_encoder& operator=(const basic_msgpack_encoder&) = delete; -public: - explicit basic_msgpack_encoder(result_type result) - : result_(std::move(result)) - { - } - - ~basic_msgpack_encoder() - { - try - { - result_.flush(); - } - catch (...) - { - } - } - -private: - // Implementing methods - - void do_flush() override - { - result_.flush(); - } - - bool do_begin_object(semantic_tag, const ser_context&) override - { - throw ser_error(msgpack_errc::object_length_required); - } - - bool do_begin_object(size_t length, semantic_tag, const ser_context&) override - { - stack_.push_back(stack_item(msgpack_container_type::object, length)); - - if (length <= 15) - { - // fixmap - jsoncons::detail::to_big_endian(static_cast(jsoncons::msgpack::detail::msgpack_format ::fixmap_base_cd | (length & 0xf)), - std::back_inserter(result_)); - } - else if (length <= 65535) - { - // map 16 - jsoncons::detail::to_big_endian(static_cast(jsoncons::msgpack::detail::msgpack_format ::map16_cd), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(length), - std::back_inserter(result_)); - } - else if (length <= 4294967295) - { - // map 32 - jsoncons::detail::to_big_endian(static_cast(jsoncons::msgpack::detail::msgpack_format ::map32_cd), - std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(length), - std::back_inserter(result_)); - } - - return true; - } - - bool do_end_object(const ser_context&) override - { - JSONCONS_ASSERT(!stack_.empty()); - - if (stack_.back().count() < stack_.back().length()) - { - throw ser_error( msgpack_errc::too_few_items); - } - else if (stack_.back().count() > stack_.back().length()) - { - throw ser_error( msgpack_errc::too_many_items); - } - - stack_.pop_back(); - end_value(); - return true; - } - - bool do_begin_array(semantic_tag, const ser_context&) override - { - throw ser_error(msgpack_errc::array_length_required); - } - - bool do_begin_array(size_t length, semantic_tag, const ser_context&) override - { - stack_.push_back(stack_item(msgpack_container_type::array, length)); - if (length <= 15) - { - // fixarray - jsoncons::detail::to_big_endian(static_cast(jsoncons::msgpack::detail::msgpack_format ::fixarray_base_cd | (length & 0xf)), std::back_inserter(result_)); - } - else if (length <= (std::numeric_limits::max)()) - { - // array 16 - jsoncons::detail::to_big_endian(static_cast(jsoncons::msgpack::detail::msgpack_format ::array16_cd), std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(length),std::back_inserter(result_)); - } - else if (length <= (std::numeric_limits::max)()) - { - // array 32 - jsoncons::detail::to_big_endian(static_cast(jsoncons::msgpack::detail::msgpack_format ::array32_cd), std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(length),std::back_inserter(result_)); - } - return true; - } - - bool do_end_array(const ser_context&) override - { - JSONCONS_ASSERT(!stack_.empty()); - - if (stack_.back().count() < stack_.back().length()) - { - throw ser_error(msgpack_errc::too_few_items); - } - else if (stack_.back().count() > stack_.back().length()) - { - throw ser_error(msgpack_errc::too_many_items); - } - - stack_.pop_back(); - end_value(); - return true; - } - - bool do_name(const string_view_type& name, const ser_context&) override - { - write_string_value(name); - return true; - } - - bool do_null_value(semantic_tag, const ser_context&) override - { - // nil - jsoncons::detail::to_big_endian(static_cast(jsoncons::msgpack::detail::msgpack_format ::nil_cd), std::back_inserter(result_)); - end_value(); - return true; - } - - bool do_string_value(const string_view_type& sv, semantic_tag, const ser_context&) override - { - write_string_value(sv); - end_value(); - return true; - } - - void write_string_value(const string_view_type& sv) - { - auto result = unicons::validate(sv.begin(), sv.end()); - if (result.ec != unicons::conv_errc()) - { - throw ser_error(msgpack_errc::invalid_utf8_text_string); - } - - const size_t length = sv.length(); - if (length <= 31) - { - // fixstr stores a byte array whose length is upto 31 bytes - jsoncons::detail::to_big_endian(static_cast(jsoncons::msgpack::detail::msgpack_format ::fixstr_base_cd | length), std::back_inserter(result_)); - } - else if (length <= (std::numeric_limits::max)()) - { - // str 8 stores a byte array whose length is upto (2^8)-1 bytes - jsoncons::detail::to_big_endian(static_cast(jsoncons::msgpack::detail::msgpack_format ::str8_cd), std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(length), std::back_inserter(result_)); - } - else if (length <= (std::numeric_limits::max)()) - { - // str 16 stores a byte array whose length is upto (2^16)-1 bytes - jsoncons::detail::to_big_endian(static_cast(jsoncons::msgpack::detail::msgpack_format ::str16_cd), std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(length), std::back_inserter(result_)); - } - else if (length <= (std::numeric_limits::max)()) - { - // str 32 stores a byte array whose length is upto (2^32)-1 bytes - jsoncons::detail::to_big_endian(static_cast(jsoncons::msgpack::detail::msgpack_format ::str32_cd), std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(length),std::back_inserter(result_)); - } - - for (auto c : sv) - { - result_.push_back(c); - } - } - - bool do_byte_string_value(const byte_string_view& b, - semantic_tag, - const ser_context&) override - { - - const size_t length = b.length(); - if (length <= (std::numeric_limits::max)()) - { - // str 8 stores a byte array whose length is upto (2^8)-1 bytes - jsoncons::detail::to_big_endian(static_cast(jsoncons::msgpack::detail::msgpack_format ::bin8_cd), std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(length), std::back_inserter(result_)); - } - else if (length <= (std::numeric_limits::max)()) - { - // str 16 stores a byte array whose length is upto (2^16)-1 bytes - jsoncons::detail::to_big_endian(static_cast(jsoncons::msgpack::detail::msgpack_format ::bin16_cd), std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(length), std::back_inserter(result_)); - } - else if (length <= (std::numeric_limits::max)()) - { - // str 32 stores a byte array whose length is upto (2^32)-1 bytes - jsoncons::detail::to_big_endian(static_cast(jsoncons::msgpack::detail::msgpack_format ::bin32_cd), std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(length),std::back_inserter(result_)); - } - - for (auto c : b) - { - result_.push_back(c); - } - - end_value(); - return true; - } - - bool do_double_value(double val, - semantic_tag, - const ser_context&) override - { - float valf = (float)val; - if ((double)valf == val) - { - // float 32 - jsoncons::detail::to_big_endian(static_cast(jsoncons::msgpack::detail::msgpack_format ::float32_cd), std::back_inserter(result_)); - jsoncons::detail::to_big_endian(valf,std::back_inserter(result_)); - } - else - { - // float 64 - jsoncons::detail::to_big_endian(static_cast(jsoncons::msgpack::detail::msgpack_format ::float64_cd), std::back_inserter(result_)); - jsoncons::detail::to_big_endian(val,std::back_inserter(result_)); - } - - // write double - - end_value(); - return true; - } - - bool do_int64_value(int64_t val, - semantic_tag, - const ser_context&) override - { - if (val >= 0) - { - if (val <= 0x7f) - { - // positive fixnum stores 7-bit positive integer - jsoncons::detail::to_big_endian(static_cast(val),std::back_inserter(result_)); - } - else if (val <= (std::numeric_limits::max)()) - { - // uint 8 stores a 8-bit unsigned integer - jsoncons::detail::to_big_endian(static_cast(jsoncons::msgpack::detail::msgpack_format ::uint8_cd), std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(val),std::back_inserter(result_)); - } - else if (val <= (std::numeric_limits::max)()) - { - // uint 16 stores a 16-bit big-endian unsigned integer - jsoncons::detail::to_big_endian(static_cast(jsoncons::msgpack::detail::msgpack_format ::uint16_cd), std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(val),std::back_inserter(result_)); - } - else if (val <= (std::numeric_limits::max)()) - { - // uint 32 stores a 32-bit big-endian unsigned integer - jsoncons::detail::to_big_endian(static_cast(jsoncons::msgpack::detail::msgpack_format ::uint32_cd), std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(val),std::back_inserter(result_)); - } - else if (val <= (std::numeric_limits::max)()) - { - // int 64 stores a 64-bit big-endian signed integer - jsoncons::detail::to_big_endian(static_cast(jsoncons::msgpack::detail::msgpack_format ::uint64_cd), std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(val),std::back_inserter(result_)); - } - } - else - { - if (val >= -32) - { - // negative fixnum stores 5-bit negative integer - jsoncons::detail::to_big_endian(static_cast(val), std::back_inserter(result_)); - } - else if (val >= (std::numeric_limits::lowest)()) - { - // int 8 stores a 8-bit signed integer - jsoncons::detail::to_big_endian(static_cast(jsoncons::msgpack::detail::msgpack_format ::int8_cd), std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(val),std::back_inserter(result_)); - } - else if (val >= (std::numeric_limits::lowest)()) - { - // int 16 stores a 16-bit big-endian signed integer - jsoncons::detail::to_big_endian(static_cast(jsoncons::msgpack::detail::msgpack_format ::int16_cd), std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(val),std::back_inserter(result_)); - } - else if (val >= (std::numeric_limits::lowest)()) - { - // int 32 stores a 32-bit big-endian signed integer - jsoncons::detail::to_big_endian(static_cast(jsoncons::msgpack::detail::msgpack_format ::int32_cd), std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(val),std::back_inserter(result_)); - } - else if (val >= (std::numeric_limits::lowest)()) - { - // int 64 stores a 64-bit big-endian signed integer - jsoncons::detail::to_big_endian(static_cast(jsoncons::msgpack::detail::msgpack_format ::int64_cd), std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(val),std::back_inserter(result_)); - } - } - end_value(); - return true; - } - - bool do_uint64_value(uint64_t val, - semantic_tag, - const ser_context&) override - { - if (val <= (std::numeric_limits::max)()) - { - // positive fixnum stores 7-bit positive integer - jsoncons::detail::to_big_endian(static_cast(val), std::back_inserter(result_)); - } - else if (val <= (std::numeric_limits::max)()) - { - // uint 8 stores a 8-bit unsigned integer - jsoncons::detail::to_big_endian(static_cast(jsoncons::msgpack::detail::msgpack_format ::uint8_cd), std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(val), std::back_inserter(result_)); - } - else if (val <= (std::numeric_limits::max)()) - { - // uint 16 stores a 16-bit big-endian unsigned integer - jsoncons::detail::to_big_endian(static_cast(jsoncons::msgpack::detail::msgpack_format ::uint16_cd), std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(val),std::back_inserter(result_)); - } - else if (val <= (std::numeric_limits::max)()) - { - // uint 32 stores a 32-bit big-endian unsigned integer - jsoncons::detail::to_big_endian(static_cast(jsoncons::msgpack::detail::msgpack_format ::uint32_cd), std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(val),std::back_inserter(result_)); - } - else if (val <= (std::numeric_limits::max)()) - { - // uint 64 stores a 64-bit big-endian unsigned integer - jsoncons::detail::to_big_endian(static_cast(jsoncons::msgpack::detail::msgpack_format ::uint64_cd), std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(val),std::back_inserter(result_)); - } - end_value(); - return true; - } - - bool do_bool_value(bool val, semantic_tag, const ser_context&) override - { - // true and false - result_.push_back(static_cast(val ? jsoncons::msgpack::detail::msgpack_format ::true_cd : jsoncons::msgpack::detail::msgpack_format ::false_cd)); - //jsoncons::detail::to_big_endian(static_cast(val ? jsoncons::msgpack::detail::msgpack_format ::true_cd : jsoncons::msgpack::detail::msgpack_format ::false_cd), std::back_inserter(result_)); - - end_value(); - return true; - } - - void end_value() - { - if (!stack_.empty()) - { - ++stack_.back().count_; - } - } -}; - -typedef basic_msgpack_encoder msgpack_encoder; -typedef basic_msgpack_encoder msgpack_bytes_encoder; - -#if !defined(JSONCONS_NO_DEPRECATED) -typedef basic_msgpack_encoder msgpack_bytes_serializer; - -template -using basic_msgpack_serializer = basic_msgpack_encoder; - -typedef basic_msgpack_serializer msgpack_serializer; -typedef basic_msgpack_serializer msgpack_buffer_serializer; -#endif - -}} -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/msgpack/msgpack_error.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/msgpack/msgpack_error.hpp deleted file mode 100644 index 3b2d1d7b05..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/msgpack/msgpack_error.hpp +++ /dev/null @@ -1,82 +0,0 @@ -/// Copyright 2018 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_MSGPACK_MSGPACK_ERROR_HPP -#define JSONCONS_MSGPACK_MSGPACK_ERROR_HPP - -#include -#include - -namespace jsoncons { namespace msgpack { - -enum class msgpack_errc -{ - ok = 0, - unexpected_eof = 1, - source_error, - invalid_utf8_text_string, - array_length_required, - object_length_required, - too_many_items, - too_few_items -}; - -class msgpack_error_category_impl - : public std::error_category -{ -public: - const char* name() const noexcept override - { - return "jsoncons/msgpack"; - } - std::string message(int ev) const override - { - switch (static_cast(ev)) - { - case msgpack_errc::unexpected_eof: - return "Unexpected end of file"; - case msgpack_errc::source_error: - return "Source error"; - case msgpack_errc::invalid_utf8_text_string: - return "Illegal UTF-8 encoding in text string"; - case msgpack_errc::array_length_required: - return "MessagePack encoder requires array length"; - case msgpack_errc::object_length_required: - return "MessagePack encoder requires object length"; - case msgpack_errc::too_many_items: - return "Too many items were added to a MessagePack object or array"; - case msgpack_errc::too_few_items: - return "Too few items were added to a MessagePack object or array"; - default: - return "Unknown MessagePack parser error"; - } - } -}; - -inline -const std::error_category& msgpack_error_category() -{ - static msgpack_error_category_impl instance; - return instance; -} - -inline -std::error_code make_error_code(msgpack_errc e) -{ - return std::error_code(static_cast(e),msgpack_error_category()); -} - - -}} - -namespace std { - template<> - struct is_error_code_enum : public true_type - { - }; -} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/msgpack/msgpack_reader.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/msgpack/msgpack_reader.hpp deleted file mode 100644 index 8970675855..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/msgpack/msgpack_reader.hpp +++ /dev/null @@ -1,757 +0,0 @@ -// Copyright 2017 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_MSGPACK_MSGPACK_READER_HPP -#define JSONCONS_MSGPACK_MSGPACK_READER_HPP - -#include -#include -#include -#include // std::move -#include -#include -#include -#include -#include -#include - -namespace jsoncons { namespace msgpack { - -template -class basic_msgpack_reader : public ser_context -{ - Src source_; - json_content_handler& handler_; - size_t nesting_depth_; - std::string buffer_; -public: - template - basic_msgpack_reader(Source&& source, json_content_handler& handler) - : source_(std::forward(source)), - handler_(handler), - nesting_depth_(0) - { - } - - void read() - { - std::error_code ec; - read(ec); - if (ec) - { - throw ser_error(ec,line(),column()); - } - } - - void read(std::error_code& ec) - { - try - { - read_internal(ec); - } - catch (const ser_error& e) - { - ec = e.code(); - } - } - - size_t line() const override - { - return 0; - } - - size_t column() const override - { - return source_.position(); - } -private: - - void read_internal(std::error_code& ec) - { - if (source_.is_error()) - { - ec = msgpack_errc::source_error; - return; - } - //const uint8_t* pos = input_ptr_++; - - uint8_t type{}; - source_.get(type); - - if (type <= 0xbf) - { - if (type <= 0x7f) - { - // positive fixint - handler_.uint64_value(type, semantic_tag::none, *this); - } - else if (type <= 0x8f) - { - // fixmap - const size_t len = type & 0x0f; - handler_.begin_object(len, semantic_tag::none, *this); - ++nesting_depth_; - for (size_t i = 0; i < len; ++i) - { - parse_name(ec); - if (ec) - { - return; - } - read(ec); - if (ec) - { - return; - } - } - handler_.end_object(*this); - --nesting_depth_; - } - else if (type <= 0x9f) - { - // fixarray - const size_t len = type & 0x0f; - handler_.begin_array(len, semantic_tag::none, *this); - ++nesting_depth_; - for (size_t i = 0; i < len; ++i) - { - read(ec); - if (ec) - { - return; - } - } - handler_.end_array(*this); - --nesting_depth_; - } - else - { - // fixstr - const size_t len = type & 0x1f; - - std::basic_string s; - source_.read(std::back_inserter(s), len); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - - auto result = unicons::validate(s.begin(),s.end()); - if (result.ec != unicons::conv_errc()) - { - ec = msgpack_errc::invalid_utf8_text_string; - return; - } - handler_.string_value(basic_string_view(s.data(),s.length()), semantic_tag::none, *this); - } - } - else if (type >= 0xe0) - { - // negative fixint - handler_.int64_value(static_cast(type), semantic_tag::none, *this); - } - else - { - switch (type) - { - case jsoncons::msgpack::detail::msgpack_format ::nil_cd: - { - handler_.null_value(semantic_tag::none, *this); - break; - } - case jsoncons::msgpack::detail::msgpack_format ::true_cd: - { - handler_.bool_value(true, semantic_tag::none, *this); - break; - } - case jsoncons::msgpack::detail::msgpack_format ::false_cd: - { - handler_.bool_value(false, semantic_tag::none, *this); - break; - } - case jsoncons::msgpack::detail::msgpack_format ::float32_cd: - { - uint8_t buf[sizeof(float)]; - source_.read(buf, sizeof(float)); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - const uint8_t* endp; - float val = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - handler_.double_value(val, semantic_tag::none, *this); - break; - } - - case jsoncons::msgpack::detail::msgpack_format ::float64_cd: - { - uint8_t buf[sizeof(double)]; - source_.read(buf, sizeof(double)); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - const uint8_t* endp; - double val = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - handler_.double_value(val, semantic_tag::none, *this); - break; - } - - case jsoncons::msgpack::detail::msgpack_format ::uint8_cd: - { - uint8_t val{}; - source_.get(val); - handler_.uint64_value(val, semantic_tag::none, *this); - break; - } - - case jsoncons::msgpack::detail::msgpack_format ::uint16_cd: - { - uint8_t buf[sizeof(uint16_t)]; - source_.read(buf, sizeof(uint16_t)); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - const uint8_t* endp; - uint16_t val = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - handler_.uint64_value(val, semantic_tag::none, *this); - break; - } - - case jsoncons::msgpack::detail::msgpack_format ::uint32_cd: - { - uint8_t buf[sizeof(uint32_t)]; - source_.read(buf, sizeof(uint32_t)); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - const uint8_t* endp; - uint32_t val = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - handler_.uint64_value(val, semantic_tag::none, *this); - break; - } - - case jsoncons::msgpack::detail::msgpack_format ::uint64_cd: - { - uint8_t buf[sizeof(uint64_t)]; - source_.read(buf, sizeof(uint64_t)); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - const uint8_t* endp; - uint64_t val = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - handler_.uint64_value(val, semantic_tag::none, *this); - break; - } - - case jsoncons::msgpack::detail::msgpack_format ::int8_cd: - { - uint8_t buf[sizeof(int8_t)]; - source_.read(buf, sizeof(int8_t)); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - const uint8_t* endp; - int8_t val = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - handler_.int64_value(val, semantic_tag::none, *this); - break; - } - - case jsoncons::msgpack::detail::msgpack_format ::int16_cd: - { - uint8_t buf[sizeof(int16_t)]; - source_.read(buf, sizeof(int16_t)); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - const uint8_t* endp; - int16_t val = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - handler_.int64_value(val, semantic_tag::none, *this); - break; - } - - case jsoncons::msgpack::detail::msgpack_format ::int32_cd: - { - uint8_t buf[sizeof(int32_t)]; - source_.read(buf, sizeof(int32_t)); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - const uint8_t* endp; - int32_t val = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - handler_.int64_value(val, semantic_tag::none, *this); - break; - } - - case jsoncons::msgpack::detail::msgpack_format ::int64_cd: - { - uint8_t buf[sizeof(int64_t)]; - source_.read(buf, sizeof(int64_t)); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - const uint8_t* endp; - int64_t val = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - handler_.int64_value(val, semantic_tag::none, *this); - break; - } - - case jsoncons::msgpack::detail::msgpack_format ::str8_cd: - { - uint8_t buf[sizeof(int8_t)]; - source_.read(buf, sizeof(int8_t)); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - const uint8_t* endp; - int8_t len = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - - std::basic_string s; - source_.read(std::back_inserter(s), len); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - auto result = unicons::validate(s.begin(),s.end()); - if (result.ec != unicons::conv_errc()) - { - ec = msgpack_errc::invalid_utf8_text_string; - return; - } - handler_.string_value(basic_string_view(s.data(),s.length()), semantic_tag::none, *this); - break; - } - - case jsoncons::msgpack::detail::msgpack_format ::str16_cd: - { - uint8_t buf[sizeof(int16_t)]; - source_.read(buf, sizeof(int16_t)); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - const uint8_t* endp; - int16_t len = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - - std::basic_string s; - source_.read(std::back_inserter(s), len); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - - auto result = unicons::validate(s.begin(),s.end()); - if (result.ec != unicons::conv_errc()) - { - ec = msgpack_errc::invalid_utf8_text_string; - return; - } - handler_.string_value(basic_string_view(s.data(),s.length()), semantic_tag::none, *this); - break; - } - - case jsoncons::msgpack::detail::msgpack_format ::str32_cd: - { - uint8_t buf[sizeof(int32_t)]; - source_.read(buf, sizeof(int32_t)); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - const uint8_t* endp; - int32_t len = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - - std::basic_string s; - source_.read(std::back_inserter(s), len); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - - auto result = unicons::validate(s.begin(),s.end()); - if (result.ec != unicons::conv_errc()) - { - ec = msgpack_errc::invalid_utf8_text_string; - return; - } - handler_.string_value(basic_string_view(s.data(),s.length()), semantic_tag::none, *this); - break; - } - - case jsoncons::msgpack::detail::msgpack_format ::bin8_cd: - { - uint8_t buf[sizeof(int8_t)]; - source_.read(buf, sizeof(int8_t)); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - const uint8_t* endp; - int8_t len = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - - std::vector v; - v.reserve(len); - source_.read(std::back_inserter(v), len); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - - handler_.byte_string_value(byte_string_view(v.data(),v.size()), - semantic_tag::none, - *this); - break; - } - - case jsoncons::msgpack::detail::msgpack_format ::bin16_cd: - { - uint8_t buf[sizeof(int16_t)]; - source_.read(buf, sizeof(int16_t)); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - const uint8_t* endp; - int16_t len = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - - std::vector v; - v.reserve(len); - source_.read(std::back_inserter(v), len); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - - handler_.byte_string_value(byte_string_view(v.data(),v.size()), - semantic_tag::none, - *this); - break; - } - - case jsoncons::msgpack::detail::msgpack_format ::bin32_cd: - { - uint8_t buf[sizeof(int32_t)]; - source_.read(buf, sizeof(int32_t)); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - const uint8_t* endp; - int32_t len = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - - std::vector v; - v.reserve(len); - source_.read(std::back_inserter(v), len); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - - handler_.byte_string_value(byte_string_view(v.data(),v.size()), - semantic_tag::none, - *this); - break; - } - - case jsoncons::msgpack::detail::msgpack_format ::array16_cd: - { - uint8_t buf[sizeof(int16_t)]; - source_.read(buf, sizeof(int16_t)); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - const uint8_t* endp; - int16_t len = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - - handler_.begin_array(len, semantic_tag::none, *this); - ++nesting_depth_; - for (int16_t i = 0; i < len; ++i) - { - read(ec); - if (ec) - { - return; - } - } - handler_.end_array(*this); - --nesting_depth_; - break; - } - - case jsoncons::msgpack::detail::msgpack_format ::array32_cd: - { - uint8_t buf[sizeof(int32_t)]; - source_.read(buf, sizeof(int32_t)); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - const uint8_t* endp; - int32_t len = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - - handler_.begin_array(len, semantic_tag::none, *this); - ++nesting_depth_; - for (int32_t i = 0; i < len; ++i) - { - read(ec); - if (ec) - { - return; - } - } - handler_.end_array(*this); - --nesting_depth_; - break; - } - - case jsoncons::msgpack::detail::msgpack_format ::map16_cd : - { - uint8_t buf[sizeof(int16_t)]; - source_.read(buf, sizeof(int16_t)); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - const uint8_t* endp; - int16_t len = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - - handler_.begin_object(len, semantic_tag::none, *this); - ++nesting_depth_; - for (int16_t i = 0; i < len; ++i) - { - parse_name(ec); - if (ec) - { - return; - } - read(ec); - if (ec) - { - return; - } - } - handler_.end_object(*this); - --nesting_depth_; - break; - } - - case jsoncons::msgpack::detail::msgpack_format ::map32_cd : - { - uint8_t buf[sizeof(int32_t)]; - source_.read(buf, sizeof(int32_t)); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - const uint8_t* endp; - int32_t len = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - - handler_.begin_object(len, semantic_tag::none, *this); - ++nesting_depth_; - for (int32_t i = 0; i < len; ++i) - { - parse_name(ec); - if (ec) - { - return; - } - read(ec); - if (ec) - { - return; - } - } - handler_.end_object(*this); - --nesting_depth_; - break; - } - - default: - { - //error - } - } - } - } - - void parse_name(std::error_code& ec) - { - uint8_t type{}; - source_.get(type); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - - //const uint8_t* pos = input_ptr_++; - if (type >= 0xa0 && type <= 0xbf) - { - // fixstr - const size_t len = type & 0x1f; - - std::basic_string s; - source_.read(std::back_inserter(s), len); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - auto result = unicons::validate(s.begin(),s.end()); - if (result.ec != unicons::conv_errc()) - { - ec = msgpack_errc::invalid_utf8_text_string; - return; - } - handler_.name(basic_string_view(s.data(),s.length()), *this); - } - else - { - switch (type) - { - case jsoncons::msgpack::detail::msgpack_format ::str8_cd: - { - uint8_t buf[sizeof(int8_t)]; - source_.read(buf, sizeof(int8_t)); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - const uint8_t* endp; - int8_t len = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - - std::basic_string s; - source_.read(std::back_inserter(s), len); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - - auto result = unicons::validate(s.begin(),s.end()); - if (result.ec != unicons::conv_errc()) - { - ec = msgpack_errc::invalid_utf8_text_string; - return; - } - handler_.name(basic_string_view(s.data(),s.length()), *this); - break; - } - - case jsoncons::msgpack::detail::msgpack_format ::str16_cd: - { - uint8_t buf[sizeof(int16_t)]; - source_.read(buf, sizeof(int16_t)); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - const uint8_t* endp; - int16_t len = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - - std::basic_string s; - source_.read(std::back_inserter(s), len); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - - //std::basic_string s; - //auto result = unicons::convert( - // first, last,std::back_inserter(s),unicons::conv_flags::strict); - //if (result.ec != unicons::conv_errc()) - //{ - // JSONCONS_THROW(json_runtime_error("Illegal unicode")); - //} - handler_.name(basic_string_view(s.data(),s.length()), *this); - break; - } - - case jsoncons::msgpack::detail::msgpack_format ::str32_cd: - { - uint8_t buf[sizeof(int32_t)]; - source_.read(buf, sizeof(int32_t)); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - const uint8_t* endp; - int32_t len = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - - std::basic_string s; - source_.read(std::back_inserter(s), len); - if (source_.eof()) - { - ec = msgpack_errc::unexpected_eof; - return; - } - - //std::basic_string s; - //auto result = unicons::convert( - // first, last,std::back_inserter(s),unicons::conv_flags::strict); - //if (result.ec != unicons::conv_errc()) - //{ - // JSONCONS_THROW(json_runtime_error("Illegal unicode")); - //} - handler_.name(basic_string_view(s.data(),s.length()), *this); - break; - } - } - - } - } -}; - -typedef basic_msgpack_reader msgpack_reader; - -typedef basic_msgpack_reader msgpack_bytes_reader; - -#if !defined(JSONCONS_NO_DEPRECATED) -typedef msgpack_bytes_reader msgpack_buffer_reader; -#endif - -}} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/ubjson/ubjson.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/ubjson/ubjson.hpp deleted file mode 100644 index d30c562c41..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/ubjson/ubjson.hpp +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_UBJSON_UBJSON_HPP -#define JSONCONS_UBJSON_UBJSON_HPP - -#include -#include -#include -#include // std::enable_if -#include // std::basic_istream -#include -#include -#include -#include - -namespace jsoncons { namespace ubjson { - -// encode_ubjson - -template -typename std::enable_if::value,void>::type -encode_ubjson(const T& j, std::vector& v) -{ - typedef typename T::char_type char_type; - ubjson_bytes_encoder encoder(v); - auto adaptor = make_json_content_handler_adaptor>(encoder); - j.dump(adaptor); -} - -template -typename std::enable_if::value,void>::type -encode_ubjson(const T& val, std::vector& v) -{ - ubjson_bytes_encoder encoder(v); - write_to(json(), val, encoder); -} - -template -typename std::enable_if::value,void>::type -encode_ubjson(const T& j, std::ostream& os) -{ - typedef typename T::char_type char_type; - ubjson_encoder encoder(os); - auto adaptor = make_json_content_handler_adaptor>(encoder); - j.dump(adaptor); -} - -template -typename std::enable_if::value,void>::type -encode_ubjson(const T& val, std::ostream& os) -{ - ubjson_encoder encoder(os); - write_to(json(), val, encoder); -} - -// decode_ubjson - -template -typename std::enable_if::value,T>::type -decode_ubjson(const std::vector& v) -{ - jsoncons::json_decoder decoder; - auto adaptor = make_json_content_handler_adaptor(decoder); - basic_ubjson_reader reader(v, adaptor); - reader.read(); - return decoder.get_result(); -} - -template -typename std::enable_if::value,T>::type -decode_ubjson(const std::vector& v) -{ - jsoncons::json_decoder decoder; - basic_ubjson_reader reader(v, decoder); - reader.read(); - return decoder.get_result().template as(); -} - -template -typename std::enable_if::value,T>::type -decode_ubjson(std::istream& is) -{ - jsoncons::json_decoder decoder; - auto adaptor = make_json_content_handler_adaptor(decoder); - ubjson_reader reader(is, adaptor); - reader.read(); - return decoder.get_result(); -} - -template -typename std::enable_if::value,T>::type -decode_ubjson(std::istream& is) -{ - jsoncons::json_decoder decoder; - ubjson_reader reader(is, decoder); - reader.read(); - return decoder.get_result(); -} - -}} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/ubjson/ubjson_detail.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/ubjson/ubjson_detail.hpp deleted file mode 100644 index 99f2bf922c..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/ubjson/ubjson_detail.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2013 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_UBJSON_UBJSON_DETAIL_HPP -#define JSONCONS_UBJSON_UBJSON_DETAIL_HPP - -#include -#include -#include - -namespace jsoncons { namespace ubjson { namespace detail { - -namespace ubjson_format -{ - const uint8_t null_type = 'Z'; - const uint8_t no_op_type = 'N'; - const uint8_t true_type = 'T'; - const uint8_t false_type = 'F'; - const uint8_t int8_type = 'i'; - const uint8_t uint8_type = 'U'; - const uint8_t int16_type = 'I'; - const uint8_t int32_type = 'l'; - const uint8_t int64_type = 'L'; - const uint8_t float32_type = 'd'; - const uint8_t float64_type = 'D'; - const uint8_t high_precision_number_type = 'H'; - const uint8_t char_type = 'C'; - const uint8_t string_type = 'S'; - const uint8_t start_array_marker = '['; - const uint8_t end_array_marker = ']'; - const uint8_t start_object_marker = '{'; - const uint8_t end_object_marker = '}'; - const uint8_t type_marker = '$'; - const uint8_t count_marker = '#'; -} - -}}} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/ubjson/ubjson_encoder.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/ubjson/ubjson_encoder.hpp deleted file mode 100644 index 10085420c8..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/ubjson/ubjson_encoder.hpp +++ /dev/null @@ -1,433 +0,0 @@ -// Copyright 2018 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_UBJSON_UBJSON_ENCODER_HPP -#define JSONCONS_UBJSON_UBJSON_ENCODER_HPP - -#include -#include -#include // std::numeric_limits -#include -#include // std::move -#include -#include -#include -#include -#include -#include -#include - -namespace jsoncons { namespace ubjson { - -enum class ubjson_container_type {object, indefinite_length_object, array, indefinite_length_array}; - -template -class basic_ubjson_encoder final : public basic_json_content_handler -{ - - enum class decimal_parse_state { start, integer, exp1, exp2, fraction1 }; -public: - using typename basic_json_content_handler::string_view_type; - typedef Result result_type; - -private: - struct stack_item - { - ubjson_container_type type_; - size_t length_; - size_t count_; - - stack_item(ubjson_container_type type, size_t length = 0) - : type_(type), length_(length), count_(0) - { - } - - size_t length() const - { - return length_; - } - - size_t count() const - { - return count_; - } - - bool is_object() const - { - return type_ == ubjson_container_type::object || type_ == ubjson_container_type::indefinite_length_object; - } - - bool is_indefinite_length() const - { - return type_ == ubjson_container_type::indefinite_length_array || type_ == ubjson_container_type::indefinite_length_object; - } - - }; - std::vector stack_; - Result result_; - - // Noncopyable and nonmoveable - basic_ubjson_encoder(const basic_ubjson_encoder&) = delete; - basic_ubjson_encoder& operator=(const basic_ubjson_encoder&) = delete; -public: - basic_ubjson_encoder(result_type result) - : result_(std::move(result)) - { - } - - ~basic_ubjson_encoder() - { - try - { - result_.flush(); - } - catch (...) - { - } - } - -private: - // Implementing methods - - void do_flush() override - { - result_.flush(); - } - - bool do_begin_object(semantic_tag, const ser_context&) override - { - stack_.push_back(stack_item(ubjson_container_type::indefinite_length_object)); - result_.push_back(jsoncons::ubjson::detail::ubjson_format::start_object_marker); - - return true; - } - - bool do_begin_object(size_t length, semantic_tag, const ser_context&) override - { - stack_.push_back(stack_item(ubjson_container_type::object, length)); - result_.push_back(jsoncons::ubjson::detail::ubjson_format::start_object_marker); - result_.push_back(jsoncons::ubjson::detail::ubjson_format::count_marker); - put_length(length); - - return true; - } - - bool do_end_object(const ser_context&) override - { - JSONCONS_ASSERT(!stack_.empty()); - if (stack_.back().is_indefinite_length()) - { - result_.push_back(jsoncons::ubjson::detail::ubjson_format::end_object_marker); - } - else - { - if (stack_.back().count() < stack_.back().length()) - { - throw ser_error(ubjson_errc::too_few_items); - } - if (stack_.back().count() > stack_.back().length()) - { - throw ser_error(ubjson_errc::too_many_items); - } - } - stack_.pop_back(); - end_value(); - return true; - } - - bool do_begin_array(semantic_tag, const ser_context&) override - { - stack_.push_back(stack_item(ubjson_container_type::indefinite_length_array)); - result_.push_back(jsoncons::ubjson::detail::ubjson_format::start_array_marker); - - return true; - } - - bool do_begin_array(size_t length, semantic_tag, const ser_context&) override - { - stack_.push_back(stack_item(ubjson_container_type::array, length)); - result_.push_back(jsoncons::ubjson::detail::ubjson_format::start_array_marker); - result_.push_back(jsoncons::ubjson::detail::ubjson_format::count_marker); - put_length(length); - - return true; - } - - bool do_end_array(const ser_context&) override - { - JSONCONS_ASSERT(!stack_.empty()); - if (stack_.back().is_indefinite_length()) - { - result_.push_back(jsoncons::ubjson::detail::ubjson_format::end_array_marker); - } - else - { - if (stack_.back().count() < stack_.back().length()) - { - throw ser_error(ubjson_errc::too_few_items); - } - if (stack_.back().count() > stack_.back().length()) - { - throw ser_error(ubjson_errc::too_many_items); - } - } - stack_.pop_back(); - end_value(); - return true; - } - - bool do_name(const string_view_type& name, const ser_context&) override - { - auto result = unicons::validate(name.begin(), name.end()); - if (result.ec != unicons::conv_errc()) - { - throw ser_error(ubjson_errc::invalid_utf8_text_string); - } - - put_length(name.length()); - - for (auto c : name) - { - result_.push_back(c); - } - return true; - } - - bool do_null_value(semantic_tag, const ser_context&) override - { - // nil - jsoncons::detail::to_big_endian(static_cast(jsoncons::ubjson::detail::ubjson_format::null_type), std::back_inserter(result_)); - end_value(); - return true; - } - - bool do_string_value(const string_view_type& sv, semantic_tag tag, const ser_context&) override - { - switch (tag) - { - case semantic_tag::bigint: - case semantic_tag::bigdec: - { - result_.push_back(jsoncons::ubjson::detail::ubjson_format::high_precision_number_type); - break; - } - default: - { - result_.push_back(jsoncons::ubjson::detail::ubjson_format::string_type); - break; - } - } - - auto result = unicons::validate(sv.begin(), sv.end()); - if (result.ec != unicons::conv_errc()) - { - JSONCONS_THROW(json_runtime_error("Illegal unicode")); - } - - put_length(sv.length()); - - for (auto c : sv) - { - result_.push_back(c); - } - - end_value(); - return true; - } - - void put_length(size_t length) - { - if (length <= (std::numeric_limits::max)()) - { - result_.push_back('U'); - jsoncons::detail::to_big_endian(static_cast(length), std::back_inserter(result_)); - } - else if (length <= (size_t)(std::numeric_limits::max)()) - { - result_.push_back('I'); - jsoncons::detail::to_big_endian(static_cast(length), std::back_inserter(result_)); - } - else if (length <= (uint32_t)(std::numeric_limits::max)()) - { - result_.push_back('l'); - jsoncons::detail::to_big_endian(static_cast(length),std::back_inserter(result_)); - } - else if (length <= (uint64_t)(std::numeric_limits::max)()) - { - result_.push_back('L'); - jsoncons::detail::to_big_endian(static_cast(length),std::back_inserter(result_)); - } - } - - bool do_byte_string_value(const byte_string_view& b, - semantic_tag, - const ser_context&) override - { - - const size_t length = b.length(); - result_.push_back(jsoncons::ubjson::detail::ubjson_format::start_array_marker); - jsoncons::detail::to_big_endian(static_cast(jsoncons::ubjson::detail::ubjson_format::type_marker), std::back_inserter(result_)); - jsoncons::detail::to_big_endian(static_cast(jsoncons::ubjson::detail::ubjson_format::uint8_type), std::back_inserter(result_)); - put_length(length); - - for (auto c : b) - { - result_.push_back(c); - } - - end_value(); - return true; - } - - bool do_double_value(double val, - semantic_tag, - const ser_context&) override - { - float valf = (float)val; - if ((double)valf == val) - { - // float 32 - result_.push_back(static_cast(jsoncons::ubjson::detail::ubjson_format::float32_type)); - jsoncons::detail::to_big_endian(valf,std::back_inserter(result_)); - } - else - { - // float 64 - result_.push_back(static_cast(jsoncons::ubjson::detail::ubjson_format::float64_type)); - jsoncons::detail::to_big_endian(val,std::back_inserter(result_)); - } - - // write double - - end_value(); - return true; - } - - bool do_int64_value(int64_t val, - semantic_tag, - const ser_context&) override - { - if (val >= 0) - { - if (val <= (std::numeric_limits::max)()) - { - // uint 8 stores a 8-bit unsigned integer - result_.push_back(jsoncons::ubjson::detail::ubjson_format::uint8_type); - jsoncons::detail::to_big_endian(static_cast(val),std::back_inserter(result_)); - } - else if (val <= (std::numeric_limits::max)()) - { - // uint 16 stores a 16-bit big-endian unsigned integer - result_.push_back(jsoncons::ubjson::detail::ubjson_format::int16_type); - jsoncons::detail::to_big_endian(static_cast(val),std::back_inserter(result_)); - } - else if (val <= (std::numeric_limits::max)()) - { - // uint 32 stores a 32-bit big-endian unsigned integer - result_.push_back(jsoncons::ubjson::detail::ubjson_format::int32_type); - jsoncons::detail::to_big_endian(static_cast(val),std::back_inserter(result_)); - } - else if (val <= (std::numeric_limits::max)()) - { - // int 64 stores a 64-bit big-endian signed integer - result_.push_back(jsoncons::ubjson::detail::ubjson_format::int64_type); - jsoncons::detail::to_big_endian(static_cast(val),std::back_inserter(result_)); - } - else - { - // big integer - } - } - else - { - if (val >= (std::numeric_limits::lowest)()) - { - // int 8 stores a 8-bit signed integer - result_.push_back(jsoncons::ubjson::detail::ubjson_format::int8_type); - jsoncons::detail::to_big_endian(static_cast(val),std::back_inserter(result_)); - } - else if (val >= (std::numeric_limits::lowest)()) - { - // int 16 stores a 16-bit big-endian signed integer - result_.push_back(jsoncons::ubjson::detail::ubjson_format::int16_type); - jsoncons::detail::to_big_endian(static_cast(val),std::back_inserter(result_)); - } - else if (val >= (std::numeric_limits::lowest)()) - { - // int 32 stores a 32-bit big-endian signed integer - result_.push_back(jsoncons::ubjson::detail::ubjson_format::int32_type); - jsoncons::detail::to_big_endian(static_cast(val),std::back_inserter(result_)); - } - else if (val >= (std::numeric_limits::lowest)()) - { - // int 64 stores a 64-bit big-endian signed integer - result_.push_back(jsoncons::ubjson::detail::ubjson_format::int64_type); - jsoncons::detail::to_big_endian(static_cast(val),std::back_inserter(result_)); - } - } - end_value(); - return true; - } - - bool do_uint64_value(uint64_t val, - semantic_tag, - const ser_context&) override - { - if (val <= (std::numeric_limits::max)()) - { - result_.push_back(jsoncons::ubjson::detail::ubjson_format::uint8_type); - jsoncons::detail::to_big_endian(static_cast(val),std::back_inserter(result_)); - } - else if (val <= (std::numeric_limits::max)()) - { - result_.push_back(jsoncons::ubjson::detail::ubjson_format::int16_type); - jsoncons::detail::to_big_endian(static_cast(val),std::back_inserter(result_)); - } - else if (val <= (std::numeric_limits::max)()) - { - result_.push_back(jsoncons::ubjson::detail::ubjson_format::int32_type); - jsoncons::detail::to_big_endian(static_cast(val),std::back_inserter(result_)); - } - else if (val <= (uint64_t)(std::numeric_limits::max)()) - { - result_.push_back(jsoncons::ubjson::detail::ubjson_format::int64_type); - jsoncons::detail::to_big_endian(static_cast(val),std::back_inserter(result_)); - } - end_value(); - return true; - } - - bool do_bool_value(bool val, semantic_tag, const ser_context&) override - { - // true and false - result_.push_back(static_cast(val ? jsoncons::ubjson::detail::ubjson_format::true_type : jsoncons::ubjson::detail::ubjson_format::false_type)); - - end_value(); - return true; - } - - void end_value() - { - if (!stack_.empty()) - { - ++stack_.back().count_; - } - } -}; - -typedef basic_ubjson_encoder ubjson_encoder; -typedef basic_ubjson_encoder ubjson_bytes_encoder; - -#if !defined(JSONCONS_NO_DEPRECATED) -template -using basic_ubjson_serializer = basic_ubjson_encoder; - -typedef basic_ubjson_encoder ubjson_serializer; -typedef basic_ubjson_encoder ubjson_buffer_serializer; -#endif - -}} -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/ubjson/ubjson_error.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/ubjson/ubjson_error.hpp deleted file mode 100644 index dc11094ed9..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/ubjson/ubjson_error.hpp +++ /dev/null @@ -1,89 +0,0 @@ -/// Copyright 2018 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_UBJSON_UBJSON_ERROR_HPP -#define JSONCONS_UBJSON_UBJSON_ERROR_HPP - -#include -#include - -namespace jsoncons { namespace ubjson { - -enum class ubjson_errc -{ - ok = 0, - unexpected_eof = 1, - source_error, - count_required_after_type, - length_cannot_be_negative, - length_must_be_integer, - unknown_type, - invalid_utf8_text_string, - too_many_items, - too_few_items, - number_too_large -}; - -class ubjson_error_category_impl - : public std::error_category -{ -public: - const char* name() const noexcept override - { - return "jsoncons/ubjson"; - } - std::string message(int ev) const override - { - switch (static_cast(ev)) - { - case ubjson_errc::unexpected_eof: - return "Unexpected end of file"; - case ubjson_errc::source_error: - return "Source error"; - case ubjson_errc::count_required_after_type: - return "Type is specified for container, but count is not specified"; - case ubjson_errc::length_cannot_be_negative: - return "Length cannot be negative"; - case ubjson_errc::length_must_be_integer: - return "Length must be a integer numeric type (int8, uint8, int16, int32, int64)"; - case ubjson_errc::invalid_utf8_text_string: - return "Illegal UTF-8 encoding in text string"; - case ubjson_errc::too_many_items: - return "Too many items were added to a UBJSON object or array of known length"; - case ubjson_errc::too_few_items: - return "Too few items were added to a UBJSON object or array of known length"; - case ubjson_errc::number_too_large: - return "Number exceeds implementation limits"; - default: - return "Unknown UBJSON parser error"; - } - } -}; - -inline -const std::error_category& ubjson_error_category() -{ - static ubjson_error_category_impl instance; - return instance; -} - -inline -std::error_code make_error_code(ubjson_errc e) -{ - return std::error_code(static_cast(e),ubjson_error_category()); -} - - -}} - -namespace std { - template<> - struct is_error_code_enum : public true_type - { - }; -} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/ubjson/ubjson_reader.hpp b/cpp/thirdparty/knowhere_build/include/jsoncons_ext/ubjson/ubjson_reader.hpp deleted file mode 100644 index 540a588292..0000000000 --- a/cpp/thirdparty/knowhere_build/include/jsoncons_ext/ubjson/ubjson_reader.hpp +++ /dev/null @@ -1,589 +0,0 @@ -// Copyright 2017 Daniel Parker -// Distributed under the Boost license, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See https://github.com/danielaparker/jsoncons for latest version - -#ifndef JSONCONS_UBJSON_UBJSON_READER_HPP -#define JSONCONS_UBJSON_UBJSON_READER_HPP - -#include -#include -#include // std::move -#include -#include -#include -#include -#include -#include - -namespace jsoncons { namespace ubjson { - -template -class basic_ubjson_reader : public ser_context -{ - Src source_; - json_content_handler& handler_; - size_t nesting_depth_; - std::string buffer_; -public: - template - basic_ubjson_reader(Source&& source, json_content_handler& handler) - : source_(std::forward(source)), - handler_(handler), - nesting_depth_(0) - { - } - - void read() - { - std::error_code ec; - read(ec); - if (ec) - { - throw ser_error(ec,line(),column()); - } - } - - void read(std::error_code& ec) - { - try - { - read_internal(ec); - } - catch (const ser_error& e) - { - ec = e.code(); - } - } - - size_t line() const override - { - return 0; - } - - size_t column() const override - { - return source_.position(); - } -private: - - void read_internal(std::error_code& ec) - { - if (source_.is_error()) - { - ec = ubjson_errc::source_error; - return; - } - //const uint8_t* pos = input_ptr_++; - - uint8_t type{}; - if (source_.get(type) == 0) - { - ec = ubjson_errc::unexpected_eof; - return; - } - read_value(type, ec); - } - - void read_value(uint8_t type, std::error_code& ec) - { - switch (type) - { - case jsoncons::ubjson::detail::ubjson_format::null_type: - { - handler_.null_value(semantic_tag::none, *this); - break; - } - case jsoncons::ubjson::detail::ubjson_format::no_op_type: - { - break; - } - case jsoncons::ubjson::detail::ubjson_format::true_type: - { - handler_.bool_value(true, semantic_tag::none, *this); - break; - } - case jsoncons::ubjson::detail::ubjson_format::false_type: - { - handler_.bool_value(false, semantic_tag::none, *this); - break; - } - case jsoncons::ubjson::detail::ubjson_format::int8_type: - { - uint8_t buf[sizeof(int8_t)]; - source_.read(buf, sizeof(int8_t)); - if (source_.eof()) - { - ec = ubjson_errc::unexpected_eof; - return; - } - const uint8_t* endp; - int8_t val = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - handler_.int64_value(val, semantic_tag::none, *this); - break; - } - case jsoncons::ubjson::detail::ubjson_format::uint8_type: - { - uint8_t val{}; - if (source_.get(val) == 0) - { - ec = ubjson_errc::unexpected_eof; - return; - } - handler_.uint64_value(val, semantic_tag::none, *this); - break; - } - case jsoncons::ubjson::detail::ubjson_format::int16_type: - { - uint8_t buf[sizeof(int16_t)]; - source_.read(buf, sizeof(int16_t)); - if (source_.eof()) - { - ec = ubjson_errc::unexpected_eof; - return; - } - const uint8_t* endp; - int16_t val = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - handler_.int64_value(val, semantic_tag::none, *this); - break; - } - case jsoncons::ubjson::detail::ubjson_format::int32_type: - { - uint8_t buf[sizeof(int32_t)]; - source_.read(buf, sizeof(int32_t)); - if (source_.eof()) - { - ec = ubjson_errc::unexpected_eof; - return; - } - const uint8_t* endp; - int32_t val = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - handler_.int64_value(val, semantic_tag::none, *this); - break; - } - case jsoncons::ubjson::detail::ubjson_format::int64_type: - { - uint8_t buf[sizeof(int64_t)]; - source_.read(buf, sizeof(int64_t)); - if (source_.eof()) - { - ec = ubjson_errc::unexpected_eof; - return; - } - const uint8_t* endp; - int64_t val = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - handler_.int64_value(val, semantic_tag::none, *this); - break; - } - case jsoncons::ubjson::detail::ubjson_format::float32_type: - { - uint8_t buf[sizeof(float)]; - source_.read(buf, sizeof(float)); - if (source_.eof()) - { - ec = ubjson_errc::unexpected_eof; - return; - } - const uint8_t* endp; - float val = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - handler_.double_value(val, semantic_tag::none, *this); - break; - } - case jsoncons::ubjson::detail::ubjson_format::float64_type: - { - uint8_t buf[sizeof(double)]; - source_.read(buf, sizeof(double)); - if (source_.eof()) - { - ec = ubjson_errc::unexpected_eof; - return; - } - const uint8_t* endp; - double val = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - handler_.double_value(val, semantic_tag::none, *this); - break; - } - case jsoncons::ubjson::detail::ubjson_format::char_type: - { - uint8_t buf[sizeof(char)]; - source_.read(buf, sizeof(char)); - if (source_.eof()) - { - ec = ubjson_errc::unexpected_eof; - return; - } - const uint8_t* endp; - char c = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - auto result = unicons::validate(&c,&c+1); - if (result.ec != unicons::conv_errc()) - { - ec = ubjson_errc::invalid_utf8_text_string; - return; - } - handler_.string_value(basic_string_view(&c,1), semantic_tag::none, *this); - break; - } - case jsoncons::ubjson::detail::ubjson_format::string_type: - { - size_t length = get_length(ec); - if (ec) - { - return; - } - std::string s; - source_.read(std::back_inserter(s), length); - if (source_.eof()) - { - ec = ubjson_errc::unexpected_eof; - return; - } - auto result = unicons::validate(s.begin(),s.end()); - if (result.ec != unicons::conv_errc()) - { - ec = ubjson_errc::invalid_utf8_text_string; - return; - } - handler_.string_value(basic_string_view(s.data(),s.length()), semantic_tag::none, *this); - break; - } - case jsoncons::ubjson::detail::ubjson_format::high_precision_number_type: - { - size_t length = get_length(ec); - if (ec) - { - return; - } - std::string s; - source_.read(std::back_inserter(s), length); - if (source_.eof()) - { - ec = ubjson_errc::unexpected_eof; - return; - } - if (jsoncons::detail::is_integer(s.data(),s.length())) - { - handler_.string_value(basic_string_view(s.data(),s.length()), semantic_tag::bigint, *this); - } - else - { - handler_.string_value(basic_string_view(s.data(),s.length()), semantic_tag::bigdec, *this); - } - break; - } - case jsoncons::ubjson::detail::ubjson_format::start_array_marker: - { - if (source_.peek() == jsoncons::ubjson::detail::ubjson_format::type_marker) - { - source_.ignore(1); - uint8_t item_type{}; - if (source_.get(item_type) == 0) - { - ec = ubjson_errc::unexpected_eof; - return; - } - if (source_.peek() == jsoncons::ubjson::detail::ubjson_format::count_marker) - { - source_.ignore(1); - size_t length = get_length(ec); - handler_.begin_array(length, semantic_tag::none, *this); - for (size_t i = 0; i < length; ++i) - { - read_value(item_type, ec); - if (ec) - { - return; - } - } - handler_.end_array(*this); - } - else - { - ec = ubjson_errc::count_required_after_type; - return; - } - } - else if (source_.peek() == jsoncons::ubjson::detail::ubjson_format::count_marker) - { - source_.ignore(1); - size_t length = get_length(ec); - handler_.begin_array(length, semantic_tag::none, *this); - for (size_t i = 0; i < length; ++i) - { - read(ec); - if (ec) - { - return; - } - } - handler_.end_array(*this); - } - else - { - handler_.begin_array(semantic_tag::none, *this); - while (source_.peek() != jsoncons::ubjson::detail::ubjson_format::end_array_marker) - { - read(ec); - if (ec) - { - return; - } - } - handler_.end_array(*this); - source_.ignore(1); - } - break; - } - case jsoncons::ubjson::detail::ubjson_format::start_object_marker: - { - if (source_.peek() == jsoncons::ubjson::detail::ubjson_format::type_marker) - { - source_.ignore(1); - uint8_t item_type{}; - if (source_.get(item_type) == 0) - { - ec = ubjson_errc::unexpected_eof; - return; - } - if (source_.peek() == jsoncons::ubjson::detail::ubjson_format::count_marker) - { - source_.ignore(1); - size_t length = get_length(ec); - handler_.begin_object(length, semantic_tag::none, *this); - for (size_t i = 0; i < length; ++i) - { - read_name(ec); - if (ec) - { - return; - } - read_value(item_type, ec); - if (ec) - { - return; - } - } - handler_.end_object(*this); - } - else - { - ec = ubjson_errc::count_required_after_type; - return; - } - } - else - { - if (source_.peek() == jsoncons::ubjson::detail::ubjson_format::count_marker) - { - source_.ignore(1); - size_t length = get_length(ec); - handler_.begin_object(length, semantic_tag::none, *this); - for (size_t i = 0; i < length; ++i) - { - read_name(ec); - if (ec) - { - return; - } - read(ec); - if (ec) - { - return; - } - } - handler_.end_object(*this); - } - else - { - handler_.begin_object(semantic_tag::none, *this); - while (source_.peek() != jsoncons::ubjson::detail::ubjson_format::end_object_marker) - { - read_name(ec); - if (ec) - { - return; - } - read(ec); - if (ec) - { - return; - } - } - handler_.end_object(*this); - source_.ignore(1); - } - } - break; - } - default: - { - ec = ubjson_errc::unknown_type; - return; - } - } - } - - size_t get_length(std::error_code& ec) - { - size_t length = 0; - if (JSONCONS_UNLIKELY(source_.eof())) - { - ec = ubjson_errc::unexpected_eof; - return length; - } - uint8_t type{}; - if (source_.get(type) == 0) - { - ec = ubjson_errc::unexpected_eof; - return length; - } - switch (type) - { - case jsoncons::ubjson::detail::ubjson_format::int8_type: - { - uint8_t buf[sizeof(int8_t)]; - source_.read(buf, sizeof(int8_t)); - if (source_.eof()) - { - ec = ubjson_errc::unexpected_eof; - return length; - } - const uint8_t* endp; - int8_t val = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - if (val >= 0) - { - length = val; - } - else - { - ec = ubjson_errc::length_cannot_be_negative; - return length; - } - break; - } - case jsoncons::ubjson::detail::ubjson_format::uint8_type: - { - uint8_t val{}; - if (source_.get(val) == 0) - { - ec = ubjson_errc::unexpected_eof; - return length; - } - length = val; - break; - } - case jsoncons::ubjson::detail::ubjson_format::int16_type: - { - uint8_t buf[sizeof(int16_t)]; - source_.read(buf, sizeof(int16_t)); - if (source_.eof()) - { - ec = ubjson_errc::unexpected_eof; - return length; - } - const uint8_t* endp; - int16_t val = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - if (val >= 0) - { - length = val; - } - else - { - ec = ubjson_errc::length_cannot_be_negative; - return length; - } - break; - } - case jsoncons::ubjson::detail::ubjson_format::int32_type: - { - uint8_t buf[sizeof(int32_t)]; - source_.read(buf, sizeof(int32_t)); - if (source_.eof()) - { - ec = ubjson_errc::unexpected_eof; - return length; - } - const uint8_t* endp; - int32_t val = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - if (val >= 0) - { - length = val; - } - else - { - ec = ubjson_errc::length_cannot_be_negative; - return length; - } - break; - } - case jsoncons::ubjson::detail::ubjson_format::int64_type: - { - uint8_t buf[sizeof(int64_t)]; - source_.read(buf, sizeof(int64_t)); - if (source_.eof()) - { - ec = ubjson_errc::unexpected_eof; - return length; - } - const uint8_t* endp; - int64_t val = jsoncons::detail::from_big_endian(buf,buf+sizeof(buf),&endp); - if (val >= 0) - { - length = (size_t)val; - if (length != (uint64_t)val) - { - ec = ubjson_errc::number_too_large; - return length; - } - } - else - { - ec = ubjson_errc::length_cannot_be_negative; - return length; - } - break; - } - default: - { - ec = ubjson_errc::length_must_be_integer; - return length; - } - } - return length; - } - - void read_name(std::error_code& ec) - { - size_t length = get_length(ec); - if (ec) - { - return; - } - std::string s; - source_.read(std::back_inserter(s), length); - if (source_.eof()) - { - ec = ubjson_errc::unexpected_eof; - return; - } - auto result = unicons::validate(s.begin(),s.end()); - if (result.ec != unicons::conv_errc()) - { - ec = ubjson_errc::invalid_utf8_text_string; - return; - } - handler_.name(basic_string_view(s.data(),s.length()), *this); - } -}; - -typedef basic_ubjson_reader ubjson_reader; - -typedef basic_ubjson_reader ubjson_bytes_reader; - -#if !defined(JSONCONS_NO_DEPRECATED) -typedef ubjson_bytes_reader ubjson_buffer_reader; -#endif - -}} - -#endif diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/adapter/arrow.h b/cpp/thirdparty/knowhere_build/include/knowhere/adapter/arrow.h deleted file mode 100644 index 338ab691df..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/adapter/arrow.h +++ /dev/null @@ -1,18 +0,0 @@ - -#pragma once - -#include -#include - - -namespace zilliz { -namespace knowhere { - -ArrayPtr -CopyArray(const ArrayPtr &origin); - -SchemaPtr -CopySchema(const SchemaPtr &origin); - -} // namespace knowhere -} // namespace zilliz diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/adapter/faiss_adopt.h b/cpp/thirdparty/knowhere_build/include/knowhere/adapter/faiss_adopt.h deleted file mode 100644 index 26a005122e..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/adapter/faiss_adopt.h +++ /dev/null @@ -1,20 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved -// Unauthorized copying of this file, via any medium is strictly prohibited. -// Proprietary and confidential. -//////////////////////////////////////////////////////////////////////////////// - -#pragma once - -namespace zilliz { -namespace knowhere { - -#define GETTENSOR(dataset) \ - auto tensor = dataset->tensor()[0]; \ - auto p_data = tensor->raw_data(); \ - auto dim = tensor->shape()[1]; \ - auto rows = tensor->shape()[0]; \ - - -} -} \ No newline at end of file diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/adapter/sptag.h b/cpp/thirdparty/knowhere_build/include/knowhere/adapter/sptag.h deleted file mode 100644 index 08c4a625ee..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/adapter/sptag.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#include -#include -#include - - -namespace zilliz { -namespace knowhere { - -std::shared_ptr -ConvertToVectorSet(const DatasetPtr &dataset); - -std::shared_ptr -ConvertToMetadataSet(const DatasetPtr &dataset); - -std::vector -ConvertToQueryResult(const DatasetPtr &dataset, const Config &config); - -DatasetPtr -ConvertToDataset(std::vector query_results); - -} // namespace knowhere -} // namespace zilliz diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/adapter/structure.h b/cpp/thirdparty/knowhere_build/include/knowhere/adapter/structure.h deleted file mode 100644 index e0478ed38e..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/adapter/structure.h +++ /dev/null @@ -1,42 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved -// Unauthorized copying of this file, via any medium is strictly prohibited. -// Proprietary and confidential. -//////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include -#include - - -namespace zilliz { -namespace knowhere { - -extern ArrayPtr -ConstructInt64ArraySmart(uint8_t *data, int64_t size); - -extern ArrayPtr -ConstructFloatArraySmart(uint8_t *data, int64_t size); - -extern TensorPtr -ConstructFloatTensorSmart(uint8_t *data, int64_t size, std::vector shape); - -extern ArrayPtr -ConstructInt64Array(uint8_t *data, int64_t size); - -extern ArrayPtr -ConstructFloatArray(uint8_t *data, int64_t size); - -extern TensorPtr -ConstructFloatTensor(uint8_t *data, int64_t size, std::vector shape); - -extern FieldPtr -ConstructInt64Field(const std::string &name); - -extern FieldPtr -ConstructFloatField(const std::string &name); - - -} -} diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/common/array.h b/cpp/thirdparty/knowhere_build/include/knowhere/common/array.h deleted file mode 100644 index f3d0310596..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/common/array.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -#include "arrow/array.h" -#include "knowhere/common/schema.h" - - -namespace zilliz { -namespace knowhere { - -using ArrayData = arrow::ArrayData; -using ArrayDataPtr = std::shared_ptr; - -using Array = arrow::Array; -using ArrayPtr = std::shared_ptr; - -using BooleanArray = arrow::BooleanArray; -using BooleanArrayPtr = std::shared_ptr; - -template -using NumericArray = arrow::NumericArray; -template -using NumericArrayPtr = std::shared_ptr>; - -using BinaryArray = arrow::BinaryArray; -using BinaryArrayPtr = std::shared_ptr; - -using FixedSizeBinaryArray = arrow::FixedSizeBinaryArray; -using FixedSizeBinaryArrayPtr = std::shared_ptr; - -using Decimal128Array = arrow::Decimal128Array; -using Decimal128ArrayPtr = std::shared_ptr; - - -} // namespace knowhere -} // namespace zilliz diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/common/binary_set.h b/cpp/thirdparty/knowhere_build/include/knowhere/common/binary_set.h deleted file mode 100644 index b83d96dfe4..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/common/binary_set.h +++ /dev/null @@ -1,62 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -#include "knowhere/common/id.h" - - -namespace zilliz { -namespace knowhere { - - -struct Binary { - ID id; - std::shared_ptr data; - int64_t size = 0; -}; -using BinaryPtr = std::shared_ptr; - - -class BinarySet { - public: - BinaryPtr - GetByName(const std::string &name) const { - return binary_map_.at(name); - } - - void - Append(const std::string &name, BinaryPtr binary) { - binary_map_[name] = std::move(binary); - } - - void - Append(const std::string &name, std::shared_ptr data, int64_t size) { - auto binary = std::make_shared(); - binary->data = data; - binary->size = size; - binary_map_[name] = std::move(binary); - } - - //void - //Append(const std::string &name, void *data, int64_t size, ID id) { - // Binary binary; - // binary.data = data; - // binary.size = size; - // binary.id = id; - // binary_map_[name] = binary; - //} - - void clear() { - binary_map_.clear(); - } - - public: - std::map binary_map_; -}; - - -} // namespace knowhere -} // namespace zilliz diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/common/buffer.h b/cpp/thirdparty/knowhere_build/include/knowhere/common/buffer.h deleted file mode 100644 index 44867e760a..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/common/buffer.h +++ /dev/null @@ -1,45 +0,0 @@ -#pragma once - -#include -#include "arrow/buffer.h" - - -namespace zilliz { -namespace knowhere { - -using Buffer = arrow::Buffer; -using BufferPtr = std::shared_ptr; -using MutableBuffer = arrow::MutableBuffer; -using MutableBufferPtr = std::shared_ptr; - -namespace internal { - -struct BufferDeleter { - void operator()(Buffer *buffer) { - free((void *) buffer->data()); - } -}; - -} -inline BufferPtr -MakeBufferSmart(uint8_t *data, const int64_t size) { - return BufferPtr(new Buffer(data, size), internal::BufferDeleter()); -} - -inline MutableBufferPtr -MakeMutableBufferSmart(uint8_t *data, const int64_t size) { - return MutableBufferPtr(new MutableBuffer(data, size), internal::BufferDeleter()); -} - -inline BufferPtr -MakeBuffer(uint8_t *data, const int64_t size) { - return std::make_shared(data, size); -} - -inline MutableBufferPtr -MakeMutableBuffer(uint8_t *data, const int64_t size) { - return std::make_shared(data, size); -} - -} // namespace knowhere -} // namespace zilliz diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/common/config.h b/cpp/thirdparty/knowhere_build/include/knowhere/common/config.h deleted file mode 100644 index 3a3fee1219..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/common/config.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include - - -namespace zilliz { -namespace knowhere { - - -using Config = jsoncons::json; - - -} // namespace knowhere -} // namespace zilliz diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/common/dataset.h b/cpp/thirdparty/knowhere_build/include/knowhere/common/dataset.h deleted file mode 100644 index ee1d6e5100..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/common/dataset.h +++ /dev/null @@ -1,122 +0,0 @@ -#pragma once - -#include -#include -#include "knowhere/common/array.h" -#include "knowhere/common/buffer.h" -#include "knowhere/common/tensor.h" -#include "knowhere/common/schema.h" -#include "knowhere/common/config.h" -#include "knowhere/adapter/arrow.h" - - -namespace zilliz { -namespace knowhere { - -class Dataset; - -using DatasetPtr = std::shared_ptr; - -class Dataset { - public: - Dataset() = default; - - Dataset(std::vector &&array, SchemaPtr array_schema, - std::vector &&tensor, SchemaPtr tensor_schema) - : array_(std::move(array)), - array_schema_(std::move(array_schema)), - tensor_(std::move(tensor)), - tensor_schema_(std::move(tensor_schema)) {} - - Dataset(std::vector array, SchemaPtr array_schema) - : array_(std::move(array)), array_schema_(std::move(array_schema)) {} - - Dataset(std::vector tensor, SchemaPtr tensor_schema) - : tensor_(std::move(tensor)), tensor_schema_(std::move(tensor_schema)) {} - - Dataset(const Dataset &) = delete; - Dataset &operator=(const Dataset &) = delete; - - DatasetPtr - Clone() { - auto dataset = std::make_shared(); - - std::vector clone_array; - for (auto &array : array_) { - clone_array.emplace_back(CopyArray(array)); - } - dataset->set_array(clone_array); - - std::vector clone_tensor; - for (auto &tensor : tensor_) { - auto buffer = tensor->data(); - std::shared_ptr copy_buffer; - // TODO: checkout copy success; - buffer->Copy(0, buffer->size(), ©_buffer); - auto copy = std::make_shared(tensor->type(), copy_buffer, tensor->shape()); - clone_tensor.emplace_back(copy); - } - dataset->set_tensor(clone_tensor); - - if (array_schema_) - dataset->set_array_schema(CopySchema(array_schema_)); - if (tensor_schema_) - dataset->set_tensor_schema(CopySchema(tensor_schema_)); - - return dataset; - } - - public: - const std::vector & - array() const { return array_; } - - void - set_array(std::vector array) { - array_ = std::move(array); - } - - const std::vector & - tensor() const { return tensor_; } - - void - set_tensor(std::vector tensor) { - tensor_ = std::move(tensor); - } - - SchemaConstPtr - array_schema() const { return array_schema_; } - - void - set_array_schema(SchemaPtr array_schema) { - array_schema_ = std::move(array_schema); - } - - SchemaConstPtr - tensor_schema() const { return tensor_schema_; } - - void - set_tensor_schema(SchemaPtr tensor_schema) { - tensor_schema_ = std::move(tensor_schema); - } - - //const Config & - //meta() const { return meta_; } - - //void - //set_meta(Config meta) { - // meta_ = std::move(meta); - //} - - private: - SchemaPtr array_schema_; - SchemaPtr tensor_schema_; - std::vector array_; - std::vector tensor_; - //Config meta_; -}; - -using DatasetPtr = std::shared_ptr; - - -} // namespace knowhere -} // namespace zilliz diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/common/device_type.h b/cpp/thirdparty/knowhere_build/include/knowhere/common/device_type.h deleted file mode 100644 index 09fa362643..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/common/device_type.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - - -namespace zilliz { -namespace sched { -namespace master { - -} // namespace master -} // namespace sched -} // namespace zilliz diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/common/error.h b/cpp/thirdparty/knowhere_build/include/knowhere/common/error.h deleted file mode 100644 index ba7b5cf315..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/common/error.h +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once - -#include -#include "zlibrary/error/error.h" - - -namespace zilliz { -namespace knowhere { - -using Error = zilliz::lib::ErrorCode; - -constexpr Error STORE_SUCCESS = zilliz::lib::SUCCESS_CODE; - -constexpr Error ERROR_CODE_BASE = 0x36000; -constexpr Error ERROR_CODE_END = 0x37000; - -constexpr Error -ToGlobalErrorCode(const Error error_code) { - return zilliz::lib::ToGlobalErrorCode(error_code, ERROR_CODE_BASE); -} - -class Exception : public zilliz::lib::Exception { - public: - Exception(const Error error_code, - const std::string &message = nullptr) - : zilliz::lib::Exception(error_code, "KNOWHERE", message) {} -}; - -constexpr Error UNEXPECTED = ToGlobalErrorCode(0x001); -constexpr Error UNSUPPORTED = ToGlobalErrorCode(0x002); -constexpr Error NULL_POINTER = ToGlobalErrorCode(0x003); -constexpr Error OVERFLOW = ToGlobalErrorCode(0x004); -constexpr Error INVALID_ARGUMENT = ToGlobalErrorCode(0x005); -constexpr Error UNSUPPORTED_TYPE = ToGlobalErrorCode(0x006); - - -} // namespace store -} // namespace zilliz - -using Error = zilliz::store::Error; diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/common/exception.h b/cpp/thirdparty/knowhere_build/include/knowhere/common/exception.h deleted file mode 100644 index ea80f5657e..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/common/exception.h +++ /dev/null @@ -1,45 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved -// Unauthorized copying of this file, via any medium is strictly prohibited. -// Proprietary and confidential. -//////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include -#include - - -namespace zilliz { -namespace knowhere { - -class KnowhereException : public std::exception { - public: - explicit KnowhereException(const std::string &msg); - - KnowhereException(const std::string &msg, const char *funName, - const char *file, int line); - - const char *what() const noexcept override; - - std::string msg; -}; - - -#define KNOWHERE_THROW_MSG(MSG)\ -do {\ - throw KnowhereException(MSG, __PRETTY_FUNCTION__, __FILE__, __LINE__);\ -} while (false) - -#define KNOHERE_THROW_FORMAT(FMT, ...)\ - do { \ - std::string __s;\ - int __size = snprintf(nullptr, 0, FMT, __VA_ARGS__);\ - __s.resize(__size + 1);\ - snprintf(&__s[0], __s.size(), FMT, __VA_ARGS__);\ - throw faiss::FaissException(__s, __PRETTY_FUNCTION__, __FILE__, __LINE__);\ - } while (false) - - -} -} \ No newline at end of file diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/common/id.h b/cpp/thirdparty/knowhere_build/include/knowhere/common/id.h deleted file mode 100644 index dc823e6e22..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/common/id.h +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once - -//#include "zcommon/id/id.h" -//using ID = zilliz::common::ID; - -#include -#include - -namespace zilliz { -namespace knowhere { - - - -class ID { - public: - constexpr static int64_t kIDSize = 20; - - public: - const int32_t * - data() const { return content_; } - - int32_t * - mutable_data() { return content_; } - - bool - IsValid() const; - - std::string - ToString() const; - - bool - operator==(const ID &that) const; - - bool - operator<(const ID &that) const; - - protected: - int32_t content_[5] = {}; -}; - -} // namespace knowhere -} // namespace zilliz diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/common/schema.h b/cpp/thirdparty/knowhere_build/include/knowhere/common/schema.h deleted file mode 100644 index fe87721470..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/common/schema.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include -#include "arrow/type.h" - - -namespace zilliz { -namespace knowhere { - - -using DataType = arrow::DataType; -using Field = arrow::Field; -using FieldPtr = std::shared_ptr; -using Schema = arrow::Schema; -using SchemaPtr = std::shared_ptr; -using SchemaConstPtr = std::shared_ptr; - - - -} // namespace knowhere -} // namespace zilliz diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/common/tensor.h b/cpp/thirdparty/knowhere_build/include/knowhere/common/tensor.h deleted file mode 100644 index 93b7642cd1..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/common/tensor.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include -#include "arrow/tensor.h" - - -namespace zilliz { -namespace knowhere { - - -using Tensor = arrow::Tensor; -using TensorPtr = std::shared_ptr; - - -} // namespace knowhere -} // namespace zilliz diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/common/timer.h b/cpp/thirdparty/knowhere_build/include/knowhere/common/timer.h deleted file mode 100644 index 680d984d19..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/common/timer.h +++ /dev/null @@ -1,41 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved -// Unauthorized copying of this file, via any medium is strictly prohibited. -// Proprietary and confidential. -//////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include -#include - -namespace zilliz { -namespace knowhere { - -class TimeRecorder { - using stdclock = std::chrono::high_resolution_clock; - - public: - TimeRecorder(const std::string &header, - int64_t log_level = 0); - - ~TimeRecorder();//trace = 0, debug = 1, info = 2, warn = 3, error = 4, critical = 5 - - double RecordSection(const std::string &msg); - - double ElapseFromBegin(const std::string &msg); - - static std::string GetTimeSpanStr(double span); - - private: - void PrintTimeRecord(const std::string &msg, double span); - - private: - std::string header_; - stdclock::time_point start_; - stdclock::time_point last_; - int64_t log_level_; -}; - -} -} diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/index/index.h b/cpp/thirdparty/knowhere_build/include/knowhere/index/index.h deleted file mode 100644 index 40f3a8d5c0..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/index/index.h +++ /dev/null @@ -1,49 +0,0 @@ -#pragma once - -#include -#include "knowhere/common/binary_set.h" -#include "knowhere/common/dataset.h" -#include "knowhere/index/index_type.h" -#include "knowhere/index/index_model.h" -#include "knowhere/index/preprocessor/preprocessor.h" - - -namespace zilliz { -namespace knowhere { - - -class Index { - public: - virtual BinarySet - Serialize() = 0; - - virtual void - Load(const BinarySet &index_binary) = 0; - - // @throw - virtual DatasetPtr - Search(const DatasetPtr &dataset, const Config &config) = 0; - - public: - IndexType - idx_type() const { return idx_type_; } - - void - set_idx_type(IndexType idx_type) { idx_type_ = idx_type; } - - virtual void - set_preprocessor(PreprocessorPtr preprocessor) {} - - virtual void - set_index_model(IndexModelPtr model) {} - - private: - IndexType idx_type_; -}; - - -using IndexPtr = std::shared_ptr; - - -} // namespace knowhere -} // namespace zilliz diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/index/index_model.h b/cpp/thirdparty/knowhere_build/include/knowhere/index/index_model.h deleted file mode 100644 index 4b3a4e439c..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/index/index_model.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#include -#include "knowhere/common/binary_set.h" - -namespace zilliz { -namespace knowhere { - - -class IndexModel { - public: - virtual BinarySet - Serialize() = 0; - - virtual void - Load(const BinarySet &binary) = 0; -}; - -using IndexModelPtr = std::shared_ptr; - - - -} // namespace knowhere -} // namespace zilliz diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/index/index_type.h b/cpp/thirdparty/knowhere_build/include/knowhere/index/index_type.h deleted file mode 100644 index c7f9e39057..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/index/index_type.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - - -namespace zilliz { -namespace knowhere { - - -enum class IndexType { - kUnknown = 0, - kVecIdxBegin = 100, - kVecIVFFlat = kVecIdxBegin, - kVecIdxEnd, -}; - - -} // namespace knowhere -} // namespace zilliz diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/index/preprocessor/normalize.h b/cpp/thirdparty/knowhere_build/include/knowhere/index/preprocessor/normalize.h deleted file mode 100644 index 1d871b580d..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/index/preprocessor/normalize.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once - -#include -#include "preprocessor.h" - - -namespace zilliz { -namespace knowhere { - -class NormalizePreprocessor : public Preprocessor { - public: - DatasetPtr - Preprocess(const DatasetPtr &input) override; - - private: - - void - Normalize(float *arr, int64_t dimension); -}; - - -using NormalizePreprocessorPtr = std::shared_ptr; - - -} // namespace knowhere -} // namespace zilliz diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/index/preprocessor/preprocessor.h b/cpp/thirdparty/knowhere_build/include/knowhere/index/preprocessor/preprocessor.h deleted file mode 100644 index 368276e513..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/index/preprocessor/preprocessor.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#include -#include "knowhere/common/dataset.h" - - -namespace zilliz { -namespace knowhere { - - -class Preprocessor { - public: - virtual DatasetPtr - Preprocess(const DatasetPtr &input) = 0; -}; - - -using PreprocessorPtr = std::shared_ptr; - - -} // namespace knowhere -} // namespace zilliz diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/cpu_kdt_rng.h b/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/cpu_kdt_rng.h deleted file mode 100644 index 41b7be5daf..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/cpu_kdt_rng.h +++ /dev/null @@ -1,70 +0,0 @@ -#pragma once - -#include -#include -#include "knowhere/index/vector_index/vector_index.h" -#include "knowhere/index/index_model.h" -#include - - -namespace zilliz { -namespace knowhere { - - -class CPUKDTRNG : public VectorIndex { - public: - CPUKDTRNG() { - index_ptr_ = SPTAG::VectorIndex::CreateInstance(SPTAG::IndexAlgoType::KDT, - SPTAG::VectorValueType::Float); - index_ptr_->SetParameter("DistCalcMethod", "L2"); - } - - public: - BinarySet - Serialize() override; - - void - Load(const BinarySet &index_array) override; - - public: - PreprocessorPtr - BuildPreprocessor(const DatasetPtr &dataset, const Config &config) override; - int64_t Count() override; - int64_t Dimension() override; - - IndexModelPtr - Train(const DatasetPtr &dataset, const Config &config) override; - - void - Add(const DatasetPtr &dataset, const Config &config) override; - - DatasetPtr - Search(const DatasetPtr &dataset, const Config &config) override; - - private: - void - SetParameters(const Config &config); - - private: - PreprocessorPtr preprocessor_; - std::shared_ptr index_ptr_; -}; - -using CPUKDTRNGPtr = std::shared_ptr; - -class CPUKDTRNGIndexModel : public IndexModel { - public: - BinarySet - Serialize() override; - - void - Load(const BinarySet &binary) override; - - private: - std::shared_ptr index_; -}; - -using CPUKDTRNGIndexModelPtr = std::shared_ptr; - -} // namespace knowhere -} // namespace zilliz diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/definitions.h b/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/definitions.h deleted file mode 100644 index 9904597584..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/definitions.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include - - -namespace zilliz { -namespace knowhere { - -#define META_ROWS ("rows") -#define META_DIM ("dimension") -#define META_K ("k") - -} // namespace knowhere -} // namespace zilliz diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/gpu_ivf.h b/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/gpu_ivf.h deleted file mode 100644 index 0927bdb512..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/gpu_ivf.h +++ /dev/null @@ -1,54 +0,0 @@ -#pragma once - -#include - -#include "ivf.h" - - -namespace zilliz { -namespace knowhere { - - -class GPUIVF : public IVF { - public: - explicit GPUIVF(const int &device_id) : IVF(), gpu_id_(device_id) {} - IndexModelPtr Train(const DatasetPtr &dataset, const Config &config) override; - void set_index_model(IndexModelPtr model) override; - DatasetPtr Search(const DatasetPtr &dataset, const Config &config) override; - IVFIndexPtr Copy_index_gpu_to_cpu(); - void SetGpuDevice(const int &gpu_id); - - protected: - void search_impl(int64_t n, - const float *data, - int64_t k, - float *distances, - int64_t *labels, - const Config &cfg) override; - BinarySet SerializeImpl() override; - void LoadImpl(const BinarySet &index_binary) override; - - protected: - int64_t gpu_id_; - faiss::gpu::StandardGpuResources res_; -}; - -class GPUIVFSQ : public GPUIVF { - public: - explicit GPUIVFSQ(const int &device_id) : GPUIVF(device_id) {} - IndexModelPtr Train(const DatasetPtr &dataset, const Config &config) override; -}; - -class GPUIVFPQ : public GPUIVF { - public: - explicit GPUIVFPQ(const int &device_id) : GPUIVF(device_id) {} - IndexModelPtr Train(const DatasetPtr &dataset, const Config &config) override; - - protected: - // TODO(linxj): remove GenParams. - std::shared_ptr GenParams(const Config &config) override; -}; - - -} // namespace knowhere -} // namespace zilliz diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/idmap.h b/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/idmap.h deleted file mode 100644 index 298b100bd1..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/idmap.h +++ /dev/null @@ -1,36 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved -// Unauthorized copying of this file, via any medium is strictly prohibited. -// Proprietary and confidential. -//////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "ivf.h" - - -namespace zilliz { -namespace knowhere { - -class IDMAP : public VectorIndex, public BasicIndex { - public: - IDMAP() : BasicIndex(nullptr) {}; - BinarySet Serialize() override; - void Load(const BinarySet &index_binary) override; - void Train(const Config &config); - DatasetPtr Search(const DatasetPtr &dataset, const Config &config) override; - int64_t Count() override; - int64_t Dimension() override; - void Add(const DatasetPtr &dataset, const Config &config) override; - - float* GetRawVectors(); - int64_t* GetRawIds(); - - protected: - std::mutex mutex_; -}; - -using IDMAPPtr = std::shared_ptr; - -} -} diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/ivf.h b/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/ivf.h deleted file mode 100644 index 88ac7b3cb0..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/ivf.h +++ /dev/null @@ -1,123 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved -// Unauthorized copying of this file, via any medium is strictly prohibited. -// Proprietary and confidential. -//////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include -#include - -#include -#include -#include - -#include "knowhere/index/vector_index/vector_index.h" - - -namespace zilliz { -namespace knowhere { - -class BasicIndex { - protected: - explicit BasicIndex(std::shared_ptr index); - virtual BinarySet SerializeImpl(); - virtual void LoadImpl(const BinarySet &index_binary); - - protected: - std::shared_ptr index_ = nullptr; -}; - -using Graph = std::vector>; - -class IVF : public VectorIndex, public BasicIndex { - public: - IVF() : BasicIndex(nullptr) {}; - explicit IVF(std::shared_ptr index) : BasicIndex(std::move(index)) {}; - IndexModelPtr Train(const DatasetPtr &dataset, const Config &config) override; - void set_index_model(IndexModelPtr model) override; - void Add(const DatasetPtr &dataset, const Config &config) override; - void AddWithoutIds(const DatasetPtr &dataset, const Config &config); - DatasetPtr Search(const DatasetPtr &dataset, const Config &config) override; - void GenGraph(const int64_t &k, Graph &graph, const DatasetPtr &dataset, const Config &config); - BinarySet Serialize() override; - void Load(const BinarySet &index_binary) override; - int64_t Count() override; - int64_t Dimension() override; - - protected: - virtual std::shared_ptr GenParams(const Config &config); - - virtual void search_impl(int64_t n, - const float *data, - int64_t k, - float *distances, - int64_t *labels, - const Config &cfg); - - protected: - std::mutex mutex_; -}; - -using IVFIndexPtr = std::shared_ptr; - -class IVFSQ : public IVF { - public: - IndexModelPtr Train(const DatasetPtr &dataset, const Config &config) override; -}; - -class IVFPQ : public IVF { - public: - IndexModelPtr Train(const DatasetPtr &dataset, const Config &config) override; - protected: - std::shared_ptr GenParams(const Config &config) override; -}; - - -//class OPQIVFPQ : public IVFPQ { -// public: -// PreprocessorPtr BuildPreprocessor(const Dataset &dataset, const Config &config) override; -//}; - - -class GPUIVF; - - -struct MemoryIOWriter : public faiss::IOWriter { - uint8_t *data_ = nullptr; - size_t total = 0; - size_t rp = 0; - - size_t operator()(const void *ptr, size_t size, size_t nitems) override; -}; - - -struct MemoryIOReader : public faiss::IOReader { - uint8_t *data_; - size_t rp = 0; - size_t total = 0; - - size_t operator()(void *ptr, size_t size, size_t nitems) override; - -}; - - -class IVFIndexModel : public IndexModel, public BasicIndex { - friend IVF; - friend GPUIVF; - - public: - explicit IVFIndexModel(std::shared_ptr index); - IVFIndexModel() : BasicIndex(nullptr) {}; - BinarySet Serialize() override; - void Load(const BinarySet &binary) override; - - protected: - std::mutex mutex_; -}; - -using IVFIndexModelPtr = std::shared_ptr; - -} -} \ No newline at end of file diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/kdt_parameters.h b/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/kdt_parameters.h deleted file mode 100644 index 6f2d631d42..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/kdt_parameters.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include -#include - - -namespace zilliz { -namespace knowhere { - -using KDTParameter = std::pair; - -class KDTParameterManagement { - public: - const std::vector & - GetKDTParameters(); - - public: - static KDTParameterManagement & - GetInstance() { - static KDTParameterManagement instance; - return instance; - } - - KDTParameterManagement(const KDTParameterManagement &) = delete; - KDTParameterManagement &operator=(const KDTParameterManagement &) = delete; - private: - KDTParameterManagement(); - - private: - std::vector kdt_parameters_; -}; - -} // namespace knowhere -} // namespace zilliz diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/nsg/neighbor.h b/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/nsg/neighbor.h deleted file mode 100644 index 40281d2d6d..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/nsg/neighbor.h +++ /dev/null @@ -1,51 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved -// Unauthorized copying of this file, via any medium is strictly prohibited. -// Proprietary and confidential. -//////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include - - -namespace zilliz { -namespace knowhere { -namespace algo { - -using node_t = int64_t; - -// TODO: search use simple neighbor -struct Neighbor { - node_t id; // offset of node in origin data - float distance; - bool has_explored; - - Neighbor() = default; - explicit Neighbor(node_t id, float distance, bool f) : id{id}, distance{distance}, has_explored(f) {} - - explicit Neighbor(node_t id, float distance) : id{id}, distance{distance}, has_explored(false) {} - - inline bool operator<(const Neighbor &other) const { - return distance < other.distance; - } -}; - -//struct SimpleNeighbor { -// node_t id; // offset of node in origin data -// float distance; -// -// SimpleNeighbor() = default; -// explicit SimpleNeighbor(node_t id, float distance) : id{id}, distance{distance}{} -// -// inline bool operator<(const Neighbor &other) const { -// return distance < other.distance; -// } -//}; - -typedef std::lock_guard LockGuard; - - -} -} -} \ No newline at end of file diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/nsg/nsg.h b/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/nsg/nsg.h deleted file mode 100644 index 080bfec043..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/nsg/nsg.h +++ /dev/null @@ -1,147 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved -// Unauthorized copying of this file, via any medium is strictly prohibited. -// Proprietary and confidential. -//////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include -#include -#include - -#include -#include "neighbor.h" - - -namespace zilliz { -namespace knowhere { -namespace algo { - - -using node_t = int64_t; - -enum class MetricType { - METRIC_INNER_PRODUCT = 0, - METRIC_L2 = 1, -}; - -struct BuildParams { - size_t search_length; - size_t out_degree; - size_t candidate_pool_size; -}; - -struct SearchParams { - size_t search_length; -}; - -using Graph = std::vector>; - -class NsgIndex { - public: - size_t dimension; - size_t ntotal; // totabl nb of indexed vectors - MetricType metric_type; // L2 | IP - - float *ori_data_; - long *ids_; // TODO: support different type - Graph nsg; // final graph - Graph knng; // reset after build - - node_t navigation_point; // offset of node in origin data - - bool is_trained = false; - - /* - * build and search parameter - */ - size_t search_length; - size_t candidate_pool_size; // search deepth in fullset - size_t out_degree; - - public: - explicit NsgIndex(const size_t &dimension, - const size_t &n, - MetricType metric = MetricType::METRIC_L2); - - NsgIndex() = default; - - virtual ~NsgIndex(); - - void SetKnnGraph(Graph &knng); - - virtual void Build_with_ids(size_t nb, - const float *data, - const long *ids, - const BuildParams ¶meters); - - void Search(const float *query, - const unsigned &nq, - const unsigned &dim, - const unsigned &k, - float *dist, - long *ids, - SearchParams ¶ms); - - // Not support yet. - //virtual void Add() = 0; - //virtual void Add_with_ids() = 0; - //virtual void Delete() = 0; - //virtual void Delete_with_ids() = 0; - //virtual void Rebuild(size_t nb, - // const float *data, - // const long *ids, - // const Parameters ¶meters) = 0; - //virtual void Build(size_t nb, - // const float *data, - // const BuildParam ¶meters); - - protected: - virtual void InitNavigationPoint(); - - // link specify - void GetNeighbors(const float *query, - std::vector &resset, - std::vector &fullset, - boost::dynamic_bitset<> &has_calculated_dist); - - // FindUnconnectedNode - void GetNeighbors(const float *query, - std::vector &resset, - std::vector &fullset); - - // search and navigation-point - void GetNeighbors(const float *query, - std::vector &resset, - Graph &graph, - SearchParams *param = nullptr); - - void Link(); - - void SyncPrune(size_t q, - std::vector &pool, - boost::dynamic_bitset<> &has_calculated, - float *cut_graph_dist - ); - - void SelectEdge(unsigned &cursor, - std::vector &sort_pool, - std::vector &result, - bool limit = false); - - void InterInsert(unsigned n, std::vector &mutex_vec, float *dist); - - void CheckConnectivity(); - - void DFS(size_t root, boost::dynamic_bitset<> &flags, int64_t &count); - - void FindUnconnectedNode(boost::dynamic_bitset<> &flags, int64_t &root); - - private: - void GetKnnGraphFromFile(); -}; - -} -} -} diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/nsg/nsg.i b/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/nsg/nsg.i deleted file mode 100644 index d66dc49029..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/nsg/nsg.i +++ /dev/null @@ -1,15 +0,0 @@ -%module nsg -%{ -#define SWIG_FILE_WITH_INIT -#include - -/* Include the header in the wrapper code */ -#include "nsg.h" - - -%} - - -/* Parse the header file */ -%include "index.h" - diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/nsg/nsg_io.h b/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/nsg/nsg_io.h deleted file mode 100644 index 5f20e715c7..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/nsg/nsg_io.h +++ /dev/null @@ -1,22 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved -// Unauthorized copying of this file, via any medium is strictly prohibited. -// Proprietary and confidential. -//////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "nsg.h" -#include "knowhere/index/vector_index/ivf.h" - - -namespace zilliz { -namespace knowhere { -namespace algo { - -extern void write_index(NsgIndex* index, MemoryIOWriter& writer); -extern NsgIndex* read_index(MemoryIOReader& reader); - -} -} -} diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/nsg_index.h b/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/nsg_index.h deleted file mode 100644 index 2668f7ab06..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/nsg_index.h +++ /dev/null @@ -1,40 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved -// Unauthorized copying of this file, via any medium is strictly prohibited. -// Proprietary and confidential. -//////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "knowhere/index/vector_index/vector_index.h" - - -namespace zilliz { -namespace knowhere { - -namespace algo { -class NsgIndex; -} - -class NSG : public VectorIndex { - public: - explicit NSG(const int64_t& gpu_num):gpu_(gpu_num){} - NSG() = default; - - IndexModelPtr Train(const DatasetPtr &dataset, const Config &config) override; - DatasetPtr Search(const DatasetPtr &dataset, const Config &config) override; - void Add(const DatasetPtr &dataset, const Config &config) override; - BinarySet Serialize() override; - void Load(const BinarySet &index_binary) override; - int64_t Count() override; - int64_t Dimension() override; - - private: - std::shared_ptr index_; - int64_t gpu_; -}; - -using NSGIndexPtr = std::shared_ptr(); - -} -} diff --git a/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/vector_index.h b/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/vector_index.h deleted file mode 100644 index e9e35e1c4d..0000000000 --- a/cpp/thirdparty/knowhere_build/include/knowhere/index/vector_index/vector_index.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once - - -#include -#include "knowhere/common/config.h" -#include "knowhere/common/dataset.h" -#include "knowhere/index/index.h" -#include "knowhere/index/preprocessor/preprocessor.h" - - -namespace zilliz { -namespace knowhere { - - -class VectorIndex : public Index { - public: - virtual PreprocessorPtr - BuildPreprocessor(const DatasetPtr &dataset, const Config &config) { return nullptr; } - - virtual IndexModelPtr - Train(const DatasetPtr &dataset, const Config &config) { return nullptr; } - - virtual void - Add(const DatasetPtr &dataset, const Config &config) = 0; - - virtual int64_t - Count() = 0; - - virtual int64_t - Dimension() = 0; -}; - - -using VectorIndexPtr = std::shared_ptr; - - -} // namespace knowhere -} // namespace zilliz diff --git a/cpp/thirdparty/knowhere_build/include/lapacke.h b/cpp/thirdparty/knowhere_build/include/lapacke.h deleted file mode 100644 index c5ea465e0d..0000000000 --- a/cpp/thirdparty/knowhere_build/include/lapacke.h +++ /dev/null @@ -1,19463 +0,0 @@ -/***************************************************************************** - Copyright (c) 2014, Intel Corp. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of Intel Corporation nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - THE POSSIBILITY OF SUCH DAMAGE. -****************************************************************************** -* Contents: Native C interface to LAPACK -* Author: Intel Corporation -* Generated August, 2015 -*****************************************************************************/ - -#ifndef _LAPACKE_H_ -#define _LAPACKE_H_ - -/* -* Turn on HAVE_LAPACK_CONFIG_H to redefine C-LAPACK datatypes -*/ -#ifdef HAVE_LAPACK_CONFIG_H -#include "lapacke_config.h" -#endif - -#include - -#ifndef lapack_int -#define lapack_int int -#endif - -#ifndef lapack_logical -#define lapack_logical lapack_int -#endif - -/* Complex types are structures equivalent to the -* Fortran complex types COMPLEX(4) and COMPLEX(8). -* -* One can also redefine the types with his own types -* for example by including in the code definitions like -* -* #define lapack_complex_float std::complex -* #define lapack_complex_double std::complex -* -* or define these types in the command line: -* -* -Dlapack_complex_float="std::complex" -* -Dlapack_complex_double="std::complex" -*/ - -#ifndef LAPACK_COMPLEX_CUSTOM - -/* Complex type (single precision) */ -#ifndef lapack_complex_float -#ifndef __cplusplus -#include -#else -#include -#endif -#define lapack_complex_float float _Complex -#endif - -#ifndef lapack_complex_float_real -#define lapack_complex_float_real(z) (creal(z)) -#endif - -#ifndef lapack_complex_float_imag -#define lapack_complex_float_imag(z) (cimag(z)) -#endif - -lapack_complex_float lapack_make_complex_float( float re, float im ); - -/* Complex type (double precision) */ -#ifndef lapack_complex_double -#ifndef __cplusplus -#include -#else -#include -#endif -#define lapack_complex_double double _Complex -#endif - -#ifndef lapack_complex_double_real -#define lapack_complex_double_real(z) (creal(z)) -#endif - -#ifndef lapack_complex_double_imag -#define lapack_complex_double_imag(z) (cimag(z)) -#endif - -lapack_complex_double lapack_make_complex_double( double re, double im ); - -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#ifndef LAPACKE_malloc -#define LAPACKE_malloc( size ) malloc( size ) -#endif -#ifndef LAPACKE_free -#define LAPACKE_free( p ) free( p ) -#endif - -#define LAPACK_C2INT( x ) (lapack_int)(*((float*)&x )) -#define LAPACK_Z2INT( x ) (lapack_int)(*((double*)&x )) - -#define LAPACK_ROW_MAJOR 101 -#define LAPACK_COL_MAJOR 102 - -#define LAPACK_WORK_MEMORY_ERROR -1010 -#define LAPACK_TRANSPOSE_MEMORY_ERROR -1011 - -/* Callback logical functions of one, two, or three arguments are used -* to select eigenvalues to sort to the top left of the Schur form. -* The value is selected if function returns TRUE (non-zero). */ - -typedef lapack_logical (*LAPACK_S_SELECT2) ( const float*, const float* ); -typedef lapack_logical (*LAPACK_S_SELECT3) - ( const float*, const float*, const float* ); -typedef lapack_logical (*LAPACK_D_SELECT2) ( const double*, const double* ); -typedef lapack_logical (*LAPACK_D_SELECT3) - ( const double*, const double*, const double* ); - -typedef lapack_logical (*LAPACK_C_SELECT1) ( const lapack_complex_float* ); -typedef lapack_logical (*LAPACK_C_SELECT2) - ( const lapack_complex_float*, const lapack_complex_float* ); -typedef lapack_logical (*LAPACK_Z_SELECT1) ( const lapack_complex_double* ); -typedef lapack_logical (*LAPACK_Z_SELECT2) - ( const lapack_complex_double*, const lapack_complex_double* ); - -#include "lapacke_mangling.h" - -#define LAPACK_lsame LAPACK_GLOBAL(lsame,LSAME) -lapack_logical LAPACK_lsame( char* ca, char* cb, - lapack_int lca, lapack_int lcb ); - -/* C-LAPACK function prototypes */ - -lapack_int LAPACKE_sbdsdc( int matrix_layout, char uplo, char compq, - lapack_int n, float* d, float* e, float* u, - lapack_int ldu, float* vt, lapack_int ldvt, float* q, - lapack_int* iq ); -lapack_int LAPACKE_dbdsdc( int matrix_layout, char uplo, char compq, - lapack_int n, double* d, double* e, double* u, - lapack_int ldu, double* vt, lapack_int ldvt, - double* q, lapack_int* iq ); - -lapack_int LAPACKE_sbdsqr( int matrix_layout, char uplo, lapack_int n, - lapack_int ncvt, lapack_int nru, lapack_int ncc, - float* d, float* e, float* vt, lapack_int ldvt, - float* u, lapack_int ldu, float* c, lapack_int ldc ); -lapack_int LAPACKE_dbdsqr( int matrix_layout, char uplo, lapack_int n, - lapack_int ncvt, lapack_int nru, lapack_int ncc, - double* d, double* e, double* vt, lapack_int ldvt, - double* u, lapack_int ldu, double* c, - lapack_int ldc ); -lapack_int LAPACKE_cbdsqr( int matrix_layout, char uplo, lapack_int n, - lapack_int ncvt, lapack_int nru, lapack_int ncc, - float* d, float* e, lapack_complex_float* vt, - lapack_int ldvt, lapack_complex_float* u, - lapack_int ldu, lapack_complex_float* c, - lapack_int ldc ); -lapack_int LAPACKE_zbdsqr( int matrix_layout, char uplo, lapack_int n, - lapack_int ncvt, lapack_int nru, lapack_int ncc, - double* d, double* e, lapack_complex_double* vt, - lapack_int ldvt, lapack_complex_double* u, - lapack_int ldu, lapack_complex_double* c, - lapack_int ldc ); -lapack_int LAPACKE_sbdsvdx( int matrix_layout, char uplo, char jobz, char range, - lapack_int n, float* d, float* e, - float vl, float vu, - lapack_int il, lapack_int iu, lapack_int* ns, - float* s, float* z, lapack_int ldz, - lapack_int* superb ); -lapack_int LAPACKE_dbdsvdx( int matrix_layout, char uplo, char jobz, char range, - lapack_int n, double* d, double* e, - double vl, double vu, - lapack_int il, lapack_int iu, lapack_int* ns, - double* s, double* z, lapack_int ldz, - lapack_int* superb ); -lapack_int LAPACKE_sdisna( char job, lapack_int m, lapack_int n, const float* d, - float* sep ); -lapack_int LAPACKE_ddisna( char job, lapack_int m, lapack_int n, - const double* d, double* sep ); - -lapack_int LAPACKE_sgbbrd( int matrix_layout, char vect, lapack_int m, - lapack_int n, lapack_int ncc, lapack_int kl, - lapack_int ku, float* ab, lapack_int ldab, float* d, - float* e, float* q, lapack_int ldq, float* pt, - lapack_int ldpt, float* c, lapack_int ldc ); -lapack_int LAPACKE_dgbbrd( int matrix_layout, char vect, lapack_int m, - lapack_int n, lapack_int ncc, lapack_int kl, - lapack_int ku, double* ab, lapack_int ldab, - double* d, double* e, double* q, lapack_int ldq, - double* pt, lapack_int ldpt, double* c, - lapack_int ldc ); -lapack_int LAPACKE_cgbbrd( int matrix_layout, char vect, lapack_int m, - lapack_int n, lapack_int ncc, lapack_int kl, - lapack_int ku, lapack_complex_float* ab, - lapack_int ldab, float* d, float* e, - lapack_complex_float* q, lapack_int ldq, - lapack_complex_float* pt, lapack_int ldpt, - lapack_complex_float* c, lapack_int ldc ); -lapack_int LAPACKE_zgbbrd( int matrix_layout, char vect, lapack_int m, - lapack_int n, lapack_int ncc, lapack_int kl, - lapack_int ku, lapack_complex_double* ab, - lapack_int ldab, double* d, double* e, - lapack_complex_double* q, lapack_int ldq, - lapack_complex_double* pt, lapack_int ldpt, - lapack_complex_double* c, lapack_int ldc ); - -lapack_int LAPACKE_sgbcon( int matrix_layout, char norm, lapack_int n, - lapack_int kl, lapack_int ku, const float* ab, - lapack_int ldab, const lapack_int* ipiv, float anorm, - float* rcond ); -lapack_int LAPACKE_dgbcon( int matrix_layout, char norm, lapack_int n, - lapack_int kl, lapack_int ku, const double* ab, - lapack_int ldab, const lapack_int* ipiv, - double anorm, double* rcond ); -lapack_int LAPACKE_cgbcon( int matrix_layout, char norm, lapack_int n, - lapack_int kl, lapack_int ku, - const lapack_complex_float* ab, lapack_int ldab, - const lapack_int* ipiv, float anorm, float* rcond ); -lapack_int LAPACKE_zgbcon( int matrix_layout, char norm, lapack_int n, - lapack_int kl, lapack_int ku, - const lapack_complex_double* ab, lapack_int ldab, - const lapack_int* ipiv, double anorm, - double* rcond ); - -lapack_int LAPACKE_sgbequ( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, const float* ab, - lapack_int ldab, float* r, float* c, float* rowcnd, - float* colcnd, float* amax ); -lapack_int LAPACKE_dgbequ( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, const double* ab, - lapack_int ldab, double* r, double* c, - double* rowcnd, double* colcnd, double* amax ); -lapack_int LAPACKE_cgbequ( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, - const lapack_complex_float* ab, lapack_int ldab, - float* r, float* c, float* rowcnd, float* colcnd, - float* amax ); -lapack_int LAPACKE_zgbequ( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, - const lapack_complex_double* ab, lapack_int ldab, - double* r, double* c, double* rowcnd, double* colcnd, - double* amax ); - -lapack_int LAPACKE_sgbequb( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, const float* ab, - lapack_int ldab, float* r, float* c, float* rowcnd, - float* colcnd, float* amax ); -lapack_int LAPACKE_dgbequb( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, const double* ab, - lapack_int ldab, double* r, double* c, - double* rowcnd, double* colcnd, double* amax ); -lapack_int LAPACKE_cgbequb( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, - const lapack_complex_float* ab, lapack_int ldab, - float* r, float* c, float* rowcnd, float* colcnd, - float* amax ); -lapack_int LAPACKE_zgbequb( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, - const lapack_complex_double* ab, lapack_int ldab, - double* r, double* c, double* rowcnd, - double* colcnd, double* amax ); - -lapack_int LAPACKE_sgbrfs( int matrix_layout, char trans, lapack_int n, - lapack_int kl, lapack_int ku, lapack_int nrhs, - const float* ab, lapack_int ldab, const float* afb, - lapack_int ldafb, const lapack_int* ipiv, - const float* b, lapack_int ldb, float* x, - lapack_int ldx, float* ferr, float* berr ); -lapack_int LAPACKE_dgbrfs( int matrix_layout, char trans, lapack_int n, - lapack_int kl, lapack_int ku, lapack_int nrhs, - const double* ab, lapack_int ldab, const double* afb, - lapack_int ldafb, const lapack_int* ipiv, - const double* b, lapack_int ldb, double* x, - lapack_int ldx, double* ferr, double* berr ); -lapack_int LAPACKE_cgbrfs( int matrix_layout, char trans, lapack_int n, - lapack_int kl, lapack_int ku, lapack_int nrhs, - const lapack_complex_float* ab, lapack_int ldab, - const lapack_complex_float* afb, lapack_int ldafb, - const lapack_int* ipiv, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, float* ferr, - float* berr ); -lapack_int LAPACKE_zgbrfs( int matrix_layout, char trans, lapack_int n, - lapack_int kl, lapack_int ku, lapack_int nrhs, - const lapack_complex_double* ab, lapack_int ldab, - const lapack_complex_double* afb, lapack_int ldafb, - const lapack_int* ipiv, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* ferr, double* berr ); - -lapack_int LAPACKE_sgbrfsx( int matrix_layout, char trans, char equed, - lapack_int n, lapack_int kl, lapack_int ku, - lapack_int nrhs, const float* ab, lapack_int ldab, - const float* afb, lapack_int ldafb, - const lapack_int* ipiv, const float* r, - const float* c, const float* b, lapack_int ldb, - float* x, lapack_int ldx, float* rcond, float* berr, - lapack_int n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int nparams, - float* params ); -lapack_int LAPACKE_dgbrfsx( int matrix_layout, char trans, char equed, - lapack_int n, lapack_int kl, lapack_int ku, - lapack_int nrhs, const double* ab, lapack_int ldab, - const double* afb, lapack_int ldafb, - const lapack_int* ipiv, const double* r, - const double* c, const double* b, lapack_int ldb, - double* x, lapack_int ldx, double* rcond, - double* berr, lapack_int n_err_bnds, - double* err_bnds_norm, double* err_bnds_comp, - lapack_int nparams, double* params ); -lapack_int LAPACKE_cgbrfsx( int matrix_layout, char trans, char equed, - lapack_int n, lapack_int kl, lapack_int ku, - lapack_int nrhs, const lapack_complex_float* ab, - lapack_int ldab, const lapack_complex_float* afb, - lapack_int ldafb, const lapack_int* ipiv, - const float* r, const float* c, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* rcond, float* berr, lapack_int n_err_bnds, - float* err_bnds_norm, float* err_bnds_comp, - lapack_int nparams, float* params ); -lapack_int LAPACKE_zgbrfsx( int matrix_layout, char trans, char equed, - lapack_int n, lapack_int kl, lapack_int ku, - lapack_int nrhs, const lapack_complex_double* ab, - lapack_int ldab, const lapack_complex_double* afb, - lapack_int ldafb, const lapack_int* ipiv, - const double* r, const double* c, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* berr, lapack_int n_err_bnds, - double* err_bnds_norm, double* err_bnds_comp, - lapack_int nparams, double* params ); - -lapack_int LAPACKE_sgbsv( int matrix_layout, lapack_int n, lapack_int kl, - lapack_int ku, lapack_int nrhs, float* ab, - lapack_int ldab, lapack_int* ipiv, float* b, - lapack_int ldb ); -lapack_int LAPACKE_dgbsv( int matrix_layout, lapack_int n, lapack_int kl, - lapack_int ku, lapack_int nrhs, double* ab, - lapack_int ldab, lapack_int* ipiv, double* b, - lapack_int ldb ); -lapack_int LAPACKE_cgbsv( int matrix_layout, lapack_int n, lapack_int kl, - lapack_int ku, lapack_int nrhs, - lapack_complex_float* ab, lapack_int ldab, - lapack_int* ipiv, lapack_complex_float* b, - lapack_int ldb ); -lapack_int LAPACKE_zgbsv( int matrix_layout, lapack_int n, lapack_int kl, - lapack_int ku, lapack_int nrhs, - lapack_complex_double* ab, lapack_int ldab, - lapack_int* ipiv, lapack_complex_double* b, - lapack_int ldb ); - -lapack_int LAPACKE_sgbsvx( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int kl, lapack_int ku, - lapack_int nrhs, float* ab, lapack_int ldab, - float* afb, lapack_int ldafb, lapack_int* ipiv, - char* equed, float* r, float* c, float* b, - lapack_int ldb, float* x, lapack_int ldx, - float* rcond, float* ferr, float* berr, - float* rpivot ); -lapack_int LAPACKE_dgbsvx( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int kl, lapack_int ku, - lapack_int nrhs, double* ab, lapack_int ldab, - double* afb, lapack_int ldafb, lapack_int* ipiv, - char* equed, double* r, double* c, double* b, - lapack_int ldb, double* x, lapack_int ldx, - double* rcond, double* ferr, double* berr, - double* rpivot ); -lapack_int LAPACKE_cgbsvx( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int kl, lapack_int ku, - lapack_int nrhs, lapack_complex_float* ab, - lapack_int ldab, lapack_complex_float* afb, - lapack_int ldafb, lapack_int* ipiv, char* equed, - float* r, float* c, lapack_complex_float* b, - lapack_int ldb, lapack_complex_float* x, - lapack_int ldx, float* rcond, float* ferr, - float* berr, float* rpivot ); -lapack_int LAPACKE_zgbsvx( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int kl, lapack_int ku, - lapack_int nrhs, lapack_complex_double* ab, - lapack_int ldab, lapack_complex_double* afb, - lapack_int ldafb, lapack_int* ipiv, char* equed, - double* r, double* c, lapack_complex_double* b, - lapack_int ldb, lapack_complex_double* x, - lapack_int ldx, double* rcond, double* ferr, - double* berr, double* rpivot ); - -lapack_int LAPACKE_sgbsvxx( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int kl, lapack_int ku, - lapack_int nrhs, float* ab, lapack_int ldab, - float* afb, lapack_int ldafb, lapack_int* ipiv, - char* equed, float* r, float* c, float* b, - lapack_int ldb, float* x, lapack_int ldx, - float* rcond, float* rpvgrw, float* berr, - lapack_int n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int nparams, - float* params ); -lapack_int LAPACKE_dgbsvxx( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int kl, lapack_int ku, - lapack_int nrhs, double* ab, lapack_int ldab, - double* afb, lapack_int ldafb, lapack_int* ipiv, - char* equed, double* r, double* c, double* b, - lapack_int ldb, double* x, lapack_int ldx, - double* rcond, double* rpvgrw, double* berr, - lapack_int n_err_bnds, double* err_bnds_norm, - double* err_bnds_comp, lapack_int nparams, - double* params ); -lapack_int LAPACKE_cgbsvxx( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int kl, lapack_int ku, - lapack_int nrhs, lapack_complex_float* ab, - lapack_int ldab, lapack_complex_float* afb, - lapack_int ldafb, lapack_int* ipiv, char* equed, - float* r, float* c, lapack_complex_float* b, - lapack_int ldb, lapack_complex_float* x, - lapack_int ldx, float* rcond, float* rpvgrw, - float* berr, lapack_int n_err_bnds, - float* err_bnds_norm, float* err_bnds_comp, - lapack_int nparams, float* params ); -lapack_int LAPACKE_zgbsvxx( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int kl, lapack_int ku, - lapack_int nrhs, lapack_complex_double* ab, - lapack_int ldab, lapack_complex_double* afb, - lapack_int ldafb, lapack_int* ipiv, char* equed, - double* r, double* c, lapack_complex_double* b, - lapack_int ldb, lapack_complex_double* x, - lapack_int ldx, double* rcond, double* rpvgrw, - double* berr, lapack_int n_err_bnds, - double* err_bnds_norm, double* err_bnds_comp, - lapack_int nparams, double* params ); - -lapack_int LAPACKE_sgbtrf( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, float* ab, - lapack_int ldab, lapack_int* ipiv ); -lapack_int LAPACKE_dgbtrf( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, double* ab, - lapack_int ldab, lapack_int* ipiv ); -lapack_int LAPACKE_cgbtrf( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, - lapack_complex_float* ab, lapack_int ldab, - lapack_int* ipiv ); -lapack_int LAPACKE_zgbtrf( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, - lapack_complex_double* ab, lapack_int ldab, - lapack_int* ipiv ); - -lapack_int LAPACKE_sgbtrs( int matrix_layout, char trans, lapack_int n, - lapack_int kl, lapack_int ku, lapack_int nrhs, - const float* ab, lapack_int ldab, - const lapack_int* ipiv, float* b, lapack_int ldb ); -lapack_int LAPACKE_dgbtrs( int matrix_layout, char trans, lapack_int n, - lapack_int kl, lapack_int ku, lapack_int nrhs, - const double* ab, lapack_int ldab, - const lapack_int* ipiv, double* b, lapack_int ldb ); -lapack_int LAPACKE_cgbtrs( int matrix_layout, char trans, lapack_int n, - lapack_int kl, lapack_int ku, lapack_int nrhs, - const lapack_complex_float* ab, lapack_int ldab, - const lapack_int* ipiv, lapack_complex_float* b, - lapack_int ldb ); -lapack_int LAPACKE_zgbtrs( int matrix_layout, char trans, lapack_int n, - lapack_int kl, lapack_int ku, lapack_int nrhs, - const lapack_complex_double* ab, lapack_int ldab, - const lapack_int* ipiv, lapack_complex_double* b, - lapack_int ldb ); - -lapack_int LAPACKE_sgebak( int matrix_layout, char job, char side, lapack_int n, - lapack_int ilo, lapack_int ihi, const float* scale, - lapack_int m, float* v, lapack_int ldv ); -lapack_int LAPACKE_dgebak( int matrix_layout, char job, char side, lapack_int n, - lapack_int ilo, lapack_int ihi, const double* scale, - lapack_int m, double* v, lapack_int ldv ); -lapack_int LAPACKE_cgebak( int matrix_layout, char job, char side, lapack_int n, - lapack_int ilo, lapack_int ihi, const float* scale, - lapack_int m, lapack_complex_float* v, - lapack_int ldv ); -lapack_int LAPACKE_zgebak( int matrix_layout, char job, char side, lapack_int n, - lapack_int ilo, lapack_int ihi, const double* scale, - lapack_int m, lapack_complex_double* v, - lapack_int ldv ); - -lapack_int LAPACKE_sgebal( int matrix_layout, char job, lapack_int n, float* a, - lapack_int lda, lapack_int* ilo, lapack_int* ihi, - float* scale ); -lapack_int LAPACKE_dgebal( int matrix_layout, char job, lapack_int n, double* a, - lapack_int lda, lapack_int* ilo, lapack_int* ihi, - double* scale ); -lapack_int LAPACKE_cgebal( int matrix_layout, char job, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int* ilo, lapack_int* ihi, float* scale ); -lapack_int LAPACKE_zgebal( int matrix_layout, char job, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int* ilo, lapack_int* ihi, double* scale ); - -lapack_int LAPACKE_sgebrd( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, float* d, float* e, - float* tauq, float* taup ); -lapack_int LAPACKE_dgebrd( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, double* d, double* e, - double* tauq, double* taup ); -lapack_int LAPACKE_cgebrd( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, float* d, - float* e, lapack_complex_float* tauq, - lapack_complex_float* taup ); -lapack_int LAPACKE_zgebrd( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, double* d, - double* e, lapack_complex_double* tauq, - lapack_complex_double* taup ); - -lapack_int LAPACKE_sgecon( int matrix_layout, char norm, lapack_int n, - const float* a, lapack_int lda, float anorm, - float* rcond ); -lapack_int LAPACKE_dgecon( int matrix_layout, char norm, lapack_int n, - const double* a, lapack_int lda, double anorm, - double* rcond ); -lapack_int LAPACKE_cgecon( int matrix_layout, char norm, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - float anorm, float* rcond ); -lapack_int LAPACKE_zgecon( int matrix_layout, char norm, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - double anorm, double* rcond ); - -lapack_int LAPACKE_sgeequ( int matrix_layout, lapack_int m, lapack_int n, - const float* a, lapack_int lda, float* r, float* c, - float* rowcnd, float* colcnd, float* amax ); -lapack_int LAPACKE_dgeequ( int matrix_layout, lapack_int m, lapack_int n, - const double* a, lapack_int lda, double* r, - double* c, double* rowcnd, double* colcnd, - double* amax ); -lapack_int LAPACKE_cgeequ( int matrix_layout, lapack_int m, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - float* r, float* c, float* rowcnd, float* colcnd, - float* amax ); -lapack_int LAPACKE_zgeequ( int matrix_layout, lapack_int m, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - double* r, double* c, double* rowcnd, double* colcnd, - double* amax ); - -lapack_int LAPACKE_sgeequb( int matrix_layout, lapack_int m, lapack_int n, - const float* a, lapack_int lda, float* r, float* c, - float* rowcnd, float* colcnd, float* amax ); -lapack_int LAPACKE_dgeequb( int matrix_layout, lapack_int m, lapack_int n, - const double* a, lapack_int lda, double* r, - double* c, double* rowcnd, double* colcnd, - double* amax ); -lapack_int LAPACKE_cgeequb( int matrix_layout, lapack_int m, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - float* r, float* c, float* rowcnd, float* colcnd, - float* amax ); -lapack_int LAPACKE_zgeequb( int matrix_layout, lapack_int m, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - double* r, double* c, double* rowcnd, - double* colcnd, double* amax ); - -lapack_int LAPACKE_sgees( int matrix_layout, char jobvs, char sort, - LAPACK_S_SELECT2 select, lapack_int n, float* a, - lapack_int lda, lapack_int* sdim, float* wr, - float* wi, float* vs, lapack_int ldvs ); -lapack_int LAPACKE_dgees( int matrix_layout, char jobvs, char sort, - LAPACK_D_SELECT2 select, lapack_int n, double* a, - lapack_int lda, lapack_int* sdim, double* wr, - double* wi, double* vs, lapack_int ldvs ); -lapack_int LAPACKE_cgees( int matrix_layout, char jobvs, char sort, - LAPACK_C_SELECT1 select, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int* sdim, lapack_complex_float* w, - lapack_complex_float* vs, lapack_int ldvs ); -lapack_int LAPACKE_zgees( int matrix_layout, char jobvs, char sort, - LAPACK_Z_SELECT1 select, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int* sdim, lapack_complex_double* w, - lapack_complex_double* vs, lapack_int ldvs ); - -lapack_int LAPACKE_sgeesx( int matrix_layout, char jobvs, char sort, - LAPACK_S_SELECT2 select, char sense, lapack_int n, - float* a, lapack_int lda, lapack_int* sdim, - float* wr, float* wi, float* vs, lapack_int ldvs, - float* rconde, float* rcondv ); -lapack_int LAPACKE_dgeesx( int matrix_layout, char jobvs, char sort, - LAPACK_D_SELECT2 select, char sense, lapack_int n, - double* a, lapack_int lda, lapack_int* sdim, - double* wr, double* wi, double* vs, lapack_int ldvs, - double* rconde, double* rcondv ); -lapack_int LAPACKE_cgeesx( int matrix_layout, char jobvs, char sort, - LAPACK_C_SELECT1 select, char sense, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int* sdim, lapack_complex_float* w, - lapack_complex_float* vs, lapack_int ldvs, - float* rconde, float* rcondv ); -lapack_int LAPACKE_zgeesx( int matrix_layout, char jobvs, char sort, - LAPACK_Z_SELECT1 select, char sense, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int* sdim, lapack_complex_double* w, - lapack_complex_double* vs, lapack_int ldvs, - double* rconde, double* rcondv ); - -lapack_int LAPACKE_sgeev( int matrix_layout, char jobvl, char jobvr, - lapack_int n, float* a, lapack_int lda, float* wr, - float* wi, float* vl, lapack_int ldvl, float* vr, - lapack_int ldvr ); -lapack_int LAPACKE_dgeev( int matrix_layout, char jobvl, char jobvr, - lapack_int n, double* a, lapack_int lda, double* wr, - double* wi, double* vl, lapack_int ldvl, double* vr, - lapack_int ldvr ); -lapack_int LAPACKE_cgeev( int matrix_layout, char jobvl, char jobvr, - lapack_int n, lapack_complex_float* a, lapack_int lda, - lapack_complex_float* w, lapack_complex_float* vl, - lapack_int ldvl, lapack_complex_float* vr, - lapack_int ldvr ); -lapack_int LAPACKE_zgeev( int matrix_layout, char jobvl, char jobvr, - lapack_int n, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* w, - lapack_complex_double* vl, lapack_int ldvl, - lapack_complex_double* vr, lapack_int ldvr ); - -lapack_int LAPACKE_sgeevx( int matrix_layout, char balanc, char jobvl, - char jobvr, char sense, lapack_int n, float* a, - lapack_int lda, float* wr, float* wi, float* vl, - lapack_int ldvl, float* vr, lapack_int ldvr, - lapack_int* ilo, lapack_int* ihi, float* scale, - float* abnrm, float* rconde, float* rcondv ); -lapack_int LAPACKE_dgeevx( int matrix_layout, char balanc, char jobvl, - char jobvr, char sense, lapack_int n, double* a, - lapack_int lda, double* wr, double* wi, double* vl, - lapack_int ldvl, double* vr, lapack_int ldvr, - lapack_int* ilo, lapack_int* ihi, double* scale, - double* abnrm, double* rconde, double* rcondv ); -lapack_int LAPACKE_cgeevx( int matrix_layout, char balanc, char jobvl, - char jobvr, char sense, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* w, lapack_complex_float* vl, - lapack_int ldvl, lapack_complex_float* vr, - lapack_int ldvr, lapack_int* ilo, lapack_int* ihi, - float* scale, float* abnrm, float* rconde, - float* rcondv ); -lapack_int LAPACKE_zgeevx( int matrix_layout, char balanc, char jobvl, - char jobvr, char sense, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* w, lapack_complex_double* vl, - lapack_int ldvl, lapack_complex_double* vr, - lapack_int ldvr, lapack_int* ilo, lapack_int* ihi, - double* scale, double* abnrm, double* rconde, - double* rcondv ); - -lapack_int LAPACKE_sgehrd( int matrix_layout, lapack_int n, lapack_int ilo, - lapack_int ihi, float* a, lapack_int lda, - float* tau ); -lapack_int LAPACKE_dgehrd( int matrix_layout, lapack_int n, lapack_int ilo, - lapack_int ihi, double* a, lapack_int lda, - double* tau ); -lapack_int LAPACKE_cgehrd( int matrix_layout, lapack_int n, lapack_int ilo, - lapack_int ihi, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* tau ); -lapack_int LAPACKE_zgehrd( int matrix_layout, lapack_int n, lapack_int ilo, - lapack_int ihi, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* tau ); - -lapack_int LAPACKE_sgejsv( int matrix_layout, char joba, char jobu, char jobv, - char jobr, char jobt, char jobp, lapack_int m, - lapack_int n, float* a, lapack_int lda, float* sva, - float* u, lapack_int ldu, float* v, lapack_int ldv, - float* stat, lapack_int* istat ); -lapack_int LAPACKE_dgejsv( int matrix_layout, char joba, char jobu, char jobv, - char jobr, char jobt, char jobp, lapack_int m, - lapack_int n, double* a, lapack_int lda, double* sva, - double* u, lapack_int ldu, double* v, lapack_int ldv, - double* stat, lapack_int* istat ); -lapack_int LAPACKE_cgejsv( int matrix_layout, char joba, char jobu, char jobv, - char jobr, char jobt, char jobp, lapack_int m, - lapack_int n, lapack_complex_float* a, lapack_int lda, float* sva, - lapack_complex_float* u, lapack_int ldu, lapack_complex_float* v, lapack_int ldv, - float* stat, lapack_int* istat ); -lapack_int LAPACKE_zgejsv( int matrix_layout, char joba, char jobu, char jobv, - char jobr, char jobt, char jobp, lapack_int m, - lapack_int n, lapack_complex_double* a, lapack_int lda, double* sva, - lapack_complex_double* u, lapack_int ldu, lapack_complex_double* v, lapack_int ldv, - double* stat, lapack_int* istat ); - -lapack_int LAPACKE_sgelq2( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, float* tau ); -lapack_int LAPACKE_dgelq2( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, double* tau ); -lapack_int LAPACKE_cgelq2( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* tau ); -lapack_int LAPACKE_zgelq2( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* tau ); - -lapack_int LAPACKE_sgelqf( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, float* tau ); -lapack_int LAPACKE_dgelqf( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, double* tau ); -lapack_int LAPACKE_cgelqf( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* tau ); -lapack_int LAPACKE_zgelqf( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* tau ); - -lapack_int LAPACKE_sgels( int matrix_layout, char trans, lapack_int m, - lapack_int n, lapack_int nrhs, float* a, - lapack_int lda, float* b, lapack_int ldb ); -lapack_int LAPACKE_dgels( int matrix_layout, char trans, lapack_int m, - lapack_int n, lapack_int nrhs, double* a, - lapack_int lda, double* b, lapack_int ldb ); -lapack_int LAPACKE_cgels( int matrix_layout, char trans, lapack_int m, - lapack_int n, lapack_int nrhs, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zgels( int matrix_layout, char trans, lapack_int m, - lapack_int n, lapack_int nrhs, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_sgelsd( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nrhs, float* a, lapack_int lda, float* b, - lapack_int ldb, float* s, float rcond, - lapack_int* rank ); -lapack_int LAPACKE_dgelsd( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nrhs, double* a, lapack_int lda, - double* b, lapack_int ldb, double* s, double rcond, - lapack_int* rank ); -lapack_int LAPACKE_cgelsd( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* b, - lapack_int ldb, float* s, float rcond, - lapack_int* rank ); -lapack_int LAPACKE_zgelsd( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* b, - lapack_int ldb, double* s, double rcond, - lapack_int* rank ); - -lapack_int LAPACKE_sgelss( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nrhs, float* a, lapack_int lda, float* b, - lapack_int ldb, float* s, float rcond, - lapack_int* rank ); -lapack_int LAPACKE_dgelss( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nrhs, double* a, lapack_int lda, - double* b, lapack_int ldb, double* s, double rcond, - lapack_int* rank ); -lapack_int LAPACKE_cgelss( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* b, - lapack_int ldb, float* s, float rcond, - lapack_int* rank ); -lapack_int LAPACKE_zgelss( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* b, - lapack_int ldb, double* s, double rcond, - lapack_int* rank ); - -lapack_int LAPACKE_sgelsy( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nrhs, float* a, lapack_int lda, float* b, - lapack_int ldb, lapack_int* jpvt, float rcond, - lapack_int* rank ); -lapack_int LAPACKE_dgelsy( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nrhs, double* a, lapack_int lda, - double* b, lapack_int ldb, lapack_int* jpvt, - double rcond, lapack_int* rank ); -lapack_int LAPACKE_cgelsy( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* b, - lapack_int ldb, lapack_int* jpvt, float rcond, - lapack_int* rank ); -lapack_int LAPACKE_zgelsy( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* b, - lapack_int ldb, lapack_int* jpvt, double rcond, - lapack_int* rank ); - -lapack_int LAPACKE_sgeqlf( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, float* tau ); -lapack_int LAPACKE_dgeqlf( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, double* tau ); -lapack_int LAPACKE_cgeqlf( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* tau ); -lapack_int LAPACKE_zgeqlf( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* tau ); - -lapack_int LAPACKE_sgeqp3( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, lapack_int* jpvt, - float* tau ); -lapack_int LAPACKE_dgeqp3( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, lapack_int* jpvt, - double* tau ); -lapack_int LAPACKE_cgeqp3( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int* jpvt, lapack_complex_float* tau ); -lapack_int LAPACKE_zgeqp3( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int* jpvt, lapack_complex_double* tau ); - -lapack_int LAPACKE_sgeqpf( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, lapack_int* jpvt, - float* tau ); -lapack_int LAPACKE_dgeqpf( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, lapack_int* jpvt, - double* tau ); -lapack_int LAPACKE_cgeqpf( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int* jpvt, lapack_complex_float* tau ); -lapack_int LAPACKE_zgeqpf( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int* jpvt, lapack_complex_double* tau ); - -lapack_int LAPACKE_sgeqr2( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, float* tau ); -lapack_int LAPACKE_dgeqr2( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, double* tau ); -lapack_int LAPACKE_cgeqr2( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* tau ); -lapack_int LAPACKE_zgeqr2( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* tau ); - -lapack_int LAPACKE_sgeqrf( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, float* tau ); -lapack_int LAPACKE_dgeqrf( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, double* tau ); -lapack_int LAPACKE_cgeqrf( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* tau ); -lapack_int LAPACKE_zgeqrf( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* tau ); - -lapack_int LAPACKE_sgeqrfp( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, float* tau ); -lapack_int LAPACKE_dgeqrfp( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, double* tau ); -lapack_int LAPACKE_cgeqrfp( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* tau ); -lapack_int LAPACKE_zgeqrfp( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* tau ); - -lapack_int LAPACKE_sgerfs( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const float* a, lapack_int lda, - const float* af, lapack_int ldaf, - const lapack_int* ipiv, const float* b, - lapack_int ldb, float* x, lapack_int ldx, - float* ferr, float* berr ); -lapack_int LAPACKE_dgerfs( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const double* a, lapack_int lda, - const double* af, lapack_int ldaf, - const lapack_int* ipiv, const double* b, - lapack_int ldb, double* x, lapack_int ldx, - double* ferr, double* berr ); -lapack_int LAPACKE_cgerfs( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* af, - lapack_int ldaf, const lapack_int* ipiv, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, float* ferr, - float* berr ); -lapack_int LAPACKE_zgerfs( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_complex_double* af, - lapack_int ldaf, const lapack_int* ipiv, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* ferr, double* berr ); - -lapack_int LAPACKE_sgerfsx( int matrix_layout, char trans, char equed, - lapack_int n, lapack_int nrhs, const float* a, - lapack_int lda, const float* af, lapack_int ldaf, - const lapack_int* ipiv, const float* r, - const float* c, const float* b, lapack_int ldb, - float* x, lapack_int ldx, float* rcond, float* berr, - lapack_int n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int nparams, - float* params ); -lapack_int LAPACKE_dgerfsx( int matrix_layout, char trans, char equed, - lapack_int n, lapack_int nrhs, const double* a, - lapack_int lda, const double* af, lapack_int ldaf, - const lapack_int* ipiv, const double* r, - const double* c, const double* b, lapack_int ldb, - double* x, lapack_int ldx, double* rcond, - double* berr, lapack_int n_err_bnds, - double* err_bnds_norm, double* err_bnds_comp, - lapack_int nparams, double* params ); -lapack_int LAPACKE_cgerfsx( int matrix_layout, char trans, char equed, - lapack_int n, lapack_int nrhs, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* af, lapack_int ldaf, - const lapack_int* ipiv, const float* r, - const float* c, const lapack_complex_float* b, - lapack_int ldb, lapack_complex_float* x, - lapack_int ldx, float* rcond, float* berr, - lapack_int n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int nparams, - float* params ); -lapack_int LAPACKE_zgerfsx( int matrix_layout, char trans, char equed, - lapack_int n, lapack_int nrhs, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* af, lapack_int ldaf, - const lapack_int* ipiv, const double* r, - const double* c, const lapack_complex_double* b, - lapack_int ldb, lapack_complex_double* x, - lapack_int ldx, double* rcond, double* berr, - lapack_int n_err_bnds, double* err_bnds_norm, - double* err_bnds_comp, lapack_int nparams, - double* params ); - -lapack_int LAPACKE_sgerqf( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, float* tau ); -lapack_int LAPACKE_dgerqf( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, double* tau ); -lapack_int LAPACKE_cgerqf( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* tau ); -lapack_int LAPACKE_zgerqf( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* tau ); - -lapack_int LAPACKE_sgesdd( int matrix_layout, char jobz, lapack_int m, - lapack_int n, float* a, lapack_int lda, float* s, - float* u, lapack_int ldu, float* vt, - lapack_int ldvt ); -lapack_int LAPACKE_dgesdd( int matrix_layout, char jobz, lapack_int m, - lapack_int n, double* a, lapack_int lda, double* s, - double* u, lapack_int ldu, double* vt, - lapack_int ldvt ); -lapack_int LAPACKE_cgesdd( int matrix_layout, char jobz, lapack_int m, - lapack_int n, lapack_complex_float* a, - lapack_int lda, float* s, lapack_complex_float* u, - lapack_int ldu, lapack_complex_float* vt, - lapack_int ldvt ); -lapack_int LAPACKE_zgesdd( int matrix_layout, char jobz, lapack_int m, - lapack_int n, lapack_complex_double* a, - lapack_int lda, double* s, lapack_complex_double* u, - lapack_int ldu, lapack_complex_double* vt, - lapack_int ldvt ); - -lapack_int LAPACKE_sgesv( int matrix_layout, lapack_int n, lapack_int nrhs, - float* a, lapack_int lda, lapack_int* ipiv, float* b, - lapack_int ldb ); -lapack_int LAPACKE_dgesv( int matrix_layout, lapack_int n, lapack_int nrhs, - double* a, lapack_int lda, lapack_int* ipiv, - double* b, lapack_int ldb ); -lapack_int LAPACKE_cgesv( int matrix_layout, lapack_int n, lapack_int nrhs, - lapack_complex_float* a, lapack_int lda, - lapack_int* ipiv, lapack_complex_float* b, - lapack_int ldb ); -lapack_int LAPACKE_zgesv( int matrix_layout, lapack_int n, lapack_int nrhs, - lapack_complex_double* a, lapack_int lda, - lapack_int* ipiv, lapack_complex_double* b, - lapack_int ldb ); -lapack_int LAPACKE_dsgesv( int matrix_layout, lapack_int n, lapack_int nrhs, - double* a, lapack_int lda, lapack_int* ipiv, - double* b, lapack_int ldb, double* x, lapack_int ldx, - lapack_int* iter ); -lapack_int LAPACKE_zcgesv( int matrix_layout, lapack_int n, lapack_int nrhs, - lapack_complex_double* a, lapack_int lda, - lapack_int* ipiv, lapack_complex_double* b, - lapack_int ldb, lapack_complex_double* x, - lapack_int ldx, lapack_int* iter ); - -lapack_int LAPACKE_sgesvd( int matrix_layout, char jobu, char jobvt, - lapack_int m, lapack_int n, float* a, lapack_int lda, - float* s, float* u, lapack_int ldu, float* vt, - lapack_int ldvt, float* superb ); -lapack_int LAPACKE_dgesvd( int matrix_layout, char jobu, char jobvt, - lapack_int m, lapack_int n, double* a, - lapack_int lda, double* s, double* u, lapack_int ldu, - double* vt, lapack_int ldvt, double* superb ); -lapack_int LAPACKE_cgesvd( int matrix_layout, char jobu, char jobvt, - lapack_int m, lapack_int n, lapack_complex_float* a, - lapack_int lda, float* s, lapack_complex_float* u, - lapack_int ldu, lapack_complex_float* vt, - lapack_int ldvt, float* superb ); -lapack_int LAPACKE_zgesvd( int matrix_layout, char jobu, char jobvt, - lapack_int m, lapack_int n, lapack_complex_double* a, - lapack_int lda, double* s, lapack_complex_double* u, - lapack_int ldu, lapack_complex_double* vt, - lapack_int ldvt, double* superb ); - -lapack_int LAPACKE_sgesvdx( int matrix_layout, char jobu, char jobvt, char range, - lapack_int m, lapack_int n, float* a, - lapack_int lda, float vl, float vu, - lapack_int il, lapack_int iu, lapack_int* ns, - float* s, float* u, lapack_int ldu, - float* vt, lapack_int ldvt, - lapack_int* superb ); -lapack_int LAPACKE_dgesvdx( int matrix_layout, char jobu, char jobvt, char range, - lapack_int m, lapack_int n, double* a, - lapack_int lda, double vl, double vu, - lapack_int il, lapack_int iu, lapack_int* ns, - double* s, double* u, lapack_int ldu, - double* vt, lapack_int ldvt, - lapack_int* superb ); -lapack_int LAPACKE_cgesvdx( int matrix_layout, char jobu, char jobvt, char range, - lapack_int m, lapack_int n, lapack_complex_float* a, - lapack_int lda, float vl, float vu, - lapack_int il, lapack_int iu, lapack_int* ns, - float* s, lapack_complex_float* u, lapack_int ldu, - lapack_complex_float* vt, lapack_int ldvt, - lapack_int* superb ); -lapack_int LAPACKE_zgesvdx( int matrix_layout, char jobu, char jobvt, char range, - lapack_int m, lapack_int n, lapack_complex_double* a, - lapack_int lda, double vl, double vu, - lapack_int il, lapack_int iu, lapack_int* ns, - double* s, lapack_complex_double* u, lapack_int ldu, - lapack_complex_double* vt, lapack_int ldvt, - lapack_int* superb ); - -lapack_int LAPACKE_sgesvj( int matrix_layout, char joba, char jobu, char jobv, - lapack_int m, lapack_int n, float* a, lapack_int lda, - float* sva, lapack_int mv, float* v, lapack_int ldv, - float* stat ); -lapack_int LAPACKE_dgesvj( int matrix_layout, char joba, char jobu, char jobv, - lapack_int m, lapack_int n, double* a, - lapack_int lda, double* sva, lapack_int mv, - double* v, lapack_int ldv, double* stat ); -lapack_int LAPACKE_cgesvj( int matrix_layout, char joba, char jobu, char jobv, - lapack_int m, lapack_int n, lapack_complex_float* a, - lapack_int lda, float* sva, lapack_int mv, - lapack_complex_float* v, lapack_int ldv, float* stat ); -lapack_int LAPACKE_zgesvj( int matrix_layout, char joba, char jobu, char jobv, - lapack_int m, lapack_int n, lapack_complex_double* a, - lapack_int lda, double* sva, lapack_int mv, - lapack_complex_double* v, lapack_int ldv, double* stat ); - -lapack_int LAPACKE_sgesvx( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int nrhs, float* a, - lapack_int lda, float* af, lapack_int ldaf, - lapack_int* ipiv, char* equed, float* r, float* c, - float* b, lapack_int ldb, float* x, lapack_int ldx, - float* rcond, float* ferr, float* berr, - float* rpivot ); -lapack_int LAPACKE_dgesvx( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int nrhs, double* a, - lapack_int lda, double* af, lapack_int ldaf, - lapack_int* ipiv, char* equed, double* r, double* c, - double* b, lapack_int ldb, double* x, lapack_int ldx, - double* rcond, double* ferr, double* berr, - double* rpivot ); -lapack_int LAPACKE_cgesvx( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int nrhs, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* af, lapack_int ldaf, - lapack_int* ipiv, char* equed, float* r, float* c, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* rcond, float* ferr, float* berr, - float* rpivot ); -lapack_int LAPACKE_zgesvx( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int nrhs, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* af, lapack_int ldaf, - lapack_int* ipiv, char* equed, double* r, double* c, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* ferr, double* berr, - double* rpivot ); - -lapack_int LAPACKE_sgesvxx( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int nrhs, float* a, - lapack_int lda, float* af, lapack_int ldaf, - lapack_int* ipiv, char* equed, float* r, float* c, - float* b, lapack_int ldb, float* x, lapack_int ldx, - float* rcond, float* rpvgrw, float* berr, - lapack_int n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int nparams, - float* params ); -lapack_int LAPACKE_dgesvxx( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int nrhs, double* a, - lapack_int lda, double* af, lapack_int ldaf, - lapack_int* ipiv, char* equed, double* r, double* c, - double* b, lapack_int ldb, double* x, - lapack_int ldx, double* rcond, double* rpvgrw, - double* berr, lapack_int n_err_bnds, - double* err_bnds_norm, double* err_bnds_comp, - lapack_int nparams, double* params ); -lapack_int LAPACKE_cgesvxx( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int nrhs, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* af, lapack_int ldaf, - lapack_int* ipiv, char* equed, float* r, float* c, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* rcond, float* rpvgrw, float* berr, - lapack_int n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int nparams, - float* params ); -lapack_int LAPACKE_zgesvxx( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int nrhs, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* af, lapack_int ldaf, - lapack_int* ipiv, char* equed, double* r, double* c, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* rpvgrw, double* berr, - lapack_int n_err_bnds, double* err_bnds_norm, - double* err_bnds_comp, lapack_int nparams, - double* params ); - -lapack_int LAPACKE_sgetf2( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, lapack_int* ipiv ); -lapack_int LAPACKE_dgetf2( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, lapack_int* ipiv ); -lapack_int LAPACKE_cgetf2( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int* ipiv ); -lapack_int LAPACKE_zgetf2( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int* ipiv ); - -lapack_int LAPACKE_sgetrf( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, lapack_int* ipiv ); -lapack_int LAPACKE_dgetrf( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, lapack_int* ipiv ); -lapack_int LAPACKE_cgetrf( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int* ipiv ); -lapack_int LAPACKE_zgetrf( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int* ipiv ); - -lapack_int LAPACKE_sgetrf2( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, lapack_int* ipiv ); -lapack_int LAPACKE_dgetrf2( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, lapack_int* ipiv ); -lapack_int LAPACKE_cgetrf2( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int* ipiv ); -lapack_int LAPACKE_zgetrf2( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int* ipiv ); - -lapack_int LAPACKE_sgetri( int matrix_layout, lapack_int n, float* a, - lapack_int lda, const lapack_int* ipiv ); -lapack_int LAPACKE_dgetri( int matrix_layout, lapack_int n, double* a, - lapack_int lda, const lapack_int* ipiv ); -lapack_int LAPACKE_cgetri( int matrix_layout, lapack_int n, - lapack_complex_float* a, lapack_int lda, - const lapack_int* ipiv ); -lapack_int LAPACKE_zgetri( int matrix_layout, lapack_int n, - lapack_complex_double* a, lapack_int lda, - const lapack_int* ipiv ); - -lapack_int LAPACKE_sgetrs( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const float* a, lapack_int lda, - const lapack_int* ipiv, float* b, lapack_int ldb ); -lapack_int LAPACKE_dgetrs( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const double* a, lapack_int lda, - const lapack_int* ipiv, double* b, lapack_int ldb ); -lapack_int LAPACKE_cgetrs( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zgetrs( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_sggbak( int matrix_layout, char job, char side, lapack_int n, - lapack_int ilo, lapack_int ihi, const float* lscale, - const float* rscale, lapack_int m, float* v, - lapack_int ldv ); -lapack_int LAPACKE_dggbak( int matrix_layout, char job, char side, lapack_int n, - lapack_int ilo, lapack_int ihi, const double* lscale, - const double* rscale, lapack_int m, double* v, - lapack_int ldv ); -lapack_int LAPACKE_cggbak( int matrix_layout, char job, char side, lapack_int n, - lapack_int ilo, lapack_int ihi, const float* lscale, - const float* rscale, lapack_int m, - lapack_complex_float* v, lapack_int ldv ); -lapack_int LAPACKE_zggbak( int matrix_layout, char job, char side, lapack_int n, - lapack_int ilo, lapack_int ihi, const double* lscale, - const double* rscale, lapack_int m, - lapack_complex_double* v, lapack_int ldv ); - -lapack_int LAPACKE_sggbal( int matrix_layout, char job, lapack_int n, float* a, - lapack_int lda, float* b, lapack_int ldb, - lapack_int* ilo, lapack_int* ihi, float* lscale, - float* rscale ); -lapack_int LAPACKE_dggbal( int matrix_layout, char job, lapack_int n, double* a, - lapack_int lda, double* b, lapack_int ldb, - lapack_int* ilo, lapack_int* ihi, double* lscale, - double* rscale ); -lapack_int LAPACKE_cggbal( int matrix_layout, char job, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - lapack_int* ilo, lapack_int* ihi, float* lscale, - float* rscale ); -lapack_int LAPACKE_zggbal( int matrix_layout, char job, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - lapack_int* ilo, lapack_int* ihi, double* lscale, - double* rscale ); - -lapack_int LAPACKE_sgges( int matrix_layout, char jobvsl, char jobvsr, char sort, - LAPACK_S_SELECT3 selctg, lapack_int n, float* a, - lapack_int lda, float* b, lapack_int ldb, - lapack_int* sdim, float* alphar, float* alphai, - float* beta, float* vsl, lapack_int ldvsl, float* vsr, - lapack_int ldvsr ); -lapack_int LAPACKE_dgges( int matrix_layout, char jobvsl, char jobvsr, char sort, - LAPACK_D_SELECT3 selctg, lapack_int n, double* a, - lapack_int lda, double* b, lapack_int ldb, - lapack_int* sdim, double* alphar, double* alphai, - double* beta, double* vsl, lapack_int ldvsl, - double* vsr, lapack_int ldvsr ); -lapack_int LAPACKE_cgges( int matrix_layout, char jobvsl, char jobvsr, char sort, - LAPACK_C_SELECT2 selctg, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - lapack_int* sdim, lapack_complex_float* alpha, - lapack_complex_float* beta, lapack_complex_float* vsl, - lapack_int ldvsl, lapack_complex_float* vsr, - lapack_int ldvsr ); -lapack_int LAPACKE_zgges( int matrix_layout, char jobvsl, char jobvsr, char sort, - LAPACK_Z_SELECT2 selctg, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - lapack_int* sdim, lapack_complex_double* alpha, - lapack_complex_double* beta, - lapack_complex_double* vsl, lapack_int ldvsl, - lapack_complex_double* vsr, lapack_int ldvsr ); - -lapack_int LAPACKE_sgges3( int matrix_layout, char jobvsl, char jobvsr, - char sort, LAPACK_S_SELECT3 selctg, lapack_int n, - float* a, lapack_int lda, float* b, lapack_int ldb, - lapack_int* sdim, float* alphar, float* alphai, - float* beta, float* vsl, lapack_int ldvsl, - float* vsr, lapack_int ldvsr ); -lapack_int LAPACKE_dgges3( int matrix_layout, char jobvsl, char jobvsr, - char sort, LAPACK_D_SELECT3 selctg, lapack_int n, - double* a, lapack_int lda, double* b, lapack_int ldb, - lapack_int* sdim, double* alphar, double* alphai, - double* beta, double* vsl, lapack_int ldvsl, - double* vsr, lapack_int ldvsr ); -lapack_int LAPACKE_cgges3( int matrix_layout, char jobvsl, char jobvsr, - char sort, LAPACK_C_SELECT2 selctg, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - lapack_int* sdim, lapack_complex_float* alpha, - lapack_complex_float* beta, - lapack_complex_float* vsl, lapack_int ldvsl, - lapack_complex_float* vsr, lapack_int ldvsr ); -lapack_int LAPACKE_zgges3( int matrix_layout, char jobvsl, char jobvsr, - char sort, LAPACK_Z_SELECT2 selctg, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - lapack_int* sdim, lapack_complex_double* alpha, - lapack_complex_double* beta, - lapack_complex_double* vsl, lapack_int ldvsl, - lapack_complex_double* vsr, lapack_int ldvsr ); - -lapack_int LAPACKE_sggesx( int matrix_layout, char jobvsl, char jobvsr, - char sort, LAPACK_S_SELECT3 selctg, char sense, - lapack_int n, float* a, lapack_int lda, float* b, - lapack_int ldb, lapack_int* sdim, float* alphar, - float* alphai, float* beta, float* vsl, - lapack_int ldvsl, float* vsr, lapack_int ldvsr, - float* rconde, float* rcondv ); -lapack_int LAPACKE_dggesx( int matrix_layout, char jobvsl, char jobvsr, - char sort, LAPACK_D_SELECT3 selctg, char sense, - lapack_int n, double* a, lapack_int lda, double* b, - lapack_int ldb, lapack_int* sdim, double* alphar, - double* alphai, double* beta, double* vsl, - lapack_int ldvsl, double* vsr, lapack_int ldvsr, - double* rconde, double* rcondv ); -lapack_int LAPACKE_cggesx( int matrix_layout, char jobvsl, char jobvsr, - char sort, LAPACK_C_SELECT2 selctg, char sense, - lapack_int n, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* b, - lapack_int ldb, lapack_int* sdim, - lapack_complex_float* alpha, - lapack_complex_float* beta, - lapack_complex_float* vsl, lapack_int ldvsl, - lapack_complex_float* vsr, lapack_int ldvsr, - float* rconde, float* rcondv ); -lapack_int LAPACKE_zggesx( int matrix_layout, char jobvsl, char jobvsr, - char sort, LAPACK_Z_SELECT2 selctg, char sense, - lapack_int n, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* b, - lapack_int ldb, lapack_int* sdim, - lapack_complex_double* alpha, - lapack_complex_double* beta, - lapack_complex_double* vsl, lapack_int ldvsl, - lapack_complex_double* vsr, lapack_int ldvsr, - double* rconde, double* rcondv ); - -lapack_int LAPACKE_sggev( int matrix_layout, char jobvl, char jobvr, - lapack_int n, float* a, lapack_int lda, float* b, - lapack_int ldb, float* alphar, float* alphai, - float* beta, float* vl, lapack_int ldvl, float* vr, - lapack_int ldvr ); -lapack_int LAPACKE_dggev( int matrix_layout, char jobvl, char jobvr, - lapack_int n, double* a, lapack_int lda, double* b, - lapack_int ldb, double* alphar, double* alphai, - double* beta, double* vl, lapack_int ldvl, double* vr, - lapack_int ldvr ); -lapack_int LAPACKE_cggev( int matrix_layout, char jobvl, char jobvr, - lapack_int n, lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* alpha, - lapack_complex_float* beta, lapack_complex_float* vl, - lapack_int ldvl, lapack_complex_float* vr, - lapack_int ldvr ); -lapack_int LAPACKE_zggev( int matrix_layout, char jobvl, char jobvr, - lapack_int n, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* b, - lapack_int ldb, lapack_complex_double* alpha, - lapack_complex_double* beta, - lapack_complex_double* vl, lapack_int ldvl, - lapack_complex_double* vr, lapack_int ldvr ); - -lapack_int LAPACKE_sggev3( int matrix_layout, char jobvl, char jobvr, - lapack_int n, float* a, lapack_int lda, - float* b, lapack_int ldb, - float* alphar, float* alphai, float* beta, - float* vl, lapack_int ldvl, - float* vr, lapack_int ldvr ); -lapack_int LAPACKE_dggev3( int matrix_layout, char jobvl, char jobvr, - lapack_int n, double* a, lapack_int lda, - double* b, lapack_int ldb, - double* alphar, double* alphai, double* beta, - double* vl, lapack_int ldvl, - double* vr, lapack_int ldvr ); -lapack_int LAPACKE_cggev3( int matrix_layout, char jobvl, char jobvr, - lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* alpha, - lapack_complex_float* beta, - lapack_complex_float* vl, lapack_int ldvl, - lapack_complex_float* vr, lapack_int ldvr ); -lapack_int LAPACKE_zggev3( int matrix_layout, char jobvl, char jobvr, - lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* alpha, - lapack_complex_double* beta, - lapack_complex_double* vl, lapack_int ldvl, - lapack_complex_double* vr, lapack_int ldvr ); - -lapack_int LAPACKE_sggevx( int matrix_layout, char balanc, char jobvl, - char jobvr, char sense, lapack_int n, float* a, - lapack_int lda, float* b, lapack_int ldb, - float* alphar, float* alphai, float* beta, float* vl, - lapack_int ldvl, float* vr, lapack_int ldvr, - lapack_int* ilo, lapack_int* ihi, float* lscale, - float* rscale, float* abnrm, float* bbnrm, - float* rconde, float* rcondv ); -lapack_int LAPACKE_dggevx( int matrix_layout, char balanc, char jobvl, - char jobvr, char sense, lapack_int n, double* a, - lapack_int lda, double* b, lapack_int ldb, - double* alphar, double* alphai, double* beta, - double* vl, lapack_int ldvl, double* vr, - lapack_int ldvr, lapack_int* ilo, lapack_int* ihi, - double* lscale, double* rscale, double* abnrm, - double* bbnrm, double* rconde, double* rcondv ); -lapack_int LAPACKE_cggevx( int matrix_layout, char balanc, char jobvl, - char jobvr, char sense, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* alpha, - lapack_complex_float* beta, lapack_complex_float* vl, - lapack_int ldvl, lapack_complex_float* vr, - lapack_int ldvr, lapack_int* ilo, lapack_int* ihi, - float* lscale, float* rscale, float* abnrm, - float* bbnrm, float* rconde, float* rcondv ); -lapack_int LAPACKE_zggevx( int matrix_layout, char balanc, char jobvl, - char jobvr, char sense, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* alpha, - lapack_complex_double* beta, - lapack_complex_double* vl, lapack_int ldvl, - lapack_complex_double* vr, lapack_int ldvr, - lapack_int* ilo, lapack_int* ihi, double* lscale, - double* rscale, double* abnrm, double* bbnrm, - double* rconde, double* rcondv ); - -lapack_int LAPACKE_sggglm( int matrix_layout, lapack_int n, lapack_int m, - lapack_int p, float* a, lapack_int lda, float* b, - lapack_int ldb, float* d, float* x, float* y ); -lapack_int LAPACKE_dggglm( int matrix_layout, lapack_int n, lapack_int m, - lapack_int p, double* a, lapack_int lda, double* b, - lapack_int ldb, double* d, double* x, double* y ); -lapack_int LAPACKE_cggglm( int matrix_layout, lapack_int n, lapack_int m, - lapack_int p, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* b, - lapack_int ldb, lapack_complex_float* d, - lapack_complex_float* x, lapack_complex_float* y ); -lapack_int LAPACKE_zggglm( int matrix_layout, lapack_int n, lapack_int m, - lapack_int p, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* b, - lapack_int ldb, lapack_complex_double* d, - lapack_complex_double* x, lapack_complex_double* y ); - -lapack_int LAPACKE_sgghrd( int matrix_layout, char compq, char compz, - lapack_int n, lapack_int ilo, lapack_int ihi, - float* a, lapack_int lda, float* b, lapack_int ldb, - float* q, lapack_int ldq, float* z, lapack_int ldz ); -lapack_int LAPACKE_dgghrd( int matrix_layout, char compq, char compz, - lapack_int n, lapack_int ilo, lapack_int ihi, - double* a, lapack_int lda, double* b, lapack_int ldb, - double* q, lapack_int ldq, double* z, - lapack_int ldz ); -lapack_int LAPACKE_cgghrd( int matrix_layout, char compq, char compz, - lapack_int n, lapack_int ilo, lapack_int ihi, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* q, lapack_int ldq, - lapack_complex_float* z, lapack_int ldz ); -lapack_int LAPACKE_zgghrd( int matrix_layout, char compq, char compz, - lapack_int n, lapack_int ilo, lapack_int ihi, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* q, lapack_int ldq, - lapack_complex_double* z, lapack_int ldz ); - -lapack_int LAPACKE_sgghd3( int matrix_layout, char compq, char compz, - lapack_int n, lapack_int ilo, lapack_int ihi, - float* a, lapack_int lda, float* b, lapack_int ldb, - float* q, lapack_int ldq, float* z, lapack_int ldz ); -lapack_int LAPACKE_dgghd3( int matrix_layout, char compq, char compz, - lapack_int n, lapack_int ilo, lapack_int ihi, - double* a, lapack_int lda, double* b, lapack_int ldb, - double* q, lapack_int ldq, double* z, - lapack_int ldz ); -lapack_int LAPACKE_cgghd3( int matrix_layout, char compq, char compz, - lapack_int n, lapack_int ilo, lapack_int ihi, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* q, lapack_int ldq, - lapack_complex_float* z, lapack_int ldz ); -lapack_int LAPACKE_zgghd3( int matrix_layout, char compq, char compz, - lapack_int n, lapack_int ilo, lapack_int ihi, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* q, lapack_int ldq, - lapack_complex_double* z, lapack_int ldz ); - -lapack_int LAPACKE_sgglse( int matrix_layout, lapack_int m, lapack_int n, - lapack_int p, float* a, lapack_int lda, float* b, - lapack_int ldb, float* c, float* d, float* x ); -lapack_int LAPACKE_dgglse( int matrix_layout, lapack_int m, lapack_int n, - lapack_int p, double* a, lapack_int lda, double* b, - lapack_int ldb, double* c, double* d, double* x ); -lapack_int LAPACKE_cgglse( int matrix_layout, lapack_int m, lapack_int n, - lapack_int p, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* b, - lapack_int ldb, lapack_complex_float* c, - lapack_complex_float* d, lapack_complex_float* x ); -lapack_int LAPACKE_zgglse( int matrix_layout, lapack_int m, lapack_int n, - lapack_int p, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* b, - lapack_int ldb, lapack_complex_double* c, - lapack_complex_double* d, lapack_complex_double* x ); - -lapack_int LAPACKE_sggqrf( int matrix_layout, lapack_int n, lapack_int m, - lapack_int p, float* a, lapack_int lda, float* taua, - float* b, lapack_int ldb, float* taub ); -lapack_int LAPACKE_dggqrf( int matrix_layout, lapack_int n, lapack_int m, - lapack_int p, double* a, lapack_int lda, - double* taua, double* b, lapack_int ldb, - double* taub ); -lapack_int LAPACKE_cggqrf( int matrix_layout, lapack_int n, lapack_int m, - lapack_int p, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* taua, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* taub ); -lapack_int LAPACKE_zggqrf( int matrix_layout, lapack_int n, lapack_int m, - lapack_int p, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* taua, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* taub ); - -lapack_int LAPACKE_sggrqf( int matrix_layout, lapack_int m, lapack_int p, - lapack_int n, float* a, lapack_int lda, float* taua, - float* b, lapack_int ldb, float* taub ); -lapack_int LAPACKE_dggrqf( int matrix_layout, lapack_int m, lapack_int p, - lapack_int n, double* a, lapack_int lda, - double* taua, double* b, lapack_int ldb, - double* taub ); -lapack_int LAPACKE_cggrqf( int matrix_layout, lapack_int m, lapack_int p, - lapack_int n, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* taua, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* taub ); -lapack_int LAPACKE_zggrqf( int matrix_layout, lapack_int m, lapack_int p, - lapack_int n, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* taua, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* taub ); - -lapack_int LAPACKE_sggsvd( int matrix_layout, char jobu, char jobv, char jobq, - lapack_int m, lapack_int n, lapack_int p, - lapack_int* k, lapack_int* l, float* a, - lapack_int lda, float* b, lapack_int ldb, - float* alpha, float* beta, float* u, lapack_int ldu, - float* v, lapack_int ldv, float* q, lapack_int ldq, - lapack_int* iwork ); -lapack_int LAPACKE_dggsvd( int matrix_layout, char jobu, char jobv, char jobq, - lapack_int m, lapack_int n, lapack_int p, - lapack_int* k, lapack_int* l, double* a, - lapack_int lda, double* b, lapack_int ldb, - double* alpha, double* beta, double* u, - lapack_int ldu, double* v, lapack_int ldv, double* q, - lapack_int ldq, lapack_int* iwork ); -lapack_int LAPACKE_cggsvd( int matrix_layout, char jobu, char jobv, char jobq, - lapack_int m, lapack_int n, lapack_int p, - lapack_int* k, lapack_int* l, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - float* alpha, float* beta, lapack_complex_float* u, - lapack_int ldu, lapack_complex_float* v, - lapack_int ldv, lapack_complex_float* q, - lapack_int ldq, lapack_int* iwork ); -lapack_int LAPACKE_zggsvd( int matrix_layout, char jobu, char jobv, char jobq, - lapack_int m, lapack_int n, lapack_int p, - lapack_int* k, lapack_int* l, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - double* alpha, double* beta, - lapack_complex_double* u, lapack_int ldu, - lapack_complex_double* v, lapack_int ldv, - lapack_complex_double* q, lapack_int ldq, - lapack_int* iwork ); - -lapack_int LAPACKE_sggsvd3( int matrix_layout, char jobu, char jobv, char jobq, - lapack_int m, lapack_int n, lapack_int p, - lapack_int* k, lapack_int* l, float* a, - lapack_int lda, float* b, lapack_int ldb, - float* alpha, float* beta, float* u, lapack_int ldu, - float* v, lapack_int ldv, float* q, lapack_int ldq, - lapack_int* iwork ); -lapack_int LAPACKE_dggsvd3( int matrix_layout, char jobu, char jobv, char jobq, - lapack_int m, lapack_int n, lapack_int p, - lapack_int* k, lapack_int* l, double* a, - lapack_int lda, double* b, lapack_int ldb, - double* alpha, double* beta, double* u, - lapack_int ldu, double* v, lapack_int ldv, double* q, - lapack_int ldq, lapack_int* iwork ); -lapack_int LAPACKE_cggsvd3( int matrix_layout, char jobu, char jobv, char jobq, - lapack_int m, lapack_int n, lapack_int p, - lapack_int* k, lapack_int* l, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - float* alpha, float* beta, lapack_complex_float* u, - lapack_int ldu, lapack_complex_float* v, - lapack_int ldv, lapack_complex_float* q, - lapack_int ldq, lapack_int* iwork ); -lapack_int LAPACKE_zggsvd3( int matrix_layout, char jobu, char jobv, char jobq, - lapack_int m, lapack_int n, lapack_int p, - lapack_int* k, lapack_int* l, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - double* alpha, double* beta, - lapack_complex_double* u, lapack_int ldu, - lapack_complex_double* v, lapack_int ldv, - lapack_complex_double* q, lapack_int ldq, - lapack_int* iwork ); - -lapack_int LAPACKE_sggsvp( int matrix_layout, char jobu, char jobv, char jobq, - lapack_int m, lapack_int p, lapack_int n, float* a, - lapack_int lda, float* b, lapack_int ldb, float tola, - float tolb, lapack_int* k, lapack_int* l, float* u, - lapack_int ldu, float* v, lapack_int ldv, float* q, - lapack_int ldq ); -lapack_int LAPACKE_dggsvp( int matrix_layout, char jobu, char jobv, char jobq, - lapack_int m, lapack_int p, lapack_int n, double* a, - lapack_int lda, double* b, lapack_int ldb, - double tola, double tolb, lapack_int* k, - lapack_int* l, double* u, lapack_int ldu, double* v, - lapack_int ldv, double* q, lapack_int ldq ); -lapack_int LAPACKE_cggsvp( int matrix_layout, char jobu, char jobv, char jobq, - lapack_int m, lapack_int p, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, float tola, - float tolb, lapack_int* k, lapack_int* l, - lapack_complex_float* u, lapack_int ldu, - lapack_complex_float* v, lapack_int ldv, - lapack_complex_float* q, lapack_int ldq ); -lapack_int LAPACKE_zggsvp( int matrix_layout, char jobu, char jobv, char jobq, - lapack_int m, lapack_int p, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - double tola, double tolb, lapack_int* k, - lapack_int* l, lapack_complex_double* u, - lapack_int ldu, lapack_complex_double* v, - lapack_int ldv, lapack_complex_double* q, - lapack_int ldq ); - -lapack_int LAPACKE_sggsvp3( int matrix_layout, char jobu, char jobv, char jobq, - lapack_int m, lapack_int p, lapack_int n, float* a, - lapack_int lda, float* b, lapack_int ldb, float tola, - float tolb, lapack_int* k, lapack_int* l, float* u, - lapack_int ldu, float* v, lapack_int ldv, float* q, - lapack_int ldq ); -lapack_int LAPACKE_dggsvp3( int matrix_layout, char jobu, char jobv, char jobq, - lapack_int m, lapack_int p, lapack_int n, double* a, - lapack_int lda, double* b, lapack_int ldb, - double tola, double tolb, lapack_int* k, - lapack_int* l, double* u, lapack_int ldu, double* v, - lapack_int ldv, double* q, lapack_int ldq ); -lapack_int LAPACKE_cggsvp3( int matrix_layout, char jobu, char jobv, char jobq, - lapack_int m, lapack_int p, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, float tola, - float tolb, lapack_int* k, lapack_int* l, - lapack_complex_float* u, lapack_int ldu, - lapack_complex_float* v, lapack_int ldv, - lapack_complex_float* q, lapack_int ldq ); -lapack_int LAPACKE_zggsvp3( int matrix_layout, char jobu, char jobv, char jobq, - lapack_int m, lapack_int p, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - double tola, double tolb, lapack_int* k, - lapack_int* l, lapack_complex_double* u, - lapack_int ldu, lapack_complex_double* v, - lapack_int ldv, lapack_complex_double* q, - lapack_int ldq ); - -lapack_int LAPACKE_sgtcon( char norm, lapack_int n, const float* dl, - const float* d, const float* du, const float* du2, - const lapack_int* ipiv, float anorm, float* rcond ); -lapack_int LAPACKE_dgtcon( char norm, lapack_int n, const double* dl, - const double* d, const double* du, const double* du2, - const lapack_int* ipiv, double anorm, - double* rcond ); -lapack_int LAPACKE_cgtcon( char norm, lapack_int n, - const lapack_complex_float* dl, - const lapack_complex_float* d, - const lapack_complex_float* du, - const lapack_complex_float* du2, - const lapack_int* ipiv, float anorm, float* rcond ); -lapack_int LAPACKE_zgtcon( char norm, lapack_int n, - const lapack_complex_double* dl, - const lapack_complex_double* d, - const lapack_complex_double* du, - const lapack_complex_double* du2, - const lapack_int* ipiv, double anorm, - double* rcond ); - -lapack_int LAPACKE_sgtrfs( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const float* dl, const float* d, - const float* du, const float* dlf, const float* df, - const float* duf, const float* du2, - const lapack_int* ipiv, const float* b, - lapack_int ldb, float* x, lapack_int ldx, - float* ferr, float* berr ); -lapack_int LAPACKE_dgtrfs( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const double* dl, const double* d, - const double* du, const double* dlf, - const double* df, const double* duf, - const double* du2, const lapack_int* ipiv, - const double* b, lapack_int ldb, double* x, - lapack_int ldx, double* ferr, double* berr ); -lapack_int LAPACKE_cgtrfs( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const lapack_complex_float* dl, - const lapack_complex_float* d, - const lapack_complex_float* du, - const lapack_complex_float* dlf, - const lapack_complex_float* df, - const lapack_complex_float* duf, - const lapack_complex_float* du2, - const lapack_int* ipiv, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, float* ferr, - float* berr ); -lapack_int LAPACKE_zgtrfs( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const lapack_complex_double* dl, - const lapack_complex_double* d, - const lapack_complex_double* du, - const lapack_complex_double* dlf, - const lapack_complex_double* df, - const lapack_complex_double* duf, - const lapack_complex_double* du2, - const lapack_int* ipiv, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* ferr, double* berr ); - -lapack_int LAPACKE_sgtsv( int matrix_layout, lapack_int n, lapack_int nrhs, - float* dl, float* d, float* du, float* b, - lapack_int ldb ); -lapack_int LAPACKE_dgtsv( int matrix_layout, lapack_int n, lapack_int nrhs, - double* dl, double* d, double* du, double* b, - lapack_int ldb ); -lapack_int LAPACKE_cgtsv( int matrix_layout, lapack_int n, lapack_int nrhs, - lapack_complex_float* dl, lapack_complex_float* d, - lapack_complex_float* du, lapack_complex_float* b, - lapack_int ldb ); -lapack_int LAPACKE_zgtsv( int matrix_layout, lapack_int n, lapack_int nrhs, - lapack_complex_double* dl, lapack_complex_double* d, - lapack_complex_double* du, lapack_complex_double* b, - lapack_int ldb ); - -lapack_int LAPACKE_sgtsvx( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int nrhs, const float* dl, - const float* d, const float* du, float* dlf, - float* df, float* duf, float* du2, lapack_int* ipiv, - const float* b, lapack_int ldb, float* x, - lapack_int ldx, float* rcond, float* ferr, - float* berr ); -lapack_int LAPACKE_dgtsvx( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int nrhs, const double* dl, - const double* d, const double* du, double* dlf, - double* df, double* duf, double* du2, - lapack_int* ipiv, const double* b, lapack_int ldb, - double* x, lapack_int ldx, double* rcond, - double* ferr, double* berr ); -lapack_int LAPACKE_cgtsvx( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int nrhs, - const lapack_complex_float* dl, - const lapack_complex_float* d, - const lapack_complex_float* du, - lapack_complex_float* dlf, lapack_complex_float* df, - lapack_complex_float* duf, lapack_complex_float* du2, - lapack_int* ipiv, const lapack_complex_float* b, - lapack_int ldb, lapack_complex_float* x, - lapack_int ldx, float* rcond, float* ferr, - float* berr ); -lapack_int LAPACKE_zgtsvx( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int nrhs, - const lapack_complex_double* dl, - const lapack_complex_double* d, - const lapack_complex_double* du, - lapack_complex_double* dlf, - lapack_complex_double* df, - lapack_complex_double* duf, - lapack_complex_double* du2, lapack_int* ipiv, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* ferr, double* berr ); - -lapack_int LAPACKE_sgttrf( lapack_int n, float* dl, float* d, float* du, - float* du2, lapack_int* ipiv ); -lapack_int LAPACKE_dgttrf( lapack_int n, double* dl, double* d, double* du, - double* du2, lapack_int* ipiv ); -lapack_int LAPACKE_cgttrf( lapack_int n, lapack_complex_float* dl, - lapack_complex_float* d, lapack_complex_float* du, - lapack_complex_float* du2, lapack_int* ipiv ); -lapack_int LAPACKE_zgttrf( lapack_int n, lapack_complex_double* dl, - lapack_complex_double* d, lapack_complex_double* du, - lapack_complex_double* du2, lapack_int* ipiv ); - -lapack_int LAPACKE_sgttrs( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const float* dl, const float* d, - const float* du, const float* du2, - const lapack_int* ipiv, float* b, lapack_int ldb ); -lapack_int LAPACKE_dgttrs( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const double* dl, const double* d, - const double* du, const double* du2, - const lapack_int* ipiv, double* b, lapack_int ldb ); -lapack_int LAPACKE_cgttrs( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const lapack_complex_float* dl, - const lapack_complex_float* d, - const lapack_complex_float* du, - const lapack_complex_float* du2, - const lapack_int* ipiv, lapack_complex_float* b, - lapack_int ldb ); -lapack_int LAPACKE_zgttrs( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const lapack_complex_double* dl, - const lapack_complex_double* d, - const lapack_complex_double* du, - const lapack_complex_double* du2, - const lapack_int* ipiv, lapack_complex_double* b, - lapack_int ldb ); - -lapack_int LAPACKE_chbev( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_int kd, lapack_complex_float* ab, - lapack_int ldab, float* w, lapack_complex_float* z, - lapack_int ldz ); -lapack_int LAPACKE_zhbev( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_int kd, lapack_complex_double* ab, - lapack_int ldab, double* w, lapack_complex_double* z, - lapack_int ldz ); - -lapack_int LAPACKE_chbevd( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_int kd, lapack_complex_float* ab, - lapack_int ldab, float* w, lapack_complex_float* z, - lapack_int ldz ); -lapack_int LAPACKE_zhbevd( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_int kd, lapack_complex_double* ab, - lapack_int ldab, double* w, lapack_complex_double* z, - lapack_int ldz ); - -lapack_int LAPACKE_chbevx( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, lapack_int kd, - lapack_complex_float* ab, lapack_int ldab, - lapack_complex_float* q, lapack_int ldq, float vl, - float vu, lapack_int il, lapack_int iu, float abstol, - lapack_int* m, float* w, lapack_complex_float* z, - lapack_int ldz, lapack_int* ifail ); -lapack_int LAPACKE_zhbevx( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, lapack_int kd, - lapack_complex_double* ab, lapack_int ldab, - lapack_complex_double* q, lapack_int ldq, double vl, - double vu, lapack_int il, lapack_int iu, - double abstol, lapack_int* m, double* w, - lapack_complex_double* z, lapack_int ldz, - lapack_int* ifail ); - -lapack_int LAPACKE_chbgst( int matrix_layout, char vect, char uplo, lapack_int n, - lapack_int ka, lapack_int kb, - lapack_complex_float* ab, lapack_int ldab, - const lapack_complex_float* bb, lapack_int ldbb, - lapack_complex_float* x, lapack_int ldx ); -lapack_int LAPACKE_zhbgst( int matrix_layout, char vect, char uplo, lapack_int n, - lapack_int ka, lapack_int kb, - lapack_complex_double* ab, lapack_int ldab, - const lapack_complex_double* bb, lapack_int ldbb, - lapack_complex_double* x, lapack_int ldx ); - -lapack_int LAPACKE_chbgv( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_int ka, lapack_int kb, - lapack_complex_float* ab, lapack_int ldab, - lapack_complex_float* bb, lapack_int ldbb, float* w, - lapack_complex_float* z, lapack_int ldz ); -lapack_int LAPACKE_zhbgv( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_int ka, lapack_int kb, - lapack_complex_double* ab, lapack_int ldab, - lapack_complex_double* bb, lapack_int ldbb, double* w, - lapack_complex_double* z, lapack_int ldz ); - -lapack_int LAPACKE_chbgvd( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_int ka, lapack_int kb, - lapack_complex_float* ab, lapack_int ldab, - lapack_complex_float* bb, lapack_int ldbb, float* w, - lapack_complex_float* z, lapack_int ldz ); -lapack_int LAPACKE_zhbgvd( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_int ka, lapack_int kb, - lapack_complex_double* ab, lapack_int ldab, - lapack_complex_double* bb, lapack_int ldbb, - double* w, lapack_complex_double* z, - lapack_int ldz ); - -lapack_int LAPACKE_chbgvx( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, lapack_int ka, lapack_int kb, - lapack_complex_float* ab, lapack_int ldab, - lapack_complex_float* bb, lapack_int ldbb, - lapack_complex_float* q, lapack_int ldq, float vl, - float vu, lapack_int il, lapack_int iu, float abstol, - lapack_int* m, float* w, lapack_complex_float* z, - lapack_int ldz, lapack_int* ifail ); -lapack_int LAPACKE_zhbgvx( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, lapack_int ka, lapack_int kb, - lapack_complex_double* ab, lapack_int ldab, - lapack_complex_double* bb, lapack_int ldbb, - lapack_complex_double* q, lapack_int ldq, double vl, - double vu, lapack_int il, lapack_int iu, - double abstol, lapack_int* m, double* w, - lapack_complex_double* z, lapack_int ldz, - lapack_int* ifail ); - -lapack_int LAPACKE_chbtrd( int matrix_layout, char vect, char uplo, lapack_int n, - lapack_int kd, lapack_complex_float* ab, - lapack_int ldab, float* d, float* e, - lapack_complex_float* q, lapack_int ldq ); -lapack_int LAPACKE_zhbtrd( int matrix_layout, char vect, char uplo, lapack_int n, - lapack_int kd, lapack_complex_double* ab, - lapack_int ldab, double* d, double* e, - lapack_complex_double* q, lapack_int ldq ); - -lapack_int LAPACKE_checon( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - const lapack_int* ipiv, float anorm, float* rcond ); -lapack_int LAPACKE_zhecon( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - const lapack_int* ipiv, double anorm, - double* rcond ); - -lapack_int LAPACKE_cheequb( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - float* s, float* scond, float* amax ); -lapack_int LAPACKE_zheequb( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - double* s, double* scond, double* amax ); - -lapack_int LAPACKE_cheev( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, float* w ); -lapack_int LAPACKE_zheev( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, double* w ); - -lapack_int LAPACKE_cheevd( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, float* w ); -lapack_int LAPACKE_zheevd( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - double* w ); - -lapack_int LAPACKE_cheevr( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, lapack_complex_float* a, - lapack_int lda, float vl, float vu, lapack_int il, - lapack_int iu, float abstol, lapack_int* m, float* w, - lapack_complex_float* z, lapack_int ldz, - lapack_int* isuppz ); -lapack_int LAPACKE_zheevr( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, lapack_complex_double* a, - lapack_int lda, double vl, double vu, lapack_int il, - lapack_int iu, double abstol, lapack_int* m, - double* w, lapack_complex_double* z, lapack_int ldz, - lapack_int* isuppz ); - -lapack_int LAPACKE_cheevx( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, lapack_complex_float* a, - lapack_int lda, float vl, float vu, lapack_int il, - lapack_int iu, float abstol, lapack_int* m, float* w, - lapack_complex_float* z, lapack_int ldz, - lapack_int* ifail ); -lapack_int LAPACKE_zheevx( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, lapack_complex_double* a, - lapack_int lda, double vl, double vu, lapack_int il, - lapack_int iu, double abstol, lapack_int* m, - double* w, lapack_complex_double* z, lapack_int ldz, - lapack_int* ifail ); - -lapack_int LAPACKE_chegst( int matrix_layout, lapack_int itype, char uplo, - lapack_int n, lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* b, - lapack_int ldb ); -lapack_int LAPACKE_zhegst( int matrix_layout, lapack_int itype, char uplo, - lapack_int n, lapack_complex_double* a, - lapack_int lda, const lapack_complex_double* b, - lapack_int ldb ); - -lapack_int LAPACKE_chegv( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* b, - lapack_int ldb, float* w ); -lapack_int LAPACKE_zhegv( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* b, - lapack_int ldb, double* w ); - -lapack_int LAPACKE_chegvd( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* b, - lapack_int ldb, float* w ); -lapack_int LAPACKE_zhegvd( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* b, - lapack_int ldb, double* w ); - -lapack_int LAPACKE_chegvx( int matrix_layout, lapack_int itype, char jobz, - char range, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, float vl, - float vu, lapack_int il, lapack_int iu, float abstol, - lapack_int* m, float* w, lapack_complex_float* z, - lapack_int ldz, lapack_int* ifail ); -lapack_int LAPACKE_zhegvx( int matrix_layout, lapack_int itype, char jobz, - char range, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, double vl, - double vu, lapack_int il, lapack_int iu, - double abstol, lapack_int* m, double* w, - lapack_complex_double* z, lapack_int ldz, - lapack_int* ifail ); - -lapack_int LAPACKE_cherfs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* af, - lapack_int ldaf, const lapack_int* ipiv, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, float* ferr, - float* berr ); -lapack_int LAPACKE_zherfs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_complex_double* af, - lapack_int ldaf, const lapack_int* ipiv, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* ferr, double* berr ); - -lapack_int LAPACKE_cherfsx( int matrix_layout, char uplo, char equed, - lapack_int n, lapack_int nrhs, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* af, lapack_int ldaf, - const lapack_int* ipiv, const float* s, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* rcond, float* berr, lapack_int n_err_bnds, - float* err_bnds_norm, float* err_bnds_comp, - lapack_int nparams, float* params ); -lapack_int LAPACKE_zherfsx( int matrix_layout, char uplo, char equed, - lapack_int n, lapack_int nrhs, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* af, lapack_int ldaf, - const lapack_int* ipiv, const double* s, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* berr, lapack_int n_err_bnds, - double* err_bnds_norm, double* err_bnds_comp, - lapack_int nparams, double* params ); - -lapack_int LAPACKE_chesv( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zhesv( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_chesvx( int matrix_layout, char fact, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, lapack_complex_float* af, - lapack_int ldaf, lapack_int* ipiv, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* rcond, float* ferr, float* berr ); -lapack_int LAPACKE_zhesvx( int matrix_layout, char fact, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, lapack_complex_double* af, - lapack_int ldaf, lapack_int* ipiv, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* ferr, double* berr ); - -lapack_int LAPACKE_chesvxx( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* af, lapack_int ldaf, - lapack_int* ipiv, char* equed, float* s, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* rcond, float* rpvgrw, float* berr, - lapack_int n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int nparams, - float* params ); -lapack_int LAPACKE_zhesvxx( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* af, lapack_int ldaf, - lapack_int* ipiv, char* equed, double* s, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* rpvgrw, double* berr, - lapack_int n_err_bnds, double* err_bnds_norm, - double* err_bnds_comp, lapack_int nparams, - double* params ); - -lapack_int LAPACKE_chetrd( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, float* d, - float* e, lapack_complex_float* tau ); -lapack_int LAPACKE_zhetrd( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, double* d, - double* e, lapack_complex_double* tau ); - -lapack_int LAPACKE_chetrf( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int* ipiv ); -lapack_int LAPACKE_zhetrf( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int* ipiv ); - -lapack_int LAPACKE_chetri( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - const lapack_int* ipiv ); -lapack_int LAPACKE_zhetri( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - const lapack_int* ipiv ); - -lapack_int LAPACKE_chetrs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zhetrs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_chfrk( int matrix_layout, char transr, char uplo, char trans, - lapack_int n, lapack_int k, float alpha, - const lapack_complex_float* a, lapack_int lda, - float beta, lapack_complex_float* c ); -lapack_int LAPACKE_zhfrk( int matrix_layout, char transr, char uplo, char trans, - lapack_int n, lapack_int k, double alpha, - const lapack_complex_double* a, lapack_int lda, - double beta, lapack_complex_double* c ); - -lapack_int LAPACKE_shgeqz( int matrix_layout, char job, char compq, char compz, - lapack_int n, lapack_int ilo, lapack_int ihi, - float* h, lapack_int ldh, float* t, lapack_int ldt, - float* alphar, float* alphai, float* beta, float* q, - lapack_int ldq, float* z, lapack_int ldz ); -lapack_int LAPACKE_dhgeqz( int matrix_layout, char job, char compq, char compz, - lapack_int n, lapack_int ilo, lapack_int ihi, - double* h, lapack_int ldh, double* t, lapack_int ldt, - double* alphar, double* alphai, double* beta, - double* q, lapack_int ldq, double* z, - lapack_int ldz ); -lapack_int LAPACKE_chgeqz( int matrix_layout, char job, char compq, char compz, - lapack_int n, lapack_int ilo, lapack_int ihi, - lapack_complex_float* h, lapack_int ldh, - lapack_complex_float* t, lapack_int ldt, - lapack_complex_float* alpha, - lapack_complex_float* beta, lapack_complex_float* q, - lapack_int ldq, lapack_complex_float* z, - lapack_int ldz ); -lapack_int LAPACKE_zhgeqz( int matrix_layout, char job, char compq, char compz, - lapack_int n, lapack_int ilo, lapack_int ihi, - lapack_complex_double* h, lapack_int ldh, - lapack_complex_double* t, lapack_int ldt, - lapack_complex_double* alpha, - lapack_complex_double* beta, - lapack_complex_double* q, lapack_int ldq, - lapack_complex_double* z, lapack_int ldz ); - -lapack_int LAPACKE_chpcon( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float* ap, - const lapack_int* ipiv, float anorm, float* rcond ); -lapack_int LAPACKE_zhpcon( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double* ap, - const lapack_int* ipiv, double anorm, - double* rcond ); - -lapack_int LAPACKE_chpev( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_complex_float* ap, float* w, - lapack_complex_float* z, lapack_int ldz ); -lapack_int LAPACKE_zhpev( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_complex_double* ap, double* w, - lapack_complex_double* z, lapack_int ldz ); - -lapack_int LAPACKE_chpevd( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_complex_float* ap, float* w, - lapack_complex_float* z, lapack_int ldz ); -lapack_int LAPACKE_zhpevd( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_complex_double* ap, double* w, - lapack_complex_double* z, lapack_int ldz ); - -lapack_int LAPACKE_chpevx( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, lapack_complex_float* ap, float vl, - float vu, lapack_int il, lapack_int iu, float abstol, - lapack_int* m, float* w, lapack_complex_float* z, - lapack_int ldz, lapack_int* ifail ); -lapack_int LAPACKE_zhpevx( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, lapack_complex_double* ap, double vl, - double vu, lapack_int il, lapack_int iu, - double abstol, lapack_int* m, double* w, - lapack_complex_double* z, lapack_int ldz, - lapack_int* ifail ); - -lapack_int LAPACKE_chpgst( int matrix_layout, lapack_int itype, char uplo, - lapack_int n, lapack_complex_float* ap, - const lapack_complex_float* bp ); -lapack_int LAPACKE_zhpgst( int matrix_layout, lapack_int itype, char uplo, - lapack_int n, lapack_complex_double* ap, - const lapack_complex_double* bp ); - -lapack_int LAPACKE_chpgv( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, lapack_complex_float* ap, - lapack_complex_float* bp, float* w, - lapack_complex_float* z, lapack_int ldz ); -lapack_int LAPACKE_zhpgv( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, lapack_complex_double* ap, - lapack_complex_double* bp, double* w, - lapack_complex_double* z, lapack_int ldz ); - -lapack_int LAPACKE_chpgvd( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, lapack_complex_float* ap, - lapack_complex_float* bp, float* w, - lapack_complex_float* z, lapack_int ldz ); -lapack_int LAPACKE_zhpgvd( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, lapack_complex_double* ap, - lapack_complex_double* bp, double* w, - lapack_complex_double* z, lapack_int ldz ); - -lapack_int LAPACKE_chpgvx( int matrix_layout, lapack_int itype, char jobz, - char range, char uplo, lapack_int n, - lapack_complex_float* ap, lapack_complex_float* bp, - float vl, float vu, lapack_int il, lapack_int iu, - float abstol, lapack_int* m, float* w, - lapack_complex_float* z, lapack_int ldz, - lapack_int* ifail ); -lapack_int LAPACKE_zhpgvx( int matrix_layout, lapack_int itype, char jobz, - char range, char uplo, lapack_int n, - lapack_complex_double* ap, lapack_complex_double* bp, - double vl, double vu, lapack_int il, lapack_int iu, - double abstol, lapack_int* m, double* w, - lapack_complex_double* z, lapack_int ldz, - lapack_int* ifail ); - -lapack_int LAPACKE_chprfs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* ap, - const lapack_complex_float* afp, - const lapack_int* ipiv, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, float* ferr, - float* berr ); -lapack_int LAPACKE_zhprfs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* ap, - const lapack_complex_double* afp, - const lapack_int* ipiv, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* ferr, double* berr ); - -lapack_int LAPACKE_chpsv( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* ap, - lapack_int* ipiv, lapack_complex_float* b, - lapack_int ldb ); -lapack_int LAPACKE_zhpsv( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* ap, - lapack_int* ipiv, lapack_complex_double* b, - lapack_int ldb ); - -lapack_int LAPACKE_chpsvx( int matrix_layout, char fact, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* ap, - lapack_complex_float* afp, lapack_int* ipiv, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* rcond, float* ferr, float* berr ); -lapack_int LAPACKE_zhpsvx( int matrix_layout, char fact, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* ap, - lapack_complex_double* afp, lapack_int* ipiv, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* ferr, double* berr ); - -lapack_int LAPACKE_chptrd( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* ap, float* d, float* e, - lapack_complex_float* tau ); -lapack_int LAPACKE_zhptrd( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* ap, double* d, double* e, - lapack_complex_double* tau ); - -lapack_int LAPACKE_chptrf( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* ap, lapack_int* ipiv ); -lapack_int LAPACKE_zhptrf( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* ap, lapack_int* ipiv ); - -lapack_int LAPACKE_chptri( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* ap, const lapack_int* ipiv ); -lapack_int LAPACKE_zhptri( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* ap, const lapack_int* ipiv ); - -lapack_int LAPACKE_chptrs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* ap, - const lapack_int* ipiv, lapack_complex_float* b, - lapack_int ldb ); -lapack_int LAPACKE_zhptrs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* ap, - const lapack_int* ipiv, lapack_complex_double* b, - lapack_int ldb ); - -lapack_int LAPACKE_shsein( int matrix_layout, char job, char eigsrc, char initv, - lapack_logical* select, lapack_int n, const float* h, - lapack_int ldh, float* wr, const float* wi, - float* vl, lapack_int ldvl, float* vr, - lapack_int ldvr, lapack_int mm, lapack_int* m, - lapack_int* ifaill, lapack_int* ifailr ); -lapack_int LAPACKE_dhsein( int matrix_layout, char job, char eigsrc, char initv, - lapack_logical* select, lapack_int n, - const double* h, lapack_int ldh, double* wr, - const double* wi, double* vl, lapack_int ldvl, - double* vr, lapack_int ldvr, lapack_int mm, - lapack_int* m, lapack_int* ifaill, - lapack_int* ifailr ); -lapack_int LAPACKE_chsein( int matrix_layout, char job, char eigsrc, char initv, - const lapack_logical* select, lapack_int n, - const lapack_complex_float* h, lapack_int ldh, - lapack_complex_float* w, lapack_complex_float* vl, - lapack_int ldvl, lapack_complex_float* vr, - lapack_int ldvr, lapack_int mm, lapack_int* m, - lapack_int* ifaill, lapack_int* ifailr ); -lapack_int LAPACKE_zhsein( int matrix_layout, char job, char eigsrc, char initv, - const lapack_logical* select, lapack_int n, - const lapack_complex_double* h, lapack_int ldh, - lapack_complex_double* w, lapack_complex_double* vl, - lapack_int ldvl, lapack_complex_double* vr, - lapack_int ldvr, lapack_int mm, lapack_int* m, - lapack_int* ifaill, lapack_int* ifailr ); - -lapack_int LAPACKE_shseqr( int matrix_layout, char job, char compz, lapack_int n, - lapack_int ilo, lapack_int ihi, float* h, - lapack_int ldh, float* wr, float* wi, float* z, - lapack_int ldz ); -lapack_int LAPACKE_dhseqr( int matrix_layout, char job, char compz, lapack_int n, - lapack_int ilo, lapack_int ihi, double* h, - lapack_int ldh, double* wr, double* wi, double* z, - lapack_int ldz ); -lapack_int LAPACKE_chseqr( int matrix_layout, char job, char compz, lapack_int n, - lapack_int ilo, lapack_int ihi, - lapack_complex_float* h, lapack_int ldh, - lapack_complex_float* w, lapack_complex_float* z, - lapack_int ldz ); -lapack_int LAPACKE_zhseqr( int matrix_layout, char job, char compz, lapack_int n, - lapack_int ilo, lapack_int ihi, - lapack_complex_double* h, lapack_int ldh, - lapack_complex_double* w, lapack_complex_double* z, - lapack_int ldz ); - -lapack_int LAPACKE_clacgv( lapack_int n, lapack_complex_float* x, - lapack_int incx ); -lapack_int LAPACKE_zlacgv( lapack_int n, lapack_complex_double* x, - lapack_int incx ); - -lapack_int LAPACKE_slacn2( lapack_int n, float* v, float* x, lapack_int* isgn, - float* est, lapack_int* kase, lapack_int* isave ); -lapack_int LAPACKE_dlacn2( lapack_int n, double* v, double* x, lapack_int* isgn, - double* est, lapack_int* kase, lapack_int* isave ); -lapack_int LAPACKE_clacn2( lapack_int n, lapack_complex_float* v, - lapack_complex_float* x, - float* est, lapack_int* kase, lapack_int* isave ); -lapack_int LAPACKE_zlacn2( lapack_int n, lapack_complex_double* v, - lapack_complex_double* x, - double* est, lapack_int* kase, lapack_int* isave ); - -lapack_int LAPACKE_slacpy( int matrix_layout, char uplo, lapack_int m, - lapack_int n, const float* a, lapack_int lda, float* b, - lapack_int ldb ); -lapack_int LAPACKE_dlacpy( int matrix_layout, char uplo, lapack_int m, - lapack_int n, const double* a, lapack_int lda, double* b, - lapack_int ldb ); -lapack_int LAPACKE_clacpy( int matrix_layout, char uplo, lapack_int m, - lapack_int n, const lapack_complex_float* a, - lapack_int lda, lapack_complex_float* b, - lapack_int ldb ); -lapack_int LAPACKE_zlacpy( int matrix_layout, char uplo, lapack_int m, - lapack_int n, const lapack_complex_double* a, - lapack_int lda, lapack_complex_double* b, - lapack_int ldb ); - -lapack_int LAPACKE_clacp2( int matrix_layout, char uplo, lapack_int m, - lapack_int n, const float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zlacp2( int matrix_layout, char uplo, lapack_int m, - lapack_int n, const double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_zlag2c( int matrix_layout, lapack_int m, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - lapack_complex_float* sa, lapack_int ldsa ); - -lapack_int LAPACKE_slag2d( int matrix_layout, lapack_int m, lapack_int n, - const float* sa, lapack_int ldsa, double* a, - lapack_int lda ); - -lapack_int LAPACKE_dlag2s( int matrix_layout, lapack_int m, lapack_int n, - const double* a, lapack_int lda, float* sa, - lapack_int ldsa ); - -lapack_int LAPACKE_clag2z( int matrix_layout, lapack_int m, lapack_int n, - const lapack_complex_float* sa, lapack_int ldsa, - lapack_complex_double* a, lapack_int lda ); - -lapack_int LAPACKE_slagge( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, const float* d, - float* a, lapack_int lda, lapack_int* iseed ); -lapack_int LAPACKE_dlagge( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, const double* d, - double* a, lapack_int lda, lapack_int* iseed ); -lapack_int LAPACKE_clagge( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, const float* d, - lapack_complex_float* a, lapack_int lda, - lapack_int* iseed ); -lapack_int LAPACKE_zlagge( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, const double* d, - lapack_complex_double* a, lapack_int lda, - lapack_int* iseed ); - -float LAPACKE_slamch( char cmach ); -double LAPACKE_dlamch( char cmach ); - -float LAPACKE_slange( int matrix_layout, char norm, lapack_int m, - lapack_int n, const float* a, lapack_int lda ); -double LAPACKE_dlange( int matrix_layout, char norm, lapack_int m, - lapack_int n, const double* a, lapack_int lda ); -float LAPACKE_clange( int matrix_layout, char norm, lapack_int m, - lapack_int n, const lapack_complex_float* a, - lapack_int lda ); -double LAPACKE_zlange( int matrix_layout, char norm, lapack_int m, - lapack_int n, const lapack_complex_double* a, - lapack_int lda ); - -float LAPACKE_clanhe( int matrix_layout, char norm, char uplo, lapack_int n, - const lapack_complex_float* a, lapack_int lda ); -double LAPACKE_zlanhe( int matrix_layout, char norm, char uplo, lapack_int n, - const lapack_complex_double* a, lapack_int lda ); - -lapack_int LAPACKE_clacrm( int matrix_layout, lapack_int m, lapack_int n, - const lapack_complex_float* a, - lapack_int lda, const float* b, - lapack_int ldb, lapack_complex_float* c, - lapack_int ldc ); -lapack_int LAPACKE_zlacrm( int matrix_layout, lapack_int m, lapack_int n, - const lapack_complex_double* a, - lapack_int lda, const double* b, - lapack_int ldb, lapack_complex_double* c, - lapack_int ldc ); - -lapack_int LAPACKE_clarcm( int matrix_layout, lapack_int m, lapack_int n, - const float* a, lapack_int lda, - const lapack_complex_float* b, - lapack_int ldb, lapack_complex_float* c, - lapack_int ldc ); -lapack_int LAPACKE_zlarcm( int matrix_layout, lapack_int m, lapack_int n, - const double* a, lapack_int lda, - const lapack_complex_double* b, - lapack_int ldb, lapack_complex_double* c, - lapack_int ldc ); - -float LAPACKE_slansy( int matrix_layout, char norm, char uplo, lapack_int n, - const float* a, lapack_int lda ); -double LAPACKE_dlansy( int matrix_layout, char norm, char uplo, lapack_int n, - const double* a, lapack_int lda ); -float LAPACKE_clansy( int matrix_layout, char norm, char uplo, lapack_int n, - const lapack_complex_float* a, lapack_int lda ); -double LAPACKE_zlansy( int matrix_layout, char norm, char uplo, lapack_int n, - const lapack_complex_double* a, lapack_int lda ); - -float LAPACKE_slantr( int matrix_layout, char norm, char uplo, char diag, - lapack_int m, lapack_int n, const float* a, - lapack_int lda ); -double LAPACKE_dlantr( int matrix_layout, char norm, char uplo, char diag, - lapack_int m, lapack_int n, const double* a, - lapack_int lda ); -float LAPACKE_clantr( int matrix_layout, char norm, char uplo, char diag, - lapack_int m, lapack_int n, const lapack_complex_float* a, - lapack_int lda ); -double LAPACKE_zlantr( int matrix_layout, char norm, char uplo, char diag, - lapack_int m, lapack_int n, const lapack_complex_double* a, - lapack_int lda ); - - -lapack_int LAPACKE_slarfb( int matrix_layout, char side, char trans, char direct, - char storev, lapack_int m, lapack_int n, - lapack_int k, const float* v, lapack_int ldv, - const float* t, lapack_int ldt, float* c, - lapack_int ldc ); -lapack_int LAPACKE_dlarfb( int matrix_layout, char side, char trans, char direct, - char storev, lapack_int m, lapack_int n, - lapack_int k, const double* v, lapack_int ldv, - const double* t, lapack_int ldt, double* c, - lapack_int ldc ); -lapack_int LAPACKE_clarfb( int matrix_layout, char side, char trans, char direct, - char storev, lapack_int m, lapack_int n, - lapack_int k, const lapack_complex_float* v, - lapack_int ldv, const lapack_complex_float* t, - lapack_int ldt, lapack_complex_float* c, - lapack_int ldc ); -lapack_int LAPACKE_zlarfb( int matrix_layout, char side, char trans, char direct, - char storev, lapack_int m, lapack_int n, - lapack_int k, const lapack_complex_double* v, - lapack_int ldv, const lapack_complex_double* t, - lapack_int ldt, lapack_complex_double* c, - lapack_int ldc ); - -lapack_int LAPACKE_slarfg( lapack_int n, float* alpha, float* x, - lapack_int incx, float* tau ); -lapack_int LAPACKE_dlarfg( lapack_int n, double* alpha, double* x, - lapack_int incx, double* tau ); -lapack_int LAPACKE_clarfg( lapack_int n, lapack_complex_float* alpha, - lapack_complex_float* x, lapack_int incx, - lapack_complex_float* tau ); -lapack_int LAPACKE_zlarfg( lapack_int n, lapack_complex_double* alpha, - lapack_complex_double* x, lapack_int incx, - lapack_complex_double* tau ); - -lapack_int LAPACKE_slarft( int matrix_layout, char direct, char storev, - lapack_int n, lapack_int k, const float* v, - lapack_int ldv, const float* tau, float* t, - lapack_int ldt ); -lapack_int LAPACKE_dlarft( int matrix_layout, char direct, char storev, - lapack_int n, lapack_int k, const double* v, - lapack_int ldv, const double* tau, double* t, - lapack_int ldt ); -lapack_int LAPACKE_clarft( int matrix_layout, char direct, char storev, - lapack_int n, lapack_int k, - const lapack_complex_float* v, lapack_int ldv, - const lapack_complex_float* tau, - lapack_complex_float* t, lapack_int ldt ); -lapack_int LAPACKE_zlarft( int matrix_layout, char direct, char storev, - lapack_int n, lapack_int k, - const lapack_complex_double* v, lapack_int ldv, - const lapack_complex_double* tau, - lapack_complex_double* t, lapack_int ldt ); - -lapack_int LAPACKE_slarfx( int matrix_layout, char side, lapack_int m, - lapack_int n, const float* v, float tau, float* c, - lapack_int ldc, float* work ); -lapack_int LAPACKE_dlarfx( int matrix_layout, char side, lapack_int m, - lapack_int n, const double* v, double tau, double* c, - lapack_int ldc, double* work ); -lapack_int LAPACKE_clarfx( int matrix_layout, char side, lapack_int m, - lapack_int n, const lapack_complex_float* v, - lapack_complex_float tau, lapack_complex_float* c, - lapack_int ldc, lapack_complex_float* work ); -lapack_int LAPACKE_zlarfx( int matrix_layout, char side, lapack_int m, - lapack_int n, const lapack_complex_double* v, - lapack_complex_double tau, lapack_complex_double* c, - lapack_int ldc, lapack_complex_double* work ); - -lapack_int LAPACKE_slarnv( lapack_int idist, lapack_int* iseed, lapack_int n, - float* x ); -lapack_int LAPACKE_dlarnv( lapack_int idist, lapack_int* iseed, lapack_int n, - double* x ); -lapack_int LAPACKE_clarnv( lapack_int idist, lapack_int* iseed, lapack_int n, - lapack_complex_float* x ); -lapack_int LAPACKE_zlarnv( lapack_int idist, lapack_int* iseed, lapack_int n, - lapack_complex_double* x ); - -lapack_int LAPACKE_slascl( int matrix_layout, char type, lapack_int kl, - lapack_int ku, float cfrom, float cto, - lapack_int m, lapack_int n, float* a, - lapack_int lda ); -lapack_int LAPACKE_dlascl( int matrix_layout, char type, lapack_int kl, - lapack_int ku, double cfrom, double cto, - lapack_int m, lapack_int n, double* a, - lapack_int lda ); -lapack_int LAPACKE_clascl( int matrix_layout, char type, lapack_int kl, - lapack_int ku, float cfrom, float cto, - lapack_int m, lapack_int n, lapack_complex_float* a, - lapack_int lda ); -lapack_int LAPACKE_zlascl( int matrix_layout, char type, lapack_int kl, - lapack_int ku, double cfrom, double cto, - lapack_int m, lapack_int n, lapack_complex_double* a, - lapack_int lda ); - -lapack_int LAPACKE_slaset( int matrix_layout, char uplo, lapack_int m, - lapack_int n, float alpha, float beta, float* a, - lapack_int lda ); -lapack_int LAPACKE_dlaset( int matrix_layout, char uplo, lapack_int m, - lapack_int n, double alpha, double beta, double* a, - lapack_int lda ); -lapack_int LAPACKE_claset( int matrix_layout, char uplo, lapack_int m, - lapack_int n, lapack_complex_float alpha, - lapack_complex_float beta, lapack_complex_float* a, - lapack_int lda ); -lapack_int LAPACKE_zlaset( int matrix_layout, char uplo, lapack_int m, - lapack_int n, lapack_complex_double alpha, - lapack_complex_double beta, lapack_complex_double* a, - lapack_int lda ); - -lapack_int LAPACKE_slasrt( char id, lapack_int n, float* d ); -lapack_int LAPACKE_dlasrt( char id, lapack_int n, double* d ); - -lapack_int LAPACKE_slassq( lapack_int n, float* x, lapack_int incx, float* scale, float* sumsq ); -lapack_int LAPACKE_dlassq( lapack_int n, double* x, lapack_int incx, double* scale, double* sumsq ); -lapack_int LAPACKE_classq( lapack_int n, lapack_complex_float* x, lapack_int incx, float* scale, float* sumsq ); -lapack_int LAPACKE_zlassq( lapack_int n, lapack_complex_double* x, lapack_int incx, double* scale, double* sumsq ); - -lapack_int LAPACKE_slaswp( int matrix_layout, lapack_int n, float* a, - lapack_int lda, lapack_int k1, lapack_int k2, - const lapack_int* ipiv, lapack_int incx ); -lapack_int LAPACKE_dlaswp( int matrix_layout, lapack_int n, double* a, - lapack_int lda, lapack_int k1, lapack_int k2, - const lapack_int* ipiv, lapack_int incx ); -lapack_int LAPACKE_claswp( int matrix_layout, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int k1, lapack_int k2, const lapack_int* ipiv, - lapack_int incx ); -lapack_int LAPACKE_zlaswp( int matrix_layout, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int k1, lapack_int k2, const lapack_int* ipiv, - lapack_int incx ); - -lapack_int LAPACKE_slatms( int matrix_layout, lapack_int m, lapack_int n, - char dist, lapack_int* iseed, char sym, float* d, - lapack_int mode, float cond, float dmax, - lapack_int kl, lapack_int ku, char pack, float* a, - lapack_int lda ); -lapack_int LAPACKE_dlatms( int matrix_layout, lapack_int m, lapack_int n, - char dist, lapack_int* iseed, char sym, double* d, - lapack_int mode, double cond, double dmax, - lapack_int kl, lapack_int ku, char pack, double* a, - lapack_int lda ); -lapack_int LAPACKE_clatms( int matrix_layout, lapack_int m, lapack_int n, - char dist, lapack_int* iseed, char sym, float* d, - lapack_int mode, float cond, float dmax, - lapack_int kl, lapack_int ku, char pack, - lapack_complex_float* a, lapack_int lda ); -lapack_int LAPACKE_zlatms( int matrix_layout, lapack_int m, lapack_int n, - char dist, lapack_int* iseed, char sym, double* d, - lapack_int mode, double cond, double dmax, - lapack_int kl, lapack_int ku, char pack, - lapack_complex_double* a, lapack_int lda ); - -lapack_int LAPACKE_slauum( int matrix_layout, char uplo, lapack_int n, float* a, - lapack_int lda ); -lapack_int LAPACKE_dlauum( int matrix_layout, char uplo, lapack_int n, double* a, - lapack_int lda ); -lapack_int LAPACKE_clauum( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda ); -lapack_int LAPACKE_zlauum( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda ); - -lapack_int LAPACKE_sopgtr( int matrix_layout, char uplo, lapack_int n, - const float* ap, const float* tau, float* q, - lapack_int ldq ); -lapack_int LAPACKE_dopgtr( int matrix_layout, char uplo, lapack_int n, - const double* ap, const double* tau, double* q, - lapack_int ldq ); - -lapack_int LAPACKE_sopmtr( int matrix_layout, char side, char uplo, char trans, - lapack_int m, lapack_int n, const float* ap, - const float* tau, float* c, lapack_int ldc ); -lapack_int LAPACKE_dopmtr( int matrix_layout, char side, char uplo, char trans, - lapack_int m, lapack_int n, const double* ap, - const double* tau, double* c, lapack_int ldc ); - -lapack_int LAPACKE_sorgbr( int matrix_layout, char vect, lapack_int m, - lapack_int n, lapack_int k, float* a, lapack_int lda, - const float* tau ); -lapack_int LAPACKE_dorgbr( int matrix_layout, char vect, lapack_int m, - lapack_int n, lapack_int k, double* a, - lapack_int lda, const double* tau ); - -lapack_int LAPACKE_sorghr( int matrix_layout, lapack_int n, lapack_int ilo, - lapack_int ihi, float* a, lapack_int lda, - const float* tau ); -lapack_int LAPACKE_dorghr( int matrix_layout, lapack_int n, lapack_int ilo, - lapack_int ihi, double* a, lapack_int lda, - const double* tau ); - -lapack_int LAPACKE_sorglq( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, float* a, lapack_int lda, - const float* tau ); -lapack_int LAPACKE_dorglq( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, double* a, lapack_int lda, - const double* tau ); - -lapack_int LAPACKE_sorgql( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, float* a, lapack_int lda, - const float* tau ); -lapack_int LAPACKE_dorgql( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, double* a, lapack_int lda, - const double* tau ); - -lapack_int LAPACKE_sorgqr( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, float* a, lapack_int lda, - const float* tau ); -lapack_int LAPACKE_dorgqr( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, double* a, lapack_int lda, - const double* tau ); - -lapack_int LAPACKE_sorgrq( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, float* a, lapack_int lda, - const float* tau ); -lapack_int LAPACKE_dorgrq( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, double* a, lapack_int lda, - const double* tau ); - -lapack_int LAPACKE_sorgtr( int matrix_layout, char uplo, lapack_int n, float* a, - lapack_int lda, const float* tau ); -lapack_int LAPACKE_dorgtr( int matrix_layout, char uplo, lapack_int n, double* a, - lapack_int lda, const double* tau ); - -lapack_int LAPACKE_sormbr( int matrix_layout, char vect, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const float* a, lapack_int lda, const float* tau, - float* c, lapack_int ldc ); -lapack_int LAPACKE_dormbr( int matrix_layout, char vect, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const double* a, lapack_int lda, const double* tau, - double* c, lapack_int ldc ); - -lapack_int LAPACKE_sormhr( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int ilo, - lapack_int ihi, const float* a, lapack_int lda, - const float* tau, float* c, lapack_int ldc ); -lapack_int LAPACKE_dormhr( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int ilo, - lapack_int ihi, const double* a, lapack_int lda, - const double* tau, double* c, lapack_int ldc ); - -lapack_int LAPACKE_sormlq( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const float* a, lapack_int lda, const float* tau, - float* c, lapack_int ldc ); -lapack_int LAPACKE_dormlq( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const double* a, lapack_int lda, const double* tau, - double* c, lapack_int ldc ); - -lapack_int LAPACKE_sormql( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const float* a, lapack_int lda, const float* tau, - float* c, lapack_int ldc ); -lapack_int LAPACKE_dormql( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const double* a, lapack_int lda, const double* tau, - double* c, lapack_int ldc ); - -lapack_int LAPACKE_sormqr( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const float* a, lapack_int lda, const float* tau, - float* c, lapack_int ldc ); -lapack_int LAPACKE_dormqr( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const double* a, lapack_int lda, const double* tau, - double* c, lapack_int ldc ); - -lapack_int LAPACKE_sormrq( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const float* a, lapack_int lda, const float* tau, - float* c, lapack_int ldc ); -lapack_int LAPACKE_dormrq( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const double* a, lapack_int lda, const double* tau, - double* c, lapack_int ldc ); - -lapack_int LAPACKE_sormrz( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - lapack_int l, const float* a, lapack_int lda, - const float* tau, float* c, lapack_int ldc ); -lapack_int LAPACKE_dormrz( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - lapack_int l, const double* a, lapack_int lda, - const double* tau, double* c, lapack_int ldc ); - -lapack_int LAPACKE_sormtr( int matrix_layout, char side, char uplo, char trans, - lapack_int m, lapack_int n, const float* a, - lapack_int lda, const float* tau, float* c, - lapack_int ldc ); -lapack_int LAPACKE_dormtr( int matrix_layout, char side, char uplo, char trans, - lapack_int m, lapack_int n, const double* a, - lapack_int lda, const double* tau, double* c, - lapack_int ldc ); - -lapack_int LAPACKE_spbcon( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, const float* ab, lapack_int ldab, - float anorm, float* rcond ); -lapack_int LAPACKE_dpbcon( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, const double* ab, lapack_int ldab, - double anorm, double* rcond ); -lapack_int LAPACKE_cpbcon( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, const lapack_complex_float* ab, - lapack_int ldab, float anorm, float* rcond ); -lapack_int LAPACKE_zpbcon( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, const lapack_complex_double* ab, - lapack_int ldab, double anorm, double* rcond ); - -lapack_int LAPACKE_spbequ( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, const float* ab, lapack_int ldab, - float* s, float* scond, float* amax ); -lapack_int LAPACKE_dpbequ( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, const double* ab, lapack_int ldab, - double* s, double* scond, double* amax ); -lapack_int LAPACKE_cpbequ( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, const lapack_complex_float* ab, - lapack_int ldab, float* s, float* scond, - float* amax ); -lapack_int LAPACKE_zpbequ( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, const lapack_complex_double* ab, - lapack_int ldab, double* s, double* scond, - double* amax ); - -lapack_int LAPACKE_spbrfs( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, lapack_int nrhs, const float* ab, - lapack_int ldab, const float* afb, lapack_int ldafb, - const float* b, lapack_int ldb, float* x, - lapack_int ldx, float* ferr, float* berr ); -lapack_int LAPACKE_dpbrfs( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, lapack_int nrhs, const double* ab, - lapack_int ldab, const double* afb, lapack_int ldafb, - const double* b, lapack_int ldb, double* x, - lapack_int ldx, double* ferr, double* berr ); -lapack_int LAPACKE_cpbrfs( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, lapack_int nrhs, - const lapack_complex_float* ab, lapack_int ldab, - const lapack_complex_float* afb, lapack_int ldafb, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, float* ferr, - float* berr ); -lapack_int LAPACKE_zpbrfs( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, lapack_int nrhs, - const lapack_complex_double* ab, lapack_int ldab, - const lapack_complex_double* afb, lapack_int ldafb, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* ferr, double* berr ); - -lapack_int LAPACKE_spbstf( int matrix_layout, char uplo, lapack_int n, - lapack_int kb, float* bb, lapack_int ldbb ); -lapack_int LAPACKE_dpbstf( int matrix_layout, char uplo, lapack_int n, - lapack_int kb, double* bb, lapack_int ldbb ); -lapack_int LAPACKE_cpbstf( int matrix_layout, char uplo, lapack_int n, - lapack_int kb, lapack_complex_float* bb, - lapack_int ldbb ); -lapack_int LAPACKE_zpbstf( int matrix_layout, char uplo, lapack_int n, - lapack_int kb, lapack_complex_double* bb, - lapack_int ldbb ); - -lapack_int LAPACKE_spbsv( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, lapack_int nrhs, float* ab, - lapack_int ldab, float* b, lapack_int ldb ); -lapack_int LAPACKE_dpbsv( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, lapack_int nrhs, double* ab, - lapack_int ldab, double* b, lapack_int ldb ); -lapack_int LAPACKE_cpbsv( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, lapack_int nrhs, - lapack_complex_float* ab, lapack_int ldab, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zpbsv( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, lapack_int nrhs, - lapack_complex_double* ab, lapack_int ldab, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_spbsvx( int matrix_layout, char fact, char uplo, lapack_int n, - lapack_int kd, lapack_int nrhs, float* ab, - lapack_int ldab, float* afb, lapack_int ldafb, - char* equed, float* s, float* b, lapack_int ldb, - float* x, lapack_int ldx, float* rcond, float* ferr, - float* berr ); -lapack_int LAPACKE_dpbsvx( int matrix_layout, char fact, char uplo, lapack_int n, - lapack_int kd, lapack_int nrhs, double* ab, - lapack_int ldab, double* afb, lapack_int ldafb, - char* equed, double* s, double* b, lapack_int ldb, - double* x, lapack_int ldx, double* rcond, - double* ferr, double* berr ); -lapack_int LAPACKE_cpbsvx( int matrix_layout, char fact, char uplo, lapack_int n, - lapack_int kd, lapack_int nrhs, - lapack_complex_float* ab, lapack_int ldab, - lapack_complex_float* afb, lapack_int ldafb, - char* equed, float* s, lapack_complex_float* b, - lapack_int ldb, lapack_complex_float* x, - lapack_int ldx, float* rcond, float* ferr, - float* berr ); -lapack_int LAPACKE_zpbsvx( int matrix_layout, char fact, char uplo, lapack_int n, - lapack_int kd, lapack_int nrhs, - lapack_complex_double* ab, lapack_int ldab, - lapack_complex_double* afb, lapack_int ldafb, - char* equed, double* s, lapack_complex_double* b, - lapack_int ldb, lapack_complex_double* x, - lapack_int ldx, double* rcond, double* ferr, - double* berr ); - -lapack_int LAPACKE_spbtrf( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, float* ab, lapack_int ldab ); -lapack_int LAPACKE_dpbtrf( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, double* ab, lapack_int ldab ); -lapack_int LAPACKE_cpbtrf( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, lapack_complex_float* ab, - lapack_int ldab ); -lapack_int LAPACKE_zpbtrf( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, lapack_complex_double* ab, - lapack_int ldab ); - -lapack_int LAPACKE_spbtrs( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, lapack_int nrhs, const float* ab, - lapack_int ldab, float* b, lapack_int ldb ); -lapack_int LAPACKE_dpbtrs( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, lapack_int nrhs, const double* ab, - lapack_int ldab, double* b, lapack_int ldb ); -lapack_int LAPACKE_cpbtrs( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, lapack_int nrhs, - const lapack_complex_float* ab, lapack_int ldab, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zpbtrs( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, lapack_int nrhs, - const lapack_complex_double* ab, lapack_int ldab, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_spftrf( int matrix_layout, char transr, char uplo, - lapack_int n, float* a ); -lapack_int LAPACKE_dpftrf( int matrix_layout, char transr, char uplo, - lapack_int n, double* a ); -lapack_int LAPACKE_cpftrf( int matrix_layout, char transr, char uplo, - lapack_int n, lapack_complex_float* a ); -lapack_int LAPACKE_zpftrf( int matrix_layout, char transr, char uplo, - lapack_int n, lapack_complex_double* a ); - -lapack_int LAPACKE_spftri( int matrix_layout, char transr, char uplo, - lapack_int n, float* a ); -lapack_int LAPACKE_dpftri( int matrix_layout, char transr, char uplo, - lapack_int n, double* a ); -lapack_int LAPACKE_cpftri( int matrix_layout, char transr, char uplo, - lapack_int n, lapack_complex_float* a ); -lapack_int LAPACKE_zpftri( int matrix_layout, char transr, char uplo, - lapack_int n, lapack_complex_double* a ); - -lapack_int LAPACKE_spftrs( int matrix_layout, char transr, char uplo, - lapack_int n, lapack_int nrhs, const float* a, - float* b, lapack_int ldb ); -lapack_int LAPACKE_dpftrs( int matrix_layout, char transr, char uplo, - lapack_int n, lapack_int nrhs, const double* a, - double* b, lapack_int ldb ); -lapack_int LAPACKE_cpftrs( int matrix_layout, char transr, char uplo, - lapack_int n, lapack_int nrhs, - const lapack_complex_float* a, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zpftrs( int matrix_layout, char transr, char uplo, - lapack_int n, lapack_int nrhs, - const lapack_complex_double* a, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_spocon( int matrix_layout, char uplo, lapack_int n, - const float* a, lapack_int lda, float anorm, - float* rcond ); -lapack_int LAPACKE_dpocon( int matrix_layout, char uplo, lapack_int n, - const double* a, lapack_int lda, double anorm, - double* rcond ); -lapack_int LAPACKE_cpocon( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - float anorm, float* rcond ); -lapack_int LAPACKE_zpocon( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - double anorm, double* rcond ); - -lapack_int LAPACKE_spoequ( int matrix_layout, lapack_int n, const float* a, - lapack_int lda, float* s, float* scond, - float* amax ); -lapack_int LAPACKE_dpoequ( int matrix_layout, lapack_int n, const double* a, - lapack_int lda, double* s, double* scond, - double* amax ); -lapack_int LAPACKE_cpoequ( int matrix_layout, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - float* s, float* scond, float* amax ); -lapack_int LAPACKE_zpoequ( int matrix_layout, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - double* s, double* scond, double* amax ); - -lapack_int LAPACKE_spoequb( int matrix_layout, lapack_int n, const float* a, - lapack_int lda, float* s, float* scond, - float* amax ); -lapack_int LAPACKE_dpoequb( int matrix_layout, lapack_int n, const double* a, - lapack_int lda, double* s, double* scond, - double* amax ); -lapack_int LAPACKE_cpoequb( int matrix_layout, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - float* s, float* scond, float* amax ); -lapack_int LAPACKE_zpoequb( int matrix_layout, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - double* s, double* scond, double* amax ); - -lapack_int LAPACKE_sporfs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const float* a, lapack_int lda, - const float* af, lapack_int ldaf, const float* b, - lapack_int ldb, float* x, lapack_int ldx, - float* ferr, float* berr ); -lapack_int LAPACKE_dporfs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const double* a, lapack_int lda, - const double* af, lapack_int ldaf, const double* b, - lapack_int ldb, double* x, lapack_int ldx, - double* ferr, double* berr ); -lapack_int LAPACKE_cporfs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* af, - lapack_int ldaf, const lapack_complex_float* b, - lapack_int ldb, lapack_complex_float* x, - lapack_int ldx, float* ferr, float* berr ); -lapack_int LAPACKE_zporfs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_complex_double* af, - lapack_int ldaf, const lapack_complex_double* b, - lapack_int ldb, lapack_complex_double* x, - lapack_int ldx, double* ferr, double* berr ); - -lapack_int LAPACKE_sporfsx( int matrix_layout, char uplo, char equed, - lapack_int n, lapack_int nrhs, const float* a, - lapack_int lda, const float* af, lapack_int ldaf, - const float* s, const float* b, lapack_int ldb, - float* x, lapack_int ldx, float* rcond, float* berr, - lapack_int n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int nparams, - float* params ); -lapack_int LAPACKE_dporfsx( int matrix_layout, char uplo, char equed, - lapack_int n, lapack_int nrhs, const double* a, - lapack_int lda, const double* af, lapack_int ldaf, - const double* s, const double* b, lapack_int ldb, - double* x, lapack_int ldx, double* rcond, - double* berr, lapack_int n_err_bnds, - double* err_bnds_norm, double* err_bnds_comp, - lapack_int nparams, double* params ); -lapack_int LAPACKE_cporfsx( int matrix_layout, char uplo, char equed, - lapack_int n, lapack_int nrhs, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* af, lapack_int ldaf, - const float* s, const lapack_complex_float* b, - lapack_int ldb, lapack_complex_float* x, - lapack_int ldx, float* rcond, float* berr, - lapack_int n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int nparams, - float* params ); -lapack_int LAPACKE_zporfsx( int matrix_layout, char uplo, char equed, - lapack_int n, lapack_int nrhs, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* af, lapack_int ldaf, - const double* s, const lapack_complex_double* b, - lapack_int ldb, lapack_complex_double* x, - lapack_int ldx, double* rcond, double* berr, - lapack_int n_err_bnds, double* err_bnds_norm, - double* err_bnds_comp, lapack_int nparams, - double* params ); - -lapack_int LAPACKE_sposv( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, float* a, lapack_int lda, float* b, - lapack_int ldb ); -lapack_int LAPACKE_dposv( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, double* a, lapack_int lda, double* b, - lapack_int ldb ); -lapack_int LAPACKE_cposv( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* b, - lapack_int ldb ); -lapack_int LAPACKE_zposv( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* b, - lapack_int ldb ); -lapack_int LAPACKE_dsposv( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, double* a, lapack_int lda, - double* b, lapack_int ldb, double* x, lapack_int ldx, - lapack_int* iter ); -lapack_int LAPACKE_zcposv( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* b, - lapack_int ldb, lapack_complex_double* x, - lapack_int ldx, lapack_int* iter ); - -lapack_int LAPACKE_sposvx( int matrix_layout, char fact, char uplo, lapack_int n, - lapack_int nrhs, float* a, lapack_int lda, float* af, - lapack_int ldaf, char* equed, float* s, float* b, - lapack_int ldb, float* x, lapack_int ldx, - float* rcond, float* ferr, float* berr ); -lapack_int LAPACKE_dposvx( int matrix_layout, char fact, char uplo, lapack_int n, - lapack_int nrhs, double* a, lapack_int lda, - double* af, lapack_int ldaf, char* equed, double* s, - double* b, lapack_int ldb, double* x, lapack_int ldx, - double* rcond, double* ferr, double* berr ); -lapack_int LAPACKE_cposvx( int matrix_layout, char fact, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* af, - lapack_int ldaf, char* equed, float* s, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* rcond, float* ferr, float* berr ); -lapack_int LAPACKE_zposvx( int matrix_layout, char fact, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* af, - lapack_int ldaf, char* equed, double* s, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* ferr, double* berr ); - -lapack_int LAPACKE_sposvxx( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, float* a, - lapack_int lda, float* af, lapack_int ldaf, - char* equed, float* s, float* b, lapack_int ldb, - float* x, lapack_int ldx, float* rcond, - float* rpvgrw, float* berr, lapack_int n_err_bnds, - float* err_bnds_norm, float* err_bnds_comp, - lapack_int nparams, float* params ); -lapack_int LAPACKE_dposvxx( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, double* a, - lapack_int lda, double* af, lapack_int ldaf, - char* equed, double* s, double* b, lapack_int ldb, - double* x, lapack_int ldx, double* rcond, - double* rpvgrw, double* berr, lapack_int n_err_bnds, - double* err_bnds_norm, double* err_bnds_comp, - lapack_int nparams, double* params ); -lapack_int LAPACKE_cposvxx( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* af, lapack_int ldaf, - char* equed, float* s, lapack_complex_float* b, - lapack_int ldb, lapack_complex_float* x, - lapack_int ldx, float* rcond, float* rpvgrw, - float* berr, lapack_int n_err_bnds, - float* err_bnds_norm, float* err_bnds_comp, - lapack_int nparams, float* params ); -lapack_int LAPACKE_zposvxx( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* af, lapack_int ldaf, - char* equed, double* s, lapack_complex_double* b, - lapack_int ldb, lapack_complex_double* x, - lapack_int ldx, double* rcond, double* rpvgrw, - double* berr, lapack_int n_err_bnds, - double* err_bnds_norm, double* err_bnds_comp, - lapack_int nparams, double* params ); - -lapack_int LAPACKE_spotrf2( int matrix_layout, char uplo, lapack_int n, float* a, - lapack_int lda ); -lapack_int LAPACKE_dpotrf2( int matrix_layout, char uplo, lapack_int n, double* a, - lapack_int lda ); -lapack_int LAPACKE_cpotrf2( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda ); -lapack_int LAPACKE_zpotrf2( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda ); - -lapack_int LAPACKE_spotrf( int matrix_layout, char uplo, lapack_int n, float* a, - lapack_int lda ); -lapack_int LAPACKE_dpotrf( int matrix_layout, char uplo, lapack_int n, double* a, - lapack_int lda ); -lapack_int LAPACKE_cpotrf( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda ); -lapack_int LAPACKE_zpotrf( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda ); - -lapack_int LAPACKE_spotri( int matrix_layout, char uplo, lapack_int n, float* a, - lapack_int lda ); -lapack_int LAPACKE_dpotri( int matrix_layout, char uplo, lapack_int n, double* a, - lapack_int lda ); -lapack_int LAPACKE_cpotri( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda ); -lapack_int LAPACKE_zpotri( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda ); - -lapack_int LAPACKE_spotrs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const float* a, lapack_int lda, - float* b, lapack_int ldb ); -lapack_int LAPACKE_dpotrs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const double* a, lapack_int lda, - double* b, lapack_int ldb ); -lapack_int LAPACKE_cpotrs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, lapack_complex_float* b, - lapack_int ldb ); -lapack_int LAPACKE_zpotrs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, lapack_complex_double* b, - lapack_int ldb ); - -lapack_int LAPACKE_sppcon( int matrix_layout, char uplo, lapack_int n, - const float* ap, float anorm, float* rcond ); -lapack_int LAPACKE_dppcon( int matrix_layout, char uplo, lapack_int n, - const double* ap, double anorm, double* rcond ); -lapack_int LAPACKE_cppcon( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float* ap, float anorm, - float* rcond ); -lapack_int LAPACKE_zppcon( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double* ap, double anorm, - double* rcond ); - -lapack_int LAPACKE_sppequ( int matrix_layout, char uplo, lapack_int n, - const float* ap, float* s, float* scond, - float* amax ); -lapack_int LAPACKE_dppequ( int matrix_layout, char uplo, lapack_int n, - const double* ap, double* s, double* scond, - double* amax ); -lapack_int LAPACKE_cppequ( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float* ap, float* s, - float* scond, float* amax ); -lapack_int LAPACKE_zppequ( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double* ap, double* s, - double* scond, double* amax ); - -lapack_int LAPACKE_spprfs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const float* ap, const float* afp, - const float* b, lapack_int ldb, float* x, - lapack_int ldx, float* ferr, float* berr ); -lapack_int LAPACKE_dpprfs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const double* ap, const double* afp, - const double* b, lapack_int ldb, double* x, - lapack_int ldx, double* ferr, double* berr ); -lapack_int LAPACKE_cpprfs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* ap, - const lapack_complex_float* afp, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, float* ferr, - float* berr ); -lapack_int LAPACKE_zpprfs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* ap, - const lapack_complex_double* afp, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* ferr, double* berr ); - -lapack_int LAPACKE_sppsv( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, float* ap, float* b, - lapack_int ldb ); -lapack_int LAPACKE_dppsv( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, double* ap, double* b, - lapack_int ldb ); -lapack_int LAPACKE_cppsv( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* ap, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zppsv( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* ap, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_sppsvx( int matrix_layout, char fact, char uplo, lapack_int n, - lapack_int nrhs, float* ap, float* afp, char* equed, - float* s, float* b, lapack_int ldb, float* x, - lapack_int ldx, float* rcond, float* ferr, - float* berr ); -lapack_int LAPACKE_dppsvx( int matrix_layout, char fact, char uplo, lapack_int n, - lapack_int nrhs, double* ap, double* afp, - char* equed, double* s, double* b, lapack_int ldb, - double* x, lapack_int ldx, double* rcond, - double* ferr, double* berr ); -lapack_int LAPACKE_cppsvx( int matrix_layout, char fact, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* ap, - lapack_complex_float* afp, char* equed, float* s, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* rcond, float* ferr, float* berr ); -lapack_int LAPACKE_zppsvx( int matrix_layout, char fact, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* ap, - lapack_complex_double* afp, char* equed, double* s, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* ferr, double* berr ); - -lapack_int LAPACKE_spptrf( int matrix_layout, char uplo, lapack_int n, - float* ap ); -lapack_int LAPACKE_dpptrf( int matrix_layout, char uplo, lapack_int n, - double* ap ); -lapack_int LAPACKE_cpptrf( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* ap ); -lapack_int LAPACKE_zpptrf( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* ap ); - -lapack_int LAPACKE_spptri( int matrix_layout, char uplo, lapack_int n, - float* ap ); -lapack_int LAPACKE_dpptri( int matrix_layout, char uplo, lapack_int n, - double* ap ); -lapack_int LAPACKE_cpptri( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* ap ); -lapack_int LAPACKE_zpptri( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* ap ); - -lapack_int LAPACKE_spptrs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const float* ap, float* b, - lapack_int ldb ); -lapack_int LAPACKE_dpptrs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const double* ap, double* b, - lapack_int ldb ); -lapack_int LAPACKE_cpptrs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* ap, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zpptrs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* ap, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_spstrf( int matrix_layout, char uplo, lapack_int n, float* a, - lapack_int lda, lapack_int* piv, lapack_int* rank, - float tol ); -lapack_int LAPACKE_dpstrf( int matrix_layout, char uplo, lapack_int n, double* a, - lapack_int lda, lapack_int* piv, lapack_int* rank, - double tol ); -lapack_int LAPACKE_cpstrf( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int* piv, lapack_int* rank, float tol ); -lapack_int LAPACKE_zpstrf( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int* piv, lapack_int* rank, double tol ); - -lapack_int LAPACKE_sptcon( lapack_int n, const float* d, const float* e, - float anorm, float* rcond ); -lapack_int LAPACKE_dptcon( lapack_int n, const double* d, const double* e, - double anorm, double* rcond ); -lapack_int LAPACKE_cptcon( lapack_int n, const float* d, - const lapack_complex_float* e, float anorm, - float* rcond ); -lapack_int LAPACKE_zptcon( lapack_int n, const double* d, - const lapack_complex_double* e, double anorm, - double* rcond ); - -lapack_int LAPACKE_spteqr( int matrix_layout, char compz, lapack_int n, float* d, - float* e, float* z, lapack_int ldz ); -lapack_int LAPACKE_dpteqr( int matrix_layout, char compz, lapack_int n, - double* d, double* e, double* z, lapack_int ldz ); -lapack_int LAPACKE_cpteqr( int matrix_layout, char compz, lapack_int n, float* d, - float* e, lapack_complex_float* z, lapack_int ldz ); -lapack_int LAPACKE_zpteqr( int matrix_layout, char compz, lapack_int n, - double* d, double* e, lapack_complex_double* z, - lapack_int ldz ); - -lapack_int LAPACKE_sptrfs( int matrix_layout, lapack_int n, lapack_int nrhs, - const float* d, const float* e, const float* df, - const float* ef, const float* b, lapack_int ldb, - float* x, lapack_int ldx, float* ferr, float* berr ); -lapack_int LAPACKE_dptrfs( int matrix_layout, lapack_int n, lapack_int nrhs, - const double* d, const double* e, const double* df, - const double* ef, const double* b, lapack_int ldb, - double* x, lapack_int ldx, double* ferr, - double* berr ); -lapack_int LAPACKE_cptrfs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const float* d, - const lapack_complex_float* e, const float* df, - const lapack_complex_float* ef, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, float* ferr, - float* berr ); -lapack_int LAPACKE_zptrfs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const double* d, - const lapack_complex_double* e, const double* df, - const lapack_complex_double* ef, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* ferr, double* berr ); - -lapack_int LAPACKE_sptsv( int matrix_layout, lapack_int n, lapack_int nrhs, - float* d, float* e, float* b, lapack_int ldb ); -lapack_int LAPACKE_dptsv( int matrix_layout, lapack_int n, lapack_int nrhs, - double* d, double* e, double* b, lapack_int ldb ); -lapack_int LAPACKE_cptsv( int matrix_layout, lapack_int n, lapack_int nrhs, - float* d, lapack_complex_float* e, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zptsv( int matrix_layout, lapack_int n, lapack_int nrhs, - double* d, lapack_complex_double* e, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_sptsvx( int matrix_layout, char fact, lapack_int n, - lapack_int nrhs, const float* d, const float* e, - float* df, float* ef, const float* b, lapack_int ldb, - float* x, lapack_int ldx, float* rcond, float* ferr, - float* berr ); -lapack_int LAPACKE_dptsvx( int matrix_layout, char fact, lapack_int n, - lapack_int nrhs, const double* d, const double* e, - double* df, double* ef, const double* b, - lapack_int ldb, double* x, lapack_int ldx, - double* rcond, double* ferr, double* berr ); -lapack_int LAPACKE_cptsvx( int matrix_layout, char fact, lapack_int n, - lapack_int nrhs, const float* d, - const lapack_complex_float* e, float* df, - lapack_complex_float* ef, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* rcond, float* ferr, float* berr ); -lapack_int LAPACKE_zptsvx( int matrix_layout, char fact, lapack_int n, - lapack_int nrhs, const double* d, - const lapack_complex_double* e, double* df, - lapack_complex_double* ef, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* ferr, double* berr ); - -lapack_int LAPACKE_spttrf( lapack_int n, float* d, float* e ); -lapack_int LAPACKE_dpttrf( lapack_int n, double* d, double* e ); -lapack_int LAPACKE_cpttrf( lapack_int n, float* d, lapack_complex_float* e ); -lapack_int LAPACKE_zpttrf( lapack_int n, double* d, lapack_complex_double* e ); - -lapack_int LAPACKE_spttrs( int matrix_layout, lapack_int n, lapack_int nrhs, - const float* d, const float* e, float* b, - lapack_int ldb ); -lapack_int LAPACKE_dpttrs( int matrix_layout, lapack_int n, lapack_int nrhs, - const double* d, const double* e, double* b, - lapack_int ldb ); -lapack_int LAPACKE_cpttrs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const float* d, - const lapack_complex_float* e, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zpttrs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const double* d, - const lapack_complex_double* e, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_ssbev( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_int kd, float* ab, lapack_int ldab, float* w, - float* z, lapack_int ldz ); -lapack_int LAPACKE_dsbev( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_int kd, double* ab, lapack_int ldab, double* w, - double* z, lapack_int ldz ); - -lapack_int LAPACKE_ssbevd( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_int kd, float* ab, lapack_int ldab, float* w, - float* z, lapack_int ldz ); -lapack_int LAPACKE_dsbevd( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_int kd, double* ab, lapack_int ldab, - double* w, double* z, lapack_int ldz ); - -lapack_int LAPACKE_ssbevx( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, lapack_int kd, float* ab, - lapack_int ldab, float* q, lapack_int ldq, float vl, - float vu, lapack_int il, lapack_int iu, float abstol, - lapack_int* m, float* w, float* z, lapack_int ldz, - lapack_int* ifail ); -lapack_int LAPACKE_dsbevx( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, lapack_int kd, double* ab, - lapack_int ldab, double* q, lapack_int ldq, - double vl, double vu, lapack_int il, lapack_int iu, - double abstol, lapack_int* m, double* w, double* z, - lapack_int ldz, lapack_int* ifail ); - -lapack_int LAPACKE_ssbgst( int matrix_layout, char vect, char uplo, lapack_int n, - lapack_int ka, lapack_int kb, float* ab, - lapack_int ldab, const float* bb, lapack_int ldbb, - float* x, lapack_int ldx ); -lapack_int LAPACKE_dsbgst( int matrix_layout, char vect, char uplo, lapack_int n, - lapack_int ka, lapack_int kb, double* ab, - lapack_int ldab, const double* bb, lapack_int ldbb, - double* x, lapack_int ldx ); - -lapack_int LAPACKE_ssbgv( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_int ka, lapack_int kb, float* ab, - lapack_int ldab, float* bb, lapack_int ldbb, float* w, - float* z, lapack_int ldz ); -lapack_int LAPACKE_dsbgv( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_int ka, lapack_int kb, double* ab, - lapack_int ldab, double* bb, lapack_int ldbb, - double* w, double* z, lapack_int ldz ); - -lapack_int LAPACKE_ssbgvd( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_int ka, lapack_int kb, float* ab, - lapack_int ldab, float* bb, lapack_int ldbb, - float* w, float* z, lapack_int ldz ); -lapack_int LAPACKE_dsbgvd( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_int ka, lapack_int kb, double* ab, - lapack_int ldab, double* bb, lapack_int ldbb, - double* w, double* z, lapack_int ldz ); - -lapack_int LAPACKE_ssbgvx( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, lapack_int ka, lapack_int kb, - float* ab, lapack_int ldab, float* bb, - lapack_int ldbb, float* q, lapack_int ldq, float vl, - float vu, lapack_int il, lapack_int iu, float abstol, - lapack_int* m, float* w, float* z, lapack_int ldz, - lapack_int* ifail ); -lapack_int LAPACKE_dsbgvx( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, lapack_int ka, lapack_int kb, - double* ab, lapack_int ldab, double* bb, - lapack_int ldbb, double* q, lapack_int ldq, - double vl, double vu, lapack_int il, lapack_int iu, - double abstol, lapack_int* m, double* w, double* z, - lapack_int ldz, lapack_int* ifail ); - -lapack_int LAPACKE_ssbtrd( int matrix_layout, char vect, char uplo, lapack_int n, - lapack_int kd, float* ab, lapack_int ldab, float* d, - float* e, float* q, lapack_int ldq ); -lapack_int LAPACKE_dsbtrd( int matrix_layout, char vect, char uplo, lapack_int n, - lapack_int kd, double* ab, lapack_int ldab, - double* d, double* e, double* q, lapack_int ldq ); - -lapack_int LAPACKE_ssfrk( int matrix_layout, char transr, char uplo, char trans, - lapack_int n, lapack_int k, float alpha, - const float* a, lapack_int lda, float beta, - float* c ); -lapack_int LAPACKE_dsfrk( int matrix_layout, char transr, char uplo, char trans, - lapack_int n, lapack_int k, double alpha, - const double* a, lapack_int lda, double beta, - double* c ); - -lapack_int LAPACKE_sspcon( int matrix_layout, char uplo, lapack_int n, - const float* ap, const lapack_int* ipiv, float anorm, - float* rcond ); -lapack_int LAPACKE_dspcon( int matrix_layout, char uplo, lapack_int n, - const double* ap, const lapack_int* ipiv, - double anorm, double* rcond ); -lapack_int LAPACKE_cspcon( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float* ap, - const lapack_int* ipiv, float anorm, float* rcond ); -lapack_int LAPACKE_zspcon( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double* ap, - const lapack_int* ipiv, double anorm, - double* rcond ); - -lapack_int LAPACKE_sspev( int matrix_layout, char jobz, char uplo, lapack_int n, - float* ap, float* w, float* z, lapack_int ldz ); -lapack_int LAPACKE_dspev( int matrix_layout, char jobz, char uplo, lapack_int n, - double* ap, double* w, double* z, lapack_int ldz ); - -lapack_int LAPACKE_sspevd( int matrix_layout, char jobz, char uplo, lapack_int n, - float* ap, float* w, float* z, lapack_int ldz ); -lapack_int LAPACKE_dspevd( int matrix_layout, char jobz, char uplo, lapack_int n, - double* ap, double* w, double* z, lapack_int ldz ); - -lapack_int LAPACKE_sspevx( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, float* ap, float vl, float vu, - lapack_int il, lapack_int iu, float abstol, - lapack_int* m, float* w, float* z, lapack_int ldz, - lapack_int* ifail ); -lapack_int LAPACKE_dspevx( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, double* ap, double vl, double vu, - lapack_int il, lapack_int iu, double abstol, - lapack_int* m, double* w, double* z, lapack_int ldz, - lapack_int* ifail ); - -lapack_int LAPACKE_sspgst( int matrix_layout, lapack_int itype, char uplo, - lapack_int n, float* ap, const float* bp ); -lapack_int LAPACKE_dspgst( int matrix_layout, lapack_int itype, char uplo, - lapack_int n, double* ap, const double* bp ); - -lapack_int LAPACKE_sspgv( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, float* ap, float* bp, - float* w, float* z, lapack_int ldz ); -lapack_int LAPACKE_dspgv( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, double* ap, double* bp, - double* w, double* z, lapack_int ldz ); - -lapack_int LAPACKE_sspgvd( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, float* ap, float* bp, - float* w, float* z, lapack_int ldz ); -lapack_int LAPACKE_dspgvd( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, double* ap, double* bp, - double* w, double* z, lapack_int ldz ); - -lapack_int LAPACKE_sspgvx( int matrix_layout, lapack_int itype, char jobz, - char range, char uplo, lapack_int n, float* ap, - float* bp, float vl, float vu, lapack_int il, - lapack_int iu, float abstol, lapack_int* m, float* w, - float* z, lapack_int ldz, lapack_int* ifail ); -lapack_int LAPACKE_dspgvx( int matrix_layout, lapack_int itype, char jobz, - char range, char uplo, lapack_int n, double* ap, - double* bp, double vl, double vu, lapack_int il, - lapack_int iu, double abstol, lapack_int* m, - double* w, double* z, lapack_int ldz, - lapack_int* ifail ); - -lapack_int LAPACKE_ssprfs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const float* ap, const float* afp, - const lapack_int* ipiv, const float* b, - lapack_int ldb, float* x, lapack_int ldx, - float* ferr, float* berr ); -lapack_int LAPACKE_dsprfs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const double* ap, const double* afp, - const lapack_int* ipiv, const double* b, - lapack_int ldb, double* x, lapack_int ldx, - double* ferr, double* berr ); -lapack_int LAPACKE_csprfs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* ap, - const lapack_complex_float* afp, - const lapack_int* ipiv, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, float* ferr, - float* berr ); -lapack_int LAPACKE_zsprfs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* ap, - const lapack_complex_double* afp, - const lapack_int* ipiv, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* ferr, double* berr ); - -lapack_int LAPACKE_sspsv( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, float* ap, lapack_int* ipiv, - float* b, lapack_int ldb ); -lapack_int LAPACKE_dspsv( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, double* ap, lapack_int* ipiv, - double* b, lapack_int ldb ); -lapack_int LAPACKE_cspsv( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* ap, - lapack_int* ipiv, lapack_complex_float* b, - lapack_int ldb ); -lapack_int LAPACKE_zspsv( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* ap, - lapack_int* ipiv, lapack_complex_double* b, - lapack_int ldb ); - -lapack_int LAPACKE_sspsvx( int matrix_layout, char fact, char uplo, lapack_int n, - lapack_int nrhs, const float* ap, float* afp, - lapack_int* ipiv, const float* b, lapack_int ldb, - float* x, lapack_int ldx, float* rcond, float* ferr, - float* berr ); -lapack_int LAPACKE_dspsvx( int matrix_layout, char fact, char uplo, lapack_int n, - lapack_int nrhs, const double* ap, double* afp, - lapack_int* ipiv, const double* b, lapack_int ldb, - double* x, lapack_int ldx, double* rcond, - double* ferr, double* berr ); -lapack_int LAPACKE_cspsvx( int matrix_layout, char fact, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* ap, - lapack_complex_float* afp, lapack_int* ipiv, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* rcond, float* ferr, float* berr ); -lapack_int LAPACKE_zspsvx( int matrix_layout, char fact, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* ap, - lapack_complex_double* afp, lapack_int* ipiv, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* ferr, double* berr ); - -lapack_int LAPACKE_ssptrd( int matrix_layout, char uplo, lapack_int n, float* ap, - float* d, float* e, float* tau ); -lapack_int LAPACKE_dsptrd( int matrix_layout, char uplo, lapack_int n, - double* ap, double* d, double* e, double* tau ); - -lapack_int LAPACKE_ssptrf( int matrix_layout, char uplo, lapack_int n, float* ap, - lapack_int* ipiv ); -lapack_int LAPACKE_dsptrf( int matrix_layout, char uplo, lapack_int n, - double* ap, lapack_int* ipiv ); -lapack_int LAPACKE_csptrf( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* ap, lapack_int* ipiv ); -lapack_int LAPACKE_zsptrf( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* ap, lapack_int* ipiv ); - -lapack_int LAPACKE_ssptri( int matrix_layout, char uplo, lapack_int n, float* ap, - const lapack_int* ipiv ); -lapack_int LAPACKE_dsptri( int matrix_layout, char uplo, lapack_int n, - double* ap, const lapack_int* ipiv ); -lapack_int LAPACKE_csptri( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* ap, const lapack_int* ipiv ); -lapack_int LAPACKE_zsptri( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* ap, const lapack_int* ipiv ); - -lapack_int LAPACKE_ssptrs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const float* ap, - const lapack_int* ipiv, float* b, lapack_int ldb ); -lapack_int LAPACKE_dsptrs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const double* ap, - const lapack_int* ipiv, double* b, lapack_int ldb ); -lapack_int LAPACKE_csptrs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* ap, - const lapack_int* ipiv, lapack_complex_float* b, - lapack_int ldb ); -lapack_int LAPACKE_zsptrs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* ap, - const lapack_int* ipiv, lapack_complex_double* b, - lapack_int ldb ); - -lapack_int LAPACKE_sstebz( char range, char order, lapack_int n, float vl, - float vu, lapack_int il, lapack_int iu, float abstol, - const float* d, const float* e, lapack_int* m, - lapack_int* nsplit, float* w, lapack_int* iblock, - lapack_int* isplit ); -lapack_int LAPACKE_dstebz( char range, char order, lapack_int n, double vl, - double vu, lapack_int il, lapack_int iu, - double abstol, const double* d, const double* e, - lapack_int* m, lapack_int* nsplit, double* w, - lapack_int* iblock, lapack_int* isplit ); - -lapack_int LAPACKE_sstedc( int matrix_layout, char compz, lapack_int n, float* d, - float* e, float* z, lapack_int ldz ); -lapack_int LAPACKE_dstedc( int matrix_layout, char compz, lapack_int n, - double* d, double* e, double* z, lapack_int ldz ); -lapack_int LAPACKE_cstedc( int matrix_layout, char compz, lapack_int n, float* d, - float* e, lapack_complex_float* z, lapack_int ldz ); -lapack_int LAPACKE_zstedc( int matrix_layout, char compz, lapack_int n, - double* d, double* e, lapack_complex_double* z, - lapack_int ldz ); - -lapack_int LAPACKE_sstegr( int matrix_layout, char jobz, char range, - lapack_int n, float* d, float* e, float vl, float vu, - lapack_int il, lapack_int iu, float abstol, - lapack_int* m, float* w, float* z, lapack_int ldz, - lapack_int* isuppz ); -lapack_int LAPACKE_dstegr( int matrix_layout, char jobz, char range, - lapack_int n, double* d, double* e, double vl, - double vu, lapack_int il, lapack_int iu, - double abstol, lapack_int* m, double* w, double* z, - lapack_int ldz, lapack_int* isuppz ); -lapack_int LAPACKE_cstegr( int matrix_layout, char jobz, char range, - lapack_int n, float* d, float* e, float vl, float vu, - lapack_int il, lapack_int iu, float abstol, - lapack_int* m, float* w, lapack_complex_float* z, - lapack_int ldz, lapack_int* isuppz ); -lapack_int LAPACKE_zstegr( int matrix_layout, char jobz, char range, - lapack_int n, double* d, double* e, double vl, - double vu, lapack_int il, lapack_int iu, - double abstol, lapack_int* m, double* w, - lapack_complex_double* z, lapack_int ldz, - lapack_int* isuppz ); - -lapack_int LAPACKE_sstein( int matrix_layout, lapack_int n, const float* d, - const float* e, lapack_int m, const float* w, - const lapack_int* iblock, const lapack_int* isplit, - float* z, lapack_int ldz, lapack_int* ifailv ); -lapack_int LAPACKE_dstein( int matrix_layout, lapack_int n, const double* d, - const double* e, lapack_int m, const double* w, - const lapack_int* iblock, const lapack_int* isplit, - double* z, lapack_int ldz, lapack_int* ifailv ); -lapack_int LAPACKE_cstein( int matrix_layout, lapack_int n, const float* d, - const float* e, lapack_int m, const float* w, - const lapack_int* iblock, const lapack_int* isplit, - lapack_complex_float* z, lapack_int ldz, - lapack_int* ifailv ); -lapack_int LAPACKE_zstein( int matrix_layout, lapack_int n, const double* d, - const double* e, lapack_int m, const double* w, - const lapack_int* iblock, const lapack_int* isplit, - lapack_complex_double* z, lapack_int ldz, - lapack_int* ifailv ); - -lapack_int LAPACKE_sstemr( int matrix_layout, char jobz, char range, - lapack_int n, float* d, float* e, float vl, float vu, - lapack_int il, lapack_int iu, lapack_int* m, - float* w, float* z, lapack_int ldz, lapack_int nzc, - lapack_int* isuppz, lapack_logical* tryrac ); -lapack_int LAPACKE_dstemr( int matrix_layout, char jobz, char range, - lapack_int n, double* d, double* e, double vl, - double vu, lapack_int il, lapack_int iu, - lapack_int* m, double* w, double* z, lapack_int ldz, - lapack_int nzc, lapack_int* isuppz, - lapack_logical* tryrac ); -lapack_int LAPACKE_cstemr( int matrix_layout, char jobz, char range, - lapack_int n, float* d, float* e, float vl, float vu, - lapack_int il, lapack_int iu, lapack_int* m, - float* w, lapack_complex_float* z, lapack_int ldz, - lapack_int nzc, lapack_int* isuppz, - lapack_logical* tryrac ); -lapack_int LAPACKE_zstemr( int matrix_layout, char jobz, char range, - lapack_int n, double* d, double* e, double vl, - double vu, lapack_int il, lapack_int iu, - lapack_int* m, double* w, lapack_complex_double* z, - lapack_int ldz, lapack_int nzc, lapack_int* isuppz, - lapack_logical* tryrac ); - -lapack_int LAPACKE_ssteqr( int matrix_layout, char compz, lapack_int n, float* d, - float* e, float* z, lapack_int ldz ); -lapack_int LAPACKE_dsteqr( int matrix_layout, char compz, lapack_int n, - double* d, double* e, double* z, lapack_int ldz ); -lapack_int LAPACKE_csteqr( int matrix_layout, char compz, lapack_int n, float* d, - float* e, lapack_complex_float* z, lapack_int ldz ); -lapack_int LAPACKE_zsteqr( int matrix_layout, char compz, lapack_int n, - double* d, double* e, lapack_complex_double* z, - lapack_int ldz ); - -lapack_int LAPACKE_ssterf( lapack_int n, float* d, float* e ); -lapack_int LAPACKE_dsterf( lapack_int n, double* d, double* e ); - -lapack_int LAPACKE_sstev( int matrix_layout, char jobz, lapack_int n, float* d, - float* e, float* z, lapack_int ldz ); -lapack_int LAPACKE_dstev( int matrix_layout, char jobz, lapack_int n, double* d, - double* e, double* z, lapack_int ldz ); - -lapack_int LAPACKE_sstevd( int matrix_layout, char jobz, lapack_int n, float* d, - float* e, float* z, lapack_int ldz ); -lapack_int LAPACKE_dstevd( int matrix_layout, char jobz, lapack_int n, double* d, - double* e, double* z, lapack_int ldz ); - -lapack_int LAPACKE_sstevr( int matrix_layout, char jobz, char range, - lapack_int n, float* d, float* e, float vl, float vu, - lapack_int il, lapack_int iu, float abstol, - lapack_int* m, float* w, float* z, lapack_int ldz, - lapack_int* isuppz ); -lapack_int LAPACKE_dstevr( int matrix_layout, char jobz, char range, - lapack_int n, double* d, double* e, double vl, - double vu, lapack_int il, lapack_int iu, - double abstol, lapack_int* m, double* w, double* z, - lapack_int ldz, lapack_int* isuppz ); - -lapack_int LAPACKE_sstevx( int matrix_layout, char jobz, char range, - lapack_int n, float* d, float* e, float vl, float vu, - lapack_int il, lapack_int iu, float abstol, - lapack_int* m, float* w, float* z, lapack_int ldz, - lapack_int* ifail ); -lapack_int LAPACKE_dstevx( int matrix_layout, char jobz, char range, - lapack_int n, double* d, double* e, double vl, - double vu, lapack_int il, lapack_int iu, - double abstol, lapack_int* m, double* w, double* z, - lapack_int ldz, lapack_int* ifail ); - -lapack_int LAPACKE_ssycon( int matrix_layout, char uplo, lapack_int n, - const float* a, lapack_int lda, - const lapack_int* ipiv, float anorm, float* rcond ); -lapack_int LAPACKE_dsycon( int matrix_layout, char uplo, lapack_int n, - const double* a, lapack_int lda, - const lapack_int* ipiv, double anorm, - double* rcond ); -lapack_int LAPACKE_csycon( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - const lapack_int* ipiv, float anorm, float* rcond ); -lapack_int LAPACKE_zsycon( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - const lapack_int* ipiv, double anorm, - double* rcond ); - -lapack_int LAPACKE_ssyequb( int matrix_layout, char uplo, lapack_int n, - const float* a, lapack_int lda, float* s, - float* scond, float* amax ); -lapack_int LAPACKE_dsyequb( int matrix_layout, char uplo, lapack_int n, - const double* a, lapack_int lda, double* s, - double* scond, double* amax ); -lapack_int LAPACKE_csyequb( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - float* s, float* scond, float* amax ); -lapack_int LAPACKE_zsyequb( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - double* s, double* scond, double* amax ); - -lapack_int LAPACKE_ssyev( int matrix_layout, char jobz, char uplo, lapack_int n, - float* a, lapack_int lda, float* w ); -lapack_int LAPACKE_dsyev( int matrix_layout, char jobz, char uplo, lapack_int n, - double* a, lapack_int lda, double* w ); - -lapack_int LAPACKE_ssyevd( int matrix_layout, char jobz, char uplo, lapack_int n, - float* a, lapack_int lda, float* w ); -lapack_int LAPACKE_dsyevd( int matrix_layout, char jobz, char uplo, lapack_int n, - double* a, lapack_int lda, double* w ); - -lapack_int LAPACKE_ssyevr( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, float* a, lapack_int lda, float vl, - float vu, lapack_int il, lapack_int iu, float abstol, - lapack_int* m, float* w, float* z, lapack_int ldz, - lapack_int* isuppz ); -lapack_int LAPACKE_dsyevr( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, double* a, lapack_int lda, double vl, - double vu, lapack_int il, lapack_int iu, - double abstol, lapack_int* m, double* w, double* z, - lapack_int ldz, lapack_int* isuppz ); - -lapack_int LAPACKE_ssyevx( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, float* a, lapack_int lda, float vl, - float vu, lapack_int il, lapack_int iu, float abstol, - lapack_int* m, float* w, float* z, lapack_int ldz, - lapack_int* ifail ); -lapack_int LAPACKE_dsyevx( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, double* a, lapack_int lda, double vl, - double vu, lapack_int il, lapack_int iu, - double abstol, lapack_int* m, double* w, double* z, - lapack_int ldz, lapack_int* ifail ); - -lapack_int LAPACKE_ssygst( int matrix_layout, lapack_int itype, char uplo, - lapack_int n, float* a, lapack_int lda, - const float* b, lapack_int ldb ); -lapack_int LAPACKE_dsygst( int matrix_layout, lapack_int itype, char uplo, - lapack_int n, double* a, lapack_int lda, - const double* b, lapack_int ldb ); - -lapack_int LAPACKE_ssygv( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, float* a, lapack_int lda, - float* b, lapack_int ldb, float* w ); -lapack_int LAPACKE_dsygv( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, double* a, lapack_int lda, - double* b, lapack_int ldb, double* w ); - -lapack_int LAPACKE_ssygvd( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, float* a, lapack_int lda, - float* b, lapack_int ldb, float* w ); -lapack_int LAPACKE_dsygvd( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, double* a, lapack_int lda, - double* b, lapack_int ldb, double* w ); - -lapack_int LAPACKE_ssygvx( int matrix_layout, lapack_int itype, char jobz, - char range, char uplo, lapack_int n, float* a, - lapack_int lda, float* b, lapack_int ldb, float vl, - float vu, lapack_int il, lapack_int iu, float abstol, - lapack_int* m, float* w, float* z, lapack_int ldz, - lapack_int* ifail ); -lapack_int LAPACKE_dsygvx( int matrix_layout, lapack_int itype, char jobz, - char range, char uplo, lapack_int n, double* a, - lapack_int lda, double* b, lapack_int ldb, double vl, - double vu, lapack_int il, lapack_int iu, - double abstol, lapack_int* m, double* w, double* z, - lapack_int ldz, lapack_int* ifail ); - -lapack_int LAPACKE_ssyrfs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const float* a, lapack_int lda, - const float* af, lapack_int ldaf, - const lapack_int* ipiv, const float* b, - lapack_int ldb, float* x, lapack_int ldx, - float* ferr, float* berr ); -lapack_int LAPACKE_dsyrfs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const double* a, lapack_int lda, - const double* af, lapack_int ldaf, - const lapack_int* ipiv, const double* b, - lapack_int ldb, double* x, lapack_int ldx, - double* ferr, double* berr ); -lapack_int LAPACKE_csyrfs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* af, - lapack_int ldaf, const lapack_int* ipiv, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, float* ferr, - float* berr ); -lapack_int LAPACKE_zsyrfs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_complex_double* af, - lapack_int ldaf, const lapack_int* ipiv, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* ferr, double* berr ); - -lapack_int LAPACKE_ssyrfsx( int matrix_layout, char uplo, char equed, - lapack_int n, lapack_int nrhs, const float* a, - lapack_int lda, const float* af, lapack_int ldaf, - const lapack_int* ipiv, const float* s, - const float* b, lapack_int ldb, float* x, - lapack_int ldx, float* rcond, float* berr, - lapack_int n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int nparams, - float* params ); -lapack_int LAPACKE_dsyrfsx( int matrix_layout, char uplo, char equed, - lapack_int n, lapack_int nrhs, const double* a, - lapack_int lda, const double* af, lapack_int ldaf, - const lapack_int* ipiv, const double* s, - const double* b, lapack_int ldb, double* x, - lapack_int ldx, double* rcond, double* berr, - lapack_int n_err_bnds, double* err_bnds_norm, - double* err_bnds_comp, lapack_int nparams, - double* params ); -lapack_int LAPACKE_csyrfsx( int matrix_layout, char uplo, char equed, - lapack_int n, lapack_int nrhs, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* af, lapack_int ldaf, - const lapack_int* ipiv, const float* s, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* rcond, float* berr, lapack_int n_err_bnds, - float* err_bnds_norm, float* err_bnds_comp, - lapack_int nparams, float* params ); -lapack_int LAPACKE_zsyrfsx( int matrix_layout, char uplo, char equed, - lapack_int n, lapack_int nrhs, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* af, lapack_int ldaf, - const lapack_int* ipiv, const double* s, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* berr, lapack_int n_err_bnds, - double* err_bnds_norm, double* err_bnds_comp, - lapack_int nparams, double* params ); - -lapack_int LAPACKE_ssysv( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, float* a, lapack_int lda, - lapack_int* ipiv, float* b, lapack_int ldb ); -lapack_int LAPACKE_dsysv( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, double* a, lapack_int lda, - lapack_int* ipiv, double* b, lapack_int ldb ); -lapack_int LAPACKE_csysv( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zsysv( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_ssysvx( int matrix_layout, char fact, char uplo, lapack_int n, - lapack_int nrhs, const float* a, lapack_int lda, - float* af, lapack_int ldaf, lapack_int* ipiv, - const float* b, lapack_int ldb, float* x, - lapack_int ldx, float* rcond, float* ferr, - float* berr ); -lapack_int LAPACKE_dsysvx( int matrix_layout, char fact, char uplo, lapack_int n, - lapack_int nrhs, const double* a, lapack_int lda, - double* af, lapack_int ldaf, lapack_int* ipiv, - const double* b, lapack_int ldb, double* x, - lapack_int ldx, double* rcond, double* ferr, - double* berr ); -lapack_int LAPACKE_csysvx( int matrix_layout, char fact, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, lapack_complex_float* af, - lapack_int ldaf, lapack_int* ipiv, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* rcond, float* ferr, float* berr ); -lapack_int LAPACKE_zsysvx( int matrix_layout, char fact, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, lapack_complex_double* af, - lapack_int ldaf, lapack_int* ipiv, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* ferr, double* berr ); - -lapack_int LAPACKE_ssysvxx( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, float* a, - lapack_int lda, float* af, lapack_int ldaf, - lapack_int* ipiv, char* equed, float* s, float* b, - lapack_int ldb, float* x, lapack_int ldx, - float* rcond, float* rpvgrw, float* berr, - lapack_int n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int nparams, - float* params ); -lapack_int LAPACKE_dsysvxx( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, double* a, - lapack_int lda, double* af, lapack_int ldaf, - lapack_int* ipiv, char* equed, double* s, double* b, - lapack_int ldb, double* x, lapack_int ldx, - double* rcond, double* rpvgrw, double* berr, - lapack_int n_err_bnds, double* err_bnds_norm, - double* err_bnds_comp, lapack_int nparams, - double* params ); -lapack_int LAPACKE_csysvxx( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* af, lapack_int ldaf, - lapack_int* ipiv, char* equed, float* s, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* rcond, float* rpvgrw, float* berr, - lapack_int n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int nparams, - float* params ); -lapack_int LAPACKE_zsysvxx( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* af, lapack_int ldaf, - lapack_int* ipiv, char* equed, double* s, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* rpvgrw, double* berr, - lapack_int n_err_bnds, double* err_bnds_norm, - double* err_bnds_comp, lapack_int nparams, - double* params ); - -lapack_int LAPACKE_ssytrd( int matrix_layout, char uplo, lapack_int n, float* a, - lapack_int lda, float* d, float* e, float* tau ); -lapack_int LAPACKE_dsytrd( int matrix_layout, char uplo, lapack_int n, double* a, - lapack_int lda, double* d, double* e, double* tau ); - -lapack_int LAPACKE_ssytrf( int matrix_layout, char uplo, lapack_int n, float* a, - lapack_int lda, lapack_int* ipiv ); -lapack_int LAPACKE_dsytrf( int matrix_layout, char uplo, lapack_int n, double* a, - lapack_int lda, lapack_int* ipiv ); -lapack_int LAPACKE_csytrf( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int* ipiv ); -lapack_int LAPACKE_zsytrf( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int* ipiv ); - -lapack_int LAPACKE_ssytri( int matrix_layout, char uplo, lapack_int n, float* a, - lapack_int lda, const lapack_int* ipiv ); -lapack_int LAPACKE_dsytri( int matrix_layout, char uplo, lapack_int n, double* a, - lapack_int lda, const lapack_int* ipiv ); -lapack_int LAPACKE_csytri( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - const lapack_int* ipiv ); -lapack_int LAPACKE_zsytri( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - const lapack_int* ipiv ); - -lapack_int LAPACKE_ssytrs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const float* a, lapack_int lda, - const lapack_int* ipiv, float* b, lapack_int ldb ); -lapack_int LAPACKE_dsytrs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const double* a, lapack_int lda, - const lapack_int* ipiv, double* b, lapack_int ldb ); -lapack_int LAPACKE_csytrs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zsytrs( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_stbcon( int matrix_layout, char norm, char uplo, char diag, - lapack_int n, lapack_int kd, const float* ab, - lapack_int ldab, float* rcond ); -lapack_int LAPACKE_dtbcon( int matrix_layout, char norm, char uplo, char diag, - lapack_int n, lapack_int kd, const double* ab, - lapack_int ldab, double* rcond ); -lapack_int LAPACKE_ctbcon( int matrix_layout, char norm, char uplo, char diag, - lapack_int n, lapack_int kd, - const lapack_complex_float* ab, lapack_int ldab, - float* rcond ); -lapack_int LAPACKE_ztbcon( int matrix_layout, char norm, char uplo, char diag, - lapack_int n, lapack_int kd, - const lapack_complex_double* ab, lapack_int ldab, - double* rcond ); - -lapack_int LAPACKE_stbrfs( int matrix_layout, char uplo, char trans, char diag, - lapack_int n, lapack_int kd, lapack_int nrhs, - const float* ab, lapack_int ldab, const float* b, - lapack_int ldb, const float* x, lapack_int ldx, - float* ferr, float* berr ); -lapack_int LAPACKE_dtbrfs( int matrix_layout, char uplo, char trans, char diag, - lapack_int n, lapack_int kd, lapack_int nrhs, - const double* ab, lapack_int ldab, const double* b, - lapack_int ldb, const double* x, lapack_int ldx, - double* ferr, double* berr ); -lapack_int LAPACKE_ctbrfs( int matrix_layout, char uplo, char trans, char diag, - lapack_int n, lapack_int kd, lapack_int nrhs, - const lapack_complex_float* ab, lapack_int ldab, - const lapack_complex_float* b, lapack_int ldb, - const lapack_complex_float* x, lapack_int ldx, - float* ferr, float* berr ); -lapack_int LAPACKE_ztbrfs( int matrix_layout, char uplo, char trans, char diag, - lapack_int n, lapack_int kd, lapack_int nrhs, - const lapack_complex_double* ab, lapack_int ldab, - const lapack_complex_double* b, lapack_int ldb, - const lapack_complex_double* x, lapack_int ldx, - double* ferr, double* berr ); - -lapack_int LAPACKE_stbtrs( int matrix_layout, char uplo, char trans, char diag, - lapack_int n, lapack_int kd, lapack_int nrhs, - const float* ab, lapack_int ldab, float* b, - lapack_int ldb ); -lapack_int LAPACKE_dtbtrs( int matrix_layout, char uplo, char trans, char diag, - lapack_int n, lapack_int kd, lapack_int nrhs, - const double* ab, lapack_int ldab, double* b, - lapack_int ldb ); -lapack_int LAPACKE_ctbtrs( int matrix_layout, char uplo, char trans, char diag, - lapack_int n, lapack_int kd, lapack_int nrhs, - const lapack_complex_float* ab, lapack_int ldab, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_ztbtrs( int matrix_layout, char uplo, char trans, char diag, - lapack_int n, lapack_int kd, lapack_int nrhs, - const lapack_complex_double* ab, lapack_int ldab, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_stfsm( int matrix_layout, char transr, char side, char uplo, - char trans, char diag, lapack_int m, lapack_int n, - float alpha, const float* a, float* b, - lapack_int ldb ); -lapack_int LAPACKE_dtfsm( int matrix_layout, char transr, char side, char uplo, - char trans, char diag, lapack_int m, lapack_int n, - double alpha, const double* a, double* b, - lapack_int ldb ); -lapack_int LAPACKE_ctfsm( int matrix_layout, char transr, char side, char uplo, - char trans, char diag, lapack_int m, lapack_int n, - lapack_complex_float alpha, - const lapack_complex_float* a, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_ztfsm( int matrix_layout, char transr, char side, char uplo, - char trans, char diag, lapack_int m, lapack_int n, - lapack_complex_double alpha, - const lapack_complex_double* a, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_stftri( int matrix_layout, char transr, char uplo, char diag, - lapack_int n, float* a ); -lapack_int LAPACKE_dtftri( int matrix_layout, char transr, char uplo, char diag, - lapack_int n, double* a ); -lapack_int LAPACKE_ctftri( int matrix_layout, char transr, char uplo, char diag, - lapack_int n, lapack_complex_float* a ); -lapack_int LAPACKE_ztftri( int matrix_layout, char transr, char uplo, char diag, - lapack_int n, lapack_complex_double* a ); - -lapack_int LAPACKE_stfttp( int matrix_layout, char transr, char uplo, - lapack_int n, const float* arf, float* ap ); -lapack_int LAPACKE_dtfttp( int matrix_layout, char transr, char uplo, - lapack_int n, const double* arf, double* ap ); -lapack_int LAPACKE_ctfttp( int matrix_layout, char transr, char uplo, - lapack_int n, const lapack_complex_float* arf, - lapack_complex_float* ap ); -lapack_int LAPACKE_ztfttp( int matrix_layout, char transr, char uplo, - lapack_int n, const lapack_complex_double* arf, - lapack_complex_double* ap ); - -lapack_int LAPACKE_stfttr( int matrix_layout, char transr, char uplo, - lapack_int n, const float* arf, float* a, - lapack_int lda ); -lapack_int LAPACKE_dtfttr( int matrix_layout, char transr, char uplo, - lapack_int n, const double* arf, double* a, - lapack_int lda ); -lapack_int LAPACKE_ctfttr( int matrix_layout, char transr, char uplo, - lapack_int n, const lapack_complex_float* arf, - lapack_complex_float* a, lapack_int lda ); -lapack_int LAPACKE_ztfttr( int matrix_layout, char transr, char uplo, - lapack_int n, const lapack_complex_double* arf, - lapack_complex_double* a, lapack_int lda ); - -lapack_int LAPACKE_stgevc( int matrix_layout, char side, char howmny, - const lapack_logical* select, lapack_int n, - const float* s, lapack_int lds, const float* p, - lapack_int ldp, float* vl, lapack_int ldvl, - float* vr, lapack_int ldvr, lapack_int mm, - lapack_int* m ); -lapack_int LAPACKE_dtgevc( int matrix_layout, char side, char howmny, - const lapack_logical* select, lapack_int n, - const double* s, lapack_int lds, const double* p, - lapack_int ldp, double* vl, lapack_int ldvl, - double* vr, lapack_int ldvr, lapack_int mm, - lapack_int* m ); -lapack_int LAPACKE_ctgevc( int matrix_layout, char side, char howmny, - const lapack_logical* select, lapack_int n, - const lapack_complex_float* s, lapack_int lds, - const lapack_complex_float* p, lapack_int ldp, - lapack_complex_float* vl, lapack_int ldvl, - lapack_complex_float* vr, lapack_int ldvr, - lapack_int mm, lapack_int* m ); -lapack_int LAPACKE_ztgevc( int matrix_layout, char side, char howmny, - const lapack_logical* select, lapack_int n, - const lapack_complex_double* s, lapack_int lds, - const lapack_complex_double* p, lapack_int ldp, - lapack_complex_double* vl, lapack_int ldvl, - lapack_complex_double* vr, lapack_int ldvr, - lapack_int mm, lapack_int* m ); - -lapack_int LAPACKE_stgexc( int matrix_layout, lapack_logical wantq, - lapack_logical wantz, lapack_int n, float* a, - lapack_int lda, float* b, lapack_int ldb, float* q, - lapack_int ldq, float* z, lapack_int ldz, - lapack_int* ifst, lapack_int* ilst ); -lapack_int LAPACKE_dtgexc( int matrix_layout, lapack_logical wantq, - lapack_logical wantz, lapack_int n, double* a, - lapack_int lda, double* b, lapack_int ldb, double* q, - lapack_int ldq, double* z, lapack_int ldz, - lapack_int* ifst, lapack_int* ilst ); -lapack_int LAPACKE_ctgexc( int matrix_layout, lapack_logical wantq, - lapack_logical wantz, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* q, lapack_int ldq, - lapack_complex_float* z, lapack_int ldz, - lapack_int ifst, lapack_int ilst ); -lapack_int LAPACKE_ztgexc( int matrix_layout, lapack_logical wantq, - lapack_logical wantz, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* q, lapack_int ldq, - lapack_complex_double* z, lapack_int ldz, - lapack_int ifst, lapack_int ilst ); - -lapack_int LAPACKE_stgsen( int matrix_layout, lapack_int ijob, - lapack_logical wantq, lapack_logical wantz, - const lapack_logical* select, lapack_int n, float* a, - lapack_int lda, float* b, lapack_int ldb, - float* alphar, float* alphai, float* beta, float* q, - lapack_int ldq, float* z, lapack_int ldz, - lapack_int* m, float* pl, float* pr, float* dif ); -lapack_int LAPACKE_dtgsen( int matrix_layout, lapack_int ijob, - lapack_logical wantq, lapack_logical wantz, - const lapack_logical* select, lapack_int n, - double* a, lapack_int lda, double* b, lapack_int ldb, - double* alphar, double* alphai, double* beta, - double* q, lapack_int ldq, double* z, lapack_int ldz, - lapack_int* m, double* pl, double* pr, double* dif ); -lapack_int LAPACKE_ctgsen( int matrix_layout, lapack_int ijob, - lapack_logical wantq, lapack_logical wantz, - const lapack_logical* select, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* alpha, - lapack_complex_float* beta, lapack_complex_float* q, - lapack_int ldq, lapack_complex_float* z, - lapack_int ldz, lapack_int* m, float* pl, float* pr, - float* dif ); -lapack_int LAPACKE_ztgsen( int matrix_layout, lapack_int ijob, - lapack_logical wantq, lapack_logical wantz, - const lapack_logical* select, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* alpha, - lapack_complex_double* beta, - lapack_complex_double* q, lapack_int ldq, - lapack_complex_double* z, lapack_int ldz, - lapack_int* m, double* pl, double* pr, double* dif ); - -lapack_int LAPACKE_stgsja( int matrix_layout, char jobu, char jobv, char jobq, - lapack_int m, lapack_int p, lapack_int n, - lapack_int k, lapack_int l, float* a, lapack_int lda, - float* b, lapack_int ldb, float tola, float tolb, - float* alpha, float* beta, float* u, lapack_int ldu, - float* v, lapack_int ldv, float* q, lapack_int ldq, - lapack_int* ncycle ); -lapack_int LAPACKE_dtgsja( int matrix_layout, char jobu, char jobv, char jobq, - lapack_int m, lapack_int p, lapack_int n, - lapack_int k, lapack_int l, double* a, - lapack_int lda, double* b, lapack_int ldb, - double tola, double tolb, double* alpha, - double* beta, double* u, lapack_int ldu, double* v, - lapack_int ldv, double* q, lapack_int ldq, - lapack_int* ncycle ); -lapack_int LAPACKE_ctgsja( int matrix_layout, char jobu, char jobv, char jobq, - lapack_int m, lapack_int p, lapack_int n, - lapack_int k, lapack_int l, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* b, - lapack_int ldb, float tola, float tolb, float* alpha, - float* beta, lapack_complex_float* u, lapack_int ldu, - lapack_complex_float* v, lapack_int ldv, - lapack_complex_float* q, lapack_int ldq, - lapack_int* ncycle ); -lapack_int LAPACKE_ztgsja( int matrix_layout, char jobu, char jobv, char jobq, - lapack_int m, lapack_int p, lapack_int n, - lapack_int k, lapack_int l, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* b, - lapack_int ldb, double tola, double tolb, - double* alpha, double* beta, - lapack_complex_double* u, lapack_int ldu, - lapack_complex_double* v, lapack_int ldv, - lapack_complex_double* q, lapack_int ldq, - lapack_int* ncycle ); - -lapack_int LAPACKE_stgsna( int matrix_layout, char job, char howmny, - const lapack_logical* select, lapack_int n, - const float* a, lapack_int lda, const float* b, - lapack_int ldb, const float* vl, lapack_int ldvl, - const float* vr, lapack_int ldvr, float* s, - float* dif, lapack_int mm, lapack_int* m ); -lapack_int LAPACKE_dtgsna( int matrix_layout, char job, char howmny, - const lapack_logical* select, lapack_int n, - const double* a, lapack_int lda, const double* b, - lapack_int ldb, const double* vl, lapack_int ldvl, - const double* vr, lapack_int ldvr, double* s, - double* dif, lapack_int mm, lapack_int* m ); -lapack_int LAPACKE_ctgsna( int matrix_layout, char job, char howmny, - const lapack_logical* select, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* b, lapack_int ldb, - const lapack_complex_float* vl, lapack_int ldvl, - const lapack_complex_float* vr, lapack_int ldvr, - float* s, float* dif, lapack_int mm, lapack_int* m ); -lapack_int LAPACKE_ztgsna( int matrix_layout, char job, char howmny, - const lapack_logical* select, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* b, lapack_int ldb, - const lapack_complex_double* vl, lapack_int ldvl, - const lapack_complex_double* vr, lapack_int ldvr, - double* s, double* dif, lapack_int mm, - lapack_int* m ); - -lapack_int LAPACKE_stgsyl( int matrix_layout, char trans, lapack_int ijob, - lapack_int m, lapack_int n, const float* a, - lapack_int lda, const float* b, lapack_int ldb, - float* c, lapack_int ldc, const float* d, - lapack_int ldd, const float* e, lapack_int lde, - float* f, lapack_int ldf, float* scale, float* dif ); -lapack_int LAPACKE_dtgsyl( int matrix_layout, char trans, lapack_int ijob, - lapack_int m, lapack_int n, const double* a, - lapack_int lda, const double* b, lapack_int ldb, - double* c, lapack_int ldc, const double* d, - lapack_int ldd, const double* e, lapack_int lde, - double* f, lapack_int ldf, double* scale, - double* dif ); -lapack_int LAPACKE_ctgsyl( int matrix_layout, char trans, lapack_int ijob, - lapack_int m, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* c, lapack_int ldc, - const lapack_complex_float* d, lapack_int ldd, - const lapack_complex_float* e, lapack_int lde, - lapack_complex_float* f, lapack_int ldf, - float* scale, float* dif ); -lapack_int LAPACKE_ztgsyl( int matrix_layout, char trans, lapack_int ijob, - lapack_int m, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* c, lapack_int ldc, - const lapack_complex_double* d, lapack_int ldd, - const lapack_complex_double* e, lapack_int lde, - lapack_complex_double* f, lapack_int ldf, - double* scale, double* dif ); - -lapack_int LAPACKE_stpcon( int matrix_layout, char norm, char uplo, char diag, - lapack_int n, const float* ap, float* rcond ); -lapack_int LAPACKE_dtpcon( int matrix_layout, char norm, char uplo, char diag, - lapack_int n, const double* ap, double* rcond ); -lapack_int LAPACKE_ctpcon( int matrix_layout, char norm, char uplo, char diag, - lapack_int n, const lapack_complex_float* ap, - float* rcond ); -lapack_int LAPACKE_ztpcon( int matrix_layout, char norm, char uplo, char diag, - lapack_int n, const lapack_complex_double* ap, - double* rcond ); - -lapack_int LAPACKE_stprfs( int matrix_layout, char uplo, char trans, char diag, - lapack_int n, lapack_int nrhs, const float* ap, - const float* b, lapack_int ldb, const float* x, - lapack_int ldx, float* ferr, float* berr ); -lapack_int LAPACKE_dtprfs( int matrix_layout, char uplo, char trans, char diag, - lapack_int n, lapack_int nrhs, const double* ap, - const double* b, lapack_int ldb, const double* x, - lapack_int ldx, double* ferr, double* berr ); -lapack_int LAPACKE_ctprfs( int matrix_layout, char uplo, char trans, char diag, - lapack_int n, lapack_int nrhs, - const lapack_complex_float* ap, - const lapack_complex_float* b, lapack_int ldb, - const lapack_complex_float* x, lapack_int ldx, - float* ferr, float* berr ); -lapack_int LAPACKE_ztprfs( int matrix_layout, char uplo, char trans, char diag, - lapack_int n, lapack_int nrhs, - const lapack_complex_double* ap, - const lapack_complex_double* b, lapack_int ldb, - const lapack_complex_double* x, lapack_int ldx, - double* ferr, double* berr ); - -lapack_int LAPACKE_stptri( int matrix_layout, char uplo, char diag, lapack_int n, - float* ap ); -lapack_int LAPACKE_dtptri( int matrix_layout, char uplo, char diag, lapack_int n, - double* ap ); -lapack_int LAPACKE_ctptri( int matrix_layout, char uplo, char diag, lapack_int n, - lapack_complex_float* ap ); -lapack_int LAPACKE_ztptri( int matrix_layout, char uplo, char diag, lapack_int n, - lapack_complex_double* ap ); - -lapack_int LAPACKE_stptrs( int matrix_layout, char uplo, char trans, char diag, - lapack_int n, lapack_int nrhs, const float* ap, - float* b, lapack_int ldb ); -lapack_int LAPACKE_dtptrs( int matrix_layout, char uplo, char trans, char diag, - lapack_int n, lapack_int nrhs, const double* ap, - double* b, lapack_int ldb ); -lapack_int LAPACKE_ctptrs( int matrix_layout, char uplo, char trans, char diag, - lapack_int n, lapack_int nrhs, - const lapack_complex_float* ap, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_ztptrs( int matrix_layout, char uplo, char trans, char diag, - lapack_int n, lapack_int nrhs, - const lapack_complex_double* ap, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_stpttf( int matrix_layout, char transr, char uplo, - lapack_int n, const float* ap, float* arf ); -lapack_int LAPACKE_dtpttf( int matrix_layout, char transr, char uplo, - lapack_int n, const double* ap, double* arf ); -lapack_int LAPACKE_ctpttf( int matrix_layout, char transr, char uplo, - lapack_int n, const lapack_complex_float* ap, - lapack_complex_float* arf ); -lapack_int LAPACKE_ztpttf( int matrix_layout, char transr, char uplo, - lapack_int n, const lapack_complex_double* ap, - lapack_complex_double* arf ); - -lapack_int LAPACKE_stpttr( int matrix_layout, char uplo, lapack_int n, - const float* ap, float* a, lapack_int lda ); -lapack_int LAPACKE_dtpttr( int matrix_layout, char uplo, lapack_int n, - const double* ap, double* a, lapack_int lda ); -lapack_int LAPACKE_ctpttr( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float* ap, - lapack_complex_float* a, lapack_int lda ); -lapack_int LAPACKE_ztpttr( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double* ap, - lapack_complex_double* a, lapack_int lda ); - -lapack_int LAPACKE_strcon( int matrix_layout, char norm, char uplo, char diag, - lapack_int n, const float* a, lapack_int lda, - float* rcond ); -lapack_int LAPACKE_dtrcon( int matrix_layout, char norm, char uplo, char diag, - lapack_int n, const double* a, lapack_int lda, - double* rcond ); -lapack_int LAPACKE_ctrcon( int matrix_layout, char norm, char uplo, char diag, - lapack_int n, const lapack_complex_float* a, - lapack_int lda, float* rcond ); -lapack_int LAPACKE_ztrcon( int matrix_layout, char norm, char uplo, char diag, - lapack_int n, const lapack_complex_double* a, - lapack_int lda, double* rcond ); - -lapack_int LAPACKE_strevc( int matrix_layout, char side, char howmny, - lapack_logical* select, lapack_int n, const float* t, - lapack_int ldt, float* vl, lapack_int ldvl, - float* vr, lapack_int ldvr, lapack_int mm, - lapack_int* m ); -lapack_int LAPACKE_dtrevc( int matrix_layout, char side, char howmny, - lapack_logical* select, lapack_int n, - const double* t, lapack_int ldt, double* vl, - lapack_int ldvl, double* vr, lapack_int ldvr, - lapack_int mm, lapack_int* m ); -lapack_int LAPACKE_ctrevc( int matrix_layout, char side, char howmny, - const lapack_logical* select, lapack_int n, - lapack_complex_float* t, lapack_int ldt, - lapack_complex_float* vl, lapack_int ldvl, - lapack_complex_float* vr, lapack_int ldvr, - lapack_int mm, lapack_int* m ); -lapack_int LAPACKE_ztrevc( int matrix_layout, char side, char howmny, - const lapack_logical* select, lapack_int n, - lapack_complex_double* t, lapack_int ldt, - lapack_complex_double* vl, lapack_int ldvl, - lapack_complex_double* vr, lapack_int ldvr, - lapack_int mm, lapack_int* m ); - -lapack_int LAPACKE_strexc( int matrix_layout, char compq, lapack_int n, float* t, - lapack_int ldt, float* q, lapack_int ldq, - lapack_int* ifst, lapack_int* ilst ); -lapack_int LAPACKE_dtrexc( int matrix_layout, char compq, lapack_int n, - double* t, lapack_int ldt, double* q, lapack_int ldq, - lapack_int* ifst, lapack_int* ilst ); -lapack_int LAPACKE_ctrexc( int matrix_layout, char compq, lapack_int n, - lapack_complex_float* t, lapack_int ldt, - lapack_complex_float* q, lapack_int ldq, - lapack_int ifst, lapack_int ilst ); -lapack_int LAPACKE_ztrexc( int matrix_layout, char compq, lapack_int n, - lapack_complex_double* t, lapack_int ldt, - lapack_complex_double* q, lapack_int ldq, - lapack_int ifst, lapack_int ilst ); - -lapack_int LAPACKE_strrfs( int matrix_layout, char uplo, char trans, char diag, - lapack_int n, lapack_int nrhs, const float* a, - lapack_int lda, const float* b, lapack_int ldb, - const float* x, lapack_int ldx, float* ferr, - float* berr ); -lapack_int LAPACKE_dtrrfs( int matrix_layout, char uplo, char trans, char diag, - lapack_int n, lapack_int nrhs, const double* a, - lapack_int lda, const double* b, lapack_int ldb, - const double* x, lapack_int ldx, double* ferr, - double* berr ); -lapack_int LAPACKE_ctrrfs( int matrix_layout, char uplo, char trans, char diag, - lapack_int n, lapack_int nrhs, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* b, lapack_int ldb, - const lapack_complex_float* x, lapack_int ldx, - float* ferr, float* berr ); -lapack_int LAPACKE_ztrrfs( int matrix_layout, char uplo, char trans, char diag, - lapack_int n, lapack_int nrhs, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* b, lapack_int ldb, - const lapack_complex_double* x, lapack_int ldx, - double* ferr, double* berr ); - -lapack_int LAPACKE_strsen( int matrix_layout, char job, char compq, - const lapack_logical* select, lapack_int n, float* t, - lapack_int ldt, float* q, lapack_int ldq, float* wr, - float* wi, lapack_int* m, float* s, float* sep ); -lapack_int LAPACKE_dtrsen( int matrix_layout, char job, char compq, - const lapack_logical* select, lapack_int n, - double* t, lapack_int ldt, double* q, lapack_int ldq, - double* wr, double* wi, lapack_int* m, double* s, - double* sep ); -lapack_int LAPACKE_ctrsen( int matrix_layout, char job, char compq, - const lapack_logical* select, lapack_int n, - lapack_complex_float* t, lapack_int ldt, - lapack_complex_float* q, lapack_int ldq, - lapack_complex_float* w, lapack_int* m, float* s, - float* sep ); -lapack_int LAPACKE_ztrsen( int matrix_layout, char job, char compq, - const lapack_logical* select, lapack_int n, - lapack_complex_double* t, lapack_int ldt, - lapack_complex_double* q, lapack_int ldq, - lapack_complex_double* w, lapack_int* m, double* s, - double* sep ); - -lapack_int LAPACKE_strsna( int matrix_layout, char job, char howmny, - const lapack_logical* select, lapack_int n, - const float* t, lapack_int ldt, const float* vl, - lapack_int ldvl, const float* vr, lapack_int ldvr, - float* s, float* sep, lapack_int mm, lapack_int* m ); -lapack_int LAPACKE_dtrsna( int matrix_layout, char job, char howmny, - const lapack_logical* select, lapack_int n, - const double* t, lapack_int ldt, const double* vl, - lapack_int ldvl, const double* vr, lapack_int ldvr, - double* s, double* sep, lapack_int mm, - lapack_int* m ); -lapack_int LAPACKE_ctrsna( int matrix_layout, char job, char howmny, - const lapack_logical* select, lapack_int n, - const lapack_complex_float* t, lapack_int ldt, - const lapack_complex_float* vl, lapack_int ldvl, - const lapack_complex_float* vr, lapack_int ldvr, - float* s, float* sep, lapack_int mm, lapack_int* m ); -lapack_int LAPACKE_ztrsna( int matrix_layout, char job, char howmny, - const lapack_logical* select, lapack_int n, - const lapack_complex_double* t, lapack_int ldt, - const lapack_complex_double* vl, lapack_int ldvl, - const lapack_complex_double* vr, lapack_int ldvr, - double* s, double* sep, lapack_int mm, - lapack_int* m ); - -lapack_int LAPACKE_strsyl( int matrix_layout, char trana, char tranb, - lapack_int isgn, lapack_int m, lapack_int n, - const float* a, lapack_int lda, const float* b, - lapack_int ldb, float* c, lapack_int ldc, - float* scale ); -lapack_int LAPACKE_dtrsyl( int matrix_layout, char trana, char tranb, - lapack_int isgn, lapack_int m, lapack_int n, - const double* a, lapack_int lda, const double* b, - lapack_int ldb, double* c, lapack_int ldc, - double* scale ); -lapack_int LAPACKE_ctrsyl( int matrix_layout, char trana, char tranb, - lapack_int isgn, lapack_int m, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* c, lapack_int ldc, - float* scale ); -lapack_int LAPACKE_ztrsyl( int matrix_layout, char trana, char tranb, - lapack_int isgn, lapack_int m, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* c, lapack_int ldc, - double* scale ); - -lapack_int LAPACKE_strtri( int matrix_layout, char uplo, char diag, lapack_int n, - float* a, lapack_int lda ); -lapack_int LAPACKE_dtrtri( int matrix_layout, char uplo, char diag, lapack_int n, - double* a, lapack_int lda ); -lapack_int LAPACKE_ctrtri( int matrix_layout, char uplo, char diag, lapack_int n, - lapack_complex_float* a, lapack_int lda ); -lapack_int LAPACKE_ztrtri( int matrix_layout, char uplo, char diag, lapack_int n, - lapack_complex_double* a, lapack_int lda ); - -lapack_int LAPACKE_strtrs( int matrix_layout, char uplo, char trans, char diag, - lapack_int n, lapack_int nrhs, const float* a, - lapack_int lda, float* b, lapack_int ldb ); -lapack_int LAPACKE_dtrtrs( int matrix_layout, char uplo, char trans, char diag, - lapack_int n, lapack_int nrhs, const double* a, - lapack_int lda, double* b, lapack_int ldb ); -lapack_int LAPACKE_ctrtrs( int matrix_layout, char uplo, char trans, char diag, - lapack_int n, lapack_int nrhs, - const lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_ztrtrs( int matrix_layout, char uplo, char trans, char diag, - lapack_int n, lapack_int nrhs, - const lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_strttf( int matrix_layout, char transr, char uplo, - lapack_int n, const float* a, lapack_int lda, - float* arf ); -lapack_int LAPACKE_dtrttf( int matrix_layout, char transr, char uplo, - lapack_int n, const double* a, lapack_int lda, - double* arf ); -lapack_int LAPACKE_ctrttf( int matrix_layout, char transr, char uplo, - lapack_int n, const lapack_complex_float* a, - lapack_int lda, lapack_complex_float* arf ); -lapack_int LAPACKE_ztrttf( int matrix_layout, char transr, char uplo, - lapack_int n, const lapack_complex_double* a, - lapack_int lda, lapack_complex_double* arf ); - -lapack_int LAPACKE_strttp( int matrix_layout, char uplo, lapack_int n, - const float* a, lapack_int lda, float* ap ); -lapack_int LAPACKE_dtrttp( int matrix_layout, char uplo, lapack_int n, - const double* a, lapack_int lda, double* ap ); -lapack_int LAPACKE_ctrttp( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - lapack_complex_float* ap ); -lapack_int LAPACKE_ztrttp( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - lapack_complex_double* ap ); - -lapack_int LAPACKE_stzrzf( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, float* tau ); -lapack_int LAPACKE_dtzrzf( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, double* tau ); -lapack_int LAPACKE_ctzrzf( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* tau ); -lapack_int LAPACKE_ztzrzf( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* tau ); - -lapack_int LAPACKE_cungbr( int matrix_layout, char vect, lapack_int m, - lapack_int n, lapack_int k, lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* tau ); -lapack_int LAPACKE_zungbr( int matrix_layout, char vect, lapack_int m, - lapack_int n, lapack_int k, lapack_complex_double* a, - lapack_int lda, const lapack_complex_double* tau ); - -lapack_int LAPACKE_cunghr( int matrix_layout, lapack_int n, lapack_int ilo, - lapack_int ihi, lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* tau ); -lapack_int LAPACKE_zunghr( int matrix_layout, lapack_int n, lapack_int ilo, - lapack_int ihi, lapack_complex_double* a, - lapack_int lda, const lapack_complex_double* tau ); - -lapack_int LAPACKE_cunglq( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* tau ); -lapack_int LAPACKE_zunglq( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, lapack_complex_double* a, - lapack_int lda, const lapack_complex_double* tau ); - -lapack_int LAPACKE_cungql( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* tau ); -lapack_int LAPACKE_zungql( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, lapack_complex_double* a, - lapack_int lda, const lapack_complex_double* tau ); - -lapack_int LAPACKE_cungqr( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* tau ); -lapack_int LAPACKE_zungqr( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, lapack_complex_double* a, - lapack_int lda, const lapack_complex_double* tau ); - -lapack_int LAPACKE_cungrq( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* tau ); -lapack_int LAPACKE_zungrq( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, lapack_complex_double* a, - lapack_int lda, const lapack_complex_double* tau ); - -lapack_int LAPACKE_cungtr( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* tau ); -lapack_int LAPACKE_zungtr( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* tau ); - -lapack_int LAPACKE_cunmbr( int matrix_layout, char vect, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* tau, - lapack_complex_float* c, lapack_int ldc ); -lapack_int LAPACKE_zunmbr( int matrix_layout, char vect, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* tau, - lapack_complex_double* c, lapack_int ldc ); - -lapack_int LAPACKE_cunmhr( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int ilo, - lapack_int ihi, const lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* tau, - lapack_complex_float* c, lapack_int ldc ); -lapack_int LAPACKE_zunmhr( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int ilo, - lapack_int ihi, const lapack_complex_double* a, - lapack_int lda, const lapack_complex_double* tau, - lapack_complex_double* c, lapack_int ldc ); - -lapack_int LAPACKE_cunmlq( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* tau, - lapack_complex_float* c, lapack_int ldc ); -lapack_int LAPACKE_zunmlq( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* tau, - lapack_complex_double* c, lapack_int ldc ); - -lapack_int LAPACKE_cunmql( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* tau, - lapack_complex_float* c, lapack_int ldc ); -lapack_int LAPACKE_zunmql( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* tau, - lapack_complex_double* c, lapack_int ldc ); - -lapack_int LAPACKE_cunmqr( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* tau, - lapack_complex_float* c, lapack_int ldc ); -lapack_int LAPACKE_zunmqr( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* tau, - lapack_complex_double* c, lapack_int ldc ); - -lapack_int LAPACKE_cunmrq( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* tau, - lapack_complex_float* c, lapack_int ldc ); -lapack_int LAPACKE_zunmrq( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* tau, - lapack_complex_double* c, lapack_int ldc ); - -lapack_int LAPACKE_cunmrz( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - lapack_int l, const lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* tau, - lapack_complex_float* c, lapack_int ldc ); -lapack_int LAPACKE_zunmrz( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - lapack_int l, const lapack_complex_double* a, - lapack_int lda, const lapack_complex_double* tau, - lapack_complex_double* c, lapack_int ldc ); - -lapack_int LAPACKE_cunmtr( int matrix_layout, char side, char uplo, char trans, - lapack_int m, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* tau, - lapack_complex_float* c, lapack_int ldc ); -lapack_int LAPACKE_zunmtr( int matrix_layout, char side, char uplo, char trans, - lapack_int m, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* tau, - lapack_complex_double* c, lapack_int ldc ); - -lapack_int LAPACKE_cupgtr( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float* ap, - const lapack_complex_float* tau, - lapack_complex_float* q, lapack_int ldq ); -lapack_int LAPACKE_zupgtr( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double* ap, - const lapack_complex_double* tau, - lapack_complex_double* q, lapack_int ldq ); - -lapack_int LAPACKE_cupmtr( int matrix_layout, char side, char uplo, char trans, - lapack_int m, lapack_int n, - const lapack_complex_float* ap, - const lapack_complex_float* tau, - lapack_complex_float* c, lapack_int ldc ); -lapack_int LAPACKE_zupmtr( int matrix_layout, char side, char uplo, char trans, - lapack_int m, lapack_int n, - const lapack_complex_double* ap, - const lapack_complex_double* tau, - lapack_complex_double* c, lapack_int ldc ); - -lapack_int LAPACKE_sbdsdc_work( int matrix_layout, char uplo, char compq, - lapack_int n, float* d, float* e, float* u, - lapack_int ldu, float* vt, lapack_int ldvt, - float* q, lapack_int* iq, float* work, - lapack_int* iwork ); -lapack_int LAPACKE_dbdsdc_work( int matrix_layout, char uplo, char compq, - lapack_int n, double* d, double* e, double* u, - lapack_int ldu, double* vt, lapack_int ldvt, - double* q, lapack_int* iq, double* work, - lapack_int* iwork ); - -lapack_int LAPACKE_sbdsvdx_work( int matrix_layout, char uplo, char jobz, char range, - lapack_int n, float* d, float* e, - float vl, float vu, - lapack_int il, lapack_int iu, lapack_int* ns, - float* s, float* z, lapack_int ldz, - float* work, lapack_int* iwork ); -lapack_int LAPACKE_dbdsvdx_work( int matrix_layout, char uplo, char jobz, char range, - lapack_int n, double* d, double* e, - double vl, double vu, - lapack_int il, lapack_int iu, lapack_int* ns, - double* s, double* z, lapack_int ldz, - double* work, lapack_int* iwork ); - -lapack_int LAPACKE_sbdsqr_work( int matrix_layout, char uplo, lapack_int n, - lapack_int ncvt, lapack_int nru, lapack_int ncc, - float* d, float* e, float* vt, lapack_int ldvt, - float* u, lapack_int ldu, float* c, - lapack_int ldc, float* work ); -lapack_int LAPACKE_dbdsqr_work( int matrix_layout, char uplo, lapack_int n, - lapack_int ncvt, lapack_int nru, lapack_int ncc, - double* d, double* e, double* vt, - lapack_int ldvt, double* u, lapack_int ldu, - double* c, lapack_int ldc, double* work ); -lapack_int LAPACKE_cbdsqr_work( int matrix_layout, char uplo, lapack_int n, - lapack_int ncvt, lapack_int nru, lapack_int ncc, - float* d, float* e, lapack_complex_float* vt, - lapack_int ldvt, lapack_complex_float* u, - lapack_int ldu, lapack_complex_float* c, - lapack_int ldc, float* work ); -lapack_int LAPACKE_zbdsqr_work( int matrix_layout, char uplo, lapack_int n, - lapack_int ncvt, lapack_int nru, lapack_int ncc, - double* d, double* e, lapack_complex_double* vt, - lapack_int ldvt, lapack_complex_double* u, - lapack_int ldu, lapack_complex_double* c, - lapack_int ldc, double* work ); - -lapack_int LAPACKE_sdisna_work( char job, lapack_int m, lapack_int n, - const float* d, float* sep ); -lapack_int LAPACKE_ddisna_work( char job, lapack_int m, lapack_int n, - const double* d, double* sep ); - -lapack_int LAPACKE_sgbbrd_work( int matrix_layout, char vect, lapack_int m, - lapack_int n, lapack_int ncc, lapack_int kl, - lapack_int ku, float* ab, lapack_int ldab, - float* d, float* e, float* q, lapack_int ldq, - float* pt, lapack_int ldpt, float* c, - lapack_int ldc, float* work ); -lapack_int LAPACKE_dgbbrd_work( int matrix_layout, char vect, lapack_int m, - lapack_int n, lapack_int ncc, lapack_int kl, - lapack_int ku, double* ab, lapack_int ldab, - double* d, double* e, double* q, lapack_int ldq, - double* pt, lapack_int ldpt, double* c, - lapack_int ldc, double* work ); -lapack_int LAPACKE_cgbbrd_work( int matrix_layout, char vect, lapack_int m, - lapack_int n, lapack_int ncc, lapack_int kl, - lapack_int ku, lapack_complex_float* ab, - lapack_int ldab, float* d, float* e, - lapack_complex_float* q, lapack_int ldq, - lapack_complex_float* pt, lapack_int ldpt, - lapack_complex_float* c, lapack_int ldc, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_zgbbrd_work( int matrix_layout, char vect, lapack_int m, - lapack_int n, lapack_int ncc, lapack_int kl, - lapack_int ku, lapack_complex_double* ab, - lapack_int ldab, double* d, double* e, - lapack_complex_double* q, lapack_int ldq, - lapack_complex_double* pt, lapack_int ldpt, - lapack_complex_double* c, lapack_int ldc, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_sgbcon_work( int matrix_layout, char norm, lapack_int n, - lapack_int kl, lapack_int ku, const float* ab, - lapack_int ldab, const lapack_int* ipiv, - float anorm, float* rcond, float* work, - lapack_int* iwork ); -lapack_int LAPACKE_dgbcon_work( int matrix_layout, char norm, lapack_int n, - lapack_int kl, lapack_int ku, const double* ab, - lapack_int ldab, const lapack_int* ipiv, - double anorm, double* rcond, double* work, - lapack_int* iwork ); -lapack_int LAPACKE_cgbcon_work( int matrix_layout, char norm, lapack_int n, - lapack_int kl, lapack_int ku, - const lapack_complex_float* ab, lapack_int ldab, - const lapack_int* ipiv, float anorm, - float* rcond, lapack_complex_float* work, - float* rwork ); -lapack_int LAPACKE_zgbcon_work( int matrix_layout, char norm, lapack_int n, - lapack_int kl, lapack_int ku, - const lapack_complex_double* ab, - lapack_int ldab, const lapack_int* ipiv, - double anorm, double* rcond, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_sgbequ_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, const float* ab, - lapack_int ldab, float* r, float* c, - float* rowcnd, float* colcnd, float* amax ); -lapack_int LAPACKE_dgbequ_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, const double* ab, - lapack_int ldab, double* r, double* c, - double* rowcnd, double* colcnd, double* amax ); -lapack_int LAPACKE_cgbequ_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, - const lapack_complex_float* ab, lapack_int ldab, - float* r, float* c, float* rowcnd, - float* colcnd, float* amax ); -lapack_int LAPACKE_zgbequ_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, - const lapack_complex_double* ab, - lapack_int ldab, double* r, double* c, - double* rowcnd, double* colcnd, double* amax ); - -lapack_int LAPACKE_sgbequb_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, const float* ab, - lapack_int ldab, float* r, float* c, - float* rowcnd, float* colcnd, float* amax ); -lapack_int LAPACKE_dgbequb_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, const double* ab, - lapack_int ldab, double* r, double* c, - double* rowcnd, double* colcnd, double* amax ); -lapack_int LAPACKE_cgbequb_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, - const lapack_complex_float* ab, - lapack_int ldab, float* r, float* c, - float* rowcnd, float* colcnd, float* amax ); -lapack_int LAPACKE_zgbequb_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, - const lapack_complex_double* ab, - lapack_int ldab, double* r, double* c, - double* rowcnd, double* colcnd, double* amax ); - -lapack_int LAPACKE_sgbrfs_work( int matrix_layout, char trans, lapack_int n, - lapack_int kl, lapack_int ku, lapack_int nrhs, - const float* ab, lapack_int ldab, - const float* afb, lapack_int ldafb, - const lapack_int* ipiv, const float* b, - lapack_int ldb, float* x, lapack_int ldx, - float* ferr, float* berr, float* work, - lapack_int* iwork ); -lapack_int LAPACKE_dgbrfs_work( int matrix_layout, char trans, lapack_int n, - lapack_int kl, lapack_int ku, lapack_int nrhs, - const double* ab, lapack_int ldab, - const double* afb, lapack_int ldafb, - const lapack_int* ipiv, const double* b, - lapack_int ldb, double* x, lapack_int ldx, - double* ferr, double* berr, double* work, - lapack_int* iwork ); -lapack_int LAPACKE_cgbrfs_work( int matrix_layout, char trans, lapack_int n, - lapack_int kl, lapack_int ku, lapack_int nrhs, - const lapack_complex_float* ab, lapack_int ldab, - const lapack_complex_float* afb, - lapack_int ldafb, const lapack_int* ipiv, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* ferr, float* berr, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_zgbrfs_work( int matrix_layout, char trans, lapack_int n, - lapack_int kl, lapack_int ku, lapack_int nrhs, - const lapack_complex_double* ab, - lapack_int ldab, - const lapack_complex_double* afb, - lapack_int ldafb, const lapack_int* ipiv, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* ferr, double* berr, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_sgbrfsx_work( int matrix_layout, char trans, char equed, - lapack_int n, lapack_int kl, lapack_int ku, - lapack_int nrhs, const float* ab, - lapack_int ldab, const float* afb, - lapack_int ldafb, const lapack_int* ipiv, - const float* r, const float* c, const float* b, - lapack_int ldb, float* x, lapack_int ldx, - float* rcond, float* berr, - lapack_int n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int nparams, - float* params, float* work, - lapack_int* iwork ); -lapack_int LAPACKE_dgbrfsx_work( int matrix_layout, char trans, char equed, - lapack_int n, lapack_int kl, lapack_int ku, - lapack_int nrhs, const double* ab, - lapack_int ldab, const double* afb, - lapack_int ldafb, const lapack_int* ipiv, - const double* r, const double* c, - const double* b, lapack_int ldb, double* x, - lapack_int ldx, double* rcond, double* berr, - lapack_int n_err_bnds, double* err_bnds_norm, - double* err_bnds_comp, lapack_int nparams, - double* params, double* work, - lapack_int* iwork ); -lapack_int LAPACKE_cgbrfsx_work( int matrix_layout, char trans, char equed, - lapack_int n, lapack_int kl, lapack_int ku, - lapack_int nrhs, - const lapack_complex_float* ab, - lapack_int ldab, - const lapack_complex_float* afb, - lapack_int ldafb, const lapack_int* ipiv, - const float* r, const float* c, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* rcond, float* berr, - lapack_int n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int nparams, - float* params, lapack_complex_float* work, - float* rwork ); -lapack_int LAPACKE_zgbrfsx_work( int matrix_layout, char trans, char equed, - lapack_int n, lapack_int kl, lapack_int ku, - lapack_int nrhs, - const lapack_complex_double* ab, - lapack_int ldab, - const lapack_complex_double* afb, - lapack_int ldafb, const lapack_int* ipiv, - const double* r, const double* c, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* berr, - lapack_int n_err_bnds, double* err_bnds_norm, - double* err_bnds_comp, lapack_int nparams, - double* params, lapack_complex_double* work, - double* rwork ); - -lapack_int LAPACKE_sgbsv_work( int matrix_layout, lapack_int n, lapack_int kl, - lapack_int ku, lapack_int nrhs, float* ab, - lapack_int ldab, lapack_int* ipiv, float* b, - lapack_int ldb ); -lapack_int LAPACKE_dgbsv_work( int matrix_layout, lapack_int n, lapack_int kl, - lapack_int ku, lapack_int nrhs, double* ab, - lapack_int ldab, lapack_int* ipiv, double* b, - lapack_int ldb ); -lapack_int LAPACKE_cgbsv_work( int matrix_layout, lapack_int n, lapack_int kl, - lapack_int ku, lapack_int nrhs, - lapack_complex_float* ab, lapack_int ldab, - lapack_int* ipiv, lapack_complex_float* b, - lapack_int ldb ); -lapack_int LAPACKE_zgbsv_work( int matrix_layout, lapack_int n, lapack_int kl, - lapack_int ku, lapack_int nrhs, - lapack_complex_double* ab, lapack_int ldab, - lapack_int* ipiv, lapack_complex_double* b, - lapack_int ldb ); - -lapack_int LAPACKE_sgbsvx_work( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int kl, lapack_int ku, - lapack_int nrhs, float* ab, lapack_int ldab, - float* afb, lapack_int ldafb, lapack_int* ipiv, - char* equed, float* r, float* c, float* b, - lapack_int ldb, float* x, lapack_int ldx, - float* rcond, float* ferr, float* berr, - float* work, lapack_int* iwork ); -lapack_int LAPACKE_dgbsvx_work( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int kl, lapack_int ku, - lapack_int nrhs, double* ab, lapack_int ldab, - double* afb, lapack_int ldafb, lapack_int* ipiv, - char* equed, double* r, double* c, double* b, - lapack_int ldb, double* x, lapack_int ldx, - double* rcond, double* ferr, double* berr, - double* work, lapack_int* iwork ); -lapack_int LAPACKE_cgbsvx_work( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int kl, lapack_int ku, - lapack_int nrhs, lapack_complex_float* ab, - lapack_int ldab, lapack_complex_float* afb, - lapack_int ldafb, lapack_int* ipiv, char* equed, - float* r, float* c, lapack_complex_float* b, - lapack_int ldb, lapack_complex_float* x, - lapack_int ldx, float* rcond, float* ferr, - float* berr, lapack_complex_float* work, - float* rwork ); -lapack_int LAPACKE_zgbsvx_work( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int kl, lapack_int ku, - lapack_int nrhs, lapack_complex_double* ab, - lapack_int ldab, lapack_complex_double* afb, - lapack_int ldafb, lapack_int* ipiv, char* equed, - double* r, double* c, lapack_complex_double* b, - lapack_int ldb, lapack_complex_double* x, - lapack_int ldx, double* rcond, double* ferr, - double* berr, lapack_complex_double* work, - double* rwork ); - -lapack_int LAPACKE_sgbsvxx_work( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int kl, lapack_int ku, - lapack_int nrhs, float* ab, lapack_int ldab, - float* afb, lapack_int ldafb, lapack_int* ipiv, - char* equed, float* r, float* c, float* b, - lapack_int ldb, float* x, lapack_int ldx, - float* rcond, float* rpvgrw, float* berr, - lapack_int n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int nparams, - float* params, float* work, - lapack_int* iwork ); -lapack_int LAPACKE_dgbsvxx_work( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int kl, lapack_int ku, - lapack_int nrhs, double* ab, lapack_int ldab, - double* afb, lapack_int ldafb, - lapack_int* ipiv, char* equed, double* r, - double* c, double* b, lapack_int ldb, - double* x, lapack_int ldx, double* rcond, - double* rpvgrw, double* berr, - lapack_int n_err_bnds, double* err_bnds_norm, - double* err_bnds_comp, lapack_int nparams, - double* params, double* work, - lapack_int* iwork ); -lapack_int LAPACKE_cgbsvxx_work( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int kl, lapack_int ku, - lapack_int nrhs, lapack_complex_float* ab, - lapack_int ldab, lapack_complex_float* afb, - lapack_int ldafb, lapack_int* ipiv, - char* equed, float* r, float* c, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* rcond, float* rpvgrw, float* berr, - lapack_int n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int nparams, - float* params, lapack_complex_float* work, - float* rwork ); -lapack_int LAPACKE_zgbsvxx_work( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int kl, lapack_int ku, - lapack_int nrhs, lapack_complex_double* ab, - lapack_int ldab, lapack_complex_double* afb, - lapack_int ldafb, lapack_int* ipiv, - char* equed, double* r, double* c, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* rpvgrw, double* berr, - lapack_int n_err_bnds, double* err_bnds_norm, - double* err_bnds_comp, lapack_int nparams, - double* params, lapack_complex_double* work, - double* rwork ); - -lapack_int LAPACKE_sgbtrf_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, float* ab, - lapack_int ldab, lapack_int* ipiv ); -lapack_int LAPACKE_dgbtrf_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, double* ab, - lapack_int ldab, lapack_int* ipiv ); -lapack_int LAPACKE_cgbtrf_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, - lapack_complex_float* ab, lapack_int ldab, - lapack_int* ipiv ); -lapack_int LAPACKE_zgbtrf_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, - lapack_complex_double* ab, lapack_int ldab, - lapack_int* ipiv ); - -lapack_int LAPACKE_sgbtrs_work( int matrix_layout, char trans, lapack_int n, - lapack_int kl, lapack_int ku, lapack_int nrhs, - const float* ab, lapack_int ldab, - const lapack_int* ipiv, float* b, - lapack_int ldb ); -lapack_int LAPACKE_dgbtrs_work( int matrix_layout, char trans, lapack_int n, - lapack_int kl, lapack_int ku, lapack_int nrhs, - const double* ab, lapack_int ldab, - const lapack_int* ipiv, double* b, - lapack_int ldb ); -lapack_int LAPACKE_cgbtrs_work( int matrix_layout, char trans, lapack_int n, - lapack_int kl, lapack_int ku, lapack_int nrhs, - const lapack_complex_float* ab, lapack_int ldab, - const lapack_int* ipiv, lapack_complex_float* b, - lapack_int ldb ); -lapack_int LAPACKE_zgbtrs_work( int matrix_layout, char trans, lapack_int n, - lapack_int kl, lapack_int ku, lapack_int nrhs, - const lapack_complex_double* ab, - lapack_int ldab, const lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_sgebak_work( int matrix_layout, char job, char side, - lapack_int n, lapack_int ilo, lapack_int ihi, - const float* scale, lapack_int m, float* v, - lapack_int ldv ); -lapack_int LAPACKE_dgebak_work( int matrix_layout, char job, char side, - lapack_int n, lapack_int ilo, lapack_int ihi, - const double* scale, lapack_int m, double* v, - lapack_int ldv ); -lapack_int LAPACKE_cgebak_work( int matrix_layout, char job, char side, - lapack_int n, lapack_int ilo, lapack_int ihi, - const float* scale, lapack_int m, - lapack_complex_float* v, lapack_int ldv ); -lapack_int LAPACKE_zgebak_work( int matrix_layout, char job, char side, - lapack_int n, lapack_int ilo, lapack_int ihi, - const double* scale, lapack_int m, - lapack_complex_double* v, lapack_int ldv ); - -lapack_int LAPACKE_sgebal_work( int matrix_layout, char job, lapack_int n, - float* a, lapack_int lda, lapack_int* ilo, - lapack_int* ihi, float* scale ); -lapack_int LAPACKE_dgebal_work( int matrix_layout, char job, lapack_int n, - double* a, lapack_int lda, lapack_int* ilo, - lapack_int* ihi, double* scale ); -lapack_int LAPACKE_cgebal_work( int matrix_layout, char job, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int* ilo, lapack_int* ihi, - float* scale ); -lapack_int LAPACKE_zgebal_work( int matrix_layout, char job, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int* ilo, lapack_int* ihi, - double* scale ); - -lapack_int LAPACKE_sgebrd_work( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, float* d, float* e, - float* tauq, float* taup, float* work, - lapack_int lwork ); -lapack_int LAPACKE_dgebrd_work( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, double* d, double* e, - double* tauq, double* taup, double* work, - lapack_int lwork ); -lapack_int LAPACKE_cgebrd_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - float* d, float* e, lapack_complex_float* tauq, - lapack_complex_float* taup, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zgebrd_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - double* d, double* e, - lapack_complex_double* tauq, - lapack_complex_double* taup, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_sgecon_work( int matrix_layout, char norm, lapack_int n, - const float* a, lapack_int lda, float anorm, - float* rcond, float* work, lapack_int* iwork ); -lapack_int LAPACKE_dgecon_work( int matrix_layout, char norm, lapack_int n, - const double* a, lapack_int lda, double anorm, - double* rcond, double* work, - lapack_int* iwork ); -lapack_int LAPACKE_cgecon_work( int matrix_layout, char norm, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - float anorm, float* rcond, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_zgecon_work( int matrix_layout, char norm, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - double anorm, double* rcond, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_sgeequ_work( int matrix_layout, lapack_int m, lapack_int n, - const float* a, lapack_int lda, float* r, - float* c, float* rowcnd, float* colcnd, - float* amax ); -lapack_int LAPACKE_dgeequ_work( int matrix_layout, lapack_int m, lapack_int n, - const double* a, lapack_int lda, double* r, - double* c, double* rowcnd, double* colcnd, - double* amax ); -lapack_int LAPACKE_cgeequ_work( int matrix_layout, lapack_int m, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - float* r, float* c, float* rowcnd, - float* colcnd, float* amax ); -lapack_int LAPACKE_zgeequ_work( int matrix_layout, lapack_int m, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - double* r, double* c, double* rowcnd, - double* colcnd, double* amax ); - -lapack_int LAPACKE_sgeequb_work( int matrix_layout, lapack_int m, lapack_int n, - const float* a, lapack_int lda, float* r, - float* c, float* rowcnd, float* colcnd, - float* amax ); -lapack_int LAPACKE_dgeequb_work( int matrix_layout, lapack_int m, lapack_int n, - const double* a, lapack_int lda, double* r, - double* c, double* rowcnd, double* colcnd, - double* amax ); -lapack_int LAPACKE_cgeequb_work( int matrix_layout, lapack_int m, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - float* r, float* c, float* rowcnd, - float* colcnd, float* amax ); -lapack_int LAPACKE_zgeequb_work( int matrix_layout, lapack_int m, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - double* r, double* c, double* rowcnd, - double* colcnd, double* amax ); - -lapack_int LAPACKE_sgees_work( int matrix_layout, char jobvs, char sort, - LAPACK_S_SELECT2 select, lapack_int n, float* a, - lapack_int lda, lapack_int* sdim, float* wr, - float* wi, float* vs, lapack_int ldvs, - float* work, lapack_int lwork, - lapack_logical* bwork ); -lapack_int LAPACKE_dgees_work( int matrix_layout, char jobvs, char sort, - LAPACK_D_SELECT2 select, lapack_int n, double* a, - lapack_int lda, lapack_int* sdim, double* wr, - double* wi, double* vs, lapack_int ldvs, - double* work, lapack_int lwork, - lapack_logical* bwork ); -lapack_int LAPACKE_cgees_work( int matrix_layout, char jobvs, char sort, - LAPACK_C_SELECT1 select, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int* sdim, lapack_complex_float* w, - lapack_complex_float* vs, lapack_int ldvs, - lapack_complex_float* work, lapack_int lwork, - float* rwork, lapack_logical* bwork ); -lapack_int LAPACKE_zgees_work( int matrix_layout, char jobvs, char sort, - LAPACK_Z_SELECT1 select, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int* sdim, lapack_complex_double* w, - lapack_complex_double* vs, lapack_int ldvs, - lapack_complex_double* work, lapack_int lwork, - double* rwork, lapack_logical* bwork ); - -lapack_int LAPACKE_sgeesx_work( int matrix_layout, char jobvs, char sort, - LAPACK_S_SELECT2 select, char sense, - lapack_int n, float* a, lapack_int lda, - lapack_int* sdim, float* wr, float* wi, - float* vs, lapack_int ldvs, float* rconde, - float* rcondv, float* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork, - lapack_logical* bwork ); -lapack_int LAPACKE_dgeesx_work( int matrix_layout, char jobvs, char sort, - LAPACK_D_SELECT2 select, char sense, - lapack_int n, double* a, lapack_int lda, - lapack_int* sdim, double* wr, double* wi, - double* vs, lapack_int ldvs, double* rconde, - double* rcondv, double* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork, - lapack_logical* bwork ); -lapack_int LAPACKE_cgeesx_work( int matrix_layout, char jobvs, char sort, - LAPACK_C_SELECT1 select, char sense, - lapack_int n, lapack_complex_float* a, - lapack_int lda, lapack_int* sdim, - lapack_complex_float* w, - lapack_complex_float* vs, lapack_int ldvs, - float* rconde, float* rcondv, - lapack_complex_float* work, lapack_int lwork, - float* rwork, lapack_logical* bwork ); -lapack_int LAPACKE_zgeesx_work( int matrix_layout, char jobvs, char sort, - LAPACK_Z_SELECT1 select, char sense, - lapack_int n, lapack_complex_double* a, - lapack_int lda, lapack_int* sdim, - lapack_complex_double* w, - lapack_complex_double* vs, lapack_int ldvs, - double* rconde, double* rcondv, - lapack_complex_double* work, lapack_int lwork, - double* rwork, lapack_logical* bwork ); - -lapack_int LAPACKE_sgeev_work( int matrix_layout, char jobvl, char jobvr, - lapack_int n, float* a, lapack_int lda, - float* wr, float* wi, float* vl, lapack_int ldvl, - float* vr, lapack_int ldvr, float* work, - lapack_int lwork ); -lapack_int LAPACKE_dgeev_work( int matrix_layout, char jobvl, char jobvr, - lapack_int n, double* a, lapack_int lda, - double* wr, double* wi, double* vl, - lapack_int ldvl, double* vr, lapack_int ldvr, - double* work, lapack_int lwork ); -lapack_int LAPACKE_cgeev_work( int matrix_layout, char jobvl, char jobvr, - lapack_int n, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* w, - lapack_complex_float* vl, lapack_int ldvl, - lapack_complex_float* vr, lapack_int ldvr, - lapack_complex_float* work, lapack_int lwork, - float* rwork ); -lapack_int LAPACKE_zgeev_work( int matrix_layout, char jobvl, char jobvr, - lapack_int n, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* w, - lapack_complex_double* vl, lapack_int ldvl, - lapack_complex_double* vr, lapack_int ldvr, - lapack_complex_double* work, lapack_int lwork, - double* rwork ); - -lapack_int LAPACKE_sgeevx_work( int matrix_layout, char balanc, char jobvl, - char jobvr, char sense, lapack_int n, float* a, - lapack_int lda, float* wr, float* wi, float* vl, - lapack_int ldvl, float* vr, lapack_int ldvr, - lapack_int* ilo, lapack_int* ihi, float* scale, - float* abnrm, float* rconde, float* rcondv, - float* work, lapack_int lwork, - lapack_int* iwork ); -lapack_int LAPACKE_dgeevx_work( int matrix_layout, char balanc, char jobvl, - char jobvr, char sense, lapack_int n, double* a, - lapack_int lda, double* wr, double* wi, - double* vl, lapack_int ldvl, double* vr, - lapack_int ldvr, lapack_int* ilo, - lapack_int* ihi, double* scale, double* abnrm, - double* rconde, double* rcondv, double* work, - lapack_int lwork, lapack_int* iwork ); -lapack_int LAPACKE_cgeevx_work( int matrix_layout, char balanc, char jobvl, - char jobvr, char sense, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* w, - lapack_complex_float* vl, lapack_int ldvl, - lapack_complex_float* vr, lapack_int ldvr, - lapack_int* ilo, lapack_int* ihi, float* scale, - float* abnrm, float* rconde, float* rcondv, - lapack_complex_float* work, lapack_int lwork, - float* rwork ); -lapack_int LAPACKE_zgeevx_work( int matrix_layout, char balanc, char jobvl, - char jobvr, char sense, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* w, - lapack_complex_double* vl, lapack_int ldvl, - lapack_complex_double* vr, lapack_int ldvr, - lapack_int* ilo, lapack_int* ihi, double* scale, - double* abnrm, double* rconde, double* rcondv, - lapack_complex_double* work, lapack_int lwork, - double* rwork ); - -lapack_int LAPACKE_sgehrd_work( int matrix_layout, lapack_int n, lapack_int ilo, - lapack_int ihi, float* a, lapack_int lda, - float* tau, float* work, lapack_int lwork ); -lapack_int LAPACKE_dgehrd_work( int matrix_layout, lapack_int n, lapack_int ilo, - lapack_int ihi, double* a, lapack_int lda, - double* tau, double* work, lapack_int lwork ); -lapack_int LAPACKE_cgehrd_work( int matrix_layout, lapack_int n, lapack_int ilo, - lapack_int ihi, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* tau, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zgehrd_work( int matrix_layout, lapack_int n, lapack_int ilo, - lapack_int ihi, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* tau, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_sgejsv_work( int matrix_layout, char joba, char jobu, - char jobv, char jobr, char jobt, char jobp, - lapack_int m, lapack_int n, float* a, - lapack_int lda, float* sva, float* u, - lapack_int ldu, float* v, lapack_int ldv, - float* work, lapack_int lwork, - lapack_int* iwork ); -lapack_int LAPACKE_dgejsv_work( int matrix_layout, char joba, char jobu, - char jobv, char jobr, char jobt, char jobp, - lapack_int m, lapack_int n, double* a, - lapack_int lda, double* sva, double* u, - lapack_int ldu, double* v, lapack_int ldv, - double* work, lapack_int lwork, - lapack_int* iwork ); -lapack_int LAPACKE_cgejsv_work( int matrix_layout, char joba, char jobu, - char jobv, char jobr, char jobt, char jobp, - lapack_int m, lapack_int n, lapack_complex_float* a, - lapack_int lda, float* sva, lapack_complex_float* u, - lapack_int ldu, lapack_complex_float* v, lapack_int ldv, - lapack_complex_float* cwork, lapack_int lwork, - float* work, lapack_int lrwork, - lapack_int* iwork ); -lapack_int LAPACKE_zgejsv_work( int matrix_layout, char joba, char jobu, - char jobv, char jobr, char jobt, char jobp, - lapack_int m, lapack_int n, lapack_complex_double* a, - lapack_int lda, double* sva, lapack_complex_double* u, - lapack_int ldu, lapack_complex_double* v, lapack_int ldv, - lapack_complex_double* cwork, lapack_int lwork, - double* work, lapack_int lrwork, - lapack_int* iwork ); - -lapack_int LAPACKE_sgelq2_work( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, float* tau, - float* work ); -lapack_int LAPACKE_dgelq2_work( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, double* tau, - double* work ); -lapack_int LAPACKE_cgelq2_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* tau, - lapack_complex_float* work ); -lapack_int LAPACKE_zgelq2_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* tau, - lapack_complex_double* work ); - -lapack_int LAPACKE_sgelqf_work( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, float* tau, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dgelqf_work( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, double* tau, - double* work, lapack_int lwork ); -lapack_int LAPACKE_cgelqf_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* tau, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zgelqf_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* tau, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_sgels_work( int matrix_layout, char trans, lapack_int m, - lapack_int n, lapack_int nrhs, float* a, - lapack_int lda, float* b, lapack_int ldb, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dgels_work( int matrix_layout, char trans, lapack_int m, - lapack_int n, lapack_int nrhs, double* a, - lapack_int lda, double* b, lapack_int ldb, - double* work, lapack_int lwork ); -lapack_int LAPACKE_cgels_work( int matrix_layout, char trans, lapack_int m, - lapack_int n, lapack_int nrhs, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zgels_work( int matrix_layout, char trans, lapack_int m, - lapack_int n, lapack_int nrhs, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_sgelsd_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nrhs, float* a, lapack_int lda, - float* b, lapack_int ldb, float* s, float rcond, - lapack_int* rank, float* work, lapack_int lwork, - lapack_int* iwork ); -lapack_int LAPACKE_dgelsd_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nrhs, double* a, lapack_int lda, - double* b, lapack_int ldb, double* s, - double rcond, lapack_int* rank, double* work, - lapack_int lwork, lapack_int* iwork ); -lapack_int LAPACKE_cgelsd_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* b, - lapack_int ldb, float* s, float rcond, - lapack_int* rank, lapack_complex_float* work, - lapack_int lwork, float* rwork, - lapack_int* iwork ); -lapack_int LAPACKE_zgelsd_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* b, - lapack_int ldb, double* s, double rcond, - lapack_int* rank, lapack_complex_double* work, - lapack_int lwork, double* rwork, - lapack_int* iwork ); - -lapack_int LAPACKE_sgelss_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nrhs, float* a, lapack_int lda, - float* b, lapack_int ldb, float* s, float rcond, - lapack_int* rank, float* work, - lapack_int lwork ); -lapack_int LAPACKE_dgelss_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nrhs, double* a, lapack_int lda, - double* b, lapack_int ldb, double* s, - double rcond, lapack_int* rank, double* work, - lapack_int lwork ); -lapack_int LAPACKE_cgelss_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* b, - lapack_int ldb, float* s, float rcond, - lapack_int* rank, lapack_complex_float* work, - lapack_int lwork, float* rwork ); -lapack_int LAPACKE_zgelss_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* b, - lapack_int ldb, double* s, double rcond, - lapack_int* rank, lapack_complex_double* work, - lapack_int lwork, double* rwork ); - -lapack_int LAPACKE_sgelsy_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nrhs, float* a, lapack_int lda, - float* b, lapack_int ldb, lapack_int* jpvt, - float rcond, lapack_int* rank, float* work, - lapack_int lwork ); -lapack_int LAPACKE_dgelsy_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nrhs, double* a, lapack_int lda, - double* b, lapack_int ldb, lapack_int* jpvt, - double rcond, lapack_int* rank, double* work, - lapack_int lwork ); -lapack_int LAPACKE_cgelsy_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* b, - lapack_int ldb, lapack_int* jpvt, float rcond, - lapack_int* rank, lapack_complex_float* work, - lapack_int lwork, float* rwork ); -lapack_int LAPACKE_zgelsy_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* b, - lapack_int ldb, lapack_int* jpvt, double rcond, - lapack_int* rank, lapack_complex_double* work, - lapack_int lwork, double* rwork ); - -lapack_int LAPACKE_sgeqlf_work( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, float* tau, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dgeqlf_work( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, double* tau, - double* work, lapack_int lwork ); -lapack_int LAPACKE_cgeqlf_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* tau, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zgeqlf_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* tau, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_sgeqp3_work( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, lapack_int* jpvt, - float* tau, float* work, lapack_int lwork ); -lapack_int LAPACKE_dgeqp3_work( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, lapack_int* jpvt, - double* tau, double* work, lapack_int lwork ); -lapack_int LAPACKE_cgeqp3_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int* jpvt, lapack_complex_float* tau, - lapack_complex_float* work, lapack_int lwork, - float* rwork ); -lapack_int LAPACKE_zgeqp3_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int* jpvt, lapack_complex_double* tau, - lapack_complex_double* work, lapack_int lwork, - double* rwork ); - -lapack_int LAPACKE_sgeqpf_work( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, lapack_int* jpvt, - float* tau, float* work ); -lapack_int LAPACKE_dgeqpf_work( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, lapack_int* jpvt, - double* tau, double* work ); -lapack_int LAPACKE_cgeqpf_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int* jpvt, lapack_complex_float* tau, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_zgeqpf_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int* jpvt, lapack_complex_double* tau, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_sgeqr2_work( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, float* tau, - float* work ); -lapack_int LAPACKE_dgeqr2_work( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, double* tau, - double* work ); -lapack_int LAPACKE_cgeqr2_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* tau, - lapack_complex_float* work ); -lapack_int LAPACKE_zgeqr2_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* tau, - lapack_complex_double* work ); - -lapack_int LAPACKE_sgeqrf_work( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, float* tau, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dgeqrf_work( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, double* tau, - double* work, lapack_int lwork ); -lapack_int LAPACKE_cgeqrf_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* tau, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zgeqrf_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* tau, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_sgeqrfp_work( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, float* tau, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dgeqrfp_work( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, double* tau, - double* work, lapack_int lwork ); -lapack_int LAPACKE_cgeqrfp_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* tau, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zgeqrfp_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* tau, - lapack_complex_double* work, - lapack_int lwork ); - -lapack_int LAPACKE_sgerfs_work( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const float* a, lapack_int lda, - const float* af, lapack_int ldaf, - const lapack_int* ipiv, const float* b, - lapack_int ldb, float* x, lapack_int ldx, - float* ferr, float* berr, float* work, - lapack_int* iwork ); -lapack_int LAPACKE_dgerfs_work( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const double* a, - lapack_int lda, const double* af, - lapack_int ldaf, const lapack_int* ipiv, - const double* b, lapack_int ldb, double* x, - lapack_int ldx, double* ferr, double* berr, - double* work, lapack_int* iwork ); -lapack_int LAPACKE_cgerfs_work( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* af, - lapack_int ldaf, const lapack_int* ipiv, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* ferr, float* berr, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_zgerfs_work( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_complex_double* af, - lapack_int ldaf, const lapack_int* ipiv, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* ferr, double* berr, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_sgerfsx_work( int matrix_layout, char trans, char equed, - lapack_int n, lapack_int nrhs, const float* a, - lapack_int lda, const float* af, - lapack_int ldaf, const lapack_int* ipiv, - const float* r, const float* c, const float* b, - lapack_int ldb, float* x, lapack_int ldx, - float* rcond, float* berr, - lapack_int n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int nparams, - float* params, float* work, - lapack_int* iwork ); -lapack_int LAPACKE_dgerfsx_work( int matrix_layout, char trans, char equed, - lapack_int n, lapack_int nrhs, const double* a, - lapack_int lda, const double* af, - lapack_int ldaf, const lapack_int* ipiv, - const double* r, const double* c, - const double* b, lapack_int ldb, double* x, - lapack_int ldx, double* rcond, double* berr, - lapack_int n_err_bnds, double* err_bnds_norm, - double* err_bnds_comp, lapack_int nparams, - double* params, double* work, - lapack_int* iwork ); -lapack_int LAPACKE_cgerfsx_work( int matrix_layout, char trans, char equed, - lapack_int n, lapack_int nrhs, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* af, - lapack_int ldaf, const lapack_int* ipiv, - const float* r, const float* c, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* rcond, float* berr, - lapack_int n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int nparams, - float* params, lapack_complex_float* work, - float* rwork ); -lapack_int LAPACKE_zgerfsx_work( int matrix_layout, char trans, char equed, - lapack_int n, lapack_int nrhs, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* af, - lapack_int ldaf, const lapack_int* ipiv, - const double* r, const double* c, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* berr, - lapack_int n_err_bnds, double* err_bnds_norm, - double* err_bnds_comp, lapack_int nparams, - double* params, lapack_complex_double* work, - double* rwork ); - -lapack_int LAPACKE_sgerqf_work( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, float* tau, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dgerqf_work( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, double* tau, - double* work, lapack_int lwork ); -lapack_int LAPACKE_cgerqf_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* tau, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zgerqf_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* tau, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_sgesdd_work( int matrix_layout, char jobz, lapack_int m, - lapack_int n, float* a, lapack_int lda, - float* s, float* u, lapack_int ldu, float* vt, - lapack_int ldvt, float* work, lapack_int lwork, - lapack_int* iwork ); -lapack_int LAPACKE_dgesdd_work( int matrix_layout, char jobz, lapack_int m, - lapack_int n, double* a, lapack_int lda, - double* s, double* u, lapack_int ldu, - double* vt, lapack_int ldvt, double* work, - lapack_int lwork, lapack_int* iwork ); -lapack_int LAPACKE_cgesdd_work( int matrix_layout, char jobz, lapack_int m, - lapack_int n, lapack_complex_float* a, - lapack_int lda, float* s, - lapack_complex_float* u, lapack_int ldu, - lapack_complex_float* vt, lapack_int ldvt, - lapack_complex_float* work, lapack_int lwork, - float* rwork, lapack_int* iwork ); -lapack_int LAPACKE_zgesdd_work( int matrix_layout, char jobz, lapack_int m, - lapack_int n, lapack_complex_double* a, - lapack_int lda, double* s, - lapack_complex_double* u, lapack_int ldu, - lapack_complex_double* vt, lapack_int ldvt, - lapack_complex_double* work, lapack_int lwork, - double* rwork, lapack_int* iwork ); - -lapack_int LAPACKE_sgesv_work( int matrix_layout, lapack_int n, lapack_int nrhs, - float* a, lapack_int lda, lapack_int* ipiv, - float* b, lapack_int ldb ); -lapack_int LAPACKE_dgesv_work( int matrix_layout, lapack_int n, lapack_int nrhs, - double* a, lapack_int lda, lapack_int* ipiv, - double* b, lapack_int ldb ); -lapack_int LAPACKE_cgesv_work( int matrix_layout, lapack_int n, lapack_int nrhs, - lapack_complex_float* a, lapack_int lda, - lapack_int* ipiv, lapack_complex_float* b, - lapack_int ldb ); -lapack_int LAPACKE_zgesv_work( int matrix_layout, lapack_int n, lapack_int nrhs, - lapack_complex_double* a, lapack_int lda, - lapack_int* ipiv, lapack_complex_double* b, - lapack_int ldb ); -lapack_int LAPACKE_dsgesv_work( int matrix_layout, lapack_int n, lapack_int nrhs, - double* a, lapack_int lda, lapack_int* ipiv, - double* b, lapack_int ldb, double* x, - lapack_int ldx, double* work, float* swork, - lapack_int* iter ); -lapack_int LAPACKE_zcgesv_work( int matrix_layout, lapack_int n, lapack_int nrhs, - lapack_complex_double* a, lapack_int lda, - lapack_int* ipiv, lapack_complex_double* b, - lapack_int ldb, lapack_complex_double* x, - lapack_int ldx, lapack_complex_double* work, - lapack_complex_float* swork, double* rwork, - lapack_int* iter ); - -lapack_int LAPACKE_sgesvd_work( int matrix_layout, char jobu, char jobvt, - lapack_int m, lapack_int n, float* a, - lapack_int lda, float* s, float* u, - lapack_int ldu, float* vt, lapack_int ldvt, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dgesvd_work( int matrix_layout, char jobu, char jobvt, - lapack_int m, lapack_int n, double* a, - lapack_int lda, double* s, double* u, - lapack_int ldu, double* vt, lapack_int ldvt, - double* work, lapack_int lwork ); -lapack_int LAPACKE_cgesvd_work( int matrix_layout, char jobu, char jobvt, - lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - float* s, lapack_complex_float* u, - lapack_int ldu, lapack_complex_float* vt, - lapack_int ldvt, lapack_complex_float* work, - lapack_int lwork, float* rwork ); -lapack_int LAPACKE_zgesvd_work( int matrix_layout, char jobu, char jobvt, - lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - double* s, lapack_complex_double* u, - lapack_int ldu, lapack_complex_double* vt, - lapack_int ldvt, lapack_complex_double* work, - lapack_int lwork, double* rwork ); - -lapack_int LAPACKE_sgesvdx_work( int matrix_layout, char jobu, char jobvt, char range, - lapack_int m, lapack_int n, float* a, - lapack_int lda, float vl, float vu, - lapack_int il, lapack_int iu, lapack_int* ns, - float* s, float* u, lapack_int ldu, - float* vt, lapack_int ldvt, - float* work, lapack_int lwork, lapack_int* iwork ); -lapack_int LAPACKE_dgesvdx_work( int matrix_layout, char jobu, char jobvt, char range, - lapack_int m, lapack_int n, double* a, - lapack_int lda, double vl, double vu, - lapack_int il, lapack_int iu, lapack_int* ns, - double* s, double* u, lapack_int ldu, - double* vt, lapack_int ldvt, - double* work, lapack_int lwork, lapack_int* iwork ); -lapack_int LAPACKE_cgesvdx_work( int matrix_layout, char jobu, char jobvt, char range, - lapack_int m, lapack_int n, lapack_complex_float* a, - lapack_int lda, float vl, float vu, - lapack_int il, lapack_int iu, lapack_int* ns, - float* s, lapack_complex_float* u, lapack_int ldu, - lapack_complex_float* vt, lapack_int ldvt, - lapack_complex_float* work, lapack_int lwork, - float* rwork, lapack_int* iwork ); -lapack_int LAPACKE_zgesvdx_work( int matrix_layout, char jobu, char jobvt, char range, - lapack_int m, lapack_int n, lapack_complex_double* a, - lapack_int lda, double vl, double vu, - lapack_int il, lapack_int iu, lapack_int* ns, - double* s, lapack_complex_double* u, lapack_int ldu, - lapack_complex_double* vt, lapack_int ldvt, - lapack_complex_double* work, lapack_int lwork, - double* rwork, lapack_int* iwork ); - -lapack_int LAPACKE_sgesvj_work( int matrix_layout, char joba, char jobu, - char jobv, lapack_int m, lapack_int n, float* a, - lapack_int lda, float* sva, lapack_int mv, - float* v, lapack_int ldv, float* work, - lapack_int lwork ); -lapack_int LAPACKE_dgesvj_work( int matrix_layout, char joba, char jobu, - char jobv, lapack_int m, lapack_int n, - double* a, lapack_int lda, double* sva, - lapack_int mv, double* v, lapack_int ldv, - double* work, lapack_int lwork ); -lapack_int LAPACKE_cgesvj_work( int matrix_layout, char joba, char jobu, - char jobv, lapack_int m, lapack_int n, lapack_complex_float* a, - lapack_int lda, float* sva, lapack_int mv, - lapack_complex_float* v, lapack_int ldv, - lapack_complex_float* cwork, lapack_int lwork, - float* rwork,lapack_int lrwork ); -lapack_int LAPACKE_zgesvj_work( int matrix_layout, char joba, char jobu, - char jobv, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, double* sva, - lapack_int mv, lapack_complex_double* v, lapack_int ldv, - lapack_complex_double* cwork, lapack_int lwork, - double* rwork, lapack_int lrwork ); - -lapack_int LAPACKE_sgesvx_work( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int nrhs, float* a, - lapack_int lda, float* af, lapack_int ldaf, - lapack_int* ipiv, char* equed, float* r, - float* c, float* b, lapack_int ldb, float* x, - lapack_int ldx, float* rcond, float* ferr, - float* berr, float* work, lapack_int* iwork ); -lapack_int LAPACKE_dgesvx_work( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int nrhs, double* a, - lapack_int lda, double* af, lapack_int ldaf, - lapack_int* ipiv, char* equed, double* r, - double* c, double* b, lapack_int ldb, double* x, - lapack_int ldx, double* rcond, double* ferr, - double* berr, double* work, lapack_int* iwork ); -lapack_int LAPACKE_cgesvx_work( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int nrhs, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* af, lapack_int ldaf, - lapack_int* ipiv, char* equed, float* r, - float* c, lapack_complex_float* b, - lapack_int ldb, lapack_complex_float* x, - lapack_int ldx, float* rcond, float* ferr, - float* berr, lapack_complex_float* work, - float* rwork ); -lapack_int LAPACKE_zgesvx_work( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int nrhs, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* af, lapack_int ldaf, - lapack_int* ipiv, char* equed, double* r, - double* c, lapack_complex_double* b, - lapack_int ldb, lapack_complex_double* x, - lapack_int ldx, double* rcond, double* ferr, - double* berr, lapack_complex_double* work, - double* rwork ); - -lapack_int LAPACKE_sgesvxx_work( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int nrhs, float* a, - lapack_int lda, float* af, lapack_int ldaf, - lapack_int* ipiv, char* equed, float* r, - float* c, float* b, lapack_int ldb, float* x, - lapack_int ldx, float* rcond, float* rpvgrw, - float* berr, lapack_int n_err_bnds, - float* err_bnds_norm, float* err_bnds_comp, - lapack_int nparams, float* params, float* work, - lapack_int* iwork ); -lapack_int LAPACKE_dgesvxx_work( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int nrhs, double* a, - lapack_int lda, double* af, lapack_int ldaf, - lapack_int* ipiv, char* equed, double* r, - double* c, double* b, lapack_int ldb, - double* x, lapack_int ldx, double* rcond, - double* rpvgrw, double* berr, - lapack_int n_err_bnds, double* err_bnds_norm, - double* err_bnds_comp, lapack_int nparams, - double* params, double* work, - lapack_int* iwork ); -lapack_int LAPACKE_cgesvxx_work( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int nrhs, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* af, lapack_int ldaf, - lapack_int* ipiv, char* equed, float* r, - float* c, lapack_complex_float* b, - lapack_int ldb, lapack_complex_float* x, - lapack_int ldx, float* rcond, float* rpvgrw, - float* berr, lapack_int n_err_bnds, - float* err_bnds_norm, float* err_bnds_comp, - lapack_int nparams, float* params, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_zgesvxx_work( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int nrhs, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* af, lapack_int ldaf, - lapack_int* ipiv, char* equed, double* r, - double* c, lapack_complex_double* b, - lapack_int ldb, lapack_complex_double* x, - lapack_int ldx, double* rcond, double* rpvgrw, - double* berr, lapack_int n_err_bnds, - double* err_bnds_norm, double* err_bnds_comp, - lapack_int nparams, double* params, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_sgetf2_work( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, lapack_int* ipiv ); -lapack_int LAPACKE_dgetf2_work( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, lapack_int* ipiv ); -lapack_int LAPACKE_cgetf2_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int* ipiv ); -lapack_int LAPACKE_zgetf2_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int* ipiv ); - -lapack_int LAPACKE_sgetrf_work( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, lapack_int* ipiv ); -lapack_int LAPACKE_dgetrf_work( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, lapack_int* ipiv ); -lapack_int LAPACKE_cgetrf_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int* ipiv ); -lapack_int LAPACKE_zgetrf_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int* ipiv ); - -lapack_int LAPACKE_sgetrf2_work( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, lapack_int* ipiv ); -lapack_int LAPACKE_dgetrf2_work( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, lapack_int* ipiv ); -lapack_int LAPACKE_cgetrf2_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int* ipiv ); -lapack_int LAPACKE_zgetrf2_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int* ipiv ); - -lapack_int LAPACKE_sgetri_work( int matrix_layout, lapack_int n, float* a, - lapack_int lda, const lapack_int* ipiv, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dgetri_work( int matrix_layout, lapack_int n, double* a, - lapack_int lda, const lapack_int* ipiv, - double* work, lapack_int lwork ); -lapack_int LAPACKE_cgetri_work( int matrix_layout, lapack_int n, - lapack_complex_float* a, lapack_int lda, - const lapack_int* ipiv, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zgetri_work( int matrix_layout, lapack_int n, - lapack_complex_double* a, lapack_int lda, - const lapack_int* ipiv, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_sgetrs_work( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const float* a, lapack_int lda, - const lapack_int* ipiv, float* b, - lapack_int ldb ); -lapack_int LAPACKE_dgetrs_work( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const double* a, - lapack_int lda, const lapack_int* ipiv, - double* b, lapack_int ldb ); -lapack_int LAPACKE_cgetrs_work( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zgetrs_work( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_sggbak_work( int matrix_layout, char job, char side, - lapack_int n, lapack_int ilo, lapack_int ihi, - const float* lscale, const float* rscale, - lapack_int m, float* v, lapack_int ldv ); -lapack_int LAPACKE_dggbak_work( int matrix_layout, char job, char side, - lapack_int n, lapack_int ilo, lapack_int ihi, - const double* lscale, const double* rscale, - lapack_int m, double* v, lapack_int ldv ); -lapack_int LAPACKE_cggbak_work( int matrix_layout, char job, char side, - lapack_int n, lapack_int ilo, lapack_int ihi, - const float* lscale, const float* rscale, - lapack_int m, lapack_complex_float* v, - lapack_int ldv ); -lapack_int LAPACKE_zggbak_work( int matrix_layout, char job, char side, - lapack_int n, lapack_int ilo, lapack_int ihi, - const double* lscale, const double* rscale, - lapack_int m, lapack_complex_double* v, - lapack_int ldv ); - -lapack_int LAPACKE_sggbal_work( int matrix_layout, char job, lapack_int n, - float* a, lapack_int lda, float* b, - lapack_int ldb, lapack_int* ilo, - lapack_int* ihi, float* lscale, float* rscale, - float* work ); -lapack_int LAPACKE_dggbal_work( int matrix_layout, char job, lapack_int n, - double* a, lapack_int lda, double* b, - lapack_int ldb, lapack_int* ilo, - lapack_int* ihi, double* lscale, double* rscale, - double* work ); -lapack_int LAPACKE_cggbal_work( int matrix_layout, char job, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - lapack_int* ilo, lapack_int* ihi, float* lscale, - float* rscale, float* work ); -lapack_int LAPACKE_zggbal_work( int matrix_layout, char job, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - lapack_int* ilo, lapack_int* ihi, - double* lscale, double* rscale, double* work ); - -lapack_int LAPACKE_sgges_work( int matrix_layout, char jobvsl, char jobvsr, - char sort, LAPACK_S_SELECT3 selctg, lapack_int n, - float* a, lapack_int lda, float* b, - lapack_int ldb, lapack_int* sdim, float* alphar, - float* alphai, float* beta, float* vsl, - lapack_int ldvsl, float* vsr, lapack_int ldvsr, - float* work, lapack_int lwork, - lapack_logical* bwork ); -lapack_int LAPACKE_dgges_work( int matrix_layout, char jobvsl, char jobvsr, - char sort, LAPACK_D_SELECT3 selctg, lapack_int n, - double* a, lapack_int lda, double* b, - lapack_int ldb, lapack_int* sdim, double* alphar, - double* alphai, double* beta, double* vsl, - lapack_int ldvsl, double* vsr, lapack_int ldvsr, - double* work, lapack_int lwork, - lapack_logical* bwork ); -lapack_int LAPACKE_cgges_work( int matrix_layout, char jobvsl, char jobvsr, - char sort, LAPACK_C_SELECT2 selctg, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - lapack_int* sdim, lapack_complex_float* alpha, - lapack_complex_float* beta, - lapack_complex_float* vsl, lapack_int ldvsl, - lapack_complex_float* vsr, lapack_int ldvsr, - lapack_complex_float* work, lapack_int lwork, - float* rwork, lapack_logical* bwork ); -lapack_int LAPACKE_zgges_work( int matrix_layout, char jobvsl, char jobvsr, - char sort, LAPACK_Z_SELECT2 selctg, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - lapack_int* sdim, lapack_complex_double* alpha, - lapack_complex_double* beta, - lapack_complex_double* vsl, lapack_int ldvsl, - lapack_complex_double* vsr, lapack_int ldvsr, - lapack_complex_double* work, lapack_int lwork, - double* rwork, lapack_logical* bwork ); - -lapack_int LAPACKE_sgges3_work( int matrix_layout, char jobvsl, char jobvsr, - char sort, LAPACK_S_SELECT3 selctg, - lapack_int n, - float* a, lapack_int lda, - float* b, lapack_int ldb, lapack_int* sdim, - float* alphar, float* alphai, float* beta, - float* vsl, lapack_int ldvsl, - float* vsr, lapack_int ldvsr, - float* work, lapack_int lwork, - lapack_logical* bwork ); -lapack_int LAPACKE_dgges3_work( int matrix_layout, char jobvsl, char jobvsr, - char sort, LAPACK_D_SELECT3 selctg, - lapack_int n, - double* a, lapack_int lda, - double* b, lapack_int ldb, lapack_int* sdim, - double* alphar, double* alphai, double* beta, - double* vsl, lapack_int ldvsl, - double* vsr, lapack_int ldvsr, - double* work, lapack_int lwork, - lapack_logical* bwork ); -lapack_int LAPACKE_cgges3_work( int matrix_layout, char jobvsl, char jobvsr, - char sort, LAPACK_C_SELECT2 selctg, - lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - lapack_int* sdim, lapack_complex_float* alpha, - lapack_complex_float* beta, - lapack_complex_float* vsl, lapack_int ldvsl, - lapack_complex_float* vsr, lapack_int ldvsr, - lapack_complex_float* work, lapack_int lwork, - float* rwork, lapack_logical* bwork ); -lapack_int LAPACKE_zgges3_work( int matrix_layout, char jobvsl, char jobvsr, - char sort, LAPACK_Z_SELECT2 selctg, - lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - lapack_int* sdim, lapack_complex_double* alpha, - lapack_complex_double* beta, - lapack_complex_double* vsl, lapack_int ldvsl, - lapack_complex_double* vsr, lapack_int ldvsr, - lapack_complex_double* work, lapack_int lwork, - double* rwork, lapack_logical* bwork ); - -lapack_int LAPACKE_sggesx_work( int matrix_layout, char jobvsl, char jobvsr, - char sort, LAPACK_S_SELECT3 selctg, char sense, - lapack_int n, float* a, lapack_int lda, - float* b, lapack_int ldb, lapack_int* sdim, - float* alphar, float* alphai, float* beta, - float* vsl, lapack_int ldvsl, float* vsr, - lapack_int ldvsr, float* rconde, float* rcondv, - float* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork, - lapack_logical* bwork ); -lapack_int LAPACKE_dggesx_work( int matrix_layout, char jobvsl, char jobvsr, - char sort, LAPACK_D_SELECT3 selctg, char sense, - lapack_int n, double* a, lapack_int lda, - double* b, lapack_int ldb, lapack_int* sdim, - double* alphar, double* alphai, double* beta, - double* vsl, lapack_int ldvsl, double* vsr, - lapack_int ldvsr, double* rconde, - double* rcondv, double* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork, - lapack_logical* bwork ); -lapack_int LAPACKE_cggesx_work( int matrix_layout, char jobvsl, char jobvsr, - char sort, LAPACK_C_SELECT2 selctg, char sense, - lapack_int n, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* b, - lapack_int ldb, lapack_int* sdim, - lapack_complex_float* alpha, - lapack_complex_float* beta, - lapack_complex_float* vsl, lapack_int ldvsl, - lapack_complex_float* vsr, lapack_int ldvsr, - float* rconde, float* rcondv, - lapack_complex_float* work, lapack_int lwork, - float* rwork, lapack_int* iwork, - lapack_int liwork, lapack_logical* bwork ); -lapack_int LAPACKE_zggesx_work( int matrix_layout, char jobvsl, char jobvsr, - char sort, LAPACK_Z_SELECT2 selctg, char sense, - lapack_int n, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* b, - lapack_int ldb, lapack_int* sdim, - lapack_complex_double* alpha, - lapack_complex_double* beta, - lapack_complex_double* vsl, lapack_int ldvsl, - lapack_complex_double* vsr, lapack_int ldvsr, - double* rconde, double* rcondv, - lapack_complex_double* work, lapack_int lwork, - double* rwork, lapack_int* iwork, - lapack_int liwork, lapack_logical* bwork ); - -lapack_int LAPACKE_sggev_work( int matrix_layout, char jobvl, char jobvr, - lapack_int n, float* a, lapack_int lda, float* b, - lapack_int ldb, float* alphar, float* alphai, - float* beta, float* vl, lapack_int ldvl, - float* vr, lapack_int ldvr, float* work, - lapack_int lwork ); -lapack_int LAPACKE_dggev_work( int matrix_layout, char jobvl, char jobvr, - lapack_int n, double* a, lapack_int lda, - double* b, lapack_int ldb, double* alphar, - double* alphai, double* beta, double* vl, - lapack_int ldvl, double* vr, lapack_int ldvr, - double* work, lapack_int lwork ); -lapack_int LAPACKE_cggev_work( int matrix_layout, char jobvl, char jobvr, - lapack_int n, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* b, - lapack_int ldb, lapack_complex_float* alpha, - lapack_complex_float* beta, - lapack_complex_float* vl, lapack_int ldvl, - lapack_complex_float* vr, lapack_int ldvr, - lapack_complex_float* work, lapack_int lwork, - float* rwork ); -lapack_int LAPACKE_zggev_work( int matrix_layout, char jobvl, char jobvr, - lapack_int n, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* b, - lapack_int ldb, lapack_complex_double* alpha, - lapack_complex_double* beta, - lapack_complex_double* vl, lapack_int ldvl, - lapack_complex_double* vr, lapack_int ldvr, - lapack_complex_double* work, lapack_int lwork, - double* rwork ); - -lapack_int LAPACKE_sggev3_work( int matrix_layout, char jobvl, char jobvr, - lapack_int n, - float* a, lapack_int lda, - float* b, lapack_int ldb, - float* alphar, float* alphai, float* beta, - float* vl, lapack_int ldvl, - float* vr, lapack_int ldvr, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dggev3_work( int matrix_layout, char jobvl, char jobvr, - lapack_int n, - double* a, lapack_int lda, - double* b, lapack_int ldb, - double* alphar, double* alphai, double* beta, - double* vl, lapack_int ldvl, - double* vr, lapack_int ldvr, - double* work, lapack_int lwork ); -lapack_int LAPACKE_cggev3_work( int matrix_layout, char jobvl, char jobvr, - lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* alpha, - lapack_complex_float* beta, - lapack_complex_float* vl, lapack_int ldvl, - lapack_complex_float* vr, lapack_int ldvr, - lapack_complex_float* work, lapack_int lwork, - float* rwork ); -lapack_int LAPACKE_zggev3_work( int matrix_layout, char jobvl, char jobvr, - lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* alpha, - lapack_complex_double* beta, - lapack_complex_double* vl, lapack_int ldvl, - lapack_complex_double* vr, lapack_int ldvr, - lapack_complex_double* work, lapack_int lwork, - double* rwork ); - -lapack_int LAPACKE_sggevx_work( int matrix_layout, char balanc, char jobvl, - char jobvr, char sense, lapack_int n, float* a, - lapack_int lda, float* b, lapack_int ldb, - float* alphar, float* alphai, float* beta, - float* vl, lapack_int ldvl, float* vr, - lapack_int ldvr, lapack_int* ilo, - lapack_int* ihi, float* lscale, float* rscale, - float* abnrm, float* bbnrm, float* rconde, - float* rcondv, float* work, lapack_int lwork, - lapack_int* iwork, lapack_logical* bwork ); -lapack_int LAPACKE_dggevx_work( int matrix_layout, char balanc, char jobvl, - char jobvr, char sense, lapack_int n, double* a, - lapack_int lda, double* b, lapack_int ldb, - double* alphar, double* alphai, double* beta, - double* vl, lapack_int ldvl, double* vr, - lapack_int ldvr, lapack_int* ilo, - lapack_int* ihi, double* lscale, double* rscale, - double* abnrm, double* bbnrm, double* rconde, - double* rcondv, double* work, lapack_int lwork, - lapack_int* iwork, lapack_logical* bwork ); -lapack_int LAPACKE_cggevx_work( int matrix_layout, char balanc, char jobvl, - char jobvr, char sense, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* alpha, - lapack_complex_float* beta, - lapack_complex_float* vl, lapack_int ldvl, - lapack_complex_float* vr, lapack_int ldvr, - lapack_int* ilo, lapack_int* ihi, float* lscale, - float* rscale, float* abnrm, float* bbnrm, - float* rconde, float* rcondv, - lapack_complex_float* work, lapack_int lwork, - float* rwork, lapack_int* iwork, - lapack_logical* bwork ); -lapack_int LAPACKE_zggevx_work( int matrix_layout, char balanc, char jobvl, - char jobvr, char sense, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* alpha, - lapack_complex_double* beta, - lapack_complex_double* vl, lapack_int ldvl, - lapack_complex_double* vr, lapack_int ldvr, - lapack_int* ilo, lapack_int* ihi, - double* lscale, double* rscale, double* abnrm, - double* bbnrm, double* rconde, double* rcondv, - lapack_complex_double* work, lapack_int lwork, - double* rwork, lapack_int* iwork, - lapack_logical* bwork ); - -lapack_int LAPACKE_sggglm_work( int matrix_layout, lapack_int n, lapack_int m, - lapack_int p, float* a, lapack_int lda, - float* b, lapack_int ldb, float* d, float* x, - float* y, float* work, lapack_int lwork ); -lapack_int LAPACKE_dggglm_work( int matrix_layout, lapack_int n, lapack_int m, - lapack_int p, double* a, lapack_int lda, - double* b, lapack_int ldb, double* d, double* x, - double* y, double* work, lapack_int lwork ); -lapack_int LAPACKE_cggglm_work( int matrix_layout, lapack_int n, lapack_int m, - lapack_int p, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* b, - lapack_int ldb, lapack_complex_float* d, - lapack_complex_float* x, - lapack_complex_float* y, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zggglm_work( int matrix_layout, lapack_int n, lapack_int m, - lapack_int p, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* b, - lapack_int ldb, lapack_complex_double* d, - lapack_complex_double* x, - lapack_complex_double* y, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_sgghrd_work( int matrix_layout, char compq, char compz, - lapack_int n, lapack_int ilo, lapack_int ihi, - float* a, lapack_int lda, float* b, - lapack_int ldb, float* q, lapack_int ldq, - float* z, lapack_int ldz ); -lapack_int LAPACKE_dgghrd_work( int matrix_layout, char compq, char compz, - lapack_int n, lapack_int ilo, lapack_int ihi, - double* a, lapack_int lda, double* b, - lapack_int ldb, double* q, lapack_int ldq, - double* z, lapack_int ldz ); -lapack_int LAPACKE_cgghrd_work( int matrix_layout, char compq, char compz, - lapack_int n, lapack_int ilo, lapack_int ihi, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* q, lapack_int ldq, - lapack_complex_float* z, lapack_int ldz ); -lapack_int LAPACKE_zgghrd_work( int matrix_layout, char compq, char compz, - lapack_int n, lapack_int ilo, lapack_int ihi, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* q, lapack_int ldq, - lapack_complex_double* z, lapack_int ldz ); - -lapack_int LAPACKE_sgghd3_work( int matrix_layout, char compq, char compz, - lapack_int n, lapack_int ilo, lapack_int ihi, - float* a, lapack_int lda, - float* b, lapack_int ldb, - float* q, lapack_int ldq, - float* z, lapack_int ldz, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dgghd3_work( int matrix_layout, char compq, char compz, - lapack_int n, lapack_int ilo, lapack_int ihi, - double* a, lapack_int lda, - double* b, lapack_int ldb, - double* q, lapack_int ldq, - double* z, lapack_int ldz, - double* work, lapack_int lwork ); -lapack_int LAPACKE_cgghd3_work( int matrix_layout, char compq, char compz, - lapack_int n, lapack_int ilo, lapack_int ihi, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* q, lapack_int ldq, - lapack_complex_float* z, lapack_int ldz, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zgghd3_work( int matrix_layout, char compq, char compz, - lapack_int n, lapack_int ilo, lapack_int ihi, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* q, lapack_int ldq, - lapack_complex_double* z, lapack_int ldz, - lapack_complex_double* work, - lapack_int lwork ); - -lapack_int LAPACKE_sgglse_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int p, float* a, lapack_int lda, - float* b, lapack_int ldb, float* c, float* d, - float* x, float* work, lapack_int lwork ); -lapack_int LAPACKE_dgglse_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int p, double* a, lapack_int lda, - double* b, lapack_int ldb, double* c, double* d, - double* x, double* work, lapack_int lwork ); -lapack_int LAPACKE_cgglse_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int p, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* b, - lapack_int ldb, lapack_complex_float* c, - lapack_complex_float* d, - lapack_complex_float* x, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zgglse_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int p, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* b, - lapack_int ldb, lapack_complex_double* c, - lapack_complex_double* d, - lapack_complex_double* x, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_sggqrf_work( int matrix_layout, lapack_int n, lapack_int m, - lapack_int p, float* a, lapack_int lda, - float* taua, float* b, lapack_int ldb, - float* taub, float* work, lapack_int lwork ); -lapack_int LAPACKE_dggqrf_work( int matrix_layout, lapack_int n, lapack_int m, - lapack_int p, double* a, lapack_int lda, - double* taua, double* b, lapack_int ldb, - double* taub, double* work, lapack_int lwork ); -lapack_int LAPACKE_cggqrf_work( int matrix_layout, lapack_int n, lapack_int m, - lapack_int p, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* taua, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* taub, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zggqrf_work( int matrix_layout, lapack_int n, lapack_int m, - lapack_int p, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* taua, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* taub, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_sggrqf_work( int matrix_layout, lapack_int m, lapack_int p, - lapack_int n, float* a, lapack_int lda, - float* taua, float* b, lapack_int ldb, - float* taub, float* work, lapack_int lwork ); -lapack_int LAPACKE_dggrqf_work( int matrix_layout, lapack_int m, lapack_int p, - lapack_int n, double* a, lapack_int lda, - double* taua, double* b, lapack_int ldb, - double* taub, double* work, lapack_int lwork ); -lapack_int LAPACKE_cggrqf_work( int matrix_layout, lapack_int m, lapack_int p, - lapack_int n, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* taua, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* taub, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zggrqf_work( int matrix_layout, lapack_int m, lapack_int p, - lapack_int n, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* taua, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* taub, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_sggsvd_work( int matrix_layout, char jobu, char jobv, - char jobq, lapack_int m, lapack_int n, - lapack_int p, lapack_int* k, lapack_int* l, - float* a, lapack_int lda, float* b, - lapack_int ldb, float* alpha, float* beta, - float* u, lapack_int ldu, float* v, - lapack_int ldv, float* q, lapack_int ldq, - float* work, lapack_int* iwork ); -lapack_int LAPACKE_dggsvd_work( int matrix_layout, char jobu, char jobv, - char jobq, lapack_int m, lapack_int n, - lapack_int p, lapack_int* k, lapack_int* l, - double* a, lapack_int lda, double* b, - lapack_int ldb, double* alpha, double* beta, - double* u, lapack_int ldu, double* v, - lapack_int ldv, double* q, lapack_int ldq, - double* work, lapack_int* iwork ); -lapack_int LAPACKE_cggsvd_work( int matrix_layout, char jobu, char jobv, - char jobq, lapack_int m, lapack_int n, - lapack_int p, lapack_int* k, lapack_int* l, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - float* alpha, float* beta, - lapack_complex_float* u, lapack_int ldu, - lapack_complex_float* v, lapack_int ldv, - lapack_complex_float* q, lapack_int ldq, - lapack_complex_float* work, float* rwork, - lapack_int* iwork ); -lapack_int LAPACKE_zggsvd_work( int matrix_layout, char jobu, char jobv, - char jobq, lapack_int m, lapack_int n, - lapack_int p, lapack_int* k, lapack_int* l, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - double* alpha, double* beta, - lapack_complex_double* u, lapack_int ldu, - lapack_complex_double* v, lapack_int ldv, - lapack_complex_double* q, lapack_int ldq, - lapack_complex_double* work, double* rwork, - lapack_int* iwork ); - -lapack_int LAPACKE_sggsvd3_work( int matrix_layout, char jobu, char jobv, - char jobq, lapack_int m, lapack_int n, - lapack_int p, lapack_int* k, lapack_int* l, - float* a, lapack_int lda, float* b, - lapack_int ldb, float* alpha, float* beta, - float* u, lapack_int ldu, float* v, - lapack_int ldv, float* q, lapack_int ldq, - float* work, lapack_int lwork, - lapack_int* iwork ); -lapack_int LAPACKE_dggsvd3_work( int matrix_layout, char jobu, char jobv, - char jobq, lapack_int m, lapack_int n, - lapack_int p, lapack_int* k, lapack_int* l, - double* a, lapack_int lda, double* b, - lapack_int ldb, double* alpha, double* beta, - double* u, lapack_int ldu, double* v, - lapack_int ldv, double* q, lapack_int ldq, - double* work, lapack_int lwork, - lapack_int* iwork ); -lapack_int LAPACKE_cggsvd3_work( int matrix_layout, char jobu, char jobv, - char jobq, lapack_int m, lapack_int n, - lapack_int p, lapack_int* k, lapack_int* l, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - float* alpha, float* beta, - lapack_complex_float* u, lapack_int ldu, - lapack_complex_float* v, lapack_int ldv, - lapack_complex_float* q, lapack_int ldq, - lapack_complex_float* work, lapack_int lwork, - float* rwork, lapack_int* iwork ); -lapack_int LAPACKE_zggsvd3_work( int matrix_layout, char jobu, char jobv, - char jobq, lapack_int m, lapack_int n, - lapack_int p, lapack_int* k, lapack_int* l, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - double* alpha, double* beta, - lapack_complex_double* u, lapack_int ldu, - lapack_complex_double* v, lapack_int ldv, - lapack_complex_double* q, lapack_int ldq, - lapack_complex_double* work, lapack_int lwork, - double* rwork, lapack_int* iwork ); - -lapack_int LAPACKE_sggsvp_work( int matrix_layout, char jobu, char jobv, - char jobq, lapack_int m, lapack_int p, - lapack_int n, float* a, lapack_int lda, - float* b, lapack_int ldb, float tola, - float tolb, lapack_int* k, lapack_int* l, - float* u, lapack_int ldu, float* v, - lapack_int ldv, float* q, lapack_int ldq, - lapack_int* iwork, float* tau, float* work ); -lapack_int LAPACKE_dggsvp_work( int matrix_layout, char jobu, char jobv, - char jobq, lapack_int m, lapack_int p, - lapack_int n, double* a, lapack_int lda, - double* b, lapack_int ldb, double tola, - double tolb, lapack_int* k, lapack_int* l, - double* u, lapack_int ldu, double* v, - lapack_int ldv, double* q, lapack_int ldq, - lapack_int* iwork, double* tau, double* work ); -lapack_int LAPACKE_cggsvp_work( int matrix_layout, char jobu, char jobv, - char jobq, lapack_int m, lapack_int p, - lapack_int n, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* b, - lapack_int ldb, float tola, float tolb, - lapack_int* k, lapack_int* l, - lapack_complex_float* u, lapack_int ldu, - lapack_complex_float* v, lapack_int ldv, - lapack_complex_float* q, lapack_int ldq, - lapack_int* iwork, float* rwork, - lapack_complex_float* tau, - lapack_complex_float* work ); -lapack_int LAPACKE_zggsvp_work( int matrix_layout, char jobu, char jobv, - char jobq, lapack_int m, lapack_int p, - lapack_int n, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* b, - lapack_int ldb, double tola, double tolb, - lapack_int* k, lapack_int* l, - lapack_complex_double* u, lapack_int ldu, - lapack_complex_double* v, lapack_int ldv, - lapack_complex_double* q, lapack_int ldq, - lapack_int* iwork, double* rwork, - lapack_complex_double* tau, - lapack_complex_double* work ); - -lapack_int LAPACKE_sggsvp3_work( int matrix_layout, char jobu, char jobv, - char jobq, lapack_int m, lapack_int p, - lapack_int n, float* a, lapack_int lda, - float* b, lapack_int ldb, float tola, - float tolb, lapack_int* k, lapack_int* l, - float* u, lapack_int ldu, float* v, - lapack_int ldv, float* q, lapack_int ldq, - lapack_int* iwork, float* tau, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dggsvp3_work( int matrix_layout, char jobu, char jobv, - char jobq, lapack_int m, lapack_int p, - lapack_int n, double* a, lapack_int lda, - double* b, lapack_int ldb, double tola, - double tolb, lapack_int* k, lapack_int* l, - double* u, lapack_int ldu, double* v, - lapack_int ldv, double* q, lapack_int ldq, - lapack_int* iwork, double* tau, double* work, - lapack_int lwork ); -lapack_int LAPACKE_cggsvp3_work( int matrix_layout, char jobu, char jobv, - char jobq, lapack_int m, lapack_int p, - lapack_int n, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* b, - lapack_int ldb, float tola, float tolb, - lapack_int* k, lapack_int* l, - lapack_complex_float* u, lapack_int ldu, - lapack_complex_float* v, lapack_int ldv, - lapack_complex_float* q, lapack_int ldq, - lapack_int* iwork, float* rwork, - lapack_complex_float* tau, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zggsvp3_work( int matrix_layout, char jobu, char jobv, - char jobq, lapack_int m, lapack_int p, - lapack_int n, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* b, - lapack_int ldb, double tola, double tolb, - lapack_int* k, lapack_int* l, - lapack_complex_double* u, lapack_int ldu, - lapack_complex_double* v, lapack_int ldv, - lapack_complex_double* q, lapack_int ldq, - lapack_int* iwork, double* rwork, - lapack_complex_double* tau, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_sgtcon_work( char norm, lapack_int n, const float* dl, - const float* d, const float* du, - const float* du2, const lapack_int* ipiv, - float anorm, float* rcond, float* work, - lapack_int* iwork ); -lapack_int LAPACKE_dgtcon_work( char norm, lapack_int n, const double* dl, - const double* d, const double* du, - const double* du2, const lapack_int* ipiv, - double anorm, double* rcond, double* work, - lapack_int* iwork ); -lapack_int LAPACKE_cgtcon_work( char norm, lapack_int n, - const lapack_complex_float* dl, - const lapack_complex_float* d, - const lapack_complex_float* du, - const lapack_complex_float* du2, - const lapack_int* ipiv, float anorm, - float* rcond, lapack_complex_float* work ); -lapack_int LAPACKE_zgtcon_work( char norm, lapack_int n, - const lapack_complex_double* dl, - const lapack_complex_double* d, - const lapack_complex_double* du, - const lapack_complex_double* du2, - const lapack_int* ipiv, double anorm, - double* rcond, lapack_complex_double* work ); - -lapack_int LAPACKE_sgtrfs_work( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const float* dl, - const float* d, const float* du, - const float* dlf, const float* df, - const float* duf, const float* du2, - const lapack_int* ipiv, const float* b, - lapack_int ldb, float* x, lapack_int ldx, - float* ferr, float* berr, float* work, - lapack_int* iwork ); -lapack_int LAPACKE_dgtrfs_work( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const double* dl, - const double* d, const double* du, - const double* dlf, const double* df, - const double* duf, const double* du2, - const lapack_int* ipiv, const double* b, - lapack_int ldb, double* x, lapack_int ldx, - double* ferr, double* berr, double* work, - lapack_int* iwork ); -lapack_int LAPACKE_cgtrfs_work( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const lapack_complex_float* dl, - const lapack_complex_float* d, - const lapack_complex_float* du, - const lapack_complex_float* dlf, - const lapack_complex_float* df, - const lapack_complex_float* duf, - const lapack_complex_float* du2, - const lapack_int* ipiv, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* ferr, float* berr, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_zgtrfs_work( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, - const lapack_complex_double* dl, - const lapack_complex_double* d, - const lapack_complex_double* du, - const lapack_complex_double* dlf, - const lapack_complex_double* df, - const lapack_complex_double* duf, - const lapack_complex_double* du2, - const lapack_int* ipiv, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* ferr, double* berr, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_sgtsv_work( int matrix_layout, lapack_int n, lapack_int nrhs, - float* dl, float* d, float* du, float* b, - lapack_int ldb ); -lapack_int LAPACKE_dgtsv_work( int matrix_layout, lapack_int n, lapack_int nrhs, - double* dl, double* d, double* du, double* b, - lapack_int ldb ); -lapack_int LAPACKE_cgtsv_work( int matrix_layout, lapack_int n, lapack_int nrhs, - lapack_complex_float* dl, - lapack_complex_float* d, - lapack_complex_float* du, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zgtsv_work( int matrix_layout, lapack_int n, lapack_int nrhs, - lapack_complex_double* dl, - lapack_complex_double* d, - lapack_complex_double* du, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_sgtsvx_work( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int nrhs, const float* dl, - const float* d, const float* du, float* dlf, - float* df, float* duf, float* du2, - lapack_int* ipiv, const float* b, - lapack_int ldb, float* x, lapack_int ldx, - float* rcond, float* ferr, float* berr, - float* work, lapack_int* iwork ); -lapack_int LAPACKE_dgtsvx_work( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int nrhs, const double* dl, - const double* d, const double* du, double* dlf, - double* df, double* duf, double* du2, - lapack_int* ipiv, const double* b, - lapack_int ldb, double* x, lapack_int ldx, - double* rcond, double* ferr, double* berr, - double* work, lapack_int* iwork ); -lapack_int LAPACKE_cgtsvx_work( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int nrhs, - const lapack_complex_float* dl, - const lapack_complex_float* d, - const lapack_complex_float* du, - lapack_complex_float* dlf, - lapack_complex_float* df, - lapack_complex_float* duf, - lapack_complex_float* du2, lapack_int* ipiv, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* rcond, float* ferr, float* berr, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_zgtsvx_work( int matrix_layout, char fact, char trans, - lapack_int n, lapack_int nrhs, - const lapack_complex_double* dl, - const lapack_complex_double* d, - const lapack_complex_double* du, - lapack_complex_double* dlf, - lapack_complex_double* df, - lapack_complex_double* duf, - lapack_complex_double* du2, lapack_int* ipiv, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* ferr, double* berr, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_sgttrf_work( lapack_int n, float* dl, float* d, float* du, - float* du2, lapack_int* ipiv ); -lapack_int LAPACKE_dgttrf_work( lapack_int n, double* dl, double* d, double* du, - double* du2, lapack_int* ipiv ); -lapack_int LAPACKE_cgttrf_work( lapack_int n, lapack_complex_float* dl, - lapack_complex_float* d, - lapack_complex_float* du, - lapack_complex_float* du2, lapack_int* ipiv ); -lapack_int LAPACKE_zgttrf_work( lapack_int n, lapack_complex_double* dl, - lapack_complex_double* d, - lapack_complex_double* du, - lapack_complex_double* du2, lapack_int* ipiv ); - -lapack_int LAPACKE_sgttrs_work( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const float* dl, - const float* d, const float* du, - const float* du2, const lapack_int* ipiv, - float* b, lapack_int ldb ); -lapack_int LAPACKE_dgttrs_work( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const double* dl, - const double* d, const double* du, - const double* du2, const lapack_int* ipiv, - double* b, lapack_int ldb ); -lapack_int LAPACKE_cgttrs_work( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, const lapack_complex_float* dl, - const lapack_complex_float* d, - const lapack_complex_float* du, - const lapack_complex_float* du2, - const lapack_int* ipiv, lapack_complex_float* b, - lapack_int ldb ); -lapack_int LAPACKE_zgttrs_work( int matrix_layout, char trans, lapack_int n, - lapack_int nrhs, - const lapack_complex_double* dl, - const lapack_complex_double* d, - const lapack_complex_double* du, - const lapack_complex_double* du2, - const lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_chbev_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_int kd, - lapack_complex_float* ab, lapack_int ldab, - float* w, lapack_complex_float* z, - lapack_int ldz, lapack_complex_float* work, - float* rwork ); -lapack_int LAPACKE_zhbev_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_int kd, - lapack_complex_double* ab, lapack_int ldab, - double* w, lapack_complex_double* z, - lapack_int ldz, lapack_complex_double* work, - double* rwork ); - -lapack_int LAPACKE_chbevd_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_int kd, - lapack_complex_float* ab, lapack_int ldab, - float* w, lapack_complex_float* z, - lapack_int ldz, lapack_complex_float* work, - lapack_int lwork, float* rwork, - lapack_int lrwork, lapack_int* iwork, - lapack_int liwork ); -lapack_int LAPACKE_zhbevd_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_int kd, - lapack_complex_double* ab, lapack_int ldab, - double* w, lapack_complex_double* z, - lapack_int ldz, lapack_complex_double* work, - lapack_int lwork, double* rwork, - lapack_int lrwork, lapack_int* iwork, - lapack_int liwork ); - -lapack_int LAPACKE_chbevx_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, lapack_int kd, - lapack_complex_float* ab, lapack_int ldab, - lapack_complex_float* q, lapack_int ldq, - float vl, float vu, lapack_int il, - lapack_int iu, float abstol, lapack_int* m, - float* w, lapack_complex_float* z, - lapack_int ldz, lapack_complex_float* work, - float* rwork, lapack_int* iwork, - lapack_int* ifail ); -lapack_int LAPACKE_zhbevx_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, lapack_int kd, - lapack_complex_double* ab, lapack_int ldab, - lapack_complex_double* q, lapack_int ldq, - double vl, double vu, lapack_int il, - lapack_int iu, double abstol, lapack_int* m, - double* w, lapack_complex_double* z, - lapack_int ldz, lapack_complex_double* work, - double* rwork, lapack_int* iwork, - lapack_int* ifail ); - -lapack_int LAPACKE_chbgst_work( int matrix_layout, char vect, char uplo, - lapack_int n, lapack_int ka, lapack_int kb, - lapack_complex_float* ab, lapack_int ldab, - const lapack_complex_float* bb, lapack_int ldbb, - lapack_complex_float* x, lapack_int ldx, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_zhbgst_work( int matrix_layout, char vect, char uplo, - lapack_int n, lapack_int ka, lapack_int kb, - lapack_complex_double* ab, lapack_int ldab, - const lapack_complex_double* bb, - lapack_int ldbb, lapack_complex_double* x, - lapack_int ldx, lapack_complex_double* work, - double* rwork ); - -lapack_int LAPACKE_chbgv_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_int ka, lapack_int kb, - lapack_complex_float* ab, lapack_int ldab, - lapack_complex_float* bb, lapack_int ldbb, - float* w, lapack_complex_float* z, - lapack_int ldz, lapack_complex_float* work, - float* rwork ); -lapack_int LAPACKE_zhbgv_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_int ka, lapack_int kb, - lapack_complex_double* ab, lapack_int ldab, - lapack_complex_double* bb, lapack_int ldbb, - double* w, lapack_complex_double* z, - lapack_int ldz, lapack_complex_double* work, - double* rwork ); - -lapack_int LAPACKE_chbgvd_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_int ka, lapack_int kb, - lapack_complex_float* ab, lapack_int ldab, - lapack_complex_float* bb, lapack_int ldbb, - float* w, lapack_complex_float* z, - lapack_int ldz, lapack_complex_float* work, - lapack_int lwork, float* rwork, - lapack_int lrwork, lapack_int* iwork, - lapack_int liwork ); -lapack_int LAPACKE_zhbgvd_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_int ka, lapack_int kb, - lapack_complex_double* ab, lapack_int ldab, - lapack_complex_double* bb, lapack_int ldbb, - double* w, lapack_complex_double* z, - lapack_int ldz, lapack_complex_double* work, - lapack_int lwork, double* rwork, - lapack_int lrwork, lapack_int* iwork, - lapack_int liwork ); - -lapack_int LAPACKE_chbgvx_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, lapack_int ka, - lapack_int kb, lapack_complex_float* ab, - lapack_int ldab, lapack_complex_float* bb, - lapack_int ldbb, lapack_complex_float* q, - lapack_int ldq, float vl, float vu, - lapack_int il, lapack_int iu, float abstol, - lapack_int* m, float* w, - lapack_complex_float* z, lapack_int ldz, - lapack_complex_float* work, float* rwork, - lapack_int* iwork, lapack_int* ifail ); -lapack_int LAPACKE_zhbgvx_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, lapack_int ka, - lapack_int kb, lapack_complex_double* ab, - lapack_int ldab, lapack_complex_double* bb, - lapack_int ldbb, lapack_complex_double* q, - lapack_int ldq, double vl, double vu, - lapack_int il, lapack_int iu, double abstol, - lapack_int* m, double* w, - lapack_complex_double* z, lapack_int ldz, - lapack_complex_double* work, double* rwork, - lapack_int* iwork, lapack_int* ifail ); - -lapack_int LAPACKE_chbtrd_work( int matrix_layout, char vect, char uplo, - lapack_int n, lapack_int kd, - lapack_complex_float* ab, lapack_int ldab, - float* d, float* e, lapack_complex_float* q, - lapack_int ldq, lapack_complex_float* work ); -lapack_int LAPACKE_zhbtrd_work( int matrix_layout, char vect, char uplo, - lapack_int n, lapack_int kd, - lapack_complex_double* ab, lapack_int ldab, - double* d, double* e, lapack_complex_double* q, - lapack_int ldq, lapack_complex_double* work ); - -lapack_int LAPACKE_checon_work( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - const lapack_int* ipiv, float anorm, - float* rcond, lapack_complex_float* work ); -lapack_int LAPACKE_zhecon_work( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - const lapack_int* ipiv, double anorm, - double* rcond, lapack_complex_double* work ); - -lapack_int LAPACKE_cheequb_work( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - float* s, float* scond, float* amax, - lapack_complex_float* work ); -lapack_int LAPACKE_zheequb_work( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - double* s, double* scond, double* amax, - lapack_complex_double* work ); - -lapack_int LAPACKE_cheev_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_complex_float* a, - lapack_int lda, float* w, - lapack_complex_float* work, lapack_int lwork, - float* rwork ); -lapack_int LAPACKE_zheev_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_complex_double* a, - lapack_int lda, double* w, - lapack_complex_double* work, lapack_int lwork, - double* rwork ); - -lapack_int LAPACKE_cheevd_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_complex_float* a, - lapack_int lda, float* w, - lapack_complex_float* work, lapack_int lwork, - float* rwork, lapack_int lrwork, - lapack_int* iwork, lapack_int liwork ); -lapack_int LAPACKE_zheevd_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_complex_double* a, - lapack_int lda, double* w, - lapack_complex_double* work, lapack_int lwork, - double* rwork, lapack_int lrwork, - lapack_int* iwork, lapack_int liwork ); - -lapack_int LAPACKE_cheevr_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - float vl, float vu, lapack_int il, - lapack_int iu, float abstol, lapack_int* m, - float* w, lapack_complex_float* z, - lapack_int ldz, lapack_int* isuppz, - lapack_complex_float* work, lapack_int lwork, - float* rwork, lapack_int lrwork, - lapack_int* iwork, lapack_int liwork ); -lapack_int LAPACKE_zheevr_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - double vl, double vu, lapack_int il, - lapack_int iu, double abstol, lapack_int* m, - double* w, lapack_complex_double* z, - lapack_int ldz, lapack_int* isuppz, - lapack_complex_double* work, lapack_int lwork, - double* rwork, lapack_int lrwork, - lapack_int* iwork, lapack_int liwork ); - -lapack_int LAPACKE_cheevx_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - float vl, float vu, lapack_int il, - lapack_int iu, float abstol, lapack_int* m, - float* w, lapack_complex_float* z, - lapack_int ldz, lapack_complex_float* work, - lapack_int lwork, float* rwork, - lapack_int* iwork, lapack_int* ifail ); -lapack_int LAPACKE_zheevx_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - double vl, double vu, lapack_int il, - lapack_int iu, double abstol, lapack_int* m, - double* w, lapack_complex_double* z, - lapack_int ldz, lapack_complex_double* work, - lapack_int lwork, double* rwork, - lapack_int* iwork, lapack_int* ifail ); - -lapack_int LAPACKE_chegst_work( int matrix_layout, lapack_int itype, char uplo, - lapack_int n, lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* b, - lapack_int ldb ); -lapack_int LAPACKE_zhegst_work( int matrix_layout, lapack_int itype, char uplo, - lapack_int n, lapack_complex_double* a, - lapack_int lda, const lapack_complex_double* b, - lapack_int ldb ); - -lapack_int LAPACKE_chegv_work( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* b, - lapack_int ldb, float* w, - lapack_complex_float* work, lapack_int lwork, - float* rwork ); -lapack_int LAPACKE_zhegv_work( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - double* w, lapack_complex_double* work, - lapack_int lwork, double* rwork ); - -lapack_int LAPACKE_chegvd_work( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - float* w, lapack_complex_float* work, - lapack_int lwork, float* rwork, - lapack_int lrwork, lapack_int* iwork, - lapack_int liwork ); -lapack_int LAPACKE_zhegvd_work( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - double* w, lapack_complex_double* work, - lapack_int lwork, double* rwork, - lapack_int lrwork, lapack_int* iwork, - lapack_int liwork ); - -lapack_int LAPACKE_chegvx_work( int matrix_layout, lapack_int itype, char jobz, - char range, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - float vl, float vu, lapack_int il, - lapack_int iu, float abstol, lapack_int* m, - float* w, lapack_complex_float* z, - lapack_int ldz, lapack_complex_float* work, - lapack_int lwork, float* rwork, - lapack_int* iwork, lapack_int* ifail ); -lapack_int LAPACKE_zhegvx_work( int matrix_layout, lapack_int itype, char jobz, - char range, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - double vl, double vu, lapack_int il, - lapack_int iu, double abstol, lapack_int* m, - double* w, lapack_complex_double* z, - lapack_int ldz, lapack_complex_double* work, - lapack_int lwork, double* rwork, - lapack_int* iwork, lapack_int* ifail ); - -lapack_int LAPACKE_cherfs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* af, - lapack_int ldaf, const lapack_int* ipiv, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* ferr, float* berr, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_zherfs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_complex_double* af, - lapack_int ldaf, const lapack_int* ipiv, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* ferr, double* berr, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_cherfsx_work( int matrix_layout, char uplo, char equed, - lapack_int n, lapack_int nrhs, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* af, - lapack_int ldaf, const lapack_int* ipiv, - const float* s, const lapack_complex_float* b, - lapack_int ldb, lapack_complex_float* x, - lapack_int ldx, float* rcond, float* berr, - lapack_int n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int nparams, - float* params, lapack_complex_float* work, - float* rwork ); -lapack_int LAPACKE_zherfsx_work( int matrix_layout, char uplo, char equed, - lapack_int n, lapack_int nrhs, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* af, - lapack_int ldaf, const lapack_int* ipiv, - const double* s, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* berr, - lapack_int n_err_bnds, double* err_bnds_norm, - double* err_bnds_comp, lapack_int nparams, - double* params, lapack_complex_double* work, - double* rwork ); - -lapack_int LAPACKE_chesv_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zhesv_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_chesvx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, - const lapack_complex_float* a, lapack_int lda, - lapack_complex_float* af, lapack_int ldaf, - lapack_int* ipiv, const lapack_complex_float* b, - lapack_int ldb, lapack_complex_float* x, - lapack_int ldx, float* rcond, float* ferr, - float* berr, lapack_complex_float* work, - lapack_int lwork, float* rwork ); -lapack_int LAPACKE_zhesvx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, - const lapack_complex_double* a, lapack_int lda, - lapack_complex_double* af, lapack_int ldaf, - lapack_int* ipiv, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* ferr, double* berr, - lapack_complex_double* work, lapack_int lwork, - double* rwork ); - -lapack_int LAPACKE_chesvxx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* af, lapack_int ldaf, - lapack_int* ipiv, char* equed, float* s, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* rcond, float* rpvgrw, float* berr, - lapack_int n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int nparams, - float* params, lapack_complex_float* work, - float* rwork ); -lapack_int LAPACKE_zhesvxx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* af, lapack_int ldaf, - lapack_int* ipiv, char* equed, double* s, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* rpvgrw, double* berr, - lapack_int n_err_bnds, double* err_bnds_norm, - double* err_bnds_comp, lapack_int nparams, - double* params, lapack_complex_double* work, - double* rwork ); - -lapack_int LAPACKE_chetrd_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - float* d, float* e, lapack_complex_float* tau, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zhetrd_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - double* d, double* e, - lapack_complex_double* tau, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_chetrf_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int* ipiv, lapack_complex_float* work, - lapack_int lwork ); -lapack_int LAPACKE_zhetrf_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int* ipiv, lapack_complex_double* work, - lapack_int lwork ); - -lapack_int LAPACKE_chetri_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - const lapack_int* ipiv, - lapack_complex_float* work ); -lapack_int LAPACKE_zhetri_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - const lapack_int* ipiv, - lapack_complex_double* work ); - -lapack_int LAPACKE_chetrs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zhetrs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_chfrk_work( int matrix_layout, char transr, char uplo, - char trans, lapack_int n, lapack_int k, - float alpha, const lapack_complex_float* a, - lapack_int lda, float beta, - lapack_complex_float* c ); -lapack_int LAPACKE_zhfrk_work( int matrix_layout, char transr, char uplo, - char trans, lapack_int n, lapack_int k, - double alpha, const lapack_complex_double* a, - lapack_int lda, double beta, - lapack_complex_double* c ); - -lapack_int LAPACKE_shgeqz_work( int matrix_layout, char job, char compq, - char compz, lapack_int n, lapack_int ilo, - lapack_int ihi, float* h, lapack_int ldh, - float* t, lapack_int ldt, float* alphar, - float* alphai, float* beta, float* q, - lapack_int ldq, float* z, lapack_int ldz, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dhgeqz_work( int matrix_layout, char job, char compq, - char compz, lapack_int n, lapack_int ilo, - lapack_int ihi, double* h, lapack_int ldh, - double* t, lapack_int ldt, double* alphar, - double* alphai, double* beta, double* q, - lapack_int ldq, double* z, lapack_int ldz, - double* work, lapack_int lwork ); -lapack_int LAPACKE_chgeqz_work( int matrix_layout, char job, char compq, - char compz, lapack_int n, lapack_int ilo, - lapack_int ihi, lapack_complex_float* h, - lapack_int ldh, lapack_complex_float* t, - lapack_int ldt, lapack_complex_float* alpha, - lapack_complex_float* beta, - lapack_complex_float* q, lapack_int ldq, - lapack_complex_float* z, lapack_int ldz, - lapack_complex_float* work, lapack_int lwork, - float* rwork ); -lapack_int LAPACKE_zhgeqz_work( int matrix_layout, char job, char compq, - char compz, lapack_int n, lapack_int ilo, - lapack_int ihi, lapack_complex_double* h, - lapack_int ldh, lapack_complex_double* t, - lapack_int ldt, lapack_complex_double* alpha, - lapack_complex_double* beta, - lapack_complex_double* q, lapack_int ldq, - lapack_complex_double* z, lapack_int ldz, - lapack_complex_double* work, lapack_int lwork, - double* rwork ); - -lapack_int LAPACKE_chpcon_work( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float* ap, - const lapack_int* ipiv, float anorm, - float* rcond, lapack_complex_float* work ); -lapack_int LAPACKE_zhpcon_work( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double* ap, - const lapack_int* ipiv, double anorm, - double* rcond, lapack_complex_double* work ); - -lapack_int LAPACKE_chpev_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_complex_float* ap, float* w, - lapack_complex_float* z, lapack_int ldz, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_zhpev_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_complex_double* ap, - double* w, lapack_complex_double* z, - lapack_int ldz, lapack_complex_double* work, - double* rwork ); - -lapack_int LAPACKE_chpevd_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_complex_float* ap, - float* w, lapack_complex_float* z, - lapack_int ldz, lapack_complex_float* work, - lapack_int lwork, float* rwork, - lapack_int lrwork, lapack_int* iwork, - lapack_int liwork ); -lapack_int LAPACKE_zhpevd_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_complex_double* ap, - double* w, lapack_complex_double* z, - lapack_int ldz, lapack_complex_double* work, - lapack_int lwork, double* rwork, - lapack_int lrwork, lapack_int* iwork, - lapack_int liwork ); - -lapack_int LAPACKE_chpevx_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, - lapack_complex_float* ap, float vl, float vu, - lapack_int il, lapack_int iu, float abstol, - lapack_int* m, float* w, - lapack_complex_float* z, lapack_int ldz, - lapack_complex_float* work, float* rwork, - lapack_int* iwork, lapack_int* ifail ); -lapack_int LAPACKE_zhpevx_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, - lapack_complex_double* ap, double vl, double vu, - lapack_int il, lapack_int iu, double abstol, - lapack_int* m, double* w, - lapack_complex_double* z, lapack_int ldz, - lapack_complex_double* work, double* rwork, - lapack_int* iwork, lapack_int* ifail ); - -lapack_int LAPACKE_chpgst_work( int matrix_layout, lapack_int itype, char uplo, - lapack_int n, lapack_complex_float* ap, - const lapack_complex_float* bp ); -lapack_int LAPACKE_zhpgst_work( int matrix_layout, lapack_int itype, char uplo, - lapack_int n, lapack_complex_double* ap, - const lapack_complex_double* bp ); - -lapack_int LAPACKE_chpgv_work( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, - lapack_complex_float* ap, - lapack_complex_float* bp, float* w, - lapack_complex_float* z, lapack_int ldz, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_zhpgv_work( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, - lapack_complex_double* ap, - lapack_complex_double* bp, double* w, - lapack_complex_double* z, lapack_int ldz, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_chpgvd_work( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, - lapack_complex_float* ap, - lapack_complex_float* bp, float* w, - lapack_complex_float* z, lapack_int ldz, - lapack_complex_float* work, lapack_int lwork, - float* rwork, lapack_int lrwork, - lapack_int* iwork, lapack_int liwork ); -lapack_int LAPACKE_zhpgvd_work( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, - lapack_complex_double* ap, - lapack_complex_double* bp, double* w, - lapack_complex_double* z, lapack_int ldz, - lapack_complex_double* work, lapack_int lwork, - double* rwork, lapack_int lrwork, - lapack_int* iwork, lapack_int liwork ); - -lapack_int LAPACKE_chpgvx_work( int matrix_layout, lapack_int itype, char jobz, - char range, char uplo, lapack_int n, - lapack_complex_float* ap, - lapack_complex_float* bp, float vl, float vu, - lapack_int il, lapack_int iu, float abstol, - lapack_int* m, float* w, - lapack_complex_float* z, lapack_int ldz, - lapack_complex_float* work, float* rwork, - lapack_int* iwork, lapack_int* ifail ); -lapack_int LAPACKE_zhpgvx_work( int matrix_layout, lapack_int itype, char jobz, - char range, char uplo, lapack_int n, - lapack_complex_double* ap, - lapack_complex_double* bp, double vl, double vu, - lapack_int il, lapack_int iu, double abstol, - lapack_int* m, double* w, - lapack_complex_double* z, lapack_int ldz, - lapack_complex_double* work, double* rwork, - lapack_int* iwork, lapack_int* ifail ); - -lapack_int LAPACKE_chprfs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* ap, - const lapack_complex_float* afp, - const lapack_int* ipiv, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* ferr, float* berr, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_zhprfs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, - const lapack_complex_double* ap, - const lapack_complex_double* afp, - const lapack_int* ipiv, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* ferr, double* berr, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_chpsv_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* ap, - lapack_int* ipiv, lapack_complex_float* b, - lapack_int ldb ); -lapack_int LAPACKE_zhpsv_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* ap, - lapack_int* ipiv, lapack_complex_double* b, - lapack_int ldb ); - -lapack_int LAPACKE_chpsvx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, - const lapack_complex_float* ap, - lapack_complex_float* afp, lapack_int* ipiv, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* rcond, float* ferr, float* berr, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_zhpsvx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, - const lapack_complex_double* ap, - lapack_complex_double* afp, lapack_int* ipiv, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* ferr, double* berr, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_chptrd_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* ap, float* d, float* e, - lapack_complex_float* tau ); -lapack_int LAPACKE_zhptrd_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* ap, double* d, double* e, - lapack_complex_double* tau ); - -lapack_int LAPACKE_chptrf_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* ap, lapack_int* ipiv ); -lapack_int LAPACKE_zhptrf_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* ap, lapack_int* ipiv ); - -lapack_int LAPACKE_chptri_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* ap, - const lapack_int* ipiv, - lapack_complex_float* work ); -lapack_int LAPACKE_zhptri_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* ap, - const lapack_int* ipiv, - lapack_complex_double* work ); - -lapack_int LAPACKE_chptrs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* ap, - const lapack_int* ipiv, lapack_complex_float* b, - lapack_int ldb ); -lapack_int LAPACKE_zhptrs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, - const lapack_complex_double* ap, - const lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_shsein_work( int matrix_layout, char job, char eigsrc, - char initv, lapack_logical* select, - lapack_int n, const float* h, lapack_int ldh, - float* wr, const float* wi, float* vl, - lapack_int ldvl, float* vr, lapack_int ldvr, - lapack_int mm, lapack_int* m, float* work, - lapack_int* ifaill, lapack_int* ifailr ); -lapack_int LAPACKE_dhsein_work( int matrix_layout, char job, char eigsrc, - char initv, lapack_logical* select, - lapack_int n, const double* h, lapack_int ldh, - double* wr, const double* wi, double* vl, - lapack_int ldvl, double* vr, lapack_int ldvr, - lapack_int mm, lapack_int* m, double* work, - lapack_int* ifaill, lapack_int* ifailr ); -lapack_int LAPACKE_chsein_work( int matrix_layout, char job, char eigsrc, - char initv, const lapack_logical* select, - lapack_int n, const lapack_complex_float* h, - lapack_int ldh, lapack_complex_float* w, - lapack_complex_float* vl, lapack_int ldvl, - lapack_complex_float* vr, lapack_int ldvr, - lapack_int mm, lapack_int* m, - lapack_complex_float* work, float* rwork, - lapack_int* ifaill, lapack_int* ifailr ); -lapack_int LAPACKE_zhsein_work( int matrix_layout, char job, char eigsrc, - char initv, const lapack_logical* select, - lapack_int n, const lapack_complex_double* h, - lapack_int ldh, lapack_complex_double* w, - lapack_complex_double* vl, lapack_int ldvl, - lapack_complex_double* vr, lapack_int ldvr, - lapack_int mm, lapack_int* m, - lapack_complex_double* work, double* rwork, - lapack_int* ifaill, lapack_int* ifailr ); - -lapack_int LAPACKE_shseqr_work( int matrix_layout, char job, char compz, - lapack_int n, lapack_int ilo, lapack_int ihi, - float* h, lapack_int ldh, float* wr, float* wi, - float* z, lapack_int ldz, float* work, - lapack_int lwork ); -lapack_int LAPACKE_dhseqr_work( int matrix_layout, char job, char compz, - lapack_int n, lapack_int ilo, lapack_int ihi, - double* h, lapack_int ldh, double* wr, - double* wi, double* z, lapack_int ldz, - double* work, lapack_int lwork ); -lapack_int LAPACKE_chseqr_work( int matrix_layout, char job, char compz, - lapack_int n, lapack_int ilo, lapack_int ihi, - lapack_complex_float* h, lapack_int ldh, - lapack_complex_float* w, - lapack_complex_float* z, lapack_int ldz, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zhseqr_work( int matrix_layout, char job, char compz, - lapack_int n, lapack_int ilo, lapack_int ihi, - lapack_complex_double* h, lapack_int ldh, - lapack_complex_double* w, - lapack_complex_double* z, lapack_int ldz, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_clacgv_work( lapack_int n, lapack_complex_float* x, - lapack_int incx ); -lapack_int LAPACKE_zlacgv_work( lapack_int n, lapack_complex_double* x, - lapack_int incx ); - -lapack_int LAPACKE_slacn2_work( lapack_int n, float* v, float* x, - lapack_int* isgn, float* est, lapack_int* kase, - lapack_int* isave ); -lapack_int LAPACKE_dlacn2_work( lapack_int n, double* v, double* x, - lapack_int* isgn, double* est, lapack_int* kase, - lapack_int* isave ); -lapack_int LAPACKE_clacn2_work( lapack_int n, lapack_complex_float* v, - lapack_complex_float* x, - float* est, lapack_int* kase, - lapack_int* isave ); -lapack_int LAPACKE_zlacn2_work( lapack_int n, lapack_complex_double* v, - lapack_complex_double* x, - double* est, lapack_int* kase, - lapack_int* isave ); - -lapack_int LAPACKE_slacpy_work( int matrix_layout, char uplo, lapack_int m, - lapack_int n, const float* a, lapack_int lda, - float* b, lapack_int ldb ); -lapack_int LAPACKE_dlacpy_work( int matrix_layout, char uplo, lapack_int m, - lapack_int n, const double* a, lapack_int lda, - double* b, lapack_int ldb ); -lapack_int LAPACKE_clacpy_work( int matrix_layout, char uplo, lapack_int m, - lapack_int n, const lapack_complex_float* a, - lapack_int lda, lapack_complex_float* b, - lapack_int ldb ); -lapack_int LAPACKE_zlacpy_work( int matrix_layout, char uplo, lapack_int m, - lapack_int n, const lapack_complex_double* a, - lapack_int lda, lapack_complex_double* b, - lapack_int ldb ); - -lapack_int LAPACKE_clacp2_work( int matrix_layout, char uplo, lapack_int m, - lapack_int n, const float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zlacp2_work( int matrix_layout, char uplo, lapack_int m, - lapack_int n, const double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_zlag2c_work( int matrix_layout, lapack_int m, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - lapack_complex_float* sa, lapack_int ldsa ); - -lapack_int LAPACKE_slag2d_work( int matrix_layout, lapack_int m, lapack_int n, - const float* sa, lapack_int ldsa, double* a, - lapack_int lda ); - -lapack_int LAPACKE_dlag2s_work( int matrix_layout, lapack_int m, lapack_int n, - const double* a, lapack_int lda, float* sa, - lapack_int ldsa ); - -lapack_int LAPACKE_clag2z_work( int matrix_layout, lapack_int m, lapack_int n, - const lapack_complex_float* sa, lapack_int ldsa, - lapack_complex_double* a, lapack_int lda ); - -lapack_int LAPACKE_slagge_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, const float* d, - float* a, lapack_int lda, lapack_int* iseed, - float* work ); -lapack_int LAPACKE_dlagge_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, const double* d, - double* a, lapack_int lda, lapack_int* iseed, - double* work ); -lapack_int LAPACKE_clagge_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, const float* d, - lapack_complex_float* a, lapack_int lda, - lapack_int* iseed, lapack_complex_float* work ); -lapack_int LAPACKE_zlagge_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, const double* d, - lapack_complex_double* a, lapack_int lda, - lapack_int* iseed, - lapack_complex_double* work ); - -lapack_int LAPACKE_claghe_work( int matrix_layout, lapack_int n, lapack_int k, - const float* d, lapack_complex_float* a, - lapack_int lda, lapack_int* iseed, - lapack_complex_float* work ); -lapack_int LAPACKE_zlaghe_work( int matrix_layout, lapack_int n, lapack_int k, - const double* d, lapack_complex_double* a, - lapack_int lda, lapack_int* iseed, - lapack_complex_double* work ); - -lapack_int LAPACKE_slagsy_work( int matrix_layout, lapack_int n, lapack_int k, - const float* d, float* a, lapack_int lda, - lapack_int* iseed, float* work ); -lapack_int LAPACKE_dlagsy_work( int matrix_layout, lapack_int n, lapack_int k, - const double* d, double* a, lapack_int lda, - lapack_int* iseed, double* work ); -lapack_int LAPACKE_clagsy_work( int matrix_layout, lapack_int n, lapack_int k, - const float* d, lapack_complex_float* a, - lapack_int lda, lapack_int* iseed, - lapack_complex_float* work ); -lapack_int LAPACKE_zlagsy_work( int matrix_layout, lapack_int n, lapack_int k, - const double* d, lapack_complex_double* a, - lapack_int lda, lapack_int* iseed, - lapack_complex_double* work ); - -lapack_int LAPACKE_slapmr_work( int matrix_layout, lapack_logical forwrd, - lapack_int m, lapack_int n, float* x, - lapack_int ldx, lapack_int* k ); -lapack_int LAPACKE_dlapmr_work( int matrix_layout, lapack_logical forwrd, - lapack_int m, lapack_int n, double* x, - lapack_int ldx, lapack_int* k ); -lapack_int LAPACKE_clapmr_work( int matrix_layout, lapack_logical forwrd, - lapack_int m, lapack_int n, - lapack_complex_float* x, lapack_int ldx, - lapack_int* k ); -lapack_int LAPACKE_zlapmr_work( int matrix_layout, lapack_logical forwrd, - lapack_int m, lapack_int n, - lapack_complex_double* x, lapack_int ldx, - lapack_int* k ); - -lapack_int LAPACKE_slapmt_work( int matrix_layout, lapack_logical forwrd, - lapack_int m, lapack_int n, float* x, - lapack_int ldx, lapack_int* k ); -lapack_int LAPACKE_dlapmt_work( int matrix_layout, lapack_logical forwrd, - lapack_int m, lapack_int n, double* x, - lapack_int ldx, lapack_int* k ); -lapack_int LAPACKE_clapmt_work( int matrix_layout, lapack_logical forwrd, - lapack_int m, lapack_int n, - lapack_complex_float* x, lapack_int ldx, - lapack_int* k ); -lapack_int LAPACKE_zlapmt_work( int matrix_layout, lapack_logical forwrd, - lapack_int m, lapack_int n, - lapack_complex_double* x, lapack_int ldx, - lapack_int* k ); - -lapack_int LAPACKE_slartgp_work( float f, float g, float* cs, float* sn, - float* r ); -lapack_int LAPACKE_dlartgp_work( double f, double g, double* cs, double* sn, - double* r ); - -lapack_int LAPACKE_slartgs_work( float x, float y, float sigma, float* cs, - float* sn ); -lapack_int LAPACKE_dlartgs_work( double x, double y, double sigma, double* cs, - double* sn ); - -float LAPACKE_slapy2_work( float x, float y ); -double LAPACKE_dlapy2_work( double x, double y ); - -float LAPACKE_slapy3_work( float x, float y, float z ); -double LAPACKE_dlapy3_work( double x, double y, double z ); - -float LAPACKE_slamch_work( char cmach ); -double LAPACKE_dlamch_work( char cmach ); - -float LAPACKE_slange_work( int matrix_layout, char norm, lapack_int m, - lapack_int n, const float* a, lapack_int lda, - float* work ); -double LAPACKE_dlange_work( int matrix_layout, char norm, lapack_int m, - lapack_int n, const double* a, lapack_int lda, - double* work ); -float LAPACKE_clange_work( int matrix_layout, char norm, lapack_int m, - lapack_int n, const lapack_complex_float* a, - lapack_int lda, float* work ); -double LAPACKE_zlange_work( int matrix_layout, char norm, lapack_int m, - lapack_int n, const lapack_complex_double* a, - lapack_int lda, double* work ); - -float LAPACKE_clanhe_work( int matrix_layout, char norm, char uplo, - lapack_int n, const lapack_complex_float* a, - lapack_int lda, float* work ); -double LAPACKE_zlanhe_work( int matrix_layout, char norm, char uplo, - lapack_int n, const lapack_complex_double* a, - lapack_int lda, double* work ); - -lapack_int LAPACKE_clacrm_work( int matrix_layout, lapack_int m, lapack_int n, - const lapack_complex_float* a, - lapack_int lda, const float* b, - lapack_int ldb, lapack_complex_float* c, - lapack_int ldc, float* work ); -lapack_int LAPACKE_zlacrm_work( int matrix_layout, lapack_int m, lapack_int n, - const lapack_complex_double* a, - lapack_int lda, const double* b, - lapack_int ldb, lapack_complex_double* c, - lapack_int ldc, double* work ); - -lapack_int LAPACKE_clarcm_work( int matrix_layout, lapack_int m, lapack_int n, - const float* a, lapack_int lda, - const lapack_complex_float* b, - lapack_int ldb, lapack_complex_float* c, - lapack_int ldc, float* work ); -lapack_int LAPACKE_zlarcm_work( int matrix_layout, lapack_int m, lapack_int n, - const double* a, lapack_int lda, - const lapack_complex_double* b, - lapack_int ldb, lapack_complex_double* c, - lapack_int ldc, double* work ); - -float LAPACKE_slansy_work( int matrix_layout, char norm, char uplo, - lapack_int n, const float* a, lapack_int lda, - float* work ); -double LAPACKE_dlansy_work( int matrix_layout, char norm, char uplo, - lapack_int n, const double* a, lapack_int lda, - double* work ); -float LAPACKE_clansy_work( int matrix_layout, char norm, char uplo, - lapack_int n, const lapack_complex_float* a, - lapack_int lda, float* work ); -double LAPACKE_zlansy_work( int matrix_layout, char norm, char uplo, - lapack_int n, const lapack_complex_double* a, - lapack_int lda, double* work ); - -float LAPACKE_slantr_work( int matrix_layout, char norm, char uplo, - char diag, lapack_int m, lapack_int n, const float* a, - lapack_int lda, float* work ); -double LAPACKE_dlantr_work( int matrix_layout, char norm, char uplo, - char diag, lapack_int m, lapack_int n, - const double* a, lapack_int lda, double* work ); -float LAPACKE_clantr_work( int matrix_layout, char norm, char uplo, - char diag, lapack_int m, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - float* work ); -double LAPACKE_zlantr_work( int matrix_layout, char norm, char uplo, - char diag, lapack_int m, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - double* work ); - -lapack_int LAPACKE_slarfb_work( int matrix_layout, char side, char trans, - char direct, char storev, lapack_int m, - lapack_int n, lapack_int k, const float* v, - lapack_int ldv, const float* t, lapack_int ldt, - float* c, lapack_int ldc, float* work, - lapack_int ldwork ); -lapack_int LAPACKE_dlarfb_work( int matrix_layout, char side, char trans, - char direct, char storev, lapack_int m, - lapack_int n, lapack_int k, const double* v, - lapack_int ldv, const double* t, lapack_int ldt, - double* c, lapack_int ldc, double* work, - lapack_int ldwork ); -lapack_int LAPACKE_clarfb_work( int matrix_layout, char side, char trans, - char direct, char storev, lapack_int m, - lapack_int n, lapack_int k, - const lapack_complex_float* v, lapack_int ldv, - const lapack_complex_float* t, lapack_int ldt, - lapack_complex_float* c, lapack_int ldc, - lapack_complex_float* work, lapack_int ldwork ); -lapack_int LAPACKE_zlarfb_work( int matrix_layout, char side, char trans, - char direct, char storev, lapack_int m, - lapack_int n, lapack_int k, - const lapack_complex_double* v, lapack_int ldv, - const lapack_complex_double* t, lapack_int ldt, - lapack_complex_double* c, lapack_int ldc, - lapack_complex_double* work, - lapack_int ldwork ); - -lapack_int LAPACKE_slarfg_work( lapack_int n, float* alpha, float* x, - lapack_int incx, float* tau ); -lapack_int LAPACKE_dlarfg_work( lapack_int n, double* alpha, double* x, - lapack_int incx, double* tau ); -lapack_int LAPACKE_clarfg_work( lapack_int n, lapack_complex_float* alpha, - lapack_complex_float* x, lapack_int incx, - lapack_complex_float* tau ); -lapack_int LAPACKE_zlarfg_work( lapack_int n, lapack_complex_double* alpha, - lapack_complex_double* x, lapack_int incx, - lapack_complex_double* tau ); - -lapack_int LAPACKE_slarft_work( int matrix_layout, char direct, char storev, - lapack_int n, lapack_int k, const float* v, - lapack_int ldv, const float* tau, float* t, - lapack_int ldt ); -lapack_int LAPACKE_dlarft_work( int matrix_layout, char direct, char storev, - lapack_int n, lapack_int k, const double* v, - lapack_int ldv, const double* tau, double* t, - lapack_int ldt ); -lapack_int LAPACKE_clarft_work( int matrix_layout, char direct, char storev, - lapack_int n, lapack_int k, - const lapack_complex_float* v, lapack_int ldv, - const lapack_complex_float* tau, - lapack_complex_float* t, lapack_int ldt ); -lapack_int LAPACKE_zlarft_work( int matrix_layout, char direct, char storev, - lapack_int n, lapack_int k, - const lapack_complex_double* v, lapack_int ldv, - const lapack_complex_double* tau, - lapack_complex_double* t, lapack_int ldt ); - -lapack_int LAPACKE_slarfx_work( int matrix_layout, char side, lapack_int m, - lapack_int n, const float* v, float tau, - float* c, lapack_int ldc, float* work ); -lapack_int LAPACKE_dlarfx_work( int matrix_layout, char side, lapack_int m, - lapack_int n, const double* v, double tau, - double* c, lapack_int ldc, double* work ); -lapack_int LAPACKE_clarfx_work( int matrix_layout, char side, lapack_int m, - lapack_int n, const lapack_complex_float* v, - lapack_complex_float tau, - lapack_complex_float* c, lapack_int ldc, - lapack_complex_float* work ); -lapack_int LAPACKE_zlarfx_work( int matrix_layout, char side, lapack_int m, - lapack_int n, const lapack_complex_double* v, - lapack_complex_double tau, - lapack_complex_double* c, lapack_int ldc, - lapack_complex_double* work ); - -lapack_int LAPACKE_slarnv_work( lapack_int idist, lapack_int* iseed, - lapack_int n, float* x ); -lapack_int LAPACKE_dlarnv_work( lapack_int idist, lapack_int* iseed, - lapack_int n, double* x ); -lapack_int LAPACKE_clarnv_work( lapack_int idist, lapack_int* iseed, - lapack_int n, lapack_complex_float* x ); -lapack_int LAPACKE_zlarnv_work( lapack_int idist, lapack_int* iseed, - lapack_int n, lapack_complex_double* x ); - - -lapack_int LAPACKE_slascl_work( int matrix_layout, char type, lapack_int kl, - lapack_int ku, float cfrom, float cto, - lapack_int m, lapack_int n, float* a, - lapack_int lda ); -lapack_int LAPACKE_dlascl_work( int matrix_layout, char type, lapack_int kl, - lapack_int ku, double cfrom, double cto, - lapack_int m, lapack_int n, double* a, - lapack_int lda ); -lapack_int LAPACKE_clascl_work( int matrix_layout, char type, lapack_int kl, - lapack_int ku, float cfrom, float cto, - lapack_int m, lapack_int n, lapack_complex_float* a, - lapack_int lda ); -lapack_int LAPACKE_zlascl_work( int matrix_layout, char type, lapack_int kl, - lapack_int ku, double cfrom, double cto, - lapack_int m, lapack_int n, lapack_complex_double* a, - lapack_int lda ); - -lapack_int LAPACKE_slaset_work( int matrix_layout, char uplo, lapack_int m, - lapack_int n, float alpha, float beta, float* a, - lapack_int lda ); -lapack_int LAPACKE_dlaset_work( int matrix_layout, char uplo, lapack_int m, - lapack_int n, double alpha, double beta, - double* a, lapack_int lda ); -lapack_int LAPACKE_claset_work( int matrix_layout, char uplo, lapack_int m, - lapack_int n, lapack_complex_float alpha, - lapack_complex_float beta, - lapack_complex_float* a, lapack_int lda ); -lapack_int LAPACKE_zlaset_work( int matrix_layout, char uplo, lapack_int m, - lapack_int n, lapack_complex_double alpha, - lapack_complex_double beta, - lapack_complex_double* a, lapack_int lda ); - -lapack_int LAPACKE_slasrt_work( char id, lapack_int n, float* d ); -lapack_int LAPACKE_dlasrt_work( char id, lapack_int n, double* d ); - -lapack_int LAPACKE_slassq_work( lapack_int n, float* x, lapack_int incx, float* scale, float* sumsq ); -lapack_int LAPACKE_dlassq_work( lapack_int n, double* x, lapack_int incx, double* scale, double* sumsq ); -lapack_int LAPACKE_classq_work( lapack_int n, lapack_complex_float* x, lapack_int incx, float* scale, float* sumsq ); -lapack_int LAPACKE_zlassq_work( lapack_int n, lapack_complex_double* x, lapack_int incx, double* scale, double* sumsq ); - -lapack_int LAPACKE_slaswp_work( int matrix_layout, lapack_int n, float* a, - lapack_int lda, lapack_int k1, lapack_int k2, - const lapack_int* ipiv, lapack_int incx ); -lapack_int LAPACKE_dlaswp_work( int matrix_layout, lapack_int n, double* a, - lapack_int lda, lapack_int k1, lapack_int k2, - const lapack_int* ipiv, lapack_int incx ); -lapack_int LAPACKE_claswp_work( int matrix_layout, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int k1, lapack_int k2, - const lapack_int* ipiv, lapack_int incx ); -lapack_int LAPACKE_zlaswp_work( int matrix_layout, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int k1, lapack_int k2, - const lapack_int* ipiv, lapack_int incx ); - -lapack_int LAPACKE_slatms_work( int matrix_layout, lapack_int m, lapack_int n, - char dist, lapack_int* iseed, char sym, - float* d, lapack_int mode, float cond, - float dmax, lapack_int kl, lapack_int ku, - char pack, float* a, lapack_int lda, - float* work ); -lapack_int LAPACKE_dlatms_work( int matrix_layout, lapack_int m, lapack_int n, - char dist, lapack_int* iseed, char sym, - double* d, lapack_int mode, double cond, - double dmax, lapack_int kl, lapack_int ku, - char pack, double* a, lapack_int lda, - double* work ); -lapack_int LAPACKE_clatms_work( int matrix_layout, lapack_int m, lapack_int n, - char dist, lapack_int* iseed, char sym, - float* d, lapack_int mode, float cond, - float dmax, lapack_int kl, lapack_int ku, - char pack, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* work ); -lapack_int LAPACKE_zlatms_work( int matrix_layout, lapack_int m, lapack_int n, - char dist, lapack_int* iseed, char sym, - double* d, lapack_int mode, double cond, - double dmax, lapack_int kl, lapack_int ku, - char pack, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* work ); - -lapack_int LAPACKE_slauum_work( int matrix_layout, char uplo, lapack_int n, - float* a, lapack_int lda ); -lapack_int LAPACKE_dlauum_work( int matrix_layout, char uplo, lapack_int n, - double* a, lapack_int lda ); -lapack_int LAPACKE_clauum_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda ); -lapack_int LAPACKE_zlauum_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda ); - -lapack_int LAPACKE_sopgtr_work( int matrix_layout, char uplo, lapack_int n, - const float* ap, const float* tau, float* q, - lapack_int ldq, float* work ); -lapack_int LAPACKE_dopgtr_work( int matrix_layout, char uplo, lapack_int n, - const double* ap, const double* tau, double* q, - lapack_int ldq, double* work ); - -lapack_int LAPACKE_sopmtr_work( int matrix_layout, char side, char uplo, - char trans, lapack_int m, lapack_int n, - const float* ap, const float* tau, float* c, - lapack_int ldc, float* work ); -lapack_int LAPACKE_dopmtr_work( int matrix_layout, char side, char uplo, - char trans, lapack_int m, lapack_int n, - const double* ap, const double* tau, double* c, - lapack_int ldc, double* work ); - -lapack_int LAPACKE_sorgbr_work( int matrix_layout, char vect, lapack_int m, - lapack_int n, lapack_int k, float* a, - lapack_int lda, const float* tau, float* work, - lapack_int lwork ); -lapack_int LAPACKE_dorgbr_work( int matrix_layout, char vect, lapack_int m, - lapack_int n, lapack_int k, double* a, - lapack_int lda, const double* tau, double* work, - lapack_int lwork ); - -lapack_int LAPACKE_sorghr_work( int matrix_layout, lapack_int n, lapack_int ilo, - lapack_int ihi, float* a, lapack_int lda, - const float* tau, float* work, - lapack_int lwork ); -lapack_int LAPACKE_dorghr_work( int matrix_layout, lapack_int n, lapack_int ilo, - lapack_int ihi, double* a, lapack_int lda, - const double* tau, double* work, - lapack_int lwork ); - -lapack_int LAPACKE_sorglq_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, float* a, lapack_int lda, - const float* tau, float* work, - lapack_int lwork ); -lapack_int LAPACKE_dorglq_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, double* a, lapack_int lda, - const double* tau, double* work, - lapack_int lwork ); - -lapack_int LAPACKE_sorgql_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, float* a, lapack_int lda, - const float* tau, float* work, - lapack_int lwork ); -lapack_int LAPACKE_dorgql_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, double* a, lapack_int lda, - const double* tau, double* work, - lapack_int lwork ); - -lapack_int LAPACKE_sorgqr_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, float* a, lapack_int lda, - const float* tau, float* work, - lapack_int lwork ); -lapack_int LAPACKE_dorgqr_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, double* a, lapack_int lda, - const double* tau, double* work, - lapack_int lwork ); - -lapack_int LAPACKE_sorgrq_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, float* a, lapack_int lda, - const float* tau, float* work, - lapack_int lwork ); -lapack_int LAPACKE_dorgrq_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, double* a, lapack_int lda, - const double* tau, double* work, - lapack_int lwork ); - -lapack_int LAPACKE_sorgtr_work( int matrix_layout, char uplo, lapack_int n, - float* a, lapack_int lda, const float* tau, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dorgtr_work( int matrix_layout, char uplo, lapack_int n, - double* a, lapack_int lda, const double* tau, - double* work, lapack_int lwork ); - -lapack_int LAPACKE_sormbr_work( int matrix_layout, char vect, char side, - char trans, lapack_int m, lapack_int n, - lapack_int k, const float* a, lapack_int lda, - const float* tau, float* c, lapack_int ldc, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dormbr_work( int matrix_layout, char vect, char side, - char trans, lapack_int m, lapack_int n, - lapack_int k, const double* a, lapack_int lda, - const double* tau, double* c, lapack_int ldc, - double* work, lapack_int lwork ); - -lapack_int LAPACKE_sormhr_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int ilo, - lapack_int ihi, const float* a, lapack_int lda, - const float* tau, float* c, lapack_int ldc, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dormhr_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int ilo, - lapack_int ihi, const double* a, lapack_int lda, - const double* tau, double* c, lapack_int ldc, - double* work, lapack_int lwork ); - -lapack_int LAPACKE_sormlq_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const float* a, lapack_int lda, - const float* tau, float* c, lapack_int ldc, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dormlq_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const double* a, lapack_int lda, - const double* tau, double* c, lapack_int ldc, - double* work, lapack_int lwork ); - -lapack_int LAPACKE_sormql_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const float* a, lapack_int lda, - const float* tau, float* c, lapack_int ldc, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dormql_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const double* a, lapack_int lda, - const double* tau, double* c, lapack_int ldc, - double* work, lapack_int lwork ); - -lapack_int LAPACKE_sormqr_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const float* a, lapack_int lda, - const float* tau, float* c, lapack_int ldc, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dormqr_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const double* a, lapack_int lda, - const double* tau, double* c, lapack_int ldc, - double* work, lapack_int lwork ); - -lapack_int LAPACKE_sormrq_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const float* a, lapack_int lda, - const float* tau, float* c, lapack_int ldc, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dormrq_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const double* a, lapack_int lda, - const double* tau, double* c, lapack_int ldc, - double* work, lapack_int lwork ); - -lapack_int LAPACKE_sormrz_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - lapack_int l, const float* a, lapack_int lda, - const float* tau, float* c, lapack_int ldc, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dormrz_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - lapack_int l, const double* a, lapack_int lda, - const double* tau, double* c, lapack_int ldc, - double* work, lapack_int lwork ); - -lapack_int LAPACKE_sormtr_work( int matrix_layout, char side, char uplo, - char trans, lapack_int m, lapack_int n, - const float* a, lapack_int lda, - const float* tau, float* c, lapack_int ldc, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dormtr_work( int matrix_layout, char side, char uplo, - char trans, lapack_int m, lapack_int n, - const double* a, lapack_int lda, - const double* tau, double* c, lapack_int ldc, - double* work, lapack_int lwork ); - -lapack_int LAPACKE_spbcon_work( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, const float* ab, lapack_int ldab, - float anorm, float* rcond, float* work, - lapack_int* iwork ); -lapack_int LAPACKE_dpbcon_work( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, const double* ab, - lapack_int ldab, double anorm, double* rcond, - double* work, lapack_int* iwork ); -lapack_int LAPACKE_cpbcon_work( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, const lapack_complex_float* ab, - lapack_int ldab, float anorm, float* rcond, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_zpbcon_work( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, const lapack_complex_double* ab, - lapack_int ldab, double anorm, double* rcond, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_spbequ_work( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, const float* ab, lapack_int ldab, - float* s, float* scond, float* amax ); -lapack_int LAPACKE_dpbequ_work( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, const double* ab, - lapack_int ldab, double* s, double* scond, - double* amax ); -lapack_int LAPACKE_cpbequ_work( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, const lapack_complex_float* ab, - lapack_int ldab, float* s, float* scond, - float* amax ); -lapack_int LAPACKE_zpbequ_work( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, const lapack_complex_double* ab, - lapack_int ldab, double* s, double* scond, - double* amax ); - -lapack_int LAPACKE_spbrfs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, lapack_int nrhs, const float* ab, - lapack_int ldab, const float* afb, - lapack_int ldafb, const float* b, - lapack_int ldb, float* x, lapack_int ldx, - float* ferr, float* berr, float* work, - lapack_int* iwork ); -lapack_int LAPACKE_dpbrfs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, lapack_int nrhs, - const double* ab, lapack_int ldab, - const double* afb, lapack_int ldafb, - const double* b, lapack_int ldb, double* x, - lapack_int ldx, double* ferr, double* berr, - double* work, lapack_int* iwork ); -lapack_int LAPACKE_cpbrfs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, lapack_int nrhs, - const lapack_complex_float* ab, lapack_int ldab, - const lapack_complex_float* afb, - lapack_int ldafb, const lapack_complex_float* b, - lapack_int ldb, lapack_complex_float* x, - lapack_int ldx, float* ferr, float* berr, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_zpbrfs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, lapack_int nrhs, - const lapack_complex_double* ab, - lapack_int ldab, - const lapack_complex_double* afb, - lapack_int ldafb, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* ferr, double* berr, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_spbstf_work( int matrix_layout, char uplo, lapack_int n, - lapack_int kb, float* bb, lapack_int ldbb ); -lapack_int LAPACKE_dpbstf_work( int matrix_layout, char uplo, lapack_int n, - lapack_int kb, double* bb, lapack_int ldbb ); -lapack_int LAPACKE_cpbstf_work( int matrix_layout, char uplo, lapack_int n, - lapack_int kb, lapack_complex_float* bb, - lapack_int ldbb ); -lapack_int LAPACKE_zpbstf_work( int matrix_layout, char uplo, lapack_int n, - lapack_int kb, lapack_complex_double* bb, - lapack_int ldbb ); - -lapack_int LAPACKE_spbsv_work( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, lapack_int nrhs, float* ab, - lapack_int ldab, float* b, lapack_int ldb ); -lapack_int LAPACKE_dpbsv_work( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, lapack_int nrhs, double* ab, - lapack_int ldab, double* b, lapack_int ldb ); -lapack_int LAPACKE_cpbsv_work( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, lapack_int nrhs, - lapack_complex_float* ab, lapack_int ldab, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zpbsv_work( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, lapack_int nrhs, - lapack_complex_double* ab, lapack_int ldab, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_spbsvx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int kd, lapack_int nrhs, - float* ab, lapack_int ldab, float* afb, - lapack_int ldafb, char* equed, float* s, - float* b, lapack_int ldb, float* x, - lapack_int ldx, float* rcond, float* ferr, - float* berr, float* work, lapack_int* iwork ); -lapack_int LAPACKE_dpbsvx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int kd, lapack_int nrhs, - double* ab, lapack_int ldab, double* afb, - lapack_int ldafb, char* equed, double* s, - double* b, lapack_int ldb, double* x, - lapack_int ldx, double* rcond, double* ferr, - double* berr, double* work, lapack_int* iwork ); -lapack_int LAPACKE_cpbsvx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int kd, lapack_int nrhs, - lapack_complex_float* ab, lapack_int ldab, - lapack_complex_float* afb, lapack_int ldafb, - char* equed, float* s, lapack_complex_float* b, - lapack_int ldb, lapack_complex_float* x, - lapack_int ldx, float* rcond, float* ferr, - float* berr, lapack_complex_float* work, - float* rwork ); -lapack_int LAPACKE_zpbsvx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int kd, lapack_int nrhs, - lapack_complex_double* ab, lapack_int ldab, - lapack_complex_double* afb, lapack_int ldafb, - char* equed, double* s, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* ferr, double* berr, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_spbtrf_work( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, float* ab, lapack_int ldab ); -lapack_int LAPACKE_dpbtrf_work( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, double* ab, lapack_int ldab ); -lapack_int LAPACKE_cpbtrf_work( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, lapack_complex_float* ab, - lapack_int ldab ); -lapack_int LAPACKE_zpbtrf_work( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, lapack_complex_double* ab, - lapack_int ldab ); - -lapack_int LAPACKE_spbtrs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, lapack_int nrhs, const float* ab, - lapack_int ldab, float* b, lapack_int ldb ); -lapack_int LAPACKE_dpbtrs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, lapack_int nrhs, - const double* ab, lapack_int ldab, double* b, - lapack_int ldb ); -lapack_int LAPACKE_cpbtrs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, lapack_int nrhs, - const lapack_complex_float* ab, lapack_int ldab, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zpbtrs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, lapack_int nrhs, - const lapack_complex_double* ab, - lapack_int ldab, lapack_complex_double* b, - lapack_int ldb ); - -lapack_int LAPACKE_spftrf_work( int matrix_layout, char transr, char uplo, - lapack_int n, float* a ); -lapack_int LAPACKE_dpftrf_work( int matrix_layout, char transr, char uplo, - lapack_int n, double* a ); -lapack_int LAPACKE_cpftrf_work( int matrix_layout, char transr, char uplo, - lapack_int n, lapack_complex_float* a ); -lapack_int LAPACKE_zpftrf_work( int matrix_layout, char transr, char uplo, - lapack_int n, lapack_complex_double* a ); - -lapack_int LAPACKE_spftri_work( int matrix_layout, char transr, char uplo, - lapack_int n, float* a ); -lapack_int LAPACKE_dpftri_work( int matrix_layout, char transr, char uplo, - lapack_int n, double* a ); -lapack_int LAPACKE_cpftri_work( int matrix_layout, char transr, char uplo, - lapack_int n, lapack_complex_float* a ); -lapack_int LAPACKE_zpftri_work( int matrix_layout, char transr, char uplo, - lapack_int n, lapack_complex_double* a ); - -lapack_int LAPACKE_spftrs_work( int matrix_layout, char transr, char uplo, - lapack_int n, lapack_int nrhs, const float* a, - float* b, lapack_int ldb ); -lapack_int LAPACKE_dpftrs_work( int matrix_layout, char transr, char uplo, - lapack_int n, lapack_int nrhs, const double* a, - double* b, lapack_int ldb ); -lapack_int LAPACKE_cpftrs_work( int matrix_layout, char transr, char uplo, - lapack_int n, lapack_int nrhs, - const lapack_complex_float* a, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zpftrs_work( int matrix_layout, char transr, char uplo, - lapack_int n, lapack_int nrhs, - const lapack_complex_double* a, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_spocon_work( int matrix_layout, char uplo, lapack_int n, - const float* a, lapack_int lda, float anorm, - float* rcond, float* work, lapack_int* iwork ); -lapack_int LAPACKE_dpocon_work( int matrix_layout, char uplo, lapack_int n, - const double* a, lapack_int lda, double anorm, - double* rcond, double* work, - lapack_int* iwork ); -lapack_int LAPACKE_cpocon_work( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - float anorm, float* rcond, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_zpocon_work( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - double anorm, double* rcond, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_spoequ_work( int matrix_layout, lapack_int n, const float* a, - lapack_int lda, float* s, float* scond, - float* amax ); -lapack_int LAPACKE_dpoequ_work( int matrix_layout, lapack_int n, const double* a, - lapack_int lda, double* s, double* scond, - double* amax ); -lapack_int LAPACKE_cpoequ_work( int matrix_layout, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - float* s, float* scond, float* amax ); -lapack_int LAPACKE_zpoequ_work( int matrix_layout, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - double* s, double* scond, double* amax ); - -lapack_int LAPACKE_spoequb_work( int matrix_layout, lapack_int n, const float* a, - lapack_int lda, float* s, float* scond, - float* amax ); -lapack_int LAPACKE_dpoequb_work( int matrix_layout, lapack_int n, - const double* a, lapack_int lda, double* s, - double* scond, double* amax ); -lapack_int LAPACKE_cpoequb_work( int matrix_layout, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - float* s, float* scond, float* amax ); -lapack_int LAPACKE_zpoequb_work( int matrix_layout, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - double* s, double* scond, double* amax ); - -lapack_int LAPACKE_sporfs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const float* a, lapack_int lda, - const float* af, lapack_int ldaf, - const float* b, lapack_int ldb, float* x, - lapack_int ldx, float* ferr, float* berr, - float* work, lapack_int* iwork ); -lapack_int LAPACKE_dporfs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const double* a, - lapack_int lda, const double* af, - lapack_int ldaf, const double* b, - lapack_int ldb, double* x, lapack_int ldx, - double* ferr, double* berr, double* work, - lapack_int* iwork ); -lapack_int LAPACKE_cporfs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* af, - lapack_int ldaf, const lapack_complex_float* b, - lapack_int ldb, lapack_complex_float* x, - lapack_int ldx, float* ferr, float* berr, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_zporfs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_complex_double* af, - lapack_int ldaf, const lapack_complex_double* b, - lapack_int ldb, lapack_complex_double* x, - lapack_int ldx, double* ferr, double* berr, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_sporfsx_work( int matrix_layout, char uplo, char equed, - lapack_int n, lapack_int nrhs, const float* a, - lapack_int lda, const float* af, - lapack_int ldaf, const float* s, - const float* b, lapack_int ldb, float* x, - lapack_int ldx, float* rcond, float* berr, - lapack_int n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int nparams, - float* params, float* work, - lapack_int* iwork ); -lapack_int LAPACKE_dporfsx_work( int matrix_layout, char uplo, char equed, - lapack_int n, lapack_int nrhs, const double* a, - lapack_int lda, const double* af, - lapack_int ldaf, const double* s, - const double* b, lapack_int ldb, double* x, - lapack_int ldx, double* rcond, double* berr, - lapack_int n_err_bnds, double* err_bnds_norm, - double* err_bnds_comp, lapack_int nparams, - double* params, double* work, - lapack_int* iwork ); -lapack_int LAPACKE_cporfsx_work( int matrix_layout, char uplo, char equed, - lapack_int n, lapack_int nrhs, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* af, - lapack_int ldaf, const float* s, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* rcond, float* berr, - lapack_int n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int nparams, - float* params, lapack_complex_float* work, - float* rwork ); -lapack_int LAPACKE_zporfsx_work( int matrix_layout, char uplo, char equed, - lapack_int n, lapack_int nrhs, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* af, - lapack_int ldaf, const double* s, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* berr, - lapack_int n_err_bnds, double* err_bnds_norm, - double* err_bnds_comp, lapack_int nparams, - double* params, lapack_complex_double* work, - double* rwork ); - -lapack_int LAPACKE_sposv_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, float* a, lapack_int lda, - float* b, lapack_int ldb ); -lapack_int LAPACKE_dposv_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, double* a, lapack_int lda, - double* b, lapack_int ldb ); -lapack_int LAPACKE_cposv_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* b, - lapack_int ldb ); -lapack_int LAPACKE_zposv_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* b, - lapack_int ldb ); -lapack_int LAPACKE_dsposv_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, double* a, lapack_int lda, - double* b, lapack_int ldb, double* x, - lapack_int ldx, double* work, float* swork, - lapack_int* iter ); -lapack_int LAPACKE_zcposv_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* b, - lapack_int ldb, lapack_complex_double* x, - lapack_int ldx, lapack_complex_double* work, - lapack_complex_float* swork, double* rwork, - lapack_int* iter ); - -lapack_int LAPACKE_sposvx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, float* a, - lapack_int lda, float* af, lapack_int ldaf, - char* equed, float* s, float* b, lapack_int ldb, - float* x, lapack_int ldx, float* rcond, - float* ferr, float* berr, float* work, - lapack_int* iwork ); -lapack_int LAPACKE_dposvx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, double* a, - lapack_int lda, double* af, lapack_int ldaf, - char* equed, double* s, double* b, - lapack_int ldb, double* x, lapack_int ldx, - double* rcond, double* ferr, double* berr, - double* work, lapack_int* iwork ); -lapack_int LAPACKE_cposvx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* af, lapack_int ldaf, - char* equed, float* s, lapack_complex_float* b, - lapack_int ldb, lapack_complex_float* x, - lapack_int ldx, float* rcond, float* ferr, - float* berr, lapack_complex_float* work, - float* rwork ); -lapack_int LAPACKE_zposvx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* af, lapack_int ldaf, - char* equed, double* s, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* ferr, double* berr, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_sposvxx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, float* a, - lapack_int lda, float* af, lapack_int ldaf, - char* equed, float* s, float* b, - lapack_int ldb, float* x, lapack_int ldx, - float* rcond, float* rpvgrw, float* berr, - lapack_int n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int nparams, - float* params, float* work, - lapack_int* iwork ); -lapack_int LAPACKE_dposvxx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, double* a, - lapack_int lda, double* af, lapack_int ldaf, - char* equed, double* s, double* b, - lapack_int ldb, double* x, lapack_int ldx, - double* rcond, double* rpvgrw, double* berr, - lapack_int n_err_bnds, double* err_bnds_norm, - double* err_bnds_comp, lapack_int nparams, - double* params, double* work, - lapack_int* iwork ); -lapack_int LAPACKE_cposvxx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* af, lapack_int ldaf, - char* equed, float* s, lapack_complex_float* b, - lapack_int ldb, lapack_complex_float* x, - lapack_int ldx, float* rcond, float* rpvgrw, - float* berr, lapack_int n_err_bnds, - float* err_bnds_norm, float* err_bnds_comp, - lapack_int nparams, float* params, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_zposvxx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* af, lapack_int ldaf, - char* equed, double* s, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* rpvgrw, double* berr, - lapack_int n_err_bnds, double* err_bnds_norm, - double* err_bnds_comp, lapack_int nparams, - double* params, lapack_complex_double* work, - double* rwork ); - -lapack_int LAPACKE_spotrf2_work( int matrix_layout, char uplo, lapack_int n, - float* a, lapack_int lda ); -lapack_int LAPACKE_dpotrf2_work( int matrix_layout, char uplo, lapack_int n, - double* a, lapack_int lda ); -lapack_int LAPACKE_cpotrf2_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda ); -lapack_int LAPACKE_zpotrf2_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda ); - -lapack_int LAPACKE_spotrf_work( int matrix_layout, char uplo, lapack_int n, - float* a, lapack_int lda ); -lapack_int LAPACKE_dpotrf_work( int matrix_layout, char uplo, lapack_int n, - double* a, lapack_int lda ); -lapack_int LAPACKE_cpotrf_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda ); -lapack_int LAPACKE_zpotrf_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda ); - -lapack_int LAPACKE_spotri_work( int matrix_layout, char uplo, lapack_int n, - float* a, lapack_int lda ); -lapack_int LAPACKE_dpotri_work( int matrix_layout, char uplo, lapack_int n, - double* a, lapack_int lda ); -lapack_int LAPACKE_cpotri_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda ); -lapack_int LAPACKE_zpotri_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda ); - -lapack_int LAPACKE_spotrs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const float* a, lapack_int lda, - float* b, lapack_int ldb ); -lapack_int LAPACKE_dpotrs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const double* a, - lapack_int lda, double* b, lapack_int ldb ); -lapack_int LAPACKE_cpotrs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, lapack_complex_float* b, - lapack_int ldb ); -lapack_int LAPACKE_zpotrs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, lapack_complex_double* b, - lapack_int ldb ); - -lapack_int LAPACKE_sppcon_work( int matrix_layout, char uplo, lapack_int n, - const float* ap, float anorm, float* rcond, - float* work, lapack_int* iwork ); -lapack_int LAPACKE_dppcon_work( int matrix_layout, char uplo, lapack_int n, - const double* ap, double anorm, double* rcond, - double* work, lapack_int* iwork ); -lapack_int LAPACKE_cppcon_work( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float* ap, float anorm, - float* rcond, lapack_complex_float* work, - float* rwork ); -lapack_int LAPACKE_zppcon_work( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double* ap, double anorm, - double* rcond, lapack_complex_double* work, - double* rwork ); - -lapack_int LAPACKE_sppequ_work( int matrix_layout, char uplo, lapack_int n, - const float* ap, float* s, float* scond, - float* amax ); -lapack_int LAPACKE_dppequ_work( int matrix_layout, char uplo, lapack_int n, - const double* ap, double* s, double* scond, - double* amax ); -lapack_int LAPACKE_cppequ_work( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float* ap, float* s, - float* scond, float* amax ); -lapack_int LAPACKE_zppequ_work( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double* ap, double* s, - double* scond, double* amax ); - -lapack_int LAPACKE_spprfs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const float* ap, - const float* afp, const float* b, - lapack_int ldb, float* x, lapack_int ldx, - float* ferr, float* berr, float* work, - lapack_int* iwork ); -lapack_int LAPACKE_dpprfs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const double* ap, - const double* afp, const double* b, - lapack_int ldb, double* x, lapack_int ldx, - double* ferr, double* berr, double* work, - lapack_int* iwork ); -lapack_int LAPACKE_cpprfs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* ap, - const lapack_complex_float* afp, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* ferr, float* berr, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_zpprfs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, - const lapack_complex_double* ap, - const lapack_complex_double* afp, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* ferr, double* berr, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_sppsv_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, float* ap, float* b, - lapack_int ldb ); -lapack_int LAPACKE_dppsv_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, double* ap, double* b, - lapack_int ldb ); -lapack_int LAPACKE_cppsv_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* ap, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zppsv_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* ap, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_sppsvx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, float* ap, - float* afp, char* equed, float* s, float* b, - lapack_int ldb, float* x, lapack_int ldx, - float* rcond, float* ferr, float* berr, - float* work, lapack_int* iwork ); -lapack_int LAPACKE_dppsvx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, double* ap, - double* afp, char* equed, double* s, double* b, - lapack_int ldb, double* x, lapack_int ldx, - double* rcond, double* ferr, double* berr, - double* work, lapack_int* iwork ); -lapack_int LAPACKE_cppsvx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, - lapack_complex_float* ap, - lapack_complex_float* afp, char* equed, - float* s, lapack_complex_float* b, - lapack_int ldb, lapack_complex_float* x, - lapack_int ldx, float* rcond, float* ferr, - float* berr, lapack_complex_float* work, - float* rwork ); -lapack_int LAPACKE_zppsvx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, - lapack_complex_double* ap, - lapack_complex_double* afp, char* equed, - double* s, lapack_complex_double* b, - lapack_int ldb, lapack_complex_double* x, - lapack_int ldx, double* rcond, double* ferr, - double* berr, lapack_complex_double* work, - double* rwork ); - -lapack_int LAPACKE_spptrf_work( int matrix_layout, char uplo, lapack_int n, - float* ap ); -lapack_int LAPACKE_dpptrf_work( int matrix_layout, char uplo, lapack_int n, - double* ap ); -lapack_int LAPACKE_cpptrf_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* ap ); -lapack_int LAPACKE_zpptrf_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* ap ); - -lapack_int LAPACKE_spptri_work( int matrix_layout, char uplo, lapack_int n, - float* ap ); -lapack_int LAPACKE_dpptri_work( int matrix_layout, char uplo, lapack_int n, - double* ap ); -lapack_int LAPACKE_cpptri_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* ap ); -lapack_int LAPACKE_zpptri_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* ap ); - -lapack_int LAPACKE_spptrs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const float* ap, float* b, - lapack_int ldb ); -lapack_int LAPACKE_dpptrs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const double* ap, double* b, - lapack_int ldb ); -lapack_int LAPACKE_cpptrs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* ap, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zpptrs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, - const lapack_complex_double* ap, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_spstrf_work( int matrix_layout, char uplo, lapack_int n, - float* a, lapack_int lda, lapack_int* piv, - lapack_int* rank, float tol, float* work ); -lapack_int LAPACKE_dpstrf_work( int matrix_layout, char uplo, lapack_int n, - double* a, lapack_int lda, lapack_int* piv, - lapack_int* rank, double tol, double* work ); -lapack_int LAPACKE_cpstrf_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int* piv, lapack_int* rank, float tol, - float* work ); -lapack_int LAPACKE_zpstrf_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int* piv, lapack_int* rank, double tol, - double* work ); - -lapack_int LAPACKE_sptcon_work( lapack_int n, const float* d, const float* e, - float anorm, float* rcond, float* work ); -lapack_int LAPACKE_dptcon_work( lapack_int n, const double* d, const double* e, - double anorm, double* rcond, double* work ); -lapack_int LAPACKE_cptcon_work( lapack_int n, const float* d, - const lapack_complex_float* e, float anorm, - float* rcond, float* work ); -lapack_int LAPACKE_zptcon_work( lapack_int n, const double* d, - const lapack_complex_double* e, double anorm, - double* rcond, double* work ); - -lapack_int LAPACKE_spteqr_work( int matrix_layout, char compz, lapack_int n, - float* d, float* e, float* z, lapack_int ldz, - float* work ); -lapack_int LAPACKE_dpteqr_work( int matrix_layout, char compz, lapack_int n, - double* d, double* e, double* z, lapack_int ldz, - double* work ); -lapack_int LAPACKE_cpteqr_work( int matrix_layout, char compz, lapack_int n, - float* d, float* e, lapack_complex_float* z, - lapack_int ldz, float* work ); -lapack_int LAPACKE_zpteqr_work( int matrix_layout, char compz, lapack_int n, - double* d, double* e, lapack_complex_double* z, - lapack_int ldz, double* work ); - -lapack_int LAPACKE_sptrfs_work( int matrix_layout, lapack_int n, lapack_int nrhs, - const float* d, const float* e, const float* df, - const float* ef, const float* b, lapack_int ldb, - float* x, lapack_int ldx, float* ferr, - float* berr, float* work ); -lapack_int LAPACKE_dptrfs_work( int matrix_layout, lapack_int n, lapack_int nrhs, - const double* d, const double* e, - const double* df, const double* ef, - const double* b, lapack_int ldb, double* x, - lapack_int ldx, double* ferr, double* berr, - double* work ); -lapack_int LAPACKE_cptrfs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const float* d, - const lapack_complex_float* e, const float* df, - const lapack_complex_float* ef, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* ferr, float* berr, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_zptrfs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const double* d, - const lapack_complex_double* e, - const double* df, - const lapack_complex_double* ef, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* ferr, double* berr, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_sptsv_work( int matrix_layout, lapack_int n, lapack_int nrhs, - float* d, float* e, float* b, lapack_int ldb ); -lapack_int LAPACKE_dptsv_work( int matrix_layout, lapack_int n, lapack_int nrhs, - double* d, double* e, double* b, - lapack_int ldb ); -lapack_int LAPACKE_cptsv_work( int matrix_layout, lapack_int n, lapack_int nrhs, - float* d, lapack_complex_float* e, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zptsv_work( int matrix_layout, lapack_int n, lapack_int nrhs, - double* d, lapack_complex_double* e, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_sptsvx_work( int matrix_layout, char fact, lapack_int n, - lapack_int nrhs, const float* d, const float* e, - float* df, float* ef, const float* b, - lapack_int ldb, float* x, lapack_int ldx, - float* rcond, float* ferr, float* berr, - float* work ); -lapack_int LAPACKE_dptsvx_work( int matrix_layout, char fact, lapack_int n, - lapack_int nrhs, const double* d, - const double* e, double* df, double* ef, - const double* b, lapack_int ldb, double* x, - lapack_int ldx, double* rcond, double* ferr, - double* berr, double* work ); -lapack_int LAPACKE_cptsvx_work( int matrix_layout, char fact, lapack_int n, - lapack_int nrhs, const float* d, - const lapack_complex_float* e, float* df, - lapack_complex_float* ef, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* rcond, float* ferr, float* berr, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_zptsvx_work( int matrix_layout, char fact, lapack_int n, - lapack_int nrhs, const double* d, - const lapack_complex_double* e, double* df, - lapack_complex_double* ef, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* ferr, double* berr, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_spttrf_work( lapack_int n, float* d, float* e ); -lapack_int LAPACKE_dpttrf_work( lapack_int n, double* d, double* e ); -lapack_int LAPACKE_cpttrf_work( lapack_int n, float* d, - lapack_complex_float* e ); -lapack_int LAPACKE_zpttrf_work( lapack_int n, double* d, - lapack_complex_double* e ); - -lapack_int LAPACKE_spttrs_work( int matrix_layout, lapack_int n, lapack_int nrhs, - const float* d, const float* e, float* b, - lapack_int ldb ); -lapack_int LAPACKE_dpttrs_work( int matrix_layout, lapack_int n, lapack_int nrhs, - const double* d, const double* e, double* b, - lapack_int ldb ); -lapack_int LAPACKE_cpttrs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const float* d, - const lapack_complex_float* e, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zpttrs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const double* d, - const lapack_complex_double* e, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_ssbev_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_int kd, float* ab, - lapack_int ldab, float* w, float* z, - lapack_int ldz, float* work ); -lapack_int LAPACKE_dsbev_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_int kd, double* ab, - lapack_int ldab, double* w, double* z, - lapack_int ldz, double* work ); - -lapack_int LAPACKE_ssbevd_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_int kd, float* ab, - lapack_int ldab, float* w, float* z, - lapack_int ldz, float* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork ); -lapack_int LAPACKE_dsbevd_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_int kd, double* ab, - lapack_int ldab, double* w, double* z, - lapack_int ldz, double* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork ); - -lapack_int LAPACKE_ssbevx_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, lapack_int kd, - float* ab, lapack_int ldab, float* q, - lapack_int ldq, float vl, float vu, - lapack_int il, lapack_int iu, float abstol, - lapack_int* m, float* w, float* z, - lapack_int ldz, float* work, - lapack_int* iwork, lapack_int* ifail ); -lapack_int LAPACKE_dsbevx_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, lapack_int kd, - double* ab, lapack_int ldab, double* q, - lapack_int ldq, double vl, double vu, - lapack_int il, lapack_int iu, double abstol, - lapack_int* m, double* w, double* z, - lapack_int ldz, double* work, - lapack_int* iwork, lapack_int* ifail ); - -lapack_int LAPACKE_ssbgst_work( int matrix_layout, char vect, char uplo, - lapack_int n, lapack_int ka, lapack_int kb, - float* ab, lapack_int ldab, const float* bb, - lapack_int ldbb, float* x, lapack_int ldx, - float* work ); -lapack_int LAPACKE_dsbgst_work( int matrix_layout, char vect, char uplo, - lapack_int n, lapack_int ka, lapack_int kb, - double* ab, lapack_int ldab, const double* bb, - lapack_int ldbb, double* x, lapack_int ldx, - double* work ); - -lapack_int LAPACKE_ssbgv_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_int ka, lapack_int kb, - float* ab, lapack_int ldab, float* bb, - lapack_int ldbb, float* w, float* z, - lapack_int ldz, float* work ); -lapack_int LAPACKE_dsbgv_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_int ka, lapack_int kb, - double* ab, lapack_int ldab, double* bb, - lapack_int ldbb, double* w, double* z, - lapack_int ldz, double* work ); - -lapack_int LAPACKE_ssbgvd_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_int ka, lapack_int kb, - float* ab, lapack_int ldab, float* bb, - lapack_int ldbb, float* w, float* z, - lapack_int ldz, float* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork ); -lapack_int LAPACKE_dsbgvd_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_int ka, lapack_int kb, - double* ab, lapack_int ldab, double* bb, - lapack_int ldbb, double* w, double* z, - lapack_int ldz, double* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork ); - -lapack_int LAPACKE_ssbgvx_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, lapack_int ka, - lapack_int kb, float* ab, lapack_int ldab, - float* bb, lapack_int ldbb, float* q, - lapack_int ldq, float vl, float vu, - lapack_int il, lapack_int iu, float abstol, - lapack_int* m, float* w, float* z, - lapack_int ldz, float* work, lapack_int* iwork, - lapack_int* ifail ); -lapack_int LAPACKE_dsbgvx_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, lapack_int ka, - lapack_int kb, double* ab, lapack_int ldab, - double* bb, lapack_int ldbb, double* q, - lapack_int ldq, double vl, double vu, - lapack_int il, lapack_int iu, double abstol, - lapack_int* m, double* w, double* z, - lapack_int ldz, double* work, lapack_int* iwork, - lapack_int* ifail ); - -lapack_int LAPACKE_ssbtrd_work( int matrix_layout, char vect, char uplo, - lapack_int n, lapack_int kd, float* ab, - lapack_int ldab, float* d, float* e, float* q, - lapack_int ldq, float* work ); -lapack_int LAPACKE_dsbtrd_work( int matrix_layout, char vect, char uplo, - lapack_int n, lapack_int kd, double* ab, - lapack_int ldab, double* d, double* e, - double* q, lapack_int ldq, double* work ); - -lapack_int LAPACKE_ssfrk_work( int matrix_layout, char transr, char uplo, - char trans, lapack_int n, lapack_int k, - float alpha, const float* a, lapack_int lda, - float beta, float* c ); -lapack_int LAPACKE_dsfrk_work( int matrix_layout, char transr, char uplo, - char trans, lapack_int n, lapack_int k, - double alpha, const double* a, lapack_int lda, - double beta, double* c ); - -lapack_int LAPACKE_sspcon_work( int matrix_layout, char uplo, lapack_int n, - const float* ap, const lapack_int* ipiv, - float anorm, float* rcond, float* work, - lapack_int* iwork ); -lapack_int LAPACKE_dspcon_work( int matrix_layout, char uplo, lapack_int n, - const double* ap, const lapack_int* ipiv, - double anorm, double* rcond, double* work, - lapack_int* iwork ); -lapack_int LAPACKE_cspcon_work( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float* ap, - const lapack_int* ipiv, float anorm, - float* rcond, lapack_complex_float* work ); -lapack_int LAPACKE_zspcon_work( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double* ap, - const lapack_int* ipiv, double anorm, - double* rcond, lapack_complex_double* work ); - -lapack_int LAPACKE_sspev_work( int matrix_layout, char jobz, char uplo, - lapack_int n, float* ap, float* w, float* z, - lapack_int ldz, float* work ); -lapack_int LAPACKE_dspev_work( int matrix_layout, char jobz, char uplo, - lapack_int n, double* ap, double* w, double* z, - lapack_int ldz, double* work ); - -lapack_int LAPACKE_sspevd_work( int matrix_layout, char jobz, char uplo, - lapack_int n, float* ap, float* w, float* z, - lapack_int ldz, float* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork ); -lapack_int LAPACKE_dspevd_work( int matrix_layout, char jobz, char uplo, - lapack_int n, double* ap, double* w, double* z, - lapack_int ldz, double* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork ); - -lapack_int LAPACKE_sspevx_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, float* ap, float vl, - float vu, lapack_int il, lapack_int iu, - float abstol, lapack_int* m, float* w, float* z, - lapack_int ldz, float* work, lapack_int* iwork, - lapack_int* ifail ); -lapack_int LAPACKE_dspevx_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, double* ap, double vl, - double vu, lapack_int il, lapack_int iu, - double abstol, lapack_int* m, double* w, - double* z, lapack_int ldz, double* work, - lapack_int* iwork, lapack_int* ifail ); - -lapack_int LAPACKE_sspgst_work( int matrix_layout, lapack_int itype, char uplo, - lapack_int n, float* ap, const float* bp ); -lapack_int LAPACKE_dspgst_work( int matrix_layout, lapack_int itype, char uplo, - lapack_int n, double* ap, const double* bp ); - -lapack_int LAPACKE_sspgv_work( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, float* ap, float* bp, - float* w, float* z, lapack_int ldz, - float* work ); -lapack_int LAPACKE_dspgv_work( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, double* ap, double* bp, - double* w, double* z, lapack_int ldz, - double* work ); - -lapack_int LAPACKE_sspgvd_work( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, float* ap, float* bp, - float* w, float* z, lapack_int ldz, float* work, - lapack_int lwork, lapack_int* iwork, - lapack_int liwork ); -lapack_int LAPACKE_dspgvd_work( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, double* ap, double* bp, - double* w, double* z, lapack_int ldz, - double* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork ); - -lapack_int LAPACKE_sspgvx_work( int matrix_layout, lapack_int itype, char jobz, - char range, char uplo, lapack_int n, float* ap, - float* bp, float vl, float vu, lapack_int il, - lapack_int iu, float abstol, lapack_int* m, - float* w, float* z, lapack_int ldz, float* work, - lapack_int* iwork, lapack_int* ifail ); -lapack_int LAPACKE_dspgvx_work( int matrix_layout, lapack_int itype, char jobz, - char range, char uplo, lapack_int n, double* ap, - double* bp, double vl, double vu, lapack_int il, - lapack_int iu, double abstol, lapack_int* m, - double* w, double* z, lapack_int ldz, - double* work, lapack_int* iwork, - lapack_int* ifail ); - -lapack_int LAPACKE_ssprfs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const float* ap, - const float* afp, const lapack_int* ipiv, - const float* b, lapack_int ldb, float* x, - lapack_int ldx, float* ferr, float* berr, - float* work, lapack_int* iwork ); -lapack_int LAPACKE_dsprfs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const double* ap, - const double* afp, const lapack_int* ipiv, - const double* b, lapack_int ldb, double* x, - lapack_int ldx, double* ferr, double* berr, - double* work, lapack_int* iwork ); -lapack_int LAPACKE_csprfs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* ap, - const lapack_complex_float* afp, - const lapack_int* ipiv, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* ferr, float* berr, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_zsprfs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, - const lapack_complex_double* ap, - const lapack_complex_double* afp, - const lapack_int* ipiv, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* ferr, double* berr, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_sspsv_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, float* ap, lapack_int* ipiv, - float* b, lapack_int ldb ); -lapack_int LAPACKE_dspsv_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, double* ap, lapack_int* ipiv, - double* b, lapack_int ldb ); -lapack_int LAPACKE_cspsv_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* ap, - lapack_int* ipiv, lapack_complex_float* b, - lapack_int ldb ); -lapack_int LAPACKE_zspsv_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* ap, - lapack_int* ipiv, lapack_complex_double* b, - lapack_int ldb ); - -lapack_int LAPACKE_sspsvx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, const float* ap, - float* afp, lapack_int* ipiv, const float* b, - lapack_int ldb, float* x, lapack_int ldx, - float* rcond, float* ferr, float* berr, - float* work, lapack_int* iwork ); -lapack_int LAPACKE_dspsvx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, const double* ap, - double* afp, lapack_int* ipiv, const double* b, - lapack_int ldb, double* x, lapack_int ldx, - double* rcond, double* ferr, double* berr, - double* work, lapack_int* iwork ); -lapack_int LAPACKE_cspsvx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, - const lapack_complex_float* ap, - lapack_complex_float* afp, lapack_int* ipiv, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* rcond, float* ferr, float* berr, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_zspsvx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, - const lapack_complex_double* ap, - lapack_complex_double* afp, lapack_int* ipiv, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* ferr, double* berr, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_ssptrd_work( int matrix_layout, char uplo, lapack_int n, - float* ap, float* d, float* e, float* tau ); -lapack_int LAPACKE_dsptrd_work( int matrix_layout, char uplo, lapack_int n, - double* ap, double* d, double* e, double* tau ); - -lapack_int LAPACKE_ssptrf_work( int matrix_layout, char uplo, lapack_int n, - float* ap, lapack_int* ipiv ); -lapack_int LAPACKE_dsptrf_work( int matrix_layout, char uplo, lapack_int n, - double* ap, lapack_int* ipiv ); -lapack_int LAPACKE_csptrf_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* ap, lapack_int* ipiv ); -lapack_int LAPACKE_zsptrf_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* ap, lapack_int* ipiv ); - -lapack_int LAPACKE_ssptri_work( int matrix_layout, char uplo, lapack_int n, - float* ap, const lapack_int* ipiv, - float* work ); -lapack_int LAPACKE_dsptri_work( int matrix_layout, char uplo, lapack_int n, - double* ap, const lapack_int* ipiv, - double* work ); -lapack_int LAPACKE_csptri_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* ap, - const lapack_int* ipiv, - lapack_complex_float* work ); -lapack_int LAPACKE_zsptri_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* ap, - const lapack_int* ipiv, - lapack_complex_double* work ); - -lapack_int LAPACKE_ssptrs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const float* ap, - const lapack_int* ipiv, float* b, - lapack_int ldb ); -lapack_int LAPACKE_dsptrs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const double* ap, - const lapack_int* ipiv, double* b, - lapack_int ldb ); -lapack_int LAPACKE_csptrs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* ap, - const lapack_int* ipiv, lapack_complex_float* b, - lapack_int ldb ); -lapack_int LAPACKE_zsptrs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, - const lapack_complex_double* ap, - const lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_sstebz_work( char range, char order, lapack_int n, float vl, - float vu, lapack_int il, lapack_int iu, - float abstol, const float* d, const float* e, - lapack_int* m, lapack_int* nsplit, float* w, - lapack_int* iblock, lapack_int* isplit, - float* work, lapack_int* iwork ); -lapack_int LAPACKE_dstebz_work( char range, char order, lapack_int n, double vl, - double vu, lapack_int il, lapack_int iu, - double abstol, const double* d, const double* e, - lapack_int* m, lapack_int* nsplit, double* w, - lapack_int* iblock, lapack_int* isplit, - double* work, lapack_int* iwork ); - -lapack_int LAPACKE_sstedc_work( int matrix_layout, char compz, lapack_int n, - float* d, float* e, float* z, lapack_int ldz, - float* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork ); -lapack_int LAPACKE_dstedc_work( int matrix_layout, char compz, lapack_int n, - double* d, double* e, double* z, lapack_int ldz, - double* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork ); -lapack_int LAPACKE_cstedc_work( int matrix_layout, char compz, lapack_int n, - float* d, float* e, lapack_complex_float* z, - lapack_int ldz, lapack_complex_float* work, - lapack_int lwork, float* rwork, - lapack_int lrwork, lapack_int* iwork, - lapack_int liwork ); -lapack_int LAPACKE_zstedc_work( int matrix_layout, char compz, lapack_int n, - double* d, double* e, lapack_complex_double* z, - lapack_int ldz, lapack_complex_double* work, - lapack_int lwork, double* rwork, - lapack_int lrwork, lapack_int* iwork, - lapack_int liwork ); - -lapack_int LAPACKE_sstegr_work( int matrix_layout, char jobz, char range, - lapack_int n, float* d, float* e, float vl, - float vu, lapack_int il, lapack_int iu, - float abstol, lapack_int* m, float* w, float* z, - lapack_int ldz, lapack_int* isuppz, float* work, - lapack_int lwork, lapack_int* iwork, - lapack_int liwork ); -lapack_int LAPACKE_dstegr_work( int matrix_layout, char jobz, char range, - lapack_int n, double* d, double* e, double vl, - double vu, lapack_int il, lapack_int iu, - double abstol, lapack_int* m, double* w, - double* z, lapack_int ldz, lapack_int* isuppz, - double* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork ); -lapack_int LAPACKE_cstegr_work( int matrix_layout, char jobz, char range, - lapack_int n, float* d, float* e, float vl, - float vu, lapack_int il, lapack_int iu, - float abstol, lapack_int* m, float* w, - lapack_complex_float* z, lapack_int ldz, - lapack_int* isuppz, float* work, - lapack_int lwork, lapack_int* iwork, - lapack_int liwork ); -lapack_int LAPACKE_zstegr_work( int matrix_layout, char jobz, char range, - lapack_int n, double* d, double* e, double vl, - double vu, lapack_int il, lapack_int iu, - double abstol, lapack_int* m, double* w, - lapack_complex_double* z, lapack_int ldz, - lapack_int* isuppz, double* work, - lapack_int lwork, lapack_int* iwork, - lapack_int liwork ); - -lapack_int LAPACKE_sstein_work( int matrix_layout, lapack_int n, const float* d, - const float* e, lapack_int m, const float* w, - const lapack_int* iblock, - const lapack_int* isplit, float* z, - lapack_int ldz, float* work, lapack_int* iwork, - lapack_int* ifailv ); -lapack_int LAPACKE_dstein_work( int matrix_layout, lapack_int n, const double* d, - const double* e, lapack_int m, const double* w, - const lapack_int* iblock, - const lapack_int* isplit, double* z, - lapack_int ldz, double* work, lapack_int* iwork, - lapack_int* ifailv ); -lapack_int LAPACKE_cstein_work( int matrix_layout, lapack_int n, const float* d, - const float* e, lapack_int m, const float* w, - const lapack_int* iblock, - const lapack_int* isplit, - lapack_complex_float* z, lapack_int ldz, - float* work, lapack_int* iwork, - lapack_int* ifailv ); -lapack_int LAPACKE_zstein_work( int matrix_layout, lapack_int n, const double* d, - const double* e, lapack_int m, const double* w, - const lapack_int* iblock, - const lapack_int* isplit, - lapack_complex_double* z, lapack_int ldz, - double* work, lapack_int* iwork, - lapack_int* ifailv ); - -lapack_int LAPACKE_sstemr_work( int matrix_layout, char jobz, char range, - lapack_int n, float* d, float* e, float vl, - float vu, lapack_int il, lapack_int iu, - lapack_int* m, float* w, float* z, - lapack_int ldz, lapack_int nzc, - lapack_int* isuppz, lapack_logical* tryrac, - float* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork ); -lapack_int LAPACKE_dstemr_work( int matrix_layout, char jobz, char range, - lapack_int n, double* d, double* e, double vl, - double vu, lapack_int il, lapack_int iu, - lapack_int* m, double* w, double* z, - lapack_int ldz, lapack_int nzc, - lapack_int* isuppz, lapack_logical* tryrac, - double* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork ); -lapack_int LAPACKE_cstemr_work( int matrix_layout, char jobz, char range, - lapack_int n, float* d, float* e, float vl, - float vu, lapack_int il, lapack_int iu, - lapack_int* m, float* w, - lapack_complex_float* z, lapack_int ldz, - lapack_int nzc, lapack_int* isuppz, - lapack_logical* tryrac, float* work, - lapack_int lwork, lapack_int* iwork, - lapack_int liwork ); -lapack_int LAPACKE_zstemr_work( int matrix_layout, char jobz, char range, - lapack_int n, double* d, double* e, double vl, - double vu, lapack_int il, lapack_int iu, - lapack_int* m, double* w, - lapack_complex_double* z, lapack_int ldz, - lapack_int nzc, lapack_int* isuppz, - lapack_logical* tryrac, double* work, - lapack_int lwork, lapack_int* iwork, - lapack_int liwork ); - -lapack_int LAPACKE_ssteqr_work( int matrix_layout, char compz, lapack_int n, - float* d, float* e, float* z, lapack_int ldz, - float* work ); -lapack_int LAPACKE_dsteqr_work( int matrix_layout, char compz, lapack_int n, - double* d, double* e, double* z, lapack_int ldz, - double* work ); -lapack_int LAPACKE_csteqr_work( int matrix_layout, char compz, lapack_int n, - float* d, float* e, lapack_complex_float* z, - lapack_int ldz, float* work ); -lapack_int LAPACKE_zsteqr_work( int matrix_layout, char compz, lapack_int n, - double* d, double* e, lapack_complex_double* z, - lapack_int ldz, double* work ); - -lapack_int LAPACKE_ssterf_work( lapack_int n, float* d, float* e ); -lapack_int LAPACKE_dsterf_work( lapack_int n, double* d, double* e ); - -lapack_int LAPACKE_sstev_work( int matrix_layout, char jobz, lapack_int n, - float* d, float* e, float* z, lapack_int ldz, - float* work ); -lapack_int LAPACKE_dstev_work( int matrix_layout, char jobz, lapack_int n, - double* d, double* e, double* z, lapack_int ldz, - double* work ); - -lapack_int LAPACKE_sstevd_work( int matrix_layout, char jobz, lapack_int n, - float* d, float* e, float* z, lapack_int ldz, - float* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork ); -lapack_int LAPACKE_dstevd_work( int matrix_layout, char jobz, lapack_int n, - double* d, double* e, double* z, lapack_int ldz, - double* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork ); - -lapack_int LAPACKE_sstevr_work( int matrix_layout, char jobz, char range, - lapack_int n, float* d, float* e, float vl, - float vu, lapack_int il, lapack_int iu, - float abstol, lapack_int* m, float* w, float* z, - lapack_int ldz, lapack_int* isuppz, float* work, - lapack_int lwork, lapack_int* iwork, - lapack_int liwork ); -lapack_int LAPACKE_dstevr_work( int matrix_layout, char jobz, char range, - lapack_int n, double* d, double* e, double vl, - double vu, lapack_int il, lapack_int iu, - double abstol, lapack_int* m, double* w, - double* z, lapack_int ldz, lapack_int* isuppz, - double* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork ); - -lapack_int LAPACKE_sstevx_work( int matrix_layout, char jobz, char range, - lapack_int n, float* d, float* e, float vl, - float vu, lapack_int il, lapack_int iu, - float abstol, lapack_int* m, float* w, float* z, - lapack_int ldz, float* work, lapack_int* iwork, - lapack_int* ifail ); -lapack_int LAPACKE_dstevx_work( int matrix_layout, char jobz, char range, - lapack_int n, double* d, double* e, double vl, - double vu, lapack_int il, lapack_int iu, - double abstol, lapack_int* m, double* w, - double* z, lapack_int ldz, double* work, - lapack_int* iwork, lapack_int* ifail ); - -lapack_int LAPACKE_ssycon_work( int matrix_layout, char uplo, lapack_int n, - const float* a, lapack_int lda, - const lapack_int* ipiv, float anorm, - float* rcond, float* work, lapack_int* iwork ); -lapack_int LAPACKE_dsycon_work( int matrix_layout, char uplo, lapack_int n, - const double* a, lapack_int lda, - const lapack_int* ipiv, double anorm, - double* rcond, double* work, - lapack_int* iwork ); -lapack_int LAPACKE_csycon_work( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - const lapack_int* ipiv, float anorm, - float* rcond, lapack_complex_float* work ); -lapack_int LAPACKE_zsycon_work( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - const lapack_int* ipiv, double anorm, - double* rcond, lapack_complex_double* work ); - -lapack_int LAPACKE_ssyequb_work( int matrix_layout, char uplo, lapack_int n, - const float* a, lapack_int lda, float* s, - float* scond, float* amax, float* work ); -lapack_int LAPACKE_dsyequb_work( int matrix_layout, char uplo, lapack_int n, - const double* a, lapack_int lda, double* s, - double* scond, double* amax, double* work ); -lapack_int LAPACKE_csyequb_work( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - float* s, float* scond, float* amax, - lapack_complex_float* work ); -lapack_int LAPACKE_zsyequb_work( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - double* s, double* scond, double* amax, - lapack_complex_double* work ); - -lapack_int LAPACKE_ssyev_work( int matrix_layout, char jobz, char uplo, - lapack_int n, float* a, lapack_int lda, float* w, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dsyev_work( int matrix_layout, char jobz, char uplo, - lapack_int n, double* a, lapack_int lda, - double* w, double* work, lapack_int lwork ); - -lapack_int LAPACKE_ssyevd_work( int matrix_layout, char jobz, char uplo, - lapack_int n, float* a, lapack_int lda, - float* w, float* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork ); -lapack_int LAPACKE_dsyevd_work( int matrix_layout, char jobz, char uplo, - lapack_int n, double* a, lapack_int lda, - double* w, double* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork ); - -lapack_int LAPACKE_ssyevr_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, float* a, - lapack_int lda, float vl, float vu, - lapack_int il, lapack_int iu, float abstol, - lapack_int* m, float* w, float* z, - lapack_int ldz, lapack_int* isuppz, float* work, - lapack_int lwork, lapack_int* iwork, - lapack_int liwork ); -lapack_int LAPACKE_dsyevr_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, double* a, - lapack_int lda, double vl, double vu, - lapack_int il, lapack_int iu, double abstol, - lapack_int* m, double* w, double* z, - lapack_int ldz, lapack_int* isuppz, - double* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork ); - -lapack_int LAPACKE_ssyevx_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, float* a, - lapack_int lda, float vl, float vu, - lapack_int il, lapack_int iu, float abstol, - lapack_int* m, float* w, float* z, - lapack_int ldz, float* work, lapack_int lwork, - lapack_int* iwork, lapack_int* ifail ); -lapack_int LAPACKE_dsyevx_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, double* a, - lapack_int lda, double vl, double vu, - lapack_int il, lapack_int iu, double abstol, - lapack_int* m, double* w, double* z, - lapack_int ldz, double* work, lapack_int lwork, - lapack_int* iwork, lapack_int* ifail ); - -lapack_int LAPACKE_ssygst_work( int matrix_layout, lapack_int itype, char uplo, - lapack_int n, float* a, lapack_int lda, - const float* b, lapack_int ldb ); -lapack_int LAPACKE_dsygst_work( int matrix_layout, lapack_int itype, char uplo, - lapack_int n, double* a, lapack_int lda, - const double* b, lapack_int ldb ); - -lapack_int LAPACKE_ssygv_work( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, float* a, - lapack_int lda, float* b, lapack_int ldb, - float* w, float* work, lapack_int lwork ); -lapack_int LAPACKE_dsygv_work( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, double* a, - lapack_int lda, double* b, lapack_int ldb, - double* w, double* work, lapack_int lwork ); - -lapack_int LAPACKE_ssygvd_work( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, float* a, - lapack_int lda, float* b, lapack_int ldb, - float* w, float* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork ); -lapack_int LAPACKE_dsygvd_work( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, double* a, - lapack_int lda, double* b, lapack_int ldb, - double* w, double* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork ); - -lapack_int LAPACKE_ssygvx_work( int matrix_layout, lapack_int itype, char jobz, - char range, char uplo, lapack_int n, float* a, - lapack_int lda, float* b, lapack_int ldb, - float vl, float vu, lapack_int il, - lapack_int iu, float abstol, lapack_int* m, - float* w, float* z, lapack_int ldz, float* work, - lapack_int lwork, lapack_int* iwork, - lapack_int* ifail ); -lapack_int LAPACKE_dsygvx_work( int matrix_layout, lapack_int itype, char jobz, - char range, char uplo, lapack_int n, double* a, - lapack_int lda, double* b, lapack_int ldb, - double vl, double vu, lapack_int il, - lapack_int iu, double abstol, lapack_int* m, - double* w, double* z, lapack_int ldz, - double* work, lapack_int lwork, - lapack_int* iwork, lapack_int* ifail ); - -lapack_int LAPACKE_ssyrfs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const float* a, lapack_int lda, - const float* af, lapack_int ldaf, - const lapack_int* ipiv, const float* b, - lapack_int ldb, float* x, lapack_int ldx, - float* ferr, float* berr, float* work, - lapack_int* iwork ); -lapack_int LAPACKE_dsyrfs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const double* a, - lapack_int lda, const double* af, - lapack_int ldaf, const lapack_int* ipiv, - const double* b, lapack_int ldb, double* x, - lapack_int ldx, double* ferr, double* berr, - double* work, lapack_int* iwork ); -lapack_int LAPACKE_csyrfs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* af, - lapack_int ldaf, const lapack_int* ipiv, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* ferr, float* berr, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_zsyrfs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_complex_double* af, - lapack_int ldaf, const lapack_int* ipiv, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* ferr, double* berr, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_ssyrfsx_work( int matrix_layout, char uplo, char equed, - lapack_int n, lapack_int nrhs, const float* a, - lapack_int lda, const float* af, - lapack_int ldaf, const lapack_int* ipiv, - const float* s, const float* b, lapack_int ldb, - float* x, lapack_int ldx, float* rcond, - float* berr, lapack_int n_err_bnds, - float* err_bnds_norm, float* err_bnds_comp, - lapack_int nparams, float* params, float* work, - lapack_int* iwork ); -lapack_int LAPACKE_dsyrfsx_work( int matrix_layout, char uplo, char equed, - lapack_int n, lapack_int nrhs, const double* a, - lapack_int lda, const double* af, - lapack_int ldaf, const lapack_int* ipiv, - const double* s, const double* b, - lapack_int ldb, double* x, lapack_int ldx, - double* rcond, double* berr, - lapack_int n_err_bnds, double* err_bnds_norm, - double* err_bnds_comp, lapack_int nparams, - double* params, double* work, - lapack_int* iwork ); -lapack_int LAPACKE_csyrfsx_work( int matrix_layout, char uplo, char equed, - lapack_int n, lapack_int nrhs, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* af, - lapack_int ldaf, const lapack_int* ipiv, - const float* s, const lapack_complex_float* b, - lapack_int ldb, lapack_complex_float* x, - lapack_int ldx, float* rcond, float* berr, - lapack_int n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int nparams, - float* params, lapack_complex_float* work, - float* rwork ); -lapack_int LAPACKE_zsyrfsx_work( int matrix_layout, char uplo, char equed, - lapack_int n, lapack_int nrhs, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* af, - lapack_int ldaf, const lapack_int* ipiv, - const double* s, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* berr, - lapack_int n_err_bnds, double* err_bnds_norm, - double* err_bnds_comp, lapack_int nparams, - double* params, lapack_complex_double* work, - double* rwork ); - -lapack_int LAPACKE_ssysv_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, float* a, lapack_int lda, - lapack_int* ipiv, float* b, lapack_int ldb, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dsysv_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, double* a, lapack_int lda, - lapack_int* ipiv, double* b, lapack_int ldb, - double* work, lapack_int lwork ); -lapack_int LAPACKE_csysv_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zsysv_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_ssysvx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, const float* a, - lapack_int lda, float* af, lapack_int ldaf, - lapack_int* ipiv, const float* b, - lapack_int ldb, float* x, lapack_int ldx, - float* rcond, float* ferr, float* berr, - float* work, lapack_int lwork, - lapack_int* iwork ); -lapack_int LAPACKE_dsysvx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, const double* a, - lapack_int lda, double* af, lapack_int ldaf, - lapack_int* ipiv, const double* b, - lapack_int ldb, double* x, lapack_int ldx, - double* rcond, double* ferr, double* berr, - double* work, lapack_int lwork, - lapack_int* iwork ); -lapack_int LAPACKE_csysvx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, - const lapack_complex_float* a, lapack_int lda, - lapack_complex_float* af, lapack_int ldaf, - lapack_int* ipiv, const lapack_complex_float* b, - lapack_int ldb, lapack_complex_float* x, - lapack_int ldx, float* rcond, float* ferr, - float* berr, lapack_complex_float* work, - lapack_int lwork, float* rwork ); -lapack_int LAPACKE_zsysvx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, - const lapack_complex_double* a, lapack_int lda, - lapack_complex_double* af, lapack_int ldaf, - lapack_int* ipiv, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* ferr, double* berr, - lapack_complex_double* work, lapack_int lwork, - double* rwork ); - -lapack_int LAPACKE_ssysvxx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, float* a, - lapack_int lda, float* af, lapack_int ldaf, - lapack_int* ipiv, char* equed, float* s, - float* b, lapack_int ldb, float* x, - lapack_int ldx, float* rcond, float* rpvgrw, - float* berr, lapack_int n_err_bnds, - float* err_bnds_norm, float* err_bnds_comp, - lapack_int nparams, float* params, float* work, - lapack_int* iwork ); -lapack_int LAPACKE_dsysvxx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, double* a, - lapack_int lda, double* af, lapack_int ldaf, - lapack_int* ipiv, char* equed, double* s, - double* b, lapack_int ldb, double* x, - lapack_int ldx, double* rcond, double* rpvgrw, - double* berr, lapack_int n_err_bnds, - double* err_bnds_norm, double* err_bnds_comp, - lapack_int nparams, double* params, - double* work, lapack_int* iwork ); -lapack_int LAPACKE_csysvxx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* af, lapack_int ldaf, - lapack_int* ipiv, char* equed, float* s, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* x, lapack_int ldx, - float* rcond, float* rpvgrw, float* berr, - lapack_int n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int nparams, - float* params, lapack_complex_float* work, - float* rwork ); -lapack_int LAPACKE_zsysvxx_work( int matrix_layout, char fact, char uplo, - lapack_int n, lapack_int nrhs, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* af, lapack_int ldaf, - lapack_int* ipiv, char* equed, double* s, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* x, lapack_int ldx, - double* rcond, double* rpvgrw, double* berr, - lapack_int n_err_bnds, double* err_bnds_norm, - double* err_bnds_comp, lapack_int nparams, - double* params, lapack_complex_double* work, - double* rwork ); - -lapack_int LAPACKE_ssytrd_work( int matrix_layout, char uplo, lapack_int n, - float* a, lapack_int lda, float* d, float* e, - float* tau, float* work, lapack_int lwork ); -lapack_int LAPACKE_dsytrd_work( int matrix_layout, char uplo, lapack_int n, - double* a, lapack_int lda, double* d, double* e, - double* tau, double* work, lapack_int lwork ); - -lapack_int LAPACKE_ssytrf_work( int matrix_layout, char uplo, lapack_int n, - float* a, lapack_int lda, lapack_int* ipiv, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dsytrf_work( int matrix_layout, char uplo, lapack_int n, - double* a, lapack_int lda, lapack_int* ipiv, - double* work, lapack_int lwork ); -lapack_int LAPACKE_csytrf_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int* ipiv, lapack_complex_float* work, - lapack_int lwork ); -lapack_int LAPACKE_zsytrf_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int* ipiv, lapack_complex_double* work, - lapack_int lwork ); - -lapack_int LAPACKE_ssytri_work( int matrix_layout, char uplo, lapack_int n, - float* a, lapack_int lda, - const lapack_int* ipiv, float* work ); -lapack_int LAPACKE_dsytri_work( int matrix_layout, char uplo, lapack_int n, - double* a, lapack_int lda, - const lapack_int* ipiv, double* work ); -lapack_int LAPACKE_csytri_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - const lapack_int* ipiv, - lapack_complex_float* work ); -lapack_int LAPACKE_zsytri_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - const lapack_int* ipiv, - lapack_complex_double* work ); - -lapack_int LAPACKE_ssytrs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const float* a, lapack_int lda, - const lapack_int* ipiv, float* b, - lapack_int ldb ); -lapack_int LAPACKE_dsytrs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const double* a, - lapack_int lda, const lapack_int* ipiv, - double* b, lapack_int ldb ); -lapack_int LAPACKE_csytrs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zsytrs_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_stbcon_work( int matrix_layout, char norm, char uplo, - char diag, lapack_int n, lapack_int kd, - const float* ab, lapack_int ldab, float* rcond, - float* work, lapack_int* iwork ); -lapack_int LAPACKE_dtbcon_work( int matrix_layout, char norm, char uplo, - char diag, lapack_int n, lapack_int kd, - const double* ab, lapack_int ldab, - double* rcond, double* work, - lapack_int* iwork ); -lapack_int LAPACKE_ctbcon_work( int matrix_layout, char norm, char uplo, - char diag, lapack_int n, lapack_int kd, - const lapack_complex_float* ab, lapack_int ldab, - float* rcond, lapack_complex_float* work, - float* rwork ); -lapack_int LAPACKE_ztbcon_work( int matrix_layout, char norm, char uplo, - char diag, lapack_int n, lapack_int kd, - const lapack_complex_double* ab, - lapack_int ldab, double* rcond, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_stbrfs_work( int matrix_layout, char uplo, char trans, - char diag, lapack_int n, lapack_int kd, - lapack_int nrhs, const float* ab, - lapack_int ldab, const float* b, lapack_int ldb, - const float* x, lapack_int ldx, float* ferr, - float* berr, float* work, lapack_int* iwork ); -lapack_int LAPACKE_dtbrfs_work( int matrix_layout, char uplo, char trans, - char diag, lapack_int n, lapack_int kd, - lapack_int nrhs, const double* ab, - lapack_int ldab, const double* b, - lapack_int ldb, const double* x, lapack_int ldx, - double* ferr, double* berr, double* work, - lapack_int* iwork ); -lapack_int LAPACKE_ctbrfs_work( int matrix_layout, char uplo, char trans, - char diag, lapack_int n, lapack_int kd, - lapack_int nrhs, const lapack_complex_float* ab, - lapack_int ldab, const lapack_complex_float* b, - lapack_int ldb, const lapack_complex_float* x, - lapack_int ldx, float* ferr, float* berr, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_ztbrfs_work( int matrix_layout, char uplo, char trans, - char diag, lapack_int n, lapack_int kd, - lapack_int nrhs, - const lapack_complex_double* ab, - lapack_int ldab, const lapack_complex_double* b, - lapack_int ldb, const lapack_complex_double* x, - lapack_int ldx, double* ferr, double* berr, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_stbtrs_work( int matrix_layout, char uplo, char trans, - char diag, lapack_int n, lapack_int kd, - lapack_int nrhs, const float* ab, - lapack_int ldab, float* b, lapack_int ldb ); -lapack_int LAPACKE_dtbtrs_work( int matrix_layout, char uplo, char trans, - char diag, lapack_int n, lapack_int kd, - lapack_int nrhs, const double* ab, - lapack_int ldab, double* b, lapack_int ldb ); -lapack_int LAPACKE_ctbtrs_work( int matrix_layout, char uplo, char trans, - char diag, lapack_int n, lapack_int kd, - lapack_int nrhs, const lapack_complex_float* ab, - lapack_int ldab, lapack_complex_float* b, - lapack_int ldb ); -lapack_int LAPACKE_ztbtrs_work( int matrix_layout, char uplo, char trans, - char diag, lapack_int n, lapack_int kd, - lapack_int nrhs, - const lapack_complex_double* ab, - lapack_int ldab, lapack_complex_double* b, - lapack_int ldb ); - -lapack_int LAPACKE_stfsm_work( int matrix_layout, char transr, char side, - char uplo, char trans, char diag, lapack_int m, - lapack_int n, float alpha, const float* a, - float* b, lapack_int ldb ); -lapack_int LAPACKE_dtfsm_work( int matrix_layout, char transr, char side, - char uplo, char trans, char diag, lapack_int m, - lapack_int n, double alpha, const double* a, - double* b, lapack_int ldb ); -lapack_int LAPACKE_ctfsm_work( int matrix_layout, char transr, char side, - char uplo, char trans, char diag, lapack_int m, - lapack_int n, lapack_complex_float alpha, - const lapack_complex_float* a, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_ztfsm_work( int matrix_layout, char transr, char side, - char uplo, char trans, char diag, lapack_int m, - lapack_int n, lapack_complex_double alpha, - const lapack_complex_double* a, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_stftri_work( int matrix_layout, char transr, char uplo, - char diag, lapack_int n, float* a ); -lapack_int LAPACKE_dtftri_work( int matrix_layout, char transr, char uplo, - char diag, lapack_int n, double* a ); -lapack_int LAPACKE_ctftri_work( int matrix_layout, char transr, char uplo, - char diag, lapack_int n, - lapack_complex_float* a ); -lapack_int LAPACKE_ztftri_work( int matrix_layout, char transr, char uplo, - char diag, lapack_int n, - lapack_complex_double* a ); - -lapack_int LAPACKE_stfttp_work( int matrix_layout, char transr, char uplo, - lapack_int n, const float* arf, float* ap ); -lapack_int LAPACKE_dtfttp_work( int matrix_layout, char transr, char uplo, - lapack_int n, const double* arf, double* ap ); -lapack_int LAPACKE_ctfttp_work( int matrix_layout, char transr, char uplo, - lapack_int n, const lapack_complex_float* arf, - lapack_complex_float* ap ); -lapack_int LAPACKE_ztfttp_work( int matrix_layout, char transr, char uplo, - lapack_int n, const lapack_complex_double* arf, - lapack_complex_double* ap ); - -lapack_int LAPACKE_stfttr_work( int matrix_layout, char transr, char uplo, - lapack_int n, const float* arf, float* a, - lapack_int lda ); -lapack_int LAPACKE_dtfttr_work( int matrix_layout, char transr, char uplo, - lapack_int n, const double* arf, double* a, - lapack_int lda ); -lapack_int LAPACKE_ctfttr_work( int matrix_layout, char transr, char uplo, - lapack_int n, const lapack_complex_float* arf, - lapack_complex_float* a, lapack_int lda ); -lapack_int LAPACKE_ztfttr_work( int matrix_layout, char transr, char uplo, - lapack_int n, const lapack_complex_double* arf, - lapack_complex_double* a, lapack_int lda ); - -lapack_int LAPACKE_stgevc_work( int matrix_layout, char side, char howmny, - const lapack_logical* select, lapack_int n, - const float* s, lapack_int lds, const float* p, - lapack_int ldp, float* vl, lapack_int ldvl, - float* vr, lapack_int ldvr, lapack_int mm, - lapack_int* m, float* work ); -lapack_int LAPACKE_dtgevc_work( int matrix_layout, char side, char howmny, - const lapack_logical* select, lapack_int n, - const double* s, lapack_int lds, - const double* p, lapack_int ldp, double* vl, - lapack_int ldvl, double* vr, lapack_int ldvr, - lapack_int mm, lapack_int* m, double* work ); -lapack_int LAPACKE_ctgevc_work( int matrix_layout, char side, char howmny, - const lapack_logical* select, lapack_int n, - const lapack_complex_float* s, lapack_int lds, - const lapack_complex_float* p, lapack_int ldp, - lapack_complex_float* vl, lapack_int ldvl, - lapack_complex_float* vr, lapack_int ldvr, - lapack_int mm, lapack_int* m, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_ztgevc_work( int matrix_layout, char side, char howmny, - const lapack_logical* select, lapack_int n, - const lapack_complex_double* s, lapack_int lds, - const lapack_complex_double* p, lapack_int ldp, - lapack_complex_double* vl, lapack_int ldvl, - lapack_complex_double* vr, lapack_int ldvr, - lapack_int mm, lapack_int* m, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_stgexc_work( int matrix_layout, lapack_logical wantq, - lapack_logical wantz, lapack_int n, float* a, - lapack_int lda, float* b, lapack_int ldb, - float* q, lapack_int ldq, float* z, - lapack_int ldz, lapack_int* ifst, - lapack_int* ilst, float* work, - lapack_int lwork ); -lapack_int LAPACKE_dtgexc_work( int matrix_layout, lapack_logical wantq, - lapack_logical wantz, lapack_int n, double* a, - lapack_int lda, double* b, lapack_int ldb, - double* q, lapack_int ldq, double* z, - lapack_int ldz, lapack_int* ifst, - lapack_int* ilst, double* work, - lapack_int lwork ); -lapack_int LAPACKE_ctgexc_work( int matrix_layout, lapack_logical wantq, - lapack_logical wantz, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* q, lapack_int ldq, - lapack_complex_float* z, lapack_int ldz, - lapack_int ifst, lapack_int ilst ); -lapack_int LAPACKE_ztgexc_work( int matrix_layout, lapack_logical wantq, - lapack_logical wantz, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* q, lapack_int ldq, - lapack_complex_double* z, lapack_int ldz, - lapack_int ifst, lapack_int ilst ); - -lapack_int LAPACKE_stgsen_work( int matrix_layout, lapack_int ijob, - lapack_logical wantq, lapack_logical wantz, - const lapack_logical* select, lapack_int n, - float* a, lapack_int lda, float* b, - lapack_int ldb, float* alphar, float* alphai, - float* beta, float* q, lapack_int ldq, float* z, - lapack_int ldz, lapack_int* m, float* pl, - float* pr, float* dif, float* work, - lapack_int lwork, lapack_int* iwork, - lapack_int liwork ); -lapack_int LAPACKE_dtgsen_work( int matrix_layout, lapack_int ijob, - lapack_logical wantq, lapack_logical wantz, - const lapack_logical* select, lapack_int n, - double* a, lapack_int lda, double* b, - lapack_int ldb, double* alphar, double* alphai, - double* beta, double* q, lapack_int ldq, - double* z, lapack_int ldz, lapack_int* m, - double* pl, double* pr, double* dif, - double* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork ); -lapack_int LAPACKE_ctgsen_work( int matrix_layout, lapack_int ijob, - lapack_logical wantq, lapack_logical wantz, - const lapack_logical* select, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* alpha, - lapack_complex_float* beta, - lapack_complex_float* q, lapack_int ldq, - lapack_complex_float* z, lapack_int ldz, - lapack_int* m, float* pl, float* pr, float* dif, - lapack_complex_float* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork ); -lapack_int LAPACKE_ztgsen_work( int matrix_layout, lapack_int ijob, - lapack_logical wantq, lapack_logical wantz, - const lapack_logical* select, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* alpha, - lapack_complex_double* beta, - lapack_complex_double* q, lapack_int ldq, - lapack_complex_double* z, lapack_int ldz, - lapack_int* m, double* pl, double* pr, - double* dif, lapack_complex_double* work, - lapack_int lwork, lapack_int* iwork, - lapack_int liwork ); - -lapack_int LAPACKE_stgsja_work( int matrix_layout, char jobu, char jobv, - char jobq, lapack_int m, lapack_int p, - lapack_int n, lapack_int k, lapack_int l, - float* a, lapack_int lda, float* b, - lapack_int ldb, float tola, float tolb, - float* alpha, float* beta, float* u, - lapack_int ldu, float* v, lapack_int ldv, - float* q, lapack_int ldq, float* work, - lapack_int* ncycle ); -lapack_int LAPACKE_dtgsja_work( int matrix_layout, char jobu, char jobv, - char jobq, lapack_int m, lapack_int p, - lapack_int n, lapack_int k, lapack_int l, - double* a, lapack_int lda, double* b, - lapack_int ldb, double tola, double tolb, - double* alpha, double* beta, double* u, - lapack_int ldu, double* v, lapack_int ldv, - double* q, lapack_int ldq, double* work, - lapack_int* ncycle ); -lapack_int LAPACKE_ctgsja_work( int matrix_layout, char jobu, char jobv, - char jobq, lapack_int m, lapack_int p, - lapack_int n, lapack_int k, lapack_int l, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - float tola, float tolb, float* alpha, - float* beta, lapack_complex_float* u, - lapack_int ldu, lapack_complex_float* v, - lapack_int ldv, lapack_complex_float* q, - lapack_int ldq, lapack_complex_float* work, - lapack_int* ncycle ); -lapack_int LAPACKE_ztgsja_work( int matrix_layout, char jobu, char jobv, - char jobq, lapack_int m, lapack_int p, - lapack_int n, lapack_int k, lapack_int l, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - double tola, double tolb, double* alpha, - double* beta, lapack_complex_double* u, - lapack_int ldu, lapack_complex_double* v, - lapack_int ldv, lapack_complex_double* q, - lapack_int ldq, lapack_complex_double* work, - lapack_int* ncycle ); - -lapack_int LAPACKE_stgsna_work( int matrix_layout, char job, char howmny, - const lapack_logical* select, lapack_int n, - const float* a, lapack_int lda, const float* b, - lapack_int ldb, const float* vl, - lapack_int ldvl, const float* vr, - lapack_int ldvr, float* s, float* dif, - lapack_int mm, lapack_int* m, float* work, - lapack_int lwork, lapack_int* iwork ); -lapack_int LAPACKE_dtgsna_work( int matrix_layout, char job, char howmny, - const lapack_logical* select, lapack_int n, - const double* a, lapack_int lda, - const double* b, lapack_int ldb, - const double* vl, lapack_int ldvl, - const double* vr, lapack_int ldvr, double* s, - double* dif, lapack_int mm, lapack_int* m, - double* work, lapack_int lwork, - lapack_int* iwork ); -lapack_int LAPACKE_ctgsna_work( int matrix_layout, char job, char howmny, - const lapack_logical* select, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* b, lapack_int ldb, - const lapack_complex_float* vl, lapack_int ldvl, - const lapack_complex_float* vr, lapack_int ldvr, - float* s, float* dif, lapack_int mm, - lapack_int* m, lapack_complex_float* work, - lapack_int lwork, lapack_int* iwork ); -lapack_int LAPACKE_ztgsna_work( int matrix_layout, char job, char howmny, - const lapack_logical* select, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* b, lapack_int ldb, - const lapack_complex_double* vl, - lapack_int ldvl, - const lapack_complex_double* vr, - lapack_int ldvr, double* s, double* dif, - lapack_int mm, lapack_int* m, - lapack_complex_double* work, lapack_int lwork, - lapack_int* iwork ); - -lapack_int LAPACKE_stgsyl_work( int matrix_layout, char trans, lapack_int ijob, - lapack_int m, lapack_int n, const float* a, - lapack_int lda, const float* b, lapack_int ldb, - float* c, lapack_int ldc, const float* d, - lapack_int ldd, const float* e, lapack_int lde, - float* f, lapack_int ldf, float* scale, - float* dif, float* work, lapack_int lwork, - lapack_int* iwork ); -lapack_int LAPACKE_dtgsyl_work( int matrix_layout, char trans, lapack_int ijob, - lapack_int m, lapack_int n, const double* a, - lapack_int lda, const double* b, lapack_int ldb, - double* c, lapack_int ldc, const double* d, - lapack_int ldd, const double* e, lapack_int lde, - double* f, lapack_int ldf, double* scale, - double* dif, double* work, lapack_int lwork, - lapack_int* iwork ); -lapack_int LAPACKE_ctgsyl_work( int matrix_layout, char trans, lapack_int ijob, - lapack_int m, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* c, lapack_int ldc, - const lapack_complex_float* d, lapack_int ldd, - const lapack_complex_float* e, lapack_int lde, - lapack_complex_float* f, lapack_int ldf, - float* scale, float* dif, - lapack_complex_float* work, lapack_int lwork, - lapack_int* iwork ); -lapack_int LAPACKE_ztgsyl_work( int matrix_layout, char trans, lapack_int ijob, - lapack_int m, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* c, lapack_int ldc, - const lapack_complex_double* d, lapack_int ldd, - const lapack_complex_double* e, lapack_int lde, - lapack_complex_double* f, lapack_int ldf, - double* scale, double* dif, - lapack_complex_double* work, lapack_int lwork, - lapack_int* iwork ); - -lapack_int LAPACKE_stpcon_work( int matrix_layout, char norm, char uplo, - char diag, lapack_int n, const float* ap, - float* rcond, float* work, lapack_int* iwork ); -lapack_int LAPACKE_dtpcon_work( int matrix_layout, char norm, char uplo, - char diag, lapack_int n, const double* ap, - double* rcond, double* work, - lapack_int* iwork ); -lapack_int LAPACKE_ctpcon_work( int matrix_layout, char norm, char uplo, - char diag, lapack_int n, - const lapack_complex_float* ap, float* rcond, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_ztpcon_work( int matrix_layout, char norm, char uplo, - char diag, lapack_int n, - const lapack_complex_double* ap, double* rcond, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_stprfs_work( int matrix_layout, char uplo, char trans, - char diag, lapack_int n, lapack_int nrhs, - const float* ap, const float* b, lapack_int ldb, - const float* x, lapack_int ldx, float* ferr, - float* berr, float* work, lapack_int* iwork ); -lapack_int LAPACKE_dtprfs_work( int matrix_layout, char uplo, char trans, - char diag, lapack_int n, lapack_int nrhs, - const double* ap, const double* b, - lapack_int ldb, const double* x, lapack_int ldx, - double* ferr, double* berr, double* work, - lapack_int* iwork ); -lapack_int LAPACKE_ctprfs_work( int matrix_layout, char uplo, char trans, - char diag, lapack_int n, lapack_int nrhs, - const lapack_complex_float* ap, - const lapack_complex_float* b, lapack_int ldb, - const lapack_complex_float* x, lapack_int ldx, - float* ferr, float* berr, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_ztprfs_work( int matrix_layout, char uplo, char trans, - char diag, lapack_int n, lapack_int nrhs, - const lapack_complex_double* ap, - const lapack_complex_double* b, lapack_int ldb, - const lapack_complex_double* x, lapack_int ldx, - double* ferr, double* berr, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_stptri_work( int matrix_layout, char uplo, char diag, - lapack_int n, float* ap ); -lapack_int LAPACKE_dtptri_work( int matrix_layout, char uplo, char diag, - lapack_int n, double* ap ); -lapack_int LAPACKE_ctptri_work( int matrix_layout, char uplo, char diag, - lapack_int n, lapack_complex_float* ap ); -lapack_int LAPACKE_ztptri_work( int matrix_layout, char uplo, char diag, - lapack_int n, lapack_complex_double* ap ); - -lapack_int LAPACKE_stptrs_work( int matrix_layout, char uplo, char trans, - char diag, lapack_int n, lapack_int nrhs, - const float* ap, float* b, lapack_int ldb ); -lapack_int LAPACKE_dtptrs_work( int matrix_layout, char uplo, char trans, - char diag, lapack_int n, lapack_int nrhs, - const double* ap, double* b, lapack_int ldb ); -lapack_int LAPACKE_ctptrs_work( int matrix_layout, char uplo, char trans, - char diag, lapack_int n, lapack_int nrhs, - const lapack_complex_float* ap, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_ztptrs_work( int matrix_layout, char uplo, char trans, - char diag, lapack_int n, lapack_int nrhs, - const lapack_complex_double* ap, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_stpttf_work( int matrix_layout, char transr, char uplo, - lapack_int n, const float* ap, float* arf ); -lapack_int LAPACKE_dtpttf_work( int matrix_layout, char transr, char uplo, - lapack_int n, const double* ap, double* arf ); -lapack_int LAPACKE_ctpttf_work( int matrix_layout, char transr, char uplo, - lapack_int n, const lapack_complex_float* ap, - lapack_complex_float* arf ); -lapack_int LAPACKE_ztpttf_work( int matrix_layout, char transr, char uplo, - lapack_int n, const lapack_complex_double* ap, - lapack_complex_double* arf ); - -lapack_int LAPACKE_stpttr_work( int matrix_layout, char uplo, lapack_int n, - const float* ap, float* a, lapack_int lda ); -lapack_int LAPACKE_dtpttr_work( int matrix_layout, char uplo, lapack_int n, - const double* ap, double* a, lapack_int lda ); -lapack_int LAPACKE_ctpttr_work( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float* ap, - lapack_complex_float* a, lapack_int lda ); -lapack_int LAPACKE_ztpttr_work( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double* ap, - lapack_complex_double* a, lapack_int lda ); - -lapack_int LAPACKE_strcon_work( int matrix_layout, char norm, char uplo, - char diag, lapack_int n, const float* a, - lapack_int lda, float* rcond, float* work, - lapack_int* iwork ); -lapack_int LAPACKE_dtrcon_work( int matrix_layout, char norm, char uplo, - char diag, lapack_int n, const double* a, - lapack_int lda, double* rcond, double* work, - lapack_int* iwork ); -lapack_int LAPACKE_ctrcon_work( int matrix_layout, char norm, char uplo, - char diag, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - float* rcond, lapack_complex_float* work, - float* rwork ); -lapack_int LAPACKE_ztrcon_work( int matrix_layout, char norm, char uplo, - char diag, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - double* rcond, lapack_complex_double* work, - double* rwork ); - -lapack_int LAPACKE_strevc_work( int matrix_layout, char side, char howmny, - lapack_logical* select, lapack_int n, - const float* t, lapack_int ldt, float* vl, - lapack_int ldvl, float* vr, lapack_int ldvr, - lapack_int mm, lapack_int* m, float* work ); -lapack_int LAPACKE_dtrevc_work( int matrix_layout, char side, char howmny, - lapack_logical* select, lapack_int n, - const double* t, lapack_int ldt, double* vl, - lapack_int ldvl, double* vr, lapack_int ldvr, - lapack_int mm, lapack_int* m, double* work ); -lapack_int LAPACKE_ctrevc_work( int matrix_layout, char side, char howmny, - const lapack_logical* select, lapack_int n, - lapack_complex_float* t, lapack_int ldt, - lapack_complex_float* vl, lapack_int ldvl, - lapack_complex_float* vr, lapack_int ldvr, - lapack_int mm, lapack_int* m, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_ztrevc_work( int matrix_layout, char side, char howmny, - const lapack_logical* select, lapack_int n, - lapack_complex_double* t, lapack_int ldt, - lapack_complex_double* vl, lapack_int ldvl, - lapack_complex_double* vr, lapack_int ldvr, - lapack_int mm, lapack_int* m, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_strexc_work( int matrix_layout, char compq, lapack_int n, - float* t, lapack_int ldt, float* q, - lapack_int ldq, lapack_int* ifst, - lapack_int* ilst, float* work ); -lapack_int LAPACKE_dtrexc_work( int matrix_layout, char compq, lapack_int n, - double* t, lapack_int ldt, double* q, - lapack_int ldq, lapack_int* ifst, - lapack_int* ilst, double* work ); -lapack_int LAPACKE_ctrexc_work( int matrix_layout, char compq, lapack_int n, - lapack_complex_float* t, lapack_int ldt, - lapack_complex_float* q, lapack_int ldq, - lapack_int ifst, lapack_int ilst ); -lapack_int LAPACKE_ztrexc_work( int matrix_layout, char compq, lapack_int n, - lapack_complex_double* t, lapack_int ldt, - lapack_complex_double* q, lapack_int ldq, - lapack_int ifst, lapack_int ilst ); - -lapack_int LAPACKE_strrfs_work( int matrix_layout, char uplo, char trans, - char diag, lapack_int n, lapack_int nrhs, - const float* a, lapack_int lda, const float* b, - lapack_int ldb, const float* x, lapack_int ldx, - float* ferr, float* berr, float* work, - lapack_int* iwork ); -lapack_int LAPACKE_dtrrfs_work( int matrix_layout, char uplo, char trans, - char diag, lapack_int n, lapack_int nrhs, - const double* a, lapack_int lda, - const double* b, lapack_int ldb, - const double* x, lapack_int ldx, double* ferr, - double* berr, double* work, lapack_int* iwork ); -lapack_int LAPACKE_ctrrfs_work( int matrix_layout, char uplo, char trans, - char diag, lapack_int n, lapack_int nrhs, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* b, lapack_int ldb, - const lapack_complex_float* x, lapack_int ldx, - float* ferr, float* berr, - lapack_complex_float* work, float* rwork ); -lapack_int LAPACKE_ztrrfs_work( int matrix_layout, char uplo, char trans, - char diag, lapack_int n, lapack_int nrhs, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* b, lapack_int ldb, - const lapack_complex_double* x, lapack_int ldx, - double* ferr, double* berr, - lapack_complex_double* work, double* rwork ); - -lapack_int LAPACKE_strsen_work( int matrix_layout, char job, char compq, - const lapack_logical* select, lapack_int n, - float* t, lapack_int ldt, float* q, - lapack_int ldq, float* wr, float* wi, - lapack_int* m, float* s, float* sep, - float* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork ); -lapack_int LAPACKE_dtrsen_work( int matrix_layout, char job, char compq, - const lapack_logical* select, lapack_int n, - double* t, lapack_int ldt, double* q, - lapack_int ldq, double* wr, double* wi, - lapack_int* m, double* s, double* sep, - double* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork ); -lapack_int LAPACKE_ctrsen_work( int matrix_layout, char job, char compq, - const lapack_logical* select, lapack_int n, - lapack_complex_float* t, lapack_int ldt, - lapack_complex_float* q, lapack_int ldq, - lapack_complex_float* w, lapack_int* m, - float* s, float* sep, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_ztrsen_work( int matrix_layout, char job, char compq, - const lapack_logical* select, lapack_int n, - lapack_complex_double* t, lapack_int ldt, - lapack_complex_double* q, lapack_int ldq, - lapack_complex_double* w, lapack_int* m, - double* s, double* sep, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_strsna_work( int matrix_layout, char job, char howmny, - const lapack_logical* select, lapack_int n, - const float* t, lapack_int ldt, const float* vl, - lapack_int ldvl, const float* vr, - lapack_int ldvr, float* s, float* sep, - lapack_int mm, lapack_int* m, float* work, - lapack_int ldwork, lapack_int* iwork ); -lapack_int LAPACKE_dtrsna_work( int matrix_layout, char job, char howmny, - const lapack_logical* select, lapack_int n, - const double* t, lapack_int ldt, - const double* vl, lapack_int ldvl, - const double* vr, lapack_int ldvr, double* s, - double* sep, lapack_int mm, lapack_int* m, - double* work, lapack_int ldwork, - lapack_int* iwork ); -lapack_int LAPACKE_ctrsna_work( int matrix_layout, char job, char howmny, - const lapack_logical* select, lapack_int n, - const lapack_complex_float* t, lapack_int ldt, - const lapack_complex_float* vl, lapack_int ldvl, - const lapack_complex_float* vr, lapack_int ldvr, - float* s, float* sep, lapack_int mm, - lapack_int* m, lapack_complex_float* work, - lapack_int ldwork, float* rwork ); -lapack_int LAPACKE_ztrsna_work( int matrix_layout, char job, char howmny, - const lapack_logical* select, lapack_int n, - const lapack_complex_double* t, lapack_int ldt, - const lapack_complex_double* vl, - lapack_int ldvl, - const lapack_complex_double* vr, - lapack_int ldvr, double* s, double* sep, - lapack_int mm, lapack_int* m, - lapack_complex_double* work, lapack_int ldwork, - double* rwork ); - -lapack_int LAPACKE_strsyl_work( int matrix_layout, char trana, char tranb, - lapack_int isgn, lapack_int m, lapack_int n, - const float* a, lapack_int lda, const float* b, - lapack_int ldb, float* c, lapack_int ldc, - float* scale ); -lapack_int LAPACKE_dtrsyl_work( int matrix_layout, char trana, char tranb, - lapack_int isgn, lapack_int m, lapack_int n, - const double* a, lapack_int lda, - const double* b, lapack_int ldb, double* c, - lapack_int ldc, double* scale ); -lapack_int LAPACKE_ctrsyl_work( int matrix_layout, char trana, char tranb, - lapack_int isgn, lapack_int m, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* c, lapack_int ldc, - float* scale ); -lapack_int LAPACKE_ztrsyl_work( int matrix_layout, char trana, char tranb, - lapack_int isgn, lapack_int m, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* c, lapack_int ldc, - double* scale ); - -lapack_int LAPACKE_strtri_work( int matrix_layout, char uplo, char diag, - lapack_int n, float* a, lapack_int lda ); -lapack_int LAPACKE_dtrtri_work( int matrix_layout, char uplo, char diag, - lapack_int n, double* a, lapack_int lda ); -lapack_int LAPACKE_ctrtri_work( int matrix_layout, char uplo, char diag, - lapack_int n, lapack_complex_float* a, - lapack_int lda ); -lapack_int LAPACKE_ztrtri_work( int matrix_layout, char uplo, char diag, - lapack_int n, lapack_complex_double* a, - lapack_int lda ); - -lapack_int LAPACKE_strtrs_work( int matrix_layout, char uplo, char trans, - char diag, lapack_int n, lapack_int nrhs, - const float* a, lapack_int lda, float* b, - lapack_int ldb ); -lapack_int LAPACKE_dtrtrs_work( int matrix_layout, char uplo, char trans, - char diag, lapack_int n, lapack_int nrhs, - const double* a, lapack_int lda, double* b, - lapack_int ldb ); -lapack_int LAPACKE_ctrtrs_work( int matrix_layout, char uplo, char trans, - char diag, lapack_int n, lapack_int nrhs, - const lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_ztrtrs_work( int matrix_layout, char uplo, char trans, - char diag, lapack_int n, lapack_int nrhs, - const lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_strttf_work( int matrix_layout, char transr, char uplo, - lapack_int n, const float* a, lapack_int lda, - float* arf ); -lapack_int LAPACKE_dtrttf_work( int matrix_layout, char transr, char uplo, - lapack_int n, const double* a, lapack_int lda, - double* arf ); -lapack_int LAPACKE_ctrttf_work( int matrix_layout, char transr, char uplo, - lapack_int n, const lapack_complex_float* a, - lapack_int lda, lapack_complex_float* arf ); -lapack_int LAPACKE_ztrttf_work( int matrix_layout, char transr, char uplo, - lapack_int n, const lapack_complex_double* a, - lapack_int lda, lapack_complex_double* arf ); - -lapack_int LAPACKE_strttp_work( int matrix_layout, char uplo, lapack_int n, - const float* a, lapack_int lda, float* ap ); -lapack_int LAPACKE_dtrttp_work( int matrix_layout, char uplo, lapack_int n, - const double* a, lapack_int lda, double* ap ); -lapack_int LAPACKE_ctrttp_work( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - lapack_complex_float* ap ); -lapack_int LAPACKE_ztrttp_work( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - lapack_complex_double* ap ); - -lapack_int LAPACKE_stzrzf_work( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, float* tau, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dtzrzf_work( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, double* tau, - double* work, lapack_int lwork ); -lapack_int LAPACKE_ctzrzf_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* tau, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_ztzrzf_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* tau, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_cungbr_work( int matrix_layout, char vect, lapack_int m, - lapack_int n, lapack_int k, - lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* tau, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zungbr_work( int matrix_layout, char vect, lapack_int m, - lapack_int n, lapack_int k, - lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* tau, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_cunghr_work( int matrix_layout, lapack_int n, lapack_int ilo, - lapack_int ihi, lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* tau, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zunghr_work( int matrix_layout, lapack_int n, lapack_int ilo, - lapack_int ihi, lapack_complex_double* a, - lapack_int lda, - const lapack_complex_double* tau, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_cunglq_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* tau, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zunglq_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, lapack_complex_double* a, - lapack_int lda, - const lapack_complex_double* tau, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_cungql_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* tau, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zungql_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, lapack_complex_double* a, - lapack_int lda, - const lapack_complex_double* tau, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_cungqr_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* tau, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zungqr_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, lapack_complex_double* a, - lapack_int lda, - const lapack_complex_double* tau, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_cungrq_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* tau, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zungrq_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int k, lapack_complex_double* a, - lapack_int lda, - const lapack_complex_double* tau, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_cungtr_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* tau, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zungtr_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* tau, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_cunmbr_work( int matrix_layout, char vect, char side, - char trans, lapack_int m, lapack_int n, - lapack_int k, const lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* tau, - lapack_complex_float* c, lapack_int ldc, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zunmbr_work( int matrix_layout, char vect, char side, - char trans, lapack_int m, lapack_int n, - lapack_int k, const lapack_complex_double* a, - lapack_int lda, - const lapack_complex_double* tau, - lapack_complex_double* c, lapack_int ldc, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_cunmhr_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int ilo, - lapack_int ihi, const lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* tau, - lapack_complex_float* c, lapack_int ldc, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zunmhr_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int ilo, - lapack_int ihi, const lapack_complex_double* a, - lapack_int lda, - const lapack_complex_double* tau, - lapack_complex_double* c, lapack_int ldc, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_cunmlq_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* tau, - lapack_complex_float* c, lapack_int ldc, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zunmlq_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* tau, - lapack_complex_double* c, lapack_int ldc, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_cunmql_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* tau, - lapack_complex_float* c, lapack_int ldc, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zunmql_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* tau, - lapack_complex_double* c, lapack_int ldc, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_cunmqr_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* tau, - lapack_complex_float* c, lapack_int ldc, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zunmqr_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* tau, - lapack_complex_double* c, lapack_int ldc, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_cunmrq_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* tau, - lapack_complex_float* c, lapack_int ldc, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zunmrq_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* tau, - lapack_complex_double* c, lapack_int ldc, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_cunmrz_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - lapack_int l, const lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* tau, - lapack_complex_float* c, lapack_int ldc, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zunmrz_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - lapack_int l, const lapack_complex_double* a, - lapack_int lda, - const lapack_complex_double* tau, - lapack_complex_double* c, lapack_int ldc, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_cunmtr_work( int matrix_layout, char side, char uplo, - char trans, lapack_int m, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* tau, - lapack_complex_float* c, lapack_int ldc, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zunmtr_work( int matrix_layout, char side, char uplo, - char trans, lapack_int m, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* tau, - lapack_complex_double* c, lapack_int ldc, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_cupgtr_work( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float* ap, - const lapack_complex_float* tau, - lapack_complex_float* q, lapack_int ldq, - lapack_complex_float* work ); -lapack_int LAPACKE_zupgtr_work( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double* ap, - const lapack_complex_double* tau, - lapack_complex_double* q, lapack_int ldq, - lapack_complex_double* work ); - -lapack_int LAPACKE_cupmtr_work( int matrix_layout, char side, char uplo, - char trans, lapack_int m, lapack_int n, - const lapack_complex_float* ap, - const lapack_complex_float* tau, - lapack_complex_float* c, lapack_int ldc, - lapack_complex_float* work ); -lapack_int LAPACKE_zupmtr_work( int matrix_layout, char side, char uplo, - char trans, lapack_int m, lapack_int n, - const lapack_complex_double* ap, - const lapack_complex_double* tau, - lapack_complex_double* c, lapack_int ldc, - lapack_complex_double* work ); - -lapack_int LAPACKE_claghe( int matrix_layout, lapack_int n, lapack_int k, - const float* d, lapack_complex_float* a, - lapack_int lda, lapack_int* iseed ); -lapack_int LAPACKE_zlaghe( int matrix_layout, lapack_int n, lapack_int k, - const double* d, lapack_complex_double* a, - lapack_int lda, lapack_int* iseed ); - -lapack_int LAPACKE_slagsy( int matrix_layout, lapack_int n, lapack_int k, - const float* d, float* a, lapack_int lda, - lapack_int* iseed ); -lapack_int LAPACKE_dlagsy( int matrix_layout, lapack_int n, lapack_int k, - const double* d, double* a, lapack_int lda, - lapack_int* iseed ); -lapack_int LAPACKE_clagsy( int matrix_layout, lapack_int n, lapack_int k, - const float* d, lapack_complex_float* a, - lapack_int lda, lapack_int* iseed ); -lapack_int LAPACKE_zlagsy( int matrix_layout, lapack_int n, lapack_int k, - const double* d, lapack_complex_double* a, - lapack_int lda, lapack_int* iseed ); - -lapack_int LAPACKE_slapmr( int matrix_layout, lapack_logical forwrd, - lapack_int m, lapack_int n, float* x, lapack_int ldx, - lapack_int* k ); -lapack_int LAPACKE_dlapmr( int matrix_layout, lapack_logical forwrd, - lapack_int m, lapack_int n, double* x, - lapack_int ldx, lapack_int* k ); -lapack_int LAPACKE_clapmr( int matrix_layout, lapack_logical forwrd, - lapack_int m, lapack_int n, lapack_complex_float* x, - lapack_int ldx, lapack_int* k ); -lapack_int LAPACKE_zlapmr( int matrix_layout, lapack_logical forwrd, - lapack_int m, lapack_int n, lapack_complex_double* x, - lapack_int ldx, lapack_int* k ); - -lapack_int LAPACKE_slapmt( int matrix_layout, lapack_logical forwrd, - lapack_int m, lapack_int n, float* x, lapack_int ldx, - lapack_int* k ); -lapack_int LAPACKE_dlapmt( int matrix_layout, lapack_logical forwrd, - lapack_int m, lapack_int n, double* x, - lapack_int ldx, lapack_int* k ); -lapack_int LAPACKE_clapmt( int matrix_layout, lapack_logical forwrd, - lapack_int m, lapack_int n, lapack_complex_float* x, - lapack_int ldx, lapack_int* k ); -lapack_int LAPACKE_zlapmt( int matrix_layout, lapack_logical forwrd, - lapack_int m, lapack_int n, lapack_complex_double* x, - lapack_int ldx, lapack_int* k ); - -float LAPACKE_slapy2( float x, float y ); -double LAPACKE_dlapy2( double x, double y ); - -float LAPACKE_slapy3( float x, float y, float z ); -double LAPACKE_dlapy3( double x, double y, double z ); - -lapack_int LAPACKE_slartgp( float f, float g, float* cs, float* sn, float* r ); -lapack_int LAPACKE_dlartgp( double f, double g, double* cs, double* sn, - double* r ); - -lapack_int LAPACKE_slartgs( float x, float y, float sigma, float* cs, - float* sn ); -lapack_int LAPACKE_dlartgs( double x, double y, double sigma, double* cs, - double* sn ); - - -//LAPACK 3.3.0 -lapack_int LAPACKE_cbbcsd( int matrix_layout, char jobu1, char jobu2, - char jobv1t, char jobv2t, char trans, lapack_int m, - lapack_int p, lapack_int q, float* theta, float* phi, - lapack_complex_float* u1, lapack_int ldu1, - lapack_complex_float* u2, lapack_int ldu2, - lapack_complex_float* v1t, lapack_int ldv1t, - lapack_complex_float* v2t, lapack_int ldv2t, - float* b11d, float* b11e, float* b12d, float* b12e, - float* b21d, float* b21e, float* b22d, float* b22e ); -lapack_int LAPACKE_cbbcsd_work( int matrix_layout, char jobu1, char jobu2, - char jobv1t, char jobv2t, char trans, - lapack_int m, lapack_int p, lapack_int q, - float* theta, float* phi, - lapack_complex_float* u1, lapack_int ldu1, - lapack_complex_float* u2, lapack_int ldu2, - lapack_complex_float* v1t, lapack_int ldv1t, - lapack_complex_float* v2t, lapack_int ldv2t, - float* b11d, float* b11e, float* b12d, - float* b12e, float* b21d, float* b21e, - float* b22d, float* b22e, float* rwork, - lapack_int lrwork ); -lapack_int LAPACKE_cheswapr( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int i1, lapack_int i2 ); -lapack_int LAPACKE_cheswapr_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int i1, lapack_int i2 ); -lapack_int LAPACKE_chetri2( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - const lapack_int* ipiv ); -lapack_int LAPACKE_chetri2_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - const lapack_int* ipiv, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_chetri2x( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - const lapack_int* ipiv, lapack_int nb ); -lapack_int LAPACKE_chetri2x_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - const lapack_int* ipiv, - lapack_complex_float* work, lapack_int nb ); -lapack_int LAPACKE_chetrs2( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_chetrs2_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* work ); -lapack_int LAPACKE_csyconv( int matrix_layout, char uplo, char way, lapack_int n, - lapack_complex_float* a, lapack_int lda, - const lapack_int* ipiv, lapack_complex_float* e ); -lapack_int LAPACKE_csyconv_work( int matrix_layout, char uplo, char way, - lapack_int n, lapack_complex_float* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_float* e ); -lapack_int LAPACKE_csyswapr( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int i1, lapack_int i2 ); -lapack_int LAPACKE_csyswapr_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int i1, lapack_int i2 ); -lapack_int LAPACKE_csytri2( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - const lapack_int* ipiv ); -lapack_int LAPACKE_csytri2_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - const lapack_int* ipiv, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_csytri2x( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - const lapack_int* ipiv, lapack_int nb ); -lapack_int LAPACKE_csytri2x_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - const lapack_int* ipiv, - lapack_complex_float* work, lapack_int nb ); -lapack_int LAPACKE_csytrs2( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_csytrs2_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* work ); -lapack_int LAPACKE_cunbdb( int matrix_layout, char trans, char signs, - lapack_int m, lapack_int p, lapack_int q, - lapack_complex_float* x11, lapack_int ldx11, - lapack_complex_float* x12, lapack_int ldx12, - lapack_complex_float* x21, lapack_int ldx21, - lapack_complex_float* x22, lapack_int ldx22, - float* theta, float* phi, - lapack_complex_float* taup1, - lapack_complex_float* taup2, - lapack_complex_float* tauq1, - lapack_complex_float* tauq2 ); -lapack_int LAPACKE_cunbdb_work( int matrix_layout, char trans, char signs, - lapack_int m, lapack_int p, lapack_int q, - lapack_complex_float* x11, lapack_int ldx11, - lapack_complex_float* x12, lapack_int ldx12, - lapack_complex_float* x21, lapack_int ldx21, - lapack_complex_float* x22, lapack_int ldx22, - float* theta, float* phi, - lapack_complex_float* taup1, - lapack_complex_float* taup2, - lapack_complex_float* tauq1, - lapack_complex_float* tauq2, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_cuncsd( int matrix_layout, char jobu1, char jobu2, - char jobv1t, char jobv2t, char trans, char signs, - lapack_int m, lapack_int p, lapack_int q, - lapack_complex_float* x11, lapack_int ldx11, - lapack_complex_float* x12, lapack_int ldx12, - lapack_complex_float* x21, lapack_int ldx21, - lapack_complex_float* x22, lapack_int ldx22, - float* theta, lapack_complex_float* u1, - lapack_int ldu1, lapack_complex_float* u2, - lapack_int ldu2, lapack_complex_float* v1t, - lapack_int ldv1t, lapack_complex_float* v2t, - lapack_int ldv2t ); -lapack_int LAPACKE_cuncsd_work( int matrix_layout, char jobu1, char jobu2, - char jobv1t, char jobv2t, char trans, - char signs, lapack_int m, lapack_int p, - lapack_int q, lapack_complex_float* x11, - lapack_int ldx11, lapack_complex_float* x12, - lapack_int ldx12, lapack_complex_float* x21, - lapack_int ldx21, lapack_complex_float* x22, - lapack_int ldx22, float* theta, - lapack_complex_float* u1, lapack_int ldu1, - lapack_complex_float* u2, lapack_int ldu2, - lapack_complex_float* v1t, lapack_int ldv1t, - lapack_complex_float* v2t, lapack_int ldv2t, - lapack_complex_float* work, lapack_int lwork, - float* rwork, lapack_int lrwork, - lapack_int* iwork ); -lapack_int LAPACKE_cuncsd2by1( int matrix_layout, char jobu1, char jobu2, - char jobv1t, lapack_int m, lapack_int p, lapack_int q, - lapack_complex_float* x11, lapack_int ldx11, - lapack_complex_float* x21, lapack_int ldx21, - float* theta, lapack_complex_float* u1, - lapack_int ldu1, lapack_complex_float* u2, - lapack_int ldu2, lapack_complex_float* v1t, lapack_int ldv1t ); -lapack_int LAPACKE_cuncsd2by1_work( int matrix_layout, char jobu1, char jobu2, - char jobv1t, lapack_int m, lapack_int p, - lapack_int q, lapack_complex_float* x11, lapack_int ldx11, - lapack_complex_float* x21, lapack_int ldx21, - float* theta, lapack_complex_float* u1, - lapack_int ldu1, lapack_complex_float* u2, - lapack_int ldu2, lapack_complex_float* v1t, - lapack_int ldv1t, lapack_complex_float* work, - lapack_int lwork, float* rwork, lapack_int lrwork, - lapack_int* iwork ); -lapack_int LAPACKE_dbbcsd( int matrix_layout, char jobu1, char jobu2, - char jobv1t, char jobv2t, char trans, lapack_int m, - lapack_int p, lapack_int q, double* theta, - double* phi, double* u1, lapack_int ldu1, double* u2, - lapack_int ldu2, double* v1t, lapack_int ldv1t, - double* v2t, lapack_int ldv2t, double* b11d, - double* b11e, double* b12d, double* b12e, - double* b21d, double* b21e, double* b22d, - double* b22e ); -lapack_int LAPACKE_dbbcsd_work( int matrix_layout, char jobu1, char jobu2, - char jobv1t, char jobv2t, char trans, - lapack_int m, lapack_int p, lapack_int q, - double* theta, double* phi, double* u1, - lapack_int ldu1, double* u2, lapack_int ldu2, - double* v1t, lapack_int ldv1t, double* v2t, - lapack_int ldv2t, double* b11d, double* b11e, - double* b12d, double* b12e, double* b21d, - double* b21e, double* b22d, double* b22e, - double* work, lapack_int lwork ); -lapack_int LAPACKE_dorbdb( int matrix_layout, char trans, char signs, - lapack_int m, lapack_int p, lapack_int q, - double* x11, lapack_int ldx11, double* x12, - lapack_int ldx12, double* x21, lapack_int ldx21, - double* x22, lapack_int ldx22, double* theta, - double* phi, double* taup1, double* taup2, - double* tauq1, double* tauq2 ); -lapack_int LAPACKE_dorbdb_work( int matrix_layout, char trans, char signs, - lapack_int m, lapack_int p, lapack_int q, - double* x11, lapack_int ldx11, double* x12, - lapack_int ldx12, double* x21, lapack_int ldx21, - double* x22, lapack_int ldx22, double* theta, - double* phi, double* taup1, double* taup2, - double* tauq1, double* tauq2, double* work, - lapack_int lwork ); -lapack_int LAPACKE_dorcsd( int matrix_layout, char jobu1, char jobu2, - char jobv1t, char jobv2t, char trans, char signs, - lapack_int m, lapack_int p, lapack_int q, - double* x11, lapack_int ldx11, double* x12, - lapack_int ldx12, double* x21, lapack_int ldx21, - double* x22, lapack_int ldx22, double* theta, - double* u1, lapack_int ldu1, double* u2, - lapack_int ldu2, double* v1t, lapack_int ldv1t, - double* v2t, lapack_int ldv2t ); -lapack_int LAPACKE_dorcsd_work( int matrix_layout, char jobu1, char jobu2, - char jobv1t, char jobv2t, char trans, - char signs, lapack_int m, lapack_int p, - lapack_int q, double* x11, lapack_int ldx11, - double* x12, lapack_int ldx12, double* x21, - lapack_int ldx21, double* x22, lapack_int ldx22, - double* theta, double* u1, lapack_int ldu1, - double* u2, lapack_int ldu2, double* v1t, - lapack_int ldv1t, double* v2t, lapack_int ldv2t, - double* work, lapack_int lwork, - lapack_int* iwork ); -lapack_int LAPACKE_dorcsd2by1( int matrix_layout, char jobu1, char jobu2, - char jobv1t, lapack_int m, lapack_int p, lapack_int q, - double* x11, lapack_int ldx11, double* x21, lapack_int ldx21, - double* theta, double* u1, lapack_int ldu1, double* u2, - lapack_int ldu2, double* v1t, lapack_int ldv1t); -lapack_int LAPACKE_dorcsd2by1_work( int matrix_layout, char jobu1, char jobu2, - char jobv1t, lapack_int m, lapack_int p, lapack_int q, - double* x11, lapack_int ldx11, double* x21, lapack_int ldx21, - double* theta, double* u1, lapack_int ldu1, double* u2, - lapack_int ldu2, double* v1t, lapack_int ldv1t, - double* work, lapack_int lwork, lapack_int* iwork ); -lapack_int LAPACKE_dsyconv( int matrix_layout, char uplo, char way, lapack_int n, - double* a, lapack_int lda, const lapack_int* ipiv, double* e); -lapack_int LAPACKE_dsyconv_work( int matrix_layout, char uplo, char way, - lapack_int n, double* a, lapack_int lda, - const lapack_int* ipiv, double* e ); -lapack_int LAPACKE_dsyswapr( int matrix_layout, char uplo, lapack_int n, - double* a, lapack_int lda, lapack_int i1, - lapack_int i2 ); -lapack_int LAPACKE_dsyswapr_work( int matrix_layout, char uplo, lapack_int n, - double* a, lapack_int lda, lapack_int i1, - lapack_int i2 ); -lapack_int LAPACKE_dsytri2( int matrix_layout, char uplo, lapack_int n, - double* a, lapack_int lda, const lapack_int* ipiv ); -lapack_int LAPACKE_dsytri2_work( int matrix_layout, char uplo, lapack_int n, - double* a, lapack_int lda, - const lapack_int* ipiv, - double* work, lapack_int lwork ); -lapack_int LAPACKE_dsytri2x( int matrix_layout, char uplo, lapack_int n, - double* a, lapack_int lda, const lapack_int* ipiv, - lapack_int nb ); -lapack_int LAPACKE_dsytri2x_work( int matrix_layout, char uplo, lapack_int n, - double* a, lapack_int lda, - const lapack_int* ipiv, double* work, - lapack_int nb ); -lapack_int LAPACKE_dsytrs2( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const double* a, lapack_int lda, - const lapack_int* ipiv, double* b, lapack_int ldb ); -lapack_int LAPACKE_dsytrs2_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const double* a, - lapack_int lda, const lapack_int* ipiv, - double* b, lapack_int ldb, double* work ); -lapack_int LAPACKE_sbbcsd( int matrix_layout, char jobu1, char jobu2, - char jobv1t, char jobv2t, char trans, lapack_int m, - lapack_int p, lapack_int q, float* theta, float* phi, - float* u1, lapack_int ldu1, float* u2, - lapack_int ldu2, float* v1t, lapack_int ldv1t, - float* v2t, lapack_int ldv2t, float* b11d, - float* b11e, float* b12d, float* b12e, float* b21d, - float* b21e, float* b22d, float* b22e ); -lapack_int LAPACKE_sbbcsd_work( int matrix_layout, char jobu1, char jobu2, - char jobv1t, char jobv2t, char trans, - lapack_int m, lapack_int p, lapack_int q, - float* theta, float* phi, float* u1, - lapack_int ldu1, float* u2, lapack_int ldu2, - float* v1t, lapack_int ldv1t, float* v2t, - lapack_int ldv2t, float* b11d, float* b11e, - float* b12d, float* b12e, float* b21d, - float* b21e, float* b22d, float* b22e, - float* work, lapack_int lwork ); -lapack_int LAPACKE_sorbdb( int matrix_layout, char trans, char signs, - lapack_int m, lapack_int p, lapack_int q, float* x11, - lapack_int ldx11, float* x12, lapack_int ldx12, - float* x21, lapack_int ldx21, float* x22, - lapack_int ldx22, float* theta, float* phi, - float* taup1, float* taup2, float* tauq1, - float* tauq2 ); -lapack_int LAPACKE_sorbdb_work( int matrix_layout, char trans, char signs, - lapack_int m, lapack_int p, lapack_int q, - float* x11, lapack_int ldx11, float* x12, - lapack_int ldx12, float* x21, lapack_int ldx21, - float* x22, lapack_int ldx22, float* theta, - float* phi, float* taup1, float* taup2, - float* tauq1, float* tauq2, float* work, - lapack_int lwork ); -lapack_int LAPACKE_sorcsd( int matrix_layout, char jobu1, char jobu2, - char jobv1t, char jobv2t, char trans, char signs, - lapack_int m, lapack_int p, lapack_int q, float* x11, - lapack_int ldx11, float* x12, lapack_int ldx12, - float* x21, lapack_int ldx21, float* x22, - lapack_int ldx22, float* theta, float* u1, - lapack_int ldu1, float* u2, lapack_int ldu2, - float* v1t, lapack_int ldv1t, float* v2t, - lapack_int ldv2t ); -lapack_int LAPACKE_sorcsd_work( int matrix_layout, char jobu1, char jobu2, - char jobv1t, char jobv2t, char trans, - char signs, lapack_int m, lapack_int p, - lapack_int q, float* x11, lapack_int ldx11, - float* x12, lapack_int ldx12, float* x21, - lapack_int ldx21, float* x22, lapack_int ldx22, - float* theta, float* u1, lapack_int ldu1, - float* u2, lapack_int ldu2, float* v1t, - lapack_int ldv1t, float* v2t, lapack_int ldv2t, - float* work, lapack_int lwork, - lapack_int* iwork ); -lapack_int LAPACKE_sorcsd2by1( int matrix_layout, char jobu1, char jobu2, - char jobv1t, lapack_int m, lapack_int p, lapack_int q, - float* x11, lapack_int ldx11, float* x21, lapack_int ldx21, - float* theta, float* u1, lapack_int ldu1, float* u2, - lapack_int ldu2, float* v1t, lapack_int ldv1t); -lapack_int LAPACKE_sorcsd2by1_work( int matrix_layout, char jobu1, char jobu2, - char jobv1t, lapack_int m, lapack_int p, lapack_int q, - float* x11, lapack_int ldx11, float* x21, lapack_int ldx21, - float* theta, float* u1, lapack_int ldu1, float* u2, - lapack_int ldu2, float* v1t, lapack_int ldv1t, - float* work, lapack_int lwork, lapack_int* iwork ); -lapack_int LAPACKE_ssyconv( int matrix_layout, char uplo, char way, lapack_int n, - float* a, lapack_int lda, const lapack_int* ipiv, float* e ); -lapack_int LAPACKE_ssyconv_work( int matrix_layout, char uplo, char way, - lapack_int n, float* a, lapack_int lda, - const lapack_int* ipiv, float* e ); -lapack_int LAPACKE_ssyswapr( int matrix_layout, char uplo, lapack_int n, - float* a, lapack_int lda, lapack_int i1, - lapack_int i2 ); -lapack_int LAPACKE_ssyswapr_work( int matrix_layout, char uplo, lapack_int n, - float* a, lapack_int lda, lapack_int i1, - lapack_int i2 ); -lapack_int LAPACKE_ssytri2( int matrix_layout, char uplo, lapack_int n, float* a, - lapack_int lda, const lapack_int* ipiv ); -lapack_int LAPACKE_ssytri2_work( int matrix_layout, char uplo, lapack_int n, - float* a, lapack_int lda, - const lapack_int* ipiv, - float* work, lapack_int lwork ); -lapack_int LAPACKE_ssytri2x( int matrix_layout, char uplo, lapack_int n, - float* a, lapack_int lda, const lapack_int* ipiv, - lapack_int nb ); -lapack_int LAPACKE_ssytri2x_work( int matrix_layout, char uplo, lapack_int n, - float* a, lapack_int lda, - const lapack_int* ipiv, float* work, - lapack_int nb ); -lapack_int LAPACKE_ssytrs2( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const float* a, lapack_int lda, - const lapack_int* ipiv, float* b, lapack_int ldb ); -lapack_int LAPACKE_ssytrs2_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const float* a, - lapack_int lda, const lapack_int* ipiv, - float* b, lapack_int ldb, float* work ); -lapack_int LAPACKE_zbbcsd( int matrix_layout, char jobu1, char jobu2, - char jobv1t, char jobv2t, char trans, lapack_int m, - lapack_int p, lapack_int q, double* theta, - double* phi, lapack_complex_double* u1, - lapack_int ldu1, lapack_complex_double* u2, - lapack_int ldu2, lapack_complex_double* v1t, - lapack_int ldv1t, lapack_complex_double* v2t, - lapack_int ldv2t, double* b11d, double* b11e, - double* b12d, double* b12e, double* b21d, - double* b21e, double* b22d, double* b22e ); -lapack_int LAPACKE_zbbcsd_work( int matrix_layout, char jobu1, char jobu2, - char jobv1t, char jobv2t, char trans, - lapack_int m, lapack_int p, lapack_int q, - double* theta, double* phi, - lapack_complex_double* u1, lapack_int ldu1, - lapack_complex_double* u2, lapack_int ldu2, - lapack_complex_double* v1t, lapack_int ldv1t, - lapack_complex_double* v2t, lapack_int ldv2t, - double* b11d, double* b11e, double* b12d, - double* b12e, double* b21d, double* b21e, - double* b22d, double* b22e, double* rwork, - lapack_int lrwork ); -lapack_int LAPACKE_zheswapr( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int i1, lapack_int i2 ); -lapack_int LAPACKE_zheswapr_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int i1, lapack_int i2 ); -lapack_int LAPACKE_zhetri2( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - const lapack_int* ipiv ); -lapack_int LAPACKE_zhetri2_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - const lapack_int* ipiv, - lapack_complex_double* work, lapack_int lwork ); -lapack_int LAPACKE_zhetri2x( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - const lapack_int* ipiv, lapack_int nb ); -lapack_int LAPACKE_zhetri2x_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - const lapack_int* ipiv, - lapack_complex_double* work, lapack_int nb ); -lapack_int LAPACKE_zhetrs2( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb ); -lapack_int LAPACKE_zhetrs2_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* work ); -lapack_int LAPACKE_zsyconv( int matrix_layout, char uplo, char way, lapack_int n, - lapack_complex_double* a, lapack_int lda, - const lapack_int* ipiv, lapack_complex_double* e ); -lapack_int LAPACKE_zsyconv_work( int matrix_layout, char uplo, char way, - lapack_int n, lapack_complex_double* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_double* e ); -lapack_int LAPACKE_zsyswapr( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int i1, lapack_int i2 ); -lapack_int LAPACKE_zsyswapr_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int i1, lapack_int i2 ); -lapack_int LAPACKE_zsytri2( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - const lapack_int* ipiv ); -lapack_int LAPACKE_zsytri2_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - const lapack_int* ipiv, - lapack_complex_double* work, lapack_int lwork ); -lapack_int LAPACKE_zsytri2x( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - const lapack_int* ipiv, lapack_int nb ); -lapack_int LAPACKE_zsytri2x_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - const lapack_int* ipiv, - lapack_complex_double* work, lapack_int nb ); -lapack_int LAPACKE_zsytrs2( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb ); -lapack_int LAPACKE_zsytrs2_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* work ); -lapack_int LAPACKE_zunbdb( int matrix_layout, char trans, char signs, - lapack_int m, lapack_int p, lapack_int q, - lapack_complex_double* x11, lapack_int ldx11, - lapack_complex_double* x12, lapack_int ldx12, - lapack_complex_double* x21, lapack_int ldx21, - lapack_complex_double* x22, lapack_int ldx22, - double* theta, double* phi, - lapack_complex_double* taup1, - lapack_complex_double* taup2, - lapack_complex_double* tauq1, - lapack_complex_double* tauq2 ); -lapack_int LAPACKE_zunbdb_work( int matrix_layout, char trans, char signs, - lapack_int m, lapack_int p, lapack_int q, - lapack_complex_double* x11, lapack_int ldx11, - lapack_complex_double* x12, lapack_int ldx12, - lapack_complex_double* x21, lapack_int ldx21, - lapack_complex_double* x22, lapack_int ldx22, - double* theta, double* phi, - lapack_complex_double* taup1, - lapack_complex_double* taup2, - lapack_complex_double* tauq1, - lapack_complex_double* tauq2, - lapack_complex_double* work, lapack_int lwork ); -lapack_int LAPACKE_zuncsd( int matrix_layout, char jobu1, char jobu2, - char jobv1t, char jobv2t, char trans, char signs, - lapack_int m, lapack_int p, lapack_int q, - lapack_complex_double* x11, lapack_int ldx11, - lapack_complex_double* x12, lapack_int ldx12, - lapack_complex_double* x21, lapack_int ldx21, - lapack_complex_double* x22, lapack_int ldx22, - double* theta, lapack_complex_double* u1, - lapack_int ldu1, lapack_complex_double* u2, - lapack_int ldu2, lapack_complex_double* v1t, - lapack_int ldv1t, lapack_complex_double* v2t, - lapack_int ldv2t ); -lapack_int LAPACKE_zuncsd_work( int matrix_layout, char jobu1, char jobu2, - char jobv1t, char jobv2t, char trans, - char signs, lapack_int m, lapack_int p, - lapack_int q, lapack_complex_double* x11, - lapack_int ldx11, lapack_complex_double* x12, - lapack_int ldx12, lapack_complex_double* x21, - lapack_int ldx21, lapack_complex_double* x22, - lapack_int ldx22, double* theta, - lapack_complex_double* u1, lapack_int ldu1, - lapack_complex_double* u2, lapack_int ldu2, - lapack_complex_double* v1t, lapack_int ldv1t, - lapack_complex_double* v2t, lapack_int ldv2t, - lapack_complex_double* work, lapack_int lwork, - double* rwork, lapack_int lrwork, - lapack_int* iwork ); -lapack_int LAPACKE_zuncsd2by1( int matrix_layout, char jobu1, char jobu2, - char jobv1t, lapack_int m, lapack_int p, lapack_int q, - lapack_complex_double* x11, lapack_int ldx11, - lapack_complex_double* x21, lapack_int ldx21, - double* theta, lapack_complex_double* u1, - lapack_int ldu1, lapack_complex_double* u2, - lapack_int ldu2, lapack_complex_double* v1t, lapack_int ldv1t ); -lapack_int LAPACKE_zuncsd2by1_work( int matrix_layout, char jobu1, char jobu2, - char jobv1t, lapack_int m, lapack_int p, - lapack_int q, lapack_complex_double* x11, lapack_int ldx11, - lapack_complex_double* x21, lapack_int ldx21, - double* theta, lapack_complex_double* u1, - lapack_int ldu1, lapack_complex_double* u2, - lapack_int ldu2, lapack_complex_double* v1t, - lapack_int ldv1t, lapack_complex_double* work, - lapack_int lwork, double* rwork, lapack_int lrwork, - lapack_int* iwork ); - -//LAPACK 3.4.0 -lapack_int LAPACKE_sgemqrt( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - lapack_int nb, const float* v, lapack_int ldv, - const float* t, lapack_int ldt, float* c, - lapack_int ldc ); -lapack_int LAPACKE_dgemqrt( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - lapack_int nb, const double* v, lapack_int ldv, - const double* t, lapack_int ldt, double* c, - lapack_int ldc ); -lapack_int LAPACKE_cgemqrt( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - lapack_int nb, const lapack_complex_float* v, - lapack_int ldv, const lapack_complex_float* t, - lapack_int ldt, lapack_complex_float* c, - lapack_int ldc ); -lapack_int LAPACKE_zgemqrt( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - lapack_int nb, const lapack_complex_double* v, - lapack_int ldv, const lapack_complex_double* t, - lapack_int ldt, lapack_complex_double* c, - lapack_int ldc ); - -lapack_int LAPACKE_sgeqrt( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nb, float* a, lapack_int lda, float* t, - lapack_int ldt ); -lapack_int LAPACKE_dgeqrt( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nb, double* a, lapack_int lda, double* t, - lapack_int ldt ); -lapack_int LAPACKE_cgeqrt( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nb, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* t, - lapack_int ldt ); -lapack_int LAPACKE_zgeqrt( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nb, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* t, - lapack_int ldt ); - -lapack_int LAPACKE_sgeqrt2( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, float* t, - lapack_int ldt ); -lapack_int LAPACKE_dgeqrt2( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, double* t, - lapack_int ldt ); -lapack_int LAPACKE_cgeqrt2( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* t, lapack_int ldt ); -lapack_int LAPACKE_zgeqrt2( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* t, lapack_int ldt ); - -lapack_int LAPACKE_sgeqrt3( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, float* t, - lapack_int ldt ); -lapack_int LAPACKE_dgeqrt3( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, double* t, - lapack_int ldt ); -lapack_int LAPACKE_cgeqrt3( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* t, lapack_int ldt ); -lapack_int LAPACKE_zgeqrt3( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* t, lapack_int ldt ); - -lapack_int LAPACKE_stpmqrt( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - lapack_int l, lapack_int nb, const float* v, - lapack_int ldv, const float* t, lapack_int ldt, - float* a, lapack_int lda, float* b, - lapack_int ldb ); -lapack_int LAPACKE_dtpmqrt( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - lapack_int l, lapack_int nb, const double* v, - lapack_int ldv, const double* t, lapack_int ldt, - double* a, lapack_int lda, double* b, - lapack_int ldb ); -lapack_int LAPACKE_ctpmqrt( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - lapack_int l, lapack_int nb, - const lapack_complex_float* v, lapack_int ldv, - const lapack_complex_float* t, lapack_int ldt, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_ztpmqrt( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - lapack_int l, lapack_int nb, - const lapack_complex_double* v, lapack_int ldv, - const lapack_complex_double* t, lapack_int ldt, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_stpqrt( int matrix_layout, lapack_int m, lapack_int n, - lapack_int l, lapack_int nb, float* a, - lapack_int lda, float* b, lapack_int ldb, float* t, - lapack_int ldt ); - -lapack_int LAPACKE_dtpqrt( int matrix_layout, lapack_int m, lapack_int n, - lapack_int l, lapack_int nb, double* a, - lapack_int lda, double* b, lapack_int ldb, double* t, - lapack_int ldt ); -lapack_int LAPACKE_ctpqrt( int matrix_layout, lapack_int m, lapack_int n, - lapack_int l, lapack_int nb, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* t, lapack_int ldt ); -lapack_int LAPACKE_ztpqrt( int matrix_layout, lapack_int m, lapack_int n, - lapack_int l, lapack_int nb, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* t, lapack_int ldt ); - -lapack_int LAPACKE_stpqrt2( int matrix_layout, - lapack_int m, lapack_int n, lapack_int l, - float* a, lapack_int lda, - float* b, lapack_int ldb, - float* t, lapack_int ldt ); -lapack_int LAPACKE_dtpqrt2( int matrix_layout, - lapack_int m, lapack_int n, lapack_int l, - double* a, lapack_int lda, - double* b, lapack_int ldb, - double* t, lapack_int ldt ); -lapack_int LAPACKE_ctpqrt2( int matrix_layout, - lapack_int m, lapack_int n, lapack_int l, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* t, lapack_int ldt ); -lapack_int LAPACKE_ztpqrt2( int matrix_layout, - lapack_int m, lapack_int n, lapack_int l, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* t, lapack_int ldt ); - -lapack_int LAPACKE_stprfb( int matrix_layout, char side, char trans, char direct, - char storev, lapack_int m, lapack_int n, - lapack_int k, lapack_int l, const float* v, - lapack_int ldv, const float* t, lapack_int ldt, - float* a, lapack_int lda, float* b, lapack_int ldb ); -lapack_int LAPACKE_dtprfb( int matrix_layout, char side, char trans, char direct, - char storev, lapack_int m, lapack_int n, - lapack_int k, lapack_int l, const double* v, - lapack_int ldv, const double* t, lapack_int ldt, - double* a, lapack_int lda, double* b, lapack_int ldb ); -lapack_int LAPACKE_ctprfb( int matrix_layout, char side, char trans, char direct, - char storev, lapack_int m, lapack_int n, - lapack_int k, lapack_int l, - const lapack_complex_float* v, lapack_int ldv, - const lapack_complex_float* t, lapack_int ldt, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_ztprfb( int matrix_layout, char side, char trans, char direct, - char storev, lapack_int m, lapack_int n, - lapack_int k, lapack_int l, - const lapack_complex_double* v, lapack_int ldv, - const lapack_complex_double* t, lapack_int ldt, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_sgemqrt_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - lapack_int nb, const float* v, lapack_int ldv, - const float* t, lapack_int ldt, float* c, - lapack_int ldc, float* work ); -lapack_int LAPACKE_dgemqrt_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - lapack_int nb, const double* v, lapack_int ldv, - const double* t, lapack_int ldt, double* c, - lapack_int ldc, double* work ); -lapack_int LAPACKE_cgemqrt_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - lapack_int nb, const lapack_complex_float* v, - lapack_int ldv, const lapack_complex_float* t, - lapack_int ldt, lapack_complex_float* c, - lapack_int ldc, lapack_complex_float* work ); -lapack_int LAPACKE_zgemqrt_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - lapack_int nb, const lapack_complex_double* v, - lapack_int ldv, const lapack_complex_double* t, - lapack_int ldt, lapack_complex_double* c, - lapack_int ldc, lapack_complex_double* work ); - -lapack_int LAPACKE_sgeqrt_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nb, float* a, lapack_int lda, - float* t, lapack_int ldt, float* work ); -lapack_int LAPACKE_dgeqrt_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nb, double* a, lapack_int lda, - double* t, lapack_int ldt, double* work ); -lapack_int LAPACKE_cgeqrt_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nb, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* t, - lapack_int ldt, lapack_complex_float* work ); -lapack_int LAPACKE_zgeqrt_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int nb, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* t, - lapack_int ldt, lapack_complex_double* work ); - -lapack_int LAPACKE_sgeqrt2_work( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, float* t, - lapack_int ldt ); -lapack_int LAPACKE_dgeqrt2_work( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, double* t, - lapack_int ldt ); -lapack_int LAPACKE_cgeqrt2_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* t, lapack_int ldt ); -lapack_int LAPACKE_zgeqrt2_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* t, lapack_int ldt ); - -lapack_int LAPACKE_sgeqrt3_work( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, float* t, - lapack_int ldt ); -lapack_int LAPACKE_dgeqrt3_work( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, double* t, - lapack_int ldt ); -lapack_int LAPACKE_cgeqrt3_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* t, lapack_int ldt ); -lapack_int LAPACKE_zgeqrt3_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* t, lapack_int ldt ); - -lapack_int LAPACKE_stpmqrt_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - lapack_int l, lapack_int nb, const float* v, - lapack_int ldv, const float* t, lapack_int ldt, - float* a, lapack_int lda, float* b, - lapack_int ldb, float* work ); -lapack_int LAPACKE_dtpmqrt_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - lapack_int l, lapack_int nb, const double* v, - lapack_int ldv, const double* t, - lapack_int ldt, double* a, lapack_int lda, - double* b, lapack_int ldb, double* work ); -lapack_int LAPACKE_ctpmqrt_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - lapack_int l, lapack_int nb, - const lapack_complex_float* v, lapack_int ldv, - const lapack_complex_float* t, lapack_int ldt, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* work ); -lapack_int LAPACKE_ztpmqrt_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - lapack_int l, lapack_int nb, - const lapack_complex_double* v, lapack_int ldv, - const lapack_complex_double* t, lapack_int ldt, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* work ); - -lapack_int LAPACKE_stpqrt_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int l, lapack_int nb, float* a, - lapack_int lda, float* b, lapack_int ldb, - float* t, lapack_int ldt, float* work ); -lapack_int LAPACKE_dtpqrt_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int l, lapack_int nb, double* a, - lapack_int lda, double* b, lapack_int ldb, - double* t, lapack_int ldt, double* work ); -lapack_int LAPACKE_ctpqrt_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int l, lapack_int nb, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* t, lapack_int ldt, - lapack_complex_float* work ); -lapack_int LAPACKE_ztpqrt_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_int l, lapack_int nb, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* t, lapack_int ldt, - lapack_complex_double* work ); - -lapack_int LAPACKE_stpqrt2_work( int matrix_layout, - lapack_int m, lapack_int n, lapack_int l, - float* a, lapack_int lda, - float* b, lapack_int ldb, - float* t, lapack_int ldt ); -lapack_int LAPACKE_dtpqrt2_work( int matrix_layout, - lapack_int m, lapack_int n, lapack_int l, - double* a, lapack_int lda, - double* b, lapack_int ldb, - double* t, lapack_int ldt ); -lapack_int LAPACKE_ctpqrt2_work( int matrix_layout, - lapack_int m, lapack_int n, lapack_int l, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* t, lapack_int ldt ); -lapack_int LAPACKE_ztpqrt2_work( int matrix_layout, - lapack_int m, lapack_int n, lapack_int l, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* t, lapack_int ldt ); - -lapack_int LAPACKE_stprfb_work( int matrix_layout, char side, char trans, - char direct, char storev, lapack_int m, - lapack_int n, lapack_int k, lapack_int l, - const float* v, lapack_int ldv, const float* t, - lapack_int ldt, float* a, lapack_int lda, - float* b, lapack_int ldb, float* work, - lapack_int ldwork ); -lapack_int LAPACKE_dtprfb_work( int matrix_layout, char side, char trans, - char direct, char storev, lapack_int m, - lapack_int n, lapack_int k, lapack_int l, - const double* v, lapack_int ldv, - const double* t, lapack_int ldt, double* a, - lapack_int lda, double* b, lapack_int ldb, - double* work, lapack_int ldwork ); -lapack_int LAPACKE_ctprfb_work( int matrix_layout, char side, char trans, - char direct, char storev, lapack_int m, - lapack_int n, lapack_int k, lapack_int l, - const lapack_complex_float* v, lapack_int ldv, - const lapack_complex_float* t, lapack_int ldt, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* work, lapack_int ldwork ); -lapack_int LAPACKE_ztprfb_work( int matrix_layout, char side, char trans, - char direct, char storev, lapack_int m, - lapack_int n, lapack_int k, lapack_int l, - const lapack_complex_double* v, lapack_int ldv, - const lapack_complex_double* t, lapack_int ldt, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* work, lapack_int ldwork ); -//LAPACK 3.X.X -lapack_int LAPACKE_ssysv_rook( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, float* a, lapack_int lda, - lapack_int* ipiv, float* b, lapack_int ldb ); -lapack_int LAPACKE_dsysv_rook( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, double* a, lapack_int lda, - lapack_int* ipiv, double* b, lapack_int ldb ); -lapack_int LAPACKE_csysv_rook( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zsysv_rook( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_ssytrf_rook( int matrix_layout, char uplo, lapack_int n, float* a, - lapack_int lda, lapack_int* ipiv ); -lapack_int LAPACKE_dsytrf_rook( int matrix_layout, char uplo, lapack_int n, double* a, - lapack_int lda, lapack_int* ipiv ); -lapack_int LAPACKE_csytrf_rook( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int* ipiv ); -lapack_int LAPACKE_zsytrf_rook( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int* ipiv ); - -lapack_int LAPACKE_ssytrs_rook( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const float* a, lapack_int lda, - const lapack_int* ipiv, float* b, lapack_int ldb ); -lapack_int LAPACKE_dsytrs_rook( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const double* a, lapack_int lda, - const lapack_int* ipiv, double* b, lapack_int ldb ); -lapack_int LAPACKE_csytrs_rook( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zsytrs_rook( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_chetrf_rook( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int* ipiv ); -lapack_int LAPACKE_zhetrf_rook( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int* ipiv ); - -lapack_int LAPACKE_chetrs_rook( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zhetrs_rook( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_csyr( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float alpha, - const lapack_complex_float* x, lapack_int incx, - lapack_complex_float* a, lapack_int lda ); -lapack_int LAPACKE_zsyr( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double alpha, - const lapack_complex_double* x, lapack_int incx, - lapack_complex_double* a, lapack_int lda ); - -lapack_int LAPACKE_ssysv_rook_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, float* a, lapack_int lda, - lapack_int* ipiv, float* b, lapack_int ldb, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dsysv_rook_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, double* a, lapack_int lda, - lapack_int* ipiv, double* b, lapack_int ldb, - double* work, lapack_int lwork ); -lapack_int LAPACKE_csysv_rook_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* work, - lapack_int lwork ); -lapack_int LAPACKE_zsysv_rook_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* work, - lapack_int lwork ); - -lapack_int LAPACKE_ssytrf_rook_work( int matrix_layout, char uplo, lapack_int n, - float* a, lapack_int lda, lapack_int* ipiv, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dsytrf_rook_work( int matrix_layout, char uplo, lapack_int n, - double* a, lapack_int lda, lapack_int* ipiv, - double* work, lapack_int lwork ); -lapack_int LAPACKE_csytrf_rook_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int* ipiv, lapack_complex_float* work, - lapack_int lwork ); -lapack_int LAPACKE_zsytrf_rook_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int* ipiv, lapack_complex_double* work, - lapack_int lwork ); - -lapack_int LAPACKE_ssytrs_rook_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const float* a, lapack_int lda, - const lapack_int* ipiv, float* b, - lapack_int ldb ); -lapack_int LAPACKE_dsytrs_rook_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const double* a, - lapack_int lda, const lapack_int* ipiv, - double* b, lapack_int ldb ); -lapack_int LAPACKE_csytrs_rook_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zsytrs_rook_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_chetrf_rook_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int* ipiv, lapack_complex_float* work, - lapack_int lwork ); -lapack_int LAPACKE_zhetrf_rook_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int* ipiv, lapack_complex_double* work, - lapack_int lwork ); - -lapack_int LAPACKE_chetrs_rook_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zhetrs_rook_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb ); - - -lapack_int LAPACKE_csyr_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float alpha, - const lapack_complex_float* x, - lapack_int incx, lapack_complex_float* a, - lapack_int lda ); -lapack_int LAPACKE_zsyr_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double alpha, - const lapack_complex_double* x, - lapack_int incx, lapack_complex_double* a, - lapack_int lda ); -void LAPACKE_ilaver( lapack_int* vers_major, - lapack_int* vers_minor, - lapack_int* vers_patch ); -// LAPACK 3.7.0 -lapack_int LAPACKE_ssysv_aa( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, float* a, lapack_int lda, - lapack_int* ipiv, float* b, lapack_int ldb ); -lapack_int LAPACKE_ssysv_aa_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, float* a, lapack_int lda, - lapack_int* ipiv, float* b, lapack_int ldb, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dsysv_aa( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, double* a, lapack_int lda, - lapack_int* ipiv, double* b, lapack_int ldb ); -lapack_int LAPACKE_dsysv_aa_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, double* a, lapack_int lda, - lapack_int* ipiv, double* b, lapack_int ldb, - double* work, lapack_int lwork ); -lapack_int LAPACKE_csysv_aa( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_csysv_aa_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zsysv_aa( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb ); -lapack_int LAPACKE_zsysv_aa_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* work, lapack_int lwork ); -lapack_int LAPACKE_chesv_aa( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_chesv_aa_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zhesv_aa( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb ); -lapack_int LAPACKE_zhesv_aa_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_ssytrf_aa( int matrix_layout, char uplo, lapack_int n, float* a, - lapack_int lda, lapack_int* ipiv ); -lapack_int LAPACKE_dsytrf_aa( int matrix_layout, char uplo, lapack_int n, double* a, - lapack_int lda, lapack_int* ipiv ); -lapack_int LAPACKE_csytrf_aa( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int* ipiv ); -lapack_int LAPACKE_zsytrf_aa( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int* ipiv ); -lapack_int LAPACKE_chetrf_aa( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int* ipiv ); -lapack_int LAPACKE_zhetrf_aa( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int* ipiv ); - -lapack_int LAPACKE_ssytrf_aa_work( int matrix_layout, char uplo, lapack_int n, - float* a, lapack_int lda, lapack_int* ipiv, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dsytrf_aa_work( int matrix_layout, char uplo, lapack_int n, - double* a, lapack_int lda, lapack_int* ipiv, - double* work, lapack_int lwork ); -lapack_int LAPACKE_csytrf_aa_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int* ipiv, lapack_complex_float* work, - lapack_int lwork ); -lapack_int LAPACKE_zsytrf_aa_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int* ipiv, lapack_complex_double* work, - lapack_int lwork ); -lapack_int LAPACKE_chetrf_aa_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_int* ipiv, lapack_complex_float* work, - lapack_int lwork ); -lapack_int LAPACKE_zhetrf_aa_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_int* ipiv, lapack_complex_double* work, - lapack_int lwork ); - - -lapack_int LAPACKE_csytrs_aa( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_csytrs_aa_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_chetrs_aa( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_chetrs_aa_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_dsytrs_aa( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const double* a, lapack_int lda, - const lapack_int* ipiv, double* b, lapack_int ldb ); -lapack_int LAPACKE_dsytrs_aa_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const double* a, - lapack_int lda, const lapack_int* ipiv, - double* b, lapack_int ldb, double* work, lapack_int lwork ); -lapack_int LAPACKE_ssytrs_aa( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const float* a, lapack_int lda, - const lapack_int* ipiv, float* b, lapack_int ldb ); -lapack_int LAPACKE_ssytrs_aa_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const float* a, lapack_int lda, - const lapack_int* ipiv, float* b, - lapack_int ldb, float* work, lapack_int lwork ); -lapack_int LAPACKE_zsytrs_aa( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb ); -lapack_int LAPACKE_zsytrs_aa_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* work, lapack_int lwork); -lapack_int LAPACKE_zhetrs_aa( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb ); -lapack_int LAPACKE_zhetrs_aa_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* work, lapack_int lwork); - - -lapack_int LAPACKE_ssysv_rk( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, float* a, lapack_int lda, - float* e, lapack_int* ipiv, float* b, lapack_int ldb ); -lapack_int LAPACKE_ssysv_rk_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, float* a, lapack_int lda, - float* e, lapack_int* ipiv, float* b, lapack_int ldb, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dsysv_rk( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, double* a, lapack_int lda, - double* e, lapack_int* ipiv, double* b, lapack_int ldb ); -lapack_int LAPACKE_dsysv_rk_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, double* a, lapack_int lda, - double* e, lapack_int* ipiv, double* b, lapack_int ldb, - double* work, lapack_int lwork ); -lapack_int LAPACKE_csysv_rk( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* e, lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_csysv_rk_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* e, lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zsysv_rk( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* e, lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb ); -lapack_int LAPACKE_zsysv_rk_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* e, lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* work, lapack_int lwork ); -lapack_int LAPACKE_chesv_rk( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* e, lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_chesv_rk_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* e, lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zhesv_rk( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* e, lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb ); -lapack_int LAPACKE_zhesv_rk_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* e, lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_ssytrf_rk( int matrix_layout, char uplo, lapack_int n, float* a, - lapack_int lda, float* e, lapack_int* ipiv ); -lapack_int LAPACKE_dsytrf_rk( int matrix_layout, char uplo, lapack_int n, double* a, - lapack_int lda, double* e, lapack_int* ipiv ); -lapack_int LAPACKE_csytrf_rk( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* e, lapack_int* ipiv ); -lapack_int LAPACKE_zsytrf_rk( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* e, lapack_int* ipiv ); -lapack_int LAPACKE_chetrf_rk( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* e, lapack_int* ipiv ); -lapack_int LAPACKE_zhetrf_rk( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* e, lapack_int* ipiv ); -lapack_int LAPACKE_ssytrf_rk_work( int matrix_layout, char uplo, lapack_int n, - float* a, lapack_int lda, float* e, lapack_int* ipiv, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dsytrf_rk_work( int matrix_layout, char uplo, lapack_int n, - double* a, lapack_int lda, double* e, lapack_int* ipiv, - double* work, lapack_int lwork ); -lapack_int LAPACKE_csytrf_rk_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* e, - lapack_int* ipiv, lapack_complex_float* work, - lapack_int lwork ); -lapack_int LAPACKE_zsytrf_rk_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* e, - lapack_int* ipiv, lapack_complex_double* work, - lapack_int lwork ); -lapack_int LAPACKE_chetrf_rk_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* e, - lapack_int* ipiv, lapack_complex_float* work, - lapack_int lwork ); -lapack_int LAPACKE_zhetrf_rk_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* e, - lapack_int* ipiv, lapack_complex_double* work, - lapack_int lwork ); - -lapack_int LAPACKE_csytrs_3( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* e, - const lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_csytrs_3_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* e, - const lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb); -lapack_int LAPACKE_chetrs_3( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* e, - const lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_chetrs_3_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_float* a, - lapack_int lda, const lapack_complex_float* e, - const lapack_int* ipiv, - lapack_complex_float* b, lapack_int ldb); -lapack_int LAPACKE_dsytrs_3( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const double* a, lapack_int lda, - const double* e, - const lapack_int* ipiv, double* b, lapack_int ldb ); -lapack_int LAPACKE_dsytrs_3_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const double* a, - lapack_int lda, const double* e, - const lapack_int* ipiv, - double* b, lapack_int ldb); -lapack_int LAPACKE_ssytrs_3( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const float* a, lapack_int lda, - const float* e, - const lapack_int* ipiv, float* b, lapack_int ldb ); -lapack_int LAPACKE_ssytrs_3_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const float* a, lapack_int lda, - const float* e, const lapack_int* ipiv, float* b, - lapack_int ldb); -lapack_int LAPACKE_zsytrs_3( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_complex_double* e, - const lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb ); -lapack_int LAPACKE_zsytrs_3_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_complex_double* e, - const lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb); -lapack_int LAPACKE_zhetrs_3( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_complex_double* e, - const lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb ); -lapack_int LAPACKE_zhetrs_3_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, const lapack_complex_double* a, - lapack_int lda, const lapack_complex_double* e, - const lapack_int* ipiv, - lapack_complex_double* b, lapack_int ldb); - -lapack_int LAPACKE_ssytri_3( int matrix_layout, char uplo, lapack_int n, float* a, - lapack_int lda, const float* e, const lapack_int* ipiv ); -lapack_int LAPACKE_dsytri_3( int matrix_layout, char uplo, lapack_int n, double* a, - lapack_int lda, const double* e, const lapack_int* ipiv ); -lapack_int LAPACKE_csytri_3( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* e, const lapack_int* ipiv ); -lapack_int LAPACKE_zsytri_3( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* e, const lapack_int* ipiv ); -lapack_int LAPACKE_chetri_3( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* e, const lapack_int* ipiv ); -lapack_int LAPACKE_zhetri_3( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* e, const lapack_int* ipiv ); -lapack_int LAPACKE_ssytri_3_work( int matrix_layout, char uplo, lapack_int n, float* a, - lapack_int lda, const float* e, const lapack_int* ipiv, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dsytri_3_work( int matrix_layout, char uplo, lapack_int n, double* a, - lapack_int lda, const double* e, const lapack_int* ipiv, - double* work, lapack_int lwork ); -lapack_int LAPACKE_csytri_3_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* e, const lapack_int* ipiv, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zsytri_3_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* e, const lapack_int* ipiv, - lapack_complex_double* work, lapack_int lwork ); -lapack_int LAPACKE_chetri_3_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* e, const lapack_int* ipiv, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zhetri_3_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* e, const lapack_int* ipiv, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_ssycon_3( int matrix_layout, char uplo, lapack_int n, - const float* a, lapack_int lda, const float* e, - const lapack_int* ipiv, float anorm, float* rcond ); -lapack_int LAPACKE_dsycon_3( int matrix_layout, char uplo, lapack_int n, - const double* a, lapack_int lda, const double* e, - const lapack_int* ipiv, double anorm, - double* rcond ); -lapack_int LAPACKE_csycon_3( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* e, - const lapack_int* ipiv, float anorm, float* rcond ); -lapack_int LAPACKE_zsycon_3( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* e, - const lapack_int* ipiv, double anorm, - double* rcond ); -lapack_int LAPACKE_checon_3( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* e, - const lapack_int* ipiv, float anorm, float* rcond ); -lapack_int LAPACKE_zhecon_3( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* e, - const lapack_int* ipiv, double anorm, - double* rcond ); -lapack_int LAPACKE_ssycon_3_work( int matrix_layout, char uplo, lapack_int n, - const float* a, lapack_int lda, const float* e, - const lapack_int* ipiv, float anorm, - float* rcond, float* work, lapack_int* iwork ); -lapack_int LAPACKE_dsycon_3_work( int matrix_layout, char uplo, lapack_int n, - const double* a, lapack_int lda, const double* e, - const lapack_int* ipiv, double anorm, - double* rcond, double* work, - lapack_int* iwork ); -lapack_int LAPACKE_csycon_3_work( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* e, - const lapack_int* ipiv, float anorm, - float* rcond, lapack_complex_float* work ); -lapack_int LAPACKE_zsycon_3_work( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* e, - const lapack_int* ipiv, double anorm, - double* rcond, lapack_complex_double* work ); -lapack_int LAPACKE_checon_3_work( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* e, - const lapack_int* ipiv, float anorm, - float* rcond, lapack_complex_float* work ); -lapack_int LAPACKE_zhecon_3_work( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* e, - const lapack_int* ipiv, double anorm, - double* rcond, lapack_complex_double* work ); - -lapack_int LAPACKE_sgelq( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, - float* t, lapack_int tsize ); -lapack_int LAPACKE_dgelq( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, - double* t, lapack_int tsize ); -lapack_int LAPACKE_cgelq( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* t, lapack_int tsize ); -lapack_int LAPACKE_zgelq( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* t, lapack_int tsize ); - -lapack_int LAPACKE_sgelq_work( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, - float* t, lapack_int tsize, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dgelq_work( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, - double* t, lapack_int tsize, - double* work, lapack_int lwork ); -lapack_int LAPACKE_cgelq_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* t, lapack_int tsize, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zgelq_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* t, lapack_int tsize, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_sgemlq( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const float* a, lapack_int lda, - const float* t, lapack_int tsize, - float* c, lapack_int ldc ); -lapack_int LAPACKE_dgemlq( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const double* a, lapack_int lda, - const double* t, lapack_int tsize, - double* c, lapack_int ldc ); -lapack_int LAPACKE_cgemlq( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* t, lapack_int tsize, - lapack_complex_float* c, lapack_int ldc ); -lapack_int LAPACKE_zgemlq( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* t, lapack_int tsize, - lapack_complex_double* c, lapack_int ldc ); - -lapack_int LAPACKE_sgemlq_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const float* a, lapack_int lda, - const float* t, lapack_int tsize, - float* c, lapack_int ldc, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dgemlq_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const double* a, lapack_int lda, - const double* t, lapack_int tsize, - double* c, lapack_int ldc, - double* work, lapack_int lwork ); -lapack_int LAPACKE_cgemlq_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* t, lapack_int tsize, - lapack_complex_float* c, lapack_int ldc, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zgemlq_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* t, lapack_int tsize, - lapack_complex_double* c, lapack_int ldc, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_sgeqr( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, - float* t, lapack_int tsize ); -lapack_int LAPACKE_dgeqr( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, - double* t, lapack_int tsize ); -lapack_int LAPACKE_cgeqr( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* t, lapack_int tsize ); -lapack_int LAPACKE_zgeqr( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* t, lapack_int tsize ); - -lapack_int LAPACKE_sgeqr_work( int matrix_layout, lapack_int m, lapack_int n, - float* a, lapack_int lda, - float* t, lapack_int tsize, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dgeqr_work( int matrix_layout, lapack_int m, lapack_int n, - double* a, lapack_int lda, - double* t, lapack_int tsize, - double* work, lapack_int lwork ); -lapack_int LAPACKE_cgeqr_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* t, lapack_int tsize, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zgeqr_work( int matrix_layout, lapack_int m, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* t, lapack_int tsize, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_sgemqr( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const float* a, lapack_int lda, - const float* t, lapack_int tsize, - float* c, lapack_int ldc ); -lapack_int LAPACKE_dgemqr( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const double* a, lapack_int lda, - const double* t, lapack_int tsize, - double* c, lapack_int ldc ); -lapack_int LAPACKE_cgemqr( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* t, lapack_int tsize, - lapack_complex_float* c, lapack_int ldc ); -lapack_int LAPACKE_zgemqr( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* t, lapack_int tsize, - lapack_complex_double* c, lapack_int ldc ); - -lapack_int LAPACKE_sgemqr_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const float* a, lapack_int lda, - const float* t, lapack_int tsize, - float* c, lapack_int ldc, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dgemqr_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const double* a, lapack_int lda, - const double* t, lapack_int tsize, - double* c, lapack_int ldc, - double* work, lapack_int lwork ); -lapack_int LAPACKE_cgemqr_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const lapack_complex_float* a, lapack_int lda, - const lapack_complex_float* t, lapack_int tsize, - lapack_complex_float* c, lapack_int ldc, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zgemqr_work( int matrix_layout, char side, char trans, - lapack_int m, lapack_int n, lapack_int k, - const lapack_complex_double* a, lapack_int lda, - const lapack_complex_double* t, lapack_int tsize, - lapack_complex_double* c, lapack_int ldc, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_sgetsls( int matrix_layout, char trans, lapack_int m, - lapack_int n, lapack_int nrhs, float* a, - lapack_int lda, float* b, lapack_int ldb ); -lapack_int LAPACKE_dgetsls( int matrix_layout, char trans, lapack_int m, - lapack_int n, lapack_int nrhs, double* a, - lapack_int lda, double* b, lapack_int ldb ); -lapack_int LAPACKE_cgetsls( int matrix_layout, char trans, lapack_int m, - lapack_int n, lapack_int nrhs, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zgetsls( int matrix_layout, char trans, lapack_int m, - lapack_int n, lapack_int nrhs, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb ); - -lapack_int LAPACKE_sgetsls_work( int matrix_layout, char trans, lapack_int m, - lapack_int n, lapack_int nrhs, float* a, - lapack_int lda, float* b, lapack_int ldb, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dgetsls_work( int matrix_layout, char trans, lapack_int m, - lapack_int n, lapack_int nrhs, double* a, - lapack_int lda, double* b, lapack_int ldb, - double* work, lapack_int lwork ); -lapack_int LAPACKE_cgetsls_work( int matrix_layout, char trans, lapack_int m, - lapack_int n, lapack_int nrhs, - lapack_complex_float* a, lapack_int lda, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zgetsls_work( int matrix_layout, char trans, lapack_int m, - lapack_int n, lapack_int nrhs, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_ssyev_2stage( int matrix_layout, char jobz, char uplo, lapack_int n, - float* a, lapack_int lda, float* w ); -lapack_int LAPACKE_dsyev_2stage( int matrix_layout, char jobz, char uplo, lapack_int n, - double* a, lapack_int lda, double* w ); - -lapack_int LAPACKE_ssyevd_2stage( int matrix_layout, char jobz, char uplo, lapack_int n, - float* a, lapack_int lda, float* w ); -lapack_int LAPACKE_dsyevd_2stage( int matrix_layout, char jobz, char uplo, lapack_int n, - double* a, lapack_int lda, double* w ); - -lapack_int LAPACKE_ssyevr_2stage( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, float* a, lapack_int lda, float vl, - float vu, lapack_int il, lapack_int iu, float abstol, - lapack_int* m, float* w, float* z, lapack_int ldz, - lapack_int* isuppz ); -lapack_int LAPACKE_dsyevr_2stage( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, double* a, lapack_int lda, double vl, - double vu, lapack_int il, lapack_int iu, - double abstol, lapack_int* m, double* w, double* z, - lapack_int ldz, lapack_int* isuppz ); - -lapack_int LAPACKE_ssyevx_2stage( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, float* a, lapack_int lda, float vl, - float vu, lapack_int il, lapack_int iu, float abstol, - lapack_int* m, float* w, float* z, lapack_int ldz, - lapack_int* ifail ); -lapack_int LAPACKE_dsyevx_2stage( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, double* a, lapack_int lda, double vl, - double vu, lapack_int il, lapack_int iu, - double abstol, lapack_int* m, double* w, double* z, - lapack_int ldz, lapack_int* ifail ); - -lapack_int LAPACKE_ssyev_2stage_work( int matrix_layout, char jobz, char uplo, - lapack_int n, float* a, lapack_int lda, float* w, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dsyev_2stage_work( int matrix_layout, char jobz, char uplo, - lapack_int n, double* a, lapack_int lda, - double* w, double* work, lapack_int lwork ); - -lapack_int LAPACKE_ssyevd_2stage_work( int matrix_layout, char jobz, char uplo, - lapack_int n, float* a, lapack_int lda, - float* w, float* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork ); -lapack_int LAPACKE_dsyevd_2stage_work( int matrix_layout, char jobz, char uplo, - lapack_int n, double* a, lapack_int lda, - double* w, double* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork ); - -lapack_int LAPACKE_ssyevr_2stage_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, float* a, - lapack_int lda, float vl, float vu, - lapack_int il, lapack_int iu, float abstol, - lapack_int* m, float* w, float* z, - lapack_int ldz, lapack_int* isuppz, float* work, - lapack_int lwork, lapack_int* iwork, - lapack_int liwork ); -lapack_int LAPACKE_dsyevr_2stage_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, double* a, - lapack_int lda, double vl, double vu, - lapack_int il, lapack_int iu, double abstol, - lapack_int* m, double* w, double* z, - lapack_int ldz, lapack_int* isuppz, - double* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork ); - -lapack_int LAPACKE_ssyevx_2stage_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, float* a, - lapack_int lda, float vl, float vu, - lapack_int il, lapack_int iu, float abstol, - lapack_int* m, float* w, float* z, - lapack_int ldz, float* work, lapack_int lwork, - lapack_int* iwork, lapack_int* ifail ); -lapack_int LAPACKE_dsyevx_2stage_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, double* a, - lapack_int lda, double vl, double vu, - lapack_int il, lapack_int iu, double abstol, - lapack_int* m, double* w, double* z, - lapack_int ldz, double* work, lapack_int lwork, - lapack_int* iwork, lapack_int* ifail ); - -lapack_int LAPACKE_cheev_2stage( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, float* w ); -lapack_int LAPACKE_zheev_2stage( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, double* w ); - -lapack_int LAPACKE_cheevd_2stage( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, float* w ); -lapack_int LAPACKE_zheevd_2stage( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - double* w ); - -lapack_int LAPACKE_cheevr_2stage( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, lapack_complex_float* a, - lapack_int lda, float vl, float vu, lapack_int il, - lapack_int iu, float abstol, lapack_int* m, float* w, - lapack_complex_float* z, lapack_int ldz, - lapack_int* isuppz ); -lapack_int LAPACKE_zheevr_2stage( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, lapack_complex_double* a, - lapack_int lda, double vl, double vu, lapack_int il, - lapack_int iu, double abstol, lapack_int* m, - double* w, lapack_complex_double* z, lapack_int ldz, - lapack_int* isuppz ); - -lapack_int LAPACKE_cheevx_2stage( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, lapack_complex_float* a, - lapack_int lda, float vl, float vu, lapack_int il, - lapack_int iu, float abstol, lapack_int* m, float* w, - lapack_complex_float* z, lapack_int ldz, - lapack_int* ifail ); -lapack_int LAPACKE_zheevx_2stage( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, lapack_complex_double* a, - lapack_int lda, double vl, double vu, lapack_int il, - lapack_int iu, double abstol, lapack_int* m, - double* w, lapack_complex_double* z, lapack_int ldz, - lapack_int* ifail ); - -lapack_int LAPACKE_cheev_2stage_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_complex_float* a, - lapack_int lda, float* w, - lapack_complex_float* work, lapack_int lwork, - float* rwork ); -lapack_int LAPACKE_zheev_2stage_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_complex_double* a, - lapack_int lda, double* w, - lapack_complex_double* work, lapack_int lwork, - double* rwork ); - -lapack_int LAPACKE_cheevd_2stage_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_complex_float* a, - lapack_int lda, float* w, - lapack_complex_float* work, lapack_int lwork, - float* rwork, lapack_int lrwork, - lapack_int* iwork, lapack_int liwork ); -lapack_int LAPACKE_zheevd_2stage_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_complex_double* a, - lapack_int lda, double* w, - lapack_complex_double* work, lapack_int lwork, - double* rwork, lapack_int lrwork, - lapack_int* iwork, lapack_int liwork ); - -lapack_int LAPACKE_cheevr_2stage_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - float vl, float vu, lapack_int il, - lapack_int iu, float abstol, lapack_int* m, - float* w, lapack_complex_float* z, - lapack_int ldz, lapack_int* isuppz, - lapack_complex_float* work, lapack_int lwork, - float* rwork, lapack_int lrwork, - lapack_int* iwork, lapack_int liwork ); -lapack_int LAPACKE_zheevr_2stage_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - double vl, double vu, lapack_int il, - lapack_int iu, double abstol, lapack_int* m, - double* w, lapack_complex_double* z, - lapack_int ldz, lapack_int* isuppz, - lapack_complex_double* work, lapack_int lwork, - double* rwork, lapack_int lrwork, - lapack_int* iwork, lapack_int liwork ); - -lapack_int LAPACKE_cheevx_2stage_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, - lapack_complex_float* a, lapack_int lda, - float vl, float vu, lapack_int il, - lapack_int iu, float abstol, lapack_int* m, - float* w, lapack_complex_float* z, - lapack_int ldz, lapack_complex_float* work, - lapack_int lwork, float* rwork, - lapack_int* iwork, lapack_int* ifail ); -lapack_int LAPACKE_zheevx_2stage_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - double vl, double vu, lapack_int il, - lapack_int iu, double abstol, lapack_int* m, - double* w, lapack_complex_double* z, - lapack_int ldz, lapack_complex_double* work, - lapack_int lwork, double* rwork, - lapack_int* iwork, lapack_int* ifail ); - -lapack_int LAPACKE_ssbev_2stage( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_int kd, float* ab, lapack_int ldab, float* w, - float* z, lapack_int ldz ); -lapack_int LAPACKE_dsbev_2stage( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_int kd, double* ab, lapack_int ldab, double* w, - double* z, lapack_int ldz ); - -lapack_int LAPACKE_ssbevd_2stage( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_int kd, float* ab, lapack_int ldab, float* w, - float* z, lapack_int ldz ); -lapack_int LAPACKE_dsbevd_2stage( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_int kd, double* ab, lapack_int ldab, - double* w, double* z, lapack_int ldz ); - -lapack_int LAPACKE_ssbevx_2stage( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, lapack_int kd, float* ab, - lapack_int ldab, float* q, lapack_int ldq, float vl, - float vu, lapack_int il, lapack_int iu, float abstol, - lapack_int* m, float* w, float* z, lapack_int ldz, - lapack_int* ifail ); -lapack_int LAPACKE_dsbevx_2stage( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, lapack_int kd, double* ab, - lapack_int ldab, double* q, lapack_int ldq, - double vl, double vu, lapack_int il, lapack_int iu, - double abstol, lapack_int* m, double* w, double* z, - lapack_int ldz, lapack_int* ifail ); - -lapack_int LAPACKE_ssbev_2stage_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_int kd, float* ab, - lapack_int ldab, float* w, float* z, - lapack_int ldz, float* work, lapack_int lwork ); -lapack_int LAPACKE_dsbev_2stage_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_int kd, double* ab, - lapack_int ldab, double* w, double* z, - lapack_int ldz, double* work, lapack_int lwork ); - -lapack_int LAPACKE_ssbevd_2stage_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_int kd, float* ab, - lapack_int ldab, float* w, float* z, - lapack_int ldz, float* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork ); -lapack_int LAPACKE_dsbevd_2stage_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_int kd, double* ab, - lapack_int ldab, double* w, double* z, - lapack_int ldz, double* work, lapack_int lwork, - lapack_int* iwork, lapack_int liwork ); - -lapack_int LAPACKE_ssbevx_2stage_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, lapack_int kd, - float* ab, lapack_int ldab, float* q, - lapack_int ldq, float vl, float vu, - lapack_int il, lapack_int iu, float abstol, - lapack_int* m, float* w, float* z, - lapack_int ldz, float* work, lapack_int lwork, lapack_int* iwork, - lapack_int* ifail ); -lapack_int LAPACKE_dsbevx_2stage_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, lapack_int kd, - double* ab, lapack_int ldab, double* q, - lapack_int ldq, double vl, double vu, - lapack_int il, lapack_int iu, double abstol, - lapack_int* m, double* w, double* z, - lapack_int ldz, double* work, lapack_int lwork, lapack_int* iwork, - lapack_int* ifail ); - -lapack_int LAPACKE_chbev_2stage( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_int kd, lapack_complex_float* ab, - lapack_int ldab, float* w, lapack_complex_float* z, - lapack_int ldz ); -lapack_int LAPACKE_zhbev_2stage( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_int kd, lapack_complex_double* ab, - lapack_int ldab, double* w, lapack_complex_double* z, - lapack_int ldz ); - -lapack_int LAPACKE_chbevd_2stage( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_int kd, lapack_complex_float* ab, - lapack_int ldab, float* w, lapack_complex_float* z, - lapack_int ldz ); -lapack_int LAPACKE_zhbevd_2stage( int matrix_layout, char jobz, char uplo, lapack_int n, - lapack_int kd, lapack_complex_double* ab, - lapack_int ldab, double* w, lapack_complex_double* z, - lapack_int ldz ); - -lapack_int LAPACKE_chbevx_2stage( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, lapack_int kd, - lapack_complex_float* ab, lapack_int ldab, - lapack_complex_float* q, lapack_int ldq, float vl, - float vu, lapack_int il, lapack_int iu, float abstol, - lapack_int* m, float* w, lapack_complex_float* z, - lapack_int ldz, lapack_int* ifail ); -lapack_int LAPACKE_zhbevx_2stage( int matrix_layout, char jobz, char range, char uplo, - lapack_int n, lapack_int kd, - lapack_complex_double* ab, lapack_int ldab, - lapack_complex_double* q, lapack_int ldq, double vl, - double vu, lapack_int il, lapack_int iu, - double abstol, lapack_int* m, double* w, - lapack_complex_double* z, lapack_int ldz, - lapack_int* ifail ); - -lapack_int LAPACKE_chbev_2stage_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_int kd, - lapack_complex_float* ab, lapack_int ldab, - float* w, lapack_complex_float* z, - lapack_int ldz, lapack_complex_float* work, - lapack_int lwork, float* rwork ); -lapack_int LAPACKE_zhbev_2stage_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_int kd, - lapack_complex_double* ab, lapack_int ldab, - double* w, lapack_complex_double* z, - lapack_int ldz, lapack_complex_double* work, - lapack_int lwork, double* rwork ); - -lapack_int LAPACKE_chbevd_2stage_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_int kd, - lapack_complex_float* ab, lapack_int ldab, - float* w, lapack_complex_float* z, - lapack_int ldz, lapack_complex_float* work, - lapack_int lwork, float* rwork, - lapack_int lrwork, lapack_int* iwork, - lapack_int liwork ); -lapack_int LAPACKE_zhbevd_2stage_work( int matrix_layout, char jobz, char uplo, - lapack_int n, lapack_int kd, - lapack_complex_double* ab, lapack_int ldab, - double* w, lapack_complex_double* z, - lapack_int ldz, lapack_complex_double* work, - lapack_int lwork, double* rwork, - lapack_int lrwork, lapack_int* iwork, - lapack_int liwork ); - -lapack_int LAPACKE_chbevx_2stage_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, lapack_int kd, - lapack_complex_float* ab, lapack_int ldab, - lapack_complex_float* q, lapack_int ldq, - float vl, float vu, lapack_int il, - lapack_int iu, float abstol, lapack_int* m, - float* w, lapack_complex_float* z, - lapack_int ldz, lapack_complex_float* work, - lapack_int lwork, float* rwork, lapack_int* iwork, - lapack_int* ifail ); -lapack_int LAPACKE_zhbevx_2stage_work( int matrix_layout, char jobz, char range, - char uplo, lapack_int n, lapack_int kd, - lapack_complex_double* ab, lapack_int ldab, - lapack_complex_double* q, lapack_int ldq, - double vl, double vu, lapack_int il, - lapack_int iu, double abstol, lapack_int* m, - double* w, lapack_complex_double* z, - lapack_int ldz, lapack_complex_double* work, - lapack_int lwork, double* rwork, lapack_int* iwork, - lapack_int* ifail ); - -lapack_int LAPACKE_ssygv_2stage( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, float* a, lapack_int lda, - float* b, lapack_int ldb, float* w ); -lapack_int LAPACKE_dsygv_2stage( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, double* a, lapack_int lda, - double* b, lapack_int ldb, double* w ); -lapack_int LAPACKE_ssygv_2stage_work( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, float* a, - lapack_int lda, float* b, lapack_int ldb, - float* w, float* work, lapack_int lwork ); -lapack_int LAPACKE_dsygv_2stage_work( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, double* a, - lapack_int lda, double* b, lapack_int ldb, - double* w, double* work, lapack_int lwork ); - -lapack_int LAPACKE_chegv_2stage( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* b, - lapack_int ldb, float* w ); -lapack_int LAPACKE_zhegv_2stage( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* b, - lapack_int ldb, double* w ); -lapack_int LAPACKE_chegv_2stage_work( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* b, - lapack_int ldb, float* w, - lapack_complex_float* work, lapack_int lwork, - float* rwork ); -lapack_int LAPACKE_zhegv_2stage_work( int matrix_layout, lapack_int itype, char jobz, - char uplo, lapack_int n, - lapack_complex_double* a, lapack_int lda, - lapack_complex_double* b, lapack_int ldb, - double* w, lapack_complex_double* work, - lapack_int lwork, double* rwork ); - -//LAPACK 3.8.0 -lapack_int LAPACKE_ssysv_aa_2stage( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, float* a, lapack_int lda, - float* tb, lapack_int ltb, lapack_int* ipiv, - lapack_int* ipiv2, float* b, lapack_int ldb ); -lapack_int LAPACKE_ssysv_aa_2stage_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, float* a, lapack_int lda, - float* tb, lapack_int ltb, lapack_int* ipiv, - lapack_int* ipiv2, float* b, lapack_int ldb, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dsysv_aa_2stage( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, double* a, lapack_int lda, - double* tb, lapack_int ltb, - lapack_int* ipiv, lapack_int* ipiv2, - double* b, lapack_int ldb ); -lapack_int LAPACKE_dsysv_aa_2stage_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, double* a, lapack_int lda, - double* tb, lapack_int ltb, - lapack_int* ipiv, lapack_int* ipiv2, - double* b, lapack_int ldb, - double* work, lapack_int lwork ); -lapack_int LAPACKE_csysv_aa_2stage( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* tb, - lapack_int ltb, lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_csysv_aa_2stage_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* tb, - lapack_int ltb, lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zsysv_aa_2stage( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* tb, - lapack_int ltb, lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_double* b, lapack_int ldb ); -lapack_int LAPACKE_zsysv_aa_2stage_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* tb, - lapack_int ltb, lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* work, lapack_int lwork ); -lapack_int LAPACKE_chesv_aa_2stage( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* tb, - lapack_int ltb, lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_chesv_aa_2stage_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* tb, - lapack_int ltb, lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_float* b, lapack_int ldb, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zhesv_aa_2stage( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* tb, - lapack_int ltb, lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_double* b, lapack_int ldb ); -lapack_int LAPACKE_zhesv_aa_2stage_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* tb, - lapack_int ltb, lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_double* b, lapack_int ldb, - lapack_complex_double* work, lapack_int lwork ); - -lapack_int LAPACKE_ssytrf_aa_2stage( int matrix_layout, char uplo, lapack_int n, - float* a, lapack_int lda, - float* tb, lapack_int ltb, lapack_int* ipiv, - lapack_int* ipiv2 ); -lapack_int LAPACKE_ssytrf_aa_2stage_work( int matrix_layout, char uplo, lapack_int n, - float* a, lapack_int lda, - float* tb, lapack_int ltb, lapack_int* ipiv, - lapack_int* ipiv2, - float* work, lapack_int lwork ); -lapack_int LAPACKE_dsytrf_aa_2stage( int matrix_layout, char uplo, lapack_int n, - double* a, lapack_int lda, - double* tb, lapack_int ltb, - lapack_int* ipiv, lapack_int* ipiv2 ); -lapack_int LAPACKE_dsytrf_aa_2stage_work( int matrix_layout, char uplo, lapack_int n, - double* a, lapack_int lda, - double* tb, lapack_int ltb, - lapack_int* ipiv, lapack_int* ipiv2, - double* work, lapack_int lwork ); -lapack_int LAPACKE_csytrf_aa_2stage( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, - lapack_int lda, lapack_complex_float* tb, - lapack_int ltb, lapack_int* ipiv, lapack_int* ipiv2 ); -lapack_int LAPACKE_csytrf_aa_2stage_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, - lapack_int lda, lapack_complex_float* tb, - lapack_int ltb, lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zsytrf_aa_2stage( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, - lapack_int lda, lapack_complex_double* tb, - lapack_int ltb, lapack_int* ipiv, lapack_int* ipiv2 ); -lapack_int LAPACKE_zsytrf_aa_2stage_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, - lapack_int lda, lapack_complex_double* tb, - lapack_int ltb, lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_double* work, lapack_int lwork ); -lapack_int LAPACKE_chetrf_aa_2stage( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, - lapack_int lda, lapack_complex_float* tb, - lapack_int ltb, lapack_int* ipiv, lapack_int* ipiv2 ); -lapack_int LAPACKE_chetrf_aa_2stage_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_float* a, - lapack_int lda, lapack_complex_float* tb, - lapack_int ltb, lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_float* work, lapack_int lwork ); -lapack_int LAPACKE_zhetrf_aa_2stage( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, - lapack_int lda, lapack_complex_double* tb, - lapack_int ltb, lapack_int* ipiv, lapack_int* ipiv2 ); -lapack_int LAPACKE_zhetrf_aa_2stage_work( int matrix_layout, char uplo, lapack_int n, - lapack_complex_double* a, - lapack_int lda, lapack_complex_double* tb, - lapack_int ltb, lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_double* work, lapack_int lwork ); - - -lapack_int LAPACKE_ssytrs_aa_2stage( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, float* a, lapack_int lda, - float* tb, lapack_int ltb, lapack_int* ipiv, - lapack_int* ipiv2, float* b, lapack_int ldb ); -lapack_int LAPACKE_ssytrs_aa_2stage_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, float* a, lapack_int lda, - float* tb, lapack_int ltb, lapack_int* ipiv, - lapack_int* ipiv2, float* b, lapack_int ldb ); -lapack_int LAPACKE_dsytrs_aa_2stage( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, double* a, lapack_int lda, - double* tb, lapack_int ltb, - lapack_int* ipiv, lapack_int* ipiv2, - double* b, lapack_int ldb ); -lapack_int LAPACKE_dsytrs_aa_2stage_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, double* a, lapack_int lda, - double* tb, lapack_int ltb, - lapack_int* ipiv, lapack_int* ipiv2, - double* b, lapack_int ldb ); -lapack_int LAPACKE_csytrs_aa_2stage( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* tb, - lapack_int ltb, lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_csytrs_aa_2stage_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* tb, - lapack_int ltb, lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zsytrs_aa_2stage( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* tb, - lapack_int ltb, lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_double* b, lapack_int ldb ); -lapack_int LAPACKE_zsytrs_aa_2stage_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* tb, - lapack_int ltb, lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_double* b, lapack_int ldb ); -lapack_int LAPACKE_chetrs_aa_2stage( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* tb, - lapack_int ltb, lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_chetrs_aa_2stage_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_float* a, - lapack_int lda, lapack_complex_float* tb, - lapack_int ltb, lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_float* b, lapack_int ldb ); -lapack_int LAPACKE_zhetrs_aa_2stage( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* tb, - lapack_int ltb, lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_double* b, lapack_int ldb ); -lapack_int LAPACKE_zhetrs_aa_2stage_work( int matrix_layout, char uplo, lapack_int n, - lapack_int nrhs, lapack_complex_double* a, - lapack_int lda, lapack_complex_double* tb, - lapack_int ltb, lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_double* b, lapack_int ldb ); - -#define LAPACK_sgetrf LAPACK_GLOBAL(sgetrf,SGETRF) -#define LAPACK_dgetrf LAPACK_GLOBAL(dgetrf,DGETRF) -#define LAPACK_cgetrf LAPACK_GLOBAL(cgetrf,CGETRF) -#define LAPACK_zgetrf LAPACK_GLOBAL(zgetrf,ZGETRF) -#define LAPACK_sgetrf2 LAPACK_GLOBAL(sgetrf2,SGETRF2) -#define LAPACK_dgetrf2 LAPACK_GLOBAL(dgetrf2,DGETRF2) -#define LAPACK_cgetrf2 LAPACK_GLOBAL(cgetrf2,CGETRF2) -#define LAPACK_zgetrf2 LAPACK_GLOBAL(zgetrf2,ZGETRF2) -#define LAPACK_sgbtrf LAPACK_GLOBAL(sgbtrf,SGBTRF) -#define LAPACK_dgbtrf LAPACK_GLOBAL(dgbtrf,DGBTRF) -#define LAPACK_cgbtrf LAPACK_GLOBAL(cgbtrf,CGBTRF) -#define LAPACK_zgbtrf LAPACK_GLOBAL(zgbtrf,ZGBTRF) -#define LAPACK_sgttrf LAPACK_GLOBAL(sgttrf,SGTTRF) -#define LAPACK_dgttrf LAPACK_GLOBAL(dgttrf,DGTTRF) -#define LAPACK_cgttrf LAPACK_GLOBAL(cgttrf,CGTTRF) -#define LAPACK_zgttrf LAPACK_GLOBAL(zgttrf,ZGTTRF) -#define LAPACK_spotrf LAPACK_GLOBAL(spotrf,SPOTRF) -#define LAPACK_dpotrf LAPACK_GLOBAL(dpotrf,DPOTRF) -#define LAPACK_cpotrf LAPACK_GLOBAL(cpotrf,CPOTRF) -#define LAPACK_zpotrf LAPACK_GLOBAL(zpotrf,ZPOTRF) -#define LAPACK_spotrf2 LAPACK_GLOBAL(spotrf2,SPOTRF2) -#define LAPACK_dpotrf2 LAPACK_GLOBAL(dpotrf2,DPOTRF2) -#define LAPACK_cpotrf2 LAPACK_GLOBAL(cpotrf2,CPOTRF2) -#define LAPACK_zpotrf2 LAPACK_GLOBAL(zpotrf2,ZPOTRF2) -#define LAPACK_dpstrf LAPACK_GLOBAL(dpstrf,DPSTRF) -#define LAPACK_spstrf LAPACK_GLOBAL(spstrf,SPSTRF) -#define LAPACK_zpstrf LAPACK_GLOBAL(zpstrf,ZPSTRF) -#define LAPACK_cpstrf LAPACK_GLOBAL(cpstrf,CPSTRF) -#define LAPACK_dpftrf LAPACK_GLOBAL(dpftrf,DPFTRF) -#define LAPACK_spftrf LAPACK_GLOBAL(spftrf,SPFTRF) -#define LAPACK_zpftrf LAPACK_GLOBAL(zpftrf,ZPFTRF) -#define LAPACK_cpftrf LAPACK_GLOBAL(cpftrf,CPFTRF) -#define LAPACK_spptrf LAPACK_GLOBAL(spptrf,SPPTRF) -#define LAPACK_dpptrf LAPACK_GLOBAL(dpptrf,DPPTRF) -#define LAPACK_cpptrf LAPACK_GLOBAL(cpptrf,CPPTRF) -#define LAPACK_zpptrf LAPACK_GLOBAL(zpptrf,ZPPTRF) -#define LAPACK_spbtrf LAPACK_GLOBAL(spbtrf,SPBTRF) -#define LAPACK_dpbtrf LAPACK_GLOBAL(dpbtrf,DPBTRF) -#define LAPACK_cpbtrf LAPACK_GLOBAL(cpbtrf,CPBTRF) -#define LAPACK_zpbtrf LAPACK_GLOBAL(zpbtrf,ZPBTRF) -#define LAPACK_spttrf LAPACK_GLOBAL(spttrf,SPTTRF) -#define LAPACK_dpttrf LAPACK_GLOBAL(dpttrf,DPTTRF) -#define LAPACK_cpttrf LAPACK_GLOBAL(cpttrf,CPTTRF) -#define LAPACK_zpttrf LAPACK_GLOBAL(zpttrf,ZPTTRF) -#define LAPACK_ssytrf LAPACK_GLOBAL(ssytrf,SSYTRF) -#define LAPACK_ssytrf_rook LAPACK_GLOBAL(ssytrf_rook,SSYTRF_ROOK) -#define LAPACK_dsytrf LAPACK_GLOBAL(dsytrf,DSYTRF) -#define LAPACK_dsytrf_rook LAPACK_GLOBAL(dsytrf_rook,DSYTRF_ROOK) -#define LAPACK_csytrf LAPACK_GLOBAL(csytrf,CSYTRF) -#define LAPACK_csytrf_rook LAPACK_GLOBAL(csytrf_rook,CSYTRF_ROOK) -#define LAPACK_zsytrf LAPACK_GLOBAL(zsytrf,ZSYTRF) -#define LAPACK_zsytrf_rook LAPACK_GLOBAL(zsytrf_rook,ZSYTRF_ROOK) -#define LAPACK_chetrf LAPACK_GLOBAL(chetrf,CHETRF) -#define LAPACK_chetrf_rook LAPACK_GLOBAL(chetrf_rook,CHETRF_ROOK) -#define LAPACK_zhetrf LAPACK_GLOBAL(zhetrf,ZHETRF) -#define LAPACK_zhetrf_rook LAPACK_GLOBAL(zhetrf_rook,ZHETRF_ROOK) -#define LAPACK_ssptrf LAPACK_GLOBAL(ssptrf,SSPTRF) -#define LAPACK_dsptrf LAPACK_GLOBAL(dsptrf,DSPTRF) -#define LAPACK_csptrf LAPACK_GLOBAL(csptrf,CSPTRF) -#define LAPACK_zsptrf LAPACK_GLOBAL(zsptrf,ZSPTRF) -#define LAPACK_chptrf LAPACK_GLOBAL(chptrf,CHPTRF) -#define LAPACK_zhptrf LAPACK_GLOBAL(zhptrf,ZHPTRF) -#define LAPACK_sgetrs LAPACK_GLOBAL(sgetrs,SGETRS) -#define LAPACK_dgetrs LAPACK_GLOBAL(dgetrs,DGETRS) -#define LAPACK_cgetrs LAPACK_GLOBAL(cgetrs,CGETRS) -#define LAPACK_zgetrs LAPACK_GLOBAL(zgetrs,ZGETRS) -#define LAPACK_sgbtrs LAPACK_GLOBAL(sgbtrs,SGBTRS) -#define LAPACK_dgbtrs LAPACK_GLOBAL(dgbtrs,DGBTRS) -#define LAPACK_cgbtrs LAPACK_GLOBAL(cgbtrs,CGBTRS) -#define LAPACK_zgbtrs LAPACK_GLOBAL(zgbtrs,ZGBTRS) -#define LAPACK_sgttrs LAPACK_GLOBAL(sgttrs,SGTTRS) -#define LAPACK_dgttrs LAPACK_GLOBAL(dgttrs,DGTTRS) -#define LAPACK_cgttrs LAPACK_GLOBAL(cgttrs,CGTTRS) -#define LAPACK_zgttrs LAPACK_GLOBAL(zgttrs,ZGTTRS) -#define LAPACK_spotrs LAPACK_GLOBAL(spotrs,SPOTRS) -#define LAPACK_dpotrs LAPACK_GLOBAL(dpotrs,DPOTRS) -#define LAPACK_cpotrs LAPACK_GLOBAL(cpotrs,CPOTRS) -#define LAPACK_zpotrs LAPACK_GLOBAL(zpotrs,ZPOTRS) -#define LAPACK_dpftrs LAPACK_GLOBAL(dpftrs,DPFTRS) -#define LAPACK_spftrs LAPACK_GLOBAL(spftrs,SPFTRS) -#define LAPACK_zpftrs LAPACK_GLOBAL(zpftrs,ZPFTRS) -#define LAPACK_cpftrs LAPACK_GLOBAL(cpftrs,CPFTRS) -#define LAPACK_spptrs LAPACK_GLOBAL(spptrs,SPPTRS) -#define LAPACK_dpptrs LAPACK_GLOBAL(dpptrs,DPPTRS) -#define LAPACK_cpptrs LAPACK_GLOBAL(cpptrs,CPPTRS) -#define LAPACK_zpptrs LAPACK_GLOBAL(zpptrs,ZPPTRS) -#define LAPACK_spbtrs LAPACK_GLOBAL(spbtrs,SPBTRS) -#define LAPACK_dpbtrs LAPACK_GLOBAL(dpbtrs,DPBTRS) -#define LAPACK_cpbtrs LAPACK_GLOBAL(cpbtrs,CPBTRS) -#define LAPACK_zpbtrs LAPACK_GLOBAL(zpbtrs,ZPBTRS) -#define LAPACK_spttrs LAPACK_GLOBAL(spttrs,SPTTRS) -#define LAPACK_dpttrs LAPACK_GLOBAL(dpttrs,DPTTRS) -#define LAPACK_cpttrs LAPACK_GLOBAL(cpttrs,CPTTRS) -#define LAPACK_zpttrs LAPACK_GLOBAL(zpttrs,ZPTTRS) -#define LAPACK_ssytrs LAPACK_GLOBAL(ssytrs,SSYTRS) -#define LAPACK_ssytrs_rook LAPACK_GLOBAL(ssytrs_rook,SSYTRS_ROOK) -#define LAPACK_dsytrs LAPACK_GLOBAL(dsytrs,DSYTRS) -#define LAPACK_dsytrs_rook LAPACK_GLOBAL(dsytrs_rook,DSYTRS_ROOK) -#define LAPACK_csytrs LAPACK_GLOBAL(csytrs,CSYTRS) -#define LAPACK_csytrs_rook LAPACK_GLOBAL(csytrs_rook,CSYTRS_ROOK) -#define LAPACK_zsytrs LAPACK_GLOBAL(zsytrs,ZSYTRS) -#define LAPACK_zsytrs_rook LAPACK_GLOBAL(zsytrs_rook,ZSYTRS_ROOK) -#define LAPACK_chetrs LAPACK_GLOBAL(chetrs,CHETRS) -#define LAPACK_chetrs_rook LAPACK_GLOBAL(chetrs_rook,CHETRS_ROOK) -#define LAPACK_zhetrs LAPACK_GLOBAL(zhetrs,ZHETRS) -#define LAPACK_zhetrs_rook LAPACK_GLOBAL(zhetrs_rook,ZHETRS_ROOK) -#define LAPACK_ssptrs LAPACK_GLOBAL(ssptrs,SSPTRS) -#define LAPACK_dsptrs LAPACK_GLOBAL(dsptrs,DSPTRS) -#define LAPACK_csptrs LAPACK_GLOBAL(csptrs,CSPTRS) -#define LAPACK_zsptrs LAPACK_GLOBAL(zsptrs,ZSPTRS) -#define LAPACK_chptrs LAPACK_GLOBAL(chptrs,CHPTRS) -#define LAPACK_zhptrs LAPACK_GLOBAL(zhptrs,ZHPTRS) -#define LAPACK_strtrs LAPACK_GLOBAL(strtrs,STRTRS) -#define LAPACK_dtrtrs LAPACK_GLOBAL(dtrtrs,DTRTRS) -#define LAPACK_ctrtrs LAPACK_GLOBAL(ctrtrs,CTRTRS) -#define LAPACK_ztrtrs LAPACK_GLOBAL(ztrtrs,ZTRTRS) -#define LAPACK_stptrs LAPACK_GLOBAL(stptrs,STPTRS) -#define LAPACK_dtptrs LAPACK_GLOBAL(dtptrs,DTPTRS) -#define LAPACK_ctptrs LAPACK_GLOBAL(ctptrs,CTPTRS) -#define LAPACK_ztptrs LAPACK_GLOBAL(ztptrs,ZTPTRS) -#define LAPACK_stbtrs LAPACK_GLOBAL(stbtrs,STBTRS) -#define LAPACK_dtbtrs LAPACK_GLOBAL(dtbtrs,DTBTRS) -#define LAPACK_ctbtrs LAPACK_GLOBAL(ctbtrs,CTBTRS) -#define LAPACK_ztbtrs LAPACK_GLOBAL(ztbtrs,ZTBTRS) -#define LAPACK_sgecon LAPACK_GLOBAL(sgecon,SGECON) -#define LAPACK_dgecon LAPACK_GLOBAL(dgecon,DGECON) -#define LAPACK_cgecon LAPACK_GLOBAL(cgecon,CGECON) -#define LAPACK_zgecon LAPACK_GLOBAL(zgecon,ZGECON) -#define LAPACK_sgbcon LAPACK_GLOBAL(sgbcon,SGBCON) -#define LAPACK_dgbcon LAPACK_GLOBAL(dgbcon,DGBCON) -#define LAPACK_cgbcon LAPACK_GLOBAL(cgbcon,CGBCON) -#define LAPACK_zgbcon LAPACK_GLOBAL(zgbcon,ZGBCON) -#define LAPACK_sgtcon LAPACK_GLOBAL(sgtcon,SGTCON) -#define LAPACK_dgtcon LAPACK_GLOBAL(dgtcon,DGTCON) -#define LAPACK_cgtcon LAPACK_GLOBAL(cgtcon,CGTCON) -#define LAPACK_zgtcon LAPACK_GLOBAL(zgtcon,ZGTCON) -#define LAPACK_spocon LAPACK_GLOBAL(spocon,SPOCON) -#define LAPACK_dpocon LAPACK_GLOBAL(dpocon,DPOCON) -#define LAPACK_cpocon LAPACK_GLOBAL(cpocon,CPOCON) -#define LAPACK_zpocon LAPACK_GLOBAL(zpocon,ZPOCON) -#define LAPACK_sppcon LAPACK_GLOBAL(sppcon,SPPCON) -#define LAPACK_dppcon LAPACK_GLOBAL(dppcon,DPPCON) -#define LAPACK_cppcon LAPACK_GLOBAL(cppcon,CPPCON) -#define LAPACK_zppcon LAPACK_GLOBAL(zppcon,ZPPCON) -#define LAPACK_spbcon LAPACK_GLOBAL(spbcon,SPBCON) -#define LAPACK_dpbcon LAPACK_GLOBAL(dpbcon,DPBCON) -#define LAPACK_cpbcon LAPACK_GLOBAL(cpbcon,CPBCON) -#define LAPACK_zpbcon LAPACK_GLOBAL(zpbcon,ZPBCON) -#define LAPACK_sptcon LAPACK_GLOBAL(sptcon,SPTCON) -#define LAPACK_dptcon LAPACK_GLOBAL(dptcon,DPTCON) -#define LAPACK_cptcon LAPACK_GLOBAL(cptcon,CPTCON) -#define LAPACK_zptcon LAPACK_GLOBAL(zptcon,ZPTCON) -#define LAPACK_ssycon LAPACK_GLOBAL(ssycon,SSYCON) -#define LAPACK_dsycon LAPACK_GLOBAL(dsycon,DSYCON) -#define LAPACK_csycon LAPACK_GLOBAL(csycon,CSYCON) -#define LAPACK_zsycon LAPACK_GLOBAL(zsycon,ZSYCON) -#define LAPACK_checon LAPACK_GLOBAL(checon,CHECON) -#define LAPACK_zhecon LAPACK_GLOBAL(zhecon,ZHECON) -#define LAPACK_sspcon LAPACK_GLOBAL(sspcon,SSPCON) -#define LAPACK_dspcon LAPACK_GLOBAL(dspcon,DSPCON) -#define LAPACK_cspcon LAPACK_GLOBAL(cspcon,CSPCON) -#define LAPACK_zspcon LAPACK_GLOBAL(zspcon,ZSPCON) -#define LAPACK_chpcon LAPACK_GLOBAL(chpcon,CHPCON) -#define LAPACK_zhpcon LAPACK_GLOBAL(zhpcon,ZHPCON) -#define LAPACK_strcon LAPACK_GLOBAL(strcon,STRCON) -#define LAPACK_dtrcon LAPACK_GLOBAL(dtrcon,DTRCON) -#define LAPACK_ctrcon LAPACK_GLOBAL(ctrcon,CTRCON) -#define LAPACK_ztrcon LAPACK_GLOBAL(ztrcon,ZTRCON) -#define LAPACK_stpcon LAPACK_GLOBAL(stpcon,STPCON) -#define LAPACK_dtpcon LAPACK_GLOBAL(dtpcon,DTPCON) -#define LAPACK_ctpcon LAPACK_GLOBAL(ctpcon,CTPCON) -#define LAPACK_ztpcon LAPACK_GLOBAL(ztpcon,ZTPCON) -#define LAPACK_stbcon LAPACK_GLOBAL(stbcon,STBCON) -#define LAPACK_dtbcon LAPACK_GLOBAL(dtbcon,DTBCON) -#define LAPACK_ctbcon LAPACK_GLOBAL(ctbcon,CTBCON) -#define LAPACK_ztbcon LAPACK_GLOBAL(ztbcon,ZTBCON) -#define LAPACK_sgerfs LAPACK_GLOBAL(sgerfs,SGERFS) -#define LAPACK_dgerfs LAPACK_GLOBAL(dgerfs,DGERFS) -#define LAPACK_cgerfs LAPACK_GLOBAL(cgerfs,CGERFS) -#define LAPACK_zgerfs LAPACK_GLOBAL(zgerfs,ZGERFS) -#define LAPACK_dgerfsx LAPACK_GLOBAL(dgerfsx,DGERFSX) -#define LAPACK_sgerfsx LAPACK_GLOBAL(sgerfsx,SGERFSX) -#define LAPACK_zgerfsx LAPACK_GLOBAL(zgerfsx,ZGERFSX) -#define LAPACK_cgerfsx LAPACK_GLOBAL(cgerfsx,CGERFSX) -#define LAPACK_sgbrfs LAPACK_GLOBAL(sgbrfs,SGBRFS) -#define LAPACK_dgbrfs LAPACK_GLOBAL(dgbrfs,DGBRFS) -#define LAPACK_cgbrfs LAPACK_GLOBAL(cgbrfs,CGBRFS) -#define LAPACK_zgbrfs LAPACK_GLOBAL(zgbrfs,ZGBRFS) -#define LAPACK_dgbrfsx LAPACK_GLOBAL(dgbrfsx,DGBRFSX) -#define LAPACK_sgbrfsx LAPACK_GLOBAL(sgbrfsx,SGBRFSX) -#define LAPACK_zgbrfsx LAPACK_GLOBAL(zgbrfsx,ZGBRFSX) -#define LAPACK_cgbrfsx LAPACK_GLOBAL(cgbrfsx,CGBRFSX) -#define LAPACK_sgtrfs LAPACK_GLOBAL(sgtrfs,SGTRFS) -#define LAPACK_dgtrfs LAPACK_GLOBAL(dgtrfs,DGTRFS) -#define LAPACK_cgtrfs LAPACK_GLOBAL(cgtrfs,CGTRFS) -#define LAPACK_zgtrfs LAPACK_GLOBAL(zgtrfs,ZGTRFS) -#define LAPACK_sporfs LAPACK_GLOBAL(sporfs,SPORFS) -#define LAPACK_dporfs LAPACK_GLOBAL(dporfs,DPORFS) -#define LAPACK_cporfs LAPACK_GLOBAL(cporfs,CPORFS) -#define LAPACK_zporfs LAPACK_GLOBAL(zporfs,ZPORFS) -#define LAPACK_dporfsx LAPACK_GLOBAL(dporfsx,DPORFSX) -#define LAPACK_sporfsx LAPACK_GLOBAL(sporfsx,SPORFSX) -#define LAPACK_zporfsx LAPACK_GLOBAL(zporfsx,ZPORFSX) -#define LAPACK_cporfsx LAPACK_GLOBAL(cporfsx,CPORFSX) -#define LAPACK_spprfs LAPACK_GLOBAL(spprfs,SPPRFS) -#define LAPACK_dpprfs LAPACK_GLOBAL(dpprfs,DPPRFS) -#define LAPACK_cpprfs LAPACK_GLOBAL(cpprfs,CPPRFS) -#define LAPACK_zpprfs LAPACK_GLOBAL(zpprfs,ZPPRFS) -#define LAPACK_spbrfs LAPACK_GLOBAL(spbrfs,SPBRFS) -#define LAPACK_dpbrfs LAPACK_GLOBAL(dpbrfs,DPBRFS) -#define LAPACK_cpbrfs LAPACK_GLOBAL(cpbrfs,CPBRFS) -#define LAPACK_zpbrfs LAPACK_GLOBAL(zpbrfs,ZPBRFS) -#define LAPACK_sptrfs LAPACK_GLOBAL(sptrfs,SPTRFS) -#define LAPACK_dptrfs LAPACK_GLOBAL(dptrfs,DPTRFS) -#define LAPACK_cptrfs LAPACK_GLOBAL(cptrfs,CPTRFS) -#define LAPACK_zptrfs LAPACK_GLOBAL(zptrfs,ZPTRFS) -#define LAPACK_ssyrfs LAPACK_GLOBAL(ssyrfs,SSYRFS) -#define LAPACK_dsyrfs LAPACK_GLOBAL(dsyrfs,DSYRFS) -#define LAPACK_csyrfs LAPACK_GLOBAL(csyrfs,CSYRFS) -#define LAPACK_zsyrfs LAPACK_GLOBAL(zsyrfs,ZSYRFS) -#define LAPACK_dsyrfsx LAPACK_GLOBAL(dsyrfsx,DSYRFSX) -#define LAPACK_ssyrfsx LAPACK_GLOBAL(ssyrfsx,SSYRFSX) -#define LAPACK_zsyrfsx LAPACK_GLOBAL(zsyrfsx,ZSYRFSX) -#define LAPACK_csyrfsx LAPACK_GLOBAL(csyrfsx,CSYRFSX) -#define LAPACK_cherfs LAPACK_GLOBAL(cherfs,CHERFS) -#define LAPACK_zherfs LAPACK_GLOBAL(zherfs,ZHERFS) -#define LAPACK_zherfsx LAPACK_GLOBAL(zherfsx,ZHERFSX) -#define LAPACK_cherfsx LAPACK_GLOBAL(cherfsx,CHERFSX) -#define LAPACK_ssprfs LAPACK_GLOBAL(ssprfs,SSPRFS) -#define LAPACK_dsprfs LAPACK_GLOBAL(dsprfs,DSPRFS) -#define LAPACK_csprfs LAPACK_GLOBAL(csprfs,CSPRFS) -#define LAPACK_zsprfs LAPACK_GLOBAL(zsprfs,ZSPRFS) -#define LAPACK_chprfs LAPACK_GLOBAL(chprfs,CHPRFS) -#define LAPACK_zhprfs LAPACK_GLOBAL(zhprfs,ZHPRFS) -#define LAPACK_strrfs LAPACK_GLOBAL(strrfs,STRRFS) -#define LAPACK_dtrrfs LAPACK_GLOBAL(dtrrfs,DTRRFS) -#define LAPACK_ctrrfs LAPACK_GLOBAL(ctrrfs,CTRRFS) -#define LAPACK_ztrrfs LAPACK_GLOBAL(ztrrfs,ZTRRFS) -#define LAPACK_stprfs LAPACK_GLOBAL(stprfs,STPRFS) -#define LAPACK_dtprfs LAPACK_GLOBAL(dtprfs,DTPRFS) -#define LAPACK_ctprfs LAPACK_GLOBAL(ctprfs,CTPRFS) -#define LAPACK_ztprfs LAPACK_GLOBAL(ztprfs,ZTPRFS) -#define LAPACK_stbrfs LAPACK_GLOBAL(stbrfs,STBRFS) -#define LAPACK_dtbrfs LAPACK_GLOBAL(dtbrfs,DTBRFS) -#define LAPACK_ctbrfs LAPACK_GLOBAL(ctbrfs,CTBRFS) -#define LAPACK_ztbrfs LAPACK_GLOBAL(ztbrfs,ZTBRFS) -#define LAPACK_sgetri LAPACK_GLOBAL(sgetri,SGETRI) -#define LAPACK_dgetri LAPACK_GLOBAL(dgetri,DGETRI) -#define LAPACK_cgetri LAPACK_GLOBAL(cgetri,CGETRI) -#define LAPACK_zgetri LAPACK_GLOBAL(zgetri,ZGETRI) -#define LAPACK_spotri LAPACK_GLOBAL(spotri,SPOTRI) -#define LAPACK_dpotri LAPACK_GLOBAL(dpotri,DPOTRI) -#define LAPACK_cpotri LAPACK_GLOBAL(cpotri,CPOTRI) -#define LAPACK_zpotri LAPACK_GLOBAL(zpotri,ZPOTRI) -#define LAPACK_dpftri LAPACK_GLOBAL(dpftri,DPFTRI) -#define LAPACK_spftri LAPACK_GLOBAL(spftri,SPFTRI) -#define LAPACK_zpftri LAPACK_GLOBAL(zpftri,ZPFTRI) -#define LAPACK_cpftri LAPACK_GLOBAL(cpftri,CPFTRI) -#define LAPACK_spptri LAPACK_GLOBAL(spptri,SPPTRI) -#define LAPACK_dpptri LAPACK_GLOBAL(dpptri,DPPTRI) -#define LAPACK_cpptri LAPACK_GLOBAL(cpptri,CPPTRI) -#define LAPACK_zpptri LAPACK_GLOBAL(zpptri,ZPPTRI) -#define LAPACK_ssytri LAPACK_GLOBAL(ssytri,SSYTRI) -#define LAPACK_dsytri LAPACK_GLOBAL(dsytri,DSYTRI) -#define LAPACK_csytri LAPACK_GLOBAL(csytri,CSYTRI) -#define LAPACK_zsytri LAPACK_GLOBAL(zsytri,ZSYTRI) -#define LAPACK_chetri LAPACK_GLOBAL(chetri,CHETRI) -#define LAPACK_zhetri LAPACK_GLOBAL(zhetri,ZHETRI) -#define LAPACK_ssptri LAPACK_GLOBAL(ssptri,SSPTRI) -#define LAPACK_dsptri LAPACK_GLOBAL(dsptri,DSPTRI) -#define LAPACK_csptri LAPACK_GLOBAL(csptri,CSPTRI) -#define LAPACK_zsptri LAPACK_GLOBAL(zsptri,ZSPTRI) -#define LAPACK_chptri LAPACK_GLOBAL(chptri,CHPTRI) -#define LAPACK_zhptri LAPACK_GLOBAL(zhptri,ZHPTRI) -#define LAPACK_strtri LAPACK_GLOBAL(strtri,STRTRI) -#define LAPACK_dtrtri LAPACK_GLOBAL(dtrtri,DTRTRI) -#define LAPACK_ctrtri LAPACK_GLOBAL(ctrtri,CTRTRI) -#define LAPACK_ztrtri LAPACK_GLOBAL(ztrtri,ZTRTRI) -#define LAPACK_dtftri LAPACK_GLOBAL(dtftri,DTFTRI) -#define LAPACK_stftri LAPACK_GLOBAL(stftri,STFTRI) -#define LAPACK_ztftri LAPACK_GLOBAL(ztftri,ZTFTRI) -#define LAPACK_ctftri LAPACK_GLOBAL(ctftri,CTFTRI) -#define LAPACK_stptri LAPACK_GLOBAL(stptri,STPTRI) -#define LAPACK_dtptri LAPACK_GLOBAL(dtptri,DTPTRI) -#define LAPACK_ctptri LAPACK_GLOBAL(ctptri,CTPTRI) -#define LAPACK_ztptri LAPACK_GLOBAL(ztptri,ZTPTRI) -#define LAPACK_sgeequ LAPACK_GLOBAL(sgeequ,SGEEQU) -#define LAPACK_dgeequ LAPACK_GLOBAL(dgeequ,DGEEQU) -#define LAPACK_cgeequ LAPACK_GLOBAL(cgeequ,CGEEQU) -#define LAPACK_zgeequ LAPACK_GLOBAL(zgeequ,ZGEEQU) -#define LAPACK_dgeequb LAPACK_GLOBAL(dgeequb,DGEEQUB) -#define LAPACK_sgeequb LAPACK_GLOBAL(sgeequb,SGEEQUB) -#define LAPACK_zgeequb LAPACK_GLOBAL(zgeequb,ZGEEQUB) -#define LAPACK_cgeequb LAPACK_GLOBAL(cgeequb,CGEEQUB) -#define LAPACK_sgbequ LAPACK_GLOBAL(sgbequ,SGBEQU) -#define LAPACK_dgbequ LAPACK_GLOBAL(dgbequ,DGBEQU) -#define LAPACK_cgbequ LAPACK_GLOBAL(cgbequ,CGBEQU) -#define LAPACK_zgbequ LAPACK_GLOBAL(zgbequ,ZGBEQU) -#define LAPACK_dgbequb LAPACK_GLOBAL(dgbequb,DGBEQUB) -#define LAPACK_sgbequb LAPACK_GLOBAL(sgbequb,SGBEQUB) -#define LAPACK_zgbequb LAPACK_GLOBAL(zgbequb,ZGBEQUB) -#define LAPACK_cgbequb LAPACK_GLOBAL(cgbequb,CGBEQUB) -#define LAPACK_spoequ LAPACK_GLOBAL(spoequ,SPOEQU) -#define LAPACK_dpoequ LAPACK_GLOBAL(dpoequ,DPOEQU) -#define LAPACK_cpoequ LAPACK_GLOBAL(cpoequ,CPOEQU) -#define LAPACK_zpoequ LAPACK_GLOBAL(zpoequ,ZPOEQU) -#define LAPACK_dpoequb LAPACK_GLOBAL(dpoequb,DPOEQUB) -#define LAPACK_spoequb LAPACK_GLOBAL(spoequb,SPOEQUB) -#define LAPACK_zpoequb LAPACK_GLOBAL(zpoequb,ZPOEQUB) -#define LAPACK_cpoequb LAPACK_GLOBAL(cpoequb,CPOEQUB) -#define LAPACK_sppequ LAPACK_GLOBAL(sppequ,SPPEQU) -#define LAPACK_dppequ LAPACK_GLOBAL(dppequ,DPPEQU) -#define LAPACK_cppequ LAPACK_GLOBAL(cppequ,CPPEQU) -#define LAPACK_zppequ LAPACK_GLOBAL(zppequ,ZPPEQU) -#define LAPACK_spbequ LAPACK_GLOBAL(spbequ,SPBEQU) -#define LAPACK_dpbequ LAPACK_GLOBAL(dpbequ,DPBEQU) -#define LAPACK_cpbequ LAPACK_GLOBAL(cpbequ,CPBEQU) -#define LAPACK_zpbequ LAPACK_GLOBAL(zpbequ,ZPBEQU) -#define LAPACK_dsyequb LAPACK_GLOBAL(dsyequb,DSYEQUB) -#define LAPACK_ssyequb LAPACK_GLOBAL(ssyequb,SSYEQUB) -#define LAPACK_zsyequb LAPACK_GLOBAL(zsyequb,ZSYEQUB) -#define LAPACK_csyequb LAPACK_GLOBAL(csyequb,CSYEQUB) -#define LAPACK_zheequb LAPACK_GLOBAL(zheequb,ZHEEQUB) -#define LAPACK_cheequb LAPACK_GLOBAL(cheequb,CHEEQUB) -#define LAPACK_sgesv LAPACK_GLOBAL(sgesv,SGESV) -#define LAPACK_dgesv LAPACK_GLOBAL(dgesv,DGESV) -#define LAPACK_cgesv LAPACK_GLOBAL(cgesv,CGESV) -#define LAPACK_zgesv LAPACK_GLOBAL(zgesv,ZGESV) -#define LAPACK_dsgesv LAPACK_GLOBAL(dsgesv,DSGESV) -#define LAPACK_zcgesv LAPACK_GLOBAL(zcgesv,ZCGESV) -#define LAPACK_sgesvx LAPACK_GLOBAL(sgesvx,SGESVX) -#define LAPACK_dgesvx LAPACK_GLOBAL(dgesvx,DGESVX) -#define LAPACK_cgesvx LAPACK_GLOBAL(cgesvx,CGESVX) -#define LAPACK_zgesvx LAPACK_GLOBAL(zgesvx,ZGESVX) -#define LAPACK_dgesvxx LAPACK_GLOBAL(dgesvxx,DGESVXX) -#define LAPACK_sgesvxx LAPACK_GLOBAL(sgesvxx,SGESVXX) -#define LAPACK_zgesvxx LAPACK_GLOBAL(zgesvxx,ZGESVXX) -#define LAPACK_cgesvxx LAPACK_GLOBAL(cgesvxx,CGESVXX) -#define LAPACK_sgbsv LAPACK_GLOBAL(sgbsv,SGBSV) -#define LAPACK_dgbsv LAPACK_GLOBAL(dgbsv,DGBSV) -#define LAPACK_cgbsv LAPACK_GLOBAL(cgbsv,CGBSV) -#define LAPACK_zgbsv LAPACK_GLOBAL(zgbsv,ZGBSV) -#define LAPACK_sgbsvx LAPACK_GLOBAL(sgbsvx,SGBSVX) -#define LAPACK_dgbsvx LAPACK_GLOBAL(dgbsvx,DGBSVX) -#define LAPACK_cgbsvx LAPACK_GLOBAL(cgbsvx,CGBSVX) -#define LAPACK_zgbsvx LAPACK_GLOBAL(zgbsvx,ZGBSVX) -#define LAPACK_dgbsvxx LAPACK_GLOBAL(dgbsvxx,DGBSVXX) -#define LAPACK_sgbsvxx LAPACK_GLOBAL(sgbsvxx,SGBSVXX) -#define LAPACK_zgbsvxx LAPACK_GLOBAL(zgbsvxx,ZGBSVXX) -#define LAPACK_cgbsvxx LAPACK_GLOBAL(cgbsvxx,CGBSVXX) -#define LAPACK_sgtsv LAPACK_GLOBAL(sgtsv,SGTSV) -#define LAPACK_dgtsv LAPACK_GLOBAL(dgtsv,DGTSV) -#define LAPACK_cgtsv LAPACK_GLOBAL(cgtsv,CGTSV) -#define LAPACK_zgtsv LAPACK_GLOBAL(zgtsv,ZGTSV) -#define LAPACK_sgtsvx LAPACK_GLOBAL(sgtsvx,SGTSVX) -#define LAPACK_dgtsvx LAPACK_GLOBAL(dgtsvx,DGTSVX) -#define LAPACK_cgtsvx LAPACK_GLOBAL(cgtsvx,CGTSVX) -#define LAPACK_zgtsvx LAPACK_GLOBAL(zgtsvx,ZGTSVX) -#define LAPACK_sposv LAPACK_GLOBAL(sposv,SPOSV) -#define LAPACK_dposv LAPACK_GLOBAL(dposv,DPOSV) -#define LAPACK_cposv LAPACK_GLOBAL(cposv,CPOSV) -#define LAPACK_zposv LAPACK_GLOBAL(zposv,ZPOSV) -#define LAPACK_dsposv LAPACK_GLOBAL(dsposv,DSPOSV) -#define LAPACK_zcposv LAPACK_GLOBAL(zcposv,ZCPOSV) -#define LAPACK_sposvx LAPACK_GLOBAL(sposvx,SPOSVX) -#define LAPACK_dposvx LAPACK_GLOBAL(dposvx,DPOSVX) -#define LAPACK_cposvx LAPACK_GLOBAL(cposvx,CPOSVX) -#define LAPACK_zposvx LAPACK_GLOBAL(zposvx,ZPOSVX) -#define LAPACK_dposvxx LAPACK_GLOBAL(dposvxx,DPOSVXX) -#define LAPACK_sposvxx LAPACK_GLOBAL(sposvxx,SPOSVXX) -#define LAPACK_zposvxx LAPACK_GLOBAL(zposvxx,ZPOSVXX) -#define LAPACK_cposvxx LAPACK_GLOBAL(cposvxx,CPOSVXX) -#define LAPACK_sppsv LAPACK_GLOBAL(sppsv,SPPSV) -#define LAPACK_dppsv LAPACK_GLOBAL(dppsv,DPPSV) -#define LAPACK_cppsv LAPACK_GLOBAL(cppsv,CPPSV) -#define LAPACK_zppsv LAPACK_GLOBAL(zppsv,ZPPSV) -#define LAPACK_sppsvx LAPACK_GLOBAL(sppsvx,SPPSVX) -#define LAPACK_dppsvx LAPACK_GLOBAL(dppsvx,DPPSVX) -#define LAPACK_cppsvx LAPACK_GLOBAL(cppsvx,CPPSVX) -#define LAPACK_zppsvx LAPACK_GLOBAL(zppsvx,ZPPSVX) -#define LAPACK_spbsv LAPACK_GLOBAL(spbsv,SPBSV) -#define LAPACK_dpbsv LAPACK_GLOBAL(dpbsv,DPBSV) -#define LAPACK_cpbsv LAPACK_GLOBAL(cpbsv,CPBSV) -#define LAPACK_zpbsv LAPACK_GLOBAL(zpbsv,ZPBSV) -#define LAPACK_spbsvx LAPACK_GLOBAL(spbsvx,SPBSVX) -#define LAPACK_dpbsvx LAPACK_GLOBAL(dpbsvx,DPBSVX) -#define LAPACK_cpbsvx LAPACK_GLOBAL(cpbsvx,CPBSVX) -#define LAPACK_zpbsvx LAPACK_GLOBAL(zpbsvx,ZPBSVX) -#define LAPACK_sptsv LAPACK_GLOBAL(sptsv,SPTSV) -#define LAPACK_dptsv LAPACK_GLOBAL(dptsv,DPTSV) -#define LAPACK_cptsv LAPACK_GLOBAL(cptsv,CPTSV) -#define LAPACK_zptsv LAPACK_GLOBAL(zptsv,ZPTSV) -#define LAPACK_sptsvx LAPACK_GLOBAL(sptsvx,SPTSVX) -#define LAPACK_dptsvx LAPACK_GLOBAL(dptsvx,DPTSVX) -#define LAPACK_cptsvx LAPACK_GLOBAL(cptsvx,CPTSVX) -#define LAPACK_zptsvx LAPACK_GLOBAL(zptsvx,ZPTSVX) -#define LAPACK_ssysv LAPACK_GLOBAL(ssysv,SSYSV) -#define LAPACK_dsysv LAPACK_GLOBAL(dsysv,DSYSV) -#define LAPACK_csysv LAPACK_GLOBAL(csysv,CSYSV) -#define LAPACK_zsysv LAPACK_GLOBAL(zsysv,ZSYSV) -#define LAPACK_ssysvx LAPACK_GLOBAL(ssysvx,SSYSVX) -#define LAPACK_dsysvx LAPACK_GLOBAL(dsysvx,DSYSVX) -#define LAPACK_csysvx LAPACK_GLOBAL(csysvx,CSYSVX) -#define LAPACK_zsysvx LAPACK_GLOBAL(zsysvx,ZSYSVX) -#define LAPACK_dsysvxx LAPACK_GLOBAL(dsysvxx,DSYSVXX) -#define LAPACK_ssysvxx LAPACK_GLOBAL(ssysvxx,SSYSVXX) -#define LAPACK_zsysvxx LAPACK_GLOBAL(zsysvxx,ZSYSVXX) -#define LAPACK_csysvxx LAPACK_GLOBAL(csysvxx,CSYSVXX) -#define LAPACK_chesv LAPACK_GLOBAL(chesv,CHESV) -#define LAPACK_zhesv LAPACK_GLOBAL(zhesv,ZHESV) -#define LAPACK_chesvx LAPACK_GLOBAL(chesvx,CHESVX) -#define LAPACK_zhesvx LAPACK_GLOBAL(zhesvx,ZHESVX) -#define LAPACK_zhesvxx LAPACK_GLOBAL(zhesvxx,ZHESVXX) -#define LAPACK_chesvxx LAPACK_GLOBAL(chesvxx,CHESVXX) -#define LAPACK_sspsv LAPACK_GLOBAL(sspsv,SSPSV) -#define LAPACK_dspsv LAPACK_GLOBAL(dspsv,DSPSV) -#define LAPACK_cspsv LAPACK_GLOBAL(cspsv,CSPSV) -#define LAPACK_zspsv LAPACK_GLOBAL(zspsv,ZSPSV) -#define LAPACK_sspsvx LAPACK_GLOBAL(sspsvx,SSPSVX) -#define LAPACK_dspsvx LAPACK_GLOBAL(dspsvx,DSPSVX) -#define LAPACK_cspsvx LAPACK_GLOBAL(cspsvx,CSPSVX) -#define LAPACK_zspsvx LAPACK_GLOBAL(zspsvx,ZSPSVX) -#define LAPACK_chpsv LAPACK_GLOBAL(chpsv,CHPSV) -#define LAPACK_zhpsv LAPACK_GLOBAL(zhpsv,ZHPSV) -#define LAPACK_chpsvx LAPACK_GLOBAL(chpsvx,CHPSVX) -#define LAPACK_zhpsvx LAPACK_GLOBAL(zhpsvx,ZHPSVX) -#define LAPACK_sgeqrf LAPACK_GLOBAL(sgeqrf,SGEQRF) -#define LAPACK_dgeqrf LAPACK_GLOBAL(dgeqrf,DGEQRF) -#define LAPACK_cgeqrf LAPACK_GLOBAL(cgeqrf,CGEQRF) -#define LAPACK_zgeqrf LAPACK_GLOBAL(zgeqrf,ZGEQRF) -#define LAPACK_sgeqpf LAPACK_GLOBAL(sgeqpf,SGEQPF) -#define LAPACK_dgeqpf LAPACK_GLOBAL(dgeqpf,DGEQPF) -#define LAPACK_cgeqpf LAPACK_GLOBAL(cgeqpf,CGEQPF) -#define LAPACK_zgeqpf LAPACK_GLOBAL(zgeqpf,ZGEQPF) -#define LAPACK_sgeqp3 LAPACK_GLOBAL(sgeqp3,SGEQP3) -#define LAPACK_dgeqp3 LAPACK_GLOBAL(dgeqp3,DGEQP3) -#define LAPACK_cgeqp3 LAPACK_GLOBAL(cgeqp3,CGEQP3) -#define LAPACK_zgeqp3 LAPACK_GLOBAL(zgeqp3,ZGEQP3) -#define LAPACK_sorgqr LAPACK_GLOBAL(sorgqr,SORGQR) -#define LAPACK_dorgqr LAPACK_GLOBAL(dorgqr,DORGQR) -#define LAPACK_sormqr LAPACK_GLOBAL(sormqr,SORMQR) -#define LAPACK_dormqr LAPACK_GLOBAL(dormqr,DORMQR) -#define LAPACK_cungqr LAPACK_GLOBAL(cungqr,CUNGQR) -#define LAPACK_zungqr LAPACK_GLOBAL(zungqr,ZUNGQR) -#define LAPACK_cunmqr LAPACK_GLOBAL(cunmqr,CUNMQR) -#define LAPACK_zunmqr LAPACK_GLOBAL(zunmqr,ZUNMQR) -#define LAPACK_sgelqf LAPACK_GLOBAL(sgelqf,SGELQF) -#define LAPACK_dgelqf LAPACK_GLOBAL(dgelqf,DGELQF) -#define LAPACK_cgelqf LAPACK_GLOBAL(cgelqf,CGELQF) -#define LAPACK_zgelqf LAPACK_GLOBAL(zgelqf,ZGELQF) -#define LAPACK_sorglq LAPACK_GLOBAL(sorglq,SORGLQ) -#define LAPACK_dorglq LAPACK_GLOBAL(dorglq,DORGLQ) -#define LAPACK_sormlq LAPACK_GLOBAL(sormlq,SORMLQ) -#define LAPACK_dormlq LAPACK_GLOBAL(dormlq,DORMLQ) -#define LAPACK_cunglq LAPACK_GLOBAL(cunglq,CUNGLQ) -#define LAPACK_zunglq LAPACK_GLOBAL(zunglq,ZUNGLQ) -#define LAPACK_cunmlq LAPACK_GLOBAL(cunmlq,CUNMLQ) -#define LAPACK_zunmlq LAPACK_GLOBAL(zunmlq,ZUNMLQ) -#define LAPACK_sgeqlf LAPACK_GLOBAL(sgeqlf,SGEQLF) -#define LAPACK_dgeqlf LAPACK_GLOBAL(dgeqlf,DGEQLF) -#define LAPACK_cgeqlf LAPACK_GLOBAL(cgeqlf,CGEQLF) -#define LAPACK_zgeqlf LAPACK_GLOBAL(zgeqlf,ZGEQLF) -#define LAPACK_sorgql LAPACK_GLOBAL(sorgql,SORGQL) -#define LAPACK_dorgql LAPACK_GLOBAL(dorgql,DORGQL) -#define LAPACK_cungql LAPACK_GLOBAL(cungql,CUNGQL) -#define LAPACK_zungql LAPACK_GLOBAL(zungql,ZUNGQL) -#define LAPACK_sormql LAPACK_GLOBAL(sormql,SORMQL) -#define LAPACK_dormql LAPACK_GLOBAL(dormql,DORMQL) -#define LAPACK_cunmql LAPACK_GLOBAL(cunmql,CUNMQL) -#define LAPACK_zunmql LAPACK_GLOBAL(zunmql,ZUNMQL) -#define LAPACK_sgerqf LAPACK_GLOBAL(sgerqf,SGERQF) -#define LAPACK_dgerqf LAPACK_GLOBAL(dgerqf,DGERQF) -#define LAPACK_cgerqf LAPACK_GLOBAL(cgerqf,CGERQF) -#define LAPACK_zgerqf LAPACK_GLOBAL(zgerqf,ZGERQF) -#define LAPACK_sorgrq LAPACK_GLOBAL(sorgrq,SORGRQ) -#define LAPACK_dorgrq LAPACK_GLOBAL(dorgrq,DORGRQ) -#define LAPACK_cungrq LAPACK_GLOBAL(cungrq,CUNGRQ) -#define LAPACK_zungrq LAPACK_GLOBAL(zungrq,ZUNGRQ) -#define LAPACK_sormrq LAPACK_GLOBAL(sormrq,SORMRQ) -#define LAPACK_dormrq LAPACK_GLOBAL(dormrq,DORMRQ) -#define LAPACK_cunmrq LAPACK_GLOBAL(cunmrq,CUNMRQ) -#define LAPACK_zunmrq LAPACK_GLOBAL(zunmrq,ZUNMRQ) -#define LAPACK_stzrzf LAPACK_GLOBAL(stzrzf,STZRZF) -#define LAPACK_dtzrzf LAPACK_GLOBAL(dtzrzf,DTZRZF) -#define LAPACK_ctzrzf LAPACK_GLOBAL(ctzrzf,CTZRZF) -#define LAPACK_ztzrzf LAPACK_GLOBAL(ztzrzf,ZTZRZF) -#define LAPACK_sormrz LAPACK_GLOBAL(sormrz,SORMRZ) -#define LAPACK_dormrz LAPACK_GLOBAL(dormrz,DORMRZ) -#define LAPACK_cunmrz LAPACK_GLOBAL(cunmrz,CUNMRZ) -#define LAPACK_zunmrz LAPACK_GLOBAL(zunmrz,ZUNMRZ) -#define LAPACK_sggqrf LAPACK_GLOBAL(sggqrf,SGGQRF) -#define LAPACK_dggqrf LAPACK_GLOBAL(dggqrf,DGGQRF) -#define LAPACK_cggqrf LAPACK_GLOBAL(cggqrf,CGGQRF) -#define LAPACK_zggqrf LAPACK_GLOBAL(zggqrf,ZGGQRF) -#define LAPACK_sggrqf LAPACK_GLOBAL(sggrqf,SGGRQF) -#define LAPACK_dggrqf LAPACK_GLOBAL(dggrqf,DGGRQF) -#define LAPACK_cggrqf LAPACK_GLOBAL(cggrqf,CGGRQF) -#define LAPACK_zggrqf LAPACK_GLOBAL(zggrqf,ZGGRQF) -#define LAPACK_sgebrd LAPACK_GLOBAL(sgebrd,SGEBRD) -#define LAPACK_dgebrd LAPACK_GLOBAL(dgebrd,DGEBRD) -#define LAPACK_cgebrd LAPACK_GLOBAL(cgebrd,CGEBRD) -#define LAPACK_zgebrd LAPACK_GLOBAL(zgebrd,ZGEBRD) -#define LAPACK_sgbbrd LAPACK_GLOBAL(sgbbrd,SGBBRD) -#define LAPACK_dgbbrd LAPACK_GLOBAL(dgbbrd,DGBBRD) -#define LAPACK_cgbbrd LAPACK_GLOBAL(cgbbrd,CGBBRD) -#define LAPACK_zgbbrd LAPACK_GLOBAL(zgbbrd,ZGBBRD) -#define LAPACK_sorgbr LAPACK_GLOBAL(sorgbr,SORGBR) -#define LAPACK_dorgbr LAPACK_GLOBAL(dorgbr,DORGBR) -#define LAPACK_sormbr LAPACK_GLOBAL(sormbr,SORMBR) -#define LAPACK_dormbr LAPACK_GLOBAL(dormbr,DORMBR) -#define LAPACK_cungbr LAPACK_GLOBAL(cungbr,CUNGBR) -#define LAPACK_zungbr LAPACK_GLOBAL(zungbr,ZUNGBR) -#define LAPACK_cunmbr LAPACK_GLOBAL(cunmbr,CUNMBR) -#define LAPACK_zunmbr LAPACK_GLOBAL(zunmbr,ZUNMBR) -#define LAPACK_sbdsqr LAPACK_GLOBAL(sbdsqr,SBDSQR) -#define LAPACK_dbdsqr LAPACK_GLOBAL(dbdsqr,DBDSQR) -#define LAPACK_cbdsqr LAPACK_GLOBAL(cbdsqr,CBDSQR) -#define LAPACK_zbdsqr LAPACK_GLOBAL(zbdsqr,ZBDSQR) -#define LAPACK_sbdsdc LAPACK_GLOBAL(sbdsdc,SBDSDC) -#define LAPACK_dbdsdc LAPACK_GLOBAL(dbdsdc,DBDSDC) -#define LAPACK_sbdsvdx LAPACK_GLOBAL(sbdsvdx,SBDSVDX) -#define LAPACK_dbdsvdx LAPACK_GLOBAL(dbdsvdx,DBDSVDX) -#define LAPACK_ssytrd LAPACK_GLOBAL(ssytrd,SSYTRD) -#define LAPACK_dsytrd LAPACK_GLOBAL(dsytrd,DSYTRD) -#define LAPACK_sorgtr LAPACK_GLOBAL(sorgtr,SORGTR) -#define LAPACK_dorgtr LAPACK_GLOBAL(dorgtr,DORGTR) -#define LAPACK_sormtr LAPACK_GLOBAL(sormtr,SORMTR) -#define LAPACK_dormtr LAPACK_GLOBAL(dormtr,DORMTR) -#define LAPACK_chetrd LAPACK_GLOBAL(chetrd,CHETRD) -#define LAPACK_zhetrd LAPACK_GLOBAL(zhetrd,ZHETRD) -#define LAPACK_cungtr LAPACK_GLOBAL(cungtr,CUNGTR) -#define LAPACK_zungtr LAPACK_GLOBAL(zungtr,ZUNGTR) -#define LAPACK_cunmtr LAPACK_GLOBAL(cunmtr,CUNMTR) -#define LAPACK_zunmtr LAPACK_GLOBAL(zunmtr,ZUNMTR) -#define LAPACK_ssptrd LAPACK_GLOBAL(ssptrd,SSPTRD) -#define LAPACK_dsptrd LAPACK_GLOBAL(dsptrd,DSPTRD) -#define LAPACK_sopgtr LAPACK_GLOBAL(sopgtr,SOPGTR) -#define LAPACK_dopgtr LAPACK_GLOBAL(dopgtr,DOPGTR) -#define LAPACK_sopmtr LAPACK_GLOBAL(sopmtr,SOPMTR) -#define LAPACK_dopmtr LAPACK_GLOBAL(dopmtr,DOPMTR) -#define LAPACK_chptrd LAPACK_GLOBAL(chptrd,CHPTRD) -#define LAPACK_zhptrd LAPACK_GLOBAL(zhptrd,ZHPTRD) -#define LAPACK_cupgtr LAPACK_GLOBAL(cupgtr,CUPGTR) -#define LAPACK_zupgtr LAPACK_GLOBAL(zupgtr,ZUPGTR) -#define LAPACK_cupmtr LAPACK_GLOBAL(cupmtr,CUPMTR) -#define LAPACK_zupmtr LAPACK_GLOBAL(zupmtr,ZUPMTR) -#define LAPACK_ssbtrd LAPACK_GLOBAL(ssbtrd,SSBTRD) -#define LAPACK_dsbtrd LAPACK_GLOBAL(dsbtrd,DSBTRD) -#define LAPACK_chbtrd LAPACK_GLOBAL(chbtrd,CHBTRD) -#define LAPACK_zhbtrd LAPACK_GLOBAL(zhbtrd,ZHBTRD) -#define LAPACK_ssterf LAPACK_GLOBAL(ssterf,SSTERF) -#define LAPACK_dsterf LAPACK_GLOBAL(dsterf,DSTERF) -#define LAPACK_ssteqr LAPACK_GLOBAL(ssteqr,SSTEQR) -#define LAPACK_dsteqr LAPACK_GLOBAL(dsteqr,DSTEQR) -#define LAPACK_csteqr LAPACK_GLOBAL(csteqr,CSTEQR) -#define LAPACK_zsteqr LAPACK_GLOBAL(zsteqr,ZSTEQR) -#define LAPACK_sstemr LAPACK_GLOBAL(sstemr,SSTEMR) -#define LAPACK_dstemr LAPACK_GLOBAL(dstemr,DSTEMR) -#define LAPACK_cstemr LAPACK_GLOBAL(cstemr,CSTEMR) -#define LAPACK_zstemr LAPACK_GLOBAL(zstemr,ZSTEMR) -#define LAPACK_sstedc LAPACK_GLOBAL(sstedc,SSTEDC) -#define LAPACK_dstedc LAPACK_GLOBAL(dstedc,DSTEDC) -#define LAPACK_cstedc LAPACK_GLOBAL(cstedc,CSTEDC) -#define LAPACK_zstedc LAPACK_GLOBAL(zstedc,ZSTEDC) -#define LAPACK_sstegr LAPACK_GLOBAL(sstegr,SSTEGR) -#define LAPACK_dstegr LAPACK_GLOBAL(dstegr,DSTEGR) -#define LAPACK_cstegr LAPACK_GLOBAL(cstegr,CSTEGR) -#define LAPACK_zstegr LAPACK_GLOBAL(zstegr,ZSTEGR) -#define LAPACK_spteqr LAPACK_GLOBAL(spteqr,SPTEQR) -#define LAPACK_dpteqr LAPACK_GLOBAL(dpteqr,DPTEQR) -#define LAPACK_cpteqr LAPACK_GLOBAL(cpteqr,CPTEQR) -#define LAPACK_zpteqr LAPACK_GLOBAL(zpteqr,ZPTEQR) -#define LAPACK_sstebz LAPACK_GLOBAL(sstebz,SSTEBZ) -#define LAPACK_dstebz LAPACK_GLOBAL(dstebz,DSTEBZ) -#define LAPACK_sstein LAPACK_GLOBAL(sstein,SSTEIN) -#define LAPACK_dstein LAPACK_GLOBAL(dstein,DSTEIN) -#define LAPACK_cstein LAPACK_GLOBAL(cstein,CSTEIN) -#define LAPACK_zstein LAPACK_GLOBAL(zstein,ZSTEIN) -#define LAPACK_sdisna LAPACK_GLOBAL(sdisna,SDISNA) -#define LAPACK_ddisna LAPACK_GLOBAL(ddisna,DDISNA) -#define LAPACK_ssygst LAPACK_GLOBAL(ssygst,SSYGST) -#define LAPACK_dsygst LAPACK_GLOBAL(dsygst,DSYGST) -#define LAPACK_chegst LAPACK_GLOBAL(chegst,CHEGST) -#define LAPACK_zhegst LAPACK_GLOBAL(zhegst,ZHEGST) -#define LAPACK_sspgst LAPACK_GLOBAL(sspgst,SSPGST) -#define LAPACK_dspgst LAPACK_GLOBAL(dspgst,DSPGST) -#define LAPACK_chpgst LAPACK_GLOBAL(chpgst,CHPGST) -#define LAPACK_zhpgst LAPACK_GLOBAL(zhpgst,ZHPGST) -#define LAPACK_ssbgst LAPACK_GLOBAL(ssbgst,SSBGST) -#define LAPACK_dsbgst LAPACK_GLOBAL(dsbgst,DSBGST) -#define LAPACK_chbgst LAPACK_GLOBAL(chbgst,CHBGST) -#define LAPACK_zhbgst LAPACK_GLOBAL(zhbgst,ZHBGST) -#define LAPACK_spbstf LAPACK_GLOBAL(spbstf,SPBSTF) -#define LAPACK_dpbstf LAPACK_GLOBAL(dpbstf,DPBSTF) -#define LAPACK_cpbstf LAPACK_GLOBAL(cpbstf,CPBSTF) -#define LAPACK_zpbstf LAPACK_GLOBAL(zpbstf,ZPBSTF) -#define LAPACK_sgehrd LAPACK_GLOBAL(sgehrd,SGEHRD) -#define LAPACK_dgehrd LAPACK_GLOBAL(dgehrd,DGEHRD) -#define LAPACK_cgehrd LAPACK_GLOBAL(cgehrd,CGEHRD) -#define LAPACK_zgehrd LAPACK_GLOBAL(zgehrd,ZGEHRD) -#define LAPACK_sorghr LAPACK_GLOBAL(sorghr,SORGHR) -#define LAPACK_dorghr LAPACK_GLOBAL(dorghr,DORGHR) -#define LAPACK_sormhr LAPACK_GLOBAL(sormhr,SORMHR) -#define LAPACK_dormhr LAPACK_GLOBAL(dormhr,DORMHR) -#define LAPACK_cunghr LAPACK_GLOBAL(cunghr,CUNGHR) -#define LAPACK_zunghr LAPACK_GLOBAL(zunghr,ZUNGHR) -#define LAPACK_cunmhr LAPACK_GLOBAL(cunmhr,CUNMHR) -#define LAPACK_zunmhr LAPACK_GLOBAL(zunmhr,ZUNMHR) -#define LAPACK_sgebal LAPACK_GLOBAL(sgebal,SGEBAL) -#define LAPACK_dgebal LAPACK_GLOBAL(dgebal,DGEBAL) -#define LAPACK_cgebal LAPACK_GLOBAL(cgebal,CGEBAL) -#define LAPACK_zgebal LAPACK_GLOBAL(zgebal,ZGEBAL) -#define LAPACK_sgebak LAPACK_GLOBAL(sgebak,SGEBAK) -#define LAPACK_dgebak LAPACK_GLOBAL(dgebak,DGEBAK) -#define LAPACK_cgebak LAPACK_GLOBAL(cgebak,CGEBAK) -#define LAPACK_zgebak LAPACK_GLOBAL(zgebak,ZGEBAK) -#define LAPACK_shseqr LAPACK_GLOBAL(shseqr,SHSEQR) -#define LAPACK_dhseqr LAPACK_GLOBAL(dhseqr,DHSEQR) -#define LAPACK_chseqr LAPACK_GLOBAL(chseqr,CHSEQR) -#define LAPACK_zhseqr LAPACK_GLOBAL(zhseqr,ZHSEQR) -#define LAPACK_shsein LAPACK_GLOBAL(shsein,SHSEIN) -#define LAPACK_dhsein LAPACK_GLOBAL(dhsein,DHSEIN) -#define LAPACK_chsein LAPACK_GLOBAL(chsein,CHSEIN) -#define LAPACK_zhsein LAPACK_GLOBAL(zhsein,ZHSEIN) -#define LAPACK_strevc LAPACK_GLOBAL(strevc,STREVC) -#define LAPACK_dtrevc LAPACK_GLOBAL(dtrevc,DTREVC) -#define LAPACK_ctrevc LAPACK_GLOBAL(ctrevc,CTREVC) -#define LAPACK_ztrevc LAPACK_GLOBAL(ztrevc,ZTREVC) -#define LAPACK_strsna LAPACK_GLOBAL(strsna,STRSNA) -#define LAPACK_dtrsna LAPACK_GLOBAL(dtrsna,DTRSNA) -#define LAPACK_ctrsna LAPACK_GLOBAL(ctrsna,CTRSNA) -#define LAPACK_ztrsna LAPACK_GLOBAL(ztrsna,ZTRSNA) -#define LAPACK_strexc LAPACK_GLOBAL(strexc,STREXC) -#define LAPACK_dtrexc LAPACK_GLOBAL(dtrexc,DTREXC) -#define LAPACK_ctrexc LAPACK_GLOBAL(ctrexc,CTREXC) -#define LAPACK_ztrexc LAPACK_GLOBAL(ztrexc,ZTREXC) -#define LAPACK_strsen LAPACK_GLOBAL(strsen,STRSEN) -#define LAPACK_dtrsen LAPACK_GLOBAL(dtrsen,DTRSEN) -#define LAPACK_ctrsen LAPACK_GLOBAL(ctrsen,CTRSEN) -#define LAPACK_ztrsen LAPACK_GLOBAL(ztrsen,ZTRSEN) -#define LAPACK_strsyl LAPACK_GLOBAL(strsyl,STRSYL) -#define LAPACK_dtrsyl LAPACK_GLOBAL(dtrsyl,DTRSYL) -#define LAPACK_ctrsyl LAPACK_GLOBAL(ctrsyl,CTRSYL) -#define LAPACK_ztrsyl LAPACK_GLOBAL(ztrsyl,ZTRSYL) -#define LAPACK_sgghrd LAPACK_GLOBAL(sgghrd,SGGHRD) -#define LAPACK_dgghrd LAPACK_GLOBAL(dgghrd,DGGHRD) -#define LAPACK_cgghrd LAPACK_GLOBAL(cgghrd,CGGHRD) -#define LAPACK_zgghrd LAPACK_GLOBAL(zgghrd,ZGGHRD) -#define LAPACK_sgghd3 LAPACK_GLOBAL(sgghd3,SGGHD3) -#define LAPACK_dgghd3 LAPACK_GLOBAL(dgghd3,DGGHD3) -#define LAPACK_cgghd3 LAPACK_GLOBAL(cgghd3,CGGHD3) -#define LAPACK_zgghd3 LAPACK_GLOBAL(zgghd3,ZGGHD3) -#define LAPACK_sggbal LAPACK_GLOBAL(sggbal,SGGBAL) -#define LAPACK_dggbal LAPACK_GLOBAL(dggbal,DGGBAL) -#define LAPACK_cggbal LAPACK_GLOBAL(cggbal,CGGBAL) -#define LAPACK_zggbal LAPACK_GLOBAL(zggbal,ZGGBAL) -#define LAPACK_sggbak LAPACK_GLOBAL(sggbak,SGGBAK) -#define LAPACK_dggbak LAPACK_GLOBAL(dggbak,DGGBAK) -#define LAPACK_cggbak LAPACK_GLOBAL(cggbak,CGGBAK) -#define LAPACK_zggbak LAPACK_GLOBAL(zggbak,ZGGBAK) -#define LAPACK_shgeqz LAPACK_GLOBAL(shgeqz,SHGEQZ) -#define LAPACK_dhgeqz LAPACK_GLOBAL(dhgeqz,DHGEQZ) -#define LAPACK_chgeqz LAPACK_GLOBAL(chgeqz,CHGEQZ) -#define LAPACK_zhgeqz LAPACK_GLOBAL(zhgeqz,ZHGEQZ) -#define LAPACK_stgevc LAPACK_GLOBAL(stgevc,STGEVC) -#define LAPACK_dtgevc LAPACK_GLOBAL(dtgevc,DTGEVC) -#define LAPACK_ctgevc LAPACK_GLOBAL(ctgevc,CTGEVC) -#define LAPACK_ztgevc LAPACK_GLOBAL(ztgevc,ZTGEVC) -#define LAPACK_stgexc LAPACK_GLOBAL(stgexc,STGEXC) -#define LAPACK_dtgexc LAPACK_GLOBAL(dtgexc,DTGEXC) -#define LAPACK_ctgexc LAPACK_GLOBAL(ctgexc,CTGEXC) -#define LAPACK_ztgexc LAPACK_GLOBAL(ztgexc,ZTGEXC) -#define LAPACK_stgsen LAPACK_GLOBAL(stgsen,STGSEN) -#define LAPACK_dtgsen LAPACK_GLOBAL(dtgsen,DTGSEN) -#define LAPACK_ctgsen LAPACK_GLOBAL(ctgsen,CTGSEN) -#define LAPACK_ztgsen LAPACK_GLOBAL(ztgsen,ZTGSEN) -#define LAPACK_stgsyl LAPACK_GLOBAL(stgsyl,STGSYL) -#define LAPACK_dtgsyl LAPACK_GLOBAL(dtgsyl,DTGSYL) -#define LAPACK_ctgsyl LAPACK_GLOBAL(ctgsyl,CTGSYL) -#define LAPACK_ztgsyl LAPACK_GLOBAL(ztgsyl,ZTGSYL) -#define LAPACK_stgsna LAPACK_GLOBAL(stgsna,STGSNA) -#define LAPACK_dtgsna LAPACK_GLOBAL(dtgsna,DTGSNA) -#define LAPACK_ctgsna LAPACK_GLOBAL(ctgsna,CTGSNA) -#define LAPACK_ztgsna LAPACK_GLOBAL(ztgsna,ZTGSNA) -#define LAPACK_sggsvp LAPACK_GLOBAL(sggsvp,SGGSVP) -#define LAPACK_dggsvp LAPACK_GLOBAL(dggsvp,DGGSVP) -#define LAPACK_cggsvp LAPACK_GLOBAL(cggsvp,CGGSVP) -#define LAPACK_zggsvp LAPACK_GLOBAL(zggsvp,ZGGSVP) -#define LAPACK_sggsvp3 LAPACK_GLOBAL(sggsvp3,SGGSVP3) -#define LAPACK_dggsvp3 LAPACK_GLOBAL(dggsvp3,DGGSVP3) -#define LAPACK_cggsvp3 LAPACK_GLOBAL(cggsvp3,CGGSVP3) -#define LAPACK_zggsvp3 LAPACK_GLOBAL(zggsvp3,ZGGSVP3) -#define LAPACK_stgsja LAPACK_GLOBAL(stgsja,STGSJA) -#define LAPACK_dtgsja LAPACK_GLOBAL(dtgsja,DTGSJA) -#define LAPACK_ctgsja LAPACK_GLOBAL(ctgsja,CTGSJA) -#define LAPACK_ztgsja LAPACK_GLOBAL(ztgsja,ZTGSJA) -#define LAPACK_sgels LAPACK_GLOBAL(sgels,SGELS) -#define LAPACK_dgels LAPACK_GLOBAL(dgels,DGELS) -#define LAPACK_cgels LAPACK_GLOBAL(cgels,CGELS) -#define LAPACK_zgels LAPACK_GLOBAL(zgels,ZGELS) -#define LAPACK_sgelsy LAPACK_GLOBAL(sgelsy,SGELSY) -#define LAPACK_dgelsy LAPACK_GLOBAL(dgelsy,DGELSY) -#define LAPACK_cgelsy LAPACK_GLOBAL(cgelsy,CGELSY) -#define LAPACK_zgelsy LAPACK_GLOBAL(zgelsy,ZGELSY) -#define LAPACK_sgelss LAPACK_GLOBAL(sgelss,SGELSS) -#define LAPACK_dgelss LAPACK_GLOBAL(dgelss,DGELSS) -#define LAPACK_cgelss LAPACK_GLOBAL(cgelss,CGELSS) -#define LAPACK_zgelss LAPACK_GLOBAL(zgelss,ZGELSS) -#define LAPACK_sgelsd LAPACK_GLOBAL(sgelsd,SGELSD) -#define LAPACK_dgelsd LAPACK_GLOBAL(dgelsd,DGELSD) -#define LAPACK_cgelsd LAPACK_GLOBAL(cgelsd,CGELSD) -#define LAPACK_zgelsd LAPACK_GLOBAL(zgelsd,ZGELSD) -#define LAPACK_sgglse LAPACK_GLOBAL(sgglse,SGGLSE) -#define LAPACK_dgglse LAPACK_GLOBAL(dgglse,DGGLSE) -#define LAPACK_cgglse LAPACK_GLOBAL(cgglse,CGGLSE) -#define LAPACK_zgglse LAPACK_GLOBAL(zgglse,ZGGLSE) -#define LAPACK_sggglm LAPACK_GLOBAL(sggglm,SGGGLM) -#define LAPACK_dggglm LAPACK_GLOBAL(dggglm,DGGGLM) -#define LAPACK_cggglm LAPACK_GLOBAL(cggglm,CGGGLM) -#define LAPACK_zggglm LAPACK_GLOBAL(zggglm,ZGGGLM) -#define LAPACK_ssyev LAPACK_GLOBAL(ssyev,SSYEV) -#define LAPACK_dsyev LAPACK_GLOBAL(dsyev,DSYEV) -#define LAPACK_cheev LAPACK_GLOBAL(cheev,CHEEV) -#define LAPACK_zheev LAPACK_GLOBAL(zheev,ZHEEV) -#define LAPACK_ssyev_2stage LAPACK_GLOBAL(ssyev_2stage,SSYEV_2STAGE) -#define LAPACK_dsyev_2stage LAPACK_GLOBAL(dsyev_2stage,DSYEV_2STAGE) -#define LAPACK_cheev_2stage LAPACK_GLOBAL(cheev_2stage,CHEEV_2STAGE) -#define LAPACK_zheev_2stage LAPACK_GLOBAL(zheev_2stage,ZHEEV_2STAGE) -#define LAPACK_ssyevd LAPACK_GLOBAL(ssyevd,SSYEVD) -#define LAPACK_dsyevd LAPACK_GLOBAL(dsyevd,DSYEVD) -#define LAPACK_cheevd LAPACK_GLOBAL(cheevd,CHEEVD) -#define LAPACK_zheevd LAPACK_GLOBAL(zheevd,ZHEEVD) -#define LAPACK_ssyevd_2stage LAPACK_GLOBAL(ssyevd_2stage,SSYEVD_2STAGE) -#define LAPACK_dsyevd_2stage LAPACK_GLOBAL(dsyevd_2stage,DSYEVD_2STAGE) -#define LAPACK_cheevd_2stage LAPACK_GLOBAL(cheevd_2stage,CHEEVD_2STAGE) -#define LAPACK_zheevd_2stage LAPACK_GLOBAL(zheevd_2stage,ZHEEVD_2STAGE) -#define LAPACK_ssyevx LAPACK_GLOBAL(ssyevx,SSYEVX) -#define LAPACK_dsyevx LAPACK_GLOBAL(dsyevx,DSYEVX) -#define LAPACK_cheevx LAPACK_GLOBAL(cheevx,CHEEVX) -#define LAPACK_zheevx LAPACK_GLOBAL(zheevx,ZHEEVX) -#define LAPACK_ssyevx_2stage LAPACK_GLOBAL(ssyevx_2stage,SSYEVX_2STAGE) -#define LAPACK_dsyevx_2stage LAPACK_GLOBAL(dsyevx_2stage,DSYEVX_2STAGE) -#define LAPACK_cheevx_2stage LAPACK_GLOBAL(cheevx_2stage,CHEEVX_2STAGE) -#define LAPACK_zheevx_2stage LAPACK_GLOBAL(zheevx_2stage,ZHEEVX_2STAGE) -#define LAPACK_ssyevr LAPACK_GLOBAL(ssyevr,SSYEVR) -#define LAPACK_dsyevr LAPACK_GLOBAL(dsyevr,DSYEVR) -#define LAPACK_cheevr LAPACK_GLOBAL(cheevr,CHEEVR) -#define LAPACK_zheevr LAPACK_GLOBAL(zheevr,ZHEEVR) -#define LAPACK_ssyevr_2stage LAPACK_GLOBAL(ssyevr_2stage,SSYEVR_2STAGE) -#define LAPACK_dsyevr_2stage LAPACK_GLOBAL(dsyevr_2stage,DSYEVR_2STAGE) -#define LAPACK_cheevr_2stage LAPACK_GLOBAL(cheevr_2stage,CHEEVR_2STAGE) -#define LAPACK_zheevr_2stage LAPACK_GLOBAL(zheevr_2stage,ZHEEVR_2STAGE) -#define LAPACK_sspev LAPACK_GLOBAL(sspev,SSPEV) -#define LAPACK_dspev LAPACK_GLOBAL(dspev,DSPEV) -#define LAPACK_chpev LAPACK_GLOBAL(chpev,CHPEV) -#define LAPACK_zhpev LAPACK_GLOBAL(zhpev,ZHPEV) -#define LAPACK_sspevd LAPACK_GLOBAL(sspevd,SSPEVD) -#define LAPACK_dspevd LAPACK_GLOBAL(dspevd,DSPEVD) -#define LAPACK_chpevd LAPACK_GLOBAL(chpevd,CHPEVD) -#define LAPACK_zhpevd LAPACK_GLOBAL(zhpevd,ZHPEVD) -#define LAPACK_sspevx LAPACK_GLOBAL(sspevx,SSPEVX) -#define LAPACK_dspevx LAPACK_GLOBAL(dspevx,DSPEVX) -#define LAPACK_chpevx LAPACK_GLOBAL(chpevx,CHPEVX) -#define LAPACK_zhpevx LAPACK_GLOBAL(zhpevx,ZHPEVX) -#define LAPACK_ssbev LAPACK_GLOBAL(ssbev,SSBEV) -#define LAPACK_dsbev LAPACK_GLOBAL(dsbev,DSBEV) -#define LAPACK_chbev LAPACK_GLOBAL(chbev,CHBEV) -#define LAPACK_zhbev LAPACK_GLOBAL(zhbev,ZHBEV) -#define LAPACK_ssbev_2stage LAPACK_GLOBAL(ssbev_2stage,SSBEV_2STAGE) -#define LAPACK_dsbev_2stage LAPACK_GLOBAL(dsbev_2stage,DSBEV_2STAGE) -#define LAPACK_chbev_2stage LAPACK_GLOBAL(chbev_2stage,CHBEV_2STAGE) -#define LAPACK_zhbev_2stage LAPACK_GLOBAL(zhbev_2stage,ZHBEV_2STAGE) -#define LAPACK_ssbevd LAPACK_GLOBAL(ssbevd,SSBEVD) -#define LAPACK_dsbevd LAPACK_GLOBAL(dsbevd,DSBEVD) -#define LAPACK_chbevd LAPACK_GLOBAL(chbevd,CHBEVD) -#define LAPACK_zhbevd LAPACK_GLOBAL(zhbevd,ZHBEVD) -#define LAPACK_ssbevd_2stage LAPACK_GLOBAL(ssbevd_2stage,SSBEVD_2STAGE) -#define LAPACK_dsbevd_2stage LAPACK_GLOBAL(dsbevd_2stage,DSBEVD_2STAGE) -#define LAPACK_chbevd_2stage LAPACK_GLOBAL(chbevd_2stage,CHBEVD_2STAGE) -#define LAPACK_zhbevd_2stage LAPACK_GLOBAL(zhbevd_2stage,ZHBEVD_2STAGE) -#define LAPACK_ssbevx LAPACK_GLOBAL(ssbevx,SSBEVX) -#define LAPACK_dsbevx LAPACK_GLOBAL(dsbevx,DSBEVX) -#define LAPACK_chbevx LAPACK_GLOBAL(chbevx,CHBEVX) -#define LAPACK_zhbevx LAPACK_GLOBAL(zhbevx,ZHBEVX) -#define LAPACK_ssbevx_2stage LAPACK_GLOBAL(ssbevx_2stage,SSBEVX_2STAGE) -#define LAPACK_dsbevx_2stage LAPACK_GLOBAL(dsbevx_2stage,DSBEVX_2STAGE) -#define LAPACK_chbevx_2stage LAPACK_GLOBAL(chbevx_2stage,CHBEVX_2STAGE) -#define LAPACK_zhbevx_2stage LAPACK_GLOBAL(zhbevx_2stage,ZHBEVX_2STAGE) -#define LAPACK_sstev LAPACK_GLOBAL(sstev,SSTEV) -#define LAPACK_dstev LAPACK_GLOBAL(dstev,DSTEV) -#define LAPACK_sstevd LAPACK_GLOBAL(sstevd,SSTEVD) -#define LAPACK_dstevd LAPACK_GLOBAL(dstevd,DSTEVD) -#define LAPACK_sstevx LAPACK_GLOBAL(sstevx,SSTEVX) -#define LAPACK_dstevx LAPACK_GLOBAL(dstevx,DSTEVX) -#define LAPACK_sstevr LAPACK_GLOBAL(sstevr,SSTEVR) -#define LAPACK_dstevr LAPACK_GLOBAL(dstevr,DSTEVR) -#define LAPACK_sgees LAPACK_GLOBAL(sgees,SGEES) -#define LAPACK_dgees LAPACK_GLOBAL(dgees,DGEES) -#define LAPACK_cgees LAPACK_GLOBAL(cgees,CGEES) -#define LAPACK_zgees LAPACK_GLOBAL(zgees,ZGEES) -#define LAPACK_sgeesx LAPACK_GLOBAL(sgeesx,SGEESX) -#define LAPACK_dgeesx LAPACK_GLOBAL(dgeesx,DGEESX) -#define LAPACK_cgeesx LAPACK_GLOBAL(cgeesx,CGEESX) -#define LAPACK_zgeesx LAPACK_GLOBAL(zgeesx,ZGEESX) -#define LAPACK_sgeev LAPACK_GLOBAL(sgeev,SGEEV) -#define LAPACK_dgeev LAPACK_GLOBAL(dgeev,DGEEV) -#define LAPACK_cgeev LAPACK_GLOBAL(cgeev,CGEEV) -#define LAPACK_zgeev LAPACK_GLOBAL(zgeev,ZGEEV) -#define LAPACK_sgeevx LAPACK_GLOBAL(sgeevx,SGEEVX) -#define LAPACK_dgeevx LAPACK_GLOBAL(dgeevx,DGEEVX) -#define LAPACK_cgeevx LAPACK_GLOBAL(cgeevx,CGEEVX) -#define LAPACK_zgeevx LAPACK_GLOBAL(zgeevx,ZGEEVX) -#define LAPACK_sgesvd LAPACK_GLOBAL(sgesvd,SGESVD) -#define LAPACK_dgesvd LAPACK_GLOBAL(dgesvd,DGESVD) -#define LAPACK_cgesvd LAPACK_GLOBAL(cgesvd,CGESVD) -#define LAPACK_zgesvd LAPACK_GLOBAL(zgesvd,ZGESVD) -#define LAPACK_sgesvdx LAPACK_GLOBAL(sgesvdx,SGESVDX) -#define LAPACK_dgesvdx LAPACK_GLOBAL(dgesvdx,DGESVDX) -#define LAPACK_cgesvdx LAPACK_GLOBAL(cgesvdx,CGESVDX) -#define LAPACK_zgesvdx LAPACK_GLOBAL(zgesvdx,ZGESVDX) -#define LAPACK_sgesdd LAPACK_GLOBAL(sgesdd,SGESDD) -#define LAPACK_dgesdd LAPACK_GLOBAL(dgesdd,DGESDD) -#define LAPACK_cgesdd LAPACK_GLOBAL(cgesdd,CGESDD) -#define LAPACK_zgesdd LAPACK_GLOBAL(zgesdd,ZGESDD) -#define LAPACK_sgejsv LAPACK_GLOBAL(sgejsv,SGEJSV) -#define LAPACK_dgejsv LAPACK_GLOBAL(dgejsv,DGEJSV) -#define LAPACK_cgejsv LAPACK_GLOBAL(cgejsv,CGEJSV) -#define LAPACK_zgejsv LAPACK_GLOBAL(zgejsv,ZGEJSV) -#define LAPACK_sgesvj LAPACK_GLOBAL(sgesvj,SGESVJ) -#define LAPACK_dgesvj LAPACK_GLOBAL(dgesvj,DGESVJ) -#define LAPACK_cgesvj LAPACK_GLOBAL(cgesvj,CGESVJ) -#define LAPACK_zgesvj LAPACK_GLOBAL(zgesvj,ZGESVJ) -#define LAPACK_sggsvd LAPACK_GLOBAL(sggsvd,SGGSVD) -#define LAPACK_dggsvd LAPACK_GLOBAL(dggsvd,DGGSVD) -#define LAPACK_cggsvd LAPACK_GLOBAL(cggsvd,CGGSVD) -#define LAPACK_zggsvd LAPACK_GLOBAL(zggsvd,ZGGSVD) -#define LAPACK_ssygv LAPACK_GLOBAL(ssygv,SSYGV) -#define LAPACK_dsygv LAPACK_GLOBAL(dsygv,DSYGV) -#define LAPACK_chegv LAPACK_GLOBAL(chegv,CHEGV) -#define LAPACK_zhegv LAPACK_GLOBAL(zhegv,ZHEGV) -#define LAPACK_ssygv_2stage LAPACK_GLOBAL(ssygv_2stage,SSYGV_2STAGE) -#define LAPACK_dsygv_2stage LAPACK_GLOBAL(dsygv_2stage,DSYGV_2STAGE) -#define LAPACK_chegv_2stage LAPACK_GLOBAL(chegv_2stage,CHEGV_2STAGE) -#define LAPACK_zhegv_2stage LAPACK_GLOBAL(zhegv_2stage,ZHEGV_2STAGE) -#define LAPACK_ssygvd LAPACK_GLOBAL(ssygvd,SSYGVD) -#define LAPACK_dsygvd LAPACK_GLOBAL(dsygvd,DSYGVD) -#define LAPACK_chegvd LAPACK_GLOBAL(chegvd,CHEGVD) -#define LAPACK_zhegvd LAPACK_GLOBAL(zhegvd,ZHEGVD) -#define LAPACK_ssygvx LAPACK_GLOBAL(ssygvx,SSYGVX) -#define LAPACK_dsygvx LAPACK_GLOBAL(dsygvx,DSYGVX) -#define LAPACK_chegvx LAPACK_GLOBAL(chegvx,CHEGVX) -#define LAPACK_zhegvx LAPACK_GLOBAL(zhegvx,ZHEGVX) -#define LAPACK_sspgv LAPACK_GLOBAL(sspgv,SSPGV) -#define LAPACK_dspgv LAPACK_GLOBAL(dspgv,DSPGV) -#define LAPACK_chpgv LAPACK_GLOBAL(chpgv,CHPGV) -#define LAPACK_zhpgv LAPACK_GLOBAL(zhpgv,ZHPGV) -#define LAPACK_sspgvd LAPACK_GLOBAL(sspgvd,SSPGVD) -#define LAPACK_dspgvd LAPACK_GLOBAL(dspgvd,DSPGVD) -#define LAPACK_chpgvd LAPACK_GLOBAL(chpgvd,CHPGVD) -#define LAPACK_zhpgvd LAPACK_GLOBAL(zhpgvd,ZHPGVD) -#define LAPACK_sspgvx LAPACK_GLOBAL(sspgvx,SSPGVX) -#define LAPACK_dspgvx LAPACK_GLOBAL(dspgvx,DSPGVX) -#define LAPACK_chpgvx LAPACK_GLOBAL(chpgvx,CHPGVX) -#define LAPACK_zhpgvx LAPACK_GLOBAL(zhpgvx,ZHPGVX) -#define LAPACK_ssbgv LAPACK_GLOBAL(ssbgv,SSBGV) -#define LAPACK_dsbgv LAPACK_GLOBAL(dsbgv,DSBGV) -#define LAPACK_chbgv LAPACK_GLOBAL(chbgv,CHBGV) -#define LAPACK_zhbgv LAPACK_GLOBAL(zhbgv,ZHBGV) -#define LAPACK_ssbgvd LAPACK_GLOBAL(ssbgvd,SSBGVD) -#define LAPACK_dsbgvd LAPACK_GLOBAL(dsbgvd,DSBGVD) -#define LAPACK_chbgvd LAPACK_GLOBAL(chbgvd,CHBGVD) -#define LAPACK_zhbgvd LAPACK_GLOBAL(zhbgvd,ZHBGVD) -#define LAPACK_ssbgvx LAPACK_GLOBAL(ssbgvx,SSBGVX) -#define LAPACK_dsbgvx LAPACK_GLOBAL(dsbgvx,DSBGVX) -#define LAPACK_chbgvx LAPACK_GLOBAL(chbgvx,CHBGVX) -#define LAPACK_zhbgvx LAPACK_GLOBAL(zhbgvx,ZHBGVX) -#define LAPACK_sgges LAPACK_GLOBAL(sgges,SGGES) -#define LAPACK_dgges LAPACK_GLOBAL(dgges,DGGES) -#define LAPACK_cgges LAPACK_GLOBAL(cgges,CGGES) -#define LAPACK_zgges LAPACK_GLOBAL(zgges,ZGGES) -#define LAPACK_sgges3 LAPACK_GLOBAL(sgges3,SGGES3) -#define LAPACK_dgges3 LAPACK_GLOBAL(dgges3,DGGES3) -#define LAPACK_cgges3 LAPACK_GLOBAL(cgges3,CGGES3) -#define LAPACK_zgges3 LAPACK_GLOBAL(zgges3,ZGGES3) -#define LAPACK_sggesx LAPACK_GLOBAL(sggesx,SGGESX) -#define LAPACK_dggesx LAPACK_GLOBAL(dggesx,DGGESX) -#define LAPACK_cggesx LAPACK_GLOBAL(cggesx,CGGESX) -#define LAPACK_zggesx LAPACK_GLOBAL(zggesx,ZGGESX) -#define LAPACK_sggev LAPACK_GLOBAL(sggev,SGGEV) -#define LAPACK_dggev LAPACK_GLOBAL(dggev,DGGEV) -#define LAPACK_cggev LAPACK_GLOBAL(cggev,CGGEV) -#define LAPACK_zggev LAPACK_GLOBAL(zggev,ZGGEV) -#define LAPACK_sggev3 LAPACK_GLOBAL(sggev3,SGGEV3) -#define LAPACK_dggev3 LAPACK_GLOBAL(dggev3,DGGEV3) -#define LAPACK_cggev3 LAPACK_GLOBAL(cggev3,CGGEV3) -#define LAPACK_zggev3 LAPACK_GLOBAL(zggev3,ZGGEV3) -#define LAPACK_sggevx LAPACK_GLOBAL(sggevx,SGGEVX) -#define LAPACK_dggevx LAPACK_GLOBAL(dggevx,DGGEVX) -#define LAPACK_cggevx LAPACK_GLOBAL(cggevx,CGGEVX) -#define LAPACK_zggevx LAPACK_GLOBAL(zggevx,ZGGEVX) -#define LAPACK_dsfrk LAPACK_GLOBAL(dsfrk,DSFRK) -#define LAPACK_ssfrk LAPACK_GLOBAL(ssfrk,SSFRK) -#define LAPACK_zhfrk LAPACK_GLOBAL(zhfrk,ZHFRK) -#define LAPACK_chfrk LAPACK_GLOBAL(chfrk,CHFRK) -#define LAPACK_dtfsm LAPACK_GLOBAL(dtfsm,DTFSM) -#define LAPACK_stfsm LAPACK_GLOBAL(stfsm,STFSM) -#define LAPACK_ztfsm LAPACK_GLOBAL(ztfsm,ZTFSM) -#define LAPACK_ctfsm LAPACK_GLOBAL(ctfsm,CTFSM) -#define LAPACK_dtfttp LAPACK_GLOBAL(dtfttp,DTFTTP) -#define LAPACK_stfttp LAPACK_GLOBAL(stfttp,STFTTP) -#define LAPACK_ztfttp LAPACK_GLOBAL(ztfttp,ZTFTTP) -#define LAPACK_ctfttp LAPACK_GLOBAL(ctfttp,CTFTTP) -#define LAPACK_dtfttr LAPACK_GLOBAL(dtfttr,DTFTTR) -#define LAPACK_stfttr LAPACK_GLOBAL(stfttr,STFTTR) -#define LAPACK_ztfttr LAPACK_GLOBAL(ztfttr,ZTFTTR) -#define LAPACK_ctfttr LAPACK_GLOBAL(ctfttr,CTFTTR) -#define LAPACK_dtpttf LAPACK_GLOBAL(dtpttf,DTPTTF) -#define LAPACK_stpttf LAPACK_GLOBAL(stpttf,STPTTF) -#define LAPACK_ztpttf LAPACK_GLOBAL(ztpttf,ZTPTTF) -#define LAPACK_ctpttf LAPACK_GLOBAL(ctpttf,CTPTTF) -#define LAPACK_dtpttr LAPACK_GLOBAL(dtpttr,DTPTTR) -#define LAPACK_stpttr LAPACK_GLOBAL(stpttr,STPTTR) -#define LAPACK_ztpttr LAPACK_GLOBAL(ztpttr,ZTPTTR) -#define LAPACK_ctpttr LAPACK_GLOBAL(ctpttr,CTPTTR) -#define LAPACK_dtrttf LAPACK_GLOBAL(dtrttf,DTRTTF) -#define LAPACK_strttf LAPACK_GLOBAL(strttf,STRTTF) -#define LAPACK_ztrttf LAPACK_GLOBAL(ztrttf,ZTRTTF) -#define LAPACK_ctrttf LAPACK_GLOBAL(ctrttf,CTRTTF) -#define LAPACK_dtrttp LAPACK_GLOBAL(dtrttp,DTRTTP) -#define LAPACK_strttp LAPACK_GLOBAL(strttp,STRTTP) -#define LAPACK_ztrttp LAPACK_GLOBAL(ztrttp,ZTRTTP) -#define LAPACK_ctrttp LAPACK_GLOBAL(ctrttp,CTRTTP) -#define LAPACK_sgeqrfp LAPACK_GLOBAL(sgeqrfp,SGEQRFP) -#define LAPACK_dgeqrfp LAPACK_GLOBAL(dgeqrfp,DGEQRFP) -#define LAPACK_cgeqrfp LAPACK_GLOBAL(cgeqrfp,CGEQRFP) -#define LAPACK_zgeqrfp LAPACK_GLOBAL(zgeqrfp,ZGEQRFP) -#define LAPACK_clacgv LAPACK_GLOBAL(clacgv,CLACGV) -#define LAPACK_zlacgv LAPACK_GLOBAL(zlacgv,ZLACGV) -#define LAPACK_slarnv LAPACK_GLOBAL(slarnv,SLARNV) -#define LAPACK_dlarnv LAPACK_GLOBAL(dlarnv,DLARNV) -#define LAPACK_clarnv LAPACK_GLOBAL(clarnv,CLARNV) -#define LAPACK_zlarnv LAPACK_GLOBAL(zlarnv,ZLARNV) -#define LAPACK_sgeqr2 LAPACK_GLOBAL(sgeqr2,SGEQR2) -#define LAPACK_dgeqr2 LAPACK_GLOBAL(dgeqr2,DGEQR2) -#define LAPACK_cgeqr2 LAPACK_GLOBAL(cgeqr2,CGEQR2) -#define LAPACK_zgeqr2 LAPACK_GLOBAL(zgeqr2,ZGEQR2) -#define LAPACK_slacn2 LAPACK_GLOBAL(slacn2,SLACN2) -#define LAPACK_dlacn2 LAPACK_GLOBAL(dlacn2,DLACN2) -#define LAPACK_clacn2 LAPACK_GLOBAL(clacn2,CLACN2) -#define LAPACK_zlacn2 LAPACK_GLOBAL(zlacn2,ZLACN2) -#define LAPACK_slacpy LAPACK_GLOBAL(slacpy,SLACPY) -#define LAPACK_dlacpy LAPACK_GLOBAL(dlacpy,DLACPY) -#define LAPACK_clacpy LAPACK_GLOBAL(clacpy,CLACPY) -#define LAPACK_zlacpy LAPACK_GLOBAL(zlacpy,ZLACPY) -#define LAPACK_clacp2 LAPACK_GLOBAL(clacp2,CLACP2) -#define LAPACK_zlacp2 LAPACK_GLOBAL(zlacp2,ZLACP2) -#define LAPACK_sgetf2 LAPACK_GLOBAL(sgetf2,SGETF2) -#define LAPACK_dgetf2 LAPACK_GLOBAL(dgetf2,DGETF2) -#define LAPACK_cgetf2 LAPACK_GLOBAL(cgetf2,CGETF2) -#define LAPACK_zgetf2 LAPACK_GLOBAL(zgetf2,ZGETF2) -#define LAPACK_slaswp LAPACK_GLOBAL(slaswp,SLASWP) -#define LAPACK_dlaswp LAPACK_GLOBAL(dlaswp,DLASWP) -#define LAPACK_claswp LAPACK_GLOBAL(claswp,CLASWP) -#define LAPACK_zlaswp LAPACK_GLOBAL(zlaswp,ZLASWP) -#define LAPACK_slange LAPACK_GLOBAL(slange,SLANGE) -#define LAPACK_dlange LAPACK_GLOBAL(dlange,DLANGE) -#define LAPACK_clange LAPACK_GLOBAL(clange,CLANGE) -#define LAPACK_zlange LAPACK_GLOBAL(zlange,ZLANGE) -#define LAPACK_clanhe LAPACK_GLOBAL(clanhe,CLANHE) -#define LAPACK_zlanhe LAPACK_GLOBAL(zlanhe,ZLANHE) -#define LAPACK_clarcm LAPACK_GLOBAL(clarcm,CLARCM) -#define LAPACK_zlarcm LAPACK_GLOBAL(zlarcm,ZLARCM) -#define LAPACK_clacrm LAPACK_GLOBAL(clacrm,CLACRM) -#define LAPACK_zlacrm LAPACK_GLOBAL(zlacrm,ZLACRM) -#define LAPACK_slansy LAPACK_GLOBAL(slansy,SLANSY) -#define LAPACK_dlansy LAPACK_GLOBAL(dlansy,DLANSY) -#define LAPACK_clansy LAPACK_GLOBAL(clansy,CLANSY) -#define LAPACK_zlansy LAPACK_GLOBAL(zlansy,ZLANSY) -#define LAPACK_slantr LAPACK_GLOBAL(slantr,SLANTR) -#define LAPACK_dlantr LAPACK_GLOBAL(dlantr,DLANTR) -#define LAPACK_clantr LAPACK_GLOBAL(clantr,CLANTR) -#define LAPACK_zlantr LAPACK_GLOBAL(zlantr,ZLANTR) -#define LAPACK_slamch LAPACK_GLOBAL(slamch,SLAMCH) -#define LAPACK_dlamch LAPACK_GLOBAL(dlamch,DLAMCH) -#define LAPACK_sgelq2 LAPACK_GLOBAL(sgelq2,SGELQ2) -#define LAPACK_dgelq2 LAPACK_GLOBAL(dgelq2,DGELQ2) -#define LAPACK_cgelq2 LAPACK_GLOBAL(cgelq2,CGELQ2) -#define LAPACK_zgelq2 LAPACK_GLOBAL(zgelq2,ZGELQ2) -#define LAPACK_slarfb LAPACK_GLOBAL(slarfb,SLARFB) -#define LAPACK_dlarfb LAPACK_GLOBAL(dlarfb,DLARFB) -#define LAPACK_clarfb LAPACK_GLOBAL(clarfb,CLARFB) -#define LAPACK_zlarfb LAPACK_GLOBAL(zlarfb,ZLARFB) -#define LAPACK_slarfg LAPACK_GLOBAL(slarfg,SLARFG) -#define LAPACK_dlarfg LAPACK_GLOBAL(dlarfg,DLARFG) -#define LAPACK_clarfg LAPACK_GLOBAL(clarfg,CLARFG) -#define LAPACK_zlarfg LAPACK_GLOBAL(zlarfg,ZLARFG) -#define LAPACK_slassq LAPACK_GLOBAL(slassq,SLASSQ) -#define LAPACK_dlassq LAPACK_GLOBAL(dlassq,DLASSQ) -#define LAPACK_classq LAPACK_GLOBAL(classq,CLASSQ) -#define LAPACK_zlassq LAPACK_GLOBAL(zlassq,ZLASSQ) -#define LAPACK_slarft LAPACK_GLOBAL(slarft,SLARFT) -#define LAPACK_dlarft LAPACK_GLOBAL(dlarft,DLARFT) -#define LAPACK_clarft LAPACK_GLOBAL(clarft,CLARFT) -#define LAPACK_zlarft LAPACK_GLOBAL(zlarft,ZLARFT) -#define LAPACK_slarfx LAPACK_GLOBAL(slarfx,SLARFX) -#define LAPACK_dlarfx LAPACK_GLOBAL(dlarfx,DLARFX) -#define LAPACK_clarfx LAPACK_GLOBAL(clarfx,CLARFX) -#define LAPACK_zlarfx LAPACK_GLOBAL(zlarfx,ZLARFX) -#define LAPACK_slatms LAPACK_GLOBAL(slatms,SLATMS) -#define LAPACK_dlatms LAPACK_GLOBAL(dlatms,DLATMS) -#define LAPACK_clatms LAPACK_GLOBAL(clatms,CLATMS) -#define LAPACK_zlatms LAPACK_GLOBAL(zlatms,ZLATMS) -#define LAPACK_slag2d LAPACK_GLOBAL(slag2d,SLAG2D) -#define LAPACK_dlag2s LAPACK_GLOBAL(dlag2s,DLAG2S) -#define LAPACK_clag2z LAPACK_GLOBAL(clag2z,CLAG2Z) -#define LAPACK_zlag2c LAPACK_GLOBAL(zlag2c,ZLAG2C) -#define LAPACK_slauum LAPACK_GLOBAL(slauum,SLAUUM) -#define LAPACK_dlauum LAPACK_GLOBAL(dlauum,DLAUUM) -#define LAPACK_clauum LAPACK_GLOBAL(clauum,CLAUUM) -#define LAPACK_zlauum LAPACK_GLOBAL(zlauum,ZLAUUM) -#define LAPACK_slagge LAPACK_GLOBAL(slagge,SLAGGE) -#define LAPACK_dlagge LAPACK_GLOBAL(dlagge,DLAGGE) -#define LAPACK_clagge LAPACK_GLOBAL(clagge,CLAGGE) -#define LAPACK_zlagge LAPACK_GLOBAL(zlagge,ZLAGGE) -#define LAPACK_slascl LAPACK_GLOBAL(slascl,SLASCL) -#define LAPACK_dlascl LAPACK_GLOBAL(dlascl,DLASCL) -#define LAPACK_clascl LAPACK_GLOBAL(clascl,CLASCL) -#define LAPACK_zlascl LAPACK_GLOBAL(zlascl,ZLASCL) -#define LAPACK_slaset LAPACK_GLOBAL(slaset,SLASET) -#define LAPACK_dlaset LAPACK_GLOBAL(dlaset,DLASET) -#define LAPACK_claset LAPACK_GLOBAL(claset,CLASET) -#define LAPACK_zlaset LAPACK_GLOBAL(zlaset,ZLASET) -#define LAPACK_slasrt LAPACK_GLOBAL(slasrt,SLASRT) -#define LAPACK_dlasrt LAPACK_GLOBAL(dlasrt,DLASRT) -#define LAPACK_slagsy LAPACK_GLOBAL(slagsy,SLAGSY) -#define LAPACK_dlagsy LAPACK_GLOBAL(dlagsy,DLAGSY) -#define LAPACK_clagsy LAPACK_GLOBAL(clagsy,CLAGSY) -#define LAPACK_zlagsy LAPACK_GLOBAL(zlagsy,ZLAGSY) -#define LAPACK_claghe LAPACK_GLOBAL(claghe,CLAGHE) -#define LAPACK_zlaghe LAPACK_GLOBAL(zlaghe,ZLAGHE) -#define LAPACK_slapmr LAPACK_GLOBAL(slapmr,SLAPMR) -#define LAPACK_dlapmr LAPACK_GLOBAL(dlapmr,DLAPMR) -#define LAPACK_clapmr LAPACK_GLOBAL(clapmr,CLAPMR) -#define LAPACK_zlapmr LAPACK_GLOBAL(zlapmr,ZLAPMR) -#define LAPACK_slapmt LAPACK_GLOBAL(slapmt,SLAPMT) -#define LAPACK_dlapmt LAPACK_GLOBAL(dlapmt,DLAPMT) -#define LAPACK_clapmt LAPACK_GLOBAL(clapmt,CLAPMT) -#define LAPACK_zlapmt LAPACK_GLOBAL(zlapmt,ZLAPMT) -#define LAPACK_slapy2 LAPACK_GLOBAL(slapy2,SLAPY2) -#define LAPACK_dlapy2 LAPACK_GLOBAL(dlapy2,DLAPY2) -#define LAPACK_slapy3 LAPACK_GLOBAL(slapy3,SLAPY3) -#define LAPACK_dlapy3 LAPACK_GLOBAL(dlapy3,DLAPY3) -#define LAPACK_slartgp LAPACK_GLOBAL(slartgp,SLARTGP) -#define LAPACK_dlartgp LAPACK_GLOBAL(dlartgp,DLARTGP) -#define LAPACK_slartgs LAPACK_GLOBAL(slartgs,SLARTGS) -#define LAPACK_dlartgs LAPACK_GLOBAL(dlartgs,DLARTGS) -// LAPACK 3.3.0 -#define LAPACK_cbbcsd LAPACK_GLOBAL(cbbcsd,CBBCSD) -#define LAPACK_cheswapr LAPACK_GLOBAL(cheswapr,CHESWAPR) -#define LAPACK_chetri2 LAPACK_GLOBAL(chetri2,CHETRI2) -#define LAPACK_chetri2x LAPACK_GLOBAL(chetri2x,CHETRI2X) -#define LAPACK_chetrs2 LAPACK_GLOBAL(chetrs2,CHETRS2) -#define LAPACK_csyconv LAPACK_GLOBAL(csyconv,CSYCONV) -#define LAPACK_csyswapr LAPACK_GLOBAL(csyswapr,CSYSWAPR) -#define LAPACK_csytri2 LAPACK_GLOBAL(csytri2,CSYTRI2) -#define LAPACK_csytri2x LAPACK_GLOBAL(csytri2x,CSYTRI2X) -#define LAPACK_csytrs2 LAPACK_GLOBAL(csytrs2,CSYTRS2) -#define LAPACK_cunbdb LAPACK_GLOBAL(cunbdb,CUNBDB) -#define LAPACK_cuncsd LAPACK_GLOBAL(cuncsd,CUNCSD) -#define LAPACK_cuncsd2by1 LAPACK_GLOBAL(cuncsd2by1,CUNCSD2BY1) -#define LAPACK_dbbcsd LAPACK_GLOBAL(dbbcsd,DBBCSD) -#define LAPACK_dorbdb LAPACK_GLOBAL(dorbdb,DORBDB) -#define LAPACK_dorcsd LAPACK_GLOBAL(dorcsd,DORCSD) -#define LAPACK_dorcsd2by1 LAPACK_GLOBAL(dorcsd2by1,DORCSD2BY1) -#define LAPACK_dsyconv LAPACK_GLOBAL(dsyconv,DSYCONV) -#define LAPACK_dsyswapr LAPACK_GLOBAL(dsyswapr,DSYSWAPR) -#define LAPACK_dsytri2 LAPACK_GLOBAL(dsytri2,DSYTRI2) -#define LAPACK_dsytri2x LAPACK_GLOBAL(dsytri2x,DSYTRI2X) -#define LAPACK_dsytrs2 LAPACK_GLOBAL(dsytrs2,DSYTRS2) -#define LAPACK_sbbcsd LAPACK_GLOBAL(sbbcsd,SBBCSD) -#define LAPACK_sorbdb LAPACK_GLOBAL(sorbdb,SORBDB) -#define LAPACK_sorcsd LAPACK_GLOBAL(sorcsd,SORCSD) -#define LAPACK_sorcsd2by1 LAPACK_GLOBAL(sorcsd2by1,SORCSD2BY1) -#define LAPACK_ssyconv LAPACK_GLOBAL(ssyconv,SSYCONV) -#define LAPACK_ssyswapr LAPACK_GLOBAL(ssyswapr,SSYSWAPR) -#define LAPACK_ssytri2 LAPACK_GLOBAL(ssytri2,SSYTRI2) -#define LAPACK_ssytri2x LAPACK_GLOBAL(ssytri2x,SSYTRI2X) -#define LAPACK_ssytrs2 LAPACK_GLOBAL(ssytrs2,SSYTRS2) -#define LAPACK_zbbcsd LAPACK_GLOBAL(zbbcsd,ZBBCSD) -#define LAPACK_zheswapr LAPACK_GLOBAL(zheswapr,ZHESWAPR) -#define LAPACK_zhetri2 LAPACK_GLOBAL(zhetri2,ZHETRI2) -#define LAPACK_zhetri2x LAPACK_GLOBAL(zhetri2x,ZHETRI2X) -#define LAPACK_zhetrs2 LAPACK_GLOBAL(zhetrs2,ZHETRS2) -#define LAPACK_zsyconv LAPACK_GLOBAL(zsyconv,ZSYCONV) -#define LAPACK_zsyswapr LAPACK_GLOBAL(zsyswapr,ZSYSWAPR) -#define LAPACK_zsytri2 LAPACK_GLOBAL(zsytri2,ZSYTRI2) -#define LAPACK_zsytri2x LAPACK_GLOBAL(zsytri2x,ZSYTRI2X) -#define LAPACK_zsytrs2 LAPACK_GLOBAL(zsytrs2,ZSYTRS2) -#define LAPACK_zunbdb LAPACK_GLOBAL(zunbdb,ZUNBDB) -#define LAPACK_zuncsd LAPACK_GLOBAL(zuncsd,ZUNCSD) -#define LAPACK_zuncsd2by1 LAPACK_GLOBAL(zuncsd2by1,ZUNCSD2BY1) -// LAPACK 3.4.0 -#define LAPACK_sgemqrt LAPACK_GLOBAL(sgemqrt,SGEMQRT) -#define LAPACK_dgemqrt LAPACK_GLOBAL(dgemqrt,DGEMQRT) -#define LAPACK_cgemqrt LAPACK_GLOBAL(cgemqrt,CGEMQRT) -#define LAPACK_zgemqrt LAPACK_GLOBAL(zgemqrt,ZGEMQRT) -#define LAPACK_sgeqrt LAPACK_GLOBAL(sgeqrt,SGEQRT) -#define LAPACK_dgeqrt LAPACK_GLOBAL(dgeqrt,DGEQRT) -#define LAPACK_cgeqrt LAPACK_GLOBAL(cgeqrt,CGEQRT) -#define LAPACK_zgeqrt LAPACK_GLOBAL(zgeqrt,ZGEQRT) -#define LAPACK_sgeqrt2 LAPACK_GLOBAL(sgeqrt2,SGEQRT2) -#define LAPACK_dgeqrt2 LAPACK_GLOBAL(dgeqrt2,DGEQRT2) -#define LAPACK_cgeqrt2 LAPACK_GLOBAL(cgeqrt2,CGEQRT2) -#define LAPACK_zgeqrt2 LAPACK_GLOBAL(zgeqrt2,ZGEQRT2) -#define LAPACK_sgeqrt3 LAPACK_GLOBAL(sgeqrt3,SGEQRT3) -#define LAPACK_dgeqrt3 LAPACK_GLOBAL(dgeqrt3,DGEQRT3) -#define LAPACK_cgeqrt3 LAPACK_GLOBAL(cgeqrt3,CGEQRT3) -#define LAPACK_zgeqrt3 LAPACK_GLOBAL(zgeqrt3,ZGEQRT3) -#define LAPACK_stpmqrt LAPACK_GLOBAL(stpmqrt,STPMQRT) -#define LAPACK_dtpmqrt LAPACK_GLOBAL(dtpmqrt,DTPMQRT) -#define LAPACK_ctpmqrt LAPACK_GLOBAL(ctpmqrt,CTPMQRT) -#define LAPACK_ztpmqrt LAPACK_GLOBAL(ztpmqrt,ZTPMQRT) -#define LAPACK_stpqrt LAPACK_GLOBAL(stpqrt,STPQRT) -#define LAPACK_dtpqrt LAPACK_GLOBAL(dtpqrt,DTPQRT) -#define LAPACK_ctpqrt LAPACK_GLOBAL(ctpqrt,CTPQRT) -#define LAPACK_ztpqrt LAPACK_GLOBAL(ztpqrt,ZTPQRT) -#define LAPACK_stpqrt2 LAPACK_GLOBAL(stpqrt2,STPQRT2) -#define LAPACK_dtpqrt2 LAPACK_GLOBAL(dtpqrt2,DTPQRT2) -#define LAPACK_ctpqrt2 LAPACK_GLOBAL(ctpqrt2,CTPQRT2) -#define LAPACK_ztpqrt2 LAPACK_GLOBAL(ztpqrt2,ZTPQRT2) -#define LAPACK_stprfb LAPACK_GLOBAL(stprfb,STPRFB) -#define LAPACK_dtprfb LAPACK_GLOBAL(dtprfb,DTPRFB) -#define LAPACK_ctprfb LAPACK_GLOBAL(ctprfb,CTPRFB) -#define LAPACK_ztprfb LAPACK_GLOBAL(ztprfb,ZTPRFB) -// LAPACK 3.5.0 -#define LAPACK_ssysv_rook LAPACK_GLOBAL(ssysv_rook,SSYSV_ROOK) -#define LAPACK_dsysv_rook LAPACK_GLOBAL(dsysv_rook,DSYSV_ROOK) -#define LAPACK_csysv_rook LAPACK_GLOBAL(csysv_rook,CSYSV_ROOK) -#define LAPACK_zsysv_rook LAPACK_GLOBAL(zsysv_rook,ZSYSV_ROOK) -#define LAPACK_csyr LAPACK_GLOBAL(csyr,CSYR) -#define LAPACK_zsyr LAPACK_GLOBAL(zsyr,ZSYR) -#define LAPACK_ilaver LAPACK_GLOBAL(ilaver,ILAVER) -// LAPACK 3.6.0 -#define LAPACK_sggsvd3 LAPACK_GLOBAL(sggsvd3,SGGSVD3) -#define LAPACK_dggsvd3 LAPACK_GLOBAL(dggsvd3,DGGSVD3) -#define LAPACK_cggsvd3 LAPACK_GLOBAL(cggsvd3,CGGSVD3) -#define LAPACK_zggsvd3 LAPACK_GLOBAL(zggsvd3,ZGGSVD3) -// LAPACK 3.7.0 -#define LAPACK_ssysv_aa LAPACK_GLOBAL(ssysv_aa,SSYSV_AA) -#define LAPACK_dsysv_aa LAPACK_GLOBAL(dsysv_aa,DSYSV_AA) -#define LAPACK_chesv_aa LAPACK_GLOBAL(chesv_aa,CHESV_AA) -#define LAPACK_zsysv_aa LAPACK_GLOBAL(zsysv_aa,ZSYSV_AA) -#define LAPACK_csysv_aa LAPACK_GLOBAL(csysv_aa,CSYSV_AA) -#define LAPACK_zhesv_aa LAPACK_GLOBAL(zhesv_aa,ZHESV_AA) -#define LAPACK_ssytrs_aa LAPACK_GLOBAL(ssytrs_aa,SSYTRS_AA) -#define LAPACK_dsytrs_aa LAPACK_GLOBAL(dsytrs_aa,DSYTRS_AA) -#define LAPACK_csytrs_aa LAPACK_GLOBAL(csytrs_aa,CSYTRS_AA) -#define LAPACK_zsytrs_aa LAPACK_GLOBAL(zsytrs_aa,ZSYTRS_AA) -#define LAPACK_chetrs_aa LAPACK_GLOBAL(chetrs_aa,CHETRS_AA) -#define LAPACK_zhetrs_aa LAPACK_GLOBAL(zhetrs_aa,ZHETRS_AA) -#define LAPACK_ssytrf_aa LAPACK_GLOBAL(ssytrf_aa,SSYTRF_AA) -#define LAPACK_dsytrf_aa LAPACK_GLOBAL(dsytrf_aa,DSYTRF_AA) -#define LAPACK_csytrf_aa LAPACK_GLOBAL(csytrf_aa,CSYTRF_AA) -#define LAPACK_zsytrf_aa LAPACK_GLOBAL(zsytrf_aa,ZSYTRF_AA) -#define LAPACK_chetrf_aa LAPACK_GLOBAL(chetrf_aa,CHETRF_AA) -#define LAPACK_zhetrf_aa LAPACK_GLOBAL(zhetrf_aa,ZHETRF_AA) - -#define LAPACK_ssysv_rk LAPACK_GLOBAL(ssysv_rk,SSYSV_RK) -#define LAPACK_dsysv_rk LAPACK_GLOBAL(dsysv_rk,DSYSV_RK) -#define LAPACK_chesv_rk LAPACK_GLOBAL(chesv_rk,CHESV_RK) -#define LAPACK_zsysv_rk LAPACK_GLOBAL(zsysv_rk,ZSYSV_RK) -#define LAPACK_csysv_rk LAPACK_GLOBAL(csysv_rk,CSYSV_RK) -#define LAPACK_zhesv_rk LAPACK_GLOBAL(zhesv_rk,ZHESV_RK) -#define LAPACK_ssytrf_rk LAPACK_GLOBAL(ssytrf_rk,SSYTRF_RK) -#define LAPACK_dsytrf_rk LAPACK_GLOBAL(dsytrf_rk,DSYTRF_RK) -#define LAPACK_csytrf_rk LAPACK_GLOBAL(csytrf_rk,CSYTRF_RK) -#define LAPACK_zsytrf_rk LAPACK_GLOBAL(zsytrf_rk,ZSYTRF_RK) -#define LAPACK_chetrf_rk LAPACK_GLOBAL(chetrf_rk,CHETRF_RK) -#define LAPACK_zhetrf_rk LAPACK_GLOBAL(zhetrf_rk,ZHETRF_RK) -#define LAPACK_ssytrs_3 LAPACK_GLOBAL(ssytrs_3,SSYTRS_3) -#define LAPACK_dsytrs_3 LAPACK_GLOBAL(dsytrs_3,DSYTRS_3) -#define LAPACK_csytrs_3 LAPACK_GLOBAL(csytrs_3,CSYTRS_3) -#define LAPACK_zsytrs_3 LAPACK_GLOBAL(zsytrs_3,ZSYTRS_3) -#define LAPACK_chetrs_3 LAPACK_GLOBAL(chetrs_3,CHETRS_3) -#define LAPACK_zhetrs_3 LAPACK_GLOBAL(zhetrs_3,ZHETRS_3) -#define LAPACK_ssytri_3 LAPACK_GLOBAL(ssytri_3,SSYTRI_3) -#define LAPACK_dsytri_3 LAPACK_GLOBAL(dsytri_3,DSYTRI_3) -#define LAPACK_csytri_3 LAPACK_GLOBAL(csytri_3,CSYTRI_3) -#define LAPACK_zsytri_3 LAPACK_GLOBAL(zsytri_3,ZSYTRI_3) -#define LAPACK_chetri_3 LAPACK_GLOBAL(chetri_3,CHETRI_3) -#define LAPACK_zhetri_3 LAPACK_GLOBAL(zhetri_3,ZHETRI_3) -#define LAPACK_ssycon_3 LAPACK_GLOBAL(ssycon_3,SSYCON_3) -#define LAPACK_dsycon_3 LAPACK_GLOBAL(dsycon_3,DSYCON_3) -#define LAPACK_csycon_3 LAPACK_GLOBAL(csycon_3,CSYCON_3) -#define LAPACK_zsycon_3 LAPACK_GLOBAL(zsycon_3,ZSYCON_3) -#define LAPACK_checon_3 LAPACK_GLOBAL(checon_3,CHECON_3) -#define LAPACK_zhecon_3 LAPACK_GLOBAL(zhecon_3,ZHECON_3) -#define LAPACK_sgelq LAPACK_GLOBAL(sgelq,SGELQ) -#define LAPACK_dgelq LAPACK_GLOBAL(dgelq,DGELQ) -#define LAPACK_cgelq LAPACK_GLOBAL(cgelq,CGELQ) -#define LAPACK_zgelq LAPACK_GLOBAL(zgelq,ZGELQ) -#define LAPACK_sgemlq LAPACK_GLOBAL(sgemlq,SGEMLQ) -#define LAPACK_dgemlq LAPACK_GLOBAL(dgemlq,DGEMLQ) -#define LAPACK_cgemlq LAPACK_GLOBAL(cgemlq,CGEMLQ) -#define LAPACK_zgemlq LAPACK_GLOBAL(zgemlq,ZGEMLQ) -#define LAPACK_sgeqr LAPACK_GLOBAL(sgeqr,SGEQR) -#define LAPACK_dgeqr LAPACK_GLOBAL(dgeqr,DGEQR) -#define LAPACK_cgeqr LAPACK_GLOBAL(cgeqr,CGEQR) -#define LAPACK_zgeqr LAPACK_GLOBAL(zgeqr,ZGEQR) -#define LAPACK_sgemqr LAPACK_GLOBAL(sgemqr,SGEMQR) -#define LAPACK_dgemqr LAPACK_GLOBAL(dgemqr,DGEMQR) -#define LAPACK_cgemqr LAPACK_GLOBAL(cgemqr,CGEMQR) -#define LAPACK_zgemqr LAPACK_GLOBAL(zgemqr,ZGEMQR) -#define LAPACK_sgetsls LAPACK_GLOBAL(sgetsls,SGETSLS) -#define LAPACK_dgetsls LAPACK_GLOBAL(dgetsls,DGETSLS) -#define LAPACK_cgetsls LAPACK_GLOBAL(cgetsls,CGETSLS) -#define LAPACK_zgetsls LAPACK_GLOBAL(zgetsls,ZGETSLS) - -// LAPACK 3.8.0 -#define LAPACK_ssysv_aa_2stage LAPACK_GLOBAL(ssysv_aa_2stage,SSYSV_AA_2STAGE) -#define LAPACK_dsysv_aa_2stage LAPACK_GLOBAL(dsysv_aa_2stage,DSYSV_AA_2STAGE) -#define LAPACK_chesv_aa_2stage LAPACK_GLOBAL(chesv_aa_2stage,CHESV_AA_2STAGE) -#define LAPACK_zsysv_aa_2stage LAPACK_GLOBAL(zsysv_aa_2stage,ZSYSV_AA_2STAGE) -#define LAPACK_csysv_aa_2stage LAPACK_GLOBAL(csysv_aa_2stage,CSYSV_AA_2STAGE) -#define LAPACK_zhesv_aa_2stage LAPACK_GLOBAL(zhesv_aa_2stage,ZHESV_AA_2STAGE) -#define LAPACK_ssytrs_aa_2stage LAPACK_GLOBAL(ssytrs_aa_2stage,SSYTRS_AA_2STAGE) -#define LAPACK_dsytrs_aa_2stage LAPACK_GLOBAL(dsytrs_aa_2stage,DSYTRS_AA_2STAGE) -#define LAPACK_csytrs_aa_2stage LAPACK_GLOBAL(csytrs_aa_2stage,CSYTRS_AA_2STAGE) -#define LAPACK_zsytrs_aa_2stage LAPACK_GLOBAL(zsytrs_aa_2stage,ZSYTRS_AA_2STAGE) -#define LAPACK_chetrs_aa_2stage LAPACK_GLOBAL(chetrs_aa_2stage,CHETRS_AA_2STAGE) -#define LAPACK_zhetrs_aa_2stage LAPACK_GLOBAL(zhetrs_aa_2stage,ZHETRS_AA_2STAGE) -#define LAPACK_ssytrf_aa_2stage LAPACK_GLOBAL(ssytrf_aa_2stage,SSYTRF_AA_2STAGE) -#define LAPACK_dsytrf_aa_2stage LAPACK_GLOBAL(dsytrf_aa_2stage,DSYTRF_AA_2STAGE) -#define LAPACK_csytrf_aa_2stage LAPACK_GLOBAL(csytrf_aa_2stage,CSYTRF_AA_2STAGE) -#define LAPACK_zsytrf_aa_2stage LAPACK_GLOBAL(zsytrf_aa_2stage,ZSYTRF_AA_2STAGE) -#define LAPACK_chetrf_aa_2stage LAPACK_GLOBAL(chetrf_aa_2stage,CHETRF_AA_2STAGE) -#define LAPACK_zhetrf_aa_2stage LAPACK_GLOBAL(zhetrf_aa_2stage,ZHETRF_AA_2STAGE) - - -void LAPACK_sgetrf( lapack_int* m, lapack_int* n, float* a, lapack_int* lda, - lapack_int* ipiv, lapack_int *info ); -void LAPACK_dgetrf( lapack_int* m, lapack_int* n, double* a, lapack_int* lda, - lapack_int* ipiv, lapack_int *info ); -void LAPACK_cgetrf( lapack_int* m, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_int* ipiv, lapack_int *info ); -void LAPACK_zgetrf( lapack_int* m, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_int* ipiv, lapack_int *info ); -void LAPACK_sgetrf2( lapack_int* m, lapack_int* n, float* a, lapack_int* lda, - lapack_int* ipiv, lapack_int *info ); -void LAPACK_dgetrf2( lapack_int* m, lapack_int* n, double* a, lapack_int* lda, - lapack_int* ipiv, lapack_int *info ); -void LAPACK_cgetrf2( lapack_int* m, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_int* ipiv, lapack_int *info ); -void LAPACK_zgetrf2( lapack_int* m, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_int* ipiv, lapack_int *info ); -void LAPACK_sgbtrf( lapack_int* m, lapack_int* n, lapack_int* kl, - lapack_int* ku, float* ab, lapack_int* ldab, - lapack_int* ipiv, lapack_int *info ); -void LAPACK_dgbtrf( lapack_int* m, lapack_int* n, lapack_int* kl, - lapack_int* ku, double* ab, lapack_int* ldab, - lapack_int* ipiv, lapack_int *info ); -void LAPACK_cgbtrf( lapack_int* m, lapack_int* n, lapack_int* kl, - lapack_int* ku, lapack_complex_float* ab, lapack_int* ldab, - lapack_int* ipiv, lapack_int *info ); -void LAPACK_zgbtrf( lapack_int* m, lapack_int* n, lapack_int* kl, - lapack_int* ku, lapack_complex_double* ab, lapack_int* ldab, - lapack_int* ipiv, lapack_int *info ); -void LAPACK_sgttrf( lapack_int* n, float* dl, float* d, float* du, float* du2, - lapack_int* ipiv, lapack_int *info ); -void LAPACK_dgttrf( lapack_int* n, double* dl, double* d, double* du, - double* du2, lapack_int* ipiv, lapack_int *info ); -void LAPACK_cgttrf( lapack_int* n, lapack_complex_float* dl, - lapack_complex_float* d, lapack_complex_float* du, - lapack_complex_float* du2, lapack_int* ipiv, - lapack_int *info ); -void LAPACK_zgttrf( lapack_int* n, lapack_complex_double* dl, - lapack_complex_double* d, lapack_complex_double* du, - lapack_complex_double* du2, lapack_int* ipiv, - lapack_int *info ); -void LAPACK_spotrf2( char* uplo, lapack_int* n, float* a, lapack_int* lda, - lapack_int *info ); -void LAPACK_dpotrf2( char* uplo, lapack_int* n, double* a, lapack_int* lda, - lapack_int *info ); -void LAPACK_cpotrf2( char* uplo, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_int *info ); -void LAPACK_zpotrf2( char* uplo, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_int *info ); -void LAPACK_spotrf( char* uplo, lapack_int* n, float* a, lapack_int* lda, - lapack_int *info ); -void LAPACK_dpotrf( char* uplo, lapack_int* n, double* a, lapack_int* lda, - lapack_int *info ); -void LAPACK_cpotrf( char* uplo, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_int *info ); -void LAPACK_zpotrf( char* uplo, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_int *info ); -void LAPACK_dpstrf( char* uplo, lapack_int* n, double* a, lapack_int* lda, - lapack_int* piv, lapack_int* rank, double* tol, - double* work, lapack_int *info ); -void LAPACK_spstrf( char* uplo, lapack_int* n, float* a, lapack_int* lda, - lapack_int* piv, lapack_int* rank, float* tol, float* work, - lapack_int *info ); -void LAPACK_zpstrf( char* uplo, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_int* piv, lapack_int* rank, - double* tol, double* work, lapack_int *info ); -void LAPACK_cpstrf( char* uplo, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_int* piv, lapack_int* rank, - float* tol, float* work, lapack_int *info ); -void LAPACK_dpftrf( char* transr, char* uplo, lapack_int* n, double* a, - lapack_int *info ); -void LAPACK_spftrf( char* transr, char* uplo, lapack_int* n, float* a, - lapack_int *info ); -void LAPACK_zpftrf( char* transr, char* uplo, lapack_int* n, - lapack_complex_double* a, lapack_int *info ); -void LAPACK_cpftrf( char* transr, char* uplo, lapack_int* n, - lapack_complex_float* a, lapack_int *info ); -void LAPACK_spptrf( char* uplo, lapack_int* n, float* ap, lapack_int *info ); -void LAPACK_dpptrf( char* uplo, lapack_int* n, double* ap, lapack_int *info ); -void LAPACK_cpptrf( char* uplo, lapack_int* n, lapack_complex_float* ap, - lapack_int *info ); -void LAPACK_zpptrf( char* uplo, lapack_int* n, lapack_complex_double* ap, - lapack_int *info ); -void LAPACK_spbtrf( char* uplo, lapack_int* n, lapack_int* kd, float* ab, - lapack_int* ldab, lapack_int *info ); -void LAPACK_dpbtrf( char* uplo, lapack_int* n, lapack_int* kd, double* ab, - lapack_int* ldab, lapack_int *info ); -void LAPACK_cpbtrf( char* uplo, lapack_int* n, lapack_int* kd, - lapack_complex_float* ab, lapack_int* ldab, - lapack_int *info ); -void LAPACK_zpbtrf( char* uplo, lapack_int* n, lapack_int* kd, - lapack_complex_double* ab, lapack_int* ldab, - lapack_int *info ); -void LAPACK_spttrf( lapack_int* n, float* d, float* e, lapack_int *info ); -void LAPACK_dpttrf( lapack_int* n, double* d, double* e, lapack_int *info ); -void LAPACK_cpttrf( lapack_int* n, float* d, lapack_complex_float* e, - lapack_int *info ); -void LAPACK_zpttrf( lapack_int* n, double* d, lapack_complex_double* e, - lapack_int *info ); -void LAPACK_ssytrf( char* uplo, lapack_int* n, float* a, lapack_int* lda, - lapack_int* ipiv, float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_dsytrf( char* uplo, lapack_int* n, double* a, lapack_int* lda, - lapack_int* ipiv, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_csytrf( char* uplo, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_int* ipiv, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zsytrf( char* uplo, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_int* ipiv, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_chetrf( char* uplo, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_int* ipiv, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zhetrf( char* uplo, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_int* ipiv, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_ssptrf( char* uplo, lapack_int* n, float* ap, lapack_int* ipiv, - lapack_int *info ); -void LAPACK_dsptrf( char* uplo, lapack_int* n, double* ap, lapack_int* ipiv, - lapack_int *info ); -void LAPACK_csptrf( char* uplo, lapack_int* n, lapack_complex_float* ap, - lapack_int* ipiv, lapack_int *info ); -void LAPACK_zsptrf( char* uplo, lapack_int* n, lapack_complex_double* ap, - lapack_int* ipiv, lapack_int *info ); -void LAPACK_chptrf( char* uplo, lapack_int* n, lapack_complex_float* ap, - lapack_int* ipiv, lapack_int *info ); -void LAPACK_zhptrf( char* uplo, lapack_int* n, lapack_complex_double* ap, - lapack_int* ipiv, lapack_int *info ); -void LAPACK_sgetrs( char* trans, lapack_int* n, lapack_int* nrhs, - const float* a, lapack_int* lda, const lapack_int* ipiv, - float* b, lapack_int* ldb, lapack_int *info ); -void LAPACK_dgetrs( char* trans, lapack_int* n, lapack_int* nrhs, - const double* a, lapack_int* lda, const lapack_int* ipiv, - double* b, lapack_int* ldb, lapack_int *info ); -void LAPACK_cgetrs( char* trans, lapack_int* n, lapack_int* nrhs, - const lapack_complex_float* a, lapack_int* lda, - const lapack_int* ipiv, lapack_complex_float* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_zgetrs( char* trans, lapack_int* n, lapack_int* nrhs, - const lapack_complex_double* a, lapack_int* lda, - const lapack_int* ipiv, lapack_complex_double* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_sgbtrs( char* trans, lapack_int* n, lapack_int* kl, lapack_int* ku, - lapack_int* nrhs, const float* ab, lapack_int* ldab, - const lapack_int* ipiv, float* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_dgbtrs( char* trans, lapack_int* n, lapack_int* kl, lapack_int* ku, - lapack_int* nrhs, const double* ab, lapack_int* ldab, - const lapack_int* ipiv, double* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_cgbtrs( char* trans, lapack_int* n, lapack_int* kl, lapack_int* ku, - lapack_int* nrhs, const lapack_complex_float* ab, - lapack_int* ldab, const lapack_int* ipiv, - lapack_complex_float* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_zgbtrs( char* trans, lapack_int* n, lapack_int* kl, lapack_int* ku, - lapack_int* nrhs, const lapack_complex_double* ab, - lapack_int* ldab, const lapack_int* ipiv, - lapack_complex_double* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_sgttrs( char* trans, lapack_int* n, lapack_int* nrhs, - const float* dl, const float* d, const float* du, - const float* du2, const lapack_int* ipiv, float* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_dgttrs( char* trans, lapack_int* n, lapack_int* nrhs, - const double* dl, const double* d, const double* du, - const double* du2, const lapack_int* ipiv, double* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_cgttrs( char* trans, lapack_int* n, lapack_int* nrhs, - const lapack_complex_float* dl, - const lapack_complex_float* d, - const lapack_complex_float* du, - const lapack_complex_float* du2, const lapack_int* ipiv, - lapack_complex_float* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_zgttrs( char* trans, lapack_int* n, lapack_int* nrhs, - const lapack_complex_double* dl, - const lapack_complex_double* d, - const lapack_complex_double* du, - const lapack_complex_double* du2, const lapack_int* ipiv, - lapack_complex_double* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_spotrs( char* uplo, lapack_int* n, lapack_int* nrhs, const float* a, - lapack_int* lda, float* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_dpotrs( char* uplo, lapack_int* n, lapack_int* nrhs, - const double* a, lapack_int* lda, double* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_cpotrs( char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_zpotrs( char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_dpftrs( char* transr, char* uplo, lapack_int* n, lapack_int* nrhs, - const double* a, double* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_spftrs( char* transr, char* uplo, lapack_int* n, lapack_int* nrhs, - const float* a, float* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_zpftrs( char* transr, char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_double* a, lapack_complex_double* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_cpftrs( char* transr, char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_float* a, lapack_complex_float* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_spptrs( char* uplo, lapack_int* n, lapack_int* nrhs, - const float* ap, float* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_dpptrs( char* uplo, lapack_int* n, lapack_int* nrhs, - const double* ap, double* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_cpptrs( char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_float* ap, lapack_complex_float* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_zpptrs( char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_double* ap, lapack_complex_double* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_spbtrs( char* uplo, lapack_int* n, lapack_int* kd, lapack_int* nrhs, - const float* ab, lapack_int* ldab, float* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_dpbtrs( char* uplo, lapack_int* n, lapack_int* kd, lapack_int* nrhs, - const double* ab, lapack_int* ldab, double* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_cpbtrs( char* uplo, lapack_int* n, lapack_int* kd, lapack_int* nrhs, - const lapack_complex_float* ab, lapack_int* ldab, - lapack_complex_float* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_zpbtrs( char* uplo, lapack_int* n, lapack_int* kd, lapack_int* nrhs, - const lapack_complex_double* ab, lapack_int* ldab, - lapack_complex_double* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_spttrs( lapack_int* n, lapack_int* nrhs, const float* d, - const float* e, float* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_dpttrs( lapack_int* n, lapack_int* nrhs, const double* d, - const double* e, double* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_cpttrs( char* uplo, lapack_int* n, lapack_int* nrhs, const float* d, - const lapack_complex_float* e, lapack_complex_float* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_zpttrs( char* uplo, lapack_int* n, lapack_int* nrhs, - const double* d, const lapack_complex_double* e, - lapack_complex_double* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_ssytrs( char* uplo, lapack_int* n, lapack_int* nrhs, const float* a, - lapack_int* lda, const lapack_int* ipiv, float* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_dsytrs( char* uplo, lapack_int* n, lapack_int* nrhs, - const double* a, lapack_int* lda, const lapack_int* ipiv, - double* b, lapack_int* ldb, lapack_int *info ); -void LAPACK_csytrs( char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_float* a, lapack_int* lda, - const lapack_int* ipiv, lapack_complex_float* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_zsytrs( char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_double* a, lapack_int* lda, - const lapack_int* ipiv, lapack_complex_double* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_chetrs( char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_float* a, lapack_int* lda, - const lapack_int* ipiv, lapack_complex_float* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_zhetrs( char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_double* a, lapack_int* lda, - const lapack_int* ipiv, lapack_complex_double* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_ssptrs( char* uplo, lapack_int* n, lapack_int* nrhs, - const float* ap, const lapack_int* ipiv, float* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_dsptrs( char* uplo, lapack_int* n, lapack_int* nrhs, - const double* ap, const lapack_int* ipiv, double* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_csptrs( char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_float* ap, const lapack_int* ipiv, - lapack_complex_float* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_zsptrs( char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_double* ap, const lapack_int* ipiv, - lapack_complex_double* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_chptrs( char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_float* ap, const lapack_int* ipiv, - lapack_complex_float* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_zhptrs( char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_double* ap, const lapack_int* ipiv, - lapack_complex_double* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_strtrs( char* uplo, char* trans, char* diag, lapack_int* n, - lapack_int* nrhs, const float* a, lapack_int* lda, float* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_dtrtrs( char* uplo, char* trans, char* diag, lapack_int* n, - lapack_int* nrhs, const double* a, lapack_int* lda, - double* b, lapack_int* ldb, lapack_int *info ); -void LAPACK_ctrtrs( char* uplo, char* trans, char* diag, lapack_int* n, - lapack_int* nrhs, const lapack_complex_float* a, - lapack_int* lda, lapack_complex_float* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_ztrtrs( char* uplo, char* trans, char* diag, lapack_int* n, - lapack_int* nrhs, const lapack_complex_double* a, - lapack_int* lda, lapack_complex_double* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_stptrs( char* uplo, char* trans, char* diag, lapack_int* n, - lapack_int* nrhs, const float* ap, float* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_dtptrs( char* uplo, char* trans, char* diag, lapack_int* n, - lapack_int* nrhs, const double* ap, double* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_ctptrs( char* uplo, char* trans, char* diag, lapack_int* n, - lapack_int* nrhs, const lapack_complex_float* ap, - lapack_complex_float* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_ztptrs( char* uplo, char* trans, char* diag, lapack_int* n, - lapack_int* nrhs, const lapack_complex_double* ap, - lapack_complex_double* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_stbtrs( char* uplo, char* trans, char* diag, lapack_int* n, - lapack_int* kd, lapack_int* nrhs, const float* ab, - lapack_int* ldab, float* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_dtbtrs( char* uplo, char* trans, char* diag, lapack_int* n, - lapack_int* kd, lapack_int* nrhs, const double* ab, - lapack_int* ldab, double* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_ctbtrs( char* uplo, char* trans, char* diag, lapack_int* n, - lapack_int* kd, lapack_int* nrhs, - const lapack_complex_float* ab, lapack_int* ldab, - lapack_complex_float* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_ztbtrs( char* uplo, char* trans, char* diag, lapack_int* n, - lapack_int* kd, lapack_int* nrhs, - const lapack_complex_double* ab, lapack_int* ldab, - lapack_complex_double* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_sgecon( char* norm, lapack_int* n, const float* a, lapack_int* lda, - float* anorm, float* rcond, float* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_dgecon( char* norm, lapack_int* n, const double* a, lapack_int* lda, - double* anorm, double* rcond, double* work, - lapack_int* iwork, lapack_int *info ); -void LAPACK_cgecon( char* norm, lapack_int* n, const lapack_complex_float* a, - lapack_int* lda, float* anorm, float* rcond, - lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_zgecon( char* norm, lapack_int* n, const lapack_complex_double* a, - lapack_int* lda, double* anorm, double* rcond, - lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_sgbcon( char* norm, lapack_int* n, lapack_int* kl, lapack_int* ku, - const float* ab, lapack_int* ldab, const lapack_int* ipiv, - float* anorm, float* rcond, float* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_dgbcon( char* norm, lapack_int* n, lapack_int* kl, lapack_int* ku, - const double* ab, lapack_int* ldab, const lapack_int* ipiv, - double* anorm, double* rcond, double* work, - lapack_int* iwork, lapack_int *info ); -void LAPACK_cgbcon( char* norm, lapack_int* n, lapack_int* kl, lapack_int* ku, - const lapack_complex_float* ab, lapack_int* ldab, - const lapack_int* ipiv, float* anorm, float* rcond, - lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_zgbcon( char* norm, lapack_int* n, lapack_int* kl, lapack_int* ku, - const lapack_complex_double* ab, lapack_int* ldab, - const lapack_int* ipiv, double* anorm, double* rcond, - lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_sgtcon( char* norm, lapack_int* n, const float* dl, const float* d, - const float* du, const float* du2, const lapack_int* ipiv, - float* anorm, float* rcond, float* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_dgtcon( char* norm, lapack_int* n, const double* dl, - const double* d, const double* du, const double* du2, - const lapack_int* ipiv, double* anorm, double* rcond, - double* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_cgtcon( char* norm, lapack_int* n, const lapack_complex_float* dl, - const lapack_complex_float* d, - const lapack_complex_float* du, - const lapack_complex_float* du2, const lapack_int* ipiv, - float* anorm, float* rcond, lapack_complex_float* work, - lapack_int *info ); -void LAPACK_zgtcon( char* norm, lapack_int* n, const lapack_complex_double* dl, - const lapack_complex_double* d, - const lapack_complex_double* du, - const lapack_complex_double* du2, const lapack_int* ipiv, - double* anorm, double* rcond, lapack_complex_double* work, - lapack_int *info ); -void LAPACK_spocon( char* uplo, lapack_int* n, const float* a, lapack_int* lda, - float* anorm, float* rcond, float* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_dpocon( char* uplo, lapack_int* n, const double* a, lapack_int* lda, - double* anorm, double* rcond, double* work, - lapack_int* iwork, lapack_int *info ); -void LAPACK_cpocon( char* uplo, lapack_int* n, const lapack_complex_float* a, - lapack_int* lda, float* anorm, float* rcond, - lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_zpocon( char* uplo, lapack_int* n, const lapack_complex_double* a, - lapack_int* lda, double* anorm, double* rcond, - lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_sppcon( char* uplo, lapack_int* n, const float* ap, float* anorm, - float* rcond, float* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_dppcon( char* uplo, lapack_int* n, const double* ap, double* anorm, - double* rcond, double* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_cppcon( char* uplo, lapack_int* n, const lapack_complex_float* ap, - float* anorm, float* rcond, lapack_complex_float* work, - float* rwork, lapack_int *info ); -void LAPACK_zppcon( char* uplo, lapack_int* n, const lapack_complex_double* ap, - double* anorm, double* rcond, lapack_complex_double* work, - double* rwork, lapack_int *info ); -void LAPACK_spbcon( char* uplo, lapack_int* n, lapack_int* kd, const float* ab, - lapack_int* ldab, float* anorm, float* rcond, float* work, - lapack_int* iwork, lapack_int *info ); -void LAPACK_dpbcon( char* uplo, lapack_int* n, lapack_int* kd, const double* ab, - lapack_int* ldab, double* anorm, double* rcond, - double* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_cpbcon( char* uplo, lapack_int* n, lapack_int* kd, - const lapack_complex_float* ab, lapack_int* ldab, - float* anorm, float* rcond, lapack_complex_float* work, - float* rwork, lapack_int *info ); -void LAPACK_zpbcon( char* uplo, lapack_int* n, lapack_int* kd, - const lapack_complex_double* ab, lapack_int* ldab, - double* anorm, double* rcond, lapack_complex_double* work, - double* rwork, lapack_int *info ); -void LAPACK_sptcon( lapack_int* n, const float* d, const float* e, float* anorm, - float* rcond, float* work, lapack_int *info ); -void LAPACK_dptcon( lapack_int* n, const double* d, const double* e, - double* anorm, double* rcond, double* work, - lapack_int *info ); -void LAPACK_cptcon( lapack_int* n, const float* d, - const lapack_complex_float* e, float* anorm, float* rcond, - float* work, lapack_int *info ); -void LAPACK_zptcon( lapack_int* n, const double* d, - const lapack_complex_double* e, double* anorm, - double* rcond, double* work, lapack_int *info ); -void LAPACK_ssycon( char* uplo, lapack_int* n, const float* a, lapack_int* lda, - const lapack_int* ipiv, float* anorm, float* rcond, - float* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_dsycon( char* uplo, lapack_int* n, const double* a, lapack_int* lda, - const lapack_int* ipiv, double* anorm, double* rcond, - double* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_csycon( char* uplo, lapack_int* n, const lapack_complex_float* a, - lapack_int* lda, const lapack_int* ipiv, float* anorm, - float* rcond, lapack_complex_float* work, - lapack_int *info ); -void LAPACK_zsycon( char* uplo, lapack_int* n, const lapack_complex_double* a, - lapack_int* lda, const lapack_int* ipiv, double* anorm, - double* rcond, lapack_complex_double* work, - lapack_int *info ); -void LAPACK_checon( char* uplo, lapack_int* n, const lapack_complex_float* a, - lapack_int* lda, const lapack_int* ipiv, float* anorm, - float* rcond, lapack_complex_float* work, - lapack_int *info ); -void LAPACK_zhecon( char* uplo, lapack_int* n, const lapack_complex_double* a, - lapack_int* lda, const lapack_int* ipiv, double* anorm, - double* rcond, lapack_complex_double* work, - lapack_int *info ); -void LAPACK_sspcon( char* uplo, lapack_int* n, const float* ap, - const lapack_int* ipiv, float* anorm, float* rcond, - float* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_dspcon( char* uplo, lapack_int* n, const double* ap, - const lapack_int* ipiv, double* anorm, double* rcond, - double* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_cspcon( char* uplo, lapack_int* n, const lapack_complex_float* ap, - const lapack_int* ipiv, float* anorm, float* rcond, - lapack_complex_float* work, lapack_int *info ); -void LAPACK_zspcon( char* uplo, lapack_int* n, const lapack_complex_double* ap, - const lapack_int* ipiv, double* anorm, double* rcond, - lapack_complex_double* work, lapack_int *info ); -void LAPACK_chpcon( char* uplo, lapack_int* n, const lapack_complex_float* ap, - const lapack_int* ipiv, float* anorm, float* rcond, - lapack_complex_float* work, lapack_int *info ); -void LAPACK_zhpcon( char* uplo, lapack_int* n, const lapack_complex_double* ap, - const lapack_int* ipiv, double* anorm, double* rcond, - lapack_complex_double* work, lapack_int *info ); -void LAPACK_strcon( char* norm, char* uplo, char* diag, lapack_int* n, - const float* a, lapack_int* lda, float* rcond, float* work, - lapack_int* iwork, lapack_int *info ); -void LAPACK_dtrcon( char* norm, char* uplo, char* diag, lapack_int* n, - const double* a, lapack_int* lda, double* rcond, - double* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_ctrcon( char* norm, char* uplo, char* diag, lapack_int* n, - const lapack_complex_float* a, lapack_int* lda, - float* rcond, lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_ztrcon( char* norm, char* uplo, char* diag, lapack_int* n, - const lapack_complex_double* a, lapack_int* lda, - double* rcond, lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_stpcon( char* norm, char* uplo, char* diag, lapack_int* n, - const float* ap, float* rcond, float* work, - lapack_int* iwork, lapack_int *info ); -void LAPACK_dtpcon( char* norm, char* uplo, char* diag, lapack_int* n, - const double* ap, double* rcond, double* work, - lapack_int* iwork, lapack_int *info ); -void LAPACK_ctpcon( char* norm, char* uplo, char* diag, lapack_int* n, - const lapack_complex_float* ap, float* rcond, - lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_ztpcon( char* norm, char* uplo, char* diag, lapack_int* n, - const lapack_complex_double* ap, double* rcond, - lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_stbcon( char* norm, char* uplo, char* diag, lapack_int* n, - lapack_int* kd, const float* ab, lapack_int* ldab, - float* rcond, float* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_dtbcon( char* norm, char* uplo, char* diag, lapack_int* n, - lapack_int* kd, const double* ab, lapack_int* ldab, - double* rcond, double* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_ctbcon( char* norm, char* uplo, char* diag, lapack_int* n, - lapack_int* kd, const lapack_complex_float* ab, - lapack_int* ldab, float* rcond, lapack_complex_float* work, - float* rwork, lapack_int *info ); -void LAPACK_ztbcon( char* norm, char* uplo, char* diag, lapack_int* n, - lapack_int* kd, const lapack_complex_double* ab, - lapack_int* ldab, double* rcond, - lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_sgerfs( char* trans, lapack_int* n, lapack_int* nrhs, - const float* a, lapack_int* lda, const float* af, - lapack_int* ldaf, const lapack_int* ipiv, const float* b, - lapack_int* ldb, float* x, lapack_int* ldx, float* ferr, - float* berr, float* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_dgerfs( char* trans, lapack_int* n, lapack_int* nrhs, - const double* a, lapack_int* lda, const double* af, - lapack_int* ldaf, const lapack_int* ipiv, const double* b, - lapack_int* ldb, double* x, lapack_int* ldx, double* ferr, - double* berr, double* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_cgerfs( char* trans, lapack_int* n, lapack_int* nrhs, - const lapack_complex_float* a, lapack_int* lda, - const lapack_complex_float* af, lapack_int* ldaf, - const lapack_int* ipiv, const lapack_complex_float* b, - lapack_int* ldb, lapack_complex_float* x, lapack_int* ldx, - float* ferr, float* berr, lapack_complex_float* work, - float* rwork, lapack_int *info ); -void LAPACK_zgerfs( char* trans, lapack_int* n, lapack_int* nrhs, - const lapack_complex_double* a, lapack_int* lda, - const lapack_complex_double* af, lapack_int* ldaf, - const lapack_int* ipiv, const lapack_complex_double* b, - lapack_int* ldb, lapack_complex_double* x, lapack_int* ldx, - double* ferr, double* berr, lapack_complex_double* work, - double* rwork, lapack_int *info ); -void LAPACK_dgerfsx( char* trans, char* equed, lapack_int* n, lapack_int* nrhs, - const double* a, lapack_int* lda, const double* af, - lapack_int* ldaf, const lapack_int* ipiv, const double* r, - const double* c, const double* b, lapack_int* ldb, - double* x, lapack_int* ldx, double* rcond, double* berr, - lapack_int* n_err_bnds, double* err_bnds_norm, - double* err_bnds_comp, lapack_int* nparams, double* params, - double* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_sgerfsx( char* trans, char* equed, lapack_int* n, lapack_int* nrhs, - const float* a, lapack_int* lda, const float* af, - lapack_int* ldaf, const lapack_int* ipiv, const float* r, - const float* c, const float* b, lapack_int* ldb, float* x, - lapack_int* ldx, float* rcond, float* berr, - lapack_int* n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int* nparams, float* params, - float* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_zgerfsx( char* trans, char* equed, lapack_int* n, lapack_int* nrhs, - const lapack_complex_double* a, lapack_int* lda, - const lapack_complex_double* af, lapack_int* ldaf, - const lapack_int* ipiv, const double* r, const double* c, - const lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* x, lapack_int* ldx, double* rcond, - double* berr, lapack_int* n_err_bnds, - double* err_bnds_norm, double* err_bnds_comp, - lapack_int* nparams, double* params, - lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_cgerfsx( char* trans, char* equed, lapack_int* n, lapack_int* nrhs, - const lapack_complex_float* a, lapack_int* lda, - const lapack_complex_float* af, lapack_int* ldaf, - const lapack_int* ipiv, const float* r, const float* c, - const lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* x, lapack_int* ldx, float* rcond, - float* berr, lapack_int* n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int* nparams, float* params, - lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_sgbrfs( char* trans, lapack_int* n, lapack_int* kl, lapack_int* ku, - lapack_int* nrhs, const float* ab, lapack_int* ldab, - const float* afb, lapack_int* ldafb, const lapack_int* ipiv, - const float* b, lapack_int* ldb, float* x, lapack_int* ldx, - float* ferr, float* berr, float* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_dgbrfs( char* trans, lapack_int* n, lapack_int* kl, lapack_int* ku, - lapack_int* nrhs, const double* ab, lapack_int* ldab, - const double* afb, lapack_int* ldafb, - const lapack_int* ipiv, const double* b, lapack_int* ldb, - double* x, lapack_int* ldx, double* ferr, double* berr, - double* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_cgbrfs( char* trans, lapack_int* n, lapack_int* kl, lapack_int* ku, - lapack_int* nrhs, const lapack_complex_float* ab, - lapack_int* ldab, const lapack_complex_float* afb, - lapack_int* ldafb, const lapack_int* ipiv, - const lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* x, lapack_int* ldx, float* ferr, - float* berr, lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_zgbrfs( char* trans, lapack_int* n, lapack_int* kl, lapack_int* ku, - lapack_int* nrhs, const lapack_complex_double* ab, - lapack_int* ldab, const lapack_complex_double* afb, - lapack_int* ldafb, const lapack_int* ipiv, - const lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* x, lapack_int* ldx, double* ferr, - double* berr, lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_dgbrfsx( char* trans, char* equed, lapack_int* n, lapack_int* kl, - lapack_int* ku, lapack_int* nrhs, const double* ab, - lapack_int* ldab, const double* afb, lapack_int* ldafb, - const lapack_int* ipiv, const double* r, const double* c, - const double* b, lapack_int* ldb, double* x, - lapack_int* ldx, double* rcond, double* berr, - lapack_int* n_err_bnds, double* err_bnds_norm, - double* err_bnds_comp, lapack_int* nparams, double* params, - double* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_sgbrfsx( char* trans, char* equed, lapack_int* n, lapack_int* kl, - lapack_int* ku, lapack_int* nrhs, const float* ab, - lapack_int* ldab, const float* afb, lapack_int* ldafb, - const lapack_int* ipiv, const float* r, const float* c, - const float* b, lapack_int* ldb, float* x, lapack_int* ldx, - float* rcond, float* berr, lapack_int* n_err_bnds, - float* err_bnds_norm, float* err_bnds_comp, - lapack_int* nparams, float* params, float* work, - lapack_int* iwork, lapack_int *info ); -void LAPACK_zgbrfsx( char* trans, char* equed, lapack_int* n, lapack_int* kl, - lapack_int* ku, lapack_int* nrhs, - const lapack_complex_double* ab, lapack_int* ldab, - const lapack_complex_double* afb, lapack_int* ldafb, - const lapack_int* ipiv, const double* r, const double* c, - const lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* x, lapack_int* ldx, double* rcond, - double* berr, lapack_int* n_err_bnds, - double* err_bnds_norm, double* err_bnds_comp, - lapack_int* nparams, double* params, - lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_cgbrfsx( char* trans, char* equed, lapack_int* n, lapack_int* kl, - lapack_int* ku, lapack_int* nrhs, - const lapack_complex_float* ab, lapack_int* ldab, - const lapack_complex_float* afb, lapack_int* ldafb, - const lapack_int* ipiv, const float* r, const float* c, - const lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* x, lapack_int* ldx, float* rcond, - float* berr, lapack_int* n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int* nparams, float* params, - lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_sgtrfs( char* trans, lapack_int* n, lapack_int* nrhs, - const float* dl, const float* d, const float* du, - const float* dlf, const float* df, const float* duf, - const float* du2, const lapack_int* ipiv, const float* b, - lapack_int* ldb, float* x, lapack_int* ldx, float* ferr, - float* berr, float* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_dgtrfs( char* trans, lapack_int* n, lapack_int* nrhs, - const double* dl, const double* d, const double* du, - const double* dlf, const double* df, const double* duf, - const double* du2, const lapack_int* ipiv, const double* b, - lapack_int* ldb, double* x, lapack_int* ldx, double* ferr, - double* berr, double* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_cgtrfs( char* trans, lapack_int* n, lapack_int* nrhs, - const lapack_complex_float* dl, - const lapack_complex_float* d, - const lapack_complex_float* du, - const lapack_complex_float* dlf, - const lapack_complex_float* df, - const lapack_complex_float* duf, - const lapack_complex_float* du2, const lapack_int* ipiv, - const lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* x, lapack_int* ldx, float* ferr, - float* berr, lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_zgtrfs( char* trans, lapack_int* n, lapack_int* nrhs, - const lapack_complex_double* dl, - const lapack_complex_double* d, - const lapack_complex_double* du, - const lapack_complex_double* dlf, - const lapack_complex_double* df, - const lapack_complex_double* duf, - const lapack_complex_double* du2, const lapack_int* ipiv, - const lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* x, lapack_int* ldx, double* ferr, - double* berr, lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_sporfs( char* uplo, lapack_int* n, lapack_int* nrhs, const float* a, - lapack_int* lda, const float* af, lapack_int* ldaf, - const float* b, lapack_int* ldb, float* x, lapack_int* ldx, - float* ferr, float* berr, float* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_dporfs( char* uplo, lapack_int* n, lapack_int* nrhs, - const double* a, lapack_int* lda, const double* af, - lapack_int* ldaf, const double* b, lapack_int* ldb, - double* x, lapack_int* ldx, double* ferr, double* berr, - double* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_cporfs( char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_float* a, lapack_int* lda, - const lapack_complex_float* af, lapack_int* ldaf, - const lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* x, lapack_int* ldx, float* ferr, - float* berr, lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_zporfs( char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_double* a, lapack_int* lda, - const lapack_complex_double* af, lapack_int* ldaf, - const lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* x, lapack_int* ldx, double* ferr, - double* berr, lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_dporfsx( char* uplo, char* equed, lapack_int* n, lapack_int* nrhs, - const double* a, lapack_int* lda, const double* af, - lapack_int* ldaf, const double* s, const double* b, - lapack_int* ldb, double* x, lapack_int* ldx, double* rcond, - double* berr, lapack_int* n_err_bnds, - double* err_bnds_norm, double* err_bnds_comp, - lapack_int* nparams, double* params, double* work, - lapack_int* iwork, lapack_int *info ); -void LAPACK_sporfsx( char* uplo, char* equed, lapack_int* n, lapack_int* nrhs, - const float* a, lapack_int* lda, const float* af, - lapack_int* ldaf, const float* s, const float* b, - lapack_int* ldb, float* x, lapack_int* ldx, float* rcond, - float* berr, lapack_int* n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int* nparams, float* params, - float* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_zporfsx( char* uplo, char* equed, lapack_int* n, lapack_int* nrhs, - const lapack_complex_double* a, lapack_int* lda, - const lapack_complex_double* af, lapack_int* ldaf, - const double* s, const lapack_complex_double* b, - lapack_int* ldb, lapack_complex_double* x, lapack_int* ldx, - double* rcond, double* berr, lapack_int* n_err_bnds, - double* err_bnds_norm, double* err_bnds_comp, - lapack_int* nparams, double* params, - lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_cporfsx( char* uplo, char* equed, lapack_int* n, lapack_int* nrhs, - const lapack_complex_float* a, lapack_int* lda, - const lapack_complex_float* af, lapack_int* ldaf, - const float* s, const lapack_complex_float* b, - lapack_int* ldb, lapack_complex_float* x, lapack_int* ldx, - float* rcond, float* berr, lapack_int* n_err_bnds, - float* err_bnds_norm, float* err_bnds_comp, - lapack_int* nparams, float* params, - lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_spprfs( char* uplo, lapack_int* n, lapack_int* nrhs, - const float* ap, const float* afp, const float* b, - lapack_int* ldb, float* x, lapack_int* ldx, float* ferr, - float* berr, float* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_dpprfs( char* uplo, lapack_int* n, lapack_int* nrhs, - const double* ap, const double* afp, const double* b, - lapack_int* ldb, double* x, lapack_int* ldx, double* ferr, - double* berr, double* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_cpprfs( char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_float* ap, - const lapack_complex_float* afp, - const lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* x, lapack_int* ldx, float* ferr, - float* berr, lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_zpprfs( char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_double* ap, - const lapack_complex_double* afp, - const lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* x, lapack_int* ldx, double* ferr, - double* berr, lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_spbrfs( char* uplo, lapack_int* n, lapack_int* kd, lapack_int* nrhs, - const float* ab, lapack_int* ldab, const float* afb, - lapack_int* ldafb, const float* b, lapack_int* ldb, - float* x, lapack_int* ldx, float* ferr, float* berr, - float* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_dpbrfs( char* uplo, lapack_int* n, lapack_int* kd, lapack_int* nrhs, - const double* ab, lapack_int* ldab, const double* afb, - lapack_int* ldafb, const double* b, lapack_int* ldb, - double* x, lapack_int* ldx, double* ferr, double* berr, - double* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_cpbrfs( char* uplo, lapack_int* n, lapack_int* kd, lapack_int* nrhs, - const lapack_complex_float* ab, lapack_int* ldab, - const lapack_complex_float* afb, lapack_int* ldafb, - const lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* x, lapack_int* ldx, float* ferr, - float* berr, lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_zpbrfs( char* uplo, lapack_int* n, lapack_int* kd, lapack_int* nrhs, - const lapack_complex_double* ab, lapack_int* ldab, - const lapack_complex_double* afb, lapack_int* ldafb, - const lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* x, lapack_int* ldx, double* ferr, - double* berr, lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_sptrfs( lapack_int* n, lapack_int* nrhs, const float* d, - const float* e, const float* df, const float* ef, - const float* b, lapack_int* ldb, float* x, lapack_int* ldx, - float* ferr, float* berr, float* work, lapack_int *info ); -void LAPACK_dptrfs( lapack_int* n, lapack_int* nrhs, const double* d, - const double* e, const double* df, const double* ef, - const double* b, lapack_int* ldb, double* x, - lapack_int* ldx, double* ferr, double* berr, double* work, - lapack_int *info ); -void LAPACK_cptrfs( char* uplo, lapack_int* n, lapack_int* nrhs, const float* d, - const lapack_complex_float* e, const float* df, - const lapack_complex_float* ef, - const lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* x, lapack_int* ldx, float* ferr, - float* berr, lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_zptrfs( char* uplo, lapack_int* n, lapack_int* nrhs, - const double* d, const lapack_complex_double* e, - const double* df, const lapack_complex_double* ef, - const lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* x, lapack_int* ldx, double* ferr, - double* berr, lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_ssyrfs( char* uplo, lapack_int* n, lapack_int* nrhs, const float* a, - lapack_int* lda, const float* af, lapack_int* ldaf, - const lapack_int* ipiv, const float* b, lapack_int* ldb, - float* x, lapack_int* ldx, float* ferr, float* berr, - float* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_dsyrfs( char* uplo, lapack_int* n, lapack_int* nrhs, - const double* a, lapack_int* lda, const double* af, - lapack_int* ldaf, const lapack_int* ipiv, const double* b, - lapack_int* ldb, double* x, lapack_int* ldx, double* ferr, - double* berr, double* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_csyrfs( char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_float* a, lapack_int* lda, - const lapack_complex_float* af, lapack_int* ldaf, - const lapack_int* ipiv, const lapack_complex_float* b, - lapack_int* ldb, lapack_complex_float* x, lapack_int* ldx, - float* ferr, float* berr, lapack_complex_float* work, - float* rwork, lapack_int *info ); -void LAPACK_zsyrfs( char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_double* a, lapack_int* lda, - const lapack_complex_double* af, lapack_int* ldaf, - const lapack_int* ipiv, const lapack_complex_double* b, - lapack_int* ldb, lapack_complex_double* x, lapack_int* ldx, - double* ferr, double* berr, lapack_complex_double* work, - double* rwork, lapack_int *info ); -void LAPACK_dsyrfsx( char* uplo, char* equed, lapack_int* n, lapack_int* nrhs, - const double* a, lapack_int* lda, const double* af, - lapack_int* ldaf, const lapack_int* ipiv, const double* s, - const double* b, lapack_int* ldb, double* x, - lapack_int* ldx, double* rcond, double* berr, - lapack_int* n_err_bnds, double* err_bnds_norm, - double* err_bnds_comp, lapack_int* nparams, double* params, - double* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_ssyrfsx( char* uplo, char* equed, lapack_int* n, lapack_int* nrhs, - const float* a, lapack_int* lda, const float* af, - lapack_int* ldaf, const lapack_int* ipiv, const float* s, - const float* b, lapack_int* ldb, float* x, lapack_int* ldx, - float* rcond, float* berr, lapack_int* n_err_bnds, - float* err_bnds_norm, float* err_bnds_comp, - lapack_int* nparams, float* params, float* work, - lapack_int* iwork, lapack_int *info ); -void LAPACK_zsyrfsx( char* uplo, char* equed, lapack_int* n, lapack_int* nrhs, - const lapack_complex_double* a, lapack_int* lda, - const lapack_complex_double* af, lapack_int* ldaf, - const lapack_int* ipiv, const double* s, - const lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* x, lapack_int* ldx, double* rcond, - double* berr, lapack_int* n_err_bnds, - double* err_bnds_norm, double* err_bnds_comp, - lapack_int* nparams, double* params, - lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_csyrfsx( char* uplo, char* equed, lapack_int* n, lapack_int* nrhs, - const lapack_complex_float* a, lapack_int* lda, - const lapack_complex_float* af, lapack_int* ldaf, - const lapack_int* ipiv, const float* s, - const lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* x, lapack_int* ldx, float* rcond, - float* berr, lapack_int* n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int* nparams, float* params, - lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_cherfs( char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_float* a, lapack_int* lda, - const lapack_complex_float* af, lapack_int* ldaf, - const lapack_int* ipiv, const lapack_complex_float* b, - lapack_int* ldb, lapack_complex_float* x, lapack_int* ldx, - float* ferr, float* berr, lapack_complex_float* work, - float* rwork, lapack_int *info ); -void LAPACK_zherfs( char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_double* a, lapack_int* lda, - const lapack_complex_double* af, lapack_int* ldaf, - const lapack_int* ipiv, const lapack_complex_double* b, - lapack_int* ldb, lapack_complex_double* x, lapack_int* ldx, - double* ferr, double* berr, lapack_complex_double* work, - double* rwork, lapack_int *info ); -void LAPACK_zherfsx( char* uplo, char* equed, lapack_int* n, lapack_int* nrhs, - const lapack_complex_double* a, lapack_int* lda, - const lapack_complex_double* af, lapack_int* ldaf, - const lapack_int* ipiv, const double* s, - const lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* x, lapack_int* ldx, double* rcond, - double* berr, lapack_int* n_err_bnds, - double* err_bnds_norm, double* err_bnds_comp, - lapack_int* nparams, double* params, - lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_cherfsx( char* uplo, char* equed, lapack_int* n, lapack_int* nrhs, - const lapack_complex_float* a, lapack_int* lda, - const lapack_complex_float* af, lapack_int* ldaf, - const lapack_int* ipiv, const float* s, - const lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* x, lapack_int* ldx, float* rcond, - float* berr, lapack_int* n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int* nparams, float* params, - lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_ssprfs( char* uplo, lapack_int* n, lapack_int* nrhs, - const float* ap, const float* afp, const lapack_int* ipiv, - const float* b, lapack_int* ldb, float* x, lapack_int* ldx, - float* ferr, float* berr, float* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_dsprfs( char* uplo, lapack_int* n, lapack_int* nrhs, - const double* ap, const double* afp, const lapack_int* ipiv, - const double* b, lapack_int* ldb, double* x, - lapack_int* ldx, double* ferr, double* berr, double* work, - lapack_int* iwork, lapack_int *info ); -void LAPACK_csprfs( char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_float* ap, - const lapack_complex_float* afp, const lapack_int* ipiv, - const lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* x, lapack_int* ldx, float* ferr, - float* berr, lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_zsprfs( char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_double* ap, - const lapack_complex_double* afp, const lapack_int* ipiv, - const lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* x, lapack_int* ldx, double* ferr, - double* berr, lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_chprfs( char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_float* ap, - const lapack_complex_float* afp, const lapack_int* ipiv, - const lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* x, lapack_int* ldx, float* ferr, - float* berr, lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_zhprfs( char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_double* ap, - const lapack_complex_double* afp, const lapack_int* ipiv, - const lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* x, lapack_int* ldx, double* ferr, - double* berr, lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_strrfs( char* uplo, char* trans, char* diag, lapack_int* n, - lapack_int* nrhs, const float* a, lapack_int* lda, - const float* b, lapack_int* ldb, const float* x, - lapack_int* ldx, float* ferr, float* berr, float* work, - lapack_int* iwork, lapack_int *info ); -void LAPACK_dtrrfs( char* uplo, char* trans, char* diag, lapack_int* n, - lapack_int* nrhs, const double* a, lapack_int* lda, - const double* b, lapack_int* ldb, const double* x, - lapack_int* ldx, double* ferr, double* berr, double* work, - lapack_int* iwork, lapack_int *info ); -void LAPACK_ctrrfs( char* uplo, char* trans, char* diag, lapack_int* n, - lapack_int* nrhs, const lapack_complex_float* a, - lapack_int* lda, const lapack_complex_float* b, - lapack_int* ldb, const lapack_complex_float* x, - lapack_int* ldx, float* ferr, float* berr, - lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_ztrrfs( char* uplo, char* trans, char* diag, lapack_int* n, - lapack_int* nrhs, const lapack_complex_double* a, - lapack_int* lda, const lapack_complex_double* b, - lapack_int* ldb, const lapack_complex_double* x, - lapack_int* ldx, double* ferr, double* berr, - lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_stprfs( char* uplo, char* trans, char* diag, lapack_int* n, - lapack_int* nrhs, const float* ap, const float* b, - lapack_int* ldb, const float* x, lapack_int* ldx, - float* ferr, float* berr, float* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_dtprfs( char* uplo, char* trans, char* diag, lapack_int* n, - lapack_int* nrhs, const double* ap, const double* b, - lapack_int* ldb, const double* x, lapack_int* ldx, - double* ferr, double* berr, double* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_ctprfs( char* uplo, char* trans, char* diag, lapack_int* n, - lapack_int* nrhs, const lapack_complex_float* ap, - const lapack_complex_float* b, lapack_int* ldb, - const lapack_complex_float* x, lapack_int* ldx, float* ferr, - float* berr, lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_ztprfs( char* uplo, char* trans, char* diag, lapack_int* n, - lapack_int* nrhs, const lapack_complex_double* ap, - const lapack_complex_double* b, lapack_int* ldb, - const lapack_complex_double* x, lapack_int* ldx, - double* ferr, double* berr, lapack_complex_double* work, - double* rwork, lapack_int *info ); -void LAPACK_stbrfs( char* uplo, char* trans, char* diag, lapack_int* n, - lapack_int* kd, lapack_int* nrhs, const float* ab, - lapack_int* ldab, const float* b, lapack_int* ldb, - const float* x, lapack_int* ldx, float* ferr, float* berr, - float* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_dtbrfs( char* uplo, char* trans, char* diag, lapack_int* n, - lapack_int* kd, lapack_int* nrhs, const double* ab, - lapack_int* ldab, const double* b, lapack_int* ldb, - const double* x, lapack_int* ldx, double* ferr, - double* berr, double* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_ctbrfs( char* uplo, char* trans, char* diag, lapack_int* n, - lapack_int* kd, lapack_int* nrhs, - const lapack_complex_float* ab, lapack_int* ldab, - const lapack_complex_float* b, lapack_int* ldb, - const lapack_complex_float* x, lapack_int* ldx, float* ferr, - float* berr, lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_ztbrfs( char* uplo, char* trans, char* diag, lapack_int* n, - lapack_int* kd, lapack_int* nrhs, - const lapack_complex_double* ab, lapack_int* ldab, - const lapack_complex_double* b, lapack_int* ldb, - const lapack_complex_double* x, lapack_int* ldx, - double* ferr, double* berr, lapack_complex_double* work, - double* rwork, lapack_int *info ); -void LAPACK_sgetri( lapack_int* n, float* a, lapack_int* lda, - const lapack_int* ipiv, float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_dgetri( lapack_int* n, double* a, lapack_int* lda, - const lapack_int* ipiv, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_cgetri( lapack_int* n, lapack_complex_float* a, lapack_int* lda, - const lapack_int* ipiv, lapack_complex_float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_zgetri( lapack_int* n, lapack_complex_double* a, lapack_int* lda, - const lapack_int* ipiv, lapack_complex_double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_spotri( char* uplo, lapack_int* n, float* a, lapack_int* lda, - lapack_int *info ); -void LAPACK_dpotri( char* uplo, lapack_int* n, double* a, lapack_int* lda, - lapack_int *info ); -void LAPACK_cpotri( char* uplo, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_int *info ); -void LAPACK_zpotri( char* uplo, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_int *info ); -void LAPACK_dpftri( char* transr, char* uplo, lapack_int* n, double* a, - lapack_int *info ); -void LAPACK_spftri( char* transr, char* uplo, lapack_int* n, float* a, - lapack_int *info ); -void LAPACK_zpftri( char* transr, char* uplo, lapack_int* n, - lapack_complex_double* a, lapack_int *info ); -void LAPACK_cpftri( char* transr, char* uplo, lapack_int* n, - lapack_complex_float* a, lapack_int *info ); -void LAPACK_spptri( char* uplo, lapack_int* n, float* ap, lapack_int *info ); -void LAPACK_dpptri( char* uplo, lapack_int* n, double* ap, lapack_int *info ); -void LAPACK_cpptri( char* uplo, lapack_int* n, lapack_complex_float* ap, - lapack_int *info ); -void LAPACK_zpptri( char* uplo, lapack_int* n, lapack_complex_double* ap, - lapack_int *info ); -void LAPACK_ssytri( char* uplo, lapack_int* n, float* a, lapack_int* lda, - const lapack_int* ipiv, float* work, lapack_int *info ); -void LAPACK_dsytri( char* uplo, lapack_int* n, double* a, lapack_int* lda, - const lapack_int* ipiv, double* work, lapack_int *info ); -void LAPACK_csytri( char* uplo, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, const lapack_int* ipiv, - lapack_complex_float* work, lapack_int *info ); -void LAPACK_zsytri( char* uplo, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, const lapack_int* ipiv, - lapack_complex_double* work, lapack_int *info ); -void LAPACK_chetri( char* uplo, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, const lapack_int* ipiv, - lapack_complex_float* work, lapack_int *info ); -void LAPACK_zhetri( char* uplo, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, const lapack_int* ipiv, - lapack_complex_double* work, lapack_int *info ); -void LAPACK_ssptri( char* uplo, lapack_int* n, float* ap, - const lapack_int* ipiv, float* work, lapack_int *info ); -void LAPACK_dsptri( char* uplo, lapack_int* n, double* ap, - const lapack_int* ipiv, double* work, lapack_int *info ); -void LAPACK_csptri( char* uplo, lapack_int* n, lapack_complex_float* ap, - const lapack_int* ipiv, lapack_complex_float* work, - lapack_int *info ); -void LAPACK_zsptri( char* uplo, lapack_int* n, lapack_complex_double* ap, - const lapack_int* ipiv, lapack_complex_double* work, - lapack_int *info ); -void LAPACK_chptri( char* uplo, lapack_int* n, lapack_complex_float* ap, - const lapack_int* ipiv, lapack_complex_float* work, - lapack_int *info ); -void LAPACK_zhptri( char* uplo, lapack_int* n, lapack_complex_double* ap, - const lapack_int* ipiv, lapack_complex_double* work, - lapack_int *info ); -void LAPACK_strtri( char* uplo, char* diag, lapack_int* n, float* a, - lapack_int* lda, lapack_int *info ); -void LAPACK_dtrtri( char* uplo, char* diag, lapack_int* n, double* a, - lapack_int* lda, lapack_int *info ); -void LAPACK_ctrtri( char* uplo, char* diag, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, - lapack_int *info ); -void LAPACK_ztrtri( char* uplo, char* diag, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, - lapack_int *info ); -void LAPACK_dtftri( char* transr, char* uplo, char* diag, lapack_int* n, - double* a, lapack_int *info ); -void LAPACK_stftri( char* transr, char* uplo, char* diag, lapack_int* n, - float* a, lapack_int *info ); -void LAPACK_ztftri( char* transr, char* uplo, char* diag, lapack_int* n, - lapack_complex_double* a, lapack_int *info ); -void LAPACK_ctftri( char* transr, char* uplo, char* diag, lapack_int* n, - lapack_complex_float* a, lapack_int *info ); -void LAPACK_stptri( char* uplo, char* diag, lapack_int* n, float* ap, - lapack_int *info ); -void LAPACK_dtptri( char* uplo, char* diag, lapack_int* n, double* ap, - lapack_int *info ); -void LAPACK_ctptri( char* uplo, char* diag, lapack_int* n, - lapack_complex_float* ap, lapack_int *info ); -void LAPACK_ztptri( char* uplo, char* diag, lapack_int* n, - lapack_complex_double* ap, lapack_int *info ); -void LAPACK_sgeequ( lapack_int* m, lapack_int* n, const float* a, - lapack_int* lda, float* r, float* c, float* rowcnd, - float* colcnd, float* amax, lapack_int *info ); -void LAPACK_dgeequ( lapack_int* m, lapack_int* n, const double* a, - lapack_int* lda, double* r, double* c, double* rowcnd, - double* colcnd, double* amax, lapack_int *info ); -void LAPACK_cgeequ( lapack_int* m, lapack_int* n, const lapack_complex_float* a, - lapack_int* lda, float* r, float* c, float* rowcnd, - float* colcnd, float* amax, lapack_int *info ); -void LAPACK_zgeequ( lapack_int* m, lapack_int* n, - const lapack_complex_double* a, lapack_int* lda, double* r, - double* c, double* rowcnd, double* colcnd, double* amax, - lapack_int *info ); -void LAPACK_dgeequb( lapack_int* m, lapack_int* n, const double* a, - lapack_int* lda, double* r, double* c, double* rowcnd, - double* colcnd, double* amax, lapack_int *info ); -void LAPACK_sgeequb( lapack_int* m, lapack_int* n, const float* a, - lapack_int* lda, float* r, float* c, float* rowcnd, - float* colcnd, float* amax, lapack_int *info ); -void LAPACK_zgeequb( lapack_int* m, lapack_int* n, - const lapack_complex_double* a, lapack_int* lda, double* r, - double* c, double* rowcnd, double* colcnd, double* amax, - lapack_int *info ); -void LAPACK_cgeequb( lapack_int* m, lapack_int* n, - const lapack_complex_float* a, lapack_int* lda, float* r, - float* c, float* rowcnd, float* colcnd, float* amax, - lapack_int *info ); -void LAPACK_sgbequ( lapack_int* m, lapack_int* n, lapack_int* kl, - lapack_int* ku, const float* ab, lapack_int* ldab, float* r, - float* c, float* rowcnd, float* colcnd, float* amax, - lapack_int *info ); -void LAPACK_dgbequ( lapack_int* m, lapack_int* n, lapack_int* kl, - lapack_int* ku, const double* ab, lapack_int* ldab, - double* r, double* c, double* rowcnd, double* colcnd, - double* amax, lapack_int *info ); -void LAPACK_cgbequ( lapack_int* m, lapack_int* n, lapack_int* kl, - lapack_int* ku, const lapack_complex_float* ab, - lapack_int* ldab, float* r, float* c, float* rowcnd, - float* colcnd, float* amax, lapack_int *info ); -void LAPACK_zgbequ( lapack_int* m, lapack_int* n, lapack_int* kl, - lapack_int* ku, const lapack_complex_double* ab, - lapack_int* ldab, double* r, double* c, double* rowcnd, - double* colcnd, double* amax, lapack_int *info ); -void LAPACK_dgbequb( lapack_int* m, lapack_int* n, lapack_int* kl, - lapack_int* ku, const double* ab, lapack_int* ldab, - double* r, double* c, double* rowcnd, double* colcnd, - double* amax, lapack_int *info ); -void LAPACK_sgbequb( lapack_int* m, lapack_int* n, lapack_int* kl, - lapack_int* ku, const float* ab, lapack_int* ldab, - float* r, float* c, float* rowcnd, float* colcnd, - float* amax, lapack_int *info ); -void LAPACK_zgbequb( lapack_int* m, lapack_int* n, lapack_int* kl, - lapack_int* ku, const lapack_complex_double* ab, - lapack_int* ldab, double* r, double* c, double* rowcnd, - double* colcnd, double* amax, lapack_int *info ); -void LAPACK_cgbequb( lapack_int* m, lapack_int* n, lapack_int* kl, - lapack_int* ku, const lapack_complex_float* ab, - lapack_int* ldab, float* r, float* c, float* rowcnd, - float* colcnd, float* amax, lapack_int *info ); -void LAPACK_spoequ( lapack_int* n, const float* a, lapack_int* lda, float* s, - float* scond, float* amax, lapack_int *info ); -void LAPACK_dpoequ( lapack_int* n, const double* a, lapack_int* lda, double* s, - double* scond, double* amax, lapack_int *info ); -void LAPACK_cpoequ( lapack_int* n, const lapack_complex_float* a, - lapack_int* lda, float* s, float* scond, float* amax, - lapack_int *info ); -void LAPACK_zpoequ( lapack_int* n, const lapack_complex_double* a, - lapack_int* lda, double* s, double* scond, double* amax, - lapack_int *info ); -void LAPACK_dpoequb( lapack_int* n, const double* a, lapack_int* lda, double* s, - double* scond, double* amax, lapack_int *info ); -void LAPACK_spoequb( lapack_int* n, const float* a, lapack_int* lda, float* s, - float* scond, float* amax, lapack_int *info ); -void LAPACK_zpoequb( lapack_int* n, const lapack_complex_double* a, - lapack_int* lda, double* s, double* scond, double* amax, - lapack_int *info ); -void LAPACK_cpoequb( lapack_int* n, const lapack_complex_float* a, - lapack_int* lda, float* s, float* scond, float* amax, - lapack_int *info ); -void LAPACK_sppequ( char* uplo, lapack_int* n, const float* ap, float* s, - float* scond, float* amax, lapack_int *info ); -void LAPACK_dppequ( char* uplo, lapack_int* n, const double* ap, double* s, - double* scond, double* amax, lapack_int *info ); -void LAPACK_cppequ( char* uplo, lapack_int* n, const lapack_complex_float* ap, - float* s, float* scond, float* amax, lapack_int *info ); -void LAPACK_zppequ( char* uplo, lapack_int* n, const lapack_complex_double* ap, - double* s, double* scond, double* amax, lapack_int *info ); -void LAPACK_spbequ( char* uplo, lapack_int* n, lapack_int* kd, const float* ab, - lapack_int* ldab, float* s, float* scond, float* amax, - lapack_int *info ); -void LAPACK_dpbequ( char* uplo, lapack_int* n, lapack_int* kd, const double* ab, - lapack_int* ldab, double* s, double* scond, double* amax, - lapack_int *info ); -void LAPACK_cpbequ( char* uplo, lapack_int* n, lapack_int* kd, - const lapack_complex_float* ab, lapack_int* ldab, float* s, - float* scond, float* amax, lapack_int *info ); -void LAPACK_zpbequ( char* uplo, lapack_int* n, lapack_int* kd, - const lapack_complex_double* ab, lapack_int* ldab, - double* s, double* scond, double* amax, lapack_int *info ); -void LAPACK_dsyequb( char* uplo, lapack_int* n, const double* a, - lapack_int* lda, double* s, double* scond, double* amax, - double* work, lapack_int *info ); -void LAPACK_ssyequb( char* uplo, lapack_int* n, const float* a, lapack_int* lda, - float* s, float* scond, float* amax, float* work, - lapack_int *info ); -void LAPACK_zsyequb( char* uplo, lapack_int* n, const lapack_complex_double* a, - lapack_int* lda, double* s, double* scond, double* amax, - lapack_complex_double* work, lapack_int *info ); -void LAPACK_csyequb( char* uplo, lapack_int* n, const lapack_complex_float* a, - lapack_int* lda, float* s, float* scond, float* amax, - lapack_complex_float* work, lapack_int *info ); -void LAPACK_zheequb( char* uplo, lapack_int* n, const lapack_complex_double* a, - lapack_int* lda, double* s, double* scond, double* amax, - lapack_complex_double* work, lapack_int *info ); -void LAPACK_cheequb( char* uplo, lapack_int* n, const lapack_complex_float* a, - lapack_int* lda, float* s, float* scond, float* amax, - lapack_complex_float* work, lapack_int *info ); -void LAPACK_sgesv( lapack_int* n, lapack_int* nrhs, float* a, lapack_int* lda, - lapack_int* ipiv, float* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_dgesv( lapack_int* n, lapack_int* nrhs, double* a, lapack_int* lda, - lapack_int* ipiv, double* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_cgesv( lapack_int* n, lapack_int* nrhs, lapack_complex_float* a, - lapack_int* lda, lapack_int* ipiv, lapack_complex_float* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_zgesv( lapack_int* n, lapack_int* nrhs, lapack_complex_double* a, - lapack_int* lda, lapack_int* ipiv, lapack_complex_double* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_dsgesv( lapack_int* n, lapack_int* nrhs, double* a, lapack_int* lda, - lapack_int* ipiv, double* b, lapack_int* ldb, double* x, - lapack_int* ldx, double* work, float* swork, - lapack_int* iter, lapack_int *info ); -void LAPACK_zcgesv( lapack_int* n, lapack_int* nrhs, lapack_complex_double* a, - lapack_int* lda, lapack_int* ipiv, lapack_complex_double* b, - lapack_int* ldb, lapack_complex_double* x, lapack_int* ldx, - lapack_complex_double* work, lapack_complex_float* swork, - double* rwork, lapack_int* iter, lapack_int *info ); -void LAPACK_sgesvx( char* fact, char* trans, lapack_int* n, lapack_int* nrhs, - float* a, lapack_int* lda, float* af, lapack_int* ldaf, - lapack_int* ipiv, char* equed, float* r, float* c, float* b, - lapack_int* ldb, float* x, lapack_int* ldx, float* rcond, - float* ferr, float* berr, float* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_dgesvx( char* fact, char* trans, lapack_int* n, lapack_int* nrhs, - double* a, lapack_int* lda, double* af, lapack_int* ldaf, - lapack_int* ipiv, char* equed, double* r, double* c, - double* b, lapack_int* ldb, double* x, lapack_int* ldx, - double* rcond, double* ferr, double* berr, double* work, - lapack_int* iwork, lapack_int *info ); -void LAPACK_cgesvx( char* fact, char* trans, lapack_int* n, lapack_int* nrhs, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* af, lapack_int* ldaf, - lapack_int* ipiv, char* equed, float* r, float* c, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* x, lapack_int* ldx, float* rcond, - float* ferr, float* berr, lapack_complex_float* work, - float* rwork, lapack_int *info ); -void LAPACK_zgesvx( char* fact, char* trans, lapack_int* n, lapack_int* nrhs, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* af, lapack_int* ldaf, - lapack_int* ipiv, char* equed, double* r, double* c, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* x, lapack_int* ldx, double* rcond, - double* ferr, double* berr, lapack_complex_double* work, - double* rwork, lapack_int *info ); -void LAPACK_dgesvxx( char* fact, char* trans, lapack_int* n, lapack_int* nrhs, - double* a, lapack_int* lda, double* af, lapack_int* ldaf, - lapack_int* ipiv, char* equed, double* r, double* c, - double* b, lapack_int* ldb, double* x, lapack_int* ldx, - double* rcond, double* rpvgrw, double* berr, - lapack_int* n_err_bnds, double* err_bnds_norm, - double* err_bnds_comp, lapack_int* nparams, double* params, - double* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_sgesvxx( char* fact, char* trans, lapack_int* n, lapack_int* nrhs, - float* a, lapack_int* lda, float* af, lapack_int* ldaf, - lapack_int* ipiv, char* equed, float* r, float* c, - float* b, lapack_int* ldb, float* x, lapack_int* ldx, - float* rcond, float* rpvgrw, float* berr, - lapack_int* n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int* nparams, float* params, - float* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_zgesvxx( char* fact, char* trans, lapack_int* n, lapack_int* nrhs, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* af, lapack_int* ldaf, - lapack_int* ipiv, char* equed, double* r, double* c, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* x, lapack_int* ldx, double* rcond, - double* rpvgrw, double* berr, lapack_int* n_err_bnds, - double* err_bnds_norm, double* err_bnds_comp, - lapack_int* nparams, double* params, - lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_cgesvxx( char* fact, char* trans, lapack_int* n, lapack_int* nrhs, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* af, lapack_int* ldaf, - lapack_int* ipiv, char* equed, float* r, float* c, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* x, lapack_int* ldx, float* rcond, - float* rpvgrw, float* berr, lapack_int* n_err_bnds, - float* err_bnds_norm, float* err_bnds_comp, - lapack_int* nparams, float* params, - lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_sgbsv( lapack_int* n, lapack_int* kl, lapack_int* ku, - lapack_int* nrhs, float* ab, lapack_int* ldab, - lapack_int* ipiv, float* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_dgbsv( lapack_int* n, lapack_int* kl, lapack_int* ku, - lapack_int* nrhs, double* ab, lapack_int* ldab, - lapack_int* ipiv, double* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_cgbsv( lapack_int* n, lapack_int* kl, lapack_int* ku, - lapack_int* nrhs, lapack_complex_float* ab, lapack_int* ldab, - lapack_int* ipiv, lapack_complex_float* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_zgbsv( lapack_int* n, lapack_int* kl, lapack_int* ku, - lapack_int* nrhs, lapack_complex_double* ab, - lapack_int* ldab, lapack_int* ipiv, lapack_complex_double* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_sgbsvx( char* fact, char* trans, lapack_int* n, lapack_int* kl, - lapack_int* ku, lapack_int* nrhs, float* ab, - lapack_int* ldab, float* afb, lapack_int* ldafb, - lapack_int* ipiv, char* equed, float* r, float* c, float* b, - lapack_int* ldb, float* x, lapack_int* ldx, float* rcond, - float* ferr, float* berr, float* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_dgbsvx( char* fact, char* trans, lapack_int* n, lapack_int* kl, - lapack_int* ku, lapack_int* nrhs, double* ab, - lapack_int* ldab, double* afb, lapack_int* ldafb, - lapack_int* ipiv, char* equed, double* r, double* c, - double* b, lapack_int* ldb, double* x, lapack_int* ldx, - double* rcond, double* ferr, double* berr, double* work, - lapack_int* iwork, lapack_int *info ); -void LAPACK_cgbsvx( char* fact, char* trans, lapack_int* n, lapack_int* kl, - lapack_int* ku, lapack_int* nrhs, lapack_complex_float* ab, - lapack_int* ldab, lapack_complex_float* afb, - lapack_int* ldafb, lapack_int* ipiv, char* equed, float* r, - float* c, lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* x, lapack_int* ldx, float* rcond, - float* ferr, float* berr, lapack_complex_float* work, - float* rwork, lapack_int *info ); -void LAPACK_zgbsvx( char* fact, char* trans, lapack_int* n, lapack_int* kl, - lapack_int* ku, lapack_int* nrhs, lapack_complex_double* ab, - lapack_int* ldab, lapack_complex_double* afb, - lapack_int* ldafb, lapack_int* ipiv, char* equed, double* r, - double* c, lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* x, lapack_int* ldx, double* rcond, - double* ferr, double* berr, lapack_complex_double* work, - double* rwork, lapack_int *info ); -void LAPACK_dgbsvxx( char* fact, char* trans, lapack_int* n, lapack_int* kl, - lapack_int* ku, lapack_int* nrhs, double* ab, - lapack_int* ldab, double* afb, lapack_int* ldafb, - lapack_int* ipiv, char* equed, double* r, double* c, - double* b, lapack_int* ldb, double* x, lapack_int* ldx, - double* rcond, double* rpvgrw, double* berr, - lapack_int* n_err_bnds, double* err_bnds_norm, - double* err_bnds_comp, lapack_int* nparams, double* params, - double* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_sgbsvxx( char* fact, char* trans, lapack_int* n, lapack_int* kl, - lapack_int* ku, lapack_int* nrhs, float* ab, - lapack_int* ldab, float* afb, lapack_int* ldafb, - lapack_int* ipiv, char* equed, float* r, float* c, - float* b, lapack_int* ldb, float* x, lapack_int* ldx, - float* rcond, float* rpvgrw, float* berr, - lapack_int* n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int* nparams, float* params, - float* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_zgbsvxx( char* fact, char* trans, lapack_int* n, lapack_int* kl, - lapack_int* ku, lapack_int* nrhs, - lapack_complex_double* ab, lapack_int* ldab, - lapack_complex_double* afb, lapack_int* ldafb, - lapack_int* ipiv, char* equed, double* r, double* c, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* x, lapack_int* ldx, double* rcond, - double* rpvgrw, double* berr, lapack_int* n_err_bnds, - double* err_bnds_norm, double* err_bnds_comp, - lapack_int* nparams, double* params, - lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_cgbsvxx( char* fact, char* trans, lapack_int* n, lapack_int* kl, - lapack_int* ku, lapack_int* nrhs, lapack_complex_float* ab, - lapack_int* ldab, lapack_complex_float* afb, - lapack_int* ldafb, lapack_int* ipiv, char* equed, float* r, - float* c, lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* x, lapack_int* ldx, float* rcond, - float* rpvgrw, float* berr, lapack_int* n_err_bnds, - float* err_bnds_norm, float* err_bnds_comp, - lapack_int* nparams, float* params, - lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_sgtsv( lapack_int* n, lapack_int* nrhs, float* dl, float* d, - float* du, float* b, lapack_int* ldb, lapack_int *info ); -void LAPACK_dgtsv( lapack_int* n, lapack_int* nrhs, double* dl, double* d, - double* du, double* b, lapack_int* ldb, lapack_int *info ); -void LAPACK_cgtsv( lapack_int* n, lapack_int* nrhs, lapack_complex_float* dl, - lapack_complex_float* d, lapack_complex_float* du, - lapack_complex_float* b, lapack_int* ldb, lapack_int *info ); -void LAPACK_zgtsv( lapack_int* n, lapack_int* nrhs, lapack_complex_double* dl, - lapack_complex_double* d, lapack_complex_double* du, - lapack_complex_double* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_sgtsvx( char* fact, char* trans, lapack_int* n, lapack_int* nrhs, - const float* dl, const float* d, const float* du, - float* dlf, float* df, float* duf, float* du2, - lapack_int* ipiv, const float* b, lapack_int* ldb, float* x, - lapack_int* ldx, float* rcond, float* ferr, float* berr, - float* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_dgtsvx( char* fact, char* trans, lapack_int* n, lapack_int* nrhs, - const double* dl, const double* d, const double* du, - double* dlf, double* df, double* duf, double* du2, - lapack_int* ipiv, const double* b, lapack_int* ldb, - double* x, lapack_int* ldx, double* rcond, double* ferr, - double* berr, double* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_cgtsvx( char* fact, char* trans, lapack_int* n, lapack_int* nrhs, - const lapack_complex_float* dl, - const lapack_complex_float* d, - const lapack_complex_float* du, lapack_complex_float* dlf, - lapack_complex_float* df, lapack_complex_float* duf, - lapack_complex_float* du2, lapack_int* ipiv, - const lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* x, lapack_int* ldx, float* rcond, - float* ferr, float* berr, lapack_complex_float* work, - float* rwork, lapack_int *info ); -void LAPACK_zgtsvx( char* fact, char* trans, lapack_int* n, lapack_int* nrhs, - const lapack_complex_double* dl, - const lapack_complex_double* d, - const lapack_complex_double* du, lapack_complex_double* dlf, - lapack_complex_double* df, lapack_complex_double* duf, - lapack_complex_double* du2, lapack_int* ipiv, - const lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* x, lapack_int* ldx, double* rcond, - double* ferr, double* berr, lapack_complex_double* work, - double* rwork, lapack_int *info ); -void LAPACK_sposv( char* uplo, lapack_int* n, lapack_int* nrhs, float* a, - lapack_int* lda, float* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_dposv( char* uplo, lapack_int* n, lapack_int* nrhs, double* a, - lapack_int* lda, double* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_cposv( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, lapack_int *info ); -void LAPACK_zposv( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_dsposv( char* uplo, lapack_int* n, lapack_int* nrhs, double* a, - lapack_int* lda, double* b, lapack_int* ldb, double* x, - lapack_int* ldx, double* work, float* swork, - lapack_int* iter, lapack_int *info ); -void LAPACK_zcposv( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* x, lapack_int* ldx, - lapack_complex_double* work, lapack_complex_float* swork, - double* rwork, lapack_int* iter, lapack_int *info ); -void LAPACK_sposvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - float* a, lapack_int* lda, float* af, lapack_int* ldaf, - char* equed, float* s, float* b, lapack_int* ldb, float* x, - lapack_int* ldx, float* rcond, float* ferr, float* berr, - float* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_dposvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - double* a, lapack_int* lda, double* af, lapack_int* ldaf, - char* equed, double* s, double* b, lapack_int* ldb, - double* x, lapack_int* ldx, double* rcond, double* ferr, - double* berr, double* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_cposvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* af, lapack_int* ldaf, char* equed, - float* s, lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* x, lapack_int* ldx, float* rcond, - float* ferr, float* berr, lapack_complex_float* work, - float* rwork, lapack_int *info ); -void LAPACK_zposvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* af, lapack_int* ldaf, char* equed, - double* s, lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* x, lapack_int* ldx, double* rcond, - double* ferr, double* berr, lapack_complex_double* work, - double* rwork, lapack_int *info ); -void LAPACK_dposvxx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - double* a, lapack_int* lda, double* af, lapack_int* ldaf, - char* equed, double* s, double* b, lapack_int* ldb, - double* x, lapack_int* ldx, double* rcond, double* rpvgrw, - double* berr, lapack_int* n_err_bnds, - double* err_bnds_norm, double* err_bnds_comp, - lapack_int* nparams, double* params, double* work, - lapack_int* iwork, lapack_int *info ); -void LAPACK_sposvxx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - float* a, lapack_int* lda, float* af, lapack_int* ldaf, - char* equed, float* s, float* b, lapack_int* ldb, float* x, - lapack_int* ldx, float* rcond, float* rpvgrw, float* berr, - lapack_int* n_err_bnds, float* err_bnds_norm, - float* err_bnds_comp, lapack_int* nparams, float* params, - float* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_zposvxx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* af, lapack_int* ldaf, char* equed, - double* s, lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* x, lapack_int* ldx, double* rcond, - double* rpvgrw, double* berr, lapack_int* n_err_bnds, - double* err_bnds_norm, double* err_bnds_comp, - lapack_int* nparams, double* params, - lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_cposvxx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* af, lapack_int* ldaf, char* equed, - float* s, lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* x, lapack_int* ldx, float* rcond, - float* rpvgrw, float* berr, lapack_int* n_err_bnds, - float* err_bnds_norm, float* err_bnds_comp, - lapack_int* nparams, float* params, - lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_sppsv( char* uplo, lapack_int* n, lapack_int* nrhs, float* ap, - float* b, lapack_int* ldb, lapack_int *info ); -void LAPACK_dppsv( char* uplo, lapack_int* n, lapack_int* nrhs, double* ap, - double* b, lapack_int* ldb, lapack_int *info ); -void LAPACK_cppsv( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_float* ap, lapack_complex_float* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_zppsv( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_double* ap, lapack_complex_double* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_sppsvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - float* ap, float* afp, char* equed, float* s, float* b, - lapack_int* ldb, float* x, lapack_int* ldx, float* rcond, - float* ferr, float* berr, float* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_dppsvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - double* ap, double* afp, char* equed, double* s, double* b, - lapack_int* ldb, double* x, lapack_int* ldx, double* rcond, - double* ferr, double* berr, double* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_cppsvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_float* ap, lapack_complex_float* afp, - char* equed, float* s, lapack_complex_float* b, - lapack_int* ldb, lapack_complex_float* x, lapack_int* ldx, - float* rcond, float* ferr, float* berr, - lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_zppsvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_double* ap, lapack_complex_double* afp, - char* equed, double* s, lapack_complex_double* b, - lapack_int* ldb, lapack_complex_double* x, lapack_int* ldx, - double* rcond, double* ferr, double* berr, - lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_spbsv( char* uplo, lapack_int* n, lapack_int* kd, lapack_int* nrhs, - float* ab, lapack_int* ldab, float* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_dpbsv( char* uplo, lapack_int* n, lapack_int* kd, lapack_int* nrhs, - double* ab, lapack_int* ldab, double* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_cpbsv( char* uplo, lapack_int* n, lapack_int* kd, lapack_int* nrhs, - lapack_complex_float* ab, lapack_int* ldab, - lapack_complex_float* b, lapack_int* ldb, lapack_int *info ); -void LAPACK_zpbsv( char* uplo, lapack_int* n, lapack_int* kd, lapack_int* nrhs, - lapack_complex_double* ab, lapack_int* ldab, - lapack_complex_double* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_spbsvx( char* fact, char* uplo, lapack_int* n, lapack_int* kd, - lapack_int* nrhs, float* ab, lapack_int* ldab, float* afb, - lapack_int* ldafb, char* equed, float* s, float* b, - lapack_int* ldb, float* x, lapack_int* ldx, float* rcond, - float* ferr, float* berr, float* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_dpbsvx( char* fact, char* uplo, lapack_int* n, lapack_int* kd, - lapack_int* nrhs, double* ab, lapack_int* ldab, double* afb, - lapack_int* ldafb, char* equed, double* s, double* b, - lapack_int* ldb, double* x, lapack_int* ldx, double* rcond, - double* ferr, double* berr, double* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_cpbsvx( char* fact, char* uplo, lapack_int* n, lapack_int* kd, - lapack_int* nrhs, lapack_complex_float* ab, - lapack_int* ldab, lapack_complex_float* afb, - lapack_int* ldafb, char* equed, float* s, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* x, lapack_int* ldx, float* rcond, - float* ferr, float* berr, lapack_complex_float* work, - float* rwork, lapack_int *info ); -void LAPACK_zpbsvx( char* fact, char* uplo, lapack_int* n, lapack_int* kd, - lapack_int* nrhs, lapack_complex_double* ab, - lapack_int* ldab, lapack_complex_double* afb, - lapack_int* ldafb, char* equed, double* s, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* x, lapack_int* ldx, double* rcond, - double* ferr, double* berr, lapack_complex_double* work, - double* rwork, lapack_int *info ); -void LAPACK_sptsv( lapack_int* n, lapack_int* nrhs, float* d, float* e, - float* b, lapack_int* ldb, lapack_int *info ); -void LAPACK_dptsv( lapack_int* n, lapack_int* nrhs, double* d, double* e, - double* b, lapack_int* ldb, lapack_int *info ); -void LAPACK_cptsv( lapack_int* n, lapack_int* nrhs, float* d, - lapack_complex_float* e, lapack_complex_float* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_zptsv( lapack_int* n, lapack_int* nrhs, double* d, - lapack_complex_double* e, lapack_complex_double* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_sptsvx( char* fact, lapack_int* n, lapack_int* nrhs, const float* d, - const float* e, float* df, float* ef, const float* b, - lapack_int* ldb, float* x, lapack_int* ldx, float* rcond, - float* ferr, float* berr, float* work, lapack_int *info ); -void LAPACK_dptsvx( char* fact, lapack_int* n, lapack_int* nrhs, - const double* d, const double* e, double* df, double* ef, - const double* b, lapack_int* ldb, double* x, - lapack_int* ldx, double* rcond, double* ferr, double* berr, - double* work, lapack_int *info ); -void LAPACK_cptsvx( char* fact, lapack_int* n, lapack_int* nrhs, const float* d, - const lapack_complex_float* e, float* df, - lapack_complex_float* ef, const lapack_complex_float* b, - lapack_int* ldb, lapack_complex_float* x, lapack_int* ldx, - float* rcond, float* ferr, float* berr, - lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_zptsvx( char* fact, lapack_int* n, lapack_int* nrhs, - const double* d, const lapack_complex_double* e, double* df, - lapack_complex_double* ef, const lapack_complex_double* b, - lapack_int* ldb, lapack_complex_double* x, lapack_int* ldx, - double* rcond, double* ferr, double* berr, - lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_ssysv( char* uplo, lapack_int* n, lapack_int* nrhs, float* a, - lapack_int* lda, lapack_int* ipiv, float* b, lapack_int* ldb, - float* work, lapack_int* lwork, lapack_int *info ); -void LAPACK_dsysv( char* uplo, lapack_int* n, lapack_int* nrhs, double* a, - lapack_int* lda, lapack_int* ipiv, double* b, - lapack_int* ldb, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_csysv( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_float* a, lapack_int* lda, lapack_int* ipiv, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zsysv( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_double* a, lapack_int* lda, lapack_int* ipiv, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_ssysvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - const float* a, lapack_int* lda, float* af, - lapack_int* ldaf, lapack_int* ipiv, const float* b, - lapack_int* ldb, float* x, lapack_int* ldx, float* rcond, - float* ferr, float* berr, float* work, lapack_int* lwork, - lapack_int* iwork, lapack_int *info ); -void LAPACK_dsysvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - const double* a, lapack_int* lda, double* af, - lapack_int* ldaf, lapack_int* ipiv, const double* b, - lapack_int* ldb, double* x, lapack_int* ldx, double* rcond, - double* ferr, double* berr, double* work, lapack_int* lwork, - lapack_int* iwork, lapack_int *info ); -void LAPACK_csysvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* af, lapack_int* ldaf, - lapack_int* ipiv, const lapack_complex_float* b, - lapack_int* ldb, lapack_complex_float* x, lapack_int* ldx, - float* rcond, float* ferr, float* berr, - lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_int *info ); -void LAPACK_zsysvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* af, lapack_int* ldaf, - lapack_int* ipiv, const lapack_complex_double* b, - lapack_int* ldb, lapack_complex_double* x, lapack_int* ldx, - double* rcond, double* ferr, double* berr, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_int *info ); -void LAPACK_dsysvxx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - double* a, lapack_int* lda, double* af, lapack_int* ldaf, - lapack_int* ipiv, char* equed, double* s, double* b, - lapack_int* ldb, double* x, lapack_int* ldx, double* rcond, - double* rpvgrw, double* berr, lapack_int* n_err_bnds, - double* err_bnds_norm, double* err_bnds_comp, - lapack_int* nparams, double* params, double* work, - lapack_int* iwork, lapack_int *info ); -void LAPACK_ssysvxx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - float* a, lapack_int* lda, float* af, lapack_int* ldaf, - lapack_int* ipiv, char* equed, float* s, float* b, - lapack_int* ldb, float* x, lapack_int* ldx, float* rcond, - float* rpvgrw, float* berr, lapack_int* n_err_bnds, - float* err_bnds_norm, float* err_bnds_comp, - lapack_int* nparams, float* params, float* work, - lapack_int* iwork, lapack_int *info ); -void LAPACK_zsysvxx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* af, lapack_int* ldaf, - lapack_int* ipiv, char* equed, double* s, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* x, lapack_int* ldx, double* rcond, - double* rpvgrw, double* berr, lapack_int* n_err_bnds, - double* err_bnds_norm, double* err_bnds_comp, - lapack_int* nparams, double* params, - lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_csysvxx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* af, lapack_int* ldaf, - lapack_int* ipiv, char* equed, float* s, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* x, lapack_int* ldx, float* rcond, - float* rpvgrw, float* berr, lapack_int* n_err_bnds, - float* err_bnds_norm, float* err_bnds_comp, - lapack_int* nparams, float* params, - lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_chesv( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_float* a, lapack_int* lda, lapack_int* ipiv, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zhesv( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_double* a, lapack_int* lda, lapack_int* ipiv, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_chesvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* af, lapack_int* ldaf, - lapack_int* ipiv, const lapack_complex_float* b, - lapack_int* ldb, lapack_complex_float* x, lapack_int* ldx, - float* rcond, float* ferr, float* berr, - lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_int *info ); -void LAPACK_zhesvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* af, lapack_int* ldaf, - lapack_int* ipiv, const lapack_complex_double* b, - lapack_int* ldb, lapack_complex_double* x, lapack_int* ldx, - double* rcond, double* ferr, double* berr, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_int *info ); -void LAPACK_zhesvxx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* af, lapack_int* ldaf, - lapack_int* ipiv, char* equed, double* s, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* x, lapack_int* ldx, double* rcond, - double* rpvgrw, double* berr, lapack_int* n_err_bnds, - double* err_bnds_norm, double* err_bnds_comp, - lapack_int* nparams, double* params, - lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_chesvxx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* af, lapack_int* ldaf, - lapack_int* ipiv, char* equed, float* s, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* x, lapack_int* ldx, float* rcond, - float* rpvgrw, float* berr, lapack_int* n_err_bnds, - float* err_bnds_norm, float* err_bnds_comp, - lapack_int* nparams, float* params, - lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_sspsv( char* uplo, lapack_int* n, lapack_int* nrhs, float* ap, - lapack_int* ipiv, float* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_dspsv( char* uplo, lapack_int* n, lapack_int* nrhs, double* ap, - lapack_int* ipiv, double* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_cspsv( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_float* ap, lapack_int* ipiv, - lapack_complex_float* b, lapack_int* ldb, lapack_int *info ); -void LAPACK_zspsv( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_double* ap, lapack_int* ipiv, - lapack_complex_double* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_sspsvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - const float* ap, float* afp, lapack_int* ipiv, - const float* b, lapack_int* ldb, float* x, lapack_int* ldx, - float* rcond, float* ferr, float* berr, float* work, - lapack_int* iwork, lapack_int *info ); -void LAPACK_dspsvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - const double* ap, double* afp, lapack_int* ipiv, - const double* b, lapack_int* ldb, double* x, - lapack_int* ldx, double* rcond, double* ferr, double* berr, - double* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_cspsvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_float* ap, lapack_complex_float* afp, - lapack_int* ipiv, const lapack_complex_float* b, - lapack_int* ldb, lapack_complex_float* x, lapack_int* ldx, - float* rcond, float* ferr, float* berr, - lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_zspsvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_double* ap, lapack_complex_double* afp, - lapack_int* ipiv, const lapack_complex_double* b, - lapack_int* ldb, lapack_complex_double* x, lapack_int* ldx, - double* rcond, double* ferr, double* berr, - lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_chpsv( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_float* ap, lapack_int* ipiv, - lapack_complex_float* b, lapack_int* ldb, lapack_int *info ); -void LAPACK_zhpsv( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_double* ap, lapack_int* ipiv, - lapack_complex_double* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_chpsvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_float* ap, lapack_complex_float* afp, - lapack_int* ipiv, const lapack_complex_float* b, - lapack_int* ldb, lapack_complex_float* x, lapack_int* ldx, - float* rcond, float* ferr, float* berr, - lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_zhpsvx( char* fact, char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_double* ap, lapack_complex_double* afp, - lapack_int* ipiv, const lapack_complex_double* b, - lapack_int* ldb, lapack_complex_double* x, lapack_int* ldx, - double* rcond, double* ferr, double* berr, - lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_sgeqrf( lapack_int* m, lapack_int* n, float* a, lapack_int* lda, - float* tau, float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_dgeqrf( lapack_int* m, lapack_int* n, double* a, lapack_int* lda, - double* tau, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_cgeqrf( lapack_int* m, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_complex_float* tau, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zgeqrf( lapack_int* m, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_complex_double* tau, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_sgeqpf( lapack_int* m, lapack_int* n, float* a, lapack_int* lda, - lapack_int* jpvt, float* tau, float* work, - lapack_int *info ); -void LAPACK_dgeqpf( lapack_int* m, lapack_int* n, double* a, lapack_int* lda, - lapack_int* jpvt, double* tau, double* work, - lapack_int *info ); -void LAPACK_cgeqpf( lapack_int* m, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_int* jpvt, - lapack_complex_float* tau, lapack_complex_float* work, - float* rwork, lapack_int *info ); -void LAPACK_zgeqpf( lapack_int* m, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_int* jpvt, - lapack_complex_double* tau, lapack_complex_double* work, - double* rwork, lapack_int *info ); -void LAPACK_sgeqp3( lapack_int* m, lapack_int* n, float* a, lapack_int* lda, - lapack_int* jpvt, float* tau, float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_dgeqp3( lapack_int* m, lapack_int* n, double* a, lapack_int* lda, - lapack_int* jpvt, double* tau, double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_cgeqp3( lapack_int* m, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_int* jpvt, - lapack_complex_float* tau, lapack_complex_float* work, - lapack_int* lwork, float* rwork, lapack_int *info ); -void LAPACK_zgeqp3( lapack_int* m, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_int* jpvt, - lapack_complex_double* tau, lapack_complex_double* work, - lapack_int* lwork, double* rwork, lapack_int *info ); -void LAPACK_sorgqr( lapack_int* m, lapack_int* n, lapack_int* k, float* a, - lapack_int* lda, const float* tau, float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_dorgqr( lapack_int* m, lapack_int* n, lapack_int* k, double* a, - lapack_int* lda, const double* tau, double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_sormqr( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* k, const float* a, lapack_int* lda, - const float* tau, float* c, lapack_int* ldc, float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_dormqr( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* k, const double* a, lapack_int* lda, - const double* tau, double* c, lapack_int* ldc, double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_cungqr( lapack_int* m, lapack_int* n, lapack_int* k, - lapack_complex_float* a, lapack_int* lda, - const lapack_complex_float* tau, lapack_complex_float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_zungqr( lapack_int* m, lapack_int* n, lapack_int* k, - lapack_complex_double* a, lapack_int* lda, - const lapack_complex_double* tau, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_cunmqr( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* k, const lapack_complex_float* a, - lapack_int* lda, const lapack_complex_float* tau, - lapack_complex_float* c, lapack_int* ldc, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zunmqr( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* k, const lapack_complex_double* a, - lapack_int* lda, const lapack_complex_double* tau, - lapack_complex_double* c, lapack_int* ldc, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_sgelqf( lapack_int* m, lapack_int* n, float* a, lapack_int* lda, - float* tau, float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_dgelqf( lapack_int* m, lapack_int* n, double* a, lapack_int* lda, - double* tau, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_cgelqf( lapack_int* m, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_complex_float* tau, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zgelqf( lapack_int* m, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_complex_double* tau, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_sorglq( lapack_int* m, lapack_int* n, lapack_int* k, float* a, - lapack_int* lda, const float* tau, float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_dorglq( lapack_int* m, lapack_int* n, lapack_int* k, double* a, - lapack_int* lda, const double* tau, double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_sormlq( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* k, const float* a, lapack_int* lda, - const float* tau, float* c, lapack_int* ldc, float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_dormlq( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* k, const double* a, lapack_int* lda, - const double* tau, double* c, lapack_int* ldc, double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_cunglq( lapack_int* m, lapack_int* n, lapack_int* k, - lapack_complex_float* a, lapack_int* lda, - const lapack_complex_float* tau, lapack_complex_float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_zunglq( lapack_int* m, lapack_int* n, lapack_int* k, - lapack_complex_double* a, lapack_int* lda, - const lapack_complex_double* tau, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_cunmlq( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* k, const lapack_complex_float* a, - lapack_int* lda, const lapack_complex_float* tau, - lapack_complex_float* c, lapack_int* ldc, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zunmlq( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* k, const lapack_complex_double* a, - lapack_int* lda, const lapack_complex_double* tau, - lapack_complex_double* c, lapack_int* ldc, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_sgeqlf( lapack_int* m, lapack_int* n, float* a, lapack_int* lda, - float* tau, float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_dgeqlf( lapack_int* m, lapack_int* n, double* a, lapack_int* lda, - double* tau, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_cgeqlf( lapack_int* m, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_complex_float* tau, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zgeqlf( lapack_int* m, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_complex_double* tau, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_sorgql( lapack_int* m, lapack_int* n, lapack_int* k, float* a, - lapack_int* lda, const float* tau, float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_dorgql( lapack_int* m, lapack_int* n, lapack_int* k, double* a, - lapack_int* lda, const double* tau, double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_cungql( lapack_int* m, lapack_int* n, lapack_int* k, - lapack_complex_float* a, lapack_int* lda, - const lapack_complex_float* tau, lapack_complex_float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_zungql( lapack_int* m, lapack_int* n, lapack_int* k, - lapack_complex_double* a, lapack_int* lda, - const lapack_complex_double* tau, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_sormql( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* k, const float* a, lapack_int* lda, - const float* tau, float* c, lapack_int* ldc, float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_dormql( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* k, const double* a, lapack_int* lda, - const double* tau, double* c, lapack_int* ldc, double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_cunmql( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* k, const lapack_complex_float* a, - lapack_int* lda, const lapack_complex_float* tau, - lapack_complex_float* c, lapack_int* ldc, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zunmql( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* k, const lapack_complex_double* a, - lapack_int* lda, const lapack_complex_double* tau, - lapack_complex_double* c, lapack_int* ldc, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_sgerqf( lapack_int* m, lapack_int* n, float* a, lapack_int* lda, - float* tau, float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_dgerqf( lapack_int* m, lapack_int* n, double* a, lapack_int* lda, - double* tau, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_cgerqf( lapack_int* m, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_complex_float* tau, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zgerqf( lapack_int* m, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_complex_double* tau, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_sorgrq( lapack_int* m, lapack_int* n, lapack_int* k, float* a, - lapack_int* lda, const float* tau, float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_dorgrq( lapack_int* m, lapack_int* n, lapack_int* k, double* a, - lapack_int* lda, const double* tau, double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_cungrq( lapack_int* m, lapack_int* n, lapack_int* k, - lapack_complex_float* a, lapack_int* lda, - const lapack_complex_float* tau, lapack_complex_float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_zungrq( lapack_int* m, lapack_int* n, lapack_int* k, - lapack_complex_double* a, lapack_int* lda, - const lapack_complex_double* tau, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_sormrq( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* k, const float* a, lapack_int* lda, - const float* tau, float* c, lapack_int* ldc, float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_dormrq( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* k, const double* a, lapack_int* lda, - const double* tau, double* c, lapack_int* ldc, double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_cunmrq( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* k, const lapack_complex_float* a, - lapack_int* lda, const lapack_complex_float* tau, - lapack_complex_float* c, lapack_int* ldc, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zunmrq( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* k, const lapack_complex_double* a, - lapack_int* lda, const lapack_complex_double* tau, - lapack_complex_double* c, lapack_int* ldc, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_stzrzf( lapack_int* m, lapack_int* n, float* a, lapack_int* lda, - float* tau, float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_dtzrzf( lapack_int* m, lapack_int* n, double* a, lapack_int* lda, - double* tau, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_ctzrzf( lapack_int* m, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_complex_float* tau, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_ztzrzf( lapack_int* m, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_complex_double* tau, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_sormrz( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* k, lapack_int* l, const float* a, - lapack_int* lda, const float* tau, float* c, - lapack_int* ldc, float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_dormrz( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* k, lapack_int* l, const double* a, - lapack_int* lda, const double* tau, double* c, - lapack_int* ldc, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_cunmrz( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* k, lapack_int* l, const lapack_complex_float* a, - lapack_int* lda, const lapack_complex_float* tau, - lapack_complex_float* c, lapack_int* ldc, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zunmrz( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* k, lapack_int* l, - const lapack_complex_double* a, lapack_int* lda, - const lapack_complex_double* tau, lapack_complex_double* c, - lapack_int* ldc, lapack_complex_double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_sggqrf( lapack_int* n, lapack_int* m, lapack_int* p, float* a, - lapack_int* lda, float* taua, float* b, lapack_int* ldb, - float* taub, float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_dggqrf( lapack_int* n, lapack_int* m, lapack_int* p, double* a, - lapack_int* lda, double* taua, double* b, lapack_int* ldb, - double* taub, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_cggqrf( lapack_int* n, lapack_int* m, lapack_int* p, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* taua, lapack_complex_float* b, - lapack_int* ldb, lapack_complex_float* taub, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zggqrf( lapack_int* n, lapack_int* m, lapack_int* p, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* taua, lapack_complex_double* b, - lapack_int* ldb, lapack_complex_double* taub, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_sggrqf( lapack_int* m, lapack_int* p, lapack_int* n, float* a, - lapack_int* lda, float* taua, float* b, lapack_int* ldb, - float* taub, float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_dggrqf( lapack_int* m, lapack_int* p, lapack_int* n, double* a, - lapack_int* lda, double* taua, double* b, lapack_int* ldb, - double* taub, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_cggrqf( lapack_int* m, lapack_int* p, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* taua, lapack_complex_float* b, - lapack_int* ldb, lapack_complex_float* taub, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zggrqf( lapack_int* m, lapack_int* p, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* taua, lapack_complex_double* b, - lapack_int* ldb, lapack_complex_double* taub, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_sgebrd( lapack_int* m, lapack_int* n, float* a, lapack_int* lda, - float* d, float* e, float* tauq, float* taup, float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_dgebrd( lapack_int* m, lapack_int* n, double* a, lapack_int* lda, - double* d, double* e, double* tauq, double* taup, - double* work, lapack_int* lwork, lapack_int *info ); -void LAPACK_cgebrd( lapack_int* m, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, float* d, float* e, - lapack_complex_float* tauq, lapack_complex_float* taup, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zgebrd( lapack_int* m, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, double* d, double* e, - lapack_complex_double* tauq, lapack_complex_double* taup, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_sgbbrd( char* vect, lapack_int* m, lapack_int* n, lapack_int* ncc, - lapack_int* kl, lapack_int* ku, float* ab, lapack_int* ldab, - float* d, float* e, float* q, lapack_int* ldq, float* pt, - lapack_int* ldpt, float* c, lapack_int* ldc, float* work, - lapack_int *info ); -void LAPACK_dgbbrd( char* vect, lapack_int* m, lapack_int* n, lapack_int* ncc, - lapack_int* kl, lapack_int* ku, double* ab, - lapack_int* ldab, double* d, double* e, double* q, - lapack_int* ldq, double* pt, lapack_int* ldpt, double* c, - lapack_int* ldc, double* work, lapack_int *info ); -void LAPACK_cgbbrd( char* vect, lapack_int* m, lapack_int* n, lapack_int* ncc, - lapack_int* kl, lapack_int* ku, lapack_complex_float* ab, - lapack_int* ldab, float* d, float* e, - lapack_complex_float* q, lapack_int* ldq, - lapack_complex_float* pt, lapack_int* ldpt, - lapack_complex_float* c, lapack_int* ldc, - lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_zgbbrd( char* vect, lapack_int* m, lapack_int* n, lapack_int* ncc, - lapack_int* kl, lapack_int* ku, lapack_complex_double* ab, - lapack_int* ldab, double* d, double* e, - lapack_complex_double* q, lapack_int* ldq, - lapack_complex_double* pt, lapack_int* ldpt, - lapack_complex_double* c, lapack_int* ldc, - lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_sorgbr( char* vect, lapack_int* m, lapack_int* n, lapack_int* k, - float* a, lapack_int* lda, const float* tau, float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_dorgbr( char* vect, lapack_int* m, lapack_int* n, lapack_int* k, - double* a, lapack_int* lda, const double* tau, double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_sormbr( char* vect, char* side, char* trans, lapack_int* m, - lapack_int* n, lapack_int* k, const float* a, - lapack_int* lda, const float* tau, float* c, - lapack_int* ldc, float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_dormbr( char* vect, char* side, char* trans, lapack_int* m, - lapack_int* n, lapack_int* k, const double* a, - lapack_int* lda, const double* tau, double* c, - lapack_int* ldc, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_cungbr( char* vect, lapack_int* m, lapack_int* n, lapack_int* k, - lapack_complex_float* a, lapack_int* lda, - const lapack_complex_float* tau, lapack_complex_float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_zungbr( char* vect, lapack_int* m, lapack_int* n, lapack_int* k, - lapack_complex_double* a, lapack_int* lda, - const lapack_complex_double* tau, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_cunmbr( char* vect, char* side, char* trans, lapack_int* m, - lapack_int* n, lapack_int* k, const lapack_complex_float* a, - lapack_int* lda, const lapack_complex_float* tau, - lapack_complex_float* c, lapack_int* ldc, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zunmbr( char* vect, char* side, char* trans, lapack_int* m, - lapack_int* n, lapack_int* k, - const lapack_complex_double* a, lapack_int* lda, - const lapack_complex_double* tau, lapack_complex_double* c, - lapack_int* ldc, lapack_complex_double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_sbdsqr( char* uplo, lapack_int* n, lapack_int* ncvt, - lapack_int* nru, lapack_int* ncc, float* d, float* e, - float* vt, lapack_int* ldvt, float* u, lapack_int* ldu, - float* c, lapack_int* ldc, float* work, lapack_int *info ); -void LAPACK_dbdsqr( char* uplo, lapack_int* n, lapack_int* ncvt, - lapack_int* nru, lapack_int* ncc, double* d, double* e, - double* vt, lapack_int* ldvt, double* u, lapack_int* ldu, - double* c, lapack_int* ldc, double* work, - lapack_int *info ); -void LAPACK_cbdsqr( char* uplo, lapack_int* n, lapack_int* ncvt, - lapack_int* nru, lapack_int* ncc, float* d, float* e, - lapack_complex_float* vt, lapack_int* ldvt, - lapack_complex_float* u, lapack_int* ldu, - lapack_complex_float* c, lapack_int* ldc, float* work, - lapack_int *info ); -void LAPACK_zbdsqr( char* uplo, lapack_int* n, lapack_int* ncvt, - lapack_int* nru, lapack_int* ncc, double* d, double* e, - lapack_complex_double* vt, lapack_int* ldvt, - lapack_complex_double* u, lapack_int* ldu, - lapack_complex_double* c, lapack_int* ldc, double* work, - lapack_int *info ); -void LAPACK_sbdsdc( char* uplo, char* compq, lapack_int* n, float* d, float* e, - float* u, lapack_int* ldu, float* vt, lapack_int* ldvt, - float* q, lapack_int* iq, float* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_dbdsdc( char* uplo, char* compq, lapack_int* n, double* d, - double* e, double* u, lapack_int* ldu, double* vt, - lapack_int* ldvt, double* q, lapack_int* iq, double* work, - lapack_int* iwork, lapack_int *info ); -void LAPACK_sbdsvdx( char* uplo, char* jobz, char* range, - lapack_int* n, float* d, float* e, - float* vl, float* vu, - lapack_int* il, lapack_int* iu, lapack_int* ns, - float* s, float* z, lapack_int* ldz, - float* work, lapack_int *iwork, lapack_int *info ); -void LAPACK_dbdsvdx( char* uplo, char* jobz, char* range, - lapack_int* n, double* d, double* e, - double* vl, double* vu, - lapack_int* il, lapack_int* iu, lapack_int* ns, - double* s, double* z, lapack_int* ldz, - double* work, lapack_int *iwork, lapack_int *info ); -void LAPACK_ssytrd( char* uplo, lapack_int* n, float* a, lapack_int* lda, - float* d, float* e, float* tau, float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_dsytrd( char* uplo, lapack_int* n, double* a, lapack_int* lda, - double* d, double* e, double* tau, double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_sorgtr( char* uplo, lapack_int* n, float* a, lapack_int* lda, - const float* tau, float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_dorgtr( char* uplo, lapack_int* n, double* a, lapack_int* lda, - const double* tau, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_sormtr( char* side, char* uplo, char* trans, lapack_int* m, - lapack_int* n, const float* a, lapack_int* lda, - const float* tau, float* c, lapack_int* ldc, float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_dormtr( char* side, char* uplo, char* trans, lapack_int* m, - lapack_int* n, const double* a, lapack_int* lda, - const double* tau, double* c, lapack_int* ldc, double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_chetrd( char* uplo, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, float* d, float* e, - lapack_complex_float* tau, lapack_complex_float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_zhetrd( char* uplo, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, double* d, double* e, - lapack_complex_double* tau, lapack_complex_double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_cungtr( char* uplo, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, const lapack_complex_float* tau, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zungtr( char* uplo, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, const lapack_complex_double* tau, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_cunmtr( char* side, char* uplo, char* trans, lapack_int* m, - lapack_int* n, const lapack_complex_float* a, - lapack_int* lda, const lapack_complex_float* tau, - lapack_complex_float* c, lapack_int* ldc, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zunmtr( char* side, char* uplo, char* trans, lapack_int* m, - lapack_int* n, const lapack_complex_double* a, - lapack_int* lda, const lapack_complex_double* tau, - lapack_complex_double* c, lapack_int* ldc, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_ssptrd( char* uplo, lapack_int* n, float* ap, float* d, float* e, - float* tau, lapack_int *info ); -void LAPACK_dsptrd( char* uplo, lapack_int* n, double* ap, double* d, double* e, - double* tau, lapack_int *info ); -void LAPACK_sopgtr( char* uplo, lapack_int* n, const float* ap, - const float* tau, float* q, lapack_int* ldq, float* work, - lapack_int *info ); -void LAPACK_dopgtr( char* uplo, lapack_int* n, const double* ap, - const double* tau, double* q, lapack_int* ldq, double* work, - lapack_int *info ); -void LAPACK_sopmtr( char* side, char* uplo, char* trans, lapack_int* m, - lapack_int* n, const float* ap, const float* tau, float* c, - lapack_int* ldc, float* work, lapack_int *info ); -void LAPACK_dopmtr( char* side, char* uplo, char* trans, lapack_int* m, - lapack_int* n, const double* ap, const double* tau, - double* c, lapack_int* ldc, double* work, - lapack_int *info ); -void LAPACK_chptrd( char* uplo, lapack_int* n, lapack_complex_float* ap, - float* d, float* e, lapack_complex_float* tau, - lapack_int *info ); -void LAPACK_zhptrd( char* uplo, lapack_int* n, lapack_complex_double* ap, - double* d, double* e, lapack_complex_double* tau, - lapack_int *info ); -void LAPACK_cupgtr( char* uplo, lapack_int* n, const lapack_complex_float* ap, - const lapack_complex_float* tau, lapack_complex_float* q, - lapack_int* ldq, lapack_complex_float* work, - lapack_int *info ); -void LAPACK_zupgtr( char* uplo, lapack_int* n, const lapack_complex_double* ap, - const lapack_complex_double* tau, lapack_complex_double* q, - lapack_int* ldq, lapack_complex_double* work, - lapack_int *info ); -void LAPACK_cupmtr( char* side, char* uplo, char* trans, lapack_int* m, - lapack_int* n, const lapack_complex_float* ap, - const lapack_complex_float* tau, lapack_complex_float* c, - lapack_int* ldc, lapack_complex_float* work, - lapack_int *info ); -void LAPACK_zupmtr( char* side, char* uplo, char* trans, lapack_int* m, - lapack_int* n, const lapack_complex_double* ap, - const lapack_complex_double* tau, lapack_complex_double* c, - lapack_int* ldc, lapack_complex_double* work, - lapack_int *info ); -void LAPACK_ssbtrd( char* vect, char* uplo, lapack_int* n, lapack_int* kd, - float* ab, lapack_int* ldab, float* d, float* e, float* q, - lapack_int* ldq, float* work, lapack_int *info ); -void LAPACK_dsbtrd( char* vect, char* uplo, lapack_int* n, lapack_int* kd, - double* ab, lapack_int* ldab, double* d, double* e, - double* q, lapack_int* ldq, double* work, - lapack_int *info ); -void LAPACK_chbtrd( char* vect, char* uplo, lapack_int* n, lapack_int* kd, - lapack_complex_float* ab, lapack_int* ldab, float* d, - float* e, lapack_complex_float* q, lapack_int* ldq, - lapack_complex_float* work, lapack_int *info ); -void LAPACK_zhbtrd( char* vect, char* uplo, lapack_int* n, lapack_int* kd, - lapack_complex_double* ab, lapack_int* ldab, double* d, - double* e, lapack_complex_double* q, lapack_int* ldq, - lapack_complex_double* work, lapack_int *info ); -void LAPACK_ssterf( lapack_int* n, float* d, float* e, lapack_int *info ); -void LAPACK_dsterf( lapack_int* n, double* d, double* e, lapack_int *info ); -void LAPACK_ssteqr( char* compz, lapack_int* n, float* d, float* e, float* z, - lapack_int* ldz, float* work, lapack_int *info ); -void LAPACK_dsteqr( char* compz, lapack_int* n, double* d, double* e, double* z, - lapack_int* ldz, double* work, lapack_int *info ); -void LAPACK_csteqr( char* compz, lapack_int* n, float* d, float* e, - lapack_complex_float* z, lapack_int* ldz, float* work, - lapack_int *info ); -void LAPACK_zsteqr( char* compz, lapack_int* n, double* d, double* e, - lapack_complex_double* z, lapack_int* ldz, double* work, - lapack_int *info ); -void LAPACK_sstemr( char* jobz, char* range, lapack_int* n, float* d, float* e, - float* vl, float* vu, lapack_int* il, lapack_int* iu, - lapack_int* m, float* w, float* z, lapack_int* ldz, - lapack_int* nzc, lapack_int* isuppz, lapack_logical* tryrac, - float* work, lapack_int* lwork, lapack_int* iwork, - lapack_int* liwork, lapack_int *info ); -void LAPACK_dstemr( char* jobz, char* range, lapack_int* n, double* d, - double* e, double* vl, double* vu, lapack_int* il, - lapack_int* iu, lapack_int* m, double* w, double* z, - lapack_int* ldz, lapack_int* nzc, lapack_int* isuppz, - lapack_logical* tryrac, double* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* liwork, lapack_int *info ); -void LAPACK_cstemr( char* jobz, char* range, lapack_int* n, float* d, float* e, - float* vl, float* vu, lapack_int* il, lapack_int* iu, - lapack_int* m, float* w, lapack_complex_float* z, - lapack_int* ldz, lapack_int* nzc, lapack_int* isuppz, - lapack_logical* tryrac, float* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* liwork, lapack_int *info ); -void LAPACK_zstemr( char* jobz, char* range, lapack_int* n, double* d, - double* e, double* vl, double* vu, lapack_int* il, - lapack_int* iu, lapack_int* m, double* w, - lapack_complex_double* z, lapack_int* ldz, lapack_int* nzc, - lapack_int* isuppz, lapack_logical* tryrac, double* work, - lapack_int* lwork, lapack_int* iwork, lapack_int* liwork, - lapack_int *info ); -void LAPACK_sstedc( char* compz, lapack_int* n, float* d, float* e, float* z, - lapack_int* ldz, float* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* liwork, lapack_int *info ); -void LAPACK_dstedc( char* compz, lapack_int* n, double* d, double* e, double* z, - lapack_int* ldz, double* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* liwork, lapack_int *info ); -void LAPACK_cstedc( char* compz, lapack_int* n, float* d, float* e, - lapack_complex_float* z, lapack_int* ldz, - lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_int* lrwork, lapack_int* iwork, lapack_int* liwork, - lapack_int *info ); -void LAPACK_zstedc( char* compz, lapack_int* n, double* d, double* e, - lapack_complex_double* z, lapack_int* ldz, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_int* lrwork, lapack_int* iwork, - lapack_int* liwork, lapack_int *info ); -void LAPACK_sstegr( char* jobz, char* range, lapack_int* n, float* d, float* e, - float* vl, float* vu, lapack_int* il, lapack_int* iu, - float* abstol, lapack_int* m, float* w, float* z, - lapack_int* ldz, lapack_int* isuppz, float* work, - lapack_int* lwork, lapack_int* iwork, lapack_int* liwork, - lapack_int *info ); -void LAPACK_dstegr( char* jobz, char* range, lapack_int* n, double* d, - double* e, double* vl, double* vu, lapack_int* il, - lapack_int* iu, double* abstol, lapack_int* m, double* w, - double* z, lapack_int* ldz, lapack_int* isuppz, - double* work, lapack_int* lwork, lapack_int* iwork, - lapack_int* liwork, lapack_int *info ); -void LAPACK_cstegr( char* jobz, char* range, lapack_int* n, float* d, float* e, - float* vl, float* vu, lapack_int* il, lapack_int* iu, - float* abstol, lapack_int* m, float* w, - lapack_complex_float* z, lapack_int* ldz, - lapack_int* isuppz, float* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* liwork, lapack_int *info ); -void LAPACK_zstegr( char* jobz, char* range, lapack_int* n, double* d, - double* e, double* vl, double* vu, lapack_int* il, - lapack_int* iu, double* abstol, lapack_int* m, double* w, - lapack_complex_double* z, lapack_int* ldz, - lapack_int* isuppz, double* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* liwork, lapack_int *info ); -void LAPACK_spteqr( char* compz, lapack_int* n, float* d, float* e, float* z, - lapack_int* ldz, float* work, lapack_int *info ); -void LAPACK_dpteqr( char* compz, lapack_int* n, double* d, double* e, double* z, - lapack_int* ldz, double* work, lapack_int *info ); -void LAPACK_cpteqr( char* compz, lapack_int* n, float* d, float* e, - lapack_complex_float* z, lapack_int* ldz, float* work, - lapack_int *info ); -void LAPACK_zpteqr( char* compz, lapack_int* n, double* d, double* e, - lapack_complex_double* z, lapack_int* ldz, double* work, - lapack_int *info ); -void LAPACK_sstebz( char* range, char* order, lapack_int* n, float* vl, - float* vu, lapack_int* il, lapack_int* iu, float* abstol, - const float* d, const float* e, lapack_int* m, - lapack_int* nsplit, float* w, lapack_int* iblock, - lapack_int* isplit, float* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_dstebz( char* range, char* order, lapack_int* n, double* vl, - double* vu, lapack_int* il, lapack_int* iu, double* abstol, - const double* d, const double* e, lapack_int* m, - lapack_int* nsplit, double* w, lapack_int* iblock, - lapack_int* isplit, double* work, lapack_int* iwork, - lapack_int *info ); -void LAPACK_sstein( lapack_int* n, const float* d, const float* e, - lapack_int* m, const float* w, const lapack_int* iblock, - const lapack_int* isplit, float* z, lapack_int* ldz, - float* work, lapack_int* iwork, lapack_int* ifailv, - lapack_int *info ); -void LAPACK_dstein( lapack_int* n, const double* d, const double* e, - lapack_int* m, const double* w, const lapack_int* iblock, - const lapack_int* isplit, double* z, lapack_int* ldz, - double* work, lapack_int* iwork, lapack_int* ifailv, - lapack_int *info ); -void LAPACK_cstein( lapack_int* n, const float* d, const float* e, - lapack_int* m, const float* w, const lapack_int* iblock, - const lapack_int* isplit, lapack_complex_float* z, - lapack_int* ldz, float* work, lapack_int* iwork, - lapack_int* ifailv, lapack_int *info ); -void LAPACK_zstein( lapack_int* n, const double* d, const double* e, - lapack_int* m, const double* w, const lapack_int* iblock, - const lapack_int* isplit, lapack_complex_double* z, - lapack_int* ldz, double* work, lapack_int* iwork, - lapack_int* ifailv, lapack_int *info ); -void LAPACK_sdisna( char* job, lapack_int* m, lapack_int* n, const float* d, - float* sep, lapack_int *info ); -void LAPACK_ddisna( char* job, lapack_int* m, lapack_int* n, const double* d, - double* sep, lapack_int *info ); -void LAPACK_ssygst( lapack_int* itype, char* uplo, lapack_int* n, float* a, - lapack_int* lda, const float* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_dsygst( lapack_int* itype, char* uplo, lapack_int* n, double* a, - lapack_int* lda, const double* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_chegst( lapack_int* itype, char* uplo, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, - const lapack_complex_float* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_zhegst( lapack_int* itype, char* uplo, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, - const lapack_complex_double* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_sspgst( lapack_int* itype, char* uplo, lapack_int* n, float* ap, - const float* bp, lapack_int *info ); -void LAPACK_dspgst( lapack_int* itype, char* uplo, lapack_int* n, double* ap, - const double* bp, lapack_int *info ); -void LAPACK_chpgst( lapack_int* itype, char* uplo, lapack_int* n, - lapack_complex_float* ap, const lapack_complex_float* bp, - lapack_int *info ); -void LAPACK_zhpgst( lapack_int* itype, char* uplo, lapack_int* n, - lapack_complex_double* ap, const lapack_complex_double* bp, - lapack_int *info ); -void LAPACK_ssbgst( char* vect, char* uplo, lapack_int* n, lapack_int* ka, - lapack_int* kb, float* ab, lapack_int* ldab, - const float* bb, lapack_int* ldbb, float* x, - lapack_int* ldx, float* work, lapack_int *info ); -void LAPACK_dsbgst( char* vect, char* uplo, lapack_int* n, lapack_int* ka, - lapack_int* kb, double* ab, lapack_int* ldab, - const double* bb, lapack_int* ldbb, double* x, - lapack_int* ldx, double* work, lapack_int *info ); -void LAPACK_chbgst( char* vect, char* uplo, lapack_int* n, lapack_int* ka, - lapack_int* kb, lapack_complex_float* ab, lapack_int* ldab, - const lapack_complex_float* bb, lapack_int* ldbb, - lapack_complex_float* x, lapack_int* ldx, - lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_zhbgst( char* vect, char* uplo, lapack_int* n, lapack_int* ka, - lapack_int* kb, lapack_complex_double* ab, lapack_int* ldab, - const lapack_complex_double* bb, lapack_int* ldbb, - lapack_complex_double* x, lapack_int* ldx, - lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_spbstf( char* uplo, lapack_int* n, lapack_int* kb, float* bb, - lapack_int* ldbb, lapack_int *info ); -void LAPACK_dpbstf( char* uplo, lapack_int* n, lapack_int* kb, double* bb, - lapack_int* ldbb, lapack_int *info ); -void LAPACK_cpbstf( char* uplo, lapack_int* n, lapack_int* kb, - lapack_complex_float* bb, lapack_int* ldbb, - lapack_int *info ); -void LAPACK_zpbstf( char* uplo, lapack_int* n, lapack_int* kb, - lapack_complex_double* bb, lapack_int* ldbb, - lapack_int *info ); -void LAPACK_sgehrd( lapack_int* n, lapack_int* ilo, lapack_int* ihi, float* a, - lapack_int* lda, float* tau, float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_dgehrd( lapack_int* n, lapack_int* ilo, lapack_int* ihi, double* a, - lapack_int* lda, double* tau, double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_cgehrd( lapack_int* n, lapack_int* ilo, lapack_int* ihi, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* tau, lapack_complex_float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_zgehrd( lapack_int* n, lapack_int* ilo, lapack_int* ihi, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* tau, lapack_complex_double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_sorghr( lapack_int* n, lapack_int* ilo, lapack_int* ihi, float* a, - lapack_int* lda, const float* tau, float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_dorghr( lapack_int* n, lapack_int* ilo, lapack_int* ihi, double* a, - lapack_int* lda, const double* tau, double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_sormhr( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* ilo, lapack_int* ihi, const float* a, - lapack_int* lda, const float* tau, float* c, - lapack_int* ldc, float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_dormhr( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* ilo, lapack_int* ihi, const double* a, - lapack_int* lda, const double* tau, double* c, - lapack_int* ldc, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_cunghr( lapack_int* n, lapack_int* ilo, lapack_int* ihi, - lapack_complex_float* a, lapack_int* lda, - const lapack_complex_float* tau, lapack_complex_float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_zunghr( lapack_int* n, lapack_int* ilo, lapack_int* ihi, - lapack_complex_double* a, lapack_int* lda, - const lapack_complex_double* tau, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_cunmhr( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* ilo, lapack_int* ihi, - const lapack_complex_float* a, lapack_int* lda, - const lapack_complex_float* tau, lapack_complex_float* c, - lapack_int* ldc, lapack_complex_float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_zunmhr( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* ilo, lapack_int* ihi, - const lapack_complex_double* a, lapack_int* lda, - const lapack_complex_double* tau, lapack_complex_double* c, - lapack_int* ldc, lapack_complex_double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_sgebal( char* job, lapack_int* n, float* a, lapack_int* lda, - lapack_int* ilo, lapack_int* ihi, float* scale, - lapack_int *info ); -void LAPACK_dgebal( char* job, lapack_int* n, double* a, lapack_int* lda, - lapack_int* ilo, lapack_int* ihi, double* scale, - lapack_int *info ); -void LAPACK_cgebal( char* job, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_int* ilo, lapack_int* ihi, - float* scale, lapack_int *info ); -void LAPACK_zgebal( char* job, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_int* ilo, lapack_int* ihi, - double* scale, lapack_int *info ); -void LAPACK_sgebak( char* job, char* side, lapack_int* n, lapack_int* ilo, - lapack_int* ihi, const float* scale, lapack_int* m, - float* v, lapack_int* ldv, lapack_int *info ); -void LAPACK_dgebak( char* job, char* side, lapack_int* n, lapack_int* ilo, - lapack_int* ihi, const double* scale, lapack_int* m, - double* v, lapack_int* ldv, lapack_int *info ); -void LAPACK_cgebak( char* job, char* side, lapack_int* n, lapack_int* ilo, - lapack_int* ihi, const float* scale, lapack_int* m, - lapack_complex_float* v, lapack_int* ldv, - lapack_int *info ); -void LAPACK_zgebak( char* job, char* side, lapack_int* n, lapack_int* ilo, - lapack_int* ihi, const double* scale, lapack_int* m, - lapack_complex_double* v, lapack_int* ldv, - lapack_int *info ); -void LAPACK_shseqr( char* job, char* compz, lapack_int* n, lapack_int* ilo, - lapack_int* ihi, float* h, lapack_int* ldh, float* wr, - float* wi, float* z, lapack_int* ldz, float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_dhseqr( char* job, char* compz, lapack_int* n, lapack_int* ilo, - lapack_int* ihi, double* h, lapack_int* ldh, double* wr, - double* wi, double* z, lapack_int* ldz, double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_chseqr( char* job, char* compz, lapack_int* n, lapack_int* ilo, - lapack_int* ihi, lapack_complex_float* h, lapack_int* ldh, - lapack_complex_float* w, lapack_complex_float* z, - lapack_int* ldz, lapack_complex_float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_zhseqr( char* job, char* compz, lapack_int* n, lapack_int* ilo, - lapack_int* ihi, lapack_complex_double* h, lapack_int* ldh, - lapack_complex_double* w, lapack_complex_double* z, - lapack_int* ldz, lapack_complex_double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_shsein( char* job, char* eigsrc, char* initv, - lapack_logical* select, lapack_int* n, const float* h, - lapack_int* ldh, float* wr, const float* wi, float* vl, - lapack_int* ldvl, float* vr, lapack_int* ldvr, - lapack_int* mm, lapack_int* m, float* work, - lapack_int* ifaill, lapack_int* ifailr, lapack_int *info ); -void LAPACK_dhsein( char* job, char* eigsrc, char* initv, - lapack_logical* select, lapack_int* n, const double* h, - lapack_int* ldh, double* wr, const double* wi, double* vl, - lapack_int* ldvl, double* vr, lapack_int* ldvr, - lapack_int* mm, lapack_int* m, double* work, - lapack_int* ifaill, lapack_int* ifailr, lapack_int *info ); -void LAPACK_chsein( char* job, char* eigsrc, char* initv, - const lapack_logical* select, lapack_int* n, - const lapack_complex_float* h, lapack_int* ldh, - lapack_complex_float* w, lapack_complex_float* vl, - lapack_int* ldvl, lapack_complex_float* vr, - lapack_int* ldvr, lapack_int* mm, lapack_int* m, - lapack_complex_float* work, float* rwork, - lapack_int* ifaill, lapack_int* ifailr, lapack_int *info ); -void LAPACK_zhsein( char* job, char* eigsrc, char* initv, - const lapack_logical* select, lapack_int* n, - const lapack_complex_double* h, lapack_int* ldh, - lapack_complex_double* w, lapack_complex_double* vl, - lapack_int* ldvl, lapack_complex_double* vr, - lapack_int* ldvr, lapack_int* mm, lapack_int* m, - lapack_complex_double* work, double* rwork, - lapack_int* ifaill, lapack_int* ifailr, lapack_int *info ); -void LAPACK_strevc( char* side, char* howmny, lapack_logical* select, - lapack_int* n, const float* t, lapack_int* ldt, float* vl, - lapack_int* ldvl, float* vr, lapack_int* ldvr, - lapack_int* mm, lapack_int* m, float* work, - lapack_int *info ); -void LAPACK_dtrevc( char* side, char* howmny, lapack_logical* select, - lapack_int* n, const double* t, lapack_int* ldt, double* vl, - lapack_int* ldvl, double* vr, lapack_int* ldvr, - lapack_int* mm, lapack_int* m, double* work, - lapack_int *info ); -void LAPACK_ctrevc( char* side, char* howmny, const lapack_logical* select, - lapack_int* n, lapack_complex_float* t, lapack_int* ldt, - lapack_complex_float* vl, lapack_int* ldvl, - lapack_complex_float* vr, lapack_int* ldvr, lapack_int* mm, - lapack_int* m, lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_ztrevc( char* side, char* howmny, const lapack_logical* select, - lapack_int* n, lapack_complex_double* t, lapack_int* ldt, - lapack_complex_double* vl, lapack_int* ldvl, - lapack_complex_double* vr, lapack_int* ldvr, lapack_int* mm, - lapack_int* m, lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_strsna( char* job, char* howmny, const lapack_logical* select, - lapack_int* n, const float* t, lapack_int* ldt, - const float* vl, lapack_int* ldvl, const float* vr, - lapack_int* ldvr, float* s, float* sep, lapack_int* mm, - lapack_int* m, float* work, lapack_int* ldwork, - lapack_int* iwork, lapack_int *info ); -void LAPACK_dtrsna( char* job, char* howmny, const lapack_logical* select, - lapack_int* n, const double* t, lapack_int* ldt, - const double* vl, lapack_int* ldvl, const double* vr, - lapack_int* ldvr, double* s, double* sep, lapack_int* mm, - lapack_int* m, double* work, lapack_int* ldwork, - lapack_int* iwork, lapack_int *info ); -void LAPACK_ctrsna( char* job, char* howmny, const lapack_logical* select, - lapack_int* n, const lapack_complex_float* t, - lapack_int* ldt, const lapack_complex_float* vl, - lapack_int* ldvl, const lapack_complex_float* vr, - lapack_int* ldvr, float* s, float* sep, lapack_int* mm, - lapack_int* m, lapack_complex_float* work, - lapack_int* ldwork, float* rwork, lapack_int *info ); -void LAPACK_ztrsna( char* job, char* howmny, const lapack_logical* select, - lapack_int* n, const lapack_complex_double* t, - lapack_int* ldt, const lapack_complex_double* vl, - lapack_int* ldvl, const lapack_complex_double* vr, - lapack_int* ldvr, double* s, double* sep, lapack_int* mm, - lapack_int* m, lapack_complex_double* work, - lapack_int* ldwork, double* rwork, lapack_int *info ); -void LAPACK_strexc( char* compq, lapack_int* n, float* t, lapack_int* ldt, - float* q, lapack_int* ldq, lapack_int* ifst, - lapack_int* ilst, float* work, lapack_int *info ); -void LAPACK_dtrexc( char* compq, lapack_int* n, double* t, lapack_int* ldt, - double* q, lapack_int* ldq, lapack_int* ifst, - lapack_int* ilst, double* work, lapack_int *info ); -void LAPACK_ctrexc( char* compq, lapack_int* n, lapack_complex_float* t, - lapack_int* ldt, lapack_complex_float* q, lapack_int* ldq, - lapack_int* ifst, lapack_int* ilst, lapack_int *info ); -void LAPACK_ztrexc( char* compq, lapack_int* n, lapack_complex_double* t, - lapack_int* ldt, lapack_complex_double* q, lapack_int* ldq, - lapack_int* ifst, lapack_int* ilst, lapack_int *info ); -void LAPACK_strsen( char* job, char* compq, const lapack_logical* select, - lapack_int* n, float* t, lapack_int* ldt, float* q, - lapack_int* ldq, float* wr, float* wi, lapack_int* m, - float* s, float* sep, float* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* liwork, lapack_int *info ); -void LAPACK_dtrsen( char* job, char* compq, const lapack_logical* select, - lapack_int* n, double* t, lapack_int* ldt, double* q, - lapack_int* ldq, double* wr, double* wi, lapack_int* m, - double* s, double* sep, double* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* liwork, lapack_int *info ); -void LAPACK_ctrsen( char* job, char* compq, const lapack_logical* select, - lapack_int* n, lapack_complex_float* t, lapack_int* ldt, - lapack_complex_float* q, lapack_int* ldq, - lapack_complex_float* w, lapack_int* m, float* s, - float* sep, lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_ztrsen( char* job, char* compq, const lapack_logical* select, - lapack_int* n, lapack_complex_double* t, lapack_int* ldt, - lapack_complex_double* q, lapack_int* ldq, - lapack_complex_double* w, lapack_int* m, double* s, - double* sep, lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_strsyl( char* trana, char* tranb, lapack_int* isgn, lapack_int* m, - lapack_int* n, const float* a, lapack_int* lda, - const float* b, lapack_int* ldb, float* c, lapack_int* ldc, - float* scale, lapack_int *info ); -void LAPACK_dtrsyl( char* trana, char* tranb, lapack_int* isgn, lapack_int* m, - lapack_int* n, const double* a, lapack_int* lda, - const double* b, lapack_int* ldb, double* c, - lapack_int* ldc, double* scale, lapack_int *info ); -void LAPACK_ctrsyl( char* trana, char* tranb, lapack_int* isgn, lapack_int* m, - lapack_int* n, const lapack_complex_float* a, - lapack_int* lda, const lapack_complex_float* b, - lapack_int* ldb, lapack_complex_float* c, lapack_int* ldc, - float* scale, lapack_int *info ); -void LAPACK_ztrsyl( char* trana, char* tranb, lapack_int* isgn, lapack_int* m, - lapack_int* n, const lapack_complex_double* a, - lapack_int* lda, const lapack_complex_double* b, - lapack_int* ldb, lapack_complex_double* c, lapack_int* ldc, - double* scale, lapack_int *info ); -void LAPACK_sgghrd( char* compq, char* compz, lapack_int* n, lapack_int* ilo, - lapack_int* ihi, float* a, lapack_int* lda, float* b, - lapack_int* ldb, float* q, lapack_int* ldq, float* z, - lapack_int* ldz, lapack_int *info ); -void LAPACK_dgghrd( char* compq, char* compz, lapack_int* n, lapack_int* ilo, - lapack_int* ihi, double* a, lapack_int* lda, double* b, - lapack_int* ldb, double* q, lapack_int* ldq, double* z, - lapack_int* ldz, lapack_int *info ); -void LAPACK_cgghrd( char* compq, char* compz, lapack_int* n, lapack_int* ilo, - lapack_int* ihi, lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* q, lapack_int* ldq, - lapack_complex_float* z, lapack_int* ldz, - lapack_int *info ); -void LAPACK_zgghrd( char* compq, char* compz, lapack_int* n, lapack_int* ilo, - lapack_int* ihi, lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* q, lapack_int* ldq, - lapack_complex_double* z, lapack_int* ldz, - lapack_int *info ); -void LAPACK_sgghd3( char* compq, char* compz, lapack_int* n, lapack_int* ilo, - lapack_int* ihi, float* a, lapack_int* lda, float* b, - lapack_int* ldb, float* q, lapack_int* ldq, float* z, - lapack_int* ldz, float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_dgghd3( char* compq, char* compz, lapack_int* n, lapack_int* ilo, - lapack_int* ihi, double* a, lapack_int* lda, double* b, - lapack_int* ldb, double* q, lapack_int* ldq, double* z, - lapack_int* ldz, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_cgghd3( char* compq, char* compz, lapack_int* n, - lapack_int* ilo, lapack_int* ihi, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* q, lapack_int* ldq, - lapack_complex_float* z, lapack_int* ldz, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zgghd3( char* compq, char* compz, lapack_int* n, - lapack_int* ilo, lapack_int* ihi, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* q, lapack_int* ldq, - lapack_complex_double* z, lapack_int* ldz, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_sggbal( char* job, lapack_int* n, float* a, lapack_int* lda, - float* b, lapack_int* ldb, lapack_int* ilo, lapack_int* ihi, - float* lscale, float* rscale, float* work, - lapack_int *info ); -void LAPACK_dggbal( char* job, lapack_int* n, double* a, lapack_int* lda, - double* b, lapack_int* ldb, lapack_int* ilo, - lapack_int* ihi, double* lscale, double* rscale, - double* work, lapack_int *info ); -void LAPACK_cggbal( char* job, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_complex_float* b, lapack_int* ldb, - lapack_int* ilo, lapack_int* ihi, float* lscale, - float* rscale, float* work, lapack_int *info ); -void LAPACK_zggbal( char* job, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_complex_double* b, lapack_int* ldb, - lapack_int* ilo, lapack_int* ihi, double* lscale, - double* rscale, double* work, lapack_int *info ); -void LAPACK_sggbak( char* job, char* side, lapack_int* n, lapack_int* ilo, - lapack_int* ihi, const float* lscale, const float* rscale, - lapack_int* m, float* v, lapack_int* ldv, - lapack_int *info ); -void LAPACK_dggbak( char* job, char* side, lapack_int* n, lapack_int* ilo, - lapack_int* ihi, const double* lscale, const double* rscale, - lapack_int* m, double* v, lapack_int* ldv, - lapack_int *info ); -void LAPACK_cggbak( char* job, char* side, lapack_int* n, lapack_int* ilo, - lapack_int* ihi, const float* lscale, const float* rscale, - lapack_int* m, lapack_complex_float* v, lapack_int* ldv, - lapack_int *info ); -void LAPACK_zggbak( char* job, char* side, lapack_int* n, lapack_int* ilo, - lapack_int* ihi, const double* lscale, const double* rscale, - lapack_int* m, lapack_complex_double* v, lapack_int* ldv, - lapack_int *info ); -void LAPACK_shgeqz( char* job, char* compq, char* compz, lapack_int* n, - lapack_int* ilo, lapack_int* ihi, float* h, lapack_int* ldh, - float* t, lapack_int* ldt, float* alphar, float* alphai, - float* beta, float* q, lapack_int* ldq, float* z, - lapack_int* ldz, float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_dhgeqz( char* job, char* compq, char* compz, lapack_int* n, - lapack_int* ilo, lapack_int* ihi, double* h, - lapack_int* ldh, double* t, lapack_int* ldt, double* alphar, - double* alphai, double* beta, double* q, lapack_int* ldq, - double* z, lapack_int* ldz, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_chgeqz( char* job, char* compq, char* compz, lapack_int* n, - lapack_int* ilo, lapack_int* ihi, lapack_complex_float* h, - lapack_int* ldh, lapack_complex_float* t, lapack_int* ldt, - lapack_complex_float* alpha, lapack_complex_float* beta, - lapack_complex_float* q, lapack_int* ldq, - lapack_complex_float* z, lapack_int* ldz, - lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_int *info ); -void LAPACK_zhgeqz( char* job, char* compq, char* compz, lapack_int* n, - lapack_int* ilo, lapack_int* ihi, lapack_complex_double* h, - lapack_int* ldh, lapack_complex_double* t, lapack_int* ldt, - lapack_complex_double* alpha, lapack_complex_double* beta, - lapack_complex_double* q, lapack_int* ldq, - lapack_complex_double* z, lapack_int* ldz, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_int *info ); -void LAPACK_stgevc( char* side, char* howmny, const lapack_logical* select, - lapack_int* n, const float* s, lapack_int* lds, - const float* p, lapack_int* ldp, float* vl, - lapack_int* ldvl, float* vr, lapack_int* ldvr, - lapack_int* mm, lapack_int* m, float* work, - lapack_int *info ); -void LAPACK_dtgevc( char* side, char* howmny, const lapack_logical* select, - lapack_int* n, const double* s, lapack_int* lds, - const double* p, lapack_int* ldp, double* vl, - lapack_int* ldvl, double* vr, lapack_int* ldvr, - lapack_int* mm, lapack_int* m, double* work, - lapack_int *info ); -void LAPACK_ctgevc( char* side, char* howmny, const lapack_logical* select, - lapack_int* n, const lapack_complex_float* s, - lapack_int* lds, const lapack_complex_float* p, - lapack_int* ldp, lapack_complex_float* vl, lapack_int* ldvl, - lapack_complex_float* vr, lapack_int* ldvr, lapack_int* mm, - lapack_int* m, lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_ztgevc( char* side, char* howmny, const lapack_logical* select, - lapack_int* n, const lapack_complex_double* s, - lapack_int* lds, const lapack_complex_double* p, - lapack_int* ldp, lapack_complex_double* vl, - lapack_int* ldvl, lapack_complex_double* vr, - lapack_int* ldvr, lapack_int* mm, lapack_int* m, - lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_stgexc( lapack_logical* wantq, lapack_logical* wantz, lapack_int* n, - float* a, lapack_int* lda, float* b, lapack_int* ldb, - float* q, lapack_int* ldq, float* z, lapack_int* ldz, - lapack_int* ifst, lapack_int* ilst, float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_dtgexc( lapack_logical* wantq, lapack_logical* wantz, lapack_int* n, - double* a, lapack_int* lda, double* b, lapack_int* ldb, - double* q, lapack_int* ldq, double* z, lapack_int* ldz, - lapack_int* ifst, lapack_int* ilst, double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_ctgexc( lapack_logical* wantq, lapack_logical* wantz, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* q, lapack_int* ldq, - lapack_complex_float* z, lapack_int* ldz, lapack_int* ifst, - lapack_int* ilst, lapack_int *info ); -void LAPACK_ztgexc( lapack_logical* wantq, lapack_logical* wantz, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* q, lapack_int* ldq, - lapack_complex_double* z, lapack_int* ldz, lapack_int* ifst, - lapack_int* ilst, lapack_int *info ); -void LAPACK_stgsen( lapack_int* ijob, lapack_logical* wantq, - lapack_logical* wantz, const lapack_logical* select, - lapack_int* n, float* a, lapack_int* lda, float* b, - lapack_int* ldb, float* alphar, float* alphai, float* beta, - float* q, lapack_int* ldq, float* z, lapack_int* ldz, - lapack_int* m, float* pl, float* pr, float* dif, - float* work, lapack_int* lwork, lapack_int* iwork, - lapack_int* liwork, lapack_int *info ); -void LAPACK_dtgsen( lapack_int* ijob, lapack_logical* wantq, - lapack_logical* wantz, const lapack_logical* select, - lapack_int* n, double* a, lapack_int* lda, double* b, - lapack_int* ldb, double* alphar, double* alphai, - double* beta, double* q, lapack_int* ldq, double* z, - lapack_int* ldz, lapack_int* m, double* pl, double* pr, - double* dif, double* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* liwork, lapack_int *info ); -void LAPACK_ctgsen( lapack_int* ijob, lapack_logical* wantq, - lapack_logical* wantz, const lapack_logical* select, - lapack_int* n, lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* alpha, lapack_complex_float* beta, - lapack_complex_float* q, lapack_int* ldq, - lapack_complex_float* z, lapack_int* ldz, lapack_int* m, - float* pl, float* pr, float* dif, - lapack_complex_float* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* liwork, lapack_int *info ); -void LAPACK_ztgsen( lapack_int* ijob, lapack_logical* wantq, - lapack_logical* wantz, const lapack_logical* select, - lapack_int* n, lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* alpha, lapack_complex_double* beta, - lapack_complex_double* q, lapack_int* ldq, - lapack_complex_double* z, lapack_int* ldz, lapack_int* m, - double* pl, double* pr, double* dif, - lapack_complex_double* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* liwork, lapack_int *info ); -void LAPACK_stgsyl( char* trans, lapack_int* ijob, lapack_int* m, lapack_int* n, - const float* a, lapack_int* lda, const float* b, - lapack_int* ldb, float* c, lapack_int* ldc, const float* d, - lapack_int* ldd, const float* e, lapack_int* lde, float* f, - lapack_int* ldf, float* scale, float* dif, float* work, - lapack_int* lwork, lapack_int* iwork, lapack_int *info ); -void LAPACK_dtgsyl( char* trans, lapack_int* ijob, lapack_int* m, lapack_int* n, - const double* a, lapack_int* lda, const double* b, - lapack_int* ldb, double* c, lapack_int* ldc, - const double* d, lapack_int* ldd, const double* e, - lapack_int* lde, double* f, lapack_int* ldf, double* scale, - double* dif, double* work, lapack_int* lwork, - lapack_int* iwork, lapack_int *info ); -void LAPACK_ctgsyl( char* trans, lapack_int* ijob, lapack_int* m, lapack_int* n, - const lapack_complex_float* a, lapack_int* lda, - const lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* c, lapack_int* ldc, - const lapack_complex_float* d, lapack_int* ldd, - const lapack_complex_float* e, lapack_int* lde, - lapack_complex_float* f, lapack_int* ldf, float* scale, - float* dif, lapack_complex_float* work, lapack_int* lwork, - lapack_int* iwork, lapack_int *info ); -void LAPACK_ztgsyl( char* trans, lapack_int* ijob, lapack_int* m, lapack_int* n, - const lapack_complex_double* a, lapack_int* lda, - const lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* c, lapack_int* ldc, - const lapack_complex_double* d, lapack_int* ldd, - const lapack_complex_double* e, lapack_int* lde, - lapack_complex_double* f, lapack_int* ldf, double* scale, - double* dif, lapack_complex_double* work, lapack_int* lwork, - lapack_int* iwork, lapack_int *info ); -void LAPACK_stgsna( char* job, char* howmny, const lapack_logical* select, - lapack_int* n, const float* a, lapack_int* lda, - const float* b, lapack_int* ldb, const float* vl, - lapack_int* ldvl, const float* vr, lapack_int* ldvr, - float* s, float* dif, lapack_int* mm, lapack_int* m, - float* work, lapack_int* lwork, lapack_int* iwork, - lapack_int *info ); -void LAPACK_dtgsna( char* job, char* howmny, const lapack_logical* select, - lapack_int* n, const double* a, lapack_int* lda, - const double* b, lapack_int* ldb, const double* vl, - lapack_int* ldvl, const double* vr, lapack_int* ldvr, - double* s, double* dif, lapack_int* mm, lapack_int* m, - double* work, lapack_int* lwork, lapack_int* iwork, - lapack_int *info ); -void LAPACK_ctgsna( char* job, char* howmny, const lapack_logical* select, - lapack_int* n, const lapack_complex_float* a, - lapack_int* lda, const lapack_complex_float* b, - lapack_int* ldb, const lapack_complex_float* vl, - lapack_int* ldvl, const lapack_complex_float* vr, - lapack_int* ldvr, float* s, float* dif, lapack_int* mm, - lapack_int* m, lapack_complex_float* work, - lapack_int* lwork, lapack_int* iwork, lapack_int *info ); -void LAPACK_ztgsna( char* job, char* howmny, const lapack_logical* select, - lapack_int* n, const lapack_complex_double* a, - lapack_int* lda, const lapack_complex_double* b, - lapack_int* ldb, const lapack_complex_double* vl, - lapack_int* ldvl, const lapack_complex_double* vr, - lapack_int* ldvr, double* s, double* dif, lapack_int* mm, - lapack_int* m, lapack_complex_double* work, - lapack_int* lwork, lapack_int* iwork, lapack_int *info ); -void LAPACK_sggsvp( char* jobu, char* jobv, char* jobq, lapack_int* m, - lapack_int* p, lapack_int* n, float* a, lapack_int* lda, - float* b, lapack_int* ldb, float* tola, float* tolb, - lapack_int* k, lapack_int* l, float* u, lapack_int* ldu, - float* v, lapack_int* ldv, float* q, lapack_int* ldq, - lapack_int* iwork, float* tau, float* work, - lapack_int *info ); -void LAPACK_dggsvp( char* jobu, char* jobv, char* jobq, lapack_int* m, - lapack_int* p, lapack_int* n, double* a, lapack_int* lda, - double* b, lapack_int* ldb, double* tola, double* tolb, - lapack_int* k, lapack_int* l, double* u, lapack_int* ldu, - double* v, lapack_int* ldv, double* q, lapack_int* ldq, - lapack_int* iwork, double* tau, double* work, - lapack_int *info ); -void LAPACK_cggsvp( char* jobu, char* jobv, char* jobq, lapack_int* m, - lapack_int* p, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_complex_float* b, lapack_int* ldb, - float* tola, float* tolb, lapack_int* k, lapack_int* l, - lapack_complex_float* u, lapack_int* ldu, - lapack_complex_float* v, lapack_int* ldv, - lapack_complex_float* q, lapack_int* ldq, lapack_int* iwork, - float* rwork, lapack_complex_float* tau, - lapack_complex_float* work, lapack_int *info ); -void LAPACK_zggsvp( char* jobu, char* jobv, char* jobq, lapack_int* m, - lapack_int* p, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_complex_double* b, lapack_int* ldb, - double* tola, double* tolb, lapack_int* k, lapack_int* l, - lapack_complex_double* u, lapack_int* ldu, - lapack_complex_double* v, lapack_int* ldv, - lapack_complex_double* q, lapack_int* ldq, - lapack_int* iwork, double* rwork, - lapack_complex_double* tau, lapack_complex_double* work, - lapack_int *info ); -void LAPACK_sggsvp3( char* jobu, char* jobv, char* jobq, lapack_int* m, - lapack_int* p, lapack_int* n, float* a, lapack_int* lda, - float* b, lapack_int* ldb, float* tola, float* tolb, - lapack_int* k, lapack_int* l, float* u, lapack_int* ldu, - float* v, lapack_int* ldv, float* q, lapack_int* ldq, - lapack_int* iwork, float* tau, float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_dggsvp3( char* jobu, char* jobv, char* jobq, lapack_int* m, - lapack_int* p, lapack_int* n, double* a, lapack_int* lda, - double* b, lapack_int* ldb, double* tola, double* tolb, - lapack_int* k, lapack_int* l, double* u, lapack_int* ldu, - double* v, lapack_int* ldv, double* q, lapack_int* ldq, - lapack_int* iwork, double* tau, double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_cggsvp3( char* jobu, char* jobv, char* jobq, lapack_int* m, - lapack_int* p, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_complex_float* b, lapack_int* ldb, - float* tola, float* tolb, lapack_int* k, lapack_int* l, - lapack_complex_float* u, lapack_int* ldu, - lapack_complex_float* v, lapack_int* ldv, - lapack_complex_float* q, lapack_int* ldq, lapack_int* iwork, - float* rwork, lapack_complex_float* tau, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zggsvp3( char* jobu, char* jobv, char* jobq, lapack_int* m, - lapack_int* p, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_complex_double* b, lapack_int* ldb, - double* tola, double* tolb, lapack_int* k, lapack_int* l, - lapack_complex_double* u, lapack_int* ldu, - lapack_complex_double* v, lapack_int* ldv, - lapack_complex_double* q, lapack_int* ldq, - lapack_int* iwork, double* rwork, - lapack_complex_double* tau, lapack_complex_double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_stgsja( char* jobu, char* jobv, char* jobq, lapack_int* m, - lapack_int* p, lapack_int* n, lapack_int* k, lapack_int* l, - float* a, lapack_int* lda, float* b, lapack_int* ldb, - float* tola, float* tolb, float* alpha, float* beta, - float* u, lapack_int* ldu, float* v, lapack_int* ldv, - float* q, lapack_int* ldq, float* work, lapack_int* ncycle, - lapack_int *info ); -void LAPACK_dtgsja( char* jobu, char* jobv, char* jobq, lapack_int* m, - lapack_int* p, lapack_int* n, lapack_int* k, lapack_int* l, - double* a, lapack_int* lda, double* b, lapack_int* ldb, - double* tola, double* tolb, double* alpha, double* beta, - double* u, lapack_int* ldu, double* v, lapack_int* ldv, - double* q, lapack_int* ldq, double* work, - lapack_int* ncycle, lapack_int *info ); -void LAPACK_ctgsja( char* jobu, char* jobv, char* jobq, lapack_int* m, - lapack_int* p, lapack_int* n, lapack_int* k, lapack_int* l, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, float* tola, - float* tolb, float* alpha, float* beta, - lapack_complex_float* u, lapack_int* ldu, - lapack_complex_float* v, lapack_int* ldv, - lapack_complex_float* q, lapack_int* ldq, - lapack_complex_float* work, lapack_int* ncycle, - lapack_int *info ); -void LAPACK_ztgsja( char* jobu, char* jobv, char* jobq, lapack_int* m, - lapack_int* p, lapack_int* n, lapack_int* k, lapack_int* l, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, double* tola, - double* tolb, double* alpha, double* beta, - lapack_complex_double* u, lapack_int* ldu, - lapack_complex_double* v, lapack_int* ldv, - lapack_complex_double* q, lapack_int* ldq, - lapack_complex_double* work, lapack_int* ncycle, - lapack_int *info ); -void LAPACK_sgels( char* trans, lapack_int* m, lapack_int* n, lapack_int* nrhs, - float* a, lapack_int* lda, float* b, lapack_int* ldb, - float* work, lapack_int* lwork, lapack_int *info ); -void LAPACK_dgels( char* trans, lapack_int* m, lapack_int* n, lapack_int* nrhs, - double* a, lapack_int* lda, double* b, lapack_int* ldb, - double* work, lapack_int* lwork, lapack_int *info ); -void LAPACK_cgels( char* trans, lapack_int* m, lapack_int* n, lapack_int* nrhs, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zgels( char* trans, lapack_int* m, lapack_int* n, lapack_int* nrhs, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_sgelsy( lapack_int* m, lapack_int* n, lapack_int* nrhs, float* a, - lapack_int* lda, float* b, lapack_int* ldb, - lapack_int* jpvt, float* rcond, lapack_int* rank, - float* work, lapack_int* lwork, lapack_int *info ); -void LAPACK_dgelsy( lapack_int* m, lapack_int* n, lapack_int* nrhs, double* a, - lapack_int* lda, double* b, lapack_int* ldb, - lapack_int* jpvt, double* rcond, lapack_int* rank, - double* work, lapack_int* lwork, lapack_int *info ); -void LAPACK_cgelsy( lapack_int* m, lapack_int* n, lapack_int* nrhs, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, lapack_int* jpvt, - float* rcond, lapack_int* rank, lapack_complex_float* work, - lapack_int* lwork, float* rwork, lapack_int *info ); -void LAPACK_zgelsy( lapack_int* m, lapack_int* n, lapack_int* nrhs, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, lapack_int* jpvt, - double* rcond, lapack_int* rank, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_int *info ); -void LAPACK_sgelss( lapack_int* m, lapack_int* n, lapack_int* nrhs, float* a, - lapack_int* lda, float* b, lapack_int* ldb, float* s, - float* rcond, lapack_int* rank, float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_dgelss( lapack_int* m, lapack_int* n, lapack_int* nrhs, double* a, - lapack_int* lda, double* b, lapack_int* ldb, double* s, - double* rcond, lapack_int* rank, double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_cgelss( lapack_int* m, lapack_int* n, lapack_int* nrhs, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, float* s, - float* rcond, lapack_int* rank, lapack_complex_float* work, - lapack_int* lwork, float* rwork, lapack_int *info ); -void LAPACK_zgelss( lapack_int* m, lapack_int* n, lapack_int* nrhs, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, double* s, - double* rcond, lapack_int* rank, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_int *info ); -void LAPACK_sgelsd( lapack_int* m, lapack_int* n, lapack_int* nrhs, float* a, - lapack_int* lda, float* b, lapack_int* ldb, float* s, - float* rcond, lapack_int* rank, float* work, - lapack_int* lwork, lapack_int* iwork, lapack_int *info ); -void LAPACK_dgelsd( lapack_int* m, lapack_int* n, lapack_int* nrhs, double* a, - lapack_int* lda, double* b, lapack_int* ldb, double* s, - double* rcond, lapack_int* rank, double* work, - lapack_int* lwork, lapack_int* iwork, lapack_int *info ); -void LAPACK_cgelsd( lapack_int* m, lapack_int* n, lapack_int* nrhs, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, float* s, - float* rcond, lapack_int* rank, lapack_complex_float* work, - lapack_int* lwork, float* rwork, lapack_int* iwork, - lapack_int *info ); -void LAPACK_zgelsd( lapack_int* m, lapack_int* n, lapack_int* nrhs, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, double* s, - double* rcond, lapack_int* rank, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_int* iwork, lapack_int *info ); -void LAPACK_sgglse( lapack_int* m, lapack_int* n, lapack_int* p, float* a, - lapack_int* lda, float* b, lapack_int* ldb, float* c, - float* d, float* x, float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_dgglse( lapack_int* m, lapack_int* n, lapack_int* p, double* a, - lapack_int* lda, double* b, lapack_int* ldb, double* c, - double* d, double* x, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_cgglse( lapack_int* m, lapack_int* n, lapack_int* p, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* c, lapack_complex_float* d, - lapack_complex_float* x, lapack_complex_float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_zgglse( lapack_int* m, lapack_int* n, lapack_int* p, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* c, lapack_complex_double* d, - lapack_complex_double* x, lapack_complex_double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_sggglm( lapack_int* n, lapack_int* m, lapack_int* p, float* a, - lapack_int* lda, float* b, lapack_int* ldb, float* d, - float* x, float* y, float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_dggglm( lapack_int* n, lapack_int* m, lapack_int* p, double* a, - lapack_int* lda, double* b, lapack_int* ldb, double* d, - double* x, double* y, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_cggglm( lapack_int* n, lapack_int* m, lapack_int* p, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* d, lapack_complex_float* x, - lapack_complex_float* y, lapack_complex_float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_zggglm( lapack_int* n, lapack_int* m, lapack_int* p, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* d, lapack_complex_double* x, - lapack_complex_double* y, lapack_complex_double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_ssyev( char* jobz, char* uplo, lapack_int* n, float* a, - lapack_int* lda, float* w, float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_dsyev( char* jobz, char* uplo, lapack_int* n, double* a, - lapack_int* lda, double* w, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_cheev( char* jobz, char* uplo, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, float* w, - lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_int *info ); -void LAPACK_zheev( char* jobz, char* uplo, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, double* w, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_int *info ); -void LAPACK_ssyevd( char* jobz, char* uplo, lapack_int* n, float* a, - lapack_int* lda, float* w, float* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* liwork, lapack_int *info ); -void LAPACK_dsyevd( char* jobz, char* uplo, lapack_int* n, double* a, - lapack_int* lda, double* w, double* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* liwork, lapack_int *info ); -void LAPACK_cheevd( char* jobz, char* uplo, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, float* w, - lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_int* lrwork, lapack_int* iwork, lapack_int* liwork, - lapack_int *info ); -void LAPACK_zheevd( char* jobz, char* uplo, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, double* w, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_int* lrwork, lapack_int* iwork, - lapack_int* liwork, lapack_int *info ); -void LAPACK_ssyevx( char* jobz, char* range, char* uplo, lapack_int* n, - float* a, lapack_int* lda, float* vl, float* vu, - lapack_int* il, lapack_int* iu, float* abstol, - lapack_int* m, float* w, float* z, lapack_int* ldz, - float* work, lapack_int* lwork, lapack_int* iwork, - lapack_int* ifail, lapack_int *info ); -void LAPACK_dsyevx( char* jobz, char* range, char* uplo, lapack_int* n, - double* a, lapack_int* lda, double* vl, double* vu, - lapack_int* il, lapack_int* iu, double* abstol, - lapack_int* m, double* w, double* z, lapack_int* ldz, - double* work, lapack_int* lwork, lapack_int* iwork, - lapack_int* ifail, lapack_int *info ); -void LAPACK_cheevx( char* jobz, char* range, char* uplo, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, float* vl, - float* vu, lapack_int* il, lapack_int* iu, float* abstol, - lapack_int* m, float* w, lapack_complex_float* z, - lapack_int* ldz, lapack_complex_float* work, - lapack_int* lwork, float* rwork, lapack_int* iwork, - lapack_int* ifail, lapack_int *info ); -void LAPACK_zheevx( char* jobz, char* range, char* uplo, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, double* vl, - double* vu, lapack_int* il, lapack_int* iu, double* abstol, - lapack_int* m, double* w, lapack_complex_double* z, - lapack_int* ldz, lapack_complex_double* work, - lapack_int* lwork, double* rwork, lapack_int* iwork, - lapack_int* ifail, lapack_int *info ); -void LAPACK_ssyevr( char* jobz, char* range, char* uplo, lapack_int* n, - float* a, lapack_int* lda, float* vl, float* vu, - lapack_int* il, lapack_int* iu, float* abstol, - lapack_int* m, float* w, float* z, lapack_int* ldz, - lapack_int* isuppz, float* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* liwork, lapack_int *info ); -void LAPACK_dsyevr( char* jobz, char* range, char* uplo, lapack_int* n, - double* a, lapack_int* lda, double* vl, double* vu, - lapack_int* il, lapack_int* iu, double* abstol, - lapack_int* m, double* w, double* z, lapack_int* ldz, - lapack_int* isuppz, double* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* liwork, lapack_int *info ); -void LAPACK_cheevr( char* jobz, char* range, char* uplo, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, float* vl, - float* vu, lapack_int* il, lapack_int* iu, float* abstol, - lapack_int* m, float* w, lapack_complex_float* z, - lapack_int* ldz, lapack_int* isuppz, - lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_int* lrwork, lapack_int* iwork, lapack_int* liwork, - lapack_int *info ); -void LAPACK_zheevr( char* jobz, char* range, char* uplo, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, double* vl, - double* vu, lapack_int* il, lapack_int* iu, double* abstol, - lapack_int* m, double* w, lapack_complex_double* z, - lapack_int* ldz, lapack_int* isuppz, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_int* lrwork, lapack_int* iwork, - lapack_int* liwork, lapack_int *info ); -void LAPACK_sspev( char* jobz, char* uplo, lapack_int* n, float* ap, float* w, - float* z, lapack_int* ldz, float* work, lapack_int *info ); -void LAPACK_dspev( char* jobz, char* uplo, lapack_int* n, double* ap, double* w, - double* z, lapack_int* ldz, double* work, lapack_int *info ); -void LAPACK_chpev( char* jobz, char* uplo, lapack_int* n, - lapack_complex_float* ap, float* w, lapack_complex_float* z, - lapack_int* ldz, lapack_complex_float* work, float* rwork, - lapack_int *info ); -void LAPACK_zhpev( char* jobz, char* uplo, lapack_int* n, - lapack_complex_double* ap, double* w, - lapack_complex_double* z, lapack_int* ldz, - lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_sspevd( char* jobz, char* uplo, lapack_int* n, float* ap, float* w, - float* z, lapack_int* ldz, float* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* liwork, lapack_int *info ); -void LAPACK_dspevd( char* jobz, char* uplo, lapack_int* n, double* ap, - double* w, double* z, lapack_int* ldz, double* work, - lapack_int* lwork, lapack_int* iwork, lapack_int* liwork, - lapack_int *info ); -void LAPACK_chpevd( char* jobz, char* uplo, lapack_int* n, - lapack_complex_float* ap, float* w, lapack_complex_float* z, - lapack_int* ldz, lapack_complex_float* work, - lapack_int* lwork, float* rwork, lapack_int* lrwork, - lapack_int* iwork, lapack_int* liwork, lapack_int *info ); -void LAPACK_zhpevd( char* jobz, char* uplo, lapack_int* n, - lapack_complex_double* ap, double* w, - lapack_complex_double* z, lapack_int* ldz, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_int* lrwork, lapack_int* iwork, - lapack_int* liwork, lapack_int *info ); -void LAPACK_sspevx( char* jobz, char* range, char* uplo, lapack_int* n, - float* ap, float* vl, float* vu, lapack_int* il, - lapack_int* iu, float* abstol, lapack_int* m, float* w, - float* z, lapack_int* ldz, float* work, lapack_int* iwork, - lapack_int* ifail, lapack_int *info ); -void LAPACK_dspevx( char* jobz, char* range, char* uplo, lapack_int* n, - double* ap, double* vl, double* vu, lapack_int* il, - lapack_int* iu, double* abstol, lapack_int* m, double* w, - double* z, lapack_int* ldz, double* work, lapack_int* iwork, - lapack_int* ifail, lapack_int *info ); -void LAPACK_chpevx( char* jobz, char* range, char* uplo, lapack_int* n, - lapack_complex_float* ap, float* vl, float* vu, - lapack_int* il, lapack_int* iu, float* abstol, - lapack_int* m, float* w, lapack_complex_float* z, - lapack_int* ldz, lapack_complex_float* work, float* rwork, - lapack_int* iwork, lapack_int* ifail, lapack_int *info ); -void LAPACK_zhpevx( char* jobz, char* range, char* uplo, lapack_int* n, - lapack_complex_double* ap, double* vl, double* vu, - lapack_int* il, lapack_int* iu, double* abstol, - lapack_int* m, double* w, lapack_complex_double* z, - lapack_int* ldz, lapack_complex_double* work, double* rwork, - lapack_int* iwork, lapack_int* ifail, lapack_int *info ); -void LAPACK_ssbev( char* jobz, char* uplo, lapack_int* n, lapack_int* kd, - float* ab, lapack_int* ldab, float* w, float* z, - lapack_int* ldz, float* work, lapack_int *info ); -void LAPACK_dsbev( char* jobz, char* uplo, lapack_int* n, lapack_int* kd, - double* ab, lapack_int* ldab, double* w, double* z, - lapack_int* ldz, double* work, lapack_int *info ); -void LAPACK_chbev( char* jobz, char* uplo, lapack_int* n, lapack_int* kd, - lapack_complex_float* ab, lapack_int* ldab, float* w, - lapack_complex_float* z, lapack_int* ldz, - lapack_complex_float* work, float* rwork, lapack_int *info ); -void LAPACK_zhbev( char* jobz, char* uplo, lapack_int* n, lapack_int* kd, - lapack_complex_double* ab, lapack_int* ldab, double* w, - lapack_complex_double* z, lapack_int* ldz, - lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_ssbevd( char* jobz, char* uplo, lapack_int* n, lapack_int* kd, - float* ab, lapack_int* ldab, float* w, float* z, - lapack_int* ldz, float* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* liwork, lapack_int *info ); -void LAPACK_dsbevd( char* jobz, char* uplo, lapack_int* n, lapack_int* kd, - double* ab, lapack_int* ldab, double* w, double* z, - lapack_int* ldz, double* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* liwork, lapack_int *info ); -void LAPACK_chbevd( char* jobz, char* uplo, lapack_int* n, lapack_int* kd, - lapack_complex_float* ab, lapack_int* ldab, float* w, - lapack_complex_float* z, lapack_int* ldz, - lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_int* lrwork, lapack_int* iwork, lapack_int* liwork, - lapack_int *info ); -void LAPACK_zhbevd( char* jobz, char* uplo, lapack_int* n, lapack_int* kd, - lapack_complex_double* ab, lapack_int* ldab, double* w, - lapack_complex_double* z, lapack_int* ldz, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_int* lrwork, lapack_int* iwork, - lapack_int* liwork, lapack_int *info ); -void LAPACK_ssbevx( char* jobz, char* range, char* uplo, lapack_int* n, - lapack_int* kd, float* ab, lapack_int* ldab, float* q, - lapack_int* ldq, float* vl, float* vu, lapack_int* il, - lapack_int* iu, float* abstol, lapack_int* m, float* w, - float* z, lapack_int* ldz, float* work, - lapack_int* iwork, lapack_int* ifail, lapack_int *info ); -void LAPACK_dsbevx( char* jobz, char* range, char* uplo, lapack_int* n, - lapack_int* kd, double* ab, lapack_int* ldab, double* q, - lapack_int* ldq, double* vl, double* vu, lapack_int* il, - lapack_int* iu, double* abstol, lapack_int* m, double* w, - double* z, lapack_int* ldz, double* work, - lapack_int* iwork, lapack_int* ifail, lapack_int *info ); -void LAPACK_chbevx( char* jobz, char* range, char* uplo, lapack_int* n, - lapack_int* kd, lapack_complex_float* ab, lapack_int* ldab, - lapack_complex_float* q, lapack_int* ldq, float* vl, - float* vu, lapack_int* il, lapack_int* iu, float* abstol, - lapack_int* m, float* w, lapack_complex_float* z, - lapack_int* ldz, lapack_complex_float* work, - float* rwork, lapack_int* iwork, lapack_int* ifail, lapack_int *info ); -void LAPACK_zhbevx( char* jobz, char* range, char* uplo, lapack_int* n, - lapack_int* kd, lapack_complex_double* ab, lapack_int* ldab, - lapack_complex_double* q, lapack_int* ldq, double* vl, - double* vu, lapack_int* il, lapack_int* iu, double* abstol, - lapack_int* m, double* w, lapack_complex_double* z, - lapack_int* ldz, lapack_complex_double* work, - double* rwork, lapack_int* iwork, lapack_int* ifail, lapack_int *info ); -void LAPACK_sstev( char* jobz, lapack_int* n, float* d, float* e, float* z, - lapack_int* ldz, float* work, lapack_int *info ); -void LAPACK_dstev( char* jobz, lapack_int* n, double* d, double* e, double* z, - lapack_int* ldz, double* work, lapack_int *info ); -void LAPACK_sstevd( char* jobz, lapack_int* n, float* d, float* e, float* z, - lapack_int* ldz, float* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* liwork, lapack_int *info ); -void LAPACK_dstevd( char* jobz, lapack_int* n, double* d, double* e, double* z, - lapack_int* ldz, double* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* liwork, lapack_int *info ); -void LAPACK_sstevx( char* jobz, char* range, lapack_int* n, float* d, float* e, - float* vl, float* vu, lapack_int* il, lapack_int* iu, - float* abstol, lapack_int* m, float* w, float* z, - lapack_int* ldz, float* work, lapack_int* iwork, - lapack_int* ifail, lapack_int *info ); -void LAPACK_dstevx( char* jobz, char* range, lapack_int* n, double* d, - double* e, double* vl, double* vu, lapack_int* il, - lapack_int* iu, double* abstol, lapack_int* m, double* w, - double* z, lapack_int* ldz, double* work, lapack_int* iwork, - lapack_int* ifail, lapack_int *info ); -void LAPACK_sstevr( char* jobz, char* range, lapack_int* n, float* d, float* e, - float* vl, float* vu, lapack_int* il, lapack_int* iu, - float* abstol, lapack_int* m, float* w, float* z, - lapack_int* ldz, lapack_int* isuppz, float* work, - lapack_int* lwork, lapack_int* iwork, lapack_int* liwork, - lapack_int *info ); -void LAPACK_dstevr( char* jobz, char* range, lapack_int* n, double* d, - double* e, double* vl, double* vu, lapack_int* il, - lapack_int* iu, double* abstol, lapack_int* m, double* w, - double* z, lapack_int* ldz, lapack_int* isuppz, - double* work, lapack_int* lwork, lapack_int* iwork, - lapack_int* liwork, lapack_int *info ); -void LAPACK_sgees( char* jobvs, char* sort, LAPACK_S_SELECT2 select, - lapack_int* n, float* a, lapack_int* lda, lapack_int* sdim, - float* wr, float* wi, float* vs, lapack_int* ldvs, - float* work, lapack_int* lwork, lapack_logical* bwork, - lapack_int *info ); -void LAPACK_dgees( char* jobvs, char* sort, LAPACK_D_SELECT2 select, - lapack_int* n, double* a, lapack_int* lda, lapack_int* sdim, - double* wr, double* wi, double* vs, lapack_int* ldvs, - double* work, lapack_int* lwork, lapack_logical* bwork, - lapack_int *info ); -void LAPACK_cgees( char* jobvs, char* sort, LAPACK_C_SELECT1 select, - lapack_int* n, lapack_complex_float* a, lapack_int* lda, - lapack_int* sdim, lapack_complex_float* w, - lapack_complex_float* vs, lapack_int* ldvs, - lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_logical* bwork, lapack_int *info ); -void LAPACK_zgees( char* jobvs, char* sort, LAPACK_Z_SELECT1 select, - lapack_int* n, lapack_complex_double* a, lapack_int* lda, - lapack_int* sdim, lapack_complex_double* w, - lapack_complex_double* vs, lapack_int* ldvs, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_logical* bwork, lapack_int *info ); -void LAPACK_sgeesx( char* jobvs, char* sort, LAPACK_S_SELECT2 select, - char* sense, lapack_int* n, float* a, lapack_int* lda, - lapack_int* sdim, float* wr, float* wi, float* vs, - lapack_int* ldvs, float* rconde, float* rcondv, float* work, - lapack_int* lwork, lapack_int* iwork, lapack_int* liwork, - lapack_logical* bwork, lapack_int *info ); -void LAPACK_dgeesx( char* jobvs, char* sort, LAPACK_D_SELECT2 select, - char* sense, lapack_int* n, double* a, lapack_int* lda, - lapack_int* sdim, double* wr, double* wi, double* vs, - lapack_int* ldvs, double* rconde, double* rcondv, - double* work, lapack_int* lwork, lapack_int* iwork, - lapack_int* liwork, lapack_logical* bwork, - lapack_int *info ); -void LAPACK_cgeesx( char* jobvs, char* sort, LAPACK_C_SELECT1 select, - char* sense, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_int* sdim, lapack_complex_float* w, - lapack_complex_float* vs, lapack_int* ldvs, float* rconde, - float* rcondv, lapack_complex_float* work, - lapack_int* lwork, float* rwork, lapack_logical* bwork, - lapack_int *info ); -void LAPACK_zgeesx( char* jobvs, char* sort, LAPACK_Z_SELECT1 select, - char* sense, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_int* sdim, lapack_complex_double* w, - lapack_complex_double* vs, lapack_int* ldvs, double* rconde, - double* rcondv, lapack_complex_double* work, - lapack_int* lwork, double* rwork, lapack_logical* bwork, - lapack_int *info ); -void LAPACK_sgeev( char* jobvl, char* jobvr, lapack_int* n, float* a, - lapack_int* lda, float* wr, float* wi, float* vl, - lapack_int* ldvl, float* vr, lapack_int* ldvr, float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_dgeev( char* jobvl, char* jobvr, lapack_int* n, double* a, - lapack_int* lda, double* wr, double* wi, double* vl, - lapack_int* ldvl, double* vr, lapack_int* ldvr, double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_cgeev( char* jobvl, char* jobvr, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* w, lapack_complex_float* vl, - lapack_int* ldvl, lapack_complex_float* vr, lapack_int* ldvr, - lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_int *info ); -void LAPACK_zgeev( char* jobvl, char* jobvr, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* w, lapack_complex_double* vl, - lapack_int* ldvl, lapack_complex_double* vr, - lapack_int* ldvr, lapack_complex_double* work, - lapack_int* lwork, double* rwork, lapack_int *info ); -void LAPACK_sgeevx( char* balanc, char* jobvl, char* jobvr, char* sense, - lapack_int* n, float* a, lapack_int* lda, float* wr, - float* wi, float* vl, lapack_int* ldvl, float* vr, - lapack_int* ldvr, lapack_int* ilo, lapack_int* ihi, - float* scale, float* abnrm, float* rconde, float* rcondv, - float* work, lapack_int* lwork, lapack_int* iwork, - lapack_int *info ); -void LAPACK_dgeevx( char* balanc, char* jobvl, char* jobvr, char* sense, - lapack_int* n, double* a, lapack_int* lda, double* wr, - double* wi, double* vl, lapack_int* ldvl, double* vr, - lapack_int* ldvr, lapack_int* ilo, lapack_int* ihi, - double* scale, double* abnrm, double* rconde, - double* rcondv, double* work, lapack_int* lwork, - lapack_int* iwork, lapack_int *info ); -void LAPACK_cgeevx( char* balanc, char* jobvl, char* jobvr, char* sense, - lapack_int* n, lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* w, lapack_complex_float* vl, - lapack_int* ldvl, lapack_complex_float* vr, - lapack_int* ldvr, lapack_int* ilo, lapack_int* ihi, - float* scale, float* abnrm, float* rconde, float* rcondv, - lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_int *info ); -void LAPACK_zgeevx( char* balanc, char* jobvl, char* jobvr, char* sense, - lapack_int* n, lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* w, lapack_complex_double* vl, - lapack_int* ldvl, lapack_complex_double* vr, - lapack_int* ldvr, lapack_int* ilo, lapack_int* ihi, - double* scale, double* abnrm, double* rconde, - double* rcondv, lapack_complex_double* work, - lapack_int* lwork, double* rwork, lapack_int *info ); -void LAPACK_sgesvd( char* jobu, char* jobvt, lapack_int* m, lapack_int* n, - float* a, lapack_int* lda, float* s, float* u, - lapack_int* ldu, float* vt, lapack_int* ldvt, float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_dgesvd( char* jobu, char* jobvt, lapack_int* m, lapack_int* n, - double* a, lapack_int* lda, double* s, double* u, - lapack_int* ldu, double* vt, lapack_int* ldvt, double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_cgesvd( char* jobu, char* jobvt, lapack_int* m, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, float* s, - lapack_complex_float* u, lapack_int* ldu, - lapack_complex_float* vt, lapack_int* ldvt, - lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_int *info ); -void LAPACK_zgesvd( char* jobu, char* jobvt, lapack_int* m, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, double* s, - lapack_complex_double* u, lapack_int* ldu, - lapack_complex_double* vt, lapack_int* ldvt, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_int *info ); -void LAPACK_sgesvdx( char* jobu, char* jobvt, char* range, lapack_int* m, lapack_int* n, - float* a, lapack_int* lda, float* vl, float* vu, - lapack_int* il, lapack_int* iu, lapack_int* ns, float* s, float* u, - lapack_int* ldu, float* vt, lapack_int* ldvt, float* work, - lapack_int* lwork, lapack_int *iwork, lapack_int *info ); -void LAPACK_dgesvdx( char* jobu, char* jobvt, char* range, lapack_int* m, lapack_int* n, - double* a, lapack_int* lda, double* vl, double* vu, - lapack_int* il, lapack_int* iu, lapack_int* ns, double* s, double* u, - lapack_int* ldu, double* vt, lapack_int* ldvt, double* work, - lapack_int* lwork, lapack_int *iwork, lapack_int *info ); -void LAPACK_cgesvdx( char* jobu, char* jobvt, char* range, lapack_int* m, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, float* vl, float* vu, - lapack_int* il, lapack_int* iu, lapack_int* ns, float* s, - lapack_complex_float* u, lapack_int* ldu, - lapack_complex_float* vt, lapack_int* ldvt, - lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_int *iwork, lapack_int *info ); -void LAPACK_zgesvdx( char* jobu, char* jobvt, char* range, lapack_int* m, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, double* vl, double* vu, - lapack_int* il, lapack_int* iu, lapack_int* ns, double* s, - lapack_complex_double* u, lapack_int* ldu, - lapack_complex_double* vt, lapack_int* ldvt, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_int *iwork, lapack_int *info ); -void LAPACK_sgesdd( char* jobz, lapack_int* m, lapack_int* n, float* a, - lapack_int* lda, float* s, float* u, lapack_int* ldu, - float* vt, lapack_int* ldvt, float* work, lapack_int* lwork, - lapack_int* iwork, lapack_int *info ); -void LAPACK_dgesdd( char* jobz, lapack_int* m, lapack_int* n, double* a, - lapack_int* lda, double* s, double* u, lapack_int* ldu, - double* vt, lapack_int* ldvt, double* work, - lapack_int* lwork, lapack_int* iwork, lapack_int *info ); -void LAPACK_cgesdd( char* jobz, lapack_int* m, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, float* s, - lapack_complex_float* u, lapack_int* ldu, - lapack_complex_float* vt, lapack_int* ldvt, - lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_int* iwork, lapack_int *info ); -void LAPACK_zgesdd( char* jobz, lapack_int* m, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, double* s, - lapack_complex_double* u, lapack_int* ldu, - lapack_complex_double* vt, lapack_int* ldvt, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_int* iwork, lapack_int *info ); -void LAPACK_dgejsv( char* joba, char* jobu, char* jobv, char* jobr, char* jobt, - char* jobp, lapack_int* m, lapack_int* n, double* a, - lapack_int* lda, double* sva, double* u, lapack_int* ldu, - double* v, lapack_int* ldv, double* work, lapack_int* lwork, - lapack_int* iwork, lapack_int *info ); -void LAPACK_sgejsv( char* joba, char* jobu, char* jobv, char* jobr, char* jobt, - char* jobp, lapack_int* m, lapack_int* n, float* a, - lapack_int* lda, float* sva, float* u, lapack_int* ldu, - float* v, lapack_int* ldv, float* work, lapack_int* lwork, - lapack_int* iwork, lapack_int *info ); -void LAPACK_cgejsv( char* joba, char* jobu, char* jobv, char* jobr, char* jobt, - char* jobp, lapack_int* m, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, float* sva, lapack_complex_float* u, lapack_int* ldu, - lapack_complex_float* v, lapack_int* ldv, lapack_complex_float* cwork, - lapack_int* lwork, float* work, lapack_int* lrwork, - lapack_int* iwork, lapack_int *info ); -void LAPACK_zgejsv( char* joba, char* jobu, char* jobv, char* jobr, char* jobt, - char* jobp, lapack_int* m, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, double* sva, lapack_complex_double* u, lapack_int* ldu, - lapack_complex_double* v, lapack_int* ldv, lapack_complex_double* cwork, - lapack_int* lwork, double* work, lapack_int* lrwork, - lapack_int* iwork, lapack_int *info ); -void LAPACK_dgesvj( char* joba, char* jobu, char* jobv, lapack_int* m, - lapack_int* n, double* a, lapack_int* lda, double* sva, - lapack_int* mv, double* v, lapack_int* ldv, double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_sgesvj( char* joba, char* jobu, char* jobv, lapack_int* m, - lapack_int* n, float* a, lapack_int* lda, float* sva, - lapack_int* mv, float* v, lapack_int* ldv, float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_cgesvj( char* joba, char* jobu, char* jobv, lapack_int* m, - lapack_int* n, lapack_complex_float* a, lapack_int* lda, float* sva, - lapack_int* mv, lapack_complex_float* v, lapack_int* ldv, - lapack_complex_float* cwork, lapack_int* lwork, float* rwork, - lapack_int* lrwork, lapack_int *info ); -void LAPACK_zgesvj( char* joba, char* jobu, char* jobv, lapack_int* m, - lapack_int* n, lapack_complex_double* a, lapack_int* lda, double* sva, - lapack_int* mv, lapack_complex_double* v, lapack_int* ldv, - lapack_complex_double* cwork, lapack_int* lwork, double* rwork, - lapack_int* lrwork, lapack_int *info ); -void LAPACK_sggsvd( char* jobu, char* jobv, char* jobq, lapack_int* m, - lapack_int* n, lapack_int* p, lapack_int* k, lapack_int* l, - float* a, lapack_int* lda, float* b, lapack_int* ldb, - float* alpha, float* beta, float* u, lapack_int* ldu, - float* v, lapack_int* ldv, float* q, lapack_int* ldq, - float* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_dggsvd( char* jobu, char* jobv, char* jobq, lapack_int* m, - lapack_int* n, lapack_int* p, lapack_int* k, lapack_int* l, - double* a, lapack_int* lda, double* b, lapack_int* ldb, - double* alpha, double* beta, double* u, lapack_int* ldu, - double* v, lapack_int* ldv, double* q, lapack_int* ldq, - double* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_cggsvd( char* jobu, char* jobv, char* jobq, lapack_int* m, - lapack_int* n, lapack_int* p, lapack_int* k, lapack_int* l, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, float* alpha, - float* beta, lapack_complex_float* u, lapack_int* ldu, - lapack_complex_float* v, lapack_int* ldv, - lapack_complex_float* q, lapack_int* ldq, - lapack_complex_float* work, float* rwork, lapack_int* iwork, - lapack_int *info ); -void LAPACK_zggsvd( char* jobu, char* jobv, char* jobq, lapack_int* m, - lapack_int* n, lapack_int* p, lapack_int* k, lapack_int* l, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, double* alpha, - double* beta, lapack_complex_double* u, lapack_int* ldu, - lapack_complex_double* v, lapack_int* ldv, - lapack_complex_double* q, lapack_int* ldq, - lapack_complex_double* work, double* rwork, - lapack_int* iwork, lapack_int *info ); -void LAPACK_sggsvd3( char* jobu, char* jobv, char* jobq, lapack_int* m, - lapack_int* n, lapack_int* p, lapack_int* k, lapack_int* l, - float* a, lapack_int* lda, float* b, lapack_int* ldb, - float* alpha, float* beta, float* u, lapack_int* ldu, - float* v, lapack_int* ldv, float* q, lapack_int* ldq, - float* work, lapack_int* lwork, lapack_int* iwork, - lapack_int *info ); -void LAPACK_dggsvd3( char* jobu, char* jobv, char* jobq, lapack_int* m, - lapack_int* n, lapack_int* p, lapack_int* k, lapack_int* l, - double* a, lapack_int* lda, double* b, lapack_int* ldb, - double* alpha, double* beta, double* u, lapack_int* ldu, - double* v, lapack_int* ldv, double* q, lapack_int* ldq, - double* work, lapack_int* lwork, lapack_int* iwork, - lapack_int *info ); -void LAPACK_cggsvd3( char* jobu, char* jobv, char* jobq, lapack_int* m, - lapack_int* n, lapack_int* p, lapack_int* k, lapack_int* l, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, float* alpha, - float* beta, lapack_complex_float* u, lapack_int* ldu, - lapack_complex_float* v, lapack_int* ldv, - lapack_complex_float* q, lapack_int* ldq, - lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_int* iwork, lapack_int *info ); -void LAPACK_zggsvd3( char* jobu, char* jobv, char* jobq, lapack_int* m, - lapack_int* n, lapack_int* p, lapack_int* k, lapack_int* l, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, double* alpha, - double* beta, lapack_complex_double* u, lapack_int* ldu, - lapack_complex_double* v, lapack_int* ldv, - lapack_complex_double* q, lapack_int* ldq, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_int* iwork, lapack_int *info ); -void LAPACK_ssygv( lapack_int* itype, char* jobz, char* uplo, lapack_int* n, - float* a, lapack_int* lda, float* b, lapack_int* ldb, - float* w, float* work, lapack_int* lwork, lapack_int *info ); -void LAPACK_dsygv( lapack_int* itype, char* jobz, char* uplo, lapack_int* n, - double* a, lapack_int* lda, double* b, lapack_int* ldb, - double* w, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_chegv( lapack_int* itype, char* jobz, char* uplo, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, float* w, - lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_int *info ); -void LAPACK_zhegv( lapack_int* itype, char* jobz, char* uplo, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, double* w, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_int *info ); -void LAPACK_ssygvd( lapack_int* itype, char* jobz, char* uplo, lapack_int* n, - float* a, lapack_int* lda, float* b, lapack_int* ldb, - float* w, float* work, lapack_int* lwork, lapack_int* iwork, - lapack_int* liwork, lapack_int *info ); -void LAPACK_dsygvd( lapack_int* itype, char* jobz, char* uplo, lapack_int* n, - double* a, lapack_int* lda, double* b, lapack_int* ldb, - double* w, double* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* liwork, lapack_int *info ); -void LAPACK_chegvd( lapack_int* itype, char* jobz, char* uplo, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, float* w, - lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_int* lrwork, lapack_int* iwork, lapack_int* liwork, - lapack_int *info ); -void LAPACK_zhegvd( lapack_int* itype, char* jobz, char* uplo, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, double* w, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_int* lrwork, lapack_int* iwork, - lapack_int* liwork, lapack_int *info ); -void LAPACK_ssygvx( lapack_int* itype, char* jobz, char* range, char* uplo, - lapack_int* n, float* a, lapack_int* lda, float* b, - lapack_int* ldb, float* vl, float* vu, lapack_int* il, - lapack_int* iu, float* abstol, lapack_int* m, float* w, - float* z, lapack_int* ldz, float* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* ifail, lapack_int *info ); -void LAPACK_dsygvx( lapack_int* itype, char* jobz, char* range, char* uplo, - lapack_int* n, double* a, lapack_int* lda, double* b, - lapack_int* ldb, double* vl, double* vu, lapack_int* il, - lapack_int* iu, double* abstol, lapack_int* m, double* w, - double* z, lapack_int* ldz, double* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* ifail, lapack_int *info ); -void LAPACK_chegvx( lapack_int* itype, char* jobz, char* range, char* uplo, - lapack_int* n, lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, float* vl, - float* vu, lapack_int* il, lapack_int* iu, float* abstol, - lapack_int* m, float* w, lapack_complex_float* z, - lapack_int* ldz, lapack_complex_float* work, - lapack_int* lwork, float* rwork, lapack_int* iwork, - lapack_int* ifail, lapack_int *info ); -void LAPACK_zhegvx( lapack_int* itype, char* jobz, char* range, char* uplo, - lapack_int* n, lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, double* vl, - double* vu, lapack_int* il, lapack_int* iu, double* abstol, - lapack_int* m, double* w, lapack_complex_double* z, - lapack_int* ldz, lapack_complex_double* work, - lapack_int* lwork, double* rwork, lapack_int* iwork, - lapack_int* ifail, lapack_int *info ); -void LAPACK_sspgv( lapack_int* itype, char* jobz, char* uplo, lapack_int* n, - float* ap, float* bp, float* w, float* z, lapack_int* ldz, - float* work, lapack_int *info ); -void LAPACK_dspgv( lapack_int* itype, char* jobz, char* uplo, lapack_int* n, - double* ap, double* bp, double* w, double* z, - lapack_int* ldz, double* work, lapack_int *info ); -void LAPACK_chpgv( lapack_int* itype, char* jobz, char* uplo, lapack_int* n, - lapack_complex_float* ap, lapack_complex_float* bp, float* w, - lapack_complex_float* z, lapack_int* ldz, - lapack_complex_float* work, float* rwork, lapack_int *info ); -void LAPACK_zhpgv( lapack_int* itype, char* jobz, char* uplo, lapack_int* n, - lapack_complex_double* ap, lapack_complex_double* bp, - double* w, lapack_complex_double* z, lapack_int* ldz, - lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_sspgvd( lapack_int* itype, char* jobz, char* uplo, lapack_int* n, - float* ap, float* bp, float* w, float* z, lapack_int* ldz, - float* work, lapack_int* lwork, lapack_int* iwork, - lapack_int* liwork, lapack_int *info ); -void LAPACK_dspgvd( lapack_int* itype, char* jobz, char* uplo, lapack_int* n, - double* ap, double* bp, double* w, double* z, - lapack_int* ldz, double* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* liwork, lapack_int *info ); -void LAPACK_chpgvd( lapack_int* itype, char* jobz, char* uplo, lapack_int* n, - lapack_complex_float* ap, lapack_complex_float* bp, - float* w, lapack_complex_float* z, lapack_int* ldz, - lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_int* lrwork, lapack_int* iwork, lapack_int* liwork, - lapack_int *info ); -void LAPACK_zhpgvd( lapack_int* itype, char* jobz, char* uplo, lapack_int* n, - lapack_complex_double* ap, lapack_complex_double* bp, - double* w, lapack_complex_double* z, lapack_int* ldz, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_int* lrwork, lapack_int* iwork, - lapack_int* liwork, lapack_int *info ); -void LAPACK_sspgvx( lapack_int* itype, char* jobz, char* range, char* uplo, - lapack_int* n, float* ap, float* bp, float* vl, float* vu, - lapack_int* il, lapack_int* iu, float* abstol, - lapack_int* m, float* w, float* z, lapack_int* ldz, - float* work, lapack_int* iwork, lapack_int* ifail, - lapack_int *info ); -void LAPACK_dspgvx( lapack_int* itype, char* jobz, char* range, char* uplo, - lapack_int* n, double* ap, double* bp, double* vl, - double* vu, lapack_int* il, lapack_int* iu, double* abstol, - lapack_int* m, double* w, double* z, lapack_int* ldz, - double* work, lapack_int* iwork, lapack_int* ifail, - lapack_int *info ); -void LAPACK_chpgvx( lapack_int* itype, char* jobz, char* range, char* uplo, - lapack_int* n, lapack_complex_float* ap, - lapack_complex_float* bp, float* vl, float* vu, - lapack_int* il, lapack_int* iu, float* abstol, - lapack_int* m, float* w, lapack_complex_float* z, - lapack_int* ldz, lapack_complex_float* work, float* rwork, - lapack_int* iwork, lapack_int* ifail, lapack_int *info ); -void LAPACK_zhpgvx( lapack_int* itype, char* jobz, char* range, char* uplo, - lapack_int* n, lapack_complex_double* ap, - lapack_complex_double* bp, double* vl, double* vu, - lapack_int* il, lapack_int* iu, double* abstol, - lapack_int* m, double* w, lapack_complex_double* z, - lapack_int* ldz, lapack_complex_double* work, double* rwork, - lapack_int* iwork, lapack_int* ifail, lapack_int *info ); -void LAPACK_ssbgv( char* jobz, char* uplo, lapack_int* n, lapack_int* ka, - lapack_int* kb, float* ab, lapack_int* ldab, float* bb, - lapack_int* ldbb, float* w, float* z, lapack_int* ldz, - float* work, lapack_int *info ); -void LAPACK_dsbgv( char* jobz, char* uplo, lapack_int* n, lapack_int* ka, - lapack_int* kb, double* ab, lapack_int* ldab, double* bb, - lapack_int* ldbb, double* w, double* z, lapack_int* ldz, - double* work, lapack_int *info ); -void LAPACK_chbgv( char* jobz, char* uplo, lapack_int* n, lapack_int* ka, - lapack_int* kb, lapack_complex_float* ab, lapack_int* ldab, - lapack_complex_float* bb, lapack_int* ldbb, float* w, - lapack_complex_float* z, lapack_int* ldz, - lapack_complex_float* work, float* rwork, lapack_int *info ); -void LAPACK_zhbgv( char* jobz, char* uplo, lapack_int* n, lapack_int* ka, - lapack_int* kb, lapack_complex_double* ab, lapack_int* ldab, - lapack_complex_double* bb, lapack_int* ldbb, double* w, - lapack_complex_double* z, lapack_int* ldz, - lapack_complex_double* work, double* rwork, - lapack_int *info ); -void LAPACK_ssbgvd( char* jobz, char* uplo, lapack_int* n, lapack_int* ka, - lapack_int* kb, float* ab, lapack_int* ldab, float* bb, - lapack_int* ldbb, float* w, float* z, lapack_int* ldz, - float* work, lapack_int* lwork, lapack_int* iwork, - lapack_int* liwork, lapack_int *info ); -void LAPACK_dsbgvd( char* jobz, char* uplo, lapack_int* n, lapack_int* ka, - lapack_int* kb, double* ab, lapack_int* ldab, double* bb, - lapack_int* ldbb, double* w, double* z, lapack_int* ldz, - double* work, lapack_int* lwork, lapack_int* iwork, - lapack_int* liwork, lapack_int *info ); -void LAPACK_chbgvd( char* jobz, char* uplo, lapack_int* n, lapack_int* ka, - lapack_int* kb, lapack_complex_float* ab, lapack_int* ldab, - lapack_complex_float* bb, lapack_int* ldbb, float* w, - lapack_complex_float* z, lapack_int* ldz, - lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_int* lrwork, lapack_int* iwork, lapack_int* liwork, - lapack_int *info ); -void LAPACK_zhbgvd( char* jobz, char* uplo, lapack_int* n, lapack_int* ka, - lapack_int* kb, lapack_complex_double* ab, lapack_int* ldab, - lapack_complex_double* bb, lapack_int* ldbb, double* w, - lapack_complex_double* z, lapack_int* ldz, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_int* lrwork, lapack_int* iwork, - lapack_int* liwork, lapack_int *info ); -void LAPACK_ssbgvx( char* jobz, char* range, char* uplo, lapack_int* n, - lapack_int* ka, lapack_int* kb, float* ab, lapack_int* ldab, - float* bb, lapack_int* ldbb, float* q, lapack_int* ldq, - float* vl, float* vu, lapack_int* il, lapack_int* iu, - float* abstol, lapack_int* m, float* w, float* z, - lapack_int* ldz, float* work, lapack_int* iwork, - lapack_int* ifail, lapack_int *info ); -void LAPACK_dsbgvx( char* jobz, char* range, char* uplo, lapack_int* n, - lapack_int* ka, lapack_int* kb, double* ab, - lapack_int* ldab, double* bb, lapack_int* ldbb, double* q, - lapack_int* ldq, double* vl, double* vu, lapack_int* il, - lapack_int* iu, double* abstol, lapack_int* m, double* w, - double* z, lapack_int* ldz, double* work, lapack_int* iwork, - lapack_int* ifail, lapack_int *info ); -void LAPACK_chbgvx( char* jobz, char* range, char* uplo, lapack_int* n, - lapack_int* ka, lapack_int* kb, lapack_complex_float* ab, - lapack_int* ldab, lapack_complex_float* bb, - lapack_int* ldbb, lapack_complex_float* q, lapack_int* ldq, - float* vl, float* vu, lapack_int* il, lapack_int* iu, - float* abstol, lapack_int* m, float* w, - lapack_complex_float* z, lapack_int* ldz, - lapack_complex_float* work, float* rwork, lapack_int* iwork, - lapack_int* ifail, lapack_int *info ); -void LAPACK_zhbgvx( char* jobz, char* range, char* uplo, lapack_int* n, - lapack_int* ka, lapack_int* kb, lapack_complex_double* ab, - lapack_int* ldab, lapack_complex_double* bb, - lapack_int* ldbb, lapack_complex_double* q, lapack_int* ldq, - double* vl, double* vu, lapack_int* il, lapack_int* iu, - double* abstol, lapack_int* m, double* w, - lapack_complex_double* z, lapack_int* ldz, - lapack_complex_double* work, double* rwork, - lapack_int* iwork, lapack_int* ifail, lapack_int *info ); -void LAPACK_sgges( char* jobvsl, char* jobvsr, char* sort, - LAPACK_S_SELECT3 selctg, lapack_int* n, float* a, - lapack_int* lda, float* b, lapack_int* ldb, lapack_int* sdim, - float* alphar, float* alphai, float* beta, float* vsl, - lapack_int* ldvsl, float* vsr, lapack_int* ldvsr, - float* work, lapack_int* lwork, lapack_logical* bwork, - lapack_int *info ); -void LAPACK_dgges( char* jobvsl, char* jobvsr, char* sort, - LAPACK_D_SELECT3 selctg, lapack_int* n, double* a, - lapack_int* lda, double* b, lapack_int* ldb, - lapack_int* sdim, double* alphar, double* alphai, - double* beta, double* vsl, lapack_int* ldvsl, double* vsr, - lapack_int* ldvsr, double* work, lapack_int* lwork, - lapack_logical* bwork, lapack_int *info ); -void LAPACK_cgges( char* jobvsl, char* jobvsr, char* sort, - LAPACK_C_SELECT2 selctg, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, lapack_int* sdim, - lapack_complex_float* alpha, lapack_complex_float* beta, - lapack_complex_float* vsl, lapack_int* ldvsl, - lapack_complex_float* vsr, lapack_int* ldvsr, - lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_logical* bwork, lapack_int *info ); -void LAPACK_zgges( char* jobvsl, char* jobvsr, char* sort, - LAPACK_Z_SELECT2 selctg, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, lapack_int* sdim, - lapack_complex_double* alpha, lapack_complex_double* beta, - lapack_complex_double* vsl, lapack_int* ldvsl, - lapack_complex_double* vsr, lapack_int* ldvsr, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_logical* bwork, lapack_int *info ); -void LAPACK_sgges3( char* jobvsl, char* jobvsr, char* sort, - LAPACK_S_SELECT3 selctg, lapack_int* n, - float* a, lapack_int* lda, float* b, lapack_int* ldb, - lapack_int* sdim, float* alphar, float* alphai, - float* beta, float* vsl, lapack_int* ldvsl, - float* vsr, lapack_int* ldvsr, - float* work, lapack_int* lwork, lapack_logical* bwork, - lapack_int *info ); -void LAPACK_dgges3( char* jobvsl, char* jobvsr, char* sort, - LAPACK_D_SELECT3 selctg, lapack_int* n, double* a, - lapack_int* lda, double* b, lapack_int* ldb, - lapack_int* sdim, double* alphar, double* alphai, - double* beta, double* vsl, lapack_int* ldvsl, double* vsr, - lapack_int* ldvsr, double* work, lapack_int* lwork, - lapack_logical* bwork, lapack_int *info ); -void LAPACK_cgges3( char* jobvsl, char* jobvsr, char* sort, - LAPACK_C_SELECT2 selctg, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, - lapack_int* sdim, - lapack_complex_float* alpha, lapack_complex_float* beta, - lapack_complex_float* vsl, lapack_int* ldvsl, - lapack_complex_float* vsr, lapack_int* ldvsr, - lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_logical* bwork, lapack_int *info ); -void LAPACK_zgges3( char* jobvsl, char* jobvsr, char* sort, - LAPACK_Z_SELECT2 selctg, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, lapack_int* sdim, - lapack_complex_double* alpha, lapack_complex_double* beta, - lapack_complex_double* vsl, lapack_int* ldvsl, - lapack_complex_double* vsr, lapack_int* ldvsr, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_logical* bwork, lapack_int *info ); -void LAPACK_sggesx( char* jobvsl, char* jobvsr, char* sort, - LAPACK_S_SELECT3 selctg, char* sense, lapack_int* n, - float* a, lapack_int* lda, float* b, lapack_int* ldb, - lapack_int* sdim, float* alphar, float* alphai, float* beta, - float* vsl, lapack_int* ldvsl, float* vsr, - lapack_int* ldvsr, float* rconde, float* rcondv, - float* work, lapack_int* lwork, lapack_int* iwork, - lapack_int* liwork, lapack_logical* bwork, - lapack_int *info ); -void LAPACK_dggesx( char* jobvsl, char* jobvsr, char* sort, - LAPACK_D_SELECT3 selctg, char* sense, lapack_int* n, - double* a, lapack_int* lda, double* b, lapack_int* ldb, - lapack_int* sdim, double* alphar, double* alphai, - double* beta, double* vsl, lapack_int* ldvsl, double* vsr, - lapack_int* ldvsr, double* rconde, double* rcondv, - double* work, lapack_int* lwork, lapack_int* iwork, - lapack_int* liwork, lapack_logical* bwork, - lapack_int *info ); -void LAPACK_cggesx( char* jobvsl, char* jobvsr, char* sort, - LAPACK_C_SELECT2 selctg, char* sense, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, lapack_int* sdim, - lapack_complex_float* alpha, lapack_complex_float* beta, - lapack_complex_float* vsl, lapack_int* ldvsl, - lapack_complex_float* vsr, lapack_int* ldvsr, float* rconde, - float* rcondv, lapack_complex_float* work, - lapack_int* lwork, float* rwork, lapack_int* iwork, - lapack_int* liwork, lapack_logical* bwork, - lapack_int *info ); -void LAPACK_zggesx( char* jobvsl, char* jobvsr, char* sort, - LAPACK_Z_SELECT2 selctg, char* sense, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, lapack_int* sdim, - lapack_complex_double* alpha, lapack_complex_double* beta, - lapack_complex_double* vsl, lapack_int* ldvsl, - lapack_complex_double* vsr, lapack_int* ldvsr, - double* rconde, double* rcondv, lapack_complex_double* work, - lapack_int* lwork, double* rwork, lapack_int* iwork, - lapack_int* liwork, lapack_logical* bwork, - lapack_int *info ); -void LAPACK_sggev( char* jobvl, char* jobvr, lapack_int* n, float* a, - lapack_int* lda, float* b, lapack_int* ldb, float* alphar, - float* alphai, float* beta, float* vl, lapack_int* ldvl, - float* vr, lapack_int* ldvr, float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_dggev( char* jobvl, char* jobvr, lapack_int* n, double* a, - lapack_int* lda, double* b, lapack_int* ldb, double* alphar, - double* alphai, double* beta, double* vl, lapack_int* ldvl, - double* vr, lapack_int* ldvr, double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_cggev( char* jobvl, char* jobvr, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* alpha, lapack_complex_float* beta, - lapack_complex_float* vl, lapack_int* ldvl, - lapack_complex_float* vr, lapack_int* ldvr, - lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_int *info ); -void LAPACK_zggev( char* jobvl, char* jobvr, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* alpha, lapack_complex_double* beta, - lapack_complex_double* vl, lapack_int* ldvl, - lapack_complex_double* vr, lapack_int* ldvr, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_int *info ); -void LAPACK_sggev3( char* jobvl, char* jobvr, lapack_int* n, float* a, - lapack_int* lda, float* b, lapack_int* ldb, float* alphar, - float* alphai, float* beta, float* vl, lapack_int* ldvl, - float* vr, lapack_int* ldvr, float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_dggev3( char* jobvl, char* jobvr, lapack_int* n, double* a, - lapack_int* lda, double* b, lapack_int* ldb, double* alphar, - double* alphai, double* beta, double* vl, lapack_int* ldvl, - double* vr, lapack_int* ldvr, double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_cggev3( char* jobvl, char* jobvr, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* alpha, lapack_complex_float* beta, - lapack_complex_float* vl, lapack_int* ldvl, - lapack_complex_float* vr, lapack_int* ldvr, - lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_int *info ); -void LAPACK_zggev3( char* jobvl, char* jobvr, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* alpha, lapack_complex_double* beta, - lapack_complex_double* vl, lapack_int* ldvl, - lapack_complex_double* vr, lapack_int* ldvr, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_int *info ); -void LAPACK_sggevx( char* balanc, char* jobvl, char* jobvr, char* sense, - lapack_int* n, float* a, lapack_int* lda, float* b, - lapack_int* ldb, float* alphar, float* alphai, float* beta, - float* vl, lapack_int* ldvl, float* vr, lapack_int* ldvr, - lapack_int* ilo, lapack_int* ihi, float* lscale, - float* rscale, float* abnrm, float* bbnrm, float* rconde, - float* rcondv, float* work, lapack_int* lwork, - lapack_int* iwork, lapack_logical* bwork, - lapack_int *info ); -void LAPACK_dggevx( char* balanc, char* jobvl, char* jobvr, char* sense, - lapack_int* n, double* a, lapack_int* lda, double* b, - lapack_int* ldb, double* alphar, double* alphai, - double* beta, double* vl, lapack_int* ldvl, double* vr, - lapack_int* ldvr, lapack_int* ilo, lapack_int* ihi, - double* lscale, double* rscale, double* abnrm, - double* bbnrm, double* rconde, double* rcondv, double* work, - lapack_int* lwork, lapack_int* iwork, lapack_logical* bwork, - lapack_int *info ); -void LAPACK_cggevx( char* balanc, char* jobvl, char* jobvr, char* sense, - lapack_int* n, lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* alpha, lapack_complex_float* beta, - lapack_complex_float* vl, lapack_int* ldvl, - lapack_complex_float* vr, lapack_int* ldvr, lapack_int* ilo, - lapack_int* ihi, float* lscale, float* rscale, float* abnrm, - float* bbnrm, float* rconde, float* rcondv, - lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_int* iwork, lapack_logical* bwork, - lapack_int *info ); -void LAPACK_zggevx( char* balanc, char* jobvl, char* jobvr, char* sense, - lapack_int* n, lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* alpha, lapack_complex_double* beta, - lapack_complex_double* vl, lapack_int* ldvl, - lapack_complex_double* vr, lapack_int* ldvr, - lapack_int* ilo, lapack_int* ihi, double* lscale, - double* rscale, double* abnrm, double* bbnrm, - double* rconde, double* rcondv, lapack_complex_double* work, - lapack_int* lwork, double* rwork, lapack_int* iwork, - lapack_logical* bwork, lapack_int *info ); -void LAPACK_dsfrk( char* transr, char* uplo, char* trans, lapack_int* n, - lapack_int* k, double* alpha, const double* a, - lapack_int* lda, double* beta, double* c ); -void LAPACK_ssfrk( char* transr, char* uplo, char* trans, lapack_int* n, - lapack_int* k, float* alpha, const float* a, lapack_int* lda, - float* beta, float* c ); -void LAPACK_zhfrk( char* transr, char* uplo, char* trans, lapack_int* n, - lapack_int* k, double* alpha, const lapack_complex_double* a, - lapack_int* lda, double* beta, lapack_complex_double* c ); -void LAPACK_chfrk( char* transr, char* uplo, char* trans, lapack_int* n, - lapack_int* k, float* alpha, const lapack_complex_float* a, - lapack_int* lda, float* beta, lapack_complex_float* c ); -void LAPACK_dtfsm( char* transr, char* side, char* uplo, char* trans, - char* diag, lapack_int* m, lapack_int* n, double* alpha, - const double* a, double* b, lapack_int* ldb ); -void LAPACK_stfsm( char* transr, char* side, char* uplo, char* trans, - char* diag, lapack_int* m, lapack_int* n, float* alpha, - const float* a, float* b, lapack_int* ldb ); -void LAPACK_ztfsm( char* transr, char* side, char* uplo, char* trans, - char* diag, lapack_int* m, lapack_int* n, - lapack_complex_double* alpha, const lapack_complex_double* a, - lapack_complex_double* b, lapack_int* ldb ); -void LAPACK_ctfsm( char* transr, char* side, char* uplo, char* trans, - char* diag, lapack_int* m, lapack_int* n, - lapack_complex_float* alpha, const lapack_complex_float* a, - lapack_complex_float* b, lapack_int* ldb ); -void LAPACK_dtfttp( char* transr, char* uplo, lapack_int* n, const double* arf, - double* ap, lapack_int *info ); -void LAPACK_stfttp( char* transr, char* uplo, lapack_int* n, const float* arf, - float* ap, lapack_int *info ); -void LAPACK_ztfttp( char* transr, char* uplo, lapack_int* n, - const lapack_complex_double* arf, lapack_complex_double* ap, - lapack_int *info ); -void LAPACK_ctfttp( char* transr, char* uplo, lapack_int* n, - const lapack_complex_float* arf, lapack_complex_float* ap, - lapack_int *info ); -void LAPACK_dtfttr( char* transr, char* uplo, lapack_int* n, const double* arf, - double* a, lapack_int* lda, lapack_int *info ); -void LAPACK_stfttr( char* transr, char* uplo, lapack_int* n, const float* arf, - float* a, lapack_int* lda, lapack_int *info ); -void LAPACK_ztfttr( char* transr, char* uplo, lapack_int* n, - const lapack_complex_double* arf, lapack_complex_double* a, - lapack_int* lda, lapack_int *info ); -void LAPACK_ctfttr( char* transr, char* uplo, lapack_int* n, - const lapack_complex_float* arf, lapack_complex_float* a, - lapack_int* lda, lapack_int *info ); -void LAPACK_dtpttf( char* transr, char* uplo, lapack_int* n, const double* ap, - double* arf, lapack_int *info ); -void LAPACK_stpttf( char* transr, char* uplo, lapack_int* n, const float* ap, - float* arf, lapack_int *info ); -void LAPACK_ztpttf( char* transr, char* uplo, lapack_int* n, - const lapack_complex_double* ap, lapack_complex_double* arf, - lapack_int *info ); -void LAPACK_ctpttf( char* transr, char* uplo, lapack_int* n, - const lapack_complex_float* ap, lapack_complex_float* arf, - lapack_int *info ); -void LAPACK_dtpttr( char* uplo, lapack_int* n, const double* ap, double* a, - lapack_int* lda, lapack_int *info ); -void LAPACK_stpttr( char* uplo, lapack_int* n, const float* ap, float* a, - lapack_int* lda, lapack_int *info ); -void LAPACK_ztpttr( char* uplo, lapack_int* n, const lapack_complex_double* ap, - lapack_complex_double* a, lapack_int* lda, - lapack_int *info ); -void LAPACK_ctpttr( char* uplo, lapack_int* n, const lapack_complex_float* ap, - lapack_complex_float* a, lapack_int* lda, - lapack_int *info ); -void LAPACK_dtrttf( char* transr, char* uplo, lapack_int* n, const double* a, - lapack_int* lda, double* arf, lapack_int *info ); -void LAPACK_strttf( char* transr, char* uplo, lapack_int* n, const float* a, - lapack_int* lda, float* arf, lapack_int *info ); -void LAPACK_ztrttf( char* transr, char* uplo, lapack_int* n, - const lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* arf, lapack_int *info ); -void LAPACK_ctrttf( char* transr, char* uplo, lapack_int* n, - const lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* arf, lapack_int *info ); -void LAPACK_dtrttp( char* uplo, lapack_int* n, const double* a, lapack_int* lda, - double* ap, lapack_int *info ); -void LAPACK_strttp( char* uplo, lapack_int* n, const float* a, lapack_int* lda, - float* ap, lapack_int *info ); -void LAPACK_ztrttp( char* uplo, lapack_int* n, const lapack_complex_double* a, - lapack_int* lda, lapack_complex_double* ap, - lapack_int *info ); -void LAPACK_ctrttp( char* uplo, lapack_int* n, const lapack_complex_float* a, - lapack_int* lda, lapack_complex_float* ap, - lapack_int *info ); -void LAPACK_sgeqrfp( lapack_int* m, lapack_int* n, float* a, lapack_int* lda, - float* tau, float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_dgeqrfp( lapack_int* m, lapack_int* n, double* a, lapack_int* lda, - double* tau, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_cgeqrfp( lapack_int* m, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_complex_float* tau, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zgeqrfp( lapack_int* m, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_complex_double* tau, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_clacgv( lapack_int* n, lapack_complex_float* x, lapack_int* incx ); -void LAPACK_zlacgv( lapack_int* n, lapack_complex_double* x, lapack_int* incx ); -void LAPACK_slarnv( lapack_int* idist, lapack_int* iseed, lapack_int* n, - float* x ); -void LAPACK_dlarnv( lapack_int* idist, lapack_int* iseed, lapack_int* n, - double* x ); -void LAPACK_clarnv( lapack_int* idist, lapack_int* iseed, lapack_int* n, - lapack_complex_float* x ); -void LAPACK_zlarnv( lapack_int* idist, lapack_int* iseed, lapack_int* n, - lapack_complex_double* x ); -void LAPACK_sgeqr2( lapack_int* m, lapack_int* n, float* a, lapack_int* lda, - float* tau, float* work, lapack_int *info ); -void LAPACK_dgeqr2( lapack_int* m, lapack_int* n, double* a, lapack_int* lda, - double* tau, double* work, lapack_int *info ); -void LAPACK_cgeqr2( lapack_int* m, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_complex_float* tau, - lapack_complex_float* work, lapack_int *info ); -void LAPACK_zgeqr2( lapack_int* m, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_complex_double* tau, - lapack_complex_double* work, lapack_int *info ); -void LAPACK_slacn2( lapack_int* n, float* v, float* x, lapack_int* isgn, - float* est, lapack_int* kase, lapack_int* isave ); -void LAPACK_dlacn2( lapack_int* n, double* v, double* x, lapack_int* isgn, - double* est, lapack_int* kase, lapack_int* isave ); -void LAPACK_clacn2( lapack_int* n, lapack_complex_float* v, - lapack_complex_float* x, float* est, - lapack_int* kase, lapack_int* isave ); -void LAPACK_zlacn2( lapack_int* n, lapack_complex_double* v, - lapack_complex_double* x, double* est, - lapack_int* kase, lapack_int* isave ); -void LAPACK_slacpy( char* uplo, lapack_int* m, lapack_int* n, const float* a, - lapack_int* lda, float* b, lapack_int* ldb ); -void LAPACK_dlacpy( char* uplo, lapack_int* m, lapack_int* n, const double* a, - lapack_int* lda, double* b, lapack_int* ldb ); -void LAPACK_clacpy( char* uplo, lapack_int* m, lapack_int* n, - const lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb ); -void LAPACK_zlacpy( char* uplo, lapack_int* m, lapack_int* n, - const lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb ); - -void LAPACK_clacp2( char* uplo, lapack_int* m, lapack_int* n, const float* a, - lapack_int* lda, lapack_complex_float* b, lapack_int* ldb ); -void LAPACK_zlacp2( char* uplo, lapack_int* m, lapack_int* n, const double* a, - lapack_int* lda, lapack_complex_double* b, - lapack_int* ldb ); - -void LAPACK_sgetf2( lapack_int* m, lapack_int* n, float* a, lapack_int* lda, - lapack_int* ipiv, lapack_int *info ); -void LAPACK_dgetf2( lapack_int* m, lapack_int* n, double* a, lapack_int* lda, - lapack_int* ipiv, lapack_int *info ); -void LAPACK_cgetf2( lapack_int* m, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_int* ipiv, lapack_int *info ); -void LAPACK_zgetf2( lapack_int* m, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_int* ipiv, lapack_int *info ); -void LAPACK_slaswp( lapack_int* n, float* a, lapack_int* lda, lapack_int* k1, - lapack_int* k2, const lapack_int* ipiv, lapack_int* incx ); -void LAPACK_dlaswp( lapack_int* n, double* a, lapack_int* lda, lapack_int* k1, - lapack_int* k2, const lapack_int* ipiv, lapack_int* incx ); -void LAPACK_claswp( lapack_int* n, lapack_complex_float* a, lapack_int* lda, - lapack_int* k1, lapack_int* k2, const lapack_int* ipiv, - lapack_int* incx ); -void LAPACK_zlaswp( lapack_int* n, lapack_complex_double* a, lapack_int* lda, - lapack_int* k1, lapack_int* k2, const lapack_int* ipiv, - lapack_int* incx ); -float LAPACK_slange( char* norm, lapack_int* m, lapack_int* n, const float* a, - lapack_int* lda, float* work ); -double LAPACK_dlange( char* norm, lapack_int* m, lapack_int* n, const double* a, - lapack_int* lda, double* work ); -float LAPACK_clange( char* norm, lapack_int* m, lapack_int* n, - const lapack_complex_float* a, lapack_int* lda, float* work ); -double LAPACK_zlange( char* norm, lapack_int* m, lapack_int* n, - const lapack_complex_double* a, lapack_int* lda, double* work ); -float LAPACK_clanhe( char* norm, char* uplo, lapack_int* n, - const lapack_complex_float* a, lapack_int* lda, float* work ); -double LAPACK_zlanhe( char* norm, char* uplo, lapack_int* n, - const lapack_complex_double* a, lapack_int* lda, double* work ); -void LAPACK_clarcm( lapack_int* m, lapack_int* n, const float* a, - lapack_int* lda, const lapack_complex_float* b, - lapack_int* ldb, lapack_complex_float* c, - lapack_int* ldc, float* work ); -void LAPACK_zlarcm( lapack_int* m, lapack_int* n, const double* a, - lapack_int* lda, const lapack_complex_double* b, - lapack_int* ldb, lapack_complex_double* c, - lapack_int* ldc, double* work ); -void LAPACK_clacrm( lapack_int* m, lapack_int* n, const lapack_complex_float* a, - lapack_int* lda, const float* b, - lapack_int* ldb, lapack_complex_float* c, - lapack_int* ldc, float* work ); -void LAPACK_zlacrm( lapack_int* m, lapack_int* n, const lapack_complex_double* a, - lapack_int* lda, const double* b, - lapack_int* ldb, lapack_complex_double* c, - lapack_int* ldc, double* work ); -float LAPACK_slansy( char* norm, char* uplo, lapack_int* n, const float* a, - lapack_int* lda, float* work ); -double LAPACK_dlansy( char* norm, char* uplo, lapack_int* n, const double* a, - lapack_int* lda, double* work ); -float LAPACK_clansy( char* norm, char* uplo, lapack_int* n, - const lapack_complex_float* a, lapack_int* lda, float* work ); -double LAPACK_zlansy( char* norm, char* uplo, lapack_int* n, - const lapack_complex_double* a, lapack_int* lda, double* work ); -float LAPACK_slantr( char* norm, char* uplo, char* diag, lapack_int* m, - lapack_int* n, const float* a, lapack_int* lda, float* work ); -double LAPACK_dlantr( char* norm, char* uplo, char* diag, lapack_int* m, - lapack_int* n, const double* a, lapack_int* lda, double* work ); -float LAPACK_clantr( char* norm, char* uplo, char* diag, lapack_int* m, - lapack_int* n, const lapack_complex_float* a, lapack_int* lda, - float* work ); -double LAPACK_zlantr( char* norm, char* uplo, char* diag, lapack_int* m, - lapack_int* n, const lapack_complex_double* a, lapack_int* lda, - double* work ); -float LAPACK_slamch( char* cmach ); -double LAPACK_dlamch( char* cmach ); -void LAPACK_sgelq2( lapack_int* m, lapack_int* n, float* a, lapack_int* lda, - float* tau, float* work, lapack_int *info ); -void LAPACK_dgelq2( lapack_int* m, lapack_int* n, double* a, lapack_int* lda, - double* tau, double* work, lapack_int *info ); -void LAPACK_cgelq2( lapack_int* m, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_complex_float* tau, - lapack_complex_float* work, lapack_int *info ); -void LAPACK_zgelq2( lapack_int* m, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_complex_double* tau, - lapack_complex_double* work, lapack_int *info ); -void LAPACK_slarfb( char* side, char* trans, char* direct, char* storev, - lapack_int* m, lapack_int* n, lapack_int* k, const float* v, - lapack_int* ldv, const float* t, lapack_int* ldt, float* c, - lapack_int* ldc, float* work, lapack_int* ldwork ); -void LAPACK_dlarfb( char* side, char* trans, char* direct, char* storev, - lapack_int* m, lapack_int* n, lapack_int* k, - const double* v, lapack_int* ldv, const double* t, - lapack_int* ldt, double* c, lapack_int* ldc, double* work, - lapack_int* ldwork ); -void LAPACK_clarfb( char* side, char* trans, char* direct, char* storev, - lapack_int* m, lapack_int* n, lapack_int* k, - const lapack_complex_float* v, lapack_int* ldv, - const lapack_complex_float* t, lapack_int* ldt, - lapack_complex_float* c, lapack_int* ldc, - lapack_complex_float* work, lapack_int* ldwork ); -void LAPACK_zlarfb( char* side, char* trans, char* direct, char* storev, - lapack_int* m, lapack_int* n, lapack_int* k, - const lapack_complex_double* v, lapack_int* ldv, - const lapack_complex_double* t, lapack_int* ldt, - lapack_complex_double* c, lapack_int* ldc, - lapack_complex_double* work, lapack_int* ldwork ); -void LAPACK_slarfg( lapack_int* n, float* alpha, float* x, lapack_int* incx, - float* tau ); -void LAPACK_dlarfg( lapack_int* n, double* alpha, double* x, lapack_int* incx, - double* tau ); -void LAPACK_clarfg( lapack_int* n, lapack_complex_float* alpha, - lapack_complex_float* x, lapack_int* incx, - lapack_complex_float* tau ); -void LAPACK_zlarfg( lapack_int* n, lapack_complex_double* alpha, - lapack_complex_double* x, lapack_int* incx, - lapack_complex_double* tau ); -void LAPACK_slassq( lapack_int *n, float* x, lapack_int *incx, float* scale, float* sumsq ); -void LAPACK_dlassq( lapack_int *n, double* x, lapack_int *incx, double* scale, double* sumsq ); -void LAPACK_classq( lapack_int *n, lapack_complex_float* x, lapack_int *incx, float* scale, float* sumsq ); -void LAPACK_zlassq( lapack_int *n, lapack_complex_double* x, lapack_int *incx, double* scale, double* sumsq ); -void LAPACK_slarft( char* direct, char* storev, lapack_int* n, lapack_int* k, - const float* v, lapack_int* ldv, const float* tau, float* t, - lapack_int* ldt ); -void LAPACK_dlarft( char* direct, char* storev, lapack_int* n, lapack_int* k, - const double* v, lapack_int* ldv, const double* tau, - double* t, lapack_int* ldt ); -void LAPACK_clarft( char* direct, char* storev, lapack_int* n, lapack_int* k, - const lapack_complex_float* v, lapack_int* ldv, - const lapack_complex_float* tau, lapack_complex_float* t, - lapack_int* ldt ); -void LAPACK_zlarft( char* direct, char* storev, lapack_int* n, lapack_int* k, - const lapack_complex_double* v, lapack_int* ldv, - const lapack_complex_double* tau, lapack_complex_double* t, - lapack_int* ldt ); -void LAPACK_slarfx( char* side, lapack_int* m, lapack_int* n, const float* v, - float* tau, float* c, lapack_int* ldc, float* work ); -void LAPACK_dlarfx( char* side, lapack_int* m, lapack_int* n, const double* v, - double* tau, double* c, lapack_int* ldc, double* work ); -void LAPACK_clarfx( char* side, lapack_int* m, lapack_int* n, - const lapack_complex_float* v, lapack_complex_float* tau, - lapack_complex_float* c, lapack_int* ldc, - lapack_complex_float* work ); -void LAPACK_zlarfx( char* side, lapack_int* m, lapack_int* n, - const lapack_complex_double* v, lapack_complex_double* tau, - lapack_complex_double* c, lapack_int* ldc, - lapack_complex_double* work ); -void LAPACK_slatms( lapack_int* m, lapack_int* n, char* dist, lapack_int* iseed, - char* sym, float* d, lapack_int* mode, float* cond, - float* dmax, lapack_int* kl, lapack_int* ku, char* pack, - float* a, lapack_int* lda, float* work, lapack_int *info ); -void LAPACK_dlatms( lapack_int* m, lapack_int* n, char* dist, lapack_int* iseed, - char* sym, double* d, lapack_int* mode, double* cond, - double* dmax, lapack_int* kl, lapack_int* ku, char* pack, - double* a, lapack_int* lda, double* work, - lapack_int *info ); -void LAPACK_clatms( lapack_int* m, lapack_int* n, char* dist, lapack_int* iseed, - char* sym, float* d, lapack_int* mode, float* cond, - float* dmax, lapack_int* kl, lapack_int* ku, char* pack, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* work, lapack_int *info ); -void LAPACK_zlatms( lapack_int* m, lapack_int* n, char* dist, lapack_int* iseed, - char* sym, double* d, lapack_int* mode, double* cond, - double* dmax, lapack_int* kl, lapack_int* ku, char* pack, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* work, lapack_int *info ); -void LAPACK_slag2d( lapack_int* m, lapack_int* n, const float* sa, - lapack_int* ldsa, double* a, lapack_int* lda, - lapack_int *info ); -void LAPACK_dlag2s( lapack_int* m, lapack_int* n, const double* a, - lapack_int* lda, float* sa, lapack_int* ldsa, - lapack_int *info ); -void LAPACK_clag2z( lapack_int* m, lapack_int* n, - const lapack_complex_float* sa, lapack_int* ldsa, - lapack_complex_double* a, lapack_int* lda, - lapack_int *info ); -void LAPACK_zlag2c( lapack_int* m, lapack_int* n, - const lapack_complex_double* a, lapack_int* lda, - lapack_complex_float* sa, lapack_int* ldsa, - lapack_int *info ); -void LAPACK_slauum( char* uplo, lapack_int* n, float* a, lapack_int* lda, - lapack_int *info ); -void LAPACK_dlauum( char* uplo, lapack_int* n, double* a, lapack_int* lda, - lapack_int *info ); -void LAPACK_clauum( char* uplo, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_int *info ); -void LAPACK_zlauum( char* uplo, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_int *info ); -void LAPACK_slagge( lapack_int* m, lapack_int* n, lapack_int* kl, - lapack_int* ku, const float* d, float* a, lapack_int* lda, - lapack_int* iseed, float* work, lapack_int *info ); -void LAPACK_dlagge( lapack_int* m, lapack_int* n, lapack_int* kl, - lapack_int* ku, const double* d, double* a, lapack_int* lda, - lapack_int* iseed, double* work, lapack_int *info ); -void LAPACK_clagge( lapack_int* m, lapack_int* n, lapack_int* kl, - lapack_int* ku, const float* d, lapack_complex_float* a, - lapack_int* lda, lapack_int* iseed, - lapack_complex_float* work, lapack_int *info ); -void LAPACK_zlagge( lapack_int* m, lapack_int* n, lapack_int* kl, - lapack_int* ku, const double* d, lapack_complex_double* a, - lapack_int* lda, lapack_int* iseed, - lapack_complex_double* work, lapack_int *info ); -void LAPACK_slascl( char* type, lapack_int* kl, lapack_int* ku, float* cfrom, - float* cto, lapack_int* m, lapack_int* n, float* a, - lapack_int* lda, lapack_int *info ); -void LAPACK_dlascl( char* type, lapack_int* kl, lapack_int* ku, double* cfrom, - double* cto, lapack_int* m, lapack_int* n, double* a, - lapack_int* lda, lapack_int *info ); -void LAPACK_clascl( char* type, lapack_int* kl, lapack_int* ku, float* cfrom, - float* cto, lapack_int* m, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_int *info ); -void LAPACK_zlascl( char* type, lapack_int* kl, lapack_int* ku, double* cfrom, - double* cto, lapack_int* m, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_int *info ); -void LAPACK_slaset( char* uplo, lapack_int* m, lapack_int* n, float* alpha, - float* beta, float* a, lapack_int* lda ); -void LAPACK_dlaset( char* uplo, lapack_int* m, lapack_int* n, double* alpha, - double* beta, double* a, lapack_int* lda ); -void LAPACK_claset( char* uplo, lapack_int* m, lapack_int* n, - lapack_complex_float* alpha, lapack_complex_float* beta, - lapack_complex_float* a, lapack_int* lda ); -void LAPACK_zlaset( char* uplo, lapack_int* m, lapack_int* n, - lapack_complex_double* alpha, lapack_complex_double* beta, - lapack_complex_double* a, lapack_int* lda ); -void LAPACK_slasrt( char* id, lapack_int* n, float* d, lapack_int *info ); -void LAPACK_dlasrt( char* id, lapack_int* n, double* d, lapack_int *info ); -void LAPACK_claghe( lapack_int* n, lapack_int* k, const float* d, - lapack_complex_float* a, lapack_int* lda, lapack_int* iseed, - lapack_complex_float* work, lapack_int *info ); -void LAPACK_zlaghe( lapack_int* n, lapack_int* k, const double* d, - lapack_complex_double* a, lapack_int* lda, - lapack_int* iseed, lapack_complex_double* work, - lapack_int *info ); -void LAPACK_slagsy( lapack_int* n, lapack_int* k, const float* d, float* a, - lapack_int* lda, lapack_int* iseed, float* work, - lapack_int *info ); -void LAPACK_dlagsy( lapack_int* n, lapack_int* k, const double* d, double* a, - lapack_int* lda, lapack_int* iseed, double* work, - lapack_int *info ); -void LAPACK_clagsy( lapack_int* n, lapack_int* k, const float* d, - lapack_complex_float* a, lapack_int* lda, lapack_int* iseed, - lapack_complex_float* work, lapack_int *info ); -void LAPACK_zlagsy( lapack_int* n, lapack_int* k, const double* d, - lapack_complex_double* a, lapack_int* lda, - lapack_int* iseed, lapack_complex_double* work, - lapack_int *info ); -void LAPACK_slapmr( lapack_logical* forwrd, lapack_int* m, lapack_int* n, - float* x, lapack_int* ldx, lapack_int* k ); -void LAPACK_dlapmr( lapack_logical* forwrd, lapack_int* m, lapack_int* n, - double* x, lapack_int* ldx, lapack_int* k ); -void LAPACK_clapmr( lapack_logical* forwrd, lapack_int* m, lapack_int* n, - lapack_complex_float* x, lapack_int* ldx, lapack_int* k ); -void LAPACK_zlapmr( lapack_logical* forwrd, lapack_int* m, lapack_int* n, - lapack_complex_double* x, lapack_int* ldx, lapack_int* k ); -void LAPACK_slapmt( lapack_logical* forwrd, lapack_int* m, lapack_int* n, - float* x, lapack_int* ldx, lapack_int* k ); -void LAPACK_dlapmt( lapack_logical* forwrd, lapack_int* m, lapack_int* n, - double* x, lapack_int* ldx, lapack_int* k ); -void LAPACK_clapmt( lapack_logical* forwrd, lapack_int* m, lapack_int* n, - lapack_complex_float* x, lapack_int* ldx, lapack_int* k ); -void LAPACK_zlapmt( lapack_logical* forwrd, lapack_int* m, lapack_int* n, - lapack_complex_double* x, lapack_int* ldx, lapack_int* k ); -float LAPACK_slapy2( float* x, float* y ); -double LAPACK_dlapy2( double* x, double* y ); -float LAPACK_slapy3( float* x, float* y, float* z ); -double LAPACK_dlapy3( double* x, double* y, double* z ); -void LAPACK_slartgp( float* f, float* g, float* cs, float* sn, float* r ); -void LAPACK_dlartgp( double* f, double* g, double* cs, double* sn, double* r ); -void LAPACK_slartgs( float* x, float* y, float* sigma, float* cs, float* sn ); -void LAPACK_dlartgs( double* x, double* y, double* sigma, double* cs, - double* sn ); -// LAPACK 3.3.0 -void LAPACK_cbbcsd( char* jobu1, char* jobu2, - char* jobv1t, char* jobv2t, char* trans, - lapack_int* m, lapack_int* p, lapack_int* q, - float* theta, float* phi, - lapack_complex_float* u1, lapack_int* ldu1, - lapack_complex_float* u2, lapack_int* ldu2, - lapack_complex_float* v1t, lapack_int* ldv1t, - lapack_complex_float* v2t, lapack_int* ldv2t, - float* b11d, float* b11e, float* b12d, - float* b12e, float* b21d, float* b21e, - float* b22d, float* b22e, float* rwork, - lapack_int* lrwork , lapack_int *info ); -void LAPACK_cheswapr( char* uplo, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_int* i1, lapack_int* i2 ); -void LAPACK_chetri2( char* uplo, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, - const lapack_int* ipiv, - lapack_complex_float* work, lapack_int* lwork , lapack_int *info ); -void LAPACK_chetri2x( char* uplo, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, - const lapack_int* ipiv, - lapack_complex_float* work, lapack_int* nb , lapack_int *info ); -void LAPACK_chetrs2( char* uplo, lapack_int* n, - lapack_int* nrhs, const lapack_complex_float* a, - lapack_int* lda, const lapack_int* ipiv, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* work , lapack_int *info ); -void LAPACK_csyconv( char* uplo, char* way, - lapack_int* n, lapack_complex_float* a, - lapack_int* lda, const lapack_int* ipiv, - lapack_complex_float* e , lapack_int *info ); -void LAPACK_csyswapr( char* uplo, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, - lapack_int* i1, lapack_int* i2 ); -void LAPACK_csytri2( char* uplo, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, - const lapack_int* ipiv, - lapack_complex_float* work, lapack_int* lwork , lapack_int *info ); -void LAPACK_csytri2x( char* uplo, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, - const lapack_int* ipiv, - lapack_complex_float* work, lapack_int* nb , lapack_int *info ); -void LAPACK_csytrs2( char* uplo, lapack_int* n, - lapack_int* nrhs, const lapack_complex_float* a, - lapack_int* lda, const lapack_int* ipiv, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* work , lapack_int *info ); -void LAPACK_cunbdb( char* trans, char* signs, - lapack_int* m, lapack_int* p, lapack_int* q, - lapack_complex_float* x11, lapack_int* ldx11, - lapack_complex_float* x12, lapack_int* ldx12, - lapack_complex_float* x21, lapack_int* ldx21, - lapack_complex_float* x22, lapack_int* ldx22, - float* theta, float* phi, - lapack_complex_float* taup1, - lapack_complex_float* taup2, - lapack_complex_float* tauq1, - lapack_complex_float* tauq2, - lapack_complex_float* work, lapack_int* lwork , lapack_int *info ); -void LAPACK_cuncsd( char* jobu1, char* jobu2, - char* jobv1t, char* jobv2t, char* trans, - char* signs, lapack_int* m, lapack_int* p, - lapack_int* q, lapack_complex_float* x11, - lapack_int* ldx11, lapack_complex_float* x12, - lapack_int* ldx12, lapack_complex_float* x21, - lapack_int* ldx21, lapack_complex_float* x22, - lapack_int* ldx22, float* theta, - lapack_complex_float* u1, lapack_int* ldu1, - lapack_complex_float* u2, lapack_int* ldu2, - lapack_complex_float* v1t, lapack_int* ldv1t, - lapack_complex_float* v2t, lapack_int* ldv2t, - lapack_complex_float* work, lapack_int* lwork, - float* rwork, lapack_int* lrwork, - lapack_int* iwork , lapack_int *info ); -void LAPACK_cuncsd2by1( char* jobu1, char* jobu2, - char* jobv1t, lapack_int* m, lapack_int* p, - lapack_int* q, lapack_complex_float* x11, - lapack_int* ldx11, lapack_complex_float* x21, - lapack_int* ldx21, float* theta, - lapack_complex_float* u1, lapack_int* ldu1, - lapack_complex_float* u2, lapack_int* ldu2, - lapack_complex_float* v1t, lapack_int* ldv1t, - lapack_complex_float* work, lapack_int* lwork, - float* rwork, lapack_int* lrwork, - lapack_int* iwork , lapack_int *info ); -void LAPACK_dbbcsd( char* jobu1, char* jobu2, - char* jobv1t, char* jobv2t, char* trans, - lapack_int* m, lapack_int* p, lapack_int* q, - double* theta, double* phi, double* u1, - lapack_int* ldu1, double* u2, lapack_int* ldu2, - double* v1t, lapack_int* ldv1t, double* v2t, - lapack_int* ldv2t, double* b11d, double* b11e, - double* b12d, double* b12e, double* b21d, - double* b21e, double* b22d, double* b22e, - double* work, lapack_int* lwork , lapack_int *info ); -void LAPACK_dorbdb( char* trans, char* signs, - lapack_int* m, lapack_int* p, lapack_int* q, - double* x11, lapack_int* ldx11, double* x12, - lapack_int* ldx12, double* x21, lapack_int* ldx21, - double* x22, lapack_int* ldx22, double* theta, - double* phi, double* taup1, double* taup2, - double* tauq1, double* tauq2, double* work, - lapack_int* lwork , lapack_int *info ); -void LAPACK_dorcsd( char* jobu1, char* jobu2, - char* jobv1t, char* jobv2t, char* trans, - char* signs, lapack_int* m, lapack_int* p, - lapack_int* q, double* x11, lapack_int* ldx11, - double* x12, lapack_int* ldx12, double* x21, - lapack_int* ldx21, double* x22, lapack_int* ldx22, - double* theta, double* u1, lapack_int* ldu1, - double* u2, lapack_int* ldu2, double* v1t, - lapack_int* ldv1t, double* v2t, lapack_int* ldv2t, - double* work, lapack_int* lwork, - lapack_int* iwork , lapack_int *info ); -void LAPACK_dorcsd2by1( char* jobu1, char* jobu2, - char* jobv1t, lapack_int* m, lapack_int* p, - lapack_int* q, double* x11, lapack_int* ldx11, - double* x21, lapack_int* ldx21, - double* theta, double* u1, lapack_int* ldu1, - double* u2, lapack_int* ldu2, double* v1t, - lapack_int* ldv1t, double* work, lapack_int* lwork, - lapack_int* iwork , lapack_int *info ); -void LAPACK_dsyconv( char* uplo, char* way, - lapack_int* n, double* a, lapack_int* lda, - const lapack_int* ipiv, double* e , lapack_int *info ); -void LAPACK_dsyswapr( char* uplo, lapack_int* n, double* a, - lapack_int* lda, lapack_int* i1, lapack_int* i2 ); -void LAPACK_dsytri2( char* uplo, lapack_int* n, - double* a, lapack_int* lda, - const lapack_int* ipiv, - double* work, lapack_int* lwork , lapack_int *info ); -void LAPACK_dsytri2x( char* uplo, lapack_int* n, - double* a, lapack_int* lda, - const lapack_int* ipiv, double* work, - lapack_int* nb , lapack_int *info ); -void LAPACK_dsytrs2( char* uplo, lapack_int* n, - lapack_int* nrhs, const double* a, - lapack_int* lda, const lapack_int* ipiv, - double* b, lapack_int* ldb, double* work , lapack_int *info ); -void LAPACK_sbbcsd( char* jobu1, char* jobu2, - char* jobv1t, char* jobv2t, char* trans, - lapack_int* m, lapack_int* p, lapack_int* q, - float* theta, float* phi, float* u1, - lapack_int* ldu1, float* u2, lapack_int* ldu2, - float* v1t, lapack_int* ldv1t, float* v2t, - lapack_int* ldv2t, float* b11d, float* b11e, - float* b12d, float* b12e, float* b21d, - float* b21e, float* b22d, float* b22e, - float* work, lapack_int* lwork , lapack_int *info ); -void LAPACK_sorbdb( char* trans, char* signs, - lapack_int* m, lapack_int* p, lapack_int* q, - float* x11, lapack_int* ldx11, float* x12, - lapack_int* ldx12, float* x21, lapack_int* ldx21, - float* x22, lapack_int* ldx22, float* theta, - float* phi, float* taup1, float* taup2, - float* tauq1, float* tauq2, float* work, - lapack_int* lwork , lapack_int *info ); -void LAPACK_sorcsd( char* jobu1, char* jobu2, - char* jobv1t, char* jobv2t, char* trans, - char* signs, lapack_int* m, lapack_int* p, - lapack_int* q, float* x11, lapack_int* ldx11, - float* x12, lapack_int* ldx12, float* x21, - lapack_int* ldx21, float* x22, lapack_int* ldx22, - float* theta, float* u1, lapack_int* ldu1, - float* u2, lapack_int* ldu2, float* v1t, - lapack_int* ldv1t, float* v2t, lapack_int* ldv2t, - float* work, lapack_int* lwork, - lapack_int* iwork , lapack_int *info ); -void LAPACK_sorcsd2by1( char* jobu1, char* jobu2, - char* jobv1t, lapack_int* m, lapack_int* p, - lapack_int* q, float* x11, lapack_int* ldx11, - float* x21, lapack_int* ldx21, - float* theta, float* u1, lapack_int* ldu1, - float* u2, lapack_int* ldu2, float* v1t, - lapack_int* ldv1t, float* work, lapack_int* lwork, - lapack_int* iwork , lapack_int *info ); -void LAPACK_ssyconv( char* uplo, char* way, - lapack_int* n, float* a, lapack_int* lda, - const lapack_int* ipiv, float* e , lapack_int *info ); -void LAPACK_ssyswapr( char* uplo, lapack_int* n, float* a, - lapack_int* lda, lapack_int* i1, lapack_int* i2 ); -void LAPACK_ssytri2( char* uplo, lapack_int* n, - float* a, lapack_int* lda, - const lapack_int* ipiv, - float* work, lapack_int* lwork , lapack_int *info ); -void LAPACK_ssytri2x( char* uplo, lapack_int* n, - float* a, lapack_int* lda, - const lapack_int* ipiv, float* work, - lapack_int* nb , lapack_int *info ); -void LAPACK_ssytrs2( char* uplo, lapack_int* n, - lapack_int* nrhs, const float* a, - lapack_int* lda, const lapack_int* ipiv, - float* b, lapack_int* ldb, float* work , lapack_int *info ); -void LAPACK_zbbcsd( char* jobu1, char* jobu2, - char* jobv1t, char* jobv2t, char* trans, - lapack_int* m, lapack_int* p, lapack_int* q, - double* theta, double* phi, - lapack_complex_double* u1, lapack_int* ldu1, - lapack_complex_double* u2, lapack_int* ldu2, - lapack_complex_double* v1t, lapack_int* ldv1t, - lapack_complex_double* v2t, lapack_int* ldv2t, - double* b11d, double* b11e, double* b12d, - double* b12e, double* b21d, double* b21e, - double* b22d, double* b22e, double* rwork, - lapack_int* lrwork , lapack_int *info ); -void LAPACK_zheswapr( char* uplo, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_int* i1, lapack_int* i2 ); -void LAPACK_zhetri2( char* uplo, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, - const lapack_int* ipiv, - lapack_complex_double* work, lapack_int* lwork , lapack_int *info ); -void LAPACK_zhetri2x( char* uplo, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, - const lapack_int* ipiv, - lapack_complex_double* work, lapack_int* nb , lapack_int *info ); -void LAPACK_zhetrs2( char* uplo, lapack_int* n, - lapack_int* nrhs, - const lapack_complex_double* a, lapack_int* lda, - const lapack_int* ipiv, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* work , lapack_int *info ); -void LAPACK_zsyconv( char* uplo, char* way, - lapack_int* n, lapack_complex_double* a, - lapack_int* lda, const lapack_int* ipiv, - lapack_complex_double* e , lapack_int *info ); -void LAPACK_zsyswapr( char* uplo, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_int* i1, - lapack_int* i2 ); -void LAPACK_zsytri2( char* uplo, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, - const lapack_int* ipiv, - lapack_complex_double* work, lapack_int* lwork , lapack_int *info ); -void LAPACK_zsytri2x( char* uplo, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, - const lapack_int* ipiv, - lapack_complex_double* work, lapack_int* nb , lapack_int *info ); -void LAPACK_zsytrs2( char* uplo, lapack_int* n, - lapack_int* nrhs, - const lapack_complex_double* a, lapack_int* lda, - const lapack_int* ipiv, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* work , lapack_int *info ); -void LAPACK_zunbdb( char* trans, char* signs, - lapack_int* m, lapack_int* p, lapack_int* q, - lapack_complex_double* x11, lapack_int* ldx11, - lapack_complex_double* x12, lapack_int* ldx12, - lapack_complex_double* x21, lapack_int* ldx21, - lapack_complex_double* x22, lapack_int* ldx22, - double* theta, double* phi, - lapack_complex_double* taup1, - lapack_complex_double* taup2, - lapack_complex_double* tauq1, - lapack_complex_double* tauq2, - lapack_complex_double* work, lapack_int* lwork , lapack_int *info ); -void LAPACK_zuncsd( char* jobu1, char* jobu2, - char* jobv1t, char* jobv2t, char* trans, - char* signs, lapack_int* m, lapack_int* p, - lapack_int* q, lapack_complex_double* x11, - lapack_int* ldx11, lapack_complex_double* x12, - lapack_int* ldx12, lapack_complex_double* x21, - lapack_int* ldx21, lapack_complex_double* x22, - lapack_int* ldx22, double* theta, - lapack_complex_double* u1, lapack_int* ldu1, - lapack_complex_double* u2, lapack_int* ldu2, - lapack_complex_double* v1t, lapack_int* ldv1t, - lapack_complex_double* v2t, lapack_int* ldv2t, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_int* lrwork, - lapack_int* iwork , lapack_int *info ); -void LAPACK_zuncsd2by1( char* jobu1, char* jobu2, - char* jobv1t, lapack_int* m, lapack_int* p, - lapack_int* q, lapack_complex_double* x11, - lapack_int* ldx11, lapack_complex_double* x21, - lapack_int* ldx21, double* theta, - lapack_complex_double* u1, lapack_int* ldu1, - lapack_complex_double* u2, lapack_int* ldu2, - lapack_complex_double* v1t, lapack_int* ldv1t, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_int* lrwork, - lapack_int* iwork , lapack_int *info ); -// LAPACK 3.4.0 -void LAPACK_sgemqrt( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* k, lapack_int* nb, const float* v, - lapack_int* ldv, const float* t, lapack_int* ldt, float* c, - lapack_int* ldc, float* work, lapack_int *info ); -void LAPACK_dgemqrt( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* k, lapack_int* nb, const double* v, - lapack_int* ldv, const double* t, lapack_int* ldt, - double* c, lapack_int* ldc, double* work, - lapack_int *info ); -void LAPACK_cgemqrt( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* k, lapack_int* nb, - const lapack_complex_float* v, lapack_int* ldv, - const lapack_complex_float* t, lapack_int* ldt, - lapack_complex_float* c, lapack_int* ldc, - lapack_complex_float* work, lapack_int *info ); -void LAPACK_zgemqrt( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* k, lapack_int* nb, - const lapack_complex_double* v, lapack_int* ldv, - const lapack_complex_double* t, lapack_int* ldt, - lapack_complex_double* c, lapack_int* ldc, - lapack_complex_double* work, lapack_int *info ); -void LAPACK_sgeqrt( lapack_int* m, lapack_int* n, lapack_int* nb, float* a, - lapack_int* lda, float* t, lapack_int* ldt, float* work, - lapack_int *info ); -void LAPACK_dgeqrt( lapack_int* m, lapack_int* n, lapack_int* nb, double* a, - lapack_int* lda, double* t, lapack_int* ldt, double* work, - lapack_int *info ); -void LAPACK_cgeqrt( lapack_int* m, lapack_int* n, lapack_int* nb, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* t, lapack_int* ldt, - lapack_complex_float* work, lapack_int *info ); -void LAPACK_zgeqrt( lapack_int* m, lapack_int* n, lapack_int* nb, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* t, lapack_int* ldt, - lapack_complex_double* work, lapack_int *info ); -void LAPACK_sgeqrt2( lapack_int* m, lapack_int* n, float* a, lapack_int* lda, - float* t, lapack_int* ldt, lapack_int *info ); -void LAPACK_dgeqrt2( lapack_int* m, lapack_int* n, double* a, lapack_int* lda, - double* t, lapack_int* ldt, lapack_int *info ); -void LAPACK_cgeqrt2( lapack_int* m, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_complex_float* t, lapack_int* ldt, - lapack_int *info ); -void LAPACK_zgeqrt2( lapack_int* m, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_complex_double* t, lapack_int* ldt, - lapack_int *info ); -void LAPACK_sgeqrt3( lapack_int* m, lapack_int* n, float* a, lapack_int* lda, - float* t, lapack_int* ldt, lapack_int *info ); -void LAPACK_dgeqrt3( lapack_int* m, lapack_int* n, double* a, lapack_int* lda, - double* t, lapack_int* ldt, lapack_int *info ); -void LAPACK_cgeqrt3( lapack_int* m, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_complex_float* t, lapack_int* ldt, - lapack_int *info ); -void LAPACK_zgeqrt3( lapack_int* m, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_complex_double* t, lapack_int* ldt, - lapack_int *info ); -void LAPACK_stpmqrt( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* k, lapack_int* l, lapack_int* nb, - const float* v, lapack_int* ldv, const float* t, - lapack_int* ldt, float* a, lapack_int* lda, float* b, - lapack_int* ldb, float* work, lapack_int *info ); -void LAPACK_dtpmqrt( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* k, lapack_int* l, lapack_int* nb, - const double* v, lapack_int* ldv, const double* t, - lapack_int* ldt, double* a, lapack_int* lda, double* b, - lapack_int* ldb, double* work, lapack_int *info ); -void LAPACK_ctpmqrt( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* k, lapack_int* l, lapack_int* nb, - const lapack_complex_float* v, lapack_int* ldv, - const lapack_complex_float* t, lapack_int* ldt, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* work, lapack_int *info ); -void LAPACK_ztpmqrt( char* side, char* trans, lapack_int* m, lapack_int* n, - lapack_int* k, lapack_int* l, lapack_int* nb, - const lapack_complex_double* v, lapack_int* ldv, - const lapack_complex_double* t, lapack_int* ldt, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* work, lapack_int *info ); -void LAPACK_stpqrt( lapack_int* m, lapack_int* n, lapack_int* l, lapack_int* nb, - float* a, lapack_int* lda, float* b, lapack_int* ldb, - float* t, lapack_int* ldt, float* work, lapack_int *info ); -void LAPACK_dtpqrt( lapack_int* m, lapack_int* n, lapack_int* l, lapack_int* nb, - double* a, lapack_int* lda, double* b, lapack_int* ldb, - double* t, lapack_int* ldt, double* work, - lapack_int *info ); -void LAPACK_ctpqrt( lapack_int* m, lapack_int* n, lapack_int* l, lapack_int* nb, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* t, lapack_int* ldt, - lapack_complex_float* work, lapack_int *info ); -void LAPACK_ztpqrt( lapack_int* m, lapack_int* n, lapack_int* l, lapack_int* nb, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* t, lapack_int* ldt, - lapack_complex_double* work, lapack_int *info ); -void LAPACK_stpqrt2( lapack_int* m, lapack_int* n, lapack_int* l, - float* a, lapack_int* lda, - float* b, lapack_int* ldb, - float* t, lapack_int* ldt, - lapack_int *info ); -void LAPACK_dtpqrt2( lapack_int* m, lapack_int* n, lapack_int* l, - double* a, lapack_int* lda, - double* b, lapack_int* ldb, - double* t, lapack_int* ldt, - lapack_int *info ); -void LAPACK_ctpqrt2( lapack_int* m, lapack_int* n, lapack_int* l, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* t, lapack_int* ldt, - lapack_int *info ); -void LAPACK_ztpqrt2( lapack_int* m, lapack_int* n, lapack_int* l, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* t, lapack_int* ldt, - lapack_int *info ); -void LAPACK_stprfb( char* side, char* trans, char* direct, char* storev, - lapack_int* m, lapack_int* n, lapack_int* k, lapack_int* l, - const float* v, lapack_int* ldv, const float* t, - lapack_int* ldt, float* a, lapack_int* lda, float* b, - lapack_int* ldb, const float* work, - lapack_int* ldwork ); -void LAPACK_dtprfb( char* side, char* trans, char* direct, char* storev, - lapack_int* m, lapack_int* n, lapack_int* k, lapack_int* l, - const double* v, lapack_int* ldv, const double* t, - lapack_int* ldt, double* a, lapack_int* lda, double* b, - lapack_int* ldb, const double* work, - lapack_int* ldwork ); -void LAPACK_ctprfb( char* side, char* trans, char* direct, char* storev, - lapack_int* m, lapack_int* n, lapack_int* k, lapack_int* l, - const lapack_complex_float* v, lapack_int* ldv, - const lapack_complex_float* t, lapack_int* ldt, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* work, lapack_int* ldwork ); -void LAPACK_ztprfb( char* side, char* trans, char* direct, char* storev, - lapack_int* m, lapack_int* n, lapack_int* k, lapack_int* l, - const lapack_complex_double* v, lapack_int* ldv, - const lapack_complex_double* t, lapack_int* ldt, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* work, lapack_int* ldwork ); -// LAPACK 3.5.0 -void LAPACK_ssysv_rook( char* uplo, lapack_int* n, lapack_int* nrhs, float* a, - lapack_int* lda, lapack_int* ipiv, float* b, - lapack_int* ldb, float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_ssytrf_rook( char* uplo, lapack_int* n, float* a, lapack_int* lda, - lapack_int* ipiv, float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_dsysv_rook( char* uplo, lapack_int* n, lapack_int* nrhs, double* a, - lapack_int* lda, lapack_int* ipiv, double* b, - lapack_int* ldb, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_dsytrf_rook( char* uplo, lapack_int* n, double* a, lapack_int* lda, - lapack_int* ipiv, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_csysv_rook( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_float* a, lapack_int* lda, - lapack_int* ipiv, lapack_complex_float* b, - lapack_int* ldb, lapack_complex_float* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_csytrf_rook( char* uplo, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_int* ipiv, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zsysv_rook( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_double* a, lapack_int* lda, - lapack_int* ipiv, lapack_complex_double* b, - lapack_int* ldb, lapack_complex_double* work, - lapack_int* lwork, lapack_int *info ); -void LAPACK_zsytrf_rook( char* uplo, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_int* ipiv, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_ssytrs_rook( char* uplo, lapack_int* n, lapack_int* nrhs, const float* a, - lapack_int* lda, const lapack_int* ipiv, float* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_dsytrs_rook( char* uplo, lapack_int* n, lapack_int* nrhs, - const double* a, lapack_int* lda, const lapack_int* ipiv, - double* b, lapack_int* ldb, lapack_int *info ); -void LAPACK_csytrs_rook( char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_float* a, lapack_int* lda, - const lapack_int* ipiv, lapack_complex_float* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_zsytrs_rook( char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_double* a, lapack_int* lda, - const lapack_int* ipiv, lapack_complex_double* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_chetrf_rook( char* uplo, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_int* ipiv, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zhetrf_rook( char* uplo, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_int* ipiv, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_chetrs_rook( char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_float* a, lapack_int* lda, - const lapack_int* ipiv, lapack_complex_float* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_zhetrs_rook( char* uplo, lapack_int* n, lapack_int* nrhs, - const lapack_complex_double* a, lapack_int* lda, - const lapack_int* ipiv, lapack_complex_double* b, - lapack_int* ldb, lapack_int *info ); - -void LAPACK_csyr( char* uplo, lapack_int* n, lapack_complex_float* alpha, - const lapack_complex_float* x, lapack_int* incx, - lapack_complex_float* a, lapack_int* lda ); -void LAPACK_zsyr( char* uplo, lapack_int* n, lapack_complex_double* alpha, - const lapack_complex_double* x, lapack_int* incx, - lapack_complex_double* a, lapack_int* lda ); -void LAPACK_ilaver( const lapack_int* vers_major, const lapack_int* vers_minor, - const lapack_int* vers_patch ); - -// LAPACK 3.7.0 -void LAPACK_ssysv_aa( char* uplo, lapack_int* n, lapack_int* nrhs, float* a, - lapack_int* lda, lapack_int* ipiv, float* b, lapack_int* ldb, - float* work, lapack_int* lwork, lapack_int *info ); -void LAPACK_dsysv_aa( char* uplo, lapack_int* n, lapack_int* nrhs, double* a, - lapack_int* lda, lapack_int* ipiv, double* b, - lapack_int* ldb, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_csysv_aa( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_float* a, lapack_int* lda, lapack_int* ipiv, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zsysv_aa( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_double* a, lapack_int* lda, lapack_int* ipiv, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_chesv_aa( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_float* a, lapack_int* lda, lapack_int* ipiv, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zhesv_aa( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_double* a, lapack_int* lda, lapack_int* ipiv, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); - -void LAPACK_ssytrf_aa( char* uplo, lapack_int* n, float* a, lapack_int* lda, - lapack_int* ipiv, float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_dsytrf_aa( char* uplo, lapack_int* n, double* a, lapack_int* lda, - lapack_int* ipiv, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_csytrf_aa( char* uplo, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_int* ipiv, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zsytrf_aa( char* uplo, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_int* ipiv, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_chetrf_aa( char* uplo, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_int* ipiv, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zhetrf_aa( char* uplo, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_int* ipiv, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); - -void LAPACK_ssytrs_aa( char* uplo, lapack_int* n, - lapack_int* nrhs, const float* a, - lapack_int* lda, const lapack_int* ipiv, - float* b, lapack_int* ldb, float* work, lapack_int* lwork, lapack_int *info ); -void LAPACK_dsytrs_aa( char* uplo, lapack_int* n, - lapack_int* nrhs, const double* a, - lapack_int* lda, const lapack_int* ipiv, - double* b, lapack_int* ldb, double* work, lapack_int* lwork, lapack_int *info ); -void LAPACK_csytrs_aa( char* uplo, lapack_int* n, - lapack_int* nrhs, const lapack_complex_float* a, - lapack_int* lda, const lapack_int* ipiv, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* work , lapack_int* lwork, lapack_int *info ); -void LAPACK_zsytrs_aa( char* uplo, lapack_int* n, - lapack_int* nrhs, - const lapack_complex_double* a, lapack_int* lda, - const lapack_int* ipiv, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* work, lapack_int* lwork, lapack_int *info ); -void LAPACK_chetrs_aa( char* uplo, lapack_int* n, - lapack_int* nrhs, const lapack_complex_float* a, - lapack_int* lda, const lapack_int* ipiv, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* work , lapack_int* lwork, lapack_int *info ); -void LAPACK_zhetrs_aa( char* uplo, lapack_int* n, - lapack_int* nrhs, - const lapack_complex_double* a, lapack_int* lda, - const lapack_int* ipiv, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* work, lapack_int* lwork, lapack_int *info ); - -void LAPACK_ssysv_rk( char* uplo, lapack_int* n, lapack_int* nrhs, float* a, - lapack_int* lda, float* e, lapack_int* ipiv, float* b, lapack_int* ldb, - float* work, lapack_int* lwork, lapack_int *info ); -void LAPACK_dsysv_rk( char* uplo, lapack_int* n, lapack_int* nrhs, double* a, - lapack_int* lda, double* e, lapack_int* ipiv, double* b, - lapack_int* ldb, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_csysv_rk( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* e, lapack_int* ipiv, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zsysv_rk( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* e, lapack_int* ipiv, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_chesv_rk( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* e, lapack_int* ipiv, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zhesv_rk( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* e, lapack_int* ipiv, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); - -void LAPACK_ssytrf_rk( char* uplo, lapack_int* n, float* a, lapack_int* lda, - float* e, lapack_int* ipiv, float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_dsytrf_rk( char* uplo, lapack_int* n, double* a, lapack_int* lda, - double* e, lapack_int* ipiv, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_csytrf_rk( char* uplo, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_complex_float* e, lapack_int* ipiv, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zsytrf_rk( char* uplo, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_complex_double* e, lapack_int* ipiv, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_chetrf_rk( char* uplo, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, lapack_complex_float* e, lapack_int* ipiv, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zhetrf_rk( char* uplo, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, lapack_complex_double* e, lapack_int* ipiv, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); - -void LAPACK_ssytrs_3( char* uplo, lapack_int* n, - lapack_int* nrhs, const float* a, - lapack_int* lda, const float* e, const lapack_int* ipiv, - float* b, lapack_int* ldb, lapack_int *info ); -void LAPACK_dsytrs_3( char* uplo, lapack_int* n, - lapack_int* nrhs, const double* a, - lapack_int* lda, const double* e, const lapack_int* ipiv, - double* b, lapack_int* ldb, lapack_int *info ); -void LAPACK_csytrs_3( char* uplo, lapack_int* n, - lapack_int* nrhs, const lapack_complex_float* a, - lapack_int* lda, const lapack_complex_float* e, - const lapack_int* ipiv, - lapack_complex_float* b, lapack_int* ldb, lapack_int *info ); -void LAPACK_zsytrs_3( char* uplo, lapack_int* n, - lapack_int* nrhs, - const lapack_complex_double* a, lapack_int* lda, - const lapack_complex_double* e, const lapack_int* ipiv, - lapack_complex_double* b, lapack_int* ldb, lapack_int *info ); -void LAPACK_chetrs_3( char* uplo, lapack_int* n, - lapack_int* nrhs, const lapack_complex_float* a, - lapack_int* lda, const lapack_complex_float* e, - const lapack_int* ipiv, - lapack_complex_float* b, lapack_int* ldb, lapack_int *info ); -void LAPACK_zhetrs_3( char* uplo, lapack_int* n, - lapack_int* nrhs, - const lapack_complex_double* a, lapack_int* lda, - const lapack_complex_double* e, - const lapack_int* ipiv, - lapack_complex_double* b, lapack_int* ldb, lapack_int *info ); - -void LAPACK_ssytri_3( char* uplo, lapack_int* n, float* a, lapack_int* lda, const float* e, - const lapack_int* ipiv, float* work, lapack_int* lwork, lapack_int *info ); -void LAPACK_dsytri_3( char* uplo, lapack_int* n, double* a, lapack_int* lda, const double* e, - const lapack_int* ipiv, double* work, lapack_int* lwork, lapack_int *info ); -void LAPACK_csytri_3( char* uplo, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, const lapack_complex_float* e, const lapack_int* ipiv, - lapack_complex_float* work, lapack_int* lwork, lapack_int *info ); -void LAPACK_zsytri_3( char* uplo, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, const lapack_complex_double* e, const lapack_int* ipiv, - lapack_complex_double* work, lapack_int* lwork, lapack_int *info ); -void LAPACK_chetri_3( char* uplo, lapack_int* n, lapack_complex_float* a, - lapack_int* lda, const lapack_complex_float* e, const lapack_int* ipiv, - lapack_complex_float* work, lapack_int* lwork, lapack_int *info ); -void LAPACK_zhetri_3( char* uplo, lapack_int* n, lapack_complex_double* a, - lapack_int* lda, const lapack_complex_double* e, const lapack_int* ipiv, - lapack_complex_double* work, lapack_int* lwork, lapack_int *info ); - -void LAPACK_ssycon_3( char* uplo, lapack_int* n, const float* a, lapack_int* lda, const float* e, - const lapack_int* ipiv, float* anorm, float* rcond, - float* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_dsycon_3( char* uplo, lapack_int* n, const double* a, lapack_int* lda, const double* e, - const lapack_int* ipiv, double* anorm, double* rcond, - double* work, lapack_int* iwork, lapack_int *info ); -void LAPACK_csycon_3( char* uplo, lapack_int* n, const lapack_complex_float* a, - lapack_int* lda, const lapack_complex_float* e, const lapack_int* ipiv, float* anorm, - float* rcond, lapack_complex_float* work, - lapack_int *info ); -void LAPACK_zsycon_3( char* uplo, lapack_int* n, const lapack_complex_double* a, - lapack_int* lda, const lapack_complex_double* e, const lapack_int* ipiv, double* anorm, - double* rcond, lapack_complex_double* work, - lapack_int *info ); -void LAPACK_checon_3( char* uplo, lapack_int* n, const lapack_complex_float* a, - lapack_int* lda, const lapack_complex_float* e, const lapack_int* ipiv, float* anorm, - float* rcond, lapack_complex_float* work, - lapack_int *info ); -void LAPACK_zhecon_3( char* uplo, lapack_int* n, const lapack_complex_double* a, - lapack_int* lda, const lapack_complex_double* e, const lapack_int* ipiv, double* anorm, - double* rcond, lapack_complex_double* work, - lapack_int *info ); - -void LAPACK_sgelq( lapack_int* m, lapack_int* n, float* a, lapack_int* lda, - float* t, lapack_int* tsize, float* work, lapack_int* lwork, - lapack_int* info ); -void LAPACK_dgelq( lapack_int* m, lapack_int* n, double* a, lapack_int* lda, - double* t, lapack_int* tsize, double* work, lapack_int* lwork, - lapack_int* info ); -void LAPACK_cgelq( lapack_int* m, lapack_int* n, lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* t, lapack_int* tsize, lapack_complex_float* work, lapack_int* lwork, - lapack_int* info ); -void LAPACK_zgelq( lapack_int* m, lapack_int* n, lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* t, lapack_int* tsize, lapack_complex_double* work, lapack_int* lwork, - lapack_int* info ); - -void LAPACK_sgemlq( char* side, char* trans, lapack_int* m, lapack_int* n, lapack_int* k, - const float* a, lapack_int* lda, - const float* t, lapack_int* tsize, - float* c, lapack_int* ldc, - float* work, lapack_int* lwork, - lapack_int* info ); -void LAPACK_dgemlq( char* side, char* trans, lapack_int* m, lapack_int* n, lapack_int* k, - const double* a, lapack_int* lda, - const double* t, lapack_int* tsize, - double* c, lapack_int* ldc, - double* work, lapack_int* lwork, - lapack_int* info ); -void LAPACK_cgemlq( char* side, char* trans, lapack_int* m, lapack_int* n, lapack_int* k, - const lapack_complex_float* a, lapack_int* lda, - const lapack_complex_float* t, lapack_int* tsize, - lapack_complex_float* c, lapack_int* ldc, - lapack_complex_float* work, lapack_int* lwork, - lapack_int* info ); -void LAPACK_zgemlq( char* side, char* trans, lapack_int* m, lapack_int* n, lapack_int* k, - const lapack_complex_double* a, lapack_int* lda, - const lapack_complex_double* t, lapack_int* tsize, - lapack_complex_double* c, lapack_int* ldc, - lapack_complex_double* work, lapack_int* lwork, - lapack_int* info ); - -void LAPACK_sgeqr( lapack_int* m, lapack_int* n, float* a, lapack_int* lda, - float* t, lapack_int* tsize, float* work, lapack_int* lwork, - lapack_int* info ); -void LAPACK_dgeqr( lapack_int* m, lapack_int* n, double* a, lapack_int* lda, - double* t, lapack_int* tsize, double* work, lapack_int* lwork, - lapack_int* info ); -void LAPACK_cgeqr( lapack_int* m, lapack_int* n, lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* t, lapack_int* tsize, lapack_complex_float* work, lapack_int* lwork, - lapack_int* info ); -void LAPACK_zgeqr( lapack_int* m, lapack_int* n, lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* t, lapack_int* tsize, lapack_complex_double* work, lapack_int* lwork, - lapack_int* info ); - -void LAPACK_sgemqr( char* side, char* trans, lapack_int* m, lapack_int* n, lapack_int* k, - const float* a, lapack_int* lda, - const float* t, lapack_int* tsize, - float* c, lapack_int* ldc, - float* work, lapack_int* lwork, - lapack_int* info ); -void LAPACK_dgemqr( char* side, char* trans, lapack_int* m, lapack_int* n, lapack_int* k, - const double* a, lapack_int* lda, - const double* t, lapack_int* tsize, - double* c, lapack_int* ldc, - double* work, lapack_int* lwork, - lapack_int* info ); -void LAPACK_cgemqr( char* side, char* trans, lapack_int* m, lapack_int* n, lapack_int* k, - const lapack_complex_float* a, lapack_int* lda, - const lapack_complex_float* t, lapack_int* tsize, - lapack_complex_float* c, lapack_int* ldc, - lapack_complex_float* work, lapack_int* lwork, - lapack_int* info ); -void LAPACK_zgemqr( char* side, char* trans, lapack_int* m, lapack_int* n, lapack_int* k, - const lapack_complex_double* a, lapack_int* lda, - const lapack_complex_double* t, lapack_int* tsize, - lapack_complex_double* c, lapack_int* ldc, - lapack_complex_double* work, lapack_int* lwork, - lapack_int* info ); - -void LAPACK_sgetsls( char* trans, lapack_int* m, lapack_int* n, lapack_int* nrhs, - float* a, lapack_int* lda, float* b, lapack_int* ldb, - float* work, lapack_int* lwork, lapack_int *info ); -void LAPACK_dgetsls( char* trans, lapack_int* m, lapack_int* n, lapack_int* nrhs, - double* a, lapack_int* lda, double* b, lapack_int* ldb, - double* work, lapack_int* lwork, lapack_int *info ); -void LAPACK_cgetsls( char* trans, lapack_int* m, lapack_int* n, lapack_int* nrhs, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zgetsls( char* trans, lapack_int* m, lapack_int* n, lapack_int* nrhs, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); - -void LAPACK_ssyev_2stage( char* jobz, char* uplo, lapack_int* n, float* a, - lapack_int* lda, float* w, float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_dsyev_2stage( char* jobz, char* uplo, lapack_int* n, double* a, - lapack_int* lda, double* w, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_cheev_2stage( char* jobz, char* uplo, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, float* w, - lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_int *info ); -void LAPACK_zheev_2stage( char* jobz, char* uplo, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, double* w, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_int *info ); -void LAPACK_ssyevd_2stage( char* jobz, char* uplo, lapack_int* n, float* a, - lapack_int* lda, float* w, float* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* liwork, lapack_int *info ); -void LAPACK_dsyevd_2stage( char* jobz, char* uplo, lapack_int* n, double* a, - lapack_int* lda, double* w, double* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* liwork, lapack_int *info ); -void LAPACK_cheevd_2stage( char* jobz, char* uplo, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, float* w, - lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_int* lrwork, lapack_int* iwork, lapack_int* liwork, - lapack_int *info ); -void LAPACK_zheevd_2stage( char* jobz, char* uplo, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, double* w, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_int* lrwork, lapack_int* iwork, - lapack_int* liwork, lapack_int *info ); -void LAPACK_ssyevx_2stage( char* jobz, char* range, char* uplo, lapack_int* n, - float* a, lapack_int* lda, float* vl, float* vu, - lapack_int* il, lapack_int* iu, float* abstol, - lapack_int* m, float* w, float* z, lapack_int* ldz, - float* work, lapack_int* lwork, lapack_int* iwork, - lapack_int* ifail, lapack_int *info ); -void LAPACK_dsyevx_2stage( char* jobz, char* range, char* uplo, lapack_int* n, - double* a, lapack_int* lda, double* vl, double* vu, - lapack_int* il, lapack_int* iu, double* abstol, - lapack_int* m, double* w, double* z, lapack_int* ldz, - double* work, lapack_int* lwork, lapack_int* iwork, - lapack_int* ifail, lapack_int *info ); -void LAPACK_cheevx_2stage( char* jobz, char* range, char* uplo, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, float* vl, - float* vu, lapack_int* il, lapack_int* iu, float* abstol, - lapack_int* m, float* w, lapack_complex_float* z, - lapack_int* ldz, lapack_complex_float* work, - lapack_int* lwork, float* rwork, lapack_int* iwork, - lapack_int* ifail, lapack_int *info ); -void LAPACK_zheevx_2stage( char* jobz, char* range, char* uplo, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, double* vl, - double* vu, lapack_int* il, lapack_int* iu, double* abstol, - lapack_int* m, double* w, lapack_complex_double* z, - lapack_int* ldz, lapack_complex_double* work, - lapack_int* lwork, double* rwork, lapack_int* iwork, - lapack_int* ifail, lapack_int *info ); -void LAPACK_ssyevr_2stage( char* jobz, char* range, char* uplo, lapack_int* n, - float* a, lapack_int* lda, float* vl, float* vu, - lapack_int* il, lapack_int* iu, float* abstol, - lapack_int* m, float* w, float* z, lapack_int* ldz, - lapack_int* isuppz, float* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* liwork, lapack_int *info ); -void LAPACK_dsyevr_2stage( char* jobz, char* range, char* uplo, lapack_int* n, - double* a, lapack_int* lda, double* vl, double* vu, - lapack_int* il, lapack_int* iu, double* abstol, - lapack_int* m, double* w, double* z, lapack_int* ldz, - lapack_int* isuppz, double* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* liwork, lapack_int *info ); -void LAPACK_cheevr_2stage( char* jobz, char* range, char* uplo, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, float* vl, - float* vu, lapack_int* il, lapack_int* iu, float* abstol, - lapack_int* m, float* w, lapack_complex_float* z, - lapack_int* ldz, lapack_int* isuppz, - lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_int* lrwork, lapack_int* iwork, lapack_int* liwork, - lapack_int *info ); -void LAPACK_zheevr_2stage( char* jobz, char* range, char* uplo, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, double* vl, - double* vu, lapack_int* il, lapack_int* iu, double* abstol, - lapack_int* m, double* w, lapack_complex_double* z, - lapack_int* ldz, lapack_int* isuppz, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_int* lrwork, lapack_int* iwork, - lapack_int* liwork, lapack_int *info ); -void LAPACK_ssbev_2stage( char* jobz, char* uplo, lapack_int* n, lapack_int* kd, - float* ab, lapack_int* ldab, float* w, float* z, - lapack_int* ldz, float* work, lapack_int* lwork, lapack_int *info ); -void LAPACK_dsbev_2stage( char* jobz, char* uplo, lapack_int* n, lapack_int* kd, - double* ab, lapack_int* ldab, double* w, double* z, - lapack_int* ldz, double* work, lapack_int* lwork, lapack_int *info ); -void LAPACK_chbev_2stage( char* jobz, char* uplo, lapack_int* n, lapack_int* kd, - lapack_complex_float* ab, lapack_int* ldab, float* w, - lapack_complex_float* z, lapack_int* ldz, - lapack_complex_float* work, lapack_int* lwork, float* rwork, lapack_int *info ); -void LAPACK_zhbev_2stage( char* jobz, char* uplo, lapack_int* n, lapack_int* kd, - lapack_complex_double* ab, lapack_int* ldab, double* w, - lapack_complex_double* z, lapack_int* ldz, - lapack_complex_double* work, lapack_int* lwork, double* rwork, - lapack_int *info ); -void LAPACK_ssbevd_2stage( char* jobz, char* uplo, lapack_int* n, lapack_int* kd, - float* ab, lapack_int* ldab, float* w, float* z, - lapack_int* ldz, float* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* liwork, lapack_int *info ); -void LAPACK_dsbevd_2stage( char* jobz, char* uplo, lapack_int* n, lapack_int* kd, - double* ab, lapack_int* ldab, double* w, double* z, - lapack_int* ldz, double* work, lapack_int* lwork, - lapack_int* iwork, lapack_int* liwork, lapack_int *info ); -void LAPACK_chbevd_2stage( char* jobz, char* uplo, lapack_int* n, lapack_int* kd, - lapack_complex_float* ab, lapack_int* ldab, float* w, - lapack_complex_float* z, lapack_int* ldz, - lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_int* lrwork, lapack_int* iwork, lapack_int* liwork, - lapack_int *info ); -void LAPACK_zhbevd_2stage( char* jobz, char* uplo, lapack_int* n, lapack_int* kd, - lapack_complex_double* ab, lapack_int* ldab, double* w, - lapack_complex_double* z, lapack_int* ldz, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_int* lrwork, lapack_int* iwork, - lapack_int* liwork, lapack_int *info ); -void LAPACK_ssbevx_2stage( char* jobz, char* range, char* uplo, lapack_int* n, - lapack_int* kd, float* ab, lapack_int* ldab, float* q, - lapack_int* ldq, float* vl, float* vu, lapack_int* il, - lapack_int* iu, float* abstol, lapack_int* m, float* w, - float* z, lapack_int* ldz, float* work, lapack_int* lwork, lapack_int* iwork, - lapack_int* ifail, lapack_int *info ); -void LAPACK_dsbevx_2stage( char* jobz, char* range, char* uplo, lapack_int* n, - lapack_int* kd, double* ab, lapack_int* ldab, double* q, - lapack_int* ldq, double* vl, double* vu, lapack_int* il, - lapack_int* iu, double* abstol, lapack_int* m, double* w, - double* z, lapack_int* ldz, double* work, lapack_int* lwork, lapack_int* iwork, - lapack_int* ifail, lapack_int *info ); -void LAPACK_chbevx_2stage( char* jobz, char* range, char* uplo, lapack_int* n, - lapack_int* kd, lapack_complex_float* ab, lapack_int* ldab, - lapack_complex_float* q, lapack_int* ldq, float* vl, - float* vu, lapack_int* il, lapack_int* iu, float* abstol, - lapack_int* m, float* w, lapack_complex_float* z, - lapack_int* ldz, lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_int* iwork, lapack_int* ifail, lapack_int *info ); -void LAPACK_zhbevx_2stage( char* jobz, char* range, char* uplo, lapack_int* n, - lapack_int* kd, lapack_complex_double* ab, lapack_int* ldab, - lapack_complex_double* q, lapack_int* ldq, double* vl, - double* vu, lapack_int* il, lapack_int* iu, double* abstol, - lapack_int* m, double* w, lapack_complex_double* z, - lapack_int* ldz, lapack_complex_double* work, lapack_int* lwork, double* rwork, - lapack_int* iwork, lapack_int* ifail, lapack_int *info ); -void LAPACK_ssygv_2stage( lapack_int* itype, char* jobz, char* uplo, lapack_int* n, - float* a, lapack_int* lda, float* b, lapack_int* ldb, - float* w, float* work, lapack_int* lwork, lapack_int *info ); -void LAPACK_dsygv_2stage( lapack_int* itype, char* jobz, char* uplo, lapack_int* n, - double* a, lapack_int* lda, double* b, lapack_int* ldb, - double* w, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_chegv_2stage( lapack_int* itype, char* jobz, char* uplo, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* b, lapack_int* ldb, float* w, - lapack_complex_float* work, lapack_int* lwork, float* rwork, - lapack_int *info ); -void LAPACK_zhegv_2stage( lapack_int* itype, char* jobz, char* uplo, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* b, lapack_int* ldb, double* w, - lapack_complex_double* work, lapack_int* lwork, - double* rwork, lapack_int *info ); - -//LAPACK 3.8.0 - -void LAPACK_ssysv_aa_2stage( char* uplo, lapack_int* n, lapack_int* nrhs, - float* a, lapack_int* lda, float* tb, lapack_int* ltb, - lapack_int* ipiv, lapack_int* ipiv2, float* b, lapack_int* ldb, - float* work, lapack_int* lwork, lapack_int *info ); -void LAPACK_dsysv_aa_2stage( char* uplo, lapack_int* n, lapack_int* nrhs, double* a, - lapack_int* lda, double* tb, lapack_int* ltb, - lapack_int* ipiv, lapack_int* ipiv2, double* b, - lapack_int* ldb, double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_csysv_aa_2stage( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* tb, lapack_int* ltb, - lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zsysv_aa_2stage( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* tb, lapack_int* ltb, - lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_chesv_aa_2stage( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* tb, lapack_int* ltb, - lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_float* b, lapack_int* ldb, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zhesv_aa_2stage( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* tb, lapack_int* ltb, - lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_double* b, lapack_int* ldb, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); - -void LAPACK_ssytrf_aa_2stage( char* uplo, lapack_int* n, - float* a, lapack_int* lda, float* tb, lapack_int* ltb, - lapack_int* ipiv, lapack_int* ipiv2, - float* work, lapack_int* lwork, lapack_int *info ); -void LAPACK_dsytrf_aa_2stage( char* uplo, lapack_int* n, double* a, - lapack_int* lda, double* tb, lapack_int* ltb, - lapack_int* ipiv, lapack_int* ipiv2, - double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_csytrf_aa_2stage( char* uplo, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* tb, lapack_int* ltb, - lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zsytrf_aa_2stage( char* uplo, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* tb, lapack_int* ltb, - lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_chetrf_aa_2stage( char* uplo, lapack_int* n, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* tb, lapack_int* ltb, - lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_float* work, lapack_int* lwork, - lapack_int *info ); -void LAPACK_zhetrf_aa_2stage( char* uplo, lapack_int* n, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* tb, lapack_int* ltb, - lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_double* work, lapack_int* lwork, - lapack_int *info ); - -void LAPACK_ssytrs_aa_2stage( char* uplo, lapack_int* n, lapack_int* nrhs, - float* a, lapack_int* lda, float* tb, lapack_int* ltb, - lapack_int* ipiv, lapack_int* ipiv2, float* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_dsytrs_aa_2stage( char* uplo, lapack_int* n, lapack_int* nrhs, double* a, - lapack_int* lda, double* tb, lapack_int* ltb, - lapack_int* ipiv, lapack_int* ipiv2, double* b, - lapack_int* ldb, lapack_int *info ); -void LAPACK_csytrs_aa_2stage( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* tb, lapack_int* ltb, - lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_float* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_zsytrs_aa_2stage( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* tb, lapack_int* ltb, - lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_double* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_chetrs_aa_2stage( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_float* a, lapack_int* lda, - lapack_complex_float* tb, lapack_int* ltb, - lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_float* b, lapack_int* ldb, - lapack_int *info ); -void LAPACK_zhetrs_aa_2stage( char* uplo, lapack_int* n, lapack_int* nrhs, - lapack_complex_double* a, lapack_int* lda, - lapack_complex_double* tb, lapack_int* ltb, - lapack_int* ipiv, lapack_int* ipiv2, - lapack_complex_double* b, lapack_int* ldb, - lapack_int *info ); - -/* APIs for set/get nancheck flags */ -void LAPACKE_set_nancheck( int flag ); -int LAPACKE_get_nancheck( ); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _LAPACKE_H_ */ diff --git a/cpp/thirdparty/knowhere_build/include/lapacke_config.h b/cpp/thirdparty/knowhere_build/include/lapacke_config.h deleted file mode 100644 index 8262c3488b..0000000000 --- a/cpp/thirdparty/knowhere_build/include/lapacke_config.h +++ /dev/null @@ -1,126 +0,0 @@ -/***************************************************************************** - Copyright (c) 2010, Intel Corp. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of Intel Corporation nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - THE POSSIBILITY OF SUCH DAMAGE. -****************************************************************************** -* Contents: Native C interface to LAPACK -* Author: Intel Corporation -* Generated May, 2011 -*****************************************************************************/ - -#ifndef _LAPACKE_CONFIG_H_ -#define _LAPACKE_CONFIG_H_ - -// For Android prior to API 21 (no include) -#if defined(__ANDROID__) -#if __ANDROID_API__ < 21 -#define LAPACK_COMPLEX_STRUCTURE -#endif -#endif - -#ifdef __cplusplus -#if defined(LAPACK_COMPLEX_CPP) -#include -#endif -extern "C" { -#endif /* __cplusplus */ - -#include - -#ifndef lapack_int -#if defined(LAPACK_ILP64) -#define lapack_int long -#else -#define lapack_int int -#endif -#endif - -#ifndef lapack_logical -#define lapack_logical lapack_int -#endif - -#ifndef LAPACK_COMPLEX_CUSTOM - -#if defined(LAPACK_COMPLEX_STRUCTURE) - -typedef struct { float real, imag; } _lapack_complex_float; -typedef struct { double real, imag; } _lapack_complex_double; -#define lapack_complex_float _lapack_complex_float -#define lapack_complex_double _lapack_complex_double -#define lapack_complex_float_real(z) ((z).real) -#define lapack_complex_float_imag(z) ((z).imag) -#define lapack_complex_double_real(z) ((z).real) -#define lapack_complex_double_imag(z) ((z).imag) - -#elif defined(LAPACK_COMPLEX_C99) - -#include -#define lapack_complex_float float _Complex -#define lapack_complex_double double _Complex -#define lapack_complex_float_real(z) (creal(z)) -#define lapack_complex_float_imag(z) (cimag(z)) -#define lapack_complex_double_real(z) (creal(z)) -#define lapack_complex_double_imag(z) (cimag(z)) - -#elif defined(LAPACK_COMPLEX_CPP) - -#define lapack_complex_float std::complex -#define lapack_complex_double std::complex -#define lapack_complex_float_real(z) ((z).real()) -#define lapack_complex_float_imag(z) ((z).imag()) -#define lapack_complex_double_real(z) ((z).real()) -#define lapack_complex_double_imag(z) ((z).imag()) - -#else - -#include -#define lapack_complex_float float _Complex -#define lapack_complex_double double _Complex -#define lapack_complex_float_real(z) (creal(z)) -#define lapack_complex_float_imag(z) (cimag(z)) -#define lapack_complex_double_real(z) (creal(z)) -#define lapack_complex_double_imag(z) (cimag(z)) - -#endif - -lapack_complex_float lapack_make_complex_float( float re, float im ); -lapack_complex_double lapack_make_complex_double( double re, double im ); - -#endif - -#ifndef LAPACK_malloc -#define LAPACK_malloc( size ) malloc( size ) -#endif - -#ifndef LAPACK_free -#define LAPACK_free( p ) free( p ) -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _LAPACKE_CONFIG_H_ */ diff --git a/cpp/thirdparty/knowhere_build/include/lapacke_mangling.h b/cpp/thirdparty/knowhere_build/include/lapacke_mangling.h deleted file mode 100644 index 6211fd144d..0000000000 --- a/cpp/thirdparty/knowhere_build/include/lapacke_mangling.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef LAPACK_HEADER_INCLUDED -#define LAPACK_HEADER_INCLUDED - -#ifndef LAPACK_GLOBAL -#if defined(LAPACK_GLOBAL_PATTERN_LC) || defined(ADD_) -#define LAPACK_GLOBAL(lcname,UCNAME) lcname##_ -#elif defined(LAPACK_GLOBAL_PATTERN_UC) || defined(UPPER) -#define LAPACK_GLOBAL(lcname,UCNAME) UCNAME -#elif defined(LAPACK_GLOBAL_PATTERN_MC) || defined(NOCHANGE) -#define LAPACK_GLOBAL(lcname,UCNAME) lcname -#else -#define LAPACK_GLOBAL(lcname,UCNAME) lcname##_ -#endif -#endif - -#endif - diff --git a/cpp/thirdparty/knowhere_build/include/lapacke_utils.h b/cpp/thirdparty/knowhere_build/include/lapacke_utils.h deleted file mode 100644 index a9236d23f9..0000000000 --- a/cpp/thirdparty/knowhere_build/include/lapacke_utils.h +++ /dev/null @@ -1,579 +0,0 @@ -/***************************************************************************** - Copyright (c) 2014, Intel Corp. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of Intel Corporation nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - THE POSSIBILITY OF SUCH DAMAGE. -****************************************************************************** -* Contents: Native C interface to LAPACK utility functions -* Author: Intel Corporation -* Created in January, 2010 -*****************************************************************************/ - -#ifndef _LAPACKE_UTILS_H_ -#define _LAPACKE_UTILS_H_ - -#include "lapacke.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#ifndef ABS -#define ABS(x) (((x) < 0) ? -(x) : (x)) -#endif -#ifndef MAX -#define MAX(x,y) (((x) > (y)) ? (x) : (y)) -#endif -#ifndef MIN -#define MIN(x,y) (((x) < (y)) ? (x) : (y)) -#endif -#ifndef MAX3 -#define MAX3(x,y,z) (((x) > MAX(y,z)) ? (x) : MAX(y,z)) -#endif -#ifndef MIN3 -#define MIN3(x,y,z) (((x) < MIN(y,z)) ? (x) : MIN(y,z)) -#endif - -#define IS_S_NONZERO(x) ( (x) < 0 || (x) > 0 ) -#define IS_D_NONZERO(x) ( (x) < 0 || (x) > 0 ) -#define IS_C_NONZERO(x) ( IS_S_NONZERO(*((float*)&x)) || \ - IS_S_NONZERO(*(((float*)&x)+1)) ) -#define IS_Z_NONZERO(x) ( IS_D_NONZERO(*((double*)&x)) || \ - IS_D_NONZERO(*(((double*)&x)+1)) ) - -/* Error handler */ -void LAPACKE_xerbla( const char *name, lapack_int info ); - -/* Compare two chars (case-insensitive) */ -lapack_logical LAPACKE_lsame( char ca, char cb ); - -/* Functions to convert column-major to row-major 2d arrays and vice versa. */ -void LAPACKE_cgb_trans( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, - const lapack_complex_float *in, lapack_int ldin, - lapack_complex_float *out, lapack_int ldout ); -void LAPACKE_cge_trans( int matrix_layout, lapack_int m, lapack_int n, - const lapack_complex_float* in, lapack_int ldin, - lapack_complex_float* out, lapack_int ldout ); -void LAPACKE_cgg_trans( int matrix_layout, lapack_int m, lapack_int n, - const lapack_complex_float* in, lapack_int ldin, - lapack_complex_float* out, lapack_int ldout ); -void LAPACKE_chb_trans( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, - const lapack_complex_float *in, lapack_int ldin, - lapack_complex_float *out, lapack_int ldout ); -void LAPACKE_che_trans( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float *in, lapack_int ldin, - lapack_complex_float *out, lapack_int ldout ); -void LAPACKE_chp_trans( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float *in, - lapack_complex_float *out ); -void LAPACKE_chs_trans( int matrix_layout, lapack_int n, - const lapack_complex_float *in, lapack_int ldin, - lapack_complex_float *out, lapack_int ldout ); -void LAPACKE_cpb_trans( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, - const lapack_complex_float *in, lapack_int ldin, - lapack_complex_float *out, lapack_int ldout ); -void LAPACKE_cpf_trans( int matrix_layout, char transr, char uplo, - lapack_int n, const lapack_complex_float *in, - lapack_complex_float *out ); -void LAPACKE_cpo_trans( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float *in, lapack_int ldin, - lapack_complex_float *out, lapack_int ldout ); -void LAPACKE_cpp_trans( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float *in, - lapack_complex_float *out ); -void LAPACKE_csp_trans( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float *in, - lapack_complex_float *out ); -void LAPACKE_csy_trans( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_float *in, lapack_int ldin, - lapack_complex_float *out, lapack_int ldout ); -void LAPACKE_ctb_trans( int matrix_layout, char uplo, char diag, - lapack_int n, lapack_int kd, - const lapack_complex_float *in, lapack_int ldin, - lapack_complex_float *out, lapack_int ldout ); -void LAPACKE_ctf_trans( int matrix_layout, char transr, char uplo, char diag, - lapack_int n, const lapack_complex_float *in, - lapack_complex_float *out ); -void LAPACKE_ctp_trans( int matrix_layout, char uplo, char diag, - lapack_int n, const lapack_complex_float *in, - lapack_complex_float *out ); -void LAPACKE_ctr_trans( int matrix_layout, char uplo, char diag, lapack_int n, - const lapack_complex_float *in, lapack_int ldin, - lapack_complex_float *out, lapack_int ldout ); - -void LAPACKE_dgb_trans( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, - const double *in, lapack_int ldin, - double *out, lapack_int ldout ); -void LAPACKE_dge_trans( int matrix_layout, lapack_int m, lapack_int n, - const double* in, lapack_int ldin, - double* out, lapack_int ldout ); -void LAPACKE_dgg_trans( int matrix_layout, lapack_int m, lapack_int n, - const double* in, lapack_int ldin, - double* out, lapack_int ldout ); -void LAPACKE_dhs_trans( int matrix_layout, lapack_int n, - const double *in, lapack_int ldin, - double *out, lapack_int ldout ); -void LAPACKE_dpb_trans( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, - const double *in, lapack_int ldin, - double *out, lapack_int ldout ); -void LAPACKE_dpf_trans( int matrix_layout, char transr, char uplo, - lapack_int n, const double *in, - double *out ); -void LAPACKE_dpo_trans( int matrix_layout, char uplo, lapack_int n, - const double *in, lapack_int ldin, - double *out, lapack_int ldout ); -void LAPACKE_dpp_trans( int matrix_layout, char uplo, lapack_int n, - const double *in, - double *out ); -void LAPACKE_dsb_trans( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, - const double *in, lapack_int ldin, - double *out, lapack_int ldout ); -void LAPACKE_dsp_trans( int matrix_layout, char uplo, lapack_int n, - const double *in, - double *out ); -void LAPACKE_dsy_trans( int matrix_layout, char uplo, lapack_int n, - const double *in, lapack_int ldin, - double *out, lapack_int ldout ); -void LAPACKE_dtb_trans( int matrix_layout, char uplo, char diag, - lapack_int n, lapack_int kd, - const double *in, lapack_int ldin, - double *out, lapack_int ldout ); -void LAPACKE_dtf_trans( int matrix_layout, char transr, char uplo, char diag, - lapack_int n, const double *in, - double *out ); -void LAPACKE_dtp_trans( int matrix_layout, char uplo, char diag, - lapack_int n, const double *in, - double *out ); -void LAPACKE_dtr_trans( int matrix_layout, char uplo, char diag, lapack_int n, - const double *in, lapack_int ldin, - double *out, lapack_int ldout ); - -void LAPACKE_sgb_trans( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, - const float *in, lapack_int ldin, - float *out, lapack_int ldout ); -void LAPACKE_sge_trans( int matrix_layout, lapack_int m, lapack_int n, - const float* in, lapack_int ldin, - float* out, lapack_int ldout ); -void LAPACKE_sgg_trans( int matrix_layout, lapack_int m, lapack_int n, - const float* in, lapack_int ldin, - float* out, lapack_int ldout ); -void LAPACKE_shs_trans( int matrix_layout, lapack_int n, - const float *in, lapack_int ldin, - float *out, lapack_int ldout ); -void LAPACKE_spb_trans( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, - const float *in, lapack_int ldin, - float *out, lapack_int ldout ); -void LAPACKE_spf_trans( int matrix_layout, char transr, char uplo, - lapack_int n, const float *in, - float *out ); -void LAPACKE_spo_trans( int matrix_layout, char uplo, lapack_int n, - const float *in, lapack_int ldin, - float *out, lapack_int ldout ); -void LAPACKE_spp_trans( int matrix_layout, char uplo, lapack_int n, - const float *in, - float *out ); -void LAPACKE_ssb_trans( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, - const float *in, lapack_int ldin, - float *out, lapack_int ldout ); -void LAPACKE_ssp_trans( int matrix_layout, char uplo, lapack_int n, - const float *in, - float *out ); -void LAPACKE_ssy_trans( int matrix_layout, char uplo, lapack_int n, - const float *in, lapack_int ldin, - float *out, lapack_int ldout ); -void LAPACKE_stb_trans( int matrix_layout, char uplo, char diag, - lapack_int n, lapack_int kd, - const float *in, lapack_int ldin, - float *out, lapack_int ldout ); -void LAPACKE_stf_trans( int matrix_layout, char transr, char uplo, char diag, - lapack_int n, const float *in, - float *out ); -void LAPACKE_stp_trans( int matrix_layout, char uplo, char diag, - lapack_int n, const float *in, - float *out ); -void LAPACKE_str_trans( int matrix_layout, char uplo, char diag, lapack_int n, - const float *in, lapack_int ldin, - float *out, lapack_int ldout ); - -void LAPACKE_zgb_trans( int matrix_layout, lapack_int m, lapack_int n, - lapack_int kl, lapack_int ku, - const lapack_complex_double *in, lapack_int ldin, - lapack_complex_double *out, lapack_int ldout ); -void LAPACKE_zge_trans( int matrix_layout, lapack_int m, lapack_int n, - const lapack_complex_double* in, lapack_int ldin, - lapack_complex_double* out, lapack_int ldout ); -void LAPACKE_zgg_trans( int matrix_layout, lapack_int m, lapack_int n, - const lapack_complex_double* in, lapack_int ldin, - lapack_complex_double* out, lapack_int ldout ); -void LAPACKE_zhb_trans( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, - const lapack_complex_double *in, lapack_int ldin, - lapack_complex_double *out, lapack_int ldout ); -void LAPACKE_zhe_trans( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double *in, lapack_int ldin, - lapack_complex_double *out, lapack_int ldout ); -void LAPACKE_zhp_trans( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double *in, - lapack_complex_double *out ); -void LAPACKE_zhs_trans( int matrix_layout, lapack_int n, - const lapack_complex_double *in, lapack_int ldin, - lapack_complex_double *out, lapack_int ldout ); -void LAPACKE_zpb_trans( int matrix_layout, char uplo, lapack_int n, - lapack_int kd, - const lapack_complex_double *in, lapack_int ldin, - lapack_complex_double *out, lapack_int ldout ); -void LAPACKE_zpf_trans( int matrix_layout, char transr, char uplo, - lapack_int n, const lapack_complex_double *in, - lapack_complex_double *out ); -void LAPACKE_zpo_trans( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double *in, lapack_int ldin, - lapack_complex_double *out, lapack_int ldout ); -void LAPACKE_zpp_trans( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double *in, - lapack_complex_double *out ); -void LAPACKE_zsp_trans( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double *in, - lapack_complex_double *out ); -void LAPACKE_zsy_trans( int matrix_layout, char uplo, lapack_int n, - const lapack_complex_double *in, lapack_int ldin, - lapack_complex_double *out, lapack_int ldout ); -void LAPACKE_ztb_trans( int matrix_layout, char uplo, char diag, - lapack_int n, lapack_int kd, - const lapack_complex_double *in, lapack_int ldin, - lapack_complex_double *out, lapack_int ldout ); -void LAPACKE_ztf_trans( int matrix_layout, char transr, char uplo, char diag, - lapack_int n, const lapack_complex_double *in, - lapack_complex_double *out ); -void LAPACKE_ztp_trans( int matrix_layout, char uplo, char diag, - lapack_int n, const lapack_complex_double *in, - lapack_complex_double *out ); -void LAPACKE_ztr_trans( int matrix_layout, char uplo, char diag, lapack_int n, - const lapack_complex_double *in, lapack_int ldin, - lapack_complex_double *out, lapack_int ldout ); - -/* NaN checkers */ -#define LAPACK_SISNAN( x ) ( x != x ) -#define LAPACK_DISNAN( x ) ( x != x ) -#define LAPACK_CISNAN( x ) ( LAPACK_SISNAN(*((float*) &x)) || \ - LAPACK_SISNAN(*(((float*) &x)+1)) ) -#define LAPACK_ZISNAN( x ) ( LAPACK_DISNAN(*((double*)&x)) || \ - LAPACK_DISNAN(*(((double*)&x)+1)) ) - -/* NaN checkers for vectors */ -lapack_logical LAPACKE_c_nancheck( lapack_int n, - const lapack_complex_float *x, - lapack_int incx ); -lapack_logical LAPACKE_d_nancheck( lapack_int n, - const double *x, - lapack_int incx ); -lapack_logical LAPACKE_s_nancheck( lapack_int n, - const float *x, - lapack_int incx ); -lapack_logical LAPACKE_z_nancheck( lapack_int n, - const lapack_complex_double *x, - lapack_int incx ); -/* NaN checkers for matrices */ -lapack_logical LAPACKE_cgb_nancheck( int matrix_layout, lapack_int m, - lapack_int n, lapack_int kl, - lapack_int ku, - const lapack_complex_float *ab, - lapack_int ldab ); -lapack_logical LAPACKE_cge_nancheck( int matrix_layout, lapack_int m, - lapack_int n, - const lapack_complex_float *a, - lapack_int lda ); -lapack_logical LAPACKE_cgg_nancheck( int matrix_layout, lapack_int m, - lapack_int n, - const lapack_complex_float *a, - lapack_int lda ); -lapack_logical LAPACKE_cgt_nancheck( lapack_int n, - const lapack_complex_float *dl, - const lapack_complex_float *d, - const lapack_complex_float *du ); -lapack_logical LAPACKE_chb_nancheck( int matrix_layout, char uplo, - lapack_int n, lapack_int kd, - const lapack_complex_float* ab, - lapack_int ldab ); -lapack_logical LAPACKE_che_nancheck( int matrix_layout, char uplo, - lapack_int n, - const lapack_complex_float *a, - lapack_int lda ); -lapack_logical LAPACKE_chp_nancheck( lapack_int n, - const lapack_complex_float *ap ); -lapack_logical LAPACKE_chs_nancheck( int matrix_layout, lapack_int n, - const lapack_complex_float *a, - lapack_int lda ); -lapack_logical LAPACKE_cpb_nancheck( int matrix_layout, char uplo, - lapack_int n, lapack_int kd, - const lapack_complex_float* ab, - lapack_int ldab ); -lapack_logical LAPACKE_cpf_nancheck( lapack_int n, - const lapack_complex_float *a ); -lapack_logical LAPACKE_cpo_nancheck( int matrix_layout, char uplo, - lapack_int n, - const lapack_complex_float *a, - lapack_int lda ); -lapack_logical LAPACKE_cpp_nancheck( lapack_int n, - const lapack_complex_float *ap ); -lapack_logical LAPACKE_cpt_nancheck( lapack_int n, - const float *d, - const lapack_complex_float *e ); -lapack_logical LAPACKE_csp_nancheck( lapack_int n, - const lapack_complex_float *ap ); -lapack_logical LAPACKE_cst_nancheck( lapack_int n, - const lapack_complex_float *d, - const lapack_complex_float *e ); -lapack_logical LAPACKE_csy_nancheck( int matrix_layout, char uplo, - lapack_int n, - const lapack_complex_float *a, - lapack_int lda ); -lapack_logical LAPACKE_ctb_nancheck( int matrix_layout, char uplo, char diag, - lapack_int n, lapack_int kd, - const lapack_complex_float* ab, - lapack_int ldab ); -lapack_logical LAPACKE_ctf_nancheck( int matrix_layout, char transr, - char uplo, char diag, - lapack_int n, - const lapack_complex_float *a ); -lapack_logical LAPACKE_ctp_nancheck( int matrix_layout, char uplo, char diag, - lapack_int n, - const lapack_complex_float *ap ); -lapack_logical LAPACKE_ctr_nancheck( int matrix_layout, char uplo, char diag, - lapack_int n, - const lapack_complex_float *a, - lapack_int lda ); - -lapack_logical LAPACKE_dgb_nancheck( int matrix_layout, lapack_int m, - lapack_int n, lapack_int kl, - lapack_int ku, - const double *ab, - lapack_int ldab ); -lapack_logical LAPACKE_dge_nancheck( int matrix_layout, lapack_int m, - lapack_int n, - const double *a, - lapack_int lda ); -lapack_logical LAPACKE_dgg_nancheck( int matrix_layout, lapack_int m, - lapack_int n, - const double *a, - lapack_int lda ); -lapack_logical LAPACKE_dgt_nancheck( lapack_int n, - const double *dl, - const double *d, - const double *du ); -lapack_logical LAPACKE_dhs_nancheck( int matrix_layout, lapack_int n, - const double *a, - lapack_int lda ); -lapack_logical LAPACKE_dpb_nancheck( int matrix_layout, char uplo, - lapack_int n, lapack_int kd, - const double* ab, - lapack_int ldab ); -lapack_logical LAPACKE_dpf_nancheck( lapack_int n, - const double *a ); -lapack_logical LAPACKE_dpo_nancheck( int matrix_layout, char uplo, - lapack_int n, - const double *a, - lapack_int lda ); -lapack_logical LAPACKE_dpp_nancheck( lapack_int n, - const double *ap ); -lapack_logical LAPACKE_dpt_nancheck( lapack_int n, - const double *d, - const double *e ); -lapack_logical LAPACKE_dsb_nancheck( int matrix_layout, char uplo, - lapack_int n, lapack_int kd, - const double* ab, - lapack_int ldab ); -lapack_logical LAPACKE_dsp_nancheck( lapack_int n, - const double *ap ); -lapack_logical LAPACKE_dst_nancheck( lapack_int n, - const double *d, - const double *e ); -lapack_logical LAPACKE_dsy_nancheck( int matrix_layout, char uplo, - lapack_int n, - const double *a, - lapack_int lda ); -lapack_logical LAPACKE_dtb_nancheck( int matrix_layout, char uplo, char diag, - lapack_int n, lapack_int kd, - const double* ab, - lapack_int ldab ); -lapack_logical LAPACKE_dtf_nancheck( int matrix_layout, char transr, - char uplo, char diag, - lapack_int n, - const double *a ); -lapack_logical LAPACKE_dtp_nancheck( int matrix_layout, char uplo, char diag, - lapack_int n, - const double *ap ); -lapack_logical LAPACKE_dtr_nancheck( int matrix_layout, char uplo, char diag, - lapack_int n, - const double *a, - lapack_int lda ); - -lapack_logical LAPACKE_sgb_nancheck( int matrix_layout, lapack_int m, - lapack_int n, lapack_int kl, - lapack_int ku, - const float *ab, - lapack_int ldab ); -lapack_logical LAPACKE_sge_nancheck( int matrix_layout, lapack_int m, - lapack_int n, - const float *a, - lapack_int lda ); -lapack_logical LAPACKE_sgg_nancheck( int matrix_layout, lapack_int m, - lapack_int n, - const float *a, - lapack_int lda ); -lapack_logical LAPACKE_sgt_nancheck( lapack_int n, - const float *dl, - const float *d, - const float *du ); -lapack_logical LAPACKE_shs_nancheck( int matrix_layout, lapack_int n, - const float *a, - lapack_int lda ); -lapack_logical LAPACKE_spb_nancheck( int matrix_layout, char uplo, - lapack_int n, lapack_int kd, - const float* ab, - lapack_int ldab ); -lapack_logical LAPACKE_spf_nancheck( lapack_int n, - const float *a ); -lapack_logical LAPACKE_spo_nancheck( int matrix_layout, char uplo, - lapack_int n, - const float *a, - lapack_int lda ); -lapack_logical LAPACKE_spp_nancheck( lapack_int n, - const float *ap ); -lapack_logical LAPACKE_spt_nancheck( lapack_int n, - const float *d, - const float *e ); -lapack_logical LAPACKE_ssb_nancheck( int matrix_layout, char uplo, - lapack_int n, lapack_int kd, - const float* ab, - lapack_int ldab ); -lapack_logical LAPACKE_ssp_nancheck( lapack_int n, - const float *ap ); -lapack_logical LAPACKE_sst_nancheck( lapack_int n, - const float *d, - const float *e ); -lapack_logical LAPACKE_ssy_nancheck( int matrix_layout, char uplo, - lapack_int n, - const float *a, - lapack_int lda ); -lapack_logical LAPACKE_stb_nancheck( int matrix_layout, char uplo, char diag, - lapack_int n, lapack_int kd, - const float* ab, - lapack_int ldab ); -lapack_logical LAPACKE_stf_nancheck( int matrix_layout, char transr, - char uplo, char diag, - lapack_int n, - const float *a ); -lapack_logical LAPACKE_stp_nancheck( int matrix_layout, char uplo, char diag, - lapack_int n, - const float *ap ); -lapack_logical LAPACKE_str_nancheck( int matrix_layout, char uplo, char diag, - lapack_int n, - const float *a, - lapack_int lda ); - -lapack_logical LAPACKE_zgb_nancheck( int matrix_layout, lapack_int m, - lapack_int n, lapack_int kl, - lapack_int ku, - const lapack_complex_double *ab, - lapack_int ldab ); -lapack_logical LAPACKE_zge_nancheck( int matrix_layout, lapack_int m, - lapack_int n, - const lapack_complex_double *a, - lapack_int lda ); -lapack_logical LAPACKE_zgg_nancheck( int matrix_layout, lapack_int m, - lapack_int n, - const lapack_complex_double *a, - lapack_int lda ); -lapack_logical LAPACKE_zgt_nancheck( lapack_int n, - const lapack_complex_double *dl, - const lapack_complex_double *d, - const lapack_complex_double *du ); -lapack_logical LAPACKE_zhb_nancheck( int matrix_layout, char uplo, - lapack_int n, lapack_int kd, - const lapack_complex_double* ab, - lapack_int ldab ); -lapack_logical LAPACKE_zhe_nancheck( int matrix_layout, char uplo, - lapack_int n, - const lapack_complex_double *a, - lapack_int lda ); -lapack_logical LAPACKE_zhp_nancheck( lapack_int n, - const lapack_complex_double *ap ); -lapack_logical LAPACKE_zhs_nancheck( int matrix_layout, lapack_int n, - const lapack_complex_double *a, - lapack_int lda ); -lapack_logical LAPACKE_zpb_nancheck( int matrix_layout, char uplo, - lapack_int n, lapack_int kd, - const lapack_complex_double* ab, - lapack_int ldab ); -lapack_logical LAPACKE_zpf_nancheck( lapack_int n, - const lapack_complex_double *a ); -lapack_logical LAPACKE_zpo_nancheck( int matrix_layout, char uplo, - lapack_int n, - const lapack_complex_double *a, - lapack_int lda ); -lapack_logical LAPACKE_zpp_nancheck( lapack_int n, - const lapack_complex_double *ap ); -lapack_logical LAPACKE_zpt_nancheck( lapack_int n, - const double *d, - const lapack_complex_double *e ); -lapack_logical LAPACKE_zsp_nancheck( lapack_int n, - const lapack_complex_double *ap ); -lapack_logical LAPACKE_zst_nancheck( lapack_int n, - const lapack_complex_double *d, - const lapack_complex_double *e ); -lapack_logical LAPACKE_zsy_nancheck( int matrix_layout, char uplo, - lapack_int n, - const lapack_complex_double *a, - lapack_int lda ); -lapack_logical LAPACKE_ztb_nancheck( int matrix_layout, char uplo, char diag, - lapack_int n, lapack_int kd, - const lapack_complex_double* ab, - lapack_int ldab ); -lapack_logical LAPACKE_ztf_nancheck( int matrix_layout, char transr, - char uplo, char diag, - lapack_int n, - const lapack_complex_double *a ); -lapack_logical LAPACKE_ztp_nancheck( int matrix_layout, char uplo, char diag, - lapack_int n, - const lapack_complex_double *ap ); -lapack_logical LAPACKE_ztr_nancheck( int matrix_layout, char uplo, char diag, - lapack_int n, - const lapack_complex_double *a, - lapack_int lda ); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _LAPACKE_UTILS_H_ */ diff --git a/cpp/thirdparty/knowhere_build/include/openblas_config.h b/cpp/thirdparty/knowhere_build/include/openblas_config.h deleted file mode 100644 index 3afd7fb646..0000000000 --- a/cpp/thirdparty/knowhere_build/include/openblas_config.h +++ /dev/null @@ -1,141 +0,0 @@ -#ifndef OPENBLAS_CONFIG_H -#define OPENBLAS_CONFIG_H -#define OPENBLAS_OS_LINUX 1 -#define OPENBLAS_ARCH_X86_64 1 -#define OPENBLAS_C_GCC 1 -#define OPENBLAS___64BIT__ 1 -#define OPENBLAS_PTHREAD_CREATE_FUNC pthread_create -#define OPENBLAS_BUNDERSCORE _ -#define OPENBLAS_NEEDBUNDERSCORE 1 -#define OPENBLAS_HASWELL -#define OPENBLAS_L1_CODE_SIZE 32768 -#define OPENBLAS_L1_CODE_ASSOCIATIVE 8 -#define OPENBLAS_L1_CODE_LINESIZE 64 -#define OPENBLAS_L1_DATA_SIZE 32768 -#define OPENBLAS_L1_DATA_ASSOCIATIVE 8 -#define OPENBLAS_L1_DATA_LINESIZE 64 -#define OPENBLAS_L2_SIZE 262144 -#define OPENBLAS_L2_ASSOCIATIVE 8 -#define OPENBLAS_L2_LINESIZE 64 -#define OPENBLAS_ITB_SIZE 2097152 -#define OPENBLAS_ITB_ASSOCIATIVE 0 -#define OPENBLAS_ITB_ENTRIES 8 -#define OPENBLAS_DTB_SIZE 4096 -#define OPENBLAS_DTB_ASSOCIATIVE 4 -#define OPENBLAS_DTB_DEFAULT_ENTRIES 64 -#define OPENBLAS_HAVE_CMOV -#define OPENBLAS_HAVE_MMX -#define OPENBLAS_HAVE_SSE -#define OPENBLAS_HAVE_SSE2 -#define OPENBLAS_HAVE_SSE3 -#define OPENBLAS_HAVE_SSSE3 -#define OPENBLAS_HAVE_SSE4_1 -#define OPENBLAS_HAVE_SSE4_2 -#define OPENBLAS_HAVE_AVX -#define OPENBLAS_HAVE_AVX2 -#define OPENBLAS_HAVE_FMA3 -#define OPENBLAS_HAVE_CFLUSH -#define OPENBLAS_NUM_SHAREDCACHE 2 -#define OPENBLAS_NUM_CORES 8 -#define OPENBLAS_CORE_HASWELL -#define OPENBLAS_CHAR_CORENAME "HASWELL" -#define OPENBLAS_SLOCAL_BUFFER_SIZE 24576 -#define OPENBLAS_DLOCAL_BUFFER_SIZE 32768 -#define OPENBLAS_CLOCAL_BUFFER_SIZE 12288 -#define OPENBLAS_ZLOCAL_BUFFER_SIZE 8192 -#define OPENBLAS_GEMM_MULTITHREAD_THRESHOLD 4 -#define OPENBLAS_VERSION " OpenBLAS 0.3.6 " -/*This is only for "make install" target.*/ - -#if defined(OPENBLAS_OS_WINNT) || defined(OPENBLAS_OS_CYGWIN_NT) || defined(OPENBLAS_OS_INTERIX) -#define OPENBLAS_WINDOWS_ABI -#define OPENBLAS_OS_WINDOWS - -#ifdef DOUBLE -#define DOUBLE_DEFINED DOUBLE -#undef DOUBLE -#endif -#endif - -#ifdef OPENBLAS_NEEDBUNDERSCORE -#define BLASFUNC(FUNC) FUNC##_ -#else -#define BLASFUNC(FUNC) FUNC -#endif - -#ifdef OPENBLAS_QUAD_PRECISION -typedef struct { - unsigned long x[2]; -} xdouble; -#elif defined OPENBLAS_EXPRECISION -#define xdouble long double -#else -#define xdouble double -#endif - -#if defined(OPENBLAS_OS_WINDOWS) && defined(OPENBLAS___64BIT__) -typedef long long BLASLONG; -typedef unsigned long long BLASULONG; -#else -typedef long BLASLONG; -typedef unsigned long BLASULONG; -#endif - -#ifdef OPENBLAS_USE64BITINT -typedef BLASLONG blasint; -#else -typedef int blasint; -#endif - -#if defined(XDOUBLE) || defined(DOUBLE) -#define FLOATRET FLOAT -#else -#ifdef NEED_F2CCONV -#define FLOATRET double -#else -#define FLOATRET float -#endif -#endif - -/* Inclusion of a standard header file is needed for definition of __STDC_* - predefined macros with some compilers (e.g. GCC 4.7 on Linux). This occurs - as a side effect of including either or . */ -#include - -/* C99 supports complex floating numbers natively, which GCC also offers as an - extension since version 3.0. If neither are available, use a compatible - structure as fallback (see Clause 6.2.5.13 of the C99 standard). */ -#if ((defined(__STDC_IEC_559_COMPLEX__) || __STDC_VERSION__ >= 199901L || \ - (__GNUC__ >= 3 && !defined(__cplusplus))) && !(defined(FORCE_OPENBLAS_COMPLEX_STRUCT))) && !defined(_MSC_VER) - #define OPENBLAS_COMPLEX_C99 -#ifndef __cplusplus - #include -#endif - typedef float _Complex openblas_complex_float; - typedef double _Complex openblas_complex_double; - typedef xdouble _Complex openblas_complex_xdouble; - #define openblas_make_complex_float(real, imag) ((real) + ((imag) * _Complex_I)) - #define openblas_make_complex_double(real, imag) ((real) + ((imag) * _Complex_I)) - #define openblas_make_complex_xdouble(real, imag) ((real) + ((imag) * _Complex_I)) - #define openblas_complex_float_real(z) (creal(z)) - #define openblas_complex_float_imag(z) (cimag(z)) - #define openblas_complex_double_real(z) (creal(z)) - #define openblas_complex_double_imag(z) (cimag(z)) - #define openblas_complex_xdouble_real(z) (creal(z)) - #define openblas_complex_xdouble_imag(z) (cimag(z)) -#else - #define OPENBLAS_COMPLEX_STRUCT - typedef struct { float real, imag; } openblas_complex_float; - typedef struct { double real, imag; } openblas_complex_double; - typedef struct { xdouble real, imag; } openblas_complex_xdouble; - #define openblas_make_complex_float(real, imag) {(real), (imag)} - #define openblas_make_complex_double(real, imag) {(real), (imag)} - #define openblas_make_complex_xdouble(real, imag) {(real), (imag)} - #define openblas_complex_float_real(z) ((z).real) - #define openblas_complex_float_imag(z) ((z).imag) - #define openblas_complex_double_real(z) ((z).real) - #define openblas_complex_double_imag(z) ((z).imag) - #define openblas_complex_xdouble_real(z) ((z).real) - #define openblas_complex_xdouble_imag(z) ((z).imag) -#endif -#endif /* OPENBLAS_CONFIG_H */