Esempio n. 1
0
        internal static int GetLengthInBits(QRMode mode, int type)
        {
            if (1 <= type && type < 10)
            {
                // 1 - 9
                switch (mode)
                {
                case QRMode.MODE_NUMBER: return(10);

                case QRMode.MODE_ALPHA_NUM: return(9);

                case QRMode.MODE_8BIT_BYTE: return(8);

                case QRMode.MODE_KANJI: return(8);

                default:
                    throw new ErrorException("mode:" + mode, ErrorCode.UnknownMode);
                }
            }
            else if (type < 27)
            {
                // 10 - 26
                switch (mode)
                {
                case QRMode.MODE_NUMBER: return(12);

                case QRMode.MODE_ALPHA_NUM: return(11);

                case QRMode.MODE_8BIT_BYTE: return(16);

                case QRMode.MODE_KANJI: return(10);

                default:
                    throw new ErrorException("mode:" + mode, ErrorCode.UnknownMode);
                }
            }
            else if (type < 41)
            {
                // 27 - 40
                switch (mode)
                {
                case QRMode.MODE_NUMBER: return(14);

                case QRMode.MODE_ALPHA_NUM: return(13);

                case QRMode.MODE_8BIT_BYTE: return(16);

                case QRMode.MODE_KANJI: return(12);

                default:
                    throw new ErrorException("mode:" + mode, ErrorCode.UnknownMode);
                }
            }
            else
            {
                throw new ErrorException("type:" + type, ErrorCode.UnknownMode);
            }
        }
Esempio n. 2
0
            public static (Tensor Q, Tensor R) qr(Tensor input, QRMode mode = QRMode.Reduced)
            {
                var Q = THSLinalg_qr(input.Handle, (byte)mode, out var R);

                if (Q == IntPtr.Zero || R == IntPtr.Zero)
                {
                    torch.CheckForErrors();
                }
                return(new Tensor(Q), new Tensor(R));
            }
Esempio n. 3
0
        public static int GetCharacterCountLength(int version, QRMode mode)
        {
            if (version < 9)
            {
                switch (mode)
                {
                case QRMode.Numeric:
                    return(10);

                case QRMode.Alphanumeric:
                    return(9);

                case QRMode.Byte:
                    return(8);

                default:
                    return(8);
                }
            }
            else if (version < 26)
            {
                switch (mode)
                {
                case QRMode.Numeric:
                    return(12);

                case QRMode.Alphanumeric:
                    return(11);

                case QRMode.Byte:
                    return(16);

                default:
                    return(10);
                }
            }
            else
            {
                switch (mode)
                {
                case QRMode.Numeric:
                    return(14);

                case QRMode.Alphanumeric:
                    return(13);

                case QRMode.Byte:
                    return(16);

                default:
                    return(12);
                }
            }
        }
Esempio n. 4
0
 public static int GetVersion(int count, QRMode mode, QRLevel level)
 {
     for (int i = 0; i < Versions.Length; ++i)
     {
         if (Versions[i][mode][level] >= count)
         {
             return(i + 1);
         }
     }
     return(0);
 }
Esempio n. 5
0
        public LevelInfo this[QRMode mode]
        {
            get
            {
                switch (mode)
                {
                case QRMode.Numeric:
                    return(Numeric);

                case QRMode.Alphanumeric:
                    return(Alphanumeric);

                case QRMode.Byte:
                    return(Byte);

                default:
                    return(null);
                }
            }
        }
Esempio n. 6
0
        internal static int GetLengthInBits(QRMode mode, int type)
        {
            bool flag = 1 > type || type >= 10;

            if (!flag)
            {
                switch (mode)
                {
                case QRMode.MODE_NUMBER:
                {
                    int result = 10;
                    return(result);
                }

                case QRMode.MODE_ALPHA_NUM:
                {
                    int result = 9;
                    return(result);
                }

                case (QRMode)3:
                    break;

                case QRMode.MODE_8BIT_BYTE:
                {
                    int result = 8;
                    return(result);
                }

                default:
                    if (mode == QRMode.MODE_KANJI)
                    {
                        int result = 8;
                        return(result);
                    }
                    break;
                }
                throw new Error("mode:" + mode);
            }
            bool flag2 = type >= 27;

            if (!flag2)
            {
                switch (mode)
                {
                case QRMode.MODE_NUMBER:
                {
                    int result = 12;
                    return(result);
                }

                case QRMode.MODE_ALPHA_NUM:
                {
                    int result = 11;
                    return(result);
                }

                case (QRMode)3:
                    break;

                case QRMode.MODE_8BIT_BYTE:
                {
                    int result = 16;
                    return(result);
                }

                default:
                    if (mode == QRMode.MODE_KANJI)
                    {
                        int result = 10;
                        return(result);
                    }
                    break;
                }
                throw new Error("mode:" + mode);
            }
            bool flag3 = type >= 41;

            if (flag3)
            {
                throw new Error("type:" + type);
            }
            switch (mode)
            {
            case QRMode.MODE_NUMBER:
            {
                int result = 14;
                return(result);
            }

            case QRMode.MODE_ALPHA_NUM:
            {
                int result = 13;
                return(result);
            }

            case (QRMode)3:
                break;

            case QRMode.MODE_8BIT_BYTE:
            {
                int result = 16;
                return(result);
            }

            default:
                if (mode == QRMode.MODE_KANJI)
                {
                    int result = 12;
                    return(result);
                }
                break;
            }
            throw new Error("mode:" + mode);
        }