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

  • SEARCH
  • Home
  • 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 7948335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:41:44+00:00 2026-06-04T01:41:44+00:00

Its easy to delete zero rows or colomn in matlab but I am stuck

  • 0

Its easy to delete zero rows or colomn in matlab but I am stuck with this problem with my current c code that I have to remove all zero rows and colomns to make my solver more faster. I couldn’t find any simple way. Could you help me in any convenient way?

  • 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-06-04T01:41:44+00:00Added an answer on June 4, 2026 at 1:41 am

    For removing only leading and trailing rows and columns

    We can implement a matrix n a way that makes these operations fairly efficient.

    You allocate a large block to hold the maximal amount of data as if it were a 2D array ([][]), and do a

    typedef struct {
       size_t aJ;      /* Allocated row length. Needed for computing positions */
       size_t uI, uJ;  /* Number of row/cols in use currently. For range checking */
       size_t oI, oJ;  /* Offset to the start of the first used row/col */
       double *matrixA /* the storage */
    } MatrixT;
    

    You will need to write initialization and cleanup routines. Old c hands will note that we could use the array trick here (or the spiffy new variable length member facility)

    Accessing element (i,j) goes something like

    double* element(MatrixT*this, size_t i, size_t j) {
      double* base = this->matrixA + oI*aJ + oJ;
      /* range checking if desired */
      return (base + i*aJ + j);
    }
    

    This has about twice the complexity of element access from a normal 2D array and can be simplified to a single line at the cost of a little clarity (but your compiler might do that for you).

    Removal of rows and columns involves decrementing the appropriate “use value” and also the appropriate “offset” value if you are taking it from the front.

    Because the structure is more complicated and requires more bookkeeping than a plain old 2D array you’ll want to wrap all operation on it up in functions.


    Old Fortran77 programers may recognize this as a re-implementation of the “passing a contiguous sub-array to a function” idiom.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there an easy way to write C code that can access its Git
This should be easy but its got me stumped. I've got a button on
I have been writing some code that creates a generic blog. Its features are
This should be easy as lots of people have asked but there answers dont
I have added an easy compound control which loads its layout from a XML
Maybe it's easy, but I couldn't really figure this out right so far... I
I have a form which looks like this: Delete [Publisher One ] [] [Publisher
I've read some posts about this but none cover this issue. I guess its
I am new to MYSQL and have a problem. Its related to php too
You know that in linux it's easy but I can't just understand how to

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.