Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7618705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:28:31+00:00 2026-05-31T03:28:31+00:00

I have four numpy arrays like: X1 = array([[1, 2], [2, 0]]) X2 =

  • 0

I have four numpy arrays like:

X1 = array([[1, 2], [2, 0]])

X2 = array([[3, 1], [2, 2]])

I1 = array([[1], [1]])

I2 = array([[1], [1]])

And I’m doing:

Y = array([I1, X1],
          [I2, X2]])

To get:

Y = array([[ 1,  1,  2],
           [ 1,  2,  0],
           [-1, -3, -1],
           [-1, -2, -2]])

Like this example, I have large matrices, where X1 and X2 are n x d matrices.

Is there an efficient way in Python whereby I can get the matrix Y?

Although I am aware of the iterative manner, I am searching for an efficient manner to accomplish the above mentioned.

Here, Y is an n x (d+1) matrix and I1 and I2 are identity matrices of the dimension n x 1.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T03:28:32+00:00Added an answer on May 31, 2026 at 3:28 am

    You need numpy.bmat

    In [4]: A = np.mat('1 ; 1 ')
    In [5]: B = np.mat('2 2; 2 2')
    In [6]: C = np.mat('3 ; 5')
    In [7]: D = np.mat('7 8; 9 0')
    In [8]: np.bmat([[A,B],[C,D]])
    Out[8]: 
    matrix([[1, 2, 2],
            [1, 2, 2],
            [3, 7, 8],
            [5, 9, 0]])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Four EditText with different background. It looks like this: I want to
I have a 2D numpy array... there are some values in the image and
I have four divs in my html page something like this: the working fiddle
I have four models that are related to one another, the way I have
I have four arrays: $qtys = $_POST['qty']; $colours = $_POST['colour']; $sizes = $_POST['size']; $names
I have four arrays that are coming in from the client. Let's say that
I have four buttons that are going to be styled in the same way
I have four packages in my program, among them i would like one and
I have four tables like the following : Cars: car_id | make_id 1 |
I have four checkboxpreferences in my preferencescreen that I would like to interact like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.