[問題] 用C++寫svd

看板C_and_CPP作者 (迷途羔羊)時間15年前 (2010/05/16 09:30), 編輯推噓0(004)
留言4則, 3人參與, 最新討論串1/1
小弟目前要用C++寫一個奇異值分解的程式 所以在網路上找了這個資料 The singular value decomposition of an m x n Matrix A (where m >= n) is a decomposition A = U * D * V.t() where U is m x n with U.t() * U equalling the identity, D is an n x n DiagonalMatrix and V is an n x n orthogonal matrix (type Matrix in Newmat). Singular value decompositions are useful for understanding the structure of ill-conditioned matrices, solving least squares problems, and for finding the eigenvalues of A.t() * A. To calculate the singular value decomposition of A (with m >= n) use one of SVD(A, D, U, V); // U = A is OK SVD(A, D); SVD(A, D, U); // U = A is OK SVD(A, D, U, false); // U (can = A) for workspace only SVD(A, D, U, V, false); // U (can = A) for workspace only 小弟不懂的是U,D,V都是未知的 為什麼一定要有D 不是因該只有SVD(A)嗎? 還請各位高手賜教 謝謝^^ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.124.201.58

05/16 17:40, , 1F
拿來放輸出的吧
05/16 17:40, 1F

05/16 17:40, , 2F
SVD(A:input,D:output,U:output,V:output)
05/16 17:40, 2F

05/16 18:20, , 3F
可是D,U,V不是未知嗎?我要拿甚麼放阿?
05/16 18:20, 3F

05/16 18:44, , 4F
就想辦法allocate memory阿..new/malloc (?
05/16 18:44, 4F
文章代碼(AID): #1Bxxix9y (C_and_CPP)