Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • a3483c2
  • /
  • bikel3
  • /
  • m4f
  • /
  • bmul2.c
Raw File Download
Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge Iframe embedding
swh:1:cnt:7d5062604e29b33cb10e46e07443e925d96b32c8
directory badge Iframe embedding
swh:1:dir:03923b55962c2e735997636bb556c266f41a3493
Citations

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
bmul2.c
// Implemented by Ming-Shing Chen, Tung Chou and Markus Krausz.
// public domain

#include "string.h"

#include "bmul2.h"
#include "bc_2.h"
#include "btfy_ffft.h"
#include "encode.h"
#include "gfv_tower.h"


void bmul2_2048_to_4096_prepare_ebuff( uint32_t * a_out, const uint8_t * a_in , uint32_t *a0 )
{
  memcpy( a0 , a_in , 2048 );
  bc_1_16384( a0 );

  uint32_t temp[16];
  for(int i=0;i<((32768/32)/32);i++) {
    for(int j=0;j<16;j++) temp[j] = a0[((32768/32)/32)*j+i];
    encode_trunc_fft( a_out+i*32, temp );
  }
  btfy_32768( a_out );
}


void bmul2_2048_to_4096_prepare( uint32_t * a_out, const uint8_t * a_in )
{
  uint32_t a0[16384/32];
  bmul2_2048_to_4096_prepare_ebuff( a_out , a_in , a0 );
}


void bmul2_2048_to_4096_mul_ebuff( uint8_t * c, const uint32_t * a, const uint32_t * b , uint32_t *a0 )
{
  uint32_t * c32 = (uint32_t*)c;

  for(int i=0;i<(32768/32);i+=32) { gf232v_mul( a0+i, a+i , b+i ); }

  ibtfy_32768( a0 );

  uint32_t temp[32];
  for(int i=0;i<(32768/32);i+=32) {
    decode_trunc_fft( temp , a0+i );
    for(int j=0;j<32;j++) c32[((32768/32)/32)*j+i/32] = temp[j];
  }
  ibc_1_32768( c32 );
}


void bmul2_2048_to_4096_mul( uint8_t * c, const uint32_t * a, const uint32_t * b )
{
  uint32_t a0[32768/32];
  bmul2_2048_to_4096_mul_ebuff( c , a, b , a0 );
}



void bmul2_2048_to_4096( uint8_t * c, const uint8_t * a, const uint8_t * b )
{
  uint32_t a_u32[32768/32];
  uint32_t b_u32[32768/32];

  bmul2_2048_to_4096_prepare( a_u32, a );
  bmul2_2048_to_4096_prepare( b_u32, b );

  bmul2_2048_to_4096_mul( c , a_u32 , b_u32 );
}



////////////////////////////////



void bmul2_4096_to_8192_prepare_ebuff( uint32_t * a_out, const uint8_t * a_in , uint32_t *a0 )
{
  memcpy( a0 , a_in , 4096 );
  bc_1_32768( a0 );

  uint32_t temp[16];
  for(int i=0;i<((65536/32)/32);i++) {
    for(int j=0;j<16;j++) temp[j] = a0[((65536/32)/32)*j+i];
    encode_trunc_fft( a_out+i*32, temp );
  }
  btfy_65536( a_out );
}

void bmul2_4096_to_8192_prepare( uint32_t * a_out, const uint8_t * a_in )
{
  uint32_t a0[32768/32];
  bmul2_4096_to_8192_prepare_ebuff( a_out , a_in , a0 );
}


void bmul2_4096_to_8192_mul_ebuff( uint8_t * c, const uint32_t * a, const uint32_t * b , uint32_t *a0)
{
  uint32_t * c32 = (uint32_t*)c;

  for(int i=0;i<(65536/32);i+=32) { gf232v_mul( a0+i, a+i , b+i ); }

  ibtfy_65536( a0 );

  uint32_t temp[32];
  for(int i=0;i<(65536/32);i+=32) {
    decode_trunc_fft( temp , a0+i );
    for(int j=0;j<32;j++) c32[((65536/32)/32)*j+i/32] = temp[j];
  }
  ibc_1_65536( c32 );
}

void bmul2_4096_to_8192_mul( uint8_t * c, const uint32_t * a, const uint32_t * b )
{
  uint32_t a0[65536/32];
  bmul2_4096_to_8192_mul_ebuff( c , a , b , a0 );
}


void bmul2_4096_to_8192( uint8_t * c, const uint8_t * a, const uint8_t * b )
{
  uint32_t a_u32[65536/32];
  uint32_t b_u32[65536/32];

  bmul2_4096_to_8192_prepare( a_u32, a );
  bmul2_4096_to_8192_prepare( b_u32, b );

  bmul2_4096_to_8192_mul( c , a_u32 , b_u32 );
}









Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Contact— JavaScript license information— Web API

back to top