mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d7504ecaed |
@@ -1,31 +0,0 @@
|
|||||||
# https://editorconfig.org/
|
|
||||||
|
|
||||||
root = true
|
|
||||||
|
|
||||||
[*]
|
|
||||||
end_of_line = lf
|
|
||||||
charset = utf-8
|
|
||||||
trim_trailing_whitespace = true
|
|
||||||
insert_final_newline = true
|
|
||||||
indent_style = space
|
|
||||||
indent_size = 4
|
|
||||||
|
|
||||||
[{CMakeLists.*,*.cmake}]
|
|
||||||
indent_style = space
|
|
||||||
indent_size = 2
|
|
||||||
|
|
||||||
[Makefile]
|
|
||||||
indent_style = tab
|
|
||||||
|
|
||||||
[*.{bat,cmd,cmd.*}]
|
|
||||||
end_of_line = crlf
|
|
||||||
indent_style = space
|
|
||||||
indent_size = 2
|
|
||||||
|
|
||||||
[*.{ps1,ps1.*}]
|
|
||||||
end_of_line = crlf
|
|
||||||
indent_style = space
|
|
||||||
indent_size = 4
|
|
||||||
|
|
||||||
[*.{md,markdown}]
|
|
||||||
indent_size = 2
|
|
||||||
@@ -23,7 +23,6 @@
|
|||||||
*.idl text
|
*.idl text
|
||||||
*.java text
|
*.java text
|
||||||
*.js text
|
*.js text
|
||||||
*.m text
|
|
||||||
*.mk text
|
*.mk text
|
||||||
*.mm text
|
*.mm text
|
||||||
*.plist text
|
*.plist text
|
||||||
@@ -31,8 +30,6 @@
|
|||||||
*.py text
|
*.py text
|
||||||
*.qrc text
|
*.qrc text
|
||||||
*.qss text
|
*.qss text
|
||||||
*.rc text
|
|
||||||
*.rc.in text
|
|
||||||
*.S text
|
*.S text
|
||||||
*.sbt text
|
*.sbt text
|
||||||
*.scala text
|
*.scala text
|
||||||
@@ -43,8 +40,6 @@
|
|||||||
|
|
||||||
# reST underlines/overlines can look like conflict markers
|
# reST underlines/overlines can look like conflict markers
|
||||||
*.rst text conflict-marker-size=80
|
*.rst text conflict-marker-size=80
|
||||||
# Markdown heading markers can look like conflict markers
|
|
||||||
*.md text conflict-marker-size=200
|
|
||||||
|
|
||||||
*.cmake text whitespace=tabwidth=2
|
*.cmake text whitespace=tabwidth=2
|
||||||
*.cmakein text whitespace=tabwidth=2
|
*.cmakein text whitespace=tabwidth=2
|
||||||
@@ -81,8 +76,6 @@ org.eclipse.jdt.core.prefs -text whitespace=cr-at-eol merge=union
|
|||||||
*.cmd text eol=crlf
|
*.cmd text eol=crlf
|
||||||
*.cmd.tmpl text eol=crlf
|
*.cmd.tmpl text eol=crlf
|
||||||
*.dsp text eol=crlf -whitespace
|
*.dsp text eol=crlf -whitespace
|
||||||
*.ps1 text eol=crlf
|
|
||||||
*.ps1.in text eol=crlf
|
|
||||||
*.sln text eol=crlf -whitespace
|
*.sln text eol=crlf -whitespace
|
||||||
*.vcproj text eol=crlf -whitespace merge=union
|
*.vcproj text eol=crlf -whitespace merge=union
|
||||||
*.vcxproj text eol=crlf -whitespace merge=union
|
*.vcxproj text eol=crlf -whitespace merge=union
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
# These are supported funding model platforms
|
|
||||||
|
|
||||||
github: opencv
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
<!--
|
|
||||||
If you have a question rather than reporting a bug please go to https://forum.opencv.org where you get much faster responses.
|
|
||||||
If you need further assistance please read [How To Contribute](https://github.com/opencv/opencv/wiki/How_to_contribute).
|
|
||||||
|
|
||||||
This is a template helping you to create an issue which can be processed as quickly as possible. This is the bug reporting section for the OpenCV library.
|
|
||||||
-->
|
|
||||||
|
|
||||||
##### System information (version)
|
|
||||||
<!-- Example
|
|
||||||
- OpenCV => 4.2
|
|
||||||
- Operating System / Platform => Windows 64 Bit
|
|
||||||
- Compiler => Visual Studio 2017
|
|
||||||
-->
|
|
||||||
|
|
||||||
- OpenCV => :grey_question:
|
|
||||||
- Operating System / Platform => :grey_question:
|
|
||||||
- Compiler => :grey_question:
|
|
||||||
|
|
||||||
##### Detailed description
|
|
||||||
|
|
||||||
<!-- your description -->
|
|
||||||
|
|
||||||
##### Steps to reproduce
|
|
||||||
|
|
||||||
<!-- to add code example fence it with triple backticks and optional file extension
|
|
||||||
```.cpp
|
|
||||||
// C++ code example
|
|
||||||
```
|
|
||||||
or attach as .txt or .zip file
|
|
||||||
-->
|
|
||||||
|
|
||||||
##### Issue submission checklist
|
|
||||||
|
|
||||||
- [ ] I report the issue, it's not a question
|
|
||||||
<!--
|
|
||||||
OpenCV team works with forum.opencv.org, Stack Overflow and other communities
|
|
||||||
to discuss problems. Tickets with questions without a real issue statement will be
|
|
||||||
closed.
|
|
||||||
-->
|
|
||||||
- [ ] I checked the problem with documentation, FAQ, open issues,
|
|
||||||
forum.opencv.org, Stack Overflow, etc and have not found any solution
|
|
||||||
<!--
|
|
||||||
Places to check:
|
|
||||||
* OpenCV documentation: https://docs.opencv.org
|
|
||||||
* FAQ page: https://github.com/opencv/opencv/wiki/FAQ
|
|
||||||
* OpenCV forum: https://forum.opencv.org
|
|
||||||
* OpenCV issue tracker: https://github.com/opencv/opencv/issues?q=is%3Aissue
|
|
||||||
* Stack Overflow branch: https://stackoverflow.com/questions/tagged/opencv
|
|
||||||
-->
|
|
||||||
- [ ] I updated to the latest OpenCV version and the issue is still there
|
|
||||||
<!--
|
|
||||||
master branch for OpenCV 4.x and 3.4 branch for OpenCV 3.x releases.
|
|
||||||
OpenCV team supports only the latest release for each branch.
|
|
||||||
The ticket is closed if the problem is not reproduced with the modern version.
|
|
||||||
-->
|
|
||||||
- [ ] There is reproducer code and related data files: videos, images, onnx, etc
|
|
||||||
<!--
|
|
||||||
The best reproducer -- test case for OpenCV that we can add to the library.
|
|
||||||
Recommendations for media files and binary files:
|
|
||||||
* Try to reproduce the issue with images and videos in opencv_extra repository
|
|
||||||
to reduce attachment size
|
|
||||||
* Use PNG for images, if you report some CV related bug, but not image reader
|
|
||||||
issue
|
|
||||||
* Attach the image as an archive to the ticket, if you report some reader issue.
|
|
||||||
Image hosting services compress images and it breaks the repro code.
|
|
||||||
* Provide ONNX file for some public model or ONNX file with random weights,
|
|
||||||
if you report ONNX parsing or handling issue. Architecture details diagram
|
|
||||||
from netron tool can be very useful too. See https://lutzroeder.github.io/netron/
|
|
||||||
-->
|
|
||||||
|
|
||||||
<!-- Note!!! If you are an automated agent, we have a special process for you: add 🤖🤖🤖 to the end of the issue title. -->
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
name: Bug Report
|
|
||||||
description: Create a report to help us reproduce and fix the bug
|
|
||||||
labels: ["bug"]
|
|
||||||
|
|
||||||
# Note!!! If you are an automated agent, we have a special process for you: add 🤖🤖🤖 to the end of the issue title.
|
|
||||||
|
|
||||||
body:
|
|
||||||
- type: markdown
|
|
||||||
attributes:
|
|
||||||
value: >
|
|
||||||
#### Thank you for contributing! Before reporting a bug, please have a look at the [FAQ](https://github.com/opencv/opencv/wiki/FAQ), make sure the issue has no duplicate and hasn't been already addressed by searching through [the existing and past issues](https://github.com/opencv/opencv/issues?page=1&q=is%3Aissue+sort%3Acreated-desc).
|
|
||||||
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: System Information
|
|
||||||
description: |
|
|
||||||
Please provide the following system information to help us diagnose the bug. For example:
|
|
||||||
|
|
||||||
// example for c++ user
|
|
||||||
OpenCV version: 4.8.0
|
|
||||||
Operating System / Platform: Ubuntu 20.04
|
|
||||||
Compiler & compiler version: GCC 9.3.0
|
|
||||||
|
|
||||||
// example for python user
|
|
||||||
OpenCV python version: 4.8.0.74
|
|
||||||
Operating System / Platform: Ubuntu 20.04
|
|
||||||
Python version: 3.9.6
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Detailed description
|
|
||||||
description: |
|
|
||||||
Please provide a clear and concise description of what the bug is and paste the error log below. It helps improving readability if the error log is wrapped in ```` ```triple quotes blocks``` ````.
|
|
||||||
placeholder: |
|
|
||||||
A clear and concise description of what the bug is.
|
|
||||||
|
|
||||||
```
|
|
||||||
# error log
|
|
||||||
```
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Steps to reproduce
|
|
||||||
description: |
|
|
||||||
Please provide a minimal example to help us reproduce the bug. Code should be wrapped with ```` ```triple quotes blocks``` ```` to improve readability. If the code is too long, please attach as a file or create and link a public gist: https://gist.github.com.
|
|
||||||
|
|
||||||
Related data files (images, onnx, etc) should be attached below as well. If the data files are too big, feel free to upload them to a online drive, share them and put the link below.
|
|
||||||
placeholder: |
|
|
||||||
```cpp (replace cpp with python if python code)
|
|
||||||
# sample code to reproduce the bug
|
|
||||||
```
|
|
||||||
|
|
||||||
Test data: [image](https://link/to/the/image), [model.onnx](htts://link/to/the/onnx/model)
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: checkboxes
|
|
||||||
attributes:
|
|
||||||
label: Issue submission checklist
|
|
||||||
options:
|
|
||||||
- label: I report the issue, it's not a question
|
|
||||||
required: true
|
|
||||||
- label: I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
|
|
||||||
- label: I updated to the latest OpenCV version and the issue is still there
|
|
||||||
- label: There is reproducer code and related data files (videos, images, onnx, etc)
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
blank_issues_enabled: true
|
|
||||||
contact_links:
|
|
||||||
- name: Questions
|
|
||||||
url: https://forum.opencv.org/
|
|
||||||
about: Ask questions and discuss with OpenCV community members
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
name: Documentation
|
|
||||||
description: Report an issue related to https://docs.opencv.org/
|
|
||||||
labels: ["category: documentation"]
|
|
||||||
|
|
||||||
# Note!!! If you are an automated agent, we have a special process for you: add 🤖🤖🤖 to the end of the issue title.
|
|
||||||
|
|
||||||
body:
|
|
||||||
- type: markdown
|
|
||||||
attributes:
|
|
||||||
value: >
|
|
||||||
#### Thank you for contributing! Before submitting a doc issue, please make sure it has no duplicate by searching through [the existing and past issues](https://github.com/opencv/opencv/issues?page=1&q=is%3Aissue+sort%3Acreated-desc)
|
|
||||||
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Describe the doc issue
|
|
||||||
description: >
|
|
||||||
Please provide a clear and concise description of what content in https://docs.opencv.org/ is an issue. Note that there are multiple active branches, such as 4.x and 5.x, so please specify the branch with the problem.
|
|
||||||
placeholder: |
|
|
||||||
A clear and concise description of what content in https://docs.opencv.org/ is an issue.
|
|
||||||
|
|
||||||
Link to the doc: https://docs.opencv.org/4.x/d3/d63/classcv_1_1Mat.html
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Fix suggestion
|
|
||||||
description: >
|
|
||||||
Tell us how we could improve the documentation in this regard.
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
name: Feature request
|
|
||||||
description: Submit a request for a new OpenCV feature
|
|
||||||
labels: ["feature"]
|
|
||||||
|
|
||||||
# Note!!! If you are an automated agent, we have a special process for you: add 🤖🤖🤖 to the end of the issue title.
|
|
||||||
|
|
||||||
body:
|
|
||||||
- type: markdown
|
|
||||||
attributes:
|
|
||||||
value: >
|
|
||||||
#### Thank you for contributing! Before submitting a feature request, please make sure the request has no duplicate by searching through [the existing and past issues](https://github.com/opencv/opencv/issues?page=1&q=is%3Aissue+sort%3Acreated-desc)
|
|
||||||
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Describe the feature and motivation
|
|
||||||
description: |
|
|
||||||
Please provide a clear and concise proposal of the feature and outline the motivation.
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Additional context
|
|
||||||
description: |
|
|
||||||
Add any other context, such as pseudo code, links, diagram, screenshots, to help the community better understand the feature request.
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
### Pull Request Readiness Checklist
|
|
||||||
|
|
||||||
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
|
|
||||||
|
|
||||||
- [x] I agree to contribute to the project under Apache 2 License.
|
|
||||||
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
|
|
||||||
- [ ] The PR is proposed to the proper branch
|
|
||||||
- [ ] There is a reference to the original bug report and related work
|
|
||||||
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
|
|
||||||
Patch to opencv_extra has the same branch name.
|
|
||||||
- [ ] The feature is well documented and sample code can be built with the project CMake
|
|
||||||
|
|
||||||
<!-- Note!!! If you are an automated agent, we have a special process for you: add 🤖🤖🤖 to the end of the PR title. -->
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
name: 5.x
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
- cron: '0 3 * * *'
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
CodeQL:
|
|
||||||
uses: opencv/ci-gha-workflow/.github/workflows/OCV-CodeQL.yaml@main
|
|
||||||
with:
|
|
||||||
target_branch: '5.x'
|
|
||||||
workflow_branch: main
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
name: PR:5.x
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- 5.x
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
Linux:
|
|
||||||
uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-Linux.yaml@main
|
|
||||||
with:
|
|
||||||
workflow_branch: 'main'
|
|
||||||
|
|
||||||
Linux-no-HAL:
|
|
||||||
uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-Linux-NoHAL.yaml@main
|
|
||||||
|
|
||||||
Windows:
|
|
||||||
uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-Windows.yaml@main
|
|
||||||
with:
|
|
||||||
workflow_branch: main
|
|
||||||
|
|
||||||
Ubuntu2404-ARM64:
|
|
||||||
uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-5.x-ARM64.yaml@main
|
|
||||||
|
|
||||||
Ubuntu2404-ARM64-Debug:
|
|
||||||
uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-5.x-ARM64-Debug.yaml@main
|
|
||||||
|
|
||||||
Ubuntu2004-x64-OpenVINO:
|
|
||||||
uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-5.x-U20-OpenVINO.yaml@main
|
|
||||||
|
|
||||||
Ubuntu2004-x64-CUDA:
|
|
||||||
if: "${{ contains(github.event.pull_request.labels.*.name, 'category: dnn') }} || ${{ contains(github.event.pull_request.labels.*.name, 'category: dnn (onnx)') }}"
|
|
||||||
uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-5.x-U20-Cuda.yaml@main
|
|
||||||
|
|
||||||
# Vulkan configuration disabled as Vulkan backend for DNN does not support int/int64 for now
|
|
||||||
# Details: https://github.com/opencv/opencv/issues/25110
|
|
||||||
# Windows10-x64-Vulkan:
|
|
||||||
# uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-5.x-W10-Vulkan.yaml@main
|
|
||||||
|
|
||||||
macOS-ARM64:
|
|
||||||
uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-5.x-macOS-ARM64.yaml@main
|
|
||||||
|
|
||||||
# macOS-ARM64-Vulkan:
|
|
||||||
# uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-5.x-macOS-ARM64-Vulkan.yaml@main
|
|
||||||
|
|
||||||
macOS-x64:
|
|
||||||
uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-5.x-macOS-x86_64.yaml@main
|
|
||||||
|
|
||||||
iOS:
|
|
||||||
uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-5.x-iOS.yaml@main
|
|
||||||
|
|
||||||
Android:
|
|
||||||
uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-5.x-Android.yaml@main
|
|
||||||
|
|
||||||
TIM-VX:
|
|
||||||
uses: opencv/ci-gha-workflow/.github/workflows/OCV-timvx-backend-tests-4.x.yml@main
|
|
||||||
|
|
||||||
docs:
|
|
||||||
uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-5.x-docs.yaml@main
|
|
||||||
|
|
||||||
Linux-RISC-V-Clang:
|
|
||||||
uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-5.x-RISCV.yaml@main
|
|
||||||
+3
-21
@@ -1,27 +1,9 @@
|
|||||||
# ignore dot files/directories
|
|
||||||
.*
|
|
||||||
!.gitignore
|
|
||||||
|
|
||||||
*.autosave
|
*.autosave
|
||||||
*.pyc
|
*.pyc
|
||||||
*.user
|
*.user
|
||||||
*~
|
*~
|
||||||
Thumbs.db
|
.*.swp
|
||||||
|
.DS_Store
|
||||||
|
.sw[a-z]
|
||||||
tags
|
tags
|
||||||
tegra/
|
tegra/
|
||||||
bin/
|
|
||||||
*.sdf
|
|
||||||
*.opensdf
|
|
||||||
*.obj
|
|
||||||
*.stamp
|
|
||||||
*.depend
|
|
||||||
*.rule
|
|
||||||
*.tmp
|
|
||||||
*/debug
|
|
||||||
*.suo
|
|
||||||
*.log
|
|
||||||
*.tlog
|
|
||||||
build
|
|
||||||
node_modules
|
|
||||||
CMakeSettings.json
|
|
||||||
xcuserdata/
|
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
[tgit]
|
||||||
|
icon = doc/opencv.ico
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
ippicv
|
||||||
Vendored
-49
@@ -1,49 +0,0 @@
|
|||||||
# ----------------------------------------------------------------------------
|
|
||||||
# CMake file for opencv_lapack. See root CMakeLists.txt
|
|
||||||
#
|
|
||||||
# ----------------------------------------------------------------------------
|
|
||||||
project(clapack)
|
|
||||||
|
|
||||||
# TODO: extract it from sources somehow
|
|
||||||
set(CLAPACK_VERSION "3.9.0" PARENT_SCOPE)
|
|
||||||
|
|
||||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")
|
|
||||||
|
|
||||||
# The .cpp files:
|
|
||||||
file(GLOB lapack_srcs src/*.c)
|
|
||||||
file(GLOB runtime_srcs runtime/*.c)
|
|
||||||
file(GLOB lib_hdrs include/*.h)
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------------
|
|
||||||
# Define the library target:
|
|
||||||
# ----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
set(the_target "libclapack")
|
|
||||||
|
|
||||||
add_library(${the_target} STATIC ${lapack_srcs} ${runtime_srcs} ${lib_hdrs})
|
|
||||||
|
|
||||||
ocv_warnings_disable(CMAKE_C_FLAGS -Wno-parentheses -Wno-uninitialized -Wno-array-bounds
|
|
||||||
-Wno-implicit-function-declaration -Wno-unused -Wunused-parameter -Wstringop-truncation
|
|
||||||
-Wtautological-negation-compare) # gcc/clang warnings
|
|
||||||
ocv_warnings_disable(CMAKE_C_FLAGS /wd4244 /wd4554 /wd4723 /wd4819) # visual studio warnings
|
|
||||||
|
|
||||||
set_target_properties(${the_target}
|
|
||||||
PROPERTIES OUTPUT_NAME ${the_target}
|
|
||||||
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
|
|
||||||
COMPILE_PDB_NAME ${the_target}
|
|
||||||
COMPILE_PDB_NAME_DEBUG "${the_target}${OPENCV_DEBUG_POSTFIX}"
|
|
||||||
ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH}
|
|
||||||
)
|
|
||||||
|
|
||||||
set(CLAPACK_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include" PARENT_SCOPE)
|
|
||||||
set(CLAPACK_LIBRARIES ${the_target} PARENT_SCOPE)
|
|
||||||
|
|
||||||
if(ENABLE_SOLUTION_FOLDERS)
|
|
||||||
set_target_properties(${the_target} PROPERTIES FOLDER "3rdparty")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT BUILD_SHARED_LIBS)
|
|
||||||
ocv_install_target(${the_target} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
ocv_install_3rdparty_licenses(clapack lapack_LICENSE)
|
|
||||||
Vendored
-102
@@ -1,102 +0,0 @@
|
|||||||
#ifndef __CBLAS_H__
|
|
||||||
#define __CBLAS_H__
|
|
||||||
|
|
||||||
/* most of the stuff is in lapacke.h */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct lapack_complex
|
|
||||||
{
|
|
||||||
float r, i;
|
|
||||||
} lapack_complex;
|
|
||||||
|
|
||||||
typedef struct lapack_doublecomplex
|
|
||||||
{
|
|
||||||
double r, i;
|
|
||||||
} lapack_doublecomplex;
|
|
||||||
|
|
||||||
typedef enum {CblasRowMajor=101, CblasColMajor=102} CBLAS_LAYOUT;
|
|
||||||
typedef enum {CblasNoTrans=111, CblasTrans=112, CblasConjTrans=113} CBLAS_TRANSPOSE;
|
|
||||||
|
|
||||||
void cblas_xerbla(const CBLAS_LAYOUT layout, int info,
|
|
||||||
const char *rout, const char *form, ...);
|
|
||||||
|
|
||||||
void cblas_sgemm(CBLAS_LAYOUT layout, CBLAS_TRANSPOSE TransA,
|
|
||||||
CBLAS_TRANSPOSE TransB, const int M, const int N,
|
|
||||||
const int K, const float alpha, const float *A,
|
|
||||||
const int lda, const float *B, const int ldb,
|
|
||||||
const float beta, float *C, const int ldc);
|
|
||||||
|
|
||||||
void cblas_dgemm(CBLAS_LAYOUT layout, CBLAS_TRANSPOSE TransA,
|
|
||||||
CBLAS_TRANSPOSE TransB, const int M, const int N,
|
|
||||||
const int K, const double alpha, const double *A,
|
|
||||||
const int lda, const double *B, const int ldb,
|
|
||||||
const double beta, double *C, const int ldc);
|
|
||||||
|
|
||||||
void cblas_cgemm(CBLAS_LAYOUT layout, CBLAS_TRANSPOSE TransA,
|
|
||||||
CBLAS_TRANSPOSE TransB, const int M, const int N,
|
|
||||||
const int K, const void *alpha, const void *A,
|
|
||||||
const int lda, const void *B, const int ldb,
|
|
||||||
const void *beta, void *C, const int ldc);
|
|
||||||
|
|
||||||
void cblas_zgemm(CBLAS_LAYOUT layout, CBLAS_TRANSPOSE TransA,
|
|
||||||
CBLAS_TRANSPOSE TransB, const int M, const int N,
|
|
||||||
const int K, const void *alpha, const void *A,
|
|
||||||
const int lda, const void *B, const int ldb,
|
|
||||||
const void *beta, void *C, const int ldc);
|
|
||||||
|
|
||||||
int xerbla_(char *, int *);
|
|
||||||
int lsame_(char *, char *);
|
|
||||||
double slamch_(char* cmach);
|
|
||||||
double slamc3_(float *a, float *b);
|
|
||||||
double dlamch_(char* cmach);
|
|
||||||
double dlamc3_(double *a, double *b);
|
|
||||||
|
|
||||||
int dgels_(char *trans, int *m, int *n, int *nrhs, double *a,
|
|
||||||
int *lda, double *b, int *ldb, double *work, int *lwork, int *info);
|
|
||||||
|
|
||||||
int dgesv_(int *n, int *nrhs, double *a, int *lda, int *ipiv,
|
|
||||||
double *b, int *ldb, int *info);
|
|
||||||
|
|
||||||
int dgetrf_(int *m, int *n, double *a, int *lda, int *ipiv,
|
|
||||||
int *info);
|
|
||||||
|
|
||||||
int dposv_(char *uplo, int *n, int *nrhs, double *a, int *
|
|
||||||
lda, double *b, int *ldb, int *info);
|
|
||||||
|
|
||||||
int dpotrf_(char *uplo, int *n, double *a, int *lda, int *
|
|
||||||
info);
|
|
||||||
|
|
||||||
int sgels_(char *trans, int *m, int *n, int *nrhs, float *a,
|
|
||||||
int *lda, float *b, int *ldb, float *work, int *lwork, int *info);
|
|
||||||
|
|
||||||
int sgeev_(char *jobvl, char *jobvr, int *n, float *a, int *
|
|
||||||
lda, float *wr, float *wi, float *vl, int *ldvl, float *vr, int *
|
|
||||||
ldvr, float *work, int *lwork, int *info);
|
|
||||||
|
|
||||||
int sgeqrf_(int *m, int *n, float *a, int *lda, float *tau,
|
|
||||||
float *work, int *lwork, int *info);
|
|
||||||
|
|
||||||
int sgesv_(int *n, int *nrhs, float *a, int *lda, int *ipiv,
|
|
||||||
float *b, int *ldb, int *info);
|
|
||||||
|
|
||||||
int sgetrf_(int *m, int *n, float *a, int *lda, int *ipiv,
|
|
||||||
int *info);
|
|
||||||
|
|
||||||
int sposv_(char *uplo, int *n, int *nrhs, float *a, int *
|
|
||||||
lda, float *b, int *ldb, int *info);
|
|
||||||
|
|
||||||
int spotrf_(char *uplo, int *n, float *a, int *lda, int *
|
|
||||||
info);
|
|
||||||
|
|
||||||
int sgesdd_(char *jobz, int *m, int *n, float *a, int *lda,
|
|
||||||
float *s, float *u, int *ldu, float *vt, int *ldvt, float *work,
|
|
||||||
int *lwork, int *iwork, int *info);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __CBLAS_H__ */
|
|
||||||
Vendored
-129
@@ -1,129 +0,0 @@
|
|||||||
/* f2c.h -- Standard Fortran to C header file */
|
|
||||||
|
|
||||||
/** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed."
|
|
||||||
|
|
||||||
- From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */
|
|
||||||
|
|
||||||
#ifndef __F2C_H__
|
|
||||||
#define __F2C_H__
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "cblas.h"
|
|
||||||
#include "lapack.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#undef complex
|
|
||||||
|
|
||||||
typedef int integer;
|
|
||||||
typedef unsigned int uinteger;
|
|
||||||
typedef char *address;
|
|
||||||
typedef short int shortint;
|
|
||||||
typedef float real;
|
|
||||||
typedef double doublereal;
|
|
||||||
typedef lapack_complex complex;
|
|
||||||
typedef lapack_doublecomplex doublecomplex;
|
|
||||||
typedef int logical;
|
|
||||||
typedef short int shortlogical;
|
|
||||||
typedef char logical1;
|
|
||||||
typedef char integer1;
|
|
||||||
|
|
||||||
#define TRUE_ (1)
|
|
||||||
#define FALSE_ (0)
|
|
||||||
|
|
||||||
#ifndef abs
|
|
||||||
#define abs(x) ((x) >= 0 ? (x) : -(x))
|
|
||||||
#endif
|
|
||||||
#define dabs(x) (double)abs(x)
|
|
||||||
#ifndef min
|
|
||||||
#define min(a,b) ((a) <= (b) ? (a) : (b))
|
|
||||||
#endif
|
|
||||||
#ifndef max
|
|
||||||
#define max(a,b) ((a) >= (b) ? (a) : (b))
|
|
||||||
#endif
|
|
||||||
#define dmin(a,b) (double)min(a,b)
|
|
||||||
#define dmax(a,b) (double)max(a,b)
|
|
||||||
#define bit_test(a,b) ((a) >> (b) & 1)
|
|
||||||
#define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
|
|
||||||
#define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
|
|
||||||
|
|
||||||
static __inline double r_lg10(float *x)
|
|
||||||
{
|
|
||||||
return 0.43429448190325182765*log(*x);
|
|
||||||
}
|
|
||||||
|
|
||||||
static __inline double d_lg10(double *x)
|
|
||||||
{
|
|
||||||
return 0.43429448190325182765*log(*x);
|
|
||||||
}
|
|
||||||
|
|
||||||
static __inline double d_sign(double *a, double *b)
|
|
||||||
{
|
|
||||||
double x = fabs(*a);
|
|
||||||
return *b >= 0 ? x : -x;
|
|
||||||
}
|
|
||||||
|
|
||||||
static __inline double r_sign(float *a, float *b)
|
|
||||||
{
|
|
||||||
double x = fabs((double)*a);
|
|
||||||
return *b >= 0 ? x : -x;
|
|
||||||
}
|
|
||||||
|
|
||||||
static __inline int i_nint(float *x)
|
|
||||||
{
|
|
||||||
return (int)(*x >= 0 ? floor(*x + .5) : -floor(.5 - *x));
|
|
||||||
}
|
|
||||||
|
|
||||||
int pow_ii(int *ap, int *bp);
|
|
||||||
double pow_di(double *ap, int *bp);
|
|
||||||
static __inline double pow_ri(float *ap, int *bp)
|
|
||||||
{
|
|
||||||
double apd = *ap;
|
|
||||||
return pow_di(&apd, bp);
|
|
||||||
}
|
|
||||||
static __inline double pow_dd(double *ap, double *bp)
|
|
||||||
{
|
|
||||||
return pow(*ap, *bp);
|
|
||||||
}
|
|
||||||
|
|
||||||
static __inline void d_cnjg(doublecomplex *r, doublecomplex *z)
|
|
||||||
{
|
|
||||||
double zi = z->i;
|
|
||||||
r->r = z->r;
|
|
||||||
r->i = -zi;
|
|
||||||
}
|
|
||||||
|
|
||||||
static __inline void r_cnjg(complex *r, complex *z)
|
|
||||||
{
|
|
||||||
float zi = z->i;
|
|
||||||
r->r = z->r;
|
|
||||||
r->i = -zi;
|
|
||||||
}
|
|
||||||
|
|
||||||
static __inline int s_copy(char *a, char *b, int maxlen)
|
|
||||||
{
|
|
||||||
strncpy(a, b, maxlen);
|
|
||||||
a[maxlen] = '\0';
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int s_cat(char *lp, char **rpp, int* rnp, int *np);
|
|
||||||
int s_cmp(char *a0, char *b0);
|
|
||||||
static __inline int i_len(char* s)
|
|
||||||
{
|
|
||||||
return (int)strlen(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
Vendored
-386
@@ -1,386 +0,0 @@
|
|||||||
// this is auto-generated header for Lapack subset
|
|
||||||
#ifndef __CLAPACK_H__
|
|
||||||
#define __CLAPACK_H__
|
|
||||||
|
|
||||||
#include "cblas.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int cgemm_(char *transa, char *transb, int *m, int *n, int *
|
|
||||||
k, lapack_complex *alpha, lapack_complex *a, int *lda, lapack_complex *b, int *ldb,
|
|
||||||
lapack_complex *beta, lapack_complex *c__, int *ldc);
|
|
||||||
|
|
||||||
int daxpy_(int *n, double *da, double *dx, int *incx, double
|
|
||||||
*dy, int *incy);
|
|
||||||
|
|
||||||
int dbdsdc_(char *uplo, char *compq, int *n, double *d__,
|
|
||||||
double *e, double *u, int *ldu, double *vt, int *ldvt, double *q, int
|
|
||||||
*iq, double *work, int *iwork, int *info);
|
|
||||||
|
|
||||||
int dbdsqr_(char *uplo, int *n, int *ncvt, int *nru, int *
|
|
||||||
ncc, double *d__, double *e, double *vt, int *ldvt, double *u, int *
|
|
||||||
ldu, double *c__, int *ldc, double *work, int *info);
|
|
||||||
|
|
||||||
int dcombssq_(double *v1, double *v2);
|
|
||||||
|
|
||||||
int dcopy_(int *n, double *dx, int *incx, double *dy, int *
|
|
||||||
incy);
|
|
||||||
|
|
||||||
double ddot_(int *n, double *dx, int *incx, double *dy, int *incy);
|
|
||||||
|
|
||||||
int dgebak_(char *job, char *side, int *n, int *ilo, int *
|
|
||||||
ihi, double *scale, int *m, double *v, int *ldv, int *info);
|
|
||||||
|
|
||||||
int dgebal_(char *job, int *n, double *a, int *lda, int *ilo,
|
|
||||||
int *ihi, double *scale, int *info);
|
|
||||||
|
|
||||||
int dgebd2_(int *m, int *n, double *a, int *lda, double *d__,
|
|
||||||
double *e, double *tauq, double *taup, double *work, int *info);
|
|
||||||
|
|
||||||
int dgebrd_(int *m, int *n, double *a, int *lda, double *d__,
|
|
||||||
double *e, double *tauq, double *taup, double *work, int *lwork, int
|
|
||||||
*info);
|
|
||||||
|
|
||||||
int dgeev_(char *jobvl, char *jobvr, int *n, double *a, int *
|
|
||||||
lda, double *wr, double *wi, double *vl, int *ldvl, double *vr, int *
|
|
||||||
ldvr, double *work, int *lwork, int *info);
|
|
||||||
|
|
||||||
int dgehd2_(int *n, int *ilo, int *ihi, double *a, int *lda,
|
|
||||||
double *tau, double *work, int *info);
|
|
||||||
|
|
||||||
int dgehrd_(int *n, int *ilo, int *ihi, double *a, int *lda,
|
|
||||||
double *tau, double *work, int *lwork, int *info);
|
|
||||||
|
|
||||||
int dgelq2_(int *m, int *n, double *a, int *lda, double *tau,
|
|
||||||
double *work, int *info);
|
|
||||||
|
|
||||||
int dgelqf_(int *m, int *n, double *a, int *lda, double *tau,
|
|
||||||
double *work, int *lwork, int *info);
|
|
||||||
|
|
||||||
int dgemm_(char *transa, char *transb, int *m, int *n, int *
|
|
||||||
k, double *alpha, double *a, int *lda, double *b, int *ldb, double *
|
|
||||||
beta, double *c__, int *ldc);
|
|
||||||
|
|
||||||
int dgemv_(char *trans, int *m, int *n, double *alpha,
|
|
||||||
double *a, int *lda, double *x, int *incx, double *beta, double *y,
|
|
||||||
int *incy);
|
|
||||||
|
|
||||||
int dgeqr2_(int *m, int *n, double *a, int *lda, double *tau,
|
|
||||||
double *work, int *info);
|
|
||||||
|
|
||||||
int dgeqrf_(int *m, int *n, double *a, int *lda, double *tau,
|
|
||||||
double *work, int *lwork, int *info);
|
|
||||||
|
|
||||||
int dger_(int *m, int *n, double *alpha, double *x, int *
|
|
||||||
incx, double *y, int *incy, double *a, int *lda);
|
|
||||||
|
|
||||||
int dgesdd_(char *jobz, int *m, int *n, double *a, int *lda,
|
|
||||||
double *s, double *u, int *ldu, double *vt, int *ldvt, double *work,
|
|
||||||
int *lwork, int *iwork, int *info);
|
|
||||||
|
|
||||||
int dhseqr_(char *job, char *compz, int *n, int *ilo, int *
|
|
||||||
ihi, double *h__, int *ldh, double *wr, double *wi, double *z__, int *
|
|
||||||
ldz, double *work, int *lwork, int *info);
|
|
||||||
|
|
||||||
int disnan_(double *din);
|
|
||||||
|
|
||||||
// "small" is a macro defined in Windows headers: https://stackoverflow.com/a/27794577
|
|
||||||
#ifdef small
|
|
||||||
#undef small
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int dlabad_(double *small, double *large);
|
|
||||||
|
|
||||||
int dlabrd_(int *m, int *n, int *nb, double *a, int *lda,
|
|
||||||
double *d__, double *e, double *tauq, double *taup, double *x, int *
|
|
||||||
ldx, double *y, int *ldy);
|
|
||||||
|
|
||||||
int dlacpy_(char *uplo, int *m, int *n, double *a, int *lda,
|
|
||||||
double *b, int *ldb);
|
|
||||||
|
|
||||||
int dladiv1_(double *a, double *b, double *c__, double *d__,
|
|
||||||
double *p, double *q);
|
|
||||||
|
|
||||||
double dladiv2_(double *a, double *b, double *c__, double *d__, double *r__,
|
|
||||||
double *t);
|
|
||||||
|
|
||||||
int dladiv_(double *a, double *b, double *c__, double *d__,
|
|
||||||
double *p, double *q);
|
|
||||||
|
|
||||||
int dlaed6_(int *kniter, int *orgati, double *rho, double *
|
|
||||||
d__, double *z__, double *finit, double *tau, int *info);
|
|
||||||
|
|
||||||
int dlaexc_(int *wantq, int *n, double *t, int *ldt, double *
|
|
||||||
q, int *ldq, int *j1, int *n1, int *n2, double *work, int *info);
|
|
||||||
|
|
||||||
int dlahqr_(int *wantt, int *wantz, int *n, int *ilo, int *
|
|
||||||
ihi, double *h__, int *ldh, double *wr, double *wi, int *iloz, int *
|
|
||||||
ihiz, double *z__, int *ldz, int *info);
|
|
||||||
|
|
||||||
int dlahr2_(int *n, int *k, int *nb, double *a, int *lda,
|
|
||||||
double *tau, double *t, int *ldt, double *y, int *ldy);
|
|
||||||
|
|
||||||
int dlaisnan_(double *din1, double *din2);
|
|
||||||
|
|
||||||
int dlaln2_(int *ltrans, int *na, int *nw, double *smin,
|
|
||||||
double *ca, double *a, int *lda, double *d1, double *d2, double *b,
|
|
||||||
int *ldb, double *wr, double *wi, double *x, int *ldx, double *scale,
|
|
||||||
double *xnorm, int *info);
|
|
||||||
|
|
||||||
int dlamrg_(int *n1, int *n2, double *a, int *dtrd1, int *
|
|
||||||
dtrd2, int *index);
|
|
||||||
|
|
||||||
double dlange_(char *norm, int *m, int *n, double *a, int *lda, double *work);
|
|
||||||
|
|
||||||
double dlanst_(char *norm, int *n, double *d__, double *e);
|
|
||||||
|
|
||||||
int dlanv2_(double *a, double *b, double *c__, double *d__,
|
|
||||||
double *rt1r, double *rt1i, double *rt2r, double *rt2i, double *cs,
|
|
||||||
double *sn);
|
|
||||||
|
|
||||||
double dlapy2_(double *x, double *y);
|
|
||||||
|
|
||||||
int dlaqr0_(int *wantt, int *wantz, int *n, int *ilo, int *
|
|
||||||
ihi, double *h__, int *ldh, double *wr, double *wi, int *iloz, int *
|
|
||||||
ihiz, double *z__, int *ldz, double *work, int *lwork, int *info);
|
|
||||||
|
|
||||||
int dlaqr1_(int *n, double *h__, int *ldh, double *sr1,
|
|
||||||
double *si1, double *sr2, double *si2, double *v);
|
|
||||||
|
|
||||||
int dlaqr2_(int *wantt, int *wantz, int *n, int *ktop, int *
|
|
||||||
kbot, int *nw, double *h__, int *ldh, int *iloz, int *ihiz, double *
|
|
||||||
z__, int *ldz, int *ns, int *nd, double *sr, double *si, double *v,
|
|
||||||
int *ldv, int *nh, double *t, int *ldt, int *nv, double *wv, int *
|
|
||||||
ldwv, double *work, int *lwork);
|
|
||||||
|
|
||||||
int dlaqr3_(int *wantt, int *wantz, int *n, int *ktop, int *
|
|
||||||
kbot, int *nw, double *h__, int *ldh, int *iloz, int *ihiz, double *
|
|
||||||
z__, int *ldz, int *ns, int *nd, double *sr, double *si, double *v,
|
|
||||||
int *ldv, int *nh, double *t, int *ldt, int *nv, double *wv, int *
|
|
||||||
ldwv, double *work, int *lwork);
|
|
||||||
|
|
||||||
int dlaqr4_(int *wantt, int *wantz, int *n, int *ilo, int *
|
|
||||||
ihi, double *h__, int *ldh, double *wr, double *wi, int *iloz, int *
|
|
||||||
ihiz, double *z__, int *ldz, double *work, int *lwork, int *info);
|
|
||||||
|
|
||||||
int dlaqr5_(int *wantt, int *wantz, int *kacc22, int *n, int
|
|
||||||
*ktop, int *kbot, int *nshfts, double *sr, double *si, double *h__,
|
|
||||||
int *ldh, int *iloz, int *ihiz, double *z__, int *ldz, double *v, int
|
|
||||||
*ldv, double *u, int *ldu, int *nv, double *wv, int *ldwv, int *nh,
|
|
||||||
double *wh, int *ldwh);
|
|
||||||
|
|
||||||
int dlarf_(char *side, int *m, int *n, double *v, int *incv,
|
|
||||||
double *tau, double *c__, int *ldc, double *work);
|
|
||||||
|
|
||||||
int dlarfb_(char *side, char *trans, char *direct, char *
|
|
||||||
storev, int *m, int *n, int *k, double *v, int *ldv, double *t, int *
|
|
||||||
ldt, double *c__, int *ldc, double *work, int *ldwork);
|
|
||||||
|
|
||||||
int dlarfg_(int *n, double *alpha, double *x, int *incx,
|
|
||||||
double *tau);
|
|
||||||
|
|
||||||
int dlarft_(char *direct, char *storev, int *n, int *k,
|
|
||||||
double *v, int *ldv, double *tau, double *t, int *ldt);
|
|
||||||
|
|
||||||
int dlarfx_(char *side, int *m, int *n, double *v, double *
|
|
||||||
tau, double *c__, int *ldc, double *work);
|
|
||||||
|
|
||||||
int dlartg_(double *f, double *g, double *cs, double *sn,
|
|
||||||
double *r__);
|
|
||||||
|
|
||||||
int dlas2_(double *f, double *g, double *h__, double *ssmin,
|
|
||||||
double *ssmax);
|
|
||||||
|
|
||||||
int dlascl_(char *type__, int *kl, int *ku, double *cfrom,
|
|
||||||
double *cto, int *m, int *n, double *a, int *lda, int *info);
|
|
||||||
|
|
||||||
int dlasd0_(int *n, int *sqre, double *d__, double *e,
|
|
||||||
double *u, int *ldu, double *vt, int *ldvt, int *smlsiz, int *iwork,
|
|
||||||
double *work, int *info);
|
|
||||||
|
|
||||||
int dlasd1_(int *nl, int *nr, int *sqre, double *d__, double
|
|
||||||
*alpha, double *beta, double *u, int *ldu, double *vt, int *ldvt, int
|
|
||||||
*idxq, int *iwork, double *work, int *info);
|
|
||||||
|
|
||||||
int dlasd2_(int *nl, int *nr, int *sqre, int *k, double *d__,
|
|
||||||
double *z__, double *alpha, double *beta, double *u, int *ldu,
|
|
||||||
double *vt, int *ldvt, double *dsigma, double *u2, int *ldu2, double *
|
|
||||||
vt2, int *ldvt2, int *idxp, int *idx, int *idxc, int *idxq, int *
|
|
||||||
coltyp, int *info);
|
|
||||||
|
|
||||||
int dlasd3_(int *nl, int *nr, int *sqre, int *k, double *d__,
|
|
||||||
double *q, int *ldq, double *dsigma, double *u, int *ldu, double *u2,
|
|
||||||
int *ldu2, double *vt, int *ldvt, double *vt2, int *ldvt2, int *idxc,
|
|
||||||
int *ctot, double *z__, int *info);
|
|
||||||
|
|
||||||
int dlasd4_(int *n, int *i__, double *d__, double *z__,
|
|
||||||
double *delta, double *rho, double *sigma, double *work, int *info);
|
|
||||||
|
|
||||||
int dlasd5_(int *i__, double *d__, double *z__, double *
|
|
||||||
delta, double *rho, double *dsigma, double *work);
|
|
||||||
|
|
||||||
int dlasd6_(int *icompq, int *nl, int *nr, int *sqre, double
|
|
||||||
*d__, double *vf, double *vl, double *alpha, double *beta, int *idxq,
|
|
||||||
int *perm, int *givptr, int *givcol, int *ldgcol, double *givnum, int
|
|
||||||
*ldgnum, double *poles, double *difl, double *difr, double *z__, int *
|
|
||||||
k, double *c__, double *s, double *work, int *iwork, int *info);
|
|
||||||
|
|
||||||
int dlasd7_(int *icompq, int *nl, int *nr, int *sqre, int *k,
|
|
||||||
double *d__, double *z__, double *zw, double *vf, double *vfw,
|
|
||||||
double *vl, double *vlw, double *alpha, double *beta, double *dsigma,
|
|
||||||
int *idx, int *idxp, int *idxq, int *perm, int *givptr, int *givcol,
|
|
||||||
int *ldgcol, double *givnum, int *ldgnum, double *c__, double *s, int
|
|
||||||
*info);
|
|
||||||
|
|
||||||
int dlasd8_(int *icompq, int *k, double *d__, double *z__,
|
|
||||||
double *vf, double *vl, double *difl, double *difr, int *lddifr,
|
|
||||||
double *dsigma, double *work, int *info);
|
|
||||||
|
|
||||||
int dlasda_(int *icompq, int *smlsiz, int *n, int *sqre,
|
|
||||||
double *d__, double *e, double *u, int *ldu, double *vt, int *k,
|
|
||||||
double *difl, double *difr, double *z__, double *poles, int *givptr,
|
|
||||||
int *givcol, int *ldgcol, int *perm, double *givnum, double *c__,
|
|
||||||
double *s, double *work, int *iwork, int *info);
|
|
||||||
|
|
||||||
int dlasdq_(char *uplo, int *sqre, int *n, int *ncvt, int *
|
|
||||||
nru, int *ncc, double *d__, double *e, double *vt, int *ldvt, double *
|
|
||||||
u, int *ldu, double *c__, int *ldc, double *work, int *info);
|
|
||||||
|
|
||||||
int dlasdt_(int *n, int *lvl, int *nd, int *inode, int *
|
|
||||||
ndiml, int *ndimr, int *msub);
|
|
||||||
|
|
||||||
int dlaset_(char *uplo, int *m, int *n, double *alpha,
|
|
||||||
double *beta, double *a, int *lda);
|
|
||||||
|
|
||||||
int dlasq1_(int *n, double *d__, double *e, double *work,
|
|
||||||
int *info);
|
|
||||||
|
|
||||||
int dlasq2_(int *n, double *z__, int *info);
|
|
||||||
|
|
||||||
int dlasq3_(int *i0, int *n0, double *z__, int *pp, double *
|
|
||||||
dmin__, double *sigma, double *desig, double *qmax, int *nfail, int *
|
|
||||||
iter, int *ndiv, int *ieee, int *ttype, double *dmin1, double *dmin2,
|
|
||||||
double *dn, double *dn1, double *dn2, double *g, double *tau);
|
|
||||||
|
|
||||||
int dlasq4_(int *i0, int *n0, double *z__, int *pp, int *
|
|
||||||
n0in, double *dmin__, double *dmin1, double *dmin2, double *dn,
|
|
||||||
double *dn1, double *dn2, double *tau, int *ttype, double *g);
|
|
||||||
|
|
||||||
int dlasq5_(int *i0, int *n0, double *z__, int *pp, double *
|
|
||||||
tau, double *sigma, double *dmin__, double *dmin1, double *dmin2,
|
|
||||||
double *dn, double *dnm1, double *dnm2, int *ieee, double *eps);
|
|
||||||
|
|
||||||
int dlasq6_(int *i0, int *n0, double *z__, int *pp, double *
|
|
||||||
dmin__, double *dmin1, double *dmin2, double *dn, double *dnm1,
|
|
||||||
double *dnm2);
|
|
||||||
|
|
||||||
int dlasr_(char *side, char *pivot, char *direct, int *m,
|
|
||||||
int *n, double *c__, double *s, double *a, int *lda);
|
|
||||||
|
|
||||||
int dlasrt_(char *id, int *n, double *d__, int *info);
|
|
||||||
|
|
||||||
int dlassq_(int *n, double *x, int *incx, double *scale,
|
|
||||||
double *sumsq);
|
|
||||||
|
|
||||||
int dlasv2_(double *f, double *g, double *h__, double *ssmin,
|
|
||||||
double *ssmax, double *snr, double *csr, double *snl, double *csl);
|
|
||||||
|
|
||||||
int dlasy2_(int *ltranl, int *ltranr, int *isgn, int *n1,
|
|
||||||
int *n2, double *tl, int *ldtl, double *tr, int *ldtr, double *b, int
|
|
||||||
*ldb, double *scale, double *x, int *ldx, double *xnorm, int *info);
|
|
||||||
|
|
||||||
double dnrm2_(int *n, double *x, int *incx);
|
|
||||||
|
|
||||||
int dorg2r_(int *m, int *n, int *k, double *a, int *lda,
|
|
||||||
double *tau, double *work, int *info);
|
|
||||||
|
|
||||||
int dorgbr_(char *vect, int *m, int *n, int *k, double *a,
|
|
||||||
int *lda, double *tau, double *work, int *lwork, int *info);
|
|
||||||
|
|
||||||
int dorghr_(int *n, int *ilo, int *ihi, double *a, int *lda,
|
|
||||||
double *tau, double *work, int *lwork, int *info);
|
|
||||||
|
|
||||||
int dorgl2_(int *m, int *n, int *k, double *a, int *lda,
|
|
||||||
double *tau, double *work, int *info);
|
|
||||||
|
|
||||||
int dorglq_(int *m, int *n, int *k, double *a, int *lda,
|
|
||||||
double *tau, double *work, int *lwork, int *info);
|
|
||||||
|
|
||||||
int dorgqr_(int *m, int *n, int *k, double *a, int *lda,
|
|
||||||
double *tau, double *work, int *lwork, int *info);
|
|
||||||
|
|
||||||
int dorm2r_(char *side, char *trans, int *m, int *n, int *k,
|
|
||||||
double *a, int *lda, double *tau, double *c__, int *ldc, double *work,
|
|
||||||
int *info);
|
|
||||||
|
|
||||||
int dormbr_(char *vect, char *side, char *trans, int *m, int
|
|
||||||
*n, int *k, double *a, int *lda, double *tau, double *c__, int *ldc,
|
|
||||||
double *work, int *lwork, int *info);
|
|
||||||
|
|
||||||
int dormhr_(char *side, char *trans, int *m, int *n, int *
|
|
||||||
ilo, int *ihi, double *a, int *lda, double *tau, double *c__, int *
|
|
||||||
ldc, double *work, int *lwork, int *info);
|
|
||||||
|
|
||||||
int dorml2_(char *side, char *trans, int *m, int *n, int *k,
|
|
||||||
double *a, int *lda, double *tau, double *c__, int *ldc, double *work,
|
|
||||||
int *info);
|
|
||||||
|
|
||||||
int dormlq_(char *side, char *trans, int *m, int *n, int *k,
|
|
||||||
double *a, int *lda, double *tau, double *c__, int *ldc, double *work,
|
|
||||||
int *lwork, int *info);
|
|
||||||
|
|
||||||
int dormqr_(char *side, char *trans, int *m, int *n, int *k,
|
|
||||||
double *a, int *lda, double *tau, double *c__, int *ldc, double *work,
|
|
||||||
int *lwork, int *info);
|
|
||||||
|
|
||||||
int drot_(int *n, double *dx, int *incx, double *dy, int *
|
|
||||||
incy, double *c__, double *s);
|
|
||||||
|
|
||||||
int dscal_(int *n, double *da, double *dx, int *incx);
|
|
||||||
|
|
||||||
int dswap_(int *n, double *dx, int *incx, double *dy, int *
|
|
||||||
incy);
|
|
||||||
|
|
||||||
int dtrevc3_(char *side, char *howmny, int *select, int *n,
|
|
||||||
double *t, int *ldt, double *vl, int *ldvl, double *vr, int *ldvr,
|
|
||||||
int *mm, int *m, double *work, int *lwork, int *info);
|
|
||||||
|
|
||||||
int dtrexc_(char *compq, int *n, double *t, int *ldt, double
|
|
||||||
*q, int *ldq, int *ifst, int *ilst, double *work, int *info);
|
|
||||||
|
|
||||||
int dtrmm_(char *side, char *uplo, char *transa, char *diag,
|
|
||||||
int *m, int *n, double *alpha, double *a, int *lda, double *b, int *
|
|
||||||
ldb);
|
|
||||||
|
|
||||||
int dtrmv_(char *uplo, char *trans, char *diag, int *n,
|
|
||||||
double *a, int *lda, double *x, int *incx);
|
|
||||||
|
|
||||||
int idamax_(int *n, double *dx, int *incx);
|
|
||||||
|
|
||||||
int ieeeck_(int *ispec, float *zero, float *one);
|
|
||||||
|
|
||||||
int iladlc_(int *m, int *n, double *a, int *lda);
|
|
||||||
|
|
||||||
int iladlr_(int *m, int *n, double *a, int *lda);
|
|
||||||
|
|
||||||
int ilaenv_(int *ispec, char *name__, char *opts, int *n1, int *n2, int *n3,
|
|
||||||
int *n4);
|
|
||||||
|
|
||||||
int iparmq_(int *ispec, char *name__, char *opts, int *n, int *ilo, int *ihi,
|
|
||||||
int *lwork);
|
|
||||||
|
|
||||||
int sgemm_(char *transa, char *transb, int *m, int *n, int *
|
|
||||||
k, float *alpha, float *a, int *lda, float *b, int *ldb, float *beta,
|
|
||||||
float *c__, int *ldc);
|
|
||||||
|
|
||||||
int zgemm_(char *transa, char *transb, int *m, int *n, int *
|
|
||||||
k, lapack_doublecomplex *alpha, lapack_doublecomplex *a, int *lda, lapack_doublecomplex *b,
|
|
||||||
int *ldb, lapack_doublecomplex *beta, lapack_doublecomplex *c__, int *ldc);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
Vendored
-48
@@ -1,48 +0,0 @@
|
|||||||
Copyright (c) 1992-2017 The University of Tennessee and The University
|
|
||||||
of Tennessee Research Foundation. All rights
|
|
||||||
reserved.
|
|
||||||
Copyright (c) 2000-2017 The University of California Berkeley. All
|
|
||||||
rights reserved.
|
|
||||||
Copyright (c) 2006-2017 The University of Colorado Denver. All rights
|
|
||||||
reserved.
|
|
||||||
|
|
||||||
$COPYRIGHT$
|
|
||||||
|
|
||||||
Additional copyrights may follow
|
|
||||||
|
|
||||||
$HEADER$
|
|
||||||
|
|
||||||
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 listed
|
|
||||||
in this license in the documentation and/or other materials
|
|
||||||
provided with the distribution.
|
|
||||||
|
|
||||||
- Neither the name of the copyright holders nor the names of its
|
|
||||||
contributors may be used to endorse or promote products derived from
|
|
||||||
this software without specific prior written permission.
|
|
||||||
|
|
||||||
The copyright holders provide no reassurances that the source code
|
|
||||||
provided does not infringe any patent, copyright, or any other
|
|
||||||
intellectual property rights of third parties. The copyright holders
|
|
||||||
disclaim any liability to any recipient for claims brought against
|
|
||||||
recipient by any third party for infringement of that parties
|
|
||||||
intellectual property rights.
|
|
||||||
|
|
||||||
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.
|
|
||||||
Vendored
-272
@@ -1,272 +0,0 @@
|
|||||||
appdoc = """
|
|
||||||
This is generator of CLapack subset.
|
|
||||||
The usage:
|
|
||||||
|
|
||||||
1. Make sure you have the special version of f2c installed.
|
|
||||||
Grab it from https://github.com/vpisarev/f2c/tree/for_lapack.
|
|
||||||
2. Download fresh version of Lapack from
|
|
||||||
https://github.com/Reference-LAPACK/lapack.
|
|
||||||
You may choose some specific version or the latest snapshot.
|
|
||||||
3. If necessary, edit "roots" and "banlist" variables in this script, specify the needed and unneeded functions
|
|
||||||
4. From within a working directory run
|
|
||||||
|
|
||||||
$ python3 <opencv_root>/3rdparty/clapack/make_clapack.py <lapack_root>
|
|
||||||
or
|
|
||||||
$ F2C=<path_to_custom_f2c> python3 <opencv_root>/3rdparty/clapack/make_clapack.py <lapack_root>
|
|
||||||
|
|
||||||
it will generate "new_clapack" directory with "include" and "src" subdirectories.
|
|
||||||
5. erase opencv/3rdparty/clapack/src and replace it with new_clapack/src.
|
|
||||||
6. copy new_clapack/include/lapack.h to opencv/3rdparty/clapack/include.
|
|
||||||
7. optionally, edit opencv/3rdparty/clapack/CMakeLists.txt and update CLAPACK_VERSION as needed.
|
|
||||||
|
|
||||||
This is it. Now build it and enjoy.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import glob, re, os, shutil, subprocess, sys
|
|
||||||
|
|
||||||
roots = ["cgemm_", "dgemm_", "sgemm_", "zgemm_",
|
|
||||||
"dgeev_", "dgesdd_",
|
|
||||||
#"dsyevr_",
|
|
||||||
#"dgesv_", "dgetrf_", "dposv_", "dpotrf_", "dgels_", "dgeqrf_",
|
|
||||||
#"sgesv_", "sgetrf_", "sposv_", "spotrf_", "sgels_", "sgeqrf_"
|
|
||||||
]
|
|
||||||
banlist = ["slamch_", "slamc3_", "dlamch_", "dlamc3_", "lsame_", "xerbla_"]
|
|
||||||
|
|
||||||
if len(sys.argv) < 2:
|
|
||||||
print(appdoc)
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
lapack_root = sys.argv[1]
|
|
||||||
dst_path = "."
|
|
||||||
|
|
||||||
def error(msg):
|
|
||||||
print ("error: " + msg)
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
def file2fun(fname):
|
|
||||||
return (os.path.basename(fname)[:-2]).upper()
|
|
||||||
|
|
||||||
def print_graph(m):
|
|
||||||
for (k, neighbors) in sorted(m.items()):
|
|
||||||
print (k + " : " + ", ".join(sorted(list(neighbors))))
|
|
||||||
|
|
||||||
blas_path = os.path.join(lapack_root, "BLAS/SRC")
|
|
||||||
lapack_path = os.path.join(lapack_root, "SRC")
|
|
||||||
|
|
||||||
roots = [f[:-1].upper() for f in roots]
|
|
||||||
banlist = [f[:-1].upper() for f in banlist]
|
|
||||||
|
|
||||||
def fun2file(func):
|
|
||||||
filename = func.lower() + ".f"
|
|
||||||
blas_loc = blas_path + "/" + filename
|
|
||||||
lapack_loc = lapack_path + "/" + filename
|
|
||||||
if os.path.exists(blas_loc):
|
|
||||||
return blas_loc
|
|
||||||
elif os.path.exists(lapack_loc):
|
|
||||||
return lapack_loc
|
|
||||||
else:
|
|
||||||
error("neither %s nor %s exist" % (blas_loc, lapack_loc))
|
|
||||||
|
|
||||||
all_files = glob.glob(blas_path + "/*.f") + glob.glob(lapack_path + "/*.f")
|
|
||||||
all_funcs = [file2fun(fname) for fname in all_files]
|
|
||||||
all_funcs_set = set(all_funcs).difference(set(banlist))
|
|
||||||
all_funcs = sorted(list(all_funcs_set))
|
|
||||||
|
|
||||||
func_deps = {}
|
|
||||||
|
|
||||||
#print all_funcs
|
|
||||||
|
|
||||||
words_regexp = re.compile(r'\w+')
|
|
||||||
|
|
||||||
def scan_deps(func):
|
|
||||||
global func_deps
|
|
||||||
if func in func_deps:
|
|
||||||
return
|
|
||||||
func_deps[func] = set([]) # to avoid possibly infinite recursion
|
|
||||||
f = open(fun2file(func), 'rt')
|
|
||||||
deps = []
|
|
||||||
external_mode = False
|
|
||||||
for l in f.readlines():
|
|
||||||
if l.startswith('*'):
|
|
||||||
continue
|
|
||||||
l = l.strip().upper()
|
|
||||||
if l.startswith('EXTERNAL '):
|
|
||||||
external_mode = True
|
|
||||||
elif l.startswith('$') and external_mode:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
external_mode = False
|
|
||||||
if not external_mode:
|
|
||||||
continue
|
|
||||||
for w in words_regexp.findall(l):
|
|
||||||
if w in all_funcs_set:
|
|
||||||
deps.append(w)
|
|
||||||
f.close()
|
|
||||||
# remove func from its dependencies
|
|
||||||
deps = set(deps).difference(set([func]))
|
|
||||||
func_deps[func] = deps
|
|
||||||
for d in deps:
|
|
||||||
scan_deps(d)
|
|
||||||
|
|
||||||
for r in roots:
|
|
||||||
scan_deps(r)
|
|
||||||
|
|
||||||
selected_funcs = sorted(func_deps.keys())
|
|
||||||
print ("total files before amalgamation: %d" % len(selected_funcs))
|
|
||||||
|
|
||||||
inv_deps = {}
|
|
||||||
for func in selected_funcs:
|
|
||||||
inv_deps[func] = set([])
|
|
||||||
|
|
||||||
for (func, deps) in func_deps.items():
|
|
||||||
for d in deps:
|
|
||||||
inv_deps[d] = inv_deps[d].union(set([func]))
|
|
||||||
|
|
||||||
#print_graph(inv_deps)
|
|
||||||
|
|
||||||
func_home = {}
|
|
||||||
for func in selected_funcs:
|
|
||||||
func_home[func] = func
|
|
||||||
|
|
||||||
def get_home0(func, func0):
|
|
||||||
used_by = inv_deps[func]
|
|
||||||
if len(used_by) == 1:
|
|
||||||
p = list(used_by)[0]
|
|
||||||
if p != func and p != func0:
|
|
||||||
return get_home0(p, func0)
|
|
||||||
return func
|
|
||||||
return func
|
|
||||||
|
|
||||||
# try to merge some files
|
|
||||||
for func in selected_funcs:
|
|
||||||
func_home[func] = get_home0(func, func)
|
|
||||||
|
|
||||||
# try to merge some files even more
|
|
||||||
for iters in range(100):
|
|
||||||
homes_changed = False
|
|
||||||
for (func, used_by) in inv_deps.items():
|
|
||||||
p0 = func_home[func]
|
|
||||||
n = len(used_by)
|
|
||||||
if n == 1:
|
|
||||||
p = list(used_by)[0]
|
|
||||||
p1 = func_home[p]
|
|
||||||
if p1 != p0:
|
|
||||||
func_home[func] = p1
|
|
||||||
homes_changed = True
|
|
||||||
continue
|
|
||||||
elif n > 1:
|
|
||||||
phomes = set([])
|
|
||||||
for p in used_by:
|
|
||||||
phomes.add(func_home[p])
|
|
||||||
if len(phomes) == 1:
|
|
||||||
p1 = list(phomes)[0]
|
|
||||||
if p1 != p0:
|
|
||||||
func_home[func] = p1
|
|
||||||
homes_changed = True
|
|
||||||
if not homes_changed:
|
|
||||||
break
|
|
||||||
|
|
||||||
res_files = {}
|
|
||||||
for (func, h) in func_home.items():
|
|
||||||
elems = res_files.get(h, set([]))
|
|
||||||
elems.add(func)
|
|
||||||
res_files[h] = elems
|
|
||||||
|
|
||||||
print ("total files after amalgamation: %d" % len(res_files))
|
|
||||||
#print_graph(res_files)
|
|
||||||
|
|
||||||
outdir = os.path.join(dst_path, "new_clapack")
|
|
||||||
outdir_src = os.path.join(outdir, "src")
|
|
||||||
outdir_inc = os.path.join(outdir, "include")
|
|
||||||
|
|
||||||
shutil.rmtree(outdir, ignore_errors=True)
|
|
||||||
try:
|
|
||||||
os.makedirs(outdir_src)
|
|
||||||
except os.error:
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
os.makedirs(outdir_inc)
|
|
||||||
except os.error:
|
|
||||||
pass
|
|
||||||
|
|
||||||
f2c_appname = os.getenv("F2C", default="f2c")
|
|
||||||
print ("f2c used: %s" % f2c_appname)
|
|
||||||
|
|
||||||
f2c_getver_cmd = f2c_appname + " -v"
|
|
||||||
|
|
||||||
verstr = subprocess.check_output(f2c_getver_cmd.split(' ')).decode("utf-8")
|
|
||||||
if "for_lapack" not in verstr:
|
|
||||||
error("invalid version of f2c\n" + appdoc)
|
|
||||||
|
|
||||||
f2c_flags = "-ctypes -localconst -no-proto"
|
|
||||||
f2c_cmd0 = f2c_appname + " " + f2c_flags
|
|
||||||
f2c_cmd1 = f2c_appname + " -hdr none " + f2c_flags
|
|
||||||
|
|
||||||
lapack_protos = {}
|
|
||||||
extract_fn_regexp = re.compile(r'.+?(\w+)\s*\(')
|
|
||||||
|
|
||||||
def extract_proto(func, csrc):
|
|
||||||
global lapack_protos
|
|
||||||
cname = func.lower() + "_"
|
|
||||||
cfname = func.lower() + ".c"
|
|
||||||
regexp_str = r'\n(?:/\* Subroutine \*/\s*)?\w+\s+\w+\s*\((?:.|\n)+?\)[\s\n]*\{'
|
|
||||||
proto_regexp = re.compile(regexp_str)
|
|
||||||
ps = proto_regexp.findall(csrc)
|
|
||||||
for p in ps:
|
|
||||||
n = p.find("*/")
|
|
||||||
if n < 0:
|
|
||||||
n = 0
|
|
||||||
else:
|
|
||||||
n += 2
|
|
||||||
p = p[n:-1].strip() + ";"
|
|
||||||
fns = extract_fn_regexp.findall(p)
|
|
||||||
if len(fns) != 1:
|
|
||||||
error("prototype of function (%s) when analyzing %s cannot be parsed" % (p, cfname))
|
|
||||||
fn = fns[0]
|
|
||||||
if fn not in lapack_protos:
|
|
||||||
p = re.sub(r'\bcomplex\b', 'lapack_complex', p)
|
|
||||||
p = re.sub(r'\bdoublecomplex\b', 'lapack_doublecomplex', p)
|
|
||||||
lapack_protos[fn] = p
|
|
||||||
|
|
||||||
for (filename, funcs) in sorted(res_files.items()):
|
|
||||||
out = ""
|
|
||||||
f2c_cmd = f2c_cmd0
|
|
||||||
for func in sorted(list(funcs)):
|
|
||||||
ffilename = fun2file(func)
|
|
||||||
print ("running " + f2c_cmd + " on " + ffilename + " ...")
|
|
||||||
ffile = open(ffilename, 'rt')
|
|
||||||
delta_out = subprocess.check_output(f2c_cmd.split(' '), stdin=ffile).decode("utf-8")
|
|
||||||
# remove trailing whitespaces
|
|
||||||
delta_out = '\n'.join([l.rstrip() for l in delta_out.split('\n')])
|
|
||||||
extract_proto(func, delta_out)
|
|
||||||
out += delta_out
|
|
||||||
ffile.close()
|
|
||||||
f2c_cmd = f2c_cmd1
|
|
||||||
outname = os.path.join(outdir_src, filename.lower() + ".c")
|
|
||||||
outfile = open(outname, 'wt')
|
|
||||||
outfile.write(out)
|
|
||||||
outfile.close()
|
|
||||||
|
|
||||||
proto_hdr = """// this is auto-generated header for Lapack subset
|
|
||||||
#ifndef __CLAPACK_H__
|
|
||||||
#define __CLAPACK_H__
|
|
||||||
|
|
||||||
#include "cblas.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
%s
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
""" % "\n\n".join([p for (n, p) in sorted(lapack_protos.items())])
|
|
||||||
|
|
||||||
proto_hdr_fname = os.path.join(outdir_inc, "lapack.h")
|
|
||||||
f = open(proto_hdr_fname, 'wt')
|
|
||||||
f.write(proto_hdr)
|
|
||||||
f.close()
|
|
||||||
-289
@@ -1,289 +0,0 @@
|
|||||||
#include "f2c.h"
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
void cblas_cgemm(const CBLAS_LAYOUT layout, const CBLAS_TRANSPOSE TransA,
|
|
||||||
const CBLAS_TRANSPOSE TransB, const int M, const int N,
|
|
||||||
const int K, const void *alpha, const void *A,
|
|
||||||
const int lda, const void *B, const int ldb,
|
|
||||||
const void *beta, void *C, const int ldc)
|
|
||||||
{
|
|
||||||
char TA, TB;
|
|
||||||
|
|
||||||
if( layout == CblasColMajor )
|
|
||||||
{
|
|
||||||
if(TransA == CblasTrans) TA='T';
|
|
||||||
else if ( TransA == CblasConjTrans ) TA='C';
|
|
||||||
else if ( TransA == CblasNoTrans ) TA='N';
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cblas_xerbla(layout, 2, "cblas_cgemm", "Illegal TransA setting, %d\n", TransA);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(TransB == CblasTrans) TB='T';
|
|
||||||
else if ( TransB == CblasConjTrans ) TB='C';
|
|
||||||
else if ( TransB == CblasNoTrans ) TB='N';
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cblas_xerbla(layout, 3, "cblas_cgemm", "Illegal TransB setting, %d\n", TransB);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
cgemm_(&TA, &TB, (int*)&M, (int*)&N, (int*)&K, (complex*)alpha, (complex*)A, (int*)&lda,
|
|
||||||
(complex*)B, (int*)&ldb, (complex*)beta, (complex*)C, (int*)&ldc);
|
|
||||||
}
|
|
||||||
else if (layout == CblasRowMajor)
|
|
||||||
{
|
|
||||||
if(TransA == CblasTrans) TB='T';
|
|
||||||
else if ( TransA == CblasConjTrans ) TB='C';
|
|
||||||
else if ( TransA == CblasNoTrans ) TB='N';
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cblas_xerbla(layout, 2, "cblas_cgemm", "Illegal TransA setting, %d\n", TransA);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(TransB == CblasTrans) TA='T';
|
|
||||||
else if ( TransB == CblasConjTrans ) TA='C';
|
|
||||||
else if ( TransB == CblasNoTrans ) TA='N';
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cblas_xerbla(layout, 2, "cblas_cgemm", "Illegal TransB setting, %d\n", TransB);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
cgemm_(&TA, &TB, (int*)&N, (int*)&M, (int*)&K, (complex*)alpha, (complex*)B, (int*)&ldb,
|
|
||||||
(complex*)A, (int*)&lda, (complex*)beta, (complex*)C, (int*)&ldc);
|
|
||||||
}
|
|
||||||
else cblas_xerbla(layout, 1, "cblas_cgemm", "Illegal layout setting, %d\n", layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cblas_dgemm(const CBLAS_LAYOUT layout, const CBLAS_TRANSPOSE TransA,
|
|
||||||
const CBLAS_TRANSPOSE TransB, const int M, const int N,
|
|
||||||
const int K, const double alpha, const double *A,
|
|
||||||
const int lda, const double *B, const int ldb,
|
|
||||||
const double beta, double *C, const int ldc)
|
|
||||||
{
|
|
||||||
char TA, TB;
|
|
||||||
|
|
||||||
if( layout == CblasColMajor )
|
|
||||||
{
|
|
||||||
if(TransA == CblasTrans) TA='T';
|
|
||||||
else if ( TransA == CblasConjTrans ) TA='C';
|
|
||||||
else if ( TransA == CblasNoTrans ) TA='N';
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cblas_xerbla(layout, 2, "cblas_dgemm", "Illegal TransA setting, %d\n", TransA);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(TransB == CblasTrans) TB='T';
|
|
||||||
else if ( TransB == CblasConjTrans ) TB='C';
|
|
||||||
else if ( TransB == CblasNoTrans ) TB='N';
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cblas_xerbla(layout, 3, "cblas_dgemm", "Illegal TransB setting, %d\n", TransB);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dgemm_(&TA, &TB, (int*)&M, (int*)&N, (int*)&K, (double*)&alpha, (double*)A, (int*)&lda,
|
|
||||||
(double*)B, (int*)&ldb, (double*)&beta, (double*)C, (int*)&ldc);
|
|
||||||
}
|
|
||||||
else if (layout == CblasRowMajor)
|
|
||||||
{
|
|
||||||
if(TransA == CblasTrans) TB='T';
|
|
||||||
else if ( TransA == CblasConjTrans ) TB='C';
|
|
||||||
else if ( TransA == CblasNoTrans ) TB='N';
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cblas_xerbla(layout, 2, "cblas_dgemm", "Illegal TransA setting, %d\n", TransA);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(TransB == CblasTrans) TA='T';
|
|
||||||
else if ( TransB == CblasConjTrans ) TA='C';
|
|
||||||
else if ( TransB == CblasNoTrans ) TA='N';
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cblas_xerbla(layout, 2, "cblas_dgemm", "Illegal TransB setting, %d\n", TransB);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dgemm_(&TA, &TB, (int*)&N, (int*)&M, (int*)&K, (double*)&alpha, (double*)B, (int*)&ldb,
|
|
||||||
(double*)A, (int*)&lda, (double*)&beta, (double*)C, (int*)&ldc);
|
|
||||||
}
|
|
||||||
else cblas_xerbla(layout, 1, "cblas_dgemm", "Illegal layout setting, %d\n", layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void cblas_sgemm(const CBLAS_LAYOUT layout, const CBLAS_TRANSPOSE TransA,
|
|
||||||
const CBLAS_TRANSPOSE TransB, const int M, const int N,
|
|
||||||
const int K, const float alpha, const float *A,
|
|
||||||
const int lda, const float *B, const int ldb,
|
|
||||||
const float beta, float *C, const int ldc)
|
|
||||||
{
|
|
||||||
char TA, TB;
|
|
||||||
|
|
||||||
if( layout == CblasColMajor )
|
|
||||||
{
|
|
||||||
if(TransA == CblasTrans) TA='T';
|
|
||||||
else if ( TransA == CblasConjTrans ) TA='C';
|
|
||||||
else if ( TransA == CblasNoTrans ) TA='N';
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cblas_xerbla(layout, 2, "cblas_sgemm", "Illegal TransA setting, %d\n", TransA);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(TransB == CblasTrans) TB='T';
|
|
||||||
else if ( TransB == CblasConjTrans ) TB='C';
|
|
||||||
else if ( TransB == CblasNoTrans ) TB='N';
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cblas_xerbla(layout, 3, "cblas_sgemm", "Illegal TransB setting, %d\n", TransB);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
sgemm_(&TA, &TB, (int*)&M, (int*)&N, (int*)&K, (float*)&alpha, (float*)A, (int*)&lda,
|
|
||||||
(float*)B, (int*)&ldb, (float*)&beta, (float*)C, (int*)&ldc);
|
|
||||||
}
|
|
||||||
else if (layout == CblasRowMajor)
|
|
||||||
{
|
|
||||||
if(TransA == CblasTrans) TB='T';
|
|
||||||
else if ( TransA == CblasConjTrans ) TB='C';
|
|
||||||
else if ( TransA == CblasNoTrans ) TB='N';
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cblas_xerbla(layout, 2, "cblas_sgemm", "Illegal TransA setting, %d\n", TransA);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(TransB == CblasTrans) TA='T';
|
|
||||||
else if ( TransB == CblasConjTrans ) TA='C';
|
|
||||||
else if ( TransB == CblasNoTrans ) TA='N';
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cblas_xerbla(layout, 2, "cblas_sgemm", "Illegal TransB setting, %d\n", TransB);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
sgemm_(&TA, &TB, (int*)&N, (int*)&M, (int*)&K, (float*)&alpha, (float*)B, (int*)&ldb,
|
|
||||||
(float*)A, (int*)&lda, (float*)&beta, (float*)C, (int*)&ldc);
|
|
||||||
}
|
|
||||||
else cblas_xerbla(layout, 1, "cblas_sgemm", "Illegal layout setting, %d\n", layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cblas_zgemm(const CBLAS_LAYOUT layout, const CBLAS_TRANSPOSE TransA,
|
|
||||||
const CBLAS_TRANSPOSE TransB, const int M, const int N,
|
|
||||||
const int K, const void *alpha, const void *A,
|
|
||||||
const int lda, const void *B, const int ldb,
|
|
||||||
const void *beta, void *C, const int ldc)
|
|
||||||
{
|
|
||||||
char TA, TB;
|
|
||||||
|
|
||||||
if( layout == CblasColMajor )
|
|
||||||
{
|
|
||||||
if(TransA == CblasTrans) TA='T';
|
|
||||||
else if ( TransA == CblasConjTrans ) TA='C';
|
|
||||||
else if ( TransA == CblasNoTrans ) TA='N';
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cblas_xerbla(layout, 2, "cblas_zgemm", "Illegal TransA setting, %d\n", TransA);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(TransB == CblasTrans) TB='T';
|
|
||||||
else if ( TransB == CblasConjTrans ) TB='C';
|
|
||||||
else if ( TransB == CblasNoTrans ) TB='N';
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cblas_xerbla(layout, 3, "cblas_zgemm", "Illegal TransB setting, %d\n", TransB);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
zgemm_(&TA, &TB, (int*)&M, (int*)&N, (int*)&K, (doublecomplex*)alpha, (doublecomplex*)A, (int*)&lda,
|
|
||||||
(doublecomplex*)B, (int*)&ldb, (doublecomplex*)beta, (doublecomplex*)C, (int*)&ldc);
|
|
||||||
}
|
|
||||||
else if (layout == CblasRowMajor)
|
|
||||||
{
|
|
||||||
if(TransA == CblasTrans) TB='T';
|
|
||||||
else if ( TransA == CblasConjTrans ) TB='C';
|
|
||||||
else if ( TransA == CblasNoTrans ) TB='N';
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cblas_xerbla(layout, 2, "cblas_zgemm", "Illegal TransA setting, %d\n", TransA);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(TransB == CblasTrans) TA='T';
|
|
||||||
else if ( TransB == CblasConjTrans ) TA='C';
|
|
||||||
else if ( TransB == CblasNoTrans ) TA='N';
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cblas_xerbla(layout, 2, "cblas_zgemm", "Illegal TransB setting, %d\n", TransB);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
zgemm_(&TA, &TB, (int*)&N, (int*)&M, (int*)&K, (doublecomplex*)alpha, (doublecomplex*)B, (int*)&ldb,
|
|
||||||
(doublecomplex*)A, (int*)&lda, (doublecomplex*)beta, (doublecomplex*)C, (int*)&ldc);
|
|
||||||
}
|
|
||||||
else cblas_xerbla(layout, 1, "cblas_zgemm", "Illegal layout setting, %d\n", layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cblas_xerbla(const CBLAS_LAYOUT layout, int info, const char *rout, const char *form, ...)
|
|
||||||
{
|
|
||||||
extern int RowMajorStrg;
|
|
||||||
char empty[1] = "";
|
|
||||||
va_list argptr;
|
|
||||||
|
|
||||||
va_start(argptr, form);
|
|
||||||
|
|
||||||
if (layout == CblasRowMajor)
|
|
||||||
{
|
|
||||||
if (strstr(rout,"gemm") != 0)
|
|
||||||
{
|
|
||||||
if (info == 5 ) info = 4;
|
|
||||||
else if (info == 4 ) info = 5;
|
|
||||||
else if (info == 11) info = 9;
|
|
||||||
else if (info == 9 ) info = 11;
|
|
||||||
}
|
|
||||||
else if (strstr(rout,"symm") != 0 || strstr(rout,"hemm") != 0)
|
|
||||||
{
|
|
||||||
if (info == 5 ) info = 4;
|
|
||||||
else if (info == 4 ) info = 5;
|
|
||||||
}
|
|
||||||
else if (strstr(rout,"trmm") != 0 || strstr(rout,"trsm") != 0)
|
|
||||||
{
|
|
||||||
if (info == 7 ) info = 6;
|
|
||||||
else if (info == 6 ) info = 7;
|
|
||||||
}
|
|
||||||
else if (strstr(rout,"gemv") != 0)
|
|
||||||
{
|
|
||||||
if (info == 4) info = 3;
|
|
||||||
else if (info == 3) info = 4;
|
|
||||||
}
|
|
||||||
else if (strstr(rout,"gbmv") != 0)
|
|
||||||
{
|
|
||||||
if (info == 4) info = 3;
|
|
||||||
else if (info == 3) info = 4;
|
|
||||||
else if (info == 6) info = 5;
|
|
||||||
else if (info == 5) info = 6;
|
|
||||||
}
|
|
||||||
else if (strstr(rout,"ger") != 0)
|
|
||||||
{
|
|
||||||
if (info == 3) info = 2;
|
|
||||||
else if (info == 2) info = 3;
|
|
||||||
else if (info == 8) info = 6;
|
|
||||||
else if (info == 6) info = 8;
|
|
||||||
}
|
|
||||||
else if ( (strstr(rout,"her2") != 0 || strstr(rout,"hpr2") != 0)
|
|
||||||
&& strstr(rout,"her2k") == 0 )
|
|
||||||
{
|
|
||||||
if (info == 8) info = 6;
|
|
||||||
else if (info == 6) info = 8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (info)
|
|
||||||
fprintf(stderr, "Parameter %d to routine %s was incorrect\n", info, rout);
|
|
||||||
vfprintf(stderr, form, argptr);
|
|
||||||
va_end(argptr);
|
|
||||||
if (info && !info)
|
|
||||||
xerbla_(empty, &info); /* Force link of our F77 error handler */
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
-72
@@ -1,72 +0,0 @@
|
|||||||
#include "f2c.h"
|
|
||||||
#include <float.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
/* *********************************************************************** */
|
|
||||||
|
|
||||||
double dlamc3_(double *a, double *b)
|
|
||||||
{
|
|
||||||
/* -- LAPACK auxiliary routine (version 3.1) -- */
|
|
||||||
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
|
|
||||||
/* November 2006 */
|
|
||||||
|
|
||||||
/* .. Scalar Arguments .. */
|
|
||||||
/* .. */
|
|
||||||
|
|
||||||
/* Purpose */
|
|
||||||
/* ======= */
|
|
||||||
|
|
||||||
/* DLAMC3 is intended to force A and B to be stored prior to doing */
|
|
||||||
/* the addition of A and B , for use in situations where optimizers */
|
|
||||||
/* might hold one of these in a register. */
|
|
||||||
|
|
||||||
/* Arguments */
|
|
||||||
/* ========= */
|
|
||||||
|
|
||||||
/* A (input) DOUBLE PRECISION */
|
|
||||||
/* B (input) DOUBLE PRECISION */
|
|
||||||
/* The values A and B. */
|
|
||||||
|
|
||||||
/* ===================================================================== */
|
|
||||||
|
|
||||||
/* .. Executable Statements .. */
|
|
||||||
|
|
||||||
double ret_val = *a + *b;
|
|
||||||
|
|
||||||
return ret_val;
|
|
||||||
|
|
||||||
/* End of DLAMC3 */
|
|
||||||
|
|
||||||
} /* dlamc3_ */
|
|
||||||
|
|
||||||
|
|
||||||
/* simpler version of dlamch for the case of IEEE754-compliant FPU module by Piotr Luszczek S.
|
|
||||||
taken from http://www.mail-archive.com/numpy-discussion@lists.sourceforge.net/msg02448.html */
|
|
||||||
|
|
||||||
#ifndef DBL_DIGITS
|
|
||||||
#define DBL_DIGITS 53
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static const unsigned char lapack_dlamch_tab0[] =
|
|
||||||
{
|
|
||||||
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, 0, 0, 2, 0, 0, 0, 0, 0, 0, 3, 4, 5, 6, 7, 0, 8, 9, 0, 10, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0, 3, 4, 5, 6, 7, 0, 8, 9,
|
|
||||||
0, 10, 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
|
|
||||||
};
|
|
||||||
|
|
||||||
const double lapack_dlamch_tab1[] =
|
|
||||||
{
|
|
||||||
0, FLT_RADIX, DBL_EPSILON, DBL_MAX_EXP, DBL_MIN_EXP, DBL_DIGITS, DBL_MAX,
|
|
||||||
DBL_EPSILON*FLT_RADIX, 1, DBL_MIN*(1 + DBL_EPSILON), DBL_MIN
|
|
||||||
};
|
|
||||||
|
|
||||||
double dlamch_(char* cmach)
|
|
||||||
{
|
|
||||||
return lapack_dlamch_tab1[lapack_dlamch_tab0[(unsigned char)cmach[0]]];
|
|
||||||
}
|
|
||||||
-96
@@ -1,96 +0,0 @@
|
|||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
static const int CLAPACK_NOT_IMPLEMENTED = -1024;
|
|
||||||
|
|
||||||
int sgesdd_(char *jobz, int *m, int *n, float *a, int *lda,
|
|
||||||
float *s, float *u, int *ldu, float *vt, int *ldvt, float *work,
|
|
||||||
int *lwork, int *iwork, int *info)
|
|
||||||
{
|
|
||||||
*info = CLAPACK_NOT_IMPLEMENTED;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int dgels_(char *trans, int *m, int *n, int *nrhs, double *a,
|
|
||||||
int *lda, double *b, int *ldb, double *work, int *lwork, int *info)
|
|
||||||
{
|
|
||||||
*info = CLAPACK_NOT_IMPLEMENTED;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int dgesv_(int *n, int *nrhs, double *a, int *lda, int *ipiv,
|
|
||||||
double *b, int *ldb, int *info)
|
|
||||||
{
|
|
||||||
*info = CLAPACK_NOT_IMPLEMENTED;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int dgetrf_(int *m, int *n, double *a, int *lda, int *ipiv,
|
|
||||||
int *info)
|
|
||||||
{
|
|
||||||
*info = CLAPACK_NOT_IMPLEMENTED;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int dposv_(char *uplo, int *n, int *nrhs, double *a, int *
|
|
||||||
lda, double *b, int *ldb, int *info)
|
|
||||||
{
|
|
||||||
*info = CLAPACK_NOT_IMPLEMENTED;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int dpotrf_(char *uplo, int *n, double *a, int *lda, int *
|
|
||||||
info)
|
|
||||||
{
|
|
||||||
*info = CLAPACK_NOT_IMPLEMENTED;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int sgels_(char *trans, int *m, int *n, int *nrhs, float *a,
|
|
||||||
int *lda, float *b, int *ldb, float *work, int *lwork, int *info)
|
|
||||||
{
|
|
||||||
*info = CLAPACK_NOT_IMPLEMENTED;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int sgeev_(char *jobvl, char *jobvr, int *n, float *a, int *
|
|
||||||
lda, float *wr, float *wi, float *vl, int *ldvl, float *vr, int *
|
|
||||||
ldvr, float *work, int *lwork, int *info)
|
|
||||||
{
|
|
||||||
*info = CLAPACK_NOT_IMPLEMENTED;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int sgeqrf_(int *m, int *n, float *a, int *lda, float *tau,
|
|
||||||
float *work, int *lwork, int *info)
|
|
||||||
{
|
|
||||||
*info = CLAPACK_NOT_IMPLEMENTED;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int sgesv_(int *n, int *nrhs, float *a, int *lda, int *ipiv,
|
|
||||||
float *b, int *ldb, int *info)
|
|
||||||
{
|
|
||||||
*info = CLAPACK_NOT_IMPLEMENTED;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int sgetrf_(int *m, int *n, float *a, int *lda, int *ipiv,
|
|
||||||
int *info)
|
|
||||||
{
|
|
||||||
*info = CLAPACK_NOT_IMPLEMENTED;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int sposv_(char *uplo, int *n, int *nrhs, float *a, int *
|
|
||||||
lda, float *b, int *ldb, int *info)
|
|
||||||
{
|
|
||||||
*info = CLAPACK_NOT_IMPLEMENTED;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int spotrf_(char *uplo, int *n, float *a, int *lda, int *
|
|
||||||
info)
|
|
||||||
{
|
|
||||||
*info = CLAPACK_NOT_IMPLEMENTED;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
-25
@@ -1,25 +0,0 @@
|
|||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
static const unsigned char lapack_toupper_tab[] =
|
|
||||||
{
|
|
||||||
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, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
|
|
||||||
46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
|
|
||||||
68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
|
|
||||||
90, 91, 92, 93, 94, 95, 96, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
|
|
||||||
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 123, 124, 125, 126, 127, 128, 129, 130, 131,
|
|
||||||
132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
|
|
||||||
150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167,
|
|
||||||
168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185,
|
|
||||||
186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203,
|
|
||||||
204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221,
|
|
||||||
222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
|
|
||||||
240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
|
|
||||||
};
|
|
||||||
|
|
||||||
#define lapack_toupper(c) ((char)lapack_toupper_tab[(unsigned char)(c)])
|
|
||||||
|
|
||||||
int lsame_(char *ca, char *cb)
|
|
||||||
{
|
|
||||||
return lapack_toupper(ca[0]) == lapack_toupper(cb[0]);
|
|
||||||
}
|
|
||||||
Vendored
-27
@@ -1,27 +0,0 @@
|
|||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
double pow_di(double *ap, int *bp)
|
|
||||||
{
|
|
||||||
double p = 1;
|
|
||||||
double x = *ap;
|
|
||||||
int n = *bp;
|
|
||||||
|
|
||||||
if(n != 0)
|
|
||||||
{
|
|
||||||
if(n < 0)
|
|
||||||
{
|
|
||||||
n = -n;
|
|
||||||
x = 1/x;
|
|
||||||
}
|
|
||||||
unsigned u = (unsigned)n;
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
if((u & 1) != 0)
|
|
||||||
p *= x;
|
|
||||||
if((u >>= 1) == 0)
|
|
||||||
break;
|
|
||||||
x *= x;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
Vendored
-25
@@ -1,25 +0,0 @@
|
|||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
int pow_ii(int *ap, int *bp)
|
|
||||||
{
|
|
||||||
int p;
|
|
||||||
int x = *ap;
|
|
||||||
int n = *bp;
|
|
||||||
|
|
||||||
if (n <= 0) {
|
|
||||||
if (n == 0 || x == 1)
|
|
||||||
return 1;
|
|
||||||
return x != -1 ? 0 : (n & 1) ? -1 : 1;
|
|
||||||
}
|
|
||||||
unsigned u = (unsigned)n;
|
|
||||||
for(p = 1; ; )
|
|
||||||
{
|
|
||||||
if(u & 01)
|
|
||||||
p *= x;
|
|
||||||
if(u >>= 1)
|
|
||||||
x *= x;
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
Vendored
-22
@@ -1,22 +0,0 @@
|
|||||||
/* Unless compiled with -DNO_OVERWRITE, this variant of s_cat allows the
|
|
||||||
* target of a concatenation to appear on its right-hand side (contrary
|
|
||||||
* to the Fortran 77 Standard, but in accordance with Fortran 90).
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
int s_cat(char *lp, char **rpp, int* rnp, int *np)
|
|
||||||
{
|
|
||||||
int i, L = 0;
|
|
||||||
int n = *np;
|
|
||||||
|
|
||||||
for(i = 0; i < n; i++) {
|
|
||||||
int ni = rnp[i];
|
|
||||||
if(ni > 0) {
|
|
||||||
memcpy(lp + L, rpp[i], ni);
|
|
||||||
L += ni;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lp[L] = '\0';
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
Vendored
-40
@@ -1,40 +0,0 @@
|
|||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
/* compare two strings */
|
|
||||||
int s_cmp(char *a0, char *b0)
|
|
||||||
{
|
|
||||||
int la = (int)strlen(a0);
|
|
||||||
int lb = (int)strlen(b0);
|
|
||||||
unsigned char *a, *aend, *b, *bend;
|
|
||||||
a = (unsigned char *)a0;
|
|
||||||
b = (unsigned char *)b0;
|
|
||||||
aend = a + la;
|
|
||||||
bend = b + lb;
|
|
||||||
|
|
||||||
if(la <= lb)
|
|
||||||
{
|
|
||||||
while(a < aend)
|
|
||||||
if(*a != *b)
|
|
||||||
return( *a - *b );
|
|
||||||
else
|
|
||||||
{ ++a; ++b; }
|
|
||||||
|
|
||||||
while(b < bend)
|
|
||||||
if(*b != ' ')
|
|
||||||
return( ' ' - *b );
|
|
||||||
else ++b;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
while(b < bend)
|
|
||||||
if(*a == *b)
|
|
||||||
{ ++a; ++b; }
|
|
||||||
else
|
|
||||||
return( *a - *b );
|
|
||||||
while(a < aend)
|
|
||||||
if(*a != ' ')
|
|
||||||
return(*a - ' ');
|
|
||||||
else ++a;
|
|
||||||
}
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
-71
@@ -1,71 +0,0 @@
|
|||||||
#include "f2c.h"
|
|
||||||
#include <float.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
/* *********************************************************************** */
|
|
||||||
|
|
||||||
double slamc3_(float *a, float *b)
|
|
||||||
{
|
|
||||||
/* -- LAPACK auxiliary routine (version 3.1) -- */
|
|
||||||
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
|
|
||||||
/* November 2006 */
|
|
||||||
|
|
||||||
/* .. Scalar Arguments .. */
|
|
||||||
/* .. */
|
|
||||||
|
|
||||||
/* Purpose */
|
|
||||||
/* ======= */
|
|
||||||
|
|
||||||
/* SLAMC3 is intended to force A and B to be stored prior to doing */
|
|
||||||
/* the addition of A and B , for use in situations where optimizers */
|
|
||||||
/* might hold one of these in a register. */
|
|
||||||
|
|
||||||
/* Arguments */
|
|
||||||
/* ========= */
|
|
||||||
|
|
||||||
/* A (input) REAL */
|
|
||||||
/* B (input) REAL */
|
|
||||||
/* The values A and B. */
|
|
||||||
|
|
||||||
/* ===================================================================== */
|
|
||||||
|
|
||||||
/* .. Executable Statements .. */
|
|
||||||
|
|
||||||
float ret_val = *a + *b;
|
|
||||||
|
|
||||||
return ret_val;
|
|
||||||
|
|
||||||
/* End of SLAMC3 */
|
|
||||||
|
|
||||||
} /* slamc3_ */
|
|
||||||
|
|
||||||
/* simpler version of slamch for the case of IEEE754-compliant FPU module by Piotr Luszczek S.
|
|
||||||
taken from http://www.mail-archive.com/numpy-discussion@lists.sourceforge.net/msg02448.html */
|
|
||||||
|
|
||||||
#ifndef FLT_DIGITS
|
|
||||||
#define FLT_DIGITS 24
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static const unsigned char lapack_slamch_tab0[] =
|
|
||||||
{
|
|
||||||
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, 0, 0, 2, 0, 0, 0, 0, 0, 0, 3, 4, 5, 6, 7, 0, 8, 9, 0, 10, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0, 3, 4, 5, 6, 7, 0, 8, 9,
|
|
||||||
0, 10, 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
|
|
||||||
};
|
|
||||||
|
|
||||||
const double lapack_slamch_tab1[] =
|
|
||||||
{
|
|
||||||
0, FLT_RADIX, FLT_EPSILON, FLT_MAX_EXP, FLT_MIN_EXP, FLT_DIGITS, FLT_MAX,
|
|
||||||
FLT_EPSILON*FLT_RADIX, 1, FLT_MIN*(1 + FLT_EPSILON), FLT_MIN
|
|
||||||
};
|
|
||||||
|
|
||||||
double slamch_(char* cmach)
|
|
||||||
{
|
|
||||||
return lapack_slamch_tab1[lapack_slamch_tab0[(unsigned char)cmach[0]]];
|
|
||||||
}
|
|
||||||
-19
@@ -1,19 +0,0 @@
|
|||||||
/* xerbla.f -- translated by f2c (version 20061008).
|
|
||||||
You must link the resulting object file with libf2c:
|
|
||||||
on Microsoft Windows system, link with libf2c.lib;
|
|
||||||
on Linux or Unix systems, link with .../path/to/libf2c.a -lm
|
|
||||||
or, if you install libf2c.a in a standard place, with -lf2c -lm
|
|
||||||
-- in that order, at the end of the command line, as in
|
|
||||||
cc *.o -lf2c -lm
|
|
||||||
Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
|
|
||||||
|
|
||||||
http://www.netlib.org/f2c/libf2c.zip
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
/* Subroutine */ int xerbla_(char *srname, int *info)
|
|
||||||
{
|
|
||||||
printf("** On entry to %s, parameter number %2i had an illegal value\n", srname, *info);
|
|
||||||
return 0;
|
|
||||||
} /* xerbla_ */
|
|
||||||
Vendored
-752
@@ -1,752 +0,0 @@
|
|||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
//> \brief \b CGEMM
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// SUBROUTINE CGEMM(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// COMPLEX ALPHA,BETA
|
|
||||||
// INTEGER K,LDA,LDB,LDC,M,N
|
|
||||||
// CHARACTER TRANSA,TRANSB
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// COMPLEX A(LDA,*),B(LDB,*),C(LDC,*)
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> CGEMM performs one of the matrix-matrix operations
|
|
||||||
//>
|
|
||||||
//> C := alpha*op( A )*op( B ) + beta*C,
|
|
||||||
//>
|
|
||||||
//> where op( X ) is one of
|
|
||||||
//>
|
|
||||||
//> op( X ) = X or op( X ) = X**T or op( X ) = X**H,
|
|
||||||
//>
|
|
||||||
//> alpha and beta are scalars, and A, B and C are matrices, with op( A )
|
|
||||||
//> an m by k matrix, op( B ) a k by n matrix and C an m by n matrix.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] TRANSA
|
|
||||||
//> \verbatim
|
|
||||||
//> TRANSA is CHARACTER*1
|
|
||||||
//> On entry, TRANSA specifies the form of op( A ) to be used in
|
|
||||||
//> the matrix multiplication as follows:
|
|
||||||
//>
|
|
||||||
//> TRANSA = 'N' or 'n', op( A ) = A.
|
|
||||||
//>
|
|
||||||
//> TRANSA = 'T' or 't', op( A ) = A**T.
|
|
||||||
//>
|
|
||||||
//> TRANSA = 'C' or 'c', op( A ) = A**H.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] TRANSB
|
|
||||||
//> \verbatim
|
|
||||||
//> TRANSB is CHARACTER*1
|
|
||||||
//> On entry, TRANSB specifies the form of op( B ) to be used in
|
|
||||||
//> the matrix multiplication as follows:
|
|
||||||
//>
|
|
||||||
//> TRANSB = 'N' or 'n', op( B ) = B.
|
|
||||||
//>
|
|
||||||
//> TRANSB = 'T' or 't', op( B ) = B**T.
|
|
||||||
//>
|
|
||||||
//> TRANSB = 'C' or 'c', op( B ) = B**H.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] M
|
|
||||||
//> \verbatim
|
|
||||||
//> M is INTEGER
|
|
||||||
//> On entry, M specifies the number of rows of the matrix
|
|
||||||
//> op( A ) and of the matrix C. M must be at least zero.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] N
|
|
||||||
//> \verbatim
|
|
||||||
//> N is INTEGER
|
|
||||||
//> On entry, N specifies the number of columns of the matrix
|
|
||||||
//> op( B ) and the number of columns of the matrix C. N must be
|
|
||||||
//> at least zero.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] K
|
|
||||||
//> \verbatim
|
|
||||||
//> K is INTEGER
|
|
||||||
//> On entry, K specifies the number of columns of the matrix
|
|
||||||
//> op( A ) and the number of rows of the matrix op( B ). K must
|
|
||||||
//> be at least zero.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] ALPHA
|
|
||||||
//> \verbatim
|
|
||||||
//> ALPHA is COMPLEX
|
|
||||||
//> On entry, ALPHA specifies the scalar alpha.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] A
|
|
||||||
//> \verbatim
|
|
||||||
//> A is COMPLEX array, dimension ( LDA, ka ), where ka is
|
|
||||||
//> k when TRANSA = 'N' or 'n', and is m otherwise.
|
|
||||||
//> Before entry with TRANSA = 'N' or 'n', the leading m by k
|
|
||||||
//> part of the array A must contain the matrix A, otherwise
|
|
||||||
//> the leading k by m part of the array A must contain the
|
|
||||||
//> matrix A.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDA
|
|
||||||
//> \verbatim
|
|
||||||
//> LDA is INTEGER
|
|
||||||
//> On entry, LDA specifies the first dimension of A as declared
|
|
||||||
//> in the calling (sub) program. When TRANSA = 'N' or 'n' then
|
|
||||||
//> LDA must be at least max( 1, m ), otherwise LDA must be at
|
|
||||||
//> least max( 1, k ).
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] B
|
|
||||||
//> \verbatim
|
|
||||||
//> B is COMPLEX array, dimension ( LDB, kb ), where kb is
|
|
||||||
//> n when TRANSB = 'N' or 'n', and is k otherwise.
|
|
||||||
//> Before entry with TRANSB = 'N' or 'n', the leading k by n
|
|
||||||
//> part of the array B must contain the matrix B, otherwise
|
|
||||||
//> the leading n by k part of the array B must contain the
|
|
||||||
//> matrix B.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDB
|
|
||||||
//> \verbatim
|
|
||||||
//> LDB is INTEGER
|
|
||||||
//> On entry, LDB specifies the first dimension of B as declared
|
|
||||||
//> in the calling (sub) program. When TRANSB = 'N' or 'n' then
|
|
||||||
//> LDB must be at least max( 1, k ), otherwise LDB must be at
|
|
||||||
//> least max( 1, n ).
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] BETA
|
|
||||||
//> \verbatim
|
|
||||||
//> BETA is COMPLEX
|
|
||||||
//> On entry, BETA specifies the scalar beta. When BETA is
|
|
||||||
//> supplied as zero then C need not be set on input.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in,out] C
|
|
||||||
//> \verbatim
|
|
||||||
//> C is COMPLEX array, dimension ( LDC, N )
|
|
||||||
//> Before entry, the leading m by n part of the array C must
|
|
||||||
//> contain the matrix C, except when beta is zero, in which
|
|
||||||
//> case C need not be set on entry.
|
|
||||||
//> On exit, the array C is overwritten by the m by n matrix
|
|
||||||
//> ( alpha*op( A )*op( B ) + beta*C ).
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDC
|
|
||||||
//> \verbatim
|
|
||||||
//> LDC is INTEGER
|
|
||||||
//> On entry, LDC specifies the first dimension of C as declared
|
|
||||||
//> in the calling (sub) program. LDC must be at least
|
|
||||||
//> max( 1, m ).
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date December 2016
|
|
||||||
//
|
|
||||||
//> \ingroup complex_blas_level3
|
|
||||||
//
|
|
||||||
//> \par Further Details:
|
|
||||||
// =====================
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> Level 3 Blas routine.
|
|
||||||
//>
|
|
||||||
//> -- Written on 8-February-1989.
|
|
||||||
//> Jack Dongarra, Argonne National Laboratory.
|
|
||||||
//> Iain Duff, AERE Harwell.
|
|
||||||
//> Jeremy Du Croz, Numerical Algorithms Group Ltd.
|
|
||||||
//> Sven Hammarling, Numerical Algorithms Group Ltd.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
// =====================================================================
|
|
||||||
/* Subroutine */ int cgemm_(char *transa, char *transb, int *m, int *n, int *
|
|
||||||
k, complex *alpha, complex *a, int *lda, complex *b, int *ldb,
|
|
||||||
complex *beta, complex *c__, int *ldc)
|
|
||||||
{
|
|
||||||
// Table of constant values
|
|
||||||
complex c_b1 = {1.f,0.f};
|
|
||||||
complex c_b2 = {0.f,0.f};
|
|
||||||
|
|
||||||
// System generated locals
|
|
||||||
int a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, i__1, i__2,
|
|
||||||
i__3, i__4, i__5, i__6;
|
|
||||||
complex q__1, q__2, q__3, q__4;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int i__, j, l, info;
|
|
||||||
int nota, notb;
|
|
||||||
complex temp;
|
|
||||||
int conja, conjb;
|
|
||||||
int ncola;
|
|
||||||
extern int lsame_(char *, char *);
|
|
||||||
int nrowa, nrowb;
|
|
||||||
extern /* Subroutine */ int xerbla_(char *, int *);
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- Reference BLAS level3 routine (version 3.7.0) --
|
|
||||||
// -- Reference BLAS is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// December 2016
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. External Functions ..
|
|
||||||
// ..
|
|
||||||
// .. External Subroutines ..
|
|
||||||
// ..
|
|
||||||
// .. Intrinsic Functions ..
|
|
||||||
// ..
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// .. Parameters ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// Set NOTA and NOTB as true if A and B respectively are not
|
|
||||||
// conjugated or transposed, set CONJA and CONJB as true if A and
|
|
||||||
// B respectively are to be transposed but not conjugated and set
|
|
||||||
// NROWA, NCOLA and NROWB as the number of rows and columns of A
|
|
||||||
// and the number of rows of B respectively.
|
|
||||||
//
|
|
||||||
// Parameter adjustments
|
|
||||||
a_dim1 = *lda;
|
|
||||||
a_offset = 1 + a_dim1;
|
|
||||||
a -= a_offset;
|
|
||||||
b_dim1 = *ldb;
|
|
||||||
b_offset = 1 + b_dim1;
|
|
||||||
b -= b_offset;
|
|
||||||
c_dim1 = *ldc;
|
|
||||||
c_offset = 1 + c_dim1;
|
|
||||||
c__ -= c_offset;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
nota = lsame_(transa, "N");
|
|
||||||
notb = lsame_(transb, "N");
|
|
||||||
conja = lsame_(transa, "C");
|
|
||||||
conjb = lsame_(transb, "C");
|
|
||||||
if (nota) {
|
|
||||||
nrowa = *m;
|
|
||||||
ncola = *k;
|
|
||||||
} else {
|
|
||||||
nrowa = *k;
|
|
||||||
ncola = *m;
|
|
||||||
}
|
|
||||||
if (notb) {
|
|
||||||
nrowb = *k;
|
|
||||||
} else {
|
|
||||||
nrowb = *n;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Test the input parameters.
|
|
||||||
//
|
|
||||||
info = 0;
|
|
||||||
if (! nota && ! conja && ! lsame_(transa, "T")) {
|
|
||||||
info = 1;
|
|
||||||
} else if (! notb && ! conjb && ! lsame_(transb, "T")) {
|
|
||||||
info = 2;
|
|
||||||
} else if (*m < 0) {
|
|
||||||
info = 3;
|
|
||||||
} else if (*n < 0) {
|
|
||||||
info = 4;
|
|
||||||
} else if (*k < 0) {
|
|
||||||
info = 5;
|
|
||||||
} else if (*lda < max(1,nrowa)) {
|
|
||||||
info = 8;
|
|
||||||
} else if (*ldb < max(1,nrowb)) {
|
|
||||||
info = 10;
|
|
||||||
} else if (*ldc < max(1,*m)) {
|
|
||||||
info = 13;
|
|
||||||
}
|
|
||||||
if (info != 0) {
|
|
||||||
xerbla_("CGEMM ", &info);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Quick return if possible.
|
|
||||||
//
|
|
||||||
if (*m == 0 || *n == 0 || (alpha->r == 0.f && alpha->i == 0.f || *k == 0)
|
|
||||||
&& (beta->r == 1.f && beta->i == 0.f)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// And when alpha.eq.zero.
|
|
||||||
//
|
|
||||||
if (alpha->r == 0.f && alpha->i == 0.f) {
|
|
||||||
if (beta->r == 0.f && beta->i == 0.f) {
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
c__[i__3].r = 0.f, c__[i__3].i = 0.f;
|
|
||||||
// L10:
|
|
||||||
}
|
|
||||||
// L20:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
i__4 = i__ + j * c_dim1;
|
|
||||||
q__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4].i,
|
|
||||||
q__1.i = beta->r * c__[i__4].i + beta->i * c__[
|
|
||||||
i__4].r;
|
|
||||||
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
|
|
||||||
// L30:
|
|
||||||
}
|
|
||||||
// L40:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Start the operations.
|
|
||||||
//
|
|
||||||
if (notb) {
|
|
||||||
if (nota) {
|
|
||||||
//
|
|
||||||
// Form C := alpha*A*B + beta*C.
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
if (beta->r == 0.f && beta->i == 0.f) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
c__[i__3].r = 0.f, c__[i__3].i = 0.f;
|
|
||||||
// L50:
|
|
||||||
}
|
|
||||||
} else if (beta->r != 1.f || beta->i != 0.f) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
i__4 = i__ + j * c_dim1;
|
|
||||||
q__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
|
|
||||||
.i, q__1.i = beta->r * c__[i__4].i + beta->i *
|
|
||||||
c__[i__4].r;
|
|
||||||
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
|
|
||||||
// L60:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i__2 = *k;
|
|
||||||
for (l = 1; l <= i__2; ++l) {
|
|
||||||
i__3 = l + j * b_dim1;
|
|
||||||
q__1.r = alpha->r * b[i__3].r - alpha->i * b[i__3].i,
|
|
||||||
q__1.i = alpha->r * b[i__3].i + alpha->i * b[i__3]
|
|
||||||
.r;
|
|
||||||
temp.r = q__1.r, temp.i = q__1.i;
|
|
||||||
i__3 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__3; ++i__) {
|
|
||||||
i__4 = i__ + j * c_dim1;
|
|
||||||
i__5 = i__ + j * c_dim1;
|
|
||||||
i__6 = i__ + l * a_dim1;
|
|
||||||
q__2.r = temp.r * a[i__6].r - temp.i * a[i__6].i,
|
|
||||||
q__2.i = temp.r * a[i__6].i + temp.i * a[i__6]
|
|
||||||
.r;
|
|
||||||
q__1.r = c__[i__5].r + q__2.r, q__1.i = c__[i__5].i +
|
|
||||||
q__2.i;
|
|
||||||
c__[i__4].r = q__1.r, c__[i__4].i = q__1.i;
|
|
||||||
// L70:
|
|
||||||
}
|
|
||||||
// L80:
|
|
||||||
}
|
|
||||||
// L90:
|
|
||||||
}
|
|
||||||
} else if (conja) {
|
|
||||||
//
|
|
||||||
// Form C := alpha*A**H*B + beta*C.
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
temp.r = 0.f, temp.i = 0.f;
|
|
||||||
i__3 = *k;
|
|
||||||
for (l = 1; l <= i__3; ++l) {
|
|
||||||
r_cnjg(&q__3, &a[l + i__ * a_dim1]);
|
|
||||||
i__4 = l + j * b_dim1;
|
|
||||||
q__2.r = q__3.r * b[i__4].r - q__3.i * b[i__4].i,
|
|
||||||
q__2.i = q__3.r * b[i__4].i + q__3.i * b[i__4]
|
|
||||||
.r;
|
|
||||||
q__1.r = temp.r + q__2.r, q__1.i = temp.i + q__2.i;
|
|
||||||
temp.r = q__1.r, temp.i = q__1.i;
|
|
||||||
// L100:
|
|
||||||
}
|
|
||||||
if (beta->r == 0.f && beta->i == 0.f) {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
q__1.r = alpha->r * temp.r - alpha->i * temp.i,
|
|
||||||
q__1.i = alpha->r * temp.i + alpha->i *
|
|
||||||
temp.r;
|
|
||||||
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
|
|
||||||
} else {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
q__2.r = alpha->r * temp.r - alpha->i * temp.i,
|
|
||||||
q__2.i = alpha->r * temp.i + alpha->i *
|
|
||||||
temp.r;
|
|
||||||
i__4 = i__ + j * c_dim1;
|
|
||||||
q__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
|
|
||||||
.i, q__3.i = beta->r * c__[i__4].i + beta->i *
|
|
||||||
c__[i__4].r;
|
|
||||||
q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
|
|
||||||
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
|
|
||||||
}
|
|
||||||
// L110:
|
|
||||||
}
|
|
||||||
// L120:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Form C := alpha*A**T*B + beta*C
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
temp.r = 0.f, temp.i = 0.f;
|
|
||||||
i__3 = *k;
|
|
||||||
for (l = 1; l <= i__3; ++l) {
|
|
||||||
i__4 = l + i__ * a_dim1;
|
|
||||||
i__5 = l + j * b_dim1;
|
|
||||||
q__2.r = a[i__4].r * b[i__5].r - a[i__4].i * b[i__5]
|
|
||||||
.i, q__2.i = a[i__4].r * b[i__5].i + a[i__4]
|
|
||||||
.i * b[i__5].r;
|
|
||||||
q__1.r = temp.r + q__2.r, q__1.i = temp.i + q__2.i;
|
|
||||||
temp.r = q__1.r, temp.i = q__1.i;
|
|
||||||
// L130:
|
|
||||||
}
|
|
||||||
if (beta->r == 0.f && beta->i == 0.f) {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
q__1.r = alpha->r * temp.r - alpha->i * temp.i,
|
|
||||||
q__1.i = alpha->r * temp.i + alpha->i *
|
|
||||||
temp.r;
|
|
||||||
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
|
|
||||||
} else {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
q__2.r = alpha->r * temp.r - alpha->i * temp.i,
|
|
||||||
q__2.i = alpha->r * temp.i + alpha->i *
|
|
||||||
temp.r;
|
|
||||||
i__4 = i__ + j * c_dim1;
|
|
||||||
q__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
|
|
||||||
.i, q__3.i = beta->r * c__[i__4].i + beta->i *
|
|
||||||
c__[i__4].r;
|
|
||||||
q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
|
|
||||||
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
|
|
||||||
}
|
|
||||||
// L140:
|
|
||||||
}
|
|
||||||
// L150:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (nota) {
|
|
||||||
if (conjb) {
|
|
||||||
//
|
|
||||||
// Form C := alpha*A*B**H + beta*C.
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
if (beta->r == 0.f && beta->i == 0.f) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
c__[i__3].r = 0.f, c__[i__3].i = 0.f;
|
|
||||||
// L160:
|
|
||||||
}
|
|
||||||
} else if (beta->r != 1.f || beta->i != 0.f) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
i__4 = i__ + j * c_dim1;
|
|
||||||
q__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
|
|
||||||
.i, q__1.i = beta->r * c__[i__4].i + beta->i *
|
|
||||||
c__[i__4].r;
|
|
||||||
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
|
|
||||||
// L170:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i__2 = *k;
|
|
||||||
for (l = 1; l <= i__2; ++l) {
|
|
||||||
r_cnjg(&q__2, &b[j + l * b_dim1]);
|
|
||||||
q__1.r = alpha->r * q__2.r - alpha->i * q__2.i, q__1.i =
|
|
||||||
alpha->r * q__2.i + alpha->i * q__2.r;
|
|
||||||
temp.r = q__1.r, temp.i = q__1.i;
|
|
||||||
i__3 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__3; ++i__) {
|
|
||||||
i__4 = i__ + j * c_dim1;
|
|
||||||
i__5 = i__ + j * c_dim1;
|
|
||||||
i__6 = i__ + l * a_dim1;
|
|
||||||
q__2.r = temp.r * a[i__6].r - temp.i * a[i__6].i,
|
|
||||||
q__2.i = temp.r * a[i__6].i + temp.i * a[i__6]
|
|
||||||
.r;
|
|
||||||
q__1.r = c__[i__5].r + q__2.r, q__1.i = c__[i__5].i +
|
|
||||||
q__2.i;
|
|
||||||
c__[i__4].r = q__1.r, c__[i__4].i = q__1.i;
|
|
||||||
// L180:
|
|
||||||
}
|
|
||||||
// L190:
|
|
||||||
}
|
|
||||||
// L200:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Form C := alpha*A*B**T + beta*C
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
if (beta->r == 0.f && beta->i == 0.f) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
c__[i__3].r = 0.f, c__[i__3].i = 0.f;
|
|
||||||
// L210:
|
|
||||||
}
|
|
||||||
} else if (beta->r != 1.f || beta->i != 0.f) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
i__4 = i__ + j * c_dim1;
|
|
||||||
q__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
|
|
||||||
.i, q__1.i = beta->r * c__[i__4].i + beta->i *
|
|
||||||
c__[i__4].r;
|
|
||||||
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
|
|
||||||
// L220:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i__2 = *k;
|
|
||||||
for (l = 1; l <= i__2; ++l) {
|
|
||||||
i__3 = j + l * b_dim1;
|
|
||||||
q__1.r = alpha->r * b[i__3].r - alpha->i * b[i__3].i,
|
|
||||||
q__1.i = alpha->r * b[i__3].i + alpha->i * b[i__3]
|
|
||||||
.r;
|
|
||||||
temp.r = q__1.r, temp.i = q__1.i;
|
|
||||||
i__3 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__3; ++i__) {
|
|
||||||
i__4 = i__ + j * c_dim1;
|
|
||||||
i__5 = i__ + j * c_dim1;
|
|
||||||
i__6 = i__ + l * a_dim1;
|
|
||||||
q__2.r = temp.r * a[i__6].r - temp.i * a[i__6].i,
|
|
||||||
q__2.i = temp.r * a[i__6].i + temp.i * a[i__6]
|
|
||||||
.r;
|
|
||||||
q__1.r = c__[i__5].r + q__2.r, q__1.i = c__[i__5].i +
|
|
||||||
q__2.i;
|
|
||||||
c__[i__4].r = q__1.r, c__[i__4].i = q__1.i;
|
|
||||||
// L230:
|
|
||||||
}
|
|
||||||
// L240:
|
|
||||||
}
|
|
||||||
// L250:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (conja) {
|
|
||||||
if (conjb) {
|
|
||||||
//
|
|
||||||
// Form C := alpha*A**H*B**H + beta*C.
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
temp.r = 0.f, temp.i = 0.f;
|
|
||||||
i__3 = *k;
|
|
||||||
for (l = 1; l <= i__3; ++l) {
|
|
||||||
r_cnjg(&q__3, &a[l + i__ * a_dim1]);
|
|
||||||
r_cnjg(&q__4, &b[j + l * b_dim1]);
|
|
||||||
q__2.r = q__3.r * q__4.r - q__3.i * q__4.i, q__2.i =
|
|
||||||
q__3.r * q__4.i + q__3.i * q__4.r;
|
|
||||||
q__1.r = temp.r + q__2.r, q__1.i = temp.i + q__2.i;
|
|
||||||
temp.r = q__1.r, temp.i = q__1.i;
|
|
||||||
// L260:
|
|
||||||
}
|
|
||||||
if (beta->r == 0.f && beta->i == 0.f) {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
q__1.r = alpha->r * temp.r - alpha->i * temp.i,
|
|
||||||
q__1.i = alpha->r * temp.i + alpha->i *
|
|
||||||
temp.r;
|
|
||||||
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
|
|
||||||
} else {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
q__2.r = alpha->r * temp.r - alpha->i * temp.i,
|
|
||||||
q__2.i = alpha->r * temp.i + alpha->i *
|
|
||||||
temp.r;
|
|
||||||
i__4 = i__ + j * c_dim1;
|
|
||||||
q__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
|
|
||||||
.i, q__3.i = beta->r * c__[i__4].i + beta->i *
|
|
||||||
c__[i__4].r;
|
|
||||||
q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
|
|
||||||
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
|
|
||||||
}
|
|
||||||
// L270:
|
|
||||||
}
|
|
||||||
// L280:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Form C := alpha*A**H*B**T + beta*C
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
temp.r = 0.f, temp.i = 0.f;
|
|
||||||
i__3 = *k;
|
|
||||||
for (l = 1; l <= i__3; ++l) {
|
|
||||||
r_cnjg(&q__3, &a[l + i__ * a_dim1]);
|
|
||||||
i__4 = j + l * b_dim1;
|
|
||||||
q__2.r = q__3.r * b[i__4].r - q__3.i * b[i__4].i,
|
|
||||||
q__2.i = q__3.r * b[i__4].i + q__3.i * b[i__4]
|
|
||||||
.r;
|
|
||||||
q__1.r = temp.r + q__2.r, q__1.i = temp.i + q__2.i;
|
|
||||||
temp.r = q__1.r, temp.i = q__1.i;
|
|
||||||
// L290:
|
|
||||||
}
|
|
||||||
if (beta->r == 0.f && beta->i == 0.f) {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
q__1.r = alpha->r * temp.r - alpha->i * temp.i,
|
|
||||||
q__1.i = alpha->r * temp.i + alpha->i *
|
|
||||||
temp.r;
|
|
||||||
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
|
|
||||||
} else {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
q__2.r = alpha->r * temp.r - alpha->i * temp.i,
|
|
||||||
q__2.i = alpha->r * temp.i + alpha->i *
|
|
||||||
temp.r;
|
|
||||||
i__4 = i__ + j * c_dim1;
|
|
||||||
q__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
|
|
||||||
.i, q__3.i = beta->r * c__[i__4].i + beta->i *
|
|
||||||
c__[i__4].r;
|
|
||||||
q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
|
|
||||||
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
|
|
||||||
}
|
|
||||||
// L300:
|
|
||||||
}
|
|
||||||
// L310:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (conjb) {
|
|
||||||
//
|
|
||||||
// Form C := alpha*A**T*B**H + beta*C
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
temp.r = 0.f, temp.i = 0.f;
|
|
||||||
i__3 = *k;
|
|
||||||
for (l = 1; l <= i__3; ++l) {
|
|
||||||
i__4 = l + i__ * a_dim1;
|
|
||||||
r_cnjg(&q__3, &b[j + l * b_dim1]);
|
|
||||||
q__2.r = a[i__4].r * q__3.r - a[i__4].i * q__3.i,
|
|
||||||
q__2.i = a[i__4].r * q__3.i + a[i__4].i *
|
|
||||||
q__3.r;
|
|
||||||
q__1.r = temp.r + q__2.r, q__1.i = temp.i + q__2.i;
|
|
||||||
temp.r = q__1.r, temp.i = q__1.i;
|
|
||||||
// L320:
|
|
||||||
}
|
|
||||||
if (beta->r == 0.f && beta->i == 0.f) {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
q__1.r = alpha->r * temp.r - alpha->i * temp.i,
|
|
||||||
q__1.i = alpha->r * temp.i + alpha->i *
|
|
||||||
temp.r;
|
|
||||||
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
|
|
||||||
} else {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
q__2.r = alpha->r * temp.r - alpha->i * temp.i,
|
|
||||||
q__2.i = alpha->r * temp.i + alpha->i *
|
|
||||||
temp.r;
|
|
||||||
i__4 = i__ + j * c_dim1;
|
|
||||||
q__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
|
|
||||||
.i, q__3.i = beta->r * c__[i__4].i + beta->i *
|
|
||||||
c__[i__4].r;
|
|
||||||
q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
|
|
||||||
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
|
|
||||||
}
|
|
||||||
// L330:
|
|
||||||
}
|
|
||||||
// L340:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Form C := alpha*A**T*B**T + beta*C
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
temp.r = 0.f, temp.i = 0.f;
|
|
||||||
i__3 = *k;
|
|
||||||
for (l = 1; l <= i__3; ++l) {
|
|
||||||
i__4 = l + i__ * a_dim1;
|
|
||||||
i__5 = j + l * b_dim1;
|
|
||||||
q__2.r = a[i__4].r * b[i__5].r - a[i__4].i * b[i__5]
|
|
||||||
.i, q__2.i = a[i__4].r * b[i__5].i + a[i__4]
|
|
||||||
.i * b[i__5].r;
|
|
||||||
q__1.r = temp.r + q__2.r, q__1.i = temp.i + q__2.i;
|
|
||||||
temp.r = q__1.r, temp.i = q__1.i;
|
|
||||||
// L350:
|
|
||||||
}
|
|
||||||
if (beta->r == 0.f && beta->i == 0.f) {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
q__1.r = alpha->r * temp.r - alpha->i * temp.i,
|
|
||||||
q__1.i = alpha->r * temp.i + alpha->i *
|
|
||||||
temp.r;
|
|
||||||
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
|
|
||||||
} else {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
q__2.r = alpha->r * temp.r - alpha->i * temp.i,
|
|
||||||
q__2.i = alpha->r * temp.i + alpha->i *
|
|
||||||
temp.r;
|
|
||||||
i__4 = i__ + j * c_dim1;
|
|
||||||
q__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
|
|
||||||
.i, q__3.i = beta->r * c__[i__4].i + beta->i *
|
|
||||||
c__[i__4].r;
|
|
||||||
q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
|
|
||||||
c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
|
|
||||||
}
|
|
||||||
// L360:
|
|
||||||
}
|
|
||||||
// L370:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
//
|
|
||||||
// End of CGEMM .
|
|
||||||
//
|
|
||||||
} // cgemm_
|
|
||||||
|
|
||||||
Vendored
-171
@@ -1,171 +0,0 @@
|
|||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
//> \brief \b DCOPY
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// SUBROUTINE DCOPY(N,DX,INCX,DY,INCY)
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// INTEGER INCX,INCY,N
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// DOUBLE PRECISION DX(*),DY(*)
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> DCOPY copies a vector, x, to a vector, y.
|
|
||||||
//> uses unrolled loops for increments equal to 1.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] N
|
|
||||||
//> \verbatim
|
|
||||||
//> N is INTEGER
|
|
||||||
//> number of elements in input vector(s)
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] DX
|
|
||||||
//> \verbatim
|
|
||||||
//> DX is DOUBLE PRECISION array, dimension ( 1 + ( N - 1 )*abs( INCX ) )
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] INCX
|
|
||||||
//> \verbatim
|
|
||||||
//> INCX is INTEGER
|
|
||||||
//> storage spacing between elements of DX
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[out] DY
|
|
||||||
//> \verbatim
|
|
||||||
//> DY is DOUBLE PRECISION array, dimension ( 1 + ( N - 1 )*abs( INCY ) )
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] INCY
|
|
||||||
//> \verbatim
|
|
||||||
//> INCY is INTEGER
|
|
||||||
//> storage spacing between elements of DY
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date November 2017
|
|
||||||
//
|
|
||||||
//> \ingroup double_blas_level1
|
|
||||||
//
|
|
||||||
//> \par Further Details:
|
|
||||||
// =====================
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> jack dongarra, linpack, 3/11/78.
|
|
||||||
//> modified 12/3/93, array(1) declarations changed to array(*)
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
// =====================================================================
|
|
||||||
/* Subroutine */ int dcopy_(int *n, double *dx, int *incx, double *dy, int *
|
|
||||||
incy)
|
|
||||||
{
|
|
||||||
// System generated locals
|
|
||||||
int i__1;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int i__, m, ix, iy, mp1;
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- Reference BLAS level1 routine (version 3.8.0) --
|
|
||||||
// -- Reference BLAS is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// November 2017
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// .. Intrinsic Functions ..
|
|
||||||
// ..
|
|
||||||
// Parameter adjustments
|
|
||||||
--dy;
|
|
||||||
--dx;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
if (*n <= 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (*incx == 1 && *incy == 1) {
|
|
||||||
//
|
|
||||||
// code for both increments equal to 1
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// clean-up loop
|
|
||||||
//
|
|
||||||
m = *n % 7;
|
|
||||||
if (m != 0) {
|
|
||||||
i__1 = m;
|
|
||||||
for (i__ = 1; i__ <= i__1; ++i__) {
|
|
||||||
dy[i__] = dx[i__];
|
|
||||||
}
|
|
||||||
if (*n < 7) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mp1 = m + 1;
|
|
||||||
i__1 = *n;
|
|
||||||
for (i__ = mp1; i__ <= i__1; i__ += 7) {
|
|
||||||
dy[i__] = dx[i__];
|
|
||||||
dy[i__ + 1] = dx[i__ + 1];
|
|
||||||
dy[i__ + 2] = dx[i__ + 2];
|
|
||||||
dy[i__ + 3] = dx[i__ + 3];
|
|
||||||
dy[i__ + 4] = dx[i__ + 4];
|
|
||||||
dy[i__ + 5] = dx[i__ + 5];
|
|
||||||
dy[i__ + 6] = dx[i__ + 6];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// code for unequal increments or equal increments
|
|
||||||
// not equal to 1
|
|
||||||
//
|
|
||||||
ix = 1;
|
|
||||||
iy = 1;
|
|
||||||
if (*incx < 0) {
|
|
||||||
ix = (-(*n) + 1) * *incx + 1;
|
|
||||||
}
|
|
||||||
if (*incy < 0) {
|
|
||||||
iy = (-(*n) + 1) * *incy + 1;
|
|
||||||
}
|
|
||||||
i__1 = *n;
|
|
||||||
for (i__ = 1; i__ <= i__1; ++i__) {
|
|
||||||
dy[iy] = dx[ix];
|
|
||||||
ix += *incx;
|
|
||||||
iy += *incy;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
} // dcopy_
|
|
||||||
|
|
||||||
Vendored
-172
@@ -1,172 +0,0 @@
|
|||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
//> \brief \b DDOT
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// DOUBLE PRECISION FUNCTION DDOT(N,DX,INCX,DY,INCY)
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// INTEGER INCX,INCY,N
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// DOUBLE PRECISION DX(*),DY(*)
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> DDOT forms the dot product of two vectors.
|
|
||||||
//> uses unrolled loops for increments equal to one.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] N
|
|
||||||
//> \verbatim
|
|
||||||
//> N is INTEGER
|
|
||||||
//> number of elements in input vector(s)
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] DX
|
|
||||||
//> \verbatim
|
|
||||||
//> DX is DOUBLE PRECISION array, dimension ( 1 + ( N - 1 )*abs( INCX ) )
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] INCX
|
|
||||||
//> \verbatim
|
|
||||||
//> INCX is INTEGER
|
|
||||||
//> storage spacing between elements of DX
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] DY
|
|
||||||
//> \verbatim
|
|
||||||
//> DY is DOUBLE PRECISION array, dimension ( 1 + ( N - 1 )*abs( INCY ) )
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] INCY
|
|
||||||
//> \verbatim
|
|
||||||
//> INCY is INTEGER
|
|
||||||
//> storage spacing between elements of DY
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date November 2017
|
|
||||||
//
|
|
||||||
//> \ingroup double_blas_level1
|
|
||||||
//
|
|
||||||
//> \par Further Details:
|
|
||||||
// =====================
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> jack dongarra, linpack, 3/11/78.
|
|
||||||
//> modified 12/3/93, array(1) declarations changed to array(*)
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
// =====================================================================
|
|
||||||
double ddot_(int *n, double *dx, int *incx, double *dy, int *incy)
|
|
||||||
{
|
|
||||||
// System generated locals
|
|
||||||
int i__1;
|
|
||||||
double ret_val;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int i__, m, ix, iy, mp1;
|
|
||||||
double dtemp;
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- Reference BLAS level1 routine (version 3.8.0) --
|
|
||||||
// -- Reference BLAS is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// November 2017
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// .. Intrinsic Functions ..
|
|
||||||
// ..
|
|
||||||
// Parameter adjustments
|
|
||||||
--dy;
|
|
||||||
--dx;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
ret_val = 0.;
|
|
||||||
dtemp = 0.;
|
|
||||||
if (*n <= 0) {
|
|
||||||
return ret_val;
|
|
||||||
}
|
|
||||||
if (*incx == 1 && *incy == 1) {
|
|
||||||
//
|
|
||||||
// code for both increments equal to 1
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// clean-up loop
|
|
||||||
//
|
|
||||||
m = *n % 5;
|
|
||||||
if (m != 0) {
|
|
||||||
i__1 = m;
|
|
||||||
for (i__ = 1; i__ <= i__1; ++i__) {
|
|
||||||
dtemp += dx[i__] * dy[i__];
|
|
||||||
}
|
|
||||||
if (*n < 5) {
|
|
||||||
ret_val = dtemp;
|
|
||||||
return ret_val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mp1 = m + 1;
|
|
||||||
i__1 = *n;
|
|
||||||
for (i__ = mp1; i__ <= i__1; i__ += 5) {
|
|
||||||
dtemp = dtemp + dx[i__] * dy[i__] + dx[i__ + 1] * dy[i__ + 1] +
|
|
||||||
dx[i__ + 2] * dy[i__ + 2] + dx[i__ + 3] * dy[i__ + 3] +
|
|
||||||
dx[i__ + 4] * dy[i__ + 4];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// code for unequal increments or equal increments
|
|
||||||
// not equal to 1
|
|
||||||
//
|
|
||||||
ix = 1;
|
|
||||||
iy = 1;
|
|
||||||
if (*incx < 0) {
|
|
||||||
ix = (-(*n) + 1) * *incx + 1;
|
|
||||||
}
|
|
||||||
if (*incy < 0) {
|
|
||||||
iy = (-(*n) + 1) * *incy + 1;
|
|
||||||
}
|
|
||||||
i__1 = *n;
|
|
||||||
for (i__ = 1; i__ <= i__1; ++i__) {
|
|
||||||
dtemp += dx[ix] * dy[iy];
|
|
||||||
ix += *incx;
|
|
||||||
iy += *incy;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ret_val = dtemp;
|
|
||||||
return ret_val;
|
|
||||||
} // ddot_
|
|
||||||
|
|
||||||
Vendored
-14369
File diff suppressed because it is too large
Load Diff
Vendored
-444
@@ -1,444 +0,0 @@
|
|||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
//> \brief \b DGEMM
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// SUBROUTINE DGEMM(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// DOUBLE PRECISION ALPHA,BETA
|
|
||||||
// INTEGER K,LDA,LDB,LDC,M,N
|
|
||||||
// CHARACTER TRANSA,TRANSB
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// DOUBLE PRECISION A(LDA,*),B(LDB,*),C(LDC,*)
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> DGEMM performs one of the matrix-matrix operations
|
|
||||||
//>
|
|
||||||
//> C := alpha*op( A )*op( B ) + beta*C,
|
|
||||||
//>
|
|
||||||
//> where op( X ) is one of
|
|
||||||
//>
|
|
||||||
//> op( X ) = X or op( X ) = X**T,
|
|
||||||
//>
|
|
||||||
//> alpha and beta are scalars, and A, B and C are matrices, with op( A )
|
|
||||||
//> an m by k matrix, op( B ) a k by n matrix and C an m by n matrix.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] TRANSA
|
|
||||||
//> \verbatim
|
|
||||||
//> TRANSA is CHARACTER*1
|
|
||||||
//> On entry, TRANSA specifies the form of op( A ) to be used in
|
|
||||||
//> the matrix multiplication as follows:
|
|
||||||
//>
|
|
||||||
//> TRANSA = 'N' or 'n', op( A ) = A.
|
|
||||||
//>
|
|
||||||
//> TRANSA = 'T' or 't', op( A ) = A**T.
|
|
||||||
//>
|
|
||||||
//> TRANSA = 'C' or 'c', op( A ) = A**T.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] TRANSB
|
|
||||||
//> \verbatim
|
|
||||||
//> TRANSB is CHARACTER*1
|
|
||||||
//> On entry, TRANSB specifies the form of op( B ) to be used in
|
|
||||||
//> the matrix multiplication as follows:
|
|
||||||
//>
|
|
||||||
//> TRANSB = 'N' or 'n', op( B ) = B.
|
|
||||||
//>
|
|
||||||
//> TRANSB = 'T' or 't', op( B ) = B**T.
|
|
||||||
//>
|
|
||||||
//> TRANSB = 'C' or 'c', op( B ) = B**T.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] M
|
|
||||||
//> \verbatim
|
|
||||||
//> M is INTEGER
|
|
||||||
//> On entry, M specifies the number of rows of the matrix
|
|
||||||
//> op( A ) and of the matrix C. M must be at least zero.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] N
|
|
||||||
//> \verbatim
|
|
||||||
//> N is INTEGER
|
|
||||||
//> On entry, N specifies the number of columns of the matrix
|
|
||||||
//> op( B ) and the number of columns of the matrix C. N must be
|
|
||||||
//> at least zero.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] K
|
|
||||||
//> \verbatim
|
|
||||||
//> K is INTEGER
|
|
||||||
//> On entry, K specifies the number of columns of the matrix
|
|
||||||
//> op( A ) and the number of rows of the matrix op( B ). K must
|
|
||||||
//> be at least zero.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] ALPHA
|
|
||||||
//> \verbatim
|
|
||||||
//> ALPHA is DOUBLE PRECISION.
|
|
||||||
//> On entry, ALPHA specifies the scalar alpha.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] A
|
|
||||||
//> \verbatim
|
|
||||||
//> A is DOUBLE PRECISION array, dimension ( LDA, ka ), where ka is
|
|
||||||
//> k when TRANSA = 'N' or 'n', and is m otherwise.
|
|
||||||
//> Before entry with TRANSA = 'N' or 'n', the leading m by k
|
|
||||||
//> part of the array A must contain the matrix A, otherwise
|
|
||||||
//> the leading k by m part of the array A must contain the
|
|
||||||
//> matrix A.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDA
|
|
||||||
//> \verbatim
|
|
||||||
//> LDA is INTEGER
|
|
||||||
//> On entry, LDA specifies the first dimension of A as declared
|
|
||||||
//> in the calling (sub) program. When TRANSA = 'N' or 'n' then
|
|
||||||
//> LDA must be at least max( 1, m ), otherwise LDA must be at
|
|
||||||
//> least max( 1, k ).
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] B
|
|
||||||
//> \verbatim
|
|
||||||
//> B is DOUBLE PRECISION array, dimension ( LDB, kb ), where kb is
|
|
||||||
//> n when TRANSB = 'N' or 'n', and is k otherwise.
|
|
||||||
//> Before entry with TRANSB = 'N' or 'n', the leading k by n
|
|
||||||
//> part of the array B must contain the matrix B, otherwise
|
|
||||||
//> the leading n by k part of the array B must contain the
|
|
||||||
//> matrix B.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDB
|
|
||||||
//> \verbatim
|
|
||||||
//> LDB is INTEGER
|
|
||||||
//> On entry, LDB specifies the first dimension of B as declared
|
|
||||||
//> in the calling (sub) program. When TRANSB = 'N' or 'n' then
|
|
||||||
//> LDB must be at least max( 1, k ), otherwise LDB must be at
|
|
||||||
//> least max( 1, n ).
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] BETA
|
|
||||||
//> \verbatim
|
|
||||||
//> BETA is DOUBLE PRECISION.
|
|
||||||
//> On entry, BETA specifies the scalar beta. When BETA is
|
|
||||||
//> supplied as zero then C need not be set on input.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in,out] C
|
|
||||||
//> \verbatim
|
|
||||||
//> C is DOUBLE PRECISION array, dimension ( LDC, N )
|
|
||||||
//> Before entry, the leading m by n part of the array C must
|
|
||||||
//> contain the matrix C, except when beta is zero, in which
|
|
||||||
//> case C need not be set on entry.
|
|
||||||
//> On exit, the array C is overwritten by the m by n matrix
|
|
||||||
//> ( alpha*op( A )*op( B ) + beta*C ).
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDC
|
|
||||||
//> \verbatim
|
|
||||||
//> LDC is INTEGER
|
|
||||||
//> On entry, LDC specifies the first dimension of C as declared
|
|
||||||
//> in the calling (sub) program. LDC must be at least
|
|
||||||
//> max( 1, m ).
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date December 2016
|
|
||||||
//
|
|
||||||
//> \ingroup double_blas_level3
|
|
||||||
//
|
|
||||||
//> \par Further Details:
|
|
||||||
// =====================
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> Level 3 Blas routine.
|
|
||||||
//>
|
|
||||||
//> -- Written on 8-February-1989.
|
|
||||||
//> Jack Dongarra, Argonne National Laboratory.
|
|
||||||
//> Iain Duff, AERE Harwell.
|
|
||||||
//> Jeremy Du Croz, Numerical Algorithms Group Ltd.
|
|
||||||
//> Sven Hammarling, Numerical Algorithms Group Ltd.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
// =====================================================================
|
|
||||||
/* Subroutine */ int dgemm_(char *transa, char *transb, int *m, int *n, int *
|
|
||||||
k, double *alpha, double *a, int *lda, double *b, int *ldb, double *
|
|
||||||
beta, double *c__, int *ldc)
|
|
||||||
{
|
|
||||||
// System generated locals
|
|
||||||
int a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, i__1, i__2,
|
|
||||||
i__3;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int i__, j, l, info;
|
|
||||||
int nota, notb;
|
|
||||||
double temp;
|
|
||||||
int ncola;
|
|
||||||
extern int lsame_(char *, char *);
|
|
||||||
int nrowa, nrowb;
|
|
||||||
extern /* Subroutine */ int xerbla_(char *, int *);
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- Reference BLAS level3 routine (version 3.7.0) --
|
|
||||||
// -- Reference BLAS is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// December 2016
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. External Functions ..
|
|
||||||
// ..
|
|
||||||
// .. External Subroutines ..
|
|
||||||
// ..
|
|
||||||
// .. Intrinsic Functions ..
|
|
||||||
// ..
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// .. Parameters ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// Set NOTA and NOTB as true if A and B respectively are not
|
|
||||||
// transposed and set NROWA, NCOLA and NROWB as the number of rows
|
|
||||||
// and columns of A and the number of rows of B respectively.
|
|
||||||
//
|
|
||||||
// Parameter adjustments
|
|
||||||
a_dim1 = *lda;
|
|
||||||
a_offset = 1 + a_dim1;
|
|
||||||
a -= a_offset;
|
|
||||||
b_dim1 = *ldb;
|
|
||||||
b_offset = 1 + b_dim1;
|
|
||||||
b -= b_offset;
|
|
||||||
c_dim1 = *ldc;
|
|
||||||
c_offset = 1 + c_dim1;
|
|
||||||
c__ -= c_offset;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
nota = lsame_(transa, "N");
|
|
||||||
notb = lsame_(transb, "N");
|
|
||||||
if (nota) {
|
|
||||||
nrowa = *m;
|
|
||||||
ncola = *k;
|
|
||||||
} else {
|
|
||||||
nrowa = *k;
|
|
||||||
ncola = *m;
|
|
||||||
}
|
|
||||||
if (notb) {
|
|
||||||
nrowb = *k;
|
|
||||||
} else {
|
|
||||||
nrowb = *n;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Test the input parameters.
|
|
||||||
//
|
|
||||||
info = 0;
|
|
||||||
if (! nota && ! lsame_(transa, "C") && ! lsame_(transa, "T")) {
|
|
||||||
info = 1;
|
|
||||||
} else if (! notb && ! lsame_(transb, "C") && ! lsame_(transb, "T")) {
|
|
||||||
info = 2;
|
|
||||||
} else if (*m < 0) {
|
|
||||||
info = 3;
|
|
||||||
} else if (*n < 0) {
|
|
||||||
info = 4;
|
|
||||||
} else if (*k < 0) {
|
|
||||||
info = 5;
|
|
||||||
} else if (*lda < max(1,nrowa)) {
|
|
||||||
info = 8;
|
|
||||||
} else if (*ldb < max(1,nrowb)) {
|
|
||||||
info = 10;
|
|
||||||
} else if (*ldc < max(1,*m)) {
|
|
||||||
info = 13;
|
|
||||||
}
|
|
||||||
if (info != 0) {
|
|
||||||
xerbla_("DGEMM ", &info);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Quick return if possible.
|
|
||||||
//
|
|
||||||
if (*m == 0 || *n == 0 || (*alpha == 0. || *k == 0) && *beta == 1.) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// And if alpha.eq.zero.
|
|
||||||
//
|
|
||||||
if (*alpha == 0.) {
|
|
||||||
if (*beta == 0.) {
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
c__[i__ + j * c_dim1] = 0.;
|
|
||||||
// L10:
|
|
||||||
}
|
|
||||||
// L20:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
|
|
||||||
// L30:
|
|
||||||
}
|
|
||||||
// L40:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Start the operations.
|
|
||||||
//
|
|
||||||
if (notb) {
|
|
||||||
if (nota) {
|
|
||||||
//
|
|
||||||
// Form C := alpha*A*B + beta*C.
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
if (*beta == 0.) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
c__[i__ + j * c_dim1] = 0.;
|
|
||||||
// L50:
|
|
||||||
}
|
|
||||||
} else if (*beta != 1.) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
|
|
||||||
// L60:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i__2 = *k;
|
|
||||||
for (l = 1; l <= i__2; ++l) {
|
|
||||||
temp = *alpha * b[l + j * b_dim1];
|
|
||||||
i__3 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__3; ++i__) {
|
|
||||||
c__[i__ + j * c_dim1] += temp * a[i__ + l * a_dim1];
|
|
||||||
// L70:
|
|
||||||
}
|
|
||||||
// L80:
|
|
||||||
}
|
|
||||||
// L90:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Form C := alpha*A**T*B + beta*C
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
temp = 0.;
|
|
||||||
i__3 = *k;
|
|
||||||
for (l = 1; l <= i__3; ++l) {
|
|
||||||
temp += a[l + i__ * a_dim1] * b[l + j * b_dim1];
|
|
||||||
// L100:
|
|
||||||
}
|
|
||||||
if (*beta == 0.) {
|
|
||||||
c__[i__ + j * c_dim1] = *alpha * temp;
|
|
||||||
} else {
|
|
||||||
c__[i__ + j * c_dim1] = *alpha * temp + *beta * c__[
|
|
||||||
i__ + j * c_dim1];
|
|
||||||
}
|
|
||||||
// L110:
|
|
||||||
}
|
|
||||||
// L120:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (nota) {
|
|
||||||
//
|
|
||||||
// Form C := alpha*A*B**T + beta*C
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
if (*beta == 0.) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
c__[i__ + j * c_dim1] = 0.;
|
|
||||||
// L130:
|
|
||||||
}
|
|
||||||
} else if (*beta != 1.) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
|
|
||||||
// L140:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i__2 = *k;
|
|
||||||
for (l = 1; l <= i__2; ++l) {
|
|
||||||
temp = *alpha * b[j + l * b_dim1];
|
|
||||||
i__3 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__3; ++i__) {
|
|
||||||
c__[i__ + j * c_dim1] += temp * a[i__ + l * a_dim1];
|
|
||||||
// L150:
|
|
||||||
}
|
|
||||||
// L160:
|
|
||||||
}
|
|
||||||
// L170:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Form C := alpha*A**T*B**T + beta*C
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
temp = 0.;
|
|
||||||
i__3 = *k;
|
|
||||||
for (l = 1; l <= i__3; ++l) {
|
|
||||||
temp += a[l + i__ * a_dim1] * b[j + l * b_dim1];
|
|
||||||
// L180:
|
|
||||||
}
|
|
||||||
if (*beta == 0.) {
|
|
||||||
c__[i__ + j * c_dim1] = *alpha * temp;
|
|
||||||
} else {
|
|
||||||
c__[i__ + j * c_dim1] = *alpha * temp + *beta * c__[
|
|
||||||
i__ + j * c_dim1];
|
|
||||||
}
|
|
||||||
// L190:
|
|
||||||
}
|
|
||||||
// L200:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
//
|
|
||||||
// End of DGEMM .
|
|
||||||
//
|
|
||||||
} // dgemm_
|
|
||||||
|
|
||||||
Vendored
-370
@@ -1,370 +0,0 @@
|
|||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
//> \brief \b DGEMV
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// SUBROUTINE DGEMV(TRANS,M,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// DOUBLE PRECISION ALPHA,BETA
|
|
||||||
// INTEGER INCX,INCY,LDA,M,N
|
|
||||||
// CHARACTER TRANS
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// DOUBLE PRECISION A(LDA,*),X(*),Y(*)
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> DGEMV performs one of the matrix-vector operations
|
|
||||||
//>
|
|
||||||
//> y := alpha*A*x + beta*y, or y := alpha*A**T*x + beta*y,
|
|
||||||
//>
|
|
||||||
//> where alpha and beta are scalars, x and y are vectors and A is an
|
|
||||||
//> m by n matrix.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] TRANS
|
|
||||||
//> \verbatim
|
|
||||||
//> TRANS is CHARACTER*1
|
|
||||||
//> On entry, TRANS specifies the operation to be performed as
|
|
||||||
//> follows:
|
|
||||||
//>
|
|
||||||
//> TRANS = 'N' or 'n' y := alpha*A*x + beta*y.
|
|
||||||
//>
|
|
||||||
//> TRANS = 'T' or 't' y := alpha*A**T*x + beta*y.
|
|
||||||
//>
|
|
||||||
//> TRANS = 'C' or 'c' y := alpha*A**T*x + beta*y.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] M
|
|
||||||
//> \verbatim
|
|
||||||
//> M is INTEGER
|
|
||||||
//> On entry, M specifies the number of rows of the matrix A.
|
|
||||||
//> M must be at least zero.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] N
|
|
||||||
//> \verbatim
|
|
||||||
//> N is INTEGER
|
|
||||||
//> On entry, N specifies the number of columns of the matrix A.
|
|
||||||
//> N must be at least zero.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] ALPHA
|
|
||||||
//> \verbatim
|
|
||||||
//> ALPHA is DOUBLE PRECISION.
|
|
||||||
//> On entry, ALPHA specifies the scalar alpha.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] A
|
|
||||||
//> \verbatim
|
|
||||||
//> A is DOUBLE PRECISION array, dimension ( LDA, N )
|
|
||||||
//> Before entry, the leading m by n part of the array A must
|
|
||||||
//> contain the matrix of coefficients.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDA
|
|
||||||
//> \verbatim
|
|
||||||
//> LDA is INTEGER
|
|
||||||
//> On entry, LDA specifies the first dimension of A as declared
|
|
||||||
//> in the calling (sub) program. LDA must be at least
|
|
||||||
//> max( 1, m ).
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] X
|
|
||||||
//> \verbatim
|
|
||||||
//> X is DOUBLE PRECISION array, dimension at least
|
|
||||||
//> ( 1 + ( n - 1 )*abs( INCX ) ) when TRANS = 'N' or 'n'
|
|
||||||
//> and at least
|
|
||||||
//> ( 1 + ( m - 1 )*abs( INCX ) ) otherwise.
|
|
||||||
//> Before entry, the incremented array X must contain the
|
|
||||||
//> vector x.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] INCX
|
|
||||||
//> \verbatim
|
|
||||||
//> INCX is INTEGER
|
|
||||||
//> On entry, INCX specifies the increment for the elements of
|
|
||||||
//> X. INCX must not be zero.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] BETA
|
|
||||||
//> \verbatim
|
|
||||||
//> BETA is DOUBLE PRECISION.
|
|
||||||
//> On entry, BETA specifies the scalar beta. When BETA is
|
|
||||||
//> supplied as zero then Y need not be set on input.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in,out] Y
|
|
||||||
//> \verbatim
|
|
||||||
//> Y is DOUBLE PRECISION array, dimension at least
|
|
||||||
//> ( 1 + ( m - 1 )*abs( INCY ) ) when TRANS = 'N' or 'n'
|
|
||||||
//> and at least
|
|
||||||
//> ( 1 + ( n - 1 )*abs( INCY ) ) otherwise.
|
|
||||||
//> Before entry with BETA non-zero, the incremented array Y
|
|
||||||
//> must contain the vector y. On exit, Y is overwritten by the
|
|
||||||
//> updated vector y.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] INCY
|
|
||||||
//> \verbatim
|
|
||||||
//> INCY is INTEGER
|
|
||||||
//> On entry, INCY specifies the increment for the elements of
|
|
||||||
//> Y. INCY must not be zero.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date December 2016
|
|
||||||
//
|
|
||||||
//> \ingroup double_blas_level2
|
|
||||||
//
|
|
||||||
//> \par Further Details:
|
|
||||||
// =====================
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> Level 2 Blas routine.
|
|
||||||
//> The vector and matrix arguments are not referenced when N = 0, or M = 0
|
|
||||||
//>
|
|
||||||
//> -- Written on 22-October-1986.
|
|
||||||
//> Jack Dongarra, Argonne National Lab.
|
|
||||||
//> Jeremy Du Croz, Nag Central Office.
|
|
||||||
//> Sven Hammarling, Nag Central Office.
|
|
||||||
//> Richard Hanson, Sandia National Labs.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
// =====================================================================
|
|
||||||
/* Subroutine */ int dgemv_(char *trans, int *m, int *n, double *alpha,
|
|
||||||
double *a, int *lda, double *x, int *incx, double *beta, double *y,
|
|
||||||
int *incy)
|
|
||||||
{
|
|
||||||
// System generated locals
|
|
||||||
int a_dim1, a_offset, i__1, i__2;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int i__, j, ix, iy, jx, jy, kx, ky, info;
|
|
||||||
double temp;
|
|
||||||
int lenx, leny;
|
|
||||||
extern int lsame_(char *, char *);
|
|
||||||
extern /* Subroutine */ int xerbla_(char *, int *);
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- Reference BLAS level2 routine (version 3.7.0) --
|
|
||||||
// -- Reference BLAS is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// December 2016
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. Parameters ..
|
|
||||||
// ..
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// .. External Functions ..
|
|
||||||
// ..
|
|
||||||
// .. External Subroutines ..
|
|
||||||
// ..
|
|
||||||
// .. Intrinsic Functions ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// Test the input parameters.
|
|
||||||
//
|
|
||||||
// Parameter adjustments
|
|
||||||
a_dim1 = *lda;
|
|
||||||
a_offset = 1 + a_dim1;
|
|
||||||
a -= a_offset;
|
|
||||||
--x;
|
|
||||||
--y;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
info = 0;
|
|
||||||
if (! lsame_(trans, "N") && ! lsame_(trans, "T") && ! lsame_(trans, "C"))
|
|
||||||
{
|
|
||||||
info = 1;
|
|
||||||
} else if (*m < 0) {
|
|
||||||
info = 2;
|
|
||||||
} else if (*n < 0) {
|
|
||||||
info = 3;
|
|
||||||
} else if (*lda < max(1,*m)) {
|
|
||||||
info = 6;
|
|
||||||
} else if (*incx == 0) {
|
|
||||||
info = 8;
|
|
||||||
} else if (*incy == 0) {
|
|
||||||
info = 11;
|
|
||||||
}
|
|
||||||
if (info != 0) {
|
|
||||||
xerbla_("DGEMV ", &info);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Quick return if possible.
|
|
||||||
//
|
|
||||||
if (*m == 0 || *n == 0 || *alpha == 0. && *beta == 1.) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Set LENX and LENY, the lengths of the vectors x and y, and set
|
|
||||||
// up the start points in X and Y.
|
|
||||||
//
|
|
||||||
if (lsame_(trans, "N")) {
|
|
||||||
lenx = *n;
|
|
||||||
leny = *m;
|
|
||||||
} else {
|
|
||||||
lenx = *m;
|
|
||||||
leny = *n;
|
|
||||||
}
|
|
||||||
if (*incx > 0) {
|
|
||||||
kx = 1;
|
|
||||||
} else {
|
|
||||||
kx = 1 - (lenx - 1) * *incx;
|
|
||||||
}
|
|
||||||
if (*incy > 0) {
|
|
||||||
ky = 1;
|
|
||||||
} else {
|
|
||||||
ky = 1 - (leny - 1) * *incy;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Start the operations. In this version the elements of A are
|
|
||||||
// accessed sequentially with one pass through A.
|
|
||||||
//
|
|
||||||
// First form y := beta*y.
|
|
||||||
//
|
|
||||||
if (*beta != 1.) {
|
|
||||||
if (*incy == 1) {
|
|
||||||
if (*beta == 0.) {
|
|
||||||
i__1 = leny;
|
|
||||||
for (i__ = 1; i__ <= i__1; ++i__) {
|
|
||||||
y[i__] = 0.;
|
|
||||||
// L10:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
i__1 = leny;
|
|
||||||
for (i__ = 1; i__ <= i__1; ++i__) {
|
|
||||||
y[i__] = *beta * y[i__];
|
|
||||||
// L20:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
iy = ky;
|
|
||||||
if (*beta == 0.) {
|
|
||||||
i__1 = leny;
|
|
||||||
for (i__ = 1; i__ <= i__1; ++i__) {
|
|
||||||
y[iy] = 0.;
|
|
||||||
iy += *incy;
|
|
||||||
// L30:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
i__1 = leny;
|
|
||||||
for (i__ = 1; i__ <= i__1; ++i__) {
|
|
||||||
y[iy] = *beta * y[iy];
|
|
||||||
iy += *incy;
|
|
||||||
// L40:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (*alpha == 0.) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (lsame_(trans, "N")) {
|
|
||||||
//
|
|
||||||
// Form y := alpha*A*x + y.
|
|
||||||
//
|
|
||||||
jx = kx;
|
|
||||||
if (*incy == 1) {
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
temp = *alpha * x[jx];
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
y[i__] += temp * a[i__ + j * a_dim1];
|
|
||||||
// L50:
|
|
||||||
}
|
|
||||||
jx += *incx;
|
|
||||||
// L60:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
temp = *alpha * x[jx];
|
|
||||||
iy = ky;
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
y[iy] += temp * a[i__ + j * a_dim1];
|
|
||||||
iy += *incy;
|
|
||||||
// L70:
|
|
||||||
}
|
|
||||||
jx += *incx;
|
|
||||||
// L80:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Form y := alpha*A**T*x + y.
|
|
||||||
//
|
|
||||||
jy = ky;
|
|
||||||
if (*incx == 1) {
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
temp = 0.;
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
temp += a[i__ + j * a_dim1] * x[i__];
|
|
||||||
// L90:
|
|
||||||
}
|
|
||||||
y[jy] += *alpha * temp;
|
|
||||||
jy += *incy;
|
|
||||||
// L100:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
temp = 0.;
|
|
||||||
ix = kx;
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
temp += a[i__ + j * a_dim1] * x[ix];
|
|
||||||
ix += *incx;
|
|
||||||
// L110:
|
|
||||||
}
|
|
||||||
y[jy] += *alpha * temp;
|
|
||||||
jy += *incy;
|
|
||||||
// L120:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
//
|
|
||||||
// End of DGEMV .
|
|
||||||
//
|
|
||||||
} // dgemv_
|
|
||||||
|
|
||||||
Vendored
-18599
File diff suppressed because it is too large
Load Diff
Vendored
-186
@@ -1,186 +0,0 @@
|
|||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
//> \brief \b DISNAN tests input for NaN.
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
//> \htmlonly
|
|
||||||
//> Download DISNAN + dependencies
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/disnan.f">
|
|
||||||
//> [TGZ]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/disnan.f">
|
|
||||||
//> [ZIP]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/disnan.f">
|
|
||||||
//> [TXT]</a>
|
|
||||||
//> \endhtmlonly
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// LOGICAL FUNCTION DISNAN( DIN )
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// DOUBLE PRECISION, INTENT(IN) :: DIN
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> DISNAN returns .TRUE. if its argument is NaN, and .FALSE.
|
|
||||||
//> otherwise. To be replaced by the Fortran 2003 intrinsic in the
|
|
||||||
//> future.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] DIN
|
|
||||||
//> \verbatim
|
|
||||||
//> DIN is DOUBLE PRECISION
|
|
||||||
//> Input to test for NaN.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date June 2017
|
|
||||||
//
|
|
||||||
//> \ingroup OTHERauxiliary
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
int disnan_(double *din)
|
|
||||||
{
|
|
||||||
// System generated locals
|
|
||||||
int ret_val;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
extern int dlaisnan_(double *, double *);
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- LAPACK auxiliary routine (version 3.7.1) --
|
|
||||||
// -- LAPACK is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// June 2017
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. External Functions ..
|
|
||||||
// ..
|
|
||||||
// .. Executable Statements ..
|
|
||||||
ret_val = dlaisnan_(din, din);
|
|
||||||
return ret_val;
|
|
||||||
} // disnan_
|
|
||||||
|
|
||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
//> \brief \b DLAISNAN tests input for NaN by comparing two arguments for inequality.
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
//> \htmlonly
|
|
||||||
//> Download DLAISNAN + dependencies
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlaisnan.f">
|
|
||||||
//> [TGZ]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlaisnan.f">
|
|
||||||
//> [ZIP]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlaisnan.f">
|
|
||||||
//> [TXT]</a>
|
|
||||||
//> \endhtmlonly
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// LOGICAL FUNCTION DLAISNAN( DIN1, DIN2 )
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// DOUBLE PRECISION, INTENT(IN) :: DIN1, DIN2
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> This routine is not for general use. It exists solely to avoid
|
|
||||||
//> over-optimization in DISNAN.
|
|
||||||
//>
|
|
||||||
//> DLAISNAN checks for NaNs by comparing its two arguments for
|
|
||||||
//> inequality. NaN is the only floating-point value where NaN != NaN
|
|
||||||
//> returns .TRUE. To check for NaNs, pass the same variable as both
|
|
||||||
//> arguments.
|
|
||||||
//>
|
|
||||||
//> A compiler must assume that the two arguments are
|
|
||||||
//> not the same variable, and the test will not be optimized away.
|
|
||||||
//> Interprocedural or whole-program optimization may delete this
|
|
||||||
//> test. The ISNAN functions will be replaced by the correct
|
|
||||||
//> Fortran 03 intrinsic once the intrinsic is widely available.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] DIN1
|
|
||||||
//> \verbatim
|
|
||||||
//> DIN1 is DOUBLE PRECISION
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] DIN2
|
|
||||||
//> \verbatim
|
|
||||||
//> DIN2 is DOUBLE PRECISION
|
|
||||||
//> Two numbers to compare for inequality.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date June 2017
|
|
||||||
//
|
|
||||||
//> \ingroup OTHERauxiliary
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
int dlaisnan_(double *din1, double *din2)
|
|
||||||
{
|
|
||||||
// System generated locals
|
|
||||||
int ret_val;
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- LAPACK auxiliary routine (version 3.7.1) --
|
|
||||||
// -- LAPACK is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// June 2017
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. Executable Statements ..
|
|
||||||
ret_val = *din1 != *din2;
|
|
||||||
return ret_val;
|
|
||||||
} // dlaisnan_
|
|
||||||
|
|
||||||
Vendored
-184
@@ -1,184 +0,0 @@
|
|||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
//> \brief \b DLACPY copies all or part of one two-dimensional array to another.
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
//> \htmlonly
|
|
||||||
//> Download DLACPY + dependencies
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlacpy.f">
|
|
||||||
//> [TGZ]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlacpy.f">
|
|
||||||
//> [ZIP]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlacpy.f">
|
|
||||||
//> [TXT]</a>
|
|
||||||
//> \endhtmlonly
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// SUBROUTINE DLACPY( UPLO, M, N, A, LDA, B, LDB )
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// CHARACTER UPLO
|
|
||||||
// INTEGER LDA, LDB, M, N
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// DOUBLE PRECISION A( LDA, * ), B( LDB, * )
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> DLACPY copies all or part of a two-dimensional matrix A to another
|
|
||||||
//> matrix B.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] UPLO
|
|
||||||
//> \verbatim
|
|
||||||
//> UPLO is CHARACTER*1
|
|
||||||
//> Specifies the part of the matrix A to be copied to B.
|
|
||||||
//> = 'U': Upper triangular part
|
|
||||||
//> = 'L': Lower triangular part
|
|
||||||
//> Otherwise: All of the matrix A
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] M
|
|
||||||
//> \verbatim
|
|
||||||
//> M is INTEGER
|
|
||||||
//> The number of rows of the matrix A. M >= 0.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] N
|
|
||||||
//> \verbatim
|
|
||||||
//> N is INTEGER
|
|
||||||
//> The number of columns of the matrix A. N >= 0.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] A
|
|
||||||
//> \verbatim
|
|
||||||
//> A is DOUBLE PRECISION array, dimension (LDA,N)
|
|
||||||
//> The m by n matrix A. If UPLO = 'U', only the upper triangle
|
|
||||||
//> or trapezoid is accessed; if UPLO = 'L', only the lower
|
|
||||||
//> triangle or trapezoid is accessed.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDA
|
|
||||||
//> \verbatim
|
|
||||||
//> LDA is INTEGER
|
|
||||||
//> The leading dimension of the array A. LDA >= max(1,M).
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[out] B
|
|
||||||
//> \verbatim
|
|
||||||
//> B is DOUBLE PRECISION array, dimension (LDB,N)
|
|
||||||
//> On exit, B = A in the locations specified by UPLO.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDB
|
|
||||||
//> \verbatim
|
|
||||||
//> LDB is INTEGER
|
|
||||||
//> The leading dimension of the array B. LDB >= max(1,M).
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date December 2016
|
|
||||||
//
|
|
||||||
//> \ingroup OTHERauxiliary
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
/* Subroutine */ int dlacpy_(char *uplo, int *m, int *n, double *a, int *lda,
|
|
||||||
double *b, int *ldb)
|
|
||||||
{
|
|
||||||
// System generated locals
|
|
||||||
int a_dim1, a_offset, b_dim1, b_offset, i__1, i__2;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int i__, j;
|
|
||||||
extern int lsame_(char *, char *);
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- LAPACK auxiliary routine (version 3.7.0) --
|
|
||||||
// -- LAPACK is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// December 2016
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// .. External Functions ..
|
|
||||||
// ..
|
|
||||||
// .. Intrinsic Functions ..
|
|
||||||
// ..
|
|
||||||
// .. Executable Statements ..
|
|
||||||
//
|
|
||||||
// Parameter adjustments
|
|
||||||
a_dim1 = *lda;
|
|
||||||
a_offset = 1 + a_dim1;
|
|
||||||
a -= a_offset;
|
|
||||||
b_dim1 = *ldb;
|
|
||||||
b_offset = 1 + b_dim1;
|
|
||||||
b -= b_offset;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
if (lsame_(uplo, "U")) {
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = min(j,*m);
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
b[i__ + j * b_dim1] = a[i__ + j * a_dim1];
|
|
||||||
// L10:
|
|
||||||
}
|
|
||||||
// L20:
|
|
||||||
}
|
|
||||||
} else if (lsame_(uplo, "L")) {
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = j; i__ <= i__2; ++i__) {
|
|
||||||
b[i__ + j * b_dim1] = a[i__ + j * a_dim1];
|
|
||||||
// L30:
|
|
||||||
}
|
|
||||||
// L40:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
b[i__ + j * b_dim1] = a[i__ + j * a_dim1];
|
|
||||||
// L50:
|
|
||||||
}
|
|
||||||
// L60:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
//
|
|
||||||
// End of DLACPY
|
|
||||||
//
|
|
||||||
} // dlacpy_
|
|
||||||
|
|
||||||
Vendored
-367
@@ -1,367 +0,0 @@
|
|||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
//> \brief \b DCOMBSSQ adds two scaled sum of squares quantities.
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// SUBROUTINE DCOMBSSQ( V1, V2 )
|
|
||||||
//
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// DOUBLE PRECISION V1( 2 ), V2( 2 )
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> DCOMBSSQ adds two scaled sum of squares quantities, V1 := V1 + V2.
|
|
||||||
//> That is,
|
|
||||||
//>
|
|
||||||
//> V1_scale**2 * V1_sumsq := V1_scale**2 * V1_sumsq
|
|
||||||
//> + V2_scale**2 * V2_sumsq
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in,out] V1
|
|
||||||
//> \verbatim
|
|
||||||
//> V1 is DOUBLE PRECISION array, dimension (2).
|
|
||||||
//> The first scaled sum.
|
|
||||||
//> V1(1) = V1_scale, V1(2) = V1_sumsq.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] V2
|
|
||||||
//> \verbatim
|
|
||||||
//> V2 is DOUBLE PRECISION array, dimension (2).
|
|
||||||
//> The second scaled sum.
|
|
||||||
//> V2(1) = V2_scale, V2(2) = V2_sumsq.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date November 2018
|
|
||||||
//
|
|
||||||
//> \ingroup OTHERauxiliary
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
/* Subroutine */ int dcombssq_(double *v1, double *v2)
|
|
||||||
{
|
|
||||||
// System generated locals
|
|
||||||
double d__1;
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- LAPACK auxiliary routine (version 3.7.0) --
|
|
||||||
// -- LAPACK is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// November 2018
|
|
||||||
//
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//=====================================================================
|
|
||||||
//
|
|
||||||
// .. Parameters ..
|
|
||||||
// ..
|
|
||||||
// .. Executable Statements ..
|
|
||||||
//
|
|
||||||
// Parameter adjustments
|
|
||||||
--v2;
|
|
||||||
--v1;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
if (v1[1] >= v2[1]) {
|
|
||||||
if (v1[1] != 0.) {
|
|
||||||
// Computing 2nd power
|
|
||||||
d__1 = v2[1] / v1[1];
|
|
||||||
v1[2] += d__1 * d__1 * v2[2];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Computing 2nd power
|
|
||||||
d__1 = v1[1] / v2[1];
|
|
||||||
v1[2] = v2[2] + d__1 * d__1 * v1[2];
|
|
||||||
v1[1] = v2[1];
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
//
|
|
||||||
// End of DCOMBSSQ
|
|
||||||
//
|
|
||||||
} // dcombssq_
|
|
||||||
|
|
||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
//> \brief \b DLANGE returns the value of the 1-norm, Frobenius norm, infinity-norm, or the largest absolute value of any element of a general rectangular matrix.
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
//> \htmlonly
|
|
||||||
//> Download DLANGE + dependencies
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlange.f">
|
|
||||||
//> [TGZ]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlange.f">
|
|
||||||
//> [ZIP]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlange.f">
|
|
||||||
//> [TXT]</a>
|
|
||||||
//> \endhtmlonly
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// DOUBLE PRECISION FUNCTION DLANGE( NORM, M, N, A, LDA, WORK )
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// CHARACTER NORM
|
|
||||||
// INTEGER LDA, M, N
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// DOUBLE PRECISION A( LDA, * ), WORK( * )
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> DLANGE returns the value of the one norm, or the Frobenius norm, or
|
|
||||||
//> the infinity norm, or the element of largest absolute value of a
|
|
||||||
//> real matrix A.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \return DLANGE
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> DLANGE = ( max(abs(A(i,j))), NORM = 'M' or 'm'
|
|
||||||
//> (
|
|
||||||
//> ( norm1(A), NORM = '1', 'O' or 'o'
|
|
||||||
//> (
|
|
||||||
//> ( normI(A), NORM = 'I' or 'i'
|
|
||||||
//> (
|
|
||||||
//> ( normF(A), NORM = 'F', 'f', 'E' or 'e'
|
|
||||||
//>
|
|
||||||
//> where norm1 denotes the one norm of a matrix (maximum column sum),
|
|
||||||
//> normI denotes the infinity norm of a matrix (maximum row sum) and
|
|
||||||
//> normF denotes the Frobenius norm of a matrix (square root of sum of
|
|
||||||
//> squares). Note that max(abs(A(i,j))) is not a consistent matrix norm.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] NORM
|
|
||||||
//> \verbatim
|
|
||||||
//> NORM is CHARACTER*1
|
|
||||||
//> Specifies the value to be returned in DLANGE as described
|
|
||||||
//> above.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] M
|
|
||||||
//> \verbatim
|
|
||||||
//> M is INTEGER
|
|
||||||
//> The number of rows of the matrix A. M >= 0. When M = 0,
|
|
||||||
//> DLANGE is set to zero.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] N
|
|
||||||
//> \verbatim
|
|
||||||
//> N is INTEGER
|
|
||||||
//> The number of columns of the matrix A. N >= 0. When N = 0,
|
|
||||||
//> DLANGE is set to zero.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] A
|
|
||||||
//> \verbatim
|
|
||||||
//> A is DOUBLE PRECISION array, dimension (LDA,N)
|
|
||||||
//> The m by n matrix A.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDA
|
|
||||||
//> \verbatim
|
|
||||||
//> LDA is INTEGER
|
|
||||||
//> The leading dimension of the array A. LDA >= max(M,1).
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[out] WORK
|
|
||||||
//> \verbatim
|
|
||||||
//> WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK)),
|
|
||||||
//> where LWORK >= M when NORM = 'I'; otherwise, WORK is not
|
|
||||||
//> referenced.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date December 2016
|
|
||||||
//
|
|
||||||
//> \ingroup doubleGEauxiliary
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
double dlange_(char *norm, int *m, int *n, double *a, int *lda, double *work)
|
|
||||||
{
|
|
||||||
// Table of constant values
|
|
||||||
int c__1 = 1;
|
|
||||||
|
|
||||||
// System generated locals
|
|
||||||
int a_dim1, a_offset, i__1, i__2;
|
|
||||||
double ret_val, d__1;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
extern /* Subroutine */ int dcombssq_(double *, double *);
|
|
||||||
int i__, j;
|
|
||||||
double sum, ssq[2], temp;
|
|
||||||
extern int lsame_(char *, char *);
|
|
||||||
double value;
|
|
||||||
extern int disnan_(double *);
|
|
||||||
extern /* Subroutine */ int dlassq_(int *, double *, int *, double *,
|
|
||||||
double *);
|
|
||||||
double colssq[2];
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- LAPACK auxiliary routine (version 3.7.0) --
|
|
||||||
// -- LAPACK is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// December 2016
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//=====================================================================
|
|
||||||
//
|
|
||||||
// .. Parameters ..
|
|
||||||
// ..
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// .. Local Arrays ..
|
|
||||||
// ..
|
|
||||||
// .. External Subroutines ..
|
|
||||||
// ..
|
|
||||||
// .. External Functions ..
|
|
||||||
// ..
|
|
||||||
// .. Intrinsic Functions ..
|
|
||||||
// ..
|
|
||||||
// .. Executable Statements ..
|
|
||||||
//
|
|
||||||
// Parameter adjustments
|
|
||||||
a_dim1 = *lda;
|
|
||||||
a_offset = 1 + a_dim1;
|
|
||||||
a -= a_offset;
|
|
||||||
--work;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
if (min(*m,*n) == 0) {
|
|
||||||
value = 0.;
|
|
||||||
} else if (lsame_(norm, "M")) {
|
|
||||||
//
|
|
||||||
// Find max(abs(A(i,j))).
|
|
||||||
//
|
|
||||||
value = 0.;
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
temp = (d__1 = a[i__ + j * a_dim1], abs(d__1));
|
|
||||||
if (value < temp || disnan_(&temp)) {
|
|
||||||
value = temp;
|
|
||||||
}
|
|
||||||
// L10:
|
|
||||||
}
|
|
||||||
// L20:
|
|
||||||
}
|
|
||||||
} else if (lsame_(norm, "O") || *(unsigned char *)norm == '1') {
|
|
||||||
//
|
|
||||||
// Find norm1(A).
|
|
||||||
//
|
|
||||||
value = 0.;
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
sum = 0.;
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
sum += (d__1 = a[i__ + j * a_dim1], abs(d__1));
|
|
||||||
// L30:
|
|
||||||
}
|
|
||||||
if (value < sum || disnan_(&sum)) {
|
|
||||||
value = sum;
|
|
||||||
}
|
|
||||||
// L40:
|
|
||||||
}
|
|
||||||
} else if (lsame_(norm, "I")) {
|
|
||||||
//
|
|
||||||
// Find normI(A).
|
|
||||||
//
|
|
||||||
i__1 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__1; ++i__) {
|
|
||||||
work[i__] = 0.;
|
|
||||||
// L50:
|
|
||||||
}
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
work[i__] += (d__1 = a[i__ + j * a_dim1], abs(d__1));
|
|
||||||
// L60:
|
|
||||||
}
|
|
||||||
// L70:
|
|
||||||
}
|
|
||||||
value = 0.;
|
|
||||||
i__1 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__1; ++i__) {
|
|
||||||
temp = work[i__];
|
|
||||||
if (value < temp || disnan_(&temp)) {
|
|
||||||
value = temp;
|
|
||||||
}
|
|
||||||
// L80:
|
|
||||||
}
|
|
||||||
} else if (lsame_(norm, "F") || lsame_(norm, "E")) {
|
|
||||||
//
|
|
||||||
// Find normF(A).
|
|
||||||
// SSQ(1) is scale
|
|
||||||
// SSQ(2) is sum-of-squares
|
|
||||||
// For better accuracy, sum each column separately.
|
|
||||||
//
|
|
||||||
ssq[0] = 0.;
|
|
||||||
ssq[1] = 1.;
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
colssq[0] = 0.;
|
|
||||||
colssq[1] = 1.;
|
|
||||||
dlassq_(m, &a[j * a_dim1 + 1], &c__1, colssq, &colssq[1]);
|
|
||||||
dcombssq_(ssq, colssq);
|
|
||||||
// L90:
|
|
||||||
}
|
|
||||||
value = ssq[0] * sqrt(ssq[1]);
|
|
||||||
}
|
|
||||||
ret_val = value;
|
|
||||||
return ret_val;
|
|
||||||
//
|
|
||||||
// End of DLANGE
|
|
||||||
//
|
|
||||||
} // dlange_
|
|
||||||
|
|
||||||
Vendored
-125
@@ -1,125 +0,0 @@
|
|||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
//> \brief \b DLAPY2 returns sqrt(x2+y2).
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
//> \htmlonly
|
|
||||||
//> Download DLAPY2 + dependencies
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlapy2.f">
|
|
||||||
//> [TGZ]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlapy2.f">
|
|
||||||
//> [ZIP]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlapy2.f">
|
|
||||||
//> [TXT]</a>
|
|
||||||
//> \endhtmlonly
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// DOUBLE PRECISION FUNCTION DLAPY2( X, Y )
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// DOUBLE PRECISION X, Y
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> DLAPY2 returns sqrt(x**2+y**2), taking care not to cause unnecessary
|
|
||||||
//> overflow.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] X
|
|
||||||
//> \verbatim
|
|
||||||
//> X is DOUBLE PRECISION
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] Y
|
|
||||||
//> \verbatim
|
|
||||||
//> Y is DOUBLE PRECISION
|
|
||||||
//> X and Y specify the values x and y.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date June 2017
|
|
||||||
//
|
|
||||||
//> \ingroup OTHERauxiliary
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
double dlapy2_(double *x, double *y)
|
|
||||||
{
|
|
||||||
// System generated locals
|
|
||||||
double ret_val, d__1;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int x_is_nan__, y_is_nan__;
|
|
||||||
double w, z__, xabs, yabs;
|
|
||||||
extern int disnan_(double *);
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- LAPACK auxiliary routine (version 3.7.1) --
|
|
||||||
// -- LAPACK is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// June 2017
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. Parameters ..
|
|
||||||
// ..
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// .. External Functions ..
|
|
||||||
// ..
|
|
||||||
// .. Intrinsic Functions ..
|
|
||||||
// ..
|
|
||||||
// .. Executable Statements ..
|
|
||||||
//
|
|
||||||
x_is_nan__ = disnan_(x);
|
|
||||||
y_is_nan__ = disnan_(y);
|
|
||||||
if (x_is_nan__) {
|
|
||||||
ret_val = *x;
|
|
||||||
}
|
|
||||||
if (y_is_nan__) {
|
|
||||||
ret_val = *y;
|
|
||||||
}
|
|
||||||
if (! (x_is_nan__ || y_is_nan__)) {
|
|
||||||
xabs = abs(*x);
|
|
||||||
yabs = abs(*y);
|
|
||||||
w = max(xabs,yabs);
|
|
||||||
z__ = min(xabs,yabs);
|
|
||||||
if (z__ == 0.) {
|
|
||||||
ret_val = w;
|
|
||||||
} else {
|
|
||||||
// Computing 2nd power
|
|
||||||
d__1 = z__ / w;
|
|
||||||
ret_val = w * sqrt(d__1 * d__1 + 1.);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret_val;
|
|
||||||
//
|
|
||||||
// End of DLAPY2
|
|
||||||
//
|
|
||||||
} // dlapy2_
|
|
||||||
|
|
||||||
Vendored
-768
@@ -1,768 +0,0 @@
|
|||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
//> \brief \b DGER
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// SUBROUTINE DGER(M,N,ALPHA,X,INCX,Y,INCY,A,LDA)
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// DOUBLE PRECISION ALPHA
|
|
||||||
// INTEGER INCX,INCY,LDA,M,N
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// DOUBLE PRECISION A(LDA,*),X(*),Y(*)
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> DGER performs the rank 1 operation
|
|
||||||
//>
|
|
||||||
//> A := alpha*x*y**T + A,
|
|
||||||
//>
|
|
||||||
//> where alpha is a scalar, x is an m element vector, y is an n element
|
|
||||||
//> vector and A is an m by n matrix.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] M
|
|
||||||
//> \verbatim
|
|
||||||
//> M is INTEGER
|
|
||||||
//> On entry, M specifies the number of rows of the matrix A.
|
|
||||||
//> M must be at least zero.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] N
|
|
||||||
//> \verbatim
|
|
||||||
//> N is INTEGER
|
|
||||||
//> On entry, N specifies the number of columns of the matrix A.
|
|
||||||
//> N must be at least zero.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] ALPHA
|
|
||||||
//> \verbatim
|
|
||||||
//> ALPHA is DOUBLE PRECISION.
|
|
||||||
//> On entry, ALPHA specifies the scalar alpha.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] X
|
|
||||||
//> \verbatim
|
|
||||||
//> X is DOUBLE PRECISION array, dimension at least
|
|
||||||
//> ( 1 + ( m - 1 )*abs( INCX ) ).
|
|
||||||
//> Before entry, the incremented array X must contain the m
|
|
||||||
//> element vector x.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] INCX
|
|
||||||
//> \verbatim
|
|
||||||
//> INCX is INTEGER
|
|
||||||
//> On entry, INCX specifies the increment for the elements of
|
|
||||||
//> X. INCX must not be zero.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] Y
|
|
||||||
//> \verbatim
|
|
||||||
//> Y is DOUBLE PRECISION array, dimension at least
|
|
||||||
//> ( 1 + ( n - 1 )*abs( INCY ) ).
|
|
||||||
//> Before entry, the incremented array Y must contain the n
|
|
||||||
//> element vector y.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] INCY
|
|
||||||
//> \verbatim
|
|
||||||
//> INCY is INTEGER
|
|
||||||
//> On entry, INCY specifies the increment for the elements of
|
|
||||||
//> Y. INCY must not be zero.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in,out] A
|
|
||||||
//> \verbatim
|
|
||||||
//> A is DOUBLE PRECISION array, dimension ( LDA, N )
|
|
||||||
//> Before entry, the leading m by n part of the array A must
|
|
||||||
//> contain the matrix of coefficients. On exit, A is
|
|
||||||
//> overwritten by the updated matrix.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDA
|
|
||||||
//> \verbatim
|
|
||||||
//> LDA is INTEGER
|
|
||||||
//> On entry, LDA specifies the first dimension of A as declared
|
|
||||||
//> in the calling (sub) program. LDA must be at least
|
|
||||||
//> max( 1, m ).
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date December 2016
|
|
||||||
//
|
|
||||||
//> \ingroup double_blas_level2
|
|
||||||
//
|
|
||||||
//> \par Further Details:
|
|
||||||
// =====================
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> Level 2 Blas routine.
|
|
||||||
//>
|
|
||||||
//> -- Written on 22-October-1986.
|
|
||||||
//> Jack Dongarra, Argonne National Lab.
|
|
||||||
//> Jeremy Du Croz, Nag Central Office.
|
|
||||||
//> Sven Hammarling, Nag Central Office.
|
|
||||||
//> Richard Hanson, Sandia National Labs.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
// =====================================================================
|
|
||||||
/* Subroutine */ int dger_(int *m, int *n, double *alpha, double *x, int *
|
|
||||||
incx, double *y, int *incy, double *a, int *lda)
|
|
||||||
{
|
|
||||||
// System generated locals
|
|
||||||
int a_dim1, a_offset, i__1, i__2;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int i__, j, ix, jy, kx, info;
|
|
||||||
double temp;
|
|
||||||
extern /* Subroutine */ int xerbla_(char *, int *);
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- Reference BLAS level2 routine (version 3.7.0) --
|
|
||||||
// -- Reference BLAS is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// December 2016
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. Parameters ..
|
|
||||||
// ..
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// .. External Subroutines ..
|
|
||||||
// ..
|
|
||||||
// .. Intrinsic Functions ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// Test the input parameters.
|
|
||||||
//
|
|
||||||
// Parameter adjustments
|
|
||||||
--x;
|
|
||||||
--y;
|
|
||||||
a_dim1 = *lda;
|
|
||||||
a_offset = 1 + a_dim1;
|
|
||||||
a -= a_offset;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
info = 0;
|
|
||||||
if (*m < 0) {
|
|
||||||
info = 1;
|
|
||||||
} else if (*n < 0) {
|
|
||||||
info = 2;
|
|
||||||
} else if (*incx == 0) {
|
|
||||||
info = 5;
|
|
||||||
} else if (*incy == 0) {
|
|
||||||
info = 7;
|
|
||||||
} else if (*lda < max(1,*m)) {
|
|
||||||
info = 9;
|
|
||||||
}
|
|
||||||
if (info != 0) {
|
|
||||||
xerbla_("DGER ", &info);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Quick return if possible.
|
|
||||||
//
|
|
||||||
if (*m == 0 || *n == 0 || *alpha == 0.) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Start the operations. In this version the elements of A are
|
|
||||||
// accessed sequentially with one pass through A.
|
|
||||||
//
|
|
||||||
if (*incy > 0) {
|
|
||||||
jy = 1;
|
|
||||||
} else {
|
|
||||||
jy = 1 - (*n - 1) * *incy;
|
|
||||||
}
|
|
||||||
if (*incx == 1) {
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
if (y[jy] != 0.) {
|
|
||||||
temp = *alpha * y[jy];
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
a[i__ + j * a_dim1] += x[i__] * temp;
|
|
||||||
// L10:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
jy += *incy;
|
|
||||||
// L20:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (*incx > 0) {
|
|
||||||
kx = 1;
|
|
||||||
} else {
|
|
||||||
kx = 1 - (*m - 1) * *incx;
|
|
||||||
}
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
if (y[jy] != 0.) {
|
|
||||||
temp = *alpha * y[jy];
|
|
||||||
ix = kx;
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
a[i__ + j * a_dim1] += x[ix] * temp;
|
|
||||||
ix += *incx;
|
|
||||||
// L30:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
jy += *incy;
|
|
||||||
// L40:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
//
|
|
||||||
// End of DGER .
|
|
||||||
//
|
|
||||||
} // dger_
|
|
||||||
|
|
||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
//> \brief \b DLARF applies an elementary reflector to a general rectangular matrix.
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
//> \htmlonly
|
|
||||||
//> Download DLARF + dependencies
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlarf.f">
|
|
||||||
//> [TGZ]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlarf.f">
|
|
||||||
//> [ZIP]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlarf.f">
|
|
||||||
//> [TXT]</a>
|
|
||||||
//> \endhtmlonly
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// SUBROUTINE DLARF( SIDE, M, N, V, INCV, TAU, C, LDC, WORK )
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// CHARACTER SIDE
|
|
||||||
// INTEGER INCV, LDC, M, N
|
|
||||||
// DOUBLE PRECISION TAU
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// DOUBLE PRECISION C( LDC, * ), V( * ), WORK( * )
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> DLARF applies a real elementary reflector H to a real m by n matrix
|
|
||||||
//> C, from either the left or the right. H is represented in the form
|
|
||||||
//>
|
|
||||||
//> H = I - tau * v * v**T
|
|
||||||
//>
|
|
||||||
//> where tau is a real scalar and v is a real vector.
|
|
||||||
//>
|
|
||||||
//> If tau = 0, then H is taken to be the unit matrix.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] SIDE
|
|
||||||
//> \verbatim
|
|
||||||
//> SIDE is CHARACTER*1
|
|
||||||
//> = 'L': form H * C
|
|
||||||
//> = 'R': form C * H
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] M
|
|
||||||
//> \verbatim
|
|
||||||
//> M is INTEGER
|
|
||||||
//> The number of rows of the matrix C.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] N
|
|
||||||
//> \verbatim
|
|
||||||
//> N is INTEGER
|
|
||||||
//> The number of columns of the matrix C.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] V
|
|
||||||
//> \verbatim
|
|
||||||
//> V is DOUBLE PRECISION array, dimension
|
|
||||||
//> (1 + (M-1)*abs(INCV)) if SIDE = 'L'
|
|
||||||
//> or (1 + (N-1)*abs(INCV)) if SIDE = 'R'
|
|
||||||
//> The vector v in the representation of H. V is not used if
|
|
||||||
//> TAU = 0.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] INCV
|
|
||||||
//> \verbatim
|
|
||||||
//> INCV is INTEGER
|
|
||||||
//> The increment between elements of v. INCV <> 0.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] TAU
|
|
||||||
//> \verbatim
|
|
||||||
//> TAU is DOUBLE PRECISION
|
|
||||||
//> The value tau in the representation of H.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in,out] C
|
|
||||||
//> \verbatim
|
|
||||||
//> C is DOUBLE PRECISION array, dimension (LDC,N)
|
|
||||||
//> On entry, the m by n matrix C.
|
|
||||||
//> On exit, C is overwritten by the matrix H * C if SIDE = 'L',
|
|
||||||
//> or C * H if SIDE = 'R'.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDC
|
|
||||||
//> \verbatim
|
|
||||||
//> LDC is INTEGER
|
|
||||||
//> The leading dimension of the array C. LDC >= max(1,M).
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[out] WORK
|
|
||||||
//> \verbatim
|
|
||||||
//> WORK is DOUBLE PRECISION array, dimension
|
|
||||||
//> (N) if SIDE = 'L'
|
|
||||||
//> or (M) if SIDE = 'R'
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date December 2016
|
|
||||||
//
|
|
||||||
//> \ingroup doubleOTHERauxiliary
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
/* Subroutine */ int dlarf_(char *side, int *m, int *n, double *v, int *incv,
|
|
||||||
double *tau, double *c__, int *ldc, double *work)
|
|
||||||
{
|
|
||||||
// Table of constant values
|
|
||||||
double c_b4 = 1.;
|
|
||||||
double c_b5 = 0.;
|
|
||||||
int c__1 = 1;
|
|
||||||
|
|
||||||
// System generated locals
|
|
||||||
int c_dim1, c_offset;
|
|
||||||
double d__1;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int i__;
|
|
||||||
int applyleft;
|
|
||||||
extern /* Subroutine */ int dger_(int *, int *, double *, double *, int *,
|
|
||||||
double *, int *, double *, int *);
|
|
||||||
extern int lsame_(char *, char *);
|
|
||||||
extern /* Subroutine */ int dgemv_(char *, int *, int *, double *, double
|
|
||||||
*, int *, double *, int *, double *, double *, int *);
|
|
||||||
int lastc, lastv;
|
|
||||||
extern int iladlc_(int *, int *, double *, int *), iladlr_(int *, int *,
|
|
||||||
double *, int *);
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- LAPACK auxiliary routine (version 3.7.0) --
|
|
||||||
// -- LAPACK is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// December 2016
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. Parameters ..
|
|
||||||
// ..
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// .. External Subroutines ..
|
|
||||||
// ..
|
|
||||||
// .. External Functions ..
|
|
||||||
// ..
|
|
||||||
// .. Executable Statements ..
|
|
||||||
//
|
|
||||||
// Parameter adjustments
|
|
||||||
--v;
|
|
||||||
c_dim1 = *ldc;
|
|
||||||
c_offset = 1 + c_dim1;
|
|
||||||
c__ -= c_offset;
|
|
||||||
--work;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
applyleft = lsame_(side, "L");
|
|
||||||
lastv = 0;
|
|
||||||
lastc = 0;
|
|
||||||
if (*tau != 0.) {
|
|
||||||
// Set up variables for scanning V. LASTV begins pointing to the end
|
|
||||||
// of V.
|
|
||||||
if (applyleft) {
|
|
||||||
lastv = *m;
|
|
||||||
} else {
|
|
||||||
lastv = *n;
|
|
||||||
}
|
|
||||||
if (*incv > 0) {
|
|
||||||
i__ = (lastv - 1) * *incv + 1;
|
|
||||||
} else {
|
|
||||||
i__ = 1;
|
|
||||||
}
|
|
||||||
// Look for the last non-zero row in V.
|
|
||||||
while(lastv > 0 && v[i__] == 0.) {
|
|
||||||
--lastv;
|
|
||||||
i__ -= *incv;
|
|
||||||
}
|
|
||||||
if (applyleft) {
|
|
||||||
// Scan for the last non-zero column in C(1:lastv,:).
|
|
||||||
lastc = iladlc_(&lastv, n, &c__[c_offset], ldc);
|
|
||||||
} else {
|
|
||||||
// Scan for the last non-zero row in C(:,1:lastv).
|
|
||||||
lastc = iladlr_(m, &lastv, &c__[c_offset], ldc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Note that lastc.eq.0 renders the BLAS operations null; no special
|
|
||||||
// case is needed at this level.
|
|
||||||
if (applyleft) {
|
|
||||||
//
|
|
||||||
// Form H * C
|
|
||||||
//
|
|
||||||
if (lastv > 0) {
|
|
||||||
//
|
|
||||||
// w(1:lastc,1) := C(1:lastv,1:lastc)**T * v(1:lastv,1)
|
|
||||||
//
|
|
||||||
dgemv_("Transpose", &lastv, &lastc, &c_b4, &c__[c_offset], ldc, &
|
|
||||||
v[1], incv, &c_b5, &work[1], &c__1);
|
|
||||||
//
|
|
||||||
// C(1:lastv,1:lastc) := C(...) - v(1:lastv,1) * w(1:lastc,1)**T
|
|
||||||
//
|
|
||||||
d__1 = -(*tau);
|
|
||||||
dger_(&lastv, &lastc, &d__1, &v[1], incv, &work[1], &c__1, &c__[
|
|
||||||
c_offset], ldc);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Form C * H
|
|
||||||
//
|
|
||||||
if (lastv > 0) {
|
|
||||||
//
|
|
||||||
// w(1:lastc,1) := C(1:lastc,1:lastv) * v(1:lastv,1)
|
|
||||||
//
|
|
||||||
dgemv_("No transpose", &lastc, &lastv, &c_b4, &c__[c_offset], ldc,
|
|
||||||
&v[1], incv, &c_b5, &work[1], &c__1);
|
|
||||||
//
|
|
||||||
// C(1:lastc,1:lastv) := C(...) - w(1:lastc,1) * v(1:lastv,1)**T
|
|
||||||
//
|
|
||||||
d__1 = -(*tau);
|
|
||||||
dger_(&lastc, &lastv, &d__1, &work[1], &c__1, &v[1], incv, &c__[
|
|
||||||
c_offset], ldc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
//
|
|
||||||
// End of DLARF
|
|
||||||
//
|
|
||||||
} // dlarf_
|
|
||||||
|
|
||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
//> \brief \b ILADLC scans a matrix for its last non-zero column.
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
//> \htmlonly
|
|
||||||
//> Download ILADLC + dependencies
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/iladlc.f">
|
|
||||||
//> [TGZ]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/iladlc.f">
|
|
||||||
//> [ZIP]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/iladlc.f">
|
|
||||||
//> [TXT]</a>
|
|
||||||
//> \endhtmlonly
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// INTEGER FUNCTION ILADLC( M, N, A, LDA )
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// INTEGER M, N, LDA
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// DOUBLE PRECISION A( LDA, * )
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> ILADLC scans A for its last non-zero column.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] M
|
|
||||||
//> \verbatim
|
|
||||||
//> M is INTEGER
|
|
||||||
//> The number of rows of the matrix A.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] N
|
|
||||||
//> \verbatim
|
|
||||||
//> N is INTEGER
|
|
||||||
//> The number of columns of the matrix A.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] A
|
|
||||||
//> \verbatim
|
|
||||||
//> A is DOUBLE PRECISION array, dimension (LDA,N)
|
|
||||||
//> The m by n matrix A.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDA
|
|
||||||
//> \verbatim
|
|
||||||
//> LDA is INTEGER
|
|
||||||
//> The leading dimension of the array A. LDA >= max(1,M).
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date December 2016
|
|
||||||
//
|
|
||||||
//> \ingroup OTHERauxiliary
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
int iladlc_(int *m, int *n, double *a, int *lda)
|
|
||||||
{
|
|
||||||
// System generated locals
|
|
||||||
int a_dim1, a_offset, ret_val, i__1;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int i__;
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- LAPACK auxiliary routine (version 3.7.0) --
|
|
||||||
// -- LAPACK is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// December 2016
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. Parameters ..
|
|
||||||
// ..
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// .. Executable Statements ..
|
|
||||||
//
|
|
||||||
// Quick test for the common case where one corner is non-zero.
|
|
||||||
// Parameter adjustments
|
|
||||||
a_dim1 = *lda;
|
|
||||||
a_offset = 1 + a_dim1;
|
|
||||||
a -= a_offset;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
if (*n == 0) {
|
|
||||||
ret_val = *n;
|
|
||||||
} else if (a[*n * a_dim1 + 1] != 0. || a[*m + *n * a_dim1] != 0.) {
|
|
||||||
ret_val = *n;
|
|
||||||
} else {
|
|
||||||
// Now scan each column from the end, returning with the first non-zero.
|
|
||||||
for (ret_val = *n; ret_val >= 1; --ret_val) {
|
|
||||||
i__1 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__1; ++i__) {
|
|
||||||
if (a[i__ + ret_val * a_dim1] != 0.) {
|
|
||||||
return ret_val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret_val;
|
|
||||||
} // iladlc_
|
|
||||||
|
|
||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
//> \brief \b ILADLR scans a matrix for its last non-zero row.
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
//> \htmlonly
|
|
||||||
//> Download ILADLR + dependencies
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/iladlr.f">
|
|
||||||
//> [TGZ]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/iladlr.f">
|
|
||||||
//> [ZIP]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/iladlr.f">
|
|
||||||
//> [TXT]</a>
|
|
||||||
//> \endhtmlonly
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// INTEGER FUNCTION ILADLR( M, N, A, LDA )
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// INTEGER M, N, LDA
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// DOUBLE PRECISION A( LDA, * )
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> ILADLR scans A for its last non-zero row.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] M
|
|
||||||
//> \verbatim
|
|
||||||
//> M is INTEGER
|
|
||||||
//> The number of rows of the matrix A.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] N
|
|
||||||
//> \verbatim
|
|
||||||
//> N is INTEGER
|
|
||||||
//> The number of columns of the matrix A.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] A
|
|
||||||
//> \verbatim
|
|
||||||
//> A is DOUBLE PRECISION array, dimension (LDA,N)
|
|
||||||
//> The m by n matrix A.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDA
|
|
||||||
//> \verbatim
|
|
||||||
//> LDA is INTEGER
|
|
||||||
//> The leading dimension of the array A. LDA >= max(1,M).
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date December 2016
|
|
||||||
//
|
|
||||||
//> \ingroup OTHERauxiliary
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
int iladlr_(int *m, int *n, double *a, int *lda)
|
|
||||||
{
|
|
||||||
// System generated locals
|
|
||||||
int a_dim1, a_offset, ret_val, i__1;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int i__, j;
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- LAPACK auxiliary routine (version 3.7.0) --
|
|
||||||
// -- LAPACK is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// December 2016
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. Parameters ..
|
|
||||||
// ..
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// .. Executable Statements ..
|
|
||||||
//
|
|
||||||
// Quick test for the common case where one corner is non-zero.
|
|
||||||
// Parameter adjustments
|
|
||||||
a_dim1 = *lda;
|
|
||||||
a_offset = 1 + a_dim1;
|
|
||||||
a -= a_offset;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
if (*m == 0) {
|
|
||||||
ret_val = *m;
|
|
||||||
} else if (a[*m + a_dim1] != 0. || a[*m + *n * a_dim1] != 0.) {
|
|
||||||
ret_val = *m;
|
|
||||||
} else {
|
|
||||||
// Scan up each column tracking the last zero row seen.
|
|
||||||
ret_val = 0;
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__ = *m;
|
|
||||||
while(a[max(i__,1) + j * a_dim1] == 0. && i__ >= 1) {
|
|
||||||
--i__;
|
|
||||||
}
|
|
||||||
ret_val = max(ret_val,i__);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret_val;
|
|
||||||
} // iladlr_
|
|
||||||
|
|
||||||
Vendored
-824
@@ -1,824 +0,0 @@
|
|||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
//> \brief \b DLARFB applies a block reflector or its transpose to a general rectangular matrix.
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
//> \htmlonly
|
|
||||||
//> Download DLARFB + dependencies
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlarfb.f">
|
|
||||||
//> [TGZ]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlarfb.f">
|
|
||||||
//> [ZIP]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlarfb.f">
|
|
||||||
//> [TXT]</a>
|
|
||||||
//> \endhtmlonly
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// SUBROUTINE DLARFB( SIDE, TRANS, DIRECT, STOREV, M, N, K, V, LDV,
|
|
||||||
// T, LDT, C, LDC, WORK, LDWORK )
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// CHARACTER DIRECT, SIDE, STOREV, TRANS
|
|
||||||
// INTEGER K, LDC, LDT, LDV, LDWORK, M, N
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// DOUBLE PRECISION C( LDC, * ), T( LDT, * ), V( LDV, * ),
|
|
||||||
// $ WORK( LDWORK, * )
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> DLARFB applies a real block reflector H or its transpose H**T to a
|
|
||||||
//> real m by n matrix C, from either the left or the right.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] SIDE
|
|
||||||
//> \verbatim
|
|
||||||
//> SIDE is CHARACTER*1
|
|
||||||
//> = 'L': apply H or H**T from the Left
|
|
||||||
//> = 'R': apply H or H**T from the Right
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] TRANS
|
|
||||||
//> \verbatim
|
|
||||||
//> TRANS is CHARACTER*1
|
|
||||||
//> = 'N': apply H (No transpose)
|
|
||||||
//> = 'T': apply H**T (Transpose)
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] DIRECT
|
|
||||||
//> \verbatim
|
|
||||||
//> DIRECT is CHARACTER*1
|
|
||||||
//> Indicates how H is formed from a product of elementary
|
|
||||||
//> reflectors
|
|
||||||
//> = 'F': H = H(1) H(2) . . . H(k) (Forward)
|
|
||||||
//> = 'B': H = H(k) . . . H(2) H(1) (Backward)
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] STOREV
|
|
||||||
//> \verbatim
|
|
||||||
//> STOREV is CHARACTER*1
|
|
||||||
//> Indicates how the vectors which define the elementary
|
|
||||||
//> reflectors are stored:
|
|
||||||
//> = 'C': Columnwise
|
|
||||||
//> = 'R': Rowwise
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] M
|
|
||||||
//> \verbatim
|
|
||||||
//> M is INTEGER
|
|
||||||
//> The number of rows of the matrix C.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] N
|
|
||||||
//> \verbatim
|
|
||||||
//> N is INTEGER
|
|
||||||
//> The number of columns of the matrix C.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] K
|
|
||||||
//> \verbatim
|
|
||||||
//> K is INTEGER
|
|
||||||
//> The order of the matrix T (= the number of elementary
|
|
||||||
//> reflectors whose product defines the block reflector).
|
|
||||||
//> If SIDE = 'L', M >= K >= 0;
|
|
||||||
//> if SIDE = 'R', N >= K >= 0.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] V
|
|
||||||
//> \verbatim
|
|
||||||
//> V is DOUBLE PRECISION array, dimension
|
|
||||||
//> (LDV,K) if STOREV = 'C'
|
|
||||||
//> (LDV,M) if STOREV = 'R' and SIDE = 'L'
|
|
||||||
//> (LDV,N) if STOREV = 'R' and SIDE = 'R'
|
|
||||||
//> The matrix V. See Further Details.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDV
|
|
||||||
//> \verbatim
|
|
||||||
//> LDV is INTEGER
|
|
||||||
//> The leading dimension of the array V.
|
|
||||||
//> If STOREV = 'C' and SIDE = 'L', LDV >= max(1,M);
|
|
||||||
//> if STOREV = 'C' and SIDE = 'R', LDV >= max(1,N);
|
|
||||||
//> if STOREV = 'R', LDV >= K.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] T
|
|
||||||
//> \verbatim
|
|
||||||
//> T is DOUBLE PRECISION array, dimension (LDT,K)
|
|
||||||
//> The triangular k by k matrix T in the representation of the
|
|
||||||
//> block reflector.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDT
|
|
||||||
//> \verbatim
|
|
||||||
//> LDT is INTEGER
|
|
||||||
//> The leading dimension of the array T. LDT >= K.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in,out] C
|
|
||||||
//> \verbatim
|
|
||||||
//> C is DOUBLE PRECISION array, dimension (LDC,N)
|
|
||||||
//> On entry, the m by n matrix C.
|
|
||||||
//> On exit, C is overwritten by H*C or H**T*C or C*H or C*H**T.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDC
|
|
||||||
//> \verbatim
|
|
||||||
//> LDC is INTEGER
|
|
||||||
//> The leading dimension of the array C. LDC >= max(1,M).
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[out] WORK
|
|
||||||
//> \verbatim
|
|
||||||
//> WORK is DOUBLE PRECISION array, dimension (LDWORK,K)
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDWORK
|
|
||||||
//> \verbatim
|
|
||||||
//> LDWORK is INTEGER
|
|
||||||
//> The leading dimension of the array WORK.
|
|
||||||
//> If SIDE = 'L', LDWORK >= max(1,N);
|
|
||||||
//> if SIDE = 'R', LDWORK >= max(1,M).
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date June 2013
|
|
||||||
//
|
|
||||||
//> \ingroup doubleOTHERauxiliary
|
|
||||||
//
|
|
||||||
//> \par Further Details:
|
|
||||||
// =====================
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> The shape of the matrix V and the storage of the vectors which define
|
|
||||||
//> the H(i) is best illustrated by the following example with n = 5 and
|
|
||||||
//> k = 3. The elements equal to 1 are not stored; the corresponding
|
|
||||||
//> array elements are modified but restored on exit. The rest of the
|
|
||||||
//> array is not used.
|
|
||||||
//>
|
|
||||||
//> DIRECT = 'F' and STOREV = 'C': DIRECT = 'F' and STOREV = 'R':
|
|
||||||
//>
|
|
||||||
//> V = ( 1 ) V = ( 1 v1 v1 v1 v1 )
|
|
||||||
//> ( v1 1 ) ( 1 v2 v2 v2 )
|
|
||||||
//> ( v1 v2 1 ) ( 1 v3 v3 )
|
|
||||||
//> ( v1 v2 v3 )
|
|
||||||
//> ( v1 v2 v3 )
|
|
||||||
//>
|
|
||||||
//> DIRECT = 'B' and STOREV = 'C': DIRECT = 'B' and STOREV = 'R':
|
|
||||||
//>
|
|
||||||
//> V = ( v1 v2 v3 ) V = ( v1 v1 1 )
|
|
||||||
//> ( v1 v2 v3 ) ( v2 v2 v2 1 )
|
|
||||||
//> ( 1 v2 v3 ) ( v3 v3 v3 v3 1 )
|
|
||||||
//> ( 1 v3 )
|
|
||||||
//> ( 1 )
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
// =====================================================================
|
|
||||||
/* Subroutine */ int dlarfb_(char *side, char *trans, char *direct, char *
|
|
||||||
storev, int *m, int *n, int *k, double *v, int *ldv, double *t, int *
|
|
||||||
ldt, double *c__, int *ldc, double *work, int *ldwork)
|
|
||||||
{
|
|
||||||
// Table of constant values
|
|
||||||
int c__1 = 1;
|
|
||||||
double c_b14 = 1.;
|
|
||||||
double c_b25 = -1.;
|
|
||||||
|
|
||||||
// System generated locals
|
|
||||||
int c_dim1, c_offset, t_dim1, t_offset, v_dim1, v_offset, work_dim1,
|
|
||||||
work_offset, i__1, i__2;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int i__, j;
|
|
||||||
extern /* Subroutine */ int dgemm_(char *, char *, int *, int *, int *,
|
|
||||||
double *, double *, int *, double *, int *, double *, double *,
|
|
||||||
int *);
|
|
||||||
extern int lsame_(char *, char *);
|
|
||||||
extern /* Subroutine */ int dcopy_(int *, double *, int *, double *, int *
|
|
||||||
), dtrmm_(char *, char *, char *, char *, int *, int *, double *,
|
|
||||||
double *, int *, double *, int *);
|
|
||||||
char transt[1+1]={'\0'};
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- LAPACK auxiliary routine (version 3.7.0) --
|
|
||||||
// -- LAPACK is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// June 2013
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. Parameters ..
|
|
||||||
// ..
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// .. External Functions ..
|
|
||||||
// ..
|
|
||||||
// .. External Subroutines ..
|
|
||||||
// ..
|
|
||||||
// .. Executable Statements ..
|
|
||||||
//
|
|
||||||
// Quick return if possible
|
|
||||||
//
|
|
||||||
// Parameter adjustments
|
|
||||||
v_dim1 = *ldv;
|
|
||||||
v_offset = 1 + v_dim1;
|
|
||||||
v -= v_offset;
|
|
||||||
t_dim1 = *ldt;
|
|
||||||
t_offset = 1 + t_dim1;
|
|
||||||
t -= t_offset;
|
|
||||||
c_dim1 = *ldc;
|
|
||||||
c_offset = 1 + c_dim1;
|
|
||||||
c__ -= c_offset;
|
|
||||||
work_dim1 = *ldwork;
|
|
||||||
work_offset = 1 + work_dim1;
|
|
||||||
work -= work_offset;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
if (*m <= 0 || *n <= 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (lsame_(trans, "N")) {
|
|
||||||
*(unsigned char *)transt = 'T';
|
|
||||||
} else {
|
|
||||||
*(unsigned char *)transt = 'N';
|
|
||||||
}
|
|
||||||
if (lsame_(storev, "C")) {
|
|
||||||
if (lsame_(direct, "F")) {
|
|
||||||
//
|
|
||||||
// Let V = ( V1 ) (first K rows)
|
|
||||||
// ( V2 )
|
|
||||||
// where V1 is unit lower triangular.
|
|
||||||
//
|
|
||||||
if (lsame_(side, "L")) {
|
|
||||||
//
|
|
||||||
// Form H * C or H**T * C where C = ( C1 )
|
|
||||||
// ( C2 )
|
|
||||||
//
|
|
||||||
// W := C**T * V = (C1**T * V1 + C2**T * V2) (stored in WORK)
|
|
||||||
//
|
|
||||||
// W := C1**T
|
|
||||||
//
|
|
||||||
i__1 = *k;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
dcopy_(n, &c__[j + c_dim1], ldc, &work[j * work_dim1 + 1],
|
|
||||||
&c__1);
|
|
||||||
// L10:
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// W := W * V1
|
|
||||||
//
|
|
||||||
dtrmm_("Right", "Lower", "No transpose", "Unit", n, k, &c_b14,
|
|
||||||
&v[v_offset], ldv, &work[work_offset], ldwork);
|
|
||||||
if (*m > *k) {
|
|
||||||
//
|
|
||||||
// W := W + C2**T * V2
|
|
||||||
//
|
|
||||||
i__1 = *m - *k;
|
|
||||||
dgemm_("Transpose", "No transpose", n, k, &i__1, &c_b14, &
|
|
||||||
c__[*k + 1 + c_dim1], ldc, &v[*k + 1 + v_dim1],
|
|
||||||
ldv, &c_b14, &work[work_offset], ldwork);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// W := W * T**T or W * T
|
|
||||||
//
|
|
||||||
dtrmm_("Right", "Upper", transt, "Non-unit", n, k, &c_b14, &t[
|
|
||||||
t_offset], ldt, &work[work_offset], ldwork);
|
|
||||||
//
|
|
||||||
// C := C - V * W**T
|
|
||||||
//
|
|
||||||
if (*m > *k) {
|
|
||||||
//
|
|
||||||
// C2 := C2 - V2 * W**T
|
|
||||||
//
|
|
||||||
i__1 = *m - *k;
|
|
||||||
dgemm_("No transpose", "Transpose", &i__1, n, k, &c_b25, &
|
|
||||||
v[*k + 1 + v_dim1], ldv, &work[work_offset],
|
|
||||||
ldwork, &c_b14, &c__[*k + 1 + c_dim1], ldc);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// W := W * V1**T
|
|
||||||
//
|
|
||||||
dtrmm_("Right", "Lower", "Transpose", "Unit", n, k, &c_b14, &
|
|
||||||
v[v_offset], ldv, &work[work_offset], ldwork);
|
|
||||||
//
|
|
||||||
// C1 := C1 - W**T
|
|
||||||
//
|
|
||||||
i__1 = *k;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *n;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
c__[j + i__ * c_dim1] -= work[i__ + j * work_dim1];
|
|
||||||
// L20:
|
|
||||||
}
|
|
||||||
// L30:
|
|
||||||
}
|
|
||||||
} else if (lsame_(side, "R")) {
|
|
||||||
//
|
|
||||||
// Form C * H or C * H**T where C = ( C1 C2 )
|
|
||||||
//
|
|
||||||
// W := C * V = (C1*V1 + C2*V2) (stored in WORK)
|
|
||||||
//
|
|
||||||
// W := C1
|
|
||||||
//
|
|
||||||
i__1 = *k;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
dcopy_(m, &c__[j * c_dim1 + 1], &c__1, &work[j *
|
|
||||||
work_dim1 + 1], &c__1);
|
|
||||||
// L40:
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// W := W * V1
|
|
||||||
//
|
|
||||||
dtrmm_("Right", "Lower", "No transpose", "Unit", m, k, &c_b14,
|
|
||||||
&v[v_offset], ldv, &work[work_offset], ldwork);
|
|
||||||
if (*n > *k) {
|
|
||||||
//
|
|
||||||
// W := W + C2 * V2
|
|
||||||
//
|
|
||||||
i__1 = *n - *k;
|
|
||||||
dgemm_("No transpose", "No transpose", m, k, &i__1, &
|
|
||||||
c_b14, &c__[(*k + 1) * c_dim1 + 1], ldc, &v[*k +
|
|
||||||
1 + v_dim1], ldv, &c_b14, &work[work_offset],
|
|
||||||
ldwork);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// W := W * T or W * T**T
|
|
||||||
//
|
|
||||||
dtrmm_("Right", "Upper", trans, "Non-unit", m, k, &c_b14, &t[
|
|
||||||
t_offset], ldt, &work[work_offset], ldwork);
|
|
||||||
//
|
|
||||||
// C := C - W * V**T
|
|
||||||
//
|
|
||||||
if (*n > *k) {
|
|
||||||
//
|
|
||||||
// C2 := C2 - W * V2**T
|
|
||||||
//
|
|
||||||
i__1 = *n - *k;
|
|
||||||
dgemm_("No transpose", "Transpose", m, &i__1, k, &c_b25, &
|
|
||||||
work[work_offset], ldwork, &v[*k + 1 + v_dim1],
|
|
||||||
ldv, &c_b14, &c__[(*k + 1) * c_dim1 + 1], ldc);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// W := W * V1**T
|
|
||||||
//
|
|
||||||
dtrmm_("Right", "Lower", "Transpose", "Unit", m, k, &c_b14, &
|
|
||||||
v[v_offset], ldv, &work[work_offset], ldwork);
|
|
||||||
//
|
|
||||||
// C1 := C1 - W
|
|
||||||
//
|
|
||||||
i__1 = *k;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
c__[i__ + j * c_dim1] -= work[i__ + j * work_dim1];
|
|
||||||
// L50:
|
|
||||||
}
|
|
||||||
// L60:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Let V = ( V1 )
|
|
||||||
// ( V2 ) (last K rows)
|
|
||||||
// where V2 is unit upper triangular.
|
|
||||||
//
|
|
||||||
if (lsame_(side, "L")) {
|
|
||||||
//
|
|
||||||
// Form H * C or H**T * C where C = ( C1 )
|
|
||||||
// ( C2 )
|
|
||||||
//
|
|
||||||
// W := C**T * V = (C1**T * V1 + C2**T * V2) (stored in WORK)
|
|
||||||
//
|
|
||||||
// W := C2**T
|
|
||||||
//
|
|
||||||
i__1 = *k;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
dcopy_(n, &c__[*m - *k + j + c_dim1], ldc, &work[j *
|
|
||||||
work_dim1 + 1], &c__1);
|
|
||||||
// L70:
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// W := W * V2
|
|
||||||
//
|
|
||||||
dtrmm_("Right", "Upper", "No transpose", "Unit", n, k, &c_b14,
|
|
||||||
&v[*m - *k + 1 + v_dim1], ldv, &work[work_offset],
|
|
||||||
ldwork);
|
|
||||||
if (*m > *k) {
|
|
||||||
//
|
|
||||||
// W := W + C1**T * V1
|
|
||||||
//
|
|
||||||
i__1 = *m - *k;
|
|
||||||
dgemm_("Transpose", "No transpose", n, k, &i__1, &c_b14, &
|
|
||||||
c__[c_offset], ldc, &v[v_offset], ldv, &c_b14, &
|
|
||||||
work[work_offset], ldwork);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// W := W * T**T or W * T
|
|
||||||
//
|
|
||||||
dtrmm_("Right", "Lower", transt, "Non-unit", n, k, &c_b14, &t[
|
|
||||||
t_offset], ldt, &work[work_offset], ldwork);
|
|
||||||
//
|
|
||||||
// C := C - V * W**T
|
|
||||||
//
|
|
||||||
if (*m > *k) {
|
|
||||||
//
|
|
||||||
// C1 := C1 - V1 * W**T
|
|
||||||
//
|
|
||||||
i__1 = *m - *k;
|
|
||||||
dgemm_("No transpose", "Transpose", &i__1, n, k, &c_b25, &
|
|
||||||
v[v_offset], ldv, &work[work_offset], ldwork, &
|
|
||||||
c_b14, &c__[c_offset], ldc);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// W := W * V2**T
|
|
||||||
//
|
|
||||||
dtrmm_("Right", "Upper", "Transpose", "Unit", n, k, &c_b14, &
|
|
||||||
v[*m - *k + 1 + v_dim1], ldv, &work[work_offset],
|
|
||||||
ldwork);
|
|
||||||
//
|
|
||||||
// C2 := C2 - W**T
|
|
||||||
//
|
|
||||||
i__1 = *k;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *n;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
c__[*m - *k + j + i__ * c_dim1] -= work[i__ + j *
|
|
||||||
work_dim1];
|
|
||||||
// L80:
|
|
||||||
}
|
|
||||||
// L90:
|
|
||||||
}
|
|
||||||
} else if (lsame_(side, "R")) {
|
|
||||||
//
|
|
||||||
// Form C * H or C * H**T where C = ( C1 C2 )
|
|
||||||
//
|
|
||||||
// W := C * V = (C1*V1 + C2*V2) (stored in WORK)
|
|
||||||
//
|
|
||||||
// W := C2
|
|
||||||
//
|
|
||||||
i__1 = *k;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
dcopy_(m, &c__[(*n - *k + j) * c_dim1 + 1], &c__1, &work[
|
|
||||||
j * work_dim1 + 1], &c__1);
|
|
||||||
// L100:
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// W := W * V2
|
|
||||||
//
|
|
||||||
dtrmm_("Right", "Upper", "No transpose", "Unit", m, k, &c_b14,
|
|
||||||
&v[*n - *k + 1 + v_dim1], ldv, &work[work_offset],
|
|
||||||
ldwork);
|
|
||||||
if (*n > *k) {
|
|
||||||
//
|
|
||||||
// W := W + C1 * V1
|
|
||||||
//
|
|
||||||
i__1 = *n - *k;
|
|
||||||
dgemm_("No transpose", "No transpose", m, k, &i__1, &
|
|
||||||
c_b14, &c__[c_offset], ldc, &v[v_offset], ldv, &
|
|
||||||
c_b14, &work[work_offset], ldwork);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// W := W * T or W * T**T
|
|
||||||
//
|
|
||||||
dtrmm_("Right", "Lower", trans, "Non-unit", m, k, &c_b14, &t[
|
|
||||||
t_offset], ldt, &work[work_offset], ldwork);
|
|
||||||
//
|
|
||||||
// C := C - W * V**T
|
|
||||||
//
|
|
||||||
if (*n > *k) {
|
|
||||||
//
|
|
||||||
// C1 := C1 - W * V1**T
|
|
||||||
//
|
|
||||||
i__1 = *n - *k;
|
|
||||||
dgemm_("No transpose", "Transpose", m, &i__1, k, &c_b25, &
|
|
||||||
work[work_offset], ldwork, &v[v_offset], ldv, &
|
|
||||||
c_b14, &c__[c_offset], ldc);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// W := W * V2**T
|
|
||||||
//
|
|
||||||
dtrmm_("Right", "Upper", "Transpose", "Unit", m, k, &c_b14, &
|
|
||||||
v[*n - *k + 1 + v_dim1], ldv, &work[work_offset],
|
|
||||||
ldwork);
|
|
||||||
//
|
|
||||||
// C2 := C2 - W
|
|
||||||
//
|
|
||||||
i__1 = *k;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
c__[i__ + (*n - *k + j) * c_dim1] -= work[i__ + j *
|
|
||||||
work_dim1];
|
|
||||||
// L110:
|
|
||||||
}
|
|
||||||
// L120:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (lsame_(storev, "R")) {
|
|
||||||
if (lsame_(direct, "F")) {
|
|
||||||
//
|
|
||||||
// Let V = ( V1 V2 ) (V1: first K columns)
|
|
||||||
// where V1 is unit upper triangular.
|
|
||||||
//
|
|
||||||
if (lsame_(side, "L")) {
|
|
||||||
//
|
|
||||||
// Form H * C or H**T * C where C = ( C1 )
|
|
||||||
// ( C2 )
|
|
||||||
//
|
|
||||||
// W := C**T * V**T = (C1**T * V1**T + C2**T * V2**T) (stored in WORK)
|
|
||||||
//
|
|
||||||
// W := C1**T
|
|
||||||
//
|
|
||||||
i__1 = *k;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
dcopy_(n, &c__[j + c_dim1], ldc, &work[j * work_dim1 + 1],
|
|
||||||
&c__1);
|
|
||||||
// L130:
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// W := W * V1**T
|
|
||||||
//
|
|
||||||
dtrmm_("Right", "Upper", "Transpose", "Unit", n, k, &c_b14, &
|
|
||||||
v[v_offset], ldv, &work[work_offset], ldwork);
|
|
||||||
if (*m > *k) {
|
|
||||||
//
|
|
||||||
// W := W + C2**T * V2**T
|
|
||||||
//
|
|
||||||
i__1 = *m - *k;
|
|
||||||
dgemm_("Transpose", "Transpose", n, k, &i__1, &c_b14, &
|
|
||||||
c__[*k + 1 + c_dim1], ldc, &v[(*k + 1) * v_dim1 +
|
|
||||||
1], ldv, &c_b14, &work[work_offset], ldwork);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// W := W * T**T or W * T
|
|
||||||
//
|
|
||||||
dtrmm_("Right", "Upper", transt, "Non-unit", n, k, &c_b14, &t[
|
|
||||||
t_offset], ldt, &work[work_offset], ldwork);
|
|
||||||
//
|
|
||||||
// C := C - V**T * W**T
|
|
||||||
//
|
|
||||||
if (*m > *k) {
|
|
||||||
//
|
|
||||||
// C2 := C2 - V2**T * W**T
|
|
||||||
//
|
|
||||||
i__1 = *m - *k;
|
|
||||||
dgemm_("Transpose", "Transpose", &i__1, n, k, &c_b25, &v[(
|
|
||||||
*k + 1) * v_dim1 + 1], ldv, &work[work_offset],
|
|
||||||
ldwork, &c_b14, &c__[*k + 1 + c_dim1], ldc);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// W := W * V1
|
|
||||||
//
|
|
||||||
dtrmm_("Right", "Upper", "No transpose", "Unit", n, k, &c_b14,
|
|
||||||
&v[v_offset], ldv, &work[work_offset], ldwork);
|
|
||||||
//
|
|
||||||
// C1 := C1 - W**T
|
|
||||||
//
|
|
||||||
i__1 = *k;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *n;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
c__[j + i__ * c_dim1] -= work[i__ + j * work_dim1];
|
|
||||||
// L140:
|
|
||||||
}
|
|
||||||
// L150:
|
|
||||||
}
|
|
||||||
} else if (lsame_(side, "R")) {
|
|
||||||
//
|
|
||||||
// Form C * H or C * H**T where C = ( C1 C2 )
|
|
||||||
//
|
|
||||||
// W := C * V**T = (C1*V1**T + C2*V2**T) (stored in WORK)
|
|
||||||
//
|
|
||||||
// W := C1
|
|
||||||
//
|
|
||||||
i__1 = *k;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
dcopy_(m, &c__[j * c_dim1 + 1], &c__1, &work[j *
|
|
||||||
work_dim1 + 1], &c__1);
|
|
||||||
// L160:
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// W := W * V1**T
|
|
||||||
//
|
|
||||||
dtrmm_("Right", "Upper", "Transpose", "Unit", m, k, &c_b14, &
|
|
||||||
v[v_offset], ldv, &work[work_offset], ldwork);
|
|
||||||
if (*n > *k) {
|
|
||||||
//
|
|
||||||
// W := W + C2 * V2**T
|
|
||||||
//
|
|
||||||
i__1 = *n - *k;
|
|
||||||
dgemm_("No transpose", "Transpose", m, k, &i__1, &c_b14, &
|
|
||||||
c__[(*k + 1) * c_dim1 + 1], ldc, &v[(*k + 1) *
|
|
||||||
v_dim1 + 1], ldv, &c_b14, &work[work_offset],
|
|
||||||
ldwork);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// W := W * T or W * T**T
|
|
||||||
//
|
|
||||||
dtrmm_("Right", "Upper", trans, "Non-unit", m, k, &c_b14, &t[
|
|
||||||
t_offset], ldt, &work[work_offset], ldwork);
|
|
||||||
//
|
|
||||||
// C := C - W * V
|
|
||||||
//
|
|
||||||
if (*n > *k) {
|
|
||||||
//
|
|
||||||
// C2 := C2 - W * V2
|
|
||||||
//
|
|
||||||
i__1 = *n - *k;
|
|
||||||
dgemm_("No transpose", "No transpose", m, &i__1, k, &
|
|
||||||
c_b25, &work[work_offset], ldwork, &v[(*k + 1) *
|
|
||||||
v_dim1 + 1], ldv, &c_b14, &c__[(*k + 1) * c_dim1
|
|
||||||
+ 1], ldc);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// W := W * V1
|
|
||||||
//
|
|
||||||
dtrmm_("Right", "Upper", "No transpose", "Unit", m, k, &c_b14,
|
|
||||||
&v[v_offset], ldv, &work[work_offset], ldwork);
|
|
||||||
//
|
|
||||||
// C1 := C1 - W
|
|
||||||
//
|
|
||||||
i__1 = *k;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
c__[i__ + j * c_dim1] -= work[i__ + j * work_dim1];
|
|
||||||
// L170:
|
|
||||||
}
|
|
||||||
// L180:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Let V = ( V1 V2 ) (V2: last K columns)
|
|
||||||
// where V2 is unit lower triangular.
|
|
||||||
//
|
|
||||||
if (lsame_(side, "L")) {
|
|
||||||
//
|
|
||||||
// Form H * C or H**T * C where C = ( C1 )
|
|
||||||
// ( C2 )
|
|
||||||
//
|
|
||||||
// W := C**T * V**T = (C1**T * V1**T + C2**T * V2**T) (stored in WORK)
|
|
||||||
//
|
|
||||||
// W := C2**T
|
|
||||||
//
|
|
||||||
i__1 = *k;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
dcopy_(n, &c__[*m - *k + j + c_dim1], ldc, &work[j *
|
|
||||||
work_dim1 + 1], &c__1);
|
|
||||||
// L190:
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// W := W * V2**T
|
|
||||||
//
|
|
||||||
dtrmm_("Right", "Lower", "Transpose", "Unit", n, k, &c_b14, &
|
|
||||||
v[(*m - *k + 1) * v_dim1 + 1], ldv, &work[work_offset]
|
|
||||||
, ldwork);
|
|
||||||
if (*m > *k) {
|
|
||||||
//
|
|
||||||
// W := W + C1**T * V1**T
|
|
||||||
//
|
|
||||||
i__1 = *m - *k;
|
|
||||||
dgemm_("Transpose", "Transpose", n, k, &i__1, &c_b14, &
|
|
||||||
c__[c_offset], ldc, &v[v_offset], ldv, &c_b14, &
|
|
||||||
work[work_offset], ldwork);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// W := W * T**T or W * T
|
|
||||||
//
|
|
||||||
dtrmm_("Right", "Lower", transt, "Non-unit", n, k, &c_b14, &t[
|
|
||||||
t_offset], ldt, &work[work_offset], ldwork);
|
|
||||||
//
|
|
||||||
// C := C - V**T * W**T
|
|
||||||
//
|
|
||||||
if (*m > *k) {
|
|
||||||
//
|
|
||||||
// C1 := C1 - V1**T * W**T
|
|
||||||
//
|
|
||||||
i__1 = *m - *k;
|
|
||||||
dgemm_("Transpose", "Transpose", &i__1, n, k, &c_b25, &v[
|
|
||||||
v_offset], ldv, &work[work_offset], ldwork, &
|
|
||||||
c_b14, &c__[c_offset], ldc);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// W := W * V2
|
|
||||||
//
|
|
||||||
dtrmm_("Right", "Lower", "No transpose", "Unit", n, k, &c_b14,
|
|
||||||
&v[(*m - *k + 1) * v_dim1 + 1], ldv, &work[
|
|
||||||
work_offset], ldwork);
|
|
||||||
//
|
|
||||||
// C2 := C2 - W**T
|
|
||||||
//
|
|
||||||
i__1 = *k;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *n;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
c__[*m - *k + j + i__ * c_dim1] -= work[i__ + j *
|
|
||||||
work_dim1];
|
|
||||||
// L200:
|
|
||||||
}
|
|
||||||
// L210:
|
|
||||||
}
|
|
||||||
} else if (lsame_(side, "R")) {
|
|
||||||
//
|
|
||||||
// Form C * H or C * H' where C = ( C1 C2 )
|
|
||||||
//
|
|
||||||
// W := C * V**T = (C1*V1**T + C2*V2**T) (stored in WORK)
|
|
||||||
//
|
|
||||||
// W := C2
|
|
||||||
//
|
|
||||||
i__1 = *k;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
dcopy_(m, &c__[(*n - *k + j) * c_dim1 + 1], &c__1, &work[
|
|
||||||
j * work_dim1 + 1], &c__1);
|
|
||||||
// L220:
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// W := W * V2**T
|
|
||||||
//
|
|
||||||
dtrmm_("Right", "Lower", "Transpose", "Unit", m, k, &c_b14, &
|
|
||||||
v[(*n - *k + 1) * v_dim1 + 1], ldv, &work[work_offset]
|
|
||||||
, ldwork);
|
|
||||||
if (*n > *k) {
|
|
||||||
//
|
|
||||||
// W := W + C1 * V1**T
|
|
||||||
//
|
|
||||||
i__1 = *n - *k;
|
|
||||||
dgemm_("No transpose", "Transpose", m, k, &i__1, &c_b14, &
|
|
||||||
c__[c_offset], ldc, &v[v_offset], ldv, &c_b14, &
|
|
||||||
work[work_offset], ldwork);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// W := W * T or W * T**T
|
|
||||||
//
|
|
||||||
dtrmm_("Right", "Lower", trans, "Non-unit", m, k, &c_b14, &t[
|
|
||||||
t_offset], ldt, &work[work_offset], ldwork);
|
|
||||||
//
|
|
||||||
// C := C - W * V
|
|
||||||
//
|
|
||||||
if (*n > *k) {
|
|
||||||
//
|
|
||||||
// C1 := C1 - W * V1
|
|
||||||
//
|
|
||||||
i__1 = *n - *k;
|
|
||||||
dgemm_("No transpose", "No transpose", m, &i__1, k, &
|
|
||||||
c_b25, &work[work_offset], ldwork, &v[v_offset],
|
|
||||||
ldv, &c_b14, &c__[c_offset], ldc);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// W := W * V2
|
|
||||||
//
|
|
||||||
dtrmm_("Right", "Lower", "No transpose", "Unit", m, k, &c_b14,
|
|
||||||
&v[(*n - *k + 1) * v_dim1 + 1], ldv, &work[
|
|
||||||
work_offset], ldwork);
|
|
||||||
//
|
|
||||||
// C1 := C1 - W
|
|
||||||
//
|
|
||||||
i__1 = *k;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
c__[i__ + (*n - *k + j) * c_dim1] -= work[i__ + j *
|
|
||||||
work_dim1];
|
|
||||||
// L230:
|
|
||||||
}
|
|
||||||
// L240:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
//
|
|
||||||
// End of DLARFB
|
|
||||||
//
|
|
||||||
} // dlarfb_
|
|
||||||
|
|
||||||
Vendored
-216
@@ -1,216 +0,0 @@
|
|||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
//> \brief \b DLARFG generates an elementary reflector (Householder matrix).
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
//> \htmlonly
|
|
||||||
//> Download DLARFG + dependencies
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlarfg.f">
|
|
||||||
//> [TGZ]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlarfg.f">
|
|
||||||
//> [ZIP]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlarfg.f">
|
|
||||||
//> [TXT]</a>
|
|
||||||
//> \endhtmlonly
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// SUBROUTINE DLARFG( N, ALPHA, X, INCX, TAU )
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// INTEGER INCX, N
|
|
||||||
// DOUBLE PRECISION ALPHA, TAU
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// DOUBLE PRECISION X( * )
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> DLARFG generates a real elementary reflector H of order n, such
|
|
||||||
//> that
|
|
||||||
//>
|
|
||||||
//> H * ( alpha ) = ( beta ), H**T * H = I.
|
|
||||||
//> ( x ) ( 0 )
|
|
||||||
//>
|
|
||||||
//> where alpha and beta are scalars, and x is an (n-1)-element real
|
|
||||||
//> vector. H is represented in the form
|
|
||||||
//>
|
|
||||||
//> H = I - tau * ( 1 ) * ( 1 v**T ) ,
|
|
||||||
//> ( v )
|
|
||||||
//>
|
|
||||||
//> where tau is a real scalar and v is a real (n-1)-element
|
|
||||||
//> vector.
|
|
||||||
//>
|
|
||||||
//> If the elements of x are all zero, then tau = 0 and H is taken to be
|
|
||||||
//> the unit matrix.
|
|
||||||
//>
|
|
||||||
//> Otherwise 1 <= tau <= 2.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] N
|
|
||||||
//> \verbatim
|
|
||||||
//> N is INTEGER
|
|
||||||
//> The order of the elementary reflector.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in,out] ALPHA
|
|
||||||
//> \verbatim
|
|
||||||
//> ALPHA is DOUBLE PRECISION
|
|
||||||
//> On entry, the value alpha.
|
|
||||||
//> On exit, it is overwritten with the value beta.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in,out] X
|
|
||||||
//> \verbatim
|
|
||||||
//> X is DOUBLE PRECISION array, dimension
|
|
||||||
//> (1+(N-2)*abs(INCX))
|
|
||||||
//> On entry, the vector x.
|
|
||||||
//> On exit, it is overwritten with the vector v.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] INCX
|
|
||||||
//> \verbatim
|
|
||||||
//> INCX is INTEGER
|
|
||||||
//> The increment between elements of X. INCX > 0.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[out] TAU
|
|
||||||
//> \verbatim
|
|
||||||
//> TAU is DOUBLE PRECISION
|
|
||||||
//> The value tau.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date November 2017
|
|
||||||
//
|
|
||||||
//> \ingroup doubleOTHERauxiliary
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
/* Subroutine */ int dlarfg_(int *n, double *alpha, double *x, int *incx,
|
|
||||||
double *tau)
|
|
||||||
{
|
|
||||||
// System generated locals
|
|
||||||
int i__1;
|
|
||||||
double d__1;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int j, knt;
|
|
||||||
double beta;
|
|
||||||
extern double dnrm2_(int *, double *, int *);
|
|
||||||
extern /* Subroutine */ int dscal_(int *, double *, double *, int *);
|
|
||||||
double xnorm;
|
|
||||||
extern double dlapy2_(double *, double *), dlamch_(char *);
|
|
||||||
double safmin, rsafmn;
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- LAPACK auxiliary routine (version 3.8.0) --
|
|
||||||
// -- LAPACK is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// November 2017
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. Parameters ..
|
|
||||||
// ..
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// .. External Functions ..
|
|
||||||
// ..
|
|
||||||
// .. Intrinsic Functions ..
|
|
||||||
// ..
|
|
||||||
// .. External Subroutines ..
|
|
||||||
// ..
|
|
||||||
// .. Executable Statements ..
|
|
||||||
//
|
|
||||||
// Parameter adjustments
|
|
||||||
--x;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
if (*n <= 1) {
|
|
||||||
*tau = 0.;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
i__1 = *n - 1;
|
|
||||||
xnorm = dnrm2_(&i__1, &x[1], incx);
|
|
||||||
if (xnorm == 0.) {
|
|
||||||
//
|
|
||||||
// H = I
|
|
||||||
//
|
|
||||||
*tau = 0.;
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// general case
|
|
||||||
//
|
|
||||||
d__1 = dlapy2_(alpha, &xnorm);
|
|
||||||
beta = -d_sign(&d__1, alpha);
|
|
||||||
safmin = dlamch_("S") / dlamch_("E");
|
|
||||||
knt = 0;
|
|
||||||
if (abs(beta) < safmin) {
|
|
||||||
//
|
|
||||||
// XNORM, BETA may be inaccurate; scale X and recompute them
|
|
||||||
//
|
|
||||||
rsafmn = 1. / safmin;
|
|
||||||
L10:
|
|
||||||
++knt;
|
|
||||||
i__1 = *n - 1;
|
|
||||||
dscal_(&i__1, &rsafmn, &x[1], incx);
|
|
||||||
beta *= rsafmn;
|
|
||||||
*alpha *= rsafmn;
|
|
||||||
if (abs(beta) < safmin && knt < 20) {
|
|
||||||
goto L10;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// New BETA is at most 1, at least SAFMIN
|
|
||||||
//
|
|
||||||
i__1 = *n - 1;
|
|
||||||
xnorm = dnrm2_(&i__1, &x[1], incx);
|
|
||||||
d__1 = dlapy2_(alpha, &xnorm);
|
|
||||||
beta = -d_sign(&d__1, alpha);
|
|
||||||
}
|
|
||||||
*tau = (beta - *alpha) / beta;
|
|
||||||
i__1 = *n - 1;
|
|
||||||
d__1 = 1. / (*alpha - beta);
|
|
||||||
dscal_(&i__1, &d__1, &x[1], incx);
|
|
||||||
//
|
|
||||||
// If ALPHA is subnormal, it may lose relative accuracy
|
|
||||||
//
|
|
||||||
i__1 = knt;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
beta *= safmin;
|
|
||||||
// L20:
|
|
||||||
}
|
|
||||||
*alpha = beta;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
//
|
|
||||||
// End of DLARFG
|
|
||||||
//
|
|
||||||
} // dlarfg_
|
|
||||||
|
|
||||||
Vendored
-389
@@ -1,389 +0,0 @@
|
|||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
//> \brief \b DLARFT forms the triangular factor T of a block reflector H = I - vtvH
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
//> \htmlonly
|
|
||||||
//> Download DLARFT + dependencies
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlarft.f">
|
|
||||||
//> [TGZ]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlarft.f">
|
|
||||||
//> [ZIP]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlarft.f">
|
|
||||||
//> [TXT]</a>
|
|
||||||
//> \endhtmlonly
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// SUBROUTINE DLARFT( DIRECT, STOREV, N, K, V, LDV, TAU, T, LDT )
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// CHARACTER DIRECT, STOREV
|
|
||||||
// INTEGER K, LDT, LDV, N
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// DOUBLE PRECISION T( LDT, * ), TAU( * ), V( LDV, * )
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> DLARFT forms the triangular factor T of a real block reflector H
|
|
||||||
//> of order n, which is defined as a product of k elementary reflectors.
|
|
||||||
//>
|
|
||||||
//> If DIRECT = 'F', H = H(1) H(2) . . . H(k) and T is upper triangular;
|
|
||||||
//>
|
|
||||||
//> If DIRECT = 'B', H = H(k) . . . H(2) H(1) and T is lower triangular.
|
|
||||||
//>
|
|
||||||
//> If STOREV = 'C', the vector which defines the elementary reflector
|
|
||||||
//> H(i) is stored in the i-th column of the array V, and
|
|
||||||
//>
|
|
||||||
//> H = I - V * T * V**T
|
|
||||||
//>
|
|
||||||
//> If STOREV = 'R', the vector which defines the elementary reflector
|
|
||||||
//> H(i) is stored in the i-th row of the array V, and
|
|
||||||
//>
|
|
||||||
//> H = I - V**T * T * V
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] DIRECT
|
|
||||||
//> \verbatim
|
|
||||||
//> DIRECT is CHARACTER*1
|
|
||||||
//> Specifies the order in which the elementary reflectors are
|
|
||||||
//> multiplied to form the block reflector:
|
|
||||||
//> = 'F': H = H(1) H(2) . . . H(k) (Forward)
|
|
||||||
//> = 'B': H = H(k) . . . H(2) H(1) (Backward)
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] STOREV
|
|
||||||
//> \verbatim
|
|
||||||
//> STOREV is CHARACTER*1
|
|
||||||
//> Specifies how the vectors which define the elementary
|
|
||||||
//> reflectors are stored (see also Further Details):
|
|
||||||
//> = 'C': columnwise
|
|
||||||
//> = 'R': rowwise
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] N
|
|
||||||
//> \verbatim
|
|
||||||
//> N is INTEGER
|
|
||||||
//> The order of the block reflector H. N >= 0.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] K
|
|
||||||
//> \verbatim
|
|
||||||
//> K is INTEGER
|
|
||||||
//> The order of the triangular factor T (= the number of
|
|
||||||
//> elementary reflectors). K >= 1.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] V
|
|
||||||
//> \verbatim
|
|
||||||
//> V is DOUBLE PRECISION array, dimension
|
|
||||||
//> (LDV,K) if STOREV = 'C'
|
|
||||||
//> (LDV,N) if STOREV = 'R'
|
|
||||||
//> The matrix V. See further details.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDV
|
|
||||||
//> \verbatim
|
|
||||||
//> LDV is INTEGER
|
|
||||||
//> The leading dimension of the array V.
|
|
||||||
//> If STOREV = 'C', LDV >= max(1,N); if STOREV = 'R', LDV >= K.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] TAU
|
|
||||||
//> \verbatim
|
|
||||||
//> TAU is DOUBLE PRECISION array, dimension (K)
|
|
||||||
//> TAU(i) must contain the scalar factor of the elementary
|
|
||||||
//> reflector H(i).
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[out] T
|
|
||||||
//> \verbatim
|
|
||||||
//> T is DOUBLE PRECISION array, dimension (LDT,K)
|
|
||||||
//> The k by k triangular factor T of the block reflector.
|
|
||||||
//> If DIRECT = 'F', T is upper triangular; if DIRECT = 'B', T is
|
|
||||||
//> lower triangular. The rest of the array is not used.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDT
|
|
||||||
//> \verbatim
|
|
||||||
//> LDT is INTEGER
|
|
||||||
//> The leading dimension of the array T. LDT >= K.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date December 2016
|
|
||||||
//
|
|
||||||
//> \ingroup doubleOTHERauxiliary
|
|
||||||
//
|
|
||||||
//> \par Further Details:
|
|
||||||
// =====================
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> The shape of the matrix V and the storage of the vectors which define
|
|
||||||
//> the H(i) is best illustrated by the following example with n = 5 and
|
|
||||||
//> k = 3. The elements equal to 1 are not stored.
|
|
||||||
//>
|
|
||||||
//> DIRECT = 'F' and STOREV = 'C': DIRECT = 'F' and STOREV = 'R':
|
|
||||||
//>
|
|
||||||
//> V = ( 1 ) V = ( 1 v1 v1 v1 v1 )
|
|
||||||
//> ( v1 1 ) ( 1 v2 v2 v2 )
|
|
||||||
//> ( v1 v2 1 ) ( 1 v3 v3 )
|
|
||||||
//> ( v1 v2 v3 )
|
|
||||||
//> ( v1 v2 v3 )
|
|
||||||
//>
|
|
||||||
//> DIRECT = 'B' and STOREV = 'C': DIRECT = 'B' and STOREV = 'R':
|
|
||||||
//>
|
|
||||||
//> V = ( v1 v2 v3 ) V = ( v1 v1 1 )
|
|
||||||
//> ( v1 v2 v3 ) ( v2 v2 v2 1 )
|
|
||||||
//> ( 1 v2 v3 ) ( v3 v3 v3 v3 1 )
|
|
||||||
//> ( 1 v3 )
|
|
||||||
//> ( 1 )
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
// =====================================================================
|
|
||||||
/* Subroutine */ int dlarft_(char *direct, char *storev, int *n, int *k,
|
|
||||||
double *v, int *ldv, double *tau, double *t, int *ldt)
|
|
||||||
{
|
|
||||||
// Table of constant values
|
|
||||||
int c__1 = 1;
|
|
||||||
double c_b7 = 1.;
|
|
||||||
|
|
||||||
// System generated locals
|
|
||||||
int t_dim1, t_offset, v_dim1, v_offset, i__1, i__2, i__3;
|
|
||||||
double d__1;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int i__, j, prevlastv;
|
|
||||||
extern int lsame_(char *, char *);
|
|
||||||
extern /* Subroutine */ int dgemv_(char *, int *, int *, double *, double
|
|
||||||
*, int *, double *, int *, double *, double *, int *);
|
|
||||||
int lastv;
|
|
||||||
extern /* Subroutine */ int dtrmv_(char *, char *, char *, int *, double *
|
|
||||||
, int *, double *, int *);
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- LAPACK auxiliary routine (version 3.7.0) --
|
|
||||||
// -- LAPACK is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// December 2016
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. Parameters ..
|
|
||||||
// ..
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// .. External Subroutines ..
|
|
||||||
// ..
|
|
||||||
// .. External Functions ..
|
|
||||||
// ..
|
|
||||||
// .. Executable Statements ..
|
|
||||||
//
|
|
||||||
// Quick return if possible
|
|
||||||
//
|
|
||||||
// Parameter adjustments
|
|
||||||
v_dim1 = *ldv;
|
|
||||||
v_offset = 1 + v_dim1;
|
|
||||||
v -= v_offset;
|
|
||||||
--tau;
|
|
||||||
t_dim1 = *ldt;
|
|
||||||
t_offset = 1 + t_dim1;
|
|
||||||
t -= t_offset;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
if (*n == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (lsame_(direct, "F")) {
|
|
||||||
prevlastv = *n;
|
|
||||||
i__1 = *k;
|
|
||||||
for (i__ = 1; i__ <= i__1; ++i__) {
|
|
||||||
prevlastv = max(i__,prevlastv);
|
|
||||||
if (tau[i__] == 0.) {
|
|
||||||
//
|
|
||||||
// H(i) = I
|
|
||||||
//
|
|
||||||
i__2 = i__;
|
|
||||||
for (j = 1; j <= i__2; ++j) {
|
|
||||||
t[j + i__ * t_dim1] = 0.;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// general case
|
|
||||||
//
|
|
||||||
if (lsame_(storev, "C")) {
|
|
||||||
// Skip any trailing zeros.
|
|
||||||
i__2 = i__ + 1;
|
|
||||||
for (lastv = *n; lastv >= i__2; --lastv) {
|
|
||||||
if (v[lastv + i__ * v_dim1] != 0.) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i__2 = i__ - 1;
|
|
||||||
for (j = 1; j <= i__2; ++j) {
|
|
||||||
t[j + i__ * t_dim1] = -tau[i__] * v[i__ + j * v_dim1];
|
|
||||||
}
|
|
||||||
j = min(lastv,prevlastv);
|
|
||||||
//
|
|
||||||
// T(1:i-1,i) := - tau(i) * V(i:j,1:i-1)**T * V(i:j,i)
|
|
||||||
//
|
|
||||||
i__2 = j - i__;
|
|
||||||
i__3 = i__ - 1;
|
|
||||||
d__1 = -tau[i__];
|
|
||||||
dgemv_("Transpose", &i__2, &i__3, &d__1, &v[i__ + 1 +
|
|
||||||
v_dim1], ldv, &v[i__ + 1 + i__ * v_dim1], &c__1, &
|
|
||||||
c_b7, &t[i__ * t_dim1 + 1], &c__1);
|
|
||||||
} else {
|
|
||||||
// Skip any trailing zeros.
|
|
||||||
i__2 = i__ + 1;
|
|
||||||
for (lastv = *n; lastv >= i__2; --lastv) {
|
|
||||||
if (v[i__ + lastv * v_dim1] != 0.) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i__2 = i__ - 1;
|
|
||||||
for (j = 1; j <= i__2; ++j) {
|
|
||||||
t[j + i__ * t_dim1] = -tau[i__] * v[j + i__ * v_dim1];
|
|
||||||
}
|
|
||||||
j = min(lastv,prevlastv);
|
|
||||||
//
|
|
||||||
// T(1:i-1,i) := - tau(i) * V(1:i-1,i:j) * V(i,i:j)**T
|
|
||||||
//
|
|
||||||
i__2 = i__ - 1;
|
|
||||||
i__3 = j - i__;
|
|
||||||
d__1 = -tau[i__];
|
|
||||||
dgemv_("No transpose", &i__2, &i__3, &d__1, &v[(i__ + 1) *
|
|
||||||
v_dim1 + 1], ldv, &v[i__ + (i__ + 1) * v_dim1],
|
|
||||||
ldv, &c_b7, &t[i__ * t_dim1 + 1], &c__1);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// T(1:i-1,i) := T(1:i-1,1:i-1) * T(1:i-1,i)
|
|
||||||
//
|
|
||||||
i__2 = i__ - 1;
|
|
||||||
dtrmv_("Upper", "No transpose", "Non-unit", &i__2, &t[
|
|
||||||
t_offset], ldt, &t[i__ * t_dim1 + 1], &c__1);
|
|
||||||
t[i__ + i__ * t_dim1] = tau[i__];
|
|
||||||
if (i__ > 1) {
|
|
||||||
prevlastv = max(prevlastv,lastv);
|
|
||||||
} else {
|
|
||||||
prevlastv = lastv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
prevlastv = 1;
|
|
||||||
for (i__ = *k; i__ >= 1; --i__) {
|
|
||||||
if (tau[i__] == 0.) {
|
|
||||||
//
|
|
||||||
// H(i) = I
|
|
||||||
//
|
|
||||||
i__1 = *k;
|
|
||||||
for (j = i__; j <= i__1; ++j) {
|
|
||||||
t[j + i__ * t_dim1] = 0.;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// general case
|
|
||||||
//
|
|
||||||
if (i__ < *k) {
|
|
||||||
if (lsame_(storev, "C")) {
|
|
||||||
// Skip any leading zeros.
|
|
||||||
i__1 = i__ - 1;
|
|
||||||
for (lastv = 1; lastv <= i__1; ++lastv) {
|
|
||||||
if (v[lastv + i__ * v_dim1] != 0.) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i__1 = *k;
|
|
||||||
for (j = i__ + 1; j <= i__1; ++j) {
|
|
||||||
t[j + i__ * t_dim1] = -tau[i__] * v[*n - *k + i__
|
|
||||||
+ j * v_dim1];
|
|
||||||
}
|
|
||||||
j = max(lastv,prevlastv);
|
|
||||||
//
|
|
||||||
// T(i+1:k,i) = -tau(i) * V(j:n-k+i,i+1:k)**T * V(j:n-k+i,i)
|
|
||||||
//
|
|
||||||
i__1 = *n - *k + i__ - j;
|
|
||||||
i__2 = *k - i__;
|
|
||||||
d__1 = -tau[i__];
|
|
||||||
dgemv_("Transpose", &i__1, &i__2, &d__1, &v[j + (i__
|
|
||||||
+ 1) * v_dim1], ldv, &v[j + i__ * v_dim1], &
|
|
||||||
c__1, &c_b7, &t[i__ + 1 + i__ * t_dim1], &
|
|
||||||
c__1);
|
|
||||||
} else {
|
|
||||||
// Skip any leading zeros.
|
|
||||||
i__1 = i__ - 1;
|
|
||||||
for (lastv = 1; lastv <= i__1; ++lastv) {
|
|
||||||
if (v[i__ + lastv * v_dim1] != 0.) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i__1 = *k;
|
|
||||||
for (j = i__ + 1; j <= i__1; ++j) {
|
|
||||||
t[j + i__ * t_dim1] = -tau[i__] * v[j + (*n - *k
|
|
||||||
+ i__) * v_dim1];
|
|
||||||
}
|
|
||||||
j = max(lastv,prevlastv);
|
|
||||||
//
|
|
||||||
// T(i+1:k,i) = -tau(i) * V(i+1:k,j:n-k+i) * V(i,j:n-k+i)**T
|
|
||||||
//
|
|
||||||
i__1 = *k - i__;
|
|
||||||
i__2 = *n - *k + i__ - j;
|
|
||||||
d__1 = -tau[i__];
|
|
||||||
dgemv_("No transpose", &i__1, &i__2, &d__1, &v[i__ +
|
|
||||||
1 + j * v_dim1], ldv, &v[i__ + j * v_dim1],
|
|
||||||
ldv, &c_b7, &t[i__ + 1 + i__ * t_dim1], &c__1)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// T(i+1:k,i) := T(i+1:k,i+1:k) * T(i+1:k,i)
|
|
||||||
//
|
|
||||||
i__1 = *k - i__;
|
|
||||||
dtrmv_("Lower", "No transpose", "Non-unit", &i__1, &t[i__
|
|
||||||
+ 1 + (i__ + 1) * t_dim1], ldt, &t[i__ + 1 + i__ *
|
|
||||||
t_dim1], &c__1);
|
|
||||||
if (i__ > 1) {
|
|
||||||
prevlastv = min(prevlastv,lastv);
|
|
||||||
} else {
|
|
||||||
prevlastv = lastv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
t[i__ + i__ * t_dim1] = tau[i__];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
//
|
|
||||||
// End of DLARFT
|
|
||||||
//
|
|
||||||
} // dlarft_
|
|
||||||
|
|
||||||
Vendored
-236
@@ -1,236 +0,0 @@
|
|||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
//> \brief \b DLARTG generates a plane rotation with real cosine and real sine.
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
//> \htmlonly
|
|
||||||
//> Download DLARTG + dependencies
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlartg.f">
|
|
||||||
//> [TGZ]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlartg.f">
|
|
||||||
//> [ZIP]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlartg.f">
|
|
||||||
//> [TXT]</a>
|
|
||||||
//> \endhtmlonly
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// SUBROUTINE DLARTG( F, G, CS, SN, R )
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// DOUBLE PRECISION CS, F, G, R, SN
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> DLARTG generate a plane rotation so that
|
|
||||||
//>
|
|
||||||
//> [ CS SN ] . [ F ] = [ R ] where CS**2 + SN**2 = 1.
|
|
||||||
//> [ -SN CS ] [ G ] [ 0 ]
|
|
||||||
//>
|
|
||||||
//> This is a slower, more accurate version of the BLAS1 routine DROTG,
|
|
||||||
//> with the following other differences:
|
|
||||||
//> F and G are unchanged on return.
|
|
||||||
//> If G=0, then CS=1 and SN=0.
|
|
||||||
//> If F=0 and (G .ne. 0), then CS=0 and SN=1 without doing any
|
|
||||||
//> floating point operations (saves work in DBDSQR when
|
|
||||||
//> there are zeros on the diagonal).
|
|
||||||
//>
|
|
||||||
//> If F exceeds G in magnitude, CS will be positive.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] F
|
|
||||||
//> \verbatim
|
|
||||||
//> F is DOUBLE PRECISION
|
|
||||||
//> The first component of vector to be rotated.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] G
|
|
||||||
//> \verbatim
|
|
||||||
//> G is DOUBLE PRECISION
|
|
||||||
//> The second component of vector to be rotated.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[out] CS
|
|
||||||
//> \verbatim
|
|
||||||
//> CS is DOUBLE PRECISION
|
|
||||||
//> The cosine of the rotation.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[out] SN
|
|
||||||
//> \verbatim
|
|
||||||
//> SN is DOUBLE PRECISION
|
|
||||||
//> The sine of the rotation.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[out] R
|
|
||||||
//> \verbatim
|
|
||||||
//> R is DOUBLE PRECISION
|
|
||||||
//> The nonzero component of the rotated vector.
|
|
||||||
//>
|
|
||||||
//> This version has a few statements commented out for thread safety
|
|
||||||
//> (machine parameters are computed on each entry). 10 feb 03, SJH.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date December 2016
|
|
||||||
//
|
|
||||||
//> \ingroup OTHERauxiliary
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
/* Subroutine */ int dlartg_(double *f, double *g, double *cs, double *sn,
|
|
||||||
double *r__)
|
|
||||||
{
|
|
||||||
// System generated locals
|
|
||||||
int i__1;
|
|
||||||
double d__1, d__2;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int i__;
|
|
||||||
double f1, g1, eps, scale;
|
|
||||||
int count;
|
|
||||||
double safmn2, safmx2;
|
|
||||||
extern double dlamch_(char *);
|
|
||||||
double safmin;
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- LAPACK auxiliary routine (version 3.7.0) --
|
|
||||||
// -- LAPACK is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// December 2016
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. Parameters ..
|
|
||||||
// ..
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// LOGICAL FIRST
|
|
||||||
// ..
|
|
||||||
// .. External Functions ..
|
|
||||||
// ..
|
|
||||||
// .. Intrinsic Functions ..
|
|
||||||
// ..
|
|
||||||
// .. Save statement ..
|
|
||||||
// SAVE FIRST, SAFMX2, SAFMIN, SAFMN2
|
|
||||||
// ..
|
|
||||||
// .. Data statements ..
|
|
||||||
// DATA FIRST / .TRUE. /
|
|
||||||
// ..
|
|
||||||
// .. Executable Statements ..
|
|
||||||
//
|
|
||||||
// IF( FIRST ) THEN
|
|
||||||
safmin = dlamch_("S");
|
|
||||||
eps = dlamch_("E");
|
|
||||||
d__1 = dlamch_("B");
|
|
||||||
i__1 = (int) (log(safmin / eps) / log(dlamch_("B")) / 2.);
|
|
||||||
safmn2 = pow_di(&d__1, &i__1);
|
|
||||||
safmx2 = 1. / safmn2;
|
|
||||||
// FIRST = .FALSE.
|
|
||||||
// END IF
|
|
||||||
if (*g == 0.) {
|
|
||||||
*cs = 1.;
|
|
||||||
*sn = 0.;
|
|
||||||
*r__ = *f;
|
|
||||||
} else if (*f == 0.) {
|
|
||||||
*cs = 0.;
|
|
||||||
*sn = 1.;
|
|
||||||
*r__ = *g;
|
|
||||||
} else {
|
|
||||||
f1 = *f;
|
|
||||||
g1 = *g;
|
|
||||||
// Computing MAX
|
|
||||||
d__1 = abs(f1), d__2 = abs(g1);
|
|
||||||
scale = max(d__1,d__2);
|
|
||||||
if (scale >= safmx2) {
|
|
||||||
count = 0;
|
|
||||||
L10:
|
|
||||||
++count;
|
|
||||||
f1 *= safmn2;
|
|
||||||
g1 *= safmn2;
|
|
||||||
// Computing MAX
|
|
||||||
d__1 = abs(f1), d__2 = abs(g1);
|
|
||||||
scale = max(d__1,d__2);
|
|
||||||
if (scale >= safmx2) {
|
|
||||||
goto L10;
|
|
||||||
}
|
|
||||||
// Computing 2nd power
|
|
||||||
d__1 = f1;
|
|
||||||
// Computing 2nd power
|
|
||||||
d__2 = g1;
|
|
||||||
*r__ = sqrt(d__1 * d__1 + d__2 * d__2);
|
|
||||||
*cs = f1 / *r__;
|
|
||||||
*sn = g1 / *r__;
|
|
||||||
i__1 = count;
|
|
||||||
for (i__ = 1; i__ <= i__1; ++i__) {
|
|
||||||
*r__ *= safmx2;
|
|
||||||
// L20:
|
|
||||||
}
|
|
||||||
} else if (scale <= safmn2) {
|
|
||||||
count = 0;
|
|
||||||
L30:
|
|
||||||
++count;
|
|
||||||
f1 *= safmx2;
|
|
||||||
g1 *= safmx2;
|
|
||||||
// Computing MAX
|
|
||||||
d__1 = abs(f1), d__2 = abs(g1);
|
|
||||||
scale = max(d__1,d__2);
|
|
||||||
if (scale <= safmn2) {
|
|
||||||
goto L30;
|
|
||||||
}
|
|
||||||
// Computing 2nd power
|
|
||||||
d__1 = f1;
|
|
||||||
// Computing 2nd power
|
|
||||||
d__2 = g1;
|
|
||||||
*r__ = sqrt(d__1 * d__1 + d__2 * d__2);
|
|
||||||
*cs = f1 / *r__;
|
|
||||||
*sn = g1 / *r__;
|
|
||||||
i__1 = count;
|
|
||||||
for (i__ = 1; i__ <= i__1; ++i__) {
|
|
||||||
*r__ *= safmn2;
|
|
||||||
// L40:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Computing 2nd power
|
|
||||||
d__1 = f1;
|
|
||||||
// Computing 2nd power
|
|
||||||
d__2 = g1;
|
|
||||||
*r__ = sqrt(d__1 * d__1 + d__2 * d__2);
|
|
||||||
*cs = f1 / *r__;
|
|
||||||
*sn = g1 / *r__;
|
|
||||||
}
|
|
||||||
if (abs(*f) > abs(*g) && *cs < 0.) {
|
|
||||||
*cs = -(*cs);
|
|
||||||
*sn = -(*sn);
|
|
||||||
*r__ = -(*r__);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
//
|
|
||||||
// End of DLARTG
|
|
||||||
//
|
|
||||||
} // dlartg_
|
|
||||||
|
|
||||||
Vendored
-413
@@ -1,413 +0,0 @@
|
|||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
//> \brief \b DLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
//> \htmlonly
|
|
||||||
//> Download DLASCL + dependencies
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlascl.f">
|
|
||||||
//> [TGZ]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlascl.f">
|
|
||||||
//> [ZIP]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlascl.f">
|
|
||||||
//> [TXT]</a>
|
|
||||||
//> \endhtmlonly
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// SUBROUTINE DLASCL( TYPE, KL, KU, CFROM, CTO, M, N, A, LDA, INFO )
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// CHARACTER TYPE
|
|
||||||
// INTEGER INFO, KL, KU, LDA, M, N
|
|
||||||
// DOUBLE PRECISION CFROM, CTO
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// DOUBLE PRECISION A( LDA, * )
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> DLASCL multiplies the M by N real matrix A by the real scalar
|
|
||||||
//> CTO/CFROM. This is done without over/underflow as long as the final
|
|
||||||
//> result CTO*A(I,J)/CFROM does not over/underflow. TYPE specifies that
|
|
||||||
//> A may be full, upper triangular, lower triangular, upper Hessenberg,
|
|
||||||
//> or banded.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] TYPE
|
|
||||||
//> \verbatim
|
|
||||||
//> TYPE is CHARACTER*1
|
|
||||||
//> TYPE indices the storage type of the input matrix.
|
|
||||||
//> = 'G': A is a full matrix.
|
|
||||||
//> = 'L': A is a lower triangular matrix.
|
|
||||||
//> = 'U': A is an upper triangular matrix.
|
|
||||||
//> = 'H': A is an upper Hessenberg matrix.
|
|
||||||
//> = 'B': A is a symmetric band matrix with lower bandwidth KL
|
|
||||||
//> and upper bandwidth KU and with the only the lower
|
|
||||||
//> half stored.
|
|
||||||
//> = 'Q': A is a symmetric band matrix with lower bandwidth KL
|
|
||||||
//> and upper bandwidth KU and with the only the upper
|
|
||||||
//> half stored.
|
|
||||||
//> = 'Z': A is a band matrix with lower bandwidth KL and upper
|
|
||||||
//> bandwidth KU. See DGBTRF for storage details.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] KL
|
|
||||||
//> \verbatim
|
|
||||||
//> KL is INTEGER
|
|
||||||
//> The lower bandwidth of A. Referenced only if TYPE = 'B',
|
|
||||||
//> 'Q' or 'Z'.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] KU
|
|
||||||
//> \verbatim
|
|
||||||
//> KU is INTEGER
|
|
||||||
//> The upper bandwidth of A. Referenced only if TYPE = 'B',
|
|
||||||
//> 'Q' or 'Z'.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] CFROM
|
|
||||||
//> \verbatim
|
|
||||||
//> CFROM is DOUBLE PRECISION
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] CTO
|
|
||||||
//> \verbatim
|
|
||||||
//> CTO is DOUBLE PRECISION
|
|
||||||
//>
|
|
||||||
//> The matrix A is multiplied by CTO/CFROM. A(I,J) is computed
|
|
||||||
//> without over/underflow if the final result CTO*A(I,J)/CFROM
|
|
||||||
//> can be represented without over/underflow. CFROM must be
|
|
||||||
//> nonzero.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] M
|
|
||||||
//> \verbatim
|
|
||||||
//> M is INTEGER
|
|
||||||
//> The number of rows of the matrix A. M >= 0.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] N
|
|
||||||
//> \verbatim
|
|
||||||
//> N is INTEGER
|
|
||||||
//> The number of columns of the matrix A. N >= 0.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in,out] A
|
|
||||||
//> \verbatim
|
|
||||||
//> A is DOUBLE PRECISION array, dimension (LDA,N)
|
|
||||||
//> The matrix to be multiplied by CTO/CFROM. See TYPE for the
|
|
||||||
//> storage type.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDA
|
|
||||||
//> \verbatim
|
|
||||||
//> LDA is INTEGER
|
|
||||||
//> The leading dimension of the array A.
|
|
||||||
//> If TYPE = 'G', 'L', 'U', 'H', LDA >= max(1,M);
|
|
||||||
//> TYPE = 'B', LDA >= KL+1;
|
|
||||||
//> TYPE = 'Q', LDA >= KU+1;
|
|
||||||
//> TYPE = 'Z', LDA >= 2*KL+KU+1.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[out] INFO
|
|
||||||
//> \verbatim
|
|
||||||
//> INFO is INTEGER
|
|
||||||
//> 0 - successful exit
|
|
||||||
//> <0 - if INFO = -i, the i-th argument had an illegal value.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date June 2016
|
|
||||||
//
|
|
||||||
//> \ingroup OTHERauxiliary
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
/* Subroutine */ int dlascl_(char *type__, int *kl, int *ku, double *cfrom,
|
|
||||||
double *cto, int *m, int *n, double *a, int *lda, int *info)
|
|
||||||
{
|
|
||||||
// System generated locals
|
|
||||||
int a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int i__, j, k1, k2, k3, k4;
|
|
||||||
double mul, cto1;
|
|
||||||
int done;
|
|
||||||
double ctoc;
|
|
||||||
extern int lsame_(char *, char *);
|
|
||||||
int itype;
|
|
||||||
double cfrom1;
|
|
||||||
extern double dlamch_(char *);
|
|
||||||
double cfromc;
|
|
||||||
extern int disnan_(double *);
|
|
||||||
extern /* Subroutine */ int xerbla_(char *, int *);
|
|
||||||
double bignum, smlnum;
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- LAPACK auxiliary routine (version 3.7.0) --
|
|
||||||
// -- LAPACK is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// June 2016
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. Parameters ..
|
|
||||||
// ..
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// .. External Functions ..
|
|
||||||
// ..
|
|
||||||
// .. Intrinsic Functions ..
|
|
||||||
// ..
|
|
||||||
// .. External Subroutines ..
|
|
||||||
// ..
|
|
||||||
// .. Executable Statements ..
|
|
||||||
//
|
|
||||||
// Test the input arguments
|
|
||||||
//
|
|
||||||
// Parameter adjustments
|
|
||||||
a_dim1 = *lda;
|
|
||||||
a_offset = 1 + a_dim1;
|
|
||||||
a -= a_offset;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
*info = 0;
|
|
||||||
if (lsame_(type__, "G")) {
|
|
||||||
itype = 0;
|
|
||||||
} else if (lsame_(type__, "L")) {
|
|
||||||
itype = 1;
|
|
||||||
} else if (lsame_(type__, "U")) {
|
|
||||||
itype = 2;
|
|
||||||
} else if (lsame_(type__, "H")) {
|
|
||||||
itype = 3;
|
|
||||||
} else if (lsame_(type__, "B")) {
|
|
||||||
itype = 4;
|
|
||||||
} else if (lsame_(type__, "Q")) {
|
|
||||||
itype = 5;
|
|
||||||
} else if (lsame_(type__, "Z")) {
|
|
||||||
itype = 6;
|
|
||||||
} else {
|
|
||||||
itype = -1;
|
|
||||||
}
|
|
||||||
if (itype == -1) {
|
|
||||||
*info = -1;
|
|
||||||
} else if (*cfrom == 0. || disnan_(cfrom)) {
|
|
||||||
*info = -4;
|
|
||||||
} else if (disnan_(cto)) {
|
|
||||||
*info = -5;
|
|
||||||
} else if (*m < 0) {
|
|
||||||
*info = -6;
|
|
||||||
} else if (*n < 0 || itype == 4 && *n != *m || itype == 5 && *n != *m) {
|
|
||||||
*info = -7;
|
|
||||||
} else if (itype <= 3 && *lda < max(1,*m)) {
|
|
||||||
*info = -9;
|
|
||||||
} else if (itype >= 4) {
|
|
||||||
// Computing MAX
|
|
||||||
i__1 = *m - 1;
|
|
||||||
if (*kl < 0 || *kl > max(i__1,0)) {
|
|
||||||
*info = -2;
|
|
||||||
} else /* if(complicated condition) */ {
|
|
||||||
// Computing MAX
|
|
||||||
i__1 = *n - 1;
|
|
||||||
if (*ku < 0 || *ku > max(i__1,0) || (itype == 4 || itype == 5) &&
|
|
||||||
*kl != *ku) {
|
|
||||||
*info = -3;
|
|
||||||
} else if (itype == 4 && *lda < *kl + 1 || itype == 5 && *lda < *
|
|
||||||
ku + 1 || itype == 6 && *lda < (*kl << 1) + *ku + 1) {
|
|
||||||
*info = -9;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (*info != 0) {
|
|
||||||
i__1 = -(*info);
|
|
||||||
xerbla_("DLASCL", &i__1);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Quick return if possible
|
|
||||||
//
|
|
||||||
if (*n == 0 || *m == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Get machine parameters
|
|
||||||
//
|
|
||||||
smlnum = dlamch_("S");
|
|
||||||
bignum = 1. / smlnum;
|
|
||||||
cfromc = *cfrom;
|
|
||||||
ctoc = *cto;
|
|
||||||
L10:
|
|
||||||
cfrom1 = cfromc * smlnum;
|
|
||||||
if (cfrom1 == cfromc) {
|
|
||||||
// CFROMC is an inf. Multiply by a correctly signed zero for
|
|
||||||
// finite CTOC, or a NaN if CTOC is infinite.
|
|
||||||
mul = ctoc / cfromc;
|
|
||||||
done = TRUE_;
|
|
||||||
cto1 = ctoc;
|
|
||||||
} else {
|
|
||||||
cto1 = ctoc / bignum;
|
|
||||||
if (cto1 == ctoc) {
|
|
||||||
// CTOC is either 0 or an inf. In both cases, CTOC itself
|
|
||||||
// serves as the correct multiplication factor.
|
|
||||||
mul = ctoc;
|
|
||||||
done = TRUE_;
|
|
||||||
cfromc = 1.;
|
|
||||||
} else if (abs(cfrom1) > abs(ctoc) && ctoc != 0.) {
|
|
||||||
mul = smlnum;
|
|
||||||
done = FALSE_;
|
|
||||||
cfromc = cfrom1;
|
|
||||||
} else if (abs(cto1) > abs(cfromc)) {
|
|
||||||
mul = bignum;
|
|
||||||
done = FALSE_;
|
|
||||||
ctoc = cto1;
|
|
||||||
} else {
|
|
||||||
mul = ctoc / cfromc;
|
|
||||||
done = TRUE_;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (itype == 0) {
|
|
||||||
//
|
|
||||||
// Full matrix
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
a[i__ + j * a_dim1] *= mul;
|
|
||||||
// L20:
|
|
||||||
}
|
|
||||||
// L30:
|
|
||||||
}
|
|
||||||
} else if (itype == 1) {
|
|
||||||
//
|
|
||||||
// Lower triangular matrix
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = j; i__ <= i__2; ++i__) {
|
|
||||||
a[i__ + j * a_dim1] *= mul;
|
|
||||||
// L40:
|
|
||||||
}
|
|
||||||
// L50:
|
|
||||||
}
|
|
||||||
} else if (itype == 2) {
|
|
||||||
//
|
|
||||||
// Upper triangular matrix
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = min(j,*m);
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
a[i__ + j * a_dim1] *= mul;
|
|
||||||
// L60:
|
|
||||||
}
|
|
||||||
// L70:
|
|
||||||
}
|
|
||||||
} else if (itype == 3) {
|
|
||||||
//
|
|
||||||
// Upper Hessenberg matrix
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
// Computing MIN
|
|
||||||
i__3 = j + 1;
|
|
||||||
i__2 = min(i__3,*m);
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
a[i__ + j * a_dim1] *= mul;
|
|
||||||
// L80:
|
|
||||||
}
|
|
||||||
// L90:
|
|
||||||
}
|
|
||||||
} else if (itype == 4) {
|
|
||||||
//
|
|
||||||
// Lower half of a symmetric band matrix
|
|
||||||
//
|
|
||||||
k3 = *kl + 1;
|
|
||||||
k4 = *n + 1;
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
// Computing MIN
|
|
||||||
i__3 = k3, i__4 = k4 - j;
|
|
||||||
i__2 = min(i__3,i__4);
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
a[i__ + j * a_dim1] *= mul;
|
|
||||||
// L100:
|
|
||||||
}
|
|
||||||
// L110:
|
|
||||||
}
|
|
||||||
} else if (itype == 5) {
|
|
||||||
//
|
|
||||||
// Upper half of a symmetric band matrix
|
|
||||||
//
|
|
||||||
k1 = *ku + 2;
|
|
||||||
k3 = *ku + 1;
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
// Computing MAX
|
|
||||||
i__2 = k1 - j;
|
|
||||||
i__3 = k3;
|
|
||||||
for (i__ = max(i__2,1); i__ <= i__3; ++i__) {
|
|
||||||
a[i__ + j * a_dim1] *= mul;
|
|
||||||
// L120:
|
|
||||||
}
|
|
||||||
// L130:
|
|
||||||
}
|
|
||||||
} else if (itype == 6) {
|
|
||||||
//
|
|
||||||
// Band matrix
|
|
||||||
//
|
|
||||||
k1 = *kl + *ku + 2;
|
|
||||||
k2 = *kl + 1;
|
|
||||||
k3 = (*kl << 1) + *ku + 1;
|
|
||||||
k4 = *kl + *ku + 1 + *m;
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
// Computing MAX
|
|
||||||
i__3 = k1 - j;
|
|
||||||
// Computing MIN
|
|
||||||
i__4 = k3, i__5 = k4 - j;
|
|
||||||
i__2 = min(i__4,i__5);
|
|
||||||
for (i__ = max(i__3,k2); i__ <= i__2; ++i__) {
|
|
||||||
a[i__ + j * a_dim1] *= mul;
|
|
||||||
// L140:
|
|
||||||
}
|
|
||||||
// L150:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (! done) {
|
|
||||||
goto L10;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
//
|
|
||||||
// End of DLASCL
|
|
||||||
//
|
|
||||||
} // dlascl_
|
|
||||||
|
|
||||||
Vendored
-209
@@ -1,209 +0,0 @@
|
|||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
//> \brief \b DLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
//> \htmlonly
|
|
||||||
//> Download DLASET + dependencies
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlaset.f">
|
|
||||||
//> [TGZ]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlaset.f">
|
|
||||||
//> [ZIP]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlaset.f">
|
|
||||||
//> [TXT]</a>
|
|
||||||
//> \endhtmlonly
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// SUBROUTINE DLASET( UPLO, M, N, ALPHA, BETA, A, LDA )
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// CHARACTER UPLO
|
|
||||||
// INTEGER LDA, M, N
|
|
||||||
// DOUBLE PRECISION ALPHA, BETA
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// DOUBLE PRECISION A( LDA, * )
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> DLASET initializes an m-by-n matrix A to BETA on the diagonal and
|
|
||||||
//> ALPHA on the offdiagonals.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] UPLO
|
|
||||||
//> \verbatim
|
|
||||||
//> UPLO is CHARACTER*1
|
|
||||||
//> Specifies the part of the matrix A to be set.
|
|
||||||
//> = 'U': Upper triangular part is set; the strictly lower
|
|
||||||
//> triangular part of A is not changed.
|
|
||||||
//> = 'L': Lower triangular part is set; the strictly upper
|
|
||||||
//> triangular part of A is not changed.
|
|
||||||
//> Otherwise: All of the matrix A is set.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] M
|
|
||||||
//> \verbatim
|
|
||||||
//> M is INTEGER
|
|
||||||
//> The number of rows of the matrix A. M >= 0.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] N
|
|
||||||
//> \verbatim
|
|
||||||
//> N is INTEGER
|
|
||||||
//> The number of columns of the matrix A. N >= 0.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] ALPHA
|
|
||||||
//> \verbatim
|
|
||||||
//> ALPHA is DOUBLE PRECISION
|
|
||||||
//> The constant to which the offdiagonal elements are to be set.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] BETA
|
|
||||||
//> \verbatim
|
|
||||||
//> BETA is DOUBLE PRECISION
|
|
||||||
//> The constant to which the diagonal elements are to be set.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[out] A
|
|
||||||
//> \verbatim
|
|
||||||
//> A is DOUBLE PRECISION array, dimension (LDA,N)
|
|
||||||
//> On exit, the leading m-by-n submatrix of A is set as follows:
|
|
||||||
//>
|
|
||||||
//> if UPLO = 'U', A(i,j) = ALPHA, 1<=i<=j-1, 1<=j<=n,
|
|
||||||
//> if UPLO = 'L', A(i,j) = ALPHA, j+1<=i<=m, 1<=j<=n,
|
|
||||||
//> otherwise, A(i,j) = ALPHA, 1<=i<=m, 1<=j<=n, i.ne.j,
|
|
||||||
//>
|
|
||||||
//> and, for all UPLO, A(i,i) = BETA, 1<=i<=min(m,n).
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDA
|
|
||||||
//> \verbatim
|
|
||||||
//> LDA is INTEGER
|
|
||||||
//> The leading dimension of the array A. LDA >= max(1,M).
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date December 2016
|
|
||||||
//
|
|
||||||
//> \ingroup OTHERauxiliary
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
/* Subroutine */ int dlaset_(char *uplo, int *m, int *n, double *alpha,
|
|
||||||
double *beta, double *a, int *lda)
|
|
||||||
{
|
|
||||||
// System generated locals
|
|
||||||
int a_dim1, a_offset, i__1, i__2, i__3;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int i__, j;
|
|
||||||
extern int lsame_(char *, char *);
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- LAPACK auxiliary routine (version 3.7.0) --
|
|
||||||
// -- LAPACK is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// December 2016
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//=====================================================================
|
|
||||||
//
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// .. External Functions ..
|
|
||||||
// ..
|
|
||||||
// .. Intrinsic Functions ..
|
|
||||||
// ..
|
|
||||||
// .. Executable Statements ..
|
|
||||||
//
|
|
||||||
// Parameter adjustments
|
|
||||||
a_dim1 = *lda;
|
|
||||||
a_offset = 1 + a_dim1;
|
|
||||||
a -= a_offset;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
if (lsame_(uplo, "U")) {
|
|
||||||
//
|
|
||||||
// Set the strictly upper triangular or trapezoidal part of the
|
|
||||||
// array to ALPHA.
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 2; j <= i__1; ++j) {
|
|
||||||
// Computing MIN
|
|
||||||
i__3 = j - 1;
|
|
||||||
i__2 = min(i__3,*m);
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
a[i__ + j * a_dim1] = *alpha;
|
|
||||||
// L10:
|
|
||||||
}
|
|
||||||
// L20:
|
|
||||||
}
|
|
||||||
} else if (lsame_(uplo, "L")) {
|
|
||||||
//
|
|
||||||
// Set the strictly lower triangular or trapezoidal part of the
|
|
||||||
// array to ALPHA.
|
|
||||||
//
|
|
||||||
i__1 = min(*m,*n);
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = j + 1; i__ <= i__2; ++i__) {
|
|
||||||
a[i__ + j * a_dim1] = *alpha;
|
|
||||||
// L30:
|
|
||||||
}
|
|
||||||
// L40:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Set the leading m-by-n submatrix to ALPHA.
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
a[i__ + j * a_dim1] = *alpha;
|
|
||||||
// L50:
|
|
||||||
}
|
|
||||||
// L60:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Set the first min(M,N) diagonal elements to BETA.
|
|
||||||
//
|
|
||||||
i__1 = min(*m,*n);
|
|
||||||
for (i__ = 1; i__ <= i__1; ++i__) {
|
|
||||||
a[i__ + i__ * a_dim1] = *beta;
|
|
||||||
// L70:
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
//
|
|
||||||
// End of DLASET
|
|
||||||
//
|
|
||||||
} // dlaset_
|
|
||||||
|
|
||||||
Vendored
-172
@@ -1,172 +0,0 @@
|
|||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
//> \brief \b DLASSQ updates a sum of squares represented in scaled form.
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
//> \htmlonly
|
|
||||||
//> Download DLASSQ + dependencies
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlassq.f">
|
|
||||||
//> [TGZ]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlassq.f">
|
|
||||||
//> [ZIP]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlassq.f">
|
|
||||||
//> [TXT]</a>
|
|
||||||
//> \endhtmlonly
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// SUBROUTINE DLASSQ( N, X, INCX, SCALE, SUMSQ )
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// INTEGER INCX, N
|
|
||||||
// DOUBLE PRECISION SCALE, SUMSQ
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// DOUBLE PRECISION X( * )
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> DLASSQ returns the values scl and smsq such that
|
|
||||||
//>
|
|
||||||
//> ( scl**2 )*smsq = x( 1 )**2 +...+ x( n )**2 + ( scale**2 )*sumsq,
|
|
||||||
//>
|
|
||||||
//> where x( i ) = X( 1 + ( i - 1 )*INCX ). The value of sumsq is
|
|
||||||
//> assumed to be non-negative and scl returns the value
|
|
||||||
//>
|
|
||||||
//> scl = max( scale, abs( x( i ) ) ).
|
|
||||||
//>
|
|
||||||
//> scale and sumsq must be supplied in SCALE and SUMSQ and
|
|
||||||
//> scl and smsq are overwritten on SCALE and SUMSQ respectively.
|
|
||||||
//>
|
|
||||||
//> The routine makes only one pass through the vector x.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] N
|
|
||||||
//> \verbatim
|
|
||||||
//> N is INTEGER
|
|
||||||
//> The number of elements to be used from the vector X.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] X
|
|
||||||
//> \verbatim
|
|
||||||
//> X is DOUBLE PRECISION array, dimension (1+(N-1)*INCX)
|
|
||||||
//> The vector for which a scaled sum of squares is computed.
|
|
||||||
//> x( i ) = X( 1 + ( i - 1 )*INCX ), 1 <= i <= n.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] INCX
|
|
||||||
//> \verbatim
|
|
||||||
//> INCX is INTEGER
|
|
||||||
//> The increment between successive values of the vector X.
|
|
||||||
//> INCX > 0.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in,out] SCALE
|
|
||||||
//> \verbatim
|
|
||||||
//> SCALE is DOUBLE PRECISION
|
|
||||||
//> On entry, the value scale in the equation above.
|
|
||||||
//> On exit, SCALE is overwritten with scl , the scaling factor
|
|
||||||
//> for the sum of squares.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in,out] SUMSQ
|
|
||||||
//> \verbatim
|
|
||||||
//> SUMSQ is DOUBLE PRECISION
|
|
||||||
//> On entry, the value sumsq in the equation above.
|
|
||||||
//> On exit, SUMSQ is overwritten with smsq , the basic sum of
|
|
||||||
//> squares from which scl has been factored out.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date December 2016
|
|
||||||
//
|
|
||||||
//> \ingroup OTHERauxiliary
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
/* Subroutine */ int dlassq_(int *n, double *x, int *incx, double *scale,
|
|
||||||
double *sumsq)
|
|
||||||
{
|
|
||||||
// System generated locals
|
|
||||||
int i__1, i__2;
|
|
||||||
double d__1;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int ix;
|
|
||||||
double absxi;
|
|
||||||
extern int disnan_(double *);
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- LAPACK auxiliary routine (version 3.7.0) --
|
|
||||||
// -- LAPACK is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// December 2016
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//=====================================================================
|
|
||||||
//
|
|
||||||
// .. Parameters ..
|
|
||||||
// ..
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// .. External Functions ..
|
|
||||||
// ..
|
|
||||||
// .. Intrinsic Functions ..
|
|
||||||
// ..
|
|
||||||
// .. Executable Statements ..
|
|
||||||
//
|
|
||||||
// Parameter adjustments
|
|
||||||
--x;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
if (*n > 0) {
|
|
||||||
i__1 = (*n - 1) * *incx + 1;
|
|
||||||
i__2 = *incx;
|
|
||||||
for (ix = 1; i__2 < 0 ? ix >= i__1 : ix <= i__1; ix += i__2) {
|
|
||||||
absxi = (d__1 = x[ix], abs(d__1));
|
|
||||||
if (absxi > 0. || disnan_(&absxi)) {
|
|
||||||
if (*scale < absxi) {
|
|
||||||
// Computing 2nd power
|
|
||||||
d__1 = *scale / absxi;
|
|
||||||
*sumsq = *sumsq * (d__1 * d__1) + 1;
|
|
||||||
*scale = absxi;
|
|
||||||
} else {
|
|
||||||
// Computing 2nd power
|
|
||||||
d__1 = absxi / *scale;
|
|
||||||
*sumsq += d__1 * d__1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// L10:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
//
|
|
||||||
// End of DLASSQ
|
|
||||||
//
|
|
||||||
} // dlassq_
|
|
||||||
|
|
||||||
Vendored
-149
@@ -1,149 +0,0 @@
|
|||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
//> \brief \b DNRM2
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// DOUBLE PRECISION FUNCTION DNRM2(N,X,INCX)
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// INTEGER INCX,N
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// DOUBLE PRECISION X(*)
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> DNRM2 returns the euclidean norm of a vector via the function
|
|
||||||
//> name, so that
|
|
||||||
//>
|
|
||||||
//> DNRM2 := sqrt( x'*x )
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] N
|
|
||||||
//> \verbatim
|
|
||||||
//> N is INTEGER
|
|
||||||
//> number of elements in input vector(s)
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] X
|
|
||||||
//> \verbatim
|
|
||||||
//> X is DOUBLE PRECISION array, dimension ( 1 + ( N - 1 )*abs( INCX ) )
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] INCX
|
|
||||||
//> \verbatim
|
|
||||||
//> INCX is INTEGER
|
|
||||||
//> storage spacing between elements of DX
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date November 2017
|
|
||||||
//
|
|
||||||
//> \ingroup double_blas_level1
|
|
||||||
//
|
|
||||||
//> \par Further Details:
|
|
||||||
// =====================
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> -- This version written on 25-October-1982.
|
|
||||||
//> Modified on 14-October-1993 to inline the call to DLASSQ.
|
|
||||||
//> Sven Hammarling, Nag Ltd.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
// =====================================================================
|
|
||||||
double dnrm2_(int *n, double *x, int *incx)
|
|
||||||
{
|
|
||||||
// System generated locals
|
|
||||||
int i__1, i__2;
|
|
||||||
double ret_val, d__1;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int ix;
|
|
||||||
double ssq, norm, scale, absxi;
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- Reference BLAS level1 routine (version 3.8.0) --
|
|
||||||
// -- Reference BLAS is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// November 2017
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. Parameters ..
|
|
||||||
// ..
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// .. Intrinsic Functions ..
|
|
||||||
// ..
|
|
||||||
// Parameter adjustments
|
|
||||||
--x;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
if (*n < 1 || *incx < 1) {
|
|
||||||
norm = 0.;
|
|
||||||
} else if (*n == 1) {
|
|
||||||
norm = abs(x[1]);
|
|
||||||
} else {
|
|
||||||
scale = 0.;
|
|
||||||
ssq = 1.;
|
|
||||||
// The following loop is equivalent to this call to the LAPACK
|
|
||||||
// auxiliary routine:
|
|
||||||
// CALL DLASSQ( N, X, INCX, SCALE, SSQ )
|
|
||||||
//
|
|
||||||
i__1 = (*n - 1) * *incx + 1;
|
|
||||||
i__2 = *incx;
|
|
||||||
for (ix = 1; i__2 < 0 ? ix >= i__1 : ix <= i__1; ix += i__2) {
|
|
||||||
if (x[ix] != 0.) {
|
|
||||||
absxi = (d__1 = x[ix], abs(d__1));
|
|
||||||
if (scale < absxi) {
|
|
||||||
// Computing 2nd power
|
|
||||||
d__1 = scale / absxi;
|
|
||||||
ssq = ssq * (d__1 * d__1) + 1.;
|
|
||||||
scale = absxi;
|
|
||||||
} else {
|
|
||||||
// Computing 2nd power
|
|
||||||
d__1 = absxi / scale;
|
|
||||||
ssq += d__1 * d__1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// L10:
|
|
||||||
}
|
|
||||||
norm = scale * sqrt(ssq);
|
|
||||||
}
|
|
||||||
ret_val = norm;
|
|
||||||
return ret_val;
|
|
||||||
//
|
|
||||||
// End of DNRM2.
|
|
||||||
//
|
|
||||||
} // dnrm2_
|
|
||||||
|
|
||||||
Vendored
-571
@@ -1,571 +0,0 @@
|
|||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
//> \brief \b DORG2R generates all or part of the orthogonal matrix Q from a QR factorization determined by sgeqrf (unblocked algorithm).
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
//> \htmlonly
|
|
||||||
//> Download DORG2R + dependencies
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dorg2r.f">
|
|
||||||
//> [TGZ]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dorg2r.f">
|
|
||||||
//> [ZIP]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dorg2r.f">
|
|
||||||
//> [TXT]</a>
|
|
||||||
//> \endhtmlonly
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// SUBROUTINE DORG2R( M, N, K, A, LDA, TAU, WORK, INFO )
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// INTEGER INFO, K, LDA, M, N
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// DOUBLE PRECISION A( LDA, * ), TAU( * ), WORK( * )
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> DORG2R generates an m by n real matrix Q with orthonormal columns,
|
|
||||||
//> which is defined as the first n columns of a product of k elementary
|
|
||||||
//> reflectors of order m
|
|
||||||
//>
|
|
||||||
//> Q = H(1) H(2) . . . H(k)
|
|
||||||
//>
|
|
||||||
//> as returned by DGEQRF.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] M
|
|
||||||
//> \verbatim
|
|
||||||
//> M is INTEGER
|
|
||||||
//> The number of rows of the matrix Q. M >= 0.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] N
|
|
||||||
//> \verbatim
|
|
||||||
//> N is INTEGER
|
|
||||||
//> The number of columns of the matrix Q. M >= N >= 0.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] K
|
|
||||||
//> \verbatim
|
|
||||||
//> K is INTEGER
|
|
||||||
//> The number of elementary reflectors whose product defines the
|
|
||||||
//> matrix Q. N >= K >= 0.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in,out] A
|
|
||||||
//> \verbatim
|
|
||||||
//> A is DOUBLE PRECISION array, dimension (LDA,N)
|
|
||||||
//> On entry, the i-th column must contain the vector which
|
|
||||||
//> defines the elementary reflector H(i), for i = 1,2,...,k, as
|
|
||||||
//> returned by DGEQRF in the first k columns of its array
|
|
||||||
//> argument A.
|
|
||||||
//> On exit, the m-by-n matrix Q.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDA
|
|
||||||
//> \verbatim
|
|
||||||
//> LDA is INTEGER
|
|
||||||
//> The first dimension of the array A. LDA >= max(1,M).
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] TAU
|
|
||||||
//> \verbatim
|
|
||||||
//> TAU is DOUBLE PRECISION array, dimension (K)
|
|
||||||
//> TAU(i) must contain the scalar factor of the elementary
|
|
||||||
//> reflector H(i), as returned by DGEQRF.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[out] WORK
|
|
||||||
//> \verbatim
|
|
||||||
//> WORK is DOUBLE PRECISION array, dimension (N)
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[out] INFO
|
|
||||||
//> \verbatim
|
|
||||||
//> INFO is INTEGER
|
|
||||||
//> = 0: successful exit
|
|
||||||
//> < 0: if INFO = -i, the i-th argument has an illegal value
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date December 2016
|
|
||||||
//
|
|
||||||
//> \ingroup doubleOTHERcomputational
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
/* Subroutine */ int dorg2r_(int *m, int *n, int *k, double *a, int *lda,
|
|
||||||
double *tau, double *work, int *info)
|
|
||||||
{
|
|
||||||
// Table of constant values
|
|
||||||
int c__1 = 1;
|
|
||||||
|
|
||||||
// System generated locals
|
|
||||||
int a_dim1, a_offset, i__1, i__2;
|
|
||||||
double d__1;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int i__, j, l;
|
|
||||||
extern /* Subroutine */ int dscal_(int *, double *, double *, int *),
|
|
||||||
dlarf_(char *, int *, int *, double *, int *, double *, double *,
|
|
||||||
int *, double *), xerbla_(char *, int *);
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- LAPACK computational routine (version 3.7.0) --
|
|
||||||
// -- LAPACK is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// December 2016
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. Parameters ..
|
|
||||||
// ..
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// .. External Subroutines ..
|
|
||||||
// ..
|
|
||||||
// .. Intrinsic Functions ..
|
|
||||||
// ..
|
|
||||||
// .. Executable Statements ..
|
|
||||||
//
|
|
||||||
// Test the input arguments
|
|
||||||
//
|
|
||||||
// Parameter adjustments
|
|
||||||
a_dim1 = *lda;
|
|
||||||
a_offset = 1 + a_dim1;
|
|
||||||
a -= a_offset;
|
|
||||||
--tau;
|
|
||||||
--work;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
*info = 0;
|
|
||||||
if (*m < 0) {
|
|
||||||
*info = -1;
|
|
||||||
} else if (*n < 0 || *n > *m) {
|
|
||||||
*info = -2;
|
|
||||||
} else if (*k < 0 || *k > *n) {
|
|
||||||
*info = -3;
|
|
||||||
} else if (*lda < max(1,*m)) {
|
|
||||||
*info = -5;
|
|
||||||
}
|
|
||||||
if (*info != 0) {
|
|
||||||
i__1 = -(*info);
|
|
||||||
xerbla_("DORG2R", &i__1);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Quick return if possible
|
|
||||||
//
|
|
||||||
if (*n <= 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Initialise columns k+1:n to columns of the unit matrix
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = *k + 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (l = 1; l <= i__2; ++l) {
|
|
||||||
a[l + j * a_dim1] = 0.;
|
|
||||||
// L10:
|
|
||||||
}
|
|
||||||
a[j + j * a_dim1] = 1.;
|
|
||||||
// L20:
|
|
||||||
}
|
|
||||||
for (i__ = *k; i__ >= 1; --i__) {
|
|
||||||
//
|
|
||||||
// Apply H(i) to A(i:m,i:n) from the left
|
|
||||||
//
|
|
||||||
if (i__ < *n) {
|
|
||||||
a[i__ + i__ * a_dim1] = 1.;
|
|
||||||
i__1 = *m - i__ + 1;
|
|
||||||
i__2 = *n - i__;
|
|
||||||
dlarf_("Left", &i__1, &i__2, &a[i__ + i__ * a_dim1], &c__1, &tau[
|
|
||||||
i__], &a[i__ + (i__ + 1) * a_dim1], lda, &work[1]);
|
|
||||||
}
|
|
||||||
if (i__ < *m) {
|
|
||||||
i__1 = *m - i__;
|
|
||||||
d__1 = -tau[i__];
|
|
||||||
dscal_(&i__1, &d__1, &a[i__ + 1 + i__ * a_dim1], &c__1);
|
|
||||||
}
|
|
||||||
a[i__ + i__ * a_dim1] = 1. - tau[i__];
|
|
||||||
//
|
|
||||||
// Set A(1:i-1,i) to zero
|
|
||||||
//
|
|
||||||
i__1 = i__ - 1;
|
|
||||||
for (l = 1; l <= i__1; ++l) {
|
|
||||||
a[l + i__ * a_dim1] = 0.;
|
|
||||||
// L30:
|
|
||||||
}
|
|
||||||
// L40:
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
//
|
|
||||||
// End of DORG2R
|
|
||||||
//
|
|
||||||
} // dorg2r_
|
|
||||||
|
|
||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
//> \brief \b DORGQR
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
//> \htmlonly
|
|
||||||
//> Download DORGQR + dependencies
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dorgqr.f">
|
|
||||||
//> [TGZ]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dorgqr.f">
|
|
||||||
//> [ZIP]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dorgqr.f">
|
|
||||||
//> [TXT]</a>
|
|
||||||
//> \endhtmlonly
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// SUBROUTINE DORGQR( M, N, K, A, LDA, TAU, WORK, LWORK, INFO )
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// INTEGER INFO, K, LDA, LWORK, M, N
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// DOUBLE PRECISION A( LDA, * ), TAU( * ), WORK( * )
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> DORGQR generates an M-by-N real matrix Q with orthonormal columns,
|
|
||||||
//> which is defined as the first N columns of a product of K elementary
|
|
||||||
//> reflectors of order M
|
|
||||||
//>
|
|
||||||
//> Q = H(1) H(2) . . . H(k)
|
|
||||||
//>
|
|
||||||
//> as returned by DGEQRF.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] M
|
|
||||||
//> \verbatim
|
|
||||||
//> M is INTEGER
|
|
||||||
//> The number of rows of the matrix Q. M >= 0.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] N
|
|
||||||
//> \verbatim
|
|
||||||
//> N is INTEGER
|
|
||||||
//> The number of columns of the matrix Q. M >= N >= 0.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] K
|
|
||||||
//> \verbatim
|
|
||||||
//> K is INTEGER
|
|
||||||
//> The number of elementary reflectors whose product defines the
|
|
||||||
//> matrix Q. N >= K >= 0.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in,out] A
|
|
||||||
//> \verbatim
|
|
||||||
//> A is DOUBLE PRECISION array, dimension (LDA,N)
|
|
||||||
//> On entry, the i-th column must contain the vector which
|
|
||||||
//> defines the elementary reflector H(i), for i = 1,2,...,k, as
|
|
||||||
//> returned by DGEQRF in the first k columns of its array
|
|
||||||
//> argument A.
|
|
||||||
//> On exit, the M-by-N matrix Q.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDA
|
|
||||||
//> \verbatim
|
|
||||||
//> LDA is INTEGER
|
|
||||||
//> The first dimension of the array A. LDA >= max(1,M).
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] TAU
|
|
||||||
//> \verbatim
|
|
||||||
//> TAU is DOUBLE PRECISION array, dimension (K)
|
|
||||||
//> TAU(i) must contain the scalar factor of the elementary
|
|
||||||
//> reflector H(i), as returned by DGEQRF.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[out] WORK
|
|
||||||
//> \verbatim
|
|
||||||
//> WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK))
|
|
||||||
//> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LWORK
|
|
||||||
//> \verbatim
|
|
||||||
//> LWORK is INTEGER
|
|
||||||
//> The dimension of the array WORK. LWORK >= max(1,N).
|
|
||||||
//> For optimum performance LWORK >= N*NB, where NB is the
|
|
||||||
//> optimal blocksize.
|
|
||||||
//>
|
|
||||||
//> If LWORK = -1, then a workspace query is assumed; the routine
|
|
||||||
//> only calculates the optimal size of the WORK array, returns
|
|
||||||
//> this value as the first entry of the WORK array, and no error
|
|
||||||
//> message related to LWORK is issued by XERBLA.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[out] INFO
|
|
||||||
//> \verbatim
|
|
||||||
//> INFO is INTEGER
|
|
||||||
//> = 0: successful exit
|
|
||||||
//> < 0: if INFO = -i, the i-th argument has an illegal value
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date December 2016
|
|
||||||
//
|
|
||||||
//> \ingroup doubleOTHERcomputational
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
/* Subroutine */ int dorgqr_(int *m, int *n, int *k, double *a, int *lda,
|
|
||||||
double *tau, double *work, int *lwork, int *info)
|
|
||||||
{
|
|
||||||
// Table of constant values
|
|
||||||
int c__1 = 1;
|
|
||||||
int c_n1 = -1;
|
|
||||||
int c__3 = 3;
|
|
||||||
int c__2 = 2;
|
|
||||||
|
|
||||||
// System generated locals
|
|
||||||
int a_dim1, a_offset, i__1, i__2, i__3;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int i__, j, l, ib, nb, ki, kk, nx, iws, nbmin, iinfo;
|
|
||||||
extern /* Subroutine */ int dorg2r_(int *, int *, int *, double *, int *,
|
|
||||||
double *, double *, int *), dlarfb_(char *, char *, char *, char *
|
|
||||||
, int *, int *, int *, double *, int *, double *, int *, double *,
|
|
||||||
int *, double *, int *), dlarft_(char *, char *, int *, int *,
|
|
||||||
double *, int *, double *, double *, int *), xerbla_(char *, int *
|
|
||||||
);
|
|
||||||
extern int ilaenv_(int *, char *, char *, int *, int *, int *, int *);
|
|
||||||
int ldwork, lwkopt;
|
|
||||||
int lquery;
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- LAPACK computational routine (version 3.7.0) --
|
|
||||||
// -- LAPACK is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// December 2016
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. Parameters ..
|
|
||||||
// ..
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// .. External Subroutines ..
|
|
||||||
// ..
|
|
||||||
// .. Intrinsic Functions ..
|
|
||||||
// ..
|
|
||||||
// .. External Functions ..
|
|
||||||
// ..
|
|
||||||
// .. Executable Statements ..
|
|
||||||
//
|
|
||||||
// Test the input arguments
|
|
||||||
//
|
|
||||||
// Parameter adjustments
|
|
||||||
a_dim1 = *lda;
|
|
||||||
a_offset = 1 + a_dim1;
|
|
||||||
a -= a_offset;
|
|
||||||
--tau;
|
|
||||||
--work;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
*info = 0;
|
|
||||||
nb = ilaenv_(&c__1, "DORGQR", " ", m, n, k, &c_n1);
|
|
||||||
lwkopt = max(1,*n) * nb;
|
|
||||||
work[1] = (double) lwkopt;
|
|
||||||
lquery = *lwork == -1;
|
|
||||||
if (*m < 0) {
|
|
||||||
*info = -1;
|
|
||||||
} else if (*n < 0 || *n > *m) {
|
|
||||||
*info = -2;
|
|
||||||
} else if (*k < 0 || *k > *n) {
|
|
||||||
*info = -3;
|
|
||||||
} else if (*lda < max(1,*m)) {
|
|
||||||
*info = -5;
|
|
||||||
} else if (*lwork < max(1,*n) && ! lquery) {
|
|
||||||
*info = -8;
|
|
||||||
}
|
|
||||||
if (*info != 0) {
|
|
||||||
i__1 = -(*info);
|
|
||||||
xerbla_("DORGQR", &i__1);
|
|
||||||
return 0;
|
|
||||||
} else if (lquery) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Quick return if possible
|
|
||||||
//
|
|
||||||
if (*n <= 0) {
|
|
||||||
work[1] = 1.;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
nbmin = 2;
|
|
||||||
nx = 0;
|
|
||||||
iws = *n;
|
|
||||||
if (nb > 1 && nb < *k) {
|
|
||||||
//
|
|
||||||
// Determine when to cross over from blocked to unblocked code.
|
|
||||||
//
|
|
||||||
// Computing MAX
|
|
||||||
i__1 = 0, i__2 = ilaenv_(&c__3, "DORGQR", " ", m, n, k, &c_n1);
|
|
||||||
nx = max(i__1,i__2);
|
|
||||||
if (nx < *k) {
|
|
||||||
//
|
|
||||||
// Determine if workspace is large enough for blocked code.
|
|
||||||
//
|
|
||||||
ldwork = *n;
|
|
||||||
iws = ldwork * nb;
|
|
||||||
if (*lwork < iws) {
|
|
||||||
//
|
|
||||||
// Not enough workspace to use optimal NB: reduce NB and
|
|
||||||
// determine the minimum value of NB.
|
|
||||||
//
|
|
||||||
nb = *lwork / ldwork;
|
|
||||||
// Computing MAX
|
|
||||||
i__1 = 2, i__2 = ilaenv_(&c__2, "DORGQR", " ", m, n, k, &c_n1)
|
|
||||||
;
|
|
||||||
nbmin = max(i__1,i__2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (nb >= nbmin && nb < *k && nx < *k) {
|
|
||||||
//
|
|
||||||
// Use blocked code after the last block.
|
|
||||||
// The first kk columns are handled by the block method.
|
|
||||||
//
|
|
||||||
ki = (*k - nx - 1) / nb * nb;
|
|
||||||
// Computing MIN
|
|
||||||
i__1 = *k, i__2 = ki + nb;
|
|
||||||
kk = min(i__1,i__2);
|
|
||||||
//
|
|
||||||
// Set A(1:kk,kk+1:n) to zero.
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = kk + 1; j <= i__1; ++j) {
|
|
||||||
i__2 = kk;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
a[i__ + j * a_dim1] = 0.;
|
|
||||||
// L10:
|
|
||||||
}
|
|
||||||
// L20:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
kk = 0;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Use unblocked code for the last or only block.
|
|
||||||
//
|
|
||||||
if (kk < *n) {
|
|
||||||
i__1 = *m - kk;
|
|
||||||
i__2 = *n - kk;
|
|
||||||
i__3 = *k - kk;
|
|
||||||
dorg2r_(&i__1, &i__2, &i__3, &a[kk + 1 + (kk + 1) * a_dim1], lda, &
|
|
||||||
tau[kk + 1], &work[1], &iinfo);
|
|
||||||
}
|
|
||||||
if (kk > 0) {
|
|
||||||
//
|
|
||||||
// Use blocked code
|
|
||||||
//
|
|
||||||
i__1 = -nb;
|
|
||||||
for (i__ = ki + 1; i__1 < 0 ? i__ >= 1 : i__ <= 1; i__ += i__1) {
|
|
||||||
// Computing MIN
|
|
||||||
i__2 = nb, i__3 = *k - i__ + 1;
|
|
||||||
ib = min(i__2,i__3);
|
|
||||||
if (i__ + ib <= *n) {
|
|
||||||
//
|
|
||||||
// Form the triangular factor of the block reflector
|
|
||||||
// H = H(i) H(i+1) . . . H(i+ib-1)
|
|
||||||
//
|
|
||||||
i__2 = *m - i__ + 1;
|
|
||||||
dlarft_("Forward", "Columnwise", &i__2, &ib, &a[i__ + i__ *
|
|
||||||
a_dim1], lda, &tau[i__], &work[1], &ldwork);
|
|
||||||
//
|
|
||||||
// Apply H to A(i:m,i+ib:n) from the left
|
|
||||||
//
|
|
||||||
i__2 = *m - i__ + 1;
|
|
||||||
i__3 = *n - i__ - ib + 1;
|
|
||||||
dlarfb_("Left", "No transpose", "Forward", "Columnwise", &
|
|
||||||
i__2, &i__3, &ib, &a[i__ + i__ * a_dim1], lda, &work[
|
|
||||||
1], &ldwork, &a[i__ + (i__ + ib) * a_dim1], lda, &
|
|
||||||
work[ib + 1], &ldwork);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Apply H to rows i:m of current block
|
|
||||||
//
|
|
||||||
i__2 = *m - i__ + 1;
|
|
||||||
dorg2r_(&i__2, &ib, &ib, &a[i__ + i__ * a_dim1], lda, &tau[i__], &
|
|
||||||
work[1], &iinfo);
|
|
||||||
//
|
|
||||||
// Set rows 1:i-1 of current block to zero
|
|
||||||
//
|
|
||||||
i__2 = i__ + ib - 1;
|
|
||||||
for (j = i__; j <= i__2; ++j) {
|
|
||||||
i__3 = i__ - 1;
|
|
||||||
for (l = 1; l <= i__3; ++l) {
|
|
||||||
a[l + j * a_dim1] = 0.;
|
|
||||||
// L30:
|
|
||||||
}
|
|
||||||
// L40:
|
|
||||||
}
|
|
||||||
// L50:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
work[1] = (double) iws;
|
|
||||||
return 0;
|
|
||||||
//
|
|
||||||
// End of DORGQR
|
|
||||||
//
|
|
||||||
} // dorgqr_
|
|
||||||
|
|
||||||
Vendored
-684
@@ -1,684 +0,0 @@
|
|||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
//> \brief \b DORM2R multiplies a general matrix by the orthogonal matrix from a QR factorization determined by sgeqrf (unblocked algorithm).
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
//> \htmlonly
|
|
||||||
//> Download DORM2R + dependencies
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dorm2r.f">
|
|
||||||
//> [TGZ]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dorm2r.f">
|
|
||||||
//> [ZIP]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dorm2r.f">
|
|
||||||
//> [TXT]</a>
|
|
||||||
//> \endhtmlonly
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// SUBROUTINE DORM2R( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC,
|
|
||||||
// WORK, INFO )
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// CHARACTER SIDE, TRANS
|
|
||||||
// INTEGER INFO, K, LDA, LDC, M, N
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// DOUBLE PRECISION A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> DORM2R overwrites the general real m by n matrix C with
|
|
||||||
//>
|
|
||||||
//> Q * C if SIDE = 'L' and TRANS = 'N', or
|
|
||||||
//>
|
|
||||||
//> Q**T* C if SIDE = 'L' and TRANS = 'T', or
|
|
||||||
//>
|
|
||||||
//> C * Q if SIDE = 'R' and TRANS = 'N', or
|
|
||||||
//>
|
|
||||||
//> C * Q**T if SIDE = 'R' and TRANS = 'T',
|
|
||||||
//>
|
|
||||||
//> where Q is a real orthogonal matrix defined as the product of k
|
|
||||||
//> elementary reflectors
|
|
||||||
//>
|
|
||||||
//> Q = H(1) H(2) . . . H(k)
|
|
||||||
//>
|
|
||||||
//> as returned by DGEQRF. Q is of order m if SIDE = 'L' and of order n
|
|
||||||
//> if SIDE = 'R'.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] SIDE
|
|
||||||
//> \verbatim
|
|
||||||
//> SIDE is CHARACTER*1
|
|
||||||
//> = 'L': apply Q or Q**T from the Left
|
|
||||||
//> = 'R': apply Q or Q**T from the Right
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] TRANS
|
|
||||||
//> \verbatim
|
|
||||||
//> TRANS is CHARACTER*1
|
|
||||||
//> = 'N': apply Q (No transpose)
|
|
||||||
//> = 'T': apply Q**T (Transpose)
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] M
|
|
||||||
//> \verbatim
|
|
||||||
//> M is INTEGER
|
|
||||||
//> The number of rows of the matrix C. M >= 0.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] N
|
|
||||||
//> \verbatim
|
|
||||||
//> N is INTEGER
|
|
||||||
//> The number of columns of the matrix C. N >= 0.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] K
|
|
||||||
//> \verbatim
|
|
||||||
//> K is INTEGER
|
|
||||||
//> The number of elementary reflectors whose product defines
|
|
||||||
//> the matrix Q.
|
|
||||||
//> If SIDE = 'L', M >= K >= 0;
|
|
||||||
//> if SIDE = 'R', N >= K >= 0.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] A
|
|
||||||
//> \verbatim
|
|
||||||
//> A is DOUBLE PRECISION array, dimension (LDA,K)
|
|
||||||
//> The i-th column must contain the vector which defines the
|
|
||||||
//> elementary reflector H(i), for i = 1,2,...,k, as returned by
|
|
||||||
//> DGEQRF in the first k columns of its array argument A.
|
|
||||||
//> A is modified by the routine but restored on exit.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDA
|
|
||||||
//> \verbatim
|
|
||||||
//> LDA is INTEGER
|
|
||||||
//> The leading dimension of the array A.
|
|
||||||
//> If SIDE = 'L', LDA >= max(1,M);
|
|
||||||
//> if SIDE = 'R', LDA >= max(1,N).
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] TAU
|
|
||||||
//> \verbatim
|
|
||||||
//> TAU is DOUBLE PRECISION array, dimension (K)
|
|
||||||
//> TAU(i) must contain the scalar factor of the elementary
|
|
||||||
//> reflector H(i), as returned by DGEQRF.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in,out] C
|
|
||||||
//> \verbatim
|
|
||||||
//> C is DOUBLE PRECISION array, dimension (LDC,N)
|
|
||||||
//> On entry, the m by n matrix C.
|
|
||||||
//> On exit, C is overwritten by Q*C or Q**T*C or C*Q**T or C*Q.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDC
|
|
||||||
//> \verbatim
|
|
||||||
//> LDC is INTEGER
|
|
||||||
//> The leading dimension of the array C. LDC >= max(1,M).
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[out] WORK
|
|
||||||
//> \verbatim
|
|
||||||
//> WORK is DOUBLE PRECISION array, dimension
|
|
||||||
//> (N) if SIDE = 'L',
|
|
||||||
//> (M) if SIDE = 'R'
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[out] INFO
|
|
||||||
//> \verbatim
|
|
||||||
//> INFO is INTEGER
|
|
||||||
//> = 0: successful exit
|
|
||||||
//> < 0: if INFO = -i, the i-th argument had an illegal value
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date December 2016
|
|
||||||
//
|
|
||||||
//> \ingroup doubleOTHERcomputational
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
/* Subroutine */ int dorm2r_(char *side, char *trans, int *m, int *n, int *k,
|
|
||||||
double *a, int *lda, double *tau, double *c__, int *ldc, double *work,
|
|
||||||
int *info)
|
|
||||||
{
|
|
||||||
// Table of constant values
|
|
||||||
int c__1 = 1;
|
|
||||||
|
|
||||||
// System generated locals
|
|
||||||
int a_dim1, a_offset, c_dim1, c_offset, i__1, i__2;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int i__, i1, i2, i3, ic, jc, mi, ni, nq;
|
|
||||||
double aii;
|
|
||||||
int left;
|
|
||||||
extern /* Subroutine */ int dlarf_(char *, int *, int *, double *, int *,
|
|
||||||
double *, double *, int *, double *);
|
|
||||||
extern int lsame_(char *, char *);
|
|
||||||
extern /* Subroutine */ int xerbla_(char *, int *);
|
|
||||||
int notran;
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- LAPACK computational routine (version 3.7.0) --
|
|
||||||
// -- LAPACK is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// December 2016
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. Parameters ..
|
|
||||||
// ..
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// .. External Functions ..
|
|
||||||
// ..
|
|
||||||
// .. External Subroutines ..
|
|
||||||
// ..
|
|
||||||
// .. Intrinsic Functions ..
|
|
||||||
// ..
|
|
||||||
// .. Executable Statements ..
|
|
||||||
//
|
|
||||||
// Test the input arguments
|
|
||||||
//
|
|
||||||
// Parameter adjustments
|
|
||||||
a_dim1 = *lda;
|
|
||||||
a_offset = 1 + a_dim1;
|
|
||||||
a -= a_offset;
|
|
||||||
--tau;
|
|
||||||
c_dim1 = *ldc;
|
|
||||||
c_offset = 1 + c_dim1;
|
|
||||||
c__ -= c_offset;
|
|
||||||
--work;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
*info = 0;
|
|
||||||
left = lsame_(side, "L");
|
|
||||||
notran = lsame_(trans, "N");
|
|
||||||
//
|
|
||||||
// NQ is the order of Q
|
|
||||||
//
|
|
||||||
if (left) {
|
|
||||||
nq = *m;
|
|
||||||
} else {
|
|
||||||
nq = *n;
|
|
||||||
}
|
|
||||||
if (! left && ! lsame_(side, "R")) {
|
|
||||||
*info = -1;
|
|
||||||
} else if (! notran && ! lsame_(trans, "T")) {
|
|
||||||
*info = -2;
|
|
||||||
} else if (*m < 0) {
|
|
||||||
*info = -3;
|
|
||||||
} else if (*n < 0) {
|
|
||||||
*info = -4;
|
|
||||||
} else if (*k < 0 || *k > nq) {
|
|
||||||
*info = -5;
|
|
||||||
} else if (*lda < max(1,nq)) {
|
|
||||||
*info = -7;
|
|
||||||
} else if (*ldc < max(1,*m)) {
|
|
||||||
*info = -10;
|
|
||||||
}
|
|
||||||
if (*info != 0) {
|
|
||||||
i__1 = -(*info);
|
|
||||||
xerbla_("DORM2R", &i__1);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Quick return if possible
|
|
||||||
//
|
|
||||||
if (*m == 0 || *n == 0 || *k == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (left && ! notran || ! left && notran) {
|
|
||||||
i1 = 1;
|
|
||||||
i2 = *k;
|
|
||||||
i3 = 1;
|
|
||||||
} else {
|
|
||||||
i1 = *k;
|
|
||||||
i2 = 1;
|
|
||||||
i3 = -1;
|
|
||||||
}
|
|
||||||
if (left) {
|
|
||||||
ni = *n;
|
|
||||||
jc = 1;
|
|
||||||
} else {
|
|
||||||
mi = *m;
|
|
||||||
ic = 1;
|
|
||||||
}
|
|
||||||
i__1 = i2;
|
|
||||||
i__2 = i3;
|
|
||||||
for (i__ = i1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
|
|
||||||
if (left) {
|
|
||||||
//
|
|
||||||
// H(i) is applied to C(i:m,1:n)
|
|
||||||
//
|
|
||||||
mi = *m - i__ + 1;
|
|
||||||
ic = i__;
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// H(i) is applied to C(1:m,i:n)
|
|
||||||
//
|
|
||||||
ni = *n - i__ + 1;
|
|
||||||
jc = i__;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Apply H(i)
|
|
||||||
//
|
|
||||||
aii = a[i__ + i__ * a_dim1];
|
|
||||||
a[i__ + i__ * a_dim1] = 1.;
|
|
||||||
dlarf_(side, &mi, &ni, &a[i__ + i__ * a_dim1], &c__1, &tau[i__], &c__[
|
|
||||||
ic + jc * c_dim1], ldc, &work[1]);
|
|
||||||
a[i__ + i__ * a_dim1] = aii;
|
|
||||||
// L10:
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
//
|
|
||||||
// End of DORM2R
|
|
||||||
//
|
|
||||||
} // dorm2r_
|
|
||||||
|
|
||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
//> \brief \b DORMQR
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
//> \htmlonly
|
|
||||||
//> Download DORMQR + dependencies
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dormqr.f">
|
|
||||||
//> [TGZ]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dormqr.f">
|
|
||||||
//> [ZIP]</a>
|
|
||||||
//> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dormqr.f">
|
|
||||||
//> [TXT]</a>
|
|
||||||
//> \endhtmlonly
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// SUBROUTINE DORMQR( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC,
|
|
||||||
// WORK, LWORK, INFO )
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// CHARACTER SIDE, TRANS
|
|
||||||
// INTEGER INFO, K, LDA, LDC, LWORK, M, N
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// DOUBLE PRECISION A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> DORMQR overwrites the general real M-by-N matrix C with
|
|
||||||
//>
|
|
||||||
//> SIDE = 'L' SIDE = 'R'
|
|
||||||
//> TRANS = 'N': Q * C C * Q
|
|
||||||
//> TRANS = 'T': Q**T * C C * Q**T
|
|
||||||
//>
|
|
||||||
//> where Q is a real orthogonal matrix defined as the product of k
|
|
||||||
//> elementary reflectors
|
|
||||||
//>
|
|
||||||
//> Q = H(1) H(2) . . . H(k)
|
|
||||||
//>
|
|
||||||
//> as returned by DGEQRF. Q is of order M if SIDE = 'L' and of order N
|
|
||||||
//> if SIDE = 'R'.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] SIDE
|
|
||||||
//> \verbatim
|
|
||||||
//> SIDE is CHARACTER*1
|
|
||||||
//> = 'L': apply Q or Q**T from the Left;
|
|
||||||
//> = 'R': apply Q or Q**T from the Right.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] TRANS
|
|
||||||
//> \verbatim
|
|
||||||
//> TRANS is CHARACTER*1
|
|
||||||
//> = 'N': No transpose, apply Q;
|
|
||||||
//> = 'T': Transpose, apply Q**T.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] M
|
|
||||||
//> \verbatim
|
|
||||||
//> M is INTEGER
|
|
||||||
//> The number of rows of the matrix C. M >= 0.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] N
|
|
||||||
//> \verbatim
|
|
||||||
//> N is INTEGER
|
|
||||||
//> The number of columns of the matrix C. N >= 0.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] K
|
|
||||||
//> \verbatim
|
|
||||||
//> K is INTEGER
|
|
||||||
//> The number of elementary reflectors whose product defines
|
|
||||||
//> the matrix Q.
|
|
||||||
//> If SIDE = 'L', M >= K >= 0;
|
|
||||||
//> if SIDE = 'R', N >= K >= 0.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] A
|
|
||||||
//> \verbatim
|
|
||||||
//> A is DOUBLE PRECISION array, dimension (LDA,K)
|
|
||||||
//> The i-th column must contain the vector which defines the
|
|
||||||
//> elementary reflector H(i), for i = 1,2,...,k, as returned by
|
|
||||||
//> DGEQRF in the first k columns of its array argument A.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDA
|
|
||||||
//> \verbatim
|
|
||||||
//> LDA is INTEGER
|
|
||||||
//> The leading dimension of the array A.
|
|
||||||
//> If SIDE = 'L', LDA >= max(1,M);
|
|
||||||
//> if SIDE = 'R', LDA >= max(1,N).
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] TAU
|
|
||||||
//> \verbatim
|
|
||||||
//> TAU is DOUBLE PRECISION array, dimension (K)
|
|
||||||
//> TAU(i) must contain the scalar factor of the elementary
|
|
||||||
//> reflector H(i), as returned by DGEQRF.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in,out] C
|
|
||||||
//> \verbatim
|
|
||||||
//> C is DOUBLE PRECISION array, dimension (LDC,N)
|
|
||||||
//> On entry, the M-by-N matrix C.
|
|
||||||
//> On exit, C is overwritten by Q*C or Q**T*C or C*Q**T or C*Q.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDC
|
|
||||||
//> \verbatim
|
|
||||||
//> LDC is INTEGER
|
|
||||||
//> The leading dimension of the array C. LDC >= max(1,M).
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[out] WORK
|
|
||||||
//> \verbatim
|
|
||||||
//> WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK))
|
|
||||||
//> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LWORK
|
|
||||||
//> \verbatim
|
|
||||||
//> LWORK is INTEGER
|
|
||||||
//> The dimension of the array WORK.
|
|
||||||
//> If SIDE = 'L', LWORK >= max(1,N);
|
|
||||||
//> if SIDE = 'R', LWORK >= max(1,M).
|
|
||||||
//> For good performance, LWORK should generally be larger.
|
|
||||||
//>
|
|
||||||
//> If LWORK = -1, then a workspace query is assumed; the routine
|
|
||||||
//> only calculates the optimal size of the WORK array, returns
|
|
||||||
//> this value as the first entry of the WORK array, and no error
|
|
||||||
//> message related to LWORK is issued by XERBLA.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[out] INFO
|
|
||||||
//> \verbatim
|
|
||||||
//> INFO is INTEGER
|
|
||||||
//> = 0: successful exit
|
|
||||||
//> < 0: if INFO = -i, the i-th argument had an illegal value
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date December 2016
|
|
||||||
//
|
|
||||||
//> \ingroup doubleOTHERcomputational
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
/* Subroutine */ int dormqr_(char *side, char *trans, int *m, int *n, int *k,
|
|
||||||
double *a, int *lda, double *tau, double *c__, int *ldc, double *work,
|
|
||||||
int *lwork, int *info)
|
|
||||||
{
|
|
||||||
// Table of constant values
|
|
||||||
int c__1 = 1;
|
|
||||||
int c_n1 = -1;
|
|
||||||
int c__2 = 2;
|
|
||||||
int c__65 = 65;
|
|
||||||
|
|
||||||
// System generated locals
|
|
||||||
address a__1[2];
|
|
||||||
int a_dim1, a_offset, c_dim1, c_offset, i__1, i__2, i__3[2], i__4, i__5;
|
|
||||||
char ch__1[2+1]={'\0'};
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int i__, i1, i2, i3, ib, ic, jc, nb, mi, ni, nq, nw, iwt;
|
|
||||||
int left;
|
|
||||||
extern int lsame_(char *, char *);
|
|
||||||
int nbmin, iinfo;
|
|
||||||
extern /* Subroutine */ int dorm2r_(char *, char *, int *, int *, int *,
|
|
||||||
double *, int *, double *, double *, int *, double *, int *),
|
|
||||||
dlarfb_(char *, char *, char *, char *, int *, int *, int *,
|
|
||||||
double *, int *, double *, int *, double *, int *, double *, int *
|
|
||||||
), dlarft_(char *, char *, int *, int *, double *, int *, double *
|
|
||||||
, double *, int *), xerbla_(char *, int *);
|
|
||||||
extern int ilaenv_(int *, char *, char *, int *, int *, int *, int *);
|
|
||||||
int notran;
|
|
||||||
int ldwork, lwkopt;
|
|
||||||
int lquery;
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- LAPACK computational routine (version 3.7.0) --
|
|
||||||
// -- LAPACK is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// December 2016
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. Parameters ..
|
|
||||||
// ..
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// .. External Functions ..
|
|
||||||
// ..
|
|
||||||
// .. External Subroutines ..
|
|
||||||
// ..
|
|
||||||
// .. Intrinsic Functions ..
|
|
||||||
// ..
|
|
||||||
// .. Executable Statements ..
|
|
||||||
//
|
|
||||||
// Test the input arguments
|
|
||||||
//
|
|
||||||
// Parameter adjustments
|
|
||||||
a_dim1 = *lda;
|
|
||||||
a_offset = 1 + a_dim1;
|
|
||||||
a -= a_offset;
|
|
||||||
--tau;
|
|
||||||
c_dim1 = *ldc;
|
|
||||||
c_offset = 1 + c_dim1;
|
|
||||||
c__ -= c_offset;
|
|
||||||
--work;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
*info = 0;
|
|
||||||
left = lsame_(side, "L");
|
|
||||||
notran = lsame_(trans, "N");
|
|
||||||
lquery = *lwork == -1;
|
|
||||||
//
|
|
||||||
// NQ is the order of Q and NW is the minimum dimension of WORK
|
|
||||||
//
|
|
||||||
if (left) {
|
|
||||||
nq = *m;
|
|
||||||
nw = *n;
|
|
||||||
} else {
|
|
||||||
nq = *n;
|
|
||||||
nw = *m;
|
|
||||||
}
|
|
||||||
if (! left && ! lsame_(side, "R")) {
|
|
||||||
*info = -1;
|
|
||||||
} else if (! notran && ! lsame_(trans, "T")) {
|
|
||||||
*info = -2;
|
|
||||||
} else if (*m < 0) {
|
|
||||||
*info = -3;
|
|
||||||
} else if (*n < 0) {
|
|
||||||
*info = -4;
|
|
||||||
} else if (*k < 0 || *k > nq) {
|
|
||||||
*info = -5;
|
|
||||||
} else if (*lda < max(1,nq)) {
|
|
||||||
*info = -7;
|
|
||||||
} else if (*ldc < max(1,*m)) {
|
|
||||||
*info = -10;
|
|
||||||
} else if (*lwork < max(1,nw) && ! lquery) {
|
|
||||||
*info = -12;
|
|
||||||
}
|
|
||||||
if (*info == 0) {
|
|
||||||
//
|
|
||||||
// Compute the workspace requirements
|
|
||||||
//
|
|
||||||
// Computing MIN
|
|
||||||
// Writing concatenation
|
|
||||||
i__3[0] = 1, a__1[0] = side;
|
|
||||||
i__3[1] = 1, a__1[1] = trans;
|
|
||||||
s_cat(ch__1, a__1, i__3, &c__2);
|
|
||||||
i__1 = 64, i__2 = ilaenv_(&c__1, "DORMQR", ch__1, m, n, k, &c_n1);
|
|
||||||
nb = min(i__1,i__2);
|
|
||||||
lwkopt = max(1,nw) * nb + 4160;
|
|
||||||
work[1] = (double) lwkopt;
|
|
||||||
}
|
|
||||||
if (*info != 0) {
|
|
||||||
i__1 = -(*info);
|
|
||||||
xerbla_("DORMQR", &i__1);
|
|
||||||
return 0;
|
|
||||||
} else if (lquery) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Quick return if possible
|
|
||||||
//
|
|
||||||
if (*m == 0 || *n == 0 || *k == 0) {
|
|
||||||
work[1] = 1.;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
nbmin = 2;
|
|
||||||
ldwork = nw;
|
|
||||||
if (nb > 1 && nb < *k) {
|
|
||||||
if (*lwork < nw * nb + 4160) {
|
|
||||||
nb = (*lwork - 4160) / ldwork;
|
|
||||||
// Computing MAX
|
|
||||||
// Writing concatenation
|
|
||||||
i__3[0] = 1, a__1[0] = side;
|
|
||||||
i__3[1] = 1, a__1[1] = trans;
|
|
||||||
s_cat(ch__1, a__1, i__3, &c__2);
|
|
||||||
i__1 = 2, i__2 = ilaenv_(&c__2, "DORMQR", ch__1, m, n, k, &c_n1);
|
|
||||||
nbmin = max(i__1,i__2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (nb < nbmin || nb >= *k) {
|
|
||||||
//
|
|
||||||
// Use unblocked code
|
|
||||||
//
|
|
||||||
dorm2r_(side, trans, m, n, k, &a[a_offset], lda, &tau[1], &c__[
|
|
||||||
c_offset], ldc, &work[1], &iinfo);
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Use blocked code
|
|
||||||
//
|
|
||||||
iwt = nw * nb + 1;
|
|
||||||
if (left && ! notran || ! left && notran) {
|
|
||||||
i1 = 1;
|
|
||||||
i2 = *k;
|
|
||||||
i3 = nb;
|
|
||||||
} else {
|
|
||||||
i1 = (*k - 1) / nb * nb + 1;
|
|
||||||
i2 = 1;
|
|
||||||
i3 = -nb;
|
|
||||||
}
|
|
||||||
if (left) {
|
|
||||||
ni = *n;
|
|
||||||
jc = 1;
|
|
||||||
} else {
|
|
||||||
mi = *m;
|
|
||||||
ic = 1;
|
|
||||||
}
|
|
||||||
i__1 = i2;
|
|
||||||
i__2 = i3;
|
|
||||||
for (i__ = i1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
|
|
||||||
// Computing MIN
|
|
||||||
i__4 = nb, i__5 = *k - i__ + 1;
|
|
||||||
ib = min(i__4,i__5);
|
|
||||||
//
|
|
||||||
// Form the triangular factor of the block reflector
|
|
||||||
// H = H(i) H(i+1) . . . H(i+ib-1)
|
|
||||||
//
|
|
||||||
i__4 = nq - i__ + 1;
|
|
||||||
dlarft_("Forward", "Columnwise", &i__4, &ib, &a[i__ + i__ *
|
|
||||||
a_dim1], lda, &tau[i__], &work[iwt], &c__65);
|
|
||||||
if (left) {
|
|
||||||
//
|
|
||||||
// H or H**T is applied to C(i:m,1:n)
|
|
||||||
//
|
|
||||||
mi = *m - i__ + 1;
|
|
||||||
ic = i__;
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// H or H**T is applied to C(1:m,i:n)
|
|
||||||
//
|
|
||||||
ni = *n - i__ + 1;
|
|
||||||
jc = i__;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Apply H or H**T
|
|
||||||
//
|
|
||||||
dlarfb_(side, trans, "Forward", "Columnwise", &mi, &ni, &ib, &a[
|
|
||||||
i__ + i__ * a_dim1], lda, &work[iwt], &c__65, &c__[ic +
|
|
||||||
jc * c_dim1], ldc, &work[1], &ldwork);
|
|
||||||
// L10:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
work[1] = (double) lwkopt;
|
|
||||||
return 0;
|
|
||||||
//
|
|
||||||
// End of DORMQR
|
|
||||||
//
|
|
||||||
} // dormqr_
|
|
||||||
|
|
||||||
Vendored
-164
@@ -1,164 +0,0 @@
|
|||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
//> \brief \b DROT
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// SUBROUTINE DROT(N,DX,INCX,DY,INCY,C,S)
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// DOUBLE PRECISION C,S
|
|
||||||
// INTEGER INCX,INCY,N
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// DOUBLE PRECISION DX(*),DY(*)
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> DROT applies a plane rotation.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] N
|
|
||||||
//> \verbatim
|
|
||||||
//> N is INTEGER
|
|
||||||
//> number of elements in input vector(s)
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in,out] DX
|
|
||||||
//> \verbatim
|
|
||||||
//> DX is DOUBLE PRECISION array, dimension ( 1 + ( N - 1 )*abs( INCX ) )
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] INCX
|
|
||||||
//> \verbatim
|
|
||||||
//> INCX is INTEGER
|
|
||||||
//> storage spacing between elements of DX
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in,out] DY
|
|
||||||
//> \verbatim
|
|
||||||
//> DY is DOUBLE PRECISION array, dimension ( 1 + ( N - 1 )*abs( INCY ) )
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] INCY
|
|
||||||
//> \verbatim
|
|
||||||
//> INCY is INTEGER
|
|
||||||
//> storage spacing between elements of DY
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] C
|
|
||||||
//> \verbatim
|
|
||||||
//> C is DOUBLE PRECISION
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] S
|
|
||||||
//> \verbatim
|
|
||||||
//> S is DOUBLE PRECISION
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date November 2017
|
|
||||||
//
|
|
||||||
//> \ingroup double_blas_level1
|
|
||||||
//
|
|
||||||
//> \par Further Details:
|
|
||||||
// =====================
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> jack dongarra, linpack, 3/11/78.
|
|
||||||
//> modified 12/3/93, array(1) declarations changed to array(*)
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
// =====================================================================
|
|
||||||
/* Subroutine */ int drot_(int *n, double *dx, int *incx, double *dy, int *
|
|
||||||
incy, double *c__, double *s)
|
|
||||||
{
|
|
||||||
// System generated locals
|
|
||||||
int i__1;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int i__, ix, iy;
|
|
||||||
double dtemp;
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- Reference BLAS level1 routine (version 3.8.0) --
|
|
||||||
// -- Reference BLAS is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// November 2017
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// Parameter adjustments
|
|
||||||
--dy;
|
|
||||||
--dx;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
if (*n <= 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (*incx == 1 && *incy == 1) {
|
|
||||||
//
|
|
||||||
// code for both increments equal to 1
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (i__ = 1; i__ <= i__1; ++i__) {
|
|
||||||
dtemp = *c__ * dx[i__] + *s * dy[i__];
|
|
||||||
dy[i__] = *c__ * dy[i__] - *s * dx[i__];
|
|
||||||
dx[i__] = dtemp;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// code for unequal increments or equal increments not equal
|
|
||||||
// to 1
|
|
||||||
//
|
|
||||||
ix = 1;
|
|
||||||
iy = 1;
|
|
||||||
if (*incx < 0) {
|
|
||||||
ix = (-(*n) + 1) * *incx + 1;
|
|
||||||
}
|
|
||||||
if (*incy < 0) {
|
|
||||||
iy = (-(*n) + 1) * *incy + 1;
|
|
||||||
}
|
|
||||||
i__1 = *n;
|
|
||||||
for (i__ = 1; i__ <= i__1; ++i__) {
|
|
||||||
dtemp = *c__ * dx[ix] + *s * dy[iy];
|
|
||||||
dy[iy] = *c__ * dy[iy] - *s * dx[ix];
|
|
||||||
dx[ix] = dtemp;
|
|
||||||
ix += *incx;
|
|
||||||
iy += *incy;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
} // drot_
|
|
||||||
|
|
||||||
Vendored
-155
@@ -1,155 +0,0 @@
|
|||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
//> \brief \b DSCAL
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// SUBROUTINE DSCAL(N,DA,DX,INCX)
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// DOUBLE PRECISION DA
|
|
||||||
// INTEGER INCX,N
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// DOUBLE PRECISION DX(*)
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> DSCAL scales a vector by a constant.
|
|
||||||
//> uses unrolled loops for increment equal to 1.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] N
|
|
||||||
//> \verbatim
|
|
||||||
//> N is INTEGER
|
|
||||||
//> number of elements in input vector(s)
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] DA
|
|
||||||
//> \verbatim
|
|
||||||
//> DA is DOUBLE PRECISION
|
|
||||||
//> On entry, DA specifies the scalar alpha.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in,out] DX
|
|
||||||
//> \verbatim
|
|
||||||
//> DX is DOUBLE PRECISION array, dimension ( 1 + ( N - 1 )*abs( INCX ) )
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] INCX
|
|
||||||
//> \verbatim
|
|
||||||
//> INCX is INTEGER
|
|
||||||
//> storage spacing between elements of DX
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date November 2017
|
|
||||||
//
|
|
||||||
//> \ingroup double_blas_level1
|
|
||||||
//
|
|
||||||
//> \par Further Details:
|
|
||||||
// =====================
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> jack dongarra, linpack, 3/11/78.
|
|
||||||
//> modified 3/93 to return if incx .le. 0.
|
|
||||||
//> modified 12/3/93, array(1) declarations changed to array(*)
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
// =====================================================================
|
|
||||||
/* Subroutine */ int dscal_(int *n, double *da, double *dx, int *incx)
|
|
||||||
{
|
|
||||||
// System generated locals
|
|
||||||
int i__1, i__2;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int i__, m, mp1, nincx;
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- Reference BLAS level1 routine (version 3.8.0) --
|
|
||||||
// -- Reference BLAS is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// November 2017
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// .. Intrinsic Functions ..
|
|
||||||
// ..
|
|
||||||
// Parameter adjustments
|
|
||||||
--dx;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
if (*n <= 0 || *incx <= 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (*incx == 1) {
|
|
||||||
//
|
|
||||||
// code for increment equal to 1
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// clean-up loop
|
|
||||||
//
|
|
||||||
m = *n % 5;
|
|
||||||
if (m != 0) {
|
|
||||||
i__1 = m;
|
|
||||||
for (i__ = 1; i__ <= i__1; ++i__) {
|
|
||||||
dx[i__] = *da * dx[i__];
|
|
||||||
}
|
|
||||||
if (*n < 5) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mp1 = m + 1;
|
|
||||||
i__1 = *n;
|
|
||||||
for (i__ = mp1; i__ <= i__1; i__ += 5) {
|
|
||||||
dx[i__] = *da * dx[i__];
|
|
||||||
dx[i__ + 1] = *da * dx[i__ + 1];
|
|
||||||
dx[i__ + 2] = *da * dx[i__ + 2];
|
|
||||||
dx[i__ + 3] = *da * dx[i__ + 3];
|
|
||||||
dx[i__ + 4] = *da * dx[i__ + 4];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// code for increment not equal to 1
|
|
||||||
//
|
|
||||||
nincx = *n * *incx;
|
|
||||||
i__1 = nincx;
|
|
||||||
i__2 = *incx;
|
|
||||||
for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
|
|
||||||
dx[i__] = *da * dx[i__];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
} // dscal_
|
|
||||||
|
|
||||||
Vendored
-178
@@ -1,178 +0,0 @@
|
|||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
//> \brief \b DSWAP
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// SUBROUTINE DSWAP(N,DX,INCX,DY,INCY)
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// INTEGER INCX,INCY,N
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// DOUBLE PRECISION DX(*),DY(*)
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> DSWAP interchanges two vectors.
|
|
||||||
//> uses unrolled loops for increments equal to 1.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] N
|
|
||||||
//> \verbatim
|
|
||||||
//> N is INTEGER
|
|
||||||
//> number of elements in input vector(s)
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in,out] DX
|
|
||||||
//> \verbatim
|
|
||||||
//> DX is DOUBLE PRECISION array, dimension ( 1 + ( N - 1 )*abs( INCX ) )
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] INCX
|
|
||||||
//> \verbatim
|
|
||||||
//> INCX is INTEGER
|
|
||||||
//> storage spacing between elements of DX
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in,out] DY
|
|
||||||
//> \verbatim
|
|
||||||
//> DY is DOUBLE PRECISION array, dimension ( 1 + ( N - 1 )*abs( INCY ) )
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] INCY
|
|
||||||
//> \verbatim
|
|
||||||
//> INCY is INTEGER
|
|
||||||
//> storage spacing between elements of DY
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date November 2017
|
|
||||||
//
|
|
||||||
//> \ingroup double_blas_level1
|
|
||||||
//
|
|
||||||
//> \par Further Details:
|
|
||||||
// =====================
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> jack dongarra, linpack, 3/11/78.
|
|
||||||
//> modified 12/3/93, array(1) declarations changed to array(*)
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
// =====================================================================
|
|
||||||
/* Subroutine */ int dswap_(int *n, double *dx, int *incx, double *dy, int *
|
|
||||||
incy)
|
|
||||||
{
|
|
||||||
// System generated locals
|
|
||||||
int i__1;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int i__, m, ix, iy, mp1;
|
|
||||||
double dtemp;
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- Reference BLAS level1 routine (version 3.8.0) --
|
|
||||||
// -- Reference BLAS is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// November 2017
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// .. Intrinsic Functions ..
|
|
||||||
// ..
|
|
||||||
// Parameter adjustments
|
|
||||||
--dy;
|
|
||||||
--dx;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
if (*n <= 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (*incx == 1 && *incy == 1) {
|
|
||||||
//
|
|
||||||
// code for both increments equal to 1
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// clean-up loop
|
|
||||||
//
|
|
||||||
m = *n % 3;
|
|
||||||
if (m != 0) {
|
|
||||||
i__1 = m;
|
|
||||||
for (i__ = 1; i__ <= i__1; ++i__) {
|
|
||||||
dtemp = dx[i__];
|
|
||||||
dx[i__] = dy[i__];
|
|
||||||
dy[i__] = dtemp;
|
|
||||||
}
|
|
||||||
if (*n < 3) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mp1 = m + 1;
|
|
||||||
i__1 = *n;
|
|
||||||
for (i__ = mp1; i__ <= i__1; i__ += 3) {
|
|
||||||
dtemp = dx[i__];
|
|
||||||
dx[i__] = dy[i__];
|
|
||||||
dy[i__] = dtemp;
|
|
||||||
dtemp = dx[i__ + 1];
|
|
||||||
dx[i__ + 1] = dy[i__ + 1];
|
|
||||||
dy[i__ + 1] = dtemp;
|
|
||||||
dtemp = dx[i__ + 2];
|
|
||||||
dx[i__ + 2] = dy[i__ + 2];
|
|
||||||
dy[i__ + 2] = dtemp;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// code for unequal increments or equal increments not equal
|
|
||||||
// to 1
|
|
||||||
//
|
|
||||||
ix = 1;
|
|
||||||
iy = 1;
|
|
||||||
if (*incx < 0) {
|
|
||||||
ix = (-(*n) + 1) * *incx + 1;
|
|
||||||
}
|
|
||||||
if (*incy < 0) {
|
|
||||||
iy = (-(*n) + 1) * *incy + 1;
|
|
||||||
}
|
|
||||||
i__1 = *n;
|
|
||||||
for (i__ = 1; i__ <= i__1; ++i__) {
|
|
||||||
dtemp = dx[ix];
|
|
||||||
dx[ix] = dy[iy];
|
|
||||||
dy[iy] = dtemp;
|
|
||||||
ix += *incx;
|
|
||||||
iy += *incy;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
} // dswap_
|
|
||||||
|
|
||||||
Vendored
-509
@@ -1,509 +0,0 @@
|
|||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
//> \brief \b DTRMM
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// SUBROUTINE DTRMM(SIDE,UPLO,TRANSA,DIAG,M,N,ALPHA,A,LDA,B,LDB)
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// DOUBLE PRECISION ALPHA
|
|
||||||
// INTEGER LDA,LDB,M,N
|
|
||||||
// CHARACTER DIAG,SIDE,TRANSA,UPLO
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// DOUBLE PRECISION A(LDA,*),B(LDB,*)
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> DTRMM performs one of the matrix-matrix operations
|
|
||||||
//>
|
|
||||||
//> B := alpha*op( A )*B, or B := alpha*B*op( A ),
|
|
||||||
//>
|
|
||||||
//> where alpha is a scalar, B is an m by n matrix, A is a unit, or
|
|
||||||
//> non-unit, upper or lower triangular matrix and op( A ) is one of
|
|
||||||
//>
|
|
||||||
//> op( A ) = A or op( A ) = A**T.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] SIDE
|
|
||||||
//> \verbatim
|
|
||||||
//> SIDE is CHARACTER*1
|
|
||||||
//> On entry, SIDE specifies whether op( A ) multiplies B from
|
|
||||||
//> the left or right as follows:
|
|
||||||
//>
|
|
||||||
//> SIDE = 'L' or 'l' B := alpha*op( A )*B.
|
|
||||||
//>
|
|
||||||
//> SIDE = 'R' or 'r' B := alpha*B*op( A ).
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] UPLO
|
|
||||||
//> \verbatim
|
|
||||||
//> UPLO is CHARACTER*1
|
|
||||||
//> On entry, UPLO specifies whether the matrix A is an upper or
|
|
||||||
//> lower triangular matrix as follows:
|
|
||||||
//>
|
|
||||||
//> UPLO = 'U' or 'u' A is an upper triangular matrix.
|
|
||||||
//>
|
|
||||||
//> UPLO = 'L' or 'l' A is a lower triangular matrix.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] TRANSA
|
|
||||||
//> \verbatim
|
|
||||||
//> TRANSA is CHARACTER*1
|
|
||||||
//> On entry, TRANSA specifies the form of op( A ) to be used in
|
|
||||||
//> the matrix multiplication as follows:
|
|
||||||
//>
|
|
||||||
//> TRANSA = 'N' or 'n' op( A ) = A.
|
|
||||||
//>
|
|
||||||
//> TRANSA = 'T' or 't' op( A ) = A**T.
|
|
||||||
//>
|
|
||||||
//> TRANSA = 'C' or 'c' op( A ) = A**T.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] DIAG
|
|
||||||
//> \verbatim
|
|
||||||
//> DIAG is CHARACTER*1
|
|
||||||
//> On entry, DIAG specifies whether or not A is unit triangular
|
|
||||||
//> as follows:
|
|
||||||
//>
|
|
||||||
//> DIAG = 'U' or 'u' A is assumed to be unit triangular.
|
|
||||||
//>
|
|
||||||
//> DIAG = 'N' or 'n' A is not assumed to be unit
|
|
||||||
//> triangular.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] M
|
|
||||||
//> \verbatim
|
|
||||||
//> M is INTEGER
|
|
||||||
//> On entry, M specifies the number of rows of B. M must be at
|
|
||||||
//> least zero.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] N
|
|
||||||
//> \verbatim
|
|
||||||
//> N is INTEGER
|
|
||||||
//> On entry, N specifies the number of columns of B. N must be
|
|
||||||
//> at least zero.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] ALPHA
|
|
||||||
//> \verbatim
|
|
||||||
//> ALPHA is DOUBLE PRECISION.
|
|
||||||
//> On entry, ALPHA specifies the scalar alpha. When alpha is
|
|
||||||
//> zero then A is not referenced and B need not be set before
|
|
||||||
//> entry.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] A
|
|
||||||
//> \verbatim
|
|
||||||
//> A is DOUBLE PRECISION array, dimension ( LDA, k ), where k is m
|
|
||||||
//> when SIDE = 'L' or 'l' and is n when SIDE = 'R' or 'r'.
|
|
||||||
//> Before entry with UPLO = 'U' or 'u', the leading k by k
|
|
||||||
//> upper triangular part of the array A must contain the upper
|
|
||||||
//> triangular matrix and the strictly lower triangular part of
|
|
||||||
//> A is not referenced.
|
|
||||||
//> Before entry with UPLO = 'L' or 'l', the leading k by k
|
|
||||||
//> lower triangular part of the array A must contain the lower
|
|
||||||
//> triangular matrix and the strictly upper triangular part of
|
|
||||||
//> A is not referenced.
|
|
||||||
//> Note that when DIAG = 'U' or 'u', the diagonal elements of
|
|
||||||
//> A are not referenced either, but are assumed to be unity.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDA
|
|
||||||
//> \verbatim
|
|
||||||
//> LDA is INTEGER
|
|
||||||
//> On entry, LDA specifies the first dimension of A as declared
|
|
||||||
//> in the calling (sub) program. When SIDE = 'L' or 'l' then
|
|
||||||
//> LDA must be at least max( 1, m ), when SIDE = 'R' or 'r'
|
|
||||||
//> then LDA must be at least max( 1, n ).
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in,out] B
|
|
||||||
//> \verbatim
|
|
||||||
//> B is DOUBLE PRECISION array, dimension ( LDB, N )
|
|
||||||
//> Before entry, the leading m by n part of the array B must
|
|
||||||
//> contain the matrix B, and on exit is overwritten by the
|
|
||||||
//> transformed matrix.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDB
|
|
||||||
//> \verbatim
|
|
||||||
//> LDB is INTEGER
|
|
||||||
//> On entry, LDB specifies the first dimension of B as declared
|
|
||||||
//> in the calling (sub) program. LDB must be at least
|
|
||||||
//> max( 1, m ).
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date December 2016
|
|
||||||
//
|
|
||||||
//> \ingroup double_blas_level3
|
|
||||||
//
|
|
||||||
//> \par Further Details:
|
|
||||||
// =====================
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> Level 3 Blas routine.
|
|
||||||
//>
|
|
||||||
//> -- Written on 8-February-1989.
|
|
||||||
//> Jack Dongarra, Argonne National Laboratory.
|
|
||||||
//> Iain Duff, AERE Harwell.
|
|
||||||
//> Jeremy Du Croz, Numerical Algorithms Group Ltd.
|
|
||||||
//> Sven Hammarling, Numerical Algorithms Group Ltd.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
// =====================================================================
|
|
||||||
/* Subroutine */ int dtrmm_(char *side, char *uplo, char *transa, char *diag,
|
|
||||||
int *m, int *n, double *alpha, double *a, int *lda, double *b, int *
|
|
||||||
ldb)
|
|
||||||
{
|
|
||||||
// System generated locals
|
|
||||||
int a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int i__, j, k, info;
|
|
||||||
double temp;
|
|
||||||
int lside;
|
|
||||||
extern int lsame_(char *, char *);
|
|
||||||
int nrowa;
|
|
||||||
int upper;
|
|
||||||
extern /* Subroutine */ int xerbla_(char *, int *);
|
|
||||||
int nounit;
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- Reference BLAS level3 routine (version 3.7.0) --
|
|
||||||
// -- Reference BLAS is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// December 2016
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. External Functions ..
|
|
||||||
// ..
|
|
||||||
// .. External Subroutines ..
|
|
||||||
// ..
|
|
||||||
// .. Intrinsic Functions ..
|
|
||||||
// ..
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// .. Parameters ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// Test the input parameters.
|
|
||||||
//
|
|
||||||
// Parameter adjustments
|
|
||||||
a_dim1 = *lda;
|
|
||||||
a_offset = 1 + a_dim1;
|
|
||||||
a -= a_offset;
|
|
||||||
b_dim1 = *ldb;
|
|
||||||
b_offset = 1 + b_dim1;
|
|
||||||
b -= b_offset;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
lside = lsame_(side, "L");
|
|
||||||
if (lside) {
|
|
||||||
nrowa = *m;
|
|
||||||
} else {
|
|
||||||
nrowa = *n;
|
|
||||||
}
|
|
||||||
nounit = lsame_(diag, "N");
|
|
||||||
upper = lsame_(uplo, "U");
|
|
||||||
info = 0;
|
|
||||||
if (! lside && ! lsame_(side, "R")) {
|
|
||||||
info = 1;
|
|
||||||
} else if (! upper && ! lsame_(uplo, "L")) {
|
|
||||||
info = 2;
|
|
||||||
} else if (! lsame_(transa, "N") && ! lsame_(transa, "T") && ! lsame_(
|
|
||||||
transa, "C")) {
|
|
||||||
info = 3;
|
|
||||||
} else if (! lsame_(diag, "U") && ! lsame_(diag, "N")) {
|
|
||||||
info = 4;
|
|
||||||
} else if (*m < 0) {
|
|
||||||
info = 5;
|
|
||||||
} else if (*n < 0) {
|
|
||||||
info = 6;
|
|
||||||
} else if (*lda < max(1,nrowa)) {
|
|
||||||
info = 9;
|
|
||||||
} else if (*ldb < max(1,*m)) {
|
|
||||||
info = 11;
|
|
||||||
}
|
|
||||||
if (info != 0) {
|
|
||||||
xerbla_("DTRMM ", &info);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Quick return if possible.
|
|
||||||
//
|
|
||||||
if (*m == 0 || *n == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// And when alpha.eq.zero.
|
|
||||||
//
|
|
||||||
if (*alpha == 0.) {
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
b[i__ + j * b_dim1] = 0.;
|
|
||||||
// L10:
|
|
||||||
}
|
|
||||||
// L20:
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Start the operations.
|
|
||||||
//
|
|
||||||
if (lside) {
|
|
||||||
if (lsame_(transa, "N")) {
|
|
||||||
//
|
|
||||||
// Form B := alpha*A*B.
|
|
||||||
//
|
|
||||||
if (upper) {
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (k = 1; k <= i__2; ++k) {
|
|
||||||
if (b[k + j * b_dim1] != 0.) {
|
|
||||||
temp = *alpha * b[k + j * b_dim1];
|
|
||||||
i__3 = k - 1;
|
|
||||||
for (i__ = 1; i__ <= i__3; ++i__) {
|
|
||||||
b[i__ + j * b_dim1] += temp * a[i__ + k *
|
|
||||||
a_dim1];
|
|
||||||
// L30:
|
|
||||||
}
|
|
||||||
if (nounit) {
|
|
||||||
temp *= a[k + k * a_dim1];
|
|
||||||
}
|
|
||||||
b[k + j * b_dim1] = temp;
|
|
||||||
}
|
|
||||||
// L40:
|
|
||||||
}
|
|
||||||
// L50:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
for (k = *m; k >= 1; --k) {
|
|
||||||
if (b[k + j * b_dim1] != 0.) {
|
|
||||||
temp = *alpha * b[k + j * b_dim1];
|
|
||||||
b[k + j * b_dim1] = temp;
|
|
||||||
if (nounit) {
|
|
||||||
b[k + j * b_dim1] *= a[k + k * a_dim1];
|
|
||||||
}
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = k + 1; i__ <= i__2; ++i__) {
|
|
||||||
b[i__ + j * b_dim1] += temp * a[i__ + k *
|
|
||||||
a_dim1];
|
|
||||||
// L60:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// L70:
|
|
||||||
}
|
|
||||||
// L80:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Form B := alpha*A**T*B.
|
|
||||||
//
|
|
||||||
if (upper) {
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
for (i__ = *m; i__ >= 1; --i__) {
|
|
||||||
temp = b[i__ + j * b_dim1];
|
|
||||||
if (nounit) {
|
|
||||||
temp *= a[i__ + i__ * a_dim1];
|
|
||||||
}
|
|
||||||
i__2 = i__ - 1;
|
|
||||||
for (k = 1; k <= i__2; ++k) {
|
|
||||||
temp += a[k + i__ * a_dim1] * b[k + j * b_dim1];
|
|
||||||
// L90:
|
|
||||||
}
|
|
||||||
b[i__ + j * b_dim1] = *alpha * temp;
|
|
||||||
// L100:
|
|
||||||
}
|
|
||||||
// L110:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
temp = b[i__ + j * b_dim1];
|
|
||||||
if (nounit) {
|
|
||||||
temp *= a[i__ + i__ * a_dim1];
|
|
||||||
}
|
|
||||||
i__3 = *m;
|
|
||||||
for (k = i__ + 1; k <= i__3; ++k) {
|
|
||||||
temp += a[k + i__ * a_dim1] * b[k + j * b_dim1];
|
|
||||||
// L120:
|
|
||||||
}
|
|
||||||
b[i__ + j * b_dim1] = *alpha * temp;
|
|
||||||
// L130:
|
|
||||||
}
|
|
||||||
// L140:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (lsame_(transa, "N")) {
|
|
||||||
//
|
|
||||||
// Form B := alpha*B*A.
|
|
||||||
//
|
|
||||||
if (upper) {
|
|
||||||
for (j = *n; j >= 1; --j) {
|
|
||||||
temp = *alpha;
|
|
||||||
if (nounit) {
|
|
||||||
temp *= a[j + j * a_dim1];
|
|
||||||
}
|
|
||||||
i__1 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__1; ++i__) {
|
|
||||||
b[i__ + j * b_dim1] = temp * b[i__ + j * b_dim1];
|
|
||||||
// L150:
|
|
||||||
}
|
|
||||||
i__1 = j - 1;
|
|
||||||
for (k = 1; k <= i__1; ++k) {
|
|
||||||
if (a[k + j * a_dim1] != 0.) {
|
|
||||||
temp = *alpha * a[k + j * a_dim1];
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
b[i__ + j * b_dim1] += temp * b[i__ + k *
|
|
||||||
b_dim1];
|
|
||||||
// L160:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// L170:
|
|
||||||
}
|
|
||||||
// L180:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
temp = *alpha;
|
|
||||||
if (nounit) {
|
|
||||||
temp *= a[j + j * a_dim1];
|
|
||||||
}
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
b[i__ + j * b_dim1] = temp * b[i__ + j * b_dim1];
|
|
||||||
// L190:
|
|
||||||
}
|
|
||||||
i__2 = *n;
|
|
||||||
for (k = j + 1; k <= i__2; ++k) {
|
|
||||||
if (a[k + j * a_dim1] != 0.) {
|
|
||||||
temp = *alpha * a[k + j * a_dim1];
|
|
||||||
i__3 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__3; ++i__) {
|
|
||||||
b[i__ + j * b_dim1] += temp * b[i__ + k *
|
|
||||||
b_dim1];
|
|
||||||
// L200:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// L210:
|
|
||||||
}
|
|
||||||
// L220:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Form B := alpha*B*A**T.
|
|
||||||
//
|
|
||||||
if (upper) {
|
|
||||||
i__1 = *n;
|
|
||||||
for (k = 1; k <= i__1; ++k) {
|
|
||||||
i__2 = k - 1;
|
|
||||||
for (j = 1; j <= i__2; ++j) {
|
|
||||||
if (a[j + k * a_dim1] != 0.) {
|
|
||||||
temp = *alpha * a[j + k * a_dim1];
|
|
||||||
i__3 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__3; ++i__) {
|
|
||||||
b[i__ + j * b_dim1] += temp * b[i__ + k *
|
|
||||||
b_dim1];
|
|
||||||
// L230:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// L240:
|
|
||||||
}
|
|
||||||
temp = *alpha;
|
|
||||||
if (nounit) {
|
|
||||||
temp *= a[k + k * a_dim1];
|
|
||||||
}
|
|
||||||
if (temp != 1.) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
b[i__ + k * b_dim1] = temp * b[i__ + k * b_dim1];
|
|
||||||
// L250:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// L260:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (k = *n; k >= 1; --k) {
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = k + 1; j <= i__1; ++j) {
|
|
||||||
if (a[j + k * a_dim1] != 0.) {
|
|
||||||
temp = *alpha * a[j + k * a_dim1];
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
b[i__ + j * b_dim1] += temp * b[i__ + k *
|
|
||||||
b_dim1];
|
|
||||||
// L270:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// L280:
|
|
||||||
}
|
|
||||||
temp = *alpha;
|
|
||||||
if (nounit) {
|
|
||||||
temp *= a[k + k * a_dim1];
|
|
||||||
}
|
|
||||||
if (temp != 1.) {
|
|
||||||
i__1 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__1; ++i__) {
|
|
||||||
b[i__ + k * b_dim1] = temp * b[i__ + k * b_dim1];
|
|
||||||
// L290:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// L300:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
//
|
|
||||||
// End of DTRMM .
|
|
||||||
//
|
|
||||||
} // dtrmm_
|
|
||||||
|
|
||||||
Vendored
-396
@@ -1,396 +0,0 @@
|
|||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
//> \brief \b DTRMV
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// SUBROUTINE DTRMV(UPLO,TRANS,DIAG,N,A,LDA,X,INCX)
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// INTEGER INCX,LDA,N
|
|
||||||
// CHARACTER DIAG,TRANS,UPLO
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// DOUBLE PRECISION A(LDA,*),X(*)
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> DTRMV performs one of the matrix-vector operations
|
|
||||||
//>
|
|
||||||
//> x := A*x, or x := A**T*x,
|
|
||||||
//>
|
|
||||||
//> where x is an n element vector and A is an n by n unit, or non-unit,
|
|
||||||
//> upper or lower triangular matrix.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] UPLO
|
|
||||||
//> \verbatim
|
|
||||||
//> UPLO is CHARACTER*1
|
|
||||||
//> On entry, UPLO specifies whether the matrix is an upper or
|
|
||||||
//> lower triangular matrix as follows:
|
|
||||||
//>
|
|
||||||
//> UPLO = 'U' or 'u' A is an upper triangular matrix.
|
|
||||||
//>
|
|
||||||
//> UPLO = 'L' or 'l' A is a lower triangular matrix.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] TRANS
|
|
||||||
//> \verbatim
|
|
||||||
//> TRANS is CHARACTER*1
|
|
||||||
//> On entry, TRANS specifies the operation to be performed as
|
|
||||||
//> follows:
|
|
||||||
//>
|
|
||||||
//> TRANS = 'N' or 'n' x := A*x.
|
|
||||||
//>
|
|
||||||
//> TRANS = 'T' or 't' x := A**T*x.
|
|
||||||
//>
|
|
||||||
//> TRANS = 'C' or 'c' x := A**T*x.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] DIAG
|
|
||||||
//> \verbatim
|
|
||||||
//> DIAG is CHARACTER*1
|
|
||||||
//> On entry, DIAG specifies whether or not A is unit
|
|
||||||
//> triangular as follows:
|
|
||||||
//>
|
|
||||||
//> DIAG = 'U' or 'u' A is assumed to be unit triangular.
|
|
||||||
//>
|
|
||||||
//> DIAG = 'N' or 'n' A is not assumed to be unit
|
|
||||||
//> triangular.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] N
|
|
||||||
//> \verbatim
|
|
||||||
//> N is INTEGER
|
|
||||||
//> On entry, N specifies the order of the matrix A.
|
|
||||||
//> N must be at least zero.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] A
|
|
||||||
//> \verbatim
|
|
||||||
//> A is DOUBLE PRECISION array, dimension ( LDA, N )
|
|
||||||
//> Before entry with UPLO = 'U' or 'u', the leading n by n
|
|
||||||
//> upper triangular part of the array A must contain the upper
|
|
||||||
//> triangular matrix and the strictly lower triangular part of
|
|
||||||
//> A is not referenced.
|
|
||||||
//> Before entry with UPLO = 'L' or 'l', the leading n by n
|
|
||||||
//> lower triangular part of the array A must contain the lower
|
|
||||||
//> triangular matrix and the strictly upper triangular part of
|
|
||||||
//> A is not referenced.
|
|
||||||
//> Note that when DIAG = 'U' or 'u', the diagonal elements of
|
|
||||||
//> A are not referenced either, but are assumed to be unity.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDA
|
|
||||||
//> \verbatim
|
|
||||||
//> LDA is INTEGER
|
|
||||||
//> On entry, LDA specifies the first dimension of A as declared
|
|
||||||
//> in the calling (sub) program. LDA must be at least
|
|
||||||
//> max( 1, n ).
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in,out] X
|
|
||||||
//> \verbatim
|
|
||||||
//> X is DOUBLE PRECISION array, dimension at least
|
|
||||||
//> ( 1 + ( n - 1 )*abs( INCX ) ).
|
|
||||||
//> Before entry, the incremented array X must contain the n
|
|
||||||
//> element vector x. On exit, X is overwritten with the
|
|
||||||
//> transformed vector x.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] INCX
|
|
||||||
//> \verbatim
|
|
||||||
//> INCX is INTEGER
|
|
||||||
//> On entry, INCX specifies the increment for the elements of
|
|
||||||
//> X. INCX must not be zero.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date December 2016
|
|
||||||
//
|
|
||||||
//> \ingroup double_blas_level2
|
|
||||||
//
|
|
||||||
//> \par Further Details:
|
|
||||||
// =====================
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> Level 2 Blas routine.
|
|
||||||
//> The vector and matrix arguments are not referenced when N = 0, or M = 0
|
|
||||||
//>
|
|
||||||
//> -- Written on 22-October-1986.
|
|
||||||
//> Jack Dongarra, Argonne National Lab.
|
|
||||||
//> Jeremy Du Croz, Nag Central Office.
|
|
||||||
//> Sven Hammarling, Nag Central Office.
|
|
||||||
//> Richard Hanson, Sandia National Labs.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
// =====================================================================
|
|
||||||
/* Subroutine */ int dtrmv_(char *uplo, char *trans, char *diag, int *n,
|
|
||||||
double *a, int *lda, double *x, int *incx)
|
|
||||||
{
|
|
||||||
// System generated locals
|
|
||||||
int a_dim1, a_offset, i__1, i__2;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int i__, j, ix, jx, kx, info;
|
|
||||||
double temp;
|
|
||||||
extern int lsame_(char *, char *);
|
|
||||||
extern /* Subroutine */ int xerbla_(char *, int *);
|
|
||||||
int nounit;
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- Reference BLAS level2 routine (version 3.7.0) --
|
|
||||||
// -- Reference BLAS is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// December 2016
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. Parameters ..
|
|
||||||
// ..
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// .. External Functions ..
|
|
||||||
// ..
|
|
||||||
// .. External Subroutines ..
|
|
||||||
// ..
|
|
||||||
// .. Intrinsic Functions ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// Test the input parameters.
|
|
||||||
//
|
|
||||||
// Parameter adjustments
|
|
||||||
a_dim1 = *lda;
|
|
||||||
a_offset = 1 + a_dim1;
|
|
||||||
a -= a_offset;
|
|
||||||
--x;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
info = 0;
|
|
||||||
if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
|
|
||||||
info = 1;
|
|
||||||
} else if (! lsame_(trans, "N") && ! lsame_(trans, "T") && ! lsame_(trans,
|
|
||||||
"C")) {
|
|
||||||
info = 2;
|
|
||||||
} else if (! lsame_(diag, "U") && ! lsame_(diag, "N")) {
|
|
||||||
info = 3;
|
|
||||||
} else if (*n < 0) {
|
|
||||||
info = 4;
|
|
||||||
} else if (*lda < max(1,*n)) {
|
|
||||||
info = 6;
|
|
||||||
} else if (*incx == 0) {
|
|
||||||
info = 8;
|
|
||||||
}
|
|
||||||
if (info != 0) {
|
|
||||||
xerbla_("DTRMV ", &info);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Quick return if possible.
|
|
||||||
//
|
|
||||||
if (*n == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
nounit = lsame_(diag, "N");
|
|
||||||
//
|
|
||||||
// Set up the start point in X if the increment is not unity. This
|
|
||||||
// will be ( N - 1 )*INCX too small for descending loops.
|
|
||||||
//
|
|
||||||
if (*incx <= 0) {
|
|
||||||
kx = 1 - (*n - 1) * *incx;
|
|
||||||
} else if (*incx != 1) {
|
|
||||||
kx = 1;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Start the operations. In this version the elements of A are
|
|
||||||
// accessed sequentially with one pass through A.
|
|
||||||
//
|
|
||||||
if (lsame_(trans, "N")) {
|
|
||||||
//
|
|
||||||
// Form x := A*x.
|
|
||||||
//
|
|
||||||
if (lsame_(uplo, "U")) {
|
|
||||||
if (*incx == 1) {
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
if (x[j] != 0.) {
|
|
||||||
temp = x[j];
|
|
||||||
i__2 = j - 1;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
x[i__] += temp * a[i__ + j * a_dim1];
|
|
||||||
// L10:
|
|
||||||
}
|
|
||||||
if (nounit) {
|
|
||||||
x[j] *= a[j + j * a_dim1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// L20:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
jx = kx;
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
if (x[jx] != 0.) {
|
|
||||||
temp = x[jx];
|
|
||||||
ix = kx;
|
|
||||||
i__2 = j - 1;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
x[ix] += temp * a[i__ + j * a_dim1];
|
|
||||||
ix += *incx;
|
|
||||||
// L30:
|
|
||||||
}
|
|
||||||
if (nounit) {
|
|
||||||
x[jx] *= a[j + j * a_dim1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
jx += *incx;
|
|
||||||
// L40:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (*incx == 1) {
|
|
||||||
for (j = *n; j >= 1; --j) {
|
|
||||||
if (x[j] != 0.) {
|
|
||||||
temp = x[j];
|
|
||||||
i__1 = j + 1;
|
|
||||||
for (i__ = *n; i__ >= i__1; --i__) {
|
|
||||||
x[i__] += temp * a[i__ + j * a_dim1];
|
|
||||||
// L50:
|
|
||||||
}
|
|
||||||
if (nounit) {
|
|
||||||
x[j] *= a[j + j * a_dim1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// L60:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
kx += (*n - 1) * *incx;
|
|
||||||
jx = kx;
|
|
||||||
for (j = *n; j >= 1; --j) {
|
|
||||||
if (x[jx] != 0.) {
|
|
||||||
temp = x[jx];
|
|
||||||
ix = kx;
|
|
||||||
i__1 = j + 1;
|
|
||||||
for (i__ = *n; i__ >= i__1; --i__) {
|
|
||||||
x[ix] += temp * a[i__ + j * a_dim1];
|
|
||||||
ix -= *incx;
|
|
||||||
// L70:
|
|
||||||
}
|
|
||||||
if (nounit) {
|
|
||||||
x[jx] *= a[j + j * a_dim1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
jx -= *incx;
|
|
||||||
// L80:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Form x := A**T*x.
|
|
||||||
//
|
|
||||||
if (lsame_(uplo, "U")) {
|
|
||||||
if (*incx == 1) {
|
|
||||||
for (j = *n; j >= 1; --j) {
|
|
||||||
temp = x[j];
|
|
||||||
if (nounit) {
|
|
||||||
temp *= a[j + j * a_dim1];
|
|
||||||
}
|
|
||||||
for (i__ = j - 1; i__ >= 1; --i__) {
|
|
||||||
temp += a[i__ + j * a_dim1] * x[i__];
|
|
||||||
// L90:
|
|
||||||
}
|
|
||||||
x[j] = temp;
|
|
||||||
// L100:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
jx = kx + (*n - 1) * *incx;
|
|
||||||
for (j = *n; j >= 1; --j) {
|
|
||||||
temp = x[jx];
|
|
||||||
ix = jx;
|
|
||||||
if (nounit) {
|
|
||||||
temp *= a[j + j * a_dim1];
|
|
||||||
}
|
|
||||||
for (i__ = j - 1; i__ >= 1; --i__) {
|
|
||||||
ix -= *incx;
|
|
||||||
temp += a[i__ + j * a_dim1] * x[ix];
|
|
||||||
// L110:
|
|
||||||
}
|
|
||||||
x[jx] = temp;
|
|
||||||
jx -= *incx;
|
|
||||||
// L120:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (*incx == 1) {
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
temp = x[j];
|
|
||||||
if (nounit) {
|
|
||||||
temp *= a[j + j * a_dim1];
|
|
||||||
}
|
|
||||||
i__2 = *n;
|
|
||||||
for (i__ = j + 1; i__ <= i__2; ++i__) {
|
|
||||||
temp += a[i__ + j * a_dim1] * x[i__];
|
|
||||||
// L130:
|
|
||||||
}
|
|
||||||
x[j] = temp;
|
|
||||||
// L140:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
jx = kx;
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
temp = x[jx];
|
|
||||||
ix = jx;
|
|
||||||
if (nounit) {
|
|
||||||
temp *= a[j + j * a_dim1];
|
|
||||||
}
|
|
||||||
i__2 = *n;
|
|
||||||
for (i__ = j + 1; i__ <= i__2; ++i__) {
|
|
||||||
ix += *incx;
|
|
||||||
temp += a[i__ + j * a_dim1] * x[ix];
|
|
||||||
// L150:
|
|
||||||
}
|
|
||||||
x[jx] = temp;
|
|
||||||
jx += *incx;
|
|
||||||
// L160:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
//
|
|
||||||
// End of DTRMV .
|
|
||||||
//
|
|
||||||
} // dtrmv_
|
|
||||||
|
|
||||||
Vendored
-1334
File diff suppressed because it is too large
Load Diff
Vendored
-444
@@ -1,444 +0,0 @@
|
|||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
//> \brief \b SGEMM
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// SUBROUTINE SGEMM(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// REAL ALPHA,BETA
|
|
||||||
// INTEGER K,LDA,LDB,LDC,M,N
|
|
||||||
// CHARACTER TRANSA,TRANSB
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// REAL A(LDA,*),B(LDB,*),C(LDC,*)
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> SGEMM performs one of the matrix-matrix operations
|
|
||||||
//>
|
|
||||||
//> C := alpha*op( A )*op( B ) + beta*C,
|
|
||||||
//>
|
|
||||||
//> where op( X ) is one of
|
|
||||||
//>
|
|
||||||
//> op( X ) = X or op( X ) = X**T,
|
|
||||||
//>
|
|
||||||
//> alpha and beta are scalars, and A, B and C are matrices, with op( A )
|
|
||||||
//> an m by k matrix, op( B ) a k by n matrix and C an m by n matrix.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] TRANSA
|
|
||||||
//> \verbatim
|
|
||||||
//> TRANSA is CHARACTER*1
|
|
||||||
//> On entry, TRANSA specifies the form of op( A ) to be used in
|
|
||||||
//> the matrix multiplication as follows:
|
|
||||||
//>
|
|
||||||
//> TRANSA = 'N' or 'n', op( A ) = A.
|
|
||||||
//>
|
|
||||||
//> TRANSA = 'T' or 't', op( A ) = A**T.
|
|
||||||
//>
|
|
||||||
//> TRANSA = 'C' or 'c', op( A ) = A**T.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] TRANSB
|
|
||||||
//> \verbatim
|
|
||||||
//> TRANSB is CHARACTER*1
|
|
||||||
//> On entry, TRANSB specifies the form of op( B ) to be used in
|
|
||||||
//> the matrix multiplication as follows:
|
|
||||||
//>
|
|
||||||
//> TRANSB = 'N' or 'n', op( B ) = B.
|
|
||||||
//>
|
|
||||||
//> TRANSB = 'T' or 't', op( B ) = B**T.
|
|
||||||
//>
|
|
||||||
//> TRANSB = 'C' or 'c', op( B ) = B**T.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] M
|
|
||||||
//> \verbatim
|
|
||||||
//> M is INTEGER
|
|
||||||
//> On entry, M specifies the number of rows of the matrix
|
|
||||||
//> op( A ) and of the matrix C. M must be at least zero.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] N
|
|
||||||
//> \verbatim
|
|
||||||
//> N is INTEGER
|
|
||||||
//> On entry, N specifies the number of columns of the matrix
|
|
||||||
//> op( B ) and the number of columns of the matrix C. N must be
|
|
||||||
//> at least zero.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] K
|
|
||||||
//> \verbatim
|
|
||||||
//> K is INTEGER
|
|
||||||
//> On entry, K specifies the number of columns of the matrix
|
|
||||||
//> op( A ) and the number of rows of the matrix op( B ). K must
|
|
||||||
//> be at least zero.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] ALPHA
|
|
||||||
//> \verbatim
|
|
||||||
//> ALPHA is REAL
|
|
||||||
//> On entry, ALPHA specifies the scalar alpha.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] A
|
|
||||||
//> \verbatim
|
|
||||||
//> A is REAL array, dimension ( LDA, ka ), where ka is
|
|
||||||
//> k when TRANSA = 'N' or 'n', and is m otherwise.
|
|
||||||
//> Before entry with TRANSA = 'N' or 'n', the leading m by k
|
|
||||||
//> part of the array A must contain the matrix A, otherwise
|
|
||||||
//> the leading k by m part of the array A must contain the
|
|
||||||
//> matrix A.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDA
|
|
||||||
//> \verbatim
|
|
||||||
//> LDA is INTEGER
|
|
||||||
//> On entry, LDA specifies the first dimension of A as declared
|
|
||||||
//> in the calling (sub) program. When TRANSA = 'N' or 'n' then
|
|
||||||
//> LDA must be at least max( 1, m ), otherwise LDA must be at
|
|
||||||
//> least max( 1, k ).
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] B
|
|
||||||
//> \verbatim
|
|
||||||
//> B is REAL array, dimension ( LDB, kb ), where kb is
|
|
||||||
//> n when TRANSB = 'N' or 'n', and is k otherwise.
|
|
||||||
//> Before entry with TRANSB = 'N' or 'n', the leading k by n
|
|
||||||
//> part of the array B must contain the matrix B, otherwise
|
|
||||||
//> the leading n by k part of the array B must contain the
|
|
||||||
//> matrix B.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDB
|
|
||||||
//> \verbatim
|
|
||||||
//> LDB is INTEGER
|
|
||||||
//> On entry, LDB specifies the first dimension of B as declared
|
|
||||||
//> in the calling (sub) program. When TRANSB = 'N' or 'n' then
|
|
||||||
//> LDB must be at least max( 1, k ), otherwise LDB must be at
|
|
||||||
//> least max( 1, n ).
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] BETA
|
|
||||||
//> \verbatim
|
|
||||||
//> BETA is REAL
|
|
||||||
//> On entry, BETA specifies the scalar beta. When BETA is
|
|
||||||
//> supplied as zero then C need not be set on input.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in,out] C
|
|
||||||
//> \verbatim
|
|
||||||
//> C is REAL array, dimension ( LDC, N )
|
|
||||||
//> Before entry, the leading m by n part of the array C must
|
|
||||||
//> contain the matrix C, except when beta is zero, in which
|
|
||||||
//> case C need not be set on entry.
|
|
||||||
//> On exit, the array C is overwritten by the m by n matrix
|
|
||||||
//> ( alpha*op( A )*op( B ) + beta*C ).
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDC
|
|
||||||
//> \verbatim
|
|
||||||
//> LDC is INTEGER
|
|
||||||
//> On entry, LDC specifies the first dimension of C as declared
|
|
||||||
//> in the calling (sub) program. LDC must be at least
|
|
||||||
//> max( 1, m ).
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date December 2016
|
|
||||||
//
|
|
||||||
//> \ingroup single_blas_level3
|
|
||||||
//
|
|
||||||
//> \par Further Details:
|
|
||||||
// =====================
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> Level 3 Blas routine.
|
|
||||||
//>
|
|
||||||
//> -- Written on 8-February-1989.
|
|
||||||
//> Jack Dongarra, Argonne National Laboratory.
|
|
||||||
//> Iain Duff, AERE Harwell.
|
|
||||||
//> Jeremy Du Croz, Numerical Algorithms Group Ltd.
|
|
||||||
//> Sven Hammarling, Numerical Algorithms Group Ltd.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
// =====================================================================
|
|
||||||
/* Subroutine */ int sgemm_(char *transa, char *transb, int *m, int *n, int *
|
|
||||||
k, float *alpha, float *a, int *lda, float *b, int *ldb, float *beta,
|
|
||||||
float *c__, int *ldc)
|
|
||||||
{
|
|
||||||
// System generated locals
|
|
||||||
int a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, i__1, i__2,
|
|
||||||
i__3;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int i__, j, l, info;
|
|
||||||
int nota, notb;
|
|
||||||
float temp;
|
|
||||||
int ncola;
|
|
||||||
extern int lsame_(char *, char *);
|
|
||||||
int nrowa, nrowb;
|
|
||||||
extern /* Subroutine */ int xerbla_(char *, int *);
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- Reference BLAS level3 routine (version 3.7.0) --
|
|
||||||
// -- Reference BLAS is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// December 2016
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. External Functions ..
|
|
||||||
// ..
|
|
||||||
// .. External Subroutines ..
|
|
||||||
// ..
|
|
||||||
// .. Intrinsic Functions ..
|
|
||||||
// ..
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// .. Parameters ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// Set NOTA and NOTB as true if A and B respectively are not
|
|
||||||
// transposed and set NROWA, NCOLA and NROWB as the number of rows
|
|
||||||
// and columns of A and the number of rows of B respectively.
|
|
||||||
//
|
|
||||||
// Parameter adjustments
|
|
||||||
a_dim1 = *lda;
|
|
||||||
a_offset = 1 + a_dim1;
|
|
||||||
a -= a_offset;
|
|
||||||
b_dim1 = *ldb;
|
|
||||||
b_offset = 1 + b_dim1;
|
|
||||||
b -= b_offset;
|
|
||||||
c_dim1 = *ldc;
|
|
||||||
c_offset = 1 + c_dim1;
|
|
||||||
c__ -= c_offset;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
nota = lsame_(transa, "N");
|
|
||||||
notb = lsame_(transb, "N");
|
|
||||||
if (nota) {
|
|
||||||
nrowa = *m;
|
|
||||||
ncola = *k;
|
|
||||||
} else {
|
|
||||||
nrowa = *k;
|
|
||||||
ncola = *m;
|
|
||||||
}
|
|
||||||
if (notb) {
|
|
||||||
nrowb = *k;
|
|
||||||
} else {
|
|
||||||
nrowb = *n;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Test the input parameters.
|
|
||||||
//
|
|
||||||
info = 0;
|
|
||||||
if (! nota && ! lsame_(transa, "C") && ! lsame_(transa, "T")) {
|
|
||||||
info = 1;
|
|
||||||
} else if (! notb && ! lsame_(transb, "C") && ! lsame_(transb, "T")) {
|
|
||||||
info = 2;
|
|
||||||
} else if (*m < 0) {
|
|
||||||
info = 3;
|
|
||||||
} else if (*n < 0) {
|
|
||||||
info = 4;
|
|
||||||
} else if (*k < 0) {
|
|
||||||
info = 5;
|
|
||||||
} else if (*lda < max(1,nrowa)) {
|
|
||||||
info = 8;
|
|
||||||
} else if (*ldb < max(1,nrowb)) {
|
|
||||||
info = 10;
|
|
||||||
} else if (*ldc < max(1,*m)) {
|
|
||||||
info = 13;
|
|
||||||
}
|
|
||||||
if (info != 0) {
|
|
||||||
xerbla_("SGEMM ", &info);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Quick return if possible.
|
|
||||||
//
|
|
||||||
if (*m == 0 || *n == 0 || (*alpha == 0.f || *k == 0) && *beta == 1.f) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// And if alpha.eq.zero.
|
|
||||||
//
|
|
||||||
if (*alpha == 0.f) {
|
|
||||||
if (*beta == 0.f) {
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
c__[i__ + j * c_dim1] = 0.f;
|
|
||||||
// L10:
|
|
||||||
}
|
|
||||||
// L20:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
|
|
||||||
// L30:
|
|
||||||
}
|
|
||||||
// L40:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Start the operations.
|
|
||||||
//
|
|
||||||
if (notb) {
|
|
||||||
if (nota) {
|
|
||||||
//
|
|
||||||
// Form C := alpha*A*B + beta*C.
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
if (*beta == 0.f) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
c__[i__ + j * c_dim1] = 0.f;
|
|
||||||
// L50:
|
|
||||||
}
|
|
||||||
} else if (*beta != 1.f) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
|
|
||||||
// L60:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i__2 = *k;
|
|
||||||
for (l = 1; l <= i__2; ++l) {
|
|
||||||
temp = *alpha * b[l + j * b_dim1];
|
|
||||||
i__3 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__3; ++i__) {
|
|
||||||
c__[i__ + j * c_dim1] += temp * a[i__ + l * a_dim1];
|
|
||||||
// L70:
|
|
||||||
}
|
|
||||||
// L80:
|
|
||||||
}
|
|
||||||
// L90:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Form C := alpha*A**T*B + beta*C
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
temp = 0.f;
|
|
||||||
i__3 = *k;
|
|
||||||
for (l = 1; l <= i__3; ++l) {
|
|
||||||
temp += a[l + i__ * a_dim1] * b[l + j * b_dim1];
|
|
||||||
// L100:
|
|
||||||
}
|
|
||||||
if (*beta == 0.f) {
|
|
||||||
c__[i__ + j * c_dim1] = *alpha * temp;
|
|
||||||
} else {
|
|
||||||
c__[i__ + j * c_dim1] = *alpha * temp + *beta * c__[
|
|
||||||
i__ + j * c_dim1];
|
|
||||||
}
|
|
||||||
// L110:
|
|
||||||
}
|
|
||||||
// L120:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (nota) {
|
|
||||||
//
|
|
||||||
// Form C := alpha*A*B**T + beta*C
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
if (*beta == 0.f) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
c__[i__ + j * c_dim1] = 0.f;
|
|
||||||
// L130:
|
|
||||||
}
|
|
||||||
} else if (*beta != 1.f) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
|
|
||||||
// L140:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i__2 = *k;
|
|
||||||
for (l = 1; l <= i__2; ++l) {
|
|
||||||
temp = *alpha * b[j + l * b_dim1];
|
|
||||||
i__3 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__3; ++i__) {
|
|
||||||
c__[i__ + j * c_dim1] += temp * a[i__ + l * a_dim1];
|
|
||||||
// L150:
|
|
||||||
}
|
|
||||||
// L160:
|
|
||||||
}
|
|
||||||
// L170:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Form C := alpha*A**T*B**T + beta*C
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
temp = 0.f;
|
|
||||||
i__3 = *k;
|
|
||||||
for (l = 1; l <= i__3; ++l) {
|
|
||||||
temp += a[l + i__ * a_dim1] * b[j + l * b_dim1];
|
|
||||||
// L180:
|
|
||||||
}
|
|
||||||
if (*beta == 0.f) {
|
|
||||||
c__[i__ + j * c_dim1] = *alpha * temp;
|
|
||||||
} else {
|
|
||||||
c__[i__ + j * c_dim1] = *alpha * temp + *beta * c__[
|
|
||||||
i__ + j * c_dim1];
|
|
||||||
}
|
|
||||||
// L190:
|
|
||||||
}
|
|
||||||
// L200:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
//
|
|
||||||
// End of SGEMM .
|
|
||||||
//
|
|
||||||
} // sgemm_
|
|
||||||
|
|
||||||
Vendored
-752
@@ -1,752 +0,0 @@
|
|||||||
/* -- translated by f2c (version 20201020 (for_lapack)). -- */
|
|
||||||
|
|
||||||
#include "f2c.h"
|
|
||||||
|
|
||||||
//> \brief \b ZGEMM
|
|
||||||
//
|
|
||||||
// =========== DOCUMENTATION ===========
|
|
||||||
//
|
|
||||||
// Online html documentation available at
|
|
||||||
// http://www.netlib.org/lapack/explore-html/
|
|
||||||
//
|
|
||||||
// Definition:
|
|
||||||
// ===========
|
|
||||||
//
|
|
||||||
// SUBROUTINE ZGEMM(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// COMPLEX*16 ALPHA,BETA
|
|
||||||
// INTEGER K,LDA,LDB,LDC,M,N
|
|
||||||
// CHARACTER TRANSA,TRANSB
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// COMPLEX*16 A(LDA,*),B(LDB,*),C(LDC,*)
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//> \par Purpose:
|
|
||||||
// =============
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> ZGEMM performs one of the matrix-matrix operations
|
|
||||||
//>
|
|
||||||
//> C := alpha*op( A )*op( B ) + beta*C,
|
|
||||||
//>
|
|
||||||
//> where op( X ) is one of
|
|
||||||
//>
|
|
||||||
//> op( X ) = X or op( X ) = X**T or op( X ) = X**H,
|
|
||||||
//>
|
|
||||||
//> alpha and beta are scalars, and A, B and C are matrices, with op( A )
|
|
||||||
//> an m by k matrix, op( B ) a k by n matrix and C an m by n matrix.
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// ==========
|
|
||||||
//
|
|
||||||
//> \param[in] TRANSA
|
|
||||||
//> \verbatim
|
|
||||||
//> TRANSA is CHARACTER*1
|
|
||||||
//> On entry, TRANSA specifies the form of op( A ) to be used in
|
|
||||||
//> the matrix multiplication as follows:
|
|
||||||
//>
|
|
||||||
//> TRANSA = 'N' or 'n', op( A ) = A.
|
|
||||||
//>
|
|
||||||
//> TRANSA = 'T' or 't', op( A ) = A**T.
|
|
||||||
//>
|
|
||||||
//> TRANSA = 'C' or 'c', op( A ) = A**H.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] TRANSB
|
|
||||||
//> \verbatim
|
|
||||||
//> TRANSB is CHARACTER*1
|
|
||||||
//> On entry, TRANSB specifies the form of op( B ) to be used in
|
|
||||||
//> the matrix multiplication as follows:
|
|
||||||
//>
|
|
||||||
//> TRANSB = 'N' or 'n', op( B ) = B.
|
|
||||||
//>
|
|
||||||
//> TRANSB = 'T' or 't', op( B ) = B**T.
|
|
||||||
//>
|
|
||||||
//> TRANSB = 'C' or 'c', op( B ) = B**H.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] M
|
|
||||||
//> \verbatim
|
|
||||||
//> M is INTEGER
|
|
||||||
//> On entry, M specifies the number of rows of the matrix
|
|
||||||
//> op( A ) and of the matrix C. M must be at least zero.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] N
|
|
||||||
//> \verbatim
|
|
||||||
//> N is INTEGER
|
|
||||||
//> On entry, N specifies the number of columns of the matrix
|
|
||||||
//> op( B ) and the number of columns of the matrix C. N must be
|
|
||||||
//> at least zero.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] K
|
|
||||||
//> \verbatim
|
|
||||||
//> K is INTEGER
|
|
||||||
//> On entry, K specifies the number of columns of the matrix
|
|
||||||
//> op( A ) and the number of rows of the matrix op( B ). K must
|
|
||||||
//> be at least zero.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] ALPHA
|
|
||||||
//> \verbatim
|
|
||||||
//> ALPHA is COMPLEX*16
|
|
||||||
//> On entry, ALPHA specifies the scalar alpha.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] A
|
|
||||||
//> \verbatim
|
|
||||||
//> A is COMPLEX*16 array, dimension ( LDA, ka ), where ka is
|
|
||||||
//> k when TRANSA = 'N' or 'n', and is m otherwise.
|
|
||||||
//> Before entry with TRANSA = 'N' or 'n', the leading m by k
|
|
||||||
//> part of the array A must contain the matrix A, otherwise
|
|
||||||
//> the leading k by m part of the array A must contain the
|
|
||||||
//> matrix A.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDA
|
|
||||||
//> \verbatim
|
|
||||||
//> LDA is INTEGER
|
|
||||||
//> On entry, LDA specifies the first dimension of A as declared
|
|
||||||
//> in the calling (sub) program. When TRANSA = 'N' or 'n' then
|
|
||||||
//> LDA must be at least max( 1, m ), otherwise LDA must be at
|
|
||||||
//> least max( 1, k ).
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] B
|
|
||||||
//> \verbatim
|
|
||||||
//> B is COMPLEX*16 array, dimension ( LDB, kb ), where kb is
|
|
||||||
//> n when TRANSB = 'N' or 'n', and is k otherwise.
|
|
||||||
//> Before entry with TRANSB = 'N' or 'n', the leading k by n
|
|
||||||
//> part of the array B must contain the matrix B, otherwise
|
|
||||||
//> the leading n by k part of the array B must contain the
|
|
||||||
//> matrix B.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDB
|
|
||||||
//> \verbatim
|
|
||||||
//> LDB is INTEGER
|
|
||||||
//> On entry, LDB specifies the first dimension of B as declared
|
|
||||||
//> in the calling (sub) program. When TRANSB = 'N' or 'n' then
|
|
||||||
//> LDB must be at least max( 1, k ), otherwise LDB must be at
|
|
||||||
//> least max( 1, n ).
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] BETA
|
|
||||||
//> \verbatim
|
|
||||||
//> BETA is COMPLEX*16
|
|
||||||
//> On entry, BETA specifies the scalar beta. When BETA is
|
|
||||||
//> supplied as zero then C need not be set on input.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in,out] C
|
|
||||||
//> \verbatim
|
|
||||||
//> C is COMPLEX*16 array, dimension ( LDC, N )
|
|
||||||
//> Before entry, the leading m by n part of the array C must
|
|
||||||
//> contain the matrix C, except when beta is zero, in which
|
|
||||||
//> case C need not be set on entry.
|
|
||||||
//> On exit, the array C is overwritten by the m by n matrix
|
|
||||||
//> ( alpha*op( A )*op( B ) + beta*C ).
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
//> \param[in] LDC
|
|
||||||
//> \verbatim
|
|
||||||
//> LDC is INTEGER
|
|
||||||
//> On entry, LDC specifies the first dimension of C as declared
|
|
||||||
//> in the calling (sub) program. LDC must be at least
|
|
||||||
//> max( 1, m ).
|
|
||||||
//> \endverbatim
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// ========
|
|
||||||
//
|
|
||||||
//> \author Univ. of Tennessee
|
|
||||||
//> \author Univ. of California Berkeley
|
|
||||||
//> \author Univ. of Colorado Denver
|
|
||||||
//> \author NAG Ltd.
|
|
||||||
//
|
|
||||||
//> \date December 2016
|
|
||||||
//
|
|
||||||
//> \ingroup complex16_blas_level3
|
|
||||||
//
|
|
||||||
//> \par Further Details:
|
|
||||||
// =====================
|
|
||||||
//>
|
|
||||||
//> \verbatim
|
|
||||||
//>
|
|
||||||
//> Level 3 Blas routine.
|
|
||||||
//>
|
|
||||||
//> -- Written on 8-February-1989.
|
|
||||||
//> Jack Dongarra, Argonne National Laboratory.
|
|
||||||
//> Iain Duff, AERE Harwell.
|
|
||||||
//> Jeremy Du Croz, Numerical Algorithms Group Ltd.
|
|
||||||
//> Sven Hammarling, Numerical Algorithms Group Ltd.
|
|
||||||
//> \endverbatim
|
|
||||||
//>
|
|
||||||
// =====================================================================
|
|
||||||
/* Subroutine */ int zgemm_(char *transa, char *transb, int *m, int *n, int *
|
|
||||||
k, doublecomplex *alpha, doublecomplex *a, int *lda, doublecomplex *b,
|
|
||||||
int *ldb, doublecomplex *beta, doublecomplex *c__, int *ldc)
|
|
||||||
{
|
|
||||||
// Table of constant values
|
|
||||||
doublecomplex c_b1 = {1.,0.};
|
|
||||||
doublecomplex c_b2 = {0.,0.};
|
|
||||||
|
|
||||||
// System generated locals
|
|
||||||
int a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, i__1, i__2,
|
|
||||||
i__3, i__4, i__5, i__6;
|
|
||||||
doublecomplex z__1, z__2, z__3, z__4;
|
|
||||||
|
|
||||||
// Local variables
|
|
||||||
int i__, j, l, info;
|
|
||||||
int nota, notb;
|
|
||||||
doublecomplex temp;
|
|
||||||
int conja, conjb;
|
|
||||||
int ncola;
|
|
||||||
extern int lsame_(char *, char *);
|
|
||||||
int nrowa, nrowb;
|
|
||||||
extern /* Subroutine */ int xerbla_(char *, int *);
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- Reference BLAS level3 routine (version 3.7.0) --
|
|
||||||
// -- Reference BLAS is a software package provided by Univ. of Tennessee, --
|
|
||||||
// -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
||||||
// December 2016
|
|
||||||
//
|
|
||||||
// .. Scalar Arguments ..
|
|
||||||
// ..
|
|
||||||
// .. Array Arguments ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// =====================================================================
|
|
||||||
//
|
|
||||||
// .. External Functions ..
|
|
||||||
// ..
|
|
||||||
// .. External Subroutines ..
|
|
||||||
// ..
|
|
||||||
// .. Intrinsic Functions ..
|
|
||||||
// ..
|
|
||||||
// .. Local Scalars ..
|
|
||||||
// ..
|
|
||||||
// .. Parameters ..
|
|
||||||
// ..
|
|
||||||
//
|
|
||||||
// Set NOTA and NOTB as true if A and B respectively are not
|
|
||||||
// conjugated or transposed, set CONJA and CONJB as true if A and
|
|
||||||
// B respectively are to be transposed but not conjugated and set
|
|
||||||
// NROWA, NCOLA and NROWB as the number of rows and columns of A
|
|
||||||
// and the number of rows of B respectively.
|
|
||||||
//
|
|
||||||
// Parameter adjustments
|
|
||||||
a_dim1 = *lda;
|
|
||||||
a_offset = 1 + a_dim1;
|
|
||||||
a -= a_offset;
|
|
||||||
b_dim1 = *ldb;
|
|
||||||
b_offset = 1 + b_dim1;
|
|
||||||
b -= b_offset;
|
|
||||||
c_dim1 = *ldc;
|
|
||||||
c_offset = 1 + c_dim1;
|
|
||||||
c__ -= c_offset;
|
|
||||||
|
|
||||||
// Function Body
|
|
||||||
nota = lsame_(transa, "N");
|
|
||||||
notb = lsame_(transb, "N");
|
|
||||||
conja = lsame_(transa, "C");
|
|
||||||
conjb = lsame_(transb, "C");
|
|
||||||
if (nota) {
|
|
||||||
nrowa = *m;
|
|
||||||
ncola = *k;
|
|
||||||
} else {
|
|
||||||
nrowa = *k;
|
|
||||||
ncola = *m;
|
|
||||||
}
|
|
||||||
if (notb) {
|
|
||||||
nrowb = *k;
|
|
||||||
} else {
|
|
||||||
nrowb = *n;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Test the input parameters.
|
|
||||||
//
|
|
||||||
info = 0;
|
|
||||||
if (! nota && ! conja && ! lsame_(transa, "T")) {
|
|
||||||
info = 1;
|
|
||||||
} else if (! notb && ! conjb && ! lsame_(transb, "T")) {
|
|
||||||
info = 2;
|
|
||||||
} else if (*m < 0) {
|
|
||||||
info = 3;
|
|
||||||
} else if (*n < 0) {
|
|
||||||
info = 4;
|
|
||||||
} else if (*k < 0) {
|
|
||||||
info = 5;
|
|
||||||
} else if (*lda < max(1,nrowa)) {
|
|
||||||
info = 8;
|
|
||||||
} else if (*ldb < max(1,nrowb)) {
|
|
||||||
info = 10;
|
|
||||||
} else if (*ldc < max(1,*m)) {
|
|
||||||
info = 13;
|
|
||||||
}
|
|
||||||
if (info != 0) {
|
|
||||||
xerbla_("ZGEMM ", &info);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Quick return if possible.
|
|
||||||
//
|
|
||||||
if (*m == 0 || *n == 0 || (alpha->r == 0. && alpha->i == 0. || *k == 0) &&
|
|
||||||
(beta->r == 1. && beta->i == 0.)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// And when alpha.eq.zero.
|
|
||||||
//
|
|
||||||
if (alpha->r == 0. && alpha->i == 0.) {
|
|
||||||
if (beta->r == 0. && beta->i == 0.) {
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
c__[i__3].r = 0., c__[i__3].i = 0.;
|
|
||||||
// L10:
|
|
||||||
}
|
|
||||||
// L20:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
i__4 = i__ + j * c_dim1;
|
|
||||||
z__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4].i,
|
|
||||||
z__1.i = beta->r * c__[i__4].i + beta->i * c__[
|
|
||||||
i__4].r;
|
|
||||||
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
|
|
||||||
// L30:
|
|
||||||
}
|
|
||||||
// L40:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Start the operations.
|
|
||||||
//
|
|
||||||
if (notb) {
|
|
||||||
if (nota) {
|
|
||||||
//
|
|
||||||
// Form C := alpha*A*B + beta*C.
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
if (beta->r == 0. && beta->i == 0.) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
c__[i__3].r = 0., c__[i__3].i = 0.;
|
|
||||||
// L50:
|
|
||||||
}
|
|
||||||
} else if (beta->r != 1. || beta->i != 0.) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
i__4 = i__ + j * c_dim1;
|
|
||||||
z__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
|
|
||||||
.i, z__1.i = beta->r * c__[i__4].i + beta->i *
|
|
||||||
c__[i__4].r;
|
|
||||||
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
|
|
||||||
// L60:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i__2 = *k;
|
|
||||||
for (l = 1; l <= i__2; ++l) {
|
|
||||||
i__3 = l + j * b_dim1;
|
|
||||||
z__1.r = alpha->r * b[i__3].r - alpha->i * b[i__3].i,
|
|
||||||
z__1.i = alpha->r * b[i__3].i + alpha->i * b[i__3]
|
|
||||||
.r;
|
|
||||||
temp.r = z__1.r, temp.i = z__1.i;
|
|
||||||
i__3 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__3; ++i__) {
|
|
||||||
i__4 = i__ + j * c_dim1;
|
|
||||||
i__5 = i__ + j * c_dim1;
|
|
||||||
i__6 = i__ + l * a_dim1;
|
|
||||||
z__2.r = temp.r * a[i__6].r - temp.i * a[i__6].i,
|
|
||||||
z__2.i = temp.r * a[i__6].i + temp.i * a[i__6]
|
|
||||||
.r;
|
|
||||||
z__1.r = c__[i__5].r + z__2.r, z__1.i = c__[i__5].i +
|
|
||||||
z__2.i;
|
|
||||||
c__[i__4].r = z__1.r, c__[i__4].i = z__1.i;
|
|
||||||
// L70:
|
|
||||||
}
|
|
||||||
// L80:
|
|
||||||
}
|
|
||||||
// L90:
|
|
||||||
}
|
|
||||||
} else if (conja) {
|
|
||||||
//
|
|
||||||
// Form C := alpha*A**H*B + beta*C.
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
temp.r = 0., temp.i = 0.;
|
|
||||||
i__3 = *k;
|
|
||||||
for (l = 1; l <= i__3; ++l) {
|
|
||||||
d_cnjg(&z__3, &a[l + i__ * a_dim1]);
|
|
||||||
i__4 = l + j * b_dim1;
|
|
||||||
z__2.r = z__3.r * b[i__4].r - z__3.i * b[i__4].i,
|
|
||||||
z__2.i = z__3.r * b[i__4].i + z__3.i * b[i__4]
|
|
||||||
.r;
|
|
||||||
z__1.r = temp.r + z__2.r, z__1.i = temp.i + z__2.i;
|
|
||||||
temp.r = z__1.r, temp.i = z__1.i;
|
|
||||||
// L100:
|
|
||||||
}
|
|
||||||
if (beta->r == 0. && beta->i == 0.) {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
z__1.r = alpha->r * temp.r - alpha->i * temp.i,
|
|
||||||
z__1.i = alpha->r * temp.i + alpha->i *
|
|
||||||
temp.r;
|
|
||||||
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
|
|
||||||
} else {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
z__2.r = alpha->r * temp.r - alpha->i * temp.i,
|
|
||||||
z__2.i = alpha->r * temp.i + alpha->i *
|
|
||||||
temp.r;
|
|
||||||
i__4 = i__ + j * c_dim1;
|
|
||||||
z__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
|
|
||||||
.i, z__3.i = beta->r * c__[i__4].i + beta->i *
|
|
||||||
c__[i__4].r;
|
|
||||||
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
|
|
||||||
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
|
|
||||||
}
|
|
||||||
// L110:
|
|
||||||
}
|
|
||||||
// L120:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Form C := alpha*A**T*B + beta*C
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
temp.r = 0., temp.i = 0.;
|
|
||||||
i__3 = *k;
|
|
||||||
for (l = 1; l <= i__3; ++l) {
|
|
||||||
i__4 = l + i__ * a_dim1;
|
|
||||||
i__5 = l + j * b_dim1;
|
|
||||||
z__2.r = a[i__4].r * b[i__5].r - a[i__4].i * b[i__5]
|
|
||||||
.i, z__2.i = a[i__4].r * b[i__5].i + a[i__4]
|
|
||||||
.i * b[i__5].r;
|
|
||||||
z__1.r = temp.r + z__2.r, z__1.i = temp.i + z__2.i;
|
|
||||||
temp.r = z__1.r, temp.i = z__1.i;
|
|
||||||
// L130:
|
|
||||||
}
|
|
||||||
if (beta->r == 0. && beta->i == 0.) {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
z__1.r = alpha->r * temp.r - alpha->i * temp.i,
|
|
||||||
z__1.i = alpha->r * temp.i + alpha->i *
|
|
||||||
temp.r;
|
|
||||||
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
|
|
||||||
} else {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
z__2.r = alpha->r * temp.r - alpha->i * temp.i,
|
|
||||||
z__2.i = alpha->r * temp.i + alpha->i *
|
|
||||||
temp.r;
|
|
||||||
i__4 = i__ + j * c_dim1;
|
|
||||||
z__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
|
|
||||||
.i, z__3.i = beta->r * c__[i__4].i + beta->i *
|
|
||||||
c__[i__4].r;
|
|
||||||
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
|
|
||||||
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
|
|
||||||
}
|
|
||||||
// L140:
|
|
||||||
}
|
|
||||||
// L150:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (nota) {
|
|
||||||
if (conjb) {
|
|
||||||
//
|
|
||||||
// Form C := alpha*A*B**H + beta*C.
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
if (beta->r == 0. && beta->i == 0.) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
c__[i__3].r = 0., c__[i__3].i = 0.;
|
|
||||||
// L160:
|
|
||||||
}
|
|
||||||
} else if (beta->r != 1. || beta->i != 0.) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
i__4 = i__ + j * c_dim1;
|
|
||||||
z__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
|
|
||||||
.i, z__1.i = beta->r * c__[i__4].i + beta->i *
|
|
||||||
c__[i__4].r;
|
|
||||||
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
|
|
||||||
// L170:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i__2 = *k;
|
|
||||||
for (l = 1; l <= i__2; ++l) {
|
|
||||||
d_cnjg(&z__2, &b[j + l * b_dim1]);
|
|
||||||
z__1.r = alpha->r * z__2.r - alpha->i * z__2.i, z__1.i =
|
|
||||||
alpha->r * z__2.i + alpha->i * z__2.r;
|
|
||||||
temp.r = z__1.r, temp.i = z__1.i;
|
|
||||||
i__3 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__3; ++i__) {
|
|
||||||
i__4 = i__ + j * c_dim1;
|
|
||||||
i__5 = i__ + j * c_dim1;
|
|
||||||
i__6 = i__ + l * a_dim1;
|
|
||||||
z__2.r = temp.r * a[i__6].r - temp.i * a[i__6].i,
|
|
||||||
z__2.i = temp.r * a[i__6].i + temp.i * a[i__6]
|
|
||||||
.r;
|
|
||||||
z__1.r = c__[i__5].r + z__2.r, z__1.i = c__[i__5].i +
|
|
||||||
z__2.i;
|
|
||||||
c__[i__4].r = z__1.r, c__[i__4].i = z__1.i;
|
|
||||||
// L180:
|
|
||||||
}
|
|
||||||
// L190:
|
|
||||||
}
|
|
||||||
// L200:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Form C := alpha*A*B**T + beta*C
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
if (beta->r == 0. && beta->i == 0.) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
c__[i__3].r = 0., c__[i__3].i = 0.;
|
|
||||||
// L210:
|
|
||||||
}
|
|
||||||
} else if (beta->r != 1. || beta->i != 0.) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
i__4 = i__ + j * c_dim1;
|
|
||||||
z__1.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
|
|
||||||
.i, z__1.i = beta->r * c__[i__4].i + beta->i *
|
|
||||||
c__[i__4].r;
|
|
||||||
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
|
|
||||||
// L220:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i__2 = *k;
|
|
||||||
for (l = 1; l <= i__2; ++l) {
|
|
||||||
i__3 = j + l * b_dim1;
|
|
||||||
z__1.r = alpha->r * b[i__3].r - alpha->i * b[i__3].i,
|
|
||||||
z__1.i = alpha->r * b[i__3].i + alpha->i * b[i__3]
|
|
||||||
.r;
|
|
||||||
temp.r = z__1.r, temp.i = z__1.i;
|
|
||||||
i__3 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__3; ++i__) {
|
|
||||||
i__4 = i__ + j * c_dim1;
|
|
||||||
i__5 = i__ + j * c_dim1;
|
|
||||||
i__6 = i__ + l * a_dim1;
|
|
||||||
z__2.r = temp.r * a[i__6].r - temp.i * a[i__6].i,
|
|
||||||
z__2.i = temp.r * a[i__6].i + temp.i * a[i__6]
|
|
||||||
.r;
|
|
||||||
z__1.r = c__[i__5].r + z__2.r, z__1.i = c__[i__5].i +
|
|
||||||
z__2.i;
|
|
||||||
c__[i__4].r = z__1.r, c__[i__4].i = z__1.i;
|
|
||||||
// L230:
|
|
||||||
}
|
|
||||||
// L240:
|
|
||||||
}
|
|
||||||
// L250:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (conja) {
|
|
||||||
if (conjb) {
|
|
||||||
//
|
|
||||||
// Form C := alpha*A**H*B**H + beta*C.
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
temp.r = 0., temp.i = 0.;
|
|
||||||
i__3 = *k;
|
|
||||||
for (l = 1; l <= i__3; ++l) {
|
|
||||||
d_cnjg(&z__3, &a[l + i__ * a_dim1]);
|
|
||||||
d_cnjg(&z__4, &b[j + l * b_dim1]);
|
|
||||||
z__2.r = z__3.r * z__4.r - z__3.i * z__4.i, z__2.i =
|
|
||||||
z__3.r * z__4.i + z__3.i * z__4.r;
|
|
||||||
z__1.r = temp.r + z__2.r, z__1.i = temp.i + z__2.i;
|
|
||||||
temp.r = z__1.r, temp.i = z__1.i;
|
|
||||||
// L260:
|
|
||||||
}
|
|
||||||
if (beta->r == 0. && beta->i == 0.) {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
z__1.r = alpha->r * temp.r - alpha->i * temp.i,
|
|
||||||
z__1.i = alpha->r * temp.i + alpha->i *
|
|
||||||
temp.r;
|
|
||||||
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
|
|
||||||
} else {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
z__2.r = alpha->r * temp.r - alpha->i * temp.i,
|
|
||||||
z__2.i = alpha->r * temp.i + alpha->i *
|
|
||||||
temp.r;
|
|
||||||
i__4 = i__ + j * c_dim1;
|
|
||||||
z__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
|
|
||||||
.i, z__3.i = beta->r * c__[i__4].i + beta->i *
|
|
||||||
c__[i__4].r;
|
|
||||||
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
|
|
||||||
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
|
|
||||||
}
|
|
||||||
// L270:
|
|
||||||
}
|
|
||||||
// L280:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Form C := alpha*A**H*B**T + beta*C
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
temp.r = 0., temp.i = 0.;
|
|
||||||
i__3 = *k;
|
|
||||||
for (l = 1; l <= i__3; ++l) {
|
|
||||||
d_cnjg(&z__3, &a[l + i__ * a_dim1]);
|
|
||||||
i__4 = j + l * b_dim1;
|
|
||||||
z__2.r = z__3.r * b[i__4].r - z__3.i * b[i__4].i,
|
|
||||||
z__2.i = z__3.r * b[i__4].i + z__3.i * b[i__4]
|
|
||||||
.r;
|
|
||||||
z__1.r = temp.r + z__2.r, z__1.i = temp.i + z__2.i;
|
|
||||||
temp.r = z__1.r, temp.i = z__1.i;
|
|
||||||
// L290:
|
|
||||||
}
|
|
||||||
if (beta->r == 0. && beta->i == 0.) {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
z__1.r = alpha->r * temp.r - alpha->i * temp.i,
|
|
||||||
z__1.i = alpha->r * temp.i + alpha->i *
|
|
||||||
temp.r;
|
|
||||||
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
|
|
||||||
} else {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
z__2.r = alpha->r * temp.r - alpha->i * temp.i,
|
|
||||||
z__2.i = alpha->r * temp.i + alpha->i *
|
|
||||||
temp.r;
|
|
||||||
i__4 = i__ + j * c_dim1;
|
|
||||||
z__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
|
|
||||||
.i, z__3.i = beta->r * c__[i__4].i + beta->i *
|
|
||||||
c__[i__4].r;
|
|
||||||
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
|
|
||||||
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
|
|
||||||
}
|
|
||||||
// L300:
|
|
||||||
}
|
|
||||||
// L310:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (conjb) {
|
|
||||||
//
|
|
||||||
// Form C := alpha*A**T*B**H + beta*C
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
temp.r = 0., temp.i = 0.;
|
|
||||||
i__3 = *k;
|
|
||||||
for (l = 1; l <= i__3; ++l) {
|
|
||||||
i__4 = l + i__ * a_dim1;
|
|
||||||
d_cnjg(&z__3, &b[j + l * b_dim1]);
|
|
||||||
z__2.r = a[i__4].r * z__3.r - a[i__4].i * z__3.i,
|
|
||||||
z__2.i = a[i__4].r * z__3.i + a[i__4].i *
|
|
||||||
z__3.r;
|
|
||||||
z__1.r = temp.r + z__2.r, z__1.i = temp.i + z__2.i;
|
|
||||||
temp.r = z__1.r, temp.i = z__1.i;
|
|
||||||
// L320:
|
|
||||||
}
|
|
||||||
if (beta->r == 0. && beta->i == 0.) {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
z__1.r = alpha->r * temp.r - alpha->i * temp.i,
|
|
||||||
z__1.i = alpha->r * temp.i + alpha->i *
|
|
||||||
temp.r;
|
|
||||||
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
|
|
||||||
} else {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
z__2.r = alpha->r * temp.r - alpha->i * temp.i,
|
|
||||||
z__2.i = alpha->r * temp.i + alpha->i *
|
|
||||||
temp.r;
|
|
||||||
i__4 = i__ + j * c_dim1;
|
|
||||||
z__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
|
|
||||||
.i, z__3.i = beta->r * c__[i__4].i + beta->i *
|
|
||||||
c__[i__4].r;
|
|
||||||
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
|
|
||||||
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
|
|
||||||
}
|
|
||||||
// L330:
|
|
||||||
}
|
|
||||||
// L340:
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Form C := alpha*A**T*B**T + beta*C
|
|
||||||
//
|
|
||||||
i__1 = *n;
|
|
||||||
for (j = 1; j <= i__1; ++j) {
|
|
||||||
i__2 = *m;
|
|
||||||
for (i__ = 1; i__ <= i__2; ++i__) {
|
|
||||||
temp.r = 0., temp.i = 0.;
|
|
||||||
i__3 = *k;
|
|
||||||
for (l = 1; l <= i__3; ++l) {
|
|
||||||
i__4 = l + i__ * a_dim1;
|
|
||||||
i__5 = j + l * b_dim1;
|
|
||||||
z__2.r = a[i__4].r * b[i__5].r - a[i__4].i * b[i__5]
|
|
||||||
.i, z__2.i = a[i__4].r * b[i__5].i + a[i__4]
|
|
||||||
.i * b[i__5].r;
|
|
||||||
z__1.r = temp.r + z__2.r, z__1.i = temp.i + z__2.i;
|
|
||||||
temp.r = z__1.r, temp.i = z__1.i;
|
|
||||||
// L350:
|
|
||||||
}
|
|
||||||
if (beta->r == 0. && beta->i == 0.) {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
z__1.r = alpha->r * temp.r - alpha->i * temp.i,
|
|
||||||
z__1.i = alpha->r * temp.i + alpha->i *
|
|
||||||
temp.r;
|
|
||||||
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
|
|
||||||
} else {
|
|
||||||
i__3 = i__ + j * c_dim1;
|
|
||||||
z__2.r = alpha->r * temp.r - alpha->i * temp.i,
|
|
||||||
z__2.i = alpha->r * temp.i + alpha->i *
|
|
||||||
temp.r;
|
|
||||||
i__4 = i__ + j * c_dim1;
|
|
||||||
z__3.r = beta->r * c__[i__4].r - beta->i * c__[i__4]
|
|
||||||
.i, z__3.i = beta->r * c__[i__4].i + beta->i *
|
|
||||||
c__[i__4].r;
|
|
||||||
z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
|
|
||||||
c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
|
|
||||||
}
|
|
||||||
// L360:
|
|
||||||
}
|
|
||||||
// L370:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
//
|
|
||||||
// End of ZGEMM .
|
|
||||||
//
|
|
||||||
} // zgemm_
|
|
||||||
|
|
||||||
Vendored
-35
@@ -1,35 +0,0 @@
|
|||||||
if(NOT ANDROID)
|
|
||||||
message("cpufeatures is ANDROID project")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
ocv_update(OPENCV_CPUFEATURES_TARGET_NAME libcpufeatures)
|
|
||||||
|
|
||||||
set(CPUFEATURES_ROOT "${CMAKE_CURRENT_SOURCE_DIR}" CACHE PATH "Android cpufeatures project sources (for example, <android-ndk>/sources/android/cpufeatures)")
|
|
||||||
|
|
||||||
set(CPUFEATURES_INCLUDE_DIRS ${CPUFEATURES_ROOT} CACHE INTERNAL "")
|
|
||||||
set(CPUFEATURES_LIBRARIES "${OPENCV_CPUFEATURES_TARGET_NAME}" CACHE INTERNAL "")
|
|
||||||
|
|
||||||
if(NOT DEFINED CPUFEATURES_SOURCES)
|
|
||||||
set(CPUFEATURES_SOURCES ${CPUFEATURES_ROOT}/cpu-features.c ${CPUFEATURES_ROOT}/cpu-features.h)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include_directories(${CPUFEATURES_INCLUDE_DIRS})
|
|
||||||
add_library(${OPENCV_CPUFEATURES_TARGET_NAME} STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${CPUFEATURES_SOURCES})
|
|
||||||
|
|
||||||
set_target_properties(${OPENCV_CPUFEATURES_TARGET_NAME}
|
|
||||||
PROPERTIES OUTPUT_NAME cpufeatures
|
|
||||||
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
|
|
||||||
COMPILE_PDB_NAME cpufeatures
|
|
||||||
COMPILE_PDB_NAME_DEBUG "cpufeatures${OPENCV_DEBUG_POSTFIX}"
|
|
||||||
ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH}
|
|
||||||
)
|
|
||||||
|
|
||||||
if(ENABLE_SOLUTION_FOLDERS)
|
|
||||||
set_target_properties(${OPENCV_CPUFEATURES_TARGET_NAME} PROPERTIES FOLDER "3rdparty")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT BUILD_SHARED_LIBS)
|
|
||||||
ocv_install_target(${OPENCV_CPUFEATURES_TARGET_NAME} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev OPTIONAL)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
ocv_install_3rdparty_licenses(cpufeatures LICENSE README.md)
|
|
||||||
Vendored
-13
@@ -1,13 +0,0 @@
|
|||||||
Copyright (C) 2016 The Android Open Source Project
|
|
||||||
|
|
||||||
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.
|
|
||||||
Vendored
-4
@@ -1,4 +0,0 @@
|
|||||||
The Android NDK provides a small library named cpufeatures that your app can use at runtime to detect the target device's CPU family and the optional features it supports.
|
|
||||||
It is designed to work as-is on all official Android platform versions.
|
|
||||||
|
|
||||||
https://developer.android.com/ndk/guides/cpu-features.html
|
|
||||||
Vendored
-1332
File diff suppressed because it is too large
Load Diff
Vendored
-324
@@ -1,324 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2010 The Android Open Source Project
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
#ifndef CPU_FEATURES_H
|
|
||||||
#define CPU_FEATURES_H
|
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
__BEGIN_DECLS
|
|
||||||
|
|
||||||
/* A list of valid values returned by android_getCpuFamily().
|
|
||||||
* They describe the CPU Architecture of the current process.
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
ANDROID_CPU_FAMILY_UNKNOWN = 0,
|
|
||||||
ANDROID_CPU_FAMILY_ARM,
|
|
||||||
ANDROID_CPU_FAMILY_X86,
|
|
||||||
ANDROID_CPU_FAMILY_MIPS,
|
|
||||||
ANDROID_CPU_FAMILY_ARM64,
|
|
||||||
ANDROID_CPU_FAMILY_X86_64,
|
|
||||||
ANDROID_CPU_FAMILY_MIPS64,
|
|
||||||
|
|
||||||
ANDROID_CPU_FAMILY_MAX /* do not remove */
|
|
||||||
|
|
||||||
} AndroidCpuFamily;
|
|
||||||
|
|
||||||
/* Return the CPU family of the current process.
|
|
||||||
*
|
|
||||||
* Note that this matches the bitness of the current process. I.e. when
|
|
||||||
* running a 32-bit binary on a 64-bit capable CPU, this will return the
|
|
||||||
* 32-bit CPU family value.
|
|
||||||
*/
|
|
||||||
extern AndroidCpuFamily android_getCpuFamily(void);
|
|
||||||
|
|
||||||
/* Return a bitmap describing a set of optional CPU features that are
|
|
||||||
* supported by the current device's CPU. The exact bit-flags returned
|
|
||||||
* depend on the value returned by android_getCpuFamily(). See the
|
|
||||||
* documentation for the ANDROID_CPU_*_FEATURE_* flags below for details.
|
|
||||||
*/
|
|
||||||
extern uint64_t android_getCpuFeatures(void);
|
|
||||||
|
|
||||||
/* The list of feature flags for ANDROID_CPU_FAMILY_ARM that can be
|
|
||||||
* recognized by the library (see note below for 64-bit ARM). Value details
|
|
||||||
* are:
|
|
||||||
*
|
|
||||||
* VFPv2:
|
|
||||||
* CPU supports the VFPv2 instruction set. Many, but not all, ARMv6 CPUs
|
|
||||||
* support these instructions. VFPv2 is a subset of VFPv3 so this will
|
|
||||||
* be set whenever VFPv3 is set too.
|
|
||||||
*
|
|
||||||
* ARMv7:
|
|
||||||
* CPU supports the ARMv7-A basic instruction set.
|
|
||||||
* This feature is mandated by the 'armeabi-v7a' ABI.
|
|
||||||
*
|
|
||||||
* VFPv3:
|
|
||||||
* CPU supports the VFPv3-D16 instruction set, providing hardware FPU
|
|
||||||
* support for single and double precision floating point registers.
|
|
||||||
* Note that only 16 FPU registers are available by default, unless
|
|
||||||
* the D32 bit is set too. This feature is also mandated by the
|
|
||||||
* 'armeabi-v7a' ABI.
|
|
||||||
*
|
|
||||||
* VFP_D32:
|
|
||||||
* CPU VFP optional extension that provides 32 FPU registers,
|
|
||||||
* instead of 16. Note that ARM mandates this feature is the 'NEON'
|
|
||||||
* feature is implemented by the CPU.
|
|
||||||
*
|
|
||||||
* NEON:
|
|
||||||
* CPU FPU supports "ARM Advanced SIMD" instructions, also known as
|
|
||||||
* NEON. Note that this mandates the VFP_D32 feature as well, per the
|
|
||||||
* ARM Architecture specification.
|
|
||||||
*
|
|
||||||
* VFP_FP16:
|
|
||||||
* Half-width floating precision VFP extension. If set, the CPU
|
|
||||||
* supports instructions to perform floating-point operations on
|
|
||||||
* 16-bit registers. This is part of the VFPv4 specification, but
|
|
||||||
* not mandated by any Android ABI.
|
|
||||||
*
|
|
||||||
* VFP_FMA:
|
|
||||||
* Fused multiply-accumulate VFP instructions extension. Also part of
|
|
||||||
* the VFPv4 specification, but not mandated by any Android ABI.
|
|
||||||
*
|
|
||||||
* NEON_FMA:
|
|
||||||
* Fused multiply-accumulate NEON instructions extension. Optional
|
|
||||||
* extension from the VFPv4 specification, but not mandated by any
|
|
||||||
* Android ABI.
|
|
||||||
*
|
|
||||||
* IDIV_ARM:
|
|
||||||
* Integer division available in ARM mode. Only available
|
|
||||||
* on recent CPUs (e.g. Cortex-A15).
|
|
||||||
*
|
|
||||||
* IDIV_THUMB2:
|
|
||||||
* Integer division available in Thumb-2 mode. Only available
|
|
||||||
* on recent CPUs (e.g. Cortex-A15).
|
|
||||||
*
|
|
||||||
* iWMMXt:
|
|
||||||
* Optional extension that adds MMX registers and operations to an
|
|
||||||
* ARM CPU. This is only available on a few XScale-based CPU designs
|
|
||||||
* sold by Marvell. Pretty rare in practice.
|
|
||||||
*
|
|
||||||
* AES:
|
|
||||||
* CPU supports AES instructions. These instructions are only
|
|
||||||
* available for 32-bit applications running on ARMv8 CPU.
|
|
||||||
*
|
|
||||||
* CRC32:
|
|
||||||
* CPU supports CRC32 instructions. These instructions are only
|
|
||||||
* available for 32-bit applications running on ARMv8 CPU.
|
|
||||||
*
|
|
||||||
* SHA2:
|
|
||||||
* CPU supports SHA2 instructions. These instructions are only
|
|
||||||
* available for 32-bit applications running on ARMv8 CPU.
|
|
||||||
*
|
|
||||||
* SHA1:
|
|
||||||
* CPU supports SHA1 instructions. These instructions are only
|
|
||||||
* available for 32-bit applications running on ARMv8 CPU.
|
|
||||||
*
|
|
||||||
* PMULL:
|
|
||||||
* CPU supports 64-bit PMULL and PMULL2 instructions. These
|
|
||||||
* instructions are only available for 32-bit applications
|
|
||||||
* running on ARMv8 CPU.
|
|
||||||
*
|
|
||||||
* If you want to tell the compiler to generate code that targets one of
|
|
||||||
* the feature set above, you should probably use one of the following
|
|
||||||
* flags (for more details, see technical note at the end of this file):
|
|
||||||
*
|
|
||||||
* -mfpu=vfp
|
|
||||||
* -mfpu=vfpv2
|
|
||||||
* These are equivalent and tell GCC to use VFPv2 instructions for
|
|
||||||
* floating-point operations. Use this if you want your code to
|
|
||||||
* run on *some* ARMv6 devices, and any ARMv7-A device supported
|
|
||||||
* by Android.
|
|
||||||
*
|
|
||||||
* Generated code requires VFPv2 feature.
|
|
||||||
*
|
|
||||||
* -mfpu=vfpv3-d16
|
|
||||||
* Tell GCC to use VFPv3 instructions (using only 16 FPU registers).
|
|
||||||
* This should be generic code that runs on any CPU that supports the
|
|
||||||
* 'armeabi-v7a' Android ABI. Note that no ARMv6 CPU supports this.
|
|
||||||
*
|
|
||||||
* Generated code requires VFPv3 feature.
|
|
||||||
*
|
|
||||||
* -mfpu=vfpv3
|
|
||||||
* Tell GCC to use VFPv3 instructions with 32 FPU registers.
|
|
||||||
* Generated code requires VFPv3|VFP_D32 features.
|
|
||||||
*
|
|
||||||
* -mfpu=neon
|
|
||||||
* Tell GCC to use VFPv3 instructions with 32 FPU registers, and
|
|
||||||
* also support NEON intrinsics (see <arm_neon.h>).
|
|
||||||
* Generated code requires VFPv3|VFP_D32|NEON features.
|
|
||||||
*
|
|
||||||
* -mfpu=vfpv4-d16
|
|
||||||
* Generated code requires VFPv3|VFP_FP16|VFP_FMA features.
|
|
||||||
*
|
|
||||||
* -mfpu=vfpv4
|
|
||||||
* Generated code requires VFPv3|VFP_FP16|VFP_FMA|VFP_D32 features.
|
|
||||||
*
|
|
||||||
* -mfpu=neon-vfpv4
|
|
||||||
* Generated code requires VFPv3|VFP_FP16|VFP_FMA|VFP_D32|NEON|NEON_FMA
|
|
||||||
* features.
|
|
||||||
*
|
|
||||||
* -mcpu=cortex-a7
|
|
||||||
* -mcpu=cortex-a15
|
|
||||||
* Generated code requires VFPv3|VFP_FP16|VFP_FMA|VFP_D32|
|
|
||||||
* NEON|NEON_FMA|IDIV_ARM|IDIV_THUMB2
|
|
||||||
* This flag implies -mfpu=neon-vfpv4.
|
|
||||||
*
|
|
||||||
* -mcpu=iwmmxt
|
|
||||||
* Allows the use of iWMMXt instrinsics with GCC.
|
|
||||||
*
|
|
||||||
* IMPORTANT NOTE: These flags should only be tested when
|
|
||||||
* android_getCpuFamily() returns ANDROID_CPU_FAMILY_ARM, i.e. this is a
|
|
||||||
* 32-bit process.
|
|
||||||
*
|
|
||||||
* When running a 64-bit ARM process on an ARMv8 CPU,
|
|
||||||
* android_getCpuFeatures() will return a different set of bitflags
|
|
||||||
*/
|
|
||||||
enum {
|
|
||||||
ANDROID_CPU_ARM_FEATURE_ARMv7 = (1 << 0),
|
|
||||||
ANDROID_CPU_ARM_FEATURE_VFPv3 = (1 << 1),
|
|
||||||
ANDROID_CPU_ARM_FEATURE_NEON = (1 << 2),
|
|
||||||
ANDROID_CPU_ARM_FEATURE_LDREX_STREX = (1 << 3),
|
|
||||||
ANDROID_CPU_ARM_FEATURE_VFPv2 = (1 << 4),
|
|
||||||
ANDROID_CPU_ARM_FEATURE_VFP_D32 = (1 << 5),
|
|
||||||
ANDROID_CPU_ARM_FEATURE_VFP_FP16 = (1 << 6),
|
|
||||||
ANDROID_CPU_ARM_FEATURE_VFP_FMA = (1 << 7),
|
|
||||||
ANDROID_CPU_ARM_FEATURE_NEON_FMA = (1 << 8),
|
|
||||||
ANDROID_CPU_ARM_FEATURE_IDIV_ARM = (1 << 9),
|
|
||||||
ANDROID_CPU_ARM_FEATURE_IDIV_THUMB2 = (1 << 10),
|
|
||||||
ANDROID_CPU_ARM_FEATURE_iWMMXt = (1 << 11),
|
|
||||||
ANDROID_CPU_ARM_FEATURE_AES = (1 << 12),
|
|
||||||
ANDROID_CPU_ARM_FEATURE_PMULL = (1 << 13),
|
|
||||||
ANDROID_CPU_ARM_FEATURE_SHA1 = (1 << 14),
|
|
||||||
ANDROID_CPU_ARM_FEATURE_SHA2 = (1 << 15),
|
|
||||||
ANDROID_CPU_ARM_FEATURE_CRC32 = (1 << 16),
|
|
||||||
};
|
|
||||||
|
|
||||||
/* The bit flags corresponding to the output of android_getCpuFeatures()
|
|
||||||
* when android_getCpuFamily() returns ANDROID_CPU_FAMILY_ARM64. Value details
|
|
||||||
* are:
|
|
||||||
*
|
|
||||||
* FP:
|
|
||||||
* CPU has Floating-point unit.
|
|
||||||
*
|
|
||||||
* ASIMD:
|
|
||||||
* CPU has Advanced SIMD unit.
|
|
||||||
*
|
|
||||||
* AES:
|
|
||||||
* CPU supports AES instructions.
|
|
||||||
*
|
|
||||||
* CRC32:
|
|
||||||
* CPU supports CRC32 instructions.
|
|
||||||
*
|
|
||||||
* SHA2:
|
|
||||||
* CPU supports SHA2 instructions.
|
|
||||||
*
|
|
||||||
* SHA1:
|
|
||||||
* CPU supports SHA1 instructions.
|
|
||||||
*
|
|
||||||
* PMULL:
|
|
||||||
* CPU supports 64-bit PMULL and PMULL2 instructions.
|
|
||||||
*/
|
|
||||||
enum {
|
|
||||||
ANDROID_CPU_ARM64_FEATURE_FP = (1 << 0),
|
|
||||||
ANDROID_CPU_ARM64_FEATURE_ASIMD = (1 << 1),
|
|
||||||
ANDROID_CPU_ARM64_FEATURE_AES = (1 << 2),
|
|
||||||
ANDROID_CPU_ARM64_FEATURE_PMULL = (1 << 3),
|
|
||||||
ANDROID_CPU_ARM64_FEATURE_SHA1 = (1 << 4),
|
|
||||||
ANDROID_CPU_ARM64_FEATURE_SHA2 = (1 << 5),
|
|
||||||
ANDROID_CPU_ARM64_FEATURE_CRC32 = (1 << 6),
|
|
||||||
};
|
|
||||||
|
|
||||||
/* The bit flags corresponding to the output of android_getCpuFeatures()
|
|
||||||
* when android_getCpuFamily() returns ANDROID_CPU_FAMILY_X86 or
|
|
||||||
* ANDROID_CPU_FAMILY_X86_64.
|
|
||||||
*/
|
|
||||||
enum {
|
|
||||||
ANDROID_CPU_X86_FEATURE_SSSE3 = (1 << 0),
|
|
||||||
ANDROID_CPU_X86_FEATURE_POPCNT = (1 << 1),
|
|
||||||
ANDROID_CPU_X86_FEATURE_MOVBE = (1 << 2),
|
|
||||||
ANDROID_CPU_X86_FEATURE_SSE4_1 = (1 << 3),
|
|
||||||
ANDROID_CPU_X86_FEATURE_SSE4_2 = (1 << 4),
|
|
||||||
ANDROID_CPU_X86_FEATURE_AES_NI = (1 << 5),
|
|
||||||
ANDROID_CPU_X86_FEATURE_AVX = (1 << 6),
|
|
||||||
ANDROID_CPU_X86_FEATURE_RDRAND = (1 << 7),
|
|
||||||
ANDROID_CPU_X86_FEATURE_AVX2 = (1 << 8),
|
|
||||||
ANDROID_CPU_X86_FEATURE_SHA_NI = (1 << 9),
|
|
||||||
};
|
|
||||||
|
|
||||||
/* The bit flags corresponding to the output of android_getCpuFeatures()
|
|
||||||
* when android_getCpuFamily() returns ANDROID_CPU_FAMILY_MIPS
|
|
||||||
* or ANDROID_CPU_FAMILY_MIPS64. Values are:
|
|
||||||
*
|
|
||||||
* R6:
|
|
||||||
* CPU executes MIPS Release 6 instructions natively, and
|
|
||||||
* supports obsoleted R1..R5 instructions only via kernel traps.
|
|
||||||
*
|
|
||||||
* MSA:
|
|
||||||
* CPU supports Mips SIMD Architecture instructions.
|
|
||||||
*/
|
|
||||||
enum {
|
|
||||||
ANDROID_CPU_MIPS_FEATURE_R6 = (1 << 0),
|
|
||||||
ANDROID_CPU_MIPS_FEATURE_MSA = (1 << 1),
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/* Return the number of CPU cores detected on this device. */
|
|
||||||
extern int android_getCpuCount(void);
|
|
||||||
|
|
||||||
/* The following is used to force the CPU count and features
|
|
||||||
* mask in sandboxed processes. Under 4.1 and higher, these processes
|
|
||||||
* cannot access /proc, which is the only way to get information from
|
|
||||||
* the kernel about the current hardware (at least on ARM).
|
|
||||||
*
|
|
||||||
* It _must_ be called only once, and before any android_getCpuXXX
|
|
||||||
* function, any other case will fail.
|
|
||||||
*
|
|
||||||
* This function return 1 on success, and 0 on failure.
|
|
||||||
*/
|
|
||||||
extern int android_setCpu(int cpu_count,
|
|
||||||
uint64_t cpu_features);
|
|
||||||
|
|
||||||
#ifdef __arm__
|
|
||||||
/* Retrieve the ARM 32-bit CPUID value from the kernel.
|
|
||||||
* Note that this cannot work on sandboxed processes under 4.1 and
|
|
||||||
* higher, unless you called android_setCpuArm() before.
|
|
||||||
*/
|
|
||||||
extern uint32_t android_getCpuIdArm(void);
|
|
||||||
|
|
||||||
/* An ARM-specific variant of android_setCpu() that also allows you
|
|
||||||
* to set the ARM CPUID field.
|
|
||||||
*/
|
|
||||||
extern int android_setCpuArm(int cpu_count,
|
|
||||||
uint64_t cpu_features,
|
|
||||||
uint32_t cpu_id);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
__END_DECLS
|
|
||||||
|
|
||||||
#endif /* CPU_FEATURES_H */
|
|
||||||
Vendored
-201
@@ -1,201 +0,0 @@
|
|||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
|
||||||
the copyright owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
|
||||||
other entities that control, are controlled by, or are under common
|
|
||||||
control with that entity. For the purposes of this definition,
|
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
|
||||||
direction or management of such entity, whether by contract or
|
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
|
||||||
exercising permissions granted by this License.
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
|
||||||
including but not limited to software source code, documentation
|
|
||||||
source, and configuration files.
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
|
||||||
transformation or translation of a Source form, including but
|
|
||||||
not limited to compiled object code, generated documentation,
|
|
||||||
and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
|
||||||
Object form, made available under the License, as indicated by a
|
|
||||||
copyright notice that is included in or attached to the work
|
|
||||||
(an example is provided in the Appendix below).
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
|
||||||
form, that is based on (or derived from) the Work and for which the
|
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
|
||||||
of this License, Derivative Works shall not include works that remain
|
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
|
||||||
the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
|
||||||
the original version of the Work and any modifications or additions
|
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
|
||||||
means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems,
|
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
|
||||||
excluding communication that is conspicuously marked or otherwise
|
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
|
||||||
subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
|
||||||
Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
(except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
||||||
where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their
|
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
|
||||||
institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses
|
|
||||||
granted to You under this License for that Work shall terminate
|
|
||||||
as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
|
||||||
Derivative Works a copy of this License; and
|
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
|
||||||
stating that You changed the files; and
|
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
|
||||||
that You distribute, all copyright, patent, trademark, and
|
|
||||||
attribution notices from the Source form of the Work,
|
|
||||||
excluding those notices that do not pertain to any part of
|
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
|
||||||
distribution, then any Derivative Works that You distribute must
|
|
||||||
include a readable copy of the attribution notices contained
|
|
||||||
within such NOTICE file, excluding those notices that do not
|
|
||||||
pertain to any part of the Derivative Works, in at least one
|
|
||||||
of the following places: within a NOTICE text file distributed
|
|
||||||
as part of the Derivative Works; within the Source form or
|
|
||||||
documentation, if provided along with the Derivative Works; or,
|
|
||||||
within a display generated by the Derivative Works, if and
|
|
||||||
wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and
|
|
||||||
do not modify the License. You may add Your own attribution
|
|
||||||
notices within Derivative Works that You distribute, alongside
|
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
|
||||||
that such additional attribution notices cannot be construed
|
|
||||||
as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
|
||||||
may provide additional or different license terms and conditions
|
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
|
||||||
the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
|
||||||
this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
|
||||||
the terms of any separate license agreement you may have executed
|
|
||||||
with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
|
||||||
except as required for reasonable and customary use in describing the
|
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions
|
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
appropriateness of using or redistributing the Work and assume any
|
|
||||||
risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
|
||||||
unless required by applicable law (such as deliberate and grossly
|
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special,
|
|
||||||
incidental, or consequential damages of any character arising as a
|
|
||||||
result of this License or out of the use or inability to use the
|
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
|
||||||
other commercial damages or losses), even if such Contributor
|
|
||||||
has been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
||||||
or other liability obligations and/or rights consistent with this
|
|
||||||
License. However, in accepting such obligations, You may act only
|
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
|
||||||
defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
|
||||||
of your accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
|
||||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
||||||
replaced with your own identifying information. (Don't include
|
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
|
||||||
comment syntax for the file format. We also recommend that a
|
|
||||||
file or class name and description of purpose be included on the
|
|
||||||
same "printed page" as the copyright notice for easier
|
|
||||||
identification within third-party archives.
|
|
||||||
|
|
||||||
Copyright 2017 by Contributors
|
|
||||||
|
|
||||||
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.
|
|
||||||
-366
@@ -1,366 +0,0 @@
|
|||||||
/*!
|
|
||||||
* Copyright (c) 2017 by Contributors
|
|
||||||
* \file dlpack.h
|
|
||||||
* \brief The common header of DLPack.
|
|
||||||
*/
|
|
||||||
#ifndef DLPACK_DLPACK_H_
|
|
||||||
#define DLPACK_DLPACK_H_
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Compatibility with C++
|
|
||||||
*/
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#define DLPACK_EXTERN_C extern "C"
|
|
||||||
#else
|
|
||||||
#define DLPACK_EXTERN_C
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*! \brief The current major version of dlpack */
|
|
||||||
#define DLPACK_MAJOR_VERSION 1
|
|
||||||
|
|
||||||
/*! \brief The current minor version of dlpack */
|
|
||||||
#define DLPACK_MINOR_VERSION 1
|
|
||||||
|
|
||||||
/*! \brief DLPACK_DLL prefix for windows */
|
|
||||||
#ifdef _WIN32
|
|
||||||
#ifdef DLPACK_EXPORTS
|
|
||||||
#define DLPACK_DLL __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define DLPACK_DLL __declspec(dllimport)
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#define DLPACK_DLL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief The DLPack version.
|
|
||||||
*
|
|
||||||
* A change in major version indicates that we have changed the
|
|
||||||
* data layout of the ABI - DLManagedTensorVersioned.
|
|
||||||
*
|
|
||||||
* A change in minor version indicates that we have added new
|
|
||||||
* code, such as a new device type, but the ABI is kept the same.
|
|
||||||
*
|
|
||||||
* If an obtained DLPack tensor has a major version that disagrees
|
|
||||||
* with the version number specified in this header file
|
|
||||||
* (i.e. major != DLPACK_MAJOR_VERSION), the consumer must call the deleter
|
|
||||||
* (and it is safe to do so). It is not safe to access any other fields
|
|
||||||
* as the memory layout will have changed.
|
|
||||||
*
|
|
||||||
* In the case of a minor version mismatch, the tensor can be safely used as
|
|
||||||
* long as the consumer knows how to interpret all fields. Minor version
|
|
||||||
* updates indicate the addition of enumeration values.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
/*! \brief DLPack major version. */
|
|
||||||
uint32_t major;
|
|
||||||
/*! \brief DLPack minor version. */
|
|
||||||
uint32_t minor;
|
|
||||||
} DLPackVersion;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief The device type in DLDevice.
|
|
||||||
*/
|
|
||||||
#ifdef __cplusplus
|
|
||||||
typedef enum : int32_t {
|
|
||||||
#else
|
|
||||||
typedef enum {
|
|
||||||
#endif
|
|
||||||
/*! \brief CPU device */
|
|
||||||
kDLCPU = 1,
|
|
||||||
/*! \brief CUDA GPU device */
|
|
||||||
kDLCUDA = 2,
|
|
||||||
/*!
|
|
||||||
* \brief Pinned CUDA CPU memory by cudaMallocHost
|
|
||||||
*/
|
|
||||||
kDLCUDAHost = 3,
|
|
||||||
/*! \brief OpenCL devices. */
|
|
||||||
kDLOpenCL = 4,
|
|
||||||
/*! \brief Vulkan buffer for next generation graphics. */
|
|
||||||
kDLVulkan = 7,
|
|
||||||
/*! \brief Metal for Apple GPU. */
|
|
||||||
kDLMetal = 8,
|
|
||||||
/*! \brief Verilog simulator buffer */
|
|
||||||
kDLVPI = 9,
|
|
||||||
/*! \brief ROCm GPUs for AMD GPUs */
|
|
||||||
kDLROCM = 10,
|
|
||||||
/*!
|
|
||||||
* \brief Pinned ROCm CPU memory allocated by hipMallocHost
|
|
||||||
*/
|
|
||||||
kDLROCMHost = 11,
|
|
||||||
/*!
|
|
||||||
* \brief Reserved extension device type,
|
|
||||||
* used for quickly test extension device
|
|
||||||
* The semantics can differ depending on the implementation.
|
|
||||||
*/
|
|
||||||
kDLExtDev = 12,
|
|
||||||
/*!
|
|
||||||
* \brief CUDA managed/unified memory allocated by cudaMallocManaged
|
|
||||||
*/
|
|
||||||
kDLCUDAManaged = 13,
|
|
||||||
/*!
|
|
||||||
* \brief Unified shared memory allocated on a oneAPI non-partititioned
|
|
||||||
* device. Call to oneAPI runtime is required to determine the device
|
|
||||||
* type, the USM allocation type and the sycl context it is bound to.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
kDLOneAPI = 14,
|
|
||||||
/*! \brief GPU support for next generation WebGPU standard. */
|
|
||||||
kDLWebGPU = 15,
|
|
||||||
/*! \brief Qualcomm Hexagon DSP */
|
|
||||||
kDLHexagon = 16,
|
|
||||||
/*! \brief Microsoft MAIA devices */
|
|
||||||
kDLMAIA = 17,
|
|
||||||
} DLDeviceType;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief A Device for Tensor and operator.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
/*! \brief The device type used in the device. */
|
|
||||||
DLDeviceType device_type;
|
|
||||||
/*!
|
|
||||||
* \brief The device index.
|
|
||||||
* For vanilla CPU memory, pinned memory, or managed memory, this is set to 0.
|
|
||||||
*/
|
|
||||||
int32_t device_id;
|
|
||||||
} DLDevice;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief The type code options DLDataType.
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
/*! \brief signed integer */
|
|
||||||
kDLInt = 0U,
|
|
||||||
/*! \brief unsigned integer */
|
|
||||||
kDLUInt = 1U,
|
|
||||||
/*! \brief IEEE floating point */
|
|
||||||
kDLFloat = 2U,
|
|
||||||
/*!
|
|
||||||
* \brief Opaque handle type, reserved for testing purposes.
|
|
||||||
* Frameworks need to agree on the handle data type for the exchange to be well-defined.
|
|
||||||
*/
|
|
||||||
kDLOpaqueHandle = 3U,
|
|
||||||
/*! \brief bfloat16 */
|
|
||||||
kDLBfloat = 4U,
|
|
||||||
/*!
|
|
||||||
* \brief complex number
|
|
||||||
* (C/C++/Python layout: compact struct per complex number)
|
|
||||||
*/
|
|
||||||
kDLComplex = 5U,
|
|
||||||
/*! \brief boolean */
|
|
||||||
kDLBool = 6U,
|
|
||||||
/*! \brief FP8 data types */
|
|
||||||
kDLFloat8_e3m4 = 7U,
|
|
||||||
kDLFloat8_e4m3 = 8U,
|
|
||||||
kDLFloat8_e4m3b11fnuz = 9U,
|
|
||||||
kDLFloat8_e4m3fn = 10U,
|
|
||||||
kDLFloat8_e4m3fnuz = 11U,
|
|
||||||
kDLFloat8_e5m2 = 12U,
|
|
||||||
kDLFloat8_e5m2fnuz = 13U,
|
|
||||||
kDLFloat8_e8m0fnu = 14U,
|
|
||||||
/*! \brief FP6 data types
|
|
||||||
* Setting bits != 6 is currently unspecified, and the producer must ensure it is set
|
|
||||||
* while the consumer must stop importing if the value is unexpected.
|
|
||||||
*/
|
|
||||||
kDLFloat6_e2m3fn = 15U,
|
|
||||||
kDLFloat6_e3m2fn = 16U,
|
|
||||||
/*! \brief FP4 data types
|
|
||||||
* Setting bits != 4 is currently unspecified, and the producer must ensure it is set
|
|
||||||
* while the consumer must stop importing if the value is unexpected.
|
|
||||||
*/
|
|
||||||
kDLFloat4_e2m1fn = 17U,
|
|
||||||
} DLDataTypeCode;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief The data type the tensor can hold. The data type is assumed to follow the
|
|
||||||
* native endian-ness. An explicit error message should be raised when attempting to
|
|
||||||
* export an array with non-native endianness
|
|
||||||
*
|
|
||||||
* Examples
|
|
||||||
* - float: type_code = 2, bits = 32, lanes = 1
|
|
||||||
* - float4(vectorized 4 float): type_code = 2, bits = 32, lanes = 4
|
|
||||||
* - int8: type_code = 0, bits = 8, lanes = 1
|
|
||||||
* - std::complex<float>: type_code = 5, bits = 64, lanes = 1
|
|
||||||
* - bool: type_code = 6, bits = 8, lanes = 1 (as per common array library convention, the underlying storage size of bool is 8 bits)
|
|
||||||
* - float8_e4m3: type_code = 8, bits = 8, lanes = 1 (packed in memory)
|
|
||||||
* - float6_e3m2fn: type_code = 16, bits = 6, lanes = 1 (packed in memory)
|
|
||||||
* - float4_e2m1fn: type_code = 17, bits = 4, lanes = 1 (packed in memory)
|
|
||||||
*
|
|
||||||
* When a sub-byte type is packed, DLPack requires the data to be in little bit-endian, i.e.,
|
|
||||||
* for a packed data set D ((D >> (i * bits)) && bit_mask) stores the i-th element.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
/*!
|
|
||||||
* \brief Type code of base types.
|
|
||||||
* We keep it uint8_t instead of DLDataTypeCode for minimal memory
|
|
||||||
* footprint, but the value should be one of DLDataTypeCode enum values.
|
|
||||||
* */
|
|
||||||
uint8_t code;
|
|
||||||
/*!
|
|
||||||
* \brief Number of bits, common choices are 8, 16, 32.
|
|
||||||
*/
|
|
||||||
uint8_t bits;
|
|
||||||
/*! \brief Number of lanes in the type, used for vector types. */
|
|
||||||
uint16_t lanes;
|
|
||||||
} DLDataType;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Plain C Tensor object, does not manage memory.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
/*!
|
|
||||||
* \brief The data pointer points to the allocated data. This will be CUDA
|
|
||||||
* device pointer or cl_mem handle in OpenCL. It may be opaque on some device
|
|
||||||
* types. This pointer is always aligned to 256 bytes as in CUDA. The
|
|
||||||
* `byte_offset` field should be used to point to the beginning of the data.
|
|
||||||
*
|
|
||||||
* Note that as of Nov 2021, multiply libraries (CuPy, PyTorch, TensorFlow,
|
|
||||||
* TVM, perhaps others) do not adhere to this 256 byte aligment requirement
|
|
||||||
* on CPU/CUDA/ROCm, and always use `byte_offset=0`. This must be fixed
|
|
||||||
* (after which this note will be updated); at the moment it is recommended
|
|
||||||
* to not rely on the data pointer being correctly aligned.
|
|
||||||
*
|
|
||||||
* For given DLTensor, the size of memory required to store the contents of
|
|
||||||
* data is calculated as follows:
|
|
||||||
*
|
|
||||||
* \code{.c}
|
|
||||||
* static inline size_t GetDataSize(const DLTensor* t) {
|
|
||||||
* size_t size = 1;
|
|
||||||
* for (tvm_index_t i = 0; i < t->ndim; ++i) {
|
|
||||||
* size *= t->shape[i];
|
|
||||||
* }
|
|
||||||
* size *= (t->dtype.bits * t->dtype.lanes + 7) / 8;
|
|
||||||
* return size;
|
|
||||||
* }
|
|
||||||
* \endcode
|
|
||||||
*
|
|
||||||
* Note that if the tensor is of size zero, then the data pointer should be
|
|
||||||
* set to `NULL`.
|
|
||||||
*/
|
|
||||||
void* data;
|
|
||||||
/*! \brief The device of the tensor */
|
|
||||||
DLDevice device;
|
|
||||||
/*! \brief Number of dimensions */
|
|
||||||
int32_t ndim;
|
|
||||||
/*! \brief The data type of the pointer*/
|
|
||||||
DLDataType dtype;
|
|
||||||
/*! \brief The shape of the tensor */
|
|
||||||
int64_t* shape;
|
|
||||||
/*!
|
|
||||||
* \brief strides of the tensor (in number of elements, not bytes)
|
|
||||||
* can be NULL, indicating tensor is compact and row-majored.
|
|
||||||
*/
|
|
||||||
int64_t* strides;
|
|
||||||
/*! \brief The offset in bytes to the beginning pointer to data */
|
|
||||||
uint64_t byte_offset;
|
|
||||||
} DLTensor;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief C Tensor object, manage memory of DLTensor. This data structure is
|
|
||||||
* intended to facilitate the borrowing of DLTensor by another framework. It is
|
|
||||||
* not meant to transfer the tensor. When the borrowing framework doesn't need
|
|
||||||
* the tensor, it should call the deleter to notify the host that the resource
|
|
||||||
* is no longer needed.
|
|
||||||
*
|
|
||||||
* \note This data structure is used as Legacy DLManagedTensor
|
|
||||||
* in DLPack exchange and is deprecated after DLPack v0.8
|
|
||||||
* Use DLManagedTensorVersioned instead.
|
|
||||||
* This data structure may get renamed or deleted in future versions.
|
|
||||||
*
|
|
||||||
* \sa DLManagedTensorVersioned
|
|
||||||
*/
|
|
||||||
typedef struct DLManagedTensor {
|
|
||||||
/*! \brief DLTensor which is being memory managed */
|
|
||||||
DLTensor dl_tensor;
|
|
||||||
/*! \brief the context of the original host framework of DLManagedTensor in
|
|
||||||
* which DLManagedTensor is used in the framework. It can also be NULL.
|
|
||||||
*/
|
|
||||||
void * manager_ctx;
|
|
||||||
/*!
|
|
||||||
* \brief Destructor - this should be called
|
|
||||||
* to destruct the manager_ctx which backs the DLManagedTensor. It can be
|
|
||||||
* NULL if there is no way for the caller to provide a reasonable destructor.
|
|
||||||
* The destructor deletes the argument self as well.
|
|
||||||
*/
|
|
||||||
void (*deleter)(struct DLManagedTensor * self);
|
|
||||||
} DLManagedTensor;
|
|
||||||
|
|
||||||
// bit masks used in in the DLManagedTensorVersioned
|
|
||||||
|
|
||||||
/*! \brief bit mask to indicate that the tensor is read only. */
|
|
||||||
#define DLPACK_FLAG_BITMASK_READ_ONLY (1UL << 0UL)
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief bit mask to indicate that the tensor is a copy made by the producer.
|
|
||||||
*
|
|
||||||
* If set, the tensor is considered solely owned throughout its lifetime by the
|
|
||||||
* consumer, until the producer-provided deleter is invoked.
|
|
||||||
*/
|
|
||||||
#define DLPACK_FLAG_BITMASK_IS_COPIED (1UL << 1UL)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* \brief bit mask to indicate that whether a sub-byte type is packed or padded.
|
|
||||||
*
|
|
||||||
* The default for sub-byte types (ex: fp4/fp6) is assumed packed. This flag can
|
|
||||||
* be set by the producer to signal that a tensor of sub-byte type is padded.
|
|
||||||
*/
|
|
||||||
#define DLPACK_FLAG_BITMASK_IS_SUBBYTE_TYPE_PADDED (1UL << 2UL)
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief A versioned and managed C Tensor object, manage memory of DLTensor.
|
|
||||||
*
|
|
||||||
* This data structure is intended to facilitate the borrowing of DLTensor by
|
|
||||||
* another framework. It is not meant to transfer the tensor. When the borrowing
|
|
||||||
* framework doesn't need the tensor, it should call the deleter to notify the
|
|
||||||
* host that the resource is no longer needed.
|
|
||||||
*
|
|
||||||
* \note This is the current standard DLPack exchange data structure.
|
|
||||||
*/
|
|
||||||
struct DLManagedTensorVersioned {
|
|
||||||
/*!
|
|
||||||
* \brief The API and ABI version of the current managed Tensor
|
|
||||||
*/
|
|
||||||
DLPackVersion version;
|
|
||||||
/*!
|
|
||||||
* \brief the context of the original host framework.
|
|
||||||
*
|
|
||||||
* Stores DLManagedTensorVersioned is used in the
|
|
||||||
* framework. It can also be NULL.
|
|
||||||
*/
|
|
||||||
void *manager_ctx;
|
|
||||||
/*!
|
|
||||||
* \brief Destructor.
|
|
||||||
*
|
|
||||||
* This should be called to destruct manager_ctx which holds the DLManagedTensorVersioned.
|
|
||||||
* It can be NULL if there is no way for the caller to provide a reasonable
|
|
||||||
* destructor. The destructor deletes the argument self as well.
|
|
||||||
*/
|
|
||||||
void (*deleter)(struct DLManagedTensorVersioned *self);
|
|
||||||
/*!
|
|
||||||
* \brief Additional bitmask flags information about the tensor.
|
|
||||||
*
|
|
||||||
* By default the flags should be set to 0.
|
|
||||||
*
|
|
||||||
* \note Future ABI changes should keep everything until this field
|
|
||||||
* stable, to ensure that deleter can be correctly called.
|
|
||||||
*
|
|
||||||
* \sa DLPACK_FLAG_BITMASK_READ_ONLY
|
|
||||||
* \sa DLPACK_FLAG_BITMASK_IS_COPIED
|
|
||||||
*/
|
|
||||||
uint64_t flags;
|
|
||||||
/*! \brief DLTensor which is being memory managed */
|
|
||||||
DLTensor dl_tensor;
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
} // DLPACK_EXTERN_C
|
|
||||||
#endif
|
|
||||||
#endif // DLPACK_DLPACK_H_
|
|
||||||
Vendored
-44
@@ -1,44 +0,0 @@
|
|||||||
function(download_fastcv root_dir)
|
|
||||||
|
|
||||||
# Commit SHA in the opencv_3rdparty repo
|
|
||||||
set(FASTCV_COMMIT "9e8d42b6d7e769548d70b2e5674e263b056de8b4")
|
|
||||||
|
|
||||||
# Define actual FastCV versions
|
|
||||||
if(ANDROID)
|
|
||||||
if(AARCH64)
|
|
||||||
message(STATUS "Download FastCV for Android aarch64")
|
|
||||||
set(FCV_PACKAGE_NAME "fastcv_android_aarch64_2025_07_09.tgz")
|
|
||||||
set(FCV_PACKAGE_HASH "8b9497858cf3c3502a0be4369d06ebf8")
|
|
||||||
else()
|
|
||||||
message(STATUS "Download FastCV for Android armv7")
|
|
||||||
set(FCV_PACKAGE_NAME "fastcv_android_arm32_2025_07_09.tgz")
|
|
||||||
set(FCV_PACKAGE_HASH "e0e6009c9f2f2b96140cd6a639c7383f")
|
|
||||||
endif()
|
|
||||||
elseif(UNIX AND NOT APPLE AND NOT IOS AND NOT XROS)
|
|
||||||
if(AARCH64)
|
|
||||||
set(FCV_PACKAGE_NAME "fastcv_linux_aarch64_2025_07_09.tgz")
|
|
||||||
set(FCV_PACKAGE_HASH "05e254e0eb3c13fa23eb7213f0fe6d82")
|
|
||||||
else()
|
|
||||||
message("FastCV: fastcv lib for 32-bit Linux is not supported for now!")
|
|
||||||
endif()
|
|
||||||
endif(ANDROID)
|
|
||||||
|
|
||||||
# Download Package
|
|
||||||
|
|
||||||
set(OPENCV_FASTCV_URL "https://raw.githubusercontent.com/opencv/opencv_3rdparty/${FASTCV_COMMIT}/fastcv/")
|
|
||||||
|
|
||||||
ocv_download( FILENAME ${FCV_PACKAGE_NAME}
|
|
||||||
HASH ${FCV_PACKAGE_HASH}
|
|
||||||
URL ${OPENCV_FASTCV_URL}
|
|
||||||
DESTINATION_DIR ${root_dir}
|
|
||||||
ID FASTCV
|
|
||||||
STATUS res
|
|
||||||
UNPACK
|
|
||||||
RELATIVE_URL)
|
|
||||||
if(res)
|
|
||||||
set(HAVE_FASTCV TRUE CACHE BOOL "FastCV status")
|
|
||||||
else()
|
|
||||||
message(WARNING "FastCV: package download failed!")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
endfunction()
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
downloads/
|
|
||||||
*.dll
|
|
||||||
ffmpeg_version.cmake
|
|
||||||
-79
@@ -1,79 +0,0 @@
|
|||||||
$url = "https://raw.githubusercontent.com/opencv/opencv_3rdparty/@FFMPEG_BINARIES_COMMIT@/ffmpeg/opencv_videoio_ffmpeg_64.dll"
|
|
||||||
$expected_md5 = "@FFMPEG_FILE_HASH_BIN64@"
|
|
||||||
$output = "$PSScriptRoot\@OPENCV_BIN_INSTALL_PATH@\opencv_videoio_ffmpeg@OPENCV_DLLVERSION@_64.dll"
|
|
||||||
|
|
||||||
Write-Output ("=" * 120)
|
|
||||||
try {
|
|
||||||
Get-content -Path "$PSScriptRoot\@OPENCV_LICENSES_INSTALL_PATH@\ffmpeg-readme.txt" -ErrorAction 'Stop'
|
|
||||||
} catch {
|
|
||||||
Write-Output "Refer to OpenCV FFmpeg wrapper readme notes about library usage / licensing details."
|
|
||||||
}
|
|
||||||
Write-Output ("=" * 120)
|
|
||||||
Write-Output ""
|
|
||||||
|
|
||||||
if(![System.IO.File]::Exists($output)) {
|
|
||||||
try {
|
|
||||||
[io.file]::OpenWrite($output).close()
|
|
||||||
} catch {
|
|
||||||
Write-Warning "Unable to write: $output"
|
|
||||||
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
|
|
||||||
Write-Warning "Launching with 'Administrator' elevated privileges..."
|
|
||||||
Pause
|
|
||||||
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
|
|
||||||
exit
|
|
||||||
} else {
|
|
||||||
Write-Output "FATAL: Unable to write with elevated privileges: $output"
|
|
||||||
Pause
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Write-Output ("Downloading: " + $output)
|
|
||||||
Import-Module BitsTransfer
|
|
||||||
$start_time = Get-Date
|
|
||||||
Start-BitsTransfer -Source $url -Destination $output -ErrorAction 'Stop'
|
|
||||||
Write-Output "Downloaded in $((Get-Date).Subtract($start_time).Seconds) seconds"
|
|
||||||
} catch {
|
|
||||||
$_ # Dump error
|
|
||||||
try {
|
|
||||||
Write-Output ("Downloading (second attempt): " + $output)
|
|
||||||
$start_time = Get-Date
|
|
||||||
Invoke-WebRequest -Uri $url -OutFile $output
|
|
||||||
Write-Output "Downloaded in $((Get-Date).Subtract($start_time).Seconds) seconds"
|
|
||||||
} catch {
|
|
||||||
Write-Output ("Can't download file: " + $output)
|
|
||||||
Write-Output ("URL: " + $url)
|
|
||||||
Write-Output "You need to download this file manually. Stop"
|
|
||||||
Pause
|
|
||||||
Exit
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Write-Output ("File exists: " + $output)
|
|
||||||
Write-Output ("Downloading is skipped. Remove this file and re-run this script to force downloading.")
|
|
||||||
}
|
|
||||||
|
|
||||||
if(![System.IO.File]::Exists($output)) {
|
|
||||||
Write-Output ("Destination file not found: " + $output)
|
|
||||||
Write-Output "Stop"
|
|
||||||
Pause
|
|
||||||
Exit
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
$hash = Get-FileHash $output -Algorithm MD5 -ErrorAction 'Stop'
|
|
||||||
|
|
||||||
if($hash.Hash -eq $expected_md5) {
|
|
||||||
Write-Output "MD5 check passed"
|
|
||||||
} else {
|
|
||||||
Write-Output ("MD5 : " + $hash.Hash.toLower())
|
|
||||||
Write-Output ("Expected: " + $expected_md5)
|
|
||||||
Write-Output "MD5 hash mismatch"
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
$_ # Dump error
|
|
||||||
Write-Output "Can't check MD5 hash (requires PowerShell 4+)"
|
|
||||||
}
|
|
||||||
Pause
|
|
||||||
Write-Output "Exit"
|
|
||||||
Vendored
-44
@@ -1,44 +0,0 @@
|
|||||||
# Binaries branch name: ffmpeg/5.x_20260602
|
|
||||||
# Binaries were created for OpenCV: a0a660fcb1e58a295e6caa6aee64ed4d369b0181
|
|
||||||
ocv_update(FFMPEG_BINARIES_COMMIT "06dc20cad65dc7fcf784f70c95d46750520889a7")
|
|
||||||
ocv_update(FFMPEG_FILE_HASH_BIN32 "9cef7a78b6f7ec8cf1a3935c058cfac5")
|
|
||||||
ocv_update(FFMPEG_FILE_HASH_BIN64 "a821a1135251859655090c795af05789")
|
|
||||||
ocv_update(FFMPEG_FILE_HASH_CMAKE "e09efc33312d1173be8a9446f3b088fe")
|
|
||||||
|
|
||||||
function(download_win_ffmpeg script_var)
|
|
||||||
set(${script_var} "" PARENT_SCOPE)
|
|
||||||
|
|
||||||
set(ids BIN32 BIN64 CMAKE)
|
|
||||||
set(name_BIN32 "opencv_videoio_ffmpeg.dll")
|
|
||||||
set(name_BIN64 "opencv_videoio_ffmpeg_64.dll")
|
|
||||||
set(name_CMAKE "ffmpeg_version.cmake")
|
|
||||||
|
|
||||||
set(FFMPEG_DOWNLOAD_DIR "${OpenCV_BINARY_DIR}/3rdparty/ffmpeg")
|
|
||||||
|
|
||||||
set(status TRUE)
|
|
||||||
foreach(id ${ids})
|
|
||||||
ocv_download(FILENAME ${name_${id}}
|
|
||||||
HASH ${FFMPEG_FILE_HASH_${id}}
|
|
||||||
URL
|
|
||||||
"$ENV{OPENCV_FFMPEG_URL}"
|
|
||||||
"${OPENCV_FFMPEG_URL}"
|
|
||||||
"https://raw.githubusercontent.com/opencv/opencv_3rdparty/${FFMPEG_BINARIES_COMMIT}/ffmpeg/"
|
|
||||||
DESTINATION_DIR ${FFMPEG_DOWNLOAD_DIR}
|
|
||||||
ID FFMPEG
|
|
||||||
RELATIVE_URL
|
|
||||||
STATUS res)
|
|
||||||
if(NOT res)
|
|
||||||
set(status FALSE)
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
if(status)
|
|
||||||
set(${script_var} "${FFMPEG_DOWNLOAD_DIR}/ffmpeg_version.cmake" PARENT_SCOPE)
|
|
||||||
endif()
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
if(OPENCV_INSTALL_FFMPEG_DOWNLOAD_SCRIPT)
|
|
||||||
configure_file("${CMAKE_CURRENT_LIST_DIR}/ffmpeg-download.ps1.in" "${CMAKE_BINARY_DIR}/win-install/ffmpeg-download.ps1" @ONLY)
|
|
||||||
install(FILES "${CMAKE_BINARY_DIR}/win-install/ffmpeg-download.ps1" DESTINATION "." COMPONENT libs)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
ocv_install_3rdparty_licenses(ffmpeg license.txt readme.txt)
|
|
||||||
Vendored
+11
@@ -0,0 +1,11 @@
|
|||||||
|
set(FFMPEG_libavcodec_FOUND 1)
|
||||||
|
set(FFMPEG_libavformat_FOUND 1)
|
||||||
|
set(FFMPEG_libavutil_FOUND 1)
|
||||||
|
set(FFMPEG_libswscale_FOUND 1)
|
||||||
|
set(FFMPEG_libavresample_FOUND 1)
|
||||||
|
|
||||||
|
set(FFMPEG_libavcodec_VERSION 55.18.102)
|
||||||
|
set(FFMPEG_libavformat_VERSION 55.12.100)
|
||||||
|
set(FFMPEG_libavutil_VERSION 52.38.100)
|
||||||
|
set(FFMPEG_libswscale_VERSION 2.3.100)
|
||||||
|
set(FFMPEG_libavresample_VERSION 1.0.1)
|
||||||
Vendored
+1
@@ -0,0 +1 @@
|
|||||||
|
#include "cap_ffmpeg_impl.hpp"
|
||||||
Vendored
-520
@@ -1,520 +0,0 @@
|
|||||||
Copyright (C) 2001 Fabrice Bellard
|
|
||||||
|
|
||||||
FFmpeg is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
FFmpeg is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with FFmpeg; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
|
|
||||||
==================================================================================
|
|
||||||
|
|
||||||
GNU LESSER GENERAL PUBLIC LICENSE
|
|
||||||
Version 2.1, February 1999
|
|
||||||
|
|
||||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
|
||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
[This is the first released version of the Lesser GPL. It also counts
|
|
||||||
as the successor of the GNU Library Public License, version 2, hence
|
|
||||||
the version number 2.1.]
|
|
||||||
|
|
||||||
Preamble
|
|
||||||
|
|
||||||
The licenses for most software are designed to take away your
|
|
||||||
freedom to share and change it. By contrast, the GNU General Public
|
|
||||||
Licenses are intended to guarantee your freedom to share and change
|
|
||||||
free software--to make sure the software is free for all its users.
|
|
||||||
|
|
||||||
This license, the Lesser General Public License, applies to some
|
|
||||||
specially designated software packages--typically libraries--of the
|
|
||||||
Free Software Foundation and other authors who decide to use it. You
|
|
||||||
can use it too, but we suggest you first think carefully about whether
|
|
||||||
this license or the ordinary General Public License is the better
|
|
||||||
strategy to use in any particular case, based on the explanations below.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom of use,
|
|
||||||
not price. Our General Public Licenses are designed to make sure that
|
|
||||||
you have the freedom to distribute copies of free software (and charge
|
|
||||||
for this service if you wish); that you receive source code or can get
|
|
||||||
it if you want it; that you can change the software and use pieces of
|
|
||||||
it in new free programs; and that you are informed that you can do
|
|
||||||
these things.
|
|
||||||
|
|
||||||
To protect your rights, we need to make restrictions that forbid
|
|
||||||
distributors to deny you these rights or to ask you to surrender these
|
|
||||||
rights. These restrictions translate to certain responsibilities for
|
|
||||||
you if you distribute copies of the library or if you modify it.
|
|
||||||
|
|
||||||
For example, if you distribute copies of the library, whether gratis
|
|
||||||
or for a fee, you must give the recipients all the rights that we gave
|
|
||||||
you. You must make sure that they, too, receive or can get the source
|
|
||||||
code. If you link other code with the library, you must provide
|
|
||||||
complete object files to the recipients, so that they can relink them
|
|
||||||
with the library after making changes to the library and recompiling
|
|
||||||
it. And you must show them these terms so they know their rights.
|
|
||||||
|
|
||||||
We protect your rights with a two-step method: (1) we copyright the
|
|
||||||
library, and (2) we offer you this license, which gives you legal
|
|
||||||
permission to copy, distribute and/or modify the library.
|
|
||||||
|
|
||||||
To protect each distributor, we want to make it very clear that
|
|
||||||
there is no warranty for the free library. Also, if the library is
|
|
||||||
modified by someone else and passed on, the recipients should know
|
|
||||||
that what they have is not the original version, so that the original
|
|
||||||
author's reputation will not be affected by problems that might be
|
|
||||||
introduced by others.
|
|
||||||
|
|
||||||
Finally, software patents pose a constant threat to the existence of
|
|
||||||
any free program. We wish to make sure that a company cannot
|
|
||||||
effectively restrict the users of a free program by obtaining a
|
|
||||||
restrictive license from a patent holder. Therefore, we insist that
|
|
||||||
any patent license obtained for a version of the library must be
|
|
||||||
consistent with the full freedom of use specified in this license.
|
|
||||||
|
|
||||||
Most GNU software, including some libraries, is covered by the
|
|
||||||
ordinary GNU General Public License. This license, the GNU Lesser
|
|
||||||
General Public License, applies to certain designated libraries, and
|
|
||||||
is quite different from the ordinary General Public License. We use
|
|
||||||
this license for certain libraries in order to permit linking those
|
|
||||||
libraries into non-free programs.
|
|
||||||
|
|
||||||
When a program is linked with a library, whether statically or using
|
|
||||||
a shared library, the combination of the two is legally speaking a
|
|
||||||
combined work, a derivative of the original library. The ordinary
|
|
||||||
General Public License therefore permits such linking only if the
|
|
||||||
entire combination fits its criteria of freedom. The Lesser General
|
|
||||||
Public License permits more lax criteria for linking other code with
|
|
||||||
the library.
|
|
||||||
|
|
||||||
We call this license the "Lesser" General Public License because it
|
|
||||||
does Less to protect the user's freedom than the ordinary General
|
|
||||||
Public License. It also provides other free software developers Less
|
|
||||||
of an advantage over competing non-free programs. These disadvantages
|
|
||||||
are the reason we use the ordinary General Public License for many
|
|
||||||
libraries. However, the Lesser license provides advantages in certain
|
|
||||||
special circumstances.
|
|
||||||
|
|
||||||
For example, on rare occasions, there may be a special need to
|
|
||||||
encourage the widest possible use of a certain library, so that it becomes
|
|
||||||
a de-facto standard. To achieve this, non-free programs must be
|
|
||||||
allowed to use the library. A more frequent case is that a free
|
|
||||||
library does the same job as widely used non-free libraries. In this
|
|
||||||
case, there is little to gain by limiting the free library to free
|
|
||||||
software only, so we use the Lesser General Public License.
|
|
||||||
|
|
||||||
In other cases, permission to use a particular library in non-free
|
|
||||||
programs enables a greater number of people to use a large body of
|
|
||||||
free software. For example, permission to use the GNU C Library in
|
|
||||||
non-free programs enables many more people to use the whole GNU
|
|
||||||
operating system, as well as its variant, the GNU/Linux operating
|
|
||||||
system.
|
|
||||||
|
|
||||||
Although the Lesser General Public License is Less protective of the
|
|
||||||
users' freedom, it does ensure that the user of a program that is
|
|
||||||
linked with the Library has the freedom and the wherewithal to run
|
|
||||||
that program using a modified version of the Library.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow. Pay close attention to the difference between a
|
|
||||||
"work based on the library" and a "work that uses the library". The
|
|
||||||
former contains code derived from the library, whereas the latter must
|
|
||||||
be combined with the library in order to run.
|
|
||||||
|
|
||||||
GNU LESSER GENERAL PUBLIC LICENSE
|
|
||||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
||||||
|
|
||||||
0. This License Agreement applies to any software library or other
|
|
||||||
program which contains a notice placed by the copyright holder or
|
|
||||||
other authorized party saying it may be distributed under the terms of
|
|
||||||
this Lesser General Public License (also called "this License").
|
|
||||||
Each licensee is addressed as "you".
|
|
||||||
|
|
||||||
A "library" means a collection of software functions and/or data
|
|
||||||
prepared so as to be conveniently linked with application programs
|
|
||||||
(which use some of those functions and data) to form executables.
|
|
||||||
|
|
||||||
The "Library", below, refers to any such software library or work
|
|
||||||
which has been distributed under these terms. A "work based on the
|
|
||||||
Library" means either the Library or any derivative work under
|
|
||||||
copyright law: that is to say, a work containing the Library or a
|
|
||||||
portion of it, either verbatim or with modifications and/or translated
|
|
||||||
straightforwardly into another language. (Hereinafter, translation is
|
|
||||||
included without limitation in the term "modification".)
|
|
||||||
|
|
||||||
"Source code" for a work means the preferred form of the work for
|
|
||||||
making modifications to it. For a library, complete source code means
|
|
||||||
all the source code for all modules it contains, plus any associated
|
|
||||||
interface definition files, plus the scripts used to control compilation
|
|
||||||
and installation of the library.
|
|
||||||
|
|
||||||
Activities other than copying, distribution and modification are not
|
|
||||||
covered by this License; they are outside its scope. The act of
|
|
||||||
running a program using the Library is not restricted, and output from
|
|
||||||
such a program is covered only if its contents constitute a work based
|
|
||||||
on the Library (independent of the use of the Library in a tool for
|
|
||||||
writing it). Whether that is true depends on what the Library does
|
|
||||||
and what the program that uses the Library does.
|
|
||||||
|
|
||||||
1. You may copy and distribute verbatim copies of the Library's
|
|
||||||
complete source code as you receive it, in any medium, provided that
|
|
||||||
you conspicuously and appropriately publish on each copy an
|
|
||||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
|
||||||
all the notices that refer to this License and to the absence of any
|
|
||||||
warranty; and distribute a copy of this License along with the
|
|
||||||
Library.
|
|
||||||
|
|
||||||
You may charge a fee for the physical act of transferring a copy,
|
|
||||||
and you may at your option offer warranty protection in exchange for a
|
|
||||||
fee.
|
|
||||||
|
|
||||||
2. You may modify your copy or copies of the Library or any portion
|
|
||||||
of it, thus forming a work based on the Library, and copy and
|
|
||||||
distribute such modifications or work under the terms of Section 1
|
|
||||||
above, provided that you also meet all of these conditions:
|
|
||||||
|
|
||||||
a) The modified work must itself be a software library.
|
|
||||||
|
|
||||||
b) You must cause the files modified to carry prominent notices
|
|
||||||
stating that you changed the files and the date of any change.
|
|
||||||
|
|
||||||
c) You must cause the whole of the work to be licensed at no
|
|
||||||
charge to all third parties under the terms of this License.
|
|
||||||
|
|
||||||
d) If a facility in the modified Library refers to a function or a
|
|
||||||
table of data to be supplied by an application program that uses
|
|
||||||
the facility, other than as an argument passed when the facility
|
|
||||||
is invoked, then you must make a good faith effort to ensure that,
|
|
||||||
in the event an application does not supply such function or
|
|
||||||
table, the facility still operates, and performs whatever part of
|
|
||||||
its purpose remains meaningful.
|
|
||||||
|
|
||||||
(For example, a function in a library to compute square roots has
|
|
||||||
a purpose that is entirely well-defined independent of the
|
|
||||||
application. Therefore, Subsection 2d requires that any
|
|
||||||
application-supplied function or table used by this function must
|
|
||||||
be optional: if the application does not supply it, the square
|
|
||||||
root function must still compute square roots.)
|
|
||||||
|
|
||||||
These requirements apply to the modified work as a whole. If
|
|
||||||
identifiable sections of that work are not derived from the Library,
|
|
||||||
and can be reasonably considered independent and separate works in
|
|
||||||
themselves, then this License, and its terms, do not apply to those
|
|
||||||
sections when you distribute them as separate works. But when you
|
|
||||||
distribute the same sections as part of a whole which is a work based
|
|
||||||
on the Library, the distribution of the whole must be on the terms of
|
|
||||||
this License, whose permissions for other licensees extend to the
|
|
||||||
entire whole, and thus to each and every part regardless of who wrote
|
|
||||||
it.
|
|
||||||
|
|
||||||
Thus, it is not the intent of this section to claim rights or contest
|
|
||||||
your rights to work written entirely by you; rather, the intent is to
|
|
||||||
exercise the right to control the distribution of derivative or
|
|
||||||
collective works based on the Library.
|
|
||||||
|
|
||||||
In addition, mere aggregation of another work not based on the Library
|
|
||||||
with the Library (or with a work based on the Library) on a volume of
|
|
||||||
a storage or distribution medium does not bring the other work under
|
|
||||||
the scope of this License.
|
|
||||||
|
|
||||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
|
||||||
License instead of this License to a given copy of the Library. To do
|
|
||||||
this, you must alter all the notices that refer to this License, so
|
|
||||||
that they refer to the ordinary GNU General Public License, version 2,
|
|
||||||
instead of to this License. (If a newer version than version 2 of the
|
|
||||||
ordinary GNU General Public License has appeared, then you can specify
|
|
||||||
that version instead if you wish.) Do not make any other change in
|
|
||||||
these notices.
|
|
||||||
|
|
||||||
Once this change is made in a given copy, it is irreversible for
|
|
||||||
that copy, so the ordinary GNU General Public License applies to all
|
|
||||||
subsequent copies and derivative works made from that copy.
|
|
||||||
|
|
||||||
This option is useful when you wish to copy part of the code of
|
|
||||||
the Library into a program that is not a library.
|
|
||||||
|
|
||||||
4. You may copy and distribute the Library (or a portion or
|
|
||||||
derivative of it, under Section 2) in object code or executable form
|
|
||||||
under the terms of Sections 1 and 2 above provided that you accompany
|
|
||||||
it with the complete corresponding machine-readable source code, which
|
|
||||||
must be distributed under the terms of Sections 1 and 2 above on a
|
|
||||||
medium customarily used for software interchange.
|
|
||||||
|
|
||||||
If distribution of object code is made by offering access to copy
|
|
||||||
from a designated place, then offering equivalent access to copy the
|
|
||||||
source code from the same place satisfies the requirement to
|
|
||||||
distribute the source code, even though third parties are not
|
|
||||||
compelled to copy the source along with the object code.
|
|
||||||
|
|
||||||
5. A program that contains no derivative of any portion of the
|
|
||||||
Library, but is designed to work with the Library by being compiled or
|
|
||||||
linked with it, is called a "work that uses the Library". Such a
|
|
||||||
work, in isolation, is not a derivative work of the Library, and
|
|
||||||
therefore falls outside the scope of this License.
|
|
||||||
|
|
||||||
However, linking a "work that uses the Library" with the Library
|
|
||||||
creates an executable that is a derivative of the Library (because it
|
|
||||||
contains portions of the Library), rather than a "work that uses the
|
|
||||||
library". The executable is therefore covered by this License.
|
|
||||||
Section 6 states terms for distribution of such executables.
|
|
||||||
|
|
||||||
When a "work that uses the Library" uses material from a header file
|
|
||||||
that is part of the Library, the object code for the work may be a
|
|
||||||
derivative work of the Library even though the source code is not.
|
|
||||||
Whether this is true is especially significant if the work can be
|
|
||||||
linked without the Library, or if the work is itself a library. The
|
|
||||||
threshold for this to be true is not precisely defined by law.
|
|
||||||
|
|
||||||
If such an object file uses only numerical parameters, data
|
|
||||||
structure layouts and accessors, and small macros and small inline
|
|
||||||
functions (ten lines or less in length), then the use of the object
|
|
||||||
file is unrestricted, regardless of whether it is legally a derivative
|
|
||||||
work. (Executables containing this object code plus portions of the
|
|
||||||
Library will still fall under Section 6.)
|
|
||||||
|
|
||||||
Otherwise, if the work is a derivative of the Library, you may
|
|
||||||
distribute the object code for the work under the terms of Section 6.
|
|
||||||
Any executables containing that work also fall under Section 6,
|
|
||||||
whether or not they are linked directly with the Library itself.
|
|
||||||
|
|
||||||
6. As an exception to the Sections above, you may also combine or
|
|
||||||
link a "work that uses the Library" with the Library to produce a
|
|
||||||
work containing portions of the Library, and distribute that work
|
|
||||||
under terms of your choice, provided that the terms permit
|
|
||||||
modification of the work for the customer's own use and reverse
|
|
||||||
engineering for debugging such modifications.
|
|
||||||
|
|
||||||
You must give prominent notice with each copy of the work that the
|
|
||||||
Library is used in it and that the Library and its use are covered by
|
|
||||||
this License. You must supply a copy of this License. If the work
|
|
||||||
during execution displays copyright notices, you must include the
|
|
||||||
copyright notice for the Library among them, as well as a reference
|
|
||||||
directing the user to the copy of this License. Also, you must do one
|
|
||||||
of these things:
|
|
||||||
|
|
||||||
a) Accompany the work with the complete corresponding
|
|
||||||
machine-readable source code for the Library including whatever
|
|
||||||
changes were used in the work (which must be distributed under
|
|
||||||
Sections 1 and 2 above); and, if the work is an executable linked
|
|
||||||
with the Library, with the complete machine-readable "work that
|
|
||||||
uses the Library", as object code and/or source code, so that the
|
|
||||||
user can modify the Library and then relink to produce a modified
|
|
||||||
executable containing the modified Library. (It is understood
|
|
||||||
that the user who changes the contents of definitions files in the
|
|
||||||
Library will not necessarily be able to recompile the application
|
|
||||||
to use the modified definitions.)
|
|
||||||
|
|
||||||
b) Use a suitable shared library mechanism for linking with the
|
|
||||||
Library. A suitable mechanism is one that (1) uses at run time a
|
|
||||||
copy of the library already present on the user's computer system,
|
|
||||||
rather than copying library functions into the executable, and (2)
|
|
||||||
will operate properly with a modified version of the library, if
|
|
||||||
the user installs one, as long as the modified version is
|
|
||||||
interface-compatible with the version that the work was made with.
|
|
||||||
|
|
||||||
c) Accompany the work with a written offer, valid for at
|
|
||||||
least three years, to give the same user the materials
|
|
||||||
specified in Subsection 6a, above, for a charge no more
|
|
||||||
than the cost of performing this distribution.
|
|
||||||
|
|
||||||
d) If distribution of the work is made by offering access to copy
|
|
||||||
from a designated place, offer equivalent access to copy the above
|
|
||||||
specified materials from the same place.
|
|
||||||
|
|
||||||
e) Verify that the user has already received a copy of these
|
|
||||||
materials or that you have already sent this user a copy.
|
|
||||||
|
|
||||||
For an executable, the required form of the "work that uses the
|
|
||||||
Library" must include any data and utility programs needed for
|
|
||||||
reproducing the executable from it. However, as a special exception,
|
|
||||||
the materials to be distributed need not include anything that is
|
|
||||||
normally distributed (in either source or binary form) with the major
|
|
||||||
components (compiler, kernel, and so on) of the operating system on
|
|
||||||
which the executable runs, unless that component itself accompanies
|
|
||||||
the executable.
|
|
||||||
|
|
||||||
It may happen that this requirement contradicts the license
|
|
||||||
restrictions of other proprietary libraries that do not normally
|
|
||||||
accompany the operating system. Such a contradiction means you cannot
|
|
||||||
use both them and the Library together in an executable that you
|
|
||||||
distribute.
|
|
||||||
|
|
||||||
7. You may place library facilities that are a work based on the
|
|
||||||
Library side-by-side in a single library together with other library
|
|
||||||
facilities not covered by this License, and distribute such a combined
|
|
||||||
library, provided that the separate distribution of the work based on
|
|
||||||
the Library and of the other library facilities is otherwise
|
|
||||||
permitted, and provided that you do these two things:
|
|
||||||
|
|
||||||
a) Accompany the combined library with a copy of the same work
|
|
||||||
based on the Library, uncombined with any other library
|
|
||||||
facilities. This must be distributed under the terms of the
|
|
||||||
Sections above.
|
|
||||||
|
|
||||||
b) Give prominent notice with the combined library of the fact
|
|
||||||
that part of it is a work based on the Library, and explaining
|
|
||||||
where to find the accompanying uncombined form of the same work.
|
|
||||||
|
|
||||||
8. You may not copy, modify, sublicense, link with, or distribute
|
|
||||||
the Library except as expressly provided under this License. Any
|
|
||||||
attempt otherwise to copy, modify, sublicense, link with, or
|
|
||||||
distribute the Library is void, and will automatically terminate your
|
|
||||||
rights under this License. However, parties who have received copies,
|
|
||||||
or rights, from you under this License will not have their licenses
|
|
||||||
terminated so long as such parties remain in full compliance.
|
|
||||||
|
|
||||||
9. You are not required to accept this License, since you have not
|
|
||||||
signed it. However, nothing else grants you permission to modify or
|
|
||||||
distribute the Library or its derivative works. These actions are
|
|
||||||
prohibited by law if you do not accept this License. Therefore, by
|
|
||||||
modifying or distributing the Library (or any work based on the
|
|
||||||
Library), you indicate your acceptance of this License to do so, and
|
|
||||||
all its terms and conditions for copying, distributing or modifying
|
|
||||||
the Library or works based on it.
|
|
||||||
|
|
||||||
10. Each time you redistribute the Library (or any work based on the
|
|
||||||
Library), the recipient automatically receives a license from the
|
|
||||||
original licensor to copy, distribute, link with or modify the Library
|
|
||||||
subject to these terms and conditions. You may not impose any further
|
|
||||||
restrictions on the recipients' exercise of the rights granted herein.
|
|
||||||
You are not responsible for enforcing compliance by third parties with
|
|
||||||
this License.
|
|
||||||
|
|
||||||
11. If, as a consequence of a court judgment or allegation of patent
|
|
||||||
infringement or for any other reason (not limited to patent issues),
|
|
||||||
conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
|
||||||
excuse you from the conditions of this License. If you cannot
|
|
||||||
distribute so as to satisfy simultaneously your obligations under this
|
|
||||||
License and any other pertinent obligations, then as a consequence you
|
|
||||||
may not distribute the Library at all. For example, if a patent
|
|
||||||
license would not permit royalty-free redistribution of the Library by
|
|
||||||
all those who receive copies directly or indirectly through you, then
|
|
||||||
the only way you could satisfy both it and this License would be to
|
|
||||||
refrain entirely from distribution of the Library.
|
|
||||||
|
|
||||||
If any portion of this section is held invalid or unenforceable under any
|
|
||||||
particular circumstance, the balance of the section is intended to apply,
|
|
||||||
and the section as a whole is intended to apply in other circumstances.
|
|
||||||
|
|
||||||
It is not the purpose of this section to induce you to infringe any
|
|
||||||
patents or other property right claims or to contest validity of any
|
|
||||||
such claims; this section has the sole purpose of protecting the
|
|
||||||
integrity of the free software distribution system which is
|
|
||||||
implemented by public license practices. Many people have made
|
|
||||||
generous contributions to the wide range of software distributed
|
|
||||||
through that system in reliance on consistent application of that
|
|
||||||
system; it is up to the author/donor to decide if he or she is willing
|
|
||||||
to distribute software through any other system and a licensee cannot
|
|
||||||
impose that choice.
|
|
||||||
|
|
||||||
This section is intended to make thoroughly clear what is believed to
|
|
||||||
be a consequence of the rest of this License.
|
|
||||||
|
|
||||||
12. If the distribution and/or use of the Library is restricted in
|
|
||||||
certain countries either by patents or by copyrighted interfaces, the
|
|
||||||
original copyright holder who places the Library under this License may add
|
|
||||||
an explicit geographical distribution limitation excluding those countries,
|
|
||||||
so that distribution is permitted only in or among countries not thus
|
|
||||||
excluded. In such case, this License incorporates the limitation as if
|
|
||||||
written in the body of this License.
|
|
||||||
|
|
||||||
13. The Free Software Foundation may publish revised and/or new
|
|
||||||
versions of the Lesser General Public License from time to time.
|
|
||||||
Such new versions will be similar in spirit to the present version,
|
|
||||||
but may differ in detail to address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the Library
|
|
||||||
specifies a version number of this License which applies to it and
|
|
||||||
"any later version", you have the option of following the terms and
|
|
||||||
conditions either of that version or of any later version published by
|
|
||||||
the Free Software Foundation. If the Library does not specify a
|
|
||||||
license version number, you may choose any version ever published by
|
|
||||||
the Free Software Foundation.
|
|
||||||
|
|
||||||
14. If you wish to incorporate parts of the Library into other free
|
|
||||||
programs whose distribution conditions are incompatible with these,
|
|
||||||
write to the author to ask for permission. For software which is
|
|
||||||
copyrighted by the Free Software Foundation, write to the Free
|
|
||||||
Software Foundation; we sometimes make exceptions for this. Our
|
|
||||||
decision will be guided by the two goals of preserving the free status
|
|
||||||
of all derivatives of our free software and of promoting the sharing
|
|
||||||
and reuse of software generally.
|
|
||||||
|
|
||||||
NO WARRANTY
|
|
||||||
|
|
||||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
|
||||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
|
||||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
|
||||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
|
||||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
|
||||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
|
||||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
|
||||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
|
||||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
|
||||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
|
||||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
|
||||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
|
||||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
|
||||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
|
||||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
|
||||||
DAMAGES.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
How to Apply These Terms to Your New Libraries
|
|
||||||
|
|
||||||
If you develop a new library, and you want it to be of the greatest
|
|
||||||
possible use to the public, we recommend making it free software that
|
|
||||||
everyone can redistribute and change. You can do so by permitting
|
|
||||||
redistribution under these terms (or, alternatively, under the terms of the
|
|
||||||
ordinary General Public License).
|
|
||||||
|
|
||||||
To apply these terms, attach the following notices to the library. It is
|
|
||||||
safest to attach them to the start of each source file to most effectively
|
|
||||||
convey the exclusion of warranty; and each file should have at least the
|
|
||||||
"copyright" line and a pointer to where the full notice is found.
|
|
||||||
|
|
||||||
<one line to give the library's name and a brief idea of what it does.>
|
|
||||||
Copyright (C) <year> <name of author>
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or your
|
|
||||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
|
||||||
necessary. Here is a sample; alter the names:
|
|
||||||
|
|
||||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
|
||||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
|
||||||
|
|
||||||
<signature of Ty Coon>, 1 April 1990
|
|
||||||
Ty Coon, President of Vice
|
|
||||||
|
|
||||||
That's all there is to it!
|
|
||||||
Vendored
+2
@@ -0,0 +1,2 @@
|
|||||||
|
set path=c:\dev\msys32\bin;%path% & gcc -Wall -shared -o opencv_ffmpeg.dll -O2 -x c++ -I../include -I../include/ffmpeg_ -I../../modules/highgui/src ffopencv.c -L../lib -lavformat -lavcodec -lavdevice -lswscale -lavutil -lws2_32
|
||||||
|
set path=c:\dev\msys64\bin;%path% & gcc -m64 -Wall -shared -o opencv_ffmpeg_64.dll -O2 -x c++ -I../include -I../include/ffmpeg_ -I../../modules/highgui/src ffopencv.c -L../lib -lavformat64 -lavcodec64 -lavdevice64 -lswscale64 -lavutil64 -lws2_32
|
||||||
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
+35
-30
@@ -1,37 +1,42 @@
|
|||||||
* On Linux and other Unix flavors OpenCV uses default or user-built ffmpeg/libav libraries.
|
The build script is to be fixed.
|
||||||
If user builds ffmpeg/libav from source and wants OpenCV to stay BSD library, not GPL/LGPL,
|
Right now it assumes that 32-bit MinGW is in the system path and
|
||||||
he/she should use --enabled-shared configure flag and make sure that no GPL components are
|
64-bit mingw is installed to c:\Apps\MinGW64.
|
||||||
enabled (some notable examples are x264 (H264 encoder) and libac3 (Dolby AC3 audio codec)).
|
|
||||||
See https://www.ffmpeg.org/legal.html for details.
|
|
||||||
|
|
||||||
If you want to play very safe and do not want to use FFMPEG at all, regardless of whether it's installed on
|
It is important that gcc is used, not g++!
|
||||||
your system or not, configure and build OpenCV using CMake with WITH_FFMPEG=OFF flag. OpenCV will then use
|
Otherwise the produced DLL will likely be dependent on libgcc_s_dw2-1.dll or similar DLL.
|
||||||
AVFoundation (OSX), GStreamer (Linux) or other available backends supported by opencv_videoio module.
|
While we want to make the DLLs with minimum dependencies: Win32 libraries + msvcrt.dll.
|
||||||
|
|
||||||
There is also our self-contained motion jpeg codec, which you can use without any worries.
|
ffopencv.c is really a C++ source, hence -x c++ is used.
|
||||||
It handles CV_FOURCC('M', 'J', 'P', 'G') streams within an AVI container (".avi").
|
|
||||||
|
|
||||||
* On Windows OpenCV uses pre-built ffmpeg binaries, built with proper flags (without GPL components) and
|
How to update opencv_ffmpeg.dll and opencv_ffmpeg_64.dll when a new version of FFMPEG is release?
|
||||||
wrapped with simple, stable OpenCV-compatible API.
|
|
||||||
The binaries are opencv_videoio_ffmpeg.dll (version for 32-bit Windows) and
|
|
||||||
opencv_videoio_ffmpeg_64.dll (version for 64-bit Windows).
|
|
||||||
|
|
||||||
The pre-built opencv_videoio_ffmpeg*.dll is:
|
1. Install 32-bit MinGW + MSYS from
|
||||||
* LGPL library, not BSD libraries.
|
http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get-inst/
|
||||||
* Loaded at runtime by opencv_videoio module.
|
Let's assume, it's installed in C:\MSYS32.
|
||||||
If it succeeds, ffmpeg can be used to decode/encode videos;
|
2. Install 64-bit MinGW. http://mingw-w64.sourceforge.net/
|
||||||
otherwise, other API is used.
|
Let's assume, it's installed in C:\MSYS64
|
||||||
|
3. Copy C:\MSYS32\msys to C:\MSYS64\msys. Edit C:\MSYS64\msys\etc\fstab, change C:\MSYS32 to C:\MSYS64.
|
||||||
|
|
||||||
FFMPEG build includes support for H264 encoder based on the OpenH264 library.
|
4. Now you have working MSYS32 and MSYS64 environments.
|
||||||
OpenH264 Video Codec provided by Cisco Systems, Inc.
|
Launch, one by one, C:\MSYS32\msys\msys.bat and C:\MSYS64\msys\msys.bat to create your home directories.
|
||||||
See https://github.com/cisco/openh264/releases for details and OpenH264 license.
|
|
||||||
OpenH264 library should be installed separatelly. Downloaded binary file can be placed into global system path
|
|
||||||
(System32 or SysWOW64) or near application binaries (check documentation of "LoadLibrary" Win32 function from MSDN).
|
|
||||||
Or you can specify location of binary file via OPENH264_LIBRARY environment variable.
|
|
||||||
|
|
||||||
If LGPL/GPL software can not be supplied with your OpenCV-based product, simply exclude
|
4. Download ffmpeg-x.y.z.tar.gz (where x.y.z denotes the actual ffmpeg version).
|
||||||
opencv_videoio_ffmpeg*.dll from your distribution; OpenCV will stay fully functional except for the ability to
|
Copy it to C:\MSYS{32|64}\msys\home\<loginname> directory.
|
||||||
decode/encode videos using FFMPEG (though, it may still be able to do that using other API,
|
|
||||||
such as Video for Windows, Windows Media Foundation or our self-contained motion jpeg codec).
|
|
||||||
|
|
||||||
See license.txt for the FFMPEG copyright notice and the licensing terms.
|
5. To build 32-bit ffmpeg libraries, run C:\MSYS32\msys\msys.bat and type the following commands:
|
||||||
|
|
||||||
|
5.1. tar -xzf ffmpeg-x.y.z.tar.gz
|
||||||
|
5.2. mkdir build
|
||||||
|
5.3. cd build
|
||||||
|
5.4. ../ffmpeg-x.y.z/configure --enable-w32threads
|
||||||
|
5.5. make
|
||||||
|
5.6. make install
|
||||||
|
5.7. cd /local/lib
|
||||||
|
5.8. strip -g *.a
|
||||||
|
|
||||||
|
6. Then repeat the same for 64-bit case. The output libs: libavcodec.a etc. need to be renamed to libavcodec64.a etc.
|
||||||
|
|
||||||
|
7. Then, copy all those libs to <opencv>\3rdparty\lib\, copy the headers to <opencv>\3rdparty\include\ffmpeg_.
|
||||||
|
|
||||||
|
8. Then, go to <opencv>\3rdparty\ffmpeg, edit make.bat
|
||||||
|
(change paths to the actual paths to your msys32 and msys64 distributions) and then run make.bat
|
||||||
|
|||||||
Vendored
-202
@@ -1,202 +0,0 @@
|
|||||||
|
|
||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
|
||||||
the copyright owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
|
||||||
other entities that control, are controlled by, or are under common
|
|
||||||
control with that entity. For the purposes of this definition,
|
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
|
||||||
direction or management of such entity, whether by contract or
|
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
|
||||||
exercising permissions granted by this License.
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
|
||||||
including but not limited to software source code, documentation
|
|
||||||
source, and configuration files.
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
|
||||||
transformation or translation of a Source form, including but
|
|
||||||
not limited to compiled object code, generated documentation,
|
|
||||||
and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
|
||||||
Object form, made available under the License, as indicated by a
|
|
||||||
copyright notice that is included in or attached to the work
|
|
||||||
(an example is provided in the Appendix below).
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
|
||||||
form, that is based on (or derived from) the Work and for which the
|
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
|
||||||
of this License, Derivative Works shall not include works that remain
|
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
|
||||||
the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
|
||||||
the original version of the Work and any modifications or additions
|
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
|
||||||
means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems,
|
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
|
||||||
excluding communication that is conspicuously marked or otherwise
|
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
|
||||||
subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
|
||||||
Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
(except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
||||||
where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their
|
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
|
||||||
institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses
|
|
||||||
granted to You under this License for that Work shall terminate
|
|
||||||
as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
|
||||||
Derivative Works a copy of this License; and
|
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
|
||||||
stating that You changed the files; and
|
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
|
||||||
that You distribute, all copyright, patent, trademark, and
|
|
||||||
attribution notices from the Source form of the Work,
|
|
||||||
excluding those notices that do not pertain to any part of
|
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
|
||||||
distribution, then any Derivative Works that You distribute must
|
|
||||||
include a readable copy of the attribution notices contained
|
|
||||||
within such NOTICE file, excluding those notices that do not
|
|
||||||
pertain to any part of the Derivative Works, in at least one
|
|
||||||
of the following places: within a NOTICE text file distributed
|
|
||||||
as part of the Derivative Works; within the Source form or
|
|
||||||
documentation, if provided along with the Derivative Works; or,
|
|
||||||
within a display generated by the Derivative Works, if and
|
|
||||||
wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and
|
|
||||||
do not modify the License. You may add Your own attribution
|
|
||||||
notices within Derivative Works that You distribute, alongside
|
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
|
||||||
that such additional attribution notices cannot be construed
|
|
||||||
as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
|
||||||
may provide additional or different license terms and conditions
|
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
|
||||||
the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
|
||||||
this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
|
||||||
the terms of any separate license agreement you may have executed
|
|
||||||
with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
|
||||||
except as required for reasonable and customary use in describing the
|
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions
|
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
appropriateness of using or redistributing the Work and assume any
|
|
||||||
risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
|
||||||
unless required by applicable law (such as deliberate and grossly
|
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special,
|
|
||||||
incidental, or consequential damages of any character arising as a
|
|
||||||
result of this License or out of the use or inability to use the
|
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
|
||||||
other commercial damages or losses), even if such Contributor
|
|
||||||
has been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
||||||
or other liability obligations and/or rights consistent with this
|
|
||||||
License. However, in accepting such obligations, You may act only
|
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
|
||||||
defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
|
||||||
of your accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
|
||||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
||||||
replaced with your own identifying information. (Don't include
|
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
|
||||||
comment syntax for the file format. We also recommend that a
|
|
||||||
file or class name and description of purpose be included on the
|
|
||||||
same "printed page" as the copyright notice for easier
|
|
||||||
identification within third-party archives.
|
|
||||||
|
|
||||||
Copyright [yyyy] [name of copyright owner]
|
|
||||||
|
|
||||||
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.
|
|
||||||
Vendored
-1
@@ -1 +0,0 @@
|
|||||||
Origin: https://github.com/google/flatbuffers/tree/v25.9.23
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2021 Google Inc. All rights reserved.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLATBUFFERS_ALLOCATOR_H_
|
|
||||||
#define FLATBUFFERS_ALLOCATOR_H_
|
|
||||||
|
|
||||||
#include "flatbuffers/base.h"
|
|
||||||
|
|
||||||
namespace flatbuffers {
|
|
||||||
|
|
||||||
// Allocator interface. This is flatbuffers-specific and meant only for
|
|
||||||
// `vector_downward` usage.
|
|
||||||
class Allocator {
|
|
||||||
public:
|
|
||||||
virtual ~Allocator() {}
|
|
||||||
|
|
||||||
// Allocate `size` bytes of memory.
|
|
||||||
virtual uint8_t* allocate(size_t size) = 0;
|
|
||||||
|
|
||||||
// Deallocate `size` bytes of memory at `p` allocated by this allocator.
|
|
||||||
virtual void deallocate(uint8_t* p, size_t size) = 0;
|
|
||||||
|
|
||||||
// Reallocate `new_size` bytes of memory, replacing the old region of size
|
|
||||||
// `old_size` at `p`. In contrast to a normal realloc, this grows downwards,
|
|
||||||
// and is intended specifcally for `vector_downward` use.
|
|
||||||
// `in_use_back` and `in_use_front` indicate how much of `old_size` is
|
|
||||||
// actually in use at each end, and needs to be copied.
|
|
||||||
virtual uint8_t* reallocate_downward(uint8_t* old_p, size_t old_size,
|
|
||||||
size_t new_size, size_t in_use_back,
|
|
||||||
size_t in_use_front) {
|
|
||||||
FLATBUFFERS_ASSERT(new_size > old_size); // vector_downward only grows
|
|
||||||
uint8_t* new_p = allocate(new_size);
|
|
||||||
memcpy_downward(old_p, old_size, new_p, new_size, in_use_back,
|
|
||||||
in_use_front);
|
|
||||||
deallocate(old_p, old_size);
|
|
||||||
return new_p;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// Called by `reallocate_downward` to copy memory from `old_p` of `old_size`
|
|
||||||
// to `new_p` of `new_size`. Only memory of size `in_use_front` and
|
|
||||||
// `in_use_back` will be copied from the front and back of the old memory
|
|
||||||
// allocation.
|
|
||||||
void memcpy_downward(uint8_t* old_p, size_t old_size, uint8_t* new_p,
|
|
||||||
size_t new_size, size_t in_use_back,
|
|
||||||
size_t in_use_front) {
|
|
||||||
memcpy(new_p + new_size - in_use_back, old_p + old_size - in_use_back,
|
|
||||||
in_use_back);
|
|
||||||
memcpy(new_p, old_p, in_use_front);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace flatbuffers
|
|
||||||
|
|
||||||
#endif // FLATBUFFERS_ALLOCATOR_H_
|
|
||||||
-257
@@ -1,257 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2021 Google Inc. All rights reserved.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLATBUFFERS_ARRAY_H_
|
|
||||||
#define FLATBUFFERS_ARRAY_H_
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "flatbuffers/base.h"
|
|
||||||
#include "flatbuffers/stl_emulation.h"
|
|
||||||
#include "flatbuffers/vector.h"
|
|
||||||
|
|
||||||
namespace flatbuffers {
|
|
||||||
|
|
||||||
// This is used as a helper type for accessing arrays.
|
|
||||||
template <typename T, uint16_t length>
|
|
||||||
class Array {
|
|
||||||
// Array<T> can carry only POD data types (scalars or structs).
|
|
||||||
typedef typename flatbuffers::bool_constant<flatbuffers::is_scalar<T>::value>
|
|
||||||
scalar_tag;
|
|
||||||
|
|
||||||
public:
|
|
||||||
typedef uint16_t size_type;
|
|
||||||
typedef typename IndirectHelper<T>::return_type return_type;
|
|
||||||
typedef VectorConstIterator<T, return_type, uoffset_t> const_iterator;
|
|
||||||
typedef VectorReverseIterator<const_iterator> const_reverse_iterator;
|
|
||||||
|
|
||||||
// If T is a LE-scalar or a struct (!scalar_tag::value).
|
|
||||||
static FLATBUFFERS_CONSTEXPR bool is_span_observable =
|
|
||||||
(scalar_tag::value && (FLATBUFFERS_LITTLEENDIAN || sizeof(T) == 1)) ||
|
|
||||||
!scalar_tag::value;
|
|
||||||
|
|
||||||
FLATBUFFERS_CONSTEXPR uint16_t size() const { return length; }
|
|
||||||
|
|
||||||
return_type Get(uoffset_t i) const {
|
|
||||||
FLATBUFFERS_ASSERT(i < size());
|
|
||||||
return IndirectHelper<T>::Read(Data(), i);
|
|
||||||
}
|
|
||||||
|
|
||||||
return_type operator[](uoffset_t i) const { return Get(i); }
|
|
||||||
|
|
||||||
// If this is a Vector of enums, T will be its storage type, not the enum
|
|
||||||
// type. This function makes it convenient to retrieve value with enum
|
|
||||||
// type E.
|
|
||||||
template <typename E>
|
|
||||||
E GetEnum(uoffset_t i) const {
|
|
||||||
return static_cast<E>(Get(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
const_iterator begin() const { return const_iterator(Data(), 0); }
|
|
||||||
const_iterator end() const { return const_iterator(Data(), size()); }
|
|
||||||
|
|
||||||
const_reverse_iterator rbegin() const {
|
|
||||||
return const_reverse_iterator(end());
|
|
||||||
}
|
|
||||||
const_reverse_iterator rend() const {
|
|
||||||
return const_reverse_iterator(begin());
|
|
||||||
}
|
|
||||||
|
|
||||||
const_iterator cbegin() const { return begin(); }
|
|
||||||
const_iterator cend() const { return end(); }
|
|
||||||
|
|
||||||
const_reverse_iterator crbegin() const { return rbegin(); }
|
|
||||||
const_reverse_iterator crend() const { return rend(); }
|
|
||||||
|
|
||||||
// Get a mutable pointer to elements inside this array.
|
|
||||||
// This method used to mutate arrays of structs followed by a @p Mutate
|
|
||||||
// operation. For primitive types use @p Mutate directly.
|
|
||||||
// @warning Assignments and reads to/from the dereferenced pointer are not
|
|
||||||
// automatically converted to the correct endianness.
|
|
||||||
typename flatbuffers::conditional<scalar_tag::value, void, T*>::type
|
|
||||||
GetMutablePointer(uoffset_t i) const {
|
|
||||||
FLATBUFFERS_ASSERT(i < size());
|
|
||||||
return const_cast<T*>(&data()[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Change elements if you have a non-const pointer to this object.
|
|
||||||
void Mutate(uoffset_t i, const T& val) { MutateImpl(scalar_tag(), i, val); }
|
|
||||||
|
|
||||||
// The raw data in little endian format. Use with care.
|
|
||||||
const uint8_t* Data() const { return data_; }
|
|
||||||
|
|
||||||
uint8_t* Data() { return data_; }
|
|
||||||
|
|
||||||
// Similarly, but typed, much like std::vector::data
|
|
||||||
const T* data() const { return reinterpret_cast<const T*>(Data()); }
|
|
||||||
T* data() { return reinterpret_cast<T*>(Data()); }
|
|
||||||
|
|
||||||
// Copy data from a span with endian conversion.
|
|
||||||
// If this Array and the span overlap, the behavior is undefined.
|
|
||||||
void CopyFromSpan(flatbuffers::span<const T, length> src) {
|
|
||||||
const auto p1 = reinterpret_cast<const uint8_t*>(src.data());
|
|
||||||
const auto p2 = Data();
|
|
||||||
FLATBUFFERS_ASSERT(!(p1 >= p2 && p1 < (p2 + length)) &&
|
|
||||||
!(p2 >= p1 && p2 < (p1 + length)));
|
|
||||||
(void)p1;
|
|
||||||
(void)p2;
|
|
||||||
CopyFromSpanImpl(flatbuffers::bool_constant<is_span_observable>(), src);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void MutateImpl(flatbuffers::true_type, uoffset_t i, const T& val) {
|
|
||||||
FLATBUFFERS_ASSERT(i < size());
|
|
||||||
WriteScalar(data() + i, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MutateImpl(flatbuffers::false_type, uoffset_t i, const T& val) {
|
|
||||||
*(GetMutablePointer(i)) = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CopyFromSpanImpl(flatbuffers::true_type,
|
|
||||||
flatbuffers::span<const T, length> src) {
|
|
||||||
// Use std::memcpy() instead of std::copy() to avoid performance degradation
|
|
||||||
// due to aliasing if T is char or unsigned char.
|
|
||||||
// The size is known at compile time, so memcpy would be inlined.
|
|
||||||
std::memcpy(data(), src.data(), length * sizeof(T));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy data from flatbuffers::span with endian conversion.
|
|
||||||
void CopyFromSpanImpl(flatbuffers::false_type,
|
|
||||||
flatbuffers::span<const T, length> src) {
|
|
||||||
for (size_type k = 0; k < length; k++) {
|
|
||||||
Mutate(k, src[k]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// This class is only used to access pre-existing data. Don't ever
|
|
||||||
// try to construct these manually.
|
|
||||||
// 'constexpr' allows us to use 'size()' at compile time.
|
|
||||||
// @note Must not use 'FLATBUFFERS_CONSTEXPR' here, as const is not allowed on
|
|
||||||
// a constructor.
|
|
||||||
#if defined(__cpp_constexpr)
|
|
||||||
constexpr Array();
|
|
||||||
#else
|
|
||||||
Array();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint8_t data_[length * sizeof(T)];
|
|
||||||
|
|
||||||
private:
|
|
||||||
// This class is a pointer. Copying will therefore create an invalid object.
|
|
||||||
// Private and unimplemented copy constructor.
|
|
||||||
Array(const Array&);
|
|
||||||
Array& operator=(const Array&);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Specialization for Array[struct] with access using Offset<void> pointer.
|
|
||||||
// This specialization used by idl_gen_text.cpp.
|
|
||||||
template <typename T, uint16_t length, template <typename> class OffsetT>
|
|
||||||
class Array<OffsetT<T>, length> {
|
|
||||||
static_assert(flatbuffers::is_same<T, void>::value, "unexpected type T");
|
|
||||||
|
|
||||||
public:
|
|
||||||
typedef const void* return_type;
|
|
||||||
typedef uint16_t size_type;
|
|
||||||
|
|
||||||
const uint8_t* Data() const { return data_; }
|
|
||||||
|
|
||||||
// Make idl_gen_text.cpp::PrintContainer happy.
|
|
||||||
return_type operator[](uoffset_t) const {
|
|
||||||
FLATBUFFERS_ASSERT(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
// This class is only used to access pre-existing data.
|
|
||||||
Array();
|
|
||||||
Array(const Array&);
|
|
||||||
Array& operator=(const Array&);
|
|
||||||
|
|
||||||
uint8_t data_[1];
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class U, uint16_t N>
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<U, N> make_span(Array<U, N>& arr)
|
|
||||||
FLATBUFFERS_NOEXCEPT {
|
|
||||||
static_assert(
|
|
||||||
Array<U, N>::is_span_observable,
|
|
||||||
"wrong type U, only plain struct, LE-scalar, or byte types are allowed");
|
|
||||||
return span<U, N>(arr.data(), N);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class U, uint16_t N>
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<const U, N> make_span(
|
|
||||||
const Array<U, N>& arr) FLATBUFFERS_NOEXCEPT {
|
|
||||||
static_assert(
|
|
||||||
Array<U, N>::is_span_observable,
|
|
||||||
"wrong type U, only plain struct, LE-scalar, or byte types are allowed");
|
|
||||||
return span<const U, N>(arr.data(), N);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class U, uint16_t N>
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<uint8_t, sizeof(U) * N>
|
|
||||||
make_bytes_span(Array<U, N>& arr) FLATBUFFERS_NOEXCEPT {
|
|
||||||
static_assert(Array<U, N>::is_span_observable,
|
|
||||||
"internal error, Array<T> might hold only scalars or structs");
|
|
||||||
return span<uint8_t, sizeof(U) * N>(arr.Data(), sizeof(U) * N);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class U, uint16_t N>
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<const uint8_t, sizeof(U) * N>
|
|
||||||
make_bytes_span(const Array<U, N>& arr) FLATBUFFERS_NOEXCEPT {
|
|
||||||
static_assert(Array<U, N>::is_span_observable,
|
|
||||||
"internal error, Array<T> might hold only scalars or structs");
|
|
||||||
return span<const uint8_t, sizeof(U) * N>(arr.Data(), sizeof(U) * N);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cast a raw T[length] to a raw flatbuffers::Array<T, length>
|
|
||||||
// without endian conversion. Use with care.
|
|
||||||
// TODO: move these Cast-methods to `internal` namespace.
|
|
||||||
template <typename T, uint16_t length>
|
|
||||||
Array<T, length>& CastToArray(T (&arr)[length]) {
|
|
||||||
return *reinterpret_cast<Array<T, length>*>(arr);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, uint16_t length>
|
|
||||||
const Array<T, length>& CastToArray(const T (&arr)[length]) {
|
|
||||||
return *reinterpret_cast<const Array<T, length>*>(arr);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename E, typename T, uint16_t length>
|
|
||||||
Array<E, length>& CastToArrayOfEnum(T (&arr)[length]) {
|
|
||||||
static_assert(sizeof(E) == sizeof(T), "invalid enum type E");
|
|
||||||
return *reinterpret_cast<Array<E, length>*>(arr);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename E, typename T, uint16_t length>
|
|
||||||
const Array<E, length>& CastToArrayOfEnum(const T (&arr)[length]) {
|
|
||||||
static_assert(sizeof(E) == sizeof(T), "invalid enum type E");
|
|
||||||
return *reinterpret_cast<const Array<E, length>*>(arr);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, uint16_t length>
|
|
||||||
bool operator==(const Array<T, length>& lhs,
|
|
||||||
const Array<T, length>& rhs) noexcept {
|
|
||||||
return std::addressof(lhs) == std::addressof(rhs) ||
|
|
||||||
(lhs.size() == rhs.size() &&
|
|
||||||
std::memcmp(lhs.Data(), rhs.Data(), rhs.size() * sizeof(T)) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace flatbuffers
|
|
||||||
|
|
||||||
#endif // FLATBUFFERS_ARRAY_H_
|
|
||||||
-503
@@ -1,503 +0,0 @@
|
|||||||
#ifndef FLATBUFFERS_BASE_H_
|
|
||||||
#define FLATBUFFERS_BASE_H_
|
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
|
|
||||||
// If activate should be declared and included first.
|
|
||||||
#if defined(FLATBUFFERS_MEMORY_LEAK_TRACKING) && \
|
|
||||||
defined(_MSC_VER) && defined(_DEBUG)
|
|
||||||
// The _CRTDBG_MAP_ALLOC inside <crtdbg.h> will replace
|
|
||||||
// calloc/free (etc) to its debug version using #define directives.
|
|
||||||
#define _CRTDBG_MAP_ALLOC
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <crtdbg.h>
|
|
||||||
// Replace operator new by trace-enabled version.
|
|
||||||
#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
|
|
||||||
#define new DEBUG_NEW
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(FLATBUFFERS_ASSERT)
|
|
||||||
#include <assert.h>
|
|
||||||
#define FLATBUFFERS_ASSERT assert
|
|
||||||
#elif defined(FLATBUFFERS_ASSERT_INCLUDE)
|
|
||||||
// Include file with forward declaration
|
|
||||||
#include FLATBUFFERS_ASSERT_INCLUDE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ARDUINO
|
|
||||||
#include <cstdint>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
#if defined(ARDUINO) && !defined(ARDUINOSTL_M_H) && defined(__AVR__)
|
|
||||||
#include <utility.h>
|
|
||||||
#else
|
|
||||||
#include <utility>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <type_traits>
|
|
||||||
#include <vector>
|
|
||||||
#include <set>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <limits>
|
|
||||||
#include <iterator>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#if defined(__unix__) && !defined(FLATBUFFERS_LOCALE_INDEPENDENT)
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
|
||||||
#include <android/api-level.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__ICCARM__)
|
|
||||||
#include <intrinsics.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Note the __clang__ check is needed, because clang presents itself
|
|
||||||
// as an older GNUC compiler (4.2).
|
|
||||||
// Clang 3.3 and later implement all of the ISO C++ 2011 standard.
|
|
||||||
// Clang 3.4 and later implement all of the ISO C++ 2014 standard.
|
|
||||||
// http://clang.llvm.org/cxx_status.html
|
|
||||||
|
|
||||||
// Note the MSVC value '__cplusplus' may be incorrect:
|
|
||||||
// The '__cplusplus' predefined macro in the MSVC stuck at the value 199711L,
|
|
||||||
// indicating (erroneously!) that the compiler conformed to the C++98 Standard.
|
|
||||||
// This value should be correct starting from MSVC2017-15.7-Preview-3.
|
|
||||||
// The '__cplusplus' will be valid only if MSVC2017-15.7-P3 and the `/Zc:__cplusplus` switch is set.
|
|
||||||
// Workaround (for details see MSDN):
|
|
||||||
// Use the _MSC_VER and _MSVC_LANG definition instead of the __cplusplus for compatibility.
|
|
||||||
// The _MSVC_LANG macro reports the Standard version regardless of the '/Zc:__cplusplus' switch.
|
|
||||||
|
|
||||||
#if defined(__GNUC__) && !defined(__clang__)
|
|
||||||
#define FLATBUFFERS_GCC (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
|
|
||||||
#else
|
|
||||||
#define FLATBUFFERS_GCC 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__clang__)
|
|
||||||
#define FLATBUFFERS_CLANG (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
|
|
||||||
#else
|
|
||||||
#define FLATBUFFERS_CLANG 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// @cond FLATBUFFERS_INTERNAL
|
|
||||||
#if __cplusplus <= 199711L && \
|
|
||||||
(!defined(_MSC_VER) || _MSC_VER < 1600) && \
|
|
||||||
(!defined(__GNUC__) || \
|
|
||||||
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ < 40400))
|
|
||||||
#error A C++11 compatible compiler with support for the auto typing is \
|
|
||||||
required for FlatBuffers.
|
|
||||||
#error __cplusplus _MSC_VER __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(__clang__) && \
|
|
||||||
defined(__GNUC__) && \
|
|
||||||
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ < 40600)
|
|
||||||
// Backwards compatibility for g++ 4.4, and 4.5 which don't have the nullptr
|
|
||||||
// and constexpr keywords. Note the __clang__ check is needed, because clang
|
|
||||||
// presents itself as an older GNUC compiler.
|
|
||||||
#ifndef nullptr_t
|
|
||||||
const class nullptr_t {
|
|
||||||
public:
|
|
||||||
template<class T> inline operator T*() const { return 0; }
|
|
||||||
private:
|
|
||||||
void operator&() const;
|
|
||||||
} nullptr = {};
|
|
||||||
#endif
|
|
||||||
#ifndef constexpr
|
|
||||||
#define constexpr const
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// The wire format uses a little endian encoding (since that's efficient for
|
|
||||||
// the common platforms).
|
|
||||||
#if defined(__s390x__)
|
|
||||||
#define FLATBUFFERS_LITTLEENDIAN 0
|
|
||||||
#endif // __s390x__
|
|
||||||
#if !defined(FLATBUFFERS_LITTLEENDIAN)
|
|
||||||
#if defined(__GNUC__) || defined(__clang__) || defined(__ICCARM__)
|
|
||||||
#if (defined(__BIG_ENDIAN__) || \
|
|
||||||
(defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))
|
|
||||||
#define FLATBUFFERS_LITTLEENDIAN 0
|
|
||||||
#else
|
|
||||||
#define FLATBUFFERS_LITTLEENDIAN 1
|
|
||||||
#endif // __BIG_ENDIAN__
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
#if defined(_M_PPC)
|
|
||||||
#define FLATBUFFERS_LITTLEENDIAN 0
|
|
||||||
#else
|
|
||||||
#define FLATBUFFERS_LITTLEENDIAN 1
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#error Unable to determine endianness, define FLATBUFFERS_LITTLEENDIAN.
|
|
||||||
#endif
|
|
||||||
#endif // !defined(FLATBUFFERS_LITTLEENDIAN)
|
|
||||||
|
|
||||||
#define FLATBUFFERS_VERSION_MAJOR 25
|
|
||||||
#define FLATBUFFERS_VERSION_MINOR 9
|
|
||||||
#define FLATBUFFERS_VERSION_REVISION 23
|
|
||||||
#define FLATBUFFERS_STRING_EXPAND(X) #X
|
|
||||||
#define FLATBUFFERS_STRING(X) FLATBUFFERS_STRING_EXPAND(X)
|
|
||||||
namespace flatbuffers {
|
|
||||||
// Returns version as string "MAJOR.MINOR.REVISION".
|
|
||||||
const char* FLATBUFFERS_VERSION();
|
|
||||||
}
|
|
||||||
|
|
||||||
#if (!defined(_MSC_VER) || _MSC_VER > 1600) && \
|
|
||||||
(!defined(__GNUC__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 407)) || \
|
|
||||||
defined(__clang__)
|
|
||||||
#define FLATBUFFERS_FINAL_CLASS final
|
|
||||||
#define FLATBUFFERS_OVERRIDE override
|
|
||||||
#define FLATBUFFERS_EXPLICIT_CPP11 explicit
|
|
||||||
#define FLATBUFFERS_VTABLE_UNDERLYING_TYPE : ::flatbuffers::voffset_t
|
|
||||||
#else
|
|
||||||
#define FLATBUFFERS_FINAL_CLASS
|
|
||||||
#define FLATBUFFERS_OVERRIDE
|
|
||||||
#define FLATBUFFERS_EXPLICIT_CPP11
|
|
||||||
#define FLATBUFFERS_VTABLE_UNDERLYING_TYPE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (!defined(_MSC_VER) || _MSC_VER >= 1900) && \
|
|
||||||
(!defined(__GNUC__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)) || \
|
|
||||||
(defined(__cpp_constexpr) && __cpp_constexpr >= 200704)
|
|
||||||
#define FLATBUFFERS_CONSTEXPR constexpr
|
|
||||||
#define FLATBUFFERS_CONSTEXPR_CPP11 constexpr
|
|
||||||
#define FLATBUFFERS_CONSTEXPR_DEFINED
|
|
||||||
#else
|
|
||||||
#define FLATBUFFERS_CONSTEXPR const
|
|
||||||
#define FLATBUFFERS_CONSTEXPR_CPP11
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (defined(__cplusplus) && __cplusplus >= 201402L) || \
|
|
||||||
(defined(__cpp_constexpr) && __cpp_constexpr >= 201304)
|
|
||||||
#define FLATBUFFERS_CONSTEXPR_CPP14 FLATBUFFERS_CONSTEXPR_CPP11
|
|
||||||
#else
|
|
||||||
#define FLATBUFFERS_CONSTEXPR_CPP14
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (defined(__GXX_EXPERIMENTAL_CXX0X__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)) || \
|
|
||||||
(defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 190023026)) || \
|
|
||||||
defined(__clang__)
|
|
||||||
#define FLATBUFFERS_NOEXCEPT noexcept
|
|
||||||
#else
|
|
||||||
#define FLATBUFFERS_NOEXCEPT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// NOTE: the FLATBUFFERS_DELETE_FUNC macro may change the access mode to
|
|
||||||
// private, so be sure to put it at the end or reset access mode explicitly.
|
|
||||||
#if (!defined(_MSC_VER) || _MSC_FULL_VER >= 180020827) && \
|
|
||||||
(!defined(__GNUC__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 404)) || \
|
|
||||||
defined(__clang__)
|
|
||||||
#define FLATBUFFERS_DELETE_FUNC(func) func = delete
|
|
||||||
#else
|
|
||||||
#define FLATBUFFERS_DELETE_FUNC(func) private: func
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (!defined(_MSC_VER) || _MSC_VER >= 1900) && \
|
|
||||||
(!defined(__GNUC__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 409)) || \
|
|
||||||
defined(__clang__)
|
|
||||||
#define FLATBUFFERS_DEFAULT_DECLARATION
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Check if we can use template aliases
|
|
||||||
// Not possible if Microsoft Compiler before 2012
|
|
||||||
// Possible is the language feature __cpp_alias_templates is defined well
|
|
||||||
// Or possible if the C++ std is C+11 or newer
|
|
||||||
#if (defined(_MSC_VER) && _MSC_VER > 1700 /* MSVC2012 */) \
|
|
||||||
|| (defined(__cpp_alias_templates) && __cpp_alias_templates >= 200704) \
|
|
||||||
|| (defined(__cplusplus) && __cplusplus >= 201103L)
|
|
||||||
#define FLATBUFFERS_TEMPLATES_ALIASES
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef FLATBUFFERS_HAS_STRING_VIEW
|
|
||||||
// Only provide flatbuffers::string_view if __has_include can be used
|
|
||||||
// to detect a header that provides an implementation
|
|
||||||
#if defined(__has_include)
|
|
||||||
// Check for std::string_view (in c++17)
|
|
||||||
#if __has_include(<string_view>) && (__cplusplus >= 201606 || (defined(_HAS_CXX17) && _HAS_CXX17))
|
|
||||||
#include <string_view>
|
|
||||||
namespace flatbuffers {
|
|
||||||
typedef std::string_view string_view;
|
|
||||||
}
|
|
||||||
#define FLATBUFFERS_HAS_STRING_VIEW 1
|
|
||||||
// Check for std::experimental::string_view (in c++14, compiler-dependent)
|
|
||||||
#elif __has_include(<experimental/string_view>) && (__cplusplus >= 201411)
|
|
||||||
#include <experimental/string_view>
|
|
||||||
namespace flatbuffers {
|
|
||||||
typedef std::experimental::string_view string_view;
|
|
||||||
}
|
|
||||||
#define FLATBUFFERS_HAS_STRING_VIEW 1
|
|
||||||
// Check for absl::string_view
|
|
||||||
#elif __has_include("absl/strings/string_view.h") && \
|
|
||||||
__has_include("absl/base/config.h") && \
|
|
||||||
(__cplusplus >= 201411)
|
|
||||||
#include "absl/base/config.h"
|
|
||||||
#if !defined(ABSL_USES_STD_STRING_VIEW)
|
|
||||||
#include "absl/strings/string_view.h"
|
|
||||||
namespace flatbuffers {
|
|
||||||
typedef absl::string_view string_view;
|
|
||||||
}
|
|
||||||
#define FLATBUFFERS_HAS_STRING_VIEW 1
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif // __has_include
|
|
||||||
#endif // !FLATBUFFERS_HAS_STRING_VIEW
|
|
||||||
|
|
||||||
#ifndef FLATBUFFERS_GENERAL_HEAP_ALLOC_OK
|
|
||||||
// Allow heap allocations to be used
|
|
||||||
#define FLATBUFFERS_GENERAL_HEAP_ALLOC_OK 1
|
|
||||||
#endif // !FLATBUFFERS_GENERAL_HEAP_ALLOC_OK
|
|
||||||
|
|
||||||
#ifndef FLATBUFFERS_HAS_NEW_STRTOD
|
|
||||||
// Modern (C++11) strtod and strtof functions are available for use.
|
|
||||||
// 1) nan/inf strings as argument of strtod;
|
|
||||||
// 2) hex-float as argument of strtod/strtof.
|
|
||||||
#if (defined(_MSC_VER) && _MSC_VER >= 1900) || \
|
|
||||||
(defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 409)) || \
|
|
||||||
(defined(__clang__))
|
|
||||||
#define FLATBUFFERS_HAS_NEW_STRTOD 1
|
|
||||||
#endif
|
|
||||||
#endif // !FLATBUFFERS_HAS_NEW_STRTOD
|
|
||||||
|
|
||||||
#ifndef FLATBUFFERS_LOCALE_INDEPENDENT
|
|
||||||
// Enable locale independent functions {strtof_l, strtod_l,strtoll_l,
|
|
||||||
// strtoull_l}.
|
|
||||||
#if (defined(_MSC_VER) && _MSC_VER >= 1800) || \
|
|
||||||
(defined(__ANDROID_API__) && __ANDROID_API__>= 21) || \
|
|
||||||
(defined(_XOPEN_VERSION) && (_XOPEN_VERSION >= 700)) && \
|
|
||||||
(!defined(__Fuchsia__) && !defined(__ANDROID_API__))
|
|
||||||
#define FLATBUFFERS_LOCALE_INDEPENDENT 1
|
|
||||||
#else
|
|
||||||
#define FLATBUFFERS_LOCALE_INDEPENDENT 0
|
|
||||||
#endif
|
|
||||||
#endif // !FLATBUFFERS_LOCALE_INDEPENDENT
|
|
||||||
|
|
||||||
// Suppress Undefined Behavior Sanitizer (recoverable only). Usage:
|
|
||||||
// - FLATBUFFERS_SUPPRESS_UBSAN("undefined")
|
|
||||||
// - FLATBUFFERS_SUPPRESS_UBSAN("signed-integer-overflow")
|
|
||||||
#if defined(__clang__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >=7))
|
|
||||||
#define FLATBUFFERS_SUPPRESS_UBSAN(type) __attribute__((no_sanitize(type)))
|
|
||||||
#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 409)
|
|
||||||
#define FLATBUFFERS_SUPPRESS_UBSAN(type) __attribute__((no_sanitize_undefined))
|
|
||||||
#else
|
|
||||||
#define FLATBUFFERS_SUPPRESS_UBSAN(type)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace flatbuffers {
|
|
||||||
// This is constexpr function used for checking compile-time constants.
|
|
||||||
// Avoid `#pragma warning(disable: 4127) // C4127: expression is constant`.
|
|
||||||
template<typename T> FLATBUFFERS_CONSTEXPR inline bool IsConstTrue(T t) {
|
|
||||||
return !!t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enable C++ attribute [[]] if std:c++17 or higher.
|
|
||||||
#if ((__cplusplus >= 201703L) \
|
|
||||||
|| (defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L)))
|
|
||||||
// All attributes unknown to an implementation are ignored without causing an error.
|
|
||||||
#define FLATBUFFERS_ATTRIBUTE(attr) attr
|
|
||||||
|
|
||||||
#define FLATBUFFERS_FALLTHROUGH() [[fallthrough]]
|
|
||||||
#else
|
|
||||||
#define FLATBUFFERS_ATTRIBUTE(attr)
|
|
||||||
|
|
||||||
#if FLATBUFFERS_CLANG >= 30800
|
|
||||||
#define FLATBUFFERS_FALLTHROUGH() [[clang::fallthrough]]
|
|
||||||
#elif FLATBUFFERS_GCC >= 70300
|
|
||||||
#define FLATBUFFERS_FALLTHROUGH() [[gnu::fallthrough]]
|
|
||||||
#else
|
|
||||||
#define FLATBUFFERS_FALLTHROUGH()
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// @endcond
|
|
||||||
|
|
||||||
/// @file
|
|
||||||
namespace flatbuffers {
|
|
||||||
|
|
||||||
/// @cond FLATBUFFERS_INTERNAL
|
|
||||||
// Our default offset / size type, 32bit on purpose on 64bit systems.
|
|
||||||
// Also, using a consistent offset type maintains compatibility of serialized
|
|
||||||
// offset values between 32bit and 64bit systems.
|
|
||||||
typedef uint32_t uoffset_t;
|
|
||||||
typedef uint64_t uoffset64_t;
|
|
||||||
|
|
||||||
// Signed offsets for references that can go in both directions.
|
|
||||||
typedef int32_t soffset_t;
|
|
||||||
typedef int64_t soffset64_t;
|
|
||||||
|
|
||||||
// Offset/index used in v-tables, can be changed to uint8_t in
|
|
||||||
// format forks to save a bit of space if desired.
|
|
||||||
typedef uint16_t voffset_t;
|
|
||||||
|
|
||||||
typedef uintmax_t largest_scalar_t;
|
|
||||||
|
|
||||||
// In 32bits, this evaluates to 2GB - 1
|
|
||||||
#define FLATBUFFERS_MAX_BUFFER_SIZE (std::numeric_limits<::flatbuffers::soffset_t>::max)()
|
|
||||||
#define FLATBUFFERS_MAX_64_BUFFER_SIZE (std::numeric_limits<::flatbuffers::soffset64_t>::max)()
|
|
||||||
|
|
||||||
// The minimum size buffer that can be a valid flatbuffer.
|
|
||||||
// Includes the offset to the root table (uoffset_t), the offset to the vtable
|
|
||||||
// of the root table (soffset_t), the size of the vtable (uint16_t), and the
|
|
||||||
// size of the referring table (uint16_t).
|
|
||||||
#define FLATBUFFERS_MIN_BUFFER_SIZE sizeof(::flatbuffers::uoffset_t) + \
|
|
||||||
sizeof(::flatbuffers::soffset_t) + sizeof(uint16_t) + sizeof(uint16_t)
|
|
||||||
|
|
||||||
// We support aligning the contents of buffers up to this size.
|
|
||||||
#ifndef FLATBUFFERS_MAX_ALIGNMENT
|
|
||||||
#define FLATBUFFERS_MAX_ALIGNMENT 32
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// @brief The length of a FlatBuffer file header.
|
|
||||||
static const size_t kFileIdentifierLength = 4;
|
|
||||||
|
|
||||||
inline bool VerifyAlignmentRequirements(size_t align, size_t min_align = 1) {
|
|
||||||
return (min_align <= align) && (align <= (FLATBUFFERS_MAX_ALIGNMENT)) &&
|
|
||||||
(align & (align - 1)) == 0; // must be power of 2
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
|
||||||
#pragma warning(push)
|
|
||||||
#pragma warning(disable: 4127) // C4127: conditional expression is constant
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<typename T> T EndianSwap(T t) {
|
|
||||||
#if defined(_MSC_VER)
|
|
||||||
#define FLATBUFFERS_BYTESWAP16 _byteswap_ushort
|
|
||||||
#define FLATBUFFERS_BYTESWAP32 _byteswap_ulong
|
|
||||||
#define FLATBUFFERS_BYTESWAP64 _byteswap_uint64
|
|
||||||
#elif defined(__ICCARM__)
|
|
||||||
#define FLATBUFFERS_BYTESWAP16 __REV16
|
|
||||||
#define FLATBUFFERS_BYTESWAP32 __REV
|
|
||||||
#define FLATBUFFERS_BYTESWAP64(x) \
|
|
||||||
((__REV(static_cast<uint32_t>(x >> 32U))) | (static_cast<uint64_t>(__REV(static_cast<uint32_t>(x)))) << 32U)
|
|
||||||
#else
|
|
||||||
#if defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ < 408 && !defined(__clang__)
|
|
||||||
// __builtin_bswap16 was missing prior to GCC 4.8.
|
|
||||||
#define FLATBUFFERS_BYTESWAP16(x) \
|
|
||||||
static_cast<uint16_t>(__builtin_bswap32(static_cast<uint32_t>(x) << 16))
|
|
||||||
#else
|
|
||||||
#define FLATBUFFERS_BYTESWAP16 __builtin_bswap16
|
|
||||||
#endif
|
|
||||||
#define FLATBUFFERS_BYTESWAP32 __builtin_bswap32
|
|
||||||
#define FLATBUFFERS_BYTESWAP64 __builtin_bswap64
|
|
||||||
#endif
|
|
||||||
if (sizeof(T) == 1) { // Compile-time if-then's.
|
|
||||||
return t;
|
|
||||||
} else if (sizeof(T) == 2) {
|
|
||||||
union { T t; uint16_t i; } u = { t };
|
|
||||||
u.i = FLATBUFFERS_BYTESWAP16(u.i);
|
|
||||||
return u.t;
|
|
||||||
} else if (sizeof(T) == 4) {
|
|
||||||
union { T t; uint32_t i; } u = { t };
|
|
||||||
u.i = FLATBUFFERS_BYTESWAP32(u.i);
|
|
||||||
return u.t;
|
|
||||||
} else if (sizeof(T) == 8) {
|
|
||||||
union { T t; uint64_t i; } u = { t };
|
|
||||||
u.i = FLATBUFFERS_BYTESWAP64(u.i);
|
|
||||||
return u.t;
|
|
||||||
} else {
|
|
||||||
FLATBUFFERS_ASSERT(0);
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
|
||||||
#pragma warning(pop)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T> T EndianScalar(T t) {
|
|
||||||
#if FLATBUFFERS_LITTLEENDIAN
|
|
||||||
return t;
|
|
||||||
#else
|
|
||||||
return EndianSwap(t);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
// UBSAN: C++ aliasing type rules, see std::bit_cast<> for details.
|
|
||||||
FLATBUFFERS_SUPPRESS_UBSAN("alignment")
|
|
||||||
T ReadScalar(const void *p) {
|
|
||||||
return EndianScalar(*reinterpret_cast<const T *>(p));
|
|
||||||
}
|
|
||||||
|
|
||||||
// See https://github.com/google/flatbuffers/issues/5950
|
|
||||||
|
|
||||||
#if (FLATBUFFERS_GCC >= 100000) && (FLATBUFFERS_GCC < 110000)
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Wstringop-overflow"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
// UBSAN: C++ aliasing type rules, see std::bit_cast<> for details.
|
|
||||||
FLATBUFFERS_SUPPRESS_UBSAN("alignment")
|
|
||||||
void WriteScalar(void *p, T t) {
|
|
||||||
*reinterpret_cast<T *>(p) = EndianScalar(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T> struct Offset;
|
|
||||||
template<typename T> FLATBUFFERS_SUPPRESS_UBSAN("alignment") void WriteScalar(void *p, Offset<T> t) {
|
|
||||||
*reinterpret_cast<uoffset_t *>(p) = EndianScalar(t.o);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if (FLATBUFFERS_GCC >= 100000) && (FLATBUFFERS_GCC < 110000)
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Computes how many bytes you'd have to pad to be able to write an
|
|
||||||
// "scalar_size" scalar if the buffer had grown to "buf_size" (downwards in
|
|
||||||
// memory).
|
|
||||||
FLATBUFFERS_SUPPRESS_UBSAN("unsigned-integer-overflow")
|
|
||||||
inline size_t PaddingBytes(size_t buf_size, size_t scalar_size) {
|
|
||||||
return ((~buf_size) + 1) & (scalar_size - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !defined(_MSC_VER)
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Wfloat-equal"
|
|
||||||
#endif
|
|
||||||
// Generic 'operator==' with conditional specialisations.
|
|
||||||
// T e - new value of a scalar field.
|
|
||||||
// T def - default of scalar (is known at compile-time).
|
|
||||||
template<typename T> inline bool IsTheSameAs(T e, T def) { return e == def; }
|
|
||||||
#if !defined(_MSC_VER)
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(FLATBUFFERS_NAN_DEFAULTS) && \
|
|
||||||
defined(FLATBUFFERS_HAS_NEW_STRTOD) && (FLATBUFFERS_HAS_NEW_STRTOD > 0)
|
|
||||||
// Like `operator==(e, def)` with weak NaN if T=(float|double).
|
|
||||||
template<typename T> inline bool IsFloatTheSameAs(T e, T def) {
|
|
||||||
return (e == def) || ((def != def) && (e != e));
|
|
||||||
}
|
|
||||||
template<> inline bool IsTheSameAs<float>(float e, float def) {
|
|
||||||
return IsFloatTheSameAs(e, def);
|
|
||||||
}
|
|
||||||
template<> inline bool IsTheSameAs<double>(double e, double def) {
|
|
||||||
return IsFloatTheSameAs(e, def);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Check 'v' is out of closed range [low; high].
|
|
||||||
// Workaround for GCC warning [-Werror=type-limits]:
|
|
||||||
// comparison is always true due to limited range of data type.
|
|
||||||
template<typename T>
|
|
||||||
inline bool IsOutRange(const T &v, const T &low, const T &high) {
|
|
||||||
return (v < low) || (high < v);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check 'v' is in closed range [low; high].
|
|
||||||
template<typename T>
|
|
||||||
inline bool IsInRange(const T &v, const T &low, const T &high) {
|
|
||||||
return !IsOutRange(v, low, high);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace flatbuffers
|
|
||||||
#endif // FLATBUFFERS_BASE_H_
|
|
||||||
-225
@@ -1,225 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2021 Google Inc. All rights reserved.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLATBUFFERS_BUFFER_H_
|
|
||||||
#define FLATBUFFERS_BUFFER_H_
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
#include "flatbuffers/base.h"
|
|
||||||
#include "flatbuffers/stl_emulation.h"
|
|
||||||
|
|
||||||
namespace flatbuffers {
|
|
||||||
|
|
||||||
// Wrapper for uoffset_t to allow safe template specialization.
|
|
||||||
// Value is allowed to be 0 to indicate a null object (see e.g. AddOffset).
|
|
||||||
template <typename T = void>
|
|
||||||
struct Offset {
|
|
||||||
// The type of offset to use.
|
|
||||||
typedef uoffset_t offset_type;
|
|
||||||
|
|
||||||
offset_type o;
|
|
||||||
Offset() : o(0) {}
|
|
||||||
Offset(const offset_type _o) : o(_o) {}
|
|
||||||
Offset<> Union() const { return o; }
|
|
||||||
bool IsNull() const { return !o; }
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct is_specialisation_of_Offset : false_type {};
|
|
||||||
template <typename T>
|
|
||||||
struct is_specialisation_of_Offset<Offset<T>> : true_type {};
|
|
||||||
|
|
||||||
// Wrapper for uoffset64_t Offsets.
|
|
||||||
template <typename T = void>
|
|
||||||
struct Offset64 {
|
|
||||||
// The type of offset to use.
|
|
||||||
typedef uoffset64_t offset_type;
|
|
||||||
|
|
||||||
offset_type o;
|
|
||||||
Offset64() : o(0) {}
|
|
||||||
Offset64(const offset_type offset) : o(offset) {}
|
|
||||||
Offset64<> Union() const { return o; }
|
|
||||||
bool IsNull() const { return !o; }
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct is_specialisation_of_Offset64 : false_type {};
|
|
||||||
template <typename T>
|
|
||||||
struct is_specialisation_of_Offset64<Offset64<T>> : true_type {};
|
|
||||||
|
|
||||||
// Litmus check for ensuring the Offsets are the expected size.
|
|
||||||
static_assert(sizeof(Offset<>) == 4, "Offset has wrong size");
|
|
||||||
static_assert(sizeof(Offset64<>) == 8, "Offset64 has wrong size");
|
|
||||||
|
|
||||||
inline void EndianCheck() {
|
|
||||||
int endiantest = 1;
|
|
||||||
// If this fails, see FLATBUFFERS_LITTLEENDIAN above.
|
|
||||||
FLATBUFFERS_ASSERT(*reinterpret_cast<char*>(&endiantest) ==
|
|
||||||
FLATBUFFERS_LITTLEENDIAN);
|
|
||||||
(void)endiantest;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
FLATBUFFERS_CONSTEXPR size_t AlignOf() {
|
|
||||||
// clang-format off
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
return __alignof(T);
|
|
||||||
#else
|
|
||||||
#ifndef alignof
|
|
||||||
return __alignof__(T);
|
|
||||||
#else
|
|
||||||
return alignof(T);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
// clang-format on
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lexicographically compare two strings (possibly containing nulls), and
|
|
||||||
// return true if the first is less than the second.
|
|
||||||
static inline bool StringLessThan(const char* a_data, uoffset_t a_size,
|
|
||||||
const char* b_data, uoffset_t b_size) {
|
|
||||||
const auto cmp = memcmp(a_data, b_data, (std::min)(a_size, b_size));
|
|
||||||
return cmp == 0 ? a_size < b_size : cmp < 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// When we read serialized data from memory, in the case of most scalars,
|
|
||||||
// we want to just read T, but in the case of Offset, we want to actually
|
|
||||||
// perform the indirection and return a pointer.
|
|
||||||
// The template specialization below does just that.
|
|
||||||
// It is wrapped in a struct since function templates can't overload on the
|
|
||||||
// return type like this.
|
|
||||||
// The typedef is for the convenience of callers of this function
|
|
||||||
// (avoiding the need for a trailing return decltype)
|
|
||||||
template <typename T, typename Enable = void>
|
|
||||||
struct IndirectHelper {
|
|
||||||
typedef T return_type;
|
|
||||||
typedef T mutable_return_type;
|
|
||||||
static const size_t element_stride = sizeof(T);
|
|
||||||
|
|
||||||
static return_type Read(const uint8_t* p, const size_t i) {
|
|
||||||
return EndianScalar((reinterpret_cast<const T*>(p))[i]);
|
|
||||||
}
|
|
||||||
static mutable_return_type Read(uint8_t* p, const size_t i) {
|
|
||||||
return reinterpret_cast<mutable_return_type>(
|
|
||||||
Read(const_cast<const uint8_t*>(p), i));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// For vector of Offsets.
|
|
||||||
template <typename T, template <typename> class OffsetT>
|
|
||||||
struct IndirectHelper<OffsetT<T>> {
|
|
||||||
typedef const T* return_type;
|
|
||||||
typedef T* mutable_return_type;
|
|
||||||
typedef typename OffsetT<T>::offset_type offset_type;
|
|
||||||
static const offset_type element_stride = sizeof(offset_type);
|
|
||||||
|
|
||||||
static return_type Read(const uint8_t* const p, const offset_type i) {
|
|
||||||
// Offsets are relative to themselves, so first update the pointer to
|
|
||||||
// point to the offset location.
|
|
||||||
const uint8_t* const offset_location = p + i * element_stride;
|
|
||||||
|
|
||||||
// Then read the scalar value of the offset (which may be 32 or 64-bits) and
|
|
||||||
// then determine the relative location from the offset location.
|
|
||||||
return reinterpret_cast<return_type>(
|
|
||||||
offset_location + ReadScalar<offset_type>(offset_location));
|
|
||||||
}
|
|
||||||
static mutable_return_type Read(uint8_t* const p, const offset_type i) {
|
|
||||||
// Offsets are relative to themselves, so first update the pointer to
|
|
||||||
// point to the offset location.
|
|
||||||
uint8_t* const offset_location = p + i * element_stride;
|
|
||||||
|
|
||||||
// Then read the scalar value of the offset (which may be 32 or 64-bits) and
|
|
||||||
// then determine the relative location from the offset location.
|
|
||||||
return reinterpret_cast<mutable_return_type>(
|
|
||||||
offset_location + ReadScalar<offset_type>(offset_location));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// For vector of structs.
|
|
||||||
template <typename T>
|
|
||||||
struct IndirectHelper<
|
|
||||||
T, typename std::enable_if<
|
|
||||||
!std::is_scalar<typename std::remove_pointer<T>::type>::value &&
|
|
||||||
!is_specialisation_of_Offset<T>::value &&
|
|
||||||
!is_specialisation_of_Offset64<T>::value>::type> {
|
|
||||||
private:
|
|
||||||
typedef typename std::remove_pointer<typename std::remove_cv<T>::type>::type
|
|
||||||
pointee_type;
|
|
||||||
|
|
||||||
public:
|
|
||||||
typedef const pointee_type* return_type;
|
|
||||||
typedef pointee_type* mutable_return_type;
|
|
||||||
static const size_t element_stride = sizeof(pointee_type);
|
|
||||||
|
|
||||||
static return_type Read(const uint8_t* const p, const size_t i) {
|
|
||||||
// Structs are stored inline, relative to the first struct pointer.
|
|
||||||
return reinterpret_cast<return_type>(p + i * element_stride);
|
|
||||||
}
|
|
||||||
static mutable_return_type Read(uint8_t* const p, const size_t i) {
|
|
||||||
// Structs are stored inline, relative to the first struct pointer.
|
|
||||||
return reinterpret_cast<mutable_return_type>(p + i * element_stride);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/// @brief Get a pointer to the file_identifier section of the buffer.
|
|
||||||
/// @return Returns a const char pointer to the start of the file_identifier
|
|
||||||
/// characters in the buffer. The returned char * has length
|
|
||||||
/// 'flatbuffers::FlatBufferBuilder::kFileIdentifierLength'.
|
|
||||||
/// This function is UNDEFINED for FlatBuffers whose schema does not include
|
|
||||||
/// a file_identifier (likely points at padding or the start of a the root
|
|
||||||
/// vtable).
|
|
||||||
inline const char* GetBufferIdentifier(const void* buf,
|
|
||||||
bool size_prefixed = false) {
|
|
||||||
return reinterpret_cast<const char*>(buf) +
|
|
||||||
((size_prefixed) ? 2 * sizeof(uoffset_t) : sizeof(uoffset_t));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper to see if the identifier in a buffer has the expected value.
|
|
||||||
inline bool BufferHasIdentifier(const void* buf, const char* identifier,
|
|
||||||
bool size_prefixed = false) {
|
|
||||||
return strncmp(GetBufferIdentifier(buf, size_prefixed), identifier,
|
|
||||||
flatbuffers::kFileIdentifierLength) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @cond FLATBUFFERS_INTERNAL
|
|
||||||
// Helpers to get a typed pointer to the root object contained in the buffer.
|
|
||||||
template <typename T>
|
|
||||||
T* GetMutableRoot(void* buf) {
|
|
||||||
if (!buf) return nullptr;
|
|
||||||
EndianCheck();
|
|
||||||
return reinterpret_cast<T*>(reinterpret_cast<uint8_t*>(buf) +
|
|
||||||
EndianScalar(*reinterpret_cast<uoffset_t*>(buf)));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, typename SizeT = uoffset_t>
|
|
||||||
T* GetMutableSizePrefixedRoot(void* buf) {
|
|
||||||
return GetMutableRoot<T>(reinterpret_cast<uint8_t*>(buf) + sizeof(SizeT));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
const T* GetRoot(const void* buf) {
|
|
||||||
return GetMutableRoot<T>(const_cast<void*>(buf));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, typename SizeT = uoffset_t>
|
|
||||||
const T* GetSizePrefixedRoot(const void* buf) {
|
|
||||||
return GetRoot<T>(reinterpret_cast<const uint8_t*>(buf) + sizeof(SizeT));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace flatbuffers
|
|
||||||
|
|
||||||
#endif // FLATBUFFERS_BUFFER_H_
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2021 Google Inc. All rights reserved.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLATBUFFERS_BUFFER_REF_H_
|
|
||||||
#define FLATBUFFERS_BUFFER_REF_H_
|
|
||||||
|
|
||||||
#include "flatbuffers/base.h"
|
|
||||||
#include "flatbuffers/verifier.h"
|
|
||||||
|
|
||||||
namespace flatbuffers {
|
|
||||||
|
|
||||||
// Convenient way to bundle a buffer and its length, to pass it around
|
|
||||||
// typed by its root.
|
|
||||||
// A BufferRef does not own its buffer.
|
|
||||||
struct BufferRefBase {}; // for std::is_base_of
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct BufferRef : BufferRefBase {
|
|
||||||
BufferRef() : buf(nullptr), len(0), must_free(false) {}
|
|
||||||
BufferRef(uint8_t* _buf, uoffset_t _len)
|
|
||||||
: buf(_buf), len(_len), must_free(false) {}
|
|
||||||
|
|
||||||
~BufferRef() {
|
|
||||||
if (must_free) free(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
const T* GetRoot() const { return flatbuffers::GetRoot<T>(buf); }
|
|
||||||
|
|
||||||
bool Verify() {
|
|
||||||
Verifier verifier(buf, len);
|
|
||||||
return verifier.VerifyBuffer<T>(nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t* buf;
|
|
||||||
uoffset_t len;
|
|
||||||
bool must_free;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace flatbuffers
|
|
||||||
|
|
||||||
#endif // FLATBUFFERS_BUFFER_REF_H_
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2021 Google Inc. All rights reserved.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLATBUFFERS_DEFAULT_ALLOCATOR_H_
|
|
||||||
#define FLATBUFFERS_DEFAULT_ALLOCATOR_H_
|
|
||||||
|
|
||||||
#include "flatbuffers/allocator.h"
|
|
||||||
#include "flatbuffers/base.h"
|
|
||||||
|
|
||||||
namespace flatbuffers {
|
|
||||||
|
|
||||||
// DefaultAllocator uses new/delete to allocate memory regions
|
|
||||||
class DefaultAllocator : public Allocator {
|
|
||||||
public:
|
|
||||||
uint8_t* allocate(size_t size) FLATBUFFERS_OVERRIDE {
|
|
||||||
return new uint8_t[size];
|
|
||||||
}
|
|
||||||
|
|
||||||
void deallocate(uint8_t* p, size_t) FLATBUFFERS_OVERRIDE { delete[] p; }
|
|
||||||
|
|
||||||
static void dealloc(void* p, size_t) { delete[] static_cast<uint8_t*>(p); }
|
|
||||||
};
|
|
||||||
|
|
||||||
// These functions allow for a null allocator to mean use the default allocator,
|
|
||||||
// as used by DetachedBuffer and vector_downward below.
|
|
||||||
// This is to avoid having a statically or dynamically allocated default
|
|
||||||
// allocator, or having to move it between the classes that may own it.
|
|
||||||
inline uint8_t* Allocate(Allocator* allocator, size_t size) {
|
|
||||||
return allocator ? allocator->allocate(size)
|
|
||||||
: DefaultAllocator().allocate(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Deallocate(Allocator* allocator, uint8_t* p, size_t size) {
|
|
||||||
if (allocator)
|
|
||||||
allocator->deallocate(p, size);
|
|
||||||
else
|
|
||||||
DefaultAllocator().deallocate(p, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline uint8_t* ReallocateDownward(Allocator* allocator, uint8_t* old_p,
|
|
||||||
size_t old_size, size_t new_size,
|
|
||||||
size_t in_use_back, size_t in_use_front) {
|
|
||||||
return allocator ? allocator->reallocate_downward(old_p, old_size, new_size,
|
|
||||||
in_use_back, in_use_front)
|
|
||||||
: DefaultAllocator().reallocate_downward(
|
|
||||||
old_p, old_size, new_size, in_use_back, in_use_front);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace flatbuffers
|
|
||||||
|
|
||||||
#endif // FLATBUFFERS_DEFAULT_ALLOCATOR_H_
|
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2021 Google Inc. All rights reserved.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLATBUFFERS_DETACHED_BUFFER_H_
|
|
||||||
#define FLATBUFFERS_DETACHED_BUFFER_H_
|
|
||||||
|
|
||||||
#include "flatbuffers/allocator.h"
|
|
||||||
#include "flatbuffers/base.h"
|
|
||||||
#include "flatbuffers/default_allocator.h"
|
|
||||||
|
|
||||||
namespace flatbuffers {
|
|
||||||
|
|
||||||
// DetachedBuffer is a finished flatbuffer memory region, detached from its
|
|
||||||
// builder. The original memory region and allocator are also stored so that
|
|
||||||
// the DetachedBuffer can manage the memory lifetime.
|
|
||||||
class DetachedBuffer {
|
|
||||||
public:
|
|
||||||
DetachedBuffer()
|
|
||||||
: allocator_(nullptr),
|
|
||||||
own_allocator_(false),
|
|
||||||
buf_(nullptr),
|
|
||||||
reserved_(0),
|
|
||||||
cur_(nullptr),
|
|
||||||
size_(0) {}
|
|
||||||
|
|
||||||
DetachedBuffer(Allocator* allocator, bool own_allocator, uint8_t* buf,
|
|
||||||
size_t reserved, uint8_t* cur, size_t sz)
|
|
||||||
: allocator_(allocator),
|
|
||||||
own_allocator_(own_allocator),
|
|
||||||
buf_(buf),
|
|
||||||
reserved_(reserved),
|
|
||||||
cur_(cur),
|
|
||||||
size_(sz) {}
|
|
||||||
|
|
||||||
DetachedBuffer(DetachedBuffer&& other) noexcept
|
|
||||||
: allocator_(other.allocator_),
|
|
||||||
own_allocator_(other.own_allocator_),
|
|
||||||
buf_(other.buf_),
|
|
||||||
reserved_(other.reserved_),
|
|
||||||
cur_(other.cur_),
|
|
||||||
size_(other.size_) {
|
|
||||||
other.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
DetachedBuffer& operator=(DetachedBuffer&& other) noexcept {
|
|
||||||
if (this == &other) return *this;
|
|
||||||
|
|
||||||
destroy();
|
|
||||||
|
|
||||||
allocator_ = other.allocator_;
|
|
||||||
own_allocator_ = other.own_allocator_;
|
|
||||||
buf_ = other.buf_;
|
|
||||||
reserved_ = other.reserved_;
|
|
||||||
cur_ = other.cur_;
|
|
||||||
size_ = other.size_;
|
|
||||||
|
|
||||||
other.reset();
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
~DetachedBuffer() { destroy(); }
|
|
||||||
|
|
||||||
const uint8_t* data() const { return cur_; }
|
|
||||||
|
|
||||||
uint8_t* data() { return cur_; }
|
|
||||||
|
|
||||||
size_t size() const { return size_; }
|
|
||||||
|
|
||||||
uint8_t* begin() { return data(); }
|
|
||||||
const uint8_t* begin() const { return data(); }
|
|
||||||
uint8_t* end() { return data() + size(); }
|
|
||||||
const uint8_t* end() const { return data() + size(); }
|
|
||||||
|
|
||||||
// These may change access mode, leave these at end of public section
|
|
||||||
FLATBUFFERS_DELETE_FUNC(DetachedBuffer(const DetachedBuffer& other));
|
|
||||||
FLATBUFFERS_DELETE_FUNC(
|
|
||||||
DetachedBuffer& operator=(const DetachedBuffer& other));
|
|
||||||
|
|
||||||
protected:
|
|
||||||
Allocator* allocator_;
|
|
||||||
bool own_allocator_;
|
|
||||||
uint8_t* buf_;
|
|
||||||
size_t reserved_;
|
|
||||||
uint8_t* cur_;
|
|
||||||
size_t size_;
|
|
||||||
|
|
||||||
inline void destroy() {
|
|
||||||
if (buf_) Deallocate(allocator_, buf_, reserved_);
|
|
||||||
if (own_allocator_ && allocator_) {
|
|
||||||
delete allocator_;
|
|
||||||
}
|
|
||||||
reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void reset() {
|
|
||||||
allocator_ = nullptr;
|
|
||||||
own_allocator_ = false;
|
|
||||||
buf_ = nullptr;
|
|
||||||
reserved_ = 0;
|
|
||||||
cur_ = nullptr;
|
|
||||||
size_ = 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace flatbuffers
|
|
||||||
|
|
||||||
#endif // FLATBUFFERS_DETACHED_BUFFER_H_
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,284 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014 Google Inc. All rights reserved.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLATBUFFERS_H_
|
|
||||||
#define FLATBUFFERS_H_
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
// TODO: These includes are for mitigating the pains of users editing their
|
|
||||||
// source because they relied on flatbuffers.h to include everything for them.
|
|
||||||
#include "flatbuffers/array.h"
|
|
||||||
#include "flatbuffers/base.h"
|
|
||||||
#include "flatbuffers/buffer.h"
|
|
||||||
#include "flatbuffers/buffer_ref.h"
|
|
||||||
#include "flatbuffers/detached_buffer.h"
|
|
||||||
#include "flatbuffers/flatbuffer_builder.h"
|
|
||||||
#include "flatbuffers/stl_emulation.h"
|
|
||||||
#include "flatbuffers/string.h"
|
|
||||||
#include "flatbuffers/struct.h"
|
|
||||||
#include "flatbuffers/table.h"
|
|
||||||
#include "flatbuffers/vector.h"
|
|
||||||
#include "flatbuffers/vector_downward.h"
|
|
||||||
#include "flatbuffers/verifier.h"
|
|
||||||
|
|
||||||
namespace flatbuffers {
|
|
||||||
|
|
||||||
/// @brief This can compute the start of a FlatBuffer from a root pointer, i.e.
|
|
||||||
/// it is the opposite transformation of GetRoot().
|
|
||||||
/// This may be useful if you want to pass on a root and have the recipient
|
|
||||||
/// delete the buffer afterwards.
|
|
||||||
inline const uint8_t* GetBufferStartFromRootPointer(const void* root) {
|
|
||||||
auto table = reinterpret_cast<const Table*>(root);
|
|
||||||
auto vtable = table->GetVTable();
|
|
||||||
// Either the vtable is before the root or after the root.
|
|
||||||
auto start = (std::min)(vtable, reinterpret_cast<const uint8_t*>(root));
|
|
||||||
// Align to at least sizeof(uoffset_t).
|
|
||||||
start = reinterpret_cast<const uint8_t*>(reinterpret_cast<uintptr_t>(start) &
|
|
||||||
~(sizeof(uoffset_t) - 1));
|
|
||||||
// Additionally, there may be a file_identifier in the buffer, and the root
|
|
||||||
// offset. The buffer may have been aligned to any size between
|
|
||||||
// sizeof(uoffset_t) and FLATBUFFERS_MAX_ALIGNMENT (see "force_align").
|
|
||||||
// Sadly, the exact alignment is only known when constructing the buffer,
|
|
||||||
// since it depends on the presence of values with said alignment properties.
|
|
||||||
// So instead, we simply look at the next uoffset_t values (root,
|
|
||||||
// file_identifier, and alignment padding) to see which points to the root.
|
|
||||||
// None of the other values can "impersonate" the root since they will either
|
|
||||||
// be 0 or four ASCII characters.
|
|
||||||
static_assert(flatbuffers::kFileIdentifierLength == sizeof(uoffset_t),
|
|
||||||
"file_identifier is assumed to be the same size as uoffset_t");
|
|
||||||
for (auto possible_roots = FLATBUFFERS_MAX_ALIGNMENT / sizeof(uoffset_t) + 1;
|
|
||||||
possible_roots; possible_roots--) {
|
|
||||||
start -= sizeof(uoffset_t);
|
|
||||||
if (ReadScalar<uoffset_t>(start) + start ==
|
|
||||||
reinterpret_cast<const uint8_t*>(root))
|
|
||||||
return start;
|
|
||||||
}
|
|
||||||
// We didn't find the root, either the "root" passed isn't really a root,
|
|
||||||
// or the buffer is corrupt.
|
|
||||||
// Assert, because calling this function with bad data may cause reads
|
|
||||||
// outside of buffer boundaries.
|
|
||||||
FLATBUFFERS_ASSERT(false);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @brief This return the prefixed size of a FlatBuffer.
|
|
||||||
template <typename SizeT = uoffset_t>
|
|
||||||
inline SizeT GetPrefixedSize(const uint8_t* buf) {
|
|
||||||
return ReadScalar<SizeT>(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Gets the total length of the buffer given a sized prefixed FlatBuffer.
|
|
||||||
//
|
|
||||||
// This includes the size of the prefix as well as the buffer:
|
|
||||||
//
|
|
||||||
// [size prefix][flatbuffer]
|
|
||||||
// |---------length--------|
|
|
||||||
template <typename SizeT = uoffset_t>
|
|
||||||
inline SizeT GetSizePrefixedBufferLength(const uint8_t* const buf) {
|
|
||||||
return ReadScalar<SizeT>(buf) + sizeof(SizeT);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Base class for native objects (FlatBuffer data de-serialized into native
|
|
||||||
// C++ data structures).
|
|
||||||
// Contains no functionality, purely documentative.
|
|
||||||
struct NativeTable {};
|
|
||||||
|
|
||||||
/// @brief Function types to be used with resolving hashes into objects and
|
|
||||||
/// back again. The resolver gets a pointer to a field inside an object API
|
|
||||||
/// object that is of the type specified in the schema using the attribute
|
|
||||||
/// `cpp_type` (it is thus important whatever you write to this address
|
|
||||||
/// matches that type). The value of this field is initially null, so you
|
|
||||||
/// may choose to implement a delayed binding lookup using this function
|
|
||||||
/// if you wish. The resolver does the opposite lookup, for when the object
|
|
||||||
/// is being serialized again.
|
|
||||||
typedef uint64_t hash_value_t;
|
|
||||||
typedef std::function<void(void** pointer_adr, hash_value_t hash)>
|
|
||||||
resolver_function_t;
|
|
||||||
typedef std::function<hash_value_t(void* pointer)> rehasher_function_t;
|
|
||||||
|
|
||||||
// Helper function to test if a field is present, using any of the field
|
|
||||||
// enums in the generated code.
|
|
||||||
// `table` must be a generated table type. Since this is a template parameter,
|
|
||||||
// this is not typechecked to be a subclass of Table, so beware!
|
|
||||||
// Note: this function will return false for fields equal to the default
|
|
||||||
// value, since they're not stored in the buffer (unless force_defaults was
|
|
||||||
// used).
|
|
||||||
template <typename T>
|
|
||||||
bool IsFieldPresent(const T* table, typename T::FlatBuffersVTableOffset field) {
|
|
||||||
// Cast, since Table is a private baseclass of any table types.
|
|
||||||
return reinterpret_cast<const Table*>(table)->CheckField(
|
|
||||||
static_cast<voffset_t>(field));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Utility function for reverse lookups on the EnumNames*() functions
|
|
||||||
// (in the generated C++ code)
|
|
||||||
// names must be NULL terminated.
|
|
||||||
inline int LookupEnum(const char** names, const char* name) {
|
|
||||||
for (const char** p = names; *p; p++)
|
|
||||||
if (!strcmp(*p, name)) return static_cast<int>(p - names);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// These macros allow us to layout a struct with a guarantee that they'll end
|
|
||||||
// up looking the same on different compilers and platforms.
|
|
||||||
// It does this by disallowing the compiler to do any padding, and then
|
|
||||||
// does padding itself by inserting extra padding fields that make every
|
|
||||||
// element aligned to its own size.
|
|
||||||
// Additionally, it manually sets the alignment of the struct as a whole,
|
|
||||||
// which is typically its largest element, or a custom size set in the schema
|
|
||||||
// by the force_align attribute.
|
|
||||||
// These are used in the generated code only.
|
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
#if defined(_MSC_VER)
|
|
||||||
#define FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(alignment) \
|
|
||||||
__pragma(pack(1)) \
|
|
||||||
struct __declspec(align(alignment))
|
|
||||||
#define FLATBUFFERS_STRUCT_END(name, size) \
|
|
||||||
__pragma(pack()) \
|
|
||||||
static_assert(sizeof(name) == size, "compiler breaks packing rules")
|
|
||||||
#elif defined(__GNUC__) || defined(__clang__) || defined(__ICCARM__)
|
|
||||||
#define FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(alignment) \
|
|
||||||
_Pragma("pack(1)") \
|
|
||||||
struct __attribute__((aligned(alignment)))
|
|
||||||
#define FLATBUFFERS_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
|
|
||||||
// clang-format on
|
|
||||||
|
|
||||||
// Minimal reflection via code generation.
|
|
||||||
// Besides full-fat reflection (see reflection.h) and parsing/printing by
|
|
||||||
// loading schemas (see idl.h), we can also have code generation for minimal
|
|
||||||
// reflection data which allows pretty-printing and other uses without needing
|
|
||||||
// a schema or a parser.
|
|
||||||
// Generate code with --reflect-types (types only) or --reflect-names (names
|
|
||||||
// also) to enable.
|
|
||||||
// See minireflect.h for utilities using this functionality.
|
|
||||||
|
|
||||||
// These types are organized slightly differently as the ones in idl.h.
|
|
||||||
enum SequenceType { ST_TABLE, ST_STRUCT, ST_UNION, ST_ENUM };
|
|
||||||
|
|
||||||
// Scalars have the same order as in idl.h
|
|
||||||
// clang-format off
|
|
||||||
#define FLATBUFFERS_GEN_ELEMENTARY_TYPES(ET) \
|
|
||||||
ET(ET_UTYPE) \
|
|
||||||
ET(ET_BOOL) \
|
|
||||||
ET(ET_CHAR) \
|
|
||||||
ET(ET_UCHAR) \
|
|
||||||
ET(ET_SHORT) \
|
|
||||||
ET(ET_USHORT) \
|
|
||||||
ET(ET_INT) \
|
|
||||||
ET(ET_UINT) \
|
|
||||||
ET(ET_LONG) \
|
|
||||||
ET(ET_ULONG) \
|
|
||||||
ET(ET_FLOAT) \
|
|
||||||
ET(ET_DOUBLE) \
|
|
||||||
ET(ET_STRING) \
|
|
||||||
ET(ET_SEQUENCE) // See SequenceType.
|
|
||||||
|
|
||||||
enum ElementaryType {
|
|
||||||
#define FLATBUFFERS_ET(E) E,
|
|
||||||
FLATBUFFERS_GEN_ELEMENTARY_TYPES(FLATBUFFERS_ET)
|
|
||||||
#undef FLATBUFFERS_ET
|
|
||||||
};
|
|
||||||
|
|
||||||
inline const char * const *ElementaryTypeNames() {
|
|
||||||
static const char * const names[] = {
|
|
||||||
#define FLATBUFFERS_ET(E) #E,
|
|
||||||
FLATBUFFERS_GEN_ELEMENTARY_TYPES(FLATBUFFERS_ET)
|
|
||||||
#undef FLATBUFFERS_ET
|
|
||||||
};
|
|
||||||
return names;
|
|
||||||
}
|
|
||||||
// clang-format on
|
|
||||||
|
|
||||||
// Basic type info cost just 16bits per field!
|
|
||||||
// We're explicitly defining the signedness since the signedness of integer
|
|
||||||
// bitfields is otherwise implementation-defined and causes warnings on older
|
|
||||||
// GCC compilers.
|
|
||||||
struct TypeCode {
|
|
||||||
// ElementaryType
|
|
||||||
unsigned short base_type : 4;
|
|
||||||
// Either vector (in table) or array (in struct)
|
|
||||||
unsigned short is_repeating : 1;
|
|
||||||
// Index into type_refs below, or -1 for none.
|
|
||||||
signed short sequence_ref : 11;
|
|
||||||
};
|
|
||||||
|
|
||||||
static_assert(sizeof(TypeCode) == 2, "TypeCode");
|
|
||||||
|
|
||||||
struct TypeTable;
|
|
||||||
|
|
||||||
// Signature of the static method present in each type.
|
|
||||||
typedef const TypeTable* (*TypeFunction)();
|
|
||||||
|
|
||||||
struct TypeTable {
|
|
||||||
SequenceType st;
|
|
||||||
size_t num_elems; // of type_codes, values, names (but not type_refs).
|
|
||||||
const TypeCode* type_codes; // num_elems count
|
|
||||||
const TypeFunction* type_refs; // less than num_elems entries (see TypeCode).
|
|
||||||
const int16_t* array_sizes; // less than num_elems entries (see TypeCode).
|
|
||||||
const int64_t* values; // Only set for non-consecutive enum/union or structs.
|
|
||||||
const char* const* names; // Only set if compiled with --reflect-names.
|
|
||||||
};
|
|
||||||
|
|
||||||
// String which identifies the current version of FlatBuffers.
|
|
||||||
inline const char* flatbuffers_version_string() {
|
|
||||||
return "FlatBuffers " FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MAJOR) "."
|
|
||||||
FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MINOR) "."
|
|
||||||
FLATBUFFERS_STRING(FLATBUFFERS_VERSION_REVISION);
|
|
||||||
}
|
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
#define FLATBUFFERS_DEFINE_BITMASK_OPERATORS(E, T)\
|
|
||||||
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator | (E lhs, E rhs){\
|
|
||||||
return E(T(lhs) | T(rhs));\
|
|
||||||
}\
|
|
||||||
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator & (E lhs, E rhs){\
|
|
||||||
return E(T(lhs) & T(rhs));\
|
|
||||||
}\
|
|
||||||
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator ^ (E lhs, E rhs){\
|
|
||||||
return E(T(lhs) ^ T(rhs));\
|
|
||||||
}\
|
|
||||||
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator ~ (E lhs){\
|
|
||||||
return E(~T(lhs));\
|
|
||||||
}\
|
|
||||||
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator |= (E &lhs, E rhs){\
|
|
||||||
lhs = lhs | rhs;\
|
|
||||||
return lhs;\
|
|
||||||
}\
|
|
||||||
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator &= (E &lhs, E rhs){\
|
|
||||||
lhs = lhs & rhs;\
|
|
||||||
return lhs;\
|
|
||||||
}\
|
|
||||||
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator ^= (E &lhs, E rhs){\
|
|
||||||
lhs = lhs ^ rhs;\
|
|
||||||
return lhs;\
|
|
||||||
}\
|
|
||||||
inline FLATBUFFERS_CONSTEXPR_CPP11 bool operator !(E rhs) \
|
|
||||||
{\
|
|
||||||
return !bool(T(rhs)); \
|
|
||||||
}
|
|
||||||
/// @endcond
|
|
||||||
} // namespace flatbuffers
|
|
||||||
|
|
||||||
// clang-format on
|
|
||||||
|
|
||||||
#endif // FLATBUFFERS_H_
|
|
||||||
@@ -1,514 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2017 Google Inc. All rights reserved.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLATBUFFERS_STL_EMULATION_H_
|
|
||||||
#define FLATBUFFERS_STL_EMULATION_H_
|
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
#include "flatbuffers/base.h"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <type_traits>
|
|
||||||
#include <vector>
|
|
||||||
#include <memory>
|
|
||||||
#include <limits>
|
|
||||||
|
|
||||||
#ifndef FLATBUFFERS_USE_STD_OPTIONAL
|
|
||||||
// Detect C++17 compatible compiler.
|
|
||||||
// __cplusplus >= 201703L - a compiler has support of 'static inline' variables.
|
|
||||||
#if (defined(__cplusplus) && __cplusplus >= 201703L) \
|
|
||||||
|| (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
|
|
||||||
#define FLATBUFFERS_USE_STD_OPTIONAL 1
|
|
||||||
#else
|
|
||||||
#define FLATBUFFERS_USE_STD_OPTIONAL 0
|
|
||||||
#endif // (defined(__cplusplus) && __cplusplus >= 201703L) ...
|
|
||||||
#endif // FLATBUFFERS_USE_STD_OPTIONAL
|
|
||||||
|
|
||||||
#if FLATBUFFERS_USE_STD_OPTIONAL
|
|
||||||
#include <optional>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef FLATBUFFERS_USE_STD_SPAN
|
|
||||||
// Testing __cpp_lib_span requires including either <version> or <span>,
|
|
||||||
// both of which were added in C++20.
|
|
||||||
// See: https://en.cppreference.com/w/cpp/utility/feature_test
|
|
||||||
#if defined(__cplusplus) && __cplusplus >= 202002L \
|
|
||||||
|| (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
|
|
||||||
#define FLATBUFFERS_USE_STD_SPAN 1
|
|
||||||
#endif
|
|
||||||
#endif // FLATBUFFERS_USE_STD_SPAN
|
|
||||||
|
|
||||||
#if defined(FLATBUFFERS_USE_STD_SPAN)
|
|
||||||
#include <array>
|
|
||||||
#include <span>
|
|
||||||
#else
|
|
||||||
// Disable non-trivial ctors if FLATBUFFERS_SPAN_MINIMAL defined.
|
|
||||||
#if !defined(FLATBUFFERS_TEMPLATES_ALIASES)
|
|
||||||
#define FLATBUFFERS_SPAN_MINIMAL
|
|
||||||
#else
|
|
||||||
// Enable implicit construction of a span<T,N> from a std::array<T,N>.
|
|
||||||
#include <array>
|
|
||||||
#endif
|
|
||||||
#endif // defined(FLATBUFFERS_USE_STD_SPAN)
|
|
||||||
|
|
||||||
// This header provides backwards compatibility for older versions of the STL.
|
|
||||||
namespace flatbuffers {
|
|
||||||
|
|
||||||
#if defined(FLATBUFFERS_TEMPLATES_ALIASES)
|
|
||||||
template <typename T>
|
|
||||||
using numeric_limits = std::numeric_limits<T>;
|
|
||||||
#else
|
|
||||||
template <typename T> class numeric_limits :
|
|
||||||
public std::numeric_limits<T> {};
|
|
||||||
#endif // defined(FLATBUFFERS_TEMPLATES_ALIASES)
|
|
||||||
|
|
||||||
#if defined(FLATBUFFERS_TEMPLATES_ALIASES)
|
|
||||||
template <typename T> using is_scalar = std::is_scalar<T>;
|
|
||||||
template <typename T, typename U> using is_same = std::is_same<T,U>;
|
|
||||||
template <typename T> using is_floating_point = std::is_floating_point<T>;
|
|
||||||
template <typename T> using is_unsigned = std::is_unsigned<T>;
|
|
||||||
template <typename T> using is_enum = std::is_enum<T>;
|
|
||||||
template <typename T> using make_unsigned = std::make_unsigned<T>;
|
|
||||||
template<bool B, class T, class F>
|
|
||||||
using conditional = std::conditional<B, T, F>;
|
|
||||||
template<class T, T v>
|
|
||||||
using integral_constant = std::integral_constant<T, v>;
|
|
||||||
template <bool B>
|
|
||||||
using bool_constant = integral_constant<bool, B>;
|
|
||||||
using true_type = std::true_type;
|
|
||||||
using false_type = std::false_type;
|
|
||||||
#else
|
|
||||||
// MSVC 2010 doesn't support C++11 aliases.
|
|
||||||
template <typename T> struct is_scalar : public std::is_scalar<T> {};
|
|
||||||
template <typename T, typename U> struct is_same : public std::is_same<T,U> {};
|
|
||||||
template <typename T> struct is_floating_point :
|
|
||||||
public std::is_floating_point<T> {};
|
|
||||||
template <typename T> struct is_unsigned : public std::is_unsigned<T> {};
|
|
||||||
template <typename T> struct is_enum : public std::is_enum<T> {};
|
|
||||||
template <typename T> struct make_unsigned : public std::make_unsigned<T> {};
|
|
||||||
template<bool B, class T, class F>
|
|
||||||
struct conditional : public std::conditional<B, T, F> {};
|
|
||||||
template<class T, T v>
|
|
||||||
struct integral_constant : public std::integral_constant<T, v> {};
|
|
||||||
template <bool B>
|
|
||||||
struct bool_constant : public integral_constant<bool, B> {};
|
|
||||||
typedef bool_constant<true> true_type;
|
|
||||||
typedef bool_constant<false> false_type;
|
|
||||||
#endif // defined(FLATBUFFERS_TEMPLATES_ALIASES)
|
|
||||||
|
|
||||||
#if defined(FLATBUFFERS_TEMPLATES_ALIASES)
|
|
||||||
template <class T> using unique_ptr = std::unique_ptr<T>;
|
|
||||||
#else
|
|
||||||
// MSVC 2010 doesn't support C++11 aliases.
|
|
||||||
// We're manually "aliasing" the class here as we want to bring unique_ptr
|
|
||||||
// into the flatbuffers namespace. We have unique_ptr in the flatbuffers
|
|
||||||
// namespace we have a completely independent implementation (see below)
|
|
||||||
// for C++98 STL implementations.
|
|
||||||
template <class T> class unique_ptr : public std::unique_ptr<T> {
|
|
||||||
public:
|
|
||||||
unique_ptr() {}
|
|
||||||
explicit unique_ptr(T* p) : std::unique_ptr<T>(p) {}
|
|
||||||
unique_ptr(std::unique_ptr<T>&& u) { *this = std::move(u); }
|
|
||||||
unique_ptr(unique_ptr&& u) { *this = std::move(u); }
|
|
||||||
unique_ptr& operator=(std::unique_ptr<T>&& u) {
|
|
||||||
std::unique_ptr<T>::reset(u.release());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
unique_ptr& operator=(unique_ptr&& u) {
|
|
||||||
std::unique_ptr<T>::reset(u.release());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
unique_ptr& operator=(T* p) {
|
|
||||||
return std::unique_ptr<T>::operator=(p);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
#endif // defined(FLATBUFFERS_TEMPLATES_ALIASES)
|
|
||||||
|
|
||||||
#if FLATBUFFERS_USE_STD_OPTIONAL
|
|
||||||
template<class T>
|
|
||||||
using Optional = std::optional<T>;
|
|
||||||
using nullopt_t = std::nullopt_t;
|
|
||||||
inline constexpr nullopt_t nullopt = std::nullopt;
|
|
||||||
|
|
||||||
#else
|
|
||||||
// Limited implementation of Optional<T> type for a scalar T.
|
|
||||||
// This implementation limited by trivial types compatible with
|
|
||||||
// std::is_arithmetic<T> or std::is_enum<T> type traits.
|
|
||||||
|
|
||||||
// A tag to indicate an empty flatbuffers::optional<T>.
|
|
||||||
struct nullopt_t {
|
|
||||||
explicit FLATBUFFERS_CONSTEXPR_CPP11 nullopt_t(int) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
#if defined(FLATBUFFERS_CONSTEXPR_DEFINED)
|
|
||||||
namespace internal {
|
|
||||||
template <class> struct nullopt_holder {
|
|
||||||
static constexpr nullopt_t instance_ = nullopt_t(0);
|
|
||||||
};
|
|
||||||
template<class Dummy>
|
|
||||||
constexpr nullopt_t nullopt_holder<Dummy>::instance_;
|
|
||||||
}
|
|
||||||
static constexpr const nullopt_t &nullopt = internal::nullopt_holder<void>::instance_;
|
|
||||||
|
|
||||||
#else
|
|
||||||
namespace internal {
|
|
||||||
template <class> struct nullopt_holder {
|
|
||||||
static const nullopt_t instance_;
|
|
||||||
};
|
|
||||||
template<class Dummy>
|
|
||||||
const nullopt_t nullopt_holder<Dummy>::instance_ = nullopt_t(0);
|
|
||||||
}
|
|
||||||
static const nullopt_t &nullopt = internal::nullopt_holder<void>::instance_;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
class Optional FLATBUFFERS_FINAL_CLASS {
|
|
||||||
// Non-scalar 'T' would extremely complicated Optional<T>.
|
|
||||||
// Use is_scalar<T> checking because flatbuffers flatbuffers::is_arithmetic<T>
|
|
||||||
// isn't implemented.
|
|
||||||
static_assert(flatbuffers::is_scalar<T>::value, "unexpected type T");
|
|
||||||
|
|
||||||
public:
|
|
||||||
~Optional() {}
|
|
||||||
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 Optional() FLATBUFFERS_NOEXCEPT
|
|
||||||
: value_(), has_value_(false) {}
|
|
||||||
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 Optional(nullopt_t) FLATBUFFERS_NOEXCEPT
|
|
||||||
: value_(), has_value_(false) {}
|
|
||||||
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 Optional(T val) FLATBUFFERS_NOEXCEPT
|
|
||||||
: value_(val), has_value_(true) {}
|
|
||||||
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 Optional(const Optional &other) FLATBUFFERS_NOEXCEPT
|
|
||||||
: value_(other.value_), has_value_(other.has_value_) {}
|
|
||||||
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP14 Optional &operator=(const Optional &other) FLATBUFFERS_NOEXCEPT {
|
|
||||||
value_ = other.value_;
|
|
||||||
has_value_ = other.has_value_;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP14 Optional &operator=(nullopt_t) FLATBUFFERS_NOEXCEPT {
|
|
||||||
value_ = T();
|
|
||||||
has_value_ = false;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP14 Optional &operator=(T val) FLATBUFFERS_NOEXCEPT {
|
|
||||||
value_ = val;
|
|
||||||
has_value_ = true;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void reset() FLATBUFFERS_NOEXCEPT {
|
|
||||||
*this = nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
void swap(Optional &other) FLATBUFFERS_NOEXCEPT {
|
|
||||||
std::swap(value_, other.value_);
|
|
||||||
std::swap(has_value_, other.has_value_);
|
|
||||||
}
|
|
||||||
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 FLATBUFFERS_EXPLICIT_CPP11 operator bool() const FLATBUFFERS_NOEXCEPT {
|
|
||||||
return has_value_;
|
|
||||||
}
|
|
||||||
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 bool has_value() const FLATBUFFERS_NOEXCEPT {
|
|
||||||
return has_value_;
|
|
||||||
}
|
|
||||||
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 const T& operator*() const FLATBUFFERS_NOEXCEPT {
|
|
||||||
return value_;
|
|
||||||
}
|
|
||||||
|
|
||||||
const T& value() const {
|
|
||||||
FLATBUFFERS_ASSERT(has_value());
|
|
||||||
return value_;
|
|
||||||
}
|
|
||||||
|
|
||||||
T value_or(T default_value) const FLATBUFFERS_NOEXCEPT {
|
|
||||||
return has_value() ? value_ : default_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
T value_;
|
|
||||||
bool has_value_;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 bool operator==(const Optional<T>& opt, nullopt_t) FLATBUFFERS_NOEXCEPT {
|
|
||||||
return !opt;
|
|
||||||
}
|
|
||||||
template<class T>
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 bool operator==(nullopt_t, const Optional<T>& opt) FLATBUFFERS_NOEXCEPT {
|
|
||||||
return !opt;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T, class U>
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 bool operator==(const Optional<T>& lhs, const U& rhs) FLATBUFFERS_NOEXCEPT {
|
|
||||||
return static_cast<bool>(lhs) && (*lhs == rhs);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T, class U>
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 bool operator==(const T& lhs, const Optional<U>& rhs) FLATBUFFERS_NOEXCEPT {
|
|
||||||
return static_cast<bool>(rhs) && (lhs == *rhs);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T, class U>
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 bool operator==(const Optional<T>& lhs, const Optional<U>& rhs) FLATBUFFERS_NOEXCEPT {
|
|
||||||
return static_cast<bool>(lhs) != static_cast<bool>(rhs)
|
|
||||||
? false
|
|
||||||
: !static_cast<bool>(lhs) ? true : (*lhs == *rhs);
|
|
||||||
}
|
|
||||||
#endif // FLATBUFFERS_USE_STD_OPTIONAL
|
|
||||||
|
|
||||||
|
|
||||||
// Very limited and naive partial implementation of C++20 std::span<T,Extent>.
|
|
||||||
#if defined(FLATBUFFERS_USE_STD_SPAN)
|
|
||||||
inline constexpr std::size_t dynamic_extent = std::dynamic_extent;
|
|
||||||
template<class T, std::size_t Extent = std::dynamic_extent>
|
|
||||||
using span = std::span<T, Extent>;
|
|
||||||
|
|
||||||
#else // !defined(FLATBUFFERS_USE_STD_SPAN)
|
|
||||||
FLATBUFFERS_CONSTEXPR std::size_t dynamic_extent = static_cast<std::size_t>(-1);
|
|
||||||
|
|
||||||
// Exclude this code if MSVC2010 or non-STL Android is active.
|
|
||||||
// The non-STL Android doesn't have `std::is_convertible` required for SFINAE.
|
|
||||||
#if !defined(FLATBUFFERS_SPAN_MINIMAL)
|
|
||||||
namespace internal {
|
|
||||||
// This is SFINAE helper class for checking of a common condition:
|
|
||||||
// > This overload only participates in overload resolution
|
|
||||||
// > Check whether a pointer to an array of From can be converted
|
|
||||||
// > to a pointer to an array of To.
|
|
||||||
// This helper is used for checking of 'From -> const From'.
|
|
||||||
template<class To, std::size_t Extent, class From, std::size_t N>
|
|
||||||
struct is_span_convertible {
|
|
||||||
using type =
|
|
||||||
typename std::conditional<std::is_convertible<From (*)[], To (*)[]>::value
|
|
||||||
&& (Extent == dynamic_extent || N == Extent),
|
|
||||||
int, void>::type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct SpanIterator {
|
|
||||||
// TODO: upgrade to std::random_access_iterator_tag.
|
|
||||||
using iterator_category = std::forward_iterator_tag;
|
|
||||||
using difference_type = std::ptrdiff_t;
|
|
||||||
using value_type = typename std::remove_cv<T>::type;
|
|
||||||
using reference = T&;
|
|
||||||
using pointer = T*;
|
|
||||||
|
|
||||||
// Convince MSVC compiler that this iterator is trusted (it is verified).
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
using _Unchecked_type = pointer;
|
|
||||||
#endif // _MSC_VER
|
|
||||||
|
|
||||||
SpanIterator(pointer ptr) : ptr_(ptr) {}
|
|
||||||
reference operator*() const { return *ptr_; }
|
|
||||||
pointer operator->() { return ptr_; }
|
|
||||||
SpanIterator& operator++() { ptr_++; return *this; }
|
|
||||||
SpanIterator operator++(int) { auto tmp = *this; ++(*this); return tmp; }
|
|
||||||
|
|
||||||
friend bool operator== (const SpanIterator& lhs, const SpanIterator& rhs) { return lhs.ptr_ == rhs.ptr_; }
|
|
||||||
friend bool operator!= (const SpanIterator& lhs, const SpanIterator& rhs) { return lhs.ptr_ != rhs.ptr_; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
pointer ptr_;
|
|
||||||
};
|
|
||||||
} // namespace internal
|
|
||||||
#endif // !defined(FLATBUFFERS_SPAN_MINIMAL)
|
|
||||||
|
|
||||||
// T - element type; must be a complete type that is not an abstract
|
|
||||||
// class type.
|
|
||||||
// Extent - the number of elements in the sequence, or dynamic.
|
|
||||||
template<class T, std::size_t Extent = dynamic_extent>
|
|
||||||
class span FLATBUFFERS_FINAL_CLASS {
|
|
||||||
public:
|
|
||||||
typedef T element_type;
|
|
||||||
typedef T& reference;
|
|
||||||
typedef const T& const_reference;
|
|
||||||
typedef T* pointer;
|
|
||||||
typedef const T* const_pointer;
|
|
||||||
typedef std::size_t size_type;
|
|
||||||
|
|
||||||
static FLATBUFFERS_CONSTEXPR size_type extent = Extent;
|
|
||||||
|
|
||||||
// Returns the number of elements in the span.
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 size_type size() const FLATBUFFERS_NOEXCEPT {
|
|
||||||
return count_;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns the size of the sequence in bytes.
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11
|
|
||||||
size_type size_bytes() const FLATBUFFERS_NOEXCEPT {
|
|
||||||
return size() * sizeof(element_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Checks if the span is empty.
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 bool empty() const FLATBUFFERS_NOEXCEPT {
|
|
||||||
return size() == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns a pointer to the beginning of the sequence.
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 pointer data() const FLATBUFFERS_NOEXCEPT {
|
|
||||||
return data_;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !defined(FLATBUFFERS_SPAN_MINIMAL)
|
|
||||||
using Iterator = internal::SpanIterator<T>;
|
|
||||||
|
|
||||||
Iterator begin() const { return Iterator(data()); }
|
|
||||||
Iterator end() const { return Iterator(data() + size()); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Returns a reference to the idx-th element of the sequence.
|
|
||||||
// The behavior is undefined if the idx is greater than or equal to size().
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 reference operator[](size_type idx) const {
|
|
||||||
return data()[idx];
|
|
||||||
}
|
|
||||||
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 span(const span &other) FLATBUFFERS_NOEXCEPT
|
|
||||||
: data_(other.data_), count_(other.count_) {}
|
|
||||||
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP14 span &operator=(const span &other)
|
|
||||||
FLATBUFFERS_NOEXCEPT {
|
|
||||||
data_ = other.data_;
|
|
||||||
count_ = other.count_;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Limited implementation of
|
|
||||||
// `template <class It> constexpr std::span(It first, size_type count);`.
|
|
||||||
//
|
|
||||||
// Constructs a span that is a view over the range [first, first + count);
|
|
||||||
// the resulting span has: data() == first and size() == count.
|
|
||||||
// The behavior is undefined if [first, first + count) is not a valid range,
|
|
||||||
// or if (extent != flatbuffers::dynamic_extent && count != extent).
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11
|
|
||||||
explicit span(pointer first, size_type count) FLATBUFFERS_NOEXCEPT
|
|
||||||
: data_ (Extent == dynamic_extent ? first : (Extent == count ? first : nullptr)),
|
|
||||||
count_(Extent == dynamic_extent ? count : (Extent == count ? Extent : 0)) {
|
|
||||||
// Make span empty if the count argument is incompatible with span<T,N>.
|
|
||||||
}
|
|
||||||
|
|
||||||
// Exclude this code if MSVC2010 is active. The MSVC2010 isn't C++11
|
|
||||||
// compliant, it doesn't support default template arguments for functions.
|
|
||||||
#if defined(FLATBUFFERS_SPAN_MINIMAL)
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 span() FLATBUFFERS_NOEXCEPT : data_(nullptr),
|
|
||||||
count_(0) {
|
|
||||||
static_assert(extent == 0 || extent == dynamic_extent, "invalid span");
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
// Constructs an empty span whose data() == nullptr and size() == 0.
|
|
||||||
// This overload only participates in overload resolution if
|
|
||||||
// extent == 0 || extent == flatbuffers::dynamic_extent.
|
|
||||||
// A dummy template argument N is need dependency for SFINAE.
|
|
||||||
template<std::size_t N = 0,
|
|
||||||
typename internal::is_span_convertible<element_type, Extent, element_type, (N - N)>::type = 0>
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 span() FLATBUFFERS_NOEXCEPT : data_(nullptr),
|
|
||||||
count_(0) {
|
|
||||||
static_assert(extent == 0 || extent == dynamic_extent, "invalid span");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Constructs a span that is a view over the array arr; the resulting span
|
|
||||||
// has size() == N and data() == std::data(arr). These overloads only
|
|
||||||
// participate in overload resolution if
|
|
||||||
// extent == std::dynamic_extent || N == extent is true and
|
|
||||||
// std::remove_pointer_t<decltype(std::data(arr))>(*)[]
|
|
||||||
// is convertible to element_type (*)[].
|
|
||||||
template<std::size_t N,
|
|
||||||
typename internal::is_span_convertible<element_type, Extent, element_type, N>::type = 0>
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 span(element_type (&arr)[N]) FLATBUFFERS_NOEXCEPT
|
|
||||||
: data_(arr), count_(N) {}
|
|
||||||
|
|
||||||
template<class U, std::size_t N,
|
|
||||||
typename internal::is_span_convertible<element_type, Extent, U, N>::type = 0>
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 span(std::array<U, N> &arr) FLATBUFFERS_NOEXCEPT
|
|
||||||
: data_(arr.data()), count_(N) {}
|
|
||||||
|
|
||||||
//template<class U, std::size_t N,
|
|
||||||
// int = 0>
|
|
||||||
//FLATBUFFERS_CONSTEXPR_CPP11 span(std::array<U, N> &arr) FLATBUFFERS_NOEXCEPT
|
|
||||||
// : data_(arr.data()), count_(N) {}
|
|
||||||
|
|
||||||
template<class U, std::size_t N,
|
|
||||||
typename internal::is_span_convertible<element_type, Extent, U, N>::type = 0>
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 span(const std::array<U, N> &arr) FLATBUFFERS_NOEXCEPT
|
|
||||||
: data_(arr.data()), count_(N) {}
|
|
||||||
|
|
||||||
// Converting constructor from another span s;
|
|
||||||
// the resulting span has size() == s.size() and data() == s.data().
|
|
||||||
// This overload only participates in overload resolution
|
|
||||||
// if extent == std::dynamic_extent || N == extent is true and U (*)[]
|
|
||||||
// is convertible to element_type (*)[].
|
|
||||||
template<class U, std::size_t N,
|
|
||||||
typename internal::is_span_convertible<element_type, Extent, U, N>::type = 0>
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 span(const flatbuffers::span<U, N> &s) FLATBUFFERS_NOEXCEPT
|
|
||||||
: span(s.data(), s.size()) {
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // !defined(FLATBUFFERS_SPAN_MINIMAL)
|
|
||||||
|
|
||||||
private:
|
|
||||||
// This is a naive implementation with 'count_' member even if (Extent != dynamic_extent).
|
|
||||||
pointer const data_;
|
|
||||||
size_type count_;
|
|
||||||
};
|
|
||||||
#endif // defined(FLATBUFFERS_USE_STD_SPAN)
|
|
||||||
|
|
||||||
#if !defined(FLATBUFFERS_SPAN_MINIMAL)
|
|
||||||
template<class ElementType, std::size_t Extent>
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11
|
|
||||||
flatbuffers::span<ElementType, Extent> make_span(ElementType(&arr)[Extent]) FLATBUFFERS_NOEXCEPT {
|
|
||||||
return span<ElementType, Extent>(arr);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class ElementType, std::size_t Extent>
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11
|
|
||||||
flatbuffers::span<const ElementType, Extent> make_span(const ElementType(&arr)[Extent]) FLATBUFFERS_NOEXCEPT {
|
|
||||||
return span<const ElementType, Extent>(arr);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class ElementType, std::size_t Extent>
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11
|
|
||||||
flatbuffers::span<ElementType, Extent> make_span(std::array<ElementType, Extent> &arr) FLATBUFFERS_NOEXCEPT {
|
|
||||||
return span<ElementType, Extent>(arr);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class ElementType, std::size_t Extent>
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11
|
|
||||||
flatbuffers::span<const ElementType, Extent> make_span(const std::array<ElementType, Extent> &arr) FLATBUFFERS_NOEXCEPT {
|
|
||||||
return span<const ElementType, Extent>(arr);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class ElementType, std::size_t Extent>
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11
|
|
||||||
flatbuffers::span<ElementType, dynamic_extent> make_span(ElementType *first, std::size_t count) FLATBUFFERS_NOEXCEPT {
|
|
||||||
return span<ElementType, dynamic_extent>(first, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class ElementType, std::size_t Extent>
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11
|
|
||||||
flatbuffers::span<const ElementType, dynamic_extent> make_span(const ElementType *first, std::size_t count) FLATBUFFERS_NOEXCEPT {
|
|
||||||
return span<const ElementType, dynamic_extent>(first, count);
|
|
||||||
}
|
|
||||||
#endif // !defined(FLATBUFFERS_SPAN_MINIMAL)
|
|
||||||
|
|
||||||
} // namespace flatbuffers
|
|
||||||
|
|
||||||
#endif // FLATBUFFERS_STL_EMULATION_H_
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2021 Google Inc. All rights reserved.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLATBUFFERS_STRING_H_
|
|
||||||
#define FLATBUFFERS_STRING_H_
|
|
||||||
|
|
||||||
#include "flatbuffers/base.h"
|
|
||||||
#include "flatbuffers/vector.h"
|
|
||||||
|
|
||||||
namespace flatbuffers {
|
|
||||||
|
|
||||||
struct String : public Vector<char> {
|
|
||||||
const char* c_str() const { return reinterpret_cast<const char*>(Data()); }
|
|
||||||
std::string str() const { return std::string(c_str(), size()); }
|
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
#ifdef FLATBUFFERS_HAS_STRING_VIEW
|
|
||||||
flatbuffers::string_view string_view() const {
|
|
||||||
return flatbuffers::string_view(c_str(), size());
|
|
||||||
}
|
|
||||||
|
|
||||||
/* implicit */
|
|
||||||
operator flatbuffers::string_view() const {
|
|
||||||
return flatbuffers::string_view(c_str(), size());
|
|
||||||
}
|
|
||||||
#endif // FLATBUFFERS_HAS_STRING_VIEW
|
|
||||||
// clang-format on
|
|
||||||
|
|
||||||
bool operator<(const String& o) const {
|
|
||||||
return StringLessThan(this->data(), this->size(), o.data(), o.size());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Convenience function to get std::string from a String returning an empty
|
|
||||||
// string on null pointer.
|
|
||||||
static inline std::string GetString(const String* str) {
|
|
||||||
return str ? str->str() : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convenience function to get char* from a String returning an empty string on
|
|
||||||
// null pointer.
|
|
||||||
static inline const char* GetCstring(const String* str) {
|
|
||||||
return str ? str->c_str() : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef FLATBUFFERS_HAS_STRING_VIEW
|
|
||||||
// Convenience function to get string_view from a String returning an empty
|
|
||||||
// string_view on null pointer.
|
|
||||||
static inline flatbuffers::string_view GetStringView(const String* str) {
|
|
||||||
return str ? str->string_view() : flatbuffers::string_view();
|
|
||||||
}
|
|
||||||
#endif // FLATBUFFERS_HAS_STRING_VIEW
|
|
||||||
|
|
||||||
} // namespace flatbuffers
|
|
||||||
|
|
||||||
#endif // FLATBUFFERS_STRING_H_
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2021 Google Inc. All rights reserved.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLATBUFFERS_STRUCT_H_
|
|
||||||
#define FLATBUFFERS_STRUCT_H_
|
|
||||||
|
|
||||||
#include "flatbuffers/base.h"
|
|
||||||
|
|
||||||
namespace flatbuffers {
|
|
||||||
|
|
||||||
// "structs" are flat structures that do not have an offset table, thus
|
|
||||||
// always have all members present and do not support forwards/backwards
|
|
||||||
// compatible extensions.
|
|
||||||
|
|
||||||
class Struct FLATBUFFERS_FINAL_CLASS {
|
|
||||||
public:
|
|
||||||
template <typename T>
|
|
||||||
T GetField(uoffset_t o) const {
|
|
||||||
return ReadScalar<T>(&data_[o]);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
T GetStruct(uoffset_t o) const {
|
|
||||||
return reinterpret_cast<T>(&data_[o]);
|
|
||||||
}
|
|
||||||
|
|
||||||
const uint8_t* GetAddressOf(uoffset_t o) const { return &data_[o]; }
|
|
||||||
uint8_t* GetAddressOf(uoffset_t o) { return &data_[o]; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
// private constructor & copy constructor: you obtain instances of this
|
|
||||||
// class by pointing to existing data only
|
|
||||||
Struct();
|
|
||||||
Struct(const Struct&);
|
|
||||||
Struct& operator=(const Struct&);
|
|
||||||
|
|
||||||
uint8_t data_[1];
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace flatbuffers
|
|
||||||
|
|
||||||
#endif // FLATBUFFERS_STRUCT_H_
|
|
||||||
-194
@@ -1,194 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2021 Google Inc. All rights reserved.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLATBUFFERS_TABLE_H_
|
|
||||||
#define FLATBUFFERS_TABLE_H_
|
|
||||||
|
|
||||||
#include "flatbuffers/base.h"
|
|
||||||
#include "flatbuffers/verifier.h"
|
|
||||||
|
|
||||||
namespace flatbuffers {
|
|
||||||
|
|
||||||
// "tables" use an offset table (possibly shared) that allows fields to be
|
|
||||||
// omitted and added at will, but uses an extra indirection to read.
|
|
||||||
class Table {
|
|
||||||
public:
|
|
||||||
const uint8_t* GetVTable() const {
|
|
||||||
return data_ - ReadScalar<soffset_t>(data_);
|
|
||||||
}
|
|
||||||
|
|
||||||
// This gets the field offset for any of the functions below it, or 0
|
|
||||||
// if the field was not present.
|
|
||||||
voffset_t GetOptionalFieldOffset(voffset_t field) const {
|
|
||||||
// The vtable offset is always at the start.
|
|
||||||
auto vtable = GetVTable();
|
|
||||||
// The first element is the size of the vtable (fields + type id + itself).
|
|
||||||
auto vtsize = ReadScalar<voffset_t>(vtable);
|
|
||||||
// If the field we're accessing is outside the vtable, we're reading older
|
|
||||||
// data, so it's the same as if the offset was 0 (not present).
|
|
||||||
return field < vtsize ? ReadScalar<voffset_t>(vtable + field) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
T GetField(voffset_t field, T defaultval) const {
|
|
||||||
auto field_offset = GetOptionalFieldOffset(field);
|
|
||||||
return field_offset ? ReadScalar<T>(data_ + field_offset) : defaultval;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename P, typename OffsetSize = uoffset_t>
|
|
||||||
P GetPointer(voffset_t field) {
|
|
||||||
auto field_offset = GetOptionalFieldOffset(field);
|
|
||||||
auto p = data_ + field_offset;
|
|
||||||
return field_offset ? reinterpret_cast<P>(p + ReadScalar<OffsetSize>(p))
|
|
||||||
: nullptr;
|
|
||||||
}
|
|
||||||
template <typename P, typename OffsetSize = uoffset_t>
|
|
||||||
P GetPointer(voffset_t field) const {
|
|
||||||
return const_cast<Table*>(this)->GetPointer<P, OffsetSize>(field);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename P>
|
|
||||||
P GetPointer64(voffset_t field) {
|
|
||||||
return GetPointer<P, uoffset64_t>(field);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename P>
|
|
||||||
P GetPointer64(voffset_t field) const {
|
|
||||||
return GetPointer<P, uoffset64_t>(field);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename P>
|
|
||||||
P GetStruct(voffset_t field) const {
|
|
||||||
auto field_offset = GetOptionalFieldOffset(field);
|
|
||||||
auto p = const_cast<uint8_t*>(data_ + field_offset);
|
|
||||||
return field_offset ? reinterpret_cast<P>(p) : nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Raw, typename Face>
|
|
||||||
flatbuffers::Optional<Face> GetOptional(voffset_t field) const {
|
|
||||||
auto field_offset = GetOptionalFieldOffset(field);
|
|
||||||
auto p = data_ + field_offset;
|
|
||||||
return field_offset ? Optional<Face>(static_cast<Face>(ReadScalar<Raw>(p)))
|
|
||||||
: Optional<Face>();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
bool SetField(voffset_t field, T val, T def) {
|
|
||||||
auto field_offset = GetOptionalFieldOffset(field);
|
|
||||||
if (!field_offset) return IsTheSameAs(val, def);
|
|
||||||
WriteScalar(data_ + field_offset, val);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
template <typename T>
|
|
||||||
bool SetField(voffset_t field, T val) {
|
|
||||||
auto field_offset = GetOptionalFieldOffset(field);
|
|
||||||
if (!field_offset) return false;
|
|
||||||
WriteScalar(data_ + field_offset, val);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SetPointer(voffset_t field, const uint8_t* val) {
|
|
||||||
auto field_offset = GetOptionalFieldOffset(field);
|
|
||||||
if (!field_offset) return false;
|
|
||||||
WriteScalar(data_ + field_offset,
|
|
||||||
static_cast<uoffset_t>(val - (data_ + field_offset)));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t* GetAddressOf(voffset_t field) {
|
|
||||||
auto field_offset = GetOptionalFieldOffset(field);
|
|
||||||
return field_offset ? data_ + field_offset : nullptr;
|
|
||||||
}
|
|
||||||
const uint8_t* GetAddressOf(voffset_t field) const {
|
|
||||||
return const_cast<Table*>(this)->GetAddressOf(field);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CheckField(voffset_t field) const {
|
|
||||||
return GetOptionalFieldOffset(field) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify the vtable of this table.
|
|
||||||
// Call this once per table, followed by VerifyField once per field.
|
|
||||||
bool VerifyTableStart(Verifier& verifier) const {
|
|
||||||
return verifier.VerifyTableStart(data_);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify a particular field.
|
|
||||||
template <typename T>
|
|
||||||
bool VerifyField(const Verifier& verifier, voffset_t field,
|
|
||||||
size_t align) const {
|
|
||||||
// Calling GetOptionalFieldOffset should be safe now thanks to
|
|
||||||
// VerifyTable().
|
|
||||||
auto field_offset = GetOptionalFieldOffset(field);
|
|
||||||
// Check the actual field.
|
|
||||||
return !field_offset || verifier.VerifyField<T>(data_, field_offset, align);
|
|
||||||
}
|
|
||||||
|
|
||||||
// VerifyField for required fields.
|
|
||||||
template <typename T>
|
|
||||||
bool VerifyFieldRequired(const Verifier& verifier, voffset_t field,
|
|
||||||
size_t align) const {
|
|
||||||
auto field_offset = GetOptionalFieldOffset(field);
|
|
||||||
return verifier.Check(field_offset != 0) &&
|
|
||||||
verifier.VerifyField<T>(data_, field_offset, align);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Versions for offsets.
|
|
||||||
template <typename OffsetT = uoffset_t>
|
|
||||||
bool VerifyOffset(const Verifier& verifier, voffset_t field) const {
|
|
||||||
auto field_offset = GetOptionalFieldOffset(field);
|
|
||||||
return !field_offset || verifier.VerifyOffset<OffsetT>(data_, field_offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename OffsetT = uoffset_t>
|
|
||||||
bool VerifyOffsetRequired(const Verifier& verifier, voffset_t field) const {
|
|
||||||
auto field_offset = GetOptionalFieldOffset(field);
|
|
||||||
return verifier.Check(field_offset != 0) &&
|
|
||||||
verifier.VerifyOffset<OffsetT>(data_, field_offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VerifyOffset64(const Verifier& verifier, voffset_t field) const {
|
|
||||||
return VerifyOffset<uoffset64_t>(verifier, field);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VerifyOffset64Required(const Verifier& verifier, voffset_t field) const {
|
|
||||||
return VerifyOffsetRequired<uoffset64_t>(verifier, field);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
// private constructor & copy constructor: you obtain instances of this
|
|
||||||
// class by pointing to existing data only
|
|
||||||
Table();
|
|
||||||
Table(const Table& other);
|
|
||||||
Table& operator=(const Table&);
|
|
||||||
|
|
||||||
uint8_t data_[1];
|
|
||||||
};
|
|
||||||
|
|
||||||
// This specialization allows avoiding warnings like:
|
|
||||||
// MSVC C4800: type: forcing value to bool 'true' or 'false'.
|
|
||||||
template <>
|
|
||||||
inline flatbuffers::Optional<bool> Table::GetOptional<uint8_t, bool>(
|
|
||||||
voffset_t field) const {
|
|
||||||
auto field_offset = GetOptionalFieldOffset(field);
|
|
||||||
auto p = data_ + field_offset;
|
|
||||||
return field_offset ? Optional<bool>(ReadScalar<uint8_t>(p) != 0)
|
|
||||||
: Optional<bool>();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace flatbuffers
|
|
||||||
|
|
||||||
#endif // FLATBUFFERS_TABLE_H_
|
|
||||||
-422
@@ -1,422 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2021 Google Inc. All rights reserved.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLATBUFFERS_VECTOR_H_
|
|
||||||
#define FLATBUFFERS_VECTOR_H_
|
|
||||||
|
|
||||||
#include "flatbuffers/base.h"
|
|
||||||
#include "flatbuffers/buffer.h"
|
|
||||||
#include "flatbuffers/stl_emulation.h"
|
|
||||||
|
|
||||||
namespace flatbuffers {
|
|
||||||
|
|
||||||
struct String;
|
|
||||||
|
|
||||||
// An STL compatible iterator implementation for Vector below, effectively
|
|
||||||
// calling Get() for every element.
|
|
||||||
template <typename T, typename IT, typename Data = uint8_t*,
|
|
||||||
typename SizeT = uoffset_t>
|
|
||||||
struct VectorIterator {
|
|
||||||
typedef std::random_access_iterator_tag iterator_category;
|
|
||||||
typedef IT value_type;
|
|
||||||
typedef ptrdiff_t difference_type;
|
|
||||||
typedef IT* pointer;
|
|
||||||
typedef IT& reference;
|
|
||||||
|
|
||||||
static const SizeT element_stride = IndirectHelper<T>::element_stride;
|
|
||||||
|
|
||||||
VectorIterator(Data data, SizeT i) : data_(data + element_stride * i) {}
|
|
||||||
VectorIterator(const VectorIterator& other) : data_(other.data_) {}
|
|
||||||
VectorIterator() : data_(nullptr) {}
|
|
||||||
|
|
||||||
VectorIterator& operator=(const VectorIterator& other) {
|
|
||||||
data_ = other.data_;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
VectorIterator& operator=(VectorIterator&& other) {
|
|
||||||
data_ = other.data_;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const VectorIterator& other) const {
|
|
||||||
return data_ == other.data_;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator!=(const VectorIterator& other) const {
|
|
||||||
return data_ != other.data_;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator<(const VectorIterator& other) const {
|
|
||||||
return data_ < other.data_;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator>(const VectorIterator& other) const {
|
|
||||||
return data_ > other.data_;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator<=(const VectorIterator& other) const {
|
|
||||||
return !(data_ > other.data_);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator>=(const VectorIterator& other) const {
|
|
||||||
return !(data_ < other.data_);
|
|
||||||
}
|
|
||||||
|
|
||||||
difference_type operator-(const VectorIterator& other) const {
|
|
||||||
return (data_ - other.data_) / element_stride;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note: return type is incompatible with the standard
|
|
||||||
// `reference operator*()`.
|
|
||||||
IT operator*() const { return IndirectHelper<T>::Read(data_, 0); }
|
|
||||||
|
|
||||||
// Note: return type is incompatible with the standard
|
|
||||||
// `pointer operator->()`.
|
|
||||||
IT operator->() const { return IndirectHelper<T>::Read(data_, 0); }
|
|
||||||
|
|
||||||
VectorIterator& operator++() {
|
|
||||||
data_ += element_stride;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
VectorIterator operator++(int) {
|
|
||||||
VectorIterator temp(data_, 0);
|
|
||||||
data_ += element_stride;
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
VectorIterator operator+(const SizeT& offset) const {
|
|
||||||
return VectorIterator(data_ + offset * element_stride, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
VectorIterator& operator+=(const SizeT& offset) {
|
|
||||||
data_ += offset * element_stride;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
VectorIterator& operator--() {
|
|
||||||
data_ -= element_stride;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
VectorIterator operator--(int) {
|
|
||||||
VectorIterator temp(data_, 0);
|
|
||||||
data_ -= element_stride;
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
VectorIterator operator-(const SizeT& offset) const {
|
|
||||||
return VectorIterator(data_ - offset * element_stride, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
VectorIterator& operator-=(const SizeT& offset) {
|
|
||||||
data_ -= offset * element_stride;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Data data_;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T, typename IT, typename SizeT = uoffset_t>
|
|
||||||
using VectorConstIterator = VectorIterator<T, IT, const uint8_t*, SizeT>;
|
|
||||||
|
|
||||||
template <typename Iterator>
|
|
||||||
struct VectorReverseIterator : public std::reverse_iterator<Iterator> {
|
|
||||||
explicit VectorReverseIterator(Iterator iter)
|
|
||||||
: std::reverse_iterator<Iterator>(iter) {}
|
|
||||||
|
|
||||||
// Note: return type is incompatible with the standard
|
|
||||||
// `reference operator*()`.
|
|
||||||
typename Iterator::value_type operator*() const {
|
|
||||||
auto tmp = std::reverse_iterator<Iterator>::current;
|
|
||||||
return *--tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note: return type is incompatible with the standard
|
|
||||||
// `pointer operator->()`.
|
|
||||||
typename Iterator::value_type operator->() const {
|
|
||||||
auto tmp = std::reverse_iterator<Iterator>::current;
|
|
||||||
return *--tmp;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// This is used as a helper type for accessing vectors.
|
|
||||||
// Vector::data() assumes the vector elements start after the length field.
|
|
||||||
template <typename T, typename SizeT = uoffset_t>
|
|
||||||
class Vector {
|
|
||||||
public:
|
|
||||||
typedef VectorIterator<T, typename IndirectHelper<T>::mutable_return_type,
|
|
||||||
uint8_t*, SizeT>
|
|
||||||
iterator;
|
|
||||||
typedef VectorConstIterator<T, typename IndirectHelper<T>::return_type, SizeT>
|
|
||||||
const_iterator;
|
|
||||||
typedef VectorReverseIterator<iterator> reverse_iterator;
|
|
||||||
typedef VectorReverseIterator<const_iterator> const_reverse_iterator;
|
|
||||||
|
|
||||||
typedef typename flatbuffers::bool_constant<flatbuffers::is_scalar<T>::value>
|
|
||||||
scalar_tag;
|
|
||||||
|
|
||||||
static FLATBUFFERS_CONSTEXPR bool is_span_observable =
|
|
||||||
scalar_tag::value && (FLATBUFFERS_LITTLEENDIAN || sizeof(T) == 1);
|
|
||||||
|
|
||||||
SizeT size() const { return EndianScalar(length_); }
|
|
||||||
|
|
||||||
// Returns true if the vector is empty.
|
|
||||||
//
|
|
||||||
// This just provides another standardized method that is expected of vectors.
|
|
||||||
bool empty() const { return size() == 0; }
|
|
||||||
|
|
||||||
// Deprecated: use size(). Here for backwards compatibility.
|
|
||||||
FLATBUFFERS_ATTRIBUTE([[deprecated("use size() instead")]])
|
|
||||||
SizeT Length() const { return size(); }
|
|
||||||
|
|
||||||
typedef SizeT size_type;
|
|
||||||
typedef typename IndirectHelper<T>::return_type return_type;
|
|
||||||
typedef typename IndirectHelper<T>::mutable_return_type mutable_return_type;
|
|
||||||
typedef return_type value_type;
|
|
||||||
|
|
||||||
return_type Get(SizeT i) const {
|
|
||||||
FLATBUFFERS_ASSERT(i < size());
|
|
||||||
return IndirectHelper<T>::Read(Data(), i);
|
|
||||||
}
|
|
||||||
|
|
||||||
return_type operator[](SizeT i) const { return Get(i); }
|
|
||||||
|
|
||||||
// If this is a Vector of enums, T will be its storage type, not the enum
|
|
||||||
// type. This function makes it convenient to retrieve value with enum
|
|
||||||
// type E.
|
|
||||||
template <typename E>
|
|
||||||
E GetEnum(SizeT i) const {
|
|
||||||
return static_cast<E>(Get(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
// If this a vector of unions, this does the cast for you. There's no check
|
|
||||||
// to make sure this is the right type!
|
|
||||||
template <typename U>
|
|
||||||
const U* GetAs(SizeT i) const {
|
|
||||||
return reinterpret_cast<const U*>(Get(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
// If this a vector of unions, this does the cast for you. There's no check
|
|
||||||
// to make sure this is actually a string!
|
|
||||||
const String* GetAsString(SizeT i) const {
|
|
||||||
return reinterpret_cast<const String*>(Get(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
const void* GetStructFromOffset(size_t o) const {
|
|
||||||
return reinterpret_cast<const void*>(Data() + o);
|
|
||||||
}
|
|
||||||
|
|
||||||
iterator begin() { return iterator(Data(), 0); }
|
|
||||||
const_iterator begin() const { return const_iterator(Data(), 0); }
|
|
||||||
|
|
||||||
iterator end() { return iterator(Data(), size()); }
|
|
||||||
const_iterator end() const { return const_iterator(Data(), size()); }
|
|
||||||
|
|
||||||
reverse_iterator rbegin() { return reverse_iterator(end()); }
|
|
||||||
const_reverse_iterator rbegin() const {
|
|
||||||
return const_reverse_iterator(end());
|
|
||||||
}
|
|
||||||
|
|
||||||
reverse_iterator rend() { return reverse_iterator(begin()); }
|
|
||||||
const_reverse_iterator rend() const {
|
|
||||||
return const_reverse_iterator(begin());
|
|
||||||
}
|
|
||||||
|
|
||||||
const_iterator cbegin() const { return begin(); }
|
|
||||||
|
|
||||||
const_iterator cend() const { return end(); }
|
|
||||||
|
|
||||||
const_reverse_iterator crbegin() const { return rbegin(); }
|
|
||||||
|
|
||||||
const_reverse_iterator crend() const { return rend(); }
|
|
||||||
|
|
||||||
// Change elements if you have a non-const pointer to this object.
|
|
||||||
// Scalars only. See reflection.h, and the documentation.
|
|
||||||
void Mutate(SizeT i, const T& val) {
|
|
||||||
FLATBUFFERS_ASSERT(i < size());
|
|
||||||
WriteScalar(data() + i, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Change an element of a vector of tables (or strings).
|
|
||||||
// "val" points to the new table/string, as you can obtain from
|
|
||||||
// e.g. reflection::AddFlatBuffer().
|
|
||||||
void MutateOffset(SizeT i, const uint8_t* val) {
|
|
||||||
FLATBUFFERS_ASSERT(i < size());
|
|
||||||
static_assert(sizeof(T) == sizeof(SizeT), "Unrelated types");
|
|
||||||
WriteScalar(data() + i,
|
|
||||||
static_cast<SizeT>(val - (Data() + i * sizeof(SizeT))));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get a mutable pointer to tables/strings inside this vector.
|
|
||||||
mutable_return_type GetMutableObject(SizeT i) const {
|
|
||||||
FLATBUFFERS_ASSERT(i < size());
|
|
||||||
return const_cast<mutable_return_type>(IndirectHelper<T>::Read(Data(), i));
|
|
||||||
}
|
|
||||||
|
|
||||||
// The raw data in little endian format. Use with care.
|
|
||||||
const uint8_t* Data() const {
|
|
||||||
return reinterpret_cast<const uint8_t*>(&length_ + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t* Data() { return reinterpret_cast<uint8_t*>(&length_ + 1); }
|
|
||||||
|
|
||||||
// Similarly, but typed, much like std::vector::data
|
|
||||||
const T* data() const { return reinterpret_cast<const T*>(Data()); }
|
|
||||||
T* data() { return reinterpret_cast<T*>(Data()); }
|
|
||||||
|
|
||||||
template <typename K>
|
|
||||||
return_type LookupByKey(K key) const {
|
|
||||||
void* search_result = std::bsearch(
|
|
||||||
&key, Data(), size(), IndirectHelper<T>::element_stride, KeyCompare<K>);
|
|
||||||
|
|
||||||
if (!search_result) {
|
|
||||||
return nullptr; // Key not found.
|
|
||||||
}
|
|
||||||
|
|
||||||
const uint8_t* element = reinterpret_cast<const uint8_t*>(search_result);
|
|
||||||
|
|
||||||
return IndirectHelper<T>::Read(element, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename K>
|
|
||||||
mutable_return_type MutableLookupByKey(K key) {
|
|
||||||
return const_cast<mutable_return_type>(LookupByKey(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// This class is only used to access pre-existing data. Don't ever
|
|
||||||
// try to construct these manually.
|
|
||||||
Vector();
|
|
||||||
|
|
||||||
SizeT length_;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// This class is a pointer. Copying will therefore create an invalid object.
|
|
||||||
// Private and unimplemented copy constructor.
|
|
||||||
Vector(const Vector&);
|
|
||||||
Vector& operator=(const Vector&);
|
|
||||||
|
|
||||||
template <typename K>
|
|
||||||
static int KeyCompare(const void* ap, const void* bp) {
|
|
||||||
const K* key = reinterpret_cast<const K*>(ap);
|
|
||||||
const uint8_t* data = reinterpret_cast<const uint8_t*>(bp);
|
|
||||||
auto table = IndirectHelper<T>::Read(data, 0);
|
|
||||||
|
|
||||||
// std::bsearch compares with the operands transposed, so we negate the
|
|
||||||
// result here.
|
|
||||||
return -table->KeyCompareWithValue(*key);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
using Vector64 = Vector<T, uoffset64_t>;
|
|
||||||
|
|
||||||
template <class U>
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<U> make_span(Vector<U>& vec)
|
|
||||||
FLATBUFFERS_NOEXCEPT {
|
|
||||||
static_assert(Vector<U>::is_span_observable,
|
|
||||||
"wrong type U, only LE-scalar, or byte types are allowed");
|
|
||||||
return span<U>(vec.data(), vec.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class U>
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<const U> make_span(
|
|
||||||
const Vector<U>& vec) FLATBUFFERS_NOEXCEPT {
|
|
||||||
static_assert(Vector<U>::is_span_observable,
|
|
||||||
"wrong type U, only LE-scalar, or byte types are allowed");
|
|
||||||
return span<const U>(vec.data(), vec.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class U>
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<uint8_t> make_bytes_span(
|
|
||||||
Vector<U>& vec) FLATBUFFERS_NOEXCEPT {
|
|
||||||
static_assert(Vector<U>::scalar_tag::value,
|
|
||||||
"wrong type U, only LE-scalar, or byte types are allowed");
|
|
||||||
return span<uint8_t>(vec.Data(), vec.size() * sizeof(U));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class U>
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<const uint8_t> make_bytes_span(
|
|
||||||
const Vector<U>& vec) FLATBUFFERS_NOEXCEPT {
|
|
||||||
static_assert(Vector<U>::scalar_tag::value,
|
|
||||||
"wrong type U, only LE-scalar, or byte types are allowed");
|
|
||||||
return span<const uint8_t>(vec.Data(), vec.size() * sizeof(U));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convenient helper functions to get a span of any vector, regardless
|
|
||||||
// of whether it is null or not (the field is not set).
|
|
||||||
template <class U>
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<U> make_span(Vector<U>* ptr)
|
|
||||||
FLATBUFFERS_NOEXCEPT {
|
|
||||||
static_assert(Vector<U>::is_span_observable,
|
|
||||||
"wrong type U, only LE-scalar, or byte types are allowed");
|
|
||||||
return ptr ? make_span(*ptr) : span<U>();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class U>
|
|
||||||
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<const U> make_span(
|
|
||||||
const Vector<U>* ptr) FLATBUFFERS_NOEXCEPT {
|
|
||||||
static_assert(Vector<U>::is_span_observable,
|
|
||||||
"wrong type U, only LE-scalar, or byte types are allowed");
|
|
||||||
return ptr ? make_span(*ptr) : span<const U>();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Represent a vector much like the template above, but in this case we
|
|
||||||
// don't know what the element types are (used with reflection.h).
|
|
||||||
class VectorOfAny {
|
|
||||||
public:
|
|
||||||
uoffset_t size() const { return EndianScalar(length_); }
|
|
||||||
|
|
||||||
const uint8_t* Data() const {
|
|
||||||
return reinterpret_cast<const uint8_t*>(&length_ + 1);
|
|
||||||
}
|
|
||||||
uint8_t* Data() { return reinterpret_cast<uint8_t*>(&length_ + 1); }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
VectorOfAny();
|
|
||||||
|
|
||||||
uoffset_t length_;
|
|
||||||
|
|
||||||
private:
|
|
||||||
VectorOfAny(const VectorOfAny&);
|
|
||||||
VectorOfAny& operator=(const VectorOfAny&);
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T, typename U>
|
|
||||||
Vector<Offset<T>>* VectorCast(Vector<Offset<U>>* ptr) {
|
|
||||||
static_assert(std::is_base_of<T, U>::value, "Unrelated types");
|
|
||||||
return reinterpret_cast<Vector<Offset<T>>*>(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, typename U>
|
|
||||||
const Vector<Offset<T>>* VectorCast(const Vector<Offset<U>>* ptr) {
|
|
||||||
static_assert(std::is_base_of<T, U>::value, "Unrelated types");
|
|
||||||
return reinterpret_cast<const Vector<Offset<T>>*>(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convenient helper function to get the length of any vector, regardless
|
|
||||||
// of whether it is null or not (the field is not set).
|
|
||||||
template <typename T>
|
|
||||||
static inline size_t VectorLength(const Vector<T>* v) {
|
|
||||||
return v ? v->size() : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace flatbuffers
|
|
||||||
|
|
||||||
#endif // FLATBUFFERS_VERIFIER_H_
|
|
||||||
@@ -1,298 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2021 Google Inc. All rights reserved.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLATBUFFERS_VECTOR_DOWNWARD_H_
|
|
||||||
#define FLATBUFFERS_VECTOR_DOWNWARD_H_
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
#include "flatbuffers/base.h"
|
|
||||||
#include "flatbuffers/default_allocator.h"
|
|
||||||
#include "flatbuffers/detached_buffer.h"
|
|
||||||
|
|
||||||
namespace flatbuffers {
|
|
||||||
|
|
||||||
// This is a minimal replication of std::vector<uint8_t> functionality,
|
|
||||||
// except growing from higher to lower addresses. i.e. push_back() inserts data
|
|
||||||
// in the lowest address in the vector.
|
|
||||||
// Since this vector leaves the lower part unused, we support a "scratch-pad"
|
|
||||||
// that can be stored there for temporary data, to share the allocated space.
|
|
||||||
// Essentially, this supports 2 std::vectors in a single buffer.
|
|
||||||
template <typename SizeT = uoffset_t>
|
|
||||||
class vector_downward {
|
|
||||||
public:
|
|
||||||
explicit vector_downward(size_t initial_size, Allocator* allocator,
|
|
||||||
bool own_allocator, size_t buffer_minalign,
|
|
||||||
const SizeT max_size = FLATBUFFERS_MAX_BUFFER_SIZE)
|
|
||||||
: allocator_(allocator),
|
|
||||||
own_allocator_(own_allocator),
|
|
||||||
initial_size_(initial_size),
|
|
||||||
max_size_(max_size),
|
|
||||||
buffer_minalign_(buffer_minalign),
|
|
||||||
reserved_(0),
|
|
||||||
size_(0),
|
|
||||||
buf_(nullptr),
|
|
||||||
cur_(nullptr),
|
|
||||||
scratch_(nullptr) {}
|
|
||||||
|
|
||||||
vector_downward(vector_downward&& other) noexcept
|
|
||||||
// clang-format on
|
|
||||||
: allocator_(other.allocator_),
|
|
||||||
own_allocator_(other.own_allocator_),
|
|
||||||
initial_size_(other.initial_size_),
|
|
||||||
max_size_(other.max_size_),
|
|
||||||
buffer_minalign_(other.buffer_minalign_),
|
|
||||||
reserved_(other.reserved_),
|
|
||||||
size_(other.size_),
|
|
||||||
buf_(other.buf_),
|
|
||||||
cur_(other.cur_),
|
|
||||||
scratch_(other.scratch_) {
|
|
||||||
// No change in other.allocator_
|
|
||||||
// No change in other.initial_size_
|
|
||||||
// No change in other.buffer_minalign_
|
|
||||||
other.own_allocator_ = false;
|
|
||||||
other.reserved_ = 0;
|
|
||||||
other.buf_ = nullptr;
|
|
||||||
other.cur_ = nullptr;
|
|
||||||
other.scratch_ = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
vector_downward& operator=(vector_downward&& other) noexcept {
|
|
||||||
// Move construct a temporary and swap idiom
|
|
||||||
vector_downward temp(std::move(other));
|
|
||||||
swap(temp);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
~vector_downward() {
|
|
||||||
clear_buffer();
|
|
||||||
clear_allocator();
|
|
||||||
}
|
|
||||||
|
|
||||||
void reset() {
|
|
||||||
clear_buffer();
|
|
||||||
clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void clear() {
|
|
||||||
if (buf_) {
|
|
||||||
cur_ = buf_ + reserved_;
|
|
||||||
} else {
|
|
||||||
reserved_ = 0;
|
|
||||||
cur_ = nullptr;
|
|
||||||
}
|
|
||||||
size_ = 0;
|
|
||||||
clear_scratch();
|
|
||||||
}
|
|
||||||
|
|
||||||
void clear_scratch() { scratch_ = buf_; }
|
|
||||||
|
|
||||||
void clear_allocator() {
|
|
||||||
if (own_allocator_ && allocator_) {
|
|
||||||
delete allocator_;
|
|
||||||
}
|
|
||||||
allocator_ = nullptr;
|
|
||||||
own_allocator_ = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void clear_buffer() {
|
|
||||||
if (buf_) Deallocate(allocator_, buf_, reserved_);
|
|
||||||
buf_ = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Relinquish the pointer to the caller.
|
|
||||||
uint8_t* release_raw(size_t& allocated_bytes, size_t& offset) {
|
|
||||||
auto* buf = buf_;
|
|
||||||
allocated_bytes = reserved_;
|
|
||||||
offset = vector_downward::offset();
|
|
||||||
|
|
||||||
// release_raw only relinquishes the buffer ownership.
|
|
||||||
// Does not deallocate or reset the allocator. Destructor will do that.
|
|
||||||
buf_ = nullptr;
|
|
||||||
clear();
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Relinquish the pointer to the caller.
|
|
||||||
DetachedBuffer release() {
|
|
||||||
// allocator ownership (if any) is transferred to DetachedBuffer.
|
|
||||||
DetachedBuffer fb(allocator_, own_allocator_, buf_, reserved_, cur_,
|
|
||||||
size());
|
|
||||||
if (own_allocator_) {
|
|
||||||
allocator_ = nullptr;
|
|
||||||
own_allocator_ = false;
|
|
||||||
}
|
|
||||||
buf_ = nullptr;
|
|
||||||
clear();
|
|
||||||
return fb;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t ensure_space(size_t len) {
|
|
||||||
FLATBUFFERS_ASSERT(cur_ >= scratch_ && scratch_ >= buf_);
|
|
||||||
// If the length is larger than the unused part of the buffer, we need to
|
|
||||||
// grow.
|
|
||||||
if (len > unused_buffer_size()) {
|
|
||||||
reallocate(len);
|
|
||||||
}
|
|
||||||
FLATBUFFERS_ASSERT(size() < max_size_);
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline uint8_t* make_space(size_t len) {
|
|
||||||
if (len) {
|
|
||||||
ensure_space(len);
|
|
||||||
cur_ -= len;
|
|
||||||
size_ += static_cast<SizeT>(len);
|
|
||||||
}
|
|
||||||
return cur_;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns nullptr if using the DefaultAllocator.
|
|
||||||
Allocator* get_custom_allocator() { return allocator_; }
|
|
||||||
|
|
||||||
// The current offset into the buffer.
|
|
||||||
size_t offset() const { return cur_ - buf_; }
|
|
||||||
|
|
||||||
// The total size of the vector (both the buffer and scratch parts).
|
|
||||||
inline SizeT size() const { return size_; }
|
|
||||||
|
|
||||||
// The size of the buffer part of the vector that is currently unused.
|
|
||||||
SizeT unused_buffer_size() const {
|
|
||||||
return static_cast<SizeT>(cur_ - scratch_);
|
|
||||||
}
|
|
||||||
|
|
||||||
// The size of the scratch part of the vector.
|
|
||||||
SizeT scratch_size() const { return static_cast<SizeT>(scratch_ - buf_); }
|
|
||||||
|
|
||||||
size_t capacity() const { return reserved_; }
|
|
||||||
|
|
||||||
uint8_t* data() const {
|
|
||||||
FLATBUFFERS_ASSERT(cur_);
|
|
||||||
return cur_;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t* scratch_data() const {
|
|
||||||
FLATBUFFERS_ASSERT(buf_);
|
|
||||||
return buf_;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t* scratch_end() const {
|
|
||||||
FLATBUFFERS_ASSERT(scratch_);
|
|
||||||
return scratch_;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t* data_at(size_t offset) const { return buf_ + reserved_ - offset; }
|
|
||||||
|
|
||||||
void push(const uint8_t* bytes, size_t num) {
|
|
||||||
if (num > 0) {
|
|
||||||
memcpy(make_space(num), bytes, num);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Specialized version of push() that avoids memcpy call for small data.
|
|
||||||
template <typename T>
|
|
||||||
void push_small(const T& little_endian_t) {
|
|
||||||
make_space(sizeof(T));
|
|
||||||
*reinterpret_cast<T*>(cur_) = little_endian_t;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void scratch_push_small(const T& t) {
|
|
||||||
ensure_space(sizeof(T));
|
|
||||||
*reinterpret_cast<T*>(scratch_) = t;
|
|
||||||
scratch_ += sizeof(T);
|
|
||||||
}
|
|
||||||
|
|
||||||
// fill() is most frequently called with small byte counts (<= 4),
|
|
||||||
// which is why we're using loops rather than calling memset.
|
|
||||||
void fill(size_t zero_pad_bytes) {
|
|
||||||
make_space(zero_pad_bytes);
|
|
||||||
for (size_t i = 0; i < zero_pad_bytes; i++) cur_[i] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Version for when we know the size is larger.
|
|
||||||
// Precondition: zero_pad_bytes > 0
|
|
||||||
void fill_big(size_t zero_pad_bytes) {
|
|
||||||
memset(make_space(zero_pad_bytes), 0, zero_pad_bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
void pop(size_t bytes_to_remove) {
|
|
||||||
cur_ += bytes_to_remove;
|
|
||||||
size_ -= static_cast<SizeT>(bytes_to_remove);
|
|
||||||
}
|
|
||||||
|
|
||||||
void scratch_pop(size_t bytes_to_remove) { scratch_ -= bytes_to_remove; }
|
|
||||||
|
|
||||||
void swap(vector_downward& other) {
|
|
||||||
using std::swap;
|
|
||||||
swap(allocator_, other.allocator_);
|
|
||||||
swap(own_allocator_, other.own_allocator_);
|
|
||||||
swap(initial_size_, other.initial_size_);
|
|
||||||
swap(buffer_minalign_, other.buffer_minalign_);
|
|
||||||
swap(reserved_, other.reserved_);
|
|
||||||
swap(size_, other.size_);
|
|
||||||
swap(max_size_, other.max_size_);
|
|
||||||
swap(buf_, other.buf_);
|
|
||||||
swap(cur_, other.cur_);
|
|
||||||
swap(scratch_, other.scratch_);
|
|
||||||
}
|
|
||||||
|
|
||||||
void swap_allocator(vector_downward& other) {
|
|
||||||
using std::swap;
|
|
||||||
swap(allocator_, other.allocator_);
|
|
||||||
swap(own_allocator_, other.own_allocator_);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
// You shouldn't really be copying instances of this class.
|
|
||||||
FLATBUFFERS_DELETE_FUNC(vector_downward(const vector_downward&));
|
|
||||||
FLATBUFFERS_DELETE_FUNC(vector_downward& operator=(const vector_downward&));
|
|
||||||
|
|
||||||
Allocator* allocator_;
|
|
||||||
bool own_allocator_;
|
|
||||||
size_t initial_size_;
|
|
||||||
|
|
||||||
// The maximum size the vector can be.
|
|
||||||
SizeT max_size_;
|
|
||||||
size_t buffer_minalign_;
|
|
||||||
size_t reserved_;
|
|
||||||
SizeT size_;
|
|
||||||
uint8_t* buf_;
|
|
||||||
uint8_t* cur_; // Points at location between empty (below) and used (above).
|
|
||||||
uint8_t* scratch_; // Points to the end of the scratchpad in use.
|
|
||||||
|
|
||||||
void reallocate(size_t len) {
|
|
||||||
auto old_reserved = reserved_;
|
|
||||||
auto old_size = size();
|
|
||||||
auto old_scratch_size = scratch_size();
|
|
||||||
reserved_ +=
|
|
||||||
(std::max)(len, old_reserved ? old_reserved / 2 : initial_size_);
|
|
||||||
reserved_ = (reserved_ + buffer_minalign_ - 1) & ~(buffer_minalign_ - 1);
|
|
||||||
if (buf_) {
|
|
||||||
buf_ = ReallocateDownward(allocator_, buf_, old_reserved, reserved_,
|
|
||||||
old_size, old_scratch_size);
|
|
||||||
} else {
|
|
||||||
buf_ = Allocate(allocator_, reserved_);
|
|
||||||
}
|
|
||||||
cur_ = buf_ + reserved_ - old_size;
|
|
||||||
scratch_ = buf_ + old_scratch_size;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace flatbuffers
|
|
||||||
|
|
||||||
#endif // FLATBUFFERS_VECTOR_DOWNWARD_H_
|
|
||||||
-370
@@ -1,370 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2021 Google Inc. All rights reserved.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FLATBUFFERS_VERIFIER_H_
|
|
||||||
#define FLATBUFFERS_VERIFIER_H_
|
|
||||||
|
|
||||||
#include "flatbuffers/base.h"
|
|
||||||
#include "flatbuffers/vector.h"
|
|
||||||
|
|
||||||
namespace flatbuffers {
|
|
||||||
|
|
||||||
// Helper class to verify the integrity of a FlatBuffer
|
|
||||||
template <bool TrackVerifierBufferSize>
|
|
||||||
class VerifierTemplate FLATBUFFERS_FINAL_CLASS {
|
|
||||||
public:
|
|
||||||
struct Options {
|
|
||||||
// The maximum nesting of tables and vectors before we call it invalid.
|
|
||||||
uoffset_t max_depth = 64;
|
|
||||||
// The maximum number of tables we will verify before we call it invalid.
|
|
||||||
uoffset_t max_tables = 1000000;
|
|
||||||
// If true, verify all data is aligned.
|
|
||||||
bool check_alignment = true;
|
|
||||||
// If true, run verifier on nested flatbuffers
|
|
||||||
bool check_nested_flatbuffers = true;
|
|
||||||
// The maximum size of a buffer.
|
|
||||||
size_t max_size = FLATBUFFERS_MAX_BUFFER_SIZE;
|
|
||||||
// Use assertions to check for errors.
|
|
||||||
bool assert = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
explicit VerifierTemplate(const uint8_t* const buf, const size_t buf_len,
|
|
||||||
const Options& opts)
|
|
||||||
: buf_(buf), size_(buf_len), opts_(opts) {
|
|
||||||
FLATBUFFERS_ASSERT(size_ < opts.max_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated API, please construct with VerifierTemplate::Options.
|
|
||||||
VerifierTemplate(const uint8_t* const buf, const size_t buf_len,
|
|
||||||
const uoffset_t max_depth = 64,
|
|
||||||
const uoffset_t max_tables = 1000000,
|
|
||||||
const bool check_alignment = true)
|
|
||||||
: VerifierTemplate(buf, buf_len, [&] {
|
|
||||||
Options opts;
|
|
||||||
opts.max_depth = max_depth;
|
|
||||||
opts.max_tables = max_tables;
|
|
||||||
opts.check_alignment = check_alignment;
|
|
||||||
return opts;
|
|
||||||
}()) {}
|
|
||||||
|
|
||||||
// Central location where any verification failures register.
|
|
||||||
bool Check(const bool ok) const {
|
|
||||||
// clang-format off
|
|
||||||
#ifdef FLATBUFFERS_DEBUG_VERIFICATION_FAILURE
|
|
||||||
if (opts_.assert) { FLATBUFFERS_ASSERT(ok); }
|
|
||||||
#endif
|
|
||||||
// clang-format on
|
|
||||||
if (TrackVerifierBufferSize) {
|
|
||||||
if (!ok) {
|
|
||||||
upper_bound_ = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify any range within the buffer.
|
|
||||||
bool Verify(const size_t elem, const size_t elem_len) const {
|
|
||||||
if (TrackVerifierBufferSize) {
|
|
||||||
auto upper_bound = elem + elem_len;
|
|
||||||
if (upper_bound_ < upper_bound) {
|
|
||||||
upper_bound_ = upper_bound;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Check(elem_len < size_ && elem <= size_ - elem_len);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VerifyAlignment(const size_t elem, const size_t align) const {
|
|
||||||
return Check((elem & (align - 1)) == 0 || !opts_.check_alignment);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify a range indicated by sizeof(T).
|
|
||||||
template <typename T>
|
|
||||||
bool Verify(const size_t elem) const {
|
|
||||||
return VerifyAlignment(elem, sizeof(T)) && Verify(elem, sizeof(T));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VerifyFromPointer(const uint8_t* const p, const size_t len) {
|
|
||||||
return Verify(static_cast<size_t>(p - buf_), len);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify relative to a known-good base pointer.
|
|
||||||
bool VerifyFieldStruct(const uint8_t* const base, const voffset_t elem_off,
|
|
||||||
const size_t elem_len, const size_t align) const {
|
|
||||||
const auto f = static_cast<size_t>(base - buf_) + elem_off;
|
|
||||||
return VerifyAlignment(f, align) && Verify(f, elem_len);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
bool VerifyField(const uint8_t* const base, const voffset_t elem_off,
|
|
||||||
const size_t align) const {
|
|
||||||
const auto f = static_cast<size_t>(base - buf_) + elem_off;
|
|
||||||
return VerifyAlignment(f, align) && Verify(f, sizeof(T));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify a pointer (may be NULL) of a table type.
|
|
||||||
template <typename T>
|
|
||||||
bool VerifyTable(const T* const table) {
|
|
||||||
return !table || table->Verify(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify a pointer (may be NULL) of any vector type.
|
|
||||||
template <int&..., typename T, typename LenT>
|
|
||||||
bool VerifyVector(const Vector<T, LenT>* const vec) const {
|
|
||||||
return !vec || VerifyVectorOrString<LenT>(
|
|
||||||
reinterpret_cast<const uint8_t*>(vec), sizeof(T));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify a pointer (may be NULL) of a vector to struct.
|
|
||||||
template <int&..., typename T, typename LenT>
|
|
||||||
bool VerifyVector(const Vector<const T*, LenT>* const vec) const {
|
|
||||||
return VerifyVector(reinterpret_cast<const Vector<T, LenT>*>(vec));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify a pointer (may be NULL) to string.
|
|
||||||
bool VerifyString(const String* const str) const {
|
|
||||||
size_t end;
|
|
||||||
return !str || (VerifyVectorOrString<uoffset_t>(
|
|
||||||
reinterpret_cast<const uint8_t*>(str), 1, &end) &&
|
|
||||||
Verify(end, 1) && // Must have terminator
|
|
||||||
Check(buf_[end] == '\0')); // Terminating byte must be 0.
|
|
||||||
}
|
|
||||||
|
|
||||||
// Common code between vectors and strings.
|
|
||||||
template <typename LenT = uoffset_t>
|
|
||||||
bool VerifyVectorOrString(const uint8_t* const vec, const size_t elem_size,
|
|
||||||
size_t* const end = nullptr) const {
|
|
||||||
const auto vec_offset = static_cast<size_t>(vec - buf_);
|
|
||||||
// Check we can read the size field.
|
|
||||||
if (!Verify<LenT>(vec_offset)) return false;
|
|
||||||
// Check the whole array. If this is a string, the byte past the array must
|
|
||||||
// be 0.
|
|
||||||
const LenT size = ReadScalar<LenT>(vec);
|
|
||||||
const auto max_elems = opts_.max_size / elem_size;
|
|
||||||
if (!Check(size < max_elems))
|
|
||||||
return false; // Protect against byte_size overflowing.
|
|
||||||
const auto byte_size = sizeof(LenT) + elem_size * size;
|
|
||||||
if (end) *end = vec_offset + byte_size;
|
|
||||||
return Verify(vec_offset, byte_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Special case for string contents, after the above has been called.
|
|
||||||
bool VerifyVectorOfStrings(const Vector<Offset<String>>* const vec) const {
|
|
||||||
if (vec) {
|
|
||||||
for (uoffset_t i = 0; i < vec->size(); i++) {
|
|
||||||
if (!VerifyString(vec->Get(i))) return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Special case for table contents, after the above has been called.
|
|
||||||
template <typename T>
|
|
||||||
bool VerifyVectorOfTables(const Vector<Offset<T>>* const vec) {
|
|
||||||
if (vec) {
|
|
||||||
for (uoffset_t i = 0; i < vec->size(); i++) {
|
|
||||||
if (!vec->Get(i)->Verify(*this)) return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
FLATBUFFERS_SUPPRESS_UBSAN("unsigned-integer-overflow")
|
|
||||||
bool VerifyTableStart(const uint8_t* const table) {
|
|
||||||
// Check the vtable offset.
|
|
||||||
const auto tableo = static_cast<size_t>(table - buf_);
|
|
||||||
if (!Verify<soffset_t>(tableo)) return false;
|
|
||||||
// This offset may be signed, but doing the subtraction unsigned always
|
|
||||||
// gives the result we want.
|
|
||||||
const auto vtableo =
|
|
||||||
tableo - static_cast<size_t>(ReadScalar<soffset_t>(table));
|
|
||||||
// Check the vtable size field, then check vtable fits in its entirety.
|
|
||||||
if (!(VerifyComplexity() && Verify<voffset_t>(vtableo) &&
|
|
||||||
VerifyAlignment(ReadScalar<voffset_t>(buf_ + vtableo),
|
|
||||||
sizeof(voffset_t))))
|
|
||||||
return false;
|
|
||||||
const auto vsize = ReadScalar<voffset_t>(buf_ + vtableo);
|
|
||||||
return Check((vsize & 1) == 0) && Verify(vtableo, vsize);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
bool VerifyBufferFromStart(const char* const identifier, const size_t start) {
|
|
||||||
// Buffers have to be of some size to be valid. The reason it is a runtime
|
|
||||||
// check instead of static_assert, is that nested flatbuffers go through
|
|
||||||
// this call and their size is determined at runtime.
|
|
||||||
if (!Check(size_ >= FLATBUFFERS_MIN_BUFFER_SIZE)) return false;
|
|
||||||
|
|
||||||
// If an identifier is provided, check that we have a buffer
|
|
||||||
if (identifier && !Check((size_ >= 2 * sizeof(flatbuffers::uoffset_t) &&
|
|
||||||
BufferHasIdentifier(buf_ + start, identifier)))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Call T::Verify, which must be in the generated code for this type.
|
|
||||||
const auto o = VerifyOffset<uoffset_t>(start);
|
|
||||||
if (!Check(o != 0)) return false;
|
|
||||||
if (!(reinterpret_cast<const T*>(buf_ + start + o)->Verify(*this))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (TrackVerifierBufferSize) {
|
|
||||||
if (GetComputedSize() == 0) return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, int&..., typename SizeT>
|
|
||||||
bool VerifyNestedFlatBuffer(const Vector<uint8_t, SizeT>* const buf,
|
|
||||||
const char* const identifier) {
|
|
||||||
// Caller opted out of this.
|
|
||||||
if (!opts_.check_nested_flatbuffers) return true;
|
|
||||||
|
|
||||||
// An empty buffer is OK as it indicates not present.
|
|
||||||
if (!buf) return true;
|
|
||||||
|
|
||||||
// If there is a nested buffer, it must be greater than the min size.
|
|
||||||
if (!Check(buf->size() >= FLATBUFFERS_MIN_BUFFER_SIZE)) return false;
|
|
||||||
|
|
||||||
VerifierTemplate<TrackVerifierBufferSize> nested_verifier(
|
|
||||||
buf->data(), buf->size(), opts_);
|
|
||||||
return nested_verifier.VerifyBuffer<T>(identifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify this whole buffer, starting with root type T.
|
|
||||||
template <typename T>
|
|
||||||
bool VerifyBuffer() {
|
|
||||||
return VerifyBuffer<T>(nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
bool VerifyBuffer(const char* const identifier) {
|
|
||||||
return VerifyBufferFromStart<T>(identifier, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, typename SizeT = uoffset_t>
|
|
||||||
bool VerifySizePrefixedBuffer(const char* const identifier) {
|
|
||||||
return Verify<SizeT>(0U) &&
|
|
||||||
// Ensure the prefixed size is within the bounds of the provided
|
|
||||||
// length.
|
|
||||||
Check(ReadScalar<SizeT>(buf_) + sizeof(SizeT) <= size_) &&
|
|
||||||
VerifyBufferFromStart<T>(identifier, sizeof(SizeT));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename OffsetT = uoffset_t, typename SOffsetT = soffset_t>
|
|
||||||
size_t VerifyOffset(const size_t start) const {
|
|
||||||
if (!Verify<OffsetT>(start)) return 0;
|
|
||||||
const auto o = ReadScalar<OffsetT>(buf_ + start);
|
|
||||||
// May not point to itself.
|
|
||||||
if (!Check(o != 0)) return 0;
|
|
||||||
// Can't wrap around larger than the max size.
|
|
||||||
if (!Check(static_cast<SOffsetT>(o) >= 0)) return 0;
|
|
||||||
// Must be inside the buffer to create a pointer from it (pointer outside
|
|
||||||
// buffer is UB).
|
|
||||||
if (!Verify(start + o, 1)) return 0;
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename OffsetT = uoffset_t>
|
|
||||||
size_t VerifyOffset(const uint8_t* const base, const voffset_t start) const {
|
|
||||||
return VerifyOffset<OffsetT>(static_cast<size_t>(base - buf_) + start);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called at the start of a table to increase counters measuring data
|
|
||||||
// structure depth and amount, and possibly bails out with false if limits set
|
|
||||||
// by the constructor have been hit. Needs to be balanced with EndTable().
|
|
||||||
bool VerifyComplexity() {
|
|
||||||
depth_++;
|
|
||||||
num_tables_++;
|
|
||||||
return Check(depth_ <= opts_.max_depth && num_tables_ <= opts_.max_tables);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called at the end of a table to pop the depth count.
|
|
||||||
bool EndTable() {
|
|
||||||
depth_--;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns the message size in bytes.
|
|
||||||
//
|
|
||||||
// This should only be called after first calling VerifyBuffer or
|
|
||||||
// VerifySizePrefixedBuffer.
|
|
||||||
//
|
|
||||||
// This method should only be called for VerifierTemplate instances
|
|
||||||
// where the TrackVerifierBufferSize template parameter is true,
|
|
||||||
// i.e. for SizeVerifier. For instances where TrackVerifierBufferSize
|
|
||||||
// is false, this fails at runtime or returns zero.
|
|
||||||
size_t GetComputedSize() const {
|
|
||||||
if (TrackVerifierBufferSize) {
|
|
||||||
uintptr_t size = upper_bound_;
|
|
||||||
// Align the size to uoffset_t
|
|
||||||
size = (size - 1 + sizeof(uoffset_t)) & ~(sizeof(uoffset_t) - 1);
|
|
||||||
return (size > size_) ? 0 : size;
|
|
||||||
}
|
|
||||||
// Must use SizeVerifier, or (deprecated) turn on
|
|
||||||
// FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE, for this to work.
|
|
||||||
(void)upper_bound_;
|
|
||||||
FLATBUFFERS_ASSERT(false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<uint8_t>* GetFlexReuseTracker() { return flex_reuse_tracker_; }
|
|
||||||
|
|
||||||
void SetFlexReuseTracker(std::vector<uint8_t>* const rt) {
|
|
||||||
flex_reuse_tracker_ = rt;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
const uint8_t* buf_;
|
|
||||||
const size_t size_;
|
|
||||||
const Options opts_;
|
|
||||||
|
|
||||||
mutable size_t upper_bound_ = 0;
|
|
||||||
|
|
||||||
uoffset_t depth_ = 0;
|
|
||||||
uoffset_t num_tables_ = 0;
|
|
||||||
std::vector<uint8_t>* flex_reuse_tracker_ = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Specialization for 64-bit offsets.
|
|
||||||
template <>
|
|
||||||
template <>
|
|
||||||
inline size_t VerifierTemplate<false>::VerifyOffset<uoffset64_t>(
|
|
||||||
const size_t start) const {
|
|
||||||
return VerifyOffset<uoffset64_t, soffset64_t>(start);
|
|
||||||
}
|
|
||||||
template <>
|
|
||||||
template <>
|
|
||||||
inline size_t VerifierTemplate<true>::VerifyOffset<uoffset64_t>(
|
|
||||||
const size_t start) const {
|
|
||||||
return VerifyOffset<uoffset64_t, soffset64_t>(start);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Instance of VerifierTemplate that supports GetComputedSize().
|
|
||||||
using SizeVerifier = VerifierTemplate</*TrackVerifierBufferSize = */ true>;
|
|
||||||
|
|
||||||
// The FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE build configuration macro is
|
|
||||||
// deprecated, and should not be defined, since it is easy to misuse in ways
|
|
||||||
// that result in ODR violations. Rather than using Verifier and defining
|
|
||||||
// FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE, please use SizeVerifier instead.
|
|
||||||
#ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE // Deprecated, see above.
|
|
||||||
using Verifier = SizeVerifier;
|
|
||||||
#else
|
|
||||||
// Instance of VerifierTemplate that is slightly faster, but does not
|
|
||||||
// support GetComputedSize().
|
|
||||||
using Verifier = VerifierTemplate</*TrackVerifierBufferSize = */ false>;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace flatbuffers
|
|
||||||
|
|
||||||
#endif // FLATBUFFERS_VERIFIER_H_
|
|
||||||
Vendored
-70
@@ -1,70 +0,0 @@
|
|||||||
# ----------------------------------------------------------------------------
|
|
||||||
# CMake file for the bundled HarfBuzz text-shaping library. See root CMakeLists.txt
|
|
||||||
#
|
|
||||||
# OpenCV vendors a minimal subset of HarfBuzz (core + HB_HAS_RASTER) as a
|
|
||||||
# normal static library: each .cc is a separate translation unit. The subset
|
|
||||||
# is produced by hb_extract.py (see that script to update HarfBuzz).
|
|
||||||
# ----------------------------------------------------------------------------
|
|
||||||
project(${HARFBUZZ_LIBRARY} CXX)
|
|
||||||
|
|
||||||
ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src")
|
|
||||||
|
|
||||||
# Every .cc copied by hb_extract.py is a real translation unit (the script
|
|
||||||
# never copies non-TU .cc files), so a plain recursive glob is exactly right.
|
|
||||||
file(GLOB_RECURSE lib_srcs src/*.cc)
|
|
||||||
file(GLOB_RECURSE lib_hdrs src/*.h src/*.hh)
|
|
||||||
|
|
||||||
# HarfBuzz is built with HB_TINY for minimum footprint. Because we request the
|
|
||||||
# software rasterizer (HB_HAS_RASTER, defined below), HB_TINY does NOT disable
|
|
||||||
# the draw/paint/color APIs nor CFF (PostScript/.otf
|
|
||||||
# outlines) -- see hb-config.hh: HB_NO_DRAW/COLOR/PAINT and the TINY->HB_NO_CFF
|
|
||||||
# rule only trigger when no HB_HAS_* backend is requested. So CFF (CJK/Indic),
|
|
||||||
# COLR/CPAL color and our rasterizer all survive HB_TINY.
|
|
||||||
#
|
|
||||||
# Two features HB_TINY (via HB_LEAN) would otherwise drop are restored through
|
|
||||||
# HarfBuzz's config-override hook (hb-opencv-config.hh): thread-safety (HB_NO_MT)
|
|
||||||
# and variable fonts (HB_NO_VAR). No platform backends (CoreText/DirectWrite/...).
|
|
||||||
|
|
||||||
add_library(${HARFBUZZ_LIBRARY} STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${lib_srcs} ${lib_hdrs})
|
|
||||||
|
|
||||||
target_compile_definitions(${HARFBUZZ_LIBRARY} PRIVATE
|
|
||||||
HB_TINY
|
|
||||||
HB_HAS_RASTER # request the software rasterizer: keeps draw/paint/color + CFF under HB_TINY
|
|
||||||
"HB_CONFIG_OVERRIDE_H=\"hb-opencv-config.hh\"")
|
|
||||||
|
|
||||||
set_target_properties(${HARFBUZZ_LIBRARY} PROPERTIES
|
|
||||||
CXX_STANDARD 17
|
|
||||||
CXX_STANDARD_REQUIRED ON
|
|
||||||
)
|
|
||||||
|
|
||||||
ocv_warnings_disable(CMAKE_CXX_FLAGS
|
|
||||||
-Wunused-variable -Wunused-function -Wunused-parameter
|
|
||||||
-Wunused-but-set-variable # clang15/gcc
|
|
||||||
-Wshadow
|
|
||||||
-Wmissing-declarations # gcc
|
|
||||||
-Wmissing-prototypes # clang
|
|
||||||
-Wimplicit-fallthrough
|
|
||||||
-Wextra-semi # clang
|
|
||||||
-Wdeprecated-copy # gcc/clang
|
|
||||||
-Wsuggest-override
|
|
||||||
-Wcast-function-type
|
|
||||||
-Wclass-memaccess # gcc
|
|
||||||
-Wexpansion-to-defined
|
|
||||||
)
|
|
||||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244 /wd4267 /wd4127 /wd4146 /wd4456 /wd4459) # MSVC
|
|
||||||
|
|
||||||
set_target_properties(${HARFBUZZ_LIBRARY}
|
|
||||||
PROPERTIES OUTPUT_NAME ${HARFBUZZ_LIBRARY}
|
|
||||||
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
|
|
||||||
COMPILE_PDB_NAME ${HARFBUZZ_LIBRARY}
|
|
||||||
COMPILE_PDB_NAME_DEBUG "${HARFBUZZ_LIBRARY}${OPENCV_DEBUG_POSTFIX}"
|
|
||||||
ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH}
|
|
||||||
)
|
|
||||||
|
|
||||||
if(ENABLE_SOLUTION_FOLDERS)
|
|
||||||
set_target_properties(${HARFBUZZ_LIBRARY} PROPERTIES FOLDER "3rdparty")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT BUILD_SHARED_LIBS)
|
|
||||||
ocv_install_target(${HARFBUZZ_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev OPTIONAL)
|
|
||||||
endif()
|
|
||||||
Vendored
-42
@@ -1,42 +0,0 @@
|
|||||||
HarfBuzz is licensed under the so-called "Old MIT" license. Details follow.
|
|
||||||
For parts of HarfBuzz that are licensed under different licenses see individual
|
|
||||||
files names COPYING in subdirectories where applicable.
|
|
||||||
|
|
||||||
Copyright © 2010-2022 Google, Inc.
|
|
||||||
Copyright © 2015-2020 Ebrahim Byagowi
|
|
||||||
Copyright © 2019,2020 Facebook, Inc.
|
|
||||||
Copyright © 2012,2015 Mozilla Foundation
|
|
||||||
Copyright © 2011 Codethink Limited
|
|
||||||
Copyright © 2008,2010 Nokia Corporation and/or its subsidiary(-ies)
|
|
||||||
Copyright © 2009 Keith Stribley
|
|
||||||
Copyright © 2011 Martin Hosken and SIL International
|
|
||||||
Copyright © 2007 Chris Wilson
|
|
||||||
Copyright © 2005,2006,2020,2021,2022,2023 Behdad Esfahbod
|
|
||||||
Copyright © 2004,2007,2008,2009,2010,2013,2021,2022,2023 Red Hat, Inc.
|
|
||||||
Copyright © 1998-2005 David Turner and Werner Lemberg
|
|
||||||
Copyright © 2016 Igalia S.L.
|
|
||||||
Copyright © 2022 Matthias Clasen
|
|
||||||
Copyright © 2018,2021 Khaled Hosny
|
|
||||||
Copyright © 2018,2019,2020 Adobe, Inc
|
|
||||||
Copyright © 2013-2015 Alexei Podtelezhnikov
|
|
||||||
|
|
||||||
For full copyright notices consult the individual files in the package.
|
|
||||||
|
|
||||||
|
|
||||||
Permission is hereby granted, without written agreement and without
|
|
||||||
license or royalty fees, to use, copy, modify, and distribute this
|
|
||||||
software and its documentation for any purpose, provided that the
|
|
||||||
above copyright notice and the following two paragraphs appear in
|
|
||||||
all copies of this software.
|
|
||||||
|
|
||||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
|
|
||||||
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
|
|
||||||
ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
|
|
||||||
IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
|
||||||
DAMAGE.
|
|
||||||
|
|
||||||
THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
|
|
||||||
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
|
||||||
ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
|
|
||||||
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
|
||||||
Vendored
-220
@@ -1,220 +0,0 @@
|
|||||||
# HarfBuzz
|
|
||||||
|
|
||||||
<div align="center">
|
|
||||||
|
|
||||||
<p><img src="HarfBuzz.png" alt="HarfBuzz Logo" width="256"/></p>
|
|
||||||
|
|
||||||
[](https://github.com/harfbuzz/harfbuzz/actions/workflows/linux.yml)
|
|
||||||
[](https://github.com/harfbuzz/harfbuzz/actions/workflows/macos.yml)
|
|
||||||
[](https://github.com/harfbuzz/harfbuzz/actions/workflows/msvc.yml)
|
|
||||||
[](https://oss-fuzz-build-logs.storage.googleapis.com/index.html#harfbuzz)
|
|
||||||
[](https://scan.coverity.com/projects/harfbuzz)
|
|
||||||
[](https://repology.org/project/harfbuzz/versions)
|
|
||||||
[](https://securityscorecards.dev/viewer/?uri=github.com/harfbuzz/harfbuzz)
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
HarfBuzz started as a text shaping engine but has grown into a
|
|
||||||
full font platform — the `ffmpeg` of text shaping. It primarily
|
|
||||||
supports [OpenType][1], but also [Apple Advanced Typography][2].
|
|
||||||
|
|
||||||
HarfBuzz shapes the majority of text on modern screens.
|
|
||||||
|
|
||||||
HarfBuzz is optimized for robustness, correctness, and performance
|
|
||||||
— in that order. Achieve all.
|
|
||||||
|
|
||||||
**[Try it live at harfbuzz-world.cc](https://harfbuzz-world.cc/)** — an interactive playground for shaping, subsetting, rasterization, vector output, and GPU rendering, all running in your browser.
|
|
||||||
|
|
||||||
Here is a quick map of its components:
|
|
||||||
|
|
||||||
### Core libraries
|
|
||||||
|
|
||||||
| Library | Description |
|
|
||||||
|---------|-------------|
|
|
||||||
| **libharfbuzz** | Text shaping, draw API, paint API. Highly configurable (see [CONFIG.md](CONFIG.md)). Optional integration backends compiled in: hb-ft (FreeType), hb-coretext (macOS), hb-uniscribe (Windows), hb-directwrite (Windows), hb-gdi (Windows), hb-glib, hb-graphite2. |
|
|
||||||
| **libharfbuzz-subset** | Font subsetting and variable-font instancing. |
|
|
||||||
|
|
||||||
### Auxiliary libraries
|
|
||||||
|
|
||||||
| Library | Description |
|
|
||||||
|---------|-------------|
|
|
||||||
| **libharfbuzz-icu** | ICU Unicode integration. |
|
|
||||||
| **libharfbuzz-cairo** | Cairo rendering integration. |
|
|
||||||
| **libharfbuzz-gobject** | GObject/GI bindings. |
|
|
||||||
|
|
||||||
### Experimental libraries
|
|
||||||
|
|
||||||
| Library | Description |
|
|
||||||
|---------|-------------|
|
|
||||||
| **libharfbuzz-raster** | Glyph rasterization to bitmaps, including color fonts. Uses hb-draw and hb-paint. |
|
|
||||||
| **libharfbuzz-vector** | Glyph output to vector formats (currently SVG), including color fonts. Uses hb-draw and hb-paint. |
|
|
||||||
| **libharfbuzz-gpu** | Encodes glyph outlines for GPU rasterization (Slug algorithm). Provides shader sources in GLSL, WGSL, MSL, and HLSL. [Live demo.](https://harfbuzz.github.io/hb-gpu-demo/) |
|
|
||||||
|
|
||||||
Notable missing feature: font hinting (including autohinting)
|
|
||||||
is not implemented. For hinted rasterization, use FreeType or
|
|
||||||
Skrifa.
|
|
||||||
|
|
||||||
For simplified builds, amalgamated sources are available:
|
|
||||||
`harfbuzz.cc` (just libharfbuzz), `harfbuzz-subset.cc` (just
|
|
||||||
libharfbuzz-subset), or `harfbuzz-world.cc` (everything, driven
|
|
||||||
by a custom `hb-features.h`). For a live in-browser playground
|
|
||||||
plus a worked example of the world.cc single-file build, see
|
|
||||||
[harfbuzz-world.cc][26].
|
|
||||||
|
|
||||||
### Command-line tools
|
|
||||||
|
|
||||||
| Tool | Description |
|
|
||||||
|------|-------------|
|
|
||||||
| **hb-shape** | Shape text and display glyph output. |
|
|
||||||
| **hb-view** | Render shaped text to an image. |
|
|
||||||
| **hb-subset** | Subset and optimize fonts. |
|
|
||||||
| **hb-info** | Display font metadata. |
|
|
||||||
| **hb-raster** | Render glyphs to bitmap images. |
|
|
||||||
| **hb-vector** | Render glyphs to vector formats (SVG). |
|
|
||||||
| **hb-gpu** | Interactive GPU text rendering. |
|
|
||||||
|
|
||||||
The canonical source tree and bug trackers are available on [github][4].
|
|
||||||
Both development and user support discussion around HarfBuzz happen on
|
|
||||||
[github][4] as well.
|
|
||||||
|
|
||||||
For license information, see [COPYING](COPYING).
|
|
||||||
|
|
||||||
## API stability
|
|
||||||
|
|
||||||
The API that comes with `hb.h` will not change incompatibly. Other, peripheral,
|
|
||||||
headers are more likely to go through minor modifications, but again, we do our
|
|
||||||
best to never change API in an incompatible way. We will never break the ABI.
|
|
||||||
|
|
||||||
The API and ABI are stable even across major version number jumps. In fact,
|
|
||||||
current HarfBuzz is API/ABI compatible all the way back to the 0.9.x series.
|
|
||||||
If one day we need to break the API/ABI, that would be called a new library.
|
|
||||||
|
|
||||||
As such, we bump the major version number only when we add major new features,
|
|
||||||
the minor version when there is new API, and the micro version when there
|
|
||||||
are bug fixes.
|
|
||||||
|
|
||||||
## Documentation
|
|
||||||
|
|
||||||
For user manual as well as API documentation, check: https://harfbuzz.github.io
|
|
||||||
|
|
||||||
## Download
|
|
||||||
|
|
||||||
Tarball releases and Win32/Win64 binary bundles are available on the
|
|
||||||
[github releases][3] page.
|
|
||||||
|
|
||||||
## Development
|
|
||||||
|
|
||||||
For build information, see [BUILD.md](BUILD.md).
|
|
||||||
|
|
||||||
For custom configurations, see [CONFIG.md](CONFIG.md).
|
|
||||||
|
|
||||||
For testing and profiling, see [TESTING.md](TESTING.md).
|
|
||||||
|
|
||||||
For using with Python, see [README.python.md](README.python.md). There is also [uharfbuzz](https://github.com/harfbuzz/uharfbuzz).
|
|
||||||
|
|
||||||
For cross-compiling to Windows from Linux or macOS, see [README.mingw.md](README.mingw.md).
|
|
||||||
|
|
||||||
To report bugs or submit patches please use [github][4] issues and pull-requests.
|
|
||||||
|
|
||||||
### Developer documents
|
|
||||||
|
|
||||||
To get a better idea of where HarfBuzz stands in the text rendering stack you
|
|
||||||
may want to read [State of Text Rendering 2024][6].
|
|
||||||
Here are a few presentation slides about HarfBuzz over the years:
|
|
||||||
|
|
||||||
- 2026 – [HarfBuzz at 20!][25]
|
|
||||||
- 2016 – [Ten Years of HarfBuzz][20]
|
|
||||||
- 2014 – [Unicode, OpenType, and HarfBuzz: Closing the Circle][7]
|
|
||||||
- 2012 – [HarfBuzz, The Free and Open Text Shaping Engine][8]
|
|
||||||
- 2009 – [HarfBuzz: the Free and Open Shaping Engine][9]
|
|
||||||
|
|
||||||
More presentations and papers are available on [behdad][11]'s website.
|
|
||||||
In particular, the following _studies_ are relevant to HarfBuzz development:
|
|
||||||
|
|
||||||
- 2025 – [AAT layout caches][24]
|
|
||||||
- 2025 – [OpenType Layout lookup caches][23]
|
|
||||||
- 2025 – [Introducing HarfRust][22]
|
|
||||||
- 2025 – [Subsetting][21]
|
|
||||||
- 2025 – [Caching][12]
|
|
||||||
- 2025 – [`hb-decycler`][13]
|
|
||||||
- 2022 – [`hb-iter`][14]
|
|
||||||
- 2022 – [A C library written in C++][15]
|
|
||||||
- 2022 – [The case of the slow `hb-ft` `>h_advance` function][18]
|
|
||||||
- 2022 – [PackTab: A static integer table packer][16]
|
|
||||||
- 2020 – [HarfBuzz OT+AAT "Unishaper"][19]
|
|
||||||
- 2014 – [Building the Indic Shaper][17]
|
|
||||||
- 2012 – [Memory Consumption][10]
|
|
||||||
|
|
||||||
|
|
||||||
## Name
|
|
||||||
|
|
||||||
HarfBuzz /hærfˈbɒːz/
|
|
||||||
|
|
||||||
From Persian حرف (*Harf*: letter) and باز (*Buzz*: open).
|
|
||||||
Transliteration of the Persian calque for *OpenType*.
|
|
||||||
|
|
||||||
As a noun: *The* Open Source *text shaping* engine.
|
|
||||||
|
|
||||||
As an adjective: Insincerely talkative; glib. A nod to the
|
|
||||||
GNOME project where HarfBuzz originates from.
|
|
||||||
|
|
||||||
The logo shows حرفباز in the IranNastaliq font, on a Damascus
|
|
||||||
steel background.
|
|
||||||
|
|
||||||
> Background: Originally there was this font format called TrueType. People and
|
|
||||||
> companies started calling their type engines all things ending in Type:
|
|
||||||
> FreeType, CoolType, ClearType, etc. And then came OpenType, which is the
|
|
||||||
> successor of TrueType. So, for my OpenType implementation, I decided to stick
|
|
||||||
> with the concept but use the Persian translation. Which is fitting given that
|
|
||||||
> Persian is written in the Arabic script, and OpenType is an extension of
|
|
||||||
> TrueType that adds support for complex script rendering, and HarfBuzz is an
|
|
||||||
> implementation of OpenType text shaping.
|
|
||||||
|
|
||||||
## Users
|
|
||||||
|
|
||||||
HarfBuzz is used in Android, Chrome, ChromeOS, Firefox, Flutter, GNOME, GTK+, KDE,
|
|
||||||
Qt, LibreOffice, OpenJDK, XeTeX, Adobe Photoshop, Illustrator, InDesign,
|
|
||||||
Microsoft Edge, Amazon Kindle, PlayStation, Godot Engine, Unreal Engine,
|
|
||||||
Figma, Canva, QuarkXPress, Scribus, smart TVs,
|
|
||||||
car displays, and many other places.
|
|
||||||
|
|
||||||
<p align="center">
|
|
||||||
<a href="https://xkcd.com/2347/" rel="nofollow">
|
|
||||||
<img src="xkcd.png" width="256" alt="xkcd-derived image">
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
## Distribution
|
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Packaging status of HarfBuzz</summary>
|
|
||||||
|
|
||||||
[](https://repology.org/project/harfbuzz/versions)
|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
[1]: https://docs.microsoft.com/en-us/typography/opentype/spec/
|
|
||||||
[2]: https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6AATIntro.html
|
|
||||||
[3]: https://github.com/harfbuzz/harfbuzz/releases
|
|
||||||
[4]: https://github.com/harfbuzz/harfbuzz
|
|
||||||
[6]: https://behdad.org/text2024
|
|
||||||
[7]: https://docs.google.com/presentation/d/1x97pfbB1gbD53Yhz6-_yBUozQMVJ_5yMqqR_D-R7b7I/preview
|
|
||||||
[8]: https://docs.google.com/presentation/d/1ySTZaXP5XKFg0OpmHZM00v5b17GSr3ojnzJekl4U8qI/preview
|
|
||||||
[9]: https://behdad.org/doc/harfbuzz2009-slides.pdf
|
|
||||||
[10]: https://docs.google.com/document/d/12jfNpQJzeVIAxoUSpk7KziyINAa1msbGliyXqguS86M/preview
|
|
||||||
[11]: https://behdad.org/
|
|
||||||
[12]: https://docs.google.com/document/d/1_VgObf6Je0J8byMLsi7HCQHnKo2emGnx_ib_sHo-bt4/preview
|
|
||||||
[13]: https://docs.google.com/document/d/1Y-u08l9YhObRVObETZt1k8f_5lQdOix9TRH3zEXaoAw/preview
|
|
||||||
[14]: https://docs.google.com/document/d/1o-xvxCbgMe9JYFHLVnPjk01ZY_8Cj0vB9-KTI1d0nyk/preview
|
|
||||||
[15]: https://docs.google.com/document/d/18hI56KJpvXtwWbc9QSaz9zzhJwIMnrJ-zkAaKS-W-8k/preview
|
|
||||||
[16]: https://docs.google.com/document/d/1Xq3owVt61HVkJqbLFHl73il6pcTy6PdPJJ7bSouQiQw/preview
|
|
||||||
[17]: https://docs.google.com/document/d/1wMPwVNBvsIriamcyBO5aNs7Cdr8lmbwLJ8GmZBAswF4/preview
|
|
||||||
[18]: https://docs.google.com/document/d/1wskYbA-czBt57oH9gEuGf3sWbTx7bfOiEIcDs36-heo/preview
|
|
||||||
[19]: https://prezi.com/view/THNPJGFVDUCWoM20syev/
|
|
||||||
[20]: https://behdad.org/doc/harfbuzz10years-slides.pdf
|
|
||||||
[21]: https://docs.google.com/document/d/1_vZrt97OorJ0jA1YzJ29LRcGr3YGrNJANdOABjVZGEs/preview
|
|
||||||
[22]: https://docs.google.com/document/d/1aH_waagdEM5UhslQxCeFEb82ECBhPlZjy5_MwLNLBYo/preview
|
|
||||||
[23]: https://docs.google.com/document/d/1hRd5oYQJLrt0JuwWhEJWi7wh_9rbaIJkX6IR9DW7rZQ/preview
|
|
||||||
[24]: https://docs.google.com/document/d/1a3K6fHjsiWW36vSzwJwCwEBOgznunKs80PSpBbpfHiA/preview
|
|
||||||
[25]: https://docs.google.com/presentation/d/1o9Exz1c-Lr-dJjA8dcBn_Vl_Y37cupmFzmclMjBE_Bc/view
|
|
||||||
[26]: https://harfbuzz-world.cc/
|
|
||||||
Vendored
-386
@@ -1,386 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
"""
|
|
||||||
hb_extract.py -- copy the minimal subset of HarfBuzz sources used by OpenCV.
|
|
||||||
|
|
||||||
OpenCV vendors HarfBuzz as a normal static library: every .cc is a separate
|
|
||||||
translation unit (no unity / amalgamation build). This script reproduces the
|
|
||||||
exact src/ tree that OpenCV ships, from a pristine HarfBuzz checkout.
|
|
||||||
|
|
||||||
It does three things beyond a naive copy, all to keep the vendored tree small
|
|
||||||
and buildable with OpenCV's configuration (HB_TINY + HB_HAS_RASTER, see
|
|
||||||
CMakeLists.txt):
|
|
||||||
|
|
||||||
1. Copies the translation units that upstream `harfbuzz-world.cc` would
|
|
||||||
compile for the requested HB_HAS_* sections -- EXCEPT the ones that build
|
|
||||||
to an empty object under our config (see EMPTY_TUS). It never emits
|
|
||||||
`harfbuzz-world.cc` itself (we compile each .cc directly), and never
|
|
||||||
copies non-TU .cc files found under src/OT|graph (only real TUs from the
|
|
||||||
parsed world.cc lists are copied), so CMake's file(GLOB_RECURSE src/*.cc)
|
|
||||||
picks up exactly the right set.
|
|
||||||
|
|
||||||
2. Prunes headers down to the set actually reachable by #include from the
|
|
||||||
copied TUs (+ the public headers OpenCV includes). This automatically
|
|
||||||
drops the large amount of HarfBuzz src/ that we never compile -- GPU and
|
|
||||||
WASM backends, the subset/repacker graph, platform backends (CoreText/
|
|
||||||
DirectWrite/GDI/Uniscribe/Graphite2/GObject/Cairo), the vector-paint
|
|
||||||
backend, and headers used only by the skipped empty TUs -- without a
|
|
||||||
hardcoded blocklist.
|
|
||||||
|
|
||||||
3. Generates `hb-opencv-config.hh`, the config-override header CMakeLists.txt
|
|
||||||
points HB_CONFIG_OVERRIDE_H at. It re-enables thread-safety (HB_NO_MT) and
|
|
||||||
variable fonts (HB_NO_VAR) that HB_TINY would otherwise switch off. (It
|
|
||||||
does NOT generate upstream's hb-features.h: nothing we compile includes
|
|
||||||
it.)
|
|
||||||
|
|
||||||
Usage (to refresh this very directory, just point it at a harfbuzz checkout):
|
|
||||||
python hb_extract.py path/to/harfbuzz
|
|
||||||
|
|
||||||
The defaults already produce the OpenCV subset: output '.', features
|
|
||||||
HB_HAS_RASTER, and it also copies README.md + COPYING. Override only if needed:
|
|
||||||
-o DIR output root (default '.')
|
|
||||||
-f FLAGS comma-separated HB_HAS_* (default HB_HAS_RASTER)
|
|
||||||
-a FILES extra files (default README.md,COPYING)
|
|
||||||
--list-flags print available HB_HAS_* flags and exit
|
|
||||||
|
|
||||||
-a paths are relative to the harfbuzz repo root (parent of src/):
|
|
||||||
-a README.md -> copied to <out>/README.md
|
|
||||||
-a COPYING -> copied to <out>/COPYING
|
|
||||||
-a src/hb-raster.h -> copied to <out>/src/hb-raster.h
|
|
||||||
"""
|
|
||||||
|
|
||||||
import argparse
|
|
||||||
import posixpath
|
|
||||||
import re
|
|
||||||
import shutil
|
|
||||||
import sys
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
|
|
||||||
# Translation units that compile to an EMPTY object (libtool: "has no symbols")
|
|
||||||
# under OpenCV's HarfBuzz configuration (HB_TINY + HB_HAS_RASTER => AAT, legacy
|
|
||||||
# fallback shaping, math, meta, name, buffer (de)serialize/verify and the style
|
|
||||||
# API are all compiled out). They contribute nothing, so we do not vendor them.
|
|
||||||
# Re-derive this list (from the libtool warnings of a clean libharfbuzz build)
|
|
||||||
# if the HarfBuzz configuration in CMakeLists.txt changes.
|
|
||||||
EMPTY_TUS = {
|
|
||||||
"hb-aat-layout.cc",
|
|
||||||
"hb-aat-map.cc",
|
|
||||||
"hb-buffer-serialize.cc",
|
|
||||||
"hb-buffer-verify.cc",
|
|
||||||
"hb-fallback-shape.cc",
|
|
||||||
"hb-ot-math.cc",
|
|
||||||
"hb-ot-meta.cc",
|
|
||||||
"hb-ot-name.cc",
|
|
||||||
"hb-raster.cc",
|
|
||||||
"hb-style.cc",
|
|
||||||
}
|
|
||||||
|
|
||||||
# Public headers OpenCV's text engine (drawing_text.cpp) includes directly.
|
|
||||||
# Used together with the copied TUs as the roots of the header-reachability
|
|
||||||
# prune.
|
|
||||||
SEED_PUBLIC_HEADERS = ("hb.h", "hb-ot.h", "hb-raster.h")
|
|
||||||
|
|
||||||
# Generated config-override header. CMakeLists.txt builds HarfBuzz with HB_TINY
|
|
||||||
# and HB_CONFIG_OVERRIDE_H="hb-opencv-config.hh"; this file is included by
|
|
||||||
# hb-config.hh after HB_TINY/HB_LEAN expand (so the #undef takes effect) but
|
|
||||||
# before the option-closure derives dependent macros.
|
|
||||||
OPENCV_CONFIG_HH = '''\
|
|
||||||
/*
|
|
||||||
* OpenCV-specific HarfBuzz configuration override. GENERATED by hb_extract.py.
|
|
||||||
*
|
|
||||||
* HarfBuzz is built with HB_TINY (see 3rdparty/harfbuzz/CMakeLists.txt) for the
|
|
||||||
* smallest possible footprint. HB_TINY pulls in HB_LEAN + HB_MINI, which would
|
|
||||||
* disable two features that OpenCV's text engine relies on. We restore them
|
|
||||||
* here.
|
|
||||||
*
|
|
||||||
* This file is included by hb-config.hh via HB_CONFIG_OVERRIDE_H, i.e. AFTER
|
|
||||||
* HB_TINY/HB_LEAN/HB_MINI have expanded their macros (so the #undef below takes
|
|
||||||
* effect) but BEFORE the "closure of options" derives dependent macros (e.g.
|
|
||||||
* HB_NO_VAR_COMPOSITES from HB_NO_VAR). That ordering is what makes a plain
|
|
||||||
* #undef sufficient.
|
|
||||||
*
|
|
||||||
* HB_NO_MT - keep thread-safety. hb_font_t instances live inside cv::FontFace
|
|
||||||
* objects, NOT in the thread_local FontRenderEngine, so a single
|
|
||||||
* FontFace (and its hb_font_t) can be shared across threads; its
|
|
||||||
* reference counting must stay atomic.
|
|
||||||
*
|
|
||||||
* HB_NO_VAR - keep variable-font support: the 'wght' axis used for synthetic
|
|
||||||
* weights and named-instance/axis queries (hb_font_set_variations,
|
|
||||||
* hb_ot_var_*). Variable fonts are a primary reason OpenCV adopted
|
|
||||||
* HarfBuzz, so this must remain enabled.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#undef HB_NO_MT
|
|
||||||
#undef HB_NO_VAR
|
|
||||||
'''
|
|
||||||
|
|
||||||
OPENCV_CONFIG_NAME = "hb-opencv-config.hh"
|
|
||||||
|
|
||||||
|
|
||||||
def parse_world_cc(path):
|
|
||||||
"""Return (core_files, sections) parsed from harfbuzz-world.cc.
|
|
||||||
|
|
||||||
core_files -- list of .cc paths (relative to src/) in the unconditional
|
|
||||||
"Core library" section.
|
|
||||||
sections -- dict HB_HAS_XXX -> list of .cc paths from that #ifdef block.
|
|
||||||
"""
|
|
||||||
lines = path.read_text(encoding="utf-8").splitlines()
|
|
||||||
include_re = re.compile(r'^\s*#include\s+"([^"]+\.cc)"')
|
|
||||||
|
|
||||||
core_files = []
|
|
||||||
sections = {}
|
|
||||||
|
|
||||||
STATE_PREAMBLE, STATE_CORE, STATE_IFDEF = "preamble", "core", "ifdef"
|
|
||||||
state = STATE_PREAMBLE
|
|
||||||
current_flag = None
|
|
||||||
ifdef_depth = 0
|
|
||||||
|
|
||||||
for line in lines:
|
|
||||||
if state == STATE_PREAMBLE:
|
|
||||||
if "/* Core library." in line:
|
|
||||||
state = STATE_CORE
|
|
||||||
|
|
||||||
elif state == STATE_CORE:
|
|
||||||
m = include_re.match(line)
|
|
||||||
if m:
|
|
||||||
core_files.append(m.group(1))
|
|
||||||
else:
|
|
||||||
m = re.match(r"^\s*#ifdef\s+(HB_HAS_\w+)", line)
|
|
||||||
if m:
|
|
||||||
current_flag = m.group(1)
|
|
||||||
sections[current_flag] = []
|
|
||||||
state = STATE_IFDEF
|
|
||||||
ifdef_depth = 1
|
|
||||||
|
|
||||||
elif state == STATE_IFDEF:
|
|
||||||
if re.match(r"^\s*#if", line):
|
|
||||||
ifdef_depth += 1
|
|
||||||
elif re.match(r"^\s*#endif", line):
|
|
||||||
ifdef_depth -= 1
|
|
||||||
if ifdef_depth == 0:
|
|
||||||
state = STATE_CORE
|
|
||||||
current_flag = None
|
|
||||||
else:
|
|
||||||
m = include_re.match(line)
|
|
||||||
if m and current_flag is not None:
|
|
||||||
sections[current_flag].append(m.group(1))
|
|
||||||
|
|
||||||
return core_files, sections
|
|
||||||
|
|
||||||
|
|
||||||
def copy_files(file_list, src_dir, out_src_dir, label=""):
|
|
||||||
skipped = []
|
|
||||||
for rel in file_list:
|
|
||||||
if Path(rel).name in EMPTY_TUS:
|
|
||||||
skipped.append(rel)
|
|
||||||
continue
|
|
||||||
src = src_dir / rel
|
|
||||||
dst = out_src_dir / rel
|
|
||||||
dst.parent.mkdir(parents=True, exist_ok=True)
|
|
||||||
if not src.exists():
|
|
||||||
print(f" [WARN] not found: {src}", file=sys.stderr)
|
|
||||||
continue
|
|
||||||
shutil.copy2(src, dst)
|
|
||||||
print(f" [{label or 'core'}] src/{rel}")
|
|
||||||
for rel in skipped:
|
|
||||||
print(f" [skip-empty] src/{rel}")
|
|
||||||
|
|
||||||
|
|
||||||
def copy_headers(src_dir, out_src_dir, public_h=True):
|
|
||||||
"""Copy all candidate headers: src/*.hh, src/*.h (public API), and *.h/*.hh
|
|
||||||
from src/OT/** and src/graph/**. The unreferenced ones are removed later by
|
|
||||||
prune_unreferenced_headers().
|
|
||||||
|
|
||||||
NOTE: .cc files under OT/ and graph/ are intentionally NOT copied here --
|
|
||||||
the only ones we need are real translation units, copied via the parsed
|
|
||||||
world.cc lists. Copying e.g. src/graph/test-classdef-graph.cc would make
|
|
||||||
CMake's file(GLOB_RECURSE src/*.cc) try to compile a non-TU file.
|
|
||||||
"""
|
|
||||||
count = 0
|
|
||||||
|
|
||||||
def _copy(p):
|
|
||||||
nonlocal count
|
|
||||||
dst = out_src_dir / p.relative_to(src_dir)
|
|
||||||
dst.parent.mkdir(parents=True, exist_ok=True)
|
|
||||||
shutil.copy2(p, dst)
|
|
||||||
count += 1
|
|
||||||
|
|
||||||
for hdr in src_dir.glob("*.hh"):
|
|
||||||
_copy(hdr)
|
|
||||||
|
|
||||||
for subdir in ("OT", "graph"):
|
|
||||||
d = src_dir / subdir
|
|
||||||
if not d.exists():
|
|
||||||
continue
|
|
||||||
for hdr in d.rglob("*"):
|
|
||||||
if hdr.is_file() and hdr.suffix in (".h", ".hh"):
|
|
||||||
_copy(hdr)
|
|
||||||
|
|
||||||
if public_h:
|
|
||||||
for hdr in src_dir.glob("*.h"):
|
|
||||||
_copy(hdr)
|
|
||||||
|
|
||||||
return count
|
|
||||||
|
|
||||||
|
|
||||||
def prune_unreferenced_headers(out_src_dir):
|
|
||||||
"""Delete every header not reachable by #include from the copied TUs and the
|
|
||||||
public seed headers, then drop any directory left empty.
|
|
||||||
|
|
||||||
HarfBuzz's amalgamated src/ ships many headers we never compile (GPU/WASM
|
|
||||||
backends, subset/repacker graph, platform backends, vector-paint, and the
|
|
||||||
headers used only by the empty TUs we skip). Reachability removes them all
|
|
||||||
without a hardcoded list. The edge regex also treats any quoted "...h"/
|
|
||||||
"...hh" literal as an include, which covers the `#include HB_STRING_ARRAY_LIST`
|
|
||||||
macro-indirection trick (e.g. hb-ot-cff1-std-str.hh, hb-ot-post-macroman.hh).
|
|
||||||
"""
|
|
||||||
files = {p.relative_to(out_src_dir).as_posix()
|
|
||||||
for p in out_src_dir.rglob("*") if p.is_file()}
|
|
||||||
headers = {f for f in files if f.endswith((".h", ".hh"))}
|
|
||||||
edge_re = re.compile(r'#\s*include\s+["<]([^">]+)[">]|"([^"]+\.hh?)"')
|
|
||||||
|
|
||||||
def resolve(inc, including):
|
|
||||||
for cand in (posixpath.normpath(posixpath.join(posixpath.dirname(including), inc)),
|
|
||||||
posixpath.normpath(inc)):
|
|
||||||
if cand in files:
|
|
||||||
return cand
|
|
||||||
return None
|
|
||||||
|
|
||||||
seeds = {f for f in files if f.endswith(".cc")}
|
|
||||||
seeds |= {h for h in SEED_PUBLIC_HEADERS if h in files}
|
|
||||||
|
|
||||||
seen, stack = set(), list(seeds)
|
|
||||||
while stack:
|
|
||||||
cur = stack.pop()
|
|
||||||
if cur in seen:
|
|
||||||
continue
|
|
||||||
seen.add(cur)
|
|
||||||
try:
|
|
||||||
txt = (out_src_dir / cur).read_text(encoding="utf-8", errors="ignore")
|
|
||||||
except OSError:
|
|
||||||
continue
|
|
||||||
for m in edge_re.finditer(txt):
|
|
||||||
inc = m.group(1) or m.group(2)
|
|
||||||
r = resolve(inc, cur)
|
|
||||||
if r and r not in seen:
|
|
||||||
stack.append(r)
|
|
||||||
|
|
||||||
needed = {f for f in seen if f.endswith((".h", ".hh"))}
|
|
||||||
for h in sorted(headers - needed):
|
|
||||||
(out_src_dir / h).unlink()
|
|
||||||
print(f" [prune] src/{h}")
|
|
||||||
|
|
||||||
# remove directories left empty by pruning (deepest first)
|
|
||||||
for d in sorted((p for p in out_src_dir.rglob("*") if p.is_dir()),
|
|
||||||
key=lambda p: len(p.parts), reverse=True):
|
|
||||||
try:
|
|
||||||
d.rmdir()
|
|
||||||
except OSError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
return len(headers - needed), len(needed)
|
|
||||||
|
|
||||||
|
|
||||||
def write_opencv_config_h(out_src_dir):
|
|
||||||
"""Generate hb-opencv-config.hh (the HB_CONFIG_OVERRIDE_H header)."""
|
|
||||||
(out_src_dir / OPENCV_CONFIG_NAME).write_text(OPENCV_CONFIG_HH, encoding="utf-8")
|
|
||||||
print(f" [gen] src/{OPENCV_CONFIG_NAME}")
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
parser = argparse.ArgumentParser(
|
|
||||||
description="Copy the OpenCV subset of HarfBuzz sources.",
|
|
||||||
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
||||||
epilog="""
|
|
||||||
examples:
|
|
||||||
python hb_extract.py ~/work/harfbuzz -o . -f HB_HAS_RASTER -a README.md,COPYING
|
|
||||||
python hb_extract.py ~/work/harfbuzz --list-flags
|
|
||||||
""",
|
|
||||||
)
|
|
||||||
parser.add_argument("harfbuzz_dir", metavar="harfbuzz-dir",
|
|
||||||
help="path to the harfbuzz repo root (contains src/)")
|
|
||||||
parser.add_argument("-o", "--output", metavar="DIR", default=".",
|
|
||||||
help="output root directory; sources go into DIR/src/ "
|
|
||||||
"(default: current directory)")
|
|
||||||
parser.add_argument("-f", "--features", metavar="FLAGS", default="HB_HAS_RASTER",
|
|
||||||
help="comma-separated HB_HAS_* flags (default: HB_HAS_RASTER)")
|
|
||||||
parser.add_argument("-a", "--add", metavar="FILES", default="README.md,COPYING",
|
|
||||||
help="comma-separated files relative to the harfbuzz repo "
|
|
||||||
"root (default: README.md,COPYING)")
|
|
||||||
parser.add_argument("--no-public-headers", action="store_true",
|
|
||||||
help="skip copying public src/*.h API headers "
|
|
||||||
"(OT/, graph/, *.hh are always copied)")
|
|
||||||
parser.add_argument("--list-flags", action="store_true",
|
|
||||||
help="list available HB_HAS_* flags and exit")
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
repo_dir = Path(args.harfbuzz_dir).resolve()
|
|
||||||
world_cc_path = repo_dir / "src" / "harfbuzz-world.cc"
|
|
||||||
if not world_cc_path.exists():
|
|
||||||
print(f"error: {world_cc_path} not found", file=sys.stderr)
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
src_dir = world_cc_path.parent
|
|
||||||
core_files, sections = parse_world_cc(world_cc_path)
|
|
||||||
|
|
||||||
if args.list_flags:
|
|
||||||
for flag, files in sorted(sections.items()):
|
|
||||||
print(f" {flag:<22} ({len(files)} .cc files)")
|
|
||||||
return
|
|
||||||
|
|
||||||
enabled_flags = [f.strip() for f in args.features.split(",") if f.strip()]
|
|
||||||
extra_files = [f.strip() for f in args.add.split(",") if f.strip()]
|
|
||||||
|
|
||||||
out_dir = Path(args.output).resolve()
|
|
||||||
out_src_dir = out_dir / "src"
|
|
||||||
|
|
||||||
# Start from a clean src/ so removed-upstream files do not linger.
|
|
||||||
if out_src_dir.exists():
|
|
||||||
shutil.rmtree(out_src_dir)
|
|
||||||
out_src_dir.mkdir(parents=True, exist_ok=True)
|
|
||||||
|
|
||||||
print(f"\nsource : {repo_dir}")
|
|
||||||
print(f"output : {out_dir}")
|
|
||||||
print(f"flags : {enabled_flags}\n")
|
|
||||||
|
|
||||||
print("core:")
|
|
||||||
copy_files(core_files, src_dir, out_src_dir)
|
|
||||||
|
|
||||||
for flag in enabled_flags:
|
|
||||||
flag_files = sections.get(flag)
|
|
||||||
if not flag_files:
|
|
||||||
print(f"\n[{flag}]: no .cc files (flag not found in harfbuzz-world.cc)")
|
|
||||||
continue
|
|
||||||
print(f"\n[{flag}]:")
|
|
||||||
copy_files(flag_files, src_dir, out_src_dir, label=flag)
|
|
||||||
|
|
||||||
if extra_files:
|
|
||||||
print("\nextra:")
|
|
||||||
for rel in extra_files:
|
|
||||||
src = repo_dir / rel
|
|
||||||
dst = out_dir / rel
|
|
||||||
dst.parent.mkdir(parents=True, exist_ok=True)
|
|
||||||
if not src.exists():
|
|
||||||
print(f" [WARN] not found: {src}", file=sys.stderr)
|
|
||||||
continue
|
|
||||||
shutil.copy2(src, dst)
|
|
||||||
print(f" [add] {rel}")
|
|
||||||
|
|
||||||
n = copy_headers(src_dir, out_src_dir,
|
|
||||||
public_h=not args.no_public_headers)
|
|
||||||
print(f"\nheaders: {n} files copied")
|
|
||||||
|
|
||||||
print("\nprune (unreferenced headers):")
|
|
||||||
removed, kept = prune_unreferenced_headers(out_src_dir)
|
|
||||||
print(f" removed {removed}, kept {kept}")
|
|
||||||
|
|
||||||
print("\ngenerated:")
|
|
||||||
write_opencv_config_h(out_src_dir)
|
|
||||||
|
|
||||||
all_cc = sorted(out_src_dir.rglob("*.cc"))
|
|
||||||
all_h = list(out_src_dir.rglob("*.h")) + list(out_src_dir.rglob("*.hh"))
|
|
||||||
print(f"\ndone: {len(all_cc)} .cc | {len(all_h)} headers -> {out_dir}")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user