/
nea
/
androidGroupBuilder
Обзор
Документация
Войти
/
nea
/
androidGroupBuilder
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
app/src/main/java/com/ea/groupbuilder/classSylow.java
1 892 строки
107 KB
ea
Группа Автоморфизмов отлажено 23_04_2026
23 апр 2026, 17:08
23 апр 2026, 17:08
4513276
Код
Авторство
О чём код?
package com.ea.groupbuilder; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.util.Log; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.Date; import java.util.List; public class classSylow { // построение силовских подгрупп private static final String TAG = "GRUGRA_SYLOW"; final static private boolean DISPLAYLOG = false; private final static int MAX_LABOR_INTENSITY = 9; // мах число итераций при поиске сил подгрупп public mAplication mApp; private DbHelper dbH; static public substitutionS classSubs; static public SQLiteDatabase db; public final static DecimalFormat DecFormat = new DecimalFormat("000"); private int vidWgrup = 0; // vidWgrup = 0 - сама группа, 1 - группа автоморфизмов public void init(mAplication mApp_, DbHelper dbH_, int vidWgrup_ ) { mApp = mApp_; dbH = dbH_; db = DbHelper.db; classSubs = mApp.classSubs; vidWgrup = vidWgrup_; } private int numPeYes = 0; // кол-во найденных p - подгрупп силовских public void f_build_sylov() { // построение силовских подгрупп // Log.e(TAG, "f_build_sylov vidWgrup=" + vidWgrup + " numPeYes = " + numPeYes + " sylovPrimeGrupPower=" + substitutionS.sylovPrimeGrupPower.size() + " sylovPrimeGrupNum = " + substitutionS.sylovPrimeGrupNum.size()); mApp.putProt("\nПостроение подгрупп силова и цоколя"); int iPe, j, k, pe, // текущее простое в порядке группы degPe, indDeg, degMain, // порядок силовских подгрупп для pe indIdl, idMain, indSbt; String sqlSel, sqlRead, sbsMain; if (DbHelper.countCentr == DbHelper.countElements) { mApp.putProt("Группа абелева"); f_sylovAbelev(); return; } db.beginTransaction(); db.execSQL("delete from temp_pe;"); db.execSQL("UPDATE SQLITE_SEQUENCE SET SEQ=0 WHERE NAME='temp_pe';"); Cursor cursorConjPe0; try { db.execSQL("delete from pe_subgroup;"); db.execSQL("UPDATE SQLITE_SEQUENCE SET SEQ=0 WHERE NAME='pe_subgroup';"); for (iPe = 0; iPe < substitutionS.sylovPrimeGrupNum.size(); iPe++) { // цикл по простым числам из порядка группы if (substitutionS.sylovPrimeGrupPower.get(iPe) > 1) { // для простого pe степень которого =1 любая циклическая подгруппа степени p - силовская, они уже были найдены при построении циклов // теперь ищу подгруппы с порядком pe > 1 pe = substitutionS.sylovPrimeGrupNum.get(iPe); degPe = substitutionS.sylovPower.get(iPe); // ПОРЯДОК СИЛОВСКОЙ ПОДГРУППЫ if (! DbHelper.peSylCreate.contains(pe)) { // возможно она одна ? sqlSel = "select pe as ccc from " + DbHelper.elements[vidWgrup] + " where pe = " + pe + ";"; j = dbH.f_getCountRow(sqlSel); if (j > 0) { // Log.e(TAG, "f_build_sylov pe=" + pe + " i=" + i + " degPe= " + degPe + " N=" + substitutionS.sylovPrimeGrupPower.get(i)); if (j == (degPe - 1)) { mApp.putProt("Подгруппа силова для простого " + pe + " единственна и нормальна, состоит из " + degPe + " элементов, имеет номер " + DbHelper.curNumSylov); sqlSel = "update " + DbHelper.elements[vidWgrup] + " set sylow_num = '" + DecFormat.format(DbHelper.curNumSylov) + "' where pe = " + pe + "; "; db.execSQL(sqlSel); sqlSel = "insert into " + DbHelper.sylov_table[vidWgrup] + " ( pe, num, id_main, id_s) " + " select " + pe + ", " + DbHelper.curNumSylov + ", 0, _id " + "from " + DbHelper.elements[vidWgrup] + " where pe = " + pe + " or _id = " + substitutionS.codEdinicy + "; "; db.execSQL(sqlSel); if (DISPLAYLOG) Log.e(TAG, "f_build_sylov Подгруппа силова для простого " + pe + " единственна и нормальна, состоит из " + degPe + " элементов, имеет номер " + DbHelper.curNumSylov + " sqlSel=" + sqlSel); DbHelper.curNumSylov++; if (!DbHelper.peSylCreate.contains(pe)) DbHelper.peSylCreate.add(pe); } } if (myExecutor.MyThread.isCancel || DbHelper.err.length() > 0) { DbHelper.err += "\n Расчет прерван"; break; } } if (! DbHelper.peSylCreate.contains(pe)) { // для pe еще не найдены подгруппы, ищу отсеиванием numPeYes = 0; // уже найдено db.execSQL("delete from temp_pe;"); // заношу все строки таблицы умножения по простому pe в temp_pe sqlSel = "insert into temp_pe (id_1, id_2, id_s, degs, center_num, pe) " + " select M.idleft, M.idright, M.idproiz, e3.deg as deg3, e3.center_num, " + pe + " from " + DbHelper.temp_multiplication[vidWgrup] + " M, " + DbHelper.elements[vidWgrup] + " e1, " + DbHelper.elements[vidWgrup] + " e2, " + DbHelper.elements[vidWgrup] + " e3\n" + " where e1._id = M.idleft and e2._id = M.idright and e3._id = M.idproiz and\n" + " e1.pe = " + pe + " and e2.pe = " + pe + " and e3.pe = " + pe + " and NOT e3.pe = 0 and\n" + " e1.sylow_num is null and e2.sylow_num is null and e3.sylow_num is null\n" + " order by e1.deg asc, e2.deg desc; "; db.execSQL(sqlSel); // просмотр всех элементов для выбора гравного в сил подгруппе sqlRead = "select _id, center_num, deg, substitution from " + DbHelper.elements[vidWgrup] + " where pe = " + pe + " and not center_num = " + DbHelper.countCentr + " order by center_num asc, deg desc; "; cursorConjPe0 = db.rawQuery(sqlRead, null); cursorConjPe0.moveToFirst(); indIdl = cursorConjPe0.getColumnIndex("_id"); indDeg = cursorConjPe0.getColumnIndex("deg"); indSbt = cursorConjPe0.getColumnIndex("substitution"); if (cursorConjPe0.getCount() > 0) { if (cursorConjPe0.moveToFirst()) { do { // idMain = cursorConjPe0.getInt(indIdl); degMain = cursorConjPe0.getInt(indDeg); sbsMain = cursorConjPe0.getString(indSbt); // если этот элемент уже записан в сил подгруппу - пропустить его // Log.e(TAG, "f_build_sylov pe=" + pe + " idMain= " + idMain); sqlSel = "select id_s as ccc from " + DbHelper.sylov_table[vidWgrup] + " where id_s = " + idMain + ";"; if (dbH.f_getCountRow(sqlSel) > 0) { // Log.e(TAG, "f_build_sylov pe=" + pe + " idMain= " + idMain + " уже есть"); continue; } db.execSQL("delete from sylov_id;"); sqlSel = "insert into sylov_id (id_s) " + " select distinct P.id_2 from temp_pe P " + // в temp_pe записаны произведения p- эл-тов " where P.id_1 = " + idMain + "; "; // idleft = idMain db.execSQL(sqlSel); sqlSel = "select id_s as ccc from sylov_id where id_s = " + idMain + ";"; if (dbH.f_getCountRow(sqlSel) > 0) { sqlSel = "insert into sylov_id (id_s) values (" + idMain + "); "; db.execSQL(sqlSel); // Log.e(TAG, "f_build_sylov pe=" + pe + " idMain= " + idMain + " добавлен sqlSel=" + sqlSel); } if (DISPLAYLOG) mApp.putProt("Для простого " + pe + " ищем подгруппу из " + degPe + " элементов, по элементу с Id " + idMain); k = MAX_LABOR_INTENSITY; // до 5 раз сею элементы do { if (f_sylowSow(pe, idMain, degPe, degMain, sbsMain, k) == 0) k = 0; else k--; } while (k > 0); } while (cursorConjPe0.moveToNext()); } } cursorConjPe0.close(); if (myExecutor.MyThread.isCancel || DbHelper.err.length() > 0) { DbHelper.err += "\n Расчет прерван"; break; } } if (! DbHelper.peSylCreate.contains(pe)) { if (f_getPeRows(pe) > 0) { // // возвращает число эл-тов для которых не найдена сил подгруппа когда силовские подгруппы только строятся // для pe еще не найдены подгруппы, ищу по 2 p-элементоам mApp.putProt("Длинный поиск подгрупп силова для p = " + pe); f_sylPoiskLong(pe, degPe); } } } // if (substitutionS.sylovPrimeGrupPower.get(iPe) > 1 } // for (i = 0; i < substitutionS.sylovPrimeGrupNum.size() // записать номера подгрупп в elements в колонку sylow_num sqlRead = "select num, id_s from " + DbHelper.sylov_table[vidWgrup] + " order by id_s asc, num asc; "; // Cursor curNum = db.rawQuery(sqlRead, null); curNum.moveToFirst(); if (curNum.getCount() > 0) { indIdl = curNum.getColumnIndex("id_s"); int indNum = curNum.getColumnIndex("num"), idMain0 = 0; String nums = ""; do { idMain = curNum.getInt(indIdl); k = curNum.getInt(indNum); if (idMain0 != idMain) { if (nums.length() > 0) { sqlSel = "update " + DbHelper.elements[vidWgrup] + " set sylow_num = '" + nums + "' where _id = " + idMain0 + ";"; db.execSQL(sqlSel); if (DISPLAYLOG) Log.e(TAG, "f_build_sylov запись № силова для _id " + idMain0 + " # " + nums + " sqlSel=" + sqlSel); } nums = ""; idMain0 = idMain; } if (nums.length() > 0) nums += (", " + DecFormat.format(k)); else nums = DecFormat.format(k); } while (curNum.moveToNext()); if (nums.length() > 0) { sqlSel = "update " + DbHelper.elements[vidWgrup] + " set sylow_num = '" + nums + "' where _id = " + idMain0 + ";"; db.execSQL(sqlSel); if (DISPLAYLOG) Log.e(TAG, "f_build_sylov запись 2 № силова для _id " + idMain0 + " # " + nums + " sqlSel=" + sqlSel); } } curNum.close(); // записать в forming - id_main sqlRead = "select num, id_s, id_main from " + DbHelper.sylov_table[vidWgrup] + " order by id_s asc, id_main asc; "; curNum = db.rawQuery(sqlRead, null); curNum.moveToFirst(); if (curNum.getCount() > 0) { indIdl = curNum.getColumnIndex("id_s"); int indNum = curNum.getColumnIndex("id_main"), idMain0 = 0; String form = ""; do { idMain = curNum.getInt(indIdl); k = curNum.getInt(indNum); if (idMain0 != idMain) { if (form.length() > 0) { sqlSel = "update " + DbHelper.elements[vidWgrup] + " set forming = '" + form + "' where _id = " + idMain0 + ";"; db.execSQL(sqlSel); } form = ""; idMain0 = idMain; } if (form.length() > 0) form += " "; form += k; } while (curNum.moveToNext()); if (form.length() > 0) { sqlSel = "update " + DbHelper.elements[vidWgrup] + " set forming = '" + form + "' where _id = " + idMain0 + ";"; db.execSQL(sqlSel); } } curNum.close(); f_saveSylov(); // сохранить в params, ищу общие подгруппы k = dbH.f_getMas("select distinct ''||pe as stext from " + DbHelper.elements[vidWgrup] + " where (sylow_num = '' or sylow_num is null) and not pe = 0;"); if (k > 0) { for (k = 0; k < DbHelper.selectedMas.length; k++) { DbHelper.peSylNoFound.add( Integer.parseInt(DbHelper.selectedMas[k].trim()) ); Log.e(TAG, "f_build_sylov Не найдены подгруппы силова для " + DbHelper.selectedMas[k] ); mApp.putProt("НЕ НАЙДЕНЫ ПОДГРУППЫ СИЛОВА ДЛЯ p = " + DbHelper.selectedMas[k] + " (или не все найдены)"); } } else mApp.putProt("Все подгруппы силова построены"); // Log.e(TAG, "f_build_sylov end vidWgrup=" + vidWgrup + " numPeYes = " + numPeYes + " N=" + substitutionS.sylovPrimeGrupPower.size()); /* select L._id as id, L.name as name, L.substitution as substitution, L.ciklos as ciklos, L.deg as deg, L.sylow_num as sylow_num, L.parity as parity, E._id as lid, E.name as namel, E.ciklos as ciklose, e.deg as dege, E.parity as paritye, R._id as rid, R.name as namer, R.ciklos as ciklosr, R.deg as degr, R.parity as parityr from switchboard S, elements L, elements E, elements R where S.work_field = 0 and S.id_switch = L._id and S.id_left = E._id and S.id_right = R._id order by L._id asc; */ } catch (Exception e) { Log.e(TAG, "Error f_build_sylov " + e.getMessage() ); e.printStackTrace(); DbHelper.err += "Error f_build_sylov " + e.getMessage() + " " + e.fillInStackTrace(); e.printStackTrace(); } if (mApp.whatRun != -1 && DbHelper.err.length() == 0) { db.setTransactionSuccessful(); } db.endTransaction(); } private int f_getPeRows(int pe) { // возвращает число эл-тов для которых не найдена сил подгруппа когда силовские подгруппы только строятся return dbH.f_getCount("select count(*) as ccc from " + DbHelper.elements[vidWgrup] + " E " + " where E.pe = " + pe + " and E._id not in ( " + " select T.id_s from " + DbHelper.sylov_table[vidWgrup] + " T " + " where T.pe = " + pe + " );"); } private void f_sylPoiskLong(int pe, int degPe) { // строит и проверяет подгруппу по nIds p - элеиентам. nIds может быть 2, 2, 4 // после нахждения подгруппы остальные peCount находятся как сопряженные с ней // pe - д б силовской порядка degPe // /* CREATE TABLE temp_pe (_id INTEGER primary key autoincrement, pe INTEGER, id_1 INTEGER NOT NULL, id_2 INTEGER NOT NULL, id_s INTEGER, degs INTEGER, center_num INTEGER, list_num TEXT ) -- switchboard_n definition CREATE TABLE switchboard_n (_id INTEGER primary key autoincrement, id_switch INTEGER, id_pair INTEGER, id_left INTEGER NOT NULL, id_right INTEGER NOT NULL, txt_pair TEXT, txt_switch TEXT, work_field INTEGER ); -- elements_n definition CREATE TABLE elements_n (_id INTEGER primary key autoincrement, id_true INTEGER NOT NULL, name TEXT,substitution TEXT NOT NULL,ciklos TEXT,deg INTEGER, pairing_num INTEGER, sylow_num TEXT, primitiv TEXT, forming TEXT, switchboard_num INTEGER, center_num INTEGER, stabilizer TEXT,cykl_len TEXT,pe INTEGER, iteration INTEGER NOT NULL,parity INTEGER, nomer_soc INTEGER,for_n INTEGER, link_to_elements INTEGER ); insert into temp_pe (id_1, id_2, id_s, center_num, degs) select E._id, Y.id_s, S.id_left, S.id_left sopragau, 0 from sylov_id Y, switchboard S, elements E where Y.id_s = S.id_right and S.id_pair = E._id and E.pe = 2 order by S.id_left asc, E._id asc update temp_pe set degs = ( UPDATE temp_pe AS target set degs = ( select count(1) from temp_pe source where source.center_num = target.center_num ); select center_num, row_number() over (partition by center_num) from temp_pe order by center_num; select Y.pe pe, Y.num num1, N.num num2, S.id_left sopragau from ( select E._id, E.sylow_num, count( distinct S.id_left ) sopragau from sylov_id Y, switchboard S, elements E where Y.id_s = S.id_right and S.id_pair = E._id and E.pe = 2 " UPDATE temp_pe AS target\n" + " set degs = (\n" + "\t select count(1)\n" + "\t from temp_pe source\n" + "\t where source.center_num = target.center_num\n" + " );\n", CREATE TABLE sylov_table (_id INTEGER primary key autoincrement, pe INTEGER,num INTEGER, id_main INTEGER NOT NULL, id_s INTEGER NOT NULL, effort INTEGER, parity INTEGER, norm_nomer integer) CREATE TABLE elements (_id INTEGER primary key autoincrement, name TEXT,substitution TEXT NOT NULL,ciklos TEXT,deg INTEGER, pairing_num INTEGER, sylow_num TEXT, primitiv TEXT, forming TEXT, switchboard_num INTEGER, center_num INTEGER, stabilizer TEXT,cykl_len TEXT,pe INTEGER, iteration INTEGER NOT NULL,parity INTEGER, nomer_soc INTEGER) */ int numPeSub = 0; // № очередной p - подгруппы не обязательно силовской db.execSQL("delete from sylov_id;"); db.execSQL("UPDATE SQLITE_SEQUENCE SET SEQ=0 WHERE NAME='sylov_id';"); // db.execSQL("update " + DbHelper.elements[vidWgrup] + " set sylow_num = null where _id not in (" + // ????? // " select id_s from " + DbHelper.sylov_table[vidWgrup] + ");"); String sqlRead, sqlSel = "", sSel = "select ", sTab = " from ", sWhereNot = "", sWhereClass = ""; int k, n0, n1, nIds = 2; for (k =0; k < nIds; k++) { if (k > 0) { sSel += ", "; sTab += ", "; sWhereNot += " and "; if (k > 1) { sWhereClass += " and "; } sWhereClass += "EE" + (k -1) + ".pairing_num <= EE" + k + ".pairing_num " + " and EE" + (k - 1) + "._id < EE" + k + "._id "; } sSel += "EE" + k + "._id iddd" + k; sTab += " " + DbHelper.elements[vidWgrup] + " EE" + k + " "; sWhereNot += "EE" + k + ".pe = " + pe + " and EE" + k + ".sylow_num is null "; } sqlRead = sSel + " " + sTab + " " + " where " + sWhereNot + " and " + sWhereClass + " order by 1 asc, 2 asc;";; if (DISPLAYLOG) Log.d(TAG, "f_sylPoiskLong pe=" + pe + " nIds= " + nIds + " degPe = " + degPe + " sqlRead=" + sqlRead); /* select EE0._id iddd0, EE1._id iddd1 from elements EE0, pairing_area PP0, elements EE1, pairing_area PP1 where EE0.pe = 2 and EE0.sylow_num is null and PP0.id_subs = EE0._id and EE1.pe = 2 and EE1.sylow_num is null and PP1.id_subs = EE1._id and PP0.class_area <= PP1.class_area and EE0._id < EE1._id order by 1 asc, 2 asc; select EE0._id iddd0, EE1._id iddd1, EE2._id iddd2, EE3._id iddd3 from elements EE0, pairing_area PP0, elements EE1, pairing_area PP1, elements EE2, pairing_area PP2, elements EE3, pairing_area PP3 where EE0.pe = 2 and EE0.sylow_num is null and PP0.id_subs = EE0._id and EE1.pe = 2 and EE1.sylow_num is null and PP1.id_subs = EE1._id and EE2.pe = 2 and EE2.sylow_num is null and PP2.id_subs = EE2._id and EE3.pe = 2 and EE3.sylow_num is null and PP3.id_subs = EE3._id and PP0.class_area <= PP1.class_area and EE0._id < EE1._id and PP1.class_area <= PP2.class_area and EE1._id < EE2._id and PP2.class_area <= PP3.class_area and EE2._id < EE3._id order by 1 asc, 2 asc; */ Cursor cursorTestPe = db.rawQuery(sqlRead, null); cursorTestPe.moveToFirst(); int id1 [] = {0, 0, 0, 0, 0}, ind1 [] = new int[nIds]; for (k = 0; k < nIds; k++) ind1[k] = cursorTestPe.getColumnIndex("iddd" + k); if (cursorTestPe.getCount() > 0) { do { db.execSQL("delete from sylov_id;"); numPeSub++; // номер подгруппы for (k = 0; k < nIds; k++) { id1[k] = cursorTestPe.getInt(ind1[k]); // _id -ы p - элементов } for (k = 0; k < nIds; k++) // записываю все id по строкам в sylov_id db.execSQL("insert into sylov_id (id_s) " + "values (" + id1[k] + ");"); if (DISPLAYLOG) Log.e(TAG, "f_sylPoiskLong numPeSub = " + numPeSub + " pe= " + pe + " id1= " + id1[0] + ", "+ id1[1] + ", " + id1[2] + ", " + id1[3] + ", " + id1[4] ); // строим подгруппу n0 = 0; n1 = 1; while (n0 < n1 ) { n0 = dbH.f_getCount("select count(*) as ccc from sylov_id;"); sqlSel = "insert into sylov_id (id_s) " + " select distinct M.idproiz from " + DbHelper.temp_multiplication[vidWgrup] + " M " + " where " + " M.idleft in " + " (select id_s from sylov_id) and " + " M.idright in " + " (select id_s from sylov_id) and " + " M.idproiz not in " + " (select id_s from sylov_id);"; db.execSQL(sqlSel); n1 = dbH.f_getCount("select count(*) as ccc from sylov_id;"); if (n1 == degPe) { if (DISPLAYLOG) Log.d(TAG, "f_sylPoiskLong НАЙДЕНА pe=" + pe + " numPeSub = " + numPeSub + " n0= " + n0 + " n1 = " + n1); break; } } // подгруппа построена в sylov_id if (n1 == degPe) { if (f_sylTest( pe, 0, degPe, numPeSub) == 0) { // проверка прошла // проверка и запись найденной первой подгруппы прошла // 1-я подгруппа найдена // остальные ищу сопряжением: final String sqlSyl[] ={ "delete from temp_pe;", "insert into temp_pe (id_1, id_2, id_s, center_num, degs) " +// ЗАПИСЬ В temp_pe ВСЕХ КАНДИДАТОВ НА СИЛ ПОДГРУППУ - все сопряженные с найденной подгруппой " select E._id, Y.id_s, S.id_left, S.id_left sopragau, 0 " + // id_s = S.id_left - сопрягающий эл-нт, он должен сопрягать всю подгруппу = (degPe - 1) эл-тов ( - единица) " from sylov_id Y, " + DbHelper.switchboard[vidWgrup] + " S, " + DbHelper.elements[vidWgrup] + " E " + " where Y.id_s = S.id_right and S.id_pair = E._id and E.pe = " + pe + " order by S.id_left asc, E._id asc;", "select id_1 new_id, id_s from temp_pe order by id_s asc, id_1 asc;", // ВЫБОР НОВЫХ СИЛ ПОДГРУПП с _id = new_id ГДЕ ЧИСЛО ЭЛ-ТОВ = degPe - 1 "delete from sylov_id;", // отсюда забирается новая подгруппа на проверку f_sylTest() "insert into sylov_id (id_s) values (" + substitutionS.codEdinicy + ");" // запись единицы группы }; db.execSQL(sqlSyl[0]); db.execSQL(sqlSyl[1]); Cursor cursorsELsYL = db.rawQuery(sqlSyl[2], null); if (DISPLAYLOG) Log.d(TAG, "f_sylPoiskLong pe=" + pe + " numPeSub = " + numPeSub + " ПОИСК СОПРЯЖЕННЫХ " ); cursorsELsYL.moveToFirst(); int idSopr, idSpr = -1, elemCount = 0, idSopr_ = cursorsELsYL.getColumnIndex("id_s"); // сопрягающий эл-нт if (cursorsELsYL.getCount() > 0) { do { idSopr = cursorsELsYL.getInt(idSopr_); if (idSpr != idSopr) { if (idSpr > 0) { if (DISPLAYLOG) Log.d(TAG, "f_sylPoiskLong DO pe=" + pe + " numPeSub = " + numPeSub + " idSpr= " + idSpr + " elemCount= " + elemCount); if (elemCount == (degPe - 1)) { // считана подгруппа db.execSQL(sqlSyl[3]); db.execSQL(sqlSyl[4]); // записать единицу sqlSel = "insert into sylov_id (id_s) " + " select id_1 from temp_pe where id_s = " + idSpr + " order by id_1 asc;"; db.execSQL(sqlSel); if (f_sylTest( pe, -idSpr, degPe, numPeYes) == 0) { // проверка прошла if (DISPLAYLOG) Log.d(TAG, "f_sylPoiskLong ЕЩЕ pe=" + pe + " numPeYes = " + numPeYes + " idSpr= " + idSpr); if (f_getPeRows(pe) == 0) // // возвращает число эл-тов для которых не найдена сил подгруппа когда силовские подгруппы только строятся break; } } } idSpr = idSopr; elemCount = 0; } elemCount++; } while (cursorsELsYL.moveToNext()); } cursorsELsYL.close(); } // // проверка и запись найденной первой подгруппы прошла if (DISPLAYLOG) Log.d(TAG, "f_sylPoiskLong n1 == degPe pe=" + pe + " numPeYes = " + numPeYes + " nIds= " + nIds + " degPe = " + degPe + " n1=" + n1 ); } // if (n1 == degPe) if (numPeYes > 0) break; } while (cursorTestPe.moveToNext()); } cursorTestPe.close(); } private int f_sylowSow(int pe, int idMain, int degPe, int degMain, String sbsMain, int kSow) { // поиск сил подгрупп отсеиванием для pe и idMain // выход 0 - найдена подгруппа и записана а sylov_table // 1 не найдена - продолжить поиск // return 1; /* int j, jCount; // Log.d(TAG, "f_sylowSow pe=" + pe + " idMain= " + idMain + " degPe = " + degPe + " k=" + kSow + " sbsMain = " + sbsMain); // есть ли единица String sqlSel = "select id_s as ccc from sylov_id S where id_s = " + substitutionS.codEdinicy + "; "; jCount = dbH.f_getCountRow(sqlSel); if (jCount == 0) { // единица не выбрана - добавить sqlSel = "insert into sylov_id (id_s) values (" + substitutionS.codEdinicy + "); "; db.execSQL(sqlSel); // if (DISPLAYLOG) // Log.d(TAG, "f_sylowSow pe=" + pe + " idMain= " + idMain + " добавлена единица sqlSel=" + sqlSel); } String sqlCheck = "select id_s as ccc from sylov_id;"; jCount = dbH.f_getCountRow(sqlCheck); // число найденных элементов if (DISPLAYLOG) Log.d(TAG, "f_sylowSow pe=" + pe + " idMain= " + idMain + " число строк =" + jCount + " надо =" + degPe + " k=" + kSow + " sbsMain = " + sbsMain); if (jCount != degPe) { sqlSel = "delete from sylov_id where id_s in (" + "select distinct M.idright\n" + " from " + DbHelper.temp_multiplication[vidWgrup] + " M, sylov_id s\n" + "where M.idleft = " + idMain + " and " + " M.idright = S.id_s and " + " M.idproiz not in " + " (select id_s from sylov_id)); "; db.execSQL(sqlSel); // если теперь после удаления число строк > degPe - прекратить работу с этим pe jCount = dbH.f_getCountRow(sqlCheck); // число найденных элементов if (DISPLAYLOG) Log.d(TAG, "f_sylowSow pe=" + pe + " idMain= " + idMain + " число строк после delete =" + jCount + " надо =" + degPe + " k=" + kSow); if (jCount < degPe) { sqlSel = "insert into sylov_id (id_s) " + " select distinct M.idproiz from " + DbHelper.temp_multiplication[vidWgrup] + " M " + " where " + " M.idleft in " + " (select id_s from sylov_id) and " + " M.idright in " + " (select id_s from sylov_id) and " + " M.idproiz not in " + " (select id_s from sylov_id);"; db.execSQL(sqlSel); } if (jCount > degPe) { // удалить элементы кроме idMain со всеми степенями и имеющие малый централизатор // отмечаю все степени idMain (sbsMain) int[] mainArr = classSubs.f_toArray(sbsMain, DbHelper.faktSubsLen); // mainArr - массив точек int[] degArr, degWrk = Arrays.copyOf(mainArr, DbHelper.faktSubsLen); String newMain = sbsMain; for (j = 0; j < degMain; j++) { sqlSel = "update " + DbHelper.elements[vidWgrup] + " set primitiv = " + (j + 1) + " where substitution = '" + newMain + "'; "; // Log.d(TAG, "f_sylowSow jCount > degPe pe=" + pe + " idMain= " + idMain + " j = " + j + " sqlSel =" + sqlSel); db.execSQL(sqlSel); degArr = classSubs.f_mnoj(mainArr, degWrk); degWrk = Arrays.copyOf(degArr, DbHelper.faktSubsLen); newMain = classSubs.f_toStringSubs(degArr, DbHelper.faktSubsLen); // новая степень idMain } } } if (jCount == degPe) return f_sylTest( pe, idMain, degPe, kSow); // число найденных элементов в sylov_id = порядку сил подгруппы, проверка return 1; } private int f_sylTest(int pe, int idMain, int degPe, int kSow) { // проверка подгруппы в sylov_id и запись в sylov_table если проверка прошла // выход = 0 - проверка прошла int retSow = 1, i, j; // проверка на умножение - не выходим из подгруппы при умножении String sqlSel = "select M.idleft as ccc from " + DbHelper.temp_multiplication[vidWgrup] + " M, " + DbHelper.elements[vidWgrup] + " e " + "where M.idproiz = e._id and e.deg > 0 and " + " M.idleft in " + " (select id_s from sylov_id) and " + "M.idright in " + " (select id_s from sylov_id) and " + "M.idproiz not in " + " (select id_s from sylov_id); "; j = dbH.f_getCountRow(sqlSel); if (DISPLAYLOG) Log.e(TAG, "f_sylTest проверка pe=" + pe + " idMain= " + idMain + " cursorCeck.getCount=" + j + " надо 0" + " k=" + kSow); if (j == 0) { // проверка прошла - записать найденную подгруппу в sylov_table c новым номером // проверка надублирование подгруппы по спискам в pe_subgroup String testLst = ""; dbH.f_getMas("select id_s || ' ' as stext from sylov_id order by 1 asc;"); for (i = 0; i < DbHelper.selectedMas.length; i++) testLst += DbHelper.selectedMas[i]; i = dbH.f_getCountRow("select pe as ccc from pe_subgroup where list_ids = '" + testLst + "';"); if (DISPLAYLOG) Log.e(TAG, "f_sylTest pe=" + pe + " idMain= " + idMain + " i = " + i + " в списке подгрупп = " + testLst); if (i == 0) { // новая подгруппа sqlSel = "insert into " + DbHelper.sylov_table[vidWgrup] + " ( pe, num, id_main, id_s, effort) " + " select " + pe + ", " + DbHelper.curNumSylov + ", " + idMain + ", id_s, " + (MAX_LABOR_INTENSITY - kSow + 1) + " from sylov_id; "; db.execSQL(sqlSel); sqlSel = "insert into pe_subgroup ( pe, num, list_ids, count_element) " + " select " + pe + ", " + DbHelper.curNumSylov + ", '" + testLst + "'," + degPe + " from sylov_id limit 1; "; db.execSQL(sqlSel); if (DISPLAYLOG) { Log.e(TAG, "f_sylTest Подгруппа силова для простого " + pe + " состоит из " + degPe + " элементов, имеет номер " + DbHelper.curNumSylov + " sqlSel=" + sqlSel); mApp.putProt("Подгруппы силова для простого " + pe + " найдена по элементу с id=" + idMain + " состоит из " + degPe + " элементов, имеет номер " + DbHelper.curNumSylov); } DbHelper.curNumSylov++; // сквозная нумирация numPeYes++; // нумирация для pe if (! DbHelper.peSylCreate.contains(pe)) DbHelper.peSylCreate.add(pe); retSow = 0; } } return retSow; } private void f_sylovAbelev() { // построение силовских подгрупп для абелевой группы int i, pe; String sqlSel, zg = ""; db.beginTransaction(); try { for (i = 0; i < substitutionS.sylovPrimeGrupNum.size(); i++) { // цикл по простым числам из порядка группы pe = substitutionS.sylovPrimeGrupNum.get(i); sqlSel = "update " + DbHelper.elements[vidWgrup] + " set sylow_num = '" + DecFormat.format(DbHelper.curNumSylov) + "' " + " where pe = " + pe + ";"; db.execSQL(sqlSel); sqlSel = "insert into " + DbHelper.sylov_table[vidWgrup] + " ( pe, num, id_main, id_s) " + // записать единицу " values (" + pe + ", " + DbHelper.curNumSylov + ", 0," + substitutionS.codEdinicy + "); "; db.execSQL(sqlSel); if (zg.length() > 0) zg += ", "; zg += DecFormat.format(DbHelper.curNumSylov); DbHelper.curNumSylov++; DbHelper.peSylCreate.add(pe); } // здесь только одна силовская подгруппа (sylov_table.num - int, а elements.sylow_num - строка!!!!) sqlSel = "insert into " + DbHelper.sylov_table[vidWgrup] + " ( pe, num, id_main, id_s) " + " select pe, sylow_num, 0, _id from " + DbHelper.elements[vidWgrup] + " where not pe = 0; "; db.execSQL(sqlSel); // единица входит во все силовские подгруппы sqlSel = "update " + DbHelper.elements[vidWgrup] + " set sylow_num = '" + zg + "' " + " where _id = "+ substitutionS.codEdinicy + "; "; db.execSQL(sqlSel); if (DISPLAYLOG) Log.e(TAG, "f_sylovAbelev sqlSel= " + sqlSel + " k=" + DbHelper.curNumCommon ); f_saveSylov(); // сохранить в params, ищу общие подгруппы } catch (Exception e) { Log.e(TAG, "Error f_sylovAbelev " + e.getMessage() + " " + e.fillInStackTrace()); DbHelper.err += "Error f_sylovAbelev " + e.getMessage() + " " + e.fillInStackTrace(); e.printStackTrace(); } if (mApp.whatRun != -1 && DbHelper.err.length() == 0) { db.setTransactionSuccessful(); } db.endTransaction(); } private void f_saveSylov() { // сохранить инфу о сил подгруппах в params создание таблицы сопрягающих элементов и еще с общими подгр силовских подгрупп Calendar now = Calendar.getInstance(); String sdt = now.getTime().toString(); int i; final String suff = (vidWgrup == 0 ? "_g" : "_a"); // окончание параметра зависит от группы final String sqlSt[] = { "update " + DbHelper.sylov_table[vidWgrup] + " set parity = \n" + " (SELECT parity FROM " + DbHelper.elements[vidWgrup] + " WHERE " + DbHelper.elements[vidWgrup] + "._ID = " + DbHelper.sylov_table[vidWgrup] + ".id_s)\n" + " where " + DbHelper.sylov_table[vidWgrup] + ".id_s in (SELECT _id FROM " + DbHelper.elements[vidWgrup] + ")", // проставляю в switchboard.work_field = 0 - id_left и id_right четные подстановки, иначе 1 (вычисляю коммутант для подгруппы четных элементов) " update " + DbHelper.switchboard[vidWgrup] + " set work_field = 1; ", " update " + DbHelper.switchboard[vidWgrup] + " set work_field = 0\n" + " where \n" + " id_left in (select _id from " + DbHelper.elements[vidWgrup] + " where " + DbHelper.elements[vidWgrup] + ".parity = 0) and\n" + "id_right in (select _id from " + DbHelper.elements[vidWgrup] + " where " + DbHelper.elements[vidWgrup] + ".parity = 0);\n", "insert into params (parm, ind, val, val_txt) " + "select 'sylovcount" + suff + "', pe, count(_id), num from " + DbHelper.sylov_table[vidWgrup] + " group by pe, num; ", "insert into params (parm, ind, val) values ('curNumSylov" + suff + "', 0, " + DbHelper.curNumSylov + " ) ;", "insert into params (parm, ind, val) values ('countElements" + suff + "', 0, " + DbHelper.countElements + " ) ;", "insert into params (parm, ind, val) values ('countCentr" + suff + "', 0, " + DbHelper.countCentr + " ) ;", "insert into params (parm, ind, val) values ('countSwitch" + suff + "', 0, " + DbHelper.countSwitch + " ) ;", "insert into params (parm, ind, val_txt) values ('faktSubsLen" + suff + "', " + DbHelper.faktSubsLen + ", '" + sdt + "' ); ", "delete from " + DbHelper.sylov_common[vidWgrup] + ";", "delete from " + DbHelper.sylow_attachments[vidWgrup] + ";", "insert into " + DbHelper.sylov_common[vidWgrup] + " (pe, id_s, count_id, parity) " + // вся группа "select distinct pe, id_s, count(id_s), 0 from " + DbHelper.sylov_table[vidWgrup] + "\n" + "group by pe, id_s\n" + " HAVING count(id_s) > 1 " + "order by pe asc, id_s asc; ", "insert into " + DbHelper.sylov_common[vidWgrup] + " (pe, id_s, count_id, parity) " + // подгруппа четных элементов "select distinct pe, id_s, count(id_s), 1 from " + DbHelper.sylov_table[vidWgrup] + "\n" + " where parity = 1 " + "group by pe, id_s\n" + " HAVING count(id_s) > 1 " + "order by pe asc, id_s asc; ", // записать списки элементов общих подгрупп силова. sylow_zag - имя подгруппы - перечерь сил подгрупп "delete from " + DbHelper.sylov_com_grup[vidWgrup] + ";", "delete from " + DbHelper.sylow_conj[vidWgrup] + ";", // сопряжение силовских подгрупп "insert into " + DbHelper.sylow_conj[vidWgrup] + " (pe, num1, num2, id_conj, count_element)\n" + "select distinct S1.pe, S1.num, S2.num, W.id_left, count(S1.id_s) " + " from " + DbHelper.switchboard[vidWgrup] + " W, " + DbHelper.sylov_table[vidWgrup] + " s1, " + DbHelper.sylov_table[vidWgrup] + " s2\n" + " where S1.pe = S2.pe and not s1.num = S2.num and\n" + " W.id_right = S1.id_s and W.id_pair = S2.id_s\n" + "group by S1.pe, S1.num, S2.num, W.id_left\n" + "order by count(S1.id_s) desc, S1.pe asc, S1.num asc, S2.num asc, W.id_left asc;" }, // resech sqlRt[] = { "update elements_n set link_to_elements = null;", "update elements_n set link_to_elements = (\n" + "select _id from elements" + " where elements_n.ciklos = elements.ciklos);", "update sylov_table_n set num_resech = null, id_resech = null;", "update sylov_table_n set num_resech = (\n" + // номер подгруппы в sylov_table " select A.num from sylov_table A, elements AA, elements_n BB\n" + " where AA.ciklos = BB.ciklos and AA._id = A.id_s and BB.id_true = sylov_table_n.id_s);", "update sylov_table_n set id_resech = (\n" + // _id подстановки сил подгруппы созданной ргуппы (не Sn) " select distinct A.id_s from sylov_table A, elements AA, elements_n BB\n" + " where AA.ciklos = BB.ciklos and AA._id = A.id_s and BB.id_true = sylov_table_n.id_s " + ");" }; int pe, nUroven, // = nomer2 - длина заголовка - уровень вложенности подгруппы degPe, k, l, indPe, indS, indL, ns, np, indP; String sqlSel, sqlSylSv, subsC, sw, sq; if (vidWgrup == 0) { db.execSQL("delete from params where parm = 'Автоморфизмы';"); // автомор не построены db.execSQL("delete from params where substr(parm, length(parm) - 1) = '_g'"); db.execSQL("insert into params (parm, val_txt) values ('GroupName_g', '" + mApp.groupName + "' );"); // Log.e(TAG, "f_saveSylov vidWgrup = " + vidWgrup + " delete from params where substr(parm, length(parm) - 1) = '_g'" ); for (i = 0; i < sqlRt.length; i++) db.execSQL(sqlRt[i]); } else { // автоморфизмы db.execSQL("delete from params where substr(parm, length(parm) - 1) = '_a'"); // Log.e(TAG, "f_saveSylov vidWgrup = " + vidWgrup + " delete from params where substr(parm, length(parm) - 1) = '_a'" ); } // Log.e(TAG, "f_saveSylov vidWgrup = " + vidWgrup + " suff = " + suff + " DbHelper.faktSubsLen = " + DbHelper.faktSubsLen ); for (i = 0; i < sqlSt.length; i++) db.execSQL(sqlSt[i]); for (i = 0; i < DbHelper.peSylNoFound.size(); i++) // не найдены (не все найдены) сил подгруппы db.execSQL("insert into params (parm, ind, val_txt) values ('SylNoFound" + suff + "', "+ DbHelper.peSylNoFound.get(i) +", ' ' ); "); substitutionS.codEdinicy = dbH.f_getCount("select _id as ccc from " + DbHelper.elements[vidWgrup] + " where deg = 0;"); substitutionS.codEdinicy_n = dbH.f_getCount("select _id as ccc from elements_n where deg = 0;"); if (vidWgrup == 0) { // в sylov_table_n для id единиц не проставлен num_resech для единицы групп // строки дают соответствие вложенности подгрупп, они могут быть вложены в несколько подгрупп с разными частями sq = "select pe, num_s, num_p, max( ccc ) + 1 xxx from (\n" + " select S.pe pe, S.num num_s, S.num_resech num_p, count(S.id_resech) ccc\n" + " from sylov_table_n S\n" + " where not id_resech is null\n" + " group by S.pe, S.num, S.num_resech\n" + " order by S.pe, S.num_resech, count(S.id_resech) desc\n" + " )\n" + "where ccc > 1\n" + "group by pe, num_s, num_p\n" + "order by pe, num_s, max( ccc ) DESC;"; List<Integer> listS = new ArrayList<>(), listP = new ArrayList<>(); Cursor curResech = db.rawQuery(sq, null); curResech.moveToFirst(); if (curResech.getCount() > 0) { indPe = curResech.getColumnIndex("pe"); indS = curResech.getColumnIndex("num_s"); indP = curResech.getColumnIndex("num_p"); k = -1; do { pe = curResech.getInt(indPe); ns = curResech.getInt(indS); if (k != ns) { np = curResech.getInt(indP); if (DISPLAYLOG) Log.e(TAG, "f_savSylow pe= " + pe + " nomerS=" + ns + " nomerP=" + np); listS.add(ns); listP.add(np); k = ns; } } while (curResech.moveToNext()); } curResech.close(); // substitutionS.codEdinicy for (i = 0; i < listS.size(); i++) { sw = "update sylov_table_n set num_resech = " + listP.get(i) + " where num = " + listS.get(i) + " and id_s = " + substitutionS.codEdinicy_n + " and id_resech = " + substitutionS.codEdinicy + ";"; if (DISPLAYLOG) Log.e(TAG, "f_savSylow sw= " + sw); db.execSQL(sw); } } if (DbHelper.peSylNoFound.size() == 0) { // все сил построены! DbHelper.curNumCommon = 1; // заполнение sylov_com_grup - общие подгруппы подгрупп силова k = f_buildCommonSubs(1); // проверяем что это подруппы умножением for (i = 1; i <= k; i++) { dbH.f_testCommonSylov(i, true, 1); } mApp.putProt("Для силовских подгрупп построено " + k + " общих подгрупп"); // заполнение sylov_com_grup - общие подгруппы уровней > 1 i = 2; do { k = f_buildCommonSubs(i); if (DISPLAYLOG) Log.e(TAG, "f_saveSylov уровень " + i + " k=" + k); if (k < 2 || i > 12) break; mApp.putProt("Для общих подгрупп уровня " + i + " построено " + k + " общих подгрупп"); i++; } while (true); } // искать цоколь classNormSub classNorn = new classNormSub(); classNorn.init(mApp, dbH, vidWgrup); classNorn.f_soc(); // заполить таблицу sylow_attachments sqlSel = "select distinct nomer2, pe \n" + "from " + DbHelper.sylov_com_grup[vidWgrup] + " \n" + "order by pe asc, nomer2 asc;"; Cursor curSylCommGr = db.rawQuery(sqlSel, null); curSylCommGr.moveToFirst(); if (curSylCommGr.getCount() > 0) { indPe = curSylCommGr.getColumnIndex("pe"); indL = curSylCommGr.getColumnIndex("nomer2"); do { pe = curSylCommGr.getInt(indPe); l = curSylCommGr.getInt(indL); if (DISPLAYLOG) Log.e(TAG, "f_saveSylov sylow_attachments pe= " + pe + " nomer2=" + l + " "+ sqlSel ); if (l == 1) f_sylow_attachments( 0, 1, pe); else f_sylow_attachments( l - 1, l, pe); } while (curSylCommGr.moveToNext()); } curSylCommGr.close(); // вывод в протокол общих подгрупп String zag; sqlSylSv = "select count(*) as ccc, pe, nomer1, nomer2, sylow_zag from " + DbHelper.sylov_com_grup[vidWgrup] + "\n" + "group by pe, nomer1, nomer2, sylow_zag\n" + "order by pe, nomer1, nomer2, sylow_zag;"; curSylCommGr = db.rawQuery(sqlSylSv, null); curSylCommGr.moveToFirst(); if (curSylCommGr.getCount() > 0) { indPe = curSylCommGr.getColumnIndex("pe"); indS = curSylCommGr.getColumnIndex("sylow_zag"); indL = curSylCommGr.getColumnIndex("ccc"); int ind1 = curSylCommGr.getColumnIndex("nomer1"), ind2 = curSylCommGr.getColumnIndex("nomer2"), n1, n2; do { zag = curSylCommGr.getString(indS); pe = curSylCommGr.getInt(indPe); l = curSylCommGr.getInt(indL); n1 = curSylCommGr.getInt(ind1); n2 = curSylCommGr.getInt(ind2); mApp.putProt("Общая подгруппа № "+n1+ " силовских подгрупп " + zag + " p= " + pe + " уровеня "+ n2 + " имеет порядок " + l); if (DISPLAYLOG) Log.e(TAG, "f_saveSylov Общая подгруппа № "+n1+ " силовских подгрупп " + zag + " p= " + pe + " уровень "+ n2 + " порядка " + l); } while (curSylCommGr.moveToNext()); } curSylCommGr.close(); // запись в params for (i = 0; i < substitutionS.sylovPrimeGrupNum.size(); i++) { // цикл по простым числам из порядка группы pe = substitutionS.sylovPrimeGrupNum.get(i); degPe = 1; // ПОРЯДОК СИЛОВСКОЙ ПОДГРУППЫ for (nUroven = 0; nUroven < substitutionS.sylovPrimeGrupPower.get(i); nUroven++) degPe *= pe; // степень pe в порядке группы sqlSel = "delete from " + DbHelper.sylow_conj[vidWgrup] + " where pe = " + pe + " and not count_element = " + degPe + "; "; db.execSQL(sqlSel); // записать простые для силов подгрупп sqlSel = "insert into params (parm, ind, val) values ('sylovPrimeGrupNum" + suff + "', " + i + ", " + pe + " ) ;"; db.execSQL(sqlSel); } sqlSel = "insert into params (parm, ind, val, val_txt) values ('socGrupCount" + suff + "', 0, " + substitutionS.nomSocSub + ", '"+ substitutionS.sel2Multiplier + "' ) ;"; db.execSQL(sqlSel); if (vidWgrup == 0) db.execSQL("insert into params (parm, val_txt, val, ind) " + // признак = группа Sn " values ('Edinica_g', '"+ substitutionS.Edinica + "', 0, " + substitutionS.codEdinicy + " );"); else db.execSQL("insert into params (parm, val_txt, val, ind) " + // признак = группа Sn " values ('Edinica_a', '"+ substitutionS.Edinica + "', 0, " + substitutionS.codEdinicy + " );"); // ищу обратные элементы sqlSylSv = "select distinct E._id as _id, E.substitution as subs from " + DbHelper.elements[vidWgrup] + " E, " + DbHelper.sylow_conj[vidWgrup] + " S\n" + "where S.id_conj = E._id order by E._id asc; "; curSylCommGr = db.rawQuery(sqlSylSv, null); curSylCommGr.moveToFirst(); if (curSylCommGr.getCount() > 0) { int indId = curSylCommGr.getColumnIndex("_id"), idMain; indS = curSylCommGr.getColumnIndex("subs"); do { idMain = curSylCommGr.getInt(indId); subsC = classSubs.f_reverseSubstitution(curSylCommGr.getString(indS)); sqlSel = "update " + DbHelper.sylow_conj[vidWgrup] + " set id_reverse = (" + "select E._id from " + DbHelper.elements[vidWgrup] + " E where substitution = '" + subsC + "' " + ") where id_conj = " + idMain + ";"; db.execSQL(sqlSel); } while (curSylCommGr.moveToNext()); } curSylCommGr.close(); // число циклов длины = 3 pe = DbHelper.faktSubsLen * (DbHelper.faktSubsLen - 1) * (DbHelper.faktSubsLen - 2) / 3; // всего циклов длины 3 в знакопеременной группе i = dbH.f_getCount("select count(*) as ccc from " + DbHelper.elements[vidWgrup] + " where cykl_len = ' 3';"); if (DISPLAYLOG) Log.e(TAG, "f_saveSylov 1 всего циклов длины 3 " + pe + " найдено " + i); if (pe == i) { pe = 1; for (i = 3; i <= DbHelper.faktSubsLen; i++) pe *= i; // порядок знакопеременной группы if (pe == DbHelper.countElements) mApp.putProt("Группа есть знакопеременная группа на " + DbHelper.faktSubsLen + " элементах"); else mApp.putProt("Группа содержит знакопеременную группу на " + DbHelper.faktSubsLen + " элементах"); } i = dbH.f_getCount("select count(*) as ccc from " + DbHelper.elements[vidWgrup] + " where parity = 0;"); if (i == DbHelper.countElements) mApp.putProt("Группа содержится в знакопеременной группе, все подстановки четные"); else mApp.putProt("Подгруппа четных подстановок имеет порядок " + i ); // проверка группы на совпадение с Sn sqlSel = "(" + substitutionS.Edinica.replaceFirst("]", ")").substring(1); i = dbH.f_getCount("select count(_id) as ccc from " + DbHelper.elements[vidWgrup] + "\n" + " where ciklos = '"+ sqlSel + "';"); k = dbH.f_getCount("select count(_id) as ccc from " + DbHelper.elements[vidWgrup] + "\n" + " where ciklos = '(1, 2)';"); if (i > 0 && k > 0) { mApp.putProt("Группа является полной симметрической группой степени " + DbHelper.faktSubsLen); db.execSQL("insert into params (parm, val_txt, val, ind) " + // признак = группа Sn " values ('SnYes"+ suff + "', 'Группа Sn', 1," + vidWgrup + " );"); } } private int f_buildCommonSubs( int newLevel) { // заполнение sylov_com_grup - общие подгруппы подгрупп (силова при newLevel = 1 или более высокого уровня newLevel > 1) String sqlSel, sqlSylCm, fromTable, whereNum, where2 = ""; int indPe, indS, indL, pe, pe0, l, l0, nUroven = 0, i, kNum = 1; // nomer1 = номер подгруппы, нумирация сквозная по уровням String wwT, wwNum, wwIds, zag; Cursor curSylConj; /* выбирает по 1 строке на каждый заголовок подгруппы в elements записан sylow_num = в какие силовские подгруппы входит этот элемент чем больше силовских подгрупп образуют общую подгруппу - тем больше уровень общей подгруппы выбираю списки сил подгрупп в порядке возрастания их числа (zag), создаю их список - urovPodgr создаю select sqlSyl для выбора общих элементов для всех сил подгрупп из списка и записа в sylov_com_grup */ if (newLevel == 1) { // выбор из силовских подгрупп sqlSel = "select distinct S.pe as pe, M.sylow_num as sylow_num, length(M.sylow_num) as el\n" + "from " + DbHelper.sylov_table[vidWgrup] + " S, " + DbHelper.elements[vidWgrup] + " M\n" + "where M._id = S.id_s\n" + "and instr(M.sylow_num, ',') > 0 and not M.deg = 0\n" + "order by S.pe asc, el asc;"; fromTable = DbHelper.sylov_table[vidWgrup]; whereNum = "num"; } else { // заполнение temp_pe строим заголовок подгруппы list_num db.execSQL("delete from temp_pe;"); boolean haveGr = false; // true - есть общие подгруппы sqlSel = "select distinct C.pe as pe, C.nomer1 as num, C.id_s as id_s \n" + " from " + DbHelper.sylov_com_grup[vidWgrup] + " C " + " where C.nomer2 = " + (newLevel - 1) + " order by C.id_s asc, C.pe asc, C.nomer1 asc;"; curSylConj = db.rawQuery(sqlSel, null); curSylConj.moveToFirst(); if (curSylConj.getCount() > 0) { indS = curSylConj.getColumnIndex("num"); indL = curSylConj.getColumnIndex("id_s"); indPe = curSylConj.getColumnIndex("pe"); zag = ""; pe0 = l0 = 0; do { i = curSylConj.getInt(indS); // num l = curSylConj.getInt(indL); // id_s pe = curSylConj.getInt(indPe); if (l0 != l || pe != pe0) { // записать temp_pe if (zag.contains(",") && l0 != substitutionS.codEdinicy) { sqlSylCm = "insert into temp_pe (id_s, list_num, pe, id_1, id_2) values (" + l0 + ", '" + zag + "', "+ pe0 + ", " + newLevel + ", 0) ;"; db.execSQL(sqlSylCm); if (DISPLAYLOG) Log.e(TAG, "f_buildCommonSubs pe= " + pe0 + " k=" + DbHelper.curNumCommon + " nUroven=" + nUroven + " l=" + l + " l0=" + l0 + " zag=" + zag + " ssqlSyl= "+ sqlSylCm); } zag = ""; l0 = l; // id_s pe0 = pe; } if (zag.length() > 0) { zag += (", " + DecFormat.format(i)); haveGr = true; } else zag = DecFormat.format(i); if (DISPLAYLOG) Log.e(TAG, "f_buildCommonSubs pe= " + pe + " k=" + DbHelper.curNumCommon + " j=" + nUroven + " l=" + l + " l0=" + l0 + " zag=" + zag + " sqlSel= "+ sqlSel); if (myExecutor.MyThread.isCancel || DbHelper.err.length() > 0) { DbHelper.err += "\n Расчет прерван"; break; } } while (curSylConj.moveToNext()); if (zag.contains(",") && l0 != substitutionS.codEdinicy) { db.execSQL("insert into temp_pe (id_s, list_num, pe, id_1, id_2) values (" + l0 + ", '" + zag + "', "+ pe0 + ", " + newLevel + ", 0) ;"); } } curSylConj.close(); if (!haveGr) return 0; // не найдено подгрупп sqlSel = "select distinct S.pe as pe, S.list_num as sylow_num, length(S.list_num) as el\n" + "from temp_pe S\n" + "where instr(S.list_num, ',') > 0 \n" + "order by S.pe asc, el asc;"; fromTable = DbHelper.sylov_com_grup[vidWgrup]; // используется для уровней > 1 whereNum = "nomer1"; } pe0 = l0 = 0; curSylConj = db.rawQuery(sqlSel, null); curSylConj.moveToFirst(); if (curSylConj.getCount() > 0) { indPe = curSylConj.getColumnIndex("pe"); indS = curSylConj.getColumnIndex("sylow_num"); indL = curSylConj.getColumnIndex("el"); do { zag = curSylConj.getString(indS); pe = curSylConj.getInt(indPe); l = curSylConj.getInt(indL); if (l != l0) nUroven++; // if (pe0 == 0) pe0 = pe; if (pe != pe0) { nUroven = 1; } if (nUroven > 1) continue; wwT = wwNum = wwIds = ""; String numsGr[] = zag.split(","); // номера подгрупп силова /* строю запрос в виде: insert into sylov_com_grup (pe, sylow_zag, id_s, nomer1, nomer2) select E0.id_s from sylov_table E0, sylov_table E1, sylov_table E2, sylov_table E3 (wwT) where E0.num = 082 and E1.num = 083 and E2.num = 084 and E3.num = 085 and (wwNum) E0.id_s = E1.id_s and E0.id_s = E2.id_s and E0.id_s = E3.id_s (wwIds) ИЛИ ДЛЯ УРОВНЯ > 1 insert into sylov_com_grup (pe, sylow_zag, id_s, nomer1, nomer2) select E0.id_s from sylov_com_grup E0, sylov_table E1, sylov_table E2, sylov_table E3 (wwT) where E0.nomer1 = 082 and E1.nomer1 = 083 and E2.nomer1 = 084 and E3.nomer1 = 085 and (wwNum) E0.id_s = E1.id_s and E0.id_s = E2.id_s and E0.id_s = E3.id_s (wwIds) AND E0.nomer2 = newLevel - 1 AND ... */ sqlSylCm = "insert into " + DbHelper.sylov_com_grup[vidWgrup] + " (pe, sylow_zag, id_s, nomer1, nomer2) \n"+ " select "+pe+ ", '"+ zag + "', E0.id_s, "+ DbHelper.curNumCommon + ", "+ newLevel +" from "; for (i=0; i<numsGr.length; i++ ) { if (DISPLAYLOG) Log.e(TAG, "f_buildCommonSubs newLevel= " + newLevel + " pe= " + pe + " i=" + i + " nUroven=" + nUroven + " zag=" + zag + " numsGr=" + numsGr.length ); if (wwT.length() > 0) wwT += ", "; wwT += fromTable + " E" + i; if (wwNum.length() == 0) wwNum = "E0." + whereNum + " = " + numsGr[0]; else wwNum += " and E" + i + "."+ whereNum + " = " + numsGr[i]; if (i > 0) wwIds += " and E0.id_s = E" + i + ".id_s "; if (i == 0) where2 = " and E0.nomer2 = " + (newLevel - 1); else where2 += " and E" + i + ".nomer2 = " + (newLevel - 1); } if ( newLevel == 1) sqlSylCm += wwT + "\n where " + wwNum + "\n" + wwIds + ";"; else sqlSylCm += wwT + "\n where " + wwNum + "\n" + wwIds + "\n" + where2 + ";"; if (DISPLAYLOG) Log.e(TAG, "f_buildCommonSubs pe= " + pe + " k=" + DbHelper.curNumCommon + " j=" + nUroven + " l=" + l + " l0=" + l0 + " zag=" + zag + " "+ sqlSylCm ); db.execSQL(sqlSylCm); // mApp.putProt("Общая подгруппа № "+curNumCommon+ " силовских подгрупп " + zag + " p= " + pe + " уровень "+ newLevel); DbHelper.curNumCommon++; kNum++; l0 = l; if (myExecutor.MyThread.isCancel || DbHelper.err.length() > 0) { DbHelper.err += "\n Расчет прерван"; break; } } while (curSylConj.moveToNext()); } curSylConj.close(); return kNum - 1; // число построенных подгрупп } private void f_sylow_attachments(int urMain, int urSub, int pe) { // заполнение sylow_attachments - в какие подгруппы уровня urMain входит подгруппы уровня urSub // при urMain == 0 - уровень силовских подгрупп, связь устанавливается только для полного включения подгруппы String sqlIns; int att_index = 1, ordMain, nomSub, nomMain, ordSub; // порядок подгруппы: nomSub = dbH.f_getCount("select K.nomer1 as ccc from " + DbHelper.sylov_com_grup[vidWgrup] + " K\n" + " where K.pe = " + pe + " and K.nomer2 = "+ urSub + " limit 1; "); ordSub = dbH.f_getCount("select count(*) as ccc from " + DbHelper.sylov_com_grup[vidWgrup] + " G\n" + "where G.pe = "+ pe + " and G.nomer2 = "+ urSub + " and \n" + " nomer1 = "+ nomSub + ";"); // порядок основной подг: att_index if (urMain > 0) { nomMain = dbH.f_getCount("select K.nomer1 as ccc from " + DbHelper.sylov_com_grup[vidWgrup] + " K\n" + " where K.pe = " + pe + " and K.nomer2 = "+ urMain + " limit 1; "); ordMain = dbH.f_getCount("select count(*) as ccc from " + DbHelper.sylov_com_grup[vidWgrup] + " G\n" + "where G.pe = " + pe + " and G.nomer2 = " + urMain + " and \n" + " nomer1 = " + nomMain + "; "); } else { nomMain = dbH.f_getCount("select K.num as ccc from " + DbHelper.sylov_table[vidWgrup] + " K\n" + " where K.pe = " + pe + " limit 1; "); ordMain = dbH.f_getCount("select count(*) as ccc from " + DbHelper.sylov_table[vidWgrup] + " G\n" + "where G.pe = " + pe + " and \n" + " num = "+ nomMain + "; "); } if (ordSub > 0) att_index = ordMain / ordSub; // индека подгруппы if (urMain == 0) sqlIns = "insert into " + DbHelper.sylow_attachments[vidWgrup] + " (main_lelel, att_level, pe, mail_num, att_num, att_order, att_index)\n" + "select 0, 1, "+ pe + ", S.num, C.nomer1, count(C.id_s), "+ att_index + "\n" + "from " + DbHelper.sylov_table[vidWgrup] + " S, " + DbHelper.sylov_com_grup[vidWgrup] + " C\n" + "where C.id_s = S.id_s and C.nomer2 = 1 and S.pe = C.pe and S.pe = "+ pe + "\n" + "group by S.num, C.nomer1\n" + "order by S.num, C.nomer1; "; else sqlIns = "insert into " + DbHelper.sylow_attachments[vidWgrup] + " (main_lelel, att_level, pe, mail_num, att_num, att_order, att_index)\n" + "select " + urMain + ", "+ urSub + ", " + pe + ", S.nomer1, C.nomer1, count(C.id_s), "+ att_index + "\n" + "from " + DbHelper.sylov_com_grup[vidWgrup] + " S, " + DbHelper.sylov_com_grup[vidWgrup] + " C\n" + "where C.id_s = S.id_s and C.nomer2 = "+ urSub + " and S.nomer2 = "+ urMain + " and S.pe = C.pe and S.pe = "+ pe + "\n" + "group by S.nomer1, C.nomer1\n" + "order by S.nomer1, C.nomer1;"; db.execSQL(sqlIns); db.execSQL("delete from " + DbHelper.sylow_attachments[vidWgrup] + " where att_order = 1;"); // удалить все, кроме полного включения подгруппы // db.execSQL("delete from sylow_attachments where " + // "att_level = "+ urSub + " and main_lelel = "+ urMain + " and pe = "+ pe + " and not att_order = "+ ordSub +"; "); } //------------------ эпиморфизм ---------------------- public void f_generateSylEpi() { // эпиморфизм на группу подстановок на силовских подгруппах // заполнение таблиц epimorphism, accordance // только для vidWgrup = 0 int pe, pe0 = 0, i, i1, i2 = 0, id, id0, maxLen = 0, posCurStart, posCurEnd; int indId, indN1, indN2, indPe; int[] iEpi = {1, 2}; String sqlEpi, sabs, sabs0 = "0"; final String sqlStmt [] = {"delete from sylow_tmp_conj;", "UPDATE SQLITE_SEQUENCE SET SEQ=0 WHERE NAME='sylow_tmp_conj';", "delete from " + DbHelper.epimorphism[vidWgrup] + "; ", "UPDATE SQLITE_SEQUENCE SET SEQ=0 WHERE NAME='" + DbHelper.epimorphism[vidWgrup] + "';", "delete from " + DbHelper.accordance[vidWgrup] + "; ", "UPDATE SQLITE_SEQUENCE SET SEQ=0 WHERE NAME='" + DbHelper.accordance[vidWgrup] + "';" }; classSubs.f_createPrimeryNumber(DbHelper.countElements); substitutionS.epiEdinica.clear(); substitutionS.epiPe.clear(); for (i = 0; i < sqlStmt.length; i++) db.execSQL(sqlStmt[i]); Cursor curSylCommGr; db.beginTransaction(); try { /* sylow_conj перепишу в sylow_tmp_conj с перенумирациец силовских подгрупп как 1,2,3... для каждого pe строится массив старых нумеров arrEpi, курсор возвращается к началу этого pe и все строки по pe переписываются в sylow_tmp_conj потом продолжается работа со след pe */ List<Integer> arrEpi = new ArrayList<>(); // считаннаы номера для одного pe sqlEpi = "select pe, num1, num2, id_conj from " + DbHelper.sylow_conj[vidWgrup] + " order by pe asc, num1 asc;"; curSylCommGr = db.rawQuery(sqlEpi, null); curSylCommGr.moveToFirst(); if (curSylCommGr.getCount() > 0) { indId = curSylCommGr.getColumnIndex("id_conj"); indN1 = curSylCommGr.getColumnIndex("num1"); indN2 = curSylCommGr.getColumnIndex("num2"); indPe = curSylCommGr.getColumnIndex("pe"); posCurStart = curSylCommGr.getPosition(); // начало нового pe do { pe = curSylCommGr.getInt(indPe); i1 = curSylCommGr.getInt(indN1); if (pe != pe0) { if (pe0 > 0) { substitutionS.epiPe.add(pe0); arrEpi.add(i2); posCurEnd = curSylCommGr.getPosition(); // начало нового pe f_epiDopisat(posCurStart, posCurEnd, arrEpi, curSylCommGr, indId, indN1, indN2, indPe); posCurStart = posCurEnd; curSylCommGr.moveToPosition(posCurEnd); } pe0 = pe; arrEpi.clear(); // arrEpi.add(i1); i2 = 0; } if (i1 != i2) { if (i2 > 0) arrEpi.add(i2); i2 = i1; } } while (curSylCommGr.moveToNext()); posCurEnd = curSylCommGr.getCount(); arrEpi.add(i1); f_epiDopisat(posCurStart, posCurEnd, arrEpi, curSylCommGr, indId, indN1, indN2, indPe); substitutionS.epiPe.add(pe0); } curSylCommGr.close(); // создание таблицы epimorphism sqlEpi = "select num1, num2, id_conj, pe \n" + " from sylow_tmp_conj\n" + " order by pe asc, id_conj asc, num1 asc;"; pe0 = id0 = -1; curSylCommGr = db.rawQuery(sqlEpi, null); curSylCommGr.moveToFirst(); if (curSylCommGr.getCount() > 0) { indId = curSylCommGr.getColumnIndex("id_conj"); indN1 = curSylCommGr.getColumnIndex("num1"); indN2 = curSylCommGr.getColumnIndex("num2"); indPe = curSylCommGr.getColumnIndex("pe"); do { pe = curSylCommGr.getInt(indPe); i1 = curSylCommGr.getInt(indN1); i2 = curSylCommGr.getInt(indN2); id = curSylCommGr.getInt(indId); if (id != id0 || pe != pe0) { if (id0 > 0) f_epaOut(pe0, maxLen, id0, iEpi); // ====== id0 = id; if (pe != pe0) { if (pe0 > 0) { // если для _id нет записи в sylow_conj - этот _id переходит в 1, вставит такие единичные строки в epimorphism f_epaReplenishment(pe0, maxLen); // вставить такие единичные строки в epimorphism } maxLen = dbH.f_getCount("select count( distinct num1) as ccc from sylow_tmp_conj where pe = " + pe + ";"); iEpi = new int[maxLen]; pe0 = pe; mApp.putProt("Построение гомоморфизма на группу подстановок силовских подгрупп для P=" + pe); } for (i = 0; i < maxLen; i++) iEpi[i] = i + 1; } if (DISPLAYLOG) Log.e(TAG, "f_generateSylEpi pe=" + pe + " pe0 = " + pe0 + " i1=" + i1 + " i2=" + i2 + " maxLen= " + maxLen + " Id=" + id); iEpi[i1 - 1] = i2; if (myExecutor.MyThread.isCancel || DbHelper.err.length() > 0) { DbHelper.err += "\n Расчет прерван"; break; } } while (curSylCommGr.moveToNext()); curSylCommGr.close(); if (id0 > 0) { f_epaOut(pe0, maxLen, id0, iEpi); // если для _id нет записи в sylow_tmp_conj - этот _id переходит в 1, вставит такие единичные строки в epimorphism f_epaReplenishment(pe0, maxLen); } // заполнить в epimorphism id_obraz = id образа, заполняется только для уникального элемента образа (Они повторяются согласно смежным классам по ядру) db.execSQL("delete from temp_sylow; "); // записываю сюда Id не повторяющихся строк (substitution) из epimorphism curSylCommGr = db.rawQuery("select id_element, pe, substitution from " + DbHelper.epimorphism[vidWgrup] + "\n" + "order by pe asc, substitution asc;", null); curSylCommGr.moveToFirst(); pe0 = 0; if (curSylCommGr.getCount() > 0) { indId = curSylCommGr.getColumnIndex("id_element"); indN1 = curSylCommGr.getColumnIndex("substitution"); indPe = curSylCommGr.getColumnIndex("pe"); do { pe = curSylCommGr.getInt(indPe); sabs = curSylCommGr.getString(indN1); i2 = curSylCommGr.getInt(indId); if (pe != pe0 | !sabs.equals(sabs0)) { db.execSQL("insert into temp_sylow (pe, idleft, idright, txt) values (" + pe + "," + i2 + "," + i2 + ", '" + sabs + "' );"); } pe0 = pe; sabs0 = sabs; } while (curSylCommGr.moveToNext()); } curSylCommGr.close(); db.execSQL("update " + DbHelper.epimorphism[vidWgrup] + " set id_obraz = " + " (select T.idleft from temp_sylow T where T.pe = " + DbHelper.epimorphism[vidWgrup] + ".pe and " + DbHelper.epimorphism[vidWgrup] + ".id_element = T.idleft);"); // заполнить adjacent - номер смежного класса, нумируются как придется curSylCommGr = db.rawQuery("select pe, txt from temp_sylow\n" + "order by pe asc, txt asc;", null); curSylCommGr.moveToFirst(); sabs0 = "0"; pe0 = i1 = 0; if (curSylCommGr.getCount() > 0) { indN1 = curSylCommGr.getColumnIndex("txt"); indPe = curSylCommGr.getColumnIndex("pe"); do { pe = curSylCommGr.getInt(indPe); sabs = curSylCommGr.getString(indN1); if (pe != pe0 | (! sabs.equals(sabs0))) { if (pe != pe0) i1 = 1; else i1++; pe0 = pe; sabs0 = sabs; } db.execSQL("update " + DbHelper.epimorphism[vidWgrup] + " set adjacent = " + i1 + " where substitution = '" + sabs + "';"); } while (curSylCommGr.moveToNext()); } } curSylCommGr.close(); // таблица соответствия номеров силовских подгрупп // pe из sylow_conj соответствует типу сил подгрупп в основной группе, не зависит от pe гомоморфизма db.execSQL("insert into " + DbHelper.accordance[vidWgrup] + " (pe, num_old, num) " + "select distinct pe, num_old1, num1 from sylow_tmp_conj\n" + "order by pe asc, num_old1 asc;" ); db.execSQL("delete from params where parm ='EpiMorfizm" + (vidWgrup == 0 ? "_g" : "_a") + "';"); // Log.e(TAG, "EpiMorfizm vidWgrup = " + vidWgrup ); for (i = 0; i < substitutionS.epiPe.size(); i++) { pe = substitutionS.epiPe.get(i); i1 = dbH.f_getCount(" select count(distinct id_obraz) as ccc from " + DbHelper.epimorphism[vidWgrup] + " where id_obraz > 0 and pe = " + pe + ";"); // ?????? mApp.putProt("Образ гомоморфизмов для P = " + substitutionS.epiPe.get(i) + " имеет порядок " + i1 + ", ядро имеет порядок " + (DbHelper.countElements / i1)); db.execSQL("insert into params (parm, ind, val, val_txt) values ('EpiMorfizm" + (vidWgrup == 0 ? "_g" : "_a") + "', " + pe + ", " + i1 + ", '" + pe + "' ) ;"); // заполнить поле soc_list.epi_pe - подгруппы ядра эпиморфизмов i1 = dbH.f_getMas("select distinct M.class_area || '' as stext from pairing_area M, " + DbHelper.epimorphism[vidWgrup] + " F\n" + " where M.id_subs = F.id_element and F.pe = " + pe + " and F.deg = 0" + " order by M.class_area asc; "); // selectedMas[] = все классы группы ядра sabs = " "; for (int j=0; j < i1; j++) sabs += " " + DbHelper.selectedMas[j] + ", "; // sostav для soc_list db.execSQL("update " + DbHelper.soc_list[vidWgrup] + " set epi_pe = " + pe + " where sostav = '" + sabs + "';" ); } if (substitutionS.epiPe.size() > 0) mApp.putProt("Построение гомоморфизмов закончено"); else mApp.putProt("Для всех простых P гомоморфизм отображает всю группу в 1"); /* построение таблицы subgrups - найденных подгрупп */ db.execSQL("DROP TABLE IF EXISTS " + DbHelper.subgrups[vidWgrup] + "") ; String sqlCreate = "CREATE TABLE IF NOT EXISTS " + DbHelper.subgrups[vidWgrup] + " (\n" + " id_element INTEGER NOT NULL, \n" + // код элемента = _id elements " flag_parity INTEGER, \n" + " flag_commutant INTEGER, \n" + " flag_zentr INTEGER, \n"; List<Integer> peDist = dbH.f_getPeDistinct(false); // все простые по одному экземпляру // Log.e(TAG, "peDist substitutionS.sylovOrderPe.= " + substitutionS.sylovOrderPe.size() + " p=" + peDist.size()); for (i = 0; i<DbHelper.faktSubsLen; i++) sqlCreate += "flag_stab_"+(i+1) + " INTEGER,\n"; // 1 - стабилизатор для i+1 for (i = 0; i<substitutionS.epiPe.size(); i++) // ядра sqlCreate += "flag_ker_" + substitutionS.epiPe.get(i) + " INTEGER,\n"; // 1 - принадлежит ядру эпиморфизма на силовскую подгруппу substitutionS.epiPe.get(i-1) for (i = 0; i<peDist.size(); i++) { // силовские подгруппы i2 = dbH.f_getMas("select distinct 'n = '||num as stext from " + DbHelper.sylov_table[vidWgrup] + " where pe = "+peDist.get(i) + " order by num;"); for (i1 = 0; i1 < i2; i1++) { sqlCreate += "flag_sylow_" + peDist.get(i) + "_"+ DbHelper.selectedMas[i1].substring(4) + " INTEGER,\n"; // 1 - принадлежит силовской подгруппе № N для P= peDist.get(i-1) } // Log.e(TAG, "peDist i= " + i + " p=" + peDist.get(i)); } // общие силов подгр // колонка flag_CommU_X_Y - есть: U=уровень общ подгруппы,X= номер простого числа, Y= номер подгруппы List<Integer> peCom1 = dbH.f_getPeCommon(1, false); // уровня 1 List<Integer> peCom2 = dbH.f_getPeCommon(2, false); // уровня 2 for (i = 0; i<peCom1.size(); i++) { // общие силовские подгруппы уровня 1 i2 = dbH.f_getMas("select distinct 'n = '||nomer1 as stext from " + DbHelper.sylov_com_grup[vidWgrup] + " where pe = "+peCom1.get(i) + " and nomer2 = 1 order by 1;"); for (i1 = 0; i1 < i2; i1++) { sqlCreate += "flag_Comm1_" + peCom1.get(i) + "_"+ DbHelper.selectedMas[i1].substring(4) + " INTEGER,\n"; // 1 - принадлежит силовской подгруппе № N для P= } // Log.e(TAG, "peDist i= " + i + " p=" + peDist.get(i)); } for (i = 0; i<peCom2.size(); i++) { // общие силовские подгруппы уровня 2 i2 = dbH.f_getMas("select distinct 'n = '||nomer1 as stext from " + DbHelper.sylov_com_grup[vidWgrup] + " where pe = "+peCom2.get(i) + " and nomer2 = 2 order by 1;"); for (i1 = 0; i1 < i2; i1++) { sqlCreate += "flag_Comm2_" + peCom2.get(i) + "_"+ DbHelper.selectedMas[i1].substring(4) + " INTEGER,\n"; // 1 - принадлежит силовской подгруппе № N для P= } // Log.e(TAG, "peDist i= " + i + " p=" + peDist.get(i)); } if (substitutionS.nomSocSub > 0) { sqlCreate += "flag_socol INTEGER,\n"; // 1 - принадлежит цоколю for (i = 0; i < substitutionS.nomSocSub -1; i++) { sqlCreate += "flag_soc_" + (i + 1) + " INTEGER,\n"; // 1 - принадлежит подгруппе цоколя № N } } sqlCreate += " _id INTEGER primary key autoincrement); "; db.execSQL(sqlCreate); // создать таблицу // Log.e(TAG, "peDist sqlCreate= " + sqlCreate); final String sql0 [] = { "insert into " + DbHelper.subgrups[vidWgrup] + " (id_element, flag_parity, flag_commutant) " + " select _id, parity+1, switchboard_num from " + DbHelper.elements[vidWgrup] + "; ", "update " + DbHelper.subgrups[vidWgrup] + " set flag_parity = null where flag_parity = 2; ", "update " + DbHelper.subgrups[vidWgrup] + " set flag_commutant = null where flag_commutant = 0; ", "update " + DbHelper.subgrups[vidWgrup] + " set flag_zentr = 1 where id_element in " + " (select _id from " + DbHelper.elements[vidWgrup] + " where center_num = " + DbHelper.countElements + "); " }; for (i=0; i < sql0.length; i++) db.execSQL( sql0[i] ) ; if (substitutionS.nomSocSub > 0) { db.execSQL("update " + DbHelper.subgrups[vidWgrup] + " set flag_socol = 1 where id_element in " + " (select _id from " + DbHelper.elements[vidWgrup] + " where nomer_soc > 0); " ); for (i = 0; i < substitutionS.nomSocSub -1; i++) { db.execSQL("update " + DbHelper.subgrups[vidWgrup] + " set flag_soc_" + (i + 1) + " = 1 where id_element in " + " (select _id from " + DbHelper.elements[vidWgrup] + " where nomer_soc = " + (i + 1) + " or _id = " + substitutionS.codEdinicy + "); " ); } } for (i = 0; i<DbHelper.faktSubsLen; i++) { sqlCreate = "update " + DbHelper.subgrups[vidWgrup] + " set flag_stab_"+(i+1) + " = 1 where id_element in " + " (select _id from " + DbHelper.elements[vidWgrup] + " where instr(' '||stabilizer, ' "+ (i+1) + "') >0);"; db.execSQL(sqlCreate); } for (i = 0; i<substitutionS.epiPe.size(); i++) db.execSQL("update " + DbHelper.subgrups[vidWgrup] + " set flag_ker_" + substitutionS.epiPe.get(i) + " = 1 where id_element in " + " (select id_element from " + DbHelper.epimorphism[vidWgrup] + " where pe = "+substitutionS.epiPe.get(i) + " and deg = 0); " ) ; for (i = 0; i<peDist.size(); i++) { i2 = dbH.f_getMas("select distinct 'n = '||num as stext from " + DbHelper.sylov_table[vidWgrup] + " where pe = "+peDist.get(i) + " order by num;"); for (i1 = 0; i1 < i2; i1++) { db.execSQL("update " + DbHelper.subgrups[vidWgrup] + " set flag_sylow_" + peDist.get(i) + "_"+ DbHelper.selectedMas[i1].substring(4) + " = 1 where id_element in " + " (select id_s from " + DbHelper.sylov_table[vidWgrup] + " where pe = "+peDist.get(i) + " and num = "+ DbHelper.selectedMas[i1].substring(4) + "); " ) ; } } for (i = 0; i<peCom1.size(); i++) { // общие силовские подгруппы уровня 1 i2 = dbH.f_getMas("select distinct 'n = '||nomer1 as stext from " + DbHelper.sylov_com_grup[vidWgrup] + " where pe = "+peCom1.get(i) + " and nomer2 = 1 order by 1;"); for (i1 = 0; i1 < i2; i1++) { db.execSQL("update " + DbHelper.subgrups[vidWgrup] + " set flag_Comm1_" + peCom1.get(i) + "_"+ DbHelper.selectedMas[i1].substring(4) + " = 1 where id_element in " + " (select id_s from " + DbHelper.sylov_com_grup[vidWgrup] + " where pe = "+peCom1.get(i) + " and nomer1 = "+ DbHelper.selectedMas[i1].substring(4) + " and nomer2 = 1 ); " ) ; } // Log.e(TAG, "peDist i= " + i + " p=" + peDist.get(i)); } for (i = 0; i<peCom2.size(); i++) { // общие силовские подгруппы уровня 2 i2 = dbH.f_getMas("select distinct 'n = '||nomer1 as stext from " + DbHelper.sylov_com_grup[vidWgrup] + " where pe = "+peCom2.get(i) + " and nomer2 = 2 order by 1;"); for (i1 = 0; i1 < i2; i1++) { db.execSQL("update " + DbHelper.subgrups[vidWgrup] + " set flag_Comm2_" + peCom2.get(i) + "_"+ DbHelper.selectedMas[i1].substring(4) + " = 1 where id_element in " + " (select id_s from " + DbHelper.sylov_com_grup[vidWgrup] + " where pe = "+peCom2.get(i) + " and nomer1 = "+ DbHelper.selectedMas[i1].substring(4) + " and nomer2 = 2 ); " ) ; } // Log.e(TAG, "peDist i= " + i + " p=" + peDist.get(i)); } sqlCreate = "select 'Всего классов ' || count(distinct P.class_area) || ', всего цикловых типов ' || count(distinct E.cykl_len) as stext \n" + " from " + DbHelper.elements[vidWgrup] + " E, pairing_area P\n" + " where P.id_subs = E._id;"; String sCoob = dbH.f_getString(sqlCreate); mApp.putProt(sCoob); if (DbHelper.countElements < 350) // ?????? f_calcPrim(); // вычисление поля forming } catch (Exception e) { Log.e(TAG, "Error f_generateSylEpi " + e.getMessage()); DbHelper.err += "Error f_generateSylEpi " + e.getMessage(); mApp.curExeption = e; } if (DbHelper.err.length() == 0) { db.setTransactionSuccessful(); } else mApp.f_messError(0,"f_generateSylEpi", true); db.endTransaction(); /* i2 = 0; do { i = dbH.f_testCommCreate(1); if (DISPLAYLOG) Log.e(TAG, " f_generateSylEpi итерация =" + i2 + " i = "+ i); if (i > 0) mApp.putProt("Построение коммутанта, итерация =" + (++i2) + " новых элементов = "+ i); } while (i > 0); i2 = dbH.f_getCount("select count(*) as ccc from elements where switchboard_num = 1;"); mApp.putProt("Порядок коммутанта " + i2); */ f_createTabCorrection(false, 0); // строит таблицу tmp_tab_correction long dTime = (new Date()).getTime() - DbHelper.timeStart; DecimalFormat xxxFormat = new DecimalFormat("###0.000"); mApp.putProt("Время построения группы " + xxxFormat.format(dTime / 60000.) + " минут"); mApp.putProt("Построение группы закончено"); } public void f_createTabCorrection(boolean gde, int chto) { // строит таблицу tmp_tab_correction - в ней подстановка разбита на колонки: col1, col2,... // таблица создается всегда а заполняется по меню Доп расчеты -> Покомпонентная сумма // gde = false - elements, true - elements_n // chto = 0 - только создание табл, // 1 - пересоздание и заполнение и подсчет итогов в sumPoColumn[j] c выдачей на экран результата // 2 - расчет (n + 1) / 2 // 3 - пересоздание и заполнение и подсчет итогов в sumPoColumn[j] без выдачи на экран результата db.execSQL("DROP TABLE IF EXISTS tmp_tab_correction;"); int id, j, k, dim = DbHelper.faktSubsLen;; String err = "", ssSel, ssRez = "select ", subs, ssq = "create table IF NOT EXISTS tmp_tab_correction " + "(_id INTEGER primary key autoincrement ", ssIns = "insert into tmp_tab_correction (id_true, substitution \n", // select sum(col1), sum(col2), sum(col3), sum(col4) from tmp_tab_correction ssVals; String rSum = "Покомпонентная сумма колонок по всей группе подстановок "; int sumPoColumn[] = new int[dim]; // Покомпонентная сумма по всей группе колонок подстановок - f_tableCreate for (j = 0; j < dim; j++) { ssq += ", col" + (j + 1) + " INTEGER NOT NULL"; ssIns += ", col" + (j + 1); if (j > 0) ssRez += ", "; ssRez += "sum( col" + (j + 1) + ") s" + (j + 1); } ssRez += " from tmp_tab_correction;"; ssq += " , id_true INTEGER NOT NULL, substitution TEXT NOT NULL);"; ssIns += ")\n values \n("; db.execSQL(ssq); if (chto == 1 || chto == 3) { // расчет (и выдача результата) int valCol[]; // итого if (gde) ssSel = "select id_true as _id, substitution from elements_n;"; else ssSel = "select _id, substitution from elements;"; Cursor mCursorSumKol = db.rawQuery(ssSel, null); db.beginTransaction(); try { if (mCursorSumKol.moveToFirst()) { if (mCursorSumKol.getCount() > 0) { int idf = mCursorSumKol.getColumnIndex("_id"), subf = mCursorSumKol.getColumnIndex("substitution"); do { id = mCursorSumKol.getInt(idf); subs = mCursorSumKol.getString(subf); ssVals = ssIns; ssVals += id + ", '" + subs + "' "; valCol = classSubs.f_toArray(subs, DbHelper.faktSubsLen); for (j = 0; j < valCol.length; j++) { ssVals += ", " + valCol[j]; } ssVals += ");"; if (DISPLAYLOG) Log.e(TAG, "f_tableCreate faktSubsLen = " + DbHelper.faktSubsLen + " dim = " + dim + " subs= " + subs + " ssVals = " + ssVals); db.execSQL(ssVals); // запись в tmp_tab_correction } while (mCursorSumKol.moveToNext()); } } mCursorSumKol.close(); // чтение итого mCursorSumKol = db.rawQuery(ssRez, null); if (mCursorSumKol.moveToFirst()) { if (mCursorSumKol.getCount() > 0) { for (j = 0; j < dim; j++) { k = mCursorSumKol.getColumnIndex("s" + (j + 1)); sumPoColumn[j] = mCursorSumKol.getInt(k); rSum += sumPoColumn[j] + " "; } } } mCursorSumKol.close(); } catch (Exception e) { Log.e(TAG, "Error f_tableCreate " + e.getMessage()); err += "Error f_tableCreate " + e.getMessage(); e.printStackTrace(); } if (err.length() == 0) { db.setTransactionSuccessful(); if (chto == 1 ) { // расчет (и выдача результата) mApp.putProt(""); rSum += (gde ? " для сохраненной Sn " : ""); mApp.putProt(rSum); } } db.endTransaction(); } else if (chto == 2) { // расчет по формуле выдача результата k = 1; for (j = 2; j <= dim + 1; j++) { k *= j; } // rSum += " (расчетная для n = " + dim + ") по всем точкам = " + (k /2); // mApp.putProt(rSum); } } private void f_calcPrim() { // вычисление поля forming // для цикл подгрупп генераторы не вычисляются mApp.putProt("Поиск нормализаторов силовских подгрупп"); final String sss[] = { "delete from generators_element;", "UPDATE SQLITE_SEQUENCE SET SEQ=0 WHERE NAME='generators_element';", "delete from temp_prim;", "delete from temp_pe;", "delete from " + DbHelper.normalizer[vidWgrup] + ";", "delete from " + DbHelper.exponent[vidWgrup] + ";", "UPDATE SQLITE_SEQUENCE SET SEQ=0 WHERE NAME='temp_prim';", "update " + DbHelper.elements[vidWgrup] + " set forming = '';", "update " + DbHelper.sylov_table[vidWgrup] + " set effort = 0;" }; int i, iPe, iSyl, pe, pe0 = 0, pe1 = 0; for (i = 0; i < sss.length; i++) db.execSQL(sss[i]); classPrime cPrime = new classPrime(); cPrime.f_init(mApp, false, vidWgrup); // для построенной группы String sNum; // заполняю поле forming в elements и в temp_pe заношу id_s (с повторениями), строит табл generators_element String ssn = ""; List<String> coobN = new ArrayList(); Cursor curForm = db.rawQuery("select distinct pe, sylow_num syln from " + DbHelper.elements[vidWgrup] + " where pe > 0 and not sylow_num is null order by pe desc, syln asc;", null); curForm.moveToFirst(); if (curForm.getCount() > 0) { iPe = curForm.getColumnIndex("pe"); iSyl = curForm.getColumnIndex("syln"); do { pe = curForm.getInt(iPe); sNum = curForm.getString(iSyl); // Log.e(TAG, "f_calcPrim pe=" + pe + " sNum = " + sNum); if ( sNum.length() > 0) { if (!sNum.contains(",")) { cPrime.f_primeConj(pe, sNum); // Сопряжение внутри силовской подгруппы ssn = cPrime.f_primeNorm(pe, sNum, (pe != pe1)); // Сопряжение внутри силовской подгруппы ???? f_primeNorm if (! coobN.contains(ssn)) { coobN.add(ssn); } pe1 = pe; // нормализаторы для всех силовских подгрупп } if (pe != pe0) { cPrime.f_prime(pe, sNum); // ЗАПОЛНЯЕТ forming в elements pe0 = pe; if (DISPLAYLOG) Log.e(TAG, "f_calcPrim write pe=" + pe + " sNum = " + sNum); } } } while (curForm.moveToNext()); } curForm.close(); for (i = 0; i < coobN.size(); i++) mApp.putProt(coobN.get(i)); /* удалить дублирование id_s db.execSQL("insert into temp_pe (pe, id_1, id_2) select 0, idproiz, 0 \n" + " from temp_multiplication\n" + " where idleft in (\n" + " select id_s from generators_element) and idright in (\n" + " select id_s from generators_element) and idproiz in (\n" + " select id_s from generators_element);"); db.execSQL("delete from generators_element where id_s in (" + " select id_1 from temp_pe );"); */ db.execSQL("delete from sylov_id;"); db.execSQL("insert into sylov_id (id_s, num) select distinct id_s, pe from generators_element;"); db.execSQL("delete from generators_element;"); db.execSQL("insert into generators_element (id_s, pe) select distinct id_s, num from sylov_id;"); // int i = dbH.f_getCount("select count(*) as ccc from generators_element;"); // mApp.putProt("Всего генераторов по всем простым " + i); // if (DISPLAYLOG) // Log.e(TAG, "f_calcPrim Всего генераторов по всем простым " + i); // вычислить экспоненту для p = 0 classSubs.arrCiklLen.clear(); dbH.f_getMas("select distinct deg || '' as stext from " + DbHelper.elements[vidWgrup] + " where pe = 0 order by deg desc;"); for (i = 0; i < DbHelper.selectedMas.length; i++) if (Integer.parseInt(DbHelper.selectedMas[i].trim()) > 0) classSubs.arrCiklLen.add(Integer.parseInt(DbHelper.selectedMas[i].trim())); iSyl = classSubs.f_calculateDeg(false); db.execSQL("insert into " + DbHelper.exponent[vidWgrup] + " (pe, val_exp) values (0, "+ iSyl + " );"); // Log.e(TAG, "f_calcPrim iSyl = " + iSyl); } private void f_epiDopisat(int posS, int posE, List<Integer> oldNum, Cursor csrDoz, int indId, int indN1, int indN2, int indPe) { // переписать часть для pe из sylow_conj в sylow_tmp_conj с перенумирацией сил подгр int i1, i2, j1 = 0, j2 = 0, pe, id, i, cnt = oldNum.size(); csrDoz.moveToPosition(posS); do { pe = csrDoz.getInt(indPe); i1 = csrDoz.getInt(indN1); i2 = csrDoz.getInt(indN2); id = csrDoz.getInt(indId); for (i=0; i<cnt; i++) if (oldNum.get(i) == i1) { j1 = i + 1; break; } for (i=0; i<cnt; i++) if (oldNum.get(i) == i2) { j2 = i + 1; break; } db.execSQL("insert into sylow_tmp_conj (pe, num1, num2, id_conj, num_old1, num_old2) " + "values ("+ pe + ", " + j1 + ", " + j2 + ", "+ id + ", "+ i1 + ", "+ i2 +") ;"); if (DISPLAYLOG) Log.e(TAG, "f_epiDopisat pe=" + pe + " posS = " + posS + " posE=" + posE + " i1=" + i1 + " "+ j1 + " i2=" + i2 + " " + j2 + " id= " + id); csrDoz.moveToNext(); if (posE == csrDoz.getPosition()) break; } while (true); } private void f_epaReplenishment(int pe, int maxL) { // дозапись в epimorphism // вставитm такие единичные строки в epimorphism String ssp; // устанавливает единичную подстановку List<Integer> e1 = new ArrayList<Integer>(); for (int i=0; i<maxL; i++) e1.add(i+1); ssp = e1.toString(); // единица в группе для P = pe substitutionS.epiEdinica.add(ssp); db.execSQL("delete from temp_sylow; "); // рабочая таблица // выбираю недостающие _id и заношу в temp_sylow db.execSQL("insert into temp_sylow (pe, idleft, idright) \n" + "select "+ pe + ", M._id, 0 \n" + "from " + DbHelper.elements[vidWgrup] + " M\n" + "where M._id not in \n" + "(select E.id_element from " + DbHelper.epimorphism[vidWgrup] + " E\n" + " where E.id_element = M._id and E.pe = " + pe + ");"); db.execSQL("insert into " + DbHelper.epimorphism[vidWgrup] + " (id_element, id_obraz, pe, substitution, ciklos, deg) \n" + "select idleft, 0, pe, '"+ ssp + "', '', 0 \n" + "from temp_sylow;"); } private void f_epaOut(int pe, int mLen, int id, int epi[]) { // записать новую подстановку в epimorphism String subt = classSubs.f_toStringSubs(epi, mLen); String cykles = classSubs.f_toIndependentCycle(mLen, epi); // ===== String lCyklos = ""; for (int j = 0; j < substitutionS.arrCiklLen.size(); j++) lCyklos += " " + substitutionS.arrCiklLen.get(j); int dgSb = classSubs.f_calculateDeg( false); String insSql = "insert into " + DbHelper.epimorphism[vidWgrup] + " (id_element, id_obraz, pe, substitution, ciklos, deg, cykl_len) values (" + id + ", 0, "+ pe + ", '" + subt + "', '" + cykles + "', " + dgSb + ", '" + lCyklos + "');"; if (DISPLAYLOG) Log.e(TAG, "f_epaOut pe=" + pe + " insSql=" + insSql); db.execSQL(insSql); } } //----------------------