{"action":"created","issue":{"url":"https://api.github.com/repos/shogun-toolbox/shogun/issues/2687","labels_url":"https://api.github.com/repos/shogun-toolbox/shogun/issues/2687/labels{/name}","comments_url":"https://api.github.com/repos/shogun-toolbox/shogun/issues/2687/comments","events_url":"https://api.github.com/repos/shogun-toolbox/shogun/issues/2687/events","html_url":"https://github.com/shogun-toolbox/shogun/issues/2687","id":55970102,"number":2687,"title":"issue in SGVector ","user":{"login":"yorkerlin","id":6913996,"avatar_url":"https://avatars.githubusercontent.com/u/6913996?v=3","gravatar_id":"","url":"https://api.github.com/users/yorkerlin","html_url":"https://github.com/yorkerlin","followers_url":"https://api.github.com/users/yorkerlin/followers","following_url":"https://api.github.com/users/yorkerlin/following{/other_user}","gists_url":"https://api.github.com/users/yorkerlin/gists{/gist_id}","starred_url":"https://api.github.com/users/yorkerlin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yorkerlin/subscriptions","organizations_url":"https://api.github.com/users/yorkerlin/orgs","repos_url":"https://api.github.com/users/yorkerlin/repos","events_url":"https://api.github.com/users/yorkerlin/events{/privacy}","received_events_url":"https://api.github.com/users/yorkerlin/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":16,"created_at":"2015-01-29T22:56:10Z","updated_at":"2015-01-30T14:40:13Z","closed_at":"2015-01-30T07:38:02Z","body":"```\r\nSGVector<float64_t> catchbug()\r\n{\r\n\tSGMatrix<float64_t> a(2,2);\r\n\ta.set_const(-0.05);\r\n\tSGVector<float64_t> tmp(a.matrix, a.num_rows*a.num_cols, false);\r\n\treturn tmp;\r\n}\r\nint main(int argc, char** argv)\r\n{\r\n\tinit_shogun_with_defaults();\r\n\tSGVector<float64_t> ok=catchbug();\r\n\tMap<VectorXd> out(ok.vector, ok.vlen);\r\n\tstd::cout<<out<<std::endl;\r\n\texit_shogun();\r\n\treturn 0;\r\n}\r\n```\r\nResult in my laptop is\r\n```\r\n4.94066e-324\r\n4.94066e-324\r\n-0.05\r\n-0.05\r\n```"},"comment":{"url":"https://api.github.com/repos/shogun-toolbox/shogun/issues/comments/72210526","html_url":"https://github.com/shogun-toolbox/shogun/issues/2687#issuecomment-72210526","issue_url":"https://api.github.com/repos/shogun-toolbox/shogun/issues/2687","id":72210526,"user":{"login":"lambday","id":3088401,"avatar_url":"https://avatars.githubusercontent.com/u/3088401?v=3","gravatar_id":"","url":"https://api.github.com/users/lambday","html_url":"https://github.com/lambday","followers_url":"https://api.github.com/users/lambday/followers","following_url":"https://api.github.com/users/lambday/following{/other_user}","gists_url":"https://api.github.com/users/lambday/gists{/gist_id}","starred_url":"https://api.github.com/users/lambday/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lambday/subscriptions","organizations_url":"https://api.github.com/users/lambday/orgs","repos_url":"https://api.github.com/users/lambday/repos","events_url":"https://api.github.com/users/lambday/events{/privacy}","received_events_url":"https://api.github.com/users/lambday/received_events","type":"User","site_admin":false},"created_at":"2015-01-30T14:40:12Z","updated_at":"2015-01-30T14:40:12Z","body":"@yorkerlin if serves your purposes, you can disable refcounting in the original matrix and just have refcount from the vector.\r\n```c++\r\nSGMatrix<float64_t> fun()\r\n{\r\n    SGMatrix<float64_t> ok(2,2, false);\r\n    ok.set_const(-0.05);\r\n    return ok; \r\n}\r\nSGVector<float64_t> catchbug(){\r\n    SGMatrix<float64_t> a=fun();\r\n    SGVector<float64_t> tmp = SGVector<float64_t>(a.matrix, a.num_rows*a.num_cols);\r\n    return tmp;\r\n}\r\nint main(int argc, char** argv)\r\n{\r\n    init_shogun_with_defaults();\r\n    SGVector<float64_t> ok=catchbug();\r\n    Map<VectorXd> out(ok.vector, ok.vlen);\r\n    std::cout<<out<<std::endl;\r\n    exit_shogun();\r\n    return 0;\r\n}\r\n```"}}