package org.javacs.kt.util

/**
 * Computes a string distance using a slightly modified
 * variant of the SIFT4 algorithm in linear time.
 * Note that the function is asymmetric with respect to
 * its two input strings and thus is not a metric in the
 * mathematical sense.
 *
 * Based on the JavaScript implementation from
 * https://siderite.dev/blog/super-fast-and-accurate-string-distance.html/
 *
 * @param candidate The first string
 * @param pattern The second string
 * @param maxOffset The number of characters to search for matching letters
 */
fun stringDistance(candidate: CharSequence, pattern: CharSequence, maxOffset: Int = 4): Int = when {
    candidate.length == 0 -> pattern.length
    pattern.length == 0 -> candidate.length
    else -> {
        val candidateLength = candidate.length
        val patternLength = pattern.length
        var iCandidate = 0
        var iPattern = 0
        var longestCommonSubsequence = 0
        var localCommonSubstring = 0

        while (iCandidate < candidateLength && iPattern < patternLength) {
            if (candidate[iCandidate] == pattern[iPattern]) {
                localCommonSubstring++
            } else {
                longestCommonSubsequence += localCommonSubstring
                localCommonSubstring = 0

                if (iCandidate != iPattern) {
                    // Using max to bypass the need for computer transpositions ("ab" vs "ba")
                    val iMax = Math.max(iCandidate, iPattern)
                    iCandidate = iMax
                    iPattern = iMax
                    if (iMax >= Math.min(candidateLength, patternLength)) {
                        break
                    }
                }

                searchWindow@
                for (i in 0 until maxOffset) {
                    when {
                        (iCandidate + i) < candidateLength -> {
                            if (candidate[iCandidate + i] == pattern[iPattern]) {
                                iCandidate += i
                                localCommonSubstring++
                                break@searchWindow
                            }
                        }
                        (iPattern + i) < patternLength -> {
                            if (candidate[iCandidate] == pattern[iPattern + i]) {
                                iPattern += i
                                localCommonSubstring++
                                break@searchWindow
                            }
                        }
                        else -> break@searchWindow
                    }
                }
            }

            iCandidate++
            iPattern++
        }

        longestCommonSubsequence += localCommonSubstring
        Math.max(candidateLength, patternLength) - longestCommonSubsequence
    }
}

/** Checks whether the candidate contains the pattern in order. */
fun containsCharactersInOrder(candidate: CharSequence, pattern: CharSequence, caseSensitive: Boolean): Boolean {
    var iCandidate = 0
    var iPattern = 0

    while (iCandidate < candidate.length && iPattern < pattern.length) {
        var patternChar = pattern[iPattern]
        var testChar = candidate[iCandidate]

        if (!caseSensitive) {
            patternChar = patternChar.lowercaseChar()
            testChar = testChar.lowercaseChar()
        }

        if (patternChar == testChar) {
            iPattern++
        }
        iCandidate++
    }

    return iPattern == pattern.length
}

Compiled from "StringUtils.kt"
public final class org.javacs.kt.util.StringUtilsKt {
  public static final int stringDistance(java.lang.CharSequence, java.lang.CharSequence, int);
    Code:
       0: aload_0
       1: ldc           #9                  // String candidate
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #17                 // String pattern
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: nop
      13: aload_0
      14: invokeinterface #23,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      19: ifne          31
      22: aload_1
      23: invokeinterface #23,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      28: goto          298
      31: aload_1
      32: invokeinterface #23,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      37: ifne          49
      40: aload_0
      41: invokeinterface #23,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      46: goto          298
      49: aload_0
      50: invokeinterface #23,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      55: istore_3
      56: aload_1
      57: invokeinterface #23,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      62: istore        4
      64: iconst_0
      65: istore        5
      67: iconst_0
      68: istore        6
      70: iconst_0
      71: istore        7
      73: iconst_0
      74: istore        8
      76: iload         5
      78: iload_3
      79: if_icmpge     282
      82: iload         6
      84: iload         4
      86: if_icmpge     282
      89: aload_0
      90: iload         5
      92: invokeinterface #27,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
      97: aload_1
      98: iload         6
     100: invokeinterface #27,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     105: if_icmpne     117
     108: iload         8
     110: iinc          8, 1
     113: pop
     114: goto          273
     117: iload         7
     119: iload         8
     121: iadd
     122: istore        7
     124: iconst_0
     125: istore        8
     127: iload         5
     129: iload         6
     131: if_icmpeq     165
     134: iload         5
     136: iload         6
     138: invokestatic  #33                 // Method java/lang/Math.max:(II)I
     141: istore        9
     143: iload         9
     145: istore        5
     147: iload         9
     149: istore        6
     151: iload         9
     153: iload_3
     154: iload         4
     156: invokestatic  #36                 // Method java/lang/Math.min:(II)I
     159: if_icmplt     165
     162: goto          282
     165: iconst_0
     166: istore        9
     168: iload         9
     170: iload_2
     171: if_icmpge     273
     174: nop
     175: iload         5
     177: iload         9
     179: iadd
     180: iload_3
     181: if_icmpge     219
     184: aload_0
     185: iload         5
     187: iload         9
     189: iadd
     190: invokeinterface #27,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     195: aload_1
     196: iload         6
     198: invokeinterface #27,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     203: if_icmpne     267
     206: iload         5
     208: iload         9
     210: iadd
     211: istore        5
     213: iinc          8, 1
     216: goto          273
     219: iload         6
     221: iload         9
     223: iadd
     224: iload         4
     226: if_icmpge     264
     229: aload_0
     230: iload         5
     232: invokeinterface #27,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     237: aload_1
     238: iload         6
     240: iload         9
     242: iadd
     243: invokeinterface #27,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     248: if_icmpne     267
     251: iload         6
     253: iload         9
     255: iadd
     256: istore        6
     258: iinc          8, 1
     261: goto          273
     264: goto          273
     267: iinc          9, 1
     270: goto          168
     273: iinc          5, 1
     276: iinc          6, 1
     279: goto          76
     282: iload         7
     284: iload         8
     286: iadd
     287: istore        7
     289: iload_3
     290: iload         4
     292: invokestatic  #33                 // Method java/lang/Math.max:(II)I
     295: iload         7
     297: isub
     298: ireturn

  public static int stringDistance$default(java.lang.CharSequence, java.lang.CharSequence, int, int, java.lang.Object);
    Code:
       0: iload_3
       1: iconst_4
       2: iand
       3: ifeq          8
       6: iconst_4
       7: istore_2
       8: aload_0
       9: aload_1
      10: iload_2
      11: invokestatic  #51                 // Method stringDistance:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;I)I
      14: ireturn

  public static final boolean containsCharactersInOrder(java.lang.CharSequence, java.lang.CharSequence, boolean);
    Code:
       0: aload_0
       1: ldc           #9                  // String candidate
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #17                 // String pattern
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: iconst_0
      13: istore_3
      14: iconst_0
      15: istore        4
      17: iload_3
      18: aload_0
      19: invokeinterface #23,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      24: if_icmpge     91
      27: iload         4
      29: aload_1
      30: invokeinterface #23,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      35: if_icmpge     91
      38: aload_1
      39: iload         4
      41: invokeinterface #27,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
      46: istore        5
      48: aload_0
      49: iload_3
      50: invokeinterface #27,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
      55: istore        6
      57: iload_2
      58: ifne          75
      61: iload         5
      63: invokestatic  #59                 // Method java/lang/Character.toLowerCase:(C)C
      66: istore        5
      68: iload         6
      70: invokestatic  #59                 // Method java/lang/Character.toLowerCase:(C)C
      73: istore        6
      75: iload         5
      77: iload         6
      79: if_icmpne     85
      82: iinc          4, 1
      85: iinc          3, 1
      88: goto          17
      91: iload         4
      93: aload_1
      94: invokeinterface #23,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      99: if_icmpne     106
     102: iconst_1
     103: goto          107
     106: iconst_0
     107: ireturn
}


package org.hiatusuk

fun main(args: Array<String>) {
    val foreNames = arrayOf("Rohan","Nathaniel","Anthony","Chris","Jonathan","Lemur","Harry","Percy","Peregrine","James","Jamie","Sidney","Gabriel","Leyton","Curtley","Jarvis");
    val middleNames = arrayOf("Rohan","Nathaniel","Tony","Chris","Jonathan","Lemur","Harry","Percy","Peregrine","James","Jamie","Sidney","Gabriel","Leyton","Curtley","Jarvis");

    foreNames.sort()
    middleNames.sort()

    var count = 0

    for (name1 in foreNames) {
        count++
        println("" + count + " ... " + name1 + " Jordan-Regan")

        val syllables1 = syllableCount(name1)

        for (name2 in middleNames) {
            if (name1 != name2) {
                val syllables2 = syllableCount(name2)

                if (name1[0] == name2[0] || (syllables1 == 1 && syllables2 == 1) || (syllables1 == 1 && syllables2 >= 3) || (syllables1 >= 3 && syllables2 >= 3) || (syllables1 >= 3 && syllables2 == 1)) {
                    continue
                }

                count++
                println("" + count + " ... " + name1 + " " + name2 + " Jordan-Regan")
            }
        }
    }
}

fun isVowel(inChar: Char) : Boolean {
    return (inChar == 'a' || inChar == 'e' || inChar == 'i' || inChar == 'o' || inChar == 'u')
}

fun syllableCount(inStr: String): Int {
    if (inStr == "Anthony" || inStr == "Gabriel") {
        return 3
    }

    if (inStr == "James") {
        return 1
    }

    var syllables = 0
    var lastChar = '.'
    var wasVowel = false

    for (idx in inStr.indices) {
        val c = inStr[idx]

        if (wasVowel && ((lastChar == 'u' && c == 'a') || (lastChar == 'i' && c == 'a'))) {
            syllables++
        }
        else if (isVowel(c) || c == 'y') {
            if (!wasVowel && (!(c == 'e') || idx < inStr.length - 1)) {
                syllables++
                wasVowel = true
            }
        }
        else {
            wasVowel = false
        }

        lastChar = c
    }

    return if (syllables == 0) 1 else syllables
}

Compiled from "BabyNamesBoys.kt"
public final class org.hiatusuk.BabyNamesBoysKt {
  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String args
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: bipush        16
       8: anewarray     #17                 // class java/lang/String
      11: astore_2
      12: aload_2
      13: iconst_0
      14: ldc           #19                 // String Rohan
      16: aastore
      17: aload_2
      18: iconst_1
      19: ldc           #21                 // String Nathaniel
      21: aastore
      22: aload_2
      23: iconst_2
      24: ldc           #23                 // String Anthony
      26: aastore
      27: aload_2
      28: iconst_3
      29: ldc           #25                 // String Chris
      31: aastore
      32: aload_2
      33: iconst_4
      34: ldc           #27                 // String Jonathan
      36: aastore
      37: aload_2
      38: iconst_5
      39: ldc           #29                 // String Lemur
      41: aastore
      42: aload_2
      43: bipush        6
      45: ldc           #31                 // String Harry
      47: aastore
      48: aload_2
      49: bipush        7
      51: ldc           #33                 // String Percy
      53: aastore
      54: aload_2
      55: bipush        8
      57: ldc           #35                 // String Peregrine
      59: aastore
      60: aload_2
      61: bipush        9
      63: ldc           #37                 // String James
      65: aastore
      66: aload_2
      67: bipush        10
      69: ldc           #39                 // String Jamie
      71: aastore
      72: aload_2
      73: bipush        11
      75: ldc           #41                 // String Sidney
      77: aastore
      78: aload_2
      79: bipush        12
      81: ldc           #43                 // String Gabriel
      83: aastore
      84: aload_2
      85: bipush        13
      87: ldc           #45                 // String Leyton
      89: aastore
      90: aload_2
      91: bipush        14
      93: ldc           #47                 // String Curtley
      95: aastore
      96: aload_2
      97: bipush        15
      99: ldc           #49                 // String Jarvis
     101: aastore
     102: aload_2
     103: astore_1
     104: bipush        16
     106: anewarray     #17                 // class java/lang/String
     109: astore_3
     110: aload_3
     111: iconst_0
     112: ldc           #19                 // String Rohan
     114: aastore
     115: aload_3
     116: iconst_1
     117: ldc           #21                 // String Nathaniel
     119: aastore
     120: aload_3
     121: iconst_2
     122: ldc           #51                 // String Tony
     124: aastore
     125: aload_3
     126: iconst_3
     127: ldc           #25                 // String Chris
     129: aastore
     130: aload_3
     131: iconst_4
     132: ldc           #27                 // String Jonathan
     134: aastore
     135: aload_3
     136: iconst_5
     137: ldc           #29                 // String Lemur
     139: aastore
     140: aload_3
     141: bipush        6
     143: ldc           #31                 // String Harry
     145: aastore
     146: aload_3
     147: bipush        7
     149: ldc           #33                 // String Percy
     151: aastore
     152: aload_3
     153: bipush        8
     155: ldc           #35                 // String Peregrine
     157: aastore
     158: aload_3
     159: bipush        9
     161: ldc           #37                 // String James
     163: aastore
     164: aload_3
     165: bipush        10
     167: ldc           #39                 // String Jamie
     169: aastore
     170: aload_3
     171: bipush        11
     173: ldc           #41                 // String Sidney
     175: aastore
     176: aload_3
     177: bipush        12
     179: ldc           #43                 // String Gabriel
     181: aastore
     182: aload_3
     183: bipush        13
     185: ldc           #45                 // String Leyton
     187: aastore
     188: aload_3
     189: bipush        14
     191: ldc           #47                 // String Curtley
     193: aastore
     194: aload_3
     195: bipush        15
     197: ldc           #49                 // String Jarvis
     199: aastore
     200: aload_3
     201: astore_2
     202: aload_1
     203: checkcast     #53                 // class "[Ljava/lang/Comparable;"
     206: invokestatic  #59                 // Method kotlin/collections/ArraysKt.sort:([Ljava/lang/Object;)V
     209: aload_2
     210: checkcast     #53                 // class "[Ljava/lang/Comparable;"
     213: invokestatic  #59                 // Method kotlin/collections/ArraysKt.sort:([Ljava/lang/Object;)V
     216: iconst_0
     217: istore_3
     218: iconst_0
     219: istore        4
     221: aload_1
     222: arraylength
     223: istore        5
     225: iload         4
     227: iload         5
     229: if_icmpge     458
     232: aload_1
     233: iload         4
     235: aaload
     236: astore        6
     238: iinc          3, 1
     241: new           #61                 // class java/lang/StringBuilder
     244: dup
     245: invokespecial #65                 // Method java/lang/StringBuilder."<init>":()V
     248: ldc           #67                 // String
     250: invokevirtual #71                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     253: iload_3
     254: invokevirtual #74                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     257: ldc           #76                 // String  ...
     259: invokevirtual #71                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     262: aload         6
     264: invokevirtual #71                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     267: ldc           #78                 // String  Jordan-Regan
     269: invokevirtual #71                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     272: invokevirtual #82                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     275: getstatic     #88                 // Field java/lang/System.out:Ljava/io/PrintStream;
     278: swap
     279: invokevirtual #94                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     282: aload         6
     284: invokestatic  #98                 // Method syllableCount:(Ljava/lang/String;)I
     287: istore        7
     289: iconst_0
     290: istore        8
     292: aload_2
     293: arraylength
     294: istore        9
     296: iload         8
     298: iload         9
     300: if_icmpge     452
     303: aload_2
     304: iload         8
     306: aaload
     307: astore        10
     309: aload         6
     311: aload         10
     313: invokestatic  #102                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     316: ifne          446
     319: aload         10
     321: invokestatic  #98                 // Method syllableCount:(Ljava/lang/String;)I
     324: istore        11
     326: aload         6
     328: iconst_0
     329: invokevirtual #106                // Method java/lang/String.charAt:(I)C
     332: aload         10
     334: iconst_0
     335: invokevirtual #106                // Method java/lang/String.charAt:(I)C
     338: if_icmpeq     389
     341: iload         7
     343: iconst_1
     344: if_icmpne     353
     347: iload         11
     349: iconst_1
     350: if_icmpeq     389
     353: iload         7
     355: iconst_1
     356: if_icmpne     365
     359: iload         11
     361: iconst_3
     362: if_icmpge     389
     365: iload         7
     367: iconst_3
     368: if_icmplt     377
     371: iload         11
     373: iconst_3
     374: if_icmpge     389
     377: iload         7
     379: iconst_3
     380: if_icmplt     392
     383: iload         11
     385: iconst_1
     386: if_icmpne     392
     389: goto          446
     392: iinc          3, 1
     395: new           #61                 // class java/lang/StringBuilder
     398: dup
     399: invokespecial #65                 // Method java/lang/StringBuilder."<init>":()V
     402: ldc           #67                 // String
     404: invokevirtual #71                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     407: iload_3
     408: invokevirtual #74                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     411: ldc           #76                 // String  ...
     413: invokevirtual #71                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     416: aload         6
     418: invokevirtual #71                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     421: bipush        32
     423: invokevirtual #109                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     426: aload         10
     428: invokevirtual #71                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     431: ldc           #78                 // String  Jordan-Regan
     433: invokevirtual #71                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     436: invokevirtual #82                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     439: getstatic     #88                 // Field java/lang/System.out:Ljava/io/PrintStream;
     442: swap
     443: invokevirtual #94                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     446: iinc          8, 1
     449: goto          296
     452: iinc          4, 1
     455: goto          225
     458: return

  public static final boolean isVowel(char);
    Code:
       0: iload_0
       1: bipush        97
       3: if_icmpeq     30
       6: iload_0
       7: bipush        101
       9: if_icmpeq     30
      12: iload_0
      13: bipush        105
      15: if_icmpeq     30
      18: iload_0
      19: bipush        111
      21: if_icmpeq     30
      24: iload_0
      25: bipush        117
      27: if_icmpne     34
      30: iconst_1
      31: goto          35
      34: iconst_0
      35: ireturn

  public static final int syllableCount(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #126                // String inStr
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: ldc           #23                 // String Anthony
       9: invokestatic  #102                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      12: ifne          24
      15: aload_0
      16: ldc           #43                 // String Gabriel
      18: invokestatic  #102                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      21: ifeq          26
      24: iconst_3
      25: ireturn
      26: aload_0
      27: ldc           #37                 // String James
      29: invokestatic  #102                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      32: ifeq          37
      35: iconst_1
      36: ireturn
      37: iconst_0
      38: istore_1
      39: bipush        46
      41: istore_2
      42: iconst_0
      43: istore_3
      44: iconst_0
      45: istore        4
      47: aload_0
      48: checkcast     #128                // class java/lang/CharSequence
      51: invokeinterface #132,  1          // InterfaceMethod java/lang/CharSequence.length:()I
      56: istore        5
      58: iload         4
      60: iload         5
      62: if_icmpge     167
      65: aload_0
      66: iload         4
      68: invokevirtual #106                // Method java/lang/String.charAt:(I)C
      71: istore        6
      73: iload_3
      74: ifeq          111
      77: iload_2
      78: bipush        117
      80: if_icmpne     90
      83: iload         6
      85: bipush        97
      87: if_icmpeq     103
      90: iload_2
      91: bipush        105
      93: if_icmpne     111
      96: iload         6
      98: bipush        97
     100: if_icmpne     111
     103: iload_1
     104: iinc          1, 1
     107: pop
     108: goto          158
     111: iload         6
     113: invokestatic  #134                // Method isVowel:(C)Z
     116: ifne          126
     119: iload         6
     121: bipush        121
     123: if_icmpne     156
     126: iload_3
     127: ifne          158
     130: iload         6
     132: bipush        101
     134: if_icmpne     148
     137: iload         4
     139: aload_0
     140: invokevirtual #135                // Method java/lang/String.length:()I
     143: iconst_1
     144: isub
     145: if_icmpge     158
     148: iinc          1, 1
     151: iconst_1
     152: istore_3
     153: goto          158
     156: iconst_0
     157: istore_3
     158: iload         6
     160: istore_2
     161: iinc          4, 1
     164: goto          58
     167: iload_1
     168: ifne          175
     171: iconst_1
     172: goto          176
     175: iload_1
     176: ireturn
}


package processor

import java.util.Scanner
import kotlin.math.min
import kotlin.math.pow

val scanner = Scanner(System.`in`)

fun readMatrix(messageInfix: String = ""): Array<DoubleArray> {
    print("Enter size of ${messageInfix}matrix: ")
    val row = scanner.nextInt()
    val col = scanner.nextInt()
    val matrix = Array(row) { DoubleArray(col) }

    println("Enter ${messageInfix}matrix:")
    for (i in 0 until row) {
        for (j in 0 until col) {
            matrix[i][j] = scanner.nextDouble()
        }
    }
    return matrix
}

fun printMatrix(matrix: Array<DoubleArray>) {
    for (i in matrix.indices) {
        var line = ""
        for (j in matrix[0].indices) {
            line += "${matrix[i][j]} "
        }
        println(line)
    }
}

fun addMatrices(matrix1: Array<DoubleArray>, matrix2: Array<DoubleArray>, log: Boolean = true): Array<DoubleArray> {
    if (log) println("The result is:")
    val sumMatrix = Array(matrix1[0].size) { DoubleArray(matrix2.size) }

    if (matrix1.size == matrix2.size && matrix1[0].size == matrix2[0].size) {
        for (i in matrix1.indices) {
            for (j in matrix1[0].indices)
                sumMatrix[i][j] = matrix1[i][j] + matrix2[i][j]
        }
    } else {
        if (log) println("The operation cannot be performed.")
    }
    return sumMatrix
}

fun multiplyMatrices(matrix1: Array<DoubleArray>,
                     matrix2: Array<DoubleArray>, log: Boolean = true): Array<DoubleArray> {
    if (log) println("The result is:")
    val productMatrix = Array(matrix1.size) { DoubleArray(matrix2[0].size) }

    if (matrix1[0].size == matrix2.size) {
        for (i in matrix1.indices) {
            for (j in matrix2[0].indices) {
                var sum = 0.0
                for (k in matrix1[0].indices) {
                    sum += matrix1[i][k] * matrix2[k][j]
                }
                productMatrix[i][j] = sum
            }
        }
    } else {
        if (log) println("The operation cannot be performed.")
    }
    return productMatrix
}

fun multiplyByConstant(constant: Double, matrix: Array<DoubleArray>, log: Boolean = true): Array<DoubleArray> {
    if (log) println("The result is:")
    val productMatrix = Array(matrix.size) { DoubleArray(matrix[0].size) }
    for (i in matrix.indices) {
        for (j in matrix[0].indices) {
            productMatrix[i][j] = constant * matrix[i][j]
        }
    }
    return productMatrix
}

fun transposeMatrix() {
    println()
    println("1. Main diagonal\n" +
            "2. Side diagonal\n" +
            "3. Vertical line\n" +
            "4. Horizontal line")
    print("Your choice: ")
    val choice = readLine()!!
    println("The result is:")
    when (choice) {
        "1" -> printMatrix(transposeMain(readMatrix()))
        "2" -> printMatrix(transposeSide(readMatrix()))
        "3" -> printMatrix(transposeVertical(readMatrix()))
        "4" -> printMatrix(transposeHorizontal(readMatrix()))
        else -> println("Invalid choice")
    }
}

fun transposeMain(matrix: Array<DoubleArray>): Array<DoubleArray> {
    val transpose = Array(matrix[0].size) { DoubleArray(matrix.size) }
    for (i in matrix.indices) {
        for (j in matrix[0].indices) {
            transpose[j][i] = matrix[i][j]
        }
    }
    return transpose
}

fun transposeSide(matrix: Array<DoubleArray>): Array<DoubleArray> {
    val transpose = Array(matrix[0].size) { DoubleArray(matrix.size) }
    for (i in matrix.indices) {
        for (j in matrix[0].indices) {
            transpose[matrix.lastIndex - j][matrix[0].lastIndex - i] = matrix[i][j]
        }
    }
    return transpose
}

fun transposeVertical(matrix: Array<DoubleArray>): Array<DoubleArray> {
    val transpose = Array(matrix[0].size) { DoubleArray(matrix.size) }
    for (i in matrix.indices) {
        for (j in matrix[0].indices) {
            transpose[i][matrix[0].lastIndex - j] = matrix[i][j]
        }
    }
    return transpose
}

fun transposeHorizontal(matrix: Array<DoubleArray>): Array<DoubleArray> {
    val transpose = Array(matrix[0].size) { DoubleArray(matrix.size) }
    for (i in matrix.indices) {
        for (j in matrix[0].indices) {
            transpose[matrix.lastIndex - i][j] = matrix[i][j]
        }
    }
    return transpose
}

// Get the minor matrix from the original matrix after excluding the given row and column
fun getCofactor(matrix: Array<DoubleArray>, row: Int, col: Int): Double {
    val minor = Array(matrix[0].size - 1) { DoubleArray(matrix.size - 1) }
    val temp = matrix.filterIndexed { i, _ -> i != row }.toTypedArray()
    for (i in temp.indices) {
        minor[i] = temp[i].filterIndexed { j, _ -> j != col }.toDoubleArray()
    }
    return determinant(minor) * (-1.0).pow(row + col)
}

// Get the determinant of a matrix
fun determinant(matrix: Array<DoubleArray>): Double {
    return if (matrix.size == 2) {
        matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0]
    } else {
        var result = 0.0
        for (j in matrix.indices)
            result += getCofactor(matrix, 0, j) * matrix[0][j]
        result
    }
}

fun calcDeterminant() {
    val matrix = readMatrix()
    println("The result is:")
    if (matrix.size == matrix[0].size) {
        println(determinant(matrix))
    } else {
        println("The operation cannot be performed.")
    }
}

fun getAdjoint(matrix: Array<DoubleArray>): Array<DoubleArray> {
    val adjoint = Array(matrix.size) { DoubleArray(matrix[0].size) }
    for (i in matrix.indices) {
        for (j in matrix[0].indices) {
            adjoint[i][j] = getCofactor(matrix, i, j)
        }
    }
    return transposeMain(adjoint)
}

fun inverseMatrix(matrix: Array<DoubleArray>, log: Boolean = true): Array<DoubleArray> {
    if (log) println("The result is:")
    val det = determinant(matrix)
    return if (det != 0.0) {
        multiplyByConstant(1 / det, getAdjoint(matrix), false)
    } else {
        if (log) println("This matrix doesn't have an inverse.")
        Array(matrix.size) { DoubleArray(matrix[0].size) }
    }
}

fun main() {
    while (true) {
        println("1. Add matrices\n" +
                "2. Multiply matrix by a constant\n" +
                "3. Multiply matrices\n" +
                "4. Transpose matrix\n" +
                "5. Calculate a determinant\n" +
                "6. Inverse matrix\n" +
                "0. Exit")
        print("Your choice: ")
        when (readLine()) {
            "0" -> return
            "1" -> printMatrix(addMatrices(readMatrix("first "), readMatrix("second ")))
            "2" -> {
                val matrix = readMatrix()
                print("Enter constant:")
                printMatrix(multiplyByConstant(scanner.nextDouble(), matrix))
            }
            "3" -> printMatrix(multiplyMatrices(readMatrix("first "), readMatrix("second ")))
            "4" -> transposeMatrix()
            "5" -> calcDeterminant()
            "6" -> printMatrix(inverseMatrix(readMatrix()))
            else -> println("Invalid choice")
        }
        println()
    }
}

Compiled from "Main.kt"
public final class processor.MainKt {
  private static final java.util.Scanner scanner;

  public static final java.util.Scanner getScanner();
    Code:
       0: getstatic     #11                 // Field scanner:Ljava/util/Scanner;
       3: areturn

  public static final double[][] readMatrix(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #15                 // String messageInfix
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #23                 // class java/lang/StringBuilder
       9: dup
      10: invokespecial #27                 // Method java/lang/StringBuilder."<init>":()V
      13: ldc           #29                 // String Enter size of
      15: invokevirtual #33                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      18: aload_0
      19: invokevirtual #33                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      22: ldc           #35                 // String matrix:
      24: invokevirtual #33                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      27: invokevirtual #39                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      30: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
      33: swap
      34: invokevirtual #51                 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
      37: getstatic     #11                 // Field scanner:Ljava/util/Scanner;
      40: invokevirtual #57                 // Method java/util/Scanner.nextInt:()I
      43: istore_1
      44: getstatic     #11                 // Field scanner:Ljava/util/Scanner;
      47: invokevirtual #57                 // Method java/util/Scanner.nextInt:()I
      50: istore_2
      51: iconst_0
      52: istore        4
      54: iload_1
      55: anewarray     #59                 // class "[D"
      58: astore        5
      60: iload         4
      62: iload_1
      63: if_icmpge     84
      66: iload         4
      68: istore        6
      70: aload         5
      72: iload         6
      74: iload_2
      75: newarray       double
      77: aastore
      78: iinc          4, 1
      81: goto          60
      84: aload         5
      86: astore_3
      87: new           #23                 // class java/lang/StringBuilder
      90: dup
      91: invokespecial #27                 // Method java/lang/StringBuilder."<init>":()V
      94: ldc           #61                 // String Enter
      96: invokevirtual #33                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      99: aload_0
     100: invokevirtual #33                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     103: ldc           #63                 // String matrix:
     105: invokevirtual #33                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     108: invokevirtual #39                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     111: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
     114: swap
     115: invokevirtual #66                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     118: iconst_0
     119: istore        4
     121: iload         4
     123: iload_1
     124: if_icmpge     161
     127: iconst_0
     128: istore        5
     130: iload         5
     132: iload_2
     133: if_icmpge     155
     136: aload_3
     137: iload         4
     139: aaload
     140: iload         5
     142: getstatic     #11                 // Field scanner:Ljava/util/Scanner;
     145: invokevirtual #70                 // Method java/util/Scanner.nextDouble:()D
     148: dastore
     149: iinc          5, 1
     152: goto          130
     155: iinc          4, 1
     158: goto          121
     161: aload_3
     162: areturn

  public static double[][] readMatrix$default(java.lang.String, int, java.lang.Object);
    Code:
       0: iload_1
       1: iconst_1
       2: iand
       3: ifeq          9
       6: ldc           #85                 // String
       8: astore_0
       9: aload_0
      10: invokestatic  #87                 // Method readMatrix:(Ljava/lang/String;)[[D
      13: areturn

  public static final void printMatrix(double[][]);
    Code:
       0: aload_0
       1: ldc           #90                 // String matrix
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_1
       8: aload_0
       9: checkcast     #92                 // class "[Ljava/lang/Object;"
      12: arraylength
      13: istore_2
      14: iload_1
      15: iload_2
      16: if_icmpge     86
      19: ldc           #85                 // String
      21: astore_3
      22: iconst_0
      23: istore        4
      25: aload_0
      26: iconst_0
      27: aaload
      28: arraylength
      29: istore        5
      31: iload         4
      33: iload         5
      35: if_icmpge     73
      38: new           #23                 // class java/lang/StringBuilder
      41: dup
      42: invokespecial #27                 // Method java/lang/StringBuilder."<init>":()V
      45: aload_3
      46: invokevirtual #33                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      49: aload_0
      50: iload_1
      51: aaload
      52: iload         4
      54: daload
      55: invokevirtual #95                 // Method java/lang/StringBuilder.append:(D)Ljava/lang/StringBuilder;
      58: bipush        32
      60: invokevirtual #98                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      63: invokevirtual #39                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      66: astore_3
      67: iinc          4, 1
      70: goto          31
      73: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
      76: aload_3
      77: invokevirtual #66                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      80: iinc          1, 1
      83: goto          14
      86: return

  public static final double[][] addMatrices(double[][], double[][], boolean);
    Code:
       0: aload_0
       1: ldc           #103                // String matrix1
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #105                // String matrix2
       9: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: iload_2
      13: ifeq          25
      16: ldc           #107                // String The result is:
      18: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
      21: swap
      22: invokevirtual #66                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      25: iconst_0
      26: istore        4
      28: aload_0
      29: iconst_0
      30: aaload
      31: arraylength
      32: istore        5
      34: iload         5
      36: anewarray     #59                 // class "[D"
      39: astore        6
      41: iload         4
      43: iload         5
      45: if_icmpge     70
      48: iload         4
      50: istore        7
      52: aload         6
      54: iload         7
      56: aload_1
      57: checkcast     #92                 // class "[Ljava/lang/Object;"
      60: arraylength
      61: newarray       double
      63: aastore
      64: iinc          4, 1
      67: goto          41
      70: aload         6
      72: astore_3
      73: aload_0
      74: checkcast     #92                 // class "[Ljava/lang/Object;"
      77: arraylength
      78: aload_1
      79: checkcast     #92                 // class "[Ljava/lang/Object;"
      82: arraylength
      83: if_icmpne     164
      86: aload_0
      87: iconst_0
      88: aaload
      89: arraylength
      90: aload_1
      91: iconst_0
      92: aaload
      93: arraylength
      94: if_icmpne     164
      97: iconst_0
      98: istore        4
     100: aload_0
     101: checkcast     #92                 // class "[Ljava/lang/Object;"
     104: arraylength
     105: istore        5
     107: iload         4
     109: iload         5
     111: if_icmpge     177
     114: iconst_0
     115: istore        6
     117: aload_0
     118: iconst_0
     119: aaload
     120: arraylength
     121: istore        7
     123: iload         6
     125: iload         7
     127: if_icmpge     158
     130: aload_3
     131: iload         4
     133: aaload
     134: iload         6
     136: aload_0
     137: iload         4
     139: aaload
     140: iload         6
     142: daload
     143: aload_1
     144: iload         4
     146: aaload
     147: iload         6
     149: daload
     150: dadd
     151: dastore
     152: iinc          6, 1
     155: goto          123
     158: iinc          4, 1
     161: goto          107
     164: iload_2
     165: ifeq          177
     168: ldc           #109                // String The operation cannot be performed.
     170: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
     173: swap
     174: invokevirtual #66                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     177: aload_3
     178: areturn

  public static double[][] addMatrices$default(double[][], double[][], boolean, int, java.lang.Object);
    Code:
       0: iload_3
       1: iconst_4
       2: iand
       3: ifeq          8
       6: iconst_1
       7: istore_2
       8: aload_0
       9: aload_1
      10: iload_2
      11: invokestatic  #116                // Method addMatrices:([[D[[DZ)[[D
      14: areturn

  public static final double[][] multiplyMatrices(double[][], double[][], boolean);
    Code:
       0: aload_0
       1: ldc           #103                // String matrix1
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #105                // String matrix2
       9: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: iload_2
      13: ifeq          25
      16: ldc           #107                // String The result is:
      18: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
      21: swap
      22: invokevirtual #66                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      25: iconst_0
      26: istore        4
      28: aload_0
      29: checkcast     #92                 // class "[Ljava/lang/Object;"
      32: arraylength
      33: istore        5
      35: iload         5
      37: anewarray     #59                 // class "[D"
      40: astore        6
      42: iload         4
      44: iload         5
      46: if_icmpge     70
      49: iload         4
      51: istore        7
      53: aload         6
      55: iload         7
      57: aload_1
      58: iconst_0
      59: aaload
      60: arraylength
      61: newarray       double
      63: aastore
      64: iinc          4, 1
      67: goto          42
      70: aload         6
      72: astore_3
      73: aload_0
      74: iconst_0
      75: aaload
      76: arraylength
      77: aload_1
      78: checkcast     #92                 // class "[Ljava/lang/Object;"
      81: arraylength
      82: if_icmpne     184
      85: iconst_0
      86: istore        4
      88: aload_0
      89: checkcast     #92                 // class "[Ljava/lang/Object;"
      92: arraylength
      93: istore        5
      95: iload         4
      97: iload         5
      99: if_icmpge     197
     102: iconst_0
     103: istore        6
     105: aload_1
     106: iconst_0
     107: aaload
     108: arraylength
     109: istore        7
     111: iload         6
     113: iload         7
     115: if_icmpge     178
     118: dconst_0
     119: dstore        8
     121: iconst_0
     122: istore        10
     124: aload_0
     125: iconst_0
     126: aaload
     127: arraylength
     128: istore        11
     130: iload         10
     132: iload         11
     134: if_icmpge     163
     137: dload         8
     139: aload_0
     140: iload         4
     142: aaload
     143: iload         10
     145: daload
     146: aload_1
     147: iload         10
     149: aaload
     150: iload         6
     152: daload
     153: dmul
     154: dadd
     155: dstore        8
     157: iinc          10, 1
     160: goto          130
     163: aload_3
     164: iload         4
     166: aaload
     167: iload         6
     169: dload         8
     171: dastore
     172: iinc          6, 1
     175: goto          111
     178: iinc          4, 1
     181: goto          95
     184: iload_2
     185: ifeq          197
     188: ldc           #109                // String The operation cannot be performed.
     190: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
     193: swap
     194: invokevirtual #66                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     197: aload_3
     198: areturn

  public static double[][] multiplyMatrices$default(double[][], double[][], boolean, int, java.lang.Object);
    Code:
       0: iload_3
       1: iconst_4
       2: iand
       3: ifeq          8
       6: iconst_1
       7: istore_2
       8: aload_0
       9: aload_1
      10: iload_2
      11: invokestatic  #124                // Method multiplyMatrices:([[D[[DZ)[[D
      14: areturn

  public static final double[][] multiplyByConstant(double, double[][], boolean);
    Code:
       0: aload_2
       1: ldc           #90                 // String matrix
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iload_3
       7: ifeq          19
      10: ldc           #107                // String The result is:
      12: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
      15: swap
      16: invokevirtual #66                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      19: iconst_0
      20: istore        5
      22: aload_2
      23: checkcast     #92                 // class "[Ljava/lang/Object;"
      26: arraylength
      27: istore        6
      29: iload         6
      31: anewarray     #59                 // class "[D"
      34: astore        7
      36: iload         5
      38: iload         6
      40: if_icmpge     64
      43: iload         5
      45: istore        8
      47: aload         7
      49: iload         8
      51: aload_2
      52: iconst_0
      53: aaload
      54: arraylength
      55: newarray       double
      57: aastore
      58: iinc          5, 1
      61: goto          36
      64: aload         7
      66: astore        4
      68: iconst_0
      69: istore        5
      71: aload_2
      72: checkcast     #92                 // class "[Ljava/lang/Object;"
      75: arraylength
      76: istore        6
      78: iload         5
      80: iload         6
      82: if_icmpge     130
      85: iconst_0
      86: istore        7
      88: aload_2
      89: iconst_0
      90: aaload
      91: arraylength
      92: istore        8
      94: iload         7
      96: iload         8
      98: if_icmpge     124
     101: aload         4
     103: iload         5
     105: aaload
     106: iload         7
     108: dload_0
     109: aload_2
     110: iload         5
     112: aaload
     113: iload         7
     115: daload
     116: dmul
     117: dastore
     118: iinc          7, 1
     121: goto          94
     124: iinc          5, 1
     127: goto          78
     130: aload         4
     132: areturn

  public static double[][] multiplyByConstant$default(double, double[][], boolean, int, java.lang.Object);
    Code:
       0: iload         4
       2: iconst_4
       3: iand
       4: ifeq          9
       7: iconst_1
       8: istore_3
       9: dload_0
      10: aload_2
      11: iload_3
      12: invokestatic  #131                // Method multiplyByConstant:(D[[DZ)[[D
      15: areturn

  public static final void transposeMatrix();
    Code:
       0: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
       3: invokevirtual #134                // Method java/io/PrintStream.println:()V
       6: ldc           #136                // String 1. Main diagonal\n2. Side diagonal\n3. Vertical line\n4. Horizontal line
       8: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
      11: swap
      12: invokevirtual #66                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      15: ldc           #138                // String Your choice:
      17: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
      20: swap
      21: invokevirtual #51                 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
      24: invokestatic  #143                // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
      27: dup
      28: invokestatic  #146                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      31: astore_0
      32: ldc           #107                // String The result is:
      34: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
      37: swap
      38: invokevirtual #66                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      41: aload_0
      42: astore_1
      43: aload_1
      44: invokevirtual #149                // Method java/lang/String.hashCode:()I
      47: tableswitch   { // 49 to 52
                    49: 76
                    50: 88
                    51: 100
                    52: 112
               default: 184
          }
      76: aload_1
      77: ldc           #151                // String 1
      79: invokevirtual #155                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      82: ifne          124
      85: goto          184
      88: aload_1
      89: ldc           #157                // String 2
      91: invokevirtual #155                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      94: ifne          139
      97: goto          184
     100: aload_1
     101: ldc           #159                // String 3
     103: invokevirtual #155                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     106: ifne          154
     109: goto          184
     112: aload_1
     113: ldc           #161                // String 4
     115: invokevirtual #155                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     118: ifne          169
     121: goto          184
     124: aconst_null
     125: iconst_1
     126: aconst_null
     127: invokestatic  #163                // Method readMatrix$default:(Ljava/lang/String;ILjava/lang/Object;)[[D
     130: invokestatic  #167                // Method transposeMain:([[D)[[D
     133: invokestatic  #169                // Method printMatrix:([[D)V
     136: goto          193
     139: aconst_null
     140: iconst_1
     141: aconst_null
     142: invokestatic  #163                // Method readMatrix$default:(Ljava/lang/String;ILjava/lang/Object;)[[D
     145: invokestatic  #172                // Method transposeSide:([[D)[[D
     148: invokestatic  #169                // Method printMatrix:([[D)V
     151: goto          193
     154: aconst_null
     155: iconst_1
     156: aconst_null
     157: invokestatic  #163                // Method readMatrix$default:(Ljava/lang/String;ILjava/lang/Object;)[[D
     160: invokestatic  #175                // Method transposeVertical:([[D)[[D
     163: invokestatic  #169                // Method printMatrix:([[D)V
     166: goto          193
     169: aconst_null
     170: iconst_1
     171: aconst_null
     172: invokestatic  #163                // Method readMatrix$default:(Ljava/lang/String;ILjava/lang/Object;)[[D
     175: invokestatic  #178                // Method transposeHorizontal:([[D)[[D
     178: invokestatic  #169                // Method printMatrix:([[D)V
     181: goto          193
     184: ldc           #180                // String Invalid choice
     186: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
     189: swap
     190: invokevirtual #66                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     193: return

  public static final double[][] transposeMain(double[][]);
    Code:
       0: aload_0
       1: ldc           #90                 // String matrix
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_2
       8: aload_0
       9: iconst_0
      10: aaload
      11: arraylength
      12: istore_3
      13: iload_3
      14: anewarray     #59                 // class "[D"
      17: astore        4
      19: iload_2
      20: iload_3
      21: if_icmpge     45
      24: iload_2
      25: istore        5
      27: aload         4
      29: iload         5
      31: aload_0
      32: checkcast     #92                 // class "[Ljava/lang/Object;"
      35: arraylength
      36: newarray       double
      38: aastore
      39: iinc          2, 1
      42: goto          19
      45: aload         4
      47: astore_1
      48: iconst_0
      49: istore_2
      50: aload_0
      51: checkcast     #92                 // class "[Ljava/lang/Object;"
      54: arraylength
      55: istore_3
      56: iload_2
      57: iload_3
      58: if_icmpge     101
      61: iconst_0
      62: istore        4
      64: aload_0
      65: iconst_0
      66: aaload
      67: arraylength
      68: istore        5
      70: iload         4
      72: iload         5
      74: if_icmpge     95
      77: aload_1
      78: iload         4
      80: aaload
      81: iload_2
      82: aload_0
      83: iload_2
      84: aaload
      85: iload         4
      87: daload
      88: dastore
      89: iinc          4, 1
      92: goto          70
      95: iinc          2, 1
      98: goto          56
     101: aload_1
     102: areturn

  public static final double[][] transposeSide(double[][]);
    Code:
       0: aload_0
       1: ldc           #90                 // String matrix
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_2
       8: aload_0
       9: iconst_0
      10: aaload
      11: arraylength
      12: istore_3
      13: iload_3
      14: anewarray     #59                 // class "[D"
      17: astore        4
      19: iload_2
      20: iload_3
      21: if_icmpge     45
      24: iload_2
      25: istore        5
      27: aload         4
      29: iload         5
      31: aload_0
      32: checkcast     #92                 // class "[Ljava/lang/Object;"
      35: arraylength
      36: newarray       double
      38: aastore
      39: iinc          2, 1
      42: goto          19
      45: aload         4
      47: astore_1
      48: iconst_0
      49: istore_2
      50: aload_0
      51: checkcast     #92                 // class "[Ljava/lang/Object;"
      54: arraylength
      55: istore_3
      56: iload_2
      57: iload_3
      58: if_icmpge     116
      61: iconst_0
      62: istore        4
      64: aload_0
      65: iconst_0
      66: aaload
      67: arraylength
      68: istore        5
      70: iload         4
      72: iload         5
      74: if_icmpge     110
      77: aload_1
      78: aload_0
      79: checkcast     #92                 // class "[Ljava/lang/Object;"
      82: invokestatic  #188                // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I
      85: iload         4
      87: isub
      88: aaload
      89: aload_0
      90: iconst_0
      91: aaload
      92: invokestatic  #191                // Method kotlin/collections/ArraysKt.getLastIndex:([D)I
      95: iload_2
      96: isub
      97: aload_0
      98: iload_2
      99: aaload
     100: iload         4
     102: daload
     103: dastore
     104: iinc          4, 1
     107: goto          70
     110: iinc          2, 1
     113: goto          56
     116: aload_1
     117: areturn

  public static final double[][] transposeVertical(double[][]);
    Code:
       0: aload_0
       1: ldc           #90                 // String matrix
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_2
       8: aload_0
       9: iconst_0
      10: aaload
      11: arraylength
      12: istore_3
      13: iload_3
      14: anewarray     #59                 // class "[D"
      17: astore        4
      19: iload_2
      20: iload_3
      21: if_icmpge     45
      24: iload_2
      25: istore        5
      27: aload         4
      29: iload         5
      31: aload_0
      32: checkcast     #92                 // class "[Ljava/lang/Object;"
      35: arraylength
      36: newarray       double
      38: aastore
      39: iinc          2, 1
      42: goto          19
      45: aload         4
      47: astore_1
      48: iconst_0
      49: istore_2
      50: aload_0
      51: checkcast     #92                 // class "[Ljava/lang/Object;"
      54: arraylength
      55: istore_3
      56: iload_2
      57: iload_3
      58: if_icmpge     108
      61: iconst_0
      62: istore        4
      64: aload_0
      65: iconst_0
      66: aaload
      67: arraylength
      68: istore        5
      70: iload         4
      72: iload         5
      74: if_icmpge     102
      77: aload_1
      78: iload_2
      79: aaload
      80: aload_0
      81: iconst_0
      82: aaload
      83: invokestatic  #191                // Method kotlin/collections/ArraysKt.getLastIndex:([D)I
      86: iload         4
      88: isub
      89: aload_0
      90: iload_2
      91: aaload
      92: iload         4
      94: daload
      95: dastore
      96: iinc          4, 1
      99: goto          70
     102: iinc          2, 1
     105: goto          56
     108: aload_1
     109: areturn

  public static final double[][] transposeHorizontal(double[][]);
    Code:
       0: aload_0
       1: ldc           #90                 // String matrix
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_2
       8: aload_0
       9: iconst_0
      10: aaload
      11: arraylength
      12: istore_3
      13: iload_3
      14: anewarray     #59                 // class "[D"
      17: astore        4
      19: iload_2
      20: iload_3
      21: if_icmpge     45
      24: iload_2
      25: istore        5
      27: aload         4
      29: iload         5
      31: aload_0
      32: checkcast     #92                 // class "[Ljava/lang/Object;"
      35: arraylength
      36: newarray       double
      38: aastore
      39: iinc          2, 1
      42: goto          19
      45: aload         4
      47: astore_1
      48: iconst_0
      49: istore_2
      50: aload_0
      51: checkcast     #92                 // class "[Ljava/lang/Object;"
      54: arraylength
      55: istore_3
      56: iload_2
      57: iload_3
      58: if_icmpge     109
      61: iconst_0
      62: istore        4
      64: aload_0
      65: iconst_0
      66: aaload
      67: arraylength
      68: istore        5
      70: iload         4
      72: iload         5
      74: if_icmpge     103
      77: aload_1
      78: aload_0
      79: checkcast     #92                 // class "[Ljava/lang/Object;"
      82: invokestatic  #188                // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I
      85: iload_2
      86: isub
      87: aaload
      88: iload         4
      90: aload_0
      91: iload_2
      92: aaload
      93: iload         4
      95: daload
      96: dastore
      97: iinc          4, 1
     100: goto          70
     103: iinc          2, 1
     106: goto          56
     109: aload_1
     110: areturn

  public static final double getCofactor(double[][], int, int);
    Code:
       0: aload_0
       1: ldc           #90                 // String matrix
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore        4
       9: aload_0
      10: iconst_0
      11: aaload
      12: arraylength
      13: iconst_1
      14: isub
      15: istore        5
      17: iload         5
      19: anewarray     #59                 // class "[D"
      22: astore        6
      24: iload         4
      26: iload         5
      28: if_icmpge     55
      31: iload         4
      33: istore        7
      35: aload         6
      37: iload         7
      39: aload_0
      40: checkcast     #92                 // class "[Ljava/lang/Object;"
      43: arraylength
      44: iconst_1
      45: isub
      46: newarray       double
      48: aastore
      49: iinc          4, 1
      52: goto          24
      55: aload         6
      57: astore_3
      58: aload_0
      59: checkcast     #92                 // class "[Ljava/lang/Object;"
      62: astore        5
      64: iconst_0
      65: istore        6
      67: aload         5
      69: astore        7
      71: new           #195                // class java/util/ArrayList
      74: dup
      75: invokespecial #196                // Method java/util/ArrayList."<init>":()V
      78: checkcast     #198                // class java/util/Collection
      81: astore        8
      83: iconst_0
      84: istore        9
      86: aload         7
      88: astore        10
      90: iconst_0
      91: istore        11
      93: iconst_0
      94: istore        12
      96: iconst_0
      97: istore        13
      99: aload         10
     101: arraylength
     102: istore        14
     104: iload         13
     106: iload         14
     108: if_icmpge     177
     111: aload         10
     113: iload         13
     115: aaload
     116: astore        15
     118: iload         12
     120: iinc          12, 1
     123: aload         15
     125: astore        16
     127: istore        17
     129: iconst_0
     130: istore        18
     132: iload         17
     134: aload         16
     136: checkcast     #59                 // class "[D"
     139: pop
     140: istore        20
     142: iconst_0
     143: istore        21
     145: iload         20
     147: iload_1
     148: if_icmpeq     155
     151: iconst_1
     152: goto          156
     155: iconst_0
     156: ifeq          169
     159: aload         8
     161: aload         16
     163: invokeinterface #201,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     168: pop
     169: nop
     170: nop
     171: iinc          13, 1
     174: goto          104
     177: nop
     178: aload         8
     180: checkcast     #203                // class java/util/List
     183: nop
     184: checkcast     #198                // class java/util/Collection
     187: astore        5
     189: nop
     190: iconst_0
     191: istore        6
     193: aload         5
     195: astore        7
     197: aload         7
     199: iconst_0
     200: anewarray     #59                 // class "[D"
     203: invokeinterface #207,  2          // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;
     208: checkcast     #81                 // class "[[D"
     211: astore        4
     213: iconst_0
     214: istore        5
     216: aload         4
     218: checkcast     #92                 // class "[Ljava/lang/Object;"
     221: arraylength
     222: istore        6
     224: iload         5
     226: iload         6
     228: if_icmpge     383
     231: aload_3
     232: iload         5
     234: aload         4
     236: iload         5
     238: aaload
     239: astore        7
     241: istore        26
     243: astore        25
     245: iconst_0
     246: istore        8
     248: aload         7
     250: astore        9
     252: new           #195                // class java/util/ArrayList
     255: dup
     256: invokespecial #196                // Method java/util/ArrayList."<init>":()V
     259: checkcast     #198                // class java/util/Collection
     262: astore        10
     264: iconst_0
     265: istore        11
     267: aload         9
     269: astore        12
     271: iconst_0
     272: istore        13
     274: iconst_0
     275: istore        14
     277: iconst_0
     278: istore        15
     280: aload         12
     282: arraylength
     283: istore        16
     285: iload         15
     287: iload         16
     289: if_icmpge     355
     292: aload         12
     294: iload         15
     296: daload
     297: dstore        17
     299: iload         14
     301: iinc          14, 1
     304: dload         17
     306: dstore        19
     308: istore        21
     310: iconst_0
     311: istore        22
     313: iload         21
     315: istore        23
     317: iconst_0
     318: istore        24
     320: iload         23
     322: iload_2
     323: if_icmpeq     330
     326: iconst_1
     327: goto          331
     330: iconst_0
     331: ifeq          347
     334: aload         10
     336: dload         19
     338: invokestatic  #213                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     341: invokeinterface #201,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     346: pop
     347: nop
     348: nop
     349: iinc          15, 1
     352: goto          285
     355: nop
     356: aload         10
     358: checkcast     #203                // class java/util/List
     361: nop
     362: astore        27
     364: aload         25
     366: iload         26
     368: aload         27
     370: checkcast     #198                // class java/util/Collection
     373: invokestatic  #219                // Method kotlin/collections/CollectionsKt.toDoubleArray:(Ljava/util/Collection;)[D
     376: aastore
     377: iinc          5, 1
     380: goto          224
     383: aload_3
     384: invokestatic  #223                // Method determinant:([[D)D
     387: ldc2_w        #224                // double -1.0d
     390: iload_1
     391: iload_2
     392: iadd
     393: i2d
     394: invokestatic  #231                // Method java/lang/Math.pow:(DD)D
     397: dmul
     398: dreturn

  public static final double determinant(double[][]);
    Code:
       0: aload_0
       1: ldc           #90                 // String matrix
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #92                 // class "[Ljava/lang/Object;"
      10: arraylength
      11: iconst_2
      12: if_icmpne     41
      15: aload_0
      16: iconst_0
      17: aaload
      18: iconst_0
      19: daload
      20: aload_0
      21: iconst_1
      22: aaload
      23: iconst_1
      24: daload
      25: dmul
      26: aload_0
      27: iconst_0
      28: aaload
      29: iconst_1
      30: daload
      31: aload_0
      32: iconst_1
      33: aaload
      34: iconst_0
      35: daload
      36: dmul
      37: dsub
      38: goto          80
      41: dconst_0
      42: dstore_1
      43: iconst_0
      44: istore_3
      45: aload_0
      46: checkcast     #92                 // class "[Ljava/lang/Object;"
      49: arraylength
      50: istore        4
      52: iload_3
      53: iload         4
      55: if_icmpge     79
      58: dload_1
      59: aload_0
      60: iconst_0
      61: iload_3
      62: invokestatic  #255                // Method getCofactor:([[DII)D
      65: aload_0
      66: iconst_0
      67: aaload
      68: iload_3
      69: daload
      70: dmul
      71: dadd
      72: dstore_1
      73: iinc          3, 1
      76: goto          52
      79: dload_1
      80: dreturn

  public static final void calcDeterminant();
    Code:
       0: aconst_null
       1: iconst_1
       2: aconst_null
       3: invokestatic  #163                // Method readMatrix$default:(Ljava/lang/String;ILjava/lang/Object;)[[D
       6: astore_0
       7: ldc           #107                // String The result is:
       9: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
      12: swap
      13: invokevirtual #66                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      16: aload_0
      17: checkcast     #92                 // class "[Ljava/lang/Object;"
      20: arraylength
      21: aload_0
      22: iconst_0
      23: aaload
      24: arraylength
      25: if_icmpne     43
      28: aload_0
      29: invokestatic  #223                // Method determinant:([[D)D
      32: dstore_1
      33: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
      36: dload_1
      37: invokevirtual #260                // Method java/io/PrintStream.println:(D)V
      40: goto          52
      43: ldc           #109                // String The operation cannot be performed.
      45: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
      48: swap
      49: invokevirtual #66                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      52: return

  public static final double[][] getAdjoint(double[][]);
    Code:
       0: aload_0
       1: ldc           #90                 // String matrix
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_2
       8: aload_0
       9: checkcast     #92                 // class "[Ljava/lang/Object;"
      12: arraylength
      13: istore_3
      14: iload_3
      15: anewarray     #59                 // class "[D"
      18: astore        4
      20: iload_2
      21: iload_3
      22: if_icmpge     45
      25: iload_2
      26: istore        5
      28: aload         4
      30: iload         5
      32: aload_0
      33: iconst_0
      34: aaload
      35: arraylength
      36: newarray       double
      38: aastore
      39: iinc          2, 1
      42: goto          20
      45: aload         4
      47: astore_1
      48: iconst_0
      49: istore_2
      50: aload_0
      51: checkcast     #92                 // class "[Ljava/lang/Object;"
      54: arraylength
      55: istore_3
      56: iload_2
      57: iload_3
      58: if_icmpge     102
      61: iconst_0
      62: istore        4
      64: aload_0
      65: iconst_0
      66: aaload
      67: arraylength
      68: istore        5
      70: iload         4
      72: iload         5
      74: if_icmpge     96
      77: aload_1
      78: iload_2
      79: aaload
      80: iload         4
      82: aload_0
      83: iload_2
      84: iload         4
      86: invokestatic  #255                // Method getCofactor:([[DII)D
      89: dastore
      90: iinc          4, 1
      93: goto          70
      96: iinc          2, 1
      99: goto          56
     102: aload_1
     103: invokestatic  #167                // Method transposeMain:([[D)[[D
     106: areturn

  public static final double[][] inverseMatrix(double[][], boolean);
    Code:
       0: aload_0
       1: ldc           #90                 // String matrix
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iload_1
       7: ifeq          19
      10: ldc           #107                // String The result is:
      12: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
      15: swap
      16: invokevirtual #66                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      19: aload_0
      20: invokestatic  #223                // Method determinant:([[D)D
      23: dstore_2
      24: dload_2
      25: dconst_0
      26: dcmpg
      27: ifne          34
      30: iconst_1
      31: goto          35
      34: iconst_0
      35: ifne          53
      38: iconst_1
      39: i2d
      40: dload_2
      41: ddiv
      42: aload_0
      43: invokestatic  #266                // Method getAdjoint:([[D)[[D
      46: iconst_0
      47: invokestatic  #131                // Method multiplyByConstant:(D[[DZ)[[D
      50: goto          114
      53: iload_1
      54: ifeq          67
      57: ldc_w         #268                // String This matrix doesn\'t have an inverse.
      60: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
      63: swap
      64: invokevirtual #66                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      67: iconst_0
      68: istore        4
      70: aload_0
      71: checkcast     #92                 // class "[Ljava/lang/Object;"
      74: arraylength
      75: istore        5
      77: iload         5
      79: anewarray     #59                 // class "[D"
      82: astore        6
      84: iload         4
      86: iload         5
      88: if_icmpge     112
      91: iload         4
      93: istore        7
      95: aload         6
      97: iload         7
      99: aload_0
     100: iconst_0
     101: aaload
     102: arraylength
     103: newarray       double
     105: aastore
     106: iinc          4, 1
     109: goto          84
     112: aload         6
     114: areturn

  public static double[][] inverseMatrix$default(double[][], boolean, int, java.lang.Object);
    Code:
       0: iload_2
       1: iconst_2
       2: iand
       3: ifeq          8
       6: iconst_1
       7: istore_1
       8: aload_0
       9: iload_1
      10: invokestatic  #273                // Method inverseMatrix:([[DZ)[[D
      13: areturn

  public static final void main();
    Code:
       0: nop
       1: ldc_w         #276                // String 1. Add matrices\n2. Multiply matrix by a constant\n3. Multiply matrices\n4. Transpose matrix\n5. Calculate a determinant\n6. Inverse matrix\n0. Exit
       4: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
       7: swap
       8: invokevirtual #66                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      11: ldc           #138                // String Your choice:
      13: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
      16: swap
      17: invokevirtual #51                 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
      20: invokestatic  #143                // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
      23: astore_0
      24: aload_0
      25: ifnull        278
      28: aload_0
      29: invokevirtual #149                // Method java/lang/String.hashCode:()I
      32: tableswitch   { // 48 to 54
                    48: 76
                    49: 89
                    50: 101
                    51: 113
                    52: 125
                    53: 137
                    54: 150
               default: 278
          }
      76: aload_0
      77: ldc_w         #278                // String 0
      80: invokevirtual #155                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      83: ifne          163
      86: goto          278
      89: aload_0
      90: ldc           #151                // String 1
      92: invokevirtual #155                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      95: ifne          164
      98: goto          278
     101: aload_0
     102: ldc           #157                // String 2
     104: invokevirtual #155                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     107: ifne          188
     110: goto          278
     113: aload_0
     114: ldc           #159                // String 3
     116: invokevirtual #155                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     119: ifne          224
     122: goto          278
     125: aload_0
     126: ldc           #161                // String 4
     128: invokevirtual #155                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     131: ifne          248
     134: goto          278
     137: aload_0
     138: ldc_w         #280                // String 5
     141: invokevirtual #155                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     144: ifne          254
     147: goto          278
     150: aload_0
     151: ldc_w         #282                // String 6
     154: invokevirtual #155                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     157: ifne          260
     160: goto          278
     163: return
     164: ldc_w         #284                // String first
     167: invokestatic  #87                 // Method readMatrix:(Ljava/lang/String;)[[D
     170: ldc_w         #286                // String second
     173: invokestatic  #87                 // Method readMatrix:(Ljava/lang/String;)[[D
     176: iconst_0
     177: iconst_4
     178: aconst_null
     179: invokestatic  #288                // Method addMatrices$default:([[D[[DZILjava/lang/Object;)[[D
     182: invokestatic  #169                // Method printMatrix:([[D)V
     185: goto          287
     188: aconst_null
     189: iconst_1
     190: aconst_null
     191: invokestatic  #163                // Method readMatrix$default:(Ljava/lang/String;ILjava/lang/Object;)[[D
     194: astore_1
     195: ldc_w         #290                // String Enter constant:
     198: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
     201: swap
     202: invokevirtual #51                 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
     205: getstatic     #11                 // Field scanner:Ljava/util/Scanner;
     208: invokevirtual #70                 // Method java/util/Scanner.nextDouble:()D
     211: aload_1
     212: iconst_0
     213: iconst_4
     214: aconst_null
     215: invokestatic  #292                // Method multiplyByConstant$default:(D[[DZILjava/lang/Object;)[[D
     218: invokestatic  #169                // Method printMatrix:([[D)V
     221: goto          287
     224: ldc_w         #284                // String first
     227: invokestatic  #87                 // Method readMatrix:(Ljava/lang/String;)[[D
     230: ldc_w         #286                // String second
     233: invokestatic  #87                 // Method readMatrix:(Ljava/lang/String;)[[D
     236: iconst_0
     237: iconst_4
     238: aconst_null
     239: invokestatic  #294                // Method multiplyMatrices$default:([[D[[DZILjava/lang/Object;)[[D
     242: invokestatic  #169                // Method printMatrix:([[D)V
     245: goto          287
     248: invokestatic  #296                // Method transposeMatrix:()V
     251: goto          287
     254: invokestatic  #298                // Method calcDeterminant:()V
     257: goto          287
     260: aconst_null
     261: iconst_1
     262: aconst_null
     263: invokestatic  #163                // Method readMatrix$default:(Ljava/lang/String;ILjava/lang/Object;)[[D
     266: iconst_0
     267: iconst_2
     268: aconst_null
     269: invokestatic  #300                // Method inverseMatrix$default:([[DZILjava/lang/Object;)[[D
     272: invokestatic  #169                // Method printMatrix:([[D)V
     275: goto          287
     278: ldc           #180                // String Invalid choice
     280: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
     283: swap
     284: invokevirtual #66                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     287: getstatic     #45                 // Field java/lang/System.out:Ljava/io/PrintStream;
     290: invokevirtual #134                // Method java/io/PrintStream.println:()V
     293: goto          0

  public static void main(java.lang.String[]);
    Code:
       0: invokestatic  #303                // Method main:()V
       3: return

  static {};
    Code:
       0: new           #53                 // class java/util/Scanner
       3: dup
       4: getstatic     #310                // Field java/lang/System.in:Ljava/io/InputStream;
       7: invokespecial #313                // Method java/util/Scanner."<init>":(Ljava/io/InputStream;)V
      10: putstatic     #11                 // Field scanner:Ljava/util/Scanner;
      13: return
}


package com.acmerobotics.roadrunner.util

import kotlin.math.*

/**
 * Various math utilities.
 */
object MathUtil {

    /**
     * Returns the real solutions to the quadratic [a]x^2 + [b]x + [c] = 0.
     */
    @JvmStatic
    fun solveQuadratic(a: Double, b: Double, c: Double): DoubleArray {
        if (a epsilonEquals 0.0) {
            return doubleArrayOf(-c / b)
        }

        val disc = b * b - 4 * a * c
        return when {
            disc epsilonEquals 0.0 -> doubleArrayOf(-b / (2 * a))
            disc > 0.0 -> doubleArrayOf(
                    (-b + sqrt(disc)) / (2 * a),
                    (-b - sqrt(disc)) / (2 * a)
            )
            else -> doubleArrayOf()
        }
    }

    /**
     * Similar to Java cbrt, but implemented with kotlin math (preserves sign)
     */
    @JvmStatic
    fun cbrt(x: Double) = sign(x) * abs(x).pow(1.0 / 3.0)

    /**
     * Returns real solutions to the cubic [a]x^3 + [b]x^2 + [c]x + [d] = 0
     * [Reference](https://github.com/davidzof/wattzap/blob/a3065da/src/com/wattzap/model/power/Cubic.java#L125-L182)
     */
    @JvmStatic
    fun solveCubic(a: Double, b: Double, c: Double, d: Double): DoubleArray {
        if (a epsilonEquals 0.0) {
            return solveQuadratic(b, c, d)
        }

        val a2 = b / a
        val a1 = c / a
        val a0 = d / a

        val lambda = a2 / 3.0
        val Q = (3.0 * a1 - a2 * a2) / 9.0
        val R = (9.0 * a1 * a2 - 27.0 * a0 - 2.0 * a2 * a2 * a2) / 54.0
        val Q3 = Q * Q * Q
        val R2 = R * R
        val D = Q3 + R2

        return when {
            D < 0.0 -> { // 3 unique reals
                val theta = acos(R / sqrt(-Q3))
                val sqrtQ = sqrt(-Q)
                doubleArrayOf(
                        2.0 * sqrtQ * cos(theta / 3.0) - lambda,
                        2.0 * sqrtQ * cos((theta + 2.0 * PI) / 3.0) - lambda,
                        2.0 * sqrtQ * cos((theta + 4.0 * PI) / 3.0) - lambda
                )
            }
            D > 0.0 -> { // 1 real
                val sqrtD = sqrt(D)
                val S = cbrt(R + sqrtD)
                val T = cbrt(R - sqrtD)
                doubleArrayOf(S + T - lambda)
            }
            else -> { // 2 unique (3 total) reals
                val cbrtR = cbrt(R)
                doubleArrayOf(2.0 * cbrtR - lambda, -cbrtR - lambda)
            }
        }
    }
}

const val EPSILON = 1e-6

infix fun Double.epsilonEquals(other: Double) = abs(this - other) < EPSILON

Compiled from "MathUtil.kt"
public final class com.acmerobotics.roadrunner.util.MathUtil {
  public static final com.acmerobotics.roadrunner.util.MathUtil INSTANCE;

  private com.acmerobotics.roadrunner.util.MathUtil();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public static final double[] solveQuadratic(double, double, double);
    Code:
       0: dload_0
       1: dconst_0
       2: invokestatic  #20                 // Method com/acmerobotics/roadrunner/util/MathUtilKt.epsilonEquals:(DD)Z
       5: ifeq          25
       8: iconst_1
       9: newarray       double
      11: astore        6
      13: aload         6
      15: iconst_0
      16: dload         4
      18: dneg
      19: dload_2
      20: ddiv
      21: dastore
      22: aload         6
      24: areturn
      25: dload_2
      26: dload_2
      27: dmul
      28: iconst_4
      29: i2d
      30: dload_0
      31: dmul
      32: dload         4
      34: dmul
      35: dsub
      36: dstore        6
      38: nop
      39: dload         6
      41: dconst_0
      42: invokestatic  #20                 // Method com/acmerobotics/roadrunner/util/MathUtilKt.epsilonEquals:(DD)Z
      45: ifeq          69
      48: iconst_1
      49: newarray       double
      51: astore        8
      53: aload         8
      55: iconst_0
      56: dload_2
      57: dneg
      58: iconst_2
      59: i2d
      60: dload_0
      61: dmul
      62: ddiv
      63: dastore
      64: aload         8
      66: goto          123
      69: dload         6
      71: dconst_0
      72: dcmpl
      73: ifle          120
      76: iconst_2
      77: newarray       double
      79: astore        8
      81: aload         8
      83: iconst_0
      84: dload_2
      85: dneg
      86: dload         6
      88: invokestatic  #26                 // Method java/lang/Math.sqrt:(D)D
      91: dadd
      92: iconst_2
      93: i2d
      94: dload_0
      95: dmul
      96: ddiv
      97: dastore
      98: aload         8
     100: iconst_1
     101: dload_2
     102: dneg
     103: dload         6
     105: invokestatic  #26                 // Method java/lang/Math.sqrt:(D)D
     108: dsub
     109: iconst_2
     110: i2d
     111: dload_0
     112: dmul
     113: ddiv
     114: dastore
     115: aload         8
     117: goto          123
     120: iconst_0
     121: newarray       double
     123: areturn

  public static final double cbrt(double);
    Code:
       0: dload_0
       1: invokestatic  #37                 // Method java/lang/Math.signum:(D)D
       4: dload_0
       5: invokestatic  #40                 // Method java/lang/Math.abs:(D)D
       8: ldc2_w        #41                 // double 0.3333333333333333d
      11: invokestatic  #46                 // Method java/lang/Math.pow:(DD)D
      14: dmul
      15: dreturn

  public static final double[] solveCubic(double, double, double, double);
    Code:
       0: dload_0
       1: dconst_0
       2: invokestatic  #20                 // Method com/acmerobotics/roadrunner/util/MathUtilKt.epsilonEquals:(DD)Z
       5: ifeq          21
       8: getstatic     #52                 // Field INSTANCE:Lcom/acmerobotics/roadrunner/util/MathUtil;
      11: pop
      12: dload_2
      13: dload         4
      15: dload         6
      17: invokestatic  #54                 // Method solveQuadratic:(DDD)[D
      20: areturn
      21: dload_2
      22: dload_0
      23: ddiv
      24: dstore        8
      26: dload         4
      28: dload_0
      29: ddiv
      30: dstore        10
      32: dload         6
      34: dload_0
      35: ddiv
      36: dstore        12
      38: dload         8
      40: ldc2_w        #55                 // double 3.0d
      43: ddiv
      44: dstore        14
      46: ldc2_w        #55                 // double 3.0d
      49: dload         10
      51: dmul
      52: dload         8
      54: dload         8
      56: dmul
      57: dsub
      58: ldc2_w        #57                 // double 9.0d
      61: ddiv
      62: dstore        16
      64: ldc2_w        #57                 // double 9.0d
      67: dload         10
      69: dmul
      70: dload         8
      72: dmul
      73: ldc2_w        #59                 // double 27.0d
      76: dload         12
      78: dmul
      79: dsub
      80: ldc2_w        #61                 // double 2.0d
      83: dload         8
      85: dmul
      86: dload         8
      88: dmul
      89: dload         8
      91: dmul
      92: dsub
      93: ldc2_w        #63                 // double 54.0d
      96: ddiv
      97: dstore        18
      99: dload         16
     101: dload         16
     103: dmul
     104: dload         16
     106: dmul
     107: dstore        20
     109: dload         18
     111: dload         18
     113: dmul
     114: dstore        22
     116: dload         20
     118: dload         22
     120: dadd
     121: dstore        24
     123: nop
     124: dload         24
     126: dconst_0
     127: dcmpg
     128: ifge          240
     131: dload         18
     133: dload         20
     135: dneg
     136: invokestatic  #26                 // Method java/lang/Math.sqrt:(D)D
     139: ddiv
     140: invokestatic  #67                 // Method java/lang/Math.acos:(D)D
     143: dstore        26
     145: dload         16
     147: dneg
     148: invokestatic  #26                 // Method java/lang/Math.sqrt:(D)D
     151: dstore        28
     153: iconst_3
     154: newarray       double
     156: astore        30
     158: aload         30
     160: iconst_0
     161: ldc2_w        #61                 // double 2.0d
     164: dload         28
     166: dmul
     167: dload         26
     169: ldc2_w        #55                 // double 3.0d
     172: ddiv
     173: invokestatic  #70                 // Method java/lang/Math.cos:(D)D
     176: dmul
     177: dload         14
     179: dsub
     180: dastore
     181: aload         30
     183: iconst_1
     184: ldc2_w        #61                 // double 2.0d
     187: dload         28
     189: dmul
     190: dload         26
     192: ldc2_w        #71                 // double 6.283185307179586d
     195: dadd
     196: ldc2_w        #55                 // double 3.0d
     199: ddiv
     200: invokestatic  #70                 // Method java/lang/Math.cos:(D)D
     203: dmul
     204: dload         14
     206: dsub
     207: dastore
     208: aload         30
     210: iconst_2
     211: ldc2_w        #61                 // double 2.0d
     214: dload         28
     216: dmul
     217: dload         26
     219: ldc2_w        #73                 // double 12.566370614359172d
     222: dadd
     223: ldc2_w        #55                 // double 3.0d
     226: ddiv
     227: invokestatic  #70                 // Method java/lang/Math.cos:(D)D
     230: dmul
     231: dload         14
     233: dsub
     234: dastore
     235: aload         30
     237: goto          345
     240: dload         24
     242: dconst_0
     243: dcmpl
     244: ifle          304
     247: dload         24
     249: invokestatic  #26                 // Method java/lang/Math.sqrt:(D)D
     252: dstore        26
     254: getstatic     #52                 // Field INSTANCE:Lcom/acmerobotics/roadrunner/util/MathUtil;
     257: pop
     258: dload         18
     260: dload         26
     262: dadd
     263: invokestatic  #76                 // Method cbrt:(D)D
     266: dstore        28
     268: getstatic     #52                 // Field INSTANCE:Lcom/acmerobotics/roadrunner/util/MathUtil;
     271: pop
     272: dload         18
     274: dload         26
     276: dsub
     277: invokestatic  #76                 // Method cbrt:(D)D
     280: dstore        30
     282: iconst_1
     283: newarray       double
     285: astore        32
     287: aload         32
     289: iconst_0
     290: dload         28
     292: dload         30
     294: dadd
     295: dload         14
     297: dsub
     298: dastore
     299: aload         32
     301: goto          345
     304: getstatic     #52                 // Field INSTANCE:Lcom/acmerobotics/roadrunner/util/MathUtil;
     307: pop
     308: dload         18
     310: invokestatic  #76                 // Method cbrt:(D)D
     313: dstore        26
     315: iconst_2
     316: newarray       double
     318: astore        28
     320: aload         28
     322: iconst_0
     323: ldc2_w        #61                 // double 2.0d
     326: dload         26
     328: dmul
     329: dload         14
     331: dsub
     332: dastore
     333: aload         28
     335: iconst_1
     336: dload         26
     338: dneg
     339: dload         14
     341: dsub
     342: dastore
     343: aload         28
     345: areturn

  static {};
    Code:
       0: new           #2                  // class com/acmerobotics/roadrunner/util/MathUtil
       3: dup
       4: invokespecial #93                 // Method "<init>":()V
       7: putstatic     #52                 // Field INSTANCE:Lcom/acmerobotics/roadrunner/util/MathUtil;
      10: return
}

Compiled from "MathUtil.kt"
public final class com.acmerobotics.roadrunner.util.MathUtilKt {
  public static final double EPSILON;

  public static final boolean epsilonEquals(double, double);
    Code:
       0: dload_0
       1: dload_2
       2: dsub
       3: invokestatic  #12                 // Method java/lang/Math.abs:(D)D
       6: ldc2_w        #13                 // double 1.0E-6d
       9: dcmpg
      10: ifge          17
      13: iconst_1
      14: goto          18
      17: iconst_0
      18: ireturn
}