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 8446897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:02:46+00:00 2026-06-10T10:02:46+00:00

I am studying multiplication source code and I don’t understand this function for multiplying

  • 0

I am studying multiplication source code and I don’t understand this function for multiplying x*A. Please help me to understand this with any numeric example please?

#define BITS_PER_LONG (8 * sizeof (unsigned long))

typedef struct matrix{
int rown;//number of rows.
int coln;//number of columns.
int rwdcnt;//number of words in a row
int alloc_size;//number of allocated bytes
unsigned long *elem;//row index.
}*binmat_t;

void mat_vec_mul(unsigned long *cR, unsigned char *x, binmat_t A)
{
    int i,j;
    unsigned long *pt;

    memset(cR, 0, A->rwdcnt*sizeof(long));
    pt = A->elem;
    for(i=0; i<A->rown; i++)
    {
        if ((x[i/8] >> (i%8)) & 1)
            for (j = 0;  j < A->rwdcnt;  ++j)
                cR[j] ^= *pt++;
        else
            pt += A->rwdcnt;
    }
}
  • 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-10T10:02:48+00:00Added an answer on June 10, 2026 at 10:02 am

    x is a vector of bits, which are stored in an array of char. The number of bits in x is A->rown. The expression (x[i/8] >> (i%8)) & 1 selects the ith bit of x.

    A is a two-dimensional array of unsigned long, with A->rown rows and A->rwdcnt columns.

    cR is a vector of unsigned long with A->rwdcnt elements. cR is cleared upon entering this routine.

    The if statement determines whether the ith bit in x is on. If the bit is on, then the ith column of A is “added” to cR. If the bit is off, then the else clause skips this column of A. Since a bit can have only values of 1 or 0, this if-else is equivalent to multiplying the column of A by the bit and adding the product to cR.

    The “addition” is done by XOR. The interpretation here is unclear. It may be that each cR is a single array of bits (and each column of A), or it may be that each unsigned long in cR (and in A) represents a polynomial over the integers modulo two. (This is a common type in cryptography.)

    I suspect that cR is a single array of bits, and that A->rwdcnt = A->coln / BITS_PER_LONG.

    Effectively, this is a standard array multiplication over the integers modulo two.

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

Sidebar

Related Questions

I'm studying this code, and there is a + in the color function which
I was studying an open source code where I came across the following line
When studying the project 'gproc' source code files, I have found several patch files
Im studying some ruby code and I see this varx variable being used with
I was just studying OCPJP questions and I found this strange code: public static
Studying some sources I often came to see this: (Part of the real source)
Studying Haskell, i'm trying to code a function takeIf that given a condition and
Studying asp.net mvc 3 + EF code-first. I am new to both. My example
When studying a snippet of unknown Python code, I occasionally bump into the varName.methodName()
I am studying an existing Perl program, which includes the following line of code:

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.