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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:15:16+00:00 2026-06-13T04:15:16+00:00

I use gsl random generator to generate 2 big matrices, and use gsl cblas

  • 0

I use gsl random generator to generate 2 big matrices, and use gsl cblas to multiply them, but I always got Segmentation fault when the cblas operation begins. When I can’t solve this, I then write the code below, using the very basic idea to do matrix multiplication, and I still got Segmentation Fault, but all the two can work all right when matrix is really a small one, I’m really puzzled about this.

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#define PI 3.1415926

void GenerateKey(int m, int n, int l, int q, float alpha)
{
    // initialization
    int i;
    int j;
    int k;

    float *A;
    float *S;
    float *E;
    float *B;

    float sigma = (alpha * q ) / sqrt(2 * PI);
    A=(float*)malloc(sizeof(float)*(m*n));
    S=(float*)malloc(sizeof(float)*(n*l));
    B=(float*)malloc(sizeof(float)*(m*l));
    E=(float*)malloc(sizeof(float)*(m*l));

    // init A
    for(i = 0; i < m*n; i++)
    {
        A[i]=0;
    }
    printf("\n");

    // init S
    for(i = 0; i < n*l; i++)
    {
        S[i]=0;
    }

    printf("\n");

    // init E
    for(i = 0; i < m*l; i++)
    {
        E[i]=0;
    }

    printf("\n");
    float po;
    for(i = 0; i < m; i++)
    {
        for(j=0; j<l; j++)
        {      
            po=0;
            for(k=0; k<n; k++)
            {
                po +=A[i*m+k]*S[k*n+j];
            }
            po += E[i*m +j];
            B[i*m+j]=((int)po) % q;
        }
    }

    printf("Game over");

    printf("\n");
    free(A);
    free(B);
    free(S);
    free(E);
}

int main()
{
    GenerateKey(2680,191,64,72973,0.000551);

    return 0;
}
  • 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-13T04:15:16+00:00Added an answer on June 13, 2026 at 4:15 am

    When you’re doing i*m+j, shouldn’t that be i*l+j ? Similarly with i*m+k should be i*l+k and k*n+j should be k*l+j

    The reason being, take for example E = (float*)malloc(sizeof(float)*(m*l)), so you have m rows and l columns (or vise versa), so if you are iterating over the m dimension you need to be multiplying your m iterator (i in this case) by the stride of your matrix in that dimension, which is l.

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

Sidebar

Related Questions

use messagepack on android, the can serialize/deserialize a class, but not absolutely right .
I am trying to use the GNU Scientific Library (GSL) http://www.gnu.org/software/gsl/ in QtCreator. How
I don't know very much about template programming, and I currently use gsl. I'm
I'm trying to use the GSL library to solve ODE and I'm having some
Context: I have an application that makes heavy use of the GSL library and
I got a problem while installing the GNU Scientific Library (gsl). I put the
If I just want to use the gsl_histogram.h library from Gnu Scientific Library (GSL),
I'm trying to write a wrapper to use the gsl library with Fortran. I
Use of rails 3 recaptcha. In view _form.html.erb insert <%= recaptcha_tags %> But when
I would like to use GSL (Gnu Scientific Lib) to calculate the standard deviation

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.