720{
721 bool doing_fraction = false;
722 int threshold = 0;
723
727
728
729
730
731
732 if (density != 1.0)
733 {
734 doing_fraction = true;
735 threshold = static_cast<int>(density * 10000);
736 }
737
738 if (special_type == 0)
739 {
740 for (int i = 0; i < c; i++)
741 for (int j = 0; j < r; j++)
742 {
743 if (doing_fraction)
744 {
746 if (u > threshold) continue;
747 }
748 try {
749 mat.set_entry(j, i, R->
random());
750 } catch (const exc::engine_error& e) {
752 return nullptr;
753 }
754 }
755 }
756 else if (special_type == 1)
757 {
758 for (int i = 0; i < c; i++)
759 {
760 int top = (i >= r ? r : i);
761 for (int j = 0; j < top; j++)
762 {
763 if (doing_fraction)
764 {
766 if (u > threshold) continue;
767 }
768 try {
769 mat.set_entry(j, i, R->
random());
770 } catch (const exc::engine_error& e) {
772 return nullptr;
773 }
774 }
775 }
776 }
777 return mat.to_matrix();
778}
friend class MatrixConstructor
virtual FreeModule * make_FreeModule() const
virtual ring_elem random() const
int32_t rawRandomInt(int32_t max)