针对modular char和modular short 在libopencad类库中的理解

版权声明:本文为Trinity原创文章,未经Trinity允许不得转载 https://blog.csdn.net/Caoyang_He/article/details/80349377

首先主要是在以下函数中与此有关

long ReadUMCHAR(const char * pabyInput, size_t& nBitOffsetFromStart)

long ReadMCHAR(const char * pabyInput, size_t& nBitOffsetFromStart)

unsigned int ReadMSHORT(const char * pabyInput, size_t& nBitOffsetFromStart)

接着就是在这些函数中最难理解的部分为:

SwapEndiannessA,B:这个函数功能是实现翻转,一般A为一个数组,B为数组里面元素个数,现在举个例子:A[0]=0,A[1]=1,A[2]=2,A[3]=3,经过SwapEndiannessA,4之后,数组A里面变为:A[0]=3,A[1]=2,A[2]=1,A[3]=0

MemcpyA,B,C):这个函数大致有两种用法:1.A,B都是数组,C为个数,即将B里面的C个字节复制给A。2.A为一个取地址值(long t,  &t),B为一个数组,C为个数,然后将B中数据复制给A,对于A而言,假设A[0]=83,A[1]=82,A[2]=0,那么这些数据复制过后由于是long,所以会对数据进行整合,其结果为82*256+83=21075。

最后结论:

对于modular char和modular short可能并不像OAD的dwg开放文档中所言是压缩算法,因为压缩意味着用更少的字节去存储更多或更大的数值,而在实际调用中发现,这个更像一个壳,避免外部能直接获取有效的信息,需要通过它自己的算法才能得到有效信息。

Modular multiplication of polynomials

02-16

Consider polynomials whose coefficients are 0 and 1. Addition of two polynomials is achieved by 'adding' the coefficients for the corresponding powers in the polynomials. The addition of coefficients is performed by addition modulo 2, i.e., (0 + 0) mod 2 = 0, (0 + 1) mod 2 = 1, (1 + 0) mod 2 = 1, and (1 + 1) mod 2 = 0. Hence, it is the same as the exclusive-or operation. nn(x6 + x4 + x2 + x + 1) + (x7 + x + 1) = x7 + x6 + x4 + x2 nnSubtraction of two polynomials is done similarly. Since subtraction of coefficients is performed by subtraction modulo 2 which is also the exclusive-or operation, subtraction of polynomials is identical to addition of polynomials. nn(x6 + x4 + x2 + x + 1) - (x7 + x + 1) = x7 + x6 + x4 + x2 nnMultiplication of two polynomials is done in the usual way (of course, addition of coefficients is performed by addition modulo 2). nn(x6 + x4 + x2 + x + 1) (x7 + x + 1) n= x13 + x11 + x9 + x8 + x6 + x5 + x4 + x3 + 1 nnMultiplication of two polynomials f(x) and g(x) modulo a polynomial h(x) is the remainder of f(x)g(x) divided by h(x). nn(x6 + x4 + x2 + x + 1) (x7 + x + 1) modulo (x8 + x4 + x3 + x + 1) n= x7 + x6 + 1 nnThe largest exponent of a polynomial is called its degree. For example, the degree of x7 + x6 + 1 is 7. nnGiven three polynomials f(x), g(x), and h(x), you are to write a program that computes f(x)g(x) modulo h(x). We assume that the degrees of both f(x) and g(x) are less than the degree of h(x). The degree of a polynomial is less than 1000. nnSince coefficients of a polynomial are 0 or 1, a polynomial can be represented by d+1 and a bit string of length d+1, where d is the degree of the polynomial and the bit string represents the coefficients of the polynomial. For example, x7 + x6 + 1 can be represented by nn8 1 1 0 0 0 0 0 1.nnInput nnThe input consists of T test cases. The number of test cases (T) is given in the first line of the input. Each test case consists of three lines that contain three polynomials f(x), g(x), and h(x), one per line. Each polynomial is represented as described above. nnOutput nnThe output should contain the polynomial f(x)g(x) modulo h(x), one per line. nnSample Input nn2 n7 1 0 1 0 1 1 1 n8 1 0 0 0 0 0 1 1 n9 1 0 0 0 1 1 0 1 1 n10 1 1 0 1 0 0 1 0 0 1 n12 1 1 0 1 0 0 1 1 0 0 1 0 n15 1 0 1 0 1 1 0 1 1 1 1 1 0 0 1nnnOutput for the Sample Input nn8 1 1 0 0 0 0 0 1 n14 1 1 0 1 1 0 0 1 1 1 0 1 0 0 n

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试

关闭