data type not understood during attaching some matrix blocks to each other
Here is my attempt to build a big matrix out of some smaller ones:
import numpy as np
lambda1 = 1
lambda3 = 0.03
def create_Lambda_matrix(lambda1, lambda3):
Lambda = np.zeros((6,7))
temp3by3 = 2*np.matrix([[lambda1, lambda3, lambda3],[lambda3, lambda1, lambda3],[lambda3, lambda3, lambda1]])
temp2by2 = 2*np.matrix([[lambda1, lambda3],[lambda3, lambda1]])
Lambda = np.bmat([[temp3by3, np.zeros(3,4)]],
[np.zeros(2,3), temp2by2, np.zeros(2,2)],
[np.zeros(2,5), temp2by2]])
return Lambda
Lambda = create_Lambda_matrix(lambda1, lambda3)
print(Lambda)
But a data type not understood error is returned at the line in which Lambda is about to be generated.
Message=data type not understood
Source=C:UsersMatinkingsourcereposPyMyPyMyPyMy.py
StackTrace:
File "C:UsersMatinkingsourcereposPyMyPyMyPyMy.py", line 41, in create_Lambda_matrix
Lambda = np.bmat([[temp3by3, np.zeros(3,4)],
File "C:UsersMatinkingsourcereposPyMyPyMyPyMy.py", line 46, in <module>
Lambda = create_Lambda_matrix(lambda1, lambda3)
What am I doing wrong?
python numpy
add a comment |
Here is my attempt to build a big matrix out of some smaller ones:
import numpy as np
lambda1 = 1
lambda3 = 0.03
def create_Lambda_matrix(lambda1, lambda3):
Lambda = np.zeros((6,7))
temp3by3 = 2*np.matrix([[lambda1, lambda3, lambda3],[lambda3, lambda1, lambda3],[lambda3, lambda3, lambda1]])
temp2by2 = 2*np.matrix([[lambda1, lambda3],[lambda3, lambda1]])
Lambda = np.bmat([[temp3by3, np.zeros(3,4)]],
[np.zeros(2,3), temp2by2, np.zeros(2,2)],
[np.zeros(2,5), temp2by2]])
return Lambda
Lambda = create_Lambda_matrix(lambda1, lambda3)
print(Lambda)
But a data type not understood error is returned at the line in which Lambda is about to be generated.
Message=data type not understood
Source=C:UsersMatinkingsourcereposPyMyPyMyPyMy.py
StackTrace:
File "C:UsersMatinkingsourcereposPyMyPyMyPyMy.py", line 41, in create_Lambda_matrix
Lambda = np.bmat([[temp3by3, np.zeros(3,4)],
File "C:UsersMatinkingsourcereposPyMyPyMyPyMy.py", line 46, in <module>
Lambda = create_Lambda_matrix(lambda1, lambda3)
What am I doing wrong?
python numpy
Provide complete error message.
– AkshayNevrekar
Nov 23 '18 at 10:42
@Sociopath: Please check the addedStackTrace.
– Roboticist
Nov 23 '18 at 10:46
the argument of bmat doesn't make sense. It has too many braces, and the lists included have len 2,3,2. I think this is your issue.
– kevinkayaks
Nov 23 '18 at 10:48
add a comment |
Here is my attempt to build a big matrix out of some smaller ones:
import numpy as np
lambda1 = 1
lambda3 = 0.03
def create_Lambda_matrix(lambda1, lambda3):
Lambda = np.zeros((6,7))
temp3by3 = 2*np.matrix([[lambda1, lambda3, lambda3],[lambda3, lambda1, lambda3],[lambda3, lambda3, lambda1]])
temp2by2 = 2*np.matrix([[lambda1, lambda3],[lambda3, lambda1]])
Lambda = np.bmat([[temp3by3, np.zeros(3,4)]],
[np.zeros(2,3), temp2by2, np.zeros(2,2)],
[np.zeros(2,5), temp2by2]])
return Lambda
Lambda = create_Lambda_matrix(lambda1, lambda3)
print(Lambda)
But a data type not understood error is returned at the line in which Lambda is about to be generated.
Message=data type not understood
Source=C:UsersMatinkingsourcereposPyMyPyMyPyMy.py
StackTrace:
File "C:UsersMatinkingsourcereposPyMyPyMyPyMy.py", line 41, in create_Lambda_matrix
Lambda = np.bmat([[temp3by3, np.zeros(3,4)],
File "C:UsersMatinkingsourcereposPyMyPyMyPyMy.py", line 46, in <module>
Lambda = create_Lambda_matrix(lambda1, lambda3)
What am I doing wrong?
python numpy
Here is my attempt to build a big matrix out of some smaller ones:
import numpy as np
lambda1 = 1
lambda3 = 0.03
def create_Lambda_matrix(lambda1, lambda3):
Lambda = np.zeros((6,7))
temp3by3 = 2*np.matrix([[lambda1, lambda3, lambda3],[lambda3, lambda1, lambda3],[lambda3, lambda3, lambda1]])
temp2by2 = 2*np.matrix([[lambda1, lambda3],[lambda3, lambda1]])
Lambda = np.bmat([[temp3by3, np.zeros(3,4)]],
[np.zeros(2,3), temp2by2, np.zeros(2,2)],
[np.zeros(2,5), temp2by2]])
return Lambda
Lambda = create_Lambda_matrix(lambda1, lambda3)
print(Lambda)
But a data type not understood error is returned at the line in which Lambda is about to be generated.
Message=data type not understood
Source=C:UsersMatinkingsourcereposPyMyPyMyPyMy.py
StackTrace:
File "C:UsersMatinkingsourcereposPyMyPyMyPyMy.py", line 41, in create_Lambda_matrix
Lambda = np.bmat([[temp3by3, np.zeros(3,4)],
File "C:UsersMatinkingsourcereposPyMyPyMyPyMy.py", line 46, in <module>
Lambda = create_Lambda_matrix(lambda1, lambda3)
What am I doing wrong?
python numpy
python numpy
edited Nov 23 '18 at 10:53
Roboticist
asked Nov 23 '18 at 10:39
RoboticistRoboticist
57211124
57211124
Provide complete error message.
– AkshayNevrekar
Nov 23 '18 at 10:42
@Sociopath: Please check the addedStackTrace.
– Roboticist
Nov 23 '18 at 10:46
the argument of bmat doesn't make sense. It has too many braces, and the lists included have len 2,3,2. I think this is your issue.
– kevinkayaks
Nov 23 '18 at 10:48
add a comment |
Provide complete error message.
– AkshayNevrekar
Nov 23 '18 at 10:42
@Sociopath: Please check the addedStackTrace.
– Roboticist
Nov 23 '18 at 10:46
the argument of bmat doesn't make sense. It has too many braces, and the lists included have len 2,3,2. I think this is your issue.
– kevinkayaks
Nov 23 '18 at 10:48
Provide complete error message.
– AkshayNevrekar
Nov 23 '18 at 10:42
Provide complete error message.
– AkshayNevrekar
Nov 23 '18 at 10:42
@Sociopath: Please check the added
StackTrace.– Roboticist
Nov 23 '18 at 10:46
@Sociopath: Please check the added
StackTrace.– Roboticist
Nov 23 '18 at 10:46
the argument of bmat doesn't make sense. It has too many braces, and the lists included have len 2,3,2. I think this is your issue.
– kevinkayaks
Nov 23 '18 at 10:48
the argument of bmat doesn't make sense. It has too many braces, and the lists included have len 2,3,2. I think this is your issue.
– kevinkayaks
Nov 23 '18 at 10:48
add a comment |
1 Answer
1
active
oldest
votes
You have a syntax error when you define temp2by2. Use instead:
temp2by2 = 2*np.matrix([[lambda1, lambda3],[lambda3, lambda1]])
However you are likely getting the error when you generate you np.zeros matrices. You have to provide the size of the matrix using an array-like type, as you do in Lambda = np.zeros((6,7))
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53445089%2fdata-type-not-understood-during-attaching-some-matrix-blocks-to-each-other%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You have a syntax error when you define temp2by2. Use instead:
temp2by2 = 2*np.matrix([[lambda1, lambda3],[lambda3, lambda1]])
However you are likely getting the error when you generate you np.zeros matrices. You have to provide the size of the matrix using an array-like type, as you do in Lambda = np.zeros((6,7))
add a comment |
You have a syntax error when you define temp2by2. Use instead:
temp2by2 = 2*np.matrix([[lambda1, lambda3],[lambda3, lambda1]])
However you are likely getting the error when you generate you np.zeros matrices. You have to provide the size of the matrix using an array-like type, as you do in Lambda = np.zeros((6,7))
add a comment |
You have a syntax error when you define temp2by2. Use instead:
temp2by2 = 2*np.matrix([[lambda1, lambda3],[lambda3, lambda1]])
However you are likely getting the error when you generate you np.zeros matrices. You have to provide the size of the matrix using an array-like type, as you do in Lambda = np.zeros((6,7))
You have a syntax error when you define temp2by2. Use instead:
temp2by2 = 2*np.matrix([[lambda1, lambda3],[lambda3, lambda1]])
However you are likely getting the error when you generate you np.zeros matrices. You have to provide the size of the matrix using an array-like type, as you do in Lambda = np.zeros((6,7))
edited Nov 23 '18 at 10:47
answered Nov 23 '18 at 10:42
yatuyatu
15.6k41542
15.6k41542
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53445089%2fdata-type-not-understood-during-attaching-some-matrix-blocks-to-each-other%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Provide complete error message.
– AkshayNevrekar
Nov 23 '18 at 10:42
@Sociopath: Please check the added
StackTrace.– Roboticist
Nov 23 '18 at 10:46
the argument of bmat doesn't make sense. It has too many braces, and the lists included have len 2,3,2. I think this is your issue.
– kevinkayaks
Nov 23 '18 at 10:48