fortran77 初始化矩陣 打印矩陣 模版 備拷

1,源碼

        SUBROUTINE INIT_MATRIX(A, m, n, lda)DOUBLE PRECISION A(*)CALL SRAND(2024)DO i=1, mDO j=1, nA(i + lda*(j-1)) = RAND() + RAND()
C                                WRITE(*, '(F8.4)') A(i)END DOEND DOENDSUBROUTINE PRINT_MATRIX(A, m, n, lda)DOUBLE PRECISION A(*)DO i=1, mDO j=1, n
C                                WRITE(*, '(F8.4 , $)') A(i + lda*(j-1))WRITE(*, 20) A(i + lda*(j-1))
20                              FORMAT (1X,F8.4, $)END DOPRINT *,''END DOENDPROGRAM MATRIX_EXINTEGER m, n, ldaDOUBLE PRECISION A(20)lda = 4m = 4n = 5CALL INIT_MATRIX(A, m, n, lda)PRINT *, "A ="CALL PRINT_MATRIX(A, m, n, lda)PRINT *, "A(11) ="PRINT *, A(11)END

?Makefile

matrix_ex: matrix_ex.fgfortran -g $< -o $@.PHONY: clean
clean:-rm matrix_ex

2,執行
?

make./matrix_ex

效果:

3, dgesvd example

*  Copyright (C) 2009-2015 Intel Corporation. All Rights Reserved.
*  The information and material ("Material") provided below is owned by Intel
*  Corporation or its suppliers or licensors, and title to such Material remains
*  with Intel Corporation or its suppliers or licensors. The Material contains
*  proprietary information of Intel or its suppliers and licensors. The Material
*  is protected by worldwide copyright laws and treaty provisions. No part of
*  the Material may be copied, reproduced, published, uploaded, posted,
*  transmitted, or distributed in any way without Intel's prior express written
*  permission. No license under any patent, copyright or other intellectual
*  property rights in the Material is granted to or conferred upon you, either
*  expressly, by implication, inducement, estoppel or otherwise. Any license
*  under such intellectual property rights must be express and approved by Intel
*  in writing.
*  =============================================================================
*
*  DGESVD Example.
*  ==============
*
*  Program computes the singular value decomposition of a general
*  rectangular matrix A:
*
*    8.79   9.93   9.83   5.45   3.16
*    6.11   6.91   5.04  -0.27   7.98
*   -9.15  -7.93   4.86   4.85   3.01
*    9.57   1.64   8.83   0.74   5.80
*   -3.49   4.02   9.80  10.00   4.27
*    9.84   0.15  -8.99  -6.02  -5.31
*
*  Description.
*  ============
*
*  The routine computes the singular value decomposition (SVD) of a real
*  m-by-n matrix A, optionally computing the left and/or right singular
*  vectors. The SVD is written as
*
*  A = U*SIGMA*VT
*
*  where SIGMA is an m-by-n matrix which is zero except for its min(m,n)
*  diagonal elements, U is an m-by-m orthogonal matrix and VT (V transposed)
*  is an n-by-n orthogonal matrix. The diagonal elements of SIGMA
*  are the singular values of A; they are real and non-negative, and are
*  returned in descending order. The first min(m, n) columns of U and V are
*  the left and right singular vectors of A.
*
*  Note that the routine returns VT, not V.
*
*  Example Program Results.
*  ========================
*
* DGESVD Example Program Results
*
* Singular values
*  27.47  22.64   8.56   5.99   2.01
*
* Left singular vectors (stored columnwise)
*  -0.59   0.26   0.36   0.31   0.23
*  -0.40   0.24  -0.22  -0.75  -0.36
*  -0.03  -0.60  -0.45   0.23  -0.31
*  -0.43   0.24  -0.69   0.33   0.16
*  -0.47  -0.35   0.39   0.16  -0.52
*   0.29   0.58  -0.02   0.38  -0.65
*
* Right singular vectors (stored rowwise)
*  -0.25  -0.40  -0.69  -0.37  -0.41
*   0.81   0.36  -0.25  -0.37  -0.10
*  -0.26   0.70  -0.22   0.39  -0.49
*   0.40  -0.45   0.25   0.43  -0.62
*  -0.22   0.14   0.59  -0.63  -0.44
*  =============================================================================
*
*     .. Parameters ..INTEGER          M, NPARAMETER        ( M = 6, N = 5 )INTEGER          LDA, LDU, LDVTPARAMETER        ( LDA = M, LDU = M, LDVT = N )INTEGER          LWMAXPARAMETER        ( LWMAX = 1000 )
*
*     .. Local Scalars ..INTEGER          INFO, LWORK
*
*     .. Local Arrays ..DOUBLE PRECISION A( LDA, N ), U( LDU, M ), VT( LDVT, N ), S( N ),$                 WORK( LWMAX )DATA             A/$  8.79, 6.11,-9.15, 9.57,-3.49, 9.84,$  9.93, 6.91,-7.93, 1.64, 4.02, 0.15,$  9.83, 5.04, 4.86, 8.83, 9.80,-8.99,$  5.45,-0.27, 4.85, 0.74,10.00,-6.02,$  3.16, 7.98, 3.01, 5.80, 4.27,-5.31$                  /
*
*     .. External Subroutines ..EXTERNAL         DGESVDEXTERNAL         PRINT_MATRIX
*
*     .. Intrinsic Functions ..INTRINSIC        INT, MIN
*
*     .. Executable Statements ..WRITE(*,*)'DGESVD Example Program Results'
*
*     Query the optimal workspace.
*LWORK = -1CALL DGESVD( 'All', 'All', M, N, A, LDA, S, U, LDU, VT, LDVT,$             WORK, LWORK, INFO )LWORK = MIN( LWMAX, INT( WORK( 1 ) ) )
*
*     Compute SVD.
*CALL DGESVD( 'All', 'All', M, N, A, LDA, S, U, LDU, VT, LDVT,$             WORK, LWORK, INFO )
*
*     Check for convergence.
*IF( INFO.GT.0 ) THENWRITE(*,*)'The algorithm computing SVD failed to converge.'STOPEND IF
*
*     Print singular values.
*CALL PRINT_MATRIX( 'Singular values', 1, N, S, 1 )
*
*     Print left singular vectors.
*CALL PRINT_MATRIX( 'Left singular vectors (stored columnwise)',$                   M, N, U, LDU )
*
*     Print right singular vectors.
*CALL PRINT_MATRIX( 'Right singular vectors (stored rowwise)',$                   N, N, VT, LDVT )STOPEND
*
*     End of DGESVD Example.
*
*  =============================================================================
*
*     Auxiliary routine: printing a matrix.
*SUBROUTINE PRINT_MATRIX( DESC, M, N, A, LDA )CHARACTER*(*)    DESCINTEGER          M, N, LDADOUBLE PRECISION A( LDA, * )
*INTEGER          I, J
*WRITE(*,*)WRITE(*,*) DESCDO I = 1, MWRITE(*,9998) ( A( I, J ), J = 1, N )END DO
*9998 FORMAT( 11(:,1X,F6.2) )RETURNEND

Makefile

svd_dgesve_ex: svd_dgesve_ex.fgfortran -g $< ../lapack-3.11/liblapack.a  ../lapack-3.11/librefblas.a -o $@

運行

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/14484.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/14484.shtml
英文地址,請注明出處:http://en.pswp.cn/web/14484.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

解釋Python中的上下文管理器(context manager)

Python中的上下文管理器&#xff08;Context Manager&#xff09;是一種用于管理某些資源的對象&#xff0c;如文件、網絡連接、數據庫連接等。這些資源在使用完畢后需要進行清理操作&#xff0c;如關閉文件、斷開連接等。通過上下文管理器&#xff0c;Python提供了一種優雅的方…

【Vue3】封裝axios請求(cli和vite)

原文作者&#xff1a;我輩李想 版權聲明&#xff1a;文章原創&#xff0c;轉載時請務必加上原文超鏈接、作者信息和本聲明。 Vue 【Vue3】env環境變量的配置和使用&#xff08;區分cli和vite&#xff09; 文章目錄 Vue前言一、常見用法二、vue3cli封裝接口1..env配置2..dev(開…

ADC協議詳解

文章目錄 簡介工作流程原理圖時序圖 優點與缺點 簡介 模數轉換器&#xff08;ADC&#xff0c;Analog-to-Digital Converter&#xff09;是一種將模擬信號轉換為數字信號的電子設備。模擬信號通常表示物理測量的連續變化&#xff0c;如聲音、溫度、壓力等&#xff0c;而數字信號…

codewars check_same_case 題解

題目 編寫一個函數來檢查兩個給定的字符是否大小寫相同。 如果任何字符不是字母&#xff0c;則返回-1如果兩個字符大小寫相同&#xff0c;則返回1如果兩個字符都是字母且大小寫不同&#xff0c;則返回0 例子 a并g返回1A并C返回1b并G返回0B并g返回00并?返回-1題解 1 此題主…

AI大模型與產品策略:產品經理的致勝之道

隨著AI大模型的快速進化&#xff0c;其生態的構建&#xff0c;已經從C端過度到了B端。 作為產品經理&#xff0c;我們應該及時響應大趨勢&#xff0c;在產品策略上融入AI大模型模塊&#xff0c;深度挖掘AI大模型的應用價值&#xff0c;這才是作為PM在現階段最有價值的地方。 …

想學接口測試,不知道那個工具適合?

引言&#xff1a; 接口測試在軟件開發中扮演著至關重要的角色&#xff0c;它可以幫助我們驗證系統的功能、性能和安全性。而選擇適合的工具是進行接口測試的重要一步。本文將從零開始&#xff0c;為你詳細介紹如何選擇合適的工具&#xff0c;并提供規范的指導。 一、了解接口…

初識C語言——第二十八天

代碼練習1&#xff1a; 用函數的方式實現9*9乘法表 void print_table(int n) {int i 0;int j 0;for (i 1; i< n; i){for (j 1; j< i; j){printf("%d*%d%-3d ", i, j, i * j);}printf("\n");}}int main() {int n 0;scanf("%d", &a…

shell :二進制安裝docker

#!/bin/bash #設置字體顏色 function RedFont(){echo -e "\033[31mError: $1 \033[0m" }function GreenFont(){echo -e "\033[32mInfo: $1 \033[0m" }function YellowFont(){echo -e "\033[33mWarning: $1 \033[0m" }CURRENT_DIRpwd FILE_NAMEdo…

漢明碼(海明碼)的計算的規則

一.漢明碼的由來 1.漢明碼&#xff08;Hamming Code&#xff09;&#xff0c;是在電信領域的一種線性調試碼&#xff0c;以發明者理查德衛斯里漢明的名字命名。漢明碼在傳輸的消息流中插入驗證碼&#xff0c;當計算機存儲或移動數據時&#xff0c;可能會產生數據位錯誤&#x…

【VUE】 如何關閉ESlint的自動修復功能

問題描述例如&#xff1a;原書寫代碼ESLint自動修復報錯如下 方案一、在文件中添加屏蔽警告的代碼html代碼中JavaScript代碼中 方案二、關閉ESLint的自動修復功能1、VSCode 擴展找到 ESLint 插件2、在設置中找到在 settings,json 中編輯3、將"autoFix": true改為&quo…

3.2 運維、運營和經營

第3章 信息技術服務知識 3.2 運維、運營和經營 3.2.1 運維 1、運維是運行維護的簡稱&#xff0c;是一種IT服務形態。2、在《信息技術服務分類與代碼》&#xff08;GB/T29264-20l2&#xff09;中&#xff0c;對運行維護服務&#xff08;operation maintenance service&#x…

4.雙指針+遞歸

一、雙指針編程技巧 方法參數傳遞數組 將數組通過方法參數傳遞&#xff0c;方法操作的數組和main方法中的數組指向同一塊內存區域&#xff0c;意味著方法操作數組&#xff0c;同時會引起main方法中數組的改變以引用的方式作為方法參數進行傳遞的 元素交換 定義臨時變量temp&a…

第十二節 SpringBoot Starter 系列結束語

感謝閱讀&#xff0c;到這里&#xff0c;本系列課程就結束了。 一、為什么選擇 SpringBoot Starter SpringBoot 近年來已經成為 Java 應用的必備框架&#xff1b; 而 SpringBoot starter 模式已經成為各大中間件集成到 SpringBoot 應用的首選方式&#xff0c;通過引入 xxx-st…

C++ | Leetcode C++題解之第101題對稱二叉樹

題目&#xff1a; 題解&#xff1a; class Solution { public:bool check(TreeNode *u, TreeNode *v) {queue <TreeNode*> q;q.push(u); q.push(v);while (!q.empty()) {u q.front(); q.pop();v q.front(); q.pop();if (!u && !v) continue;if ((!u || !v) ||…

爬蟲基礎1

一、爬蟲的基本概念 1.什么是爬蟲&#xff1f; 請求網站并提取數據的自動化程序 2.爬蟲的分類 2.1 通用爬蟲&#xff08;大而全&#xff09; 功能強大&#xff0c;采集面廣&#xff0c;通常用于搜索引擎&#xff1a;百度&#xff0c;360&#xff0c;谷歌 2.2 聚焦爬蟲&#x…

Android App啟動流程和源碼詳解

前言 之前看了些App啟動流程的文章&#xff0c;但是看得很淺顯&#xff0c;隔了沒多久就忘了&#xff0c;自己抓耳撓腮的終于看完了&#xff0c;看得頭疼哦。因為很多是個人理解&#xff0c;大哥們主打一個7分信&#xff0c;2分思考&#xff0c;1分懷疑哈。 主要看的源碼是An…

pytorch-20_1 LSTM在股價數據集上的預測實戰

LSTM在股價數據集上的預測實戰 使用完整的JPX賽題數據&#xff0c;并向大家提供完整的lstm流程。 導包 import numpy as np #數據處理 import pandas as pd #數據處理 import matplotlib as mlp import matplotlib.pyplot as plt #繪圖 from sklearn.preprocessing import M…

人類交互4 感覺輸入和運動輸出

人類感覺系統概述 人類感覺系統是由多個感覺器官和神經系統組成&#xff0c;負責感知外部世界的各種刺激和信息。人類感覺系統包括以下幾個主要部分&#xff1a; 視覺系統&#xff1a;視覺系統由眼睛、視神經和大腦視覺皮層組成&#xff0c;負責感知光線、顏色和形狀&#xff…

datasheet芯片數據手冊—新手入門學習(二)【8-18】

參考芯片手冊已經上傳&#xff0c;可自行下載 因為芯片參考手冊內容比較多&#xff0c;故再一次介紹本文內容主要講解章節。 目錄 8、內容介紹 命令真值表 9、Command Definitions 10、READ Operations &#xff08;1&#xff09;頁面讀取操作 &#xff08;2&#xff…

YTM32的flash應用答疑-詳解寫保護功能

YTM32的flash應用答疑-詳解寫保護功能 文章目錄 YTM32的flash應用答疑-詳解寫保護功能IntroductionPrincipleOperation & DemonstrationDemo #1 驗證基本的寫保護功能Demo #2 編程CUS_NVR設定EFM_ADDR_PROT初值Demo #3 啟用寫保護后試試塊擦除操作 Conclusion Introduction…