1175 7

Scientific Computing with Case Studies [推广有奖]

  • 0关注
  • 10粉丝

已卖:1625份资源

教授

8%

还不是VIP/贵宾

-

TA的文库  其他...

Must-Read Book

Winrats NewOccidental

Matlab NewOccidental

威望
1
论坛币
31504 个
通用积分
4.4911
学术水平
96 点
热心指数
43 点
信用等级
79 点
经验
9658 点
帖子
287
精华
10
在线时间
40 小时
注册时间
2013-12-14
最后登录
2024-4-12

楼主
农村固定观察点 发表于 2016-3-20 22:11:53 |AI写论文
1论坛币

Written for advanced undergraduate and early graduate courses in numerical analysis and scientific computing, this book provides a practical guide to the numerical solution of linear and nonlinear equations, differential equations, optimization problems, and eigenvalue problems. The book treats standard problems and introduces important variants such as sparse systems, differential-algebraic equations, constrained optimization, Monte Carlo simulations, and parametric studies.

In addition, a supplemental set of MATLAB code files is available for download. Optimization Toolbox is also discussed.


Retrieve Companion Software



关键词:Scientific computing Studies Comput comp scientific computing important practical addition

回帖推荐

fumingxu 发表于7楼  查看完整内容

**** 本内容被作者隐藏 ****

本帖被以下文库推荐

沙发
农村固定观察点 发表于 2016-3-20 22:29:08
  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. %                                                        %
  3. %  A solution to CSE For Your Homework Project 1         %
  4. %  Image Deblurring: I Can See Clearly Now               %
  5. %  Dianne P. O'Leary and James G. Nagy 09/02             %
  6. %                                                        %
  7. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  8. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  9. %                                                        %
  10. %  Read in a blurred image G and matrices A and B.       %
  11. %  Try to reconstruct F, where g is approximately        %
  12. %  kron(A,B) * reshape(F,m*n,1) and g = reshape(G,m*n,1) %
  13. %                                                        %
  14. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  15. load proj1data.mat

  16. imagesc(G)
  17. colormap(gray)
  18. figure(2)

  19. [m, n] = size(G);

  20. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  21. %                                                        %
  22. %  Compute the singular value decomposition of A and B.  %
  23. %                                                        %
  24. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  25. [Ua, Sa, Va] = svd(A);
  26. [Ub, Sb, Vb] = svd(B);

  27. Ghat = Ub'*G*Ua;

  28. S = diag(Sb)*(diag(Sa))';

  29. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  30. %                                                        %
  31. %  Use Tikhonov regularization, with parameters          %
  32. %  specified in lamtest, to reconstruct the image.       %
  33. %                                                        %
  34. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  35. lamtest = [.05 .01 .005 .0025 .0015 .001 .00095 .00016681 .00005];

  36. for lam=lamtest
  37.   Fhat = (S.*Ghat) ./ (S.*S+lam^2);
  38.   F = Vb*Fhat*Va';
  39.   imagesc(F)
  40.   colormap(gray)
  41.   disp(sprintf('Tikhonov lambda= %f',lam))
  42.   disp('Strike any key to continue.')
  43.   drawnow
  44.   pause
  45. end


  46. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  47. %                                                        %
  48. %  Use TSVD regularization to reconstruct the image.     %
  49. %                                                        %
  50. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  51. % Store the entries of S in a linear array s, then sort this
  52. % set in descending order and construct the permutation
  53. % that locates the ordered set in the unsorted list.

  54. s = reshape(S,n^2,1);
  55. [ss,prm] = sort(s);
  56. prm = flipud(prm);
  57. ss = flipud(ss);
  58. ls = length(s);
  59. iprm = zeros(ls,1);
  60. iprm(prm) = [1:ls]';


  61. % Using the sorted set and permutation constructed above,
  62. % remove all but the p largest singular values and then
  63. % compute the truncated expanded solution.  Test using a
  64. % set of values of p.

  65. pset = [100, 250, 500, 1000, 1500, 2000, 2500, 4000, 6000, 8000];

  66. for i=1:length(pset),
  67.   p = pset(i);
  68.   ssnew = [ss(1:p); zeros(length(ss)-p,1)];
  69.   Snew = reshape(ssnew(iprm),n,n);
  70.   Fhat = Ghat ./ S;
  71.   Fnew = Fhat .* (Snew>0);
  72.   F = Vb*Fnew*Va';
  73.   imagesc(F)
  74.   disp(sprintf('TSVD p= %d ', p))
  75.   disp('Strike any key to continue.')
  76.   drawnow
  77.   pause;
  78. end


  79. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  80. %                                                        %
  81. %  Here's an alternative approach to TSVD regularization,%
  82. %  which determines p implicitly by throwing out all     %
  83. %  singular values less than some value, here            %
  84. %  determined by the parameters in lamtest.              %
  85. %                                                        %
  86. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  87. Fhat = Ghat ./ S;
  88. for lam=lamtest
  89.   ind = S > lam;
  90.   Fnew = Fhat .* ind;
  91.   F = Vb*Fnew*Va';
  92.   imagesc(F)
  93.   disp(sprintf('TSVD lambda = %f, p = %d',lam,sum(sum(ind))))
  94.   disp('Strike any key to continue.')
  95.   drawnow
  96.   pause
  97. end
复制代码

藤椅
农村固定观察点 发表于 2016-3-20 22:30:03
  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. %                                                      %
  3. % This sample code demonstrates how to manipulate      %
  4. % Kronecker products of matrices without using a lot   %
  5. % of storage.                                          %
  6. %                                                      %
  7. % It solves the linear system  K f = g                 %
  8. % where K = kron(A,B)                                  %
  9. % using the singular value decompositions of A and B.  %
  10. %                                                      %
  11. % Notation:  F is a square array.  f contains these    %
  12. %                same entries, stacked by column.      %
  13. %            G is a square array.  g contains these    %
  14. %                same entries, stacked by column.      %
  15. %                                                      %
  16. % projdemo.m     Dianne P O'Leary 09/02                %
  17. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  18. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  19. %                                                      %
  20. % Initialize the data.  The problem is small enough    %
  21. % so that you can print everything out and look at it. %
  22. %                                                      %
  23. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  24. n = 3;
  25. F = rand(n,n);
  26. A = rand(n,n);
  27. B = rand(n,n) + eye(n);


  28. f = reshape(F,n*n,1);
  29. K = kron(A,B);
  30. g = K * f;

  31. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  32. %                                                      %
  33. % We could solve the problem by saying fcomp = K \ g,  %
  34. % but instead we will take advantage of the Kronecker  %
  35. % structure to avoid ever needing K or its factors.    %
  36. %                                                      %
  37. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  38. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  39. %                                                      %
  40. % Here is another way to compute the right-hand side.  %
  41. %                                                      %
  42. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  43. G = B * F * A';

  44. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  45. %                                                      %
  46. % Notice that it gives the same data, so the           %
  47. % following norm prints as a very small number.        %
  48. %                                                      %
  49. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  50. Gg = reshape(g,n,n);
  51. disp('norm(G - Gg)')
  52. disp(norm(G - Gg, 'fro'))

  53. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  54. %                                                      %
  55. % Let's solve the problem using SVD's of A and B,      %
  56. % as a model for understanding the data manipulation   %
  57. % in your homework.                                    %
  58. %                                                      %
  59. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


  60. [Ua, Sa, Va] = svd(A);
  61. [Ub, Sb, Vb] = svd(B);

  62. Ghat = Ub'*G*Ua;

  63. S = diag(Sb)*(diag(Sa))';

  64. Fhat = Ghat ./ S;
  65. Fc = Vb*Fhat*Va';

  66. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  67. %                                                      %
  68. % Notice that it gives almost the exact answer, so the %
  69. % following norm prints as a very small number.        %
  70. %                                                      %
  71. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  72. disp('norm(F - Fc)')
  73. disp(norm(F - Fc, 'fro'))

  74. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  75. %                                                      %
  76. % For completeness, we verify that                     %
  77. % kron(Ua,Ub) S kron(Va,Vb) is the SVD of K.           %
  78. %                                                      %
  79. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


  80. disp('norm(K-svd(K))')
  81. disp(norm(K - kron(Ua,Ub)*diag(reshape(S,n*n,1))*kron(Va,Vb)', 'fro'))
  82. disp('norm(UU^{T}-I)')
  83. disp(norm(kron(Ua,Ub)*kron(Ua,Ub)' - eye(n*n),'fro'))
  84. disp('norm(VV^{T}-I)')
  85. disp(norm(kron(Va,Vb)*kron(Va,Vb)' - eye(n*n),'fro'))
复制代码

板凳
农村固定观察点 发表于 2016-3-20 22:34:20
  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. %  Solution to Problem 3 in the homework assignment,
  3. %  Updating and Downdating Matrix Factorizations:
  4. %     A Change in Plans
  5. %
  6. %  We solve two truss problems, the first through matrix
  7. %  factorization and the second using the Sherman-Morrison-Woodbury
  8. %  formula.
  9. %
  10. %  First truss:  All members are equal length.  
  11. %                Assume a load of 50 at C.
  12. %
  13. %                  B           D
  14. %                 / \         / \
  15. %                /   \       /   \
  16. %               /     \     /     \
  17. %              /       \   /       \
  18. %             /         \ /         \
  19. %            A --------- C ----------E
  20. %
  21. %  problem3.m       Dianne P. O'Leary  12/2005
  22. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


  23. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  24. %
  25. % The original problem  A f = b, where f is the force vector
  26. % and b is the load vector.
  27. % The variables (columns) are the unknown forces:
  28. % The equations (rows) balance horizontal and vertical forces
  29. %  at each node.
  30. %
  31. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  32. c = cos(pi/3);
  33. s = sin(pi/3);
  34. l = -50;

  35. %     Ah Av AB BC CD DE BD AC CE Ev
  36. A = [ -1  0  c  0  0  0  0  1  0  0   % horizontal forces at A
  37.        0  1  s  0  0  0  0  0  0  0   % vertical   forces at A
  38.        0  0 -c  c  0  0  1  0  0  0   % horizontal forces at B
  39.        0  0  s  s  0  0  0  0  0  0   % vertical   forces at B
  40.        0  0  0 -c  c  0  0 -1  1  0   % horizontal forces at C
  41.        0  0  0  s  s  0  0  0  0  0   % vertical   forces at C
  42.        0  0  0  0 -c  c -1  0  0  0   % horizontal forces at D
  43.        0  0  0  0  s  s  0  0  0  0   % vertical   forces at D
  44.        0  0  0  0  0 -c  0  0 -1  0   % horizontal forces at E
  45.        0  0  0  0  0  s  0  0  0 -1]; % vertical   forces at E

  46. b = [  0; 0; 0; 0; 0; l; 0; 0; 0; 0];

  47. f = A \ b

  48. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  49. %
  50. %  Solve the modified problem: move node E so that member CE is
  51. %  2 times the length of the other members.
  52. %  The resulting matrix is A - Z V^T.
  53. %
  54. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


  55. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  56. % Angle DCE remains 60 degrees.
  57. % Angle CDE is 90 degrees
  58. % Angle DEC is 30 degrees.
  59. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  60. cosE =  cos(pi/6)
  61. sinE =  sin(pi/6)
  62. cosC =  cos(pi/3);

  63. gamma = pi/6;   % = angle at D between member 4 and horizontal.
  64. cosgam = cos(gamma);
  65. singam = sin(gamma);

  66. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  67. % New column 6 of matrix:
  68. % Member 4 applies horizontal force at D with factor  cos gamma   
  69. %                  vertical   force at D with factor  sin gamma   
  70. % Member 4 applies horizontal force at E with factor -cos gamma   
  71. %                  vertical   force at E with factor  sin gamma   
  72. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  73. V = zeros(10,1);
  74. V(6,1) = 1;

  75. Z = [A(:,6) - [0 0 0 0   0      0   cosgam singam -cosgam singam]'];

  76. [L,U,P]=lu(A);

  77. fmod = sherman_mw(L,U,b,Z,V,P)

  78. fmodtru = (A-Z*V')\b;

  79. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  80. % Display the results.
  81. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  82. disp(sprintf('The original vector of forces:'))
  83. disp(f')
  84. disp(sprintf('The vector of forces after the node is moved:'))
  85. disp(fmod')
  86. disp(sprintf('The difference between the Sherman-Morrison-Woodbury'))
  87. disp(sprintf(' answer and the answer computed with backslash: %e',...
  88.      norm(fmod-fmodtru)))
复制代码

报纸
农村固定观察点 发表于 2016-3-20 22:35:25
  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. %  Solution to Problem 4 in the homework assignment,
  3. %  Updating and Downdating Matrix Factorizations:
  4. %     A Change in Plans
  5. %
  6. %  For matrices of various sizes n, find the number of updates
  7. %  that makes the cost of using the Sherman-Morrison-Woodbury
  8. %  formula to solve a modified linear system comparable to
  9. %  solving the problem with backslash.
  10. %
  11. %  problem4.m       Dianne P. O'Leary  12/2005
  12. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  13. nn = [10:10:50,100:100:1000];

  14. ntries = 5;   % Number of repeats, used to try to make the timings
  15.               % more reproducible.
  16. k = 0;

  17. for nsize=1:length(nn);

  18. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  19. %  Generate a random problem of size n.
  20. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  21.    n = nn(nsize);
  22.    A = rand(n,n);
  23.    x = rand(n,1);
  24.    b = A*x;
  25.    [L,U,P]=lu(A);
  26.    P = sparse(P);

  27. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  28. %  Set timefact to be the time for solving using backslash.
  29. %  (Ignore the overhead in the "for" loop.)
  30. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  31.    tic
  32.    for j=1:ntries,
  33.       xcomp = A \ b;
  34.    end
  35.    timefact(nsize) = toc/ntries;
  36.    ttime = 0;

  37. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  38. %  Use Sherman-Morrison-Woodbury with a rank k update, and increase
  39. %  k until the time is greater than that for backslash.
  40. %  (Ignore the overhead in the "for" loop.)
  41. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  42.    while (ttime < timefact(nsize))&(k < n),
  43.      k = k + 1;
  44.      Z = rand(n,k);
  45.      V = rand(n,k);

  46.      tic
  47.      for j=1:ntries
  48.         xnew = sherman_mw(L,U,b,Z,V,P);
  49.      end
  50.      ttime = toc/ntries;
  51.    end
  52.    cross(nsize) = k;
  53.    k = k - 1;

  54. end

  55. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  56. %  Plot the results.
  57. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  58. plot(nn,cross,'LineWidth',1.5)
  59. xlabel('Size of matrix')
  60. ylabel('Rank of update')
  61. title('Making Sherman-Morrison-Woodbury time comparable to Backslash')
  62. print -dtiff smw.tif
复制代码

地板
农村固定观察点 发表于 2016-3-20 22:38:11
  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. %  Solution to Problem 6 in the homework assignment,
  3. %  Updating and Downdating Matrix Factorizations:
  4. %     A Change in Plans
  5. %
  6. %  We solve two truss problems, the first through matrix
  7. %  factorization and the second using a QR update.
  8. %
  9. %  First truss:  All members are equal length.
  10. %                Assume a load of 50 at C.
  11. %
  12. %                  B           D
  13. %                 / \         / \
  14. %                /   \       /   \
  15. %               /     \     /     \
  16. %              /       \   /       \
  17. %             /         \ /         \
  18. %            A --------- C ----------E
  19. %
  20. %
  21. %  problem6.m       Dianne P. O'Leary  12/2005
  22. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


  23. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  24. %
  25. %  The original problem  A f = b, where f is the force vector
  26. %  and b is the load vector.
  27. % The variables (columns) are the unknown forces:
  28. % The equations (rows) balance horizontal and vertical forces
  29. %  at each node.
  30. %
  31. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  32. c = cos(pi/3);
  33. s = sin(pi/3);
  34. l = -50;

  35. %     Ah Av AB BC CD DE BD AC CE Ev
  36. A = [ -1  0  c  0  0  0  0  1  0  0   % horizontal forces at A
  37.        0  1  s  0  0  0  0  0  0  0   % vertical   forces at A
  38.        0  0 -c  c  0  0  1  0  0  0   % horizontal forces at B
  39.        0  0  s  s  0  0  0  0  0  0   % vertical   forces at B
  40.        0  0  0 -c  c  0  0 -1  1  0   % horizontal forces at C
  41.        0  0  0  s  s  0  0  0  0  0   % vertical   forces at C
  42.        0  0  0  0 -c  c -1  0  0  0   % horizontal forces at D
  43.        0  0  0  0  s  s  0  0  0  0   % vertical   forces at D
  44.        0  0  0  0  0 -c  0  0 -1  0   % horizontal forces at E
  45.        0  0  0  0  0  s  0  0  0 -1]; % vertical   forces at E

  46. b = [  0; 0; 0; 0; 0; l; 0; 0; 0; 0];

  47. f = A \ b

  48. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  49. %
  50. %  Solve the modified problem: move node E so that member CE is
  51. %  2 times the length of the other members.
  52. %  The resulting matrix is A - Z V^T.
  53. %
  54. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


  55. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  56. % Angle DCE remains 60 degrees.
  57. % Angle CDE is 90 degrees
  58. % Angle DEC is 30 degrees.
  59. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  60. cosE =  cos(pi/6)
  61. sinE =  sin(pi/6)
  62. cosC =  cos(pi/3);

  63. gamma = pi/6;   % = angle at D between member 4 and horizontal.
  64. cosgam = cos(gamma);
  65. singam = sin(gamma);

  66. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  67. % New column 6 of matrix:
  68. % Member 4 applies horizontal force at D with factor  cos gamma   
  69. %                  vertical   force at D with factor  sin gamma   
  70. % Member 4 applies horizontal force at E with factor -cos gamma   
  71. %                  vertical   force at E with factor  sin gamma   
  72. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  73. V = zeros(10,1);
  74. V(6,1) = 1;

  75. Z = [A(:,6) - [0 0 0 0   0      0   cosgam singam -cosgam singam]'];

  76. [L,U,P]=lu(A);

  77. [Q,R]=qr(A);

  78. global Anew
  79. Anew = A - Z*V';

  80. [Qnew,Rnew] = qrcolchange(Q,R,6,-Z)

  81. fmod = Rnew\(Qnew'*b);
  82. fmodtru = (A-Z*V')\b;

  83. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  84. % Display the results.
  85. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  86. disp(sprintf('The original vector of forces:'))
  87. disp(f')
  88. disp(sprintf('The vector of forces after the node is moved:'))
  89. disp(fmod')
  90. disp(sprintf('The difference between the QR-update'))
  91. disp(sprintf(' answer and the answer computed with backslash: %e',...
  92.      norm(fmod-fmodtru)))
复制代码

7
fumingxu 发表于 2016-3-20 22:49:40

本帖隐藏的内容

here?Dianne P. O'Leary-Scientific Computing with Case Studies-Society for .pdf (4.52 MB)


已有 2 人评分经验 论坛币 学术水平 热心指数 信用等级 收起 理由
Nicolle + 100 + 100 + 1 + 1 + 1 精彩帖子
农村固定观察点 + 1 + 1 + 1 + 1 精彩帖子

总评分: 经验 + 100  论坛币 + 101  学术水平 + 2  热心指数 + 2  信用等级 + 2   查看全部评分

8
raistlinok 发表于 2016-6-22 21:07:09
我来吧  哦 已经有人应助了 没看见

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-31 03:05