看板 C_and_CPP 關於我們 聯絡資訊
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) Linux + gcc 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) GSL 問題(Question): 我新建了一個struct裏面包含GSL定義的struct (gsl_matrix_view) 然後有一個function是以此struct的指標為引數去讀寫該物件 可是如果要讀寫"此指標指向的物件內的物件的指標"會出問題 餵入的資料(Input): 還沒餵,還在compile 預期的正確結果(Expected Output): 無錯誤 錯誤結果(Wrong Output): error: request for member ‘matrix’ in something not a structure or union 程式碼(Code):(請善用置底文網頁, 記得排版) typedef struct EKF_FILTER_T{ double F[EKF_STATE_DIM*EKF_STATE_DIM]; gsl_matrix_view m_F; } EKF_Filter; void EKF_New(EKF_Filter* ekf) { memset(ekf, sizeof(EKF_Filter), 0); // 物件歸零 ekf->m_F = gsl_matrix_view_array (ekf->F, EKF_STATE_DIM, EKF_STATE_DIM); (老實說我不知道上一行是否正確) gsl_matrix_set_identity((ekf->m_F).matrix); -> 有錯誤訊息 } 補充說明(Supplement): gsl_matrix_view 是 GSL定義的struct,其中只有一個gsl_matrix*物件 以下可把gsl_matrix_view與某一維陣列連結: gsl_matrix_view gsl_matrix_view_array (double * base, size_t n, size_t m) void gsl_matrix_set_identity (gsl_matrix * m) -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 90.41.46.102 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1441115941.A.1D4.html
Feis: F ? 09/01 22:01
※ 編輯: wtchen (90.41.46.102), 09/01/2015 22:03:39
wtchen: 抱歉,修正了 09/01 22:03
Feis: 所以 F 是哪來的? 09/01 22:05
抱歉,又修正 ※ 編輯: wtchen (90.41.46.102), 09/01/2015 22:14:55 ※ 編輯: wtchen (90.41.46.102), 09/01/2015 22:15:29 ※ 編輯: wtchen (90.41.46.102), 09/01/2015 22:16:24 ※ 編輯: wtchen (90.41.46.102), 09/01/2015 22:16:59
Feis: gsl_matrix_set_identity(&ekf->m_F.matrix); 09/01 22:20
wtchen: 不懂,ekf不是已經是address為何還要加& 09/01 22:36
※ 編輯: wtchen (90.41.46.102), 09/01/2015 22:38:51 ※ 編輯: wtchen (90.41.46.102), 09/01/2015 22:39:54 ※ 編輯: wtchen (90.41.46.102), 09/01/2015 22:43:15 感謝,已解決, 應該要寫gsl_matrix_float_set_identity(&ekf->m_F.matrix); ※ 編輯: wtchen (90.41.46.102), 09/01/2015 22:45:49